@entur/alert 0.10.6 → 0.11.2

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/CHANGELOG.md CHANGED
@@ -3,6 +3,20 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [0.11.2](https://bitbucket.org/enturas/design-system/compare/@entur/alert@0.11.1...@entur/alert@0.11.2) (2022-06-24)
7
+
8
+ **Note:** Version bump only for package @entur/alert
9
+
10
+ ## [0.11.1](https://bitbucket.org/enturas/design-system/compare/@entur/alert@0.11.0...@entur/alert@0.11.1) (2022-06-02)
11
+
12
+ **Note:** Version bump only for package @entur/alert
13
+
14
+ # [0.11.0](https://bitbucket.org/enturas/design-system/compare/@entur/alert@0.10.6...@entur/alert@0.11.0) (2022-05-13)
15
+
16
+ ### Features
17
+
18
+ - **toast:** add exit animation for toast alert ([0e29579](https://bitbucket.org/enturas/design-system/commits/0e29579bea29d3b591752dd479e33989d8c8bcf1))
19
+
6
20
  ## [0.10.6](https://bitbucket.org/enturas/design-system/compare/@entur/alert@0.10.5...@entur/alert@0.10.6) (2022-05-04)
7
21
 
8
22
  **Note:** Version bump only for package @entur/alert
@@ -49,7 +49,7 @@ function _objectWithoutPropertiesLoose(source, excluded) {
49
49
  return target;
50
50
  }
51
51
 
52
- var _excluded$3 = ["children", "className", "closable", "closeButtonLabel", "variant", "onClose", "size", "title"];
52
+ var _excluded$3 = ["children", "className", "closable", "closeButtonLabel", "variant", "onClose", "size", "title", "toastIsBeingRemoved"];
53
53
  var iconsMap = {
54
54
  success: icons.OutlinedValidationCheckIcon,
55
55
  info: icons.OutlinedValidationInfoIcon,
@@ -70,6 +70,7 @@ var BaseAlertBox = function BaseAlertBox(_ref) {
70
70
  } : _ref$onClose,
71
71
  size = _ref.size,
72
72
  title = _ref.title,
73
+ toastIsBeingRemoved = _ref.toastIsBeingRemoved,
73
74
  rest = _objectWithoutPropertiesLoose(_ref, _excluded$3);
74
75
 
75
76
  var _React$useState = React__default["default"].useState(false),
@@ -87,7 +88,9 @@ var BaseAlertBox = function BaseAlertBox(_ref) {
87
88
 
88
89
  var Icon = iconsMap[variant];
89
90
  return React__default["default"].createElement("div", _extends({
90
- className: classNames__default["default"]('eds-alert-box', "eds-alert-box--" + size, "eds-alert-box--" + variant, className)
91
+ className: classNames__default["default"]('eds-alert-box', "eds-alert-box--" + size, "eds-alert-box--" + variant, {
92
+ 'eds-alert-box--toast--exit-animation': toastIsBeingRemoved
93
+ }, className)
91
94
  }, rest), closable && React__default["default"].createElement("button", {
92
95
  "aria-label": closeButtonLabel,
93
96
  className: "eds-alert-box__close-button",
@@ -140,6 +143,7 @@ var SmallAlertBox = function SmallAlertBox(_ref) {
140
143
  }));
141
144
  };
142
145
 
146
+ var EXIT_ANIMATION_TIME = 400;
143
147
  var ToastContext = /*#__PURE__*/React__default["default"].createContext(null);
144
148
 
145
149
  var toastReducer = function toastReducer(prevToasts, action) {
@@ -147,6 +151,14 @@ var toastReducer = function toastReducer(prevToasts, action) {
147
151
  case 'ADD_TOAST':
148
152
  return [action.payload].concat(prevToasts);
149
153
 
154
+ case 'PLAY_EXIT_ANIMATION':
155
+ return prevToasts.map(function (toast) {
156
+ if (toast.id === action.payload) return _extends({}, toast, {
157
+ isBeingRemoved: true
158
+ });
159
+ return toast;
160
+ });
161
+
150
162
  case 'REMOVE_TOAST':
151
163
  return prevToasts.filter(function (toast) {
152
164
  return toast.id !== action.payload;
@@ -163,12 +175,14 @@ var createToast = function createToast(toast, id) {
163
175
  return {
164
176
  id: id,
165
177
  content: toast,
166
- variant: 'success'
178
+ variant: 'success',
179
+ isBeingRemoved: false
167
180
  };
168
181
  } else {
169
182
  return _extends({
170
183
  id: id,
171
- variant: 'success'
184
+ variant: 'success',
185
+ isBeingRemoved: false
172
186
  }, toast);
173
187
  }
174
188
  };
@@ -199,6 +213,22 @@ var ToastProvider = function ToastProvider(_ref) {
199
213
  });
200
214
  delete timeoutIdRefs.current[id];
201
215
  }, []);
216
+ var playExitAnimation = React__default["default"].useCallback(function (id) {
217
+ window.clearTimeout(timeoutIdRefs.current[id + 'animation']);
218
+ dispatch({
219
+ type: 'PLAY_EXIT_ANIMATION',
220
+ payload: id
221
+ });
222
+ delete timeoutIdRefs.current[id + 'animation'];
223
+ }, []);
224
+ var removeToastWithAnimationAfterDelay = React__default["default"].useCallback(function (id, delay) {
225
+ timeoutIdRefs.current[id + 'animation'] = window.setTimeout(function () {
226
+ return playExitAnimation(id);
227
+ }, delay - EXIT_ANIMATION_TIME);
228
+ timeoutIdRefs.current[id] = window.setTimeout(function () {
229
+ return removeToast(id);
230
+ }, delay);
231
+ }, [timeoutIdRefs, playExitAnimation, removeToast]);
202
232
  var addToast = React__default["default"].useCallback(function (toast) {
203
233
  var id = createUniqueId();
204
234
  var payload = createToast(toast, id);
@@ -206,16 +236,15 @@ var ToastProvider = function ToastProvider(_ref) {
206
236
  type: 'ADD_TOAST',
207
237
  payload: payload
208
238
  });
209
- timeoutIdRefs.current[id] = window.setTimeout(function () {
210
- return removeToast(id);
211
- }, delay);
212
- }, [delay, removeToast]);
239
+ removeToastWithAnimationAfterDelay(id, delay);
240
+ }, [delay, removeToastWithAnimationAfterDelay]);
213
241
 
214
- var handleMouseEnter = function handleMouseEnter(toastId) {
242
+ var handleMouseEnter = function handleMouseEnter(toast) {
215
243
  return function () {
216
- setHovering(toastId);
244
+ if (toast.isBeingRemoved) return;
245
+ setHovering(toast.id);
217
246
  Object.values(timeoutIdRefs.current).forEach(function (timeoutId) {
218
- return window.clearTimeout(timeoutId);
247
+ window.clearTimeout(timeoutId);
219
248
  });
220
249
  timeoutIdRefs.current = {};
221
250
  };
@@ -224,9 +253,7 @@ var ToastProvider = function ToastProvider(_ref) {
224
253
  var handleMouseLeave = function handleMouseLeave() {
225
254
  setHovering(undefined);
226
255
  toasts.forEach(function (toast) {
227
- timeoutIdRefs.current[toast.id] = window.setTimeout(function () {
228
- return removeToast(toast.id);
229
- }, delay);
256
+ removeToastWithAnimationAfterDelay(toast.id, delay);
230
257
  });
231
258
  };
232
259
 
@@ -254,9 +281,10 @@ var ToastProvider = function ToastProvider(_ref) {
254
281
  variant: toastToShow.variant,
255
282
  title: toastToShow.title,
256
283
  onClose: handleClose(toastToShow.id),
257
- onMouseEnter: handleMouseEnter(toastToShow.id),
284
+ onMouseEnter: handleMouseEnter(toastToShow),
258
285
  onMouseLeave: handleMouseLeave,
259
286
  closable: hoveringId === toastToShow.id,
287
+ toastIsBeingRemoved: toastToShow.isBeingRemoved,
260
288
  key: toastToShow.id
261
289
  }, toastToShow.content);
262
290
  })), children);
