@zayne-labs/ui-react 0.9.6 → 0.9.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/dist/esm/await-parts-BJ6C-y1f.d.ts +36 -0
  2. package/dist/esm/chunk-BIFY3R2A.js +627 -0
  3. package/dist/esm/chunk-BIFY3R2A.js.map +1 -0
  4. package/dist/esm/chunk-CLGH26AQ.js +337 -0
  5. package/dist/esm/chunk-CLGH26AQ.js.map +1 -0
  6. package/dist/esm/chunk-CWUEUCR5.js +3 -0
  7. package/dist/esm/chunk-CWUEUCR5.js.map +1 -0
  8. package/dist/esm/chunk-EYWTW54R.js +42 -0
  9. package/dist/esm/chunk-EYWTW54R.js.map +1 -0
  10. package/dist/esm/chunk-G5BNZM66.js +32 -0
  11. package/dist/esm/chunk-G5BNZM66.js.map +1 -0
  12. package/dist/esm/{chunk-7LEVEBD2.js → chunk-JC52CA2O.js} +30 -18
  13. package/dist/esm/chunk-JC52CA2O.js.map +1 -0
  14. package/dist/esm/chunk-KLEJZWKY.js +45 -0
  15. package/dist/esm/chunk-KLEJZWKY.js.map +1 -0
  16. package/dist/esm/{chunk-V5DSTESN.js → chunk-M7YXNGT6.js} +3 -3
  17. package/dist/esm/{chunk-V5DSTESN.js.map → chunk-M7YXNGT6.js.map} +1 -1
  18. package/dist/esm/chunk-MT2MQDK2.js +13 -0
  19. package/dist/esm/chunk-MT2MQDK2.js.map +1 -0
  20. package/dist/esm/{chunk-ET4KZBFA.js → chunk-N4274N5K.js} +7 -6
  21. package/dist/esm/chunk-N4274N5K.js.map +1 -0
  22. package/dist/esm/chunk-V5ZPMMIH.js +121 -0
  23. package/dist/esm/chunk-V5ZPMMIH.js.map +1 -0
  24. package/dist/esm/{chunk-2P3P5AXH.js → chunk-Y5VBSXZS.js} +14 -7
  25. package/dist/esm/chunk-Y5VBSXZS.js.map +1 -0
  26. package/dist/esm/{chunk-IUEPHHGO.js → chunk-YO5LJ7ZJ.js} +2 -2
  27. package/dist/esm/{chunk-IUEPHHGO.js.map → chunk-YO5LJ7ZJ.js.map} +1 -1
  28. package/dist/esm/chunk-Z6JJE4G6.js +68 -0
  29. package/dist/esm/chunk-Z6JJE4G6.js.map +1 -0
  30. package/dist/esm/{chunk-DW3FXTFL.js → chunk-ZNL6YLIM.js} +9 -9
  31. package/dist/esm/chunk-ZNL6YLIM.js.map +1 -0
  32. package/dist/esm/chunk-ZSDYJOYB.js +274 -0
  33. package/dist/esm/chunk-ZSDYJOYB.js.map +1 -0
  34. package/dist/esm/components/common/await/index.d.ts +10 -12
  35. package/dist/esm/components/common/await/index.js +5 -23
  36. package/dist/esm/components/common/await/index.js.map +1 -1
  37. package/dist/esm/components/common/error-boundary/index.d.ts +4 -28
  38. package/dist/esm/components/common/error-boundary/index.js +1 -1
  39. package/dist/esm/components/common/for/index.d.ts +7 -21
  40. package/dist/esm/components/common/for/index.js +1 -1
  41. package/dist/esm/components/common/index.d.ts +13 -0
  42. package/dist/esm/components/common/index.js +14 -0
  43. package/dist/esm/components/common/show/index.js +2 -2
  44. package/dist/esm/components/common/slot/index.d.ts +7 -3
  45. package/dist/esm/components/common/slot/index.js +1 -1
  46. package/dist/esm/components/common/suspense-with-boundary/index.d.ts +3 -3
  47. package/dist/esm/components/common/suspense-with-boundary/index.js +2 -11
  48. package/dist/esm/components/common/suspense-with-boundary/index.js.map +1 -1
  49. package/dist/esm/components/common/switch/index.d.ts +5 -5
  50. package/dist/esm/components/common/switch/index.js +3 -40
  51. package/dist/esm/components/common/switch/index.js.map +1 -1
  52. package/dist/esm/components/common/teleport/index.js +1 -29
  53. package/dist/esm/components/common/teleport/index.js.map +1 -1
  54. package/dist/esm/components/ui/card/index.js +4 -43
  55. package/dist/esm/components/ui/card/index.js.map +1 -1
  56. package/dist/esm/components/ui/carousel/index.js +14 -273
  57. package/dist/esm/components/ui/carousel/index.js.map +1 -1
  58. package/dist/esm/components/ui/drag-scroll/index.js +2 -119
  59. package/dist/esm/components/ui/drag-scroll/index.js.map +1 -1
  60. package/dist/esm/components/ui/drop-zone/index.d.ts +8 -181
  61. package/dist/esm/components/ui/drop-zone/index.js +15 -327
  62. package/dist/esm/components/ui/drop-zone/index.js.map +1 -1
  63. package/dist/esm/components/ui/form/index.js +7 -625
  64. package/dist/esm/components/ui/form/index.js.map +1 -1
  65. package/dist/esm/components/ui/index.d.ts +11 -0
  66. package/dist/esm/components/ui/index.js +21 -0
  67. package/dist/esm/drop-zone-parts-CvseSoXA.d.ts +186 -0
  68. package/dist/esm/error-boundary-BD0X61Sg.d.ts +28 -0
  69. package/dist/esm/for-8C6fFbN6.d.ts +21 -0
  70. package/dist/esm/{lib/utils/getSlotMap/index.d.ts → getSlotMap-DTkxtGhd.d.ts} +15 -11
  71. package/dist/esm/lib/utils/{getSlot/index.d.ts → index.d.ts} +1 -0
  72. package/dist/esm/lib/utils/index.js +5 -0
  73. package/dist/esm/lib/utils/index.js.map +1 -0
  74. package/dist/esm/{types-CeWumkhm.d.ts → types-mdfDDNrr.d.ts} +9 -6
  75. package/dist/style.css +1 -1
  76. package/package.json +17 -16
  77. package/dist/esm/chunk-2P3P5AXH.js.map +0 -1
  78. package/dist/esm/chunk-7LEVEBD2.js.map +0 -1
  79. package/dist/esm/chunk-DW3FXTFL.js.map +0 -1
  80. package/dist/esm/chunk-ET4KZBFA.js.map +0 -1
  81. package/dist/esm/lib/utils/getSlot/index.js +0 -4
  82. package/dist/esm/lib/utils/getSlotMap/index.js +0 -4
  83. /package/dist/esm/{lib/utils/getSlot → components/common}/index.js.map +0 -0
  84. /package/dist/esm/{lib/utils/getSlotMap → components/ui}/index.js.map +0 -0
