@loadsmart/loadsmart-ui 8.0.6 → 8.0.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.
@@ -0,0 +1,29 @@
1
+ import React, { createContext, useCallback, useContext, useMemo } from "react";
2
+ //#region src/components/DragDropFile/DragDropFile.context.tsx
3
+ var DragDropFileContext = createContext(void 0);
4
+ var DragDropFileProvider = ({ fileList, onFilesAdded, onFileRemoved, onRetryUpload, children }) => {
5
+ const onRemoveFile = useCallback((removedItem, index) => {
6
+ onFileRemoved([...fileList.slice(0, index), ...fileList.slice(index + 1)], removedItem, index);
7
+ }, [fileList]);
8
+ const contextValue = useMemo(() => ({
9
+ fileList,
10
+ onFilesAdded,
11
+ onRemoveFile,
12
+ onRetryUpload
13
+ }), [
14
+ fileList,
15
+ onFilesAdded,
16
+ onRemoveFile,
17
+ onRetryUpload
18
+ ]);
19
+ return /* @__PURE__ */ React.createElement(DragDropFileContext.Provider, { value: contextValue }, children);
20
+ };
21
+ var useDragDropFileContext = () => {
22
+ const context = useContext(DragDropFileContext);
23
+ if (!context) throw new Error("useDragDropFileContext must be used within an DragDropFileProvider");
24
+ return context;
25
+ };
26
+ //#endregion
27
+ export { DragDropFileContext, DragDropFileProvider, useDragDropFileContext };
28
+
29
+ //# sourceMappingURL=DragDropFile.context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DragDropFile.context.js","names":["React","createContext","useContext","useCallback","useMemo","DragDropFileContextValue","DragDropFileProviderProps","FileWithStatus","DragDropFileContext","undefined","DragDropFileProvider","fileList","onFilesAdded","onFileRemoved","onRetryUpload","children","onRemoveFile","removedItem","index","slice","contextValue","useDragDropFileContext","context","Error"],"sources":["../src/components/DragDropFile/DragDropFile.context.tsx"],"sourcesContent":["import React, { createContext, useContext, useCallback, useMemo } from 'react'\n\nimport type { DragDropFileContextValue, DragDropFileProviderProps, FileWithStatus } from './types'\n\nexport const DragDropFileContext = createContext<DragDropFileContextValue | undefined>(undefined)\n\nexport const DragDropFileProvider = ({\n fileList,\n onFilesAdded,\n onFileRemoved,\n onRetryUpload,\n children,\n}: DragDropFileProviderProps) => {\n const onRemoveFile = useCallback(\n (removedItem: FileWithStatus, index: number) => {\n onFileRemoved([...fileList.slice(0, index), ...fileList.slice(index + 1)], removedItem, index)\n },\n [fileList]\n )\n\n const contextValue = useMemo(\n () => ({ fileList, onFilesAdded, onRemoveFile, onRetryUpload }),\n [fileList, onFilesAdded, onRemoveFile, onRetryUpload]\n )\n\n return (\n <DragDropFileContext.Provider value={contextValue}>{children}</DragDropFileContext.Provider>\n )\n}\n\nexport const useDragDropFileContext = (): DragDropFileContextValue => {\n const context = useContext(DragDropFileContext)\n\n if (!context) {\n throw new Error('useDragDropFileContext must be used within an DragDropFileProvider')\n }\n\n return context\n}\n"],"mappings":";;AAIA,IAAaQ,sBAAsBP,cAAoDQ,KAAAA,EAAU;AAEjG,IAAaC,wBAAwB,EACnCC,UACAC,cACAC,eACAC,eACAC,eAC+B;CAC/B,MAAMC,eAAeb,aAClBc,aAA6BC,UAAkB;AAC9CL,gBAAc,CAAC,GAAGF,SAASQ,MAAM,GAAGD,MAAM,EAAE,GAAGP,SAASQ,MAAMD,QAAQ,EAAE,CAAC,EAAED,aAAaC,MAAM;IAEhG,CAACP,SACH,CAAC;CAED,MAAMS,eAAehB,eACZ;EAAEO;EAAUC;EAAcI;EAAcF;EAAe,GAC9D;EAACH;EAAUC;EAAcI;EAAcF;EACzC,CAAC;AAED,QACE,sBAAA,cAAC,oBAAoB,UAArB,EAA8B,OAAOM,cAAuD,EAAxCL,SAAwC;;AAIhG,IAAaM,+BAAyD;CACpE,MAAMC,UAAUpB,WAAWM,oBAAoB;AAE/C,KAAI,CAACc,QACH,OAAM,IAAIC,MAAM,qEAAqE;AAGvF,QAAOD"}