kiban-design-system 1.1.14-hotfix.0 → 1.1.16-hotfix.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/index.js CHANGED
@@ -1012,11 +1012,14 @@ const Alert = ({ icon, appearance = 'info', content, onDismiss, id, }) => {
1012
1012
  ]
1013
1013
  .filter(Boolean)
1014
1014
  .join(' ');
1015
- return (jsxs("div", Object.assign({ className: className }, { children: [jsxs("div", Object.assign({ className: `${MAIN_CLASS$t}__content` }, { children: [icon && (jsx("div", Object.assign({ className: `${MAIN_CLASS$t}__icon` }, { children: jsx(Icon, { name: icon }, void 0) }), void 0)), jsx("span", { children: content }, void 0)] }), void 0), onDismiss ? (jsx("div", Object.assign({ className: `${MAIN_CLASS$t}__close`, onClick: () => onDismiss(id) }, { children: jsx(Icon, { name: 'Close' }, void 0) }), void 0)) : null] }), void 0));
1015
+ const iconMarkup = appearance !== 'loading' && icon ? (jsx("div", Object.assign({ className: `${MAIN_CLASS$t}__icon` }, { children: jsx(Icon, { name: icon }, void 0) }), void 0)) : null;
1016
+ const loadingMarkup = appearance === 'loading' ? (jsx("div", Object.assign({ className: `${MAIN_CLASS$t}__loading` }, { children: jsx(Icon, { name: 'Loader' }, void 0) }), void 0)) : null;
1017
+ return (jsxs("div", Object.assign({ className: className }, { children: [jsxs("div", Object.assign({ className: `${MAIN_CLASS$t}__content` }, { children: [iconMarkup, loadingMarkup, jsx("span", { children: content }, void 0)] }), void 0), onDismiss ? (jsx("div", Object.assign({ className: `${MAIN_CLASS$t}__close`, onClick: () => onDismiss(id) }, { children: jsx(Icon, { name: 'Close' }, void 0) }), void 0)) : null] }), void 0));
1016
1018
  };
1017
1019
 
1018
1020
  const AlertContext = createContext({
1019
1021
  addAlert: () => null,
1022
+ deleteAlert: () => null,
1020
1023
  limit: 0,
1021
1024
  });
1022
1025
 
@@ -1037,8 +1040,18 @@ const AlertProvider = ({ children, limit }) => {
1037
1040
  }
1038
1041
  }, [newAlert]);
1039
1042
  const countDownAlerts = () => {
1040
- let alerts = alertList.map((alertElem) => (Object.assign(Object.assign({}, alertElem), { duration: alertElem.duration - 1000 })));
1041
- alerts = alerts.filter((alertElement) => alertElement.duration > 0);
1043
+ let alerts = alertList.map((alertElem) => (Object.assign(Object.assign({}, alertElem), { duration: alertElem.duration === 'infinite'
1044
+ ? 'infinite'
1045
+ : alertElem.duration - 1000 })));
1046
+ // Trigger on dismiss event when an alert is dismissed
1047
+ alerts.forEach((alertElement) => {
1048
+ var _a;
1049
+ if (alertElement.duration === 0) {
1050
+ (_a = alertElement.onDismiss) === null || _a === void 0 ? void 0 : _a.call(alertElement, alertElement.id);
1051
+ }
1052
+ });
1053
+ alerts = alerts.filter((alertElement) => alertElement.duration === 'infinite' ||
1054
+ (typeof alertElement.duration === 'number' && alertElement.duration > 0));
1042
1055
  setAlertList(alerts);
1043
1056
  };
1044
1057
  useEffect(() => {
@@ -1053,7 +1066,7 @@ const AlertProvider = ({ children, limit }) => {
1053
1066
  clearInterval(interval);
1054
1067
  };
1055
1068
  }, [alertList]);