@@ -1,122 +1,5 @@
1
- import { cnMerge } from '../../../chunk-OHG7GB7O.js';
1
+ export { useDragScroll } from '../../../chunk-V5ZPMMIH.js';
2
+ import '../../../chunk-OHG7GB7O.js';
2
3
  import '../../../chunk-PZ5AY32C.js';
3
- import { off, on, checkIsDeviceMobile } from '@zayne-labs/toolkit-core';
4
- import { useCallbackRef } from '@zayne-labs/toolkit-react';
5
- import { mergeTwoProps, composeRefs } from '@zayne-labs/toolkit-react/utils';
6
- import { useRef } from 'react';
7
-
8
- var updateCursor = (element) => {
9
- element.style.cursor = "grabbing";
10
- element.style.userSelect = "none";
11
- };
12
- var onScrollSnap = (action, element) => {
13
- if (action === "remove") {
14
- element.style.scrollSnapType = "none";
15
- return;
16
- }
17
- element.style.scrollSnapType = "";
18
- };
19
- var resetCursor = (element) => {
20
- element.style.cursor = "";
21
- element.style.userSelect = "";
22
- };
23
- var handleScrollSnap = (dragContainer) => {
24
- const isMobile = checkIsDeviceMobile();
25
- if (!isMobile) {
26
- onScrollSnap("remove", dragContainer);
27
- } else {
28
- onScrollSnap("reset", dragContainer);
29
- }
30
- };
31
-
32
- // src/components/ui/drag-scroll/use-drag-scroll.ts
33
- var useDragScroll = (props) => {
34
- const {
35
- classNames,
36
- extraItemProps,
37
- extraRootProps,
38
- orientation = "horizontal",
39
- usage = "allScreens"
40
- } = props ?? {};
41
- const dragContainerRef = useRef(null);
42
- const positionRef = useRef({ left: 0, top: 0, x: 0, y: 0 });
43
- const handleMouseMove = useCallbackRef((event) => {
44
- if (!dragContainerRef.current) return;
45
- if (orientation === "horizontal" || orientation === "both") {
46
- const dx = event.clientX - positionRef.current.x;
47
- dragContainerRef.current.scrollLeft = positionRef.current.left - dx;
48
- }
49
- if (orientation === "vertical" || orientation === "both") {
50
- const dy = event.clientY - positionRef.current.y;
51
- dragContainerRef.current.scrollTop = positionRef.current.top - dy;
52
- }
53
- });
54
- const handleMouseUpOrLeave = useCallbackRef(() => {
55
- if (!dragContainerRef.current) return;
56
- off("mousemove", dragContainerRef.current, handleMouseMove);
57
- off("mouseup", dragContainerRef.current, handleMouseUpOrLeave);
58
- off("mouseleave", dragContainerRef.current, handleMouseUpOrLeave);
59
- resetCursor(dragContainerRef.current);
60
- });
61
- const handleMouseDown = useCallbackRef((event) => {
62
- if (usage === "mobileAndTabletOnly" && window.innerWidth >= 768) return;
63
- if (usage === "desktopOnly" && window.innerWidth < 768) return;
64
- if (!dragContainerRef.current) return;
65
- if (orientation === "horizontal" || orientation === "both") {
66
- positionRef.current.x = event.clientX;
67
- positionRef.current.left = dragContainerRef.current.scrollLeft;
68
- }
69
- if (orientation === "vertical" || orientation === "both") {
70
- positionRef.current.y = event.clientY;
71
- positionRef.current.top = dragContainerRef.current.scrollTop;
72
- }
73
- updateCursor(dragContainerRef.current);
74
- on("mousemove", dragContainerRef.current, handleMouseMove);
75
- on("mouseup", dragContainerRef.current, handleMouseUpOrLeave);
76
- on("mouseleave", dragContainerRef.current, handleMouseUpOrLeave);
77
- });
78
- const refCallBack = useCallbackRef((node) => {
79
- dragContainerRef.current = node;
80
- node && handleScrollSnap(node);
81
- const cleanup = on("mousedown", dragContainerRef.current, handleMouseDown);
82
- return cleanup;
83
- });
84
- const getRootProps = (rootProps) => {
85
- const mergedRootProps = mergeTwoProps(extraRootProps, rootProps);
86
- return {
87
- ...mergedRootProps,
88
- className: cnMerge(
89
- `scrollbar-hidden flex w-full cursor-grab snap-x snap-mandatory overflow-y-hidden
90
- overflow-x-scroll`,
91
- orientation === "horizontal" && "flex-row",
92
- orientation === "vertical" && "flex-col",
93
- usage === "mobileAndTabletOnly" && "md:cursor-default md:flex-col",
94
- usage === "desktopOnly" && "max-md:cursor-default max-md:flex-col",
95
- classNames?.base,
96
- mergedRootProps.className
97
- ),
98
- "data-part": "root",
99
- "data-scope": "drag-scroll",
100
- "data-slot": "drag-scroll-root",
101
- ref: composeRefs(
102
- refCallBack,
103
- mergedRootProps?.ref
104
- )
105
- };
106
- };
107
- const getItemProps = (itemProps) => {
108
- const mergedItemProps = mergeTwoProps(extraItemProps, itemProps);
109
- return {
110
- ...mergedItemProps,
111
- className: cnMerge("snap-center snap-always", classNames?.item, mergedItemProps.className),
112
- "data-part": "item",
113
- "data-scope": "drag-scroll",
114
- "data-slot": "drag-scroll-item"
115
- };
116
- };
117
- return { getItemProps, getRootProps };
118
- };
119
-
120
- export { useDragScroll };
121
4
  //# sourceMappingURL=index.js.map
