@entur/alert 0.10.0 → 0.10.1

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,10 @@
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.10.1](https://bitbucket.org/enturas/design-system/compare/@entur/alert@0.10.0...@entur/alert@0.10.1) (2022-02-09)
7
+
8
+ **Note:** Version bump only for package @entur/alert
9
+
6
10
  # [0.10.0](https://bitbucket.org/enturas/design-system/compare/@entur/alert@0.9.1...@entur/alert@0.10.0) (2022-01-21)
7
11
 
8
12
  ### Features
@@ -2,16 +2,20 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
6
-
7
5
  var utils = require('@entur/utils');
8
- var React = _interopDefault(require('react'));
9
- var classNames = _interopDefault(require('classnames'));
6
+ var React = require('react');
7
+ var classNames = require('classnames');
10
8
  var icons = require('@entur/icons');
11
- var copy = _interopDefault(require('copy-text-to-clipboard'));
9
+ var copy = require('copy-text-to-clipboard');
12
10
  var typography = require('@entur/typography');
13
11
  var _ = require('@entur/expand/');
14
12
 
13
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
14
+
15
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
16
+ var classNames__default = /*#__PURE__*/_interopDefaultLegacy(classNames);
17
+ var copy__default = /*#__PURE__*/_interopDefaultLegacy(copy);
18
+
15
19
  function _extends() {
16
20
  _extends = Object.assign || function (target) {
17
21
  for (var i = 1; i < arguments.length; i++) {
@@ -45,6 +49,7 @@ function _objectWithoutPropertiesLoose(source, excluded) {
45
49
  return target;
46
50
  }
47
51
 
52
+ var _excluded$3 = ["children", "className", "closable", "closeButtonLabel", "variant", "onClose", "size", "title"];
48
53
  var iconsMap = {
49
54
  success: icons.OutlinedValidationCheckIcon,
50
55
  info: icons.OutlinedValidationInfoIcon,
@@ -65,9 +70,9 @@ var BaseAlertBox = function BaseAlertBox(_ref) {
65
70
  } : _ref$onClose,
66
71
  size = _ref.size,
67
72
  title = _ref.title,
68
- rest = _objectWithoutPropertiesLoose(_ref, ["children", "className", "closable", "closeButtonLabel", "variant", "onClose", "size", "title"]);
73
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$3);
69
74
 
70
- var _React$useState = React.useState(false),
75
+ var _React$useState = React__default["default"].useState(false),
71
76
  isClosed = _React$useState[0],
72
77
  setClosed = _React$useState[1];
73
78
 
@@ -81,38 +86,39 @@ var BaseAlertBox = function BaseAlertBox(_ref) {
81
86
  };
82
87
 
83
88
  var Icon = iconsMap[variant];
84
- return React.createElement("div", Object.assign({
85
- className: classNames('eds-alert-box', "eds-alert-box--" + size, "eds-alert-box--" + variant, className)
86
- }, rest), closable && React.createElement("button", {
89
+ 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
+ }, rest), closable && React__default["default"].createElement("button", {
87
92
  "aria-label": closeButtonLabel,
88
93
  className: "eds-alert-box__close-button",
89
94
  type: "button",
90
95
  onClick: handleClose
91
- }, React.createElement(icons.CloseIcon, null)), React.createElement(Icon, {
96
+ }, React__default["default"].createElement(icons.CloseIcon, null)), React__default["default"].createElement(Icon, {
92
97
  className: "eds-alert-box__icon"
93
- }), React.createElement("div", {
94
- className: classNames('eds-alert-box__content', {
98
+ }), React__default["default"].createElement("div", {
99
+ className: classNames__default["default"]('eds-alert-box__content', {
95
100
  'eds-alert-box__content--no-title': !title,
96
101
  'eds-alert-box__content--no-children': !children
97
102
  })
98
- }, title && React.createElement("div", {
103
+ }, title && React__default["default"].createElement("div", {
99
104
  className: "eds-alert-box__title"
100
105
  }, title), children && children));
101
106
  };
102
107
 
103
108
  var BannerAlertBox = function BannerAlertBox(props) {
104
- return React.createElement(BaseAlertBox, Object.assign({}, props, {
109
+ return React__default["default"].createElement(BaseAlertBox, _extends({}, props, {
105
110
  size: "banner"
106
111
  }));
107
112
  };
108
113
 
109
114
  var ToastAlertBox = function ToastAlertBox(props) {
110
- return React.createElement(BaseAlertBox, Object.assign({}, props, {
115
+ return React__default["default"].createElement(BaseAlertBox, _extends({}, props, {
111
116
  size: "toast",
112
117
  role: "status"
113
118
  }));
114
119
  };
115
120
 
121
+ var _excluded$2 = ["className", "width", "onClose", "closable", "closeButtonLabel"];
116
122
  var SmallAlertBox = function SmallAlertBox(_ref) {
117
123
  var className = _ref.className,
118
124
  width = _ref.width,
@@ -120,10 +126,10 @@ var SmallAlertBox = function SmallAlertBox(_ref) {
120
126
  _ref$closable = _ref.closable,
121
127
  closable = _ref$closable === void 0 ? false : _ref$closable,
122
128
  closeButtonLabel = _ref.closeButtonLabel,
123
- rest = _objectWithoutPropertiesLoose(_ref, ["className", "width", "onClose", "closable", "closeButtonLabel"]);
129
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$2);
124
130
 
125
- return React.createElement(BaseAlertBox, Object.assign({
126
- className: classNames(className, {
131
+ return React__default["default"].createElement(BaseAlertBox, _extends({
132
+ className: classNames__default["default"](className, {
127
133
  'eds-alert-box--fit-content': width === 'fit-content'
128
134
  })
129
135
  }, rest, {
@@ -134,7 +140,7 @@ var SmallAlertBox = function SmallAlertBox(_ref) {
134
140
  }));
135
141
  };
136
142
 
137
- var ToastContext = /*#__PURE__*/React.createContext(null);
143
+ var ToastContext = /*#__PURE__*/React__default["default"].createContext(null);
138
144
 
139
145
  var toastReducer = function toastReducer(prevToasts, action) {
140
146
  switch (action.type) {
@@ -176,16 +182,16 @@ var ToastProvider = function ToastProvider(_ref) {
176
182
  className = _ref.className,
177
183
  style = _ref.style;
178
184
 
179
- var _React$useReducer = React.useReducer(toastReducer, []),
185
+ var _React$useReducer = React__default["default"].useReducer(toastReducer, []),
180
186
  toasts = _React$useReducer[0],
181
187
  dispatch = _React$useReducer[1];
182
188
 
183
- var _React$useState = React.useState(),
189
+ var _React$useState = React__default["default"].useState(),
184
190
  hoveringId = _React$useState[0],
185
191
  setHovering = _React$useState[1];
186
192
 
187
- var timeoutIdRefs = React.useRef({});
188
- var removeToast = React.useCallback(function (id) {
193
+ var timeoutIdRefs = React__default["default"].useRef({});
194
+ var removeToast = React__default["default"].useCallback(function (id) {
189
195
  window.clearTimeout(timeoutIdRefs.current[id]);
190
196
  dispatch({
191
197
  type: 'REMOVE_TOAST',
@@ -193,7 +199,7 @@ var ToastProvider = function ToastProvider(_ref) {
193
199
  });
194
200
  delete timeoutIdRefs.current[id];
195
201
  }, []);
196
- var addToast = React.useCallback(function (toast) {
202
+ var addToast = React__default["default"].useCallback(function (toast) {
197
203
  var id = createUniqueId();
198
204
  var payload = createToast(toast, id);
199
205
  dispatch({
@@ -231,20 +237,20 @@ var ToastProvider = function ToastProvider(_ref) {
231
237
  };
232
238
  };
233
239
 
234
- var contextValue = React.useMemo(function () {
240
+ var contextValue = React__default["default"].useMemo(function () {
235
241
  return {
236
242
  toasts: toasts,
237
243
  addToast: addToast,
238
244
  removeToast: removeToast
239
245
  };
240
246
  }, [addToast, removeToast, toasts]);
241
- return React.createElement(ToastContext.Provider, {
247
+ return React__default["default"].createElement(ToastContext.Provider, {
242
248
  value: contextValue
243
- }, toasts.length > 0 && React.createElement("div", {
244
- className: classNames('eds-toast-container', "eds-toast-container--" + position, className),
249
+ }, toasts.length > 0 && React__default["default"].createElement("div", {
250
+ className: classNames__default["default"]('eds-toast-container', "eds-toast-container--" + position, className),
245
251
  style: style
246
252
  }, toasts.slice(0, 3).map(function (toastToShow) {
247
- return React.createElement(ToastAlertBox, {
253
+ return React__default["default"].createElement(ToastAlertBox, {
248
254
  variant: toastToShow.variant,
249
255
  title: toastToShow.title,
250
256
  onClose: handleClose(toastToShow.id),
@@ -256,7 +262,7 @@ var ToastProvider = function ToastProvider(_ref) {
256
262
  })), children);
257
263
  };
258
264
  var useToast = function useToast() {
259
- var context = React.useContext(ToastContext);
265
+ var context = React__default["default"].useContext(ToastContext);
260
266
 
261
267
  if (!context) {
262
268
  throw new Error('You need to wrap your component in a ToastProvider component in ' + 'order to use the useToast hook');
@@ -268,6 +274,7 @@ var useToast = function useToast() {
268
274
  };
269
275
  };
270
276
 
277
+ var _excluded$1 = ["children", "successHeading", "successMessage", "className"];
271
278
  var CopyableText = function CopyableText(_ref) {
272
279
  var children = _ref.children,
273
280
  _ref$successHeading = _ref.successHeading,
@@ -275,15 +282,15 @@ var CopyableText = function CopyableText(_ref) {
275
282
  _ref$successMessage = _ref.successMessage,
276
283
  successMessage = _ref$successMessage === void 0 ? 'Innholdet ble kopiert til utklippstavlen.' : _ref$successMessage,
277
284
  className = _ref.className,
278
- rest = _objectWithoutPropertiesLoose(_ref, ["children", "successHeading", "successMessage", "className"]);
285
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$1);
279
286
 
280
287
  var _useToast = useToast(),
281
288
  addToast = _useToast.addToast;
282
289
 
283
- var buttonRef = React.useRef(null);
290
+ var buttonRef = React__default["default"].useRef(null);
284
291
 
285
292
  var handleClick = function handleClick() {
286
- buttonRef.current && copy(children, {
293
+ buttonRef.current && copy__default["default"](children, {
287
294
  target: buttonRef.current
288
295
  }) && addToast({
289
296
  title: successHeading,
@@ -291,25 +298,26 @@ var CopyableText = function CopyableText(_ref) {
291
298
  });
292
299
  };
293
300
 
294
- return React.createElement("button", Object.assign({
301
+ return React__default["default"].createElement("button", _extends({
295
302
  className: 'copyable-text ' + className,
296
303
  style: _extends({}, rest.style),
297
304
  type: "button",
298
305
  onClick: handleClick,
299
306
  ref: buttonRef,
300
307
  "aria-label": "Kopier innhold"
301
- }, rest), React.createElement(typography.PreformattedText, null, children), React.createElement(icons.ReportsIcon, {
308
+ }, rest), React__default["default"].createElement(typography.PreformattedText, null, children), React__default["default"].createElement(icons.ReportsIcon, {
302
309
  className: "copyable-text__icon"
303
310
  }));
304
311
  };
305
312
 
313
+ var _excluded = ["variant", "title", "children", "size", "className", "openLabel", "closeLabel"];
306
314
  var SmallExpandableAlertBox = function SmallExpandableAlertBox(props) {
307
- return React.createElement(ExpandableAlertBox, Object.assign({
315
+ return React__default["default"].createElement(ExpandableAlertBox, _extends({
308
316
  size: "small"
309
317
  }, props));
310
318
  };
311
319
  var BannerExpandableAlertBox = function BannerExpandableAlertBox(props) {
312
- return React.createElement(ExpandableAlertBox, Object.assign({
320
+ return React__default["default"].createElement(ExpandableAlertBox, _extends({
313
321
  size: "banner"
314
322
  }, props));
315
323
  };
@@ -322,17 +330,17 @@ var ExpandableAlertBox = function ExpandableAlertBox(_ref) {
322
330
  className = _ref.className,
323
331
  openLabel = _ref.openLabel,
324
332
  closeLabel = _ref.closeLabel,
325
- rest = _objectWithoutPropertiesLoose(_ref, ["variant", "title", "children", "size", "className", "openLabel", "closeLabel"]);
333
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded);
326
334
 
327
- var _React$useState = React.useState(false),
335
+ var _React$useState = React__default["default"].useState(false),
328
336
  open = _React$useState[0],
329
337
  setopen = _React$useState[1];
330
338
 
331
- return React.createElement(BaseAlertBox, Object.assign({
339
+ return React__default["default"].createElement(BaseAlertBox, _extends({
332
340
  size: size,
333
341
  variant: variant,
334
- className: classNames('eds-expandable-alert-box', className),
335
- title: React.createElement(ExpandableAlertBoxTitle, {
342
+ className: classNames__default["default"]('eds-expandable-alert-box', className),
343
+ title: React__default["default"].createElement(ExpandableAlertBoxTitle, {
336
344
  open: open,
337
345
  title: title,
338
346
  onClick: function onClick() {
@@ -341,7 +349,7 @@ var ExpandableAlertBox = function ExpandableAlertBox(_ref) {
341
349
  openLabel: openLabel,
342
350
  closeLabel: closeLabel
343
351
  })
344
- }, rest), React.createElement(_.BaseExpand, {
352
+ }, rest), React__default["default"].createElement(_.BaseExpand, {
345
353
  open: open
346
354
  }, children));
347
355
  };
@@ -354,13 +362,13 @@ var ExpandableAlertBoxTitle = function ExpandableAlertBoxTitle(_ref2) {
354
362
  _ref2$closeLabel = _ref2.closeLabel,
355
363
  closeLabel = _ref2$closeLabel === void 0 ? 'Lukk' : _ref2$closeLabel,
356
364
  onClick = _ref2.onClick;
357
- return React.createElement("div", {
365
+ return React__default["default"].createElement("div", {
358
366
  className: "eds-expandable-alert-box__title"
359
- }, React.createElement("div", null, title), React.createElement("button", {
367
+ }, React__default["default"].createElement("div", null, title), React__default["default"].createElement("button", {
360
368
  className: "eds-expandable-alert-box__button",
361
369
  onClick: onClick,
362
370
  type: "button"
363
- }, open ? closeLabel : openLabel, React.createElement(_.ExpandArrow, {
371
+ }, open ? closeLabel : openLabel, React__default["default"].createElement(_.ExpandArrow, {
364
372
  open: open,
365
373
  inline: true
366
374
  })));
@@ -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;;wBAE2BC,KAAK,CAACC,QAAN,CAAe,KAAf;MAAvBC;MAAUC;;AACjB,MAAID,QAAJ,EAAc;AACZ,WAAO,IAAP;AACD;;AACD,MAAME,WAAW,GAAG,SAAdA,WAAc;AAClBD,IAAAA,SAAS,CAAC,IAAD,C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BM,IAAAA,KAAK,EACHE,mBAAA,CAAC0F,uBAAD;AACEF,MAAAA,IAAI,EAAEA;AACN1F,MAAAA,KAAK,EAAEA;AACPU,MAAAA,OAAO,EAAE;AAAA,eAAMiF,OAAO,CAAC,CAACD,IAAF,CAAb;AAAA;AACTF,MAAAA,SAAS,EAAEA;AACXC,MAAAA,UAAU,EAAEA;KALd;KAQExF,KAbN,EAeEC,mBAAA,CAAC2F,YAAD;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,aAAD;AAAaJ,IAAAA,IAAI,EAAEA;AAAMK,IAAAA,MAAM;GAA/B,CANF,CAFF,CADF;AAaD,CApBD;;AC/EAC,4BAAsB,CAAC,OAAD,EAAU,OAAV,CAAtB;;;;;;;;;;;"}
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;AA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ACER,uCAAA,MAAA;AAAKR,IAAAA,SAAS,EAAC;GAAf,EACEQ,uCAAA,MAAA,MAAA,EAAMF,KAAN,CADF,EAEEE,uCAAA,SAAA;AACER,IAAAA,SAAS,EAAC;AACVgB,IAAAA,OAAO,EAAEA;AACTD,IAAAA,IAAI,EAAC;GAHP,EAKGiF,IAAI,GAAGD,UAAH,GAAgBD,SALvB,EAMEtF,uCAAA,CAAC4F,aAAD;AAAaJ,IAAAA,IAAI,EAAEA;AAAMK,IAAAA,MAAM;GAA/B,CANF,CAFF,CADF;AAaD,CApBD;;AC/EAC,4BAAsB,CAAC,OAAD,EAAU,OAAV,CAAtB;;;;;;;;;;;"}
@@ -1,2 +1,2 @@
1
- "use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@entur/utils"),n=e(require("react")),a=e(require("classnames")),o=require("@entur/icons"),r=e(require("copy-text-to-clipboard")),l=require("@entur/typography"),s=require("@entur/expand/");function i(){return(i=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}).apply(this,arguments)}function c(e,t){if(null==e)return{};var n,a,o={},r=Object.keys(e);for(a=0;a<r.length;a++)t.indexOf(n=r[a])>=0||(o[n]=e[n]);return o}var u={success:o.OutlinedValidationCheckIcon,info:o.OutlinedValidationInfoIcon,warning:o.OutlinedValidationExclamationIcon,error:o.OutlinedValidationErrorIcon},d=function(e){var t=e.children,r=e.className,l=e.closable,s=void 0!==l&&l,i=e.closeButtonLabel,d=void 0===i?"Lukk":i,b=e.variant,m=e.onClose,p=void 0===m?function(){return{}}:m,f=e.size,v=e.title,x=c(e,["children","className","closable","closeButtonLabel","variant","onClose","size","title"]),E=n.useState(!1),y=E[1];if(E[0])return null;var h=u[b];return n.createElement("div",Object.assign({className:a("eds-alert-box","eds-alert-box--"+f,"eds-alert-box--"+b,r)},x),s&&n.createElement("button",{"aria-label":d,className:"eds-alert-box__close-button",type:"button",onClick:function(){y(!0),p()}},n.createElement(o.CloseIcon,null)),n.createElement(h,{className:"eds-alert-box__icon"}),n.createElement("div",{className:a("eds-alert-box__content",{"eds-alert-box__content--no-title":!v,"eds-alert-box__content--no-children":!t})},v&&n.createElement("div",{className:"eds-alert-box__title"},v),t&&t))},b=function(e){return n.createElement(d,Object.assign({},e,{size:"toast",role:"status"}))},m=n.createContext(null),p=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}))}},f=function(){var e=n.useContext(m);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}},v=function(e){var t=e.variant,o=e.title,r=e.children,l=e.size,i=e.className,u=e.openLabel,b=e.closeLabel,m=c(e,["variant","title","children","size","className","openLabel","closeLabel"]),p=n.useState(!1),f=p[0],v=p[1];return n.createElement(d,Object.assign({size:l,variant:t,className:a("eds-expandable-alert-box",i),title:n.createElement(x,{open:f,title:o,onClick:function(){return v(!f)},openLabel:u,closeLabel:b})},m),n.createElement(s.BaseExpand,{open:f},r))},x=function(e){var t=e.open,a=e.openLabel,o=void 0===a?"Les mer":a,r=e.closeLabel,l=void 0===r?"Lukk":r,i=e.onClick;return n.createElement("div",{className:"eds-expandable-alert-box__title"},n.createElement("div",null,e.title),n.createElement("button",{className:"eds-expandable-alert-box__button",onClick:i,type:"button"},t?l:o,n.createElement(s.ExpandArrow,{open:t,inline:!0})))};t.warnAboutMissingStyles("alert","icons"),exports.BannerAlertBox=function(e){return n.createElement(d,Object.assign({},e,{size:"banner"}))},exports.BannerExpandableAlertBox=function(e){return n.createElement(v,Object.assign({size:"banner"},e))},exports.CopyableText=function(e){var t=e.children,a=e.successHeading,s=void 0===a?"Kopiert!":a,u=e.successMessage,d=void 0===u?"Innholdet ble kopiert til utklippstavlen.":u,b=e.className,m=c(e,["children","successHeading","successMessage","className"]),p=f().addToast,v=n.useRef(null);return n.createElement("button",Object.assign({className:"copyable-text "+b,style:i({},m.style),type:"button",onClick:function(){v.current&&r(t,{target:v.current})&&p({title:s,content:d})},ref:v,"aria-label":"Kopier innhold"},m),n.createElement(l.PreformattedText,null,t),n.createElement(o.ReportsIcon,{className:"copyable-text__icon"}))},exports.SmallAlertBox=function(e){var t=e.className,o=e.width,r=e.onClose,l=e.closable,s=void 0!==l&&l,i=e.closeButtonLabel,u=c(e,["className","width","onClose","closable","closeButtonLabel"]);return n.createElement(d,Object.assign({className:a(t,{"eds-alert-box--fit-content":"fit-content"===o})},u,{onClose:r,closable:s,closeButtonLabel:i,size:"small"}))},exports.SmallExpandableAlertBox=function(e){return n.createElement(v,Object.assign({size:"small"},e))},exports.ToastAlertBox=b,exports.ToastProvider=function(e){var t=e.delay,o=void 0===t?6e3:t,r=e.children,l=e.position,s=void 0===l?"bottom-right":l,c=e.className,u=e.style,d=n.useReducer(p,[]),f=d[0],v=d[1],x=n.useState(),E=x[0],y=x[1],h=n.useRef({}),O=n.useCallback((function(e){window.clearTimeout(h.current[e]),v({type:"REMOVE_TOAST",payload:e}),delete h.current[e]}),[]),g=n.useCallback((function(e){var t=Math.random().toString().substring(2),n=function(e,t){return"string"==typeof e?{id:t,content:e,variant:"success"}:i({id:t,variant:"success"},e)}(e,t);v({type:"ADD_TOAST",payload:n}),h.current[t]=window.setTimeout((function(){return O(t)}),o)}),[o,O]),T=function(e){return function(){y(e),Object.values(h.current).forEach((function(e){return window.clearTimeout(e)})),h.current={}}},_=function(){y(void 0),f.forEach((function(e){h.current[e.id]=window.setTimeout((function(){return O(e.id)}),o)}))},N=n.useMemo((function(){return{toasts:f,addToast:g,removeToast:O}}),[g,O,f]);return n.createElement(m.Provider,{value:N},f.length>0&&n.createElement("div",{className:a("eds-toast-container","eds-toast-container--"+s,c),style:u},f.slice(0,3).map((function(e){return n.createElement(b,{variant:e.variant,title:e.title,onClose:(t=e.id,function(){O(t),_()}),onMouseEnter:T(e.id),onMouseLeave:_,closable:E===e.id,key:e.id},e.content);var t}))),r)},exports.useToast=f;
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;
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":"wqBAWA,IAAMA,EAAW,CACfC,QAASC,8BACTC,KAAMC,6BACNC,QAASC,oCACTC,MAAOC,+BA6BIC,EAA4C,gBACvDC,IAAAA,SACAC,IAAAA,cACAC,SAAAA,oBACAC,iBAAAA,aAAm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,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 ...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,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,MACGC,WAE2BC,UAAMC,UAAS,GAA5BC,sBAER,SAMHC,EAAOtB,EAASc,UAEpBK,iCACER,UAAWY,UACT,kCACkBP,oBACAF,EAClBH,IAEEO,GAEHN,GACCO,+CACcN,EACZF,UAAU,8BACVa,KAAK,SACLC,QApBY,WAClBJ,GAAU,GACVN,MAoBMI,wBAACO,mBAGLP,wBAACG,GAAKX,UAAU,wBAChBQ,+BACER,UAAWY,UAAW,yBAA0B,qCACTN,yCACGP,KAGzCO,GAASE,+BAAKR,UAAU,wBAAwBM,GAChDP,GAAYA,KCvERiB,EAA8C,SAAAC,UACzDT,wBAACV,OAAiBmB,GAAOZ,KAAK,QAAQa,KAAK,6ECOvCC,EAAeX,UAAMY,cAAuC,MAE5DC,EAAe,SACnBC,EACAC,UAEQA,EAAOV,UACR,mBACKU,EAAOC,gBAAYF,OACxB,sBACIA,EAAWG,QAAO,SAAAC,UAASA,EAAMC,KAAOJ,EAAOC,aAsH/CI,EAET,eACIC,EAAUrB,UAAMsB,WAAWX,OAC5BU,QACG,IAAIE,MACR,wGAKG,CACLC,SAFmBH,EAAbG,qJC7HJC,EAAwD,gBAC5D9B,IAAAA,QACAG,IAAAA,MACAP,IAAAA,SACAM,IAAAA,KACAL,IAAAA,UACAkC,IAAAA,UACAC,IAAAA,WACG5B,WAEqBC,UAAMC,UAAS,GAAhC2B,OAAMC,cAEX7B,wBAACV,KACCO,KAAM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B,OAAS,GACf9E,+BACER,UAAWY,UACT,8CACwB6C,EACxBzD,GAEF+C,MAAOA,GAENY,EAAO4B,MAAM,EAAG,GAAGC,KAAI,SAAAC,UACtBjF,wBAACQ,GACCb,QAASsF,EAAYtF,QACrBG,MAAOmF,EAAYnF,MACnBF,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"}
package/dist/alert.esm.js CHANGED
@@ -39,6 +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
43
  var iconsMap = {
43
44
  success: OutlinedValidationCheckIcon,
44
45
  info: OutlinedValidationInfoIcon,
@@ -59,7 +60,7 @@ var BaseAlertBox = function BaseAlertBox(_ref) {
59
60
  } : _ref$onClose,
60
61
  size = _ref.size,
61
62
  title = _ref.title,
62
- rest = _objectWithoutPropertiesLoose(_ref, ["children", "className", "closable", "closeButtonLabel", "variant", "onClose", "size", "title"]);
63
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$3);
63
64
 
64
65
  var _React$useState = React.useState(false),
65
66
  isClosed = _React$useState[0],
@@ -75,7 +76,7 @@ var BaseAlertBox = function BaseAlertBox(_ref) {
75
76
  };
76
77
 
77
78
  var Icon = iconsMap[variant];
78
- return React.createElement("div", Object.assign({
79
+ return React.createElement("div", _extends({
79
80
  className: classNames('eds-alert-box', "eds-alert-box--" + size, "eds-alert-box--" + variant, className)
80
81
  }, rest), closable && React.createElement("button", {
81
82
  "aria-label": closeButtonLabel,
@@ -95,18 +96,19 @@ var BaseAlertBox = function BaseAlertBox(_ref) {
95
96
  };
96
97
 
97
98
  var BannerAlertBox = function BannerAlertBox(props) {
98
- return React.createElement(BaseAlertBox, Object.assign({}, props, {
99
+ return React.createElement(BaseAlertBox, _extends({}, props, {
99
100
  size: "banner"
100
101
  }));
101
102
  };
102
103
 
103
104
  var ToastAlertBox = function ToastAlertBox(props) {
104
- return React.createElement(BaseAlertBox, Object.assign({}, props, {
105
+ return React.createElement(BaseAlertBox, _extends({}, props, {
105
106
  size: "toast",
106
107
  role: "status"
107
108
  }));
108
109
  };
109
110
 
111
+ var _excluded$2 = ["className", "width", "onClose", "closable", "closeButtonLabel"];
110
112
  var SmallAlertBox = function SmallAlertBox(_ref) {
111
113
  var className = _ref.className,
112
114
  width = _ref.width,
@@ -114,9 +116,9 @@ var SmallAlertBox = function SmallAlertBox(_ref) {
114
116
  _ref$closable = _ref.closable,
115
117
  closable = _ref$closable === void 0 ? false : _ref$closable,
116
118
  closeButtonLabel = _ref.closeButtonLabel,
117
- rest = _objectWithoutPropertiesLoose(_ref, ["className", "width", "onClose", "closable", "closeButtonLabel"]);
119
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$2);
118
120
 
119
- return React.createElement(BaseAlertBox, Object.assign({
121
+ return React.createElement(BaseAlertBox, _extends({
120
122
  className: classNames(className, {
121
123
  'eds-alert-box--fit-content': width === 'fit-content'
122
124
  })
@@ -262,6 +264,7 @@ var useToast = function useToast() {
262
264
  };
263
265
  };
264
266
 
267
+ var _excluded$1 = ["children", "successHeading", "successMessage", "className"];
265
268
  var CopyableText = function CopyableText(_ref) {
266
269
  var children = _ref.children,
267
270
  _ref$successHeading = _ref.successHeading,
@@ -269,7 +272,7 @@ var CopyableText = function CopyableText(_ref) {
269
272
  _ref$successMessage = _ref.successMessage,
270
273
  successMessage = _ref$successMessage === void 0 ? 'Innholdet ble kopiert til utklippstavlen.' : _ref$successMessage,
271
274
  className = _ref.className,
272
- rest = _objectWithoutPropertiesLoose(_ref, ["children", "successHeading", "successMessage", "className"]);
275
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$1);
273
276
 
274
277
  var _useToast = useToast(),
275
278
  addToast = _useToast.addToast;
@@ -285,7 +288,7 @@ var CopyableText = function CopyableText(_ref) {
285
288
  });
286
289
  };
287
290
 
288
- return React.createElement("button", Object.assign({
291
+ return React.createElement("button", _extends({
289
292
  className: 'copyable-text ' + className,
290
293
  style: _extends({}, rest.style),
291
294
  type: "button",
@@ -297,13 +300,14 @@ var CopyableText = function CopyableText(_ref) {
297
300
  }));
298
301
  };
299
302
 
303
+ var _excluded = ["variant", "title", "children", "size", "className", "openLabel", "closeLabel"];
300
304
  var SmallExpandableAlertBox = function SmallExpandableAlertBox(props) {
301
- return React.createElement(ExpandableAlertBox, Object.assign({
305
+ return React.createElement(ExpandableAlertBox, _extends({
302
306
  size: "small"
303
307
  }, props));
304
308
  };
305
309
  var BannerExpandableAlertBox = function BannerExpandableAlertBox(props) {
306
- return React.createElement(ExpandableAlertBox, Object.assign({
310
+ return React.createElement(ExpandableAlertBox, _extends({
307
311
  size: "banner"
308
312
  }, props));
309
313
  };
@@ -316,13 +320,13 @@ var ExpandableAlertBox = function ExpandableAlertBox(_ref) {
316
320
  className = _ref.className,
317
321
  openLabel = _ref.openLabel,
318
322
  closeLabel = _ref.closeLabel,
319
- rest = _objectWithoutPropertiesLoose(_ref, ["variant", "title", "children", "size", "className", "openLabel", "closeLabel"]);
323
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded);
320
324
 
321
325
  var _React$useState = React.useState(false),
322
326
  open = _React$useState[0],
323
327
  setopen = _React$useState[1];
324
328
 
325
- return React.createElement(BaseAlertBox, Object.assign({
329
+ return React.createElement(BaseAlertBox, _extends({
326
330
  size: size,
327
331
  variant: variant,
328
332
  className: classNames('eds-expandable-alert-box', className),
@@ -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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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ACTD,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 ...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,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A7B,CAHvB;AAIEM,IAAAA,KAAK,EACHE,mBAAA,CAAC0F,uBAAD;AACEF,MAAAA,IAAI,EAAEA;AACN1F,MAAAA,KAAK,EAAEA;AACPU,MAAAA,OAAO,EAAE;AAAA,eAAMiF,OAAO,CAAC,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;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@entur/alert",
3
- "version": "0.10.0",
3
+ "version": "0.10.1",
4
4
  "license": "EUPL-1.2",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/alert.esm.js",
@@ -17,29 +17,29 @@
17
17
  "access": "public"
18
18
  },
19
19
  "scripts": {
20
- "start": "tsdx watch --noClean",
21
- "build": "tsdx build",
22
- "test": "tsdx test --env=jsdom",
23
- "lint": "tsdx lint"
20
+ "start": "dts watch --noClean",
21
+ "build": "dts build",
22
+ "test": "dts test --env=jsdom",
23
+ "lint": "dts lint"
24
24
  },
25
25
  "peerDependencies": {
26
26
  "react": ">=16.8.0",
27
27
  "react-dom": ">=16.8.0"
28
28
  },
29
29
  "dependencies": {
30
- "@entur/expand": "^3.3.6",
31
- "@entur/icons": "^3.4.0",
32
- "@entur/typography": "^1.6.10",
33
- "@entur/utils": "^0.4.2",
30
+ "@entur/expand": "^3.3.7",
31
+ "@entur/icons": "^3.4.1",
32
+ "@entur/typography": "^1.6.11",
33
+ "@entur/utils": "^0.4.3",
34
34
  "classnames": "^2.3.1",
35
35
  "copy-text-to-clipboard": "2.2"
36
36
  },
37
37
  "devDependencies": {
38
- "@entur/tokens": "^3.3.0"
38
+ "@entur/tokens": "^3.3.1"
39
39
  },
40
40
  "volta": {
41
41
  "node": "14.17.0",
42
42
  "yarn": "1.18.0"
43
43
  },
44
- "gitHead": "6a15d9e27a27775ee3f86e1d3c09d0e9ce484749"
44
+ "gitHead": "61e643371cfc5653c93160b7c220152e5b2bafeb"
45
45
  }