@equinor/cpl-error-snackbar-react 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +20 -2
- package/dist/index.d.ts +20 -2
- package/dist/index.js +34 -9
- package/dist/index.mjs +34 -9
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as react from 'react';
|
|
3
|
-
import { ReactNode, SetStateAction } from 'react';
|
|
3
|
+
import { ReactNode, SetStateAction, HTMLAttributes } from 'react';
|
|
4
4
|
|
|
5
5
|
interface CopyToClipboardButtonProps {
|
|
6
6
|
value: string;
|
|
@@ -174,7 +174,25 @@ declare const DEFAULT_TIMEOUT_MS_BY_TYPE: {
|
|
|
174
174
|
};
|
|
175
175
|
type Toaster = ReturnType<typeof buildToaster>;
|
|
176
176
|
|
|
177
|
-
|
|
177
|
+
type Placement = 'top-right';
|
|
178
|
+
interface ToastContainerInnerProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
|
|
179
|
+
toasts: Toast[];
|
|
180
|
+
/**
|
|
181
|
+
* The z-index of the toast container.
|
|
182
|
+
*
|
|
183
|
+
* @see {@link DEFAULT_TOAST_CONTAINER_Z_INDEX}
|
|
184
|
+
*
|
|
185
|
+
* @default 1000
|
|
186
|
+
*/
|
|
187
|
+
zIndex?: number;
|
|
188
|
+
deleteToastById: (id: string) => void;
|
|
189
|
+
/**
|
|
190
|
+
* @default "top-right"
|
|
191
|
+
*/
|
|
192
|
+
placement?: Placement;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
interface ToastContainerProps extends Omit<ToastContainerInnerProps, 'toasts' | 'deleteToastById'> {
|
|
178
196
|
toaster: Toaster;
|
|
179
197
|
}
|
|
180
198
|
declare function ToastContainer({ toaster }: ToastContainerProps): react_jsx_runtime.JSX.Element;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as react from 'react';
|
|
3
|
-
import { ReactNode, SetStateAction } from 'react';
|
|
3
|
+
import { ReactNode, SetStateAction, HTMLAttributes } from 'react';
|
|
4
4
|
|
|
5
5
|
interface CopyToClipboardButtonProps {
|
|
6
6
|
value: string;
|
|
@@ -174,7 +174,25 @@ declare const DEFAULT_TIMEOUT_MS_BY_TYPE: {
|
|
|
174
174
|
};
|
|
175
175
|
type Toaster = ReturnType<typeof buildToaster>;
|
|
176
176
|
|
|
177
|
-
|
|
177
|
+
type Placement = 'top-right';
|
|
178
|
+
interface ToastContainerInnerProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
|
|
179
|
+
toasts: Toast[];
|
|
180
|
+
/**
|
|
181
|
+
* The z-index of the toast container.
|
|
182
|
+
*
|
|
183
|
+
* @see {@link DEFAULT_TOAST_CONTAINER_Z_INDEX}
|
|
184
|
+
*
|
|
185
|
+
* @default 1000
|
|
186
|
+
*/
|
|
187
|
+
zIndex?: number;
|
|
188
|
+
deleteToastById: (id: string) => void;
|
|
189
|
+
/**
|
|
190
|
+
* @default "top-right"
|
|
191
|
+
*/
|
|
192
|
+
placement?: Placement;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
interface ToastContainerProps extends Omit<ToastContainerInnerProps, 'toasts' | 'deleteToastById'> {
|
|
178
196
|
toaster: Toaster;
|
|
179
197
|
}
|
|
180
198
|
declare function ToastContainer({ toaster }: ToastContainerProps): react_jsx_runtime.JSX.Element;
|
package/dist/index.js
CHANGED
|
@@ -22,6 +22,18 @@ var __spreadValues = (a, b) => {
|
|
|
22
22
|
return a;
|
|
23
23
|
};
|
|
24
24
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
25
|
+
var __objRest = (source, exclude) => {
|
|
26
|
+
var target = {};
|
|
27
|
+
for (var prop in source)
|
|
28
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
29
|
+
target[prop] = source[prop];
|
|
30
|
+
if (source != null && __getOwnPropSymbols)
|
|
31
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
32
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
33
|
+
target[prop] = source[prop];
|
|
34
|
+
}
|
|
35
|
+
return target;
|
|
36
|
+
};
|
|
25
37
|
var __export = (target, all) => {
|
|
26
38
|
for (var name in all)
|
|
27
39
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -147,7 +159,7 @@ function ErrorSnackbar({
|
|
|
147
159
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(MainColumn, { children: [
|
|
148
160
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(HeaderWrapper, { children: [
|
|
149
161
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
|
|
150
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
162
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(HeaderTypography, { variant: "h6", children: error.title }),
|
|
151
163
|
error.detail && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(BodyTypography, { children: error.detail })
|
|
152
164
|
] }),
|
|
153
165
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
@@ -162,7 +174,7 @@ function ErrorSnackbar({
|
|
|
162
174
|
)
|
|
163
175
|
] }),
|
|
164
176
|
error.error && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
|
|
165
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
177
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(HeaderTypography, { variant: "h6", children: "Error details:" }),
|
|
166
178
|
error.error.message && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(BodyTypography, { children: error.error.message }),
|
|
167
179
|
error.error.possibleAction && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(BodyTypography, { children: error.error.possibleAction }),
|
|
168
180
|
((_a = error.error.accessRequirements) == null ? void 0 : _a.length) && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(StyledList, { style: { color: "inherit" }, children: error.error.accessRequirements.map((accessRequirement) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(StyledList.Item, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(BodyTypography, { children: [
|
|
@@ -206,9 +218,13 @@ var HeaderWrapper = import_styled_components2.default.div`
|
|
|
206
218
|
display: flex;
|
|
207
219
|
justify-content: space-between;
|
|
208
220
|
`;
|
|
221
|
+
var HeaderTypography = (0, import_styled_components2.default)(import_eds_core_react2.Typography)`
|
|
222
|
+
color: ${import_eds_tokens.tokens.colors.text.static_icons__default.rgba};
|
|
223
|
+
`;
|
|
209
224
|
var BodyTypography = (0, import_styled_components2.default)(import_eds_core_react2.Typography)`
|
|
210
225
|
font-size: 0.857rem; // 14px
|
|
211
226
|
word-break: break-word;
|
|
227
|
+
color: ${import_eds_tokens.tokens.colors.text.static_icons__default.rgba};
|
|
212
228
|
`;
|
|
213
229
|
var MetadataWrapper = import_styled_components2.default.div`
|
|
214
230
|
display: flex;
|
|
@@ -217,6 +233,7 @@ var MetadataWrapper = import_styled_components2.default.div`
|
|
|
217
233
|
`;
|
|
218
234
|
var MetadataTypography = (0, import_styled_components2.default)(import_eds_core_react2.Typography)`
|
|
219
235
|
font-size: 0.625rem; // 10px
|
|
236
|
+
color: ${import_eds_tokens.tokens.colors.text.static_icons__default.rgba};
|
|
220
237
|
`;
|
|
221
238
|
var CloseButton = (0, import_styled_components2.default)(import_eds_core_react2.Button)`
|
|
222
239
|
margin: -0.5rem;
|
|
@@ -641,16 +658,24 @@ var StyledPaper = (0, import_styled_components4.default)(import_eds_core_react3.
|
|
|
641
658
|
|
|
642
659
|
// src/toast/ToastContainerInner.tsx
|
|
643
660
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
661
|
+
var DEFAULT_TOAST_CONTAINER_Z_INDEX = 1e3;
|
|
662
|
+
function ToastContainerInner(_a) {
|
|
663
|
+
var _b = _a, {
|
|
664
|
+
deleteToastById,
|
|
665
|
+
toasts,
|
|
666
|
+
placement = "top-right",
|
|
667
|
+
zIndex = DEFAULT_TOAST_CONTAINER_Z_INDEX
|
|
668
|
+
} = _b, containerProps = __objRest(_b, [
|
|
669
|
+
"deleteToastById",
|
|
670
|
+
"toasts",
|
|
671
|
+
"placement",
|
|
672
|
+
"zIndex"
|
|
673
|
+
]);
|
|
674
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Container, __spreadProps(__spreadValues({ $placement: placement, $zIndex: zIndex }, containerProps), { children: toasts.map((toast) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ToastItem, { toast, onDelete: deleteToastById }, toast.id)) }));
|
|
651
675
|
}
|
|
652
676
|
var Container = import_styled_components5.default.div`
|
|
653
677
|
position: fixed;
|
|
678
|
+
z-index: ${({ $zIndex }) => $zIndex};
|
|
654
679
|
|
|
655
680
|
padding: 16px;
|
|
656
681
|
margin: -16px;
|
package/dist/index.mjs
CHANGED
|
@@ -17,6 +17,18 @@ var __spreadValues = (a, b) => {
|
|
|
17
17
|
return a;
|
|
18
18
|
};
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
var __objRest = (source, exclude) => {
|
|
21
|
+
var target = {};
|
|
22
|
+
for (var prop in source)
|
|
23
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
+
target[prop] = source[prop];
|
|
25
|
+
if (source != null && __getOwnPropSymbols)
|
|
26
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
}
|
|
30
|
+
return target;
|
|
31
|
+
};
|
|
20
32
|
var __async = (__this, __arguments, generator) => {
|
|
21
33
|
return new Promise((resolve, reject) => {
|
|
22
34
|
var fulfilled = (value) => {
|
|
@@ -103,7 +115,7 @@ function ErrorSnackbar({
|
|
|
103
115
|
/* @__PURE__ */ jsxs2(MainColumn, { children: [
|
|
104
116
|
/* @__PURE__ */ jsxs2(HeaderWrapper, { children: [
|
|
105
117
|
/* @__PURE__ */ jsxs2("div", { children: [
|
|
106
|
-
/* @__PURE__ */ jsx2(
|
|
118
|
+
/* @__PURE__ */ jsx2(HeaderTypography, { variant: "h6", children: error.title }),
|
|
107
119
|
error.detail && /* @__PURE__ */ jsx2(BodyTypography, { children: error.detail })
|
|
108
120
|
] }),
|
|
109
121
|
/* @__PURE__ */ jsx2(
|
|
@@ -118,7 +130,7 @@ function ErrorSnackbar({
|
|
|
118
130
|
)
|
|
119
131
|
] }),
|
|
120
132
|
error.error && /* @__PURE__ */ jsxs2("div", { children: [
|
|
121
|
-
/* @__PURE__ */ jsx2(
|
|
133
|
+
/* @__PURE__ */ jsx2(HeaderTypography, { variant: "h6", children: "Error details:" }),
|
|
122
134
|
error.error.message && /* @__PURE__ */ jsx2(BodyTypography, { children: error.error.message }),
|
|
123
135
|
error.error.possibleAction && /* @__PURE__ */ jsx2(BodyTypography, { children: error.error.possibleAction }),
|
|
124
136
|
((_a = error.error.accessRequirements) == null ? void 0 : _a.length) && /* @__PURE__ */ jsx2(StyledList, { style: { color: "inherit" }, children: error.error.accessRequirements.map((accessRequirement) => /* @__PURE__ */ jsx2(StyledList.Item, { children: /* @__PURE__ */ jsxs2(BodyTypography, { children: [
|
|
@@ -162,9 +174,13 @@ var HeaderWrapper = styled2.div`
|
|
|
162
174
|
display: flex;
|
|
163
175
|
justify-content: space-between;
|
|
164
176
|
`;
|
|
177
|
+
var HeaderTypography = styled2(Typography)`
|
|
178
|
+
color: ${tokens.colors.text.static_icons__default.rgba};
|
|
179
|
+
`;
|
|
165
180
|
var BodyTypography = styled2(Typography)`
|
|
166
181
|
font-size: 0.857rem; // 14px
|
|
167
182
|
word-break: break-word;
|
|
183
|
+
color: ${tokens.colors.text.static_icons__default.rgba};
|
|
168
184
|
`;
|
|
169
185
|
var MetadataWrapper = styled2.div`
|
|
170
186
|
display: flex;
|
|
@@ -173,6 +189,7 @@ var MetadataWrapper = styled2.div`
|
|
|
173
189
|
`;
|
|
174
190
|
var MetadataTypography = styled2(Typography)`
|
|
175
191
|
font-size: 0.625rem; // 10px
|
|
192
|
+
color: ${tokens.colors.text.static_icons__default.rgba};
|
|
176
193
|
`;
|
|
177
194
|
var CloseButton = styled2(Button2)`
|
|
178
195
|
margin: -0.5rem;
|
|
@@ -597,16 +614,24 @@ var StyledPaper = styled4(Paper)`
|
|
|
597
614
|
|
|
598
615
|
// src/toast/ToastContainerInner.tsx
|
|
599
616
|
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
617
|
+
var DEFAULT_TOAST_CONTAINER_Z_INDEX = 1e3;
|
|
618
|
+
function ToastContainerInner(_a) {
|
|
619
|
+
var _b = _a, {
|
|
620
|
+
deleteToastById,
|
|
621
|
+
toasts,
|
|
622
|
+
placement = "top-right",
|
|
623
|
+
zIndex = DEFAULT_TOAST_CONTAINER_Z_INDEX
|
|
624
|
+
} = _b, containerProps = __objRest(_b, [
|
|
625
|
+
"deleteToastById",
|
|
626
|
+
"toasts",
|
|
627
|
+
"placement",
|
|
628
|
+
"zIndex"
|
|
629
|
+
]);
|
|
630
|
+
return /* @__PURE__ */ jsx7(Container, __spreadProps(__spreadValues({ $placement: placement, $zIndex: zIndex }, containerProps), { children: toasts.map((toast) => /* @__PURE__ */ jsx7(ToastItem, { toast, onDelete: deleteToastById }, toast.id)) }));
|
|
607
631
|
}
|
|
608
632
|
var Container = styled5.div`
|
|
609
633
|
position: fixed;
|
|
634
|
+
z-index: ${({ $zIndex }) => $zIndex};
|
|
610
635
|
|
|
611
636
|
padding: 16px;
|
|
612
637
|
margin: -16px;
|