kiban-design-system 1.0.284-alpha.0 → 1.0.286-alpha.0
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/components/AlertProvider/AlertProvider.d.ts +4 -3
- package/dist/components/AlertProvider/AlertProvider.props.d.ts +9 -4
- package/dist/components/AlertProvider/context/AlertContext.d.ts +1 -1
- package/dist/index.cjs.js +23 -10
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +23 -10
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { AlertProviderItemProps, AlertProviderProps } from
|
|
2
|
-
import
|
|
1
|
+
import type { AlertProviderItemProps, AlertProviderProps } from "./AlertProvider.props";
|
|
2
|
+
import "./AlertProvider.styles.scss";
|
|
3
3
|
declare const AlertProvider: ({ children, limit }: AlertProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
4
4
|
export default AlertProvider;
|
|
5
|
-
export declare const useShowAlert: () => (props: AlertProviderItemProps) =>
|
|
5
|
+
export declare const useShowAlert: () => (props: AlertProviderItemProps) => number | null;
|
|
6
|
+
export declare const useDeleteAlert: () => (id?: number) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { IconName } from
|
|
1
|
+
import type { IconName } from "../Icon";
|
|
2
2
|
export interface AlertProviderProps {
|
|
3
3
|
/**
|
|
4
4
|
* ** Content to display
|
|
@@ -16,13 +16,18 @@ export interface AlertProviderItemProps {
|
|
|
16
16
|
*
|
|
17
17
|
* @default 'info'
|
|
18
18
|
*/
|
|
19
|
-
appearance:
|
|
19
|
+
appearance: "info" | "success" | "warning" | "danger" | "majorWarning" | "loading";
|
|
20
20
|
content: React.ReactNode;
|
|
21
21
|
onDismiss?: (id?: number) => void;
|
|
22
22
|
id?: number;
|
|
23
|
-
duration: number;
|
|
23
|
+
duration: number | "infinite";
|
|
24
|
+
/**
|
|
25
|
+
* Dismissible alert
|
|
26
|
+
*/
|
|
27
|
+
dismissible?: boolean;
|
|
24
28
|
}
|
|
25
29
|
export interface AlertContextType {
|
|
26
30
|
limit: number;
|
|
27
|
-
addAlert: (props: AlertProviderItemProps) =>
|
|
31
|
+
addAlert: (props: AlertProviderItemProps) => number | null;
|
|
32
|
+
deleteAlert: (id?: number) => void;
|
|
28
33
|
}
|
package/dist/index.cjs.js
CHANGED
|
@@ -6831,7 +6831,8 @@ const Logo = ({
|
|
|
6831
6831
|
|
|
6832
6832
|
const AlertContext = /*#__PURE__*/React2.createContext({
|
|
6833
6833
|
addAlert: () => null,
|
|
6834
|
-
limit: 0
|
|
6834
|
+
limit: 0,
|
|
6835
|
+
deleteAlert: () => {}
|
|
6835
6836
|
});
|
|
6836
6837
|
|
|
6837
6838
|
const AlertProvider = ({
|
|
@@ -6857,9 +6858,15 @@ const AlertProvider = ({
|
|
|
6857
6858
|
const countDownAlerts = () => {
|
|
6858
6859
|
let alerts = alertList.map(alertElem => ({
|
|
6859
6860
|
...alertElem,
|
|
6860
|
-
duration: alertElem.duration - 1000
|
|
6861
|
+
duration: alertElem.duration === "infinite" ? "infinite" : alertElem.duration - 1000
|
|
6861
6862
|
}));
|
|
6862
|
-
|
|
6863
|
+
// Trigger on dismiss event when an alert is dismissed
|
|
6864
|
+
alerts.forEach(alertElement => {
|
|
6865
|
+
if (alertElement.duration === 0) {
|
|
6866
|
+
alertElement.onDismiss?.(alertElement.id);
|
|
6867
|
+
}
|
|
6868
|
+
});
|
|
6869
|
+
alerts = alerts.filter(alertElement => alertElement.duration === "infinite" || typeof alertElement.duration === "number" && alertElement.duration > 0);
|
|
6863
6870
|
setAlertList(alerts);
|
|
6864
6871
|
};
|
|
6865
6872
|
React2.useEffect(() => {
|
|
@@ -6876,7 +6883,9 @@ const AlertProvider = ({
|
|
|
6876
6883
|
icon,
|
|
6877
6884
|
appearance,
|
|
6878
6885
|
content,
|
|
6879
|
-
duration
|
|
6886
|
+
duration,
|
|
6887
|
+
onDismiss,
|
|
6888
|
+
dismissible = false
|
|
6880
6889
|
}) => {
|
|
6881
6890
|
const id = Math.floor(Math.random() * 100 + 1);
|
|
6882
6891
|
const alertAddProps = {
|
|
@@ -6884,9 +6893,12 @@ const AlertProvider = ({
|
|
|
6884
6893
|
appearance,
|
|
6885
6894
|
content,
|
|
6886
6895
|
duration,
|
|
6887
|
-
id
|
|
6896
|
+
id,
|
|
6897
|
+
onDismiss,
|
|
6898
|
+
dismissible
|
|
6888
6899
|
};
|
|
6889
6900
|
setNewAlert(alertAddProps);
|
|
6901
|
+
return id;
|
|
6890
6902
|
};
|
|
6891
6903
|
const deleteAlert = index => {
|
|
6892
6904
|
if (index !== undefined) {
|
|
@@ -6896,15 +6908,16 @@ const AlertProvider = ({
|
|
|
6896
6908
|
return /*#__PURE__*/jsxRuntimeExports.jsxs(AlertContext.Provider, {
|
|
6897
6909
|
value: {
|
|
6898
6910
|
addAlert,
|
|
6899
|
-
limit
|
|
6911
|
+
limit,
|
|
6912
|
+
deleteAlert
|
|
6900
6913
|
},
|
|
6901
6914
|
children: [children, portalTarget && alertList.length > 0 && /*#__PURE__*/ReactDOM.createPortal(/*#__PURE__*/jsxRuntimeExports.jsx("div", {
|
|
6902
6915
|
className: "AlertProvider",
|
|
6903
6916
|
children: alertList.map(alertItem => /*#__PURE__*/jsxRuntimeExports.jsx(Alert, {
|
|
6904
6917
|
icon: alertItem.icon,
|
|
6905
6918
|
appearance: alertItem.appearance,
|
|
6906
|
-
duration: alertItem.duration,
|
|
6907
|
-
onDismiss: alertItem.
|
|
6919
|
+
duration: alertItem.duration === "infinite" ? undefined : alertItem.duration,
|
|
6920
|
+
onDismiss: alertItem.dismissible ? () => deleteAlert(alertItem.id) : undefined,
|
|
6908
6921
|
content: alertItem.content,
|
|
6909
6922
|
id: alertItem.id
|
|
6910
6923
|
}, alertItem.id))
|
|
@@ -18301,11 +18314,11 @@ const Item$2 = ({
|
|
|
18301
18314
|
const isCollapsed = isCollapsedProp !== undefined ? isCollapsedProp : collapsed;
|
|
18302
18315
|
const AnchorComponent = !isExternal ? anchorComponent || "a" : "a";
|
|
18303
18316
|
const isActive = React2.useMemo(() => {
|
|
18304
|
-
if (location && url) {
|
|
18317
|
+
if (location?.pathname && url) {
|
|
18305
18318
|
return isExact ? location.pathname === url : location.pathname.includes(url);
|
|
18306
18319
|
}
|
|
18307
18320
|
return isActiveProp;
|
|
18308
|
-
}, [location, isExact, isActiveProp, url]);
|
|
18321
|
+
}, [location?.pathname, isExact, isActiveProp, url]);
|
|
18309
18322
|
React2.useEffect(() => {
|
|
18310
18323
|
if (isActive && subNavigationItems) {
|
|
18311
18324
|
setCurrentTierItems?.(subNavigationItems || [], {
|