@@ -1 +1 @@
1
- {"version":3,"file":"alert.cjs.development.js","sources":["../src/BaseAlertBox.tsx","../src/BannerAlertBox.tsx","../src/ToastAlertBox.tsx","../src/SmallAlertBox.tsx","../src/ToastProvider.tsx","../src/CopyableText.tsx","../src/ExpandableAlertBox.tsx","../src/index.tsx"],"sourcesContent":["import React from 'react';\nimport classNames from 'classnames';\nimport {\n CloseIcon,\n OutlinedValidationCheckIcon,\n OutlinedValidationExclamationIcon,\n OutlinedValidationInfoIcon,\n OutlinedValidationErrorIcon,\n} from '@entur/icons';\nimport './styles.scss';\n\nconst iconsMap = {\n success: OutlinedValidationCheckIcon,\n info: OutlinedValidationInfoIcon,\n warning: OutlinedValidationExclamationIcon,\n error: OutlinedValidationErrorIcon,\n};\n\ntype BaseAlertBoxProps = {\n /** Innholdet i alert-boksen */\n children?: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Skjermleser-label for lukkeknappen, om den vises\n * @default \"Lukk\"\n */\n closeButtonLabel?: string;\n /** Callback som kalles når man lukker boksen\n * @default () => {}\n */\n onClose?: () => void;\n /** Om denne er true, vil boksen få en lukkeknapp i høyre hjørne\n * @default false\n */\n closable?: boolean;\n /** Tittel på boksen - oppsummer virkning */\n title?: React.ReactNode;\n /** Farge og uttrykk på alert-boksen */\n variant: 'success' | 'info' | 'warning' | 'error';\n /** Typen boks (internt bruk) */\n size: 'banner' | 'toast' | 'small';\n [key: string]: any;\n};\n\nexport const BaseAlertBox: React.FC<BaseAlertBoxProps> = ({\n children,\n className,\n closable = false,\n closeButtonLabel = 'Lukk',\n variant,\n onClose = () => ({}),\n size,\n title,\n ...rest\n}) => {\n const [isClosed, setClosed] = React.useState(false);\n if (isClosed) {\n return null;\n }\n const handleClose = () => {\n setClosed(true);\n onClose();\n };\n const Icon = iconsMap[variant];\n return (\n <div\n className={classNames(\n 'eds-alert-box',\n `eds-alert-box--${size}`,\n `eds-alert-box--${variant}`,\n className,\n )}\n {...rest}\n >\n {closable && (\n <button\n aria-label={closeButtonLabel}\n className=\"eds-alert-box__close-button\"\n type=\"button\"\n onClick={handleClose}\n >\n <CloseIcon />\n </button>\n )}\n <Icon className=\"eds-alert-box__icon\" />\n <div\n className={classNames('eds-alert-box__content', {\n 'eds-alert-box__content--no-title': !title,\n 'eds-alert-box__content--no-children': !children,\n })}\n >\n {title && <div className=\"eds-alert-box__title\">{title}</div>}\n {children && children}\n </div>\n </div>\n );\n};\n","import React from 'react';\nimport { BaseAlertBox } from './BaseAlertBox';\n\nexport type BannerAlertBoxProps = {\n /** Innholdet i alert-boksen */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Skjermleser-label for lukkeknappen, om den vises */\n closeButtonLabel?: string;\n /** Callback som kalles når man lukker boksen */\n onClose?: () => void;\n /** Om denne er true, vil boksen få en lukkeknapp i høyre hjørne\n * @default false\n */\n closable?: boolean;\n /** Tittel på boksen - oppsummer virkning */\n title?: string;\n /** Farge og uttrykk på alert-boksen */\n variant: 'success' | 'info' | 'warning' | 'error';\n [key: string]: any;\n};\n\nexport const BannerAlertBox: React.FC<BannerAlertBoxProps> = props => (\n <BaseAlertBox {...props} size=\"banner\" />\n);\n","import React from 'react';\nimport { BaseAlertBox } from './BaseAlertBox';\n\nexport type ToastAlertBoxProps = {\n /** Innholdet i toasten */\n children?: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Skjermleser-label for lukkeknappen, om den vises */\n closeButtonLabel?: string;\n /** Callback som kalles når man lukker boksen */\n onClose?: () => void;\n /** Om denne er true, vil boksen få en lukkeknapp i høyre hjørne */\n closable?: boolean;\n /** Tittel på boksen - oppsummer virkning */\n title?: string;\n /** Farge og uttrykk på toasten */\n variant: 'success' | 'info';\n [key: string]: any;\n};\n\nexport const ToastAlertBox: React.FC<ToastAlertBoxProps> = props => (\n <BaseAlertBox {...props} size=\"toast\" role=\"status\" />\n);\n","import React from 'react';\nimport classNames from 'classnames';\nimport { BaseAlertBox } from './BaseAlertBox';\n\nexport type SmallAlertBoxProps = {\n /** Innholdet i alert-boksen */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Skjermleser-label for lukkeknappen, om den vises */\n closeButtonLabel?: string;\n /** Om denne er true, vil boksen få en lukkeknapp i høyre hjørne\n * @default false\n */\n closable?: boolean;\n /** Callback som kalles når man lukker boksen */\n onClose?: () => void;\n /** Tittel på boksen - oppsummer virkning */\n title?: string;\n /** Bredden på boksen - fullbredde eller tilpasset innholdet */\n width?: 'fluid' | 'fit-content';\n /** Farge og uttrykk på alert-boksen */\n variant: 'success' | 'info' | 'warning' | 'error';\n [key: string]: any;\n};\n\nexport const SmallAlertBox: React.FC<SmallAlertBoxProps> = ({\n className,\n width,\n onClose,\n closable = false,\n closeButtonLabel,\n ...rest\n}) => (\n <BaseAlertBox\n className={classNames(className, {\n 'eds-alert-box--fit-content': width === 'fit-content',\n })}\n {...rest}\n onClose={onClose}\n closable={closable}\n closeButtonLabel={closeButtonLabel}\n size=\"small\"\n />\n);\n","import React from 'react';\nimport { ToastAlertBox } from './ToastAlertBox';\nimport classNames from 'classnames';\n\ntype ToastId = string;\n\ntype ToastVariants = 'success' | 'info';\n\ntype ToastType = {\n title?: string;\n content: React.ReactNode;\n id: ToastId;\n variant: ToastVariants;\n};\n\ntype ToastContextType = {\n addToast: (payload: AddToastPayload) => void;\n removeToast: (id: ToastId) => void;\n toasts: ToastType[];\n};\n\ntype AddToastPayload =\n | { title?: string; content: React.ReactNode; variant?: ToastVariants }\n | string;\n\ntype ToastAction =\n | { type: 'ADD_TOAST'; payload: ToastType }\n | { type: 'REMOVE_TOAST'; payload: ToastId };\n\nconst ToastContext = React.createContext<ToastContextType | null>(null);\n\nconst toastReducer = (\n prevToasts: ToastType[],\n action: ToastAction,\n): ToastType[] => {\n switch (action.type) {\n case 'ADD_TOAST':\n return [action.payload, ...prevToasts];\n case 'REMOVE_TOAST':\n return prevToasts.filter(toast => toast.id !== action.payload);\n }\n};\n\nconst createUniqueId = () => Math.random().toString().substring(2);\n\nconst createToast = (toast: AddToastPayload, id: ToastId): ToastType => {\n if (typeof toast === 'string') {\n return { id, content: toast, variant: 'success' };\n } else {\n return { id, variant: 'success', ...toast };\n }\n};\n\nexport type ToastProviderProps = {\n /** Antall millisekunder før toasts forsvinner av seg selv\n * @default 6000\n */\n delay?: number;\n /** Plasseringen av toasts\n * @default \"bottom-right\"\n */\n position?: 'bottom-right' | 'top-right';\n /** Ekstra klassenavn til ToastProvider-wrapperen */\n className?: string;\n /** Ekstra styling som sendes til ToastProvider-wrapperen */\n style?: React.CSSProperties;\n};\n\nexport const ToastProvider: React.FC<ToastProviderProps> = ({\n delay = 6000,\n children,\n position = 'bottom-right',\n className,\n style,\n}) => {\n const [toasts, dispatch] = React.useReducer(toastReducer, []);\n const [hoveringId, setHovering] = React.useState<string>();\n const timeoutIdRefs = React.useRef<{ [key: string]: number }>({});\n\n const removeToast = React.useCallback((id: ToastId) => {\n window.clearTimeout(timeoutIdRefs.current[id]);\n dispatch({ type: 'REMOVE_TOAST', payload: id });\n delete timeoutIdRefs.current[id];\n }, []);\n\n const addToast = React.useCallback(\n (toast: AddToastPayload) => {\n const id = createUniqueId();\n const payload = createToast(toast, id);\n dispatch({ type: 'ADD_TOAST', payload });\n timeoutIdRefs.current[id] = window.setTimeout(\n () => removeToast(id),\n delay,\n );\n },\n [delay, removeToast],\n );\n\n const handleMouseEnter = (toastId: ToastId) => () => {\n setHovering(toastId);\n Object.values(timeoutIdRefs.current).forEach(timeoutId =>\n window.clearTimeout(timeoutId),\n );\n timeoutIdRefs.current = {};\n };\n\n const handleMouseLeave = () => {\n setHovering(undefined);\n toasts.forEach(toast => {\n timeoutIdRefs.current[toast.id] = window.setTimeout(\n () => removeToast(toast.id),\n delay,\n );\n });\n };\n\n const handleClose = (toastId: ToastId) => () => {\n removeToast(toastId);\n handleMouseLeave();\n };\n\n const contextValue = React.useMemo(\n () => ({ toasts, addToast, removeToast }),\n [addToast, removeToast, toasts],\n );\n\n return (\n <ToastContext.Provider value={contextValue}>\n {toasts.length > 0 && (\n <div\n className={classNames(\n 'eds-toast-container',\n `eds-toast-container--${position}`,\n className,\n )}\n style={style}\n >\n {toasts.slice(0, 3).map(toastToShow => (\n <ToastAlertBox\n variant={toastToShow.variant}\n title={toastToShow.title}\n onClose={handleClose(toastToShow.id)}\n onMouseEnter={handleMouseEnter(toastToShow.id)}\n onMouseLeave={handleMouseLeave}\n closable={hoveringId === toastToShow.id}\n key={toastToShow.id}\n >\n {toastToShow.content}\n </ToastAlertBox>\n ))}\n </div>\n )}\n {children}\n </ToastContext.Provider>\n );\n};\n\nexport const useToast: () => {\n addToast: (payload: AddToastPayload) => void;\n} = () => {\n const context = React.useContext(ToastContext);\n if (!context) {\n throw new Error(\n 'You need to wrap your component in a ToastProvider component in ' +\n 'order to use the useToast hook',\n );\n }\n const { addToast } = context;\n return {\n addToast,\n };\n};\n","import React from 'react';\n\nimport copy from 'copy-text-to-clipboard';\n\nimport { useToast } from './ToastProvider';\nimport { ReportsIcon } from '@entur/icons';\nimport { PreformattedText } from '@entur/typography';\n\nimport './CopyableText.scss';\n\nexport type CopyableTextProps = {\n /** Ekstra klassenavn */\n className?: string;\n /** Tekstinnhold som vises og kopieres */\n children: string;\n /** Overskrift i toast-varselet */\n successHeading?: string;\n /** Bekreftelsesmelding i toast-varselet */\n successMessage?: string;\n} & Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'children'>;\n\nexport const CopyableText = ({\n children,\n successHeading = 'Kopiert!',\n successMessage = 'Innholdet ble kopiert til utklippstavlen.',\n className,\n ...rest\n}: CopyableTextProps): JSX.Element => {\n const { addToast } = useToast();\n const buttonRef = React.useRef<HTMLButtonElement>(null);\n const handleClick = () => {\n buttonRef.current &&\n copy(children, {\n target: buttonRef.current,\n }) &&\n addToast({ title: successHeading, content: successMessage });\n };\n return (\n <button\n className={'copyable-text ' + className}\n style={{ ...rest.style }}\n type=\"button\"\n onClick={handleClick}\n ref={buttonRef}\n aria-label=\"Kopier innhold\"\n {...rest}\n >\n <PreformattedText>{children}</PreformattedText>\n <ReportsIcon className=\"copyable-text__icon\" />\n </button>\n );\n};\n","import { BaseExpand, ExpandArrow } from '@entur/expand/';\nimport classNames from 'classnames';\nimport React from 'react';\nimport { BannerAlertBoxProps } from './BannerAlertBox';\nimport { BaseAlertBox } from './BaseAlertBox';\nimport './ExpandableAlertBox.scss';\nimport { SmallAlertBoxProps } from './SmallAlertBox';\n\nexport type SmallExpandableAlertBoxProps = ExpandableAlertBoxProps &\n SmallAlertBoxProps;\n\nexport const SmallExpandableAlertBox: React.FC<SmallExpandableAlertBoxProps> = props => {\n return <ExpandableAlertBox size=\"small\" {...props} />;\n};\n\nexport type BannerExpandableAlertBoxProps = ExpandableAlertBoxProps &\n BannerAlertBoxProps;\n\nexport const BannerExpandableAlertBox: React.FC<BannerExpandableAlertBoxProps> = props => {\n return <ExpandableAlertBox size=\"banner\" {...props} />;\n};\n\ntype ExpandableAlertBoxProps = {\n /**Farge og uttrykk på alert-boksen */\n variant: 'success' | 'info' | 'warning' | 'error';\n /** Tittelen til ExpandableAlertBox */\n title: React.ReactNode;\n /**Innhold som vises ved ekspandering */\n children: React.ReactNode;\n /**Ekstra klassenavn */\n className?: string;\n /** Tekst som vises på ekspanderingsknappen før åpning\n * @default \"Les mer\"\n */\n openLabel?: string;\n /** Tekst som vises på ekspanderingsknappen når den er åpnet\n * @default \"Lukk\"\n */\n closeLabel?: string;\n [key: string]: any;\n};\n\nconst ExpandableAlertBox: React.FC<ExpandableAlertBoxProps> = ({\n variant,\n title,\n children,\n size,\n className,\n openLabel,\n closeLabel,\n ...rest\n}) => {\n const [open, setopen] = React.useState(false);\n return (\n <BaseAlertBox\n size={size}\n variant={variant}\n className={classNames('eds-expandable-alert-box', className)}\n title={\n <ExpandableAlertBoxTitle\n open={open}\n title={title}\n onClick={() => setopen(!open)}\n openLabel={openLabel}\n closeLabel={closeLabel}\n />\n }\n {...rest}\n >\n <BaseExpand open={open}>{children}</BaseExpand>\n </BaseAlertBox>\n );\n};\n\ntype ExpandableAlertBoxTitleProps = {\n title: React.ReactNode;\n open: boolean;\n openLabel?: string;\n closeLabel?: string;\n onClick: (e: React.MouseEvent) => void;\n};\n\nconst ExpandableAlertBoxTitle: React.FC<ExpandableAlertBoxTitleProps> = ({\n title,\n open,\n openLabel = 'Les mer',\n closeLabel = 'Lukk',\n onClick,\n}) => {\n return (\n <div className=\"eds-expandable-alert-box__title\">\n <div>{title}</div>\n <button\n className=\"eds-expandable-alert-box__button\"\n onClick={onClick}\n type=\"button\"\n >\n {open ? closeLabel : openLabel}\n <ExpandArrow open={open} inline />\n </button>\n </div>\n );\n};\n","import { warnAboutMissingStyles } from '@entur/utils';\nimport './index.scss';\n\nwarnAboutMissingStyles('alert', 'icons');\n\nexport { BannerAlertBox } from './BannerAlertBox';\nexport { ToastAlertBox } from './ToastAlertBox';\nexport { SmallAlertBox } from './SmallAlertBox';\nexport { ToastProvider, useToast } from './ToastProvider';\nexport { CopyableText } from './CopyableText';\nexport * from './ExpandableAlertBox';\n"],"names":["iconsMap","success","OutlinedValidationCheckIcon","info","OutlinedValidationInfoIcon","warning","OutlinedValidationExclamationIcon","error","OutlinedValidationErrorIcon","BaseAlertBox","children","className","closable","closeButtonLabel","variant","onClose","size","title","rest","React","useState","isClosed","setClosed","handleClose","Icon","classNames","type","onClick","CloseIcon","BannerAlertBox","props","ToastAlertBox","role","SmallAlertBox","width","ToastContext","createContext","toastReducer","prevToasts","action","payload","filter","toast","id","createUniqueId","Math","random","toString","substring","createToast","content","ToastProvider","delay","position","style","useReducer","toasts","dispatch","hoveringId","setHovering","timeoutIdRefs","useRef","removeToast","useCallback","window","clearTimeout","current","addToast","setTimeout","handleMouseEnter","toastId","Object","values","forEach","timeoutId","handleMouseLeave","undefined","contextValue","useMemo","Provider","value","length","slice","map","toastToShow","onMouseEnter","onMouseLeave","key","useToast","context","useContext","Error","CopyableText","successHeading","successMessage","buttonRef","handleClick","copy","target","ref","PreformattedText","ReportsIcon","SmallExpandableAlertBox","ExpandableAlertBox","BannerExpandableAlertBox","openLabel","closeLabel","open","setopen","ExpandableAlertBoxTitle","BaseExpand","ExpandArrow","inline","warnAboutMissingStyles"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,IAAMA,QAAQ,GAAG;AACfC,EAAAA,OAAO,EAAEC,iCADM;AAEfC,EAAAA,IAAI,EAAEC,gCAFS;AAGfC,EAAAA,OAAO,EAAEC,uCAHM;AAIfC,EAAAA,KAAK,EAAEC;AAJQ,CAAjB;AAiCO,IAAMC,YAAY,GAAgC,SAA5CA,YAA4C;MACvDC,gBAAAA;MACAC,iBAAAA;2BACAC;MAAAA,sCAAW;mCACXC;MAAAA,sDAAmB;MACnBC,eAAAA;0BACAC;MAAAA,oCAAU;AAAA,WAAO,EAAP;AAAA;MACVC,YAAAA;MACAC,aAAAA;MACGC;;AAEH,wBAA8BC,yBAAK,CAACC,QAAN,CAAe,KAAf,CAA9B;AAAA,MAAOC,QAAP;AAAA,MAAiBC,SAAjB;;AACA,MAAID,QAAJ,EAAc;AACZ,WAAO,IAAP;AACD;;AACD,MAAME,WAAW,GAAG,SAAdA,WAAc;AAClBD,IAAAA,SAAS,CAAC,IAAD,CAAT;AACAP,IAAAA,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Box.tsx","../src/ToastAlertBox.tsx","../src/SmallAlertBox.tsx","../src/ToastProvider.tsx","../src/CopyableText.tsx","../src/ExpandableAlertBox.tsx","../src/index.tsx"],"sourcesContent":["import React from 'react';\nimport classNames from 'classnames';\nimport {\n CloseIcon,\n OutlinedValidationCheckIcon,\n OutlinedValidationExclamationIcon,\n OutlinedValidationInfoIcon,\n OutlinedValidationErrorIcon,\n} from '@entur/icons';\nimport './styles.scss';\n\nconst iconsMap = {\n success: OutlinedValidationCheckIcon,\n info: OutlinedValidationInfoIcon,\n warning: OutlinedValidationExclamationIcon,\n error: OutlinedValidationErrorIcon,\n};\n\ntype BaseAlertBoxProps = {\n /** Innholdet i alert-boksen */\n children?: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Skjermleser-label for lukkeknappen, om den vises\n * @default \"Lukk\"\n */\n closeButtonLabel?: string;\n /** Callback som kalles når man lukker boksen\n * @default () => {}\n */\n onClose?: () => void;\n /** Om denne er true, vil boksen få en lukkeknapp i høyre hjørne\n * @default false\n */\n closable?: boolean;\n /** Tittel på boksen - oppsummer virkning */\n title?: React.ReactNode;\n /** Farge og uttrykk på alert-boksen */\n variant: 'success' | 'info' | 'warning' | 'error';\n /** Typen boks (internt bruk) */\n size: 'banner' | 'toast' | 'small';\n [key: string]: any;\n};\n\nexport const BaseAlertBox: React.FC<BaseAlertBoxProps> = ({\n children,\n className,\n closable = false,\n closeButtonLabel = 'Lukk',\n variant,\n onClose = () => ({}),\n size,\n title,\n toastIsBeingRemoved,\n ...rest\n}) => {\n const [isClosed, setClosed] = React.useState(false);\n if (isClosed) {\n return null;\n }\n const handleClose = () => {\n setClosed(true);\n onClose();\n };\n const Icon = iconsMap[variant];\n return (\n <div\n className={classNames(\n 'eds-alert-box',\n `eds-alert-box--${size}`,\n `eds-alert-box--${variant}`,\n { 'eds-alert-box--toast--exit-animation': toastIsBeingRemoved },\n className,\n )}\n {...rest}\n >\n {closable && (\n <button\n aria-label={closeButtonLabel}\n className=\"eds-alert-box__close-button\"\n type=\"button\"\n onClick={handleClose}\n >\n <CloseIcon />\n </button>\n )}\n <Icon className=\"eds-alert-box__icon\" />\n <div\n className={classNames('eds-alert-box__content', {\n 'eds-alert-box__content--no-title': !title,\n 'eds-alert-box__content--no-children': !children,\n })}\n >\n {title && <div className=\"eds-alert-box__title\">{title}</div>}\n {children && children}\n </div>\n </div>\n );\n};\n","import React from 'react';\nimport { BaseAlertBox } from './BaseAlertBox';\n\nexport type BannerAlertBoxProps = {\n /** Innholdet i alert-boksen */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Skjermleser-label for lukkeknappen, om den vises */\n closeButtonLabel?: string;\n /** Callback som kalles når man lukker boksen */\n onClose?: () => void;\n /** Om denne er true, vil boksen få en lukkeknapp i høyre hjørne\n * @default false\n */\n closable?: boolean;\n /** Tittel på boksen - oppsummer virkning */\n title?: string;\n /** Farge og uttrykk på alert-boksen */\n variant: 'success' | 'info' | 'warning' | 'error';\n [key: string]: any;\n};\n\nexport const BannerAlertBox: React.FC<BannerAlertBoxProps> = props => (\n <BaseAlertBox {...props} size=\"banner\" />\n);\n","import React from 'react';\nimport { BaseAlertBox } from './BaseAlertBox';\n\nexport type ToastAlertBoxProps = {\n /** Innholdet i toasten */\n children?: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Skjermleser-label for lukkeknappen, om den vises */\n closeButtonLabel?: string;\n /** Callback som kalles når man lukker boksen */\n onClose?: () => void;\n /** Om denne er true, vil boksen få en lukkeknapp i høyre hjørne */\n closable?: boolean;\n /** Tittel på boksen - oppsummer virkning */\n title?: string;\n /** Farge og uttrykk på toasten */\n variant: 'success' | 'info';\n [key: string]: any;\n};\n\nexport const ToastAlertBox: React.FC<ToastAlertBoxProps> = props => (\n <BaseAlertBox {...props} size=\"toast\" role=\"status\" />\n);\n","import React from 'react';\nimport classNames from 'classnames';\nimport { BaseAlertBox } from './BaseAlertBox';\n\nexport type SmallAlertBoxProps = {\n /** Innholdet i alert-boksen */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Skjermleser-label for lukkeknappen, om den vises */\n closeButtonLabel?: string;\n /** Om denne er true, vil boksen få en lukkeknapp i høyre hjørne\n * @default false\n */\n closable?: boolean;\n /** Callback som kalles når man lukker boksen */\n onClose?: () => void;\n /** Tittel på boksen - oppsummer virkning */\n title?: string;\n /** Bredden på boksen - fullbredde eller tilpasset innholdet */\n width?: 'fluid' | 'fit-content';\n /** Farge og uttrykk på alert-boksen */\n variant: 'success' | 'info' | 'warning' | 'error';\n [key: string]: any;\n};\n\nexport const SmallAlertBox: React.FC<SmallAlertBoxProps> = ({\n className,\n width,\n onClose,\n closable = false,\n closeButtonLabel,\n ...rest\n}) => (\n <BaseAlertBox\n className={classNames(className, {\n 'eds-alert-box--fit-content': width === 'fit-content',\n })}\n {...rest}\n onClose={onClose}\n closable={closable}\n closeButtonLabel={closeButtonLabel}\n size=\"small\"\n />\n);\n","import React from 'react';\nimport { ToastAlertBox } from './ToastAlertBox';\nimport classNames from 'classnames';\n\ntype ToastId = string;\n\ntype ToastVariants = 'success' | 'info';\n\ntype ToastType = {\n title?: string;\n content: React.ReactNode;\n id: ToastId;\n variant: ToastVariants;\n isBeingRemoved: boolean;\n};\n\ntype ToastContextType = {\n addToast: (payload: AddToastPayload) => void;\n removeToast: (id: ToastId) => void;\n toasts: ToastType[];\n};\n\ntype AddToastPayload =\n | { title?: string; content: React.ReactNode; variant?: ToastVariants }\n | string;\n\ntype ToastAction =\n | { type: 'ADD_TOAST'; payload: ToastType }\n | { type: 'REMOVE_TOAST'; payload: ToastId }\n | { type: 'PLAY_EXIT_ANIMATION'; payload: ToastId };\n\nconst EXIT_ANIMATION_TIME = 400;\n\nconst ToastContext = React.createContext<ToastContextType | null>(null);\n\nconst toastReducer = (\n prevToasts: ToastType[],\n action: ToastAction,\n): ToastType[] => {\n switch (action.type) {\n case 'ADD_TOAST':\n return [action.payload, ...prevToasts];\n case 'PLAY_EXIT_ANIMATION':\n return prevToasts.map(toast => {\n if (toast.id === action.payload)\n return { ...toast, isBeingRemoved: true };\n return toast;\n });\n case 'REMOVE_TOAST':\n return prevToasts.filter(toast => toast.id !== action.payload);\n }\n};\n\nconst createUniqueId = () => Math.random().toString().substring(2);\n\nconst createToast = (toast: AddToastPayload, id: ToastId): ToastType => {\n if (typeof toast === 'string') {\n return { id, content: toast, variant: 'success', isBeingRemoved: false };\n } else {\n return { id, variant: 'success', isBeingRemoved: false, ...toast };\n }\n};\n\nexport type ToastProviderProps = {\n /** Antall millisekunder før toasts forsvinner av seg selv\n * @default 6000\n */\n delay?: number;\n /** Plasseringen av toasts\n * @default \"bottom-right\"\n */\n position?: 'bottom-right' | 'top-right';\n /** Ekstra klassenavn til ToastProvider-wrapperen */\n className?: string;\n /** Ekstra styling som sendes til ToastProvider-wrapperen */\n style?: React.CSSProperties;\n};\n\nexport const ToastProvider: React.FC<ToastProviderProps> = ({\n delay = 6000,\n children,\n position = 'bottom-right',\n className,\n style,\n}) => {\n const [toasts, dispatch] = React.useReducer(toastReducer, []);\n const [hoveringId, setHovering] = React.useState<string>();\n const timeoutIdRefs = React.useRef<{ [key: string]: number }>({});\n\n const removeToast = React.useCallback((id: ToastId) => {\n window.clearTimeout(timeoutIdRefs.current[id]);\n dispatch({ type: 'REMOVE_TOAST', payload: id });\n delete timeoutIdRefs.current[id];\n }, []);\n\n const playExitAnimation = React.useCallback((id: ToastId) => {\n window.clearTimeout(timeoutIdRefs.current[id + 'animation']);\n dispatch({ type: 'PLAY_EXIT_ANIMATION', payload: id });\n delete timeoutIdRefs.current[id + 'animation'];\n }, []);\n\n const removeToastWithAnimationAfterDelay = React.useCallback(\n (id: ToastId, delay: number) => {\n timeoutIdRefs.current[id + 'animation'] = window.setTimeout(\n () => playExitAnimation(id),\n delay - EXIT_ANIMATION_TIME,\n );\n timeoutIdRefs.current[id] = window.setTimeout(\n () => removeToast(id),\n delay,\n );\n },\n [timeoutIdRefs, playExitAnimation, removeToast],\n );\n\n const addToast = React.useCallback(\n (toast: AddToastPayload) => {\n const id = createUniqueId();\n const payload = createToast(toast, id);\n dispatch({ type: 'ADD_TOAST', payload });\n removeToastWithAnimationAfterDelay(id, delay);\n },\n [delay, removeToastWithAnimationAfterDelay],\n );\n\n const handleMouseEnter = (toast: ToastType) => () => {\n if (toast.isBeingRemoved) return;\n setHovering(toast.id);\n Object.values(timeoutIdRefs.current).forEach(timeoutId => {\n window.clearTimeout(timeoutId);\n });\n timeoutIdRefs.current = {};\n };\n\n const handleMouseLeave = () => {\n setHovering(undefined);\n toasts.forEach(toast => {\n removeToastWithAnimationAfterDelay(toast.id, delay);\n });\n };\n\n const handleClose = (toastId: ToastId) => () => {\n removeToast(toastId);\n handleMouseLeave();\n };\n\n const contextValue = React.useMemo(\n () => ({ toasts, addToast, removeToast }),\n [addToast, removeToast, toasts],\n );\n\n return (\n <ToastContext.Provider value={contextValue}>\n {toasts.length > 0 && (\n <div\n className={classNames(\n 'eds-toast-container',\n `eds-toast-container--${position}`,\n className,\n )}\n style={style}\n >\n {toasts.slice(0, 3).map(toastToShow => (\n <ToastAlertBox\n variant={toastToShow.variant}\n title={toastToShow.title}\n onClose={handleClose(toastToShow.id)}\n onMouseEnter={handleMouseEnter(toastToShow)}\n onMouseLeave={handleMouseLeave}\n closable={hoveringId === toastToShow.id}\n toastIsBeingRemoved={toastToShow.isBeingRemoved}\n key={toastToShow.id}\n >\n {toastToShow.content}\n </ToastAlertBox>\n ))}\n </div>\n )}\n {children}\n </ToastContext.Provider>\n );\n};\n\nexport const useToast: () => {\n addToast: (payload: AddToastPayload) => void;\n} = () => {\n const context = React.useContext(ToastContext);\n if (!context) {\n throw new Error(\n 'You need to wrap your component in a ToastProvider component in ' +\n 'order to use the useToast hook',\n );\n }\n const { addToast } = context;\n return {\n addToast,\n };\n};\n","import React from 'react';\n\nimport copy from 'copy-text-to-clipboard';\n\nimport { useToast } from './ToastProvider';\nimport { ReportsIcon } from '@entur/icons';\nimport { PreformattedText } from '@entur/typography';\n\nimport './CopyableText.scss';\n\nexport type CopyableTextProps = {\n /** Ekstra klassenavn */\n className?: string;\n /** Tekstinnhold som vises og kopieres */\n children: string;\n /** Overskrift i toast-varselet */\n successHeading?: string;\n /** Bekreftelsesmelding i toast-varselet */\n successMessage?: string;\n} & Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'children'>;\n\nexport const CopyableText = ({\n children,\n successHeading = 'Kopiert!',\n successMessage = 'Innholdet ble kopiert til utklippstavlen.',\n className,\n ...rest\n}: CopyableTextProps): JSX.Element => {\n const { addToast } = useToast();\n const buttonRef = React.useRef<HTMLButtonElement>(null);\n const handleClick = () => {\n buttonRef.current &&\n copy(children, {\n target: buttonRef.current,\n }) &&\n addToast({ title: successHeading, content: successMessage });\n };\n return (\n <button\n className={'copyable-text ' + className}\n style={{ ...rest.style }}\n type=\"button\"\n onClick={handleClick}\n ref={buttonRef}\n aria-label=\"Kopier innhold\"\n {...rest}\n >\n <PreformattedText>{children}</PreformattedText>\n <ReportsIcon className=\"copyable-text__icon\" />\n </button>\n );\n};\n","import { BaseExpand, ExpandArrow } from '@entur/expand/';\nimport classNames from 'classnames';\nimport React from 'react';\nimport { BannerAlertBoxProps } from './BannerAlertBox';\nimport { BaseAlertBox } from './BaseAlertBox';\nimport './ExpandableAlertBox.scss';\nimport { SmallAlertBoxProps } from './SmallAlertBox';\n\nexport type SmallExpandableAlertBoxProps = ExpandableAlertBoxProps &\n SmallAlertBoxProps;\n\nexport const SmallExpandableAlertBox: React.FC<SmallExpandableAlertBoxProps> = props => {\n return <ExpandableAlertBox size=\"small\" {...props} />;\n};\n\nexport type BannerExpandableAlertBoxProps = ExpandableAlertBoxProps &\n BannerAlertBoxProps;\n\nexport const BannerExpandableAlertBox: React.FC<BannerExpandableAlertBoxProps> = props => {\n return <ExpandableAlertBox size=\"banner\" {...props} />;\n};\n\ntype ExpandableAlertBoxProps = {\n /**Farge og uttrykk på alert-boksen */\n variant: 'success' | 'info' | 'warning' | 'error';\n /** Tittelen til ExpandableAlertBox */\n title: React.ReactNode;\n /**Innhold som vises ved ekspandering */\n children: React.ReactNode;\n /**Ekstra klassenavn */\n className?: string;\n /** Tekst som vises på ekspanderingsknappen før åpning\n * @default \"Les mer\"\n */\n openLabel?: string;\n /** Tekst som vises på ekspanderingsknappen når den er åpnet\n * @default \"Lukk\"\n */\n closeLabel?: string;\n [key: string]: any;\n};\n\nconst ExpandableAlertBox: React.FC<ExpandableAlertBoxProps> = ({\n variant,\n title,\n children,\n size,\n className,\n openLabel,\n closeLabel,\n ...rest\n}) => {\n const [open, setopen] = React.useState(false);\n return (\n <BaseAlertBox\n size={size}\n variant={variant}\n className={classNames('eds-expandable-alert-box', className)}\n title={\n <ExpandableAlertBoxTitle\n open={open}\n title={title}\n onClick={() => setopen(!open)}\n openLabel={openLabel}\n closeLabel={closeLabel}\n />\n }\n {...rest}\n >\n <BaseExpand open={open}>{children}</BaseExpand>\n </BaseAlertBox>\n );\n};\n\ntype ExpandableAlertBoxTitleProps = {\n title: React.ReactNode;\n open: boolean;\n openLabel?: string;\n closeLabel?: string;\n onClick: (e: React.MouseEvent) => void;\n};\n\nconst ExpandableAlertBoxTitle: React.FC<ExpandableAlertBoxTitleProps> = ({\n title,\n open,\n openLabel = 'Les mer',\n closeLabel = 'Lukk',\n onClick,\n}) => {\n return (\n <div className=\"eds-expandable-alert-box__title\">\n <div>{title}</div>\n <button\n className=\"eds-expandable-alert-box__button\"\n onClick={onClick}\n type=\"button\"\n >\n {open ? closeLabel : openLabel}\n <ExpandArrow open={open} inline />\n </button>\n </div>\n );\n};\n","import { warnAboutMissingStyles } from '@entur/utils';\nimport './index.scss';\n\nwarnAboutMissingStyles('alert', 'icons');\n\nexport { BannerAlertBox } from './BannerAlertBox';\nexport { ToastAlertBox } from './ToastAlertBox';\nexport { SmallAlertBox } from './SmallAlertBox';\nexport { ToastProvider, useToast } from './ToastProvider';\nexport { CopyableText } from './CopyableText';\nexport * from './ExpandableAlertBox';\n"],"names":["iconsMap","success","OutlinedValidationCheckIcon","info","OutlinedValidationInfoIcon","warning","OutlinedValidationExclamationIcon","error","OutlinedValidationErrorIcon","BaseAlertBox","children","className","closable","closeButtonLabel","variant","onClose","size","title","toastIsBeingRemoved","rest","React","useState","isClosed","setClosed","handleClose","Icon","classNames","type","onClick","CloseIcon","BannerAlertBox","props","ToastAlertBox","role","SmallAlertBox","width","EXIT_ANIMATION_TIME","ToastContext","createContext","toastReducer","prevToasts","action","payload","map","toast","id","isBeingRemoved","filter","createUniqueId","Math","random","toString","substring","createToast","content","ToastProvider","delay","position","style","useReducer","toasts","dispatch","hoveringId","setHovering","timeoutIdRefs","useRef","removeToast","useCallback","window","clearTimeout","current","playExitAnimation","removeToastWithAnimationAfterDelay","setTimeout","addToast","handleMouseEnter","Object","values","forEach","timeoutId","handleMouseLeave","undefined","toastId","contextValue","useMemo","Provider","value","length","slice","toastToShow","onMouseEnter","onMouseLeave","key","useToast","context","useContext","Error","CopyableText","successHeading","successMessage","buttonRef","handleClick","copy","target","ref","PreformattedText","ReportsIcon","SmallExpandableAlertBox","ExpandableAlertBox","BannerExpandableAlertBox","openLabel","closeLabel","open","setopen","ExpandableAlertBoxTitle","BaseExpand","ExpandArrow","inline","warnAboutMissingStyles"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,IAAMA,QAAQ,GAAG;AACfC,EAAAA,OAAO,EAAEC,iCADM;AAEfC,EAAAA,IAAI,EAAEC,gCAFS;AAGfC,EAAAA,OAAO,EAAEC,uCAHM;AAIfC,EAAAA,KAAK,EAAEC;AAJQ,CAAjB;AAiCO,IAAMC,YAAY,GAAgC,SAA5CA,YAA4C;MACvDC,gBAAAA;MACAC,iBAAAA;2BACAC;MAAAA,sCAAW;mCACXC;MAAAA,sDAAmB;MACnBC,eAAAA;0BACAC;MAAAA,oCAAU;AAAA,WAAO,EAAP;AAAA;MACVC,YAAAA;MACAC,aAAAA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ANF,CAFF,CADF;AAaD,CApBD;;AC/EAC,4BAAsB,CAAC,OAAD,EAAU,OAAV,CAAtB;;;;;;;;;;;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@entur/utils"),t=require("react"),n=require("classnames"),a=require("@entur/icons"),l=require("copy-text-to-clipboard"),r=require("@entur/typography"),o=require("@entur/expand/");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=s(t),i=s(n),c=s(l);function d(){return d=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},d.apply(this,arguments)}function f(e,t){if(null==e)return{};var n,a,l={},r=Object.keys(e);for(a=0;a<r.length;a++)t.indexOf(n=r[a])>=0||(l[n]=e[n]);return l}var b=["children","className","closable","closeButtonLabel","variant","onClose","size","title"],m={success:a.OutlinedValidationCheckIcon,info:a.OutlinedValidationInfoIcon,warning:a.OutlinedValidationExclamationIcon,error:a.OutlinedValidationErrorIcon},p=function(e){var t=e.children,n=e.className,l=e.closable,r=void 0!==l&&l,o=e.closeButtonLabel,s=void 0===o?"Lukk":o,c=e.variant,p=e.onClose,v=void 0===p?function(){return{}}:p,x=e.size,E=e.title,y=f(e,b),h=u.default.useState(!1),T=h[1];if(h[0])return null;var _=m[c];return u.default.createElement("div",d({className:i.default("eds-alert-box","eds-alert-box--"+x,"eds-alert-box--"+c,n)},y),r&&u.default.createElement("button",{"aria-label":s,className:"eds-alert-box__close-button",type:"button",onClick:function(){T(!0),v()}},u.default.createElement(a.CloseIcon,null)),u.default.createElement(_,{className:"eds-alert-box__icon"}),u.default.createElement("div",{className:i.default("eds-alert-box__content",{"eds-alert-box__content--no-title":!E,"eds-alert-box__content--no-children":!t})},E&&u.default.createElement("div",{className:"eds-alert-box__title"},E),t&&t))},v=function(e){return u.default.createElement(p,d({},e,{size:"toast",role:"status"}))},x=["className","width","onClose","closable","closeButtonLabel"],E=u.default.createContext(null),y=function(e,t){switch(t.type){case"ADD_TOAST":return[t.payload].concat(e);case"REMOVE_TOAST":return e.filter((function(e){return e.id!==t.payload}))}},h=function(){var e=u.default.useContext(E);if(!e)throw new Error("You need to wrap your component in a ToastProvider component in order to use the useToast hook");return{addToast:e.addToast}},T=["children","successHeading","successMessage","className"],_=["variant","title","children","size","className","openLabel","closeLabel"],N=function(e){var t=e.variant,n=e.title,a=e.children,l=e.size,r=e.className,s=e.openLabel,c=e.closeLabel,b=f(e,_),m=u.default.useState(!1),v=m[0],x=m[1];return u.default.createElement(p,d({size:l,variant:t,className:i.default("eds-expandable-alert-box",r),title:u.default.createElement(w,{open:v,title:n,onClick:function(){return x(!v)},openLabel:s,closeLabel:c})},b),u.default.createElement(o.BaseExpand,{open:v},a))},w=function(e){var t=e.open,n=e.openLabel,a=void 0===n?"Les mer":n,l=e.closeLabel,r=void 0===l?"Lukk":l,s=e.onClick;return u.default.createElement("div",{className:"eds-expandable-alert-box__title"},u.default.createElement("div",null,e.title),u.default.createElement("button",{className:"eds-expandable-alert-box__button",onClick:s,type:"button"},t?r:a,u.default.createElement(o.ExpandArrow,{open:t,inline:!0})))};e.warnAboutMissingStyles("alert","icons"),exports.BannerAlertBox=function(e){return u.default.createElement(p,d({},e,{size:"banner"}))},exports.BannerExpandableAlertBox=function(e){return u.default.createElement(N,d({size:"banner"},e))},exports.CopyableText=function(e){var t=e.children,n=e.successHeading,l=void 0===n?"Kopiert!":n,o=e.successMessage,s=void 0===o?"Innholdet ble kopiert til utklippstavlen.":o,i=e.className,b=f(e,T),m=h().addToast,p=u.default.useRef(null);return u.default.createElement("button",d({className:"copyable-text "+i,style:d({},b.style),type:"button",onClick:function(){p.current&&c.default(t,{target:p.current})&&m({title:l,content:s})},ref:p,"aria-label":"Kopier innhold"},b),u.default.createElement(r.PreformattedText,null,t),u.default.createElement(a.ReportsIcon,{className:"copyable-text__icon"}))},exports.SmallAlertBox=function(e){var t=e.className,n=e.width,a=e.onClose,l=e.closable,r=void 0!==l&&l,o=e.closeButtonLabel,s=f(e,x);return u.default.createElement(p,d({className:i.default(t,{"eds-alert-box--fit-content":"fit-content"===n})},s,{onClose:a,closable:r,closeButtonLabel:o,size:"small"}))},exports.SmallExpandableAlertBox=function(e){return u.default.createElement(N,d({size:"small"},e))},exports.ToastAlertBox=v,exports.ToastProvider=function(e){var t=e.delay,n=void 0===t?6e3:t,a=e.children,l=e.position,r=void 0===l?"bottom-right":l,o=e.className,s=e.style,c=u.default.useReducer(y,[]),f=c[0],b=c[1],m=u.default.useState(),p=m[0],x=m[1],h=u.default.useRef({}),T=u.default.useCallback((function(e){window.clearTimeout(h.current[e]),b({type:"REMOVE_TOAST",payload:e}),delete h.current[e]}),[]),_=u.default.useCallback((function(e){var t=Math.random().toString().substring(2),a=function(e,t){return"string"==typeof e?{id:t,content:e,variant:"success"}:d({id:t,variant:"success"},e)}(e,t);b({type:"ADD_TOAST",payload:a}),h.current[t]=window.setTimeout((function(){return T(t)}),n)}),[n,T]),N=function(e){return function(){x(e),Object.values(h.current).forEach((function(e){return window.clearTimeout(e)})),h.current={}}},w=function(){x(void 0),f.forEach((function(e){h.current[e.id]=window.setTimeout((function(){return T(e.id)}),n)}))},C=u.default.useMemo((function(){return{toasts:f,addToast:_,removeToast:T}}),[_,T,f]);return u.default.createElement(E.Provider,{value:C},f.length>0&&u.default.createElement("div",{className:i.default("eds-toast-container","eds-toast-container--"+r,o),style:s},f.slice(0,3).map((function(e){return u.default.createElement(v,{variant:e.variant,title:e.title,onClose:(t=e.id,function(){T(t),w()}),onMouseEnter:N(e.id),onMouseLeave:w,closable:p===e.id,key:e.id},e.content);var t}))),a)},exports.useToast=h;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@entur/utils"),t=require("react"),n=require("classnames"),a=require("@entur/icons"),l=require("copy-text-to-clipboard"),o=require("@entur/typography"),r=require("@entur/expand/");function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=i(t),u=i(n),c=i(l);function d(){return d=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},d.apply(this,arguments)}function f(e,t){if(null==e)return{};var n,a,l={},o=Object.keys(e);for(a=0;a<o.length;a++)t.indexOf(n=o[a])>=0||(l[n]=e[n]);return l}var m=["children","className","closable","closeButtonLabel","variant","onClose","size","title","toastIsBeingRemoved"],b={success:a.OutlinedValidationCheckIcon,info:a.OutlinedValidationInfoIcon,warning:a.OutlinedValidationExclamationIcon,error:a.OutlinedValidationErrorIcon},p=function(e){var t=e.children,n=e.className,l=e.closable,o=void 0!==l&&l,r=e.closeButtonLabel,i=void 0===r?"Lukk":r,c=e.variant,p=e.onClose,v=void 0===p?function(){return{}}:p,x=e.size,E=e.title,y=e.toastIsBeingRemoved,T=f(e,m),_=s.default.useState(!1),h=_[1];if(_[0])return null;var N=b[c];return s.default.createElement("div",d({className:u.default("eds-alert-box","eds-alert-box--"+x,"eds-alert-box--"+c,{"eds-alert-box--toast--exit-animation":y},n)},T),o&&s.default.createElement("button",{"aria-label":i,className:"eds-alert-box__close-button",type:"button",onClick:function(){h(!0),v()}},s.default.createElement(a.CloseIcon,null)),s.default.createElement(N,{className:"eds-alert-box__icon"}),s.default.createElement("div",{className:u.default("eds-alert-box__content",{"eds-alert-box__content--no-title":!E,"eds-alert-box__content--no-children":!t})},E&&s.default.createElement("div",{className:"eds-alert-box__title"},E),t&&t))},v=function(e){return s.default.createElement(p,d({},e,{size:"toast",role:"status"}))},x=["className","width","onClose","closable","closeButtonLabel"],E=s.default.createContext(null),y=function(e,t){switch(t.type){case"ADD_TOAST":return[t.payload].concat(e);case"PLAY_EXIT_ANIMATION":return e.map((function(e){return e.id===t.payload?d({},e,{isBeingRemoved:!0}):e}));case"REMOVE_TOAST":return e.filter((function(e){return e.id!==t.payload}))}},T=function(){var e=s.default.useContext(E);if(!e)throw new Error("You need to wrap your component in a ToastProvider component in order to use the useToast hook");return{addToast:e.addToast}},_=["children","successHeading","successMessage","className"],h=["variant","title","children","size","className","openLabel","closeLabel"],N=function(e){var t=e.variant,n=e.title,a=e.children,l=e.size,o=e.className,i=e.openLabel,c=e.closeLabel,m=f(e,h),b=s.default.useState(!1),v=b[0],x=b[1];return s.default.createElement(p,d({size:l,variant:t,className:u.default("eds-expandable-alert-box",o),title:s.default.createElement(g,{open:v,title:n,onClick:function(){return x(!v)},openLabel:i,closeLabel:c})},m),s.default.createElement(r.BaseExpand,{open:v},a))},g=function(e){var t=e.open,n=e.openLabel,a=void 0===n?"Les mer":n,l=e.closeLabel,o=void 0===l?"Lukk":l,i=e.onClick;return s.default.createElement("div",{className:"eds-expandable-alert-box__title"},s.default.createElement("div",null,e.title),s.default.createElement("button",{className:"eds-expandable-alert-box__button",onClick:i,type:"button"},t?o:a,s.default.createElement(r.ExpandArrow,{open:t,inline:!0})))};e.warnAboutMissingStyles("alert","icons"),exports.BannerAlertBox=function(e){return s.default.createElement(p,d({},e,{size:"banner"}))},exports.BannerExpandableAlertBox=function(e){return s.default.createElement(N,d({size:"banner"},e))},exports.CopyableText=function(e){var t=e.children,n=e.successHeading,l=void 0===n?"Kopiert!":n,r=e.successMessage,i=void 0===r?"Innholdet ble kopiert til utklippstavlen.":r,u=e.className,m=f(e,_),b=T().addToast,p=s.default.useRef(null);return s.default.createElement("button",d({className:"copyable-text "+u,style:d({},m.style),type:"button",onClick:function(){p.current&&c.default(t,{target:p.current})&&b({title:l,content:i})},ref:p,"aria-label":"Kopier innhold"},m),s.default.createElement(o.PreformattedText,null,t),s.default.createElement(a.ReportsIcon,{className:"copyable-text__icon"}))},exports.SmallAlertBox=function(e){var t=e.className,n=e.width,a=e.onClose,l=e.closable,o=void 0!==l&&l,r=e.closeButtonLabel,i=f(e,x);return s.default.createElement(p,d({className:u.default(t,{"eds-alert-box--fit-content":"fit-content"===n})},i,{onClose:a,closable:o,closeButtonLabel:r,size:"small"}))},exports.SmallExpandableAlertBox=function(e){return s.default.createElement(N,d({size:"small"},e))},exports.ToastAlertBox=v,exports.ToastProvider=function(e){var t=e.delay,n=void 0===t?6e3:t,a=e.children,l=e.position,o=void 0===l?"bottom-right":l,r=e.className,i=e.style,c=s.default.useReducer(y,[]),f=c[0],m=c[1],b=s.default.useState(),p=b[0],x=b[1],T=s.default.useRef({}),_=s.default.useCallback((function(e){window.clearTimeout(T.current[e]),m({type:"REMOVE_TOAST",payload:e}),delete T.current[e]}),[]),h=s.default.useCallback((function(e){window.clearTimeout(T.current[e+"animation"]),m({type:"PLAY_EXIT_ANIMATION",payload:e}),delete T.current[e+"animation"]}),[]),N=s.default.useCallback((function(e,t){T.current[e+"animation"]=window.setTimeout((function(){return h(e)}),t-400),T.current[e]=window.setTimeout((function(){return _(e)}),t)}),[T,h,_]),g=s.default.useCallback((function(e){var t=Math.random().toString().substring(2),a=function(e,t){return"string"==typeof e?{id:t,content:e,variant:"success",isBeingRemoved:!1}:d({id:t,variant:"success",isBeingRemoved:!1},e)}(e,t);m({type:"ADD_TOAST",payload:a}),N(t,n)}),[n,N]),B=function(){x(void 0),f.forEach((function(e){N(e.id,n)}))},w=s.default.useMemo((function(){return{toasts:f,addToast:g,removeToast:_}}),[g,_,f]);return s.default.createElement(E.Provider,{value:w},f.length>0&&s.default.createElement("div",{className:u.default("eds-toast-container","eds-toast-container--"+o,r),style:i},f.slice(0,3).map((function(e){return s.default.createElement(v,{variant:e.variant,title:e.title,onClose:(n=e.id,function(){_(n),B()}),onMouseEnter:(t=e,function(){t.isBeingRemoved||(x(t.id),Object.values(T.current).forEach((function(e){window.clearTimeout(e)})),T.current={})}),onMouseLeave:B,closable:p===e.id,toastIsBeingRemoved:e.isBeingRemoved,key:e.id},e.content);var t,n}))),a)},exports.useToast=T;
2
2
  //# sourceMappingURL=alert.cjs.production.min.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"alert.cjs.production.min.js","sources":["../src/BaseAlertBox.tsx","../src/ToastAlertBox.tsx","../src/ToastProvider.tsx","../src/ExpandableAlertBox.tsx","../src/index.tsx","../src/BannerAlertBox.tsx","../src/CopyableText.tsx","../src/SmallAlertBox.tsx"],"sourcesContent":["import React from 'react';\nimport classNames from 'classnames';\nimport {\n CloseIcon,\n OutlinedValidationCheckIcon,\n OutlinedValidationExclamationIcon,\n OutlinedValidationInfoIcon,\n OutlinedValidationErrorIcon,\n} from '@entur/icons';\nimport './styles.scss';\n\nconst iconsMap = {\n success: OutlinedValidationCheckIcon,\n info: OutlinedValidationInfoIcon,\n warning: OutlinedValidationExclamationIcon,\n error: OutlinedValidationErrorIcon,\n};\n\ntype BaseAlertBoxProps = {\n /** Innholdet i alert-boksen */\n children?: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Skjermleser-label for lukkeknappen, om den vises\n * @default \"Lukk\"\n */\n closeButtonLabel?: string;\n /** Callback som kalles når man lukker boksen\n * @default () => {}\n */\n onClose?: () => void;\n /** Om denne er true, vil boksen få en lukkeknapp i høyre hjørne\n * @default false\n */\n closable?: boolean;\n /** Tittel på boksen - oppsummer virkning */\n title?: React.ReactNode;\n /** Farge og uttrykk på alert-boksen */\n variant: 'success' | 'info' | 'warning' | 'error';\n /** Typen boks (internt bruk) */\n size: 'banner' | 'toast' | 'small';\n [key: string]: any;\n};\n\nexport const BaseAlertBox: React.FC<BaseAlertBoxProps> = ({\n children,\n className,\n closable = false,\n closeButtonLabel = 'Lukk',\n variant,\n onClose = () => ({}),\n size,\n title,\n ...rest\n}) => {\n const [isClosed, setClosed] = React.useState(false);\n if (isClosed) {\n return null;\n }\n const handleClose = () => {\n setClosed(true);\n onClose();\n };\n const Icon = iconsMap[variant];\n return (\n <div\n className={classNames(\n 'eds-alert-box',\n `eds-alert-box--${size}`,\n `eds-alert-box--${variant}`,\n className,\n )}\n {...rest}\n >\n {closable && (\n <button\n aria-label={closeButtonLabel}\n className=\"eds-alert-box__close-button\"\n type=\"button\"\n onClick={handleClose}\n >\n <CloseIcon />\n </button>\n )}\n <Icon className=\"eds-alert-box__icon\" />\n <div\n className={classNames('eds-alert-box__content', {\n 'eds-alert-box__content--no-title': !title,\n 'eds-alert-box__content--no-children': !children,\n })}\n >\n {title && <div className=\"eds-alert-box__title\">{title}</div>}\n {children && children}\n </div>\n </div>\n );\n};\n","import React from 'react';\nimport { BaseAlertBox } from './BaseAlertBox';\n\nexport type ToastAlertBoxProps = {\n /** Innholdet i toasten */\n children?: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Skjermleser-label for lukkeknappen, om den vises */\n closeButtonLabel?: string;\n /** Callback som kalles når man lukker boksen */\n onClose?: () => void;\n /** Om denne er true, vil boksen få en lukkeknapp i høyre hjørne */\n closable?: boolean;\n /** Tittel på boksen - oppsummer virkning */\n title?: string;\n /** Farge og uttrykk på toasten */\n variant: 'success' | 'info';\n [key: string]: any;\n};\n\nexport const ToastAlertBox: React.FC<ToastAlertBoxProps> = props => (\n <BaseAlertBox {...props} size=\"toast\" role=\"status\" />\n);\n","import React from 'react';\nimport { ToastAlertBox } from './ToastAlertBox';\nimport classNames from 'classnames';\n\ntype ToastId = string;\n\ntype ToastVariants = 'success' | 'info';\n\ntype ToastType = {\n title?: string;\n content: React.ReactNode;\n id: ToastId;\n variant: ToastVariants;\n};\n\ntype ToastContextType = {\n addToast: (payload: AddToastPayload) => void;\n removeToast: (id: ToastId) => void;\n toasts: ToastType[];\n};\n\ntype AddToastPayload =\n | { title?: string; content: React.ReactNode; variant?: ToastVariants }\n | string;\n\ntype ToastAction =\n | { type: 'ADD_TOAST'; payload: ToastType }\n | { type: 'REMOVE_TOAST'; payload: ToastId };\n\nconst ToastContext = React.createContext<ToastContextType | null>(null);\n\nconst toastReducer = (\n prevToasts: ToastType[],\n action: ToastAction,\n): ToastType[] => {\n switch (action.type) {\n case 'ADD_TOAST':\n return [action.payload, ...prevToasts];\n case 'REMOVE_TOAST':\n return prevToasts.filter(toast => toast.id !== action.payload);\n }\n};\n\nconst createUniqueId = () => Math.random().toString().substring(2);\n\nconst createToast = (toast: AddToastPayload, id: ToastId): ToastType => {\n if (typeof toast === 'string') {\n return { id, content: toast, variant: 'success' };\n } else {\n return { id, variant: 'success', ...toast };\n }\n};\n\nexport type ToastProviderProps = {\n /** Antall millisekunder før toasts forsvinner av seg selv\n * @default 6000\n */\n delay?: number;\n /** Plasseringen av toasts\n * @default \"bottom-right\"\n */\n position?: 'bottom-right' | 'top-right';\n /** Ekstra klassenavn til ToastProvider-wrapperen */\n className?: string;\n /** Ekstra styling som sendes til ToastProvider-wrapperen */\n style?: React.CSSProperties;\n};\n\nexport const ToastProvider: React.FC<ToastProviderProps> = ({\n delay = 6000,\n children,\n position = 'bottom-right',\n className,\n style,\n}) => {\n const [toasts, dispatch] = React.useReducer(toastReducer, []);\n const [hoveringId, setHovering] = React.useState<string>();\n const timeoutIdRefs = React.useRef<{ [key: string]: number }>({});\n\n const removeToast = React.useCallback((id: ToastId) => {\n window.clearTimeout(timeoutIdRefs.current[id]);\n dispatch({ type: 'REMOVE_TOAST', payload: id });\n delete timeoutIdRefs.current[id];\n }, []);\n\n const addToast = React.useCallback(\n (toast: AddToastPayload) => {\n const id = createUniqueId();\n const payload = createToast(toast, id);\n dispatch({ type: 'ADD_TOAST', payload });\n timeoutIdRefs.current[id] = window.setTimeout(\n () => removeToast(id),\n delay,\n );\n },\n [delay, removeToast],\n );\n\n const handleMouseEnter = (toastId: ToastId) => () => {\n setHovering(toastId);\n Object.values(timeoutIdRefs.current).forEach(timeoutId =>\n window.clearTimeout(timeoutId),\n );\n timeoutIdRefs.current = {};\n };\n\n const handleMouseLeave = () => {\n setHovering(undefined);\n toasts.forEach(toast => {\n timeoutIdRefs.current[toast.id] = window.setTimeout(\n () => removeToast(toast.id),\n delay,\n );\n });\n };\n\n const handleClose = (toastId: ToastId) => () => {\n removeToast(toastId);\n handleMouseLeave();\n };\n\n const contextValue = React.useMemo(\n () => ({ toasts, addToast, removeToast }),\n [addToast, removeToast, toasts],\n );\n\n return (\n <ToastContext.Provider value={contextValue}>\n {toasts.length > 0 && (\n <div\n className={classNames(\n 'eds-toast-container',\n `eds-toast-container--${position}`,\n className,\n )}\n style={style}\n >\n {toasts.slice(0, 3).map(toastToShow => (\n <ToastAlertBox\n variant={toastToShow.variant}\n title={toastToShow.title}\n onClose={handleClose(toastToShow.id)}\n onMouseEnter={handleMouseEnter(toastToShow.id)}\n onMouseLeave={handleMouseLeave}\n closable={hoveringId === toastToShow.id}\n key={toastToShow.id}\n >\n {toastToShow.content}\n </ToastAlertBox>\n ))}\n </div>\n )}\n {children}\n </ToastContext.Provider>\n );\n};\n\nexport const useToast: () => {\n addToast: (payload: AddToastPayload) => void;\n} = () => {\n const context = React.useContext(ToastContext);\n if (!context) {\n throw new Error(\n 'You need to wrap your component in a ToastProvider component in ' +\n 'order to use the useToast hook',\n );\n }\n const { addToast } = context;\n return {\n addToast,\n };\n};\n","import { BaseExpand, ExpandArrow } from '@entur/expand/';\nimport classNames from 'classnames';\nimport React from 'react';\nimport { BannerAlertBoxProps } from './BannerAlertBox';\nimport { BaseAlertBox } from './BaseAlertBox';\nimport './ExpandableAlertBox.scss';\nimport { SmallAlertBoxProps } from './SmallAlertBox';\n\nexport type SmallExpandableAlertBoxProps = ExpandableAlertBoxProps &\n SmallAlertBoxProps;\n\nexport const SmallExpandableAlertBox: React.FC<SmallExpandableAlertBoxProps> = props => {\n return <ExpandableAlertBox size=\"small\" {...props} />;\n};\n\nexport type BannerExpandableAlertBoxProps = ExpandableAlertBoxProps &\n BannerAlertBoxProps;\n\nexport const BannerExpandableAlertBox: React.FC<BannerExpandableAlertBoxProps> = props => {\n return <ExpandableAlertBox size=\"banner\" {...props} />;\n};\n\ntype ExpandableAlertBoxProps = {\n /**Farge og uttrykk på alert-boksen */\n variant: 'success' | 'info' | 'warning' | 'error';\n /** Tittelen til ExpandableAlertBox */\n title: React.ReactNode;\n /**Innhold som vises ved ekspandering */\n children: React.ReactNode;\n /**Ekstra klassenavn */\n className?: string;\n /** Tekst som vises på ekspanderingsknappen før åpning\n * @default \"Les mer\"\n */\n openLabel?: string;\n /** Tekst som vises på ekspanderingsknappen når den er åpnet\n * @default \"Lukk\"\n */\n closeLabel?: string;\n [key: string]: any;\n};\n\nconst ExpandableAlertBox: React.FC<ExpandableAlertBoxProps> = ({\n variant,\n title,\n children,\n size,\n className,\n openLabel,\n closeLabel,\n ...rest\n}) => {\n const [open, setopen] = React.useState(false);\n return (\n <BaseAlertBox\n size={size}\n variant={variant}\n className={classNames('eds-expandable-alert-box', className)}\n title={\n <ExpandableAlertBoxTitle\n open={open}\n title={title}\n onClick={() => setopen(!open)}\n openLabel={openLabel}\n closeLabel={closeLabel}\n />\n }\n {...rest}\n >\n <BaseExpand open={open}>{children}</BaseExpand>\n </BaseAlertBox>\n );\n};\n\ntype ExpandableAlertBoxTitleProps = {\n title: React.ReactNode;\n open: boolean;\n openLabel?: string;\n closeLabel?: string;\n onClick: (e: React.MouseEvent) => void;\n};\n\nconst ExpandableAlertBoxTitle: React.FC<ExpandableAlertBoxTitleProps> = ({\n title,\n open,\n openLabel = 'Les mer',\n closeLabel = 'Lukk',\n onClick,\n}) => {\n return (\n <div className=\"eds-expandable-alert-box__title\">\n <div>{title}</div>\n <button\n className=\"eds-expandable-alert-box__button\"\n onClick={onClick}\n type=\"button\"\n >\n {open ? closeLabel : openLabel}\n <ExpandArrow open={open} inline />\n </button>\n </div>\n );\n};\n","import { warnAboutMissingStyles } from '@entur/utils';\nimport './index.scss';\n\nwarnAboutMissingStyles('alert', 'icons');\n\nexport { BannerAlertBox } from './BannerAlertBox';\nexport { ToastAlertBox } from './ToastAlertBox';\nexport { SmallAlertBox } from './SmallAlertBox';\nexport { ToastProvider, useToast } from './ToastProvider';\nexport { CopyableText } from './CopyableText';\nexport * from './ExpandableAlertBox';\n","import React from 'react';\nimport { BaseAlertBox } from './BaseAlertBox';\n\nexport type BannerAlertBoxProps = {\n /** Innholdet i alert-boksen */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Skjermleser-label for lukkeknappen, om den vises */\n closeButtonLabel?: string;\n /** Callback som kalles når man lukker boksen */\n onClose?: () => void;\n /** Om denne er true, vil boksen få en lukkeknapp i høyre hjørne\n * @default false\n */\n closable?: boolean;\n /** Tittel på boksen - oppsummer virkning */\n title?: string;\n /** Farge og uttrykk på alert-boksen */\n variant: 'success' | 'info' | 'warning' | 'error';\n [key: string]: any;\n};\n\nexport const BannerAlertBox: React.FC<BannerAlertBoxProps> = props => (\n <BaseAlertBox {...props} size=\"banner\" />\n);\n","import React from 'react';\n\nimport copy from 'copy-text-to-clipboard';\n\nimport { useToast } from './ToastProvider';\nimport { ReportsIcon } from '@entur/icons';\nimport { PreformattedText } from '@entur/typography';\n\nimport './CopyableText.scss';\n\nexport type CopyableTextProps = {\n /** Ekstra klassenavn */\n className?: string;\n /** Tekstinnhold som vises og kopieres */\n children: string;\n /** Overskrift i toast-varselet */\n successHeading?: string;\n /** Bekreftelsesmelding i toast-varselet */\n successMessage?: string;\n} & Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'children'>;\n\nexport const CopyableText = ({\n children,\n successHeading = 'Kopiert!',\n successMessage = 'Innholdet ble kopiert til utklippstavlen.',\n className,\n ...rest\n}: CopyableTextProps): JSX.Element => {\n const { addToast } = useToast();\n const buttonRef = React.useRef<HTMLButtonElement>(null);\n const handleClick = () => {\n buttonRef.current &&\n copy(children, {\n target: buttonRef.current,\n }) &&\n addToast({ title: successHeading, content: successMessage });\n };\n return (\n <button\n className={'copyable-text ' + className}\n style={{ ...rest.style }}\n type=\"button\"\n onClick={handleClick}\n ref={buttonRef}\n aria-label=\"Kopier innhold\"\n {...rest}\n >\n <PreformattedText>{children}</PreformattedText>\n <ReportsIcon className=\"copyable-text__icon\" />\n </button>\n );\n};\n","import React from 'react';\nimport classNames from 'classnames';\nimport { BaseAlertBox } from './BaseAlertBox';\n\nexport type SmallAlertBoxProps = {\n /** Innholdet i alert-boksen */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Skjermleser-label for lukkeknappen, om den vises */\n closeButtonLabel?: string;\n /** Om denne er true, vil boksen få en lukkeknapp i høyre hjørne\n * @default false\n */\n closable?: boolean;\n /** Callback som kalles når man lukker boksen */\n onClose?: () => void;\n /** Tittel på boksen - oppsummer virkning */\n title?: string;\n /** Bredden på boksen - fullbredde eller tilpasset innholdet */\n width?: 'fluid' | 'fit-content';\n /** Farge og uttrykk på alert-boksen */\n variant: 'success' | 'info' | 'warning' | 'error';\n [key: string]: any;\n};\n\nexport const SmallAlertBox: React.FC<SmallAlertBoxProps> = ({\n className,\n width,\n onClose,\n closable = false,\n closeButtonLabel,\n ...rest\n}) => (\n <BaseAlertBox\n className={classNames(className, {\n 'eds-alert-box--fit-content': width === 'fit-content',\n })}\n {...rest}\n onClose={onClose}\n closable={closable}\n closeButtonLabel={closeButtonLabel}\n size=\"small\"\n />\n);\n"],"names":["iconsMap","success","OutlinedValidationCheckIcon","info","OutlinedValidationInfoIcon","warning","OutlinedValidationExclamationIcon","error","OutlinedValidationErrorIcon","BaseAlertBox","children","className","closable","closeButtonLabel","variant","onClose","size","title","rest","React","useState","setClosed","Icon","classNames","type","onClick","CloseIcon","ToastAlertBox","props","role","ToastContext","createContext","toastReducer","prevToasts","action","payload","filter","toast","id","useToast","context","useContext","Error","addToast","ExpandableAlertBox","openLabel","closeLabel","open","setopen","ExpandableAlertBoxTitle","BaseExpand","ExpandArrow","inline","warnAboutMissingStyles","successHeading","successMessage","buttonRef","useRef","style","current","copy","target","content","ref","PreformattedText","ReportsIcon","width","delay","position","useReducer","toasts","dispatch","hoveringId","setHovering","timeoutIdRefs","removeToast","useCallback","window","clearTimeout","Math","random","toString","substring","createToast","setTimeout","handleMouseEnter","toastId","Object","values","forEach","timeoutId","handleMouseLeave","undefined","contextValue","useMemo","Provider","value","length","slice","map","toastToShow","onMouseEnter","onMouseLeave","key"],"mappings":"2xBAWMA,EAAW,CACfC,QAASC,8BACTC,KAAMC,6B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SAzBSuE,EAyBYc,EAAY9D,GAzBH,WACxCqC,EAAYW,GACZK,MAwBUU,aAAchB,EAAiBe,EAAY9D,IAC3CgE,aAAcX,EACd/E,SAAU4D,IAAe4B,EAAY9D,GACrCiE,IAAKH,EAAY9D,IAEhB8D,EAAYtC,SA/BL,IAACwB,MAoChB5E"}
1
+ {"version":3,"file":"alert.cjs.production.min.js","sources":["../src/BaseAlertBox.tsx","../src/ToastAlertBox.tsx","../src/ToastProvider.tsx","../src/ExpandableAlertBox.tsx","../src/index.tsx","../src/BannerAlertBox.tsx","../src/CopyableText.tsx","../src/SmallAlertBox.tsx"],"sourcesContent":["import React from 'react';\nimport classNames from 'classnames';\nimport {\n CloseIcon,\n OutlinedValidationCheckIcon,\n OutlinedValidationExclamationIcon,\n OutlinedValidationInfoIcon,\n OutlinedValidationErrorIcon,\n} from '@entur/icons';\nimport './styles.scss';\n\nconst iconsMap = {\n success: OutlinedValidationCheckIcon,\n info: OutlinedValidationInfoIcon,\n warning: OutlinedValidationExclamationIcon,\n error: OutlinedValidationErrorIcon,\n};\n\ntype BaseAlertBoxProps = {\n /** Innholdet i alert-boksen */\n children?: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Skjermleser-label for lukkeknappen, om den vises\n * @default \"Lukk\"\n */\n closeButtonLabel?: string;\n /** Callback som kalles når man lukker boksen\n * @default () => {}\n */\n onClose?: () => void;\n /** Om denne er true, vil boksen få en lukkeknapp i høyre hjørne\n * @default false\n */\n closable?: boolean;\n /** Tittel på boksen - oppsummer virkning */\n title?: React.ReactNode;\n /** Farge og uttrykk på alert-boksen */\n variant: 'success' | 'info' | 'warning' | 'error';\n /** Typen boks (internt bruk) */\n size: 'banner' | 'toast' | 'small';\n [key: string]: any;\n};\n\nexport const BaseAlertBox: React.FC<BaseAlertBoxProps> = ({\n children,\n className,\n closable = false,\n closeButtonLabel = 'Lukk',\n variant,\n onClose = () => ({}),\n size,\n title,\n toastIsBeingRemoved,\n ...rest\n}) => {\n const [isClosed, setClosed] = React.useState(false);\n if (isClosed) {\n return null;\n }\n const handleClose = () => {\n setClosed(true);\n onClose();\n };\n const Icon = iconsMap[variant];\n return (\n <div\n className={classNames(\n 'eds-alert-box',\n `eds-alert-box--${size}`,\n `eds-alert-box--${variant}`,\n { 'eds-alert-box--toast--exit-animation': toastIsBeingRemoved },\n className,\n )}\n {...rest}\n >\n {closable && (\n <button\n aria-label={closeButtonLabel}\n className=\"eds-alert-box__close-button\"\n type=\"button\"\n onClick={handleClose}\n >\n <CloseIcon />\n </button>\n )}\n <Icon className=\"eds-alert-box__icon\" />\n <div\n className={classNames('eds-alert-box__content', {\n 'eds-alert-box__content--no-title': !title,\n 'eds-alert-box__content--no-children': !children,\n })}\n >\n {title && <div className=\"eds-alert-box__title\">{title}</div>}\n {children && children}\n </div>\n </div>\n );\n};\n","import React from 'react';\nimport { BaseAlertBox } from './BaseAlertBox';\n\nexport type ToastAlertBoxProps = {\n /** Innholdet i toasten */\n children?: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Skjermleser-label for lukkeknappen, om den vises */\n closeButtonLabel?: string;\n /** Callback som kalles når man lukker boksen */\n onClose?: () => void;\n /** Om denne er true, vil boksen få en lukkeknapp i høyre hjørne */\n closable?: boolean;\n /** Tittel på boksen - oppsummer virkning */\n title?: string;\n /** Farge og uttrykk på toasten */\n variant: 'success' | 'info';\n [key: string]: any;\n};\n\nexport const ToastAlertBox: React.FC<ToastAlertBoxProps> = props => (\n <BaseAlertBox {...props} size=\"toast\" role=\"status\" />\n);\n","import React from 'react';\nimport { ToastAlertBox } from './ToastAlertBox';\nimport classNames from 'classnames';\n\ntype ToastId = string;\n\ntype ToastVariants = 'success' | 'info';\n\ntype ToastType = {\n title?: string;\n content: React.ReactNode;\n id: ToastId;\n variant: ToastVariants;\n isBeingRemoved: boolean;\n};\n\ntype ToastContextType = {\n addToast: (payload: AddToastPayload) => void;\n removeToast: (id: ToastId) => void;\n toasts: ToastType[];\n};\n\ntype AddToastPayload =\n | { title?: string; content: React.ReactNode; variant?: ToastVariants }\n | string;\n\ntype ToastAction =\n | { type: 'ADD_TOAST'; payload: ToastType }\n | { type: 'REMOVE_TOAST'; payload: ToastId }\n | { type: 'PLAY_EXIT_ANIMATION'; payload: ToastId };\n\nconst EXIT_ANIMATION_TIME = 400;\n\nconst ToastContext = React.createContext<ToastContextType | null>(null);\n\nconst toastReducer = (\n prevToasts: ToastType[],\n action: ToastAction,\n): ToastType[] => {\n switch (action.type) {\n case 'ADD_TOAST':\n return [action.payload, ...prevToasts];\n case 'PLAY_EXIT_ANIMATION':\n return prevToasts.map(toast => {\n if (toast.id === action.payload)\n return { ...toast, isBeingRemoved: true };\n return toast;\n });\n case 'REMOVE_TOAST':\n return prevToasts.filter(toast => toast.id !== action.payload);\n }\n};\n\nconst createUniqueId = () => Math.random().toString().substring(2);\n\nconst createToast = (toast: AddToastPayload, id: ToastId): ToastType => {\n if (typeof toast === 'string') {\n return { id, content: toast, variant: 'success', isBeingRemoved: false };\n } else {\n return { id, variant: 'success', isBeingRemoved: false, ...toast };\n }\n};\n\nexport type ToastProviderProps = {\n /** Antall millisekunder før toasts forsvinner av seg selv\n * @default 6000\n */\n delay?: number;\n /** Plasseringen av toasts\n * @default \"bottom-right\"\n */\n position?: 'bottom-right' | 'top-right';\n /** Ekstra klassenavn til ToastProvider-wrapperen */\n className?: string;\n /** Ekstra styling som sendes til ToastProvider-wrapperen */\n style?: React.CSSProperties;\n};\n\nexport const ToastProvider: React.FC<ToastProviderProps> = ({\n delay = 6000,\n children,\n position = 'bottom-right',\n className,\n style,\n}) => {\n const [toasts, dispatch] = React.useReducer(toastReducer, []);\n const [hoveringId, setHovering] = React.useState<string>();\n const timeoutIdRefs = React.useRef<{ [key: string]: number }>({});\n\n const removeToast = React.useCallback((id: ToastId) => {\n window.clearTimeout(timeoutIdRefs.current[id]);\n dispatch({ type: 'REMOVE_TOAST', payload: id });\n delete timeoutIdRefs.current[id];\n }, []);\n\n const playExitAnimation = React.useCallback((id: ToastId) => {\n window.clearTimeout(timeoutIdRefs.current[id + 'animation']);\n dispatch({ type: 'PLAY_EXIT_ANIMATION', payload: id });\n delete timeoutIdRefs.current[id + 'animation'];\n }, []);\n\n const removeToastWithAnimationAfterDelay = React.useCallback(\n (id: ToastId, delay: number) => {\n timeoutIdRefs.current[id + 'animation'] = window.setTimeout(\n () => playExitAnimation(id),\n delay - EXIT_ANIMATION_TIME,\n );\n timeoutIdRefs.current[id] = window.setTimeout(\n () => removeToast(id),\n delay,\n );\n },\n [timeoutIdRefs, playExitAnimation, removeToast],\n );\n\n const addToast = React.useCallback(\n (toast: AddToastPayload) => {\n const id = createUniqueId();\n const payload = createToast(toast, id);\n dispatch({ type: 'ADD_TOAST', payload });\n removeToastWithAnimationAfterDelay(id, delay);\n },\n [delay, removeToastWithAnimationAfterDelay],\n );\n\n const handleMouseEnter = (toast: ToastType) => () => {\n if (toast.isBeingRemoved) return;\n setHovering(toast.id);\n Object.values(timeoutIdRefs.current).forEach(timeoutId => {\n window.clearTimeout(timeoutId);\n });\n timeoutIdRefs.current = {};\n };\n\n const handleMouseLeave = () => {\n setHovering(undefined);\n toasts.forEach(toast => {\n removeToastWithAnimationAfterDelay(toast.id, delay);\n });\n };\n\n const handleClose = (toastId: ToastId) => () => {\n removeToast(toastId);\n handleMouseLeave();\n };\n\n const contextValue = React.useMemo(\n () => ({ toasts, addToast, removeToast }),\n [addToast, removeToast, toasts],\n );\n\n return (\n <ToastContext.Provider value={contextValue}>\n {toasts.length > 0 && (\n <div\n className={classNames(\n 'eds-toast-container',\n `eds-toast-container--${position}`,\n className,\n )}\n style={style}\n >\n {toasts.slice(0, 3).map(toastToShow => (\n <ToastAlertBox\n variant={toastToShow.variant}\n title={toastToShow.title}\n onClose={handleClose(toastToShow.id)}\n onMouseEnter={handleMouseEnter(toastToShow)}\n onMouseLeave={handleMouseLeave}\n closable={hoveringId === toastToShow.id}\n toastIsBeingRemoved={toastToShow.isBeingRemoved}\n key={toastToShow.id}\n >\n {toastToShow.content}\n </ToastAlertBox>\n ))}\n </div>\n )}\n {children}\n </ToastContext.Provider>\n );\n};\n\nexport const useToast: () => {\n addToast: (payload: AddToastPayload) => void;\n} = () => {\n const context = React.useContext(ToastContext);\n if (!context) {\n throw new Error(\n 'You need to wrap your component in a ToastProvider component in ' +\n 'order to use the useToast hook',\n );\n }\n const { addToast } = context;\n return {\n addToast,\n };\n};\n","import { BaseExpand, ExpandArrow } from '@entur/expand/';\nimport classNames from 'classnames';\nimport React from 'react';\nimport { BannerAlertBoxProps } from './BannerAlertBox';\nimport { BaseAlertBox } from './BaseAlertBox';\nimport './ExpandableAlertBox.scss';\nimport { SmallAlertBoxProps } from './SmallAlertBox';\n\nexport type SmallExpandableAlertBoxProps = ExpandableAlertBoxProps &\n SmallAlertBoxProps;\n\nexport const SmallExpandableAlertBox: React.FC<SmallExpandableAlertBoxProps> = props => {\n return <ExpandableAlertBox size=\"small\" {...props} />;\n};\n\nexport type BannerExpandableAlertBoxProps = ExpandableAlertBoxProps &\n BannerAlertBoxProps;\n\nexport const BannerExpandableAlertBox: React.FC<BannerExpandableAlertBoxProps> = props => {\n return <ExpandableAlertBox size=\"banner\" {...props} />;\n};\n\ntype ExpandableAlertBoxProps = {\n /**Farge og uttrykk på alert-boksen */\n variant: 'success' | 'info' | 'warning' | 'error';\n /** Tittelen til ExpandableAlertBox */\n title: React.ReactNode;\n /**Innhold som vises ved ekspandering */\n children: React.ReactNode;\n /**Ekstra klassenavn */\n className?: string;\n /** Tekst som vises på ekspanderingsknappen før åpning\n * @default \"Les mer\"\n */\n openLabel?: string;\n /** Tekst som vises på ekspanderingsknappen når den er åpnet\n * @default \"Lukk\"\n */\n closeLabel?: string;\n [key: string]: any;\n};\n\nconst ExpandableAlertBox: React.FC<ExpandableAlertBoxProps> = ({\n variant,\n title,\n children,\n size,\n className,\n openLabel,\n closeLabel,\n ...rest\n}) => {\n const [open, setopen] = React.useState(false);\n return (\n <BaseAlertBox\n size={size}\n variant={variant}\n className={classNames('eds-expandable-alert-box', className)}\n title={\n <ExpandableAlertBoxTitle\n open={open}\n title={title}\n onClick={() => setopen(!open)}\n openLabel={openLabel}\n closeLabel={closeLabel}\n />\n }\n {...rest}\n >\n <BaseExpand open={open}>{children}</BaseExpand>\n </BaseAlertBox>\n );\n};\n\ntype ExpandableAlertBoxTitleProps = {\n title: React.ReactNode;\n open: boolean;\n openLabel?: string;\n closeLabel?: string;\n onClick: (e: React.MouseEvent) => void;\n};\n\nconst ExpandableAlertBoxTitle: React.FC<ExpandableAlertBoxTitleProps> = ({\n title,\n open,\n openLabel = 'Les mer',\n closeLabel = 'Lukk',\n onClick,\n}) => {\n return (\n <div className=\"eds-expandable-alert-box__title\">\n <div>{title}</div>\n <button\n className=\"eds-expandable-alert-box__button\"\n onClick={onClick}\n type=\"button\"\n >\n {open ? closeLabel : openLabel}\n <ExpandArrow open={open} inline />\n </button>\n </div>\n );\n};\n","import { warnAboutMissingStyles } from '@entur/utils';\nimport './index.scss';\n\nwarnAboutMissingStyles('alert', 'icons');\n\nexport { BannerAlertBox } from './BannerAlertBox';\nexport { ToastAlertBox } from './ToastAlertBox';\nexport { SmallAlertBox } from './SmallAlertBox';\nexport { ToastProvider, useToast } from './ToastProvider';\nexport { CopyableText } from './CopyableText';\nexport * from './ExpandableAlertBox';\n","import React from 'react';\nimport { BaseAlertBox } from './BaseAlertBox';\n\nexport type BannerAlertBoxProps = {\n /** Innholdet i alert-boksen */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Skjermleser-label for lukkeknappen, om den vises */\n closeButtonLabel?: string;\n /** Callback som kalles når man lukker boksen */\n onClose?: () => void;\n /** Om denne er true, vil boksen få en lukkeknapp i høyre hjørne\n * @default false\n */\n closable?: boolean;\n /** Tittel på boksen - oppsummer virkning */\n title?: string;\n /** Farge og uttrykk på alert-boksen */\n variant: 'success' | 'info' | 'warning' | 'error';\n [key: string]: any;\n};\n\nexport const BannerAlertBox: React.FC<BannerAlertBoxProps> = props => (\n <BaseAlertBox {...props} size=\"banner\" />\n);\n","import React from 'react';\n\nimport copy from 'copy-text-to-clipboard';\n\nimport { useToast } from './ToastProvider';\nimport { ReportsIcon } from '@entur/icons';\nimport { PreformattedText } from '@entur/typography';\n\nimport './CopyableText.scss';\n\nexport type CopyableTextProps = {\n /** Ekstra klassenavn */\n className?: string;\n /** Tekstinnhold som vises og kopieres */\n children: string;\n /** Overskrift i toast-varselet */\n successHeading?: string;\n /** Bekreftelsesmelding i toast-varselet */\n successMessage?: string;\n} & Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'children'>;\n\nexport const CopyableText = ({\n children,\n successHeading = 'Kopiert!',\n successMessage = 'Innholdet ble kopiert til utklippstavlen.',\n className,\n ...rest\n}: CopyableTextProps): JSX.Element => {\n const { addToast } = useToast();\n const buttonRef = React.useRef<HTMLButtonElement>(null);\n const handleClick = () => {\n buttonRef.current &&\n copy(children, {\n target: buttonRef.current,\n }) &&\n addToast({ title: successHeading, content: successMessage });\n };\n return (\n <button\n className={'copyable-text ' + className}\n style={{ ...rest.style }}\n type=\"button\"\n onClick={handleClick}\n ref={buttonRef}\n aria-label=\"Kopier innhold\"\n {...rest}\n >\n <PreformattedText>{children}</PreformattedText>\n <ReportsIcon className=\"copyable-text__icon\" />\n </button>\n );\n};\n","import React from 'react';\nimport classNames from 'classnames';\nimport { BaseAlertBox } from './BaseAlertBox';\n\nexport type SmallAlertBoxProps = {\n /** Innholdet i alert-boksen */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Skjermleser-label for lukkeknappen, om den vises */\n closeButtonLabel?: string;\n /** Om denne er true, vil boksen få en lukkeknapp i høyre hjørne\n * @default false\n */\n closable?: boolean;\n /** Callback som kalles når man lukker boksen */\n onClose?: () => void;\n /** Tittel på boksen - oppsummer virkning */\n title?: string;\n /** Bredden på boksen - fullbredde eller tilpasset innholdet */\n width?: 'fluid' | 'fit-content';\n /** Farge og uttrykk på alert-boksen */\n variant: 'success' | 'info' | 'warning' | 'error';\n [key: string]: any;\n};\n\nexport const SmallAlertBox: React.FC<SmallAlertBoxProps> = ({\n className,\n width,\n onClose,\n closable = false,\n closeButtonLabel,\n ...rest\n}) => (\n <BaseAlertBox\n className={classNames(className, {\n 'eds-alert-box--fit-content': width === 'fit-content',\n })}\n {...rest}\n onClose={onClose}\n closable={closable}\n closeButtonLabel={closeButtonLabel}\n size=\"small\"\n />\n);\n"],"names":["iconsMap","success","OutlinedValidationCheckIcon","info","OutlinedValidationInfoIcon","warning","OutlinedValidationExclamationIcon","error","OutlinedValidationErrorIcon","BaseAlertBox","children","className","closable","closeButtonLabel","variant","onClose","size","title","toastIsBeingRemoved","rest","React","useState","setClosed","Icon","classNames","type","onClick","CloseIcon","ToastAlertBox","props","role","ToastContext","createContext","toastReducer","prevToasts","action","payload","map","toast","id","isBeingRemoved","filter","useToast","context","useContext","Error","addToast","ExpandableAlertBox","openLabel","closeLabel","open","setopen","ExpandableAlertBoxTitle","BaseExpand","ExpandArrow","inline","warnAboutMissingStyles","successHeading","successMessage","buttonRef","useRef","style","current","copy","target","content","ref","PreformattedText","ReportsIcon","width","delay","position","useReducer","toasts","dispatch","hoveringId","setHovering","timeoutIdRefs","removeToast","useCallback","window","clearTimeout","playExitAnimation","removeToastWithAnimationAfterDelay","setTimeout","Math","random","toString","substring","createToast","handleMouseLeave","undefined","forEach","contextValue","useMemo","Provider","value","length","slice","toastToShow","toastId","onMouseEnter","Object","values","timeoutId","onMouseLeave","key"],"mappings":"izBAWMA,EAAW,CACfC,QAASC,8BACTC,KAAMC,6BACNC,QAASC,oCACTC,MAAOC,+BA6BIC,EAA4C,gBACvDC,IAAAA,SACAC,IAAAA,cACAC,SAAAA,oBACAC,iBAAAA,aAAmB,SACnBC,IAAAA,YACAC,QAAAA,aAAU,iBAAO,MACjBC,IAAAA,KACAC,IAAAA,MACAC,IAAAA,oBACGC,WAE2BC,UAAMC,UAAS,GAA5BC,sBAER,SAMHC,EAAO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I,SAAA8D,UACtB/E,wBAACQ,GACCd,QAASqF,EAAYrF,QACrBG,MAAOkF,EAAYlF,MACnBF,SAzBSqF,EAyBYD,EAAY5D,GAzBH,WACxCuC,EAAYsB,GACZV,MAwBUW,cA1Cc/D,EA0CiB6D,EA1CI,WACzC7D,EAAME,iBACVoC,EAAYtC,EAAMC,IAClB+D,OAAOC,OAAO1B,EAAcf,SAAS8B,SAAQ,SAAAY,GAC3CxB,OAAOC,aAAauB,MAEtB3B,EAAcf,QAAU,MAqCd2C,aAAcf,EACd9E,SAAU+D,IAAewB,EAAY5D,GACrCrB,oBAAqBiF,EAAY3D,eACjCkE,IAAKP,EAAY5D,IAEhB4D,EAAYlC,SAhDA,IAAC3B,EAgBL8D,MAqChB1F"}
package/dist/alert.esm.js CHANGED
@@ -39,7 +39,7 @@ function _objectWithoutPropertiesLoose(source, excluded) {
39
39
  return target;
40
40
  }
41
41
 
42
- var _excluded$3 = ["children", "className", "closable", "closeButtonLabel", "variant", "onClose", "size", "title"];
42
+ var _excluded$3 = ["children", "className", "closable", "closeButtonLabel", "variant", "onClose", "size", "title", "toastIsBeingRemoved"];
43
43
  var iconsMap = {
44
44
  success: OutlinedValidationCheckIcon,
45
45
  info: OutlinedValidationInfoIcon,
@@ -60,6 +60,7 @@ var BaseAlertBox = function BaseAlertBox(_ref) {
60
60
  } : _ref$onClose,
61
61
  size = _ref.size,
62
62
  title = _ref.title,
63
+ toastIsBeingRemoved = _ref.toastIsBeingRemoved,
63
64
  rest = _objectWithoutPropertiesLoose(_ref, _excluded$3);
64
65
 
65
66
  var _React$useState = React.useState(false),
@@ -77,7 +78,9 @@ var BaseAlertBox = function BaseAlertBox(_ref) {
77
78
 
78
79
  var Icon = iconsMap[variant];
79
80
  return React.createElement("div", _extends({
80
- className: classNames('eds-alert-box', "eds-alert-box--" + size, "eds-alert-box--" + variant, className)
81
+ className: classNames('eds-alert-box', "eds-alert-box--" + size, "eds-alert-box--" + variant, {
82
+ 'eds-alert-box--toast--exit-animation': toastIsBeingRemoved
83
+ }, className)
81
84
  }, rest), closable && React.createElement("button", {
82
85
  "aria-label": closeButtonLabel,
83
86
  className: "eds-alert-box__close-button",
@@ -130,6 +133,7 @@ var SmallAlertBox = function SmallAlertBox(_ref) {
130
133
  }));
131
134
  };
132
135
 
136
+ var EXIT_ANIMATION_TIME = 400;
133
137
  var ToastContext = /*#__PURE__*/React.createContext(null);
134
138
 
135
139
  var toastReducer = function toastReducer(prevToasts, action) {
@@ -137,6 +141,14 @@ var toastReducer = function toastReducer(prevToasts, action) {
137
141
  case 'ADD_TOAST':
138
142
  return [action.payload].concat(prevToasts);
139
143
 
144
+ case 'PLAY_EXIT_ANIMATION':
145
+ return prevToasts.map(function (toast) {
146
+ if (toast.id === action.payload) return _extends({}, toast, {
147
+ isBeingRemoved: true
148
+ });
149
+ return toast;
150
+ });
151
+
140
152
  case 'REMOVE_TOAST':
141
153
  return prevToasts.filter(function (toast) {
142
154
  return toast.id !== action.payload;
@@ -153,12 +165,14 @@ var createToast = function createToast(toast, id) {
153
165
  return {
154
166
  id: id,
155
167
  content: toast,
156
- variant: 'success'
168
+ variant: 'success',
169
+ isBeingRemoved: false
157
170
  };
158
171
  } else {
159
172
  return _extends({
160
173
  id: id,
161
- variant: 'success'
174
+ variant: 'success',
175
+ isBeingRemoved: false
162
176
  }, toast);
163
177
  }
164
178
  };
@@ -189,6 +203,22 @@ var ToastProvider = function ToastProvider(_ref) {
189
203
  });
190
204
  delete timeoutIdRefs.current[id];
191
205
  }, []);
206
+ var playExitAnimation = React.useCallback(function (id) {
207
+ window.clearTimeout(timeoutIdRefs.current[id + 'animation']);
208
+ dispatch({
209
+ type: 'PLAY_EXIT_ANIMATION',
210
+ payload: id
211
+ });
212
+ delete timeoutIdRefs.current[id + 'animation'];
213
+ }, []);
214
+ var removeToastWithAnimationAfterDelay = React.useCallback(function (id, delay) {
215
+ timeoutIdRefs.current[id + 'animation'] = window.setTimeout(function () {
216
+ return playExitAnimation(id);
217
+ }, delay - EXIT_ANIMATION_TIME);
218
+ timeoutIdRefs.current[id] = window.setTimeout(function () {
219
+ return removeToast(id);
220
+ }, delay);
221
+ }, [timeoutIdRefs, playExitAnimation, removeToast]);
192
222
  var addToast = React.useCallback(function (toast) {
193
223
  var id = createUniqueId();
194
224
  var payload = createToast(toast, id);
@@ -196,16 +226,15 @@ var ToastProvider = function ToastProvider(_ref) {
196
226
  type: 'ADD_TOAST',
197
227
  payload: payload
198
228
  });
199
- timeoutIdRefs.current[id] = window.setTimeout(function () {
200
- return removeToast(id);
201
- }, delay);
202
- }, [delay, removeToast]);
229
+ removeToastWithAnimationAfterDelay(id, delay);
230
+ }, [delay, removeToastWithAnimationAfterDelay]);
203
231
 
