@telia-ace/knowledge-widget-components-notification-row 1.3.27 → 1.3.28-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -1 +1 @@
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-d5534c57.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;
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-7a9d4926.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
@@ -6,7 +6,7 @@ const v = (o) => {
6
6
  return m(
7
7
  o,
8
8
  "notification-row",
9
- import("./notification-row-5d09c41e.mjs"),
9
+ import("./notification-row-a3660cfb.mjs"),
10
10
  (e) => {
11
11
  const r = (t) => {
12
12
  e.writeProperties({
@@ -0,0 +1,114 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),y=require("@emotion/react"),f=require("@emotion/styled"),o=require("@telia-ace/knowledge-widget-ui"),m=require("@telia-ace/widget-services"),S=require("@telia-ace/widget-utilities"),r=require("react"),C="closed-notifications",K={transform:{a:({children:e,...t})=>i.jsx("a",{...t,tabIndex:-1,children:e})}},U=({className:e,...t})=>{const{types:d=[],allowPaging:b=!0,notifications:B=[],closeAriaLabel:A="",pageNextAriaLabel:I="",pagePreviousAriaLabel:T="",expandAriaLabel:N=""}=o.useProperties(),[x,H]=r.useState(!1),[w,R]=r.useState([]),[s,v]=r.useState(0),l=o.useContainer(),[$,L]=r.useState();r.useEffect(()=>{l&&(m.readStorage(l,C,m.StorageMedium.Session).then((a=[])=>R(a)),m.createStorageWriter(l,C,m.StorageCategory.Functional).then(a=>L(()=>a)))},[l]),r.useEffect(()=>{l&&m.readStorage(l,C,m.StorageMedium.Session).then((a=[])=>{w.forEach(n=>a.indexOf(n)===-1&&a.push(n)),$&&$(a)})},[w,l,$]);const p=B.filter(({id:a})=>w.indexOf(a)===-1),{length:u}=p,[c,j]=r.useState(o.useProperties().expandable),W=r.useRef(null),g=l.get("$widget"),M=r.useRef(t.id);if(r.useEffect(()=>{g.events.subscribe("notification:expandable",(a,n)=>{n.notificationRowId===M.current&&j(n.expandable)})},[g.events]),!p.length)return o.createEmptyComponent(l,{...t,className:S.appendClassNames(e,"humany-notification-row")});const z=()=>H(!x);if(b){const a=p[s]||p[s+1]||p[s-1];if(!a)return o.createEmptyComponent(l,{...t,className:S.appendClassNames(e,"humany-notification-row")});const{id:n,body:k}=a||{};return!c&&g.container.expandableNotifications&&g.container.expandableNotifications.has(n)&&j(!0),i.jsxs(P,{...t,...c?{"aria-expanded":x,role:"button"}:{},...N?{"aria-label":N}:{},tabIndex:c?0:-1,className:S.appendClassNames(e,"humany-notification-row"),"data-pageable":u>1,"data-types":d,"data-allow-paging":b,"data-expandable":c,ref:W,onKeyDown:h=>{h.key==="Enter"&&z()},onClick:z,children:[i.jsx(F,{"aria-label":A,onClick:()=>{v(p.indexOf(a)),R([...w,n])},children:i.jsx(o.SymbolBadge,{symbol:{type:"Svg",content:"close"}})}),i.jsx(q,{htmlParseInstruction:!c||x?void 0:K,"data-pageable":u>1,"data-notification":n,"data-expandable":c,"data-expanded":x,html:k}),u>1&&i.jsxs(D,{children:[i.jsx(E,{"data-testid":"page-left-button","aria-label":T,"data-disabled":s===0,onClick:h=>{h.stopPropagation(),s>0&&v(s-1)},children:i.jsx(O,{size:10,symbol:{type:"Svg",content:"caret-left"}})}),i.jsxs("span",{children:[s+1,"/",u]}),i.jsx(E,{"data-testid":"page-right-button","aria-label":I,"data-disabled":s+1>=u,onClick:h=>{h.stopPropagation(),s<u-1&&v(s+1)},children:i.jsx(O,{size:10,symbol:{type:"Svg",content:"caret-right"}})})]})]})}return i.jsx(P,{...t,className:S.appendClassNames(e,"humany-notification-row"),"data-pageable":!1,"data-types":d,"data-allow-paging":!1,children:p.map(a=>{if(!a)return null;const{id:n,body:k}=a;return!c&&g.container.expandableNotifications&&g.container.expandableNotifications.has(n)&&j(!0),i.jsx(q,{"data-pageable":!1,"data-expandable":c,"data-expanded":x,"data-notification":n,html:k},n)})})},P=f.div`
2
+ ${o.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,d,b;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":(d=e.theme.colors)==null?void 0:d.primary:(b=e.theme.colors)==null?void 0:b.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
+ ${o.linkTabStyle}
22
+ }
23
+ }
24
+
25
+ ${e=>{var t;return!e["data-allow-paging"]&&y.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=>y.css`
35
+ &:focus-visible {
36
+ .humany-html {
37
+ ${o.borderTabStyle(e)}
38
+ }
39
+ }
40
+ `}
41
+ `,q=f(o.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"]&&y.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
+ `,D=f.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
+ `,E=f(o.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
+ ${o.borderTabStyle}
83
+ }
84
+
85
+ ${e=>e["data-disabled"]?y.css`
86
+ opacity: 0.8;
87
+ `:y.css`
88
+ @media (hover) {
89
+ &:hover {
90
+ opacity: 0.5;
91
+ }
92
+ }
93
+ `}
94
+ `,F=f(E)`
95
+ position: absolute;
96
+ top: 7.5px;
97
+ right: 7.5px;
98
+ width: 25px;
99
+ height: auto;
100
+ padding: ${e=>{var t,d;return`calc(${(t=e.theme.sizes)==null?void 0:t.small}/2) ${(d=e.theme.sizes)==null?void 0:d.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
+ `,O=f(o.SymbolBadge)`
109
+ line {
110
+ stroke: #ffffff;
111
+ }
112
+ `;f.div`
113
+ display: none;
114
+ `;exports.default=U;
@@ -0,0 +1,328 @@
1
+ import { jsxs as k, jsx as l } from "react/jsx-runtime";
2
+ import { css as u } from "@emotion/react";
3
+ import c from "@emotion/styled";
4
+ import { useProperties as O, useContainer as J, createEmptyComponent as A, SymbolBadge as T, genericHtml as Q, linkTabStyle as U, borderTabStyle as W, Html as V, Button as X } from "@telia-ace/knowledge-widget-ui";
5
+ import { readStorage as B, StorageMedium as I, createStorageWriter as Z, StorageCategory as ee } from "@telia-ace/widget-services";
6
+ import { appendClassNames as y } from "@telia-ace/widget-utilities";
7
+ import te, { useState as h, useEffect as z, useRef as ae } from "react";
8
+ const R = "closed-notifications", ne = {
9
+ transform: {
10
+ a: ({ children: e, ...t }) => /* @__PURE__ */ l("a", { ...t, tabIndex: -1, children: e })
11
+ }
12
+ }, me = ({ className: e, ...t }) => {
13
+ const {
14
+ types: r = [],
15
+ allowPaging: m = !0,
16
+ notifications: K = [],
17
+ closeAriaLabel: D = "",
18
+ pageNextAriaLabel: F = "",
19
+ pagePreviousAriaLabel: G = "",
20
+ expandAriaLabel: C = ""
21
+ } = O(), [b, M] = h(!1), [x, N] = h([]), [i, w] = h(0), o = J(), [$, Y] = h();
22
+ z(() => {
23
+ o && (B(o, R, I.Session).then(
24
+ (a = []) => N(a)
25
+ ), Z(
26
+ o,
27
+ R,
28
+ ee.Functional
29
+ ).then((a) => Y(() => a)));
30
+ }, [o]), z(() => {
31
+ o && B(o, R, I.Session).then(
32
+ (a = []) => {
33
+ x.forEach(
34
+ (n) => a.indexOf(n) === -1 && a.push(n)
35
+ ), $ && $(a);
36
+ }
37
+ );
38
+ }, [x, o, $]);
39
+ const d = K.filter(({ id: a }) => x.indexOf(a) === -1), { length: p } = d, [s, v] = h(
40
+ O().expandable
41
+ ), _ = te.useRef(null), f = o.get("$widget"), q = ae(t.id);
42
+ if (z(() => {
43
+ f.events.subscribe(
44
+ "notification:expandable",
45
+ (a, n) => {
46
+ n.notificationRowId === q.current && v(n.expandable);
47
+ }
48
+ );
49
+ }, [f.events]), !d.length)
50
+ return A(o, {
51
+ ...t,
52
+ className: y(e, "humany-notification-row")
53
+ });
54
+ const P = () => M(!b);
55
+ if (m) {
56
+ const a = d[i] || d[i + 1] || d[i - 1];
57
+ if (!a)
58
+ return A(o, {
59
+ ...t,
60
+ className: y(e, "humany-notification-row")
61
+ });
62
+ const { id: n, body: S } = a || {};
63
+ return !s && f.container.expandableNotifications && f.container.expandableNotifications.has(n) && v(!0), /* @__PURE__ */ k(
64
+ H,
65
+ {
66
+ ...t,
67
+ ...s ? { "aria-expanded": b, role: "button" } : {},
68
+ ...C ? { "aria-label": C } : {},
69
+ tabIndex: s ? 0 : -1,
70
+ className: y(e, "humany-notification-row"),
71
+ "data-pageable": p > 1,
72
+ "data-types": r,
73
+ "data-allow-paging": m,
74
+ "data-expandable": s,
75
+ ref: _,
76
+ onKeyDown: (g) => {
77
+ g.key === "Enter" && P();
78
+ },
79
+ onClick: P,
80
+ children: [
81
+ /* @__PURE__ */ l(
82
+ oe,
83
+ {
84
+ "aria-label": D,
85
+ onClick: () => {
86
+ w(d.indexOf(a)), N([...x, n]);
87
+ },
88
+ children: /* @__PURE__ */ l(T, { symbol: { type: "Svg", content: "close" } })
89
+ }
90
+ ),
91
+ /* @__PURE__ */ l(
92
+ L,
93
+ {
94
+ htmlParseInstruction: !s || b ? void 0 : ne,
95
+ "data-pageable": p > 1,
96
+ "data-notification": n,
97
+ "data-expandable": s,
98
+ "data-expanded": b,
99
+ html: S
100
+ }
101
+ ),
102
+ p > 1 && /* @__PURE__ */ k(ie, { children: [
103
+ /* @__PURE__ */ l(
104
+ E,
105
+ {
106
+ "data-testid": "page-left-button",
107
+ "aria-label": G,
108
+ "data-disabled": i === 0,
109
+ onClick: (g) => {
110
+ g.stopPropagation(), i > 0 && w(i - 1);
111
+ },
112
+ children: /* @__PURE__ */ l(
113
+ j,
114
+ {
115
+ size: 10,
116
+ symbol: { type: "Svg", content: "caret-left" }
117
+ }
118
+ )
119
+ }
120
+ ),
121
+ /* @__PURE__ */ k("span", { children: [
122
+ i + 1,
123
+ "/",
124
+ p
125
+ ] }),
126
+ /* @__PURE__ */ l(
127
+ E,
128
+ {
129
+ "data-testid": "page-right-button",
130
+ "aria-label": F,
131
+ "data-disabled": i + 1 >= p,
132
+ onClick: (g) => {
133
+ g.stopPropagation(), i < p - 1 && w(i + 1);
134
+ },
135
+ children: /* @__PURE__ */ l(
136
+ j,
137
+ {
138
+ size: 10,
139
+ symbol: { type: "Svg", content: "caret-right" }
140
+ }
141
+ )
142
+ }
143
+ )
144
+ ] })
145
+ ]
146
+ }
147
+ );
148
+ }
149
+ return /* @__PURE__ */ l(
150
+ H,
151
+ {
152
+ ...t,
153
+ className: y(e, "humany-notification-row"),
154
+ "data-pageable": !1,
155
+ "data-types": r,
156
+ "data-allow-paging": !1,
157
+ children: d.map((a) => {
158
+ if (!a)
159
+ return null;
160
+ const { id: n, body: S } = a;
161
+ return !s && f.container.expandableNotifications && f.container.expandableNotifications.has(n) && v(!0), /* @__PURE__ */ l(
162
+ L,
163
+ {
164
+ "data-pageable": !1,
165
+ "data-expandable": s,
166
+ "data-expanded": b,
167
+ "data-notification": n,
168
+ html: S
169
+ },
170
+ n
171
+ );
172
+ })
173
+ }
174
+ );
175
+ }, H = c.div`
176
+ ${Q}
177
+ padding: ${(e) => {
178
+ var t;
179
+ return (t = e.theme.sizes) == null ? void 0 : t.normal;
180
+ }} ${(e) => {
181
+ var t;
182
+ return ((t = e.theme.sizes) == null ? void 0 : t.cardinal) * 12;
183
+ }}px;
184
+ background-color: ${(e) => {
185
+ var t, r, m;
186
+ 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" : (r = e.theme.colors) == null ? void 0 : r.primary : (m = e.theme.colors) == null ? void 0 : m.warning;
187
+ }};
188
+ color: ${(e) => {
189
+ var t;
190
+ return (t = e.theme.colors) == null ? void 0 : t.text;
191
+ }};
192
+ border-radius: ${(e) => e.theme.borderRadius};
193
+ text-align: center;
194
+ display: flex;
195
+ flex-direction: column;
196
+ position: relative;
197
+ cursor: ${(e) => e["data-expandable"] ? "pointer" : "default"};
198
+ overflow: hidden;
199
+
200
+ i {
201
+ color: ${(e) => {
202
+ var t;
203
+ return (t = e.theme.colors) == null ? void 0 : t.text;
204
+ }};
205
+ }
206
+
207
+ a {
208
+ color: ${(e) => {
209
+ var t;
210
+ return (t = e.theme.colors) == null ? void 0 : t.link;
211
+ }};
212
+ &:focus-visible {
213
+ ${U}
214
+ }
215
+ }
216
+
217
+ ${(e) => {
218
+ var t;
219
+ return !e["data-allow-paging"] && u`
220
+ flex-wrap: wrap;
221
+
222
+ > div {
223
+ min-width: 100%;
224
+ margin: ${((t = e.theme.sizes) == null ? void 0 : t.cardinal) * 2}px;
225
+ }
226
+ `;
227
+ }};
228
+
229
+ ${(e) => u`
230
+ &:focus-visible {
231
+ .humany-html {
232
+ ${W(e)}
233
+ }
234
+ }
235
+ `}
236
+ `, L = c(V)`
237
+ flex: 1;
238
+ font-size: ${(e) => {
239
+ var t;
240
+ return (t = e.theme.fonts) == null ? void 0 : t.normal;
241
+ }};
242
+ line-height: 1.6em;
243
+ font-weight: 300;
244
+
245
+ ${(e) => e["data-expandable"] && !e["data-expanded"] && u`
246
+ max-width: 100%;
247
+
248
+ p {
249
+ display: none;
250
+ &:first-child {
251
+ display: block;
252
+ margin-bottom: 0;
253
+ white-space: nowrap;
254
+ overflow: hidden;
255
+ text-overflow: ellipsis;
256
+ }
257
+ }
258
+ `}
259
+ `, ie = c.div`
260
+ text-align: center;
261
+ width: 100%;
262
+ span {
263
+ font-size: ${(e) => {
264
+ var t;
265
+ return (t = e.theme.fonts) == null ? void 0 : t.small;
266
+ }};
267
+ display: inline-block;
268
+ width: 30px;
269
+ text-align: center;
270
+ }
271
+ `, E = c(X)`
272
+ background-color: transparent;
273
+ border: none;
274
+ cursor: pointer;
275
+ transition: opacity 200ms ease-out;
276
+ justify-self: flex-end;
277
+ align-self: flex-start;
278
+ padding: ${(e) => {
279
+ var t;
280
+ return (t = e.theme.sizes) == null ? void 0 : t.small;
281
+ }} svg {
282
+ display: block;
283
+ }
284
+
285
+ &:focus-visible {
286
+ ${W}
287
+ }
288
+
289
+ ${(e) => e["data-disabled"] ? u`
290
+ opacity: 0.8;
291
+ ` : u`
292
+ @media (hover) {
293
+ &:hover {
294
+ opacity: 0.5;
295
+ }
296
+ }
297
+ `}
298
+ `, oe = c(E)`
299
+ position: absolute;
300
+ top: 7.5px;
301
+ right: 7.5px;
302
+ width: 25px;
303
+ height: auto;
304
+ padding: ${(e) => {
305
+ var t, r;
306
+ return `calc(${(t = e.theme.sizes) == null ? void 0 : t.small}/2) ${(r = e.theme.sizes) == null ? void 0 : r.small}`;
307
+ }};
308
+ svg {
309
+ vertical-align: middle;
310
+ line,
311
+ path {
312
+ stroke: ${(e) => {
313
+ var t;
314
+ return (t = e.theme.colors) == null ? void 0 : t.text;
315
+ }};
316
+ }
317
+ }
318
+ `, j = c(T)`
319
+ line {
320
+ stroke: #ffffff;
321
+ }
322
+ `;
323
+ c.div`
324
+ display: none;
325
+ `;
326
+ export {
327
+ me as default
328
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telia-ace/knowledge-widget-components-notification-row",
3
- "version": "1.3.27",
3
+ "version": "1.3.28-rc.1",
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.3.27",
14
- "@telia-ace/knowledge-widget-ui": "^1.3.27",
15
- "@telia-ace/widget-services": "^1.3.27",
16
- "@telia-ace/widget-utilities": "^1.3.27",
17
- "@telia-ace/knowledge-data-client": "^1.3.27",
13
+ "@telia-ace/knowledge-widget-core": "^1.3.28-rc.1",
14
+ "@telia-ace/knowledge-widget-ui": "^1.3.28-rc.1",
15
+ "@telia-ace/widget-services": "^1.3.28-rc.1",
16
+ "@telia-ace/widget-utilities": "^1.3.28-rc.1",
17
+ "@telia-ace/knowledge-data-client": "^1.3.28-rc.1",
18
18
  "@webprovisions/platform": "^1.1.4"
19
19
  },
20
20
  "peerDependencies": {
@@ -1,318 +0,0 @@
1
- import { jsxs as v, jsx as o } from "react/jsx-runtime";
2
- import { css as h } from "@emotion/react";
3
- import d from "@emotion/styled";
4
- import { useProperties as G, useContainer as M, createEmptyComponent as P, SymbolBadge as N, genericHtml as Y, linkTabStyle as _, borderTabStyle as j, Html as q, Button as J } from "@telia-ace/knowledge-widget-ui";
5
- import { readStorage as O, StorageMedium as A, 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 B } from "react";
8
- const S = "closed-notifications", V = {
9
- transform: {
10
- a: ({ children: e, ...t }) => /* @__PURE__ */ o("a", { ...t, tabIndex: -1, children: e })
11
- }
12
- }, re = ({ className: e, ...t }) => {
13
- const {
14
- types: l = [],
15
- allowPaging: f = !0,
16
- notifications: R = [],
17
- expandable: c = !1,
18
- closeAriaLabel: T = "",
19
- pageNextAriaLabel: W = "",
20
- pagePreviousAriaLabel: K = "",
21
- expandAriaLabel: z = ""
22
- } = G(), [m, D] = x(!1), [b, C] = x([]), [n, y] = x(0), i = M(), [w, F] = x();
23
- B(() => {
24
- i && (O(i, S, A.Session).then(
25
- (a = []) => C(a)
26
- ), Q(
27
- i,
28
- S,
29
- U.Functional
30
- ).then((a) => F(() => a)));
31
- }, [i]), B(() => {
32
- i && O(i, S, A.Session).then(
33
- (a = []) => {
34
- b.forEach(
35
- (r) => a.indexOf(r) === -1 && a.push(r)
36
- ), w && w(a);
37
- }
38
- );
39
- }, [b, i, w]);
40
- const s = R.filter(({ id: a }) => b.indexOf(a) === -1), { length: p } = s;
41
- if (!s.length)
42
- return P(i, {
43
- ...t,
44
- className: u(e, "humany-notification-row")
45
- });
46
- if (f) {
47
- const a = s[n] || s[n + 1] || s[n - 1];
48
- if (!a)
49
- return P(i, {
50
- ...t,
51
- className: u(e, "humany-notification-row")
52
- });
53
- const { id: r, body: $ } = a || {}, E = () => D(!m);
54
- return /* @__PURE__ */ v(
55
- H,
56
- {
57
- ...t,
58
- ...c ? { "aria-expanded": m, role: "button" } : {},
59
- ...z ? { "aria-label": z } : {},
60
- tabIndex: c ? 0 : -1,
61
- className: u(e, "humany-notification-row"),
62
- "data-pageable": p > 1,
63
- "data-types": l,
64
- "data-allow-paging": f,
65
- "data-expandable": c,
66
- onKeyDown: (g) => {
67
- g.key === "Enter" && E();
68
- },
69
- onClick: E,
70
- children: [
71
- /* @__PURE__ */ o(
72
- Z,
73
- {
74
- "aria-label": T,
75
- onClick: () => {
76
- y(s.indexOf(a)), C([...b, r]);
77
- },
78
- children: /* @__PURE__ */ o(N, { symbol: { type: "Svg", content: "close" } })
79
- }
80
- ),
81
- /* @__PURE__ */ o(
82
- I,
83
- {
84
- htmlParseInstruction: !c || m ? void 0 : V,
85
- "data-pageable": p > 1,
86
- "data-notification": r,
87
- "data-expandable": c,
88
- "data-expanded": m,
89
- html: $
90
- }
91
- ),
92
- p > 1 && /* @__PURE__ */ v(X, { children: [
93
- /* @__PURE__ */ o(
94
- k,
95
- {
96
- "data-testid": "page-left-button",
97
- "aria-label": K,
98
- "data-disabled": n === 0,
99
- onClick: (g) => {
100
- g.stopPropagation(), n > 0 && y(n - 1);
101
- },
102
- children: /* @__PURE__ */ o(
103
- L,
104
- {
105
- size: 10,
106
- symbol: { type: "Svg", content: "caret-left" }
107
- }
108
- )
109
- }
110
- ),
111
- /* @__PURE__ */ v("span", { children: [
112
- n + 1,
113
- "/",
114
- p
115
- ] }),
116
- /* @__PURE__ */ o(
117
- k,
118
- {
119
- "data-testid": "page-right-button",
120
- "aria-label": W,
121
- "data-disabled": n + 1 >= p,
122
- onClick: (g) => {
123
- g.stopPropagation(), n < p - 1 && y(n + 1);
124
- },
125
- children: /* @__PURE__ */ o(
126
- L,
127
- {
128
- size: 10,
129
- symbol: { type: "Svg", content: "caret-right" }
130
- }
131
- )
132
- }
133
- )
134
- ] })
135
- ]
136
- }
137
- );
138
- }
139
- return /* @__PURE__ */ o(
140
- H,
141
- {
142
- ...t,
143
- className: u(e, "humany-notification-row"),
144
- "data-pageable": !1,
145
- "data-types": l,
146
- "data-allow-paging": !1,
147
- children: s.map((a) => {
148
- if (!a)
149
- return null;
150
- const { id: r, body: $ } = a;
151
- return /* @__PURE__ */ o(
152
- I,
153
- {
154
- "data-pageable": !1,
155
- "data-expandable": c,
156
- "data-expanded": m,
157
- "data-notification": r,
158
- html: $
159
- },
160
- r
161
- );
162
- })
163
- }
164
- );
165
- }, H = d.div`
166
- ${Y}
167
- padding: ${(e) => {
168
- var t;
169
- return (t = e.theme.sizes) == null ? void 0 : t.normal;
170
- }} ${(e) => {
171
- var t;
172
- return ((t = e.theme.sizes) == null ? void 0 : t.cardinal) * 12;
173
- }}px;
174
- background-color: ${(e) => {
175
- var t, l, f;
176
- 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;
177
- }};
178
- color: ${(e) => {
179
- var t;
180
- return (t = e.theme.colors) == null ? void 0 : t.text;
181
- }};
182
- border-radius: ${(e) => e.theme.borderRadius};
183
- text-align: center;
184
- display: flex;
185
- flex-direction: column;
186
- position: relative;
187
- cursor: ${(e) => e["data-expandable"] ? "pointer" : "default"};
188
- overflow: hidden;
189
-
190
- i {
191
- color: ${(e) => {
192
- var t;
193
- return (t = e.theme.colors) == null ? void 0 : t.text;
194
- }};
195
- }
196
-
197
- a {
198
- color: ${(e) => {
199
- var t;
200
- return (t = e.theme.colors) == null ? void 0 : t.link;
201
- }};
202
- &:focus-visible {
203
- ${_}
204
- }
205
- }
206
-
207
- ${(e) => {
208
- var t;
209
- return !e["data-allow-paging"] && h`
210
- flex-wrap: wrap;
211
-
212
- > div {
213
- min-width: 100%;
214
- margin: ${((t = e.theme.sizes) == null ? void 0 : t.cardinal) * 2}px;
215
- }
216
- `;
217
- }};
218
-
219
- ${(e) => h`
220
- &:focus-visible {
221
- .humany-html {
222
- ${j(e)}
223
- }
224
- }
225
- `}
226
- `, I = d(q)`
227
- flex: 1;
228
- font-size: ${(e) => {
229
- var t;
230
- return (t = e.theme.fonts) == null ? void 0 : t.normal;
231
- }};
232
- line-height: 1.6em;
233
- font-weight: 300;
234
-
235
- ${(e) => e["data-expandable"] && !e["data-expanded"] && h`
236
- max-width: 100%;
237
-
238
- p {
239
- display: none;
240
- &:first-child {
241
- display: block;
242
- margin-bottom: 0;
243
- white-space: nowrap;
244
- overflow: hidden;
245
- text-overflow: ellipsis;
246
- }
247
- }
248
- `}
249
- `, X = d.div`
250
- text-align: center;
251
- width: 100%;
252
- span {
253
- font-size: ${(e) => {
254
- var t;
255
- return (t = e.theme.fonts) == null ? void 0 : t.small;
256
- }};
257
- display: inline-block;
258
- width: 30px;
259
- text-align: center;
260
- }
261
- `, k = d(J)`
262
- background-color: transparent;
263
- border: none;
264
- cursor: pointer;
265
- transition: opacity 200ms ease-out;
266
- justify-self: flex-end;
267
- align-self: flex-start;
268
- padding: ${(e) => {
269
- var t;
270
- return (t = e.theme.sizes) == null ? void 0 : t.small;
271
- }} svg {
272
- display: block;
273
- }
274
-
275
- &:focus-visible {
276
- ${j}
277
- }
278
-
279
- ${(e) => e["data-disabled"] ? h`
280
- opacity: 0.8;
281
- ` : h`
282
- @media (hover) {
283
- &:hover {
284
- opacity: 0.5;
285
- }
286
- }
287
- `}
288
- `, Z = d(k)`
289
- position: absolute;
290
- top: 7.5px;
291
- right: 7.5px;
292
- width: 25px;
293
- height: auto;
294
- padding: ${(e) => {
295
- var t, l;
296
- return `calc(${(t = e.theme.sizes) == null ? void 0 : t.small}/2) ${(l = e.theme.sizes) == null ? void 0 : l.small}`;
297
- }};
298
- svg {
299
- vertical-align: middle;
300
- line,
301
- path {
302
- stroke: ${(e) => {
303
- var t;
304
- return (t = e.theme.colors) == null ? void 0 : t.text;
305
- }};
306
- }
307
- }
308
- `, L = d(N)`
309
- line {
310
- stroke: #ffffff;
311
- }
312
- `;
313
- d.div`
314
- display: none;
315
- `;
316
- export {
317
- re as default
318
- };
@@ -1,114 +0,0 @@
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:O=[],expandable:p=!1,closeAriaLabel:B="",pageNextAriaLabel:A="",pagePreviousAriaLabel:T="",expandAriaLabel:C=""}=i.useProperties(),[x,H]=g.useState(!1),[y,z]=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=[])=>z(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=O.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||{},E=()=>H(!x);return n.jsxs(P,{...t,...p?{"aria-expanded":x,role:"button"}:{},...C?{"aria-label":C}:{},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"&&E()},onClick:E,children:[n.jsx(M,{"aria-label":B,onClick:()=>{S(d.indexOf(a)),z([...y,r])},children:n.jsx(i.SymbolBadge,{symbol:{type:"Svg",content:"close"}})}),n.jsx(q,{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,{"data-testid":"page-left-button","aria-label":T,"data-disabled":o===0,onClick:h=>{h.stopPropagation(),o>0&&S(o-1)},children:n.jsx(N,{size:10,symbol:{type:"Svg",content:"caret-left"}})}),n.jsxs("span",{children:[o+1,"/",f]}),n.jsx(k,{"data-testid":"page-right-button","aria-label":A,"data-disabled":o+1>=f,onClick:h=>{h.stopPropagation(),o<f-1&&S(o+1)},children:n.jsx(N,{size:10,symbol:{type:"Svg",content:"caret-right"}})})]})]})}return n.jsx(P,{...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(q,{"data-pageable":!1,"data-expandable":p,"data-expanded":x,"data-notification":r,html:v},r)})})},P=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
- `,q=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
- `,N=c(i.SymbolBadge)`
109
- line {
110
- stroke: #ffffff;
111
- }
112
- `;c.div`
113
- display: none;
114
- `;exports.default=R;