nis-media-uploader
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -15,3 +15,3 @@ "use strict"; | ||
// Application to Render | ||
const app = react_1.default.createElement(Wrapper_1.default, null); | ||
const app = react_1.default.createElement(Wrapper_1.default, { multiple: false }); | ||
// Render application in DOM | ||
@@ -18,0 +18,0 @@ const component = document.getElementById('app'); |
{ | ||
"name": "nis-media-uploader", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "No Input Signal Media Uploader", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -32,3 +32,3 @@ "use strict"; | ||
objectPosition: 'center', | ||
}, variant: 'top', src: `${imgUrl}/${item.url}` }), | ||
}, variant: 'top', src: `${imgUrl}/${item.id}` }), | ||
react_1.default.createElement(react_bootstrap_1.Card.Body, null, | ||
@@ -35,0 +35,0 @@ react_1.default.createElement(react_bootstrap_1.Card.Title, null, item.originalName)), |
@@ -88,3 +88,3 @@ "use strict"; | ||
return (react_1.default.createElement(react_bootstrap_1.Container, { className: 'd-flex align-items-center justify-content-center flex-column', style: { minHeight: '80vh' } }, | ||
react_1.default.createElement("input", { ref: inputRef, onChange: handleDisplayFileDetails, className: 'd-none', type: 'file', multiple: true }), | ||
react_1.default.createElement("input", { ref: inputRef, onChange: handleDisplayFileDetails, className: 'd-none', type: 'file', multiple: state === null || state === void 0 ? void 0 : state.multiple }), | ||
react_1.default.createElement(react_bootstrap_1.Button, { className: 'mb-4', onClick: () => handleUpload() }, "Upload files"), | ||
@@ -91,0 +91,0 @@ react_1.default.createElement(react_bootstrap_1.ListGroup, null, |
@@ -14,2 +14,3 @@ import { PromiseState } from './PromiseState.type'; | ||
selected: Media[]; | ||
multiple: boolean; | ||
} |
@@ -9,6 +9,7 @@ import { UploaderContextInterface } from './UploaderContext.interface'; | ||
initialMedia?: Media[]; | ||
multiple?: boolean; | ||
}; | ||
declare const UploaderContextWrapper: ({ children, callback, initialMedia, }: Props) => JSX.Element; | ||
declare const UploaderContextWrapper: ({ children, callback, initialMedia, multiple, }: Props) => JSX.Element; | ||
export default UploaderContextWrapper; | ||
export declare const useUploaderContext: () => UploaderContextInterface | null; | ||
export declare const useUploaderDispatchContext: () => React.Dispatch<UploaderContextActionsType>; |
@@ -15,6 +15,7 @@ "use strict"; | ||
callback: () => { }, | ||
multiple: true, | ||
}; | ||
const UploaderContext = react_1.default.createContext(null); | ||
const UploaderDispatchContext = react_1.default.createContext(null); | ||
const UploaderContextWrapper = ({ children, callback, initialMedia, }) => { | ||
const UploaderContextWrapper = ({ children, callback, initialMedia, multiple = true, }) => { | ||
// @ts-ignore | ||
@@ -32,2 +33,15 @@ const [state, dispatch] = (0, react_1.useReducer)((state, action) => { | ||
return (0, immer_1.produce)(state, (draftState) => { | ||
if (!state.multiple) { | ||
if (draftState.selected.length === 1 && | ||
draftState.selected[0].id === action.payload.id) { | ||
draftState.selected = []; | ||
} | ||
else if (draftState.selected.length > 0) { | ||
draftState.selected = [action.payload]; | ||
} | ||
else if (draftState.selected.length === 0) { | ||
draftState.selected = [action.payload]; | ||
} | ||
return; | ||
} | ||
draftState.selected = (0, xorWith_1.default)(draftState.selected, [action.payload], (a, b) => a.id === b.id); | ||
@@ -57,3 +71,3 @@ }); | ||
return state; | ||
}, Object.assign(Object.assign({}, initialState), { selected: initialMedia || [], callback: callback })); | ||
}, Object.assign(Object.assign({}, initialState), { multiple: multiple, selected: initialMedia || [], callback: callback })); | ||
return (react_1.default.createElement(UploaderContext.Provider, { value: state }, | ||
@@ -60,0 +74,0 @@ react_1.default.createElement(UploaderDispatchContext.Provider, { value: { dispatch: dispatch } }, children))); |
@@ -9,4 +9,5 @@ /// <reference types="react" /> | ||
postUrl?: string; | ||
multiple?: boolean; | ||
}; | ||
declare const Wrapper: ({ callback, initialMedia, imgUrl, mediaUrl, postUrl }: Props) => JSX.Element; | ||
declare const Wrapper: ({ callback, initialMedia, imgUrl, mediaUrl, postUrl, multiple }: Props) => JSX.Element; | ||
export default Wrapper; |
@@ -7,6 +7,6 @@ "use strict"; | ||
const react_1 = tslib_1.__importDefault(require("react")); | ||
const Wrapper = ({ callback, initialMedia, imgUrl, mediaUrl, postUrl }) => { | ||
return (react_1.default.createElement(UploaderContextWrapper_1.default, { callback: callback, initialMedia: initialMedia }, | ||
const Wrapper = ({ callback, initialMedia, imgUrl, mediaUrl, postUrl, multiple = true }) => { | ||
return (react_1.default.createElement(UploaderContextWrapper_1.default, { multiple: multiple, callback: callback, initialMedia: initialMedia }, | ||
react_1.default.createElement(index_1.default, { imgUrl: imgUrl, mediaUrl: mediaUrl, postUrl: postUrl }))); | ||
}; | ||
exports.default = Wrapper; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
25901
483
0