@dhis2/app-service-alerts
Advanced tools
Comparing version 3.8.0 to 3.9.0
@@ -13,5 +13,8 @@ "use strict"; | ||
it('Can add an alert with static arguments', () => { | ||
const wrapper = ({ | ||
children | ||
}) => /*#__PURE__*/_react.default.createElement(_index.AlertsProvider, null, children); | ||
const wrapper = (_ref) => { | ||
let { | ||
children | ||
} = _ref; | ||
return /*#__PURE__*/_react.default.createElement(_index.AlertsProvider, null, children); | ||
}; | ||
@@ -49,5 +52,8 @@ const { | ||
it('Can add an alert with dynamic arguments', () => { | ||
const wrapper = ({ | ||
children | ||
}) => /*#__PURE__*/_react.default.createElement(_index.AlertsProvider, null, children); | ||
const wrapper = (_ref2) => { | ||
let { | ||
children | ||
} = _ref2; | ||
return /*#__PURE__*/_react.default.createElement(_index.AlertsProvider, null, children); | ||
}; | ||
@@ -60,10 +66,16 @@ const { | ||
show | ||
} = (0, _index.useAlert)(({ | ||
username | ||
}) => "Successfully deleted ".concat(username), ({ | ||
isCurrentUser | ||
}) => isCurrentUser ? { | ||
critical: true | ||
} : { | ||
success: true | ||
} = (0, _index.useAlert)((_ref3) => { | ||
let { | ||
username | ||
} = _ref3; | ||
return `Successfully deleted ${username}`; | ||
}, (_ref4) => { | ||
let { | ||
isCurrentUser | ||
} = _ref4; | ||
return isCurrentUser ? { | ||
critical: true | ||
} : { | ||
success: true | ||
}; | ||
}); | ||
@@ -95,5 +107,8 @@ return { | ||
it('Can remove an alert with the hide function from useAlerts', () => { | ||
const wrapper = ({ | ||
children | ||
}) => /*#__PURE__*/_react.default.createElement(_index.AlertsProvider, null, children); | ||
const wrapper = (_ref5) => { | ||
let { | ||
children | ||
} = _ref5; | ||
return /*#__PURE__*/_react.default.createElement(_index.AlertsProvider, null, children); | ||
}; | ||
@@ -136,5 +151,8 @@ const { | ||
it('Can remove an alert with the remove function on the alert itself', () => { | ||
const wrapper = ({ | ||
children | ||
}) => /*#__PURE__*/_react.default.createElement(_index.AlertsProvider, null, children); | ||
const wrapper = (_ref6) => { | ||
let { | ||
children | ||
} = _ref6; | ||
return /*#__PURE__*/_react.default.createElement(_index.AlertsProvider, null, children); | ||
}; | ||
@@ -177,5 +195,8 @@ const { | ||
it('Will not create duplicate alerts because of rerenders', () => { | ||
const wrapper = ({ | ||
children | ||
}) => /*#__PURE__*/_react.default.createElement(_index.AlertsProvider, null, children); | ||
const wrapper = (_ref7) => { | ||
let { | ||
children | ||
} = _ref7; | ||
return /*#__PURE__*/_react.default.createElement(_index.AlertsProvider, null, children); | ||
}; | ||
@@ -204,5 +225,8 @@ const hook = (0, _reactHooks.renderHook)(() => { | ||
it('Will not create duplicate alerts when show is called multiple times in a render cycle', () => { | ||
const wrapper = ({ | ||
children | ||
}) => /*#__PURE__*/_react.default.createElement(_index.AlertsProvider, null, children); | ||
const wrapper = (_ref8) => { | ||
let { | ||
children | ||
} = _ref8; | ||
return /*#__PURE__*/_react.default.createElement(_index.AlertsProvider, null, children); | ||
}; | ||
@@ -232,5 +256,8 @@ const { | ||
it('Will update the alert if show is called with different arguments', () => { | ||
const wrapper = ({ | ||
children | ||
}) => /*#__PURE__*/_react.default.createElement(_index.AlertsProvider, null, children); | ||
const wrapper = (_ref9) => { | ||
let { | ||
children | ||
} = _ref9; | ||
return /*#__PURE__*/_react.default.createElement(_index.AlertsProvider, null, children); | ||
}; | ||
@@ -243,7 +270,13 @@ const { | ||
show | ||
} = (0, _index.useAlert)(({ | ||
message | ||
}) => message, ({ | ||
options | ||
}) => options); | ||
} = (0, _index.useAlert)((_ref10) => { | ||
let { | ||
message | ||
} = _ref10; | ||
return message; | ||
}, (_ref11) => { | ||
let { | ||
options | ||
} = _ref11; | ||
return options; | ||
}); | ||
return { | ||
@@ -293,5 +326,8 @@ alerts, | ||
it('Will increment IDs when multiple alerts are added', () => { | ||
const wrapper = ({ | ||
children | ||
}) => /*#__PURE__*/_react.default.createElement(_index.AlertsProvider, null, children); | ||
const wrapper = (_ref12) => { | ||
let { | ||
children | ||
} = _ref12; | ||
return /*#__PURE__*/_react.default.createElement(_index.AlertsProvider, null, children); | ||
}; | ||
@@ -331,5 +367,8 @@ const { | ||
it('Removes the correct item from the alerts array', () => { | ||
const wrapper = ({ | ||
children | ||
}) => /*#__PURE__*/_react.default.createElement(_index.AlertsProvider, null, children); | ||
const wrapper = (_ref13) => { | ||
let { | ||
children | ||
} = _ref13; | ||
return /*#__PURE__*/_react.default.createElement(_index.AlertsProvider, null, children); | ||
}; | ||
@@ -366,5 +405,8 @@ const { | ||
it('Gets added into a new slot when show is called after hide', () => { | ||
const wrapper = ({ | ||
children | ||
}) => /*#__PURE__*/_react.default.createElement(_index.AlertsProvider, null, children); | ||
const wrapper = (_ref14) => { | ||
let { | ||
children | ||
} = _ref14; | ||
return /*#__PURE__*/_react.default.createElement(_index.AlertsProvider, null, children); | ||
}; | ||
@@ -406,5 +448,8 @@ const { | ||
it('Gets added into a new slot when show is called after remove is called on an alert', () => { | ||
const wrapper = ({ | ||
children | ||
}) => /*#__PURE__*/_react.default.createElement(_index.AlertsProvider, null, children); | ||
const wrapper = (_ref15) => { | ||
let { | ||
children | ||
} = _ref15; | ||
return /*#__PURE__*/_react.default.createElement(_index.AlertsProvider, null, children); | ||
}; | ||
@@ -411,0 +456,0 @@ const { |
@@ -13,5 +13,8 @@ "use strict"; | ||
it('Hook returns a show and hide function', () => { | ||
const wrapper = ({ | ||
children | ||
}) => /*#__PURE__*/_react.default.createElement(_index.AlertsProvider, null, children); | ||
const wrapper = (_ref) => { | ||
let { | ||
children | ||
} = _ref; | ||
return /*#__PURE__*/_react.default.createElement(_index.AlertsProvider, null, children); | ||
}; | ||
@@ -18,0 +21,0 @@ const { |
@@ -13,5 +13,8 @@ "use strict"; | ||
it('Renders without crashing', () => { | ||
const wrapper = ({ | ||
children | ||
}) => /*#__PURE__*/_react.default.createElement(_index.AlertsProvider, null, children); | ||
const wrapper = (_ref) => { | ||
let { | ||
children | ||
} = _ref; | ||
return /*#__PURE__*/_react.default.createElement(_index.AlertsProvider, null, children); | ||
}; | ||
@@ -18,0 +21,0 @@ const { |
@@ -20,5 +20,6 @@ "use strict"; | ||
const AlertsProvider = ({ | ||
children | ||
}) => { | ||
const AlertsProvider = (_ref) => { | ||
let { | ||
children | ||
} = _ref; | ||
const [alerts, setAlerts] = (0, _react.useState)([]); | ||
@@ -25,0 +26,0 @@ const [alertsManager] = (0, _react.useState)(() => (0, _makeAlertsManager.makeAlertsManager)(setAlerts)); |
@@ -12,12 +12,12 @@ "use strict"; | ||
}); | ||
Object.defineProperty(exports, "useAlerts", { | ||
Object.defineProperty(exports, "useAlert", { | ||
enumerable: true, | ||
get: function () { | ||
return _useAlerts.useAlerts; | ||
return _useAlert.useAlert; | ||
} | ||
}); | ||
Object.defineProperty(exports, "useAlert", { | ||
Object.defineProperty(exports, "useAlerts", { | ||
enumerable: true, | ||
get: function () { | ||
return _useAlert.useAlert; | ||
return _useAlerts.useAlerts; | ||
} | ||
@@ -24,0 +24,0 @@ }); |
@@ -12,3 +12,4 @@ "use strict"; | ||
const useAlert = (message, options = {}) => { | ||
const useAlert = function (message) { | ||
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
const { | ||
@@ -15,0 +16,0 @@ add |
@@ -6,5 +6,8 @@ import { renderHook, act } from '@testing-library/react-hooks'; | ||
it('Can add an alert with static arguments', () => { | ||
const wrapper = ({ | ||
children | ||
}) => /*#__PURE__*/React.createElement(AlertsProvider, null, children); | ||
const wrapper = (_ref) => { | ||
let { | ||
children | ||
} = _ref; | ||
return /*#__PURE__*/React.createElement(AlertsProvider, null, children); | ||
}; | ||
@@ -42,5 +45,8 @@ const { | ||
it('Can add an alert with dynamic arguments', () => { | ||
const wrapper = ({ | ||
children | ||
}) => /*#__PURE__*/React.createElement(AlertsProvider, null, children); | ||
const wrapper = (_ref2) => { | ||
let { | ||
children | ||
} = _ref2; | ||
return /*#__PURE__*/React.createElement(AlertsProvider, null, children); | ||
}; | ||
@@ -53,10 +59,16 @@ const { | ||
show | ||
} = useAlert(({ | ||
username | ||
}) => "Successfully deleted ".concat(username), ({ | ||
isCurrentUser | ||
}) => isCurrentUser ? { | ||
critical: true | ||
} : { | ||
success: true | ||
} = useAlert((_ref3) => { | ||
let { | ||
username | ||
} = _ref3; | ||
return `Successfully deleted ${username}`; | ||
}, (_ref4) => { | ||
let { | ||
isCurrentUser | ||
} = _ref4; | ||
return isCurrentUser ? { | ||
critical: true | ||
} : { | ||
success: true | ||
}; | ||
}); | ||
@@ -88,5 +100,8 @@ return { | ||
it('Can remove an alert with the hide function from useAlerts', () => { | ||
const wrapper = ({ | ||
children | ||
}) => /*#__PURE__*/React.createElement(AlertsProvider, null, children); | ||
const wrapper = (_ref5) => { | ||
let { | ||
children | ||
} = _ref5; | ||
return /*#__PURE__*/React.createElement(AlertsProvider, null, children); | ||
}; | ||
@@ -129,5 +144,8 @@ const { | ||
it('Can remove an alert with the remove function on the alert itself', () => { | ||
const wrapper = ({ | ||
children | ||
}) => /*#__PURE__*/React.createElement(AlertsProvider, null, children); | ||
const wrapper = (_ref6) => { | ||
let { | ||
children | ||
} = _ref6; | ||
return /*#__PURE__*/React.createElement(AlertsProvider, null, children); | ||
}; | ||
@@ -170,5 +188,8 @@ const { | ||
it('Will not create duplicate alerts because of rerenders', () => { | ||
const wrapper = ({ | ||
children | ||
}) => /*#__PURE__*/React.createElement(AlertsProvider, null, children); | ||
const wrapper = (_ref7) => { | ||
let { | ||
children | ||
} = _ref7; | ||
return /*#__PURE__*/React.createElement(AlertsProvider, null, children); | ||
}; | ||
@@ -197,5 +218,8 @@ const hook = renderHook(() => { | ||
it('Will not create duplicate alerts when show is called multiple times in a render cycle', () => { | ||
const wrapper = ({ | ||
children | ||
}) => /*#__PURE__*/React.createElement(AlertsProvider, null, children); | ||
const wrapper = (_ref8) => { | ||
let { | ||
children | ||
} = _ref8; | ||
return /*#__PURE__*/React.createElement(AlertsProvider, null, children); | ||
}; | ||
@@ -225,5 +249,8 @@ const { | ||
it('Will update the alert if show is called with different arguments', () => { | ||
const wrapper = ({ | ||
children | ||
}) => /*#__PURE__*/React.createElement(AlertsProvider, null, children); | ||
const wrapper = (_ref9) => { | ||
let { | ||
children | ||
} = _ref9; | ||
return /*#__PURE__*/React.createElement(AlertsProvider, null, children); | ||
}; | ||
@@ -236,7 +263,13 @@ const { | ||
show | ||
} = useAlert(({ | ||
message | ||
}) => message, ({ | ||
options | ||
}) => options); | ||
} = useAlert((_ref10) => { | ||
let { | ||
message | ||
} = _ref10; | ||
return message; | ||
}, (_ref11) => { | ||
let { | ||
options | ||
} = _ref11; | ||
return options; | ||
}); | ||
return { | ||
@@ -286,5 +319,8 @@ alerts, | ||
it('Will increment IDs when multiple alerts are added', () => { | ||
const wrapper = ({ | ||
children | ||
}) => /*#__PURE__*/React.createElement(AlertsProvider, null, children); | ||
const wrapper = (_ref12) => { | ||
let { | ||
children | ||
} = _ref12; | ||
return /*#__PURE__*/React.createElement(AlertsProvider, null, children); | ||
}; | ||
@@ -324,5 +360,8 @@ const { | ||
it('Removes the correct item from the alerts array', () => { | ||
const wrapper = ({ | ||
children | ||
}) => /*#__PURE__*/React.createElement(AlertsProvider, null, children); | ||
const wrapper = (_ref13) => { | ||
let { | ||
children | ||
} = _ref13; | ||
return /*#__PURE__*/React.createElement(AlertsProvider, null, children); | ||
}; | ||
@@ -359,5 +398,8 @@ const { | ||
it('Gets added into a new slot when show is called after hide', () => { | ||
const wrapper = ({ | ||
children | ||
}) => /*#__PURE__*/React.createElement(AlertsProvider, null, children); | ||
const wrapper = (_ref14) => { | ||
let { | ||
children | ||
} = _ref14; | ||
return /*#__PURE__*/React.createElement(AlertsProvider, null, children); | ||
}; | ||
@@ -399,5 +441,8 @@ const { | ||
it('Gets added into a new slot when show is called after remove is called on an alert', () => { | ||
const wrapper = ({ | ||
children | ||
}) => /*#__PURE__*/React.createElement(AlertsProvider, null, children); | ||
const wrapper = (_ref15) => { | ||
let { | ||
children | ||
} = _ref15; | ||
return /*#__PURE__*/React.createElement(AlertsProvider, null, children); | ||
}; | ||
@@ -404,0 +449,0 @@ const { |
@@ -6,5 +6,8 @@ import { renderHook } from '@testing-library/react-hooks'; | ||
it('Hook returns a show and hide function', () => { | ||
const wrapper = ({ | ||
children | ||
}) => /*#__PURE__*/React.createElement(AlertsProvider, null, children); | ||
const wrapper = (_ref) => { | ||
let { | ||
children | ||
} = _ref; | ||
return /*#__PURE__*/React.createElement(AlertsProvider, null, children); | ||
}; | ||
@@ -11,0 +14,0 @@ const { |
@@ -6,5 +6,8 @@ import { renderHook } from '@testing-library/react-hooks'; | ||
it('Renders without crashing', () => { | ||
const wrapper = ({ | ||
children | ||
}) => /*#__PURE__*/React.createElement(AlertsProvider, null, children); | ||
const wrapper = (_ref) => { | ||
let { | ||
children | ||
} = _ref; | ||
return /*#__PURE__*/React.createElement(AlertsProvider, null, children); | ||
}; | ||
@@ -11,0 +14,0 @@ const { |
@@ -5,5 +5,6 @@ import React, { useState } from 'react'; | ||
import { makeAlertsManager } from './makeAlertsManager'; | ||
export const AlertsProvider = ({ | ||
children | ||
}) => { | ||
export const AlertsProvider = (_ref) => { | ||
let { | ||
children | ||
} = _ref; | ||
const [alerts, setAlerts] = useState([]); | ||
@@ -10,0 +11,0 @@ const [alertsManager] = useState(() => makeAlertsManager(setAlerts)); |
import { useContext, useRef, useCallback } from 'react'; | ||
import { AlertsManagerContext } from './AlertsManagerContext'; | ||
export const useAlert = (message, options = {}) => { | ||
export const useAlert = function (message) { | ||
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
const { | ||
@@ -5,0 +6,0 @@ add |
{ | ||
"name": "@dhis2/app-service-alerts", | ||
"version": "3.8.0", | ||
"version": "3.9.0", | ||
"main": "./build/cjs/index.js", | ||
@@ -5,0 +5,0 @@ "module": "./build/es/index.js", |
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
38868
1247