@dhis2/app-service-alerts
Advanced tools
Comparing version 3.10.0-alpha.6 to 3.10.0
@@ -17,6 +17,3 @@ "use strict"; | ||
const defaultAlertsManager = { | ||
add: placeholder, | ||
plugin: false, | ||
parentAlertsAdd: null, | ||
showAlertsInPlugin: false | ||
add: placeholder | ||
}; | ||
@@ -23,0 +20,0 @@ |
@@ -22,14 +22,8 @@ "use strict"; | ||
let { | ||
plugin, | ||
parentAlertsAdd, | ||
showAlertsInPlugin, | ||
children | ||
} = _ref; | ||
const [alerts, setAlerts] = (0, _react.useState)([]); | ||
const [alertsManager] = (0, _react.useState)(() => (0, _makeAlertsManager.makeAlertsManager)(setAlerts, plugin)); | ||
const [alertsManager] = (0, _react.useState)(() => (0, _makeAlertsManager.makeAlertsManager)(setAlerts)); | ||
return /*#__PURE__*/_react.default.createElement(_AlertsManagerContext.AlertsManagerContext.Provider, { | ||
value: { ...alertsManager, | ||
parentAlertsAdd, | ||
showAlertsInPlugin | ||
} | ||
value: alertsManager | ||
}, /*#__PURE__*/_react.default.createElement(_AlertsContext.AlertsContext.Provider, { | ||
@@ -36,0 +30,0 @@ value: alerts |
@@ -6,8 +6,2 @@ "use strict"; | ||
}); | ||
Object.defineProperty(exports, "AlertsManagerContext", { | ||
enumerable: true, | ||
get: function () { | ||
return _AlertsManagerContext.AlertsManagerContext; | ||
} | ||
}); | ||
Object.defineProperty(exports, "AlertsProvider", { | ||
@@ -36,4 +30,2 @@ enumerable: true, | ||
var _useAlert = require("./useAlert"); | ||
var _AlertsManagerContext = require("./AlertsManagerContext"); | ||
var _useAlert = require("./useAlert"); |
@@ -10,3 +10,3 @@ "use strict"; | ||
const makeAlertsManager = (setAlerts, plugin) => { | ||
const makeAlertsManager = setAlerts => { | ||
const alertsMap = new Map(); | ||
@@ -33,4 +33,3 @@ let id = 0; | ||
return { | ||
add, | ||
plugin | ||
add | ||
}; | ||
@@ -37,0 +36,0 @@ }; |
@@ -15,6 +15,3 @@ "use strict"; | ||
const { | ||
add, | ||
plugin, | ||
parentAlertsAdd, | ||
showAlertsInPlugin | ||
add | ||
} = (0, _react.useContext)(_AlertsManagerContext.AlertsManagerContext); | ||
@@ -25,15 +22,7 @@ const alertRef = (0, _react.useRef)(null); | ||
const resolvedOptions = typeof options === 'function' ? options(props) : options; | ||
if (plugin && parentAlertsAdd && !showAlertsInPlugin) { | ||
alertRef.current = parentAlertsAdd({ | ||
message: resolvedMessage, | ||
options: resolvedOptions | ||
}, alertRef); | ||
} else { | ||
alertRef.current = add({ | ||
message: resolvedMessage, | ||
options: resolvedOptions | ||
}, alertRef); | ||
} | ||
}, [add, parentAlertsAdd, message, options, plugin, showAlertsInPlugin]); | ||
alertRef.current = add({ | ||
message: resolvedMessage, | ||
options: resolvedOptions | ||
}, alertRef); | ||
}, [add, message, options]); | ||
const hide = (0, _react.useCallback)(() => { | ||
@@ -40,0 +29,0 @@ var _alertRef$current, _alertRef$current$rem; |
@@ -8,7 +8,4 @@ import React from 'react'; | ||
const defaultAlertsManager = { | ||
add: placeholder, | ||
plugin: false, | ||
parentAlertsAdd: null, | ||
showAlertsInPlugin: false | ||
add: placeholder | ||
}; | ||
export const AlertsManagerContext = /*#__PURE__*/React.createContext(defaultAlertsManager); |
@@ -7,14 +7,8 @@ import React, { useState } from 'react'; | ||
let { | ||
plugin, | ||
parentAlertsAdd, | ||
showAlertsInPlugin, | ||
children | ||
} = _ref; | ||
const [alerts, setAlerts] = useState([]); | ||
const [alertsManager] = useState(() => makeAlertsManager(setAlerts, plugin)); | ||
const [alertsManager] = useState(() => makeAlertsManager(setAlerts)); | ||
return /*#__PURE__*/React.createElement(AlertsManagerContext.Provider, { | ||
value: { ...alertsManager, | ||
parentAlertsAdd, | ||
showAlertsInPlugin | ||
} | ||
value: alertsManager | ||
}, /*#__PURE__*/React.createElement(AlertsContext.Provider, { | ||
@@ -21,0 +15,0 @@ value: alerts |
export { AlertsProvider } from './AlertsProvider'; | ||
export { useAlerts } from './useAlerts'; | ||
export { useAlert } from './useAlert'; | ||
export { AlertsManagerContext } from './AlertsManagerContext'; | ||
export { useAlert } from './useAlert'; |
const toVisibleAlertsArray = alertsMap => Array.from(alertsMap.values()); | ||
export const makeAlertsManager = (setAlerts, plugin) => { | ||
export const makeAlertsManager = setAlerts => { | ||
const alertsMap = new Map(); | ||
@@ -25,5 +25,4 @@ let id = 0; | ||
return { | ||
add, | ||
plugin | ||
add | ||
}; | ||
}; |
@@ -6,6 +6,3 @@ import { useContext, useRef, useCallback } from 'react'; | ||
const { | ||
add, | ||
plugin, | ||
parentAlertsAdd, | ||
showAlertsInPlugin | ||
add | ||
} = useContext(AlertsManagerContext); | ||
@@ -16,15 +13,7 @@ const alertRef = useRef(null); | ||
const resolvedOptions = typeof options === 'function' ? options(props) : options; | ||
if (plugin && parentAlertsAdd && !showAlertsInPlugin) { | ||
alertRef.current = parentAlertsAdd({ | ||
message: resolvedMessage, | ||
options: resolvedOptions | ||
}, alertRef); | ||
} else { | ||
alertRef.current = add({ | ||
message: resolvedMessage, | ||
options: resolvedOptions | ||
}, alertRef); | ||
} | ||
}, [add, parentAlertsAdd, message, options, plugin, showAlertsInPlugin]); | ||
alertRef.current = add({ | ||
message: resolvedMessage, | ||
options: resolvedOptions | ||
}, alertRef); | ||
}, [add, message, options]); | ||
const hide = useCallback(() => { | ||
@@ -31,0 +20,0 @@ var _alertRef$current, _alertRef$current$rem; |
import React, { ReactElement } from 'react'; | ||
export declare const AlertsProvider: ({ plugin, parentAlertsAdd, showAlertsInPlugin, children, }: { | ||
plugin: boolean; | ||
parentAlertsAdd: any; | ||
showAlertsInPlugin: boolean; | ||
export declare const AlertsProvider: ({ children, }: { | ||
children: React.ReactNode; | ||
}) => ReactElement; |
export { AlertsProvider } from './AlertsProvider'; | ||
export { useAlerts } from './useAlerts'; | ||
export { useAlert } from './useAlert'; | ||
export { AlertsManagerContext } from './AlertsManagerContext'; |
import type { Alert, AlertsManager } from './types'; | ||
export declare const makeAlertsManager: (setAlerts: React.Dispatch<React.SetStateAction<Alert[]>>, plugin: boolean) => AlertsManager; | ||
export declare const makeAlertsManager: (setAlerts: React.Dispatch<React.SetStateAction<Alert[]>>) => AlertsManager; |
@@ -13,5 +13,2 @@ import { MutableRefObject } from 'react'; | ||
add: (alert: Alert, alertRef: AlertRef) => Alert; | ||
plugin: boolean; | ||
parentAlertsAdd?: any; | ||
showAlertsInPlugin?: boolean; | ||
}; |
{ | ||
"name": "@dhis2/app-service-alerts", | ||
"version": "3.10.0-alpha.6", | ||
"version": "3.10.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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1
38869
1247