122
5
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/components/ui/drag-scroll/utils.ts","../../../../../src/components/ui/drag-scroll/use-drag-scroll.ts"],"names":[],"mappings":";;;;;;;AAGO,IAAM,YAAA,GAAe,CAA+B,OAAsB,KAAA;AAChF,EAAA,OAAA,CAAQ,MAAM,MAAS,GAAA,UAAA;AACvB,EAAA,OAAA,CAAQ,MAAM,UAAa,GAAA,MAAA;AAC5B,CAAA;AAEO,IAAM,YAAA,GAAe,CAC3B,MAAA,EACA,OACI,KAAA;AACJ,EAAA,IAAI,WAAW,QAAU,EAAA;AACxB,IAAA,OAAA,CAAQ,MAAM,cAAiB,GAAA,MAAA;AAC/B,IAAA;AAAA;AAGD,EAAA,OAAA,CAAQ,MAAM,cAAiB,GAAA,EAAA;AAChC,CAAA;AAEO,IAAM,WAAA,GAAc,CAA+B,OAAsB,KAAA;AAC/E,EAAA,OAAA,CAAQ,MAAM,MAAS,GAAA,EAAA;AACvB,EAAA,OAAA,CAAQ,MAAM,UAAa,GAAA,EAAA;AAC5B,CAAA;AAGO,IAAM,gBAAA,GAAmB,CAAC,aAA+B,KAAA;AAC/D,EAAA,MAAM,WAAW,mBAAoB,EAAA;AAErC,EAAA,IAAI,CAAC,QAAU,EAAA;AACd,IAAA,YAAA,CAAa,UAAU,aAAa,CAAA;AAAA,GAC9B,MAAA;AACN,IAAA,YAAA,CAAa,SAAS,aAAa,CAAA;AAAA;AAErC,CAAA;;;ACVM,IAAA,aAAA,GAAgB,CACrB,KAC8C,KAAA;AAC9C,EAAM,MAAA;AAAA,IACL,UAAA;AAAA,IACA,cAAA;AAAA,IACA,cAAA;AAAA,IACA,WAAc,GAAA,YAAA;AAAA,IACd,KAAQ,GAAA;AAAA,GACT,GAAI,SAAS,EAAC;AAEd,EAAM,MAAA,gBAAA,GAAmB,OAAiB,IAAI,CAAA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GACP,CAAA;AAED,EAAM,MAAA,YAAA,GAAyE,CAAC,SAAc,KAAA;AAC7F,IAAM,MAAA,eAAA,GAAkB,aAAc,CAAA,cAAA,EAAgB,SAAS,CAAA;AAE/D,IAAO,OAAA;AAAA,MACN,GAAG,eAAA;AAAA,MACH,SAAW,EAAA,OAAA;AAAA,QACV,CAAA;AAAA,qBAAA,CAAA;AAAA,QAEA,gBAAgB,YAAgB,IAAA,UAAA;AAAA,QAChC,gBAAgB,UAAc,IAAA,UAAA;AAAA,QAC9B,UAAU,qBAAyB,IAAA,+BAAA;AAAA,QACnC,UAAU,aAAiB,IAAA,uCAAA;AAAA,QAC3B,UAAY,EAAA,IAAA;AAAA,QACZ,eAAgB,CAAA;AAAA,OACjB;AAAA,MACA,WAAa,EAAA,MAAA;AAAA,MACb,YAAc,EAAA,aAAA;AAAA,MACd,WAAa,EAAA,kBAAA;AAAA,MACb,GAAK,EAAA,WAAA;AAAA,QACJ,WAAA;AAAA,QACC,eAA+D,EAAA;AAAA;AACjE,KACD;AAAA,GACD;AAEA,EAAM,MAAA,YAAA,GAAyE,CAAC,SAAc,KAAA;AAC7F,IAAM,MAAA,eAAA,GAAkB,aAAc,CAAA,cAAA,EAAgB,SAAS,CAAA;AAE/D,IAAO,OAAA;AAAA,MACN,GAAG,eAAA;AAAA,MACH,WAAW,OAAQ,CAAA,yBAAA,EAA2B,UAAY,EAAA,IAAA,EAAM,gBAAgB,SAAS,CAAA;AAAA,MACzF,WAAa,EAAA,MAAA;AAAA,MACb,YAAc,EAAA,aAAA;AAAA,MACd,WAAa,EAAA;AAAA,KACd;AAAA,GACD;AAEA,EAAO,OAAA,EAAE,cAAc,YAAa,EAAA;AACrC","file":"index.js","sourcesContent":["import { checkIsDeviceMobile } from \"@zayne-labs/toolkit-core\";\n\n/* eslint-disable no-param-reassign -- Mutation is needed here since it's an element */\nexport const updateCursor = <TElement extends HTMLElement>(element: TElement) => {\n\telement.style.cursor = \"grabbing\";\n\telement.style.userSelect = \"none\";\n};\n\nexport const onScrollSnap = <TElement extends HTMLElement>(\n\taction: \"remove\" | \"reset\",\n\telement: TElement\n) => {\n\tif (action === \"remove\") {\n\t\telement.style.scrollSnapType = \"none\";\n\t\treturn;\n\t}\n\n\telement.style.scrollSnapType = \"\";\n};\n\nexport const resetCursor = <TElement extends HTMLElement>(element: TElement) => {\n\telement.style.cursor = \"\";\n\telement.style.userSelect = \"\";\n};\n/* eslint-enable no-param-reassign -- Mutation is needed here since it's an element */\n\nexport const handleScrollSnap = (dragContainer: HTMLElement) => {\n\tconst isMobile = checkIsDeviceMobile();\n\n\tif (!isMobile) {\n\t\tonScrollSnap(\"remove\", dragContainer);\n\t} else {\n\t\tonScrollSnap(\"reset\", dragContainer);\n\t}\n};\n","import { cnMerge } from \"@/lib/utils/cn\";\nimport { off, on } from \"@zayne-labs/toolkit-core\";\nimport { useCallbackRef } from \"@zayne-labs/toolkit-react\";\nimport { type InferProps, composeRefs, mergeTwoProps } from \"@zayne-labs/toolkit-react/utils\";\nimport { type RefCallback, useRef } from \"react\";\nimport { handleScrollSnap, resetCursor, updateCursor } from \"./utils\";\n\ntype ItemProps<TItemElement extends HTMLElement> = Omit<InferProps<TItemElement>, \"children\">;\n\ntype RootProps<TElement extends HTMLElement> = Omit<InferProps<TElement>, \"children\">;\n\ntype DragScrollProps<TElement extends HTMLElement, TItemElement extends HTMLElement> = {\n\tclassNames?: { base?: string; item?: string };\n\textraItemProps?: ItemProps<TItemElement>;\n\textraRootProps?: InferProps<TElement>;\n\torientation?: \"both\" | \"horizontal\" | \"vertical\";\n\tusage?: \"allScreens\" | \"desktopOnly\" | \"mobileAndTabletOnly\";\n};\n\ntype DragScrollResult<TElement extends HTMLElement, TItemElement extends HTMLElement> = {\n\tgetItemProps: (itemProps?: ItemProps<TItemElement>) => ItemProps<TItemElement>;\n\tgetRootProps: (rootProps?: RootProps<TElement>) => RootProps<TElement>;\n};\n\nconst useDragScroll = <TElement extends HTMLElement, TItemElement extends HTMLElement = HTMLElement>(\n\tprops?: DragScrollProps<TElement, TItemElement>\n): DragScrollResult<TElement, TItemElement> => {\n\tconst {\n\t\tclassNames,\n\t\textraItemProps,\n\t\textraRootProps,\n\t\torientation = \"horizontal\",\n\t\tusage = \"allScreens\",\n\t} = props ?? {};\n\n\tconst dragContainerRef = useRef<TElement>(null);\n\n\tconst positionRef = useRef({ left: 0, top: 0, x: 0, y: 0 });\n\n\tconst handleMouseMove = useCallbackRef((event: MouseEvent) => {\n\t\tif (!dragContainerRef.current) return;\n\n\t\tif (orientation === \"horizontal\" || orientation === \"both\") {\n\t\t\t// == calculate the current change in the horizontal scroll position based on the difference between the previous mouse position and the new mouse position\n\t\t\tconst dx = event.clientX - positionRef.current.x;\n\n\t\t\t// == Assign the scrollLeft of the container to the difference between its previous horizontal scroll position and the change in the mouse position\n\t\t\tdragContainerRef.current.scrollLeft = positionRef.current.left - dx;\n\t\t}\n\n\t\tif (orientation === \"vertical\" || orientation === \"both\") {\n\t\t\t// == calculate the current change in the vertical scroll position based on the difference between the previous mouse position and the new mouse position\n\t\t\tconst dy = event.clientY - positionRef.current.y;\n\n\t\t\t// == Assign the scrollTop of the container to the difference between its previous vertical scroll position and the change in the mouse position\n\t\t\tdragContainerRef.current.scrollTop = positionRef.current.top - dy;\n\t\t}\n\t});\n\n\tconst handleMouseUpOrLeave = useCallbackRef(() => {\n\t\tif (!dragContainerRef.current) return;\n\n\t\toff(\"mousemove\", dragContainerRef.current, handleMouseMove);\n\t\toff(\"mouseup\", dragContainerRef.current, handleMouseUpOrLeave);\n\t\toff(\"mouseleave\", dragContainerRef.current, handleMouseUpOrLeave);\n\n\t\tresetCursor(dragContainerRef.current);\n\t});\n\n\tconst handleMouseDown = useCallbackRef((event: MouseEvent) => {\n\t\tif (usage === \"mobileAndTabletOnly\" && window.innerWidth >= 768) return;\n\t\tif (usage === \"desktopOnly\" && window.innerWidth < 768) return;\n\n\t\tif (!dragContainerRef.current) return;\n\n\t\t// == Update all initial position properties stored in the positionRef\n\t\tif (orientation === \"horizontal\" || orientation === \"both\") {\n\t\t\tpositionRef.current.x = event.clientX;\n\t\t\tpositionRef.current.left = dragContainerRef.current.scrollLeft;\n\t\t}\n\n\t\tif (orientation === \"vertical\" || orientation === \"both\") {\n\t\t\tpositionRef.current.y = event.clientY;\n\t\t\tpositionRef.current.top = dragContainerRef.current.scrollTop;\n\t\t}\n\n\t\tupdateCursor(dragContainerRef.current);\n\n\t\ton(\"mousemove\", dragContainerRef.current, handleMouseMove);\n\t\ton(\"mouseup\", dragContainerRef.current, handleMouseUpOrLeave);\n\t\ton(\"mouseleave\", dragContainerRef.current, handleMouseUpOrLeave);\n\t});\n\n\tconst refCallBack: RefCallback<TElement> = useCallbackRef((node) => {\n\t\tdragContainerRef.current = node;\n\n\t\tnode && handleScrollSnap(node);\n\n\t\tconst cleanup = on(\"mousedown\", dragContainerRef.current, handleMouseDown);\n\n\t\treturn cleanup;\n\t});\n\n\tconst getRootProps: DragScrollResult<TElement, TItemElement>[\"getRootProps\"] = (rootProps) => {\n\t\tconst mergedRootProps = mergeTwoProps(extraRootProps, rootProps);\n\n\t\treturn {\n\t\t\t...mergedRootProps,\n\t\t\tclassName: cnMerge(\n\t\t\t\t`scrollbar-hidden flex w-full cursor-grab snap-x snap-mandatory overflow-y-hidden\n\t\t\t\toverflow-x-scroll`,\n\t\t\t\torientation === \"horizontal\" && \"flex-row\",\n\t\t\t\torientation === \"vertical\" && \"flex-col\",\n\t\t\t\tusage === \"mobileAndTabletOnly\" && \"md:cursor-default md:flex-col\",\n\t\t\t\tusage === \"desktopOnly\" && \"max-md:cursor-default max-md:flex-col\",\n\t\t\t\tclassNames?.base,\n\t\t\t\tmergedRootProps.className\n\t\t\t),\n\t\t\t\"data-part\": \"root\",\n\t\t\t\"data-scope\": \"drag-scroll\",\n\t\t\t\"data-slot\": \"drag-scroll-root\",\n\t\t\tref: composeRefs(\n\t\t\t\trefCallBack,\n\t\t\t\t(mergedRootProps as { ref?: React.Ref<TElement> } | undefined)?.ref\n\t\t\t),\n\t\t};\n\t};\n\n\tconst getItemProps: DragScrollResult<TElement, TItemElement>[\"getItemProps\"] = (itemProps) => {\n\t\tconst mergedItemProps = mergeTwoProps(extraItemProps, itemProps);\n\n\t\treturn {\n\t\t\t...mergedItemProps,\n\t\t\tclassName: cnMerge(\"snap-center snap-always\", classNames?.item, mergedItemProps.className),\n\t\t\t\"data-part\": \"item\",\n\t\t\t\"data-scope\": \"drag-scroll\",\n\t\t\t\"data-slot\": \"drag-scroll-item\",\n\t\t};\n\t};\n\n\treturn { getItemProps, getRootProps };\n};\n\nexport { useDragScroll };\n"]}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
@@ -1,184 +1,11 @@
1
- import * as React$1 from 'react';
2
- import { GetSlotComponentProps } from '../../../lib/utils/getSlotMap/index.js';
3
- import { InferProps, DiscriminatedRenderProps, PolymorphicProps } from '@zayne-labs/toolkit-react/utils';
4
- import { FileMeta, FileValidationErrorContext, FileValidationOptions } from '@zayne-labs/toolkit-core';
5
- import { Prettify } from '@zayne-labs/toolkit-type-helpers';
6
-
7
- type ContainerProps = InferProps<HTMLElement> & {
8
- classNames?: {
9
- base?: string;
10
- isDragging?: string;
11
- };
12
- };
13
- type InputProps = InferProps<"input">;
14
- type FileWithPreview = {
15
- /**
16
- * File object or file metadata
17
- */
18
- file: File | FileMeta;
19
- /**
20
- * Unique ID for the file
21
- */
22
- id: string;
23
- /**
24
- * Preview URL for the file
25
- * - Will be undefined if `disallowPreviewForNonImageFiles` is set to `true` and the file is not an image
26
- * - Can also be undefined if `URL.createObjectURL` fails
27
- */
28
- preview: string | undefined;
29
- };
30
- type DropZoneState = {
31
- /**
32
- * List of validation errors
33
- */
34
- errors: FileValidationErrorContext[];
35
- /**
36
- * List of files with their preview URLs and unique IDs
37
- */
38
- filesWithPreview: FileWithPreview[];
39
- /**
40
- * Whether or not a file is currently being dragged over the drop zone
41
- */
42
- isDragging: boolean;
43
- };
44
- type ChangeOrDragEvent = React.ChangeEvent<HTMLInputElement> | React.DragEvent<HTMLElement>;
45
- type DropZoneActions = {
46
- addFiles: (fileList: File[] | FileList | null, event?: ChangeOrDragEvent) => void;
47
- clearErrors: () => void;
48
- clearFiles: () => void;
49
- handleDragEnter: (event: React.DragEvent<HTMLElement>) => void;
50
- handleDragLeave: (event: React.DragEvent<HTMLElement>) => void;
51
- handleDragOver: (event: React.DragEvent<HTMLElement>) => void;
52
- handleFileUpload: (event: ChangeOrDragEvent) => void;
53
- openFilePicker: () => void;
54
- removeFile: (fileToRemoveOrId: string | FileWithPreview) => void;
55
- };
56
- type UseDropZoneResult = {
57
- dropZoneActions: DropZoneActions;
58
- dropZoneState: DropZoneState;
59
- getContainerProps: (containerProps?: ContainerProps) => ContainerProps;
60
- getInputProps: (inputProps?: InputProps) => InputProps;
61
- inputRef: React.RefObject<HTMLInputElement | null>;
62
- };
63
- type UseDropZoneProps = {
64
- /**
65
- * Allowed file types to be uploaded.
66
- */
67
- allowedFileTypes?: string[];
68
- /**
69
- * CSS classes to apply to the various parts of the drop zone
70
- */
71
- classNames?: Prettify<ContainerProps["classNames"] & {
72
- input?: string;
73
- }>;
74
- /**
75
- * Whether to disallow duplicate files
76
- * @default true
77
- */
78
- disallowDuplicates?: boolean;
79
- /**
80
- * Whether to disallow preview for non-image files
81
- * @default true
82
- */
83
- disallowPreviewForNonImageFiles?: boolean;
84
- /**
85
- * Extra props to pass to the container element
86
- */
87
- extraContainerProps?: ContainerProps;
88
- /**
89
- * Extra props to pass to the input element
90
- */
91
- extraInputProps?: InputProps;
92
- /**
93
- * Initial files to populate the drop zone
94
- */
95
- initialFiles?: FileMeta | FileMeta[] | null;
96
- /**
97
- * Maximum number of files that can be uploaded.
98
- */
99
- maxFileCount?: number;
100
- /**
101
- * Maximum file size in MB
102
- */
103
- maxFileSize?: number;
104
- /**
105
- * Whether to allow multiple files to be uploaded
106
- */
107
- multiple?: boolean;
108
- /**
109
- * Callback function to be called when internal files state changes
110
- */
111
- onFilesChange?: (context: {
112
- filesWithPreview: FileWithPreview[];
113
- }) => void;
114
- /**
115
- * Callback function to be called when the render props change
116
- */
117
- onRenderPropsChange?: (props: UseDropZoneResult) => void;
118
- /**
119
- * Callback function to be called when new files are uploaded
120
- */
121
- onUpload?: (context: {
122
- event: ChangeOrDragEvent;
123
- filesWithPreview: FileWithPreview[];
124
- }) => void;
125
- /**
126
- * Callback function to be called on each file upload as they occur
127
- */
128
- onUploadError?: FileValidationOptions["onError"];
129
- /**
130
- * Callback function to be called once after all file upload errors have occurred
131
- */
132
- onUploadErrors?: FileValidationOptions["onErrors"];
133
- /**
134
- * Callback function to be called on file upload success
135
- */
136
- onUploadSuccess?: FileValidationOptions["onSuccess"];
137
- /**
138
- * Custom validation function.
139
- *
140
- * If the function returns false, the file will be rejected
141
- */
142
- validator?: NonNullable<FileValidationOptions["validationSettings"]>["validator"];
143
- /**
144
- * Custom validation function that runs after all file validation has occurred
145
- */
146
- validatorForAllFiles?: FileValidationOptions["validatorForAllFiles"];
147
- /**
148
- * Whether to allow the default file picker via the file input element
149
- * @default true
150
- */
151
- withDefaultFilePicker?: boolean;
152
- };
153
- declare const useDropZone: (props?: UseDropZoneProps) => UseDropZoneResult;
154
-
155
- type DropZoneRenderPropType = DiscriminatedRenderProps<React$1.ReactNode | ((props: UseDropZoneResult) => React$1.ReactNode)>;
156
- type DropZoneRootProps = DropZoneRenderPropType & UseDropZoneProps & {
157
- /**
158
- * Controls whether to include internal elements (root and input) or not.
159
- */
160
- withInternalElements?: boolean;
161
- };
162
- declare function DropZoneRoot(props: DropZoneRootProps): React$1.JSX.Element;
163
- type DropZoneInputProps = InputProps & {
164
- asChild?: boolean;
165
- };
166
- declare function DropZoneInput(props: DropZoneInputProps): React$1.JSX.Element;
167
- type DropZoneContainerProps = ContainerProps & {
168
- asChild?: boolean;
169
- };
170
- declare function DropZoneContainer<TElement extends React$1.ElementType = "div">(props: PolymorphicProps<TElement, DropZoneContainerProps>): React$1.JSX.Element;
171
- type SlotComponentProps = GetSlotComponentProps<"preview", React$1.ReactNode | ((props: UseDropZoneResult) => React$1.ReactNode)>;
172
- declare const DropZoneImagePreview: {
173
- (props: Pick<SlotComponentProps, "children"> & Record<string, unknown>): React$1.ReactNode;
174
- readonly slotName?: "preview" | undefined;
175
- readonly slotSymbol?: symbol;
176
- };
177
-
178
- declare namespace dropZoneParts {
179
- export { DropZoneContainer as Container, DropZoneImagePreview as ImagePreview, DropZoneInput as Input, DropZoneRoot as Root };
180
- }
1
+ import { U as UseDropZoneResult } from '../../../drop-zone-parts-CvseSoXA.js';
2
+ export { C as ContainerProps, d as DropZone, i as DropZoneActions, e as DropZoneContainer, f as DropZoneContext, g as DropZoneImagePreview, c as DropZoneInput, D as DropZoneRenderPropType, b as DropZoneRoot, a as DropZoneRootProps, h as DropZoneState, F as FileWithPreview, I as InputProps, j as UseDropZoneProps, u as useDropZone } from '../../../drop-zone-parts-CvseSoXA.js';
3
+ import 'react';
4
+ import '../../../getSlotMap-DTkxtGhd.js';
5
+ import '@zayne-labs/toolkit-type-helpers';
6
+ import '@zayne-labs/toolkit-react/utils';
7
+ import '@zayne-labs/toolkit-core';
181
8
 
182
9
  declare const useDropZoneContext: () => UseDropZoneResult;
183
10
 
184
- export { type ContainerProps, dropZoneParts as DropZone, type DropZoneActions, DropZoneContainer, DropZoneImagePreview, DropZoneInput, type DropZoneRenderPropType, DropZoneRoot, type DropZoneRootProps, type DropZoneState, type FileWithPreview, type InputProps, type UseDropZoneProps, type UseDropZoneResult, useDropZone, useDropZoneContext };
11
+ export { UseDropZoneResult, useDropZoneContext };