@mmb-digital/ds-lilly 0.3.12 → 0.3.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ds-lilly.js +54 -59
- package/dist/types/src/components/Components/Toast/Toast.d.ts +11 -1
- package/dist/types/src/components/Components/Toast/Toast.hook.d.ts +8 -14
- package/dist/types/src/components/Components/Toast/index.d.ts +1 -1
- package/package.json +1 -1
- package/dist/.DS_Store +0 -0
- package/dist/ds-lilly.css.map +0 -1
- package/dist/ds-lilly.js.map +0 -1
package/dist/ds-lilly.js
CHANGED
|
@@ -96928,62 +96928,34 @@ var Tile = function (_a) {
|
|
|
96928
96928
|
|
|
96929
96929
|
|
|
96930
96930
|
// CONCATENATED MODULE: ./src/components/Components/Toast/Toast.hook.ts
|
|
96931
|
-
var
|
|
96932
|
-
|
|
96933
|
-
|
|
96934
|
-
|
|
96935
|
-
|
|
96936
|
-
|
|
96937
|
-
|
|
96938
|
-
|
|
96939
|
-
|
|
96940
|
-
|
|
96931
|
+
var ADD_TOAST_EVENT = 'toast/add';
|
|
96932
|
+
var REMOVE_TOAST_EVENT = 'toast/remove';
|
|
96933
|
+
var REMOVE_ALL_TOASTS_EVENT = 'toast/removeAll';
|
|
96934
|
+
var triggerEvent = function (eventType, data) {
|
|
96935
|
+
try {
|
|
96936
|
+
var event_1 = new CustomEvent(eventType, { detail: data });
|
|
96937
|
+
document.dispatchEvent(event_1);
|
|
96938
|
+
}
|
|
96939
|
+
catch (err) {
|
|
96940
|
+
var event_2 = document.createEvent('CustomEvent');
|
|
96941
|
+
event_2.initCustomEvent(eventType, true, false, data);
|
|
96942
|
+
document.dispatchEvent(event_2);
|
|
96943
|
+
}
|
|
96941
96944
|
};
|
|
96942
|
-
var
|
|
96943
|
-
|
|
96944
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
96945
|
-
t[p] = s[p];
|
|
96946
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
96947
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
96948
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
96949
|
-
t[p[i]] = s[p[i]];
|
|
96950
|
-
}
|
|
96951
|
-
return t;
|
|
96945
|
+
var addToast = function (toast) {
|
|
96946
|
+
triggerEvent(ADD_TOAST_EVENT, toast);
|
|
96952
96947
|
};
|
|
96953
|
-
var
|
|
96954
|
-
|
|
96955
|
-
to[j] = from[i];
|
|
96956
|
-
return to;
|
|
96948
|
+
var removeToast = function (toastId) {
|
|
96949
|
+
triggerEvent(REMOVE_TOAST_EVENT, toastId);
|
|
96957
96950
|
};
|
|
96958
|
-
|
|
96959
|
-
|
|
96960
|
-
var useToast = function (_a) {
|
|
96961
|
-
var _b = _a === void 0 ? {} : _a, autoCloseMilliseconds = _b.autoCloseMilliseconds;
|
|
96962
|
-
var _c = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useReducer"])(function (x) { return x + 1; }, 0), forceUpdate = _c[1];
|
|
96963
|
-
var removeAllToasts = function () {
|
|
96964
|
-
Toast_hook_toasts = [];
|
|
96965
|
-
forceUpdate();
|
|
96966
|
-
};
|
|
96967
|
-
var removeToast = function (toastId) {
|
|
96968
|
-
Toast_hook_toasts = Toast_hook_toasts.filter(function (toast) { return toast.toastId !== toastId; });
|
|
96969
|
-
forceUpdate();
|
|
96970
|
-
};
|
|
96971
|
-
var addToast = function (toast) {
|
|
96972
|
-
var toastAutoCloseMilliseconds = toast.autoCloseMilliseconds, rest = Toast_hook_rest(toast, ["autoCloseMilliseconds"]);
|
|
96973
|
-
var toastId = rest.toastId || "toast-" + Math.random().toString();
|
|
96974
|
-
Toast_hook_toasts = Toast_hook_spreadArray([Toast_hook_assign(Toast_hook_assign({}, rest), { toastId: toastId })], Toast_hook_toasts);
|
|
96975
|
-
forceUpdate();
|
|
96976
|
-
if ((autoCloseMilliseconds || toastAutoCloseMilliseconds) && toastAutoCloseMilliseconds !== 0) {
|
|
96977
|
-
setTimeout(function () { return removeToast(toastId); }, autoCloseMilliseconds || toastAutoCloseMilliseconds);
|
|
96978
|
-
}
|
|
96979
|
-
};
|
|
96980
|
-
return {
|
|
96981
|
-
toasts: Toast_hook_toasts,
|
|
96982
|
-
addToast: addToast,
|
|
96983
|
-
removeToast: removeToast,
|
|
96984
|
-
removeAllToasts: removeAllToasts
|
|
96985
|
-
};
|
|
96951
|
+
var removeAllToasts = function () {
|
|
96952
|
+
triggerEvent(REMOVE_ALL_TOASTS_EVENT);
|
|
96986
96953
|
};
|
|
96954
|
+
var useToast = function () { return ({
|
|
96955
|
+
addToast: addToast,
|
|
96956
|
+
removeToast: removeToast,
|
|
96957
|
+
removeAllToasts: removeAllToasts
|
|
96958
|
+
}); };
|
|
96987
96959
|
|
|
96988
96960
|
// CONCATENATED MODULE: ./src/components/Components/Toast/Toast.tsx
|
|
96989
96961
|
var Toast_assign = (undefined && undefined.__assign) || function () {
|
|
@@ -97008,18 +96980,41 @@ var Toast_rest = (undefined && undefined.__rest) || function (s, e) {
|
|
|
97008
96980
|
}
|
|
97009
96981
|
return t;
|
|
97010
96982
|
};
|
|
96983
|
+
var Toast_spreadArray = (undefined && undefined.__spreadArray) || function (to, from) {
|
|
96984
|
+
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
|
|
96985
|
+
to[j] = from[i];
|
|
96986
|
+
return to;
|
|
96987
|
+
};
|
|
97011
96988
|
|
|
97012
96989
|
|
|
97013
96990
|
|
|
97014
96991
|
|
|
97015
|
-
|
|
97016
|
-
|
|
97017
|
-
|
|
97018
|
-
|
|
97019
|
-
|
|
97020
|
-
|
|
97021
|
-
removeToast(id);
|
|
96992
|
+
|
|
96993
|
+
var ToastContainer = function (_a) {
|
|
96994
|
+
var autoCloseMilliseconds = _a.autoCloseMilliseconds;
|
|
96995
|
+
var _b = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useState"])([]), toasts = _b[0], setToasts = _b[1];
|
|
96996
|
+
var handleCloseToast = function (toastId) { return function () {
|
|
96997
|
+
setToasts(function (prev) { return prev.filter(function (toast) { return toast.toastId !== toastId; }); });
|
|
97022
96998
|
}; };
|
|
96999
|
+
var handleAddToast = function (event) {
|
|
97000
|
+
var _a = event.detail, toastAutoCloseMilliseconds = _a.autoCloseMilliseconds, rest = Toast_rest(_a, ["autoCloseMilliseconds"]);
|
|
97001
|
+
var toastId = rest.toastId || "toast-" + Math.random().toString();
|
|
97002
|
+
setToasts(function (prev) { return Toast_spreadArray([Toast_assign(Toast_assign({}, rest), { toastId: toastId })], prev); });
|
|
97003
|
+
if ((autoCloseMilliseconds || toastAutoCloseMilliseconds) && toastAutoCloseMilliseconds !== 0) {
|
|
97004
|
+
setTimeout(function () { return handleCloseToast(toastId)(); }, autoCloseMilliseconds || toastAutoCloseMilliseconds);
|
|
97005
|
+
}
|
|
97006
|
+
};
|
|
97007
|
+
var handleRemoveToast = function (event) { return handleCloseToast(event.detail)(); };
|
|
97008
|
+
var handleRemoveAllToasts = function () { return setToasts([]); };
|
|
97009
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
97010
|
+
// @ts-ignore
|
|
97011
|
+
useEventListener(ADD_TOAST_EVENT, handleAddToast, document);
|
|
97012
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
97013
|
+
// @ts-ignore
|
|
97014
|
+
useEventListener(REMOVE_TOAST_EVENT, handleRemoveToast, document);
|
|
97015
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
97016
|
+
// @ts-ignore
|
|
97017
|
+
useEventListener(REMOVE_ALL_TOASTS_EVENT, handleRemoveAllToasts, document);
|
|
97023
97018
|
return (external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement("div", { className: "c-toast__container" },
|
|
97024
97019
|
external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement(AnimatePresence, null, toasts.map(function (_a) {
|
|
97025
97020
|
var content = _a.content, toastId = _a.toastId, props = Toast_rest(_a, ["content", "toastId"]);
|
|
@@ -1,2 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { AlertPropsType } from '..';
|
|
3
|
+
export declare type ToastType = Omit<AlertPropsType, 'alertRef' | 'children'> & {
|
|
4
|
+
autoCloseMilliseconds?: number;
|
|
5
|
+
toastId?: string;
|
|
6
|
+
content?: ReactNode;
|
|
7
|
+
};
|
|
8
|
+
export interface ToastContainerPropsType {
|
|
9
|
+
autoCloseMilliseconds?: number;
|
|
10
|
+
}
|
|
11
|
+
export declare const ToastContainer: ({ autoCloseMilliseconds }: ToastContainerPropsType) => JSX.Element;
|
|
2
12
|
//# sourceMappingURL=Toast.d.ts.map
|
|
@@ -1,18 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export declare
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
content?: ReactNode;
|
|
7
|
-
};
|
|
8
|
-
export interface ToastHookType {
|
|
9
|
-
toasts: ToastType[];
|
|
1
|
+
import { ToastType } from '.';
|
|
2
|
+
export declare const ADD_TOAST_EVENT = "toast/add";
|
|
3
|
+
export declare const REMOVE_TOAST_EVENT = "toast/remove";
|
|
4
|
+
export declare const REMOVE_ALL_TOASTS_EVENT = "toast/removeAll";
|
|
5
|
+
interface UseToastType {
|
|
10
6
|
addToast(toast: ToastType): void;
|
|
11
|
-
removeAllToasts(): void;
|
|
12
7
|
removeToast(toastId?: string): void;
|
|
8
|
+
removeAllToasts(): void;
|
|
13
9
|
}
|
|
14
|
-
export
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
export declare const useToast: ({ autoCloseMilliseconds }?: UseToastHookPropsType) => ToastHookType;
|
|
10
|
+
export declare const useToast: () => UseToastType;
|
|
11
|
+
export {};
|
|
18
12
|
//# sourceMappingURL=Toast.hook.d.ts.map
|
package/package.json
CHANGED
package/dist/.DS_Store
DELETED
|
Binary file
|