@telia-ace/widget-ui 1.3.33-rc.1 → 1.3.33-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.
Files changed (3) hide show
  1. package/index.js +1 -1
  2. package/index.mjs +1 -1
  3. package/package.json +4 -4
package/index.js CHANGED
@@ -26,7 +26,7 @@
26
26
  line-height: normal;
27
27
  margin: 0;
28
28
  padding: 0;
29
- `,Ht=({onChange:e=()=>{},onEnter:t=()=>{},className:n,autoComplete:o="",...r})=>s.jsx("input",{className:b.appendClassNames(n,"humany-checkbox"),onKeyDown:i=>{i.key==="Enter"&&t(i)},autoComplete:o,onChange:i=>e(i.target.value,i.currentTarget.checked),...R(r)}),Ve=a.createContext(new Ne.Container),Ze=a.createContext(1),he=a.createContext({id:"",type:"",name:"",branch:""}),Oe=a.createContext({}),Ae=a.createContext(null),Pe=a.createContext(null),Q=()=>a.useContext(he),M=()=>a.useContext(Ve),Tt=(e,t)=>{const n=Q().id,o=M();return(r,i)=>{(t||o).getAsync("actionResolver").then(l=>{l.action(e||n,r,i)})}},J=e=>{const t=a.useContext(he),n=Z(),[o,r]=a.useState();return a.useEffect(()=>{if((e||t.id)&&n){const i=n.nodes.get(e||t.id);r(i)}},[e,t.id,n]),o},T=()=>{const e=a.useRef(!1);return a.useEffect(()=>(e.current=!0,()=>{e.current=!1}),[]),e},Z=e=>{const t=M(),[n,o]=a.useState(null),r=T();return a.useEffect(()=>{D.ComponentPlatform.getInstance(e||t).then(i=>{r.current&&o(i)})},[r]),n},Dt=()=>{const e=J(),t=Z(),[n,o]=a.useState([]),r=T(),i=a.useCallback(l=>{if(t&&r.current&&l){const h=t.getBranch(l),c=l.getChildren(h).map(u=>D.asDescriptor(u));o(c)}},[r,t,o,e]);return a.useEffect(()=>{e&&i(e)},[e,t]),a.useEffect(()=>{if(t){const[l,h]=D.createEventSubscriber(t.events);return l("components:set-layout",(c,u)=>{(e===u.node.parent||u.node.parent===t.nodes.root)&&i(u.node.parent)}),l("components:node-appended",(c,u)=>{(e===u.node.parent||u.node.parent===t.nodes.root)&&i(u.node.parent)}),l("components:node-removed",(c,{parentNode:u})=>{(u===e||u===t.nodes.root)&&i(u)}),()=>{h()}}},[e,t,i]),n},Bt=()=>a.useContext(Ze),zt=(e,t)=>{const n=Q(),o=M(),[r,i]=a.useState(void 0),l=T(),h=e||n.type||"";return a.useEffect(()=>{if(h){let c;return(t||o).getAsync("componentResolver").then(u=>{if(l.current){const d=u.getComponent(h);i(d)}c=u.registerResolver(h,d=>{l.current&&i(d)})}),()=>{c&&c()}}},[l,h,t,o]),r},Fe=e=>{const t=J(e),n=Z(),[o,r]=a.useState({}),i=T();return a.useEffect(()=>{t&&i.current&&r(t.attributes.context)},[i,t]),a.useEffect(()=>{if(n){const l=n.events.subscribe("components:context-changed",(h,c)=>{t===c.node&&i.current&&r(c.node.attributes.context)});return()=>{l()}}},[i,n,t]),o},Wt=()=>a.useContext(Pe),It=()=>{const e=Z(),t=Q(),[n,o]=a.useState([]),[r,i]=a.useState();return a.useEffect(()=>{if(e&&t){const l=new D.ComponentQuery(e).withId(t.id),h=e.actions(l,t.type||b.uuid());i(h),n!==null&&(n.forEach(c=>{h.dispatch(c.key,c.data).then(u=>c.resolve(u)).catch(u=>c.reject(u))}),o(null))}},[e,t.id]),(l,h)=>n!==null?new Promise((c,u)=>{n.push({key:l,data:h,resolve:c,reject:u})}):r.dispatch(l,h)},H=(e,t,n=window,o=()=>!0)=>{const r=a.useRef(()=>{});a.useEffect(()=>{r.current=t},[t]),a.useEffect(()=>{if(!(n&&o()))return;const l=h=>r.current(h);return n.addEventListener(e,l),()=>{n.removeEventListener(e,l)}},[e,n])},Ke=e=>{const t=M(),{events:n}=(e||t).get("$widget");return n},Vt=()=>{const[e,t]=a.useState(!1);return a.useEffect(()=>{const n=()=>{t(!1)},o=r=>{r.keyCode===9&&t(!0)};return window.addEventListener("keydown",o),window.addEventListener("click",n),()=>{window.removeEventListener("keydown",o),window.removeEventListener("click",n)}},[]),e},V=(e,t)=>{const[n,o]=a.useState(!1),r=a.useCallback(l=>{const{key:h}=l;h===e&&(o(!0),t&&t(l))},[o,t]),i=a.useCallback(({key:l})=>{l===e&&o(!1)},[o]);return H("keydown",r,window),H("keyup",i,window),n},Zt=e=>{const t=J(e),n=Z(),[o,r]=a.useState({}),i=T();return a.useEffect(()=>{t&&i.current&&r(t.attributes.layout)},[t,i]),a.useEffect(()=>{if(n){const l=n.events.subscribe("components:layout-changed",(h,c)=>{t===c.node&&i.current&&r(c.node.attributes.layout)});return()=>{l()}}},[n,i,t]),o},me=e=>{const t=a.useRef();return a.useEffect(()=>{t.current=e}),t.current},Ot=()=>a.useContext(Oe),At=e=>{const[t,n]=a.useState(),o=M(),r=T();return a.useEffect(()=>{let i;const l=(e||o).get("$widget");if(!l)return;const{name:h,invoke:c}=l;return c("renderState").then(u=>{r.current&&n(u)}),(e||o).getAsync("actionResolver").then(u=>{i=u.subscribe(h,(d,f)=>{switch(f){case"close":case"open":r.current&&n(f==="open"?D.WidgetRenderState.open:D.WidgetRenderState.closed);break;case"hide":r.current&&n(D.WidgetRenderState.hidden)}})}),()=>{i&&i()}},[r]),t},pe=()=>a.useContext(Ae),Pt=e=>{const t=M(),n=pe(),[o,r]=a.useState({name:"",params:{}}),i=T();return a.useEffect(()=>{const l=(e||t).get("$widget");if(!l)return;const{events:h}=l;return h.subscribe("router:change",(u,{next:{routeData:d}})=>{if(i.current){const{name:f,params:m}=d;b.removeNullAndUndefinedValues(m),r({name:f,params:m})}})},[i,e,t]),a.useEffect(()=>{if(n&&n.history&&i.current){const l=n.getRouteData(),{name:h,params:c}=l;b.removeNullAndUndefinedValues(c),r({name:h,params:c})}},[n,i]),o},ge=e=>{const t=a.useRef(),n=a.useRef(0);let o;const r=a.useCallback(()=>{var u;(u=t.current)==null||u.classList.add("humany-scrolling"),clearTimeout(o),o=setTimeout(()=>{var d;(d=t.current)==null||d.classList.remove("humany-scrolling")},500)},[t]),i=a.useCallback(u=>{n.current=u.touches[0].clientY},[t]),l=u=>h(u)?u===t.current?u:null:u.parentElement?l(u.parentElement):null,h=u=>u.scrollWidth>u.clientWidth||u.scrollHeight>u.clientHeight,c=a.useCallback(u=>{if(!u.cancelable)return;const d=u.touches[0].clientY,f=l(u.target);if(!f)return;const m=f.scrollTop,g=n.current-d<0?"up":"down",p=m<=0&&g==="up",x=m>=f.scrollHeight-f.offsetHeight&&g==="down";(p||x)&&u.preventDefault(),n.current=d},[t,n]);return H("scroll",r,t.current,()=>t.current&&e),H("touchstart",i,t.current,()=>t.current&&e),H("touchmove",c,t.current,()=>t.current&&e),e?[Ft,t]:["",t]},Ft=`
29
+ `,Ht=({onChange:e=()=>{},onEnter:t=()=>{},className:n,autoComplete:o="",...r})=>s.jsx("input",{className:b.appendClassNames(n,"humany-checkbox"),onKeyDown:i=>{i.key==="Enter"&&t(i)},autoComplete:o||void 0,onChange:i=>e(i.target.value,i.currentTarget.checked),...R(r)}),Ve=a.createContext(new Ne.Container),Ze=a.createContext(1),he=a.createContext({id:"",type:"",name:"",branch:""}),Oe=a.createContext({}),Ae=a.createContext(null),Pe=a.createContext(null),Q=()=>a.useContext(he),M=()=>a.useContext(Ve),Tt=(e,t)=>{const n=Q().id,o=M();return(r,i)=>{(t||o).getAsync("actionResolver").then(l=>{l.action(e||n,r,i)})}},J=e=>{const t=a.useContext(he),n=Z(),[o,r]=a.useState();return a.useEffect(()=>{if((e||t.id)&&n){const i=n.nodes.get(e||t.id);r(i)}},[e,t.id,n]),o},T=()=>{const e=a.useRef(!1);return a.useEffect(()=>(e.current=!0,()=>{e.current=!1}),[]),e},Z=e=>{const t=M(),[n,o]=a.useState(null),r=T();return a.useEffect(()=>{D.ComponentPlatform.getInstance(e||t).then(i=>{r.current&&o(i)})},[r]),n},Dt=()=>{const e=J(),t=Z(),[n,o]=a.useState([]),r=T(),i=a.useCallback(l=>{if(t&&r.current&&l){const h=t.getBranch(l),c=l.getChildren(h).map(u=>D.asDescriptor(u));o(c)}},[r,t,o,e]);return a.useEffect(()=>{e&&i(e)},[e,t]),a.useEffect(()=>{if(t){const[l,h]=D.createEventSubscriber(t.events);return l("components:set-layout",(c,u)=>{(e===u.node.parent||u.node.parent===t.nodes.root)&&i(u.node.parent)}),l("components:node-appended",(c,u)=>{(e===u.node.parent||u.node.parent===t.nodes.root)&&i(u.node.parent)}),l("components:node-removed",(c,{parentNode:u})=>{(u===e||u===t.nodes.root)&&i(u)}),()=>{h()}}},[e,t,i]),n},Bt=()=>a.useContext(Ze),zt=(e,t)=>{const n=Q(),o=M(),[r,i]=a.useState(void 0),l=T(),h=e||n.type||"";return a.useEffect(()=>{if(h){let c;return(t||o).getAsync("componentResolver").then(u=>{if(l.current){const d=u.getComponent(h);i(d)}c=u.registerResolver(h,d=>{l.current&&i(d)})}),()=>{c&&c()}}},[l,h,t,o]),r},Fe=e=>{const t=J(e),n=Z(),[o,r]=a.useState({}),i=T();return a.useEffect(()=>{t&&i.current&&r(t.attributes.context)},[i,t]),a.useEffect(()=>{if(n){const l=n.events.subscribe("components:context-changed",(h,c)=>{t===c.node&&i.current&&r(c.node.attributes.context)});return()=>{l()}}},[i,n,t]),o},Wt=()=>a.useContext(Pe),It=()=>{const e=Z(),t=Q(),[n,o]=a.useState([]),[r,i]=a.useState();return a.useEffect(()=>{if(e&&t){const l=new D.ComponentQuery(e).withId(t.id),h=e.actions(l,t.type||b.uuid());i(h),n!==null&&(n.forEach(c=>{h.dispatch(c.key,c.data).then(u=>c.resolve(u)).catch(u=>c.reject(u))}),o(null))}},[e,t.id]),(l,h)=>n!==null?new Promise((c,u)=>{n.push({key:l,data:h,resolve:c,reject:u})}):r.dispatch(l,h)},H=(e,t,n=window,o=()=>!0)=>{const r=a.useRef(()=>{});a.useEffect(()=>{r.current=t},[t]),a.useEffect(()=>{if(!(n&&o()))return;const l=h=>r.current(h);return n.addEventListener(e,l),()=>{n.removeEventListener(e,l)}},[e,n])},Ke=e=>{const t=M(),{events:n}=(e||t).get("$widget");return n},Vt=()=>{const[e,t]=a.useState(!1);return a.useEffect(()=>{const n=()=>{t(!1)},o=r=>{r.keyCode===9&&t(!0)};return window.addEventListener("keydown",o),window.addEventListener("click",n),()=>{window.removeEventListener("keydown",o),window.removeEventListener("click",n)}},[]),e},V=(e,t)=>{const[n,o]=a.useState(!1),r=a.useCallback(l=>{const{key:h}=l;h===e&&(o(!0),t&&t(l))},[o,t]),i=a.useCallback(({key:l})=>{l===e&&o(!1)},[o]);return H("keydown",r,window),H("keyup",i,window),n},Zt=e=>{const t=J(e),n=Z(),[o,r]=a.useState({}),i=T();return a.useEffect(()=>{t&&i.current&&r(t.attributes.layout)},[t,i]),a.useEffect(()=>{if(n){const l=n.events.subscribe("components:layout-changed",(h,c)=>{t===c.node&&i.current&&r(c.node.attributes.layout)});return()=>{l()}}},[n,i,t]),o},me=e=>{const t=a.useRef();return a.useEffect(()=>{t.current=e}),t.current},Ot=()=>a.useContext(Oe),At=e=>{const[t,n]=a.useState(),o=M(),r=T();return a.useEffect(()=>{let i;const l=(e||o).get("$widget");if(!l)return;const{name:h,invoke:c}=l;return c("renderState").then(u=>{r.current&&n(u)}),(e||o).getAsync("actionResolver").then(u=>{i=u.subscribe(h,(d,f)=>{switch(f){case"close":case"open":r.current&&n(f==="open"?D.WidgetRenderState.open:D.WidgetRenderState.closed);break;case"hide":r.current&&n(D.WidgetRenderState.hidden)}})}),()=>{i&&i()}},[r]),t},pe=()=>a.useContext(Ae),Pt=e=>{const t=M(),n=pe(),[o,r]=a.useState({name:"",params:{}}),i=T();return a.useEffect(()=>{const l=(e||t).get("$widget");if(!l)return;const{events:h}=l;return h.subscribe("router:change",(u,{next:{routeData:d}})=>{if(i.current){const{name:f,params:m}=d;b.removeNullAndUndefinedValues(m),r({name:f,params:m})}})},[i,e,t]),a.useEffect(()=>{if(n&&n.history&&i.current){const l=n.getRouteData(),{name:h,params:c}=l;b.removeNullAndUndefinedValues(c),r({name:h,params:c})}},[n,i]),o},ge=e=>{const t=a.useRef(),n=a.useRef(0);let o;const r=a.useCallback(()=>{var u;(u=t.current)==null||u.classList.add("humany-scrolling"),clearTimeout(o),o=setTimeout(()=>{var d;(d=t.current)==null||d.classList.remove("humany-scrolling")},500)},[t]),i=a.useCallback(u=>{n.current=u.touches[0].clientY},[t]),l=u=>h(u)?u===t.current?u:null:u.parentElement?l(u.parentElement):null,h=u=>u.scrollWidth>u.clientWidth||u.scrollHeight>u.clientHeight,c=a.useCallback(u=>{if(!u.cancelable)return;const d=u.touches[0].clientY,f=l(u.target);if(!f)return;const m=f.scrollTop,g=n.current-d<0?"up":"down",p=m<=0&&g==="up",x=m>=f.scrollHeight-f.offsetHeight&&g==="down";(p||x)&&u.preventDefault(),n.current=d},[t,n]);return H("scroll",r,t.current,()=>t.current&&e),H("touchstart",i,t.current,()=>t.current&&e),H("touchmove",c,t.current,()=>t.current&&e),e?[Ft,t]:["",t]},Ft=`
30
30
  overflow-y: ${ce()===ae.Chrome||ce()===ae.EdgeChromium?"overlay":"auto"};
