@telia-ace/knowledge-widget-components-notification-row 1.1.8 → 1.2.0-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-0fa3c3a5.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-71e572ae.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-5caec368.mjs"),
9
+ import("./notification-row-c1d2412b.mjs"),
10
10
  (e) => {
11
11
  const r = (t) => {
12
12
  e.writeProperties({
@@ -1,4 +1,4 @@
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`
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,{"data-testid":"page-left-button","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,{"data-testid":"page-right-button","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
2
  ${i.genericHtml}
3
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
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}};
@@ -1,5 +1,5 @@
1
- import { jsxs as v, jsx as i } from "react/jsx-runtime";
2
- import { css as g } from "@emotion/react";
1
+ import { jsxs as v, jsx as n } from "react/jsx-runtime";
2
+ import { css as h } from "@emotion/react";
3
3
  import d from "@emotion/styled";
4
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
5
  import { readStorage as P, StorageMedium as O, createStorageWriter as Q, StorageCategory as U } from "@telia-ace/widget-services";
@@ -7,7 +7,7 @@ import { appendClassNames as u } from "@telia-ace/widget-utilities";
7
7
  import { useState as x, useEffect as A } from "react";
8
8
  const S = "closed-notifications", V = {
9
9
  transform: {
10
- a: ({ children: e, ...t }) => /* @__PURE__ */ i("a", { ...t, tabIndex: -1, children: e })
10
+ a: ({ children: e, ...t }) => /* @__PURE__ */ n("a", { ...t, tabIndex: -1, children: e })
11
11
  }
12
12
  }, re = ({ className: e, ...t }) => {
13
13
  const {
@@ -19,7 +19,7 @@ const S = "closed-notifications", V = {
19
19
  pageNextAriaLabel: T = "",
20
20
  pagePreviousAriaLabel: W = "",
21
21
  expandAriaLabel: K = ""
22
- } = G(), [m, D] = x(!1), [b, z] = x([]), [n, y] = x(0), o = M(), [w, F] = x();
22
+ } = G(), [m, D] = x(!1), [b, z] = x([]), [i, y] = x(0), o = M(), [w, F] = x();
23
23
  A(() => {
24
24
  o && (P(o, S, O.Session).then(
25
25
  (a = []) => z(a)
@@ -44,7 +44,7 @@ const S = "closed-notifications", V = {
44
44
  className: u(e, "humany-notification-row")
45
45
  });
46
46
  if (f) {
47
- const a = s[n] || s[n + 1] || s[n - 1];
47
+ const a = s[i] || s[i + 1] || s[i - 1];
48
48
  if (!a)
49
49
  return E(o, {
50
50
  ...t,
@@ -63,22 +63,22 @@ const S = "closed-notifications", V = {
63
63
  "data-types": l,
64
64
  "data-allow-paging": f,
65
65
  "data-expandable": c,
66
- onKeyDown: (h) => {
67
- h.key === "Enter" && C();
66
+ onKeyDown: (g) => {
67
+ g.key === "Enter" && C();
68
68
  },
69
69
  onClick: C,
70
70
  children: [
71
- /* @__PURE__ */ i(
71
+ /* @__PURE__ */ n(
72
72
  Z,
73
73
  {
74
74
  "aria-label": R,
75
75
  onClick: () => {
76
76
  y(s.indexOf(a)), z([...b, r]);
77
77
  },
78
- children: /* @__PURE__ */ i(L, { symbol: { type: "Svg", content: "close" } })
78
+ children: /* @__PURE__ */ n(L, { symbol: { type: "Svg", content: "close" } })
79
79
  }
80
80
  ),
81
- /* @__PURE__ */ i(
81
+ /* @__PURE__ */ n(
82
82
  H,
83
83
  {
84
84
  htmlParseInstruction: !c || m ? void 0 : V,
@@ -90,15 +90,16 @@ const S = "closed-notifications", V = {
90
90
  }
91
91
  ),
92
92
  p > 1 && /* @__PURE__ */ v(X, { children: [
93
- /* @__PURE__ */ i(
93
+ /* @__PURE__ */ n(
94
94
  k,
95
95
  {
96
+ "data-testid": "page-left-button",
96
97
  "aria-label": W,
97
- "data-disabled": n === 0,
98
- onClick: (h) => {
99
- h.stopPropagation(), n > 0 && y(n - 1);
98
+ "data-disabled": i === 0,
99
+ onClick: (g) => {
100
+ g.stopPropagation(), i > 0 && y(i - 1);
100
101
  },
101
- children: /* @__PURE__ */ i(
102
+ children: /* @__PURE__ */ n(
102
103
  I,
103
104
  {
104
105
  size: 10,
@@ -108,19 +109,20 @@ const S = "closed-notifications", V = {
108
109
  }
109
110
  ),
110
111
  /* @__PURE__ */ v("span", { children: [
111
- n + 1,
112
+ i + 1,
112
113
  "/",
113
114
  p
114
115
  ] }),
115
- /* @__PURE__ */ i(
116
+ /* @__PURE__ */ n(
116
117
  k,
117
118
  {
119
+ "data-testid": "page-right-button",
118
120
  "aria-label": T,
119
- "data-disabled": n + 1 >= p,
120
- onClick: (h) => {
121
- h.stopPropagation(), n < p - 1 && y(n + 1);
121
+ "data-disabled": i + 1 >= p,
122
+ onClick: (g) => {
123
+ g.stopPropagation(), i < p - 1 && y(i + 1);
122
124
  },
123
- children: /* @__PURE__ */ i(
125
+ children: /* @__PURE__ */ n(
124
126
  I,
125
127
  {
126
128
  size: 10,
@@ -134,7 +136,7 @@ const S = "closed-notifications", V = {
134
136
  }
135
137
  );
136
138
  }
137
- return /* @__PURE__ */ i(
139
+ return /* @__PURE__ */ n(
138
140
  B,
139
141
  {
140
142
  ...t,
@@ -146,7 +148,7 @@ const S = "closed-notifications", V = {
146
148
  if (!a)
147
149
  return null;
148
150
  const { id: r, body: $ } = a;
149
- return /* @__PURE__ */ i(
151
+ return /* @__PURE__ */ n(
150
152
  H,
151
153
  {
152
154
  "data-pageable": !1,
@@ -204,7 +206,7 @@ const S = "closed-notifications", V = {
204
206
 
205
207
  ${(e) => {
206
208
  var t;
207
- return !e["data-allow-paging"] && g`
209
+ return !e["data-allow-paging"] && h`
208
210
  flex-wrap: wrap;
209
211
 
210
212
  > div {
@@ -214,7 +216,7 @@ const S = "closed-notifications", V = {
214
216
  `;
215
217
  }};
216
218
 
217
- ${(e) => g`
219
+ ${(e) => h`
218
220
  &:focus-visible {
219
221
  .humany-html {
220
222
  ${N(e)}
@@ -230,7 +232,7 @@ const S = "closed-notifications", V = {
230
232
  line-height: 1.6em;
231
233
  font-weight: 300;
232
234
 
233
- ${(e) => e["data-expandable"] && !e["data-expanded"] && g`
235
+ ${(e) => e["data-expandable"] && !e["data-expanded"] && h`
234
236
  max-width: 100%;
235
237
 
236
238
  p {
@@ -274,9 +276,9 @@ const S = "closed-notifications", V = {
274
276
  ${N}
275
277
  }
276
278
 
277
- ${(e) => e["data-disabled"] ? g`
279
+ ${(e) => e["data-disabled"] ? h`
278
280
  opacity: 0.8;
279
- ` : g`
281
+ ` : h`
280
282
  @media (hover) {
281
283
  &:hover {
282
284
  opacity: 0.5;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telia-ace/knowledge-widget-components-notification-row",
3
- "version": "1.1.8",
3
+ "version": "1.2.0-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.1.8",
14
- "@telia-ace/knowledge-widget-ui": "^1.1.8",
15
- "@telia-ace/widget-services": "^1.1.8",
16
- "@telia-ace/widget-utilities": "^1.1.8",
17
- "@telia-ace/knowledge-data-client": "^1.1.8",
13
+ "@telia-ace/knowledge-widget-core": "^1.2.0-rc.1",
14
+ "@telia-ace/knowledge-widget-ui": "^1.2.0-rc.1",
15
+ "@telia-ace/widget-services": "^1.2.0-rc.1",
16
+ "@telia-ace/widget-utilities": "^1.2.0-rc.1",
17
+ "@telia-ace/knowledge-data-client": "^1.2.0-rc.1",
18
18
  "@webprovisions/platform": "^1.1.4"
19
19
  },
20
20
  "peerDependencies": {