piral-notifications
Advanced tools
Comparing version 1.6.0-beta.7240 to 1.6.0-beta.7243
@@ -1,19 +0,14 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.closeNotification = exports.openNotification = void 0; | ||
const piral_core_1 = require("piral-core"); | ||
function openNotification(ctx, dialog) { | ||
import { prependItem, excludeOn } from 'piral-core'; | ||
export function openNotification(ctx, dialog) { | ||
ctx.dispatch((state) => ({ | ||
...state, | ||
notifications: (0, piral_core_1.prependItem)(state.notifications, dialog), | ||
notifications: prependItem(state.notifications, dialog), | ||
})); | ||
} | ||
exports.openNotification = openNotification; | ||
function closeNotification(ctx, dialog) { | ||
export function closeNotification(ctx, dialog) { | ||
ctx.dispatch((state) => ({ | ||
...state, | ||
notifications: (0, piral_core_1.excludeOn)(state.notifications, (notification) => notification.id === dialog.id), | ||
notifications: excludeOn(state.notifications, (notification) => notification.id === dialog.id), | ||
})); | ||
} | ||
exports.closeNotification = closeNotification; | ||
//# sourceMappingURL=actions.js.map |
@@ -1,7 +0,4 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.PiralNotificationsToast = exports.PiralNotificationsHost = void 0; | ||
const piral_core_1 = require("piral-core"); | ||
exports.PiralNotificationsHost = (0, piral_core_1.getPiralComponent)('NotificationsHost'); | ||
exports.PiralNotificationsToast = (0, piral_core_1.getPiralComponent)('NotificationsToast'); | ||
import { getPiralComponent } from 'piral-core'; | ||
export const PiralNotificationsHost = getPiralComponent('NotificationsHost'); | ||
export const PiralNotificationsToast = getPiralComponent('NotificationsToast'); | ||
//# sourceMappingURL=components.js.map |
@@ -1,11 +0,8 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createNotificationsApi = void 0; | ||
const actions = require("./actions"); | ||
const react_1 = require("react"); | ||
const piral_core_1 = require("piral-core"); | ||
const default_1 = require("./default"); | ||
const Notifications_1 = require("./Notifications"); | ||
import * as actions from './actions'; | ||
import { isValidElement } from 'react'; | ||
import { withApi, defaultRender, withAll, withRootExtension, } from 'piral-core'; | ||
import { DefaultHost, DefaultToast } from './default'; | ||
import { Notifications } from './Notifications'; | ||
function isElement(element) { | ||
return (0, react_1.isValidElement)(element); | ||
return isValidElement(element); | ||
} | ||
@@ -15,5 +12,5 @@ function toComponent(component) { | ||
const text = component; | ||
return () => (0, piral_core_1.defaultRender)(text); | ||
return () => defaultRender(text); | ||
} | ||
else if ((0, react_1.isValidElement)(component)) { | ||
else if (isValidElement(component)) { | ||
const element = component; | ||
@@ -54,4 +51,4 @@ return () => element; | ||
components: { | ||
NotificationsHost: default_1.DefaultHost, | ||
NotificationsToast: default_1.DefaultToast, | ||
NotificationsHost: DefaultHost, | ||
NotificationsToast: DefaultToast, | ||
...state.components, | ||
@@ -65,7 +62,7 @@ }, | ||
*/ | ||
function createNotificationsApi(config = {}) { | ||
export function createNotificationsApi(config = {}) { | ||
const { defaultOptions = {}, selectId = () => `${~~(Math.random() * 10000)}`, messages = [] } = config; | ||
return (context) => { | ||
context.defineActions(actions); | ||
context.dispatch((0, piral_core_1.withAll)(withNotifications(getNotifications(context, messages, defaultOptions)), (0, piral_core_1.withRootExtension)('piral-notifications', Notifications_1.Notifications))); | ||
context.dispatch(withAll(withNotifications(getNotifications(context, messages, defaultOptions)), withRootExtension('piral-notifications', Notifications))); | ||
return (api) => ({ | ||
@@ -77,3 +74,3 @@ showNotification(content, customOptions) { | ||
? content | ||
: (0, piral_core_1.withApi)(context, content, api, 'extension'); | ||
: withApi(context, content, api, 'extension'); | ||
const notification = createNotification(context, selectId(), Component, defaultOptions, customOptions); | ||
@@ -86,3 +83,2 @@ context.openNotification(notification); | ||
} | ||
exports.createNotificationsApi = createNotificationsApi; | ||
//# sourceMappingURL=create.js.map |
@@ -1,10 +0,5 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DefaultToast = exports.DefaultHost = void 0; | ||
const React = require("react"); | ||
const piral_core_1 = require("piral-core"); | ||
const DefaultHost = (props) => (React.createElement("div", { className: "piral-notifications-host", key: "default_notifications" }, props.children)); | ||
exports.DefaultHost = DefaultHost; | ||
const DefaultToast = ({ children }) => (0, piral_core_1.defaultRender)(children); | ||
exports.DefaultToast = DefaultToast; | ||
import * as React from 'react'; | ||
import { defaultRender } from 'piral-core'; | ||
export const DefaultHost = (props) => (React.createElement("div", { className: "piral-notifications-host", key: "default_notifications" }, props.children)); | ||
export const DefaultToast = ({ children }) => defaultRender(children); | ||
//# sourceMappingURL=default.js.map |
@@ -1,8 +0,5 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const tslib_1 = require("tslib"); | ||
tslib_1.__exportStar(require("./create"), exports); | ||
tslib_1.__exportStar(require("./components"), exports); | ||
tslib_1.__exportStar(require("./Notifications"), exports); | ||
tslib_1.__exportStar(require("./types"), exports); | ||
export * from './create'; | ||
export * from './components'; | ||
export * from './Notifications'; | ||
export * from './types'; | ||
//# sourceMappingURL=index.js.map |
@@ -1,14 +0,10 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Notifications = void 0; | ||
const React = require("react"); | ||
const piral_core_1 = require("piral-core"); | ||
const components_1 = require("./components"); | ||
const Notifications = () => { | ||
const notifications = (0, piral_core_1.useGlobalState)((s) => s.notifications); | ||
return (React.createElement(components_1.PiralNotificationsHost, null, notifications.map(({ component: Component, close, options, id }) => (React.createElement(components_1.PiralNotificationsToast, { onClose: close, options: options, key: id }, | ||
import * as React from 'react'; | ||
import { useGlobalState } from 'piral-core'; | ||
import { PiralNotificationsToast, PiralNotificationsHost } from './components'; | ||
export const Notifications = () => { | ||
const notifications = useGlobalState((s) => s.notifications); | ||
return (React.createElement(PiralNotificationsHost, null, notifications.map(({ component: Component, close, options, id }) => (React.createElement(PiralNotificationsToast, { onClose: close, options: options, key: id }, | ||
React.createElement(Component, { onClose: close, options: options })))))); | ||
}; | ||
exports.Notifications = Notifications; | ||
exports.Notifications.displayName = 'Notifications'; | ||
Notifications.displayName = 'Notifications'; | ||
//# sourceMappingURL=Notifications.js.map |
@@ -1,3 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
export {}; | ||
//# sourceMappingURL=types.js.map |
{ | ||
"name": "piral-notifications", | ||
"version": "1.6.0-beta.7240", | ||
"version": "1.6.0-beta.7243", | ||
"description": "Plugin for triggering notifications in Piral.", | ||
@@ -21,20 +21,8 @@ "keywords": [ | ||
"license": "MIT", | ||
"module": "esm/index.js", | ||
"module": "lib/index.js", | ||
"main": "lib/index.js", | ||
"typings": "lib/index.d.ts", | ||
"exports": { | ||
".": { | ||
"import": "./esm/index.js", | ||
"require": "./lib/index.js" | ||
}, | ||
"./esm/*": { | ||
"import": "./esm/*" | ||
}, | ||
"./lib/*": { | ||
"require": "./lib/*" | ||
}, | ||
"./_/*": { | ||
"import": "./esm/*.js", | ||
"require": "./lib/*.js" | ||
}, | ||
".": "./lib/index.js", | ||
"./lib/*": "./lib/*", | ||
"./package.json": "./package.json" | ||
@@ -44,3 +32,2 @@ }, | ||
"files": [ | ||
"esm", | ||
"lib", | ||
@@ -59,6 +46,5 @@ "src", | ||
"cleanup": "rimraf esm lib piral-notifications.min.js", | ||
"build": "yarn build:bundle && yarn build:commonjs && yarn build:esnext", | ||
"build": "yarn build:bundle && yarn build:esnext", | ||
"build:bundle": "esbuild src/index.ts --outfile=piral-notifications.min.js --bundle --external:piral-core --external:react --minify --global-name=piralNotifications", | ||
"build:commonjs": "tsc --project tsconfig.json --outDir lib --module commonjs", | ||
"build:esnext": "tsc --project tsconfig.json --outDir esm --module esnext", | ||
"build:esnext": "tsc --project tsconfig.json --outDir lib --module esnext", | ||
"typedoc": "typedoc --json ../../../docs/types/piral-notifications.json src --exclude \"src/**/*.test.*\"", | ||
@@ -69,6 +55,6 @@ "test": "echo \"Error: run tests from root\" && exit 1" | ||
"@types/react": "^18.0.0", | ||
"piral-core": "1.6.0-beta.7240", | ||
"piral-core": "1.6.0-beta.7243", | ||
"react": "^18.0.0" | ||
}, | ||
"gitHead": "2fd8ff47d9a7e0666e4e6bc1dc5a7ef45e8e9f39" | ||
"gitHead": "bbb6e4f78c61b6ef753099a5b378ad2708565ce3" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
39427
34
703