204
- var handleMouseEnter = function handleMouseEnter(toastId) {
232
+ var handleMouseEnter = function handleMouseEnter(toast) {
205
233
  return function () {
206
- setHovering(toastId);
234
+ if (toast.isBeingRemoved) return;
235
+ setHovering(toast.id);
207
236
  Object.values(timeoutIdRefs.current).forEach(function (timeoutId) {
208
- return window.clearTimeout(timeoutId);
237
+ window.clearTimeout(timeoutId);
209
238
  });
210
239
  timeoutIdRefs.current = {};
211
240
  };
@@ -214,9 +243,7 @@ var ToastProvider = function ToastProvider(_ref) {
214
243
  var handleMouseLeave = function handleMouseLeave() {
215
244
  setHovering(undefined);
216
245
  toasts.forEach(function (toast) {
217
- timeoutIdRefs.current[toast.id] = window.setTimeout(function () {
218
- return removeToast(toast.id);
219
- }, delay);
246
+ removeToastWithAnimationAfterDelay(toast.id, delay);
220
247
  });
221
248
  };
222
249
 
@@ -244,9 +271,10 @@ var ToastProvider = function ToastProvider(_ref) {
244
271
  variant: toastToShow.variant,
245
272
  title: toastToShow.title,
246
273
  onClose: handleClose(toastToShow.id),
247
- onMouseEnter: handleMouseEnter(toastToShow.id),
274
+ onMouseEnter: handleMouseEnter(toastToShow),
248
275
  onMouseLeave: handleMouseLeave,
249
276
  closable: hoveringId === toastToShow.id,
277
+ toastIsBeingRemoved: toastToShow.isBeingRemoved,
250
278
  key: toastToShow.id
251
279
  }, toastToShow.content);
252
280
  })), children);
