@entur/alert 0.17.13-beta.8 → 0.17.13
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 +372 -0
- package/dist/alert.cjs.js.map +1 -0
- package/dist/alert.esm.js +322 -349
- package/dist/alert.esm.js.map +1 -1
- package/dist/index.d.ts +174 -7
- package/dist/styles.css +487 -501
- package/package.json +28 -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
package/dist/alert.esm.js
CHANGED
|
@@ -1,399 +1,372 @@
|
|
|
1
|
-
import { warnAboutMissingStyles } from
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
13
|
-
for (var e = 1; e < arguments.length; e++) {
|
|
14
|
-
var t = arguments[e];
|
|
15
|
-
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
16
|
-
}
|
|
17
|
-
return n;
|
|
18
|
-
}, _extends.apply(null, arguments);
|
|
19
|
-
}
|
|
20
|
-
function _objectWithoutPropertiesLoose(r, e) {
|
|
21
|
-
if (null == r) return {};
|
|
22
|
-
var t = {};
|
|
23
|
-
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
24
|
-
if (-1 !== e.indexOf(n)) continue;
|
|
25
|
-
t[n] = r[n];
|
|
26
|
-
}
|
|
27
|
-
return t;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
var _excluded$3 = ["children", "className", "closable", "closeButtonLabel", "variant", "onClose", "size", "title", "toastIsBeingRemoved"];
|
|
31
|
-
var iconsMap = {
|
|
1
|
+
import { warnAboutMissingStyles } from "@entur/utils";
|
|
2
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import classNames from "classnames";
|
|
5
|
+
import { ValidationErrorIcon, ValidationInfoIcon, ValidationExclamationIcon, ValidationSuccessIcon, CloseIcon, CopyIcon } from "@entur/icons";
|
|
6
|
+
import { IconButton } from "@entur/button";
|
|
7
|
+
import { Tooltip } from "@entur/tooltip";
|
|
8
|
+
import copy from "copy-text-to-clipboard";
|
|
9
|
+
import { PreformattedText } from "@entur/typography";
|
|
10
|
+
import { BaseExpand, ExpandArrow } from "@entur/expand";
|
|
11
|
+
const iconsMap = {
|
|
32
12
|
success: {
|
|
33
13
|
icon: ValidationSuccessIcon,
|
|
34
|
-
description:
|
|
35
|
-
},
|
|
36
|
-
information: {
|
|
37
|
-
icon: ValidationInfoIcon,
|
|
38
|
-
description: 'Infomelding'
|
|
14
|
+
description: "Suksessmelding"
|
|
39
15
|
},
|
|
16
|
+
information: { icon: ValidationInfoIcon, description: "Infomelding" },
|
|
40
17
|
warning: {
|
|
41
18
|
icon: ValidationExclamationIcon,
|
|
42
|
-
description:
|
|
43
|
-
},
|
|
44
|
-
negative: {
|
|
45
|
-
icon: ValidationErrorIcon,
|
|
46
|
-
description: 'Feilmelding'
|
|
19
|
+
description: "Varselmelding"
|
|
47
20
|
},
|
|
21
|
+
negative: { icon: ValidationErrorIcon, description: "Feilmelding" },
|
|
48
22
|
//deprecated
|
|
49
|
-
info: {
|
|
50
|
-
|
|
51
|
-
description: 'Infomelding'
|
|
52
|
-
},
|
|
53
|
-
error: {
|
|
54
|
-
icon: ValidationErrorIcon,
|
|
55
|
-
description: 'Feilmelding'
|
|
56
|
-
}
|
|
23
|
+
info: { icon: ValidationInfoIcon, description: "Infomelding" },
|
|
24
|
+
error: { icon: ValidationErrorIcon, description: "Feilmelding" }
|
|
57
25
|
};
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
title = _ref.title,
|
|
72
|
-
toastIsBeingRemoved = _ref.toastIsBeingRemoved,
|
|
73
|
-
rest = _objectWithoutPropertiesLoose(_ref, _excluded$3);
|
|
74
|
-
var _React$useState = React.useState(false),
|
|
75
|
-
isClosed = _React$useState[0],
|
|
76
|
-
setClosed = _React$useState[1];
|
|
26
|
+
const BaseAlertBox = ({
|
|
27
|
+
children,
|
|
28
|
+
className,
|
|
29
|
+
closable = false,
|
|
30
|
+
closeButtonLabel = "Lukk",
|
|
31
|
+
variant,
|
|
32
|
+
onClose = () => ({}),
|
|
33
|
+
size,
|
|
34
|
+
title,
|
|
35
|
+
toastIsBeingRemoved,
|
|
36
|
+
...rest
|
|
37
|
+
}) => {
|
|
38
|
+
const [isClosed, setClosed] = React.useState(false);
|
|
77
39
|
if (isClosed) {
|
|
78
40
|
return null;
|
|
79
41
|
}
|
|
80
|
-
|
|
42
|
+
const handleClose = () => {
|
|
81
43
|
setClosed(true);
|
|
82
44
|
onClose();
|
|
83
45
|
};
|
|
84
|
-
|
|
85
|
-
return
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
46
|
+
const Icon = iconsMap[variant].icon;
|
|
47
|
+
return /* @__PURE__ */ jsxs(
|
|
48
|
+
"div",
|
|
49
|
+
{
|
|
50
|
+
className: classNames(
|
|
51
|
+
"eds-alert-box",
|
|
52
|
+
`eds-alert-box--${size}`,
|
|
53
|
+
`eds-alert-box--${variant}`,
|
|
54
|
+
{
|
|
55
|
+
"eds-alert-box--toast--exit-animation": toastIsBeingRemoved,
|
|
56
|
+
"eds-alert-box--no-title": !title
|
|
57
|
+
},
|
|
58
|
+
className
|
|
59
|
+
),
|
|
60
|
+
...rest,
|
|
61
|
+
children: [
|
|
62
|
+
/* @__PURE__ */ jsx(
|
|
63
|
+
Icon,
|
|
64
|
+
{
|
|
65
|
+
role: "img",
|
|
66
|
+
className: "eds-alert-box__icon",
|
|
67
|
+
"aria-label": iconsMap[variant].description
|
|
68
|
+
}
|
|
69
|
+
),
|
|
70
|
+
/* @__PURE__ */ jsxs(
|
|
71
|
+
"div",
|
|
72
|
+
{
|
|
73
|
+
className: classNames("eds-alert-box__content", {
|
|
74
|
+
"eds-alert-box__content--no-children": !children
|
|
75
|
+
}),
|
|
76
|
+
children: [
|
|
77
|
+
title && /* @__PURE__ */ jsx("div", { className: "eds-alert-box__title", children: title }),
|
|
78
|
+
children && children
|
|
79
|
+
]
|
|
80
|
+
}
|
|
81
|
+
),
|
|
82
|
+
closable && /* @__PURE__ */ jsx(
|
|
83
|
+
Tooltip,
|
|
84
|
+
{
|
|
85
|
+
className: "eds-alert-box__tooltip",
|
|
86
|
+
"aria-hidden": true,
|
|
87
|
+
placement: "bottom",
|
|
88
|
+
content: "Lukk",
|
|
89
|
+
children: /* @__PURE__ */ jsx(
|
|
90
|
+
IconButton,
|
|
91
|
+
{
|
|
92
|
+
className: "eds-alert-box__close-button",
|
|
93
|
+
"aria-label": closeButtonLabel,
|
|
94
|
+
onClick: handleClose,
|
|
95
|
+
type: "button",
|
|
96
|
+
children: /* @__PURE__ */ jsx(CloseIcon, {})
|
|
97
|
+
}
|
|
98
|
+
)
|
|
99
|
+
}
|
|
100
|
+
)
|
|
101
|
+
]
|
|
102
|
+
}
|
|
103
|
+
);
|
|
124
104
|
};
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
105
|
+
const BannerAlertBox = (props) => /* @__PURE__ */ jsx(BaseAlertBox, { ...props, size: "banner" });
|
|
106
|
+
const ToastAlertBox = (props) => /* @__PURE__ */ jsx(BaseAlertBox, { ...props, size: "toast", role: "status" });
|
|
107
|
+
const SmallAlertBox = ({
|
|
108
|
+
className,
|
|
109
|
+
width,
|
|
110
|
+
onClose,
|
|
111
|
+
closable = false,
|
|
112
|
+
closeButtonLabel,
|
|
113
|
+
...rest
|
|
114
|
+
}) => /* @__PURE__ */ jsx(
|
|
115
|
+
BaseAlertBox,
|
|
116
|
+
{
|
|
136
117
|
className: classNames(className, {
|
|
137
|
-
|
|
138
|
-
})
|
|
139
|
-
|
|
140
|
-
onClose
|
|
141
|
-
closable
|
|
142
|
-
closeButtonLabel
|
|
118
|
+
"eds-alert-box--fit-content": width === "fit-content"
|
|
119
|
+
}),
|
|
120
|
+
...rest,
|
|
121
|
+
onClose,
|
|
122
|
+
closable,
|
|
123
|
+
closeButtonLabel,
|
|
143
124
|
size: "small"
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
var toastReducer = function toastReducer(prevToasts, action) {
|
|
125
|
+
}
|
|
126
|
+
);
|
|
127
|
+
const EXIT_ANIMATION_TIME = 400;
|
|
128
|
+
const ToastContext = React.createContext(null);
|
|
129
|
+
const toastReducer = (prevToasts, action) => {
|
|
150
130
|
switch (action.type) {
|
|
151
|
-
case
|
|
152
|
-
return [action.payload]
|
|
153
|
-
case
|
|
154
|
-
return prevToasts.map(
|
|
155
|
-
if (toast.id === action.payload)
|
|
156
|
-
isBeingRemoved: true
|
|
157
|
-
});
|
|
131
|
+
case "ADD_TOAST":
|
|
132
|
+
return [action.payload, ...prevToasts];
|
|
133
|
+
case "PLAY_EXIT_ANIMATION":
|
|
134
|
+
return prevToasts.map((toast) => {
|
|
135
|
+
if (toast.id === action.payload)
|
|
136
|
+
return { ...toast, isBeingRemoved: true };
|
|
158
137
|
return toast;
|
|
159
138
|
});
|
|
160
|
-
case
|
|
161
|
-
return prevToasts.filter(
|
|
162
|
-
return toast.id !== action.payload;
|
|
163
|
-
});
|
|
139
|
+
case "REMOVE_TOAST":
|
|
140
|
+
return prevToasts.filter((toast) => toast.id !== action.payload);
|
|
164
141
|
}
|
|
165
142
|
};
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
if (typeof toast === 'string') {
|
|
171
|
-
return {
|
|
172
|
-
id: id,
|
|
173
|
-
content: toast,
|
|
174
|
-
variant: 'success',
|
|
175
|
-
isBeingRemoved: false
|
|
176
|
-
};
|
|
143
|
+
const createUniqueId = () => Math.random().toString().substring(2);
|
|
144
|
+
const createToast = (toast, id) => {
|
|
145
|
+
if (typeof toast === "string") {
|
|
146
|
+
return { id, content: toast, variant: "success", isBeingRemoved: false };
|
|
177
147
|
} else {
|
|
178
|
-
return
|
|
179
|
-
id: id,
|
|
180
|
-
variant: 'success',
|
|
181
|
-
isBeingRemoved: false
|
|
182
|
-
}, toast);
|
|
148
|
+
return { id, variant: "success", isBeingRemoved: false, ...toast };
|
|
183
149
|
}
|
|
184
150
|
};
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
var _React$useState = React.useState(),
|
|
197
|
-
hoveringId = _React$useState[0],
|
|
198
|
-
setHovering = _React$useState[1];
|
|
199
|
-
var timeoutIdRefs = React.useRef({});
|
|
200
|
-
var removeToast = React.useCallback(function (id) {
|
|
151
|
+
const ToastProvider = ({
|
|
152
|
+
delay = 6e3,
|
|
153
|
+
children,
|
|
154
|
+
position = "bottom-right",
|
|
155
|
+
className,
|
|
156
|
+
style
|
|
157
|
+
}) => {
|
|
158
|
+
const [toasts, dispatch] = React.useReducer(toastReducer, []);
|
|
159
|
+
const [hoveringId, setHovering] = React.useState();
|
|
160
|
+
const timeoutIdRefs = React.useRef({});
|
|
161
|
+
const removeToast = React.useCallback((id) => {
|
|
201
162
|
window.clearTimeout(timeoutIdRefs.current[id]);
|
|
202
|
-
dispatch({
|
|
203
|
-
type: 'REMOVE_TOAST',
|
|
204
|
-
payload: id
|
|
205
|
-
});
|
|
163
|
+
dispatch({ type: "REMOVE_TOAST", payload: id });
|
|
206
164
|
delete timeoutIdRefs.current[id];
|
|
207
165
|
}, []);
|
|
208
|
-
|
|
209
|
-
window.clearTimeout(timeoutIdRefs.current[id +
|
|
210
|
-
dispatch({
|
|
211
|
-
|
|
212
|
-
payload: id
|
|
213
|
-
});
|
|
214
|
-
delete timeoutIdRefs.current[id + 'animation'];
|
|
166
|
+
const playExitAnimation = React.useCallback((id) => {
|
|
167
|
+
window.clearTimeout(timeoutIdRefs.current[id + "animation"]);
|
|
168
|
+
dispatch({ type: "PLAY_EXIT_ANIMATION", payload: id });
|
|
169
|
+
delete timeoutIdRefs.current[id + "animation"];
|
|
215
170
|
}, []);
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
171
|
+
const removeToastWithAnimationAfterDelay = React.useCallback(
|
|
172
|
+
(id, delay2) => {
|
|
173
|
+
timeoutIdRefs.current[id + "animation"] = window.setTimeout(
|
|
174
|
+
() => playExitAnimation(id),
|
|
175
|
+
delay2 - EXIT_ANIMATION_TIME
|
|
176
|
+
);
|
|
177
|
+
timeoutIdRefs.current[id] = window.setTimeout(
|
|
178
|
+
() => removeToast(id),
|
|
179
|
+
delay2
|
|
180
|
+
);
|
|
181
|
+
},
|
|
182
|
+
[timeoutIdRefs, playExitAnimation, removeToast]
|
|
183
|
+
);
|
|
184
|
+
const addToast = React.useCallback(
|
|
185
|
+
(toast) => {
|
|
186
|
+
const id = createUniqueId();
|
|
187
|
+
const payload = createToast(toast, id);
|
|
188
|
+
dispatch({ type: "ADD_TOAST", payload });
|
|
189
|
+
removeToastWithAnimationAfterDelay(id, delay);
|
|
190
|
+
},
|
|
191
|
+
[delay, removeToastWithAnimationAfterDelay]
|
|
192
|
+
);
|
|
193
|
+
const handleMouseEnter = (toast) => () => {
|
|
194
|
+
if (toast.isBeingRemoved) return;
|
|
195
|
+
setHovering(toast.id);
|
|
196
|
+
Object.values(timeoutIdRefs.current).forEach((timeoutId) => {
|
|
197
|
+
window.clearTimeout(timeoutId);
|
|
230
198
|
});
|
|
231
|
-
|
|
232
|
-
}, [delay, removeToastWithAnimationAfterDelay]);
|
|
233
|
-
var handleMouseEnter = function handleMouseEnter(toast) {
|
|
234
|
-
return function () {
|
|
235
|
-
if (toast.isBeingRemoved) return;
|
|
236
|
-
setHovering(toast.id);
|
|
237
|
-
Object.values(timeoutIdRefs.current).forEach(function (timeoutId) {
|
|
238
|
-
window.clearTimeout(timeoutId);
|
|
239
|
-
});
|
|
240
|
-
timeoutIdRefs.current = {};
|
|
241
|
-
};
|
|
199
|
+
timeoutIdRefs.current = {};
|
|
242
200
|
};
|
|
243
|
-
|
|
244
|
-
setHovering(
|
|
245
|
-
toasts.forEach(
|
|
201
|
+
const handleMouseLeave = () => {
|
|
202
|
+
setHovering(void 0);
|
|
203
|
+
toasts.forEach((toast) => {
|
|
246
204
|
removeToastWithAnimationAfterDelay(toast.id, delay);
|
|
247
205
|
});
|
|
248
206
|
};
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
handleMouseLeave();
|
|
253
|
-
};
|
|
207
|
+
const handleClose = (toastId) => () => {
|
|
208
|
+
removeToast(toastId);
|
|
209
|
+
handleMouseLeave();
|
|
254
210
|
};
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
211
|
+
const contextValue = React.useMemo(
|
|
212
|
+
() => ({ toasts, addToast, removeToast }),
|
|
213
|
+
[addToast, removeToast, toasts]
|
|
214
|
+
);
|
|
215
|
+
return /* @__PURE__ */ jsxs(ToastContext.Provider, { value: contextValue, children: [
|
|
216
|
+
toasts.length > 0 && /* @__PURE__ */ jsx(
|
|
217
|
+
"div",
|
|
218
|
+
{
|
|
219
|
+
className: classNames(
|
|
220
|
+
"eds-toast-container",
|
|
221
|
+
`eds-toast-container--${position}`,
|
|
222
|
+
className
|
|
223
|
+
),
|
|
224
|
+
style,
|
|
225
|
+
children: toasts.slice(0, 3).map((toastToShow) => /* @__PURE__ */ jsx(
|
|
226
|
+
ToastAlertBox,
|
|
227
|
+
{
|
|
228
|
+
variant: toastToShow.variant,
|
|
229
|
+
title: toastToShow.title,
|
|
230
|
+
onClose: handleClose(toastToShow.id),
|
|
231
|
+
onMouseEnter: handleMouseEnter(toastToShow),
|
|
232
|
+
onMouseLeave: handleMouseLeave,
|
|
233
|
+
closable: hoveringId === toastToShow.id,
|
|
234
|
+
toastIsBeingRemoved: toastToShow.isBeingRemoved,
|
|
235
|
+
children: toastToShow.content
|
|
236
|
+
},
|
|
237
|
+
toastToShow.id
|
|
238
|
+
))
|
|
239
|
+
}
|
|
240
|
+
),
|
|
241
|
+
children
|
|
242
|
+
] });
|
|
279
243
|
};
|
|
280
|
-
|
|
281
|
-
|
|
244
|
+
const useToast = () => {
|
|
245
|
+
const context = React.useContext(ToastContext);
|
|
282
246
|
if (!context) {
|
|
283
|
-
throw new Error(
|
|
247
|
+
throw new Error(
|
|
248
|
+
"You need to wrap your component in a ToastProvider component in order to use the useToast hook"
|
|
249
|
+
);
|
|
284
250
|
}
|
|
285
|
-
|
|
251
|
+
const { addToast } = context;
|
|
286
252
|
return {
|
|
287
|
-
addToast
|
|
253
|
+
addToast
|
|
288
254
|
};
|
|
289
255
|
};
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
var buttonRef = React.useRef(null);
|
|
305
|
-
var _textToCopy = textToCopy != null ? textToCopy : children;
|
|
306
|
-
var _successMessage = successMessage != null ? successMessage : _textToCopy + " ble kopiert til utklippstavlen.";
|
|
307
|
-
var handleClick = function handleClick() {
|
|
256
|
+
const CopyableText = ({
|
|
257
|
+
children,
|
|
258
|
+
successHeading = "Kopiert!",
|
|
259
|
+
successMessage,
|
|
260
|
+
textToCopy,
|
|
261
|
+
className,
|
|
262
|
+
"aria-label": ariaLabel = `Kopier ${textToCopy ?? children} til utklippstavlen`,
|
|
263
|
+
...rest
|
|
264
|
+
}) => {
|
|
265
|
+
const { addToast } = useToast();
|
|
266
|
+
const buttonRef = React.useRef(null);
|
|
267
|
+
const _textToCopy = textToCopy ?? children;
|
|
268
|
+
const _successMessage = successMessage ?? `${_textToCopy} ble kopiert til utklippstavlen.`;
|
|
269
|
+
const handleClick = () => {
|
|
308
270
|
buttonRef.current && copy(_textToCopy, {
|
|
309
271
|
target: buttonRef.current
|
|
310
|
-
}) && addToast({
|
|
311
|
-
title: successHeading,
|
|
312
|
-
content: _successMessage
|
|
313
|
-
});
|
|
272
|
+
}) && addToast({ title: successHeading, content: _successMessage });
|
|
314
273
|
};
|
|
315
|
-
return
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
274
|
+
return /* @__PURE__ */ jsx(
|
|
275
|
+
"div",
|
|
276
|
+
{
|
|
277
|
+
className: "eds-copyable-text " + className,
|
|
278
|
+
style: { ...rest.style },
|
|
279
|
+
type: "button",
|
|
280
|
+
onClick: handleClick,
|
|
281
|
+
tabIndex: -1,
|
|
282
|
+
"aria-label": "",
|
|
283
|
+
...rest,
|
|
284
|
+
children: /* @__PURE__ */ jsxs(PreformattedText, { className: "eds-copyable-text__preformatted-text", children: [
|
|
285
|
+
/* @__PURE__ */ jsx("span", { className: "eds-copyable-text__displayed-text", children }),
|
|
286
|
+
/* @__PURE__ */ jsx(
|
|
287
|
+
IconButton,
|
|
288
|
+
{
|
|
289
|
+
className: "eds-copyable-text__button",
|
|
290
|
+
"aria-label": ariaLabel,
|
|
291
|
+
type: "button",
|
|
292
|
+
ref: buttonRef,
|
|
293
|
+
children: /* @__PURE__ */ jsx(CopyIcon, { className: "eds-copyable-text__button__icon" })
|
|
294
|
+
}
|
|
295
|
+
)
|
|
296
|
+
] })
|
|
297
|
+
}
|
|
298
|
+
);
|
|
334
299
|
};
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
var SmallExpandableAlertBox = function SmallExpandableAlertBox(props) {
|
|
338
|
-
return React.createElement(ExpandableAlertBox, _extends({
|
|
339
|
-
size: "small"
|
|
340
|
-
}, props));
|
|
300
|
+
const SmallExpandableAlertBox = (props) => {
|
|
301
|
+
return /* @__PURE__ */ jsx(ExpandableAlertBox, { size: "small", ...props });
|
|
341
302
|
};
|
|
342
|
-
|
|
343
|
-
return
|
|
344
|
-
|
|
345
|
-
|
|
303
|
+
const BannerExpandableAlertBox = (props) => {
|
|
304
|
+
return /* @__PURE__ */ jsx(ExpandableAlertBox, { size: "banner", ...props });
|
|
305
|
+
};
|
|
306
|
+
const ExpandableAlertBox = ({
|
|
307
|
+
variant,
|
|
308
|
+
title,
|
|
309
|
+
children,
|
|
310
|
+
size,
|
|
311
|
+
className,
|
|
312
|
+
openLabel,
|
|
313
|
+
closeLabel,
|
|
314
|
+
...rest
|
|
315
|
+
}) => {
|
|
316
|
+
const [open, setopen] = React.useState(false);
|
|
317
|
+
return /* @__PURE__ */ jsx(
|
|
318
|
+
BaseAlertBox,
|
|
319
|
+
{
|
|
320
|
+
size,
|
|
321
|
+
variant,
|
|
322
|
+
className: classNames("eds-expandable-alert-box", className),
|
|
323
|
+
title: /* @__PURE__ */ jsx(
|
|
324
|
+
ExpandableAlertBoxTitle,
|
|
325
|
+
{
|
|
326
|
+
open,
|
|
327
|
+
title,
|
|
328
|
+
onClick: () => setopen(!open),
|
|
329
|
+
openLabel,
|
|
330
|
+
closeLabel
|
|
331
|
+
}
|
|
332
|
+
),
|
|
333
|
+
...rest,
|
|
334
|
+
children: /* @__PURE__ */ jsx(BaseExpand, { open, children })
|
|
335
|
+
}
|
|
336
|
+
);
|
|
346
337
|
};
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
openLabel: openLabel,
|
|
370
|
-
closeLabel: closeLabel
|
|
371
|
-
})
|
|
372
|
-
}, rest), React.createElement(BaseExpand, {
|
|
373
|
-
open: open
|
|
374
|
-
}, children));
|
|
338
|
+
const ExpandableAlertBoxTitle = ({
|
|
339
|
+
title,
|
|
340
|
+
open,
|
|
341
|
+
openLabel = "Les mer",
|
|
342
|
+
closeLabel = "Lukk",
|
|
343
|
+
onClick
|
|
344
|
+
}) => {
|
|
345
|
+
return /* @__PURE__ */ jsxs("div", { className: "eds-expandable-alert-box__title", children: [
|
|
346
|
+
/* @__PURE__ */ jsx("div", { children: title }),
|
|
347
|
+
/* @__PURE__ */ jsxs(
|
|
348
|
+
"button",
|
|
349
|
+
{
|
|
350
|
+
className: "eds-expandable-alert-box__button",
|
|
351
|
+
onClick,
|
|
352
|
+
type: "button",
|
|
353
|
+
children: [
|
|
354
|
+
open ? closeLabel : openLabel,
|
|
355
|
+
/* @__PURE__ */ jsx(ExpandArrow, { open, inline: true })
|
|
356
|
+
]
|
|
357
|
+
}
|
|
358
|
+
)
|
|
359
|
+
] });
|
|
375
360
|
};
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
}, React.createElement("div", null, title), React.createElement("button", {
|
|
387
|
-
className: "eds-expandable-alert-box__button",
|
|
388
|
-
onClick: onClick,
|
|
389
|
-
type: "button"
|
|
390
|
-
}, open ? closeLabel : openLabel, React.createElement(ExpandArrow, {
|
|
391
|
-
open: open,
|
|
392
|
-
inline: true
|
|
393
|
-
})));
|
|
361
|
+
warnAboutMissingStyles("alert", "icons");
|
|
362
|
+
export {
|
|
363
|
+
BannerAlertBox,
|
|
364
|
+
BannerExpandableAlertBox,
|
|
365
|
+
CopyableText,
|
|
366
|
+
SmallAlertBox,
|
|
367
|
+
SmallExpandableAlertBox,
|
|
368
|
+
ToastAlertBox,
|
|
369
|
+
ToastProvider,
|
|
370
|
+
useToast
|
|
394
371
|
};
|
|
395
|
-
|
|
396
|
-
warnAboutMissingStyles('alert', 'icons');
|
|
397
|
-
|
|
398
|
-
export { BannerAlertBox, BannerExpandableAlertBox, CopyableText, SmallAlertBox, SmallExpandableAlertBox, ToastAlertBox, ToastProvider, useToast };
|
|
399
372
|
//# sourceMappingURL=alert.esm.js.map
|