-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52 from uploadcare/feat/bump-file-uploader
feat: bump file-uploader from 1.2.0 to 1.9.0
- Loading branch information
Showing
9 changed files
with
121 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 17 additions & 7 deletions
24
packages/react-uploader/src/utils/getCalcPropertyOfProps.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,27 @@ | ||
export const getCalcPropertyOfProps = <T extends Object>(props: T) => { | ||
import type { FileUploaderModes, TProps } from "../Uploader/types"; | ||
|
||
export const getCalcPropertyOfProps = <T extends FileUploaderModes>(props: TProps<T>) => { | ||
const eventHandlers: Record<string, unknown> = {}; | ||
const config: Record<string, unknown> = {}; | ||
const uploader: Record<string, unknown> = {}; | ||
|
||
for (const [prop, value] of Object.entries(props)) { | ||
if (prop.startsWith("on")) { | ||
eventHandlers[prop] = value; | ||
continue; | ||
} | ||
|
||
Object.entries(props).forEach(([key, value]) => { | ||
if (key.startsWith("on")) { | ||
eventHandlers[key] = value; | ||
} else { | ||
config[key] = value; | ||
if (prop === "headless") { | ||
uploader[prop] = value; | ||
continue; | ||
} | ||
}); | ||
|
||
config[prop] = value; | ||
} | ||
|
||
return { | ||
eventHandlers, | ||
uploader, | ||
config, | ||
}; | ||
}; |