31
31
  overflow-x: hidden;
32
32
  -ms-overflow-style: none; /* IE 10+ */
package/index.mjs CHANGED
@@ -261,7 +261,7 @@ const Tt = (e) => (t) => /* @__PURE__ */ i(Tn, { attrs: t, htmlBody: e }), Nt =
261
261
  onKeyDown: (s) => {
262
262
  s.key === "Enter" && t(s);
263
263
  },
264
- autoComplete: o,
264
+ autoComplete: o || void 0,
265
265
  onChange: (s) => e(s.target.value, s.currentTarget.checked),
266
266
  ...z(r)
267
267
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telia-ace/widget-ui",
3
- "version": "1.3.33-rc.1",
3
+ "version": "1.3.33-rc.2",
4
4
  "main": "./index.js",
5
5
  "types": "./index.d.ts",
6
6
  "exports": {
@@ -10,9 +10,9 @@
10
10
  }
11
11
  },
12
12
  "dependencies": {
13
- "@telia-ace/widget-core": "^1.3.33-rc.1",
14
- "@telia-ace/widget-routing": "^1.3.33-rc.1",
15
- "@telia-ace/widget-utilities": "^1.3.33-rc.1",
13
+ "@telia-ace/widget-core": "^1.3.33-rc.2",
14
+ "@telia-ace/widget-routing": "^1.3.33-rc.2",
15
+ "@telia-ace/widget-utilities": "^1.3.33-rc.2",
16
16
  "@webprovisions/platform": "^1.1.4",
17
17
  "htmr": "1.0.2"
18
18
  },