@telia-ace/knowledge-widget-components-contact-list 1.1.1-rc.0 → 1.1.1-rc.2

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.
@@ -0,0 +1,188 @@
1
+ "use strict";const r=require("react/jsx-runtime"),p=require("@emotion/styled"),n=require("./index-c67477f3.js"),E=require("@emotion/react"),m=require("react");require("react-dom");const K=require("react-transition-group"),D=require("react-router");function*H(e){if(e)for(let t=0;t<e.length;t++){const o=e[t];yield o,o.items&&(yield*H(o.items))}}const W=(e,t)=>{const o=H(t);let s=o.next(),i=null;for(;!s.done;)s.value.id===e&&(i=s.value),s=o.next();return i},O=(e,t)=>({id:e.id,type:e.type,name:e.name,branch:t||"default"}),J=e=>e==="entering"||e==="entered",Z=e=>e==="exiting"||e==="exited",k={fade:{in:"opacity: 1;",out:"opacity: 0;"},"slide-left":{in:"transform: translateX(0);",out:"transform: translateX(-100%);"},"slide-right":{in:"transform: translateX(0);",out:"transform: translateX(100%);"},"slide-up":{in:"transform: translateY(0);",out:"transform: translateY(100%);"},"slide-down":{in:"transform: translateY(0);",out:"transform: translateY(-100%);"},scale:{in:"transform: scale(1);",out:"transform: scale(0);"}},ee=["slide-up","slide-down","slide-left","slide-right","scale"],q={compose:(e="exited",t)=>{const{enter:o,exit:s}=t,i=o.transitionKeys.split(" "),l=ee.indexOf(i[0])>-1?"transform":"opacity";if(J(e))return i&&i.length>0?E.css`
2
+ ${i&&i.length>0&&i.map(c=>k[c]?k[c].in:"")}
3
+ transition: ${l} ${o.duration}ms ${o.easing};
4
+ `:"";const d=i&&i.length>0&&E.css`
5
+ ${i.map(c=>k[c]?k[c].out:"")}
6
+ `;if(Z(e)){const c=s.transitionKeys.split(" ");return c&&c.length>0&&e==="exiting"?E.css`
7
+ ${d};
8
+ ${c.map(a=>k[a]?k[a].out:"")}
9
+ transition: ${l} ${s.duration}ms ${s.easing};
10
+ `:d}},composeViewTransition:(e,t,o)=>{if(t==="slide")return q.compose(e,{enter:{transitionKeys:o==="forth"?"slide-right":"slide-left",duration:500},exit:{transitionKeys:o==="forth"?"slide-left":"slide-right",duration:500}});if(t==="fade")return q.compose(e,{enter:{transitionKeys:"fade",duration:500},exit:{transitionKeys:"fade",duration:500}})},get:e=>k[e]},_=(e,t)=>e.get("seoConfiguration")?r.jsx(n.Empty,{...t}):null,M=()=>m.useContext(n.ComponentNodeContext),te=()=>{const e=n.useComponentNode(),t=n.useComponentPlatform(),[o,s]=m.useState([]),i=n.useIsMounted(),l=m.useCallback(d=>{if(t&&i.current&&d){const c=t.getBranch(d),a=d.getChildren(c).map(u=>O(u));s(a)}},[i,t,s,e]);return m.useEffect(()=>{e&&l(e)},[e,t]),m.useEffect(()=>{if(t){const[d,c]=n.createEventSubscriber(t.events);return d("components:set-layout",(a,u)=>{(e===u.node.parent||u.node.parent===t.nodes.root)&&l(u.node.parent)}),d("components:node-appended",(a,u)=>{(e===u.node.parent||u.node.parent===t.nodes.root)&&l(u.node.parent)}),d("components:node-removed",(a,{parentNode:u})=>{(u===e||u===t.nodes.root)&&l(u)}),()=>{c()}}},[e,t,l]),o},ne=()=>m.useContext(n.ColumnContext),U=(e,t)=>{const o=M(),s=n.useContainer(),[i,l]=m.useState(void 0),d=n.useIsMounted(),c=e||o.type||"";return m.useEffect(()=>{if(c){let a;return(t||s).getAsync("componentResolver").then(u=>{if(d.current){const g=u.getComponent(c);l(g)}a=u.registerResolver(c,g=>{d.current&&l(g)})}),()=>{a&&a()}}},[d,c,t,s]),i},X=()=>{const e=n.useComponentPlatform(),t=M(),[o,s]=m.useState([]),[i,l]=m.useState();return m.useEffect(()=>{if(e&&t){const d=new n.ComponentQuery(e).withId(t.id),c=e.actions(d,t.type||n.uuid());l(c),o!==null&&(o.forEach(a=>{c.dispatch(a.key,a.data).then(u=>a.resolve(u)).catch(u=>a.reject(u))}),s(null))}},[e,t.id]),(d,c)=>o!==null?new Promise((a,u)=>{o.push({key:d,data:c,resolve:a,reject:u})}):i.dispatch(d,c)},oe=e=>{const t=n.useComponentNode(e),o=n.useComponentPlatform(),[s,i]=m.useState({}),l=n.useIsMounted();return m.useEffect(()=>{t&&l.current&&i(t.attributes.layout)},[t,l]),m.useEffect(()=>{if(o){const d=o.events.subscribe("components:layout-changed",(c,a)=>{t===a.node&&l.current&&i(a.node.attributes.layout)});return()=>{d()}}},[o,l,t]),s},B=()=>m.useContext(n.ComponentPropertyContext);p(n.Paragraph)`
11
+ ${e=>{var t;return n.headingElement(e)("h1",E.css`
12
+ font-weight: normal;
13
+ font-size: ${(t=e.theme.fonts)==null?void 0:t.medium};
14
+ `)}}
15
+ `;const se=p(n.Html)`
16
+ ${n.genericHtml}
17
+ font-weight: 300;
18
+ line-height: 1.5em;
19
+ button:focus-visible {
20
+ ${n.borderTabStyle};
21
+ }
22
+
23
+ a:focus-visible {
24
+ ${n.linkTabStyle};
25
+ }
26
+ `,re=e=>{const t=U(e.clientName),{params:{contactCategory:o,guideCategory:s,phrase:i}}=n.useRouteData();if(typeof t>"u")return null;if(t===null)return process.env.NODE_ENV!=="production"?r.jsx(ae,{title:`client-name: ${e.clientName}, id: ${e.id}`,className:"humany-non-resolved-contact-method",children:r.jsx(n.Typography,{variant:"h5",children:"Non resolved Contact Method type"})}):null;const l=(d={})=>{const c={...e,...d},{id:a,title:u,clientName:g,symbol:f,inline:P,onClick:j=()=>{},description:C,htmlParseInstruction:x,className:b,disabled:S,guideId:N,dispatch:w=()=>{},expanded:y}=c,$=P?{onKeyDown:h=>{h.key&&h.key==="Enter"&&(j(h,c),h.defaultPrevented||!y&&w("expand",a))},onClick:h=>{j(h,c),h.defaultPrevented||!y&&w("expand",a)}}:{onClick:h=>j(h,c),routeName:"contact-method",params:n.createParams({contactCategory:o,guideId:N,guideCategory:s,phrase:i,contactMethod:a,uriName:n.formatUrl(u)})};return r.jsxs(ie,{title:u,"aria-label":u,className:b,disabled:S,description:C,"data-client-name":g,...d,...$,children:[f&&r.jsx(n.SymbolBadge,{symbol:f}),C?r.jsxs("div",{className:"humany-contact-link-rich-content",children:[r.jsx(G,{children:u}),r.jsx(se,{html:C,htmlParseInstruction:x})]}):r.jsx(G,{children:u})]})};return e.expanded?r.jsx(m.Suspense,{fallback:null,children:r.jsx(t,{...e,renderDefault:l})}):l()},Y=e=>{var t,o,s,i,l,d,c,a;return E.css`
27
+ display: flex;
28
+ padding: ${(t=e.theme.sizes)==null?void 0:t.large};
29
+ ${e.description?"":"align-items: center;"}
30
+ text-decoration: none;
31
+ span {
32
+ display: inline-block;
33
+ color: ${(o=e.theme.colors)==null?void 0:o.text};
34
+ }
35
+ i {
36
+ font-size: ${(s=e.theme.fonts)==null?void 0:s.large};
37
+ margin: 0 ${(i=e.theme.sizes)==null?void 0:i.large} 0 0;
38
+ min-height: ${(l=e.theme.fonts)==null?void 0:l.large};
39
+ min-width: ${(d=e.theme.fonts)==null?void 0:d.large};
40
+ line-height: ${(c=e.theme.fonts)==null?void 0:c.large};
41
+ display: inline-block;
42
+ vertical-align: bottom;
43
+ color: ${(a=e.theme.colors)==null?void 0:a.text};
44
+ }
45
+ `},G=p(n.StyledText)`
46
+ line-height: ${e=>{var t;return(t=e.theme.fonts)==null?void 0:t.large}};
47
+ `,ie=p(n.Link)`
48
+ ${e=>Y(e)}
49
+
50
+ &:focus-visible {
51
+ ${n.borderTabStyle};
52
+ }
53
+ `,ae=p.div`
54
+ text-align: center;
55
+ display: block;
56
+ ${e=>{var t,o;return typeof((t=e.theme.colors)==null?void 0:t.warning)<"u"&&`color: ${(o=e.theme.colors)==null?void 0:o.warning};`}}
57
+ `,F=e=>{var t,o,s;return E.css`
58
+ ${n.itemList(e)}
59
+
60
+ > div {
61
+ padding: ${(t=e.theme.sizes)==null?void 0:t.large};
62
+
63
+ ${n.headingElement(e)("h1",E.css`
64
+ margin: 0;
65
+ `)}
66
+ }
67
+
68
+ > ul {
69
+ &:not(:first-child) {
70
+ border-top: ${e.theme.border};
71
+ }
72
+
73
+ > li {
74
+ margin: 0;
75
+ white-space: normal;
76
+
77
+ > a {
78
+ overflow: hidden;
79
+ }
80
+
81
+ &:first-child > a {
82
+ border-radius: ${`${e.theme.borderRadius} ${e.theme.borderRadius} 0 0`};
83
+ }
84
+
85
+ &:last-child:not(:first-child) > a {
86
+ border-radius: ${`0 0 ${e.theme.borderRadius} ${e.theme.borderRadius}`};
87
+ }
88
+
89
+ &:not(:last-child) {
90
+ border-bottom: ${e.theme.border};
91
+ }
92
+
93
+ > div {
94
+ padding: ${(o=e.theme.sizes)==null?void 0:o.large};
95
+ }
96
+ }
97
+ }
98
+
99
+ @media (hover: hover) {
100
+ a:hover {
101
+ background-color: ${(s=e.theme.colors)==null?void 0:s.accent};
102
+ }
103
+ }
104
+ `},ce=p(n.ItemList)`
105
+ ${e=>F(e)}
106
+ `,le=({contactMethods:e,children:t,guideId:o,dispatch:s,className:i="",itemRenderer:l,action:d=()=>{},header:c=""})=>e.length?r.jsx(ce,{header:c,className:n.appendClassNames(i,"humany-contact-list"),items:e,renderItem:l?a=>r.jsx("li",{"data-contact-method":a.id,children:l(a,{action:d,dispatch:s,guideId:o})},a.id):a=>r.jsx("li",{"data-contact-method":a.id,children:r.jsx(re,{...a,action:d,dispatch:s,guideId:o})},a.id),children:t}):null;var A=(e=>(e.back="back",e.forth="forth",e))(A||{});const de=(e,t,o)=>typeof o[e]=="number"&&typeof o[t]=="number"&&o[e]>o[t]?"back":"forth",Q=({views:e,location:t,render:o})=>r.jsx(D.Switch,{location:t&&{...t,pathname:t.pathname.split("?")[0]},children:[...Object.keys(e).filter(s=>!!e[s].path),...Object.keys(e).filter(s=>!e[s].path)].map(s=>{const{path:i}=e[s];return i?Array.isArray(i)?i.map(l=>r.jsx(D.Route,{exact:!0,path:l,render:()=>o(s)},s)):r.jsx(D.Route,{exact:!0,path:i,render:()=>o(s)},s):r.jsx(D.Route,{render:()=>o(s)},s)})}),ue=p.div`
107
+ position: relative;
108
+ width: 100%;
109
+ flex: 1;
110
+ `,me=p(n.Grid)`
111
+ position: absolute;
112
+ left: 0;
113
+ right: 0;
114
+ ${e=>!!e.animationCss&&e.animationCss}
115
+ ${e=>!!e.scrollableCss&&e.scrollableCss}
116
+ `,fe={index:1,search:2,browse:3,guide:4,contact:5,"contact-method":6,conversation:7},he=({className:e="",...t})=>{const[o,s]=m.useState("index"),[i,l]=m.useState(A.forth),d=n.useRouteData(),c=n.useRouter(),a=B(),u=n.useContext(),g=n.useContainer(),f=n.useComponentNode(),{gap:P="0"}=u,{columns:j=1,animation:C="none",scrollable:x=!1,...b}=a,[S,N]=n.useScroll(x);if(!f||!c)return null;const{location:w}=c;d.name!==o&&d.name!==""&&C&&(l(de(o,d.name,fe)),s(d.name));const{views:y}=g.get("$settings");if(!Object.keys(y).length)return null;const $=(v,R,T)=>{const L=h(R,T),I=f.getChildren(v)[0];return r.jsx(me,{...t,...b,scrollableCss:S,ref:N,columns:j,gap:P,...L,className:n.appendClassNames(e,"humany-view"),children:r.jsx(V,{id:I.id,branch:"default"})})},h=(v,R)=>{if(C==="slide"||C==="fade")return{animationCss:q.composeViewTransition(v,C,R),"data-state":v}};return r.jsx(ue,{className:"humany-animated-view",children:r.jsx(K.TransitionGroup,{component:null,childFactory:v=>m.cloneElement(v,{direction:i}),children:r.jsx(K.Transition,{timeout:{enter:500,exit:500},onEnter:v=>v==null?void 0:v.clientHeight,unmountOnExit:!0,direction:A.forth,children:(v,{direction:R})=>r.jsx(Q,{views:y,location:w,render:T=>$(T,v,R)})},o)})})},pe=p(n.Grid)`
117
+ ${e=>!!e.scrollableCss&&e.scrollableCss}
118
+ `,ye=({className:e="",...t})=>{const o=B(),s=n.useContext(),i=n.useContainer(),l=n.useComponentNode(),{views:d}=i.get("$settings"),{gap:c="0"}=s,{columns:a=1,animation:u="none",scrollable:g=!1,...f}=o,[P,j]=n.useScroll(g);return l?r.jsx(pe,{...t,...f,scrollableCss:P,ref:j,columns:a,gap:c,className:n.appendClassNames(e,"humany-view"),children:r.jsx(Q,{views:d,render:C=>{const x=l.getChildren(C)[0];return r.jsx(V,{id:x.id,node:x,branch:"default"})}})}):null},z=e=>{var t,o;return E.css`
119
+ outline: none;
120
+ box-sizing: border-box;
121
+ * {
122
+ box-sizing: border-box;
123
+ outline: none;
124
+ }
125
+
126
+ grid-column: ${e["data-indent"]?`${e["data-indent"]+1} / ${e["data-indent"]+(e["data-width"]||0)+1}`:`span ${e["data-width"]}`};
127
+
128
+ ${((t=e.theme.fonts)==null?void 0:t.type)&&`
129
+ font-family: ${e.theme.fonts.type};
130
+
131
+ input, textarea {
132
+ font-family: ${e.theme.fonts.type};
133
+ }
134
+ `}
135
+
136
+ ${((o=e.theme.fonts)==null?void 0:o.base)&&`
137
+ font-size: ${e.theme.fonts.base};
138
+ `}
139
+
140
+ &:focus-visible {
141
+ ${n.paddedBorderTabStyle(e)};
142
+ }
143
+ `},ge=p(ye)`
144
+ ${e=>z(e)}
145
+ `,xe=p(he)`
146
+ ${e=>z(e)}
147
+ `,be=p.div`
148
+ text-align: center;
149
+ ${e=>{var t,o,s;return typeof((t=e.theme.colors)==null?void 0:t.warning)<"u"&&E.css`
150
+ color: ${(o=e.theme.colors)==null?void 0:o.warning};
151
+ border: 2px dashed ${(s=e.theme.colors)==null?void 0:s.warning};
152
+ `}}
153
+ ${e=>typeof e.theme.borderRadius<"u"&&`border-radius: ${e.theme.borderRadius};`}
154
+ ${e=>z(e)}
155
+ `,Ce=m.forwardRef(({className:e="",children:t,...o},s)=>{const i=U(),{name:l,type:d,id:c}=M(),a=m.useMemo(()=>i?p(i)`
156
+ ${z}
157
+ ${n.filterCssPropsStyle}
158
+ `:null,[i]);return typeof i>"u"?null:i===null||a===null?process.env.NODE_ENV!=="production"?r.jsx(be,{...o,title:`type: ${d}, definition-id: ${l}, instance-id: ${c}`,className:n.appendClassNames(e,"humany-non-resolved-component"),children:r.jsx(n.Typography,{variant:"h5",children:"Non Resolved Component Type"})}):null:r.jsx(m.Suspense,{fallback:null,children:r.jsx(a,{ref:s,...o,className:n.appendClassNames(e,"humany-component",`humany-component-${l}`),children:t})})}),$e=e=>{const t=n.useComponentNode(e),o=n.useComponentPlatform(),[s,i]=m.useState({}),l=n.useIsMounted();return m.useEffect(()=>{t&&l.current&&i(t.attributes.properties)},[t,e,l]),m.useEffect(()=>{if(o){const d=o.events.subscribe("components:properties-changed",(c,a)=>{t===a.node&&l.current&&i(a.node.attributes.properties)});return()=>{d()}}},[o,l,e,t]),s},je=(e,t)=>t?!0:typeof e=="string"?e==="full":e>0,V=m.forwardRef(({className:e="",id:t,branch:o,node:s,ariaLabel:i,tabIndex:l,context:d,...c},a)=>{const u=n.useComponentPlatform(),g=n.useContainer(),[f,P]=m.useState(),j=ne(),C=n.useContext(t),x=$e(t),{size:b="none",indent:S=0}=oe(t),N=je(b,s);if(m.useEffect(()=>{if(u){if(t&&!s){const L=u.nodes.get(t);if(L&&(P(O(L,o)),N)){const I=L.mount(g);return()=>{I()}}}else if(s){P(O(s,o));const L=s.mount(g);return()=>{L()}}}},[u,t,s,N]),!f||!N)return null;const w={...C,...d||{}},{cardinal:y,fonts:$={},accessibility:h={},...v}=w,R={type:$.type,base:$.base||"16px",small:$.small||"0.8em",normal:$.normal||"1em",medium:$.medium||"1.2em",large:$.large||"1.6em",huge:$.huge||"2.5em"},T={...v,fonts:R,accessibility:{...h}};return typeof y=="number"&&(T.sizes={cardinal:y,small:`${y}px`,normal:`${y*3}px`,medium:`${y*5}px`,large:`${y*8}px`}),r.jsx(E.ThemeProvider,{theme:T,children:r.jsx(n.ComponentNodeContext.Provider,{value:f,children:r.jsx(n.ComponentPropertyContext.Provider,{value:x,children:(()=>{const L={"data-width":b==="full"?j:Math.min(b,j),"data-indent":S,"data-name":f.name,"data-node-id":f.id,"data-component-type":f.type,"aria-label":i,tabIndex:l,id:f.id,role:x&&x.role,...c};switch(f.type){case"view":return typeof x.animation=="string"&&x.animation!=="none"?r.jsx(xe,{...L,className:e}):r.jsx(ge,{...L,className:e});default:{const I=n.filterCssProps(x);return r.jsx(Ce,{ref:a,...L,...I,className:e})}}})()})})})});m.lazy(()=>Promise.resolve().then(()=>require("./detached-component-cc2b6165.js")));const ve=({className:e,guides:t,header:o,accordion:s,loading:i,route:l="guide",categoryTitle:d,...c})=>{const{name:a,params:{contactCategory:u=0,guide:g}}=n.useRouteData(),{name:f}=M(),P=n.useContainer(),j=te(),C=X(),x=m.useCallback((b,S,N,w)=>{const{id:y,title:$}=b;return s&&g===y?r.jsx(n.AccordionListItem,{id:y,title:$,route:a,collapseUri:d&&n.formatUrl(d),children:j.map(h=>r.jsx(V,{id:h.id,branch:"default",accordion:s},h.id))},y):w?w(b,S,N,w):null},[s,j,g]);return!t.length&&!i?_(P,{...c,className:n.appendClassNames(e,"humany-deflection-list")}):r.jsx(Se,{...c,"data-loading":i,className:n.appendClassNames(e,"humany-deflection-list"),items:t,header:o,expandable:!!s,renderItem:x,dispatch:C,routing:{guide:l},paramMappers:{guide:({id:b,title:S})=>n.createParams({contactCategory:u,guide:b,accordion:s?f:void 0,uriName:n.formatUrl(S)})},children:r.jsx(n.Loader,{loading:i})})},Se=p(n.GuideList)`
159
+ ${n.contentBox}
160
+ ${n.loadingOpacity}
161
+ `,Ne=p(le)`
162
+ ${n.loadingOpacity}
163
+ ${n.contentBox}
164
+ `,we=p(n.ItemList)`
165
+ ${e=>n.loadingOpacity(e)}
166
+ ${n.contentBox}
167
+ ${F}
168
+
169
+ && {
170
+ i {
171
+ font-size: 25px;
172
+ width: 1.28571429em;
173
+ text-align: center;
174
+ }
175
+ }
176
+ `,Pe=p(n.Link)`
177
+ &:focus-visible {
178
+ ${n.borderTabStyle};
179
+ }
180
+
181
+ ${Y}
182
+ `,Le=p.div`
183
+ display: flex;
184
+ flex-direction: column;
185
+ gap: ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.normal}};
186
+ `,Ee=p(n.StyledText)`
187
+ font-weight: bold;
188
+ `,Re=({className:e,...t})=>{const o=X(),s=n.useContainer(),i=n.useRouteData(),{deflectionHeader:l="",routes:d={},contactMethods:c=[],categories:a=[],guides:u=[],deflectionAccordion:g=!1,loading:f=!1}=B(),{contactCategory:P,guide:j="guide"}=d;if(!a.length&&!c.length&&!f)return _(s,{...t,className:n.appendClassNames(e,"humany-contact-category-list")});const{name:C,params:{contactCategory:x}}=i,b=W(x,a);return c.length?r.jsxs(r.Fragment,{children:[r.jsx(ve,{className:e,guides:u,categoryTitle:b&&b.title,header:l,route:j,accordion:g,loading:f}),r.jsx(Ne,{"data-loading":f,className:e,contactMethods:c,dispatch:o,children:r.jsx(n.Loader,{loading:f})})]}):r.jsx(we,{...t,"data-loading":f,className:n.appendClassNames(e,"humany-contact-category-list"),items:b&&b.items||a,renderItem:({id:S,title:N,symbol:w,matches:y,items:$,description:h})=>y||$&&$.length?r.jsx("li",{"data-contact-category":S,children:r.jsxs(Pe,{routeName:P||C,params:n.createParams({contactCategory:S,uriName:n.formatUrl(N)}),children:[w&&r.jsx(n.SymbolBadge,{symbol:w}),h!=null&&h.length?r.jsxs(Le,{children:[r.jsx(Ee,{children:N}),r.jsx(n.StyledText,{children:h})]}):r.jsx(n.StyledText,{children:N})]})},S):null,children:r.jsx(n.Loader,{loading:f})})},ke=Object.freeze(Object.defineProperty({__proto__:null,default:Re},Symbol.toStringTag,{value:"Module"}));exports.Component=V;exports.contactList=ke;