@telia-ace/knowledge-widget-components-notification-row 1.1.1-rc.2 → 1.1.1-rc.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/index.js +1 -1
- package/index.mjs +66 -9
- package/{notification-row-856f5a51.mjs → notification-row-03145cb0.mjs} +79 -80
- package/notification-row-cc822106.js +114 -0
- package/package.json +6 -6
- package/index-373df3a5.js +0 -6
- package/index-421eaa7e.js +0 -1724
- package/index-5c9c2abf.mjs +0 -883
- package/index-fbfe8881.mjs +0 -7226
- package/notification-row-aa8b7bd7.js +0 -114
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const f=require("@telia-ace/knowledge-data-client"),d=require("@telia-ace/knowledge-widget-core"),w=require("@telia-ace/knowledge-widget-ui"),p=s=>{const{events:h}=s.get("$widget"),[u,c]=d.createEventSubscriber(h);return w.createReactComponent(s,"notification-row",Promise.resolve().then(()=>require("./notification-row-cc822106.js")),t=>{const a=e=>{t.writeProperties({...t.properties(),loading:!0,error:void 0,notifications:[]}),t.actions.dispatch("fetch",{params:e})};return t.actions.create("fetch",({error:e,topNotifications:i,bottomNotifications:o,middleNotifications:g})=>{if(e)return t.actions.dispatch("fetched",{error:e,loading:!0,notifications:[]});let r=[];const{notifications:l,types:n=[]}=t.properties();return n.length?(n.indexOf("top")>-1&&(r=r.concat(i)),n.indexOf("middle")>-1&&(r=r.concat(g)),n.indexOf("bottom")>-1&&(r=r.concat(o))):r=i,t.actions.dispatch("fetched",{notifications:r.length?r:l,loading:!1})}),t.actions.create("fetched",e=>t.writeProperties({...e,loading:!1})),s.getAsync("router").then(e=>{const{params:i}=e.getRouteData();a(i)}),u("router:changed",(e,{current:i})=>{a(i.routeData.params)}),()=>{c()}}).then(()=>d.extendComponent(s,"notification-row",t=>{t.actions.watch("notification-row.fetch",(a,e)=>f.DataClient.getInstance(s).then(i=>i.fetch(f.DataType.RowNotifications,{categories:[a.params.guideCategory,a.params.contactCategory].filter(o=>!!o),searchPhrase:a.params.phrase})).then(e).catch(i=>{if(i)return e(i)}))})).then(()=>{c()})};module.exports=p;
|
package/index.mjs
CHANGED
|
@@ -1,11 +1,68 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "
|
|
3
|
-
import "@
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { DataClient as g, DataType as p } from "@telia-ace/knowledge-data-client";
|
|
2
|
+
import { createEventSubscriber as l, extendComponent as w } from "@telia-ace/knowledge-widget-core";
|
|
3
|
+
import { createReactComponent as m } from "@telia-ace/knowledge-widget-ui";
|
|
4
|
+
const v = (o) => {
|
|
5
|
+
const { events: f } = o.get("$widget"), [h, n] = l(f);
|
|
6
|
+
return m(
|
|
7
|
+
o,
|
|
8
|
+
"notification-row",
|
|
9
|
+
import("./notification-row-03145cb0.mjs"),
|
|
10
|
+
(e) => {
|
|
11
|
+
const r = (t) => {
|
|
12
|
+
e.writeProperties({
|
|
13
|
+
...e.properties(),
|
|
14
|
+
loading: !0,
|
|
15
|
+
error: void 0,
|
|
16
|
+
notifications: []
|
|
17
|
+
}), e.actions.dispatch("fetch", { params: t });
|
|
18
|
+
};
|
|
19
|
+
return e.actions.create(
|
|
20
|
+
"fetch",
|
|
21
|
+
({
|
|
22
|
+
error: t,
|
|
23
|
+
topNotifications: i,
|
|
24
|
+
bottomNotifications: c,
|
|
25
|
+
middleNotifications: d
|
|
26
|
+
}) => {
|
|
27
|
+
if (t)
|
|
28
|
+
return e.actions.dispatch("fetched", {
|
|
29
|
+
error: t,
|
|
30
|
+
loading: !0,
|
|
31
|
+
notifications: []
|
|
32
|
+
});
|
|
33
|
+
let a = [];
|
|
34
|
+
const { notifications: u, types: s = [] } = e.properties();
|
|
35
|
+
return s.length ? (s.indexOf("top") > -1 && (a = a.concat(i)), s.indexOf("middle") > -1 && (a = a.concat(d)), s.indexOf("bottom") > -1 && (a = a.concat(c))) : a = i, e.actions.dispatch("fetched", {
|
|
36
|
+
notifications: a.length ? a : u,
|
|
37
|
+
loading: !1
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
), e.actions.create("fetched", (t) => e.writeProperties({ ...t, loading: !1 })), o.getAsync("router").then((t) => {
|
|
41
|
+
const { params: i } = t.getRouteData();
|
|
42
|
+
r(i);
|
|
43
|
+
}), h("router:changed", (t, { current: i }) => {
|
|
44
|
+
r(i.routeData.params);
|
|
45
|
+
}), () => {
|
|
46
|
+
n();
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
).then(() => w(o, "notification-row", (e) => {
|
|
50
|
+
e.actions.watch("notification-row.fetch", (r, t) => g.getInstance(o).then(
|
|
51
|
+
(i) => i.fetch(p.RowNotifications, {
|
|
52
|
+
categories: [
|
|
53
|
+
r.params.guideCategory,
|
|
54
|
+
r.params.contactCategory
|
|
55
|
+
].filter((c) => !!c),
|
|
56
|
+
searchPhrase: r.params.phrase
|
|
57
|
+
})
|
|
58
|
+
).then(t).catch((i) => {
|
|
59
|
+
if (i)
|
|
60
|
+
return t(i);
|
|
61
|
+
}));
|
|
62
|
+
})).then(() => {
|
|
63
|
+
n();
|
|
64
|
+
});
|
|
65
|
+
};
|
|
9
66
|
export {
|
|
10
|
-
|
|
67
|
+
v as default
|
|
11
68
|
};
|
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { css as
|
|
1
|
+
import { jsxs as v, jsx as i } from "react/jsx-runtime";
|
|
2
|
+
import { css as g } from "@emotion/react";
|
|
3
3
|
import d from "@emotion/styled";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import "
|
|
7
|
-
import "react
|
|
8
|
-
|
|
9
|
-
const O = (e, t) => e.get("seoConfiguration") ? /* @__PURE__ */ n(G, { ...t }) : null, Z = () => X(M), S = "closed-notifications", ee = {
|
|
4
|
+
import { useProperties as G, useContainer as M, createEmptyComponent as E, SymbolBadge as L, genericHtml as Y, linkTabStyle as _, borderTabStyle as N, Html as q, Button as J } from "@telia-ace/knowledge-widget-ui";
|
|
5
|
+
import { readStorage as P, StorageMedium as O, createStorageWriter as Q, StorageCategory as U } from "@telia-ace/widget-services";
|
|
6
|
+
import { appendClassNames as u } from "@telia-ace/widget-utilities";
|
|
7
|
+
import { useState as x, useEffect as A } from "react";
|
|
8
|
+
const S = "closed-notifications", V = {
|
|
10
9
|
transform: {
|
|
11
|
-
a: ({ children: e, ...t }) => /* @__PURE__ */
|
|
10
|
+
a: ({ children: e, ...t }) => /* @__PURE__ */ i("a", { ...t, tabIndex: -1, children: e })
|
|
12
11
|
}
|
|
13
|
-
},
|
|
12
|
+
}, re = ({ className: e, ...t }) => {
|
|
14
13
|
const {
|
|
15
|
-
types:
|
|
14
|
+
types: l = [],
|
|
16
15
|
allowPaging: f = !0,
|
|
17
16
|
notifications: j = [],
|
|
18
17
|
expandable: c = !1,
|
|
@@ -20,84 +19,84 @@ const O = (e, t) => e.get("seoConfiguration") ? /* @__PURE__ */ n(G, { ...t }) :
|
|
|
20
19
|
pageNextAriaLabel: T = "",
|
|
21
20
|
pagePreviousAriaLabel: W = "",
|
|
22
21
|
expandAriaLabel: K = ""
|
|
23
|
-
} =
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
(a = []) =>
|
|
27
|
-
),
|
|
22
|
+
} = G(), [m, D] = x(!1), [b, z] = x([]), [n, y] = x(0), o = M(), [w, F] = x();
|
|
23
|
+
A(() => {
|
|
24
|
+
o && (P(o, S, O.Session).then(
|
|
25
|
+
(a = []) => z(a)
|
|
26
|
+
), Q(o, S, U.Functional).then(
|
|
28
27
|
(a) => F(() => a)
|
|
29
28
|
));
|
|
30
|
-
}, [
|
|
31
|
-
|
|
29
|
+
}, [o]), A(() => {
|
|
30
|
+
o && P(o, S, O.Session).then(
|
|
32
31
|
(a = []) => {
|
|
33
|
-
|
|
34
|
-
(
|
|
32
|
+
b.forEach(
|
|
33
|
+
(r) => a.indexOf(r) === -1 && a.push(r)
|
|
35
34
|
), w && w(a);
|
|
36
35
|
}
|
|
37
36
|
);
|
|
38
|
-
}, [
|
|
39
|
-
const
|
|
40
|
-
if (!
|
|
41
|
-
return
|
|
37
|
+
}, [b, o, w]);
|
|
38
|
+
const s = j.filter(({ id: a }) => b.indexOf(a) === -1), { length: p } = s;
|
|
39
|
+
if (!s.length)
|
|
40
|
+
return E(o, {
|
|
42
41
|
...t,
|
|
43
|
-
className:
|
|
42
|
+
className: u(e, "humany-notification-row")
|
|
44
43
|
});
|
|
45
44
|
if (f) {
|
|
46
|
-
const a =
|
|
45
|
+
const a = s[n] || s[n + 1] || s[n - 1];
|
|
47
46
|
if (!a)
|
|
48
|
-
return
|
|
47
|
+
return E(o, {
|
|
49
48
|
...t,
|
|
50
|
-
className:
|
|
49
|
+
className: u(e, "humany-notification-row")
|
|
51
50
|
});
|
|
52
|
-
const { id:
|
|
51
|
+
const { id: r, body: $ } = a || {}, C = () => D(!m);
|
|
53
52
|
return /* @__PURE__ */ v(
|
|
54
|
-
|
|
53
|
+
B,
|
|
55
54
|
{
|
|
56
55
|
...t,
|
|
57
56
|
"aria-expanded": c ? m : !0,
|
|
58
57
|
"aria-label": K,
|
|
59
58
|
tabIndex: c ? 0 : -1,
|
|
60
|
-
className:
|
|
59
|
+
className: u(e, "humany-notification-row"),
|
|
61
60
|
"data-pageable": p > 1,
|
|
62
|
-
"data-types":
|
|
61
|
+
"data-types": l,
|
|
63
62
|
"data-allow-paging": f,
|
|
64
63
|
"data-expandable": c,
|
|
65
|
-
onKeyDown: (
|
|
66
|
-
|
|
64
|
+
onKeyDown: (h) => {
|
|
65
|
+
h.key === "Enter" && C();
|
|
67
66
|
},
|
|
68
|
-
onClick:
|
|
67
|
+
onClick: C,
|
|
69
68
|
children: [
|
|
70
|
-
/* @__PURE__ */
|
|
71
|
-
|
|
69
|
+
/* @__PURE__ */ i(
|
|
70
|
+
Z,
|
|
72
71
|
{
|
|
73
72
|
"aria-label": R,
|
|
74
73
|
onClick: () => {
|
|
75
|
-
y(
|
|
74
|
+
y(s.indexOf(a)), z([...b, r]);
|
|
76
75
|
},
|
|
77
|
-
children: /* @__PURE__ */
|
|
76
|
+
children: /* @__PURE__ */ i(L, { symbol: { type: "Svg", content: "close" } })
|
|
78
77
|
}
|
|
79
78
|
),
|
|
80
|
-
/* @__PURE__ */
|
|
79
|
+
/* @__PURE__ */ i(
|
|
81
80
|
H,
|
|
82
81
|
{
|
|
83
|
-
htmlParseInstruction: !c || m ? void 0 :
|
|
82
|
+
htmlParseInstruction: !c || m ? void 0 : V,
|
|
84
83
|
"data-pageable": p > 1,
|
|
85
|
-
"data-notification":
|
|
84
|
+
"data-notification": r,
|
|
86
85
|
"data-expandable": c,
|
|
87
86
|
"data-expanded": m,
|
|
88
87
|
html: $
|
|
89
88
|
}
|
|
90
89
|
),
|
|
91
|
-
p > 1 && /* @__PURE__ */ v(
|
|
92
|
-
/* @__PURE__ */
|
|
90
|
+
p > 1 && /* @__PURE__ */ v(X, { children: [
|
|
91
|
+
/* @__PURE__ */ i(
|
|
93
92
|
k,
|
|
94
93
|
{
|
|
95
94
|
"aria-label": W,
|
|
96
|
-
"data-disabled":
|
|
97
|
-
onClick: (
|
|
98
|
-
|
|
95
|
+
"data-disabled": n === 0,
|
|
96
|
+
onClick: (h) => {
|
|
97
|
+
h.stopPropagation(), n > 0 && y(n - 1);
|
|
99
98
|
},
|
|
100
|
-
children: /* @__PURE__ */
|
|
99
|
+
children: /* @__PURE__ */ i(
|
|
101
100
|
I,
|
|
102
101
|
{
|
|
103
102
|
size: 10,
|
|
@@ -107,19 +106,19 @@ const O = (e, t) => e.get("seoConfiguration") ? /* @__PURE__ */ n(G, { ...t }) :
|
|
|
107
106
|
}
|
|
108
107
|
),
|
|
109
108
|
/* @__PURE__ */ v("span", { children: [
|
|
110
|
-
|
|
109
|
+
n + 1,
|
|
111
110
|
"/",
|
|
112
111
|
p
|
|
113
112
|
] }),
|
|
114
|
-
/* @__PURE__ */
|
|
113
|
+
/* @__PURE__ */ i(
|
|
115
114
|
k,
|
|
116
115
|
{
|
|
117
116
|
"aria-label": T,
|
|
118
|
-
"data-disabled":
|
|
119
|
-
onClick: (
|
|
120
|
-
|
|
117
|
+
"data-disabled": n + 1 >= p,
|
|
118
|
+
onClick: (h) => {
|
|
119
|
+
h.stopPropagation(), n < p - 1 && y(n + 1);
|
|
121
120
|
},
|
|
122
|
-
children: /* @__PURE__ */
|
|
121
|
+
children: /* @__PURE__ */ i(
|
|
123
122
|
I,
|
|
124
123
|
{
|
|
125
124
|
size: 10,
|
|
@@ -133,34 +132,34 @@ const O = (e, t) => e.get("seoConfiguration") ? /* @__PURE__ */ n(G, { ...t }) :
|
|
|
133
132
|
}
|
|
134
133
|
);
|
|
135
134
|
}
|
|
136
|
-
return /* @__PURE__ */
|
|
137
|
-
|
|
135
|
+
return /* @__PURE__ */ i(
|
|
136
|
+
B,
|
|
138
137
|
{
|
|
139
138
|
...t,
|
|
140
|
-
className:
|
|
139
|
+
className: u(e, "humany-notification-row"),
|
|
141
140
|
"data-pageable": !1,
|
|
142
|
-
"data-types":
|
|
141
|
+
"data-types": l,
|
|
143
142
|
"data-allow-paging": !1,
|
|
144
|
-
children:
|
|
143
|
+
children: s.map((a) => {
|
|
145
144
|
if (!a)
|
|
146
145
|
return null;
|
|
147
|
-
const { id:
|
|
148
|
-
return /* @__PURE__ */
|
|
146
|
+
const { id: r, body: $ } = a;
|
|
147
|
+
return /* @__PURE__ */ i(
|
|
149
148
|
H,
|
|
150
149
|
{
|
|
151
150
|
"data-pageable": !1,
|
|
152
151
|
"data-expandable": c,
|
|
153
152
|
"data-expanded": m,
|
|
154
|
-
"data-notification":
|
|
153
|
+
"data-notification": r,
|
|
155
154
|
html: $
|
|
156
155
|
},
|
|
157
|
-
|
|
156
|
+
r
|
|
158
157
|
);
|
|
159
158
|
})
|
|
160
159
|
}
|
|
161
160
|
);
|
|
162
|
-
},
|
|
163
|
-
${
|
|
161
|
+
}, B = d.div`
|
|
162
|
+
${Y}
|
|
164
163
|
padding: ${(e) => {
|
|
165
164
|
var t;
|
|
166
165
|
return (t = e.theme.sizes) == null ? void 0 : t.normal;
|
|
@@ -169,8 +168,8 @@ const O = (e, t) => e.get("seoConfiguration") ? /* @__PURE__ */ n(G, { ...t }) :
|
|
|
169
168
|
return ((t = e.theme.sizes) == null ? void 0 : t.cardinal) * 12;
|
|
170
169
|
}}px;
|
|
171
170
|
background-color: ${(e) => {
|
|
172
|
-
var t,
|
|
173
|
-
return e["data-types"].length ? e["data-types"].indexOf("top") > -1 ? (t = e.theme.colors) == null ? void 0 : t.warning : e["data-types"].indexOf("bottom") > -1 ? "transparent" : (
|
|
171
|
+
var t, l, f;
|
|
172
|
+
return e["data-types"].length ? e["data-types"].indexOf("top") > -1 ? (t = e.theme.colors) == null ? void 0 : t.warning : e["data-types"].indexOf("bottom") > -1 ? "transparent" : (l = e.theme.colors) == null ? void 0 : l.primary : (f = e.theme.colors) == null ? void 0 : f.warning;
|
|
174
173
|
}};
|
|
175
174
|
color: ${(e) => {
|
|
176
175
|
var t;
|
|
@@ -197,13 +196,13 @@ const O = (e, t) => e.get("seoConfiguration") ? /* @__PURE__ */ n(G, { ...t }) :
|
|
|
197
196
|
return (t = e.theme.colors) == null ? void 0 : t.link;
|
|
198
197
|
}};
|
|
199
198
|
&:focus-visible {
|
|
200
|
-
${
|
|
199
|
+
${_}
|
|
201
200
|
}
|
|
202
201
|
}
|
|
203
202
|
|
|
204
203
|
${(e) => {
|
|
205
204
|
var t;
|
|
206
|
-
return !e["data-allow-paging"] &&
|
|
205
|
+
return !e["data-allow-paging"] && g`
|
|
207
206
|
flex-wrap: wrap;
|
|
208
207
|
|
|
209
208
|
> div {
|
|
@@ -213,14 +212,14 @@ const O = (e, t) => e.get("seoConfiguration") ? /* @__PURE__ */ n(G, { ...t }) :
|
|
|
213
212
|
`;
|
|
214
213
|
}};
|
|
215
214
|
|
|
216
|
-
${(e) =>
|
|
215
|
+
${(e) => g`
|
|
217
216
|
&:focus-visible {
|
|
218
217
|
.humany-html {
|
|
219
218
|
${N(e)}
|
|
220
219
|
}
|
|
221
220
|
}
|
|
222
221
|
`}
|
|
223
|
-
`, H = d(
|
|
222
|
+
`, H = d(q)`
|
|
224
223
|
flex: 1;
|
|
225
224
|
font-size: ${(e) => {
|
|
226
225
|
var t;
|
|
@@ -229,7 +228,7 @@ const O = (e, t) => e.get("seoConfiguration") ? /* @__PURE__ */ n(G, { ...t }) :
|
|
|
229
228
|
line-height: 1.6em;
|
|
230
229
|
font-weight: 300;
|
|
231
230
|
|
|
232
|
-
${(e) => e["data-expandable"] && !e["data-expanded"] &&
|
|
231
|
+
${(e) => e["data-expandable"] && !e["data-expanded"] && g`
|
|
233
232
|
max-width: 100%;
|
|
234
233
|
|
|
235
234
|
p {
|
|
@@ -243,7 +242,7 @@ const O = (e, t) => e.get("seoConfiguration") ? /* @__PURE__ */ n(G, { ...t }) :
|
|
|
243
242
|
}
|
|
244
243
|
}
|
|
245
244
|
`}
|
|
246
|
-
`,
|
|
245
|
+
`, X = d.div`
|
|
247
246
|
text-align: center;
|
|
248
247
|
width: 100%;
|
|
249
248
|
span {
|
|
@@ -255,7 +254,7 @@ const O = (e, t) => e.get("seoConfiguration") ? /* @__PURE__ */ n(G, { ...t }) :
|
|
|
255
254
|
width: 30px;
|
|
256
255
|
text-align: center;
|
|
257
256
|
}
|
|
258
|
-
`, k = d(
|
|
257
|
+
`, k = d(J)`
|
|
259
258
|
background-color: transparent;
|
|
260
259
|
border: none;
|
|
261
260
|
cursor: pointer;
|
|
@@ -273,24 +272,24 @@ const O = (e, t) => e.get("seoConfiguration") ? /* @__PURE__ */ n(G, { ...t }) :
|
|
|
273
272
|
${N}
|
|
274
273
|
}
|
|
275
274
|
|
|
276
|
-
${(e) => e["data-disabled"] ?
|
|
275
|
+
${(e) => e["data-disabled"] ? g`
|
|
277
276
|
opacity: 0.8;
|
|
278
|
-
` :
|
|
277
|
+
` : g`
|
|
279
278
|
@media (hover) {
|
|
280
279
|
&:hover {
|
|
281
280
|
opacity: 0.5;
|
|
282
281
|
}
|
|
283
282
|
}
|
|
284
283
|
`}
|
|
285
|
-
`,
|
|
284
|
+
`, Z = d(k)`
|
|
286
285
|
position: absolute;
|
|
287
286
|
top: 7.5px;
|
|
288
287
|
right: 7.5px;
|
|
289
288
|
width: 25px;
|
|
290
289
|
height: auto;
|
|
291
290
|
padding: ${(e) => {
|
|
292
|
-
var t,
|
|
293
|
-
return `calc(${(t = e.theme.sizes) == null ? void 0 : t.small}/2) ${(
|
|
291
|
+
var t, l;
|
|
292
|
+
return `calc(${(t = e.theme.sizes) == null ? void 0 : t.small}/2) ${(l = e.theme.sizes) == null ? void 0 : l.small}`;
|
|
294
293
|
}};
|
|
295
294
|
svg {
|
|
296
295
|
vertical-align: middle;
|
|
@@ -311,5 +310,5 @@ d.div`
|
|
|
311
310
|
display: none;
|
|
312
311
|
`;
|
|
313
312
|
export {
|
|
314
|
-
|
|
313
|
+
re as default
|
|
315
314
|
};
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),b=require("@emotion/react"),c=require("@emotion/styled"),i=require("@telia-ace/knowledge-widget-ui"),m=require("@telia-ace/widget-services"),w=require("@telia-ace/widget-utilities"),g=require("react"),j="closed-notifications",L={transform:{a:({children:e,...t})=>n.jsx("a",{...t,tabIndex:-1,children:e})}},R=({className:e,...t})=>{const{types:l=[],allowPaging:u=!0,notifications:N=[],expandable:p=!1,closeAriaLabel:O="",pageNextAriaLabel:B="",pagePreviousAriaLabel:A="",expandAriaLabel:T=""}=i.useProperties(),[x,H]=g.useState(!1),[y,C]=g.useState([]),[o,S]=g.useState(0),s=i.useContainer(),[$,I]=g.useState();g.useEffect(()=>{s&&(m.readStorage(s,j,m.StorageMedium.Session).then((a=[])=>C(a)),m.createStorageWriter(s,j,m.StorageCategory.Functional).then(a=>I(()=>a)))},[s]),g.useEffect(()=>{s&&m.readStorage(s,j,m.StorageMedium.Session).then((a=[])=>{y.forEach(r=>a.indexOf(r)===-1&&a.push(r)),$&&$(a)})},[y,s,$]);const d=N.filter(({id:a})=>y.indexOf(a)===-1),{length:f}=d;if(!d.length)return i.createEmptyComponent(s,{...t,className:w.appendClassNames(e,"humany-notification-row")});if(u){const a=d[o]||d[o+1]||d[o-1];if(!a)return i.createEmptyComponent(s,{...t,className:w.appendClassNames(e,"humany-notification-row")});const{id:r,body:v}=a||{},z=()=>H(!x);return n.jsxs(E,{...t,"aria-expanded":p?x:!0,"aria-label":T,tabIndex:p?0:-1,className:w.appendClassNames(e,"humany-notification-row"),"data-pageable":f>1,"data-types":l,"data-allow-paging":u,"data-expandable":p,onKeyDown:h=>{h.key==="Enter"&&z()},onClick:z,children:[n.jsx(M,{"aria-label":O,onClick:()=>{S(d.indexOf(a)),C([...y,r])},children:n.jsx(i.SymbolBadge,{symbol:{type:"Svg",content:"close"}})}),n.jsx(P,{htmlParseInstruction:!p||x?void 0:L,"data-pageable":f>1,"data-notification":r,"data-expandable":p,"data-expanded":x,html:v}),f>1&&n.jsxs(W,{children:[n.jsx(k,{"aria-label":A,"data-disabled":o===0,onClick:h=>{h.stopPropagation(),o>0&&S(o-1)},children:n.jsx(q,{size:10,symbol:{type:"Svg",content:"caret-left"}})}),n.jsxs("span",{children:[o+1,"/",f]}),n.jsx(k,{"aria-label":B,"data-disabled":o+1>=f,onClick:h=>{h.stopPropagation(),o<f-1&&S(o+1)},children:n.jsx(q,{size:10,symbol:{type:"Svg",content:"caret-right"}})})]})]})}return n.jsx(E,{...t,className:w.appendClassNames(e,"humany-notification-row"),"data-pageable":!1,"data-types":l,"data-allow-paging":!1,children:d.map(a=>{if(!a)return null;const{id:r,body:v}=a;return n.jsx(P,{"data-pageable":!1,"data-expandable":p,"data-expanded":x,"data-notification":r,html:v},r)})})},E=c.div`
|
|
2
|
+
${i.genericHtml}
|
|
3
|
+
padding: ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.normal}} ${e=>{var t;return((t=e.theme.sizes)==null?void 0:t.cardinal)*12}}px;
|
|
4
|
+
background-color: ${e=>{var t,l,u;return e["data-types"].length?e["data-types"].indexOf("top")>-1?(t=e.theme.colors)==null?void 0:t.warning:e["data-types"].indexOf("bottom")>-1?"transparent":(l=e.theme.colors)==null?void 0:l.primary:(u=e.theme.colors)==null?void 0:u.warning}};
|
|
5
|
+
color: ${e=>{var t;return(t=e.theme.colors)==null?void 0:t.text}};
|
|
6
|
+
border-radius: ${e=>e.theme.borderRadius};
|
|
7
|
+
text-align: center;
|
|
8
|
+
display: flex;
|
|
9
|
+
flex-direction: column;
|
|
10
|
+
position: relative;
|
|
11
|
+
cursor: ${e=>e["data-expandable"]?"pointer":"default"};
|
|
12
|
+
overflow: hidden;
|
|
13
|
+
|
|
14
|
+
i {
|
|
15
|
+
color: ${e=>{var t;return(t=e.theme.colors)==null?void 0:t.text}};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
a {
|
|
19
|
+
color: ${e=>{var t;return(t=e.theme.colors)==null?void 0:t.link}};
|
|
20
|
+
&:focus-visible {
|
|
21
|
+
${i.linkTabStyle}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
${e=>{var t;return!e["data-allow-paging"]&&b.css`
|
|
26
|
+
flex-wrap: wrap;
|
|
27
|
+
|
|
28
|
+
> div {
|
|
29
|
+
min-width: 100%;
|
|
30
|
+
margin: ${((t=e.theme.sizes)==null?void 0:t.cardinal)*2}px;
|
|
31
|
+
}
|
|
32
|
+
`}};
|
|
33
|
+
|
|
34
|
+
${e=>b.css`
|
|
35
|
+
&:focus-visible {
|
|
36
|
+
.humany-html {
|
|
37
|
+
${i.borderTabStyle(e)}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
`}
|
|
41
|
+
`,P=c(i.Html)`
|
|
42
|
+
flex: 1;
|
|
43
|
+
font-size: ${e=>{var t;return(t=e.theme.fonts)==null?void 0:t.normal}};
|
|
44
|
+
line-height: 1.6em;
|
|
45
|
+
font-weight: 300;
|
|
46
|
+
|
|
47
|
+
${e=>e["data-expandable"]&&!e["data-expanded"]&&b.css`
|
|
48
|
+
max-width: 100%;
|
|
49
|
+
|
|
50
|
+
p {
|
|
51
|
+
display: none;
|
|
52
|
+
&:first-child {
|
|
53
|
+
display: block;
|
|
54
|
+
margin-bottom: 0;
|
|
55
|
+
white-space: nowrap;
|
|
56
|
+
overflow: hidden;
|
|
57
|
+
text-overflow: ellipsis;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
`}
|
|
61
|
+
`,W=c.div`
|
|
62
|
+
text-align: center;
|
|
63
|
+
width: 100%;
|
|
64
|
+
span {
|
|
65
|
+
font-size: ${e=>{var t;return(t=e.theme.fonts)==null?void 0:t.small}};
|
|
66
|
+
display: inline-block;
|
|
67
|
+
width: 30px;
|
|
68
|
+
text-align: center;
|
|
69
|
+
}
|
|
70
|
+
`,k=c(i.Button)`
|
|
71
|
+
background-color: transparent;
|
|
72
|
+
border: none;
|
|
73
|
+
cursor: pointer;
|
|
74
|
+
transition: opacity 200ms ease-out;
|
|
75
|
+
justify-self: flex-end;
|
|
76
|
+
align-self: flex-start;
|
|
77
|
+
padding: ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.small}} svg {
|
|
78
|
+
display: block;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
&:focus-visible {
|
|
82
|
+
${i.borderTabStyle}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
${e=>e["data-disabled"]?b.css`
|
|
86
|
+
opacity: 0.8;
|
|
87
|
+
`:b.css`
|
|
88
|
+
@media (hover) {
|
|
89
|
+
&:hover {
|
|
90
|
+
opacity: 0.5;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
`}
|
|
94
|
+
`,M=c(k)`
|
|
95
|
+
position: absolute;
|
|
96
|
+
top: 7.5px;
|
|
97
|
+
right: 7.5px;
|
|
98
|
+
width: 25px;
|
|
99
|
+
height: auto;
|
|
100
|
+
padding: ${e=>{var t,l;return`calc(${(t=e.theme.sizes)==null?void 0:t.small}/2) ${(l=e.theme.sizes)==null?void 0:l.small}`}};
|
|
101
|
+
svg {
|
|
102
|
+
vertical-align: middle;
|
|
103
|
+
line,
|
|
104
|
+
path {
|
|
105
|
+
stroke: ${e=>{var t;return(t=e.theme.colors)==null?void 0:t.text}};
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
`,q=c(i.SymbolBadge)`
|
|
109
|
+
line {
|
|
110
|
+
stroke: #ffffff;
|
|
111
|
+
}
|
|
112
|
+
`;c.div`
|
|
113
|
+
display: none;
|
|
114
|
+
`;exports.default=R;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@telia-ace/knowledge-widget-components-notification-row",
|
|
3
|
-
"version": "1.1.1-rc.
|
|
3
|
+
"version": "1.1.1-rc.4",
|
|
4
4
|
"main": "./index.js",
|
|
5
5
|
"types": "./index.d.ts",
|
|
6
6
|
"exports": {
|
|
@@ -10,11 +10,11 @@
|
|
|
10
10
|
}
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@telia-ace/knowledge-widget-core": "^1.1.1-rc.
|
|
14
|
-
"@telia-ace/knowledge-widget-ui": "^1.1.1-rc.
|
|
15
|
-
"@telia-ace/widget-services": "^1.1.1-rc.
|
|
16
|
-
"@telia-ace/widget-utilities": "^1.1.1-rc.
|
|
17
|
-
"@telia-ace/knowledge-data-client": "^1.1.1-rc.
|
|
13
|
+
"@telia-ace/knowledge-widget-core": "^1.1.1-rc.4",
|
|
14
|
+
"@telia-ace/knowledge-widget-ui": "^1.1.1-rc.4",
|
|
15
|
+
"@telia-ace/widget-services": "^1.1.1-rc.4",
|
|
16
|
+
"@telia-ace/widget-utilities": "^1.1.1-rc.4",
|
|
17
|
+
"@telia-ace/knowledge-data-client": "^1.1.1-rc.4",
|
|
18
18
|
"@webprovisions/platform": "^1.1.4"
|
|
19
19
|
},
|
|
20
20
|
"peerDependencies": {
|
package/index-373df3a5.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var p=typeof globalThis<"u"&&globalThis||typeof self<"u"&&self||typeof global<"u"&&global||{},b={searchParams:"URLSearchParams"in p,iterable:"Symbol"in p&&"iterator"in Symbol,blob:"FileReader"in p&&"Blob"in p&&function(){try{return new Blob,!0}catch{return!1}}(),formData:"FormData"in p,arrayBuffer:"ArrayBuffer"in p};function re(t){return t&&DataView.prototype.isPrototypeOf(t)}if(b.arrayBuffer)var ne=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],se=ArrayBuffer.isView||function(t){return t&&ne.indexOf(Object.prototype.toString.call(t))>-1};function S(t){if(typeof t!="string"&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(t)||t==="")throw new TypeError('Invalid character in header field name: "'+t+'"');return t.toLowerCase()}function M(t){return typeof t!="string"&&(t=String(t)),t}function G(t){var e={next:function(){var r=t.shift();return{done:r===void 0,value:r}}};return b.iterable&&(e[Symbol.iterator]=function(){return e}),e}function d(t){this.map={},t instanceof d?t.forEach(function(e,r){this.append(r,e)},this):Array.isArray(t)?t.forEach(function(e){if(e.length!=2)throw new TypeError("Headers constructor: expected name/value pair to be length 2, found"+e.length);this.append(e[0],e[1])},this):t&&Object.getOwnPropertyNames(t).forEach(function(e){this.append(e,t[e])},this)}d.prototype.append=function(t,e){t=S(t),e=M(e);var r=this.map[t];this.map[t]=r?r+", "+e:e};d.prototype.delete=function(t){delete this.map[S(t)]};d.prototype.get=function(t){return t=S(t),this.has(t)?this.map[t]:null};d.prototype.has=function(t){return this.map.hasOwnProperty(S(t))};d.prototype.set=function(t,e){this.map[S(t)]=M(e)};d.prototype.forEach=function(t,e){for(var r in this.map)this.map.hasOwnProperty(r)&&t.call(e,this.map[r],r,this)};d.prototype.keys=function(){var t=[];return this.forEach(function(e,r){t.push(r)}),G(t)};d.prototype.values=function(){var t=[];return this.forEach(function(e){t.push(e)}),G(t)};d.prototype.entries=function(){var t=[];return this.forEach(function(e,r){t.push([r,e])}),G(t)};b.iterable&&(d.prototype[Symbol.iterator]=d.prototype.entries);function L(t){if(!t._noBody){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}}function W(t){return new Promise(function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}})}function oe(t){var e=new FileReader,r=W(e);return e.readAsArrayBuffer(t),r}function ie(t){var e=new FileReader,r=W(e),n=/charset=([A-Za-z0-9_-]+)/.exec(t.type),o=n?n[1]:"utf-8";return e.readAsText(t,o),r}function ae(t){for(var e=new Uint8Array(t),r=new Array(e.length),n=0;n<e.length;n++)r[n]=String.fromCharCode(e[n]);return r.join("")}function V(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function K(){return this.bodyUsed=!1,this._initBody=function(t){this.bodyUsed=this.bodyUsed,this._bodyInit=t,t?typeof t=="string"?this._bodyText=t:b.blob&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:b.formData&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:b.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():b.arrayBuffer&&b.blob&&re(t)?(this._bodyArrayBuffer=V(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):b.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(t)||se(t))?this._bodyArrayBuffer=V(t):this._bodyText=t=Object.prototype.toString.call(t):(this._noBody=!0,this._bodyText=""),this.headers.get("content-type")||(typeof t=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):b.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},b.blob&&(this.blob=function(){var t=L(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))}),this.arrayBuffer=function(){if(this._bodyArrayBuffer){var t=L(this);return t||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}else{if(b.blob)return this.blob().then(oe);throw new Error("could not read as ArrayBuffer")}},this.text=function(){var t=L(this);if(t)return t;if(this._bodyBlob)return ie(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(ae(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},b.formData&&(this.formData=function(){return this.text().then(ue)}),this.json=function(){return this.text().then(JSON.parse)},this}var ce=["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"];function he(t){var e=t.toUpperCase();return ce.indexOf(e)>-1?e:t}function j(t,e){if(!(this instanceof j))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');e=e||{};var r=e.body;if(t instanceof j){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new d(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,!r&&t._bodyInit!=null&&(r=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=e.credentials||this.credentials||"same-origin",(e.headers||!this.headers)&&(this.headers=new d(e.headers)),this.method=he(e.method||this.method||"GET"),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal||function(){if("AbortController"in p){var s=new AbortController;return s.signal}}(),this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&r)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(r),(this.method==="GET"||this.method==="HEAD")&&(e.cache==="no-store"||e.cache==="no-cache")){var n=/([?&])_=[^&]*/;if(n.test(this.url))this.url=this.url.replace(n,"$1_="+new Date().getTime());else{var o=/\?/;this.url+=(o.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}j.prototype.clone=function(){return new j(this,{body:this._bodyInit})};function ue(t){var e=new FormData;return t.trim().split("&").forEach(function(r){if(r){var n=r.split("="),o=n.shift().replace(/\+/g," "),s=n.join("=").replace(/\+/g," ");e.append(decodeURIComponent(o),decodeURIComponent(s))}}),e}function fe(t){var e=new d,r=t.replace(/\r?\n[\t ]+/g," ");return r.split("\r").map(function(n){return n.indexOf(`
|
|
2
|
-
`)===0?n.substr(1,n.length):n}).forEach(function(n){var o=n.split(":"),s=o.shift().trim();if(s){var a=o.join(":").trim();try{e.append(s,a)}catch(c){console.warn("Response "+c.message)}}}),e}K.call(j.prototype);function P(t,e){if(!(this instanceof P))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');if(e||(e={}),this.type="default",this.status=e.status===void 0?200:e.status,this.status<200||this.status>599)throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].");this.ok=this.status>=200&&this.status<300,this.statusText=e.statusText===void 0?"":""+e.statusText,this.headers=new d(e.headers),this.url=e.url||"",this._initBody(t)}K.call(P.prototype);P.prototype.clone=function(){return new P(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new d(this.headers),url:this.url})};P.error=function(){var t=new P(null,{status:200,statusText:""});return t.status=0,t.type="error",t};var le=[301,302,303,307,308];P.redirect=function(t,e){if(le.indexOf(e)===-1)throw new RangeError("Invalid status code");return new P(null,{status:e,headers:{location:t}})};var O=p.DOMException;try{new O}catch{O=function(e,r){this.message=e,this.name=r;var n=Error(e);this.stack=n.stack},O.prototype=Object.create(Error.prototype),O.prototype.constructor=O}function Y(t,e){return new Promise(function(r,n){var o=new j(t,e);if(o.signal&&o.signal.aborted)return n(new O("Aborted","AbortError"));var s=new XMLHttpRequest;function a(){s.abort()}s.onload=function(){var i={statusText:s.statusText,headers:fe(s.getAllResponseHeaders()||"")};o.url.startsWith("file://")&&(s.status<200||s.status>599)?i.status=200:i.status=s.status,i.url="responseURL"in s?s.responseURL:i.headers.get("X-Request-URL");var u="response"in s?s.response:s.responseText;setTimeout(function(){r(new P(u,i))},0)},s.onerror=function(){setTimeout(function(){n(new TypeError("Network request failed"))},0)},s.ontimeout=function(){setTimeout(function(){n(new TypeError("Network request timed out"))},0)},s.onabort=function(){setTimeout(function(){n(new O("Aborted","AbortError"))},0)};function c(i){try{return i===""&&p.location.href?p.location.href:i}catch{return i}}if(s.open(o.method,c(o.url),!0),o.credentials==="include"?s.withCredentials=!0:o.credentials==="omit"&&(s.withCredentials=!1),"responseType"in s&&(b.blob?s.responseType="blob":b.arrayBuffer&&(s.responseType="arraybuffer")),e&&typeof e.headers=="object"&&!(e.headers instanceof d||p.Headers&&e.headers instanceof p.Headers)){var h=[];Object.getOwnPropertyNames(e.headers).forEach(function(i){h.push(S(i)),s.setRequestHeader(i,M(e.headers[i]))}),o.headers.forEach(function(i,u){h.indexOf(u)===-1&&s.setRequestHeader(u,i)})}else o.headers.forEach(function(i,u){s.setRequestHeader(u,i)});o.signal&&(o.signal.addEventListener("abort",a),s.onreadystatechange=function(){s.readyState===4&&o.signal.removeEventListener("abort",a)}),s.send(typeof o._bodyInit>"u"?null:o._bodyInit)})}Y.polyfill=!0;p.fetch||(p.fetch=Y,p.Headers=d,p.Request=j,p.Response=P);self.fetch.bind(self);const F="functional",U="Humany__parameters";function de(t){const e={};return t&&Object.keys(t).forEach(r=>{const n=t[r];(_(n)==="array"?n:[n]).forEach(o=>{typeof e[r]>"u"&&(e[r]=[]),e[r].push(o)})}),e}class pe{constructor(e,r){this.isLoaded=!!e,this.parameters=de(e),r&&typeof r.get=="function"&&(this.container=r)}getAll(){return this.ensureIsLoaded(),l(!0,{},this.parameters)}add(e,r){this.ensureIsLoaded(),this.parameters[e]||(this.parameters[e]=[]),this.parameters[e].push(r),this.persist()}set(e,r){this.ensureIsLoaded(),this.parameters[e]=[r],this.persist()}remove(e,r){if(this.ensureIsLoaded(),typeof r>"u")delete this.parameters[e];else{const n=this.parameters[e]||[];n.forEach((o,s)=>{o===r&&n.splice(s,1)}),this.parameters[e]=n}this.persist()}clear(){this.ensureIsLoaded(),this.parameters={},this.persist()}persist(){try{R(this.container).indexOf(F)>-1?C(U,this.parameters,1):C(U,"",-1)}catch(e){window.console&&window.console.warn&&window.console.warn("Error occured when persisting parameter bag.",e)}}ensureIsLoaded(){if(!this.isLoaded){try{const e=q(U);this.parameters=e||{},R(this.container).indexOf(F)===-1&&C(U,"",-1)}catch(e){window.console&&window.console.warn&&window.console.warn("Error occured when loading parameter bag.",e)}this.isLoaded=!0}}}function E(){return Math.floor((1+Math.random())*65536).toString(16).substring(1)}function z(){return E()+E()+"-"+E()+"-"+E()+"-"+E()+"-"+E()+E()+E()}const Z="analytical",k="Humany__clientId";let T="";function ye(t){if(R(t).indexOf(Z)===-1)return C(k,"",-1),T.length||(T=z()),T;const e=q(k);return e||(T.length||(T=z()),C(k,T,1)),e||T}function be(){return"Default"}function me(...t){const e=window.location;return[t[0]!==!1?"http:":e.protocol,"//",e.host,e.pathname].join("")}function ge(){}const we={"[object Array]":"array","[object Boolean]":"boolean","[object Date]":"date","[object Function]":"function","[object Number]":"number","[object Object]":"object","[object RegExp]":"regexp","[object String]":"string"};function _(t){return t==null?t+"":typeof t=="object"||typeof t=="function"?we[{}.toString.call(t)]||"object":typeof t}function f(t){return _(t)==="function"}function J(t){let e;if(!t||_(t)!=="object"||t.nodeType)return!1;try{if(t.constructor&&!Object.prototype.hasOwnProperty.call(t,"constructor")&&!Object.prototype.hasOwnProperty.call(t.constructor.prototype,"isPrototypeOf"))return!1}catch{return!1}for(e in t);return e===void 0||Object.prototype.hasOwnProperty.call(t,e)}function l(...t){let e,r,n,o,s,a,c=t[0]||{},h=1;const i=t.length;let u=!1;for(typeof c=="boolean"&&(u=c,c=t[1]||{},h=2),typeof c!="object"&&!f(c)&&(c={});h<i;h++)if((e=t[h])!=null)for(r in e)n=c[r],o=e[r],c!==o&&(u&&o&&(J(o)||(s=_(o)==="array"))?(s?(s=!1,a=n&&_(n)==="array"?n:[]):a=n&&J(n)?n:{},c[r]=l(u,a,o)):o!==void 0&&(c[r]=o));return c}const q=t=>{const e=new RegExp(`(?:^|;)\\s?${t}=(.*?)(?:;|$)`,"i"),r=document.cookie.match(e),n=r&&r[1];if(n){if(t==="Humany__clientId")try{return JSON.parse(n)}catch{const s=JSON.stringify(n);return JSON.parse(s)}return JSON.parse(n)}},C=(t,e,r)=>{const n=JSON.stringify(e).trim().replace(/^"+|"+$/g,""),o=`${t}=${n}`,s=`expires=${ve(r)}`,a="path=/",c="SameSite=None",h="Secure";return document.cookie=`${o}; ${s}; ${a}; ${c}; ${h}`},R=t=>{const e=["necessary"];if(!t)return e;const r=t.get("$widget");if(!r||!r.implementation||!r.implementation.tenant)return e;const{implementation:{tenant:n}}=r,o=q(`humany_${n}`);return!o||!o.storagePolicy||!o.storagePolicy.value||!Array.isArray(o.storagePolicy.value)||!o.storagePolicy.value.length?e:o.storagePolicy.value},ve=(t=1)=>{const e=new Date;return e.setTime(e.getTime()+t*24*60*60*1e3),e.toUTCString()},Pe=(t=["necessary"])=>{t.indexOf(F)===-1&&C(U,"",-1),t.indexOf(Z)===-1&&C(k,"",-1)};function $(t,e,r){if(typeof e>"u"||typeof r>"u")return t;const n=t&&t.indexOf("?")!==-1?"&":"?";return`${t}${n}${encodeURIComponent(e)}=${encodeURIComponent(r)}`}const X="p.";function ee(t,e){let r=t;return Object.keys(e).forEach(n=>{const o=e[n];_(o)==="array"?o.forEach(s=>{r=$(r,`${X}${n}`,s)}):r=$(r,`${X}${n}`,o)}),r}class Q{constructor(e,r){l(!0,this,e,{_client:r})}}class H{constructor(e,r){l(!0,this,e,{_client:r})}}function A(t,e,r,n){const o=[];return t[e].forEach(s=>{const a=new r(s,n),c=s[e],h=_(c);s[e]&&(h==="array"||h==="object")&&(a[e]=A(s,e,r,n)),o.push(a)}),o}class N{constructor(e,r){l(!0,this,e,{_client:r})}}function x(t,e){return f(t)?e?t.call(e):t.call(window):t}function I(t,e,r,n){let o=Promise.resolve(r);for(let s=0,a=t.length;s<a;s++){const c=t[s][e];f(c)&&(o=o.then(()=>c(r,n)))}return o}class Ee{constructor(e,r={}){this.setBaseUrl(e),this.globalOptions=r,this.interceptors=r.interceptors||[]}constructUrl(e){return this.baseUrl+e}setBaseUrl(e){this.baseUrl=e+(e[e.length-1]!=="/"?"/":"")}request(e,r){const n=l(!0,{},this.globalOptions,r);let o=this.constructUrl(e);const s=this.interceptors;return n.credentials==="include"&&(o=$(o,"credentials","true")),new Promise((a,c)=>{I(s,"request",{url:o,options:n}).then(h=>fetch(h.url,h.options).then(i=>({response:i,request:h}))).then(({response:h,request:i})=>{if(h.ok){const u=h;return h.json().then(w=>{I(s,"response",{response:h,json:w,request:i}).then(()=>{n.envelope?a({json:w,response:u}):a(w),I(s,"responseEnd",{response:h,json:w,request:i})})})}else I(s,"responseError",h).then(u=>{f(n.onError)&&n.onError(u),c(u)})}).catch(h=>{I(s,"responseError",h).then(i=>{f(n.onError)&&n.onError(i),c(i)})})})}}const te=Ee;/*!
|
|
3
|
-
* Humany Service Client Library
|
|
4
|
-
* Version: 2.0
|
|
5
|
-
* Copyright 2017, Telia Company AB, http://www.humany.com/
|
|
6
|
-
*/class B{constructor(...e){const r=e[1]||{};if(this.proxy=typeof e[0]=="string"?new te(e[0]):e[0],this.settings=l(!0,{},B.defaults,e[1]||{}),this.parameters=new pe(e[2],e[3]),this.current={phrase:r.phrase},this.guideCache={},this.feedbackTypes={positive:"Positive",negative:"Negative",comment:"Comment"},this.handoverTypes={email:"Email",chat:"Chat",callback:"Callback",phone:"Phone",emailComplementary:"ComplementaryEmail",chatComplementary:"ComplementaryChat",callbackComplementary:"ComplementaryCallback",phoneComplementary:"ComplementaryPhone"},this.subscriptions=[],e[3]&&typeof e[3].get=="function"){this.container=e[3];const n=this.container.get("$widget");n&&n.events&&this.subscriptions.push(n.events.subscribe("storage:policy-changed",(o,s)=>Pe(s)))}}getConfiguration(){return{language:x(this.settings.language,this),client:x(()=>this.settings.client(this.container),this),funnel:x(this.settings.funnel,this),site:x(this.settings.site,this),reader:x(this.settings.reader,this),perspective:x(this.settings.perspective,this)}}customRequest(e,r,n={}){const o=n.configuration||{},s=n.parameters;return e=this.constructPath(e,o,s),this.proxy.request(e,{method:r,body:n.body}).then(a=>(n.success&&n.success(a),a)).catch(a=>(n.error&&n.error(a),a))}constructPath(e,r,n=!0){let o=e;const s=l(this.getConfiguration(),r);if(Object.keys(s).filter(a=>{const c=s[a];return c!==null&&typeof c<"u"}).forEach(a=>o=$(o,a,x(s[a]))),n){const a=n===!0?this.parameters.getAll():n;o=ee(o,a)}return o}match(...e){const r=e[0];let n={},o,s;typeof e[1]=="object"?(n=e[1]||{},o=e[2],s=e[3]):(o=e[1],s=e[2]);function a(y){if(f(o)){const v=this;y=this.settings.useProxyClasses&&y?(()=>(y.Matches=A(y,"Matches",N,v),y))():y,o(y)}return y}function c(y){f(s)&&s(y)}const h=l(!0,this.getConfiguration(),this.settings.paging,n),i={};let u="GET";i.categories=h.categories||h.categoryId,i.language=h.language,i.phrase=r,i.attributes=h.attributes,i.skip=h.skip,i.take=h.take,i.reader=h.reader,i.disableNotices=h.disableNotices,i.tags=h.tags,i.includeCategories=h.includeCategories,i.groupByCategory=h.groupByCategory,n.statisticsDisabled||(u="POST",i.funnel=h.funnel,i.client=h.client,i.site=h.site,this.current.phrase=r);const w="guides";n.sorting&&(i["sorting.type"]=n.sorting.type,i["sorting.direction"]=n.sorting.direction);const m=this.constructPath(w,i);return this.proxy.request(m,{method:u}).then(a.bind(this)).catch(c.bind(this))}getGuide(...e){const r=e[0];let n,o={},s,a;typeof e[1]=="function"?(s=e[1],a=e[2]):typeof e[1]=="object"?(o=e[1]||{},s=e[2],a=e[3]):typeof e[1]=="string"?(n=e[1],typeof e[2]=="function"?(s=e[2],a=e[3]):(o=e[2]||{},s=e[3],a=e[4])):!e[1]&&typeof e[2]=="function"&&(s=e[2],a=e[3]);function c(v){if(f(s)){const g=this.settings.useProxyClasses&&v?new N(v,this):v;this.guideCache[g.Id]=g,s(g)}return v}function h(v){return f(a)&&a(v),Promise.reject(v)}const i=l(!0,this.getConfiguration(),o),u={};let w="GET";u.connectionId=n||i.connectionId,u.perspective=i.perspective,u.reader=i.reader,u.phrase=this.current.phrase,this.parameters.remove("LastGuideId"),this.parameters.add("LastGuideId",r);let m=`guides/${r}`;u.connectionId&&(m+=`/${u.connectionId}`);let y="";return!o.statisticsDisabled&&!u.connectionId?(w="POST",y=this.constructPath(m,l({},this.current,o))):y=this.constructPath(m,l({},this.current,o),!1),this.proxy.request(y,{method:w}).then(c.bind(this)).catch(h.bind(this))}getCategories(...e){let r={},n,o;typeof e[0]=="object"?(r=e[0]||{},n=e[1],o=e[2]):(n=e[0],o=e[1]);function s(i){if(f(n)){const u=this;i=this.settings.useProxyClasses&&i?(()=>(i.Children=A(i,"Children",Q,u),i))():i,n(i)}return i}function a(i){f(o)&&o(i)}let c="categories";r.categoryId&&(c+="/"+r.categoryId);const h=this.constructPath(c,l({},this.current,r));return this.proxy.request(h,{method:"GET"}).then(s.bind(this)).catch(a.bind(this))}answer(...e){const r=e[0],n=e[1];let o={},s,a,c;typeof e[2]=="object"?(o=e[2]||{},s=e[3],a=e[4]):(s=e[2],a=e[3]);const h=!!o.persist;function i(){!h&&c&&this.parameters.remove(c.Condition.ParameterName,c.Condition.Value)}function u(g){if(i(),f(s)){const D=this.settings.useProxyClasses&&g?new N(g,this):g;this.guideCache[D.Id]=D,s(D)}}function w(g){i(),f(a)&&a(g)}const m=this.guideCache[r];m.Options&&m.Options.forEach(g=>{this.parameters.remove(g.Condition.ParameterName,g.Condition.Value),g.ConnectionId===n&&(c=g)}),this.parameters.add(c.Condition.ParameterName,c.Condition.Value);const y=`guides/${r}/${n}`,v=this.constructPath(y,l({},this.current,o));return this.proxy.request(v,{method:"GET"}).then(u.bind(this)).catch(w.bind(this))}giveFeedback(...e){const r=e[0];let n,o,s={},a,c;typeof e[2]=="string"?(n=e[1],o=e[2],typeof e[3]=="object"?(s=e[3]||{},a=e[4],c=e[5]):(a=e[3],c=e[4])):(o=e[1],typeof e[2]=="object"&&(s=e[2]||{},a=e[3],c=e[4]));function h(m){return f(a)&&a(m),m}function i(m){return f(c)&&c(m),m}const u=`guides/${r}${n?"/"+n:""}/feedback`,w=this.constructPath(u,l({},s,{feedbackType:o}));return this.proxy.request(w,{method:"POST"}).then(h.bind(this)).catch(i.bind(this))}completeContactMethod(...e){const r=e[0];let n={},o,s;typeof e[1]=="object"?(n=e[1],o=e[2],s=e[3]):(o=e[1],s=e[2]);function a(u){f(o)&&o(u)}function c(u){f(s)&&s(u)}const h=`contactmethods/${r}/completed`,i=this.constructPath(h,n);return this.proxy.request(i,{method:"PUT"}).then(a.bind(this)).catch(c.bind(this))}getContactMethod(...e){const r=e[0];let n={},o,s;typeof e[1]=="object"?(n=e[1],o=e[2],s=e[3]):(o=e[1],s=e[2]);function a(u){if(f(o))o(u.ContactMethod);else return u}function c(u){if(f(s))s(u);else return u}const h=`contactmethods/${r}`,i=this.constructPath(h,l({},this.current,n));return this.proxy.request(i,{method:"GET"}).then(a.bind(this)).catch(c.bind(this))}contactMethods(...e){let r,n={},o,s;typeof e[0]=="number"?(r=e[0],n=e[1]||{},o=e[2],s=e[3]):typeof e[0]=="object"?(n=e[0]||{},o=e[1],s=e[2]):(o=e[0],s=e[1]);function a(u){return f(o)&&(u=this.settings.useProxyClasses&&u?(()=>(u.Matches=A(u,"Matches",H),u))():u,o(u)),u}function c(u){return f(s)&&s(u),u}const h=r?`guides/${r}/contactmethods`:"contactmethods",i=this.constructPath(h,l({},this.current,n));return this.proxy.request(i,{method:"GET"}).then(a.bind(this)).catch(c.bind(this))}contacts(...e){let r,n={},o,s;typeof e[0]=="number"?(r=e[0],typeof e[1]=="object"?(n=e[1],o=e[2],s=e[3]):(o=e[1],s=e[2])):typeof e[0]=="object"?(n=e[0]||{},o=e[1],s=e[2]):(o=e[0],s=e[1]);function a(i){if(f(o))i&&this.settings.useProxyClasses&&(i.Children&&(i.Children=A(i,"Children",Q)),i.Matches&&(i.Matches=A(i,"Matches",H)),i.Highlighted&&(i.Highlighted=A(i,"Highlighted",H))),o(i);else return i}function c(i){if(f(s))s(i);else return i}const h=this.constructPath(`contacts/${r||""}`,l({},this.current,n));return this.proxy.request(h,{method:"GET"}).then(a.bind(this)).catch(c.bind(this))}getSettings(e){const r=this.constructPath("config",this.current);return this.proxy.request(r,{method:"GET"}).then(e)}getAuthorized(e,r){const n=this.constructPath("interfaceauthorized",this.current);return this.proxy.request(n,{method:"GET",credentials:"include"}).then(e).catch(r)}submitForm(e,r,n,o,s){let a="forms/"+e;return n&&(a+="/"+n),a=this.constructPath("config",l({},this.current,r)),this.proxy.request(a,"POST",r,o,s)}getTab(e,r,n,o){var s=arguments;typeof s[1]=="object"?(r=s[1],n=s[2],o=s[3]):(r={},n=s[1],o=s[2]);const a=`tabs/${e}`;return this.proxy.request(a,{method:"GET"}).then(n).catch(o)}dispose(){this.subscriptions.forEach(e=>e())}}B.feedbackTypes={positive:"Positive",negative:"Negative",comment:"Comment"};B.handoverTypes={email:"Email",chat:"Chat",callback:"Callback",phone:"Phone",emailComplementary:"ComplementaryEmail",chatComplementary:"ComplementaryChat",callbackComplementary:"ComplementaryCallback",phoneComplementary:"ComplementaryPhone"};B.defaults={client:ye,funnel:be,site:me,language:ge,paging:{skip:0,take:10},useProxyClasses:!1};B.version="1.0";const Ce=B;exports.ServiceClient=Ce;exports.ServiceProxy=te;exports.appendParameters=ee;exports.appendQueryString=$;exports.getCookie=q;exports.getStoragePolicyConsent=R;exports.setCookie=C;
|