kiban-design-system 1.0.284-alpha.0 → 1.0.287-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.
@@ -1,5 +1,6 @@
1
- import type { AlertProviderItemProps, AlertProviderProps } from './AlertProvider.props';
2
- import './AlertProvider.styles.scss';
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) => void;
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 '../Icon';
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: 'info' | 'success' | 'warning' | 'danger' | 'majorWarning';
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) => void;
31
+ addAlert: (props: AlertProviderItemProps) => number | null;
32
+ deleteAlert: (id?: number) => void;
28
33
  }
@@ -1,3 +1,3 @@
1
- import type { AlertContextType } from '../AlertProvider.props';
1
+ import type { AlertContextType } from "../AlertProvider.props";
2
2
  declare const AlertContext: import("react").Context<AlertContextType>;
3
3
  export default AlertContext;
@@ -1,3 +1,3 @@
1
- import AlertProvider, { useShowAlert } from './AlertProvider';
2
- export * from './AlertProvider.props';
3
- export { AlertProvider, useShowAlert };
1
+ import AlertProvider, { useShowAlert, useDeleteAlert } from "./AlertProvider";
2
+ export * from "./AlertProvider.props";
3
+ export { AlertProvider, useShowAlert, useDeleteAlert };
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
- alerts = alerts.filter(alertElement => alertElement.duration > 0);
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.id ? () => deleteAlert(alertItem.id) : undefined,
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))
@@ -6917,6 +6930,12 @@ const useShowAlert = () => {
6917
6930
  } = React2.useContext(AlertContext);
6918
6931
  return addAlert;
6919
6932
  };
6933
+ const useDeleteAlert = () => {
6934
+ const {
6935
+ deleteAlert
6936
+ } = React2.useContext(AlertContext);
6937
+ return deleteAlert;
6938
+ };
6920
6939
 
6921
6940
  const MAIN_CLASS$q = "column";
6922
6941
  /** Grid.Item is used for set size of element in the Grid
@@ -18301,11 +18320,11 @@ const Item$2 = ({
18301
18320
  const isCollapsed = isCollapsedProp !== undefined ? isCollapsedProp : collapsed;
18302
18321
  const AnchorComponent = !isExternal ? anchorComponent || "a" : "a";
18303
18322
  const isActive = React2.useMemo(() => {
18304
- if (location && url) {
18323
+ if (location?.pathname && url) {
18305
18324
  return isExact ? location.pathname === url : location.pathname.includes(url);
18306
18325
  }
18307
18326
  return isActiveProp;
18308
- }, [location, isExact, isActiveProp, url]);
18327
+ }, [location?.pathname, isExact, isActiveProp, url]);
18309
18328
  React2.useEffect(() => {
18310
18329
  if (isActive && subNavigationItems) {
18311
18330
  setCurrentTierItems?.(subNavigationItems || [], {
@@ -41465,6 +41484,7 @@ exports.formatFileSize = formatFileSize;
41465
41484
  exports.isComponentTypeOf = isComponentTypeOf;
41466
41485
  exports.isValidIcon = isValidIcon;
41467
41486
  exports.themeClassConverter = themeClassConverter;
41487
+ exports.useDeleteAlert = useDeleteAlert;
41468
41488
  exports.useShowAlert = useShowAlert;
41469
41489
  exports.useTheme = useTheme;
41470
41490
  //# sourceMappingURL=index.cjs.js.map