@@ -1 +1 @@
1
- {"version":3,"file":"alert.esm.js","sources":["../src/BaseAlertBox.tsx","../src/BannerAlertBox.tsx","../src/ToastAlertBox.tsx","../src/SmallAlertBox.tsx","../src/ToastProvider.tsx","../src/CopyableText.tsx","../src/ExpandableAlertBox.tsx","../src/index.tsx"],"sourcesContent":["import React from 'react';\nimport classNames from 'classnames';\nimport {\n CloseIcon,\n OutlinedValidationCheckIcon,\n OutlinedValidationExclamationIcon,\n OutlinedValidationInfoIcon,\n OutlinedValidationErrorIcon,\n} from '@entur/icons';\nimport './styles.scss';\n\nconst iconsMap = {\n success: OutlinedValidationCheckIcon,\n info: OutlinedValidationInfoIcon,\n warning: OutlinedValidationExclamationIcon,\n error: OutlinedValidationErrorIcon,\n};\n\ntype BaseAlertBoxProps = {\n /** Innholdet i alert-boksen */\n children?: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Skjermleser-label for lukkeknappen, om den vises\n * @default \"Lukk\"\n */\n closeButtonLabel?: string;\n /** Callback som kalles når man lukker boksen\n * @default () => {}\n */\n onClose?: () => void;\n /** Om denne er true, vil boksen få en lukkeknapp i høyre hjørne\n * @default false\n */\n closable?: boolean;\n /** Tittel på boksen - oppsummer virkning */\n title?: React.ReactNode;\n /** Farge og uttrykk på alert-boksen */\n variant: 'success' | 'info' | 'warning' | 'error';\n /** Typen boks (internt bruk) */\n size: 'banner' | 'toast' | 'small';\n [key: string]: any;\n};\n\nexport const BaseAlertBox: React.FC<BaseAlertBoxProps> = ({\n children,\n className,\n closable = false,\n closeButtonLabel = 'Lukk',\n variant,\n onClose = () => ({}),\n size,\n title,\n ...rest\n}) => {\n const [isClosed, setClosed] = React.useState(false);\n if (isClosed) {\n return null;\n }\n const handleClose = () => {\n setClosed(true);\n onClose();\n };\n const Icon = iconsMap[variant];\n return (\n <div\n className={classNames(\n 'eds-alert-box',\n `eds-alert-box--${size}`,\n `eds-alert-box--${variant}`,\n className,\n )}\n {...rest}\n >\n {closable && (\n <button\n aria-label={closeButtonLabel}\n className=\"eds-alert-box__close-button\"\n type=\"button\"\n onClick={handleClose}\n >\n <CloseIcon />\n </button>\n )}\n <Icon className=\"eds-alert-box__icon\" />\n <div\n className={classNames('eds-alert-box__content', {\n 'eds-alert-box__content--no-title': !title,\n 'eds-alert-box__content--no-children': !children,\n })}\n >\n {title && <div className=\"eds-alert-box__title\">{title}</div>}\n {children && children}\n </div>\n </div>\n );\n};\n","import React from 'react';\nimport { BaseAlertBox } from './BaseAlertBox';\n\nexport type BannerAlertBoxProps = {\n /** Innholdet i alert-boksen */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Skjermleser-label for lukkeknappen, om den vises */\n closeButtonLabel?: string;\n /** Callback som kalles når man lukker boksen */\n onClose?: () => void;\n /** Om denne er true, vil boksen få en lukkeknapp i høyre hjørne\n * @default false\n */\n closable?: boolean;\n /** Tittel på boksen - oppsummer virkning */\n title?: string;\n /** Farge og uttrykk på alert-boksen */\n variant: 'success' | 'info' | 'warning' | 'error';\n [key: string]: any;\n};\n\nexport const BannerAlertBox: React.FC<BannerAlertBoxProps> = props => (\n <BaseAlertBox {...props} size=\"banner\" />\n);\n","import React from 'react';\nimport { BaseAlertBox } from './BaseAlertBox';\n\nexport type ToastAlertBoxProps = {\n /** Innholdet i toasten */\n children?: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Skjermleser-label for lukkeknappen, om den vises */\n closeButtonLabel?: string;\n /** Callback som kalles når man lukker boksen */\n onClose?: () => void;\n /** Om denne er true, vil boksen få en lukkeknapp i høyre hjørne */\n closable?: boolean;\n /** Tittel på boksen - oppsummer virkning */\n title?: string;\n /** Farge og uttrykk på toasten */\n variant: 'success' | 'info';\n [key: string]: any;\n};\n\nexport const ToastAlertBox: React.FC<ToastAlertBoxProps> = props => (\n <BaseAlertBox {...props} size=\"toast\" role=\"status\" />\n);\n","import React from 'react';\nimport classNames from 'classnames';\nimport { BaseAlertBox } from './BaseAlertBox';\n\nexport type SmallAlertBoxProps = {\n /** Innholdet i alert-boksen */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Skjermleser-label for lukkeknappen, om den vises */\n closeButtonLabel?: string;\n /** Om denne er true, vil boksen få en lukkeknapp i høyre hjørne\n * @default false\n */\n closable?: boolean;\n /** Callback som kalles når man lukker boksen */\n onClose?: () => void;\n /** Tittel på boksen - oppsummer virkning */\n title?: string;\n /** Bredden på boksen - fullbredde eller tilpasset innholdet */\n width?: 'fluid' | 'fit-content';\n /** Farge og uttrykk på alert-boksen */\n variant: 'success' | 'info' | 'warning' | 'error';\n [key: string]: any;\n};\n\nexport const SmallAlertBox: React.FC<SmallAlertBoxProps> = ({\n className,\n width,\n onClose,\n closable = false,\n closeButtonLabel,\n ...rest\n}) => (\n <BaseAlertBox\n className={classNames(className, {\n 'eds-alert-box--fit-content': width === 'fit-content',\n })}\n {...rest}\n onClose={onClose}\n closable={closable}\n closeButtonLabel={closeButtonLabel}\n size=\"small\"\n />\n);\n","import React from 'react';\nimport { ToastAlertBox } from './ToastAlertBox';\nimport classNames from 'classnames';\n\ntype ToastId = string;\n\ntype ToastVariants = 'success' | 'info';\n\ntype ToastType = {\n title?: string;\n content: React.ReactNode;\n id: ToastId;\n variant: ToastVariants;\n};\n\ntype ToastContextType = {\n addToast: (payload: AddToastPayload) => void;\n removeToast: (id: ToastId) => void;\n toasts: ToastType[];\n};\n\ntype AddToastPayload =\n | { title?: string; content: React.ReactNode; variant?: ToastVariants }\n | string;\n\ntype ToastAction =\n | { type: 'ADD_TOAST'; payload: ToastType }\n | { type: 'REMOVE_TOAST'; payload: ToastId };\n\nconst ToastContext = React.createContext<ToastContextType | null>(null);\n\nconst toastReducer = (\n prevToasts: ToastType[],\n action: ToastAction,\n): ToastType[] => {\n switch (action.type) {\n case 'ADD_TOAST':\n return [action.payload, ...prevToasts];\n case 'REMOVE_TOAST':\n return prevToasts.filter(toast => toast.id !== action.payload);\n }\n};\n\nconst createUniqueId = () => Math.random().toString().substring(2);\n\nconst createToast = (toast: AddToastPayload, id: ToastId): ToastType => {\n if (typeof toast === 'string') {\n return { id, content: toast, variant: 'success' };\n } else {\n return { id, variant: 'success', ...toast };\n }\n};\n\nexport type ToastProviderProps = {\n /** Antall millisekunder før toasts forsvinner av seg selv\n * @default 6000\n */\n delay?: number;\n /** Plasseringen av toasts\n * @default \"bottom-right\"\n */\n position?: 'bottom-right' | 'top-right';\n /** Ekstra klassenavn til ToastProvider-wrapperen */\n className?: string;\n /** Ekstra styling som sendes til ToastProvider-wrapperen */\n style?: React.CSSProperties;\n};\n\nexport const ToastProvider: React.FC<ToastProviderProps> = ({\n delay = 6000,\n children,\n position = 'bottom-right',\n className,\n style,\n}) => {\n const [toasts, dispatch] = React.useReducer(toastReducer, []);\n const [hoveringId, setHovering] = React.useState<string>();\n const timeoutIdRefs = React.useRef<{ [key: string]: number }>({});\n\n const removeToast = React.useCallback((id: ToastId) => {\n window.clearTimeout(timeoutIdRefs.current[id]);\n dispatch({ type: 'REMOVE_TOAST', payload: id });\n delete timeoutIdRefs.current[id];\n }, []);\n\n const addToast = React.useCallback(\n (toast: AddToastPayload) => {\n const id = createUniqueId();\n const payload = createToast(toast, id);\n dispatch({ type: 'ADD_TOAST', payload });\n timeoutIdRefs.current[id] = window.setTimeout(\n () => removeToast(id),\n delay,\n );\n },\n [delay, removeToast],\n );\n\n const handleMouseEnter = (toastId: ToastId) => () => {\n setHovering(toastId);\n Object.values(timeoutIdRefs.current).forEach(timeoutId =>\n window.clearTimeout(timeoutId),\n );\n timeoutIdRefs.current = {};\n };\n\n const handleMouseLeave = () => {\n setHovering(undefined);\n toasts.forEach(toast => {\n timeoutIdRefs.current[toast.id] = window.setTimeout(\n () => removeToast(toast.id),\n delay,\n );\n });\n };\n\n const handleClose = (toastId: ToastId) => () => {\n removeToast(toastId);\n handleMouseLeave();\n };\n\n const contextValue = React.useMemo(\n () => ({ toasts, addToast, removeToast }),\n [addToast, removeToast, toasts],\n );\n\n return (\n <ToastContext.Provider value={contextValue}>\n {toasts.length > 0 && (\n <div\n className={classNames(\n 'eds-toast-container',\n `eds-toast-container--${position}`,\n className,\n )}\n style={style}\n >\n {toasts.slice(0, 3).map(toastToShow => (\n <ToastAlertBox\n variant={toastToShow.variant}\n title={toastToShow.title}\n onClose={handleClose(toastToShow.id)}\n onMouseEnter={handleMouseEnter(toastToShow.id)}\n onMouseLeave={handleMouseLeave}\n closable={hoveringId === toastToShow.id}\n key={toastToShow.id}\n >\n {toastToShow.content}\n </ToastAlertBox>\n ))}\n </div>\n )}\n {children}\n </ToastContext.Provider>\n );\n};\n\nexport const useToast: () => {\n addToast: (payload: AddToastPayload) => void;\n} = () => {\n const context = React.useContext(ToastContext);\n if (!context) {\n throw new Error(\n 'You need to wrap your component in a ToastProvider component in ' +\n 'order to use the useToast hook',\n );\n }\n const { addToast } = context;\n return {\n addToast,\n };\n};\n","import React from 'react';\n\nimport copy from 'copy-text-to-clipboard';\n\nimport { useToast } from './ToastProvider';\nimport { ReportsIcon } from '@entur/icons';\nimport { PreformattedText } from '@entur/typography';\n\nimport './CopyableText.scss';\n\nexport type CopyableTextProps = {\n /** Ekstra klassenavn */\n className?: string;\n /** Tekstinnhold som vises og kopieres */\n children: string;\n /** Overskrift i toast-varselet */\n successHeading?: string;\n /** Bekreftelsesmelding i toast-varselet */\n successMessage?: string;\n} & Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'children'>;\n\nexport const CopyableText = ({\n children,\n successHeading = 'Kopiert!',\n successMessage = 'Innholdet ble kopiert til utklippstavlen.',\n className,\n ...rest\n}: CopyableTextProps): JSX.Element => {\n const { addToast } = useToast();\n const buttonRef = React.useRef<HTMLButtonElement>(null);\n const handleClick = () => {\n buttonRef.current &&\n copy(children, {\n target: buttonRef.current,\n }) &&\n addToast({ title: successHeading, content: successMessage });\n };\n return (\n <button\n className={'copyable-text ' + className}\n style={{ ...rest.style }}\n type=\"button\"\n onClick={handleClick}\n ref={buttonRef}\n aria-label=\"Kopier innhold\"\n {...rest}\n >\n <PreformattedText>{children}</PreformattedText>\n <ReportsIcon className=\"copyable-text__icon\" />\n </button>\n );\n};\n","import { BaseExpand, ExpandArrow } from '@entur/expand/';\nimport classNames from 'classnames';\nimport React from 'react';\nimport { BannerAlertBoxProps } from './BannerAlertBox';\nimport { BaseAlertBox } from './BaseAlertBox';\nimport './ExpandableAlertBox.scss';\nimport { SmallAlertBoxProps } from './SmallAlertBox';\n\nexport type SmallExpandableAlertBoxProps = ExpandableAlertBoxProps &\n SmallAlertBoxProps;\n\nexport const SmallExpandableAlertBox: React.FC<SmallExpandableAlertBoxProps> = props => {\n return <ExpandableAlertBox size=\"small\" {...props} />;\n};\n\nexport type BannerExpandableAlertBoxProps = ExpandableAlertBoxProps &\n BannerAlertBoxProps;\n\nexport const BannerExpandableAlertBox: React.FC<BannerExpandableAlertBoxProps> = props => {\n return <ExpandableAlertBox size=\"banner\" {...props} />;\n};\n\ntype ExpandableAlertBoxProps = {\n /**Farge og uttrykk på alert-boksen */\n variant: 'success' | 'info' | 'warning' | 'error';\n /** Tittelen til ExpandableAlertBox */\n title: React.ReactNode;\n /**Innhold som vises ved ekspandering */\n children: React.ReactNode;\n /**Ekstra klassenavn */\n className?: string;\n /** Tekst som vises på ekspanderingsknappen før åpning\n * @default \"Les mer\"\n */\n openLabel?: string;\n /** Tekst som vises på ekspanderingsknappen når den er åpnet\n * @default \"Lukk\"\n */\n closeLabel?: string;\n [key: string]: any;\n};\n\nconst ExpandableAlertBox: React.FC<ExpandableAlertBoxProps> = ({\n variant,\n title,\n children,\n size,\n className,\n openLabel,\n closeLabel,\n ...rest\n}) => {\n const [open, setopen] = React.useState(false);\n return (\n <BaseAlertBox\n size={size}\n variant={variant}\n className={classNames('eds-expandable-alert-box', className)}\n title={\n <ExpandableAlertBoxTitle\n open={open}\n title={title}\n onClick={() => setopen(!open)}\n openLabel={openLabel}\n closeLabel={closeLabel}\n />\n }\n {...rest}\n >\n <BaseExpand open={open}>{children}</BaseExpand>\n </BaseAlertBox>\n );\n};\n\ntype ExpandableAlertBoxTitleProps = {\n title: React.ReactNode;\n open: boolean;\n openLabel?: string;\n closeLabel?: string;\n onClick: (e: React.MouseEvent) => void;\n};\n\nconst ExpandableAlertBoxTitle: React.FC<ExpandableAlertBoxTitleProps> = ({\n title,\n open,\n openLabel = 'Les mer',\n closeLabel = 'Lukk',\n onClick,\n}) => {\n return (\n <div className=\"eds-expandable-alert-box__title\">\n <div>{title}</div>\n <button\n className=\"eds-expandable-alert-box__button\"\n onClick={onClick}\n type=\"button\"\n >\n {open ? closeLabel : openLabel}\n <ExpandArrow open={open} inline />\n </button>\n </div>\n );\n};\n","import { warnAboutMissingStyles } from '@entur/utils';\nimport './index.scss';\n\nwarnAboutMissingStyles('alert', 'icons');\n\nexport { BannerAlertBox } from './BannerAlertBox';\nexport { ToastAlertBox } from './ToastAlertBox';\nexport { SmallAlertBox } from './SmallAlertBox';\nexport { ToastProvider, useToast } from './ToastProvider';\nexport { CopyableText } from './CopyableText';\nexport * from './ExpandableAlertBox';\n"],"names":["iconsMap","success","OutlinedValidationCheckIcon","info","OutlinedValidationInfoIcon","warning","OutlinedValidationExclamationIcon","error","OutlinedValidationErrorIcon","BaseAlertBox","children","className","closable","closeButtonLabel","variant","onClose","size","title","rest","React","useState","isClosed","setClosed","handleClose","Icon","classNames","type","onClick","CloseIcon","BannerAlertBox","props","ToastAlertBox","role","SmallAlertBox","width","ToastContext","createContext","toastReducer","prevToasts","action","payload","filter","toast","id","createUniqueId","Math","random","toString","substring","createToast","content","ToastProvider","delay","position","style","useReducer","toasts","dispatch","hoveringId","setHovering","timeoutIdRefs","useRef","removeToast","useCallback","window","clearTimeout","current","addToast","setTimeout","handleMouseEnter","toastId","Object","values","forEach","timeoutId","handleMouseLeave","undefined","contextValue","useMemo","Provider","value","length","slice","map","toastToShow","onMouseEnter","onMouseLeave","key","useToast","context","useContext","Error","CopyableText","successHeading","successMessage","buttonRef","handleClick","copy","target","ref","PreformattedText","ReportsIcon","SmallExpandableAlertBox","ExpandableAlertBox","BannerExpandableAlertBox","openLabel","closeLabel","open","setopen","ExpandableAlertBoxTitle","BaseExpand","ExpandArrow","inline","warnAboutMissingStyles"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,IAAMA,QAAQ,GAAG;AACfC,EAAAA,OAAO,EAAEC,2BADM;AAEfC,EAAAA,IAAI,EAAEC,0BAFS;AAGfC,EAAAA,OAAO,EAAEC,iCAHM;AAIfC,EAAAA,KAAK,EAAEC;AAJQ,CAAjB;AAiCO,IAAMC,YAAY,GAAgC,SAA5CA,YAA4C;MACvDC,gBAAAA;MACAC,iBAAAA;2BACAC;MAAAA,sCAAW;mCACXC;MAAAA,sDAAmB;MACnBC,eAAAA;0BACAC;MAAAA,oCAAU;AAAA,WAAO,EAAP;AAAA;MACVC,YAAAA;MACAC,aAAAA;MACGC;;AAEH,wBAA8BC,KAAK,CAACC,QAAN,CAAe,KAAf,CAA9B;AAAA,MAAOC,QAAP;AAAA,MAAiBC,SAAjB;;AACA,MAAID,QAAJ,EAAc;AACZ,WAAO,IAAP;AACD;;AACD,MAAME,WAAW,GAAG,SAAdA,WAAc;AAClBD,IAAAA,SAAS,CAAC,IAAD,CAAT;AACAP,IAAAA,OAAO;AACR,GAHD;;AAIA,MAAMS,IAAI,GAAGxB,QAAQ,CAACc,OAAD,CAArB;AACA,SACEK,mBAAA,MAAA;AACER,IAAAA,SAAS,EAAEc,UAAU,CACnB,eADmB,sBAEDT,IAFC,sBAGDF,OAHC,EAInBH,SAJmB;AADvB,KAOMO,IAPN,GASGN,QAAQ,IACPO,mBAAA,SAAA;kBACcN;AACZF,IAAAA,SAAS,EAAC;AACVe,IAAAA,IAAI,EAAC;AACLC,IAAAA,OAAO,EAAEJ;GAJX,EAMEJ,mBAAA,CAACS,SAAD,MAAA,CANF,CAVJ,EAm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CAACD,IAAF,CAAb;AAAA;AACTF,MAAAA,SAAS,EAAEA;AACXC,MAAAA,UAAU,EAAEA;KALd;AALJ,KAaMxF,IAbN,GAeEC,mBAAA,CAAC2F,UAAD;AAAYH,IAAAA,IAAI,EAAEA;GAAlB,EAAyBjG,QAAzB,CAfF,CADF;AAmBD,CA9BD;;AAwCA,IAAMmG,uBAAuB,GAA2C,SAAlEA,uBAAkE;MACtE5F,cAAAA;MACA0F,aAAAA;8BACAF;MAAAA,yCAAY;+BACZC;MAAAA,2CAAa;MACb/E,gBAAAA;AAEA,SACER,mBAAA,MAAA;AAAKR,IAAAA,SAAS,EAAC;GAAf,EACEQ,mBAAA,MAAA,MAAA,EAAMF,KAAN,CADF,EAEEE,mBAAA,SAAA;AACER,IAAAA,SAAS,EAAC;AACVgB,IAAAA,OAAO,EAAEA;AACTD,IAAAA,IAAI,EAAC;GAHP,EAKGiF,IAAI,GAAGD,UAAH,GAAgBD,SALvB,EAMEtF,mBAAA,CAAC4F,WAAD;AAAaJ,IAAAA,IAAI,EAAEA;AAAMK,IAAAA,MAAM;GAA/B,CANF,CAFF,CADF;AAaD,CApBD;;AC/EAC,sBAAsB,CAAC,OAAD,EAAU,OAAV,CAAtB;;;;"}
1
+ {"version":3,"file":"alert.esm.js","sources":["../src/BaseAlertBox.tsx","../src/BannerAlertBox.tsx","../src/ToastAlertBox.tsx","../src/SmallAlertBox.tsx","../src/ToastProvider.tsx","../src/CopyableText.tsx","../src/ExpandableAlertBox.tsx","../src/index.tsx"],"sourcesContent":["import React from 'react';\nimport classNames from 'classnames';\nimport {\n CloseIcon,\n OutlinedValidationCheckIcon,\n OutlinedValidationExclamationIcon,\n OutlinedValidationInfoIcon,\n OutlinedValidationErrorIcon,\n} from '@entur/icons';\nimport './styles.scss';\n\nconst iconsMap = {\n success: OutlinedValidationCheckIcon,\n info: OutlinedValidationInfoIcon,\n warning: OutlinedValidationExclamationIcon,\n error: OutlinedValidationErrorIcon,\n};\n\ntype BaseAlertBoxProps = {\n /** Innholdet i alert-boksen */\n children?: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Skjermleser-label for lukkeknappen, om den vises\n * @default \"Lukk\"\n */\n closeButtonLabel?: string;\n /** Callback som kalles når man lukker boksen\n * @default () => {}\n */\n onClose?: () => void;\n /** Om denne er true, vil boksen få en lukkeknapp i høyre hjørne\n * @default false\n */\n closable?: boolean;\n /** Tittel på boksen - oppsummer virkning */\n title?: React.ReactNode;\n /** Farge og uttrykk på alert-boksen */\n variant: 'success' | 'info' | 'warning' | 'error';\n /** Typen boks (internt bruk) */\n size: 'banner' | 'toast' | 'small';\n [key: string]: any;\n};\n\nexport const BaseAlertBox: React.FC<BaseAlertBoxProps> = ({\n children,\n className,\n closable = false,\n closeButtonLabel = 'Lukk',\n variant,\n onClose = () => ({}),\n size,\n title,\n toastIsBeingRemoved,\n ...rest\n}) => {\n const [isClosed, setClosed] = React.useState(false);\n if (isClosed) {\n return null;\n }\n const handleClose = () => {\n setClosed(true);\n onClose();\n };\n const Icon = iconsMap[variant];\n return (\n <div\n className={classNames(\n 'eds-alert-box',\n `eds-alert-box--${size}`,\n `eds-alert-box--${variant}`,\n { 'eds-alert-box--toast--exit-animation': toastIsBeingRemoved },\n className,\n )}\n {...rest}\n >\n {closable && (\n <button\n aria-label={closeButtonLabel}\n className=\"eds-alert-box__close-button\"\n type=\"button\"\n onClick={handleClose}\n >\n <CloseIcon />\n </button>\n )}\n <Icon className=\"eds-alert-box__icon\" />\n <div\n className={classNames('eds-alert-box__content', {\n 'eds-alert-box__content--no-title': !title,\n 'eds-alert-box__content--no-children': !children,\n })}\n >\n {title && <div className=\"eds-alert-box__title\">{title}</div>}\n {children && children}\n </div>\n </div>\n );\n};\n","import React from 'react';\nimport { BaseAlertBox } from './BaseAlertBox';\n\nexport type BannerAlertBoxProps = {\n /** Innholdet i alert-boksen */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Skjermleser-label for lukkeknappen, om den vises */\n closeButtonLabel?: string;\n /** Callback som kalles når man lukker boksen */\n onClose?: () => void;\n /** Om denne er true, vil boksen få en lukkeknapp i høyre hjørne\n * @default false\n */\n closable?: boolean;\n /** Tittel på boksen - oppsummer virkning */\n title?: string;\n /** Farge og uttrykk på alert-boksen */\n variant: 'success' | 'info' | 'warning' | 'error';\n [key: string]: any;\n};\n\nexport const BannerAlertBox: React.FC<BannerAlertBoxProps> = props => (\n <BaseAlertBox {...props} size=\"banner\" />\n);\n","import React from 'react';\nimport { BaseAlertBox } from './BaseAlertBox';\n\nexport type ToastAlertBoxProps = {\n /** Innholdet i toasten */\n children?: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Skjermleser-label for lukkeknappen, om den vises */\n closeButtonLabel?: string;\n /** Callback som kalles når man lukker boksen */\n onClose?: () => void;\n /** Om denne er true, vil boksen få en lukkeknapp i høyre hjørne */\n closable?: boolean;\n /** Tittel på boksen - oppsummer virkning */\n title?: string;\n /** Farge og uttrykk på toasten */\n variant: 'success' | 'info';\n [key: string]: any;\n};\n\nexport const ToastAlertBox: React.FC<ToastAlertBoxProps> = props => (\n <BaseAlertBox {...props} size=\"toast\" role=\"status\" />\n);\n","import React from 'react';\nimport classNames from 'classnames';\nimport { BaseAlertBox } from './BaseAlertBox';\n\nexport type SmallAlertBoxProps = {\n /** Innholdet i alert-boksen */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Skjermleser-label for lukkeknappen, om den vises */\n closeButtonLabel?: string;\n /** Om denne er true, vil boksen få en lukkeknapp i høyre hjørne\n * @default false\n */\n closable?: boolean;\n /** Callback som kalles når man lukker boksen */\n onClose?: () => void;\n /** Tittel på boksen - oppsummer virkning */\n title?: string;\n /** Bredden på boksen - fullbredde eller tilpasset innholdet */\n width?: 'fluid' | 'fit-content';\n /** Farge og uttrykk på alert-boksen */\n variant: 'success' | 'info' | 'warning' | 'error';\n [key: string]: any;\n};\n\nexport const SmallAlertBox: React.FC<SmallAlertBoxProps> = ({\n className,\n width,\n onClose,\n closable = false,\n closeButtonLabel,\n ...rest\n}) => (\n <BaseAlertBox\n className={classNames(className, {\n 'eds-alert-box--fit-content': width === 'fit-content',\n })}\n {...rest}\n onClose={onClose}\n closable={closable}\n closeButtonLabel={closeButtonLabel}\n size=\"small\"\n />\n);\n","import React from 'react';\nimport { ToastAlertBox } from './ToastAlertBox';\nimport classNames from 'classnames';\n\ntype ToastId = string;\n\ntype ToastVariants = 'success' | 'info';\n\ntype ToastType = {\n title?: string;\n content: React.ReactNode;\n id: ToastId;\n variant: ToastVariants;\n isBeingRemoved: boolean;\n};\n\ntype ToastContextType = {\n addToast: (payload: AddToastPayload) => void;\n removeToast: (id: ToastId) => void;\n toasts: ToastType[];\n};\n\ntype AddToastPayload =\n | { title?: string; content: React.ReactNode; variant?: ToastVariants }\n | string;\n\ntype ToastAction =\n | { type: 'ADD_TOAST'; payload: ToastType }\n | { type: 'REMOVE_TOAST'; payload: ToastId }\n | { type: 'PLAY_EXIT_ANIMATION'; payload: ToastId };\n\nconst EXIT_ANIMATION_TIME = 400;\n\nconst ToastContext = React.createContext<ToastContextType | null>(null);\n\nconst toastReducer = (\n prevToasts: ToastType[],\n action: ToastAction,\n): ToastType[] => {\n switch (action.type) {\n case 'ADD_TOAST':\n return [action.payload, ...prevToasts];\n case 'PLAY_EXIT_ANIMATION':\n return prevToasts.map(toast => {\n if (toast.id === action.payload)\n return { ...toast, isBeingRemoved: true };\n return toast;\n });\n case 'REMOVE_TOAST':\n return prevToasts.filter(toast => toast.id !== action.payload);\n }\n};\n\nconst createUniqueId = () => Math.random().toString().substring(2);\n\nconst createToast = (toast: AddToastPayload, id: ToastId): ToastType => {\n if (typeof toast === 'string') {\n return { id, content: toast, variant: 'success', isBeingRemoved: false };\n } else {\n return { id, variant: 'success', isBeingRemoved: false, ...toast };\n }\n};\n\nexport type ToastProviderProps = {\n /** Antall millisekunder før toasts forsvinner av seg selv\n * @default 6000\n */\n delay?: number;\n /** Plasseringen av toasts\n * @default \"bottom-right\"\n */\n position?: 'bottom-right' | 'top-right';\n /** Ekstra klassenavn til ToastProvider-wrapperen */\n className?: string;\n /** Ekstra styling som sendes til ToastProvider-wrapperen */\n style?: React.CSSProperties;\n};\n\nexport const ToastProvider: React.FC<ToastProviderProps> = ({\n delay = 6000,\n children,\n position = 'bottom-right',\n className,\n style,\n}) => {\n const [toasts, dispatch] = React.useReducer(toastReducer, []);\n const [hoveringId, setHovering] = React.useState<string>();\n const timeoutIdRefs = React.useRef<{ [key: string]: number }>({});\n\n const removeToast = React.useCallback((id: ToastId) => {\n window.clearTimeout(timeoutIdRefs.current[id]);\n dispatch({ type: 'REMOVE_TOAST', payload: id });\n delete timeoutIdRefs.current[id];\n }, []);\n\n const playExitAnimation = React.useCallback((id: ToastId) => {\n window.clearTimeout(timeoutIdRefs.current[id + 'animation']);\n dispatch({ type: 'PLAY_EXIT_ANIMATION', payload: id });\n delete timeoutIdRefs.current[id + 'animation'];\n }, []);\n\n const removeToastWithAnimationAfterDelay = React.useCallback(\n (id: ToastId, delay: number) => {\n timeoutIdRefs.current[id + 'animation'] = window.setTimeout(\n () => playExitAnimation(id),\n delay - EXIT_ANIMATION_TIME,\n );\n timeoutIdRefs.current[id] = window.setTimeout(\n () => removeToast(id),\n delay,\n );\n },\n [timeoutIdRefs, playExitAnimation, removeToast],\n );\n\n const addToast = React.useCallback(\n (toast: AddToastPayload) => {\n const id = createUniqueId();\n const payload = createToast(toast, id);\n dispatch({ type: 'ADD_TOAST', payload });\n removeToastWithAnimationAfterDelay(id, delay);\n },\n [delay, removeToastWithAnimationAfterDelay],\n );\n\n const handleMouseEnter = (toast: ToastType) => () => {\n if (toast.isBeingRemoved) return;\n setHovering(toast.id);\n Object.values(timeoutIdRefs.current).forEach(timeoutId => {\n window.clearTimeout(timeoutId);\n });\n timeoutIdRefs.current = {};\n };\n\n const handleMouseLeave = () => {\n setHovering(undefined);\n toasts.forEach(toast => {\n removeToastWithAnimationAfterDelay(toast.id, delay);\n });\n };\n\n const handleClose = (toastId: ToastId) => () => {\n removeToast(toastId);\n handleMouseLeave();\n };\n\n const contextValue = React.useMemo(\n () => ({ toasts, addToast, removeToast }),\n [addToast, removeToast, toasts],\n );\n\n return (\n <ToastContext.Provider value={contextValue}>\n {toasts.length > 0 && (\n <div\n className={classNames(\n 'eds-toast-container',\n `eds-toast-container--${position}`,\n className,\n )}\n style={style}\n >\n {toasts.slice(0, 3).map(toastToShow => (\n <ToastAlertBox\n variant={toastToShow.variant}\n title={toastToShow.title}\n onClose={handleClose(toastToShow.id)}\n onMouseEnter={handleMouseEnter(toastToShow)}\n onMouseLeave={handleMouseLeave}\n closable={hoveringId === toastToShow.id}\n toastIsBeingRemoved={toastToShow.isBeingRemoved}\n key={toastToShow.id}\n >\n {toastToShow.content}\n </ToastAlertBox>\n ))}\n </div>\n )}\n {children}\n </ToastContext.Provider>\n );\n};\n\nexport const useToast: () => {\n addToast: (payload: AddToastPayload) => void;\n} = () => {\n const context = React.useContext(ToastContext);\n if (!context) {\n throw new Error(\n 'You need to wrap your component in a ToastProvider component in ' +\n 'order to use the useToast hook',\n );\n }\n const { addToast } = context;\n return {\n addToast,\n };\n};\n","import React from 'react';\n\nimport copy from 'copy-text-to-clipboard';\n\nimport { useToast } from './ToastProvider';\nimport { ReportsIcon } from '@entur/icons';\nimport { PreformattedText } from '@entur/typography';\n\nimport './CopyableText.scss';\n\nexport type CopyableTextProps = {\n /** Ekstra klassenavn */\n className?: string;\n /** Tekstinnhold som vises og kopieres */\n children: string;\n /** Overskrift i toast-varselet */\n successHeading?: string;\n /** Bekreftelsesmelding i toast-varselet */\n successMessage?: string;\n} & Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'children'>;\n\nexport const CopyableText = ({\n children,\n successHeading = 'Kopiert!',\n successMessage = 'Innholdet ble kopiert til utklippstavlen.',\n className,\n ...rest\n}: CopyableTextProps): JSX.Element => {\n const { addToast } = useToast();\n const buttonRef = React.useRef<HTMLButtonElement>(null);\n const handleClick = () => {\n buttonRef.current &&\n copy(children, {\n target: buttonRef.current,\n }) &&\n addToast({ title: successHeading, content: successMessage });\n };\n return (\n <button\n className={'copyable-text ' + className}\n style={{ ...rest.style }}\n type=\"button\"\n onClick={handleClick}\n ref={buttonRef}\n aria-label=\"Kopier innhold\"\n {...rest}\n >\n <PreformattedText>{children}</PreformattedText>\n <ReportsIcon className=\"copyable-text__icon\" />\n </button>\n );\n};\n","import { BaseExpand, ExpandArrow } from '@entur/expand/';\nimport classNames from 'classnames';\nimport React from 'react';\nimport { BannerAlertBoxProps } from './BannerAlertBox';\nimport { BaseAlertBox } from './BaseAlertBox';\nimport './ExpandableAlertBox.scss';\nimport { SmallAlertBoxProps } from './SmallAlertBox';\n\nexport type SmallExpandableAlertBoxProps = ExpandableAlertBoxProps &\n SmallAlertBoxProps;\n\nexport const SmallExpandableAlertBox: React.FC<SmallExpandableAlertBoxProps> = props => {\n return <ExpandableAlertBox size=\"small\" {...props} />;\n};\n\nexport type BannerExpandableAlertBoxProps = ExpandableAlertBoxProps &\n BannerAlertBoxProps;\n\nexport const BannerExpandableAlertBox: React.FC<BannerExpandableAlertBoxProps> = props => {\n return <ExpandableAlertBox size=\"banner\" {...props} />;\n};\n\ntype ExpandableAlertBoxProps = {\n /**Farge og uttrykk på alert-boksen */\n variant: 'success' | 'info' | 'warning' | 'error';\n /** Tittelen til ExpandableAlertBox */\n title: React.ReactNode;\n /**Innhold som vises ved ekspandering */\n children: React.ReactNode;\n /**Ekstra klassenavn */\n className?: string;\n /** Tekst som vises på ekspanderingsknappen før åpning\n * @default \"Les mer\"\n */\n openLabel?: string;\n /** Tekst som vises på ekspanderingsknappen når den er åpnet\n * @default \"Lukk\"\n */\n closeLabel?: string;\n [key: string]: any;\n};\n\nconst ExpandableAlertBox: React.FC<ExpandableAlertBoxProps> = ({\n variant,\n title,\n children,\n size,\n className,\n openLabel,\n closeLabel,\n ...rest\n}) => {\n const [open, setopen] = React.useState(false);\n return (\n <BaseAlertBox\n size={size}\n variant={variant}\n className={classNames('eds-expandable-alert-box', className)}\n title={\n <ExpandableAlertBoxTitle\n open={open}\n title={title}\n onClick={() => setopen(!open)}\n openLabel={openLabel}\n closeLabel={closeLabel}\n />\n }\n {...rest}\n >\n <BaseExpand open={open}>{children}</BaseExpand>\n </BaseAlertBox>\n );\n};\n\ntype ExpandableAlertBoxTitleProps = {\n title: React.ReactNode;\n open: boolean;\n openLabel?: string;\n closeLabel?: string;\n onClick: (e: React.MouseEvent) => void;\n};\n\nconst ExpandableAlertBoxTitle: React.FC<ExpandableAlertBoxTitleProps> = ({\n title,\n open,\n openLabel = 'Les mer',\n closeLabel = 'Lukk',\n onClick,\n}) => {\n return (\n <div className=\"eds-expandable-alert-box__title\">\n <div>{title}</div>\n <button\n className=\"eds-expandable-alert-box__button\"\n onClick={onClick}\n type=\"button\"\n >\n {open ? closeLabel : openLabel}\n <ExpandArrow open={open} inline />\n </button>\n </div>\n );\n};\n","import { warnAboutMissingStyles } from '@entur/utils';\nimport './index.scss';\n\nwarnAboutMissingStyles('alert', 'icons');\n\nexport { BannerAlertBox } from './BannerAlertBox';\nexport { ToastAlertBox } from './ToastAlertBox';\nexport { SmallAlertBox } from './SmallAlertBox';\nexport { ToastProvider, useToast } from './ToastProvider';\nexport { CopyableText } from './CopyableText';\nexport * from './ExpandableAlertBox';\n"],"names":["iconsMap","success","OutlinedValidationCheckIcon","info","OutlinedValidationInfoIcon","warning","OutlinedValidationExclamationIcon","error","OutlinedValidationErrorIcon","BaseAlertBox","children","className","closable","closeButtonLabel","variant","onClose","size","title","toastIsBeingRemoved","rest","React","useState","isClosed","setClosed","handleClose","Icon","classNames","type","onClick","CloseIcon","BannerAlertBox","props","ToastAlertBox","role","SmallAlertBox","width","EXIT_ANIMATION_TIME","ToastContext","createContext","toastReducer","prevToasts","action","payload","map","toast","id","isBeingRemoved","filter","createUniqueId","Math","random","toString","substring","createToast","content","ToastProvider","delay","position","style","useReducer","toasts","dispatch","hoveringId","setHovering","timeoutIdRefs","useRef","removeToast","useCallback","window","clearTimeout","current","playExitAnimation","removeToastWithAnimationAfterDelay","setTimeout","addToast","handleMouseEnter","Object","values","forEach","timeoutId","handleMouseLeave","undefined","toastId","contextValue","useMemo","Provider","value","length","slice","toastToShow","onMouseEnter","onMouseLeave","key","useToast","context","useContext","Error","CopyableText","successHeading","successMessage","buttonRef","handleClick","copy","target","ref","PreformattedText","ReportsIcon","SmallExpandableAlertBox","ExpandableAlertBox","BannerExpandableAlertBox","openLabel","closeLabel","open","setopen","ExpandableAlertBoxTitle","BaseExpand","ExpandArrow","inline","warnAboutMissingStyles"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,IAAMA,QAAQ,GAAG;AACfC,EAAAA,OAAO,EAAEC,2BADM;AAEfC,EAAAA,IAAI,EAAEC,0BAFS;AAGfC,EAAAA,OAAO,EAAEC,iCAHM;AAIfC,EAAAA,KAAK,EAAEC;AAJQ,CAAjB;AAiCO,IAAMC,YAAY,GAAgC,SAA5CA,YAA4C;MACvDC,gBAAAA;MACAC,iBAAAA;2BACAC;MAAAA,sCAAW;mCACXC;MAAAA,sDAAmB;MACnBC,eAAAA;0BACAC;MAAAA,oCAAU;AAAA,WAAO,EAAP;AAAA;MACVC,YAAAA;MACAC,aAAAA;MACAC,2BAAAA;MACGC;;AAEH,wBAA8BC,KAAK,CAACC,QAAN,CAAe,KAAf,CAA9B;AAAA,MAAOC,QAAP;AAAA,MAAiBC,SAAjB;;AACA,MAAID,QAAJ,EAAc;AACZ,WAAO,IAAP;AACD;;AACD,MAAME,WAAW,GAAG,SAAdA,WAAc;AAClBD,IAAAA,SAAS,CAAC,IAAD,CAAT;AACAR,IAAAA,OAAO;AACR,GAHD;;AAIA,MAAMU,IAAI,GAAGzB,QAAQ,CAACc,OAAD,CAArB;AACA,SACEM,mBAAA,MAAA;AACET,IAAAA,SAAS,EAAEe,UAAU,CACnB,eADmB,sBAEDV,IAFC,sBAGDF,OAH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,uBAAD;AACEF,MAAAA,IAAI,EAAEA;AACN/F,MAAAA,KAAK,EAAEA;AACPW,MAAAA,OAAO,EAAE;AAAA,eAAMqF,OAAO,CAAC,CAACD,IAAF,CAAb;AAAA;AACTF,MAAAA,SAAS,EAAEA;AACXC,MAAAA,UAAU,EAAEA;KALd;AALJ,KAaM5F,IAbN,GAeEC,mBAAA,CAAC+F,UAAD;AAAYH,IAAAA,IAAI,EAAEA;GAAlB,EAAyBtG,QAAzB,CAfF,CADF;AAmBD,CA9BD;;AAwCA,IAAMwG,uBAAuB,GAA2C,SAAlEA,uBAAkE;MACtEjG,cAAAA;MACA+F,aAAAA;8BACAF;MAAAA,yCAAY;+BACZC;MAAAA,2CAAa;MACbnF,gBAAAA;AAEA,SACER,mBAAA,MAAA;AAAKT,IAAAA,SAAS,EAAC;GAAf,EACES,mBAAA,MAAA,MAAA,EAAMH,KAAN,CADF,EAEEG,mBAAA,SAAA;AACET,IAAAA,SAAS,EAAC;AACViB,IAAAA,OAAO,EAAEA;AACTD,IAAAA,IAAI,EAAC;GAHP,EAKGqF,IAAI,GAAGD,UAAH,GAAgBD,SALvB,EAME1F,mBAAA,CAACgG,WAAD;AAAaJ,IAAAA,IAAI,EAAEA;AAAMK,IAAAA,MAAM;GAA/B,CANF,CAFF,CADF;AAaD,CApBD;;AC/EAC,sBAAsB,CAAC,OAAD,EAAU,OAAV,CAAtB;;;;"}
package/dist/styles.css CHANGED
@@ -122,6 +122,10 @@
122
122
  width: fit-content;
123
123
  }
124
124
  }
125
+ .eds-alert-box--toast--exit-animation {
126
+ -webkit-animation: 0.5s ease-in-out 0s 1 bounceOutRight;
127
+ animation: 0.5s ease-in-out 0s 1 bounceOutRight;
128
+ }
125
129
  .eds-alert-box--small {
126
130
  font-size: 0.875rem;
127
131
  }
@@ -295,4 +299,24 @@
295
299
  to {
296
300
  transform: translate3d(0, 0, 0);
297
301
  }
302
+ }
303
+ @-webkit-keyframes bounceOutRight {
304
+ 20% {
305
+ opacity: 1;
306
+ transform: translate3d(-20px, 0, 0) scaleX(0.9);
307
+ }
308
+ to {
309
+ opacity: 0;
310
+ transform: translate3d(2000px, 0, 0) scaleX(2);
311
+ }
312
+ }
313
+ @keyframes bounceOutRight {
314
+ 20% {
315
+ opacity: 1;
316
+ transform: translate3d(-20px, 0, 0) scaleX(0.9);
317
+ }
318
+ to {
319
+ opacity: 0;
320
+ transform: translate3d(2000px, 0, 0) scaleX(2);
321
+ }
298
322
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@entur/alert",
3
- "version": "0.10.6",
3
+ "version": "0.11.2",
4
4
  "license": "EUPL-1.2",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/alert.esm.js",
@@ -27,9 +27,9 @@
27
27
  "react-dom": ">=16.8.0"
28
28
  },
29
29
  "dependencies": {
30
- "@entur/expand": "^3.3.12",
31
- "@entur/icons": "^4.1.2",
32
- "@entur/typography": "^1.6.12",
30
+ "@entur/expand": "^3.3.15",
31
+ "@entur/icons": "^4.2.0",
32
+ "@entur/typography": "^1.6.14",
33
33
  "@entur/utils": "^0.4.3",
34
34
  "classnames": "^2.3.1",
35
35
  "copy-text-to-clipboard": "2.2"
@@ -41,5 +41,5 @@
41
41
  "node": "14.17.0",
42
42
  "yarn": "1.18.0"
43
43
  },
44
- "gitHead": "0fba0071ad9dc75cc68b72b846f5bab78be12449"
44
+ "gitHead": "974289b6579ade4460d12aa877a89e454c983d48"
45
45
  }