1056
- const addAlert = ({ icon, appearance, content, duration, }) => {
1069
+ const addAlert = ({ icon, appearance, content, duration, onDismiss, dismissible = false, }) => {
1057
1070
  const id = Math.floor(Math.random() * 100 + 1);
1058
1071
  const alertAddProps = {
1059
1072
  icon,
@@ -1061,21 +1074,32 @@ const AlertProvider = ({ children, limit }) => {
1061
1074
  content,
1062
1075
  duration,
1063
1076
  id,
1077
+ onDismiss,
1078
+ dismissible,
1064
1079
  };
1065
1080
  setNewAlert(alertAddProps);
1081
+ return id;
1066
1082
  };
1067
1083
  const deleteAlert = (index) => {
1068
1084
  if (index !== undefined) {
1069
1085
  setAlertList(alertList.filter((filterItem) => filterItem.id !== index));
1070
1086
  }
1071
1087
  };
1072
- return (jsxs(AlertContext.Provider, Object.assign({ value: { addAlert, limit } }, { children: [children, portalTarget &&
1088
+ return (jsxs(AlertContext.Provider, Object.assign({ value: { addAlert, limit, deleteAlert } }, { children: [children, portalTarget &&
1073
1089
  alertList.length > 0 &&
1074
- createPortal(jsx("div", Object.assign({ className: 'AlertProvider' }, { children: alertList.map((alertItem) => (jsx(Alert, { icon: alertItem.icon, appearance: alertItem.appearance, duration: alertItem.duration, onDismiss: alertItem.id ? () => deleteAlert(alertItem.id) : undefined, content: alertItem.content, id: alertItem.id }, alertItem.id))) }), void 0), portalTarget)] }), void 0));
1090
+ createPortal(jsx("div", Object.assign({ className: 'AlertProvider' }, { children: alertList.map((alertItem) => (jsx(Alert, { icon: alertItem.icon, appearance: alertItem.appearance, duration: alertItem.duration === 'infinite'
1091
+ ? undefined
1092
+ : alertItem.duration, onDismiss: alertItem.dismissible
1093
+ ? () => deleteAlert(alertItem.id)
1094
+ : undefined, content: alertItem.content, id: alertItem.id }, alertItem.id))) }), void 0), portalTarget)] }), void 0));
1075
1095
  };
1076
1096
  const useShowAlert = () => {
1077
1097
  const { addAlert } = useContext(AlertContext);
1078
1098
  return addAlert;
1099
+ };
1100
+ const useDeleteAlert = () => {
1101
+ const { deleteAlert } = useContext(AlertContext);
1102
+ return deleteAlert;
1079
1103
  };
1080
1104
 
1081
1105
  const COMPONENT_NAME$F = 'AlphaAttributeInput';
@@ -30752,5 +30776,5 @@ const AlphaSegmentedControl = ({ children, title, segments, selected, onSelected
30752
30776
  return (jsxs("div", Object.assign({ className: `${MAINCLASS}__Container` }, { children: [headerMarkup, contentMarkup] }), void 0));
30753
30777
  };
30754
30778
 
30755
- export { ActionList, Alert, AlertProvider, AlphaAttributeInput, AlphaBadge, AlphaButton, AlphaChip, AlphaFilterControl, AlphaGraphicCard, AlphaIcon, AlphaInlineError, AlphaInputDate, InputTag$1 as AlphaInputTag, AlphaInputText, AlphaLabel, AlphaLabelledField, AlphaMultiSelectionPicker, AlphaSegmentedControl, AlphaSideMenu, AlphaSpinner, AlphaStepper, AlphaTag, AlphaTile, AlphaTooltip, Totalizer as AlphaTotalizer, AlphaZipCodeInput, AnnotatedSection, Avatar, Badge, Banner, Button, CalendarPicker, Card, Checkbox, ChoiceList, Collapsible, Connector, Container, Cover, DataTable, DatePicker, DeletableSection, Divider, DynamicForm, EmptyState, ErrorIcon, FileDownloader, Filedrop, FilterControl, Filters, Footer, Form, FormField, FormLayout, Frame, Grid, GridItem, Header$1 as Header, Icon, IconButton, IndexList, InlineEdit, InputPhoneNumber, InputTag, InputText, Item$3 as Item, JsonViewer, Label, Link, ListInfo, Loader, Logo, Media, Modal, ModalHeader, Nip, OptionList, Page, PageActions, Pagination, Pane, Panel, PanelFooter, PanelHeader, PendingIcon, Popover$1 as Popover, Progress, RadioButton, Section$1 as Section, SectionForm, Select, SideMenu, SkeletonInput, SkeletonMedia, SkeletonTabs, SkeletonText, SkeletonTitle, SortableList, Spinner, Stack, StepDefault, SuccessIcon, Table, Tabs, Tag, ThemeProvider, ThreadItem, Thumbnail, Tier, Tile, TimeSelector, Title, Toggle, Tooltip, WarningIcon, capitalize, cssClassName, formatDate, formatFileSize, isComponentTypeOf, isValidIcon, themeClassConverter, useShowAlert, useTheme };
30779
+ export { ActionList, Alert, AlertProvider, AlphaAttributeInput, AlphaBadge, AlphaButton, AlphaChip, AlphaFilterControl, AlphaGraphicCard, AlphaIcon, AlphaInlineError, AlphaInputDate, InputTag$1 as AlphaInputTag, AlphaInputText, AlphaLabel, AlphaLabelledField, AlphaMultiSelectionPicker, AlphaSegmentedControl, AlphaSideMenu, AlphaSpinner, AlphaStepper, AlphaTag, AlphaTile, AlphaTooltip, Totalizer as AlphaTotalizer, AlphaZipCodeInput, AnnotatedSection, Avatar, Badge, Banner, Button, CalendarPicker, Card, Checkbox, ChoiceList, Collapsible, Connector, Container, Cover, DataTable, DatePicker, DeletableSection, Divider, DynamicForm, EmptyState, ErrorIcon, FileDownloader, Filedrop, FilterControl, Filters, Footer, Form, FormField, FormLayout, Frame, Grid, GridItem, Header$1 as Header, Icon, IconButton, IndexList, InlineEdit, InputPhoneNumber, InputTag, InputText, Item$3 as Item, JsonViewer, Label, Link, ListInfo, Loader, Logo, Media, Modal, ModalHeader, Nip, OptionList, Page, PageActions, Pagination, Pane, Panel, PanelFooter, PanelHeader, PendingIcon, Popover$1 as Popover, Progress, RadioButton, Section$1 as Section, SectionForm, Select, SideMenu, SkeletonInput, SkeletonMedia, SkeletonTabs, SkeletonText, SkeletonTitle, SortableList, Spinner, Stack, StepDefault, SuccessIcon, Table, Tabs, Tag, ThemeProvider, ThreadItem, Thumbnail, Tier, Tile, TimeSelector, Title, Toggle, Tooltip, WarningIcon, capitalize, cssClassName, formatDate, formatFileSize, isComponentTypeOf, isValidIcon, themeClassConverter, useDeleteAlert, useShowAlert, useTheme };
30756
30780
  //# sourceMappingURL=index.js.map