@rpldy/shared-ui
Advanced tools
Comparing version 0.14.2 to 0.15.0
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.default = exports.DIFFERENT_VERSION_ERROR_MSG = exports.ERROR_MSG = void 0; | ||
exports.default = exports.ERROR_MSG = exports.DIFFERENT_VERSION_ERROR_MSG = void 0; | ||
@@ -19,3 +19,3 @@ var _shared = require("@rpldy/shared"); | ||
var _default = context => { | ||
const assertContext = context => { | ||
(0, _shared.invariant)(!(0, _uploadyVersion.getIsVersionRegisteredAndDifferent)(), DIFFERENT_VERSION_ERROR_MSG, (0, _uploadyVersion.getRegisteredVersion)()); | ||
@@ -26,2 +26,3 @@ (0, _shared.invariant)(context && context.hasUploader(), ERROR_MSG); | ||
var _default = assertContext; | ||
exports.default = _default; |
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.useAllAbortListener = exports.useRequestPreSend = exports.useItemFinalizeListener = exports.useItemAbortListener = exports.useItemErrorListener = exports.useItemCancelListener = exports.useItemProgressListener = exports.useItemFinishListener = exports.useItemStartListener = exports.useBatchProgressListener = exports.useBatchAbortListener = exports.useBatchCancelledListener = exports.useBatchFinishListener = exports.useBatchStartListener = exports.useBatchAddListener = void 0; | ||
exports.useRequestPreSend = exports.useItemStartListener = exports.useItemProgressListener = exports.useItemFinishListener = exports.useItemFinalizeListener = exports.useItemErrorListener = exports.useItemCancelListener = exports.useItemAbortListener = exports.useBatchStartListener = exports.useBatchProgressListener = exports.useBatchFinishListener = exports.useBatchCancelledListener = exports.useBatchAddListener = exports.useBatchAbortListener = exports.useAllAbortListener = void 0; | ||
@@ -9,0 +9,0 @@ var _uploader = require("@rpldy/uploader"); |
@@ -6,177 +6,177 @@ "use strict"; | ||
}); | ||
Object.defineProperty(exports, "useBatchAddListener", { | ||
Object.defineProperty(exports, "NoDomUploady", { | ||
enumerable: true, | ||
get: function () { | ||
return _eventListenerHooks.useBatchAddListener; | ||
return _NoDomUploady.default; | ||
} | ||
}); | ||
Object.defineProperty(exports, "useBatchStartListener", { | ||
Object.defineProperty(exports, "UploadyContext", { | ||
enumerable: true, | ||
get: function () { | ||
return _eventListenerHooks.useBatchStartListener; | ||
return _UploadyContext.default; | ||
} | ||
}); | ||
Object.defineProperty(exports, "useBatchProgressListener", { | ||
Object.defineProperty(exports, "assertContext", { | ||
enumerable: true, | ||
get: function () { | ||
return _eventListenerHooks.useBatchProgressListener; | ||
return _assertContext.default; | ||
} | ||
}); | ||
Object.defineProperty(exports, "useBatchFinishListener", { | ||
Object.defineProperty(exports, "createContextApi", { | ||
enumerable: true, | ||
get: function () { | ||
return _eventListenerHooks.useBatchFinishListener; | ||
return _UploadyContext.createContextApi; | ||
} | ||
}); | ||
Object.defineProperty(exports, "useBatchCancelledListener", { | ||
Object.defineProperty(exports, "generateUploaderEventHook", { | ||
enumerable: true, | ||
get: function () { | ||
return _eventListenerHooks.useBatchCancelledListener; | ||
return _utils.generateUploaderEventHook; | ||
} | ||
}); | ||
Object.defineProperty(exports, "useBatchAbortListener", { | ||
Object.defineProperty(exports, "generateUploaderEventHookWithState", { | ||
enumerable: true, | ||
get: function () { | ||
return _eventListenerHooks.useBatchAbortListener; | ||
return _utils.generateUploaderEventHookWithState; | ||
} | ||
}); | ||
Object.defineProperty(exports, "useItemStartListener", { | ||
Object.defineProperty(exports, "getIsUploadOptionsComponent", { | ||
enumerable: true, | ||
get: function () { | ||
return _eventListenerHooks.useItemStartListener; | ||
return _utils.getIsUploadOptionsComponent; | ||
} | ||
}); | ||
Object.defineProperty(exports, "useItemFinishListener", { | ||
Object.defineProperty(exports, "getUploadyVersion", { | ||
enumerable: true, | ||
get: function () { | ||
return _eventListenerHooks.useItemFinishListener; | ||
return _uploadyVersion.getVersion; | ||
} | ||
}); | ||
Object.defineProperty(exports, "useItemProgressListener", { | ||
Object.defineProperty(exports, "logWarning", { | ||
enumerable: true, | ||
get: function () { | ||
return _eventListenerHooks.useItemProgressListener; | ||
return _utils.logWarning; | ||
} | ||
}); | ||
Object.defineProperty(exports, "useItemCancelListener", { | ||
Object.defineProperty(exports, "markAsUploadOptionsComponent", { | ||
enumerable: true, | ||
get: function () { | ||
return _eventListenerHooks.useItemCancelListener; | ||
return _utils.markAsUploadOptionsComponent; | ||
} | ||
}); | ||
Object.defineProperty(exports, "useItemErrorListener", { | ||
Object.defineProperty(exports, "useAbortAll", { | ||
enumerable: true, | ||
get: function () { | ||
return _eventListenerHooks.useItemErrorListener; | ||
return _useAbortAll.default; | ||
} | ||
}); | ||
Object.defineProperty(exports, "useItemAbortListener", { | ||
Object.defineProperty(exports, "useAbortBatch", { | ||
enumerable: true, | ||
get: function () { | ||
return _eventListenerHooks.useItemAbortListener; | ||
return _useAbortBatch.default; | ||
} | ||
}); | ||
Object.defineProperty(exports, "useItemFinalizeListener", { | ||
Object.defineProperty(exports, "useAbortItem", { | ||
enumerable: true, | ||
get: function () { | ||
return _eventListenerHooks.useItemFinalizeListener; | ||
return _useAbortItem.default; | ||
} | ||
}); | ||
Object.defineProperty(exports, "useRequestPreSend", { | ||
Object.defineProperty(exports, "useAllAbortListener", { | ||
enumerable: true, | ||
get: function () { | ||
return _eventListenerHooks.useRequestPreSend; | ||
return _eventListenerHooks.useAllAbortListener; | ||
} | ||
}); | ||
Object.defineProperty(exports, "useAllAbortListener", { | ||
Object.defineProperty(exports, "useBatchAbortListener", { | ||
enumerable: true, | ||
get: function () { | ||
return _eventListenerHooks.useAllAbortListener; | ||
return _eventListenerHooks.useBatchAbortListener; | ||
} | ||
}); | ||
Object.defineProperty(exports, "generateUploaderEventHook", { | ||
Object.defineProperty(exports, "useBatchAddListener", { | ||
enumerable: true, | ||
get: function () { | ||
return _utils.generateUploaderEventHook; | ||
return _eventListenerHooks.useBatchAddListener; | ||
} | ||
}); | ||
Object.defineProperty(exports, "generateUploaderEventHookWithState", { | ||
Object.defineProperty(exports, "useBatchCancelledListener", { | ||
enumerable: true, | ||
get: function () { | ||
return _utils.generateUploaderEventHookWithState; | ||
return _eventListenerHooks.useBatchCancelledListener; | ||
} | ||
}); | ||
Object.defineProperty(exports, "logWarning", { | ||
Object.defineProperty(exports, "useBatchFinishListener", { | ||
enumerable: true, | ||
get: function () { | ||
return _utils.logWarning; | ||
return _eventListenerHooks.useBatchFinishListener; | ||
} | ||
}); | ||
Object.defineProperty(exports, "markAsUploadOptionsComponent", { | ||
Object.defineProperty(exports, "useBatchProgressListener", { | ||
enumerable: true, | ||
get: function () { | ||
return _utils.markAsUploadOptionsComponent; | ||
return _eventListenerHooks.useBatchProgressListener; | ||
} | ||
}); | ||
Object.defineProperty(exports, "getIsUploadOptionsComponent", { | ||
Object.defineProperty(exports, "useBatchStartListener", { | ||
enumerable: true, | ||
get: function () { | ||
return _utils.getIsUploadOptionsComponent; | ||
return _eventListenerHooks.useBatchStartListener; | ||
} | ||
}); | ||
Object.defineProperty(exports, "assertContext", { | ||
Object.defineProperty(exports, "useItemAbortListener", { | ||
enumerable: true, | ||
get: function () { | ||
return _assertContext.default; | ||
return _eventListenerHooks.useItemAbortListener; | ||
} | ||
}); | ||
Object.defineProperty(exports, "useUploadOptions", { | ||
Object.defineProperty(exports, "useItemCancelListener", { | ||
enumerable: true, | ||
get: function () { | ||
return _useUploadOptions.default; | ||
return _eventListenerHooks.useItemCancelListener; | ||
} | ||
}); | ||
Object.defineProperty(exports, "useAbortItem", { | ||
Object.defineProperty(exports, "useItemErrorListener", { | ||
enumerable: true, | ||
get: function () { | ||
return _useAbortItem.default; | ||
return _eventListenerHooks.useItemErrorListener; | ||
} | ||
}); | ||
Object.defineProperty(exports, "useAbortBatch", { | ||
Object.defineProperty(exports, "useItemFinalizeListener", { | ||
enumerable: true, | ||
get: function () { | ||
return _useAbortBatch.default; | ||
return _eventListenerHooks.useItemFinalizeListener; | ||
} | ||
}); | ||
Object.defineProperty(exports, "useAbortAll", { | ||
Object.defineProperty(exports, "useItemFinishListener", { | ||
enumerable: true, | ||
get: function () { | ||
return _useAbortAll.default; | ||
return _eventListenerHooks.useItemFinishListener; | ||
} | ||
}); | ||
Object.defineProperty(exports, "NoDomUploady", { | ||
Object.defineProperty(exports, "useItemProgressListener", { | ||
enumerable: true, | ||
get: function () { | ||
return _NoDomUploady.default; | ||
return _eventListenerHooks.useItemProgressListener; | ||
} | ||
}); | ||
Object.defineProperty(exports, "UploadyContext", { | ||
Object.defineProperty(exports, "useItemStartListener", { | ||
enumerable: true, | ||
get: function () { | ||
return _UploadyContext.default; | ||
return _eventListenerHooks.useItemStartListener; | ||
} | ||
}); | ||
Object.defineProperty(exports, "createContextApi", { | ||
Object.defineProperty(exports, "useRequestPreSend", { | ||
enumerable: true, | ||
get: function () { | ||
return _UploadyContext.createContextApi; | ||
return _eventListenerHooks.useRequestPreSend; | ||
} | ||
}); | ||
Object.defineProperty(exports, "withRequestPreSendUpdate", { | ||
Object.defineProperty(exports, "useUploadOptions", { | ||
enumerable: true, | ||
get: function () { | ||
return _withRequestPreSendUpdate.default; | ||
return _useUploadOptions.default; | ||
} | ||
}); | ||
Object.defineProperty(exports, "useUploadyContext", { | ||
Object.defineProperty(exports, "useUploady", { | ||
enumerable: true, | ||
@@ -187,3 +187,3 @@ get: function () { | ||
}); | ||
Object.defineProperty(exports, "useUploady", { | ||
Object.defineProperty(exports, "useUploadyContext", { | ||
enumerable: true, | ||
@@ -194,6 +194,6 @@ get: function () { | ||
}); | ||
Object.defineProperty(exports, "getUploadyVersion", { | ||
Object.defineProperty(exports, "withRequestPreSendUpdate", { | ||
enumerable: true, | ||
get: function () { | ||
return _uploadyVersion.getVersion; | ||
return _withRequestPreSendUpdate.default; | ||
} | ||
@@ -226,6 +226,6 @@ }); | ||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
@@ -18,5 +18,5 @@ "use strict"; | ||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
@@ -23,0 +23,0 @@ const NoDomUploady = props => { |
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.getIsVersionRegisteredAndDifferent = exports.registerUploadyContextVersion = exports.getRegisteredVersion = exports.getVersion = exports.GLOBAL_VERSION_SYM = void 0; | ||
exports.registerUploadyContextVersion = exports.getVersion = exports.getRegisteredVersion = exports.getIsVersionRegisteredAndDifferent = exports.GLOBAL_VERSION_SYM = void 0; | ||
@@ -14,3 +14,3 @@ var _shared = require("@rpldy/shared"); | ||
const getVersion = () => "0.14.2" || ""; | ||
const getVersion = () => "0.15.0" || ""; | ||
@@ -17,0 +17,0 @@ exports.getVersion = getVersion; |
@@ -16,3 +16,3 @@ "use strict"; | ||
var _default = (options, listeners) => { | ||
const useUploader = (options, listeners) => { | ||
//avoid creating new instance of uploader (unless enhancer method changed) | ||
@@ -32,3 +32,4 @@ const uploader = (0, _react.useMemo)(() => { | ||
Object.entries(listeners).forEach(([name, m]) => { | ||
Object.entries(listeners).forEach(_ref => { | ||
let [name, m] = _ref; | ||
uploader.on(name, m); | ||
@@ -42,3 +43,6 @@ }); | ||
Object.entries(listeners).forEach(([name, m]) => uploader.off(name, m)); | ||
Object.entries(listeners).forEach(_ref2 => { | ||
let [name, m] = _ref2; | ||
return uploader.off(name, m); | ||
}); | ||
} | ||
@@ -50,2 +54,3 @@ }; | ||
var _default = useUploader; | ||
exports.default = _default; |
@@ -12,3 +12,3 @@ "use strict"; | ||
var _default = options => { | ||
const useUploadOptions = options => { | ||
const context = (0, _useUploadyContext.default)(); | ||
@@ -23,2 +23,3 @@ | ||
var _default = useUploadOptions; | ||
exports.default = _default; |
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.getIsUploadOptionsComponent = exports.markAsUploadOptionsComponent = exports.logWarning = exports.generateUploaderEventHookWithState = exports.generateUploaderEventHook = void 0; | ||
exports.markAsUploadOptionsComponent = exports.logWarning = exports.getIsUploadOptionsComponent = exports.generateUploaderEventHookWithState = exports.generateUploaderEventHook = void 0; | ||
@@ -35,4 +35,8 @@ var _react = require("react"); | ||
const [eventState, setEventState] = (0, _react.useState)(null); | ||
const eventCallback = (0, _react.useCallback)((eventObj, ...args) => { | ||
const eventCallback = (0, _react.useCallback)(function (eventObj) { | ||
if (!id || eventObj.id === id) { | ||
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
args[_key - 1] = arguments[_key]; | ||
} | ||
setEventState(stateCalculator(eventObj, ...args)); | ||
@@ -51,7 +55,14 @@ | ||
const generateUploaderEventHook = (event, canScope = true) => (fn, id) => { | ||
const eventCallback = (0, _react.useCallback)((eventObj, ...args) => { | ||
return fn && (!canScope || !id || eventObj.id === id) ? fn(eventObj, ...args) : undefined; | ||
}, [fn, id]); | ||
useEventEffect(event, eventCallback); | ||
const generateUploaderEventHook = function (event) { | ||
let canScope = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; | ||
return (fn, id) => { | ||
const eventCallback = (0, _react.useCallback)(function (eventObj) { | ||
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { | ||
args[_key2 - 1] = arguments[_key2]; | ||
} | ||
return fn && (!canScope || !id || eventObj.id === id) ? fn(eventObj, ...args) : undefined; | ||
}, [fn, id]); | ||
useEventEffect(event, eventCallback); | ||
}; | ||
}; | ||
@@ -58,0 +69,0 @@ |
@@ -16,9 +16,9 @@ "use strict"; | ||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } | ||
var _default = Component => props => { | ||
const withRequestPreSendUpdate = Component => props => { | ||
const context = (0, _useUploadyContext.default)(); | ||
@@ -61,2 +61,3 @@ const { | ||
var _default = withRequestPreSendUpdate; | ||
exports.default = _default; |
@@ -6,6 +6,9 @@ import { invariant } from "@rpldy/shared"; | ||
You may be using packages of different Uploady versions. <Uploady> and all other packages using the context provider must be of the same version: %s`; | ||
export default (context => { | ||
const assertContext = context => { | ||
invariant(!getIsVersionRegisteredAndDifferent(), DIFFERENT_VERSION_ERROR_MSG, getRegisteredVersion()); | ||
invariant(context && context.hasUploader(), ERROR_MSG); | ||
return context; | ||
}); | ||
}; | ||
export default assertContext; |
import { hasWindow } from "@rpldy/shared"; | ||
export const GLOBAL_VERSION_SYM = Symbol.for("_rpldy-version_"); | ||
const getVersion = () => "0.14.2" || ""; | ||
const getVersion = () => "0.15.0" || ""; | ||
@@ -6,0 +6,0 @@ const getRegisteredVersion = () => { |
import { useEffect, useMemo } from "react"; | ||
import { logger } from "@rpldy/shared"; | ||
import createUploader from "@rpldy/uploader"; | ||
export default ((options, listeners) => { | ||
const useUploader = (options, listeners) => { | ||
//avoid creating new instance of uploader (unless enhancer method changed) | ||
@@ -17,3 +18,4 @@ const uploader = useMemo(() => { | ||
logger.debugLog("Uploady setting event listeners", listeners); | ||
Object.entries(listeners).forEach(([name, m]) => { | ||
Object.entries(listeners).forEach(_ref => { | ||
let [name, m] = _ref; | ||
uploader.on(name, m); | ||
@@ -26,3 +28,6 @@ }); | ||
logger.debugLog("Uploady removing event listeners", listeners); | ||
Object.entries(listeners).forEach(([name, m]) => uploader.off(name, m)); | ||
Object.entries(listeners).forEach(_ref2 => { | ||
let [name, m] = _ref2; | ||
return uploader.off(name, m); | ||
}); | ||
} | ||
@@ -32,2 +37,4 @@ }; | ||
return uploader; | ||
}); | ||
}; | ||
export default useUploader; |
import useUploadyContext from "./useUploadyContext"; | ||
export default (options => { | ||
const useUploadOptions = options => { | ||
const context = useUploadyContext(); | ||
@@ -10,2 +11,4 @@ | ||
return context.getOptions(); | ||
}); | ||
}; | ||
export default useUploadOptions; |
@@ -22,4 +22,8 @@ import { useEffect, useState, useCallback } from "react"; | ||
const [eventState, setEventState] = useState(null); | ||
const eventCallback = useCallback((eventObj, ...args) => { | ||
const eventCallback = useCallback(function (eventObj) { | ||
if (!id || eventObj.id === id) { | ||
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
args[_key - 1] = arguments[_key]; | ||
} | ||
setEventState(stateCalculator(eventObj, ...args)); | ||
@@ -36,7 +40,14 @@ | ||
const generateUploaderEventHook = (event, canScope = true) => (fn, id) => { | ||
const eventCallback = useCallback((eventObj, ...args) => { | ||
return fn && (!canScope || !id || eventObj.id === id) ? fn(eventObj, ...args) : undefined; | ||
}, [fn, id]); | ||
useEventEffect(event, eventCallback); | ||
const generateUploaderEventHook = function (event) { | ||
let canScope = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; | ||
return (fn, id) => { | ||
const eventCallback = useCallback(function (eventObj) { | ||
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { | ||
args[_key2 - 1] = arguments[_key2]; | ||
} | ||
return fn && (!canScope || !id || eventObj.id === id) ? fn(eventObj, ...args) : undefined; | ||
}, [fn, id]); | ||
useEventEffect(event, eventCallback); | ||
}; | ||
}; | ||
@@ -43,0 +54,0 @@ |
@@ -6,3 +6,4 @@ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } | ||
import useUploadyContext from "./useUploadyContext"; | ||
export default (Component => props => { | ||
const withRequestPreSendUpdate = Component => props => { | ||
const context = useUploadyContext(); | ||
@@ -43,2 +44,4 @@ const { | ||
})); | ||
}); | ||
}; | ||
export default withRequestPreSendUpdate; |
{ | ||
"version": "0.14.2", | ||
"version": "0.15.0", | ||
"name": "@rpldy/shared-ui", | ||
@@ -21,11 +21,11 @@ "description": "internal set of utils+types for react-uploady UI", | ||
"dependencies": { | ||
"@rpldy/shared": "^0.14.2", | ||
"@rpldy/uploader": "^0.14.2" | ||
"@rpldy/shared": "^0.15.0", | ||
"@rpldy/uploader": "^0.15.0" | ||
}, | ||
"devDependencies": { | ||
"flow-bin": "^0.159.0" | ||
"flow-bin": "^0.164.0" | ||
}, | ||
"peerDependencies": { | ||
"react": ">=16.8.x", | ||
"react-dom": ">=16.8.x" | ||
"react": ">=16.8", | ||
"react-dom": ">=16.8" | ||
}, | ||
@@ -35,3 +35,3 @@ "publishConfig": { | ||
}, | ||
"gitHead": "a03a076546fd0895f2eada2687de86a2e23f7732" | ||
"gitHead": "7909b3aacc4afd229e4bc6810da8560be19706b2" | ||
} |
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
57427
1265
+ Added@rpldy/life-events@0.15.0(transitive)
+ Added@rpldy/sender@0.15.0(transitive)
+ Added@rpldy/shared@0.15.0(transitive)
+ Added@rpldy/simple-state@0.15.0(transitive)
+ Added@rpldy/uploader@0.15.0(transitive)
- Removed@rpldy/life-events@0.14.2(transitive)
- Removed@rpldy/sender@0.14.2(transitive)
- Removed@rpldy/shared@0.14.2(transitive)
- Removed@rpldy/simple-state@0.14.2(transitive)
- Removed@rpldy/uploader@0.14.2(transitive)
Updated@rpldy/shared@^0.15.0
Updated@rpldy/uploader@^0.15.0