@entur/alert 0.17.11 → 0.17.13-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/alert.cjs.js +482 -0
- package/dist/alert.cjs.js.map +1 -0
- package/dist/alert.esm.js +430 -347
- package/dist/alert.esm.js.map +1 -1
- package/dist/index.d.ts +174 -7
- package/dist/styles.css +487 -501
- package/package.json +36 -18
- package/dist/BannerAlertBox.d.ts +0 -27
- package/dist/BaseAlertBox.d.ts +0 -34
- package/dist/CopyableText.d.ts +0 -20
- package/dist/ExpandableAlertBox.d.ts +0 -33
- package/dist/SmallAlertBox.d.ts +0 -29
- package/dist/ToastAlertBox.d.ts +0 -23
- package/dist/ToastProvider.d.ts +0 -30
- package/dist/alert.cjs.development.js +0 -410
- package/dist/alert.cjs.development.js.map +0 -1
- package/dist/alert.cjs.production.min.js +0 -2
- package/dist/alert.cjs.production.min.js.map +0 -1
- package/dist/index.js +0 -8
|
@@ -0,0 +1,482 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const utils = require("@entur/utils");
|
|
4
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
5
|
+
const React = require("react");
|
|
6
|
+
const icons = require("@entur/icons");
|
|
7
|
+
const button = require("@entur/button");
|
|
8
|
+
const tooltip = require("@entur/tooltip");
|
|
9
|
+
const typography = require("@entur/typography");
|
|
10
|
+
const expand = require("@entur/expand");
|
|
11
|
+
function getDefaultExportFromCjs(x) {
|
|
12
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
13
|
+
}
|
|
14
|
+
var classnames = { exports: {} };
|
|
15
|
+
/*!
|
|
16
|
+
Copyright (c) 2018 Jed Watson.
|
|
17
|
+
Licensed under the MIT License (MIT), see
|
|
18
|
+
http://jedwatson.github.io/classnames
|
|
19
|
+
*/
|
|
20
|
+
var hasRequiredClassnames;
|
|
21
|
+
function requireClassnames() {
|
|
22
|
+
if (hasRequiredClassnames) return classnames.exports;
|
|
23
|
+
hasRequiredClassnames = 1;
|
|
24
|
+
(function(module2) {
|
|
25
|
+
(function() {
|
|
26
|
+
var hasOwn = {}.hasOwnProperty;
|
|
27
|
+
function classNames2() {
|
|
28
|
+
var classes = "";
|
|
29
|
+
for (var i = 0; i < arguments.length; i++) {
|
|
30
|
+
var arg = arguments[i];
|
|
31
|
+
if (arg) {
|
|
32
|
+
classes = appendClass(classes, parseValue(arg));
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return classes;
|
|
36
|
+
}
|
|
37
|
+
function parseValue(arg) {
|
|
38
|
+
if (typeof arg === "string" || typeof arg === "number") {
|
|
39
|
+
return arg;
|
|
40
|
+
}
|
|
41
|
+
if (typeof arg !== "object") {
|
|
42
|
+
return "";
|
|
43
|
+
}
|
|
44
|
+
if (Array.isArray(arg)) {
|
|
45
|
+
return classNames2.apply(null, arg);
|
|
46
|
+
}
|
|
47
|
+
if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes("[native code]")) {
|
|
48
|
+
return arg.toString();
|
|
49
|
+
}
|
|
50
|
+
var classes = "";
|
|
51
|
+
for (var key in arg) {
|
|
52
|
+
if (hasOwn.call(arg, key) && arg[key]) {
|
|
53
|
+
classes = appendClass(classes, key);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return classes;
|
|
57
|
+
}
|
|
58
|
+
function appendClass(value, newClass) {
|
|
59
|
+
if (!newClass) {
|
|
60
|
+
return value;
|
|
61
|
+
}
|
|
62
|
+
if (value) {
|
|
63
|
+
return value + " " + newClass;
|
|
64
|
+
}
|
|
65
|
+
return value + newClass;
|
|
66
|
+
}
|
|
67
|
+
if (module2.exports) {
|
|
68
|
+
classNames2.default = classNames2;
|
|
69
|
+
module2.exports = classNames2;
|
|
70
|
+
} else {
|
|
71
|
+
window.classNames = classNames2;
|
|
72
|
+
}
|
|
73
|
+
})();
|
|
74
|
+
})(classnames);
|
|
75
|
+
return classnames.exports;
|
|
76
|
+
}
|
|
77
|
+
var classnamesExports = requireClassnames();
|
|
78
|
+
const classNames = /* @__PURE__ */ getDefaultExportFromCjs(classnamesExports);
|
|
79
|
+
const iconsMap = {
|
|
80
|
+
success: {
|
|
81
|
+
icon: icons.ValidationSuccessIcon,
|
|
82
|
+
description: "Suksessmelding"
|
|
83
|
+
},
|
|
84
|
+
information: { icon: icons.ValidationInfoIcon, description: "Infomelding" },
|
|
85
|
+
warning: {
|
|
86
|
+
icon: icons.ValidationExclamationIcon,
|
|
87
|
+
description: "Varselmelding"
|
|
88
|
+
},
|
|
89
|
+
negative: { icon: icons.ValidationErrorIcon, description: "Feilmelding" },
|
|
90
|
+
//deprecated
|
|
91
|
+
info: { icon: icons.ValidationInfoIcon, description: "Infomelding" },
|
|
92
|
+
error: { icon: icons.ValidationErrorIcon, description: "Feilmelding" }
|
|
93
|
+
};
|
|
94
|
+
const BaseAlertBox = ({
|
|
95
|
+
children,
|
|
96
|
+
className,
|
|
97
|
+
closable = false,
|
|
98
|
+
closeButtonLabel = "Lukk",
|
|
99
|
+
variant,
|
|
100
|
+
onClose = () => ({}),
|
|
101
|
+
size,
|
|
102
|
+
title,
|
|
103
|
+
toastIsBeingRemoved,
|
|
104
|
+
...rest
|
|
105
|
+
}) => {
|
|
106
|
+
const [isClosed, setClosed] = React.useState(false);
|
|
107
|
+
if (isClosed) {
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
const handleClose = () => {
|
|
111
|
+
setClosed(true);
|
|
112
|
+
onClose();
|
|
113
|
+
};
|
|
114
|
+
const Icon = iconsMap[variant].icon;
|
|
115
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
116
|
+
"div",
|
|
117
|
+
{
|
|
118
|
+
className: classNames(
|
|
119
|
+
"eds-alert-box",
|
|
120
|
+
`eds-alert-box--${size}`,
|
|
121
|
+
`eds-alert-box--${variant}`,
|
|
122
|
+
{
|
|
123
|
+
"eds-alert-box--toast--exit-animation": toastIsBeingRemoved,
|
|
124
|
+
"eds-alert-box--no-title": !title
|
|
125
|
+
},
|
|
126
|
+
className
|
|
127
|
+
),
|
|
128
|
+
...rest,
|
|
129
|
+
children: [
|
|
130
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
131
|
+
Icon,
|
|
132
|
+
{
|
|
133
|
+
role: "img",
|
|
134
|
+
className: "eds-alert-box__icon",
|
|
135
|
+
"aria-label": iconsMap[variant].description
|
|
136
|
+
}
|
|
137
|
+
),
|
|
138
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
139
|
+
"div",
|
|
140
|
+
{
|
|
141
|
+
className: classNames("eds-alert-box__content", {
|
|
142
|
+
"eds-alert-box__content--no-children": !children
|
|
143
|
+
}),
|
|
144
|
+
children: [
|
|
145
|
+
title && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "eds-alert-box__title", children: title }),
|
|
146
|
+
children && children
|
|
147
|
+
]
|
|
148
|
+
}
|
|
149
|
+
),
|
|
150
|
+
closable && /* @__PURE__ */ jsxRuntime.jsx(
|
|
151
|
+
tooltip.Tooltip,
|
|
152
|
+
{
|
|
153
|
+
className: "eds-alert-box__tooltip",
|
|
154
|
+
"aria-hidden": true,
|
|
155
|
+
placement: "bottom",
|
|
156
|
+
content: "Lukk",
|
|
157
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
158
|
+
button.IconButton,
|
|
159
|
+
{
|
|
160
|
+
className: "eds-alert-box__close-button",
|
|
161
|
+
"aria-label": closeButtonLabel,
|
|
162
|
+
onClick: handleClose,
|
|
163
|
+
type: "button",
|
|
164
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(icons.CloseIcon, {})
|
|
165
|
+
}
|
|
166
|
+
)
|
|
167
|
+
}
|
|
168
|
+
)
|
|
169
|
+
]
|
|
170
|
+
}
|
|
171
|
+
);
|
|
172
|
+
};
|
|
173
|
+
const BannerAlertBox = (props) => /* @__PURE__ */ jsxRuntime.jsx(BaseAlertBox, { ...props, size: "banner" });
|
|
174
|
+
const ToastAlertBox = (props) => /* @__PURE__ */ jsxRuntime.jsx(BaseAlertBox, { ...props, size: "toast", role: "status" });
|
|
175
|
+
const SmallAlertBox = ({
|
|
176
|
+
className,
|
|
177
|
+
width,
|
|
178
|
+
onClose,
|
|
179
|
+
closable = false,
|
|
180
|
+
closeButtonLabel,
|
|
181
|
+
...rest
|
|
182
|
+
}) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
183
|
+
BaseAlertBox,
|
|
184
|
+
{
|
|
185
|
+
className: classNames(className, {
|
|
186
|
+
"eds-alert-box--fit-content": width === "fit-content"
|
|
187
|
+
}),
|
|
188
|
+
...rest,
|
|
189
|
+
onClose,
|
|
190
|
+
closable,
|
|
191
|
+
closeButtonLabel,
|
|
192
|
+
size: "small"
|
|
193
|
+
}
|
|
194
|
+
);
|
|
195
|
+
const EXIT_ANIMATION_TIME = 400;
|
|
196
|
+
const ToastContext = React.createContext(null);
|
|
197
|
+
const toastReducer = (prevToasts, action) => {
|
|
198
|
+
switch (action.type) {
|
|
199
|
+
case "ADD_TOAST":
|
|
200
|
+
return [action.payload, ...prevToasts];
|
|
201
|
+
case "PLAY_EXIT_ANIMATION":
|
|
202
|
+
return prevToasts.map((toast) => {
|
|
203
|
+
if (toast.id === action.payload)
|
|
204
|
+
return { ...toast, isBeingRemoved: true };
|
|
205
|
+
return toast;
|
|
206
|
+
});
|
|
207
|
+
case "REMOVE_TOAST":
|
|
208
|
+
return prevToasts.filter((toast) => toast.id !== action.payload);
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
const createUniqueId = () => Math.random().toString().substring(2);
|
|
212
|
+
const createToast = (toast, id) => {
|
|
213
|
+
if (typeof toast === "string") {
|
|
214
|
+
return { id, content: toast, variant: "success", isBeingRemoved: false };
|
|
215
|
+
} else {
|
|
216
|
+
return { id, variant: "success", isBeingRemoved: false, ...toast };
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
const ToastProvider = ({
|
|
220
|
+
delay = 6e3,
|
|
221
|
+
children,
|
|
222
|
+
position = "bottom-right",
|
|
223
|
+
className,
|
|
224
|
+
style
|
|
225
|
+
}) => {
|
|
226
|
+
const [toasts, dispatch] = React.useReducer(toastReducer, []);
|
|
227
|
+
const [hoveringId, setHovering] = React.useState();
|
|
228
|
+
const timeoutIdRefs = React.useRef({});
|
|
229
|
+
const removeToast = React.useCallback((id) => {
|
|
230
|
+
window.clearTimeout(timeoutIdRefs.current[id]);
|
|
231
|
+
dispatch({ type: "REMOVE_TOAST", payload: id });
|
|
232
|
+
delete timeoutIdRefs.current[id];
|
|
233
|
+
}, []);
|
|
234
|
+
const playExitAnimation = React.useCallback((id) => {
|
|
235
|
+
window.clearTimeout(timeoutIdRefs.current[id + "animation"]);
|
|
236
|
+
dispatch({ type: "PLAY_EXIT_ANIMATION", payload: id });
|
|
237
|
+
delete timeoutIdRefs.current[id + "animation"];
|
|
238
|
+
}, []);
|
|
239
|
+
const removeToastWithAnimationAfterDelay = React.useCallback(
|
|
240
|
+
(id, delay2) => {
|
|
241
|
+
timeoutIdRefs.current[id + "animation"] = window.setTimeout(
|
|
242
|
+
() => playExitAnimation(id),
|
|
243
|
+
delay2 - EXIT_ANIMATION_TIME
|
|
244
|
+
);
|
|
245
|
+
timeoutIdRefs.current[id] = window.setTimeout(
|
|
246
|
+
() => removeToast(id),
|
|
247
|
+
delay2
|
|
248
|
+
);
|
|
249
|
+
},
|
|
250
|
+
[timeoutIdRefs, playExitAnimation, removeToast]
|
|
251
|
+
);
|
|
252
|
+
const addToast = React.useCallback(
|
|
253
|
+
(toast) => {
|
|
254
|
+
const id = createUniqueId();
|
|
255
|
+
const payload = createToast(toast, id);
|
|
256
|
+
dispatch({ type: "ADD_TOAST", payload });
|
|
257
|
+
removeToastWithAnimationAfterDelay(id, delay);
|
|
258
|
+
},
|
|
259
|
+
[delay, removeToastWithAnimationAfterDelay]
|
|
260
|
+
);
|
|
261
|
+
const handleMouseEnter = (toast) => () => {
|
|
262
|
+
if (toast.isBeingRemoved) return;
|
|
263
|
+
setHovering(toast.id);
|
|
264
|
+
Object.values(timeoutIdRefs.current).forEach((timeoutId) => {
|
|
265
|
+
window.clearTimeout(timeoutId);
|
|
266
|
+
});
|
|
267
|
+
timeoutIdRefs.current = {};
|
|
268
|
+
};
|
|
269
|
+
const handleMouseLeave = () => {
|
|
270
|
+
setHovering(void 0);
|
|
271
|
+
toasts.forEach((toast) => {
|
|
272
|
+
removeToastWithAnimationAfterDelay(toast.id, delay);
|
|
273
|
+
});
|
|
274
|
+
};
|
|
275
|
+
const handleClose = (toastId) => () => {
|
|
276
|
+
removeToast(toastId);
|
|
277
|
+
handleMouseLeave();
|
|
278
|
+
};
|
|
279
|
+
const contextValue = React.useMemo(
|
|
280
|
+
() => ({ toasts, addToast, removeToast }),
|
|
281
|
+
[addToast, removeToast, toasts]
|
|
282
|
+
);
|
|
283
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(ToastContext.Provider, { value: contextValue, children: [
|
|
284
|
+
toasts.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
285
|
+
"div",
|
|
286
|
+
{
|
|
287
|
+
className: classNames(
|
|
288
|
+
"eds-toast-container",
|
|
289
|
+
`eds-toast-container--${position}`,
|
|
290
|
+
className
|
|
291
|
+
),
|
|
292
|
+
style,
|
|
293
|
+
children: toasts.slice(0, 3).map((toastToShow) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
294
|
+
ToastAlertBox,
|
|
295
|
+
{
|
|
296
|
+
variant: toastToShow.variant,
|
|
297
|
+
title: toastToShow.title,
|
|
298
|
+
onClose: handleClose(toastToShow.id),
|
|
299
|
+
onMouseEnter: handleMouseEnter(toastToShow),
|
|
300
|
+
onMouseLeave: handleMouseLeave,
|
|
301
|
+
closable: hoveringId === toastToShow.id,
|
|
302
|
+
toastIsBeingRemoved: toastToShow.isBeingRemoved,
|
|
303
|
+
children: toastToShow.content
|
|
304
|
+
},
|
|
305
|
+
toastToShow.id
|
|
306
|
+
))
|
|
307
|
+
}
|
|
308
|
+
),
|
|
309
|
+
children
|
|
310
|
+
] });
|
|
311
|
+
};
|
|
312
|
+
const useToast = () => {
|
|
313
|
+
const context = React.useContext(ToastContext);
|
|
314
|
+
if (!context) {
|
|
315
|
+
throw new Error(
|
|
316
|
+
"You need to wrap your component in a ToastProvider component in order to use the useToast hook"
|
|
317
|
+
);
|
|
318
|
+
}
|
|
319
|
+
const { addToast } = context;
|
|
320
|
+
return {
|
|
321
|
+
addToast
|
|
322
|
+
};
|
|
323
|
+
};
|
|
324
|
+
var copyTextToClipboard = { exports: {} };
|
|
325
|
+
var hasRequiredCopyTextToClipboard;
|
|
326
|
+
function requireCopyTextToClipboard() {
|
|
327
|
+
if (hasRequiredCopyTextToClipboard) return copyTextToClipboard.exports;
|
|
328
|
+
hasRequiredCopyTextToClipboard = 1;
|
|
329
|
+
const copyTextToClipboard$1 = (input, { target = document.body } = {}) => {
|
|
330
|
+
const element = document.createElement("textarea");
|
|
331
|
+
const previouslyFocusedElement = document.activeElement;
|
|
332
|
+
element.value = input;
|
|
333
|
+
element.setAttribute("readonly", "");
|
|
334
|
+
element.style.contain = "strict";
|
|
335
|
+
element.style.position = "absolute";
|
|
336
|
+
element.style.left = "-9999px";
|
|
337
|
+
element.style.fontSize = "12pt";
|
|
338
|
+
const selection = document.getSelection();
|
|
339
|
+
let originalRange = false;
|
|
340
|
+
if (selection.rangeCount > 0) {
|
|
341
|
+
originalRange = selection.getRangeAt(0);
|
|
342
|
+
}
|
|
343
|
+
target.append(element);
|
|
344
|
+
element.select();
|
|
345
|
+
element.selectionStart = 0;
|
|
346
|
+
element.selectionEnd = input.length;
|
|
347
|
+
let isSuccess = false;
|
|
348
|
+
try {
|
|
349
|
+
isSuccess = document.execCommand("copy");
|
|
350
|
+
} catch (_) {
|
|
351
|
+
}
|
|
352
|
+
element.remove();
|
|
353
|
+
if (originalRange) {
|
|
354
|
+
selection.removeAllRanges();
|
|
355
|
+
selection.addRange(originalRange);
|
|
356
|
+
}
|
|
357
|
+
if (previouslyFocusedElement) {
|
|
358
|
+
previouslyFocusedElement.focus();
|
|
359
|
+
}
|
|
360
|
+
return isSuccess;
|
|
361
|
+
};
|
|
362
|
+
copyTextToClipboard.exports = copyTextToClipboard$1;
|
|
363
|
+
copyTextToClipboard.exports.default = copyTextToClipboard$1;
|
|
364
|
+
return copyTextToClipboard.exports;
|
|
365
|
+
}
|
|
366
|
+
var copyTextToClipboardExports = requireCopyTextToClipboard();
|
|
367
|
+
const copy = /* @__PURE__ */ getDefaultExportFromCjs(copyTextToClipboardExports);
|
|
368
|
+
const CopyableText = ({
|
|
369
|
+
children,
|
|
370
|
+
successHeading = "Kopiert!",
|
|
371
|
+
successMessage,
|
|
372
|
+
textToCopy,
|
|
373
|
+
className,
|
|
374
|
+
"aria-label": ariaLabel = `Kopier ${textToCopy ?? children} til utklippstavlen`,
|
|
375
|
+
...rest
|
|
376
|
+
}) => {
|
|
377
|
+
const { addToast } = useToast();
|
|
378
|
+
const buttonRef = React.useRef(null);
|
|
379
|
+
const _textToCopy = textToCopy ?? children;
|
|
380
|
+
const _successMessage = successMessage ?? `${_textToCopy} ble kopiert til utklippstavlen.`;
|
|
381
|
+
const handleClick = () => {
|
|
382
|
+
buttonRef.current && copy(_textToCopy, {
|
|
383
|
+
target: buttonRef.current
|
|
384
|
+
}) && addToast({ title: successHeading, content: _successMessage });
|
|
385
|
+
};
|
|
386
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
387
|
+
"div",
|
|
388
|
+
{
|
|
389
|
+
className: "eds-copyable-text " + className,
|
|
390
|
+
style: { ...rest.style },
|
|
391
|
+
type: "button",
|
|
392
|
+
onClick: handleClick,
|
|
393
|
+
tabIndex: -1,
|
|
394
|
+
"aria-label": "",
|
|
395
|
+
...rest,
|
|
396
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(typography.PreformattedText, { className: "eds-copyable-text__preformatted-text", children: [
|
|
397
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "eds-copyable-text__displayed-text", children }),
|
|
398
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
399
|
+
button.IconButton,
|
|
400
|
+
{
|
|
401
|
+
className: "eds-copyable-text__button",
|
|
402
|
+
"aria-label": ariaLabel,
|
|
403
|
+
type: "button",
|
|
404
|
+
ref: buttonRef,
|
|
405
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(icons.CopyIcon, { className: "eds-copyable-text__button__icon" })
|
|
406
|
+
}
|
|
407
|
+
)
|
|
408
|
+
] })
|
|
409
|
+
}
|
|
410
|
+
);
|
|
411
|
+
};
|
|
412
|
+
const SmallExpandableAlertBox = (props) => {
|
|
413
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ExpandableAlertBox, { size: "small", ...props });
|
|
414
|
+
};
|
|
415
|
+
const BannerExpandableAlertBox = (props) => {
|
|
416
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ExpandableAlertBox, { size: "banner", ...props });
|
|
417
|
+
};
|
|
418
|
+
const ExpandableAlertBox = ({
|
|
419
|
+
variant,
|
|
420
|
+
title,
|
|
421
|
+
children,
|
|
422
|
+
size,
|
|
423
|
+
className,
|
|
424
|
+
openLabel,
|
|
425
|
+
closeLabel,
|
|
426
|
+
...rest
|
|
427
|
+
}) => {
|
|
428
|
+
const [open, setopen] = React.useState(false);
|
|
429
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
430
|
+
BaseAlertBox,
|
|
431
|
+
{
|
|
432
|
+
size,
|
|
433
|
+
variant,
|
|
434
|
+
className: classNames("eds-expandable-alert-box", className),
|
|
435
|
+
title: /* @__PURE__ */ jsxRuntime.jsx(
|
|
436
|
+
ExpandableAlertBoxTitle,
|
|
437
|
+
{
|
|
438
|
+
open,
|
|
439
|
+
title,
|
|
440
|
+
onClick: () => setopen(!open),
|
|
441
|
+
openLabel,
|
|
442
|
+
closeLabel
|
|
443
|
+
}
|
|
444
|
+
),
|
|
445
|
+
...rest,
|
|
446
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(expand.BaseExpand, { open, children })
|
|
447
|
+
}
|
|
448
|
+
);
|
|
449
|
+
};
|
|
450
|
+
const ExpandableAlertBoxTitle = ({
|
|
451
|
+
title,
|
|
452
|
+
open,
|
|
453
|
+
openLabel = "Les mer",
|
|
454
|
+
closeLabel = "Lukk",
|
|
455
|
+
onClick
|
|
456
|
+
}) => {
|
|
457
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "eds-expandable-alert-box__title", children: [
|
|
458
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { children: title }),
|
|
459
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
460
|
+
"button",
|
|
461
|
+
{
|
|
462
|
+
className: "eds-expandable-alert-box__button",
|
|
463
|
+
onClick,
|
|
464
|
+
type: "button",
|
|
465
|
+
children: [
|
|
466
|
+
open ? closeLabel : openLabel,
|
|
467
|
+
/* @__PURE__ */ jsxRuntime.jsx(expand.ExpandArrow, { open, inline: true })
|
|
468
|
+
]
|
|
469
|
+
}
|
|
470
|
+
)
|
|
471
|
+
] });
|
|
472
|
+
};
|
|
473
|
+
utils.warnAboutMissingStyles("alert", "icons");
|
|
474
|
+
exports.BannerAlertBox = BannerAlertBox;
|
|
475
|
+
exports.BannerExpandableAlertBox = BannerExpandableAlertBox;
|
|
476
|
+
exports.CopyableText = CopyableText;
|
|
477
|
+
exports.SmallAlertBox = SmallAlertBox;
|
|
478
|
+
exports.SmallExpandableAlertBox = SmallExpandableAlertBox;
|
|
479
|
+
exports.ToastAlertBox = ToastAlertBox;
|
|
480
|
+
exports.ToastProvider = ToastProvider;
|
|
481
|
+
exports.useToast = useToast;
|
|
482
|
+
//# sourceMappingURL=alert.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alert.cjs.js","sources":["../../../node_modules/classnames/index.js","../src/BaseAlertBox.tsx","../src/BannerAlertBox.tsx","../src/ToastAlertBox.tsx","../src/SmallAlertBox.tsx","../src/ToastProvider.tsx","../../../node_modules/copy-text-to-clipboard/index.js","../src/CopyableText.tsx","../src/ExpandableAlertBox.tsx","../src/index.tsx"],"sourcesContent":["/*!\n\tCopyright (c) 2018 Jed Watson.\n\tLicensed under the MIT License (MIT), see\n\thttp://jedwatson.github.io/classnames\n*/\n/* global define */\n\n(function () {\n\t'use strict';\n\n\tvar hasOwn = {}.hasOwnProperty;\n\n\tfunction classNames () {\n\t\tvar classes = '';\n\n\t\tfor (var i = 0; i < arguments.length; i++) {\n\t\t\tvar arg = arguments[i];\n\t\t\tif (arg) {\n\t\t\t\tclasses = appendClass(classes, parseValue(arg));\n\t\t\t}\n\t\t}\n\n\t\treturn classes;\n\t}\n\n\tfunction parseValue (arg) {\n\t\tif (typeof arg === 'string' || typeof arg === 'number') {\n\t\t\treturn arg;\n\t\t}\n\n\t\tif (typeof arg !== 'object') {\n\t\t\treturn '';\n\t\t}\n\n\t\tif (Array.isArray(arg)) {\n\t\t\treturn classNames.apply(null, arg);\n\t\t}\n\n\t\tif (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes('[native code]')) {\n\t\t\treturn arg.toString();\n\t\t}\n\n\t\tvar classes = '';\n\n\t\tfor (var key in arg) {\n\t\t\tif (hasOwn.call(arg, key) && arg[key]) {\n\t\t\t\tclasses = appendClass(classes, key);\n\t\t\t}\n\t\t}\n\n\t\treturn classes;\n\t}\n\n\tfunction appendClass (value, newClass) {\n\t\tif (!newClass) {\n\t\t\treturn value;\n\t\t}\n\t\n\t\tif (value) {\n\t\t\treturn value + ' ' + newClass;\n\t\t}\n\t\n\t\treturn value + newClass;\n\t}\n\n\tif (typeof module !== 'undefined' && module.exports) {\n\t\tclassNames.default = classNames;\n\t\tmodule.exports = classNames;\n\t} else if (typeof define === 'function' && typeof define.amd === 'object' && define.amd) {\n\t\t// register as 'classnames', consistent with npm package name\n\t\tdefine('classnames', [], function () {\n\t\t\treturn classNames;\n\t\t});\n\t} else {\n\t\twindow.classNames = classNames;\n\t}\n}());\n","import React from 'react';\nimport classNames from 'classnames';\nimport {\n CloseIcon,\n ValidationSuccessIcon,\n ValidationExclamationIcon,\n ValidationInfoIcon,\n ValidationErrorIcon,\n} from '@entur/icons';\nimport { IconButton } from '@entur/button';\nimport { Tooltip } from '@entur/tooltip';\nimport { VariantType } from '@entur/utils';\n\nimport './BaseAlertBox.scss';\n\nconst iconsMap = {\n success: {\n icon: ValidationSuccessIcon,\n description: 'Suksessmelding',\n },\n information: { icon: ValidationInfoIcon, description: 'Infomelding' },\n warning: {\n icon: ValidationExclamationIcon,\n description: 'Varselmelding',\n },\n negative: { icon: ValidationErrorIcon, description: 'Feilmelding' },\n //deprecated\n info: { icon: ValidationInfoIcon, description: 'Infomelding' },\n error: { icon: ValidationErrorIcon, description: 'Feilmelding' },\n};\n\n/** @deprecated use variant=\"information\" instead */\nconst info = 'info';\n/** @deprecated use variant=\"negative\" instead */\nconst error = 'error';\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: VariantType | typeof info | typeof error;\n /** Typen boks (internt bruk) */\n size: 'banner' | 'toast' | 'small';\n [key: string]: any;\n};\n\nexport const BaseAlertBox: React.FC<BaseAlertBoxProps> = ({\n children,\n className,\n closable = false,\n closeButtonLabel = 'Lukk',\n variant,\n onClose = () => ({}),\n size,\n title,\n toastIsBeingRemoved,\n ...rest\n}) => {\n const [isClosed, setClosed] = React.useState(false);\n if (isClosed) {\n return null;\n }\n const handleClose = () => {\n setClosed(true);\n onClose();\n };\n const Icon = iconsMap[variant].icon;\n return (\n <div\n className={classNames(\n 'eds-alert-box',\n `eds-alert-box--${size}`,\n `eds-alert-box--${variant}`,\n {\n 'eds-alert-box--toast--exit-animation': toastIsBeingRemoved,\n 'eds-alert-box--no-title': !title,\n },\n className,\n )}\n {...rest}\n >\n <Icon\n role=\"img\"\n className=\"eds-alert-box__icon\"\n aria-label={iconsMap[variant].description}\n />\n <div\n className={classNames('eds-alert-box__content', {\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 {closable && (\n <Tooltip\n className=\"eds-alert-box__tooltip\"\n aria-hidden\n placement=\"bottom\"\n content=\"Lukk\"\n >\n <IconButton\n className=\"eds-alert-box__close-button\"\n aria-label={closeButtonLabel}\n onClick={handleClose}\n type=\"button\"\n >\n <CloseIcon />\n </IconButton>\n </Tooltip>\n )}\n </div>\n );\n};\n","import React from 'react';\nimport { BaseAlertBox } from './BaseAlertBox';\n\nimport { VariantType } from '@entur/utils';\n\n/** @deprecated use variant=\"information\" instead */\nconst info = 'info';\n/** @deprecated use variant=\"negative\" instead */\nconst error = 'error';\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: VariantType | typeof info | typeof 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';\nimport './ToastAlertBox.scss';\n\n/** @deprecated use variant=\"information\" instead */\nconst info = 'info';\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' | 'information' | typeof 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\nimport { VariantType } from '@entur/utils';\n\n/** @deprecated use variant=\"information\" instead */\nconst info = 'info';\n/** @deprecated use variant=\"negative\" instead */\nconst error = 'error';\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: VariantType | typeof info | typeof 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\n/** @deprecated use variant=\"information\" instead */\nconst info = 'info';\n\nexport type ToastVariants = 'success' | 'information' | typeof info;\n\ntype ToastType = {\n title?: string;\n content: React.ReactNode;\n id: ToastId;\n variant: ToastVariants;\n isBeingRemoved: boolean;\n};\n\ntype ToastContextType = {\n addToast: (payload: AddToastPayload | string) => void;\n removeToast: (id: ToastId) => void;\n toasts: ToastType[];\n};\n\nexport type AddToastPayload = {\n title?: string;\n content: React.ReactNode;\n variant?: ToastVariants;\n};\n\ntype ToastAction =\n | { type: 'ADD_TOAST'; payload: ToastType }\n | { type: 'REMOVE_TOAST'; payload: ToastId }\n | { type: 'PLAY_EXIT_ANIMATION'; payload: ToastId };\n\nconst EXIT_ANIMATION_TIME = 400;\n\nconst ToastContext = React.createContext<ToastContextType | null>(null);\n\nconst toastReducer = (\n prevToasts: ToastType[],\n action: ToastAction,\n): ToastType[] => {\n switch (action.type) {\n case 'ADD_TOAST':\n return [action.payload, ...prevToasts];\n case 'PLAY_EXIT_ANIMATION':\n return prevToasts.map(toast => {\n if (toast.id === action.payload)\n return { ...toast, isBeingRemoved: true };\n return toast;\n });\n case 'REMOVE_TOAST':\n return prevToasts.filter(toast => toast.id !== action.payload);\n }\n};\n\nconst createUniqueId = () => Math.random().toString().substring(2);\n\nconst createToast = (\n toast: AddToastPayload | string,\n id: ToastId,\n): ToastType => {\n if (typeof toast === 'string') {\n return { id, content: toast, variant: 'success', isBeingRemoved: false };\n } else {\n return { id, variant: 'success', isBeingRemoved: false, ...toast };\n }\n};\n\nexport type ToastProviderProps = {\n /** Antall millisekunder før toasts forsvinner av seg selv\n * @default 6000\n */\n delay?: number;\n /** Plasseringen av toasts\n * @default \"bottom-right\"\n */\n position?: 'bottom-right' | 'top-right';\n /** Ekstra klassenavn til ToastProvider-wrapperen */\n className?: string;\n /** Ekstra styling som sendes til ToastProvider-wrapperen */\n style?: React.CSSProperties;\n /** Innholdet */\n children: React.ReactNode;\n};\n\nexport const ToastProvider: React.FC<ToastProviderProps> = ({\n delay = 6000,\n children,\n position = 'bottom-right',\n className,\n style,\n}) => {\n const [toasts, dispatch] = React.useReducer(toastReducer, []);\n const [hoveringId, setHovering] = React.useState<string>();\n const timeoutIdRefs = React.useRef<{ [key: string]: number }>({});\n\n const removeToast = React.useCallback((id: ToastId) => {\n window.clearTimeout(timeoutIdRefs.current[id]);\n dispatch({ type: 'REMOVE_TOAST', payload: id });\n delete timeoutIdRefs.current[id];\n }, []);\n\n const playExitAnimation = React.useCallback((id: ToastId) => {\n window.clearTimeout(timeoutIdRefs.current[id + 'animation']);\n dispatch({ type: 'PLAY_EXIT_ANIMATION', payload: id });\n delete timeoutIdRefs.current[id + 'animation'];\n }, []);\n\n const removeToastWithAnimationAfterDelay = React.useCallback(\n (id: ToastId, delay: number) => {\n timeoutIdRefs.current[id + 'animation'] = window.setTimeout(\n () => playExitAnimation(id),\n delay - EXIT_ANIMATION_TIME,\n );\n timeoutIdRefs.current[id] = window.setTimeout(\n () => removeToast(id),\n delay,\n );\n },\n [timeoutIdRefs, playExitAnimation, removeToast],\n );\n\n const addToast = React.useCallback(\n (toast: AddToastPayload | string) => {\n const id = createUniqueId();\n const payload = createToast(toast, id);\n dispatch({ type: 'ADD_TOAST', payload });\n removeToastWithAnimationAfterDelay(id, delay);\n },\n [delay, removeToastWithAnimationAfterDelay],\n );\n\n const handleMouseEnter = (toast: ToastType) => () => {\n if (toast.isBeingRemoved) return;\n setHovering(toast.id);\n Object.values(timeoutIdRefs.current).forEach(timeoutId => {\n window.clearTimeout(timeoutId);\n });\n timeoutIdRefs.current = {};\n };\n\n const handleMouseLeave = () => {\n setHovering(undefined);\n toasts.forEach(toast => {\n removeToastWithAnimationAfterDelay(toast.id, delay);\n });\n };\n\n const handleClose = (toastId: ToastId) => () => {\n removeToast(toastId);\n handleMouseLeave();\n };\n\n const contextValue = React.useMemo(\n () => ({ toasts, addToast, removeToast }),\n [addToast, removeToast, toasts],\n );\n\n return (\n <ToastContext.Provider value={contextValue}>\n {toasts.length > 0 && (\n <div\n className={classNames(\n 'eds-toast-container',\n `eds-toast-container--${position}`,\n className,\n )}\n style={style}\n >\n {toasts.slice(0, 3).map(toastToShow => (\n <ToastAlertBox\n variant={toastToShow.variant}\n title={toastToShow.title}\n onClose={handleClose(toastToShow.id)}\n onMouseEnter={handleMouseEnter(toastToShow)}\n onMouseLeave={handleMouseLeave}\n closable={hoveringId === toastToShow.id}\n toastIsBeingRemoved={toastToShow.isBeingRemoved}\n key={toastToShow.id}\n >\n {toastToShow.content}\n </ToastAlertBox>\n ))}\n </div>\n )}\n {children}\n </ToastContext.Provider>\n );\n};\n\nexport const useToast: () => {\n addToast: (payload: AddToastPayload | string) => 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","'use strict';\n\nconst copyTextToClipboard = (input, {target = document.body} = {}) => {\n\tconst element = document.createElement('textarea');\n\tconst previouslyFocusedElement = document.activeElement;\n\n\telement.value = input;\n\n\t// Prevent keyboard from showing on mobile\n\telement.setAttribute('readonly', '');\n\n\telement.style.contain = 'strict';\n\telement.style.position = 'absolute';\n\telement.style.left = '-9999px';\n\telement.style.fontSize = '12pt'; // Prevent zooming on iOS\n\n\tconst selection = document.getSelection();\n\tlet originalRange = false;\n\tif (selection.rangeCount > 0) {\n\t\toriginalRange = selection.getRangeAt(0);\n\t}\n\n\ttarget.append(element);\n\telement.select();\n\n\t// Explicit selection workaround for iOS\n\telement.selectionStart = 0;\n\telement.selectionEnd = input.length;\n\n\tlet isSuccess = false;\n\ttry {\n\t\tisSuccess = document.execCommand('copy');\n\t} catch (_) {}\n\n\telement.remove();\n\n\tif (originalRange) {\n\t\tselection.removeAllRanges();\n\t\tselection.addRange(originalRange);\n\t}\n\n\t// Get the focus back on the previously focused element, if any\n\tif (previouslyFocusedElement) {\n\t\tpreviouslyFocusedElement.focus();\n\t}\n\n\treturn isSuccess;\n};\n\nmodule.exports = copyTextToClipboard;\n// TODO: Remove this for the next major release\nmodule.exports.default = copyTextToClipboard;\n","import React from 'react';\nimport copy from 'copy-text-to-clipboard';\n\nimport { IconButton } from '@entur/button';\nimport { CopyIcon } from '@entur/icons';\nimport { PreformattedText } from '@entur/typography';\n\nimport { useToast } from './ToastProvider';\n\nimport './CopyableText.scss';\n\nexport type CopyableTextProps = {\n /** Ekstra klassenavn */\n className?: string;\n /** Tekstinnhold som vises og kopieres */\n children: string;\n /** Hvis du ønsker å kopiere noe annet enn\n * innholdet i children kan du legge det inn her */\n textToCopy?: string;\n /** Overskrift i toast-varselet\n * @default 'Kopiert!'\n */\n successHeading?: string;\n /** Bekreftelsesmelding i toast-varselet\n * @default `${textToCopy} ble kopiert til utklippstavlen.`\n */\n successMessage?: string;\n} & Omit<React.ButtonHTMLAttributes<HTMLDivElement>, 'children'>;\n\nexport const CopyableText = ({\n children,\n successHeading = 'Kopiert!',\n successMessage,\n textToCopy,\n className,\n 'aria-label': ariaLabel = `Kopier ${\n textToCopy ?? children\n } til utklippstavlen`,\n ...rest\n}: CopyableTextProps): JSX.Element => {\n const { addToast } = useToast();\n const buttonRef = React.useRef<HTMLButtonElement>(null);\n const _textToCopy = textToCopy ?? children;\n const _successMessage =\n successMessage ?? `${_textToCopy} ble kopiert til utklippstavlen.`;\n const handleClick = () => {\n buttonRef.current &&\n copy(_textToCopy, {\n target: buttonRef.current,\n }) &&\n addToast({ title: successHeading, content: _successMessage });\n };\n return (\n <div\n className={'eds-copyable-text ' + className}\n style={{ ...rest.style }}\n type=\"button\"\n onClick={handleClick}\n tabIndex={-1}\n aria-label=\"\"\n {...rest}\n >\n <PreformattedText className=\"eds-copyable-text__preformatted-text\">\n <span className=\"eds-copyable-text__displayed-text\">{children}</span>\n <IconButton\n className=\"eds-copyable-text__button\"\n aria-label={ariaLabel}\n type=\"button\"\n ref={buttonRef}\n >\n <CopyIcon className={'eds-copyable-text__button__icon'} />\n </IconButton>\n </PreformattedText>\n </div>\n );\n};\n","import { BaseExpand, ExpandArrow } from '@entur/expand';\nimport { VariantType } from '@entur/utils';\n\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<\n SmallExpandableAlertBoxProps\n> = props => {\n return <ExpandableAlertBox size=\"small\" {...props} />;\n};\n\nexport type BannerExpandableAlertBoxProps = ExpandableAlertBoxProps &\n BannerAlertBoxProps;\n\nexport const BannerExpandableAlertBox: React.FC<\n BannerExpandableAlertBoxProps\n> = props => {\n return <ExpandableAlertBox size=\"banner\" {...props} />;\n};\n\n/** @deprecated use variant=\"information\" instead */\nconst info = 'info';\n/** @deprecated use variant=\"negative\" instead */\nconst error = 'error';\n\ntype ExpandableAlertBoxProps = {\n /**Farge og uttrykk på alert-boksen*/\n variant: VariantType | typeof info | typeof 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":["classNames","module","ValidationSuccessIcon","ValidationInfoIcon","ValidationExclamationIcon","ValidationErrorIcon","jsxs","jsx","Tooltip","IconButton","CloseIcon","delay","copyTextToClipboard","copyTextToClipboardModule","PreformattedText","CopyIcon","BaseExpand","ExpandArrow","warnAboutMissingStyles"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAOA,KAAC,WAAY;AAGZ,UAAI,SAAS,CAAA,EAAG;AAEhB,eAASA,cAAc;AACtB,YAAI,UAAU;AAEd,iBAAS,IAAI,GAAG,IAAI,UAAU,QAAQ,KAAK;AAC1C,cAAI,MAAM,UAAU,CAAC;AACrB,cAAI,KAAK;AACR,sBAAU,YAAY,SAAS,WAAW,GAAG,CAAC;AAAA,UAClD;AAAA,QAC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