@telia-ace/knowledge-widget-adapters 0.0.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.
Files changed (40) hide show
  1. package/contact-methods/chat-popup/chat-popup-plugin.d.ts +3 -0
  2. package/contact-methods/chat-popup/index.d.ts +1 -0
  3. package/contact-methods/email/email-form-component.d.ts +5 -0
  4. package/contact-methods/email/email-plugin.d.ts +17 -0
  5. package/contact-methods/email/index.d.ts +1 -0
  6. package/contact-methods/free-text/free-text-component.d.ts +5 -0
  7. package/contact-methods/free-text/free-text-plugin.d.ts +3 -0
  8. package/contact-methods/free-text/index.d.ts +1 -0
  9. package/contact-methods/index.d.ts +10 -0
  10. package/contact-methods/link/index.d.ts +1 -0
  11. package/contact-methods/link/link-component.d.ts +4 -0
  12. package/contact-methods/link/link-plugin.d.ts +3 -0
  13. package/contact-methods/phone/index.d.ts +1 -0
  14. package/contact-methods/phone/phone-component.d.ts +4 -0
  15. package/contact-methods/phone/phone-plugin.d.ts +3 -0
  16. package/contact-methods/platform.d.ts +67 -0
  17. package/contact-methods/ui/confirmation.d.ts +7 -0
  18. package/contact-methods/ui/contact-list.d.ts +20 -0
  19. package/contact-methods/ui/description.d.ts +4 -0
  20. package/contact-methods/ui/form.d.ts +5 -0
  21. package/contact-methods/ui/index.d.ts +7 -0
  22. package/contact-methods/ui/use-contact-method.d.ts +2 -0
  23. package/contact-methods/web-service/index.d.ts +1 -0
  24. package/contact-methods/web-service/web-service-plugin.d.ts +3 -0
  25. package/create-adapter.d.ts +8 -0
  26. package/default-contact-methods-plugin.d.ts +9 -0
  27. package/email-form-component-b618db4a.mjs +54 -0
  28. package/email-form-component-d156932f.js +8 -0
  29. package/free-text-component-6da84bfa.js +3 -0
  30. package/free-text-component-a4724ece.mjs +35 -0
  31. package/index-3c56a15f.js +97 -0
  32. package/index-4b2ec2f4.mjs +625 -0
  33. package/index.d.ts +5 -0
  34. package/index.js +1 -0
  35. package/index.mjs +30 -0
  36. package/link-component-1c24e6af.mjs +17 -0
  37. package/link-component-6fbdc8fb.js +1 -0
  38. package/package.json +26 -0
  39. package/phone-component-25f3e937.mjs +14 -0
  40. package/phone-component-ebf50e0d.js +1 -0
@@ -0,0 +1,3 @@
1
+ import { Container } from '@webprovisions/platform';
2
+
3
+ export default function chatPopupPlugin(container: Container): void;
@@ -0,0 +1 @@
1
+ export { default as ChatPopupPlugin } from './chat-popup-plugin';
@@ -0,0 +1,5 @@
1
+ import { default as React } from 'react';
2
+ import { ContactMethodProps } from '../ui';
3
+
4
+ declare const EmailFormComponent: React.FC<ContactMethodProps>;
5
+ export default EmailFormComponent;
@@ -0,0 +1,17 @@
1
+ import { SubmissionApiResult } from '@telia-ace/knowledge-serviceclient';
2
+ import { Container } from '@webprovisions/platform';
3
+ import { ContactMethodType } from '../ui';
4
+
5
+ export declare const submit: (container: Container, contactMethod: ContactMethodType, transform?: ((response: any) => SubmissionApiResult) | undefined) => Promise<string>;
6
+ export declare const validate: (container: Container, contactMethod: ContactMethodType) => Promise<{
7
+ valid: boolean;
8
+ errors: {
9
+ [key: string]: string;
10
+ };
11
+ errorTypes: {
12
+ [key: string]: string;
13
+ };
14
+ }>;
15
+ export declare const evaluate: (container: Container, contactMethod: ContactMethodType) => Promise<import('../../../../../forms/src/index.ts').Form>;
16
+ export declare const complete: (container: Container, contactMethod: ContactMethodType) => Promise<void>;
17
+ export default function emailPlugin(container: Container): void;
@@ -0,0 +1 @@
1
+ export { complete as defaultComplete, default as EmailPlugin, evaluate as defaultEvaluate, submit as defaultSubmit, validate as defaultValidate, } from './email-plugin';
@@ -0,0 +1,5 @@
1
+ import { default as React } from 'react';
2
+ import { ContactMethodProps } from '../ui';
3
+
4
+ declare const FreeTextComponent: React.FC<ContactMethodProps>;
5
+ export default FreeTextComponent;
@@ -0,0 +1,3 @@
1
+ import { Container } from '@webprovisions/platform';
2
+
3
+ export default function freeTextPlugin(container: Container): void;
@@ -0,0 +1 @@
1
+ export { default as FreeTextPlugin } from './free-text-plugin';
@@ -0,0 +1,10 @@
1
+ export { ChatPopupPlugin } from './chat-popup';
2
+ export { defaultComplete, defaultEvaluate, defaultSubmit, defaultValidate, EmailPlugin, } from './email';
3
+ export { FreeTextPlugin } from './free-text';
4
+ export { LinkPlugin } from './link';
5
+ export { PhonePlugin } from './phone';
6
+ export { default as ContactMethodPlatform } from './platform';
7
+ export type { Click as ContactMethodClick, ReactComponentImport, } from './platform';
8
+ export { contactItemList, contactLink, ContactList, ContactMethod, Form as DefaultForm, useContactMethod, } from './ui';
9
+ export type { ContactMethodType } from './ui';
10
+ export { WebServicePlugin } from './web-service';
@@ -0,0 +1 @@
1
+ export { default as LinkPlugin } from './link-plugin';
@@ -0,0 +1,4 @@
1
+ import { ContactMethodProps } from '../ui';
2
+ import * as React from 'react';
3
+ declare const LinkComponent: React.FC<ContactMethodProps>;
4
+ export default LinkComponent;
@@ -0,0 +1,3 @@
1
+ import { Container } from '@webprovisions/platform';
2
+
3
+ export default function linkPlugin(container: Container): void;
@@ -0,0 +1 @@
1
+ export { default as PhonePlugin } from './phone-plugin';
@@ -0,0 +1,4 @@
1
+ import { ContactMethodProps } from '../ui';
2
+ import * as React from 'react';
3
+ declare const PhoneComponent: React.FC<ContactMethodProps>;
4
+ export default PhoneComponent;
@@ -0,0 +1,3 @@
1
+ import { Container } from '@webprovisions/platform';
2
+
3
+ export default function phonePlugin(container: Container): void;
@@ -0,0 +1,67 @@
1
+ import { ComponentPlatform } from '../../../core/src/index.ts';
2
+ import { Form } from '../../../../forms/src/index.ts';
3
+ import { Container } from '@webprovisions/platform';
4
+ import { default as React } from 'react';
5
+ import { ContactMethodProps } from './ui';
6
+
7
+ export type ReactComponentImport = Promise<{
8
+ default: React.FunctionComponent<any>;
9
+ }>;
10
+ export type Click = (e: React.MouseEvent, cm: ContactMethodProps) => void;
11
+ export type AdapterSettings = {
12
+ clientName: string;
13
+ render: string | ReactComponentImport;
14
+ handleDescription?: (cm: ContactMethodProps) => Promise<string> | string;
15
+ handleDisabled?: (cm: ContactMethodProps) => Promise<boolean> | boolean;
16
+ handleClick?: (cm: ContactMethodProps) => Promise<Click> | Click;
17
+ onEvaluate?: (cm: ContactMethodProps) => Promise<Form> | Form;
18
+ onValidate?: (cm: ContactMethodProps) => Promise<ValidationResult> | ValidationResult;
19
+ onSubmit?: (cm: ContactMethodProps) => Promise<string> | string;
20
+ onComplete?: (cm: ContactMethodProps) => Promise<void> | void;
21
+ };
22
+ export type ValidationResult = {
23
+ errors?: {
24
+ [key: string]: string;
25
+ };
26
+ errorTypes?: {
27
+ [key: string]: string;
28
+ };
29
+ valid: boolean;
30
+ };
31
+ export declare enum ContactMethodTrackTypes {
32
+ ContactMethodValidate = "contact-method-validate",
33
+ ContactMethodComplete = "contact-method-complete"
34
+ }
35
+ declare class ContactMethodPlatform {
36
+ private container;
37
+ private componentPlatform;
38
+ private adapters;
39
+ private subs;
40
+ static create(container: Container): Promise<ContactMethodPlatform>;
41
+ handleAdapters(cm: ContactMethodProps): Promise<Merge<import('./ui').ContactMethodType, {
42
+ className?: string | undefined;
43
+ onClick?: ((event: React.MouseEvent<Element, MouseEvent>, properties: Merge<import('./ui').ContactMethodType, any>) => void) | undefined;
44
+ renderDefault?: ((extraProps?: any) => any) | undefined;
45
+ htmlParseInstruction?: import('../../../../ui/src/index.ts').HtmlParseInstruction | undefined;
46
+ href?: string | undefined;
47
+ target?: string | undefined;
48
+ disabled?: boolean | undefined;
49
+ action?: ((action: string, value: any) => void) | undefined;
50
+ dispatch?: import('../../../../ui/src/index.ts').DispatchAction | undefined;
51
+ symbol?: import('../../../core/src/index.ts').Symbol | undefined;
52
+ description?: string | undefined;
53
+ confirmation?: string | undefined;
54
+ guideId?: string | undefined;
55
+ autoFocus?: boolean | undefined;
56
+ }>>;
57
+ constructor(container: Container, componentPlatform: ComponentPlatform);
58
+ static getInstance(container: Container, key?: string): Promise<ContactMethodPlatform>;
59
+ private track;
60
+ complete(contactMethod: ContactMethodProps): void | Promise<void>;
61
+ evaluate(contactMethod: ContactMethodProps): Promise<Form>;
62
+ validate(contactMethod: ContactMethodProps): Promise<ValidationResult>;
63
+ submit(contactMethod: ContactMethodProps): Promise<string>;
64
+ create(settings: AdapterSettings): Promise<void>;
65
+ dispose(): void;
66
+ }
67
+ export default ContactMethodPlatform;
@@ -0,0 +1,7 @@
1
+ import { default as React } from 'react';
2
+
3
+ export type Props = {
4
+ html: string;
5
+ };
6
+ declare const Confirmation: React.FC<Props>;
7
+ export default Confirmation;
@@ -0,0 +1,20 @@
1
+ import { Theme } from '@emotion/react';
2
+ import { DispatchAction } from '../../../../ui/src/index.ts';
3
+ import { default as React, ReactNode } from 'react';
4
+ import { ContactMethodType } from './contact-method';
5
+
6
+ export declare const contactItemList: (p: {
7
+ theme: Theme;
8
+ }) => import('@emotion/react').SerializedStyles;
9
+ type Props = {
10
+ contactMethods: ContactMethodType[];
11
+ header?: string;
12
+ className?: string;
13
+ action?: (action: string, value?: any) => void;
14
+ dispatch?: DispatchAction;
15
+ children?: ReactNode;
16
+ itemRenderer?: (cm: any, props: any) => JSX.Element;
17
+ guideId?: string;
18
+ };
19
+ declare const ContactList: React.FC<Props>;
20
+ export default ContactList;
@@ -0,0 +1,4 @@
1
+ declare const _default: import('@emotion/styled').StyledComponent<any, {}, {
2
+ ref?: import('react').Ref<any> | undefined;
3
+ }>;
4
+ export default _default;
@@ -0,0 +1,5 @@
1
+ import { default as React } from 'react';
2
+ import { ContactMethodProps } from '.';
3
+
4
+ declare const Form: React.FC<ContactMethodProps>;
5
+ export default Form;
@@ -0,0 +1,7 @@
1
+ export { default as Confirmation } from './confirmation';
2
+ export { contactItemList, default as ContactList } from './contact-list';
3
+ export { contactLink, default as ContactMethod } from './contact-method';
4
+ export type { ContactMethodType, Props as ContactMethodProps, } from './contact-method';
5
+ export { default as Description } from './description';
6
+ export { default as Form } from './form';
7
+ export { default as useContactMethod } from './use-contact-method';
@@ -0,0 +1,2 @@
1
+ declare const useContactMethod: (clientName: string) => any | null;
2
+ export default useContactMethod;
@@ -0,0 +1 @@
1
+ export { default as WebServicePlugin } from './web-service-plugin';
@@ -0,0 +1,3 @@
1
+ import { Container } from '@webprovisions/platform';
2
+
3
+ export default function webServicePlugin(container: Container): void;
@@ -0,0 +1,8 @@
1
+ import { Container } from '@webprovisions/platform';
2
+
3
+ export type Callback = (settings: {
4
+ [key: string]: any;
5
+ }, data?: {
6
+ [key: string]: any;
7
+ }) => Promise<string | void> | (string | void);
8
+ export declare const createSubmitAdapter: (container: Container, clientName: string, fn: Callback) => Promise<void>;
@@ -0,0 +1,9 @@
1
+ import { Plugin } from '../../core/src/index.ts';
2
+ import { Container } from '@webprovisions/platform';
3
+
4
+ /**
5
+ * Registers default Humany contact methods.
6
+ */
7
+ export declare class DefaultContactMethodsPlugin extends Plugin {
8
+ constructor(container: Container, settings: any);
9
+ }
@@ -0,0 +1,54 @@
1
+ import { jsx as e } from "react/jsx-runtime";
2
+ import { css as l } from "@emotion/react";
3
+ import c from "@emotion/styled";
4
+ import { Html as f, genericHtml as d, headingElement as h } from "@telia-ace/knowledge-widget-ui";
5
+ import { appendClassNames as r } from "@telia-ace/widget-utilities";
6
+ import { F as p } from "./index-4b2ec2f4.mjs";
7
+ import "react";
8
+ import "@telia-ace/widget-forms";
9
+ import "@telia-ace/knowledge-widget-core";
10
+ const u = c(f)`
11
+ ${d}
12
+
13
+ ${(t) => {
14
+ var m;
15
+ return h(t)(
16
+ "h1",
17
+ l`
18
+ font-weight: normal;
19
+ font-size: ${(m = t.theme.fonts) == null ? void 0 : m.medium};
20
+ `
21
+ );
22
+ }}
23
+ `, E = (t) => {
24
+ const {
25
+ className: m,
26
+ renderDefault: n = () => {
27
+ },
28
+ body: { form: a },
29
+ confirmation: o,
30
+ htmlParseInstruction: i,
31
+ disabled: s
32
+ } = t;
33
+ return o ? /* @__PURE__ */ e(
34
+ u,
35
+ {
36
+ className: r(
37
+ m,
38
+ "humany-contact-method-confirmation",
39
+ "humany-contact-method-email"
40
+ ),
41
+ html: o,
42
+ htmlParseInstruction: i
43
+ }
44
+ ) : a && !s ? /* @__PURE__ */ e(
45
+ p,
46
+ {
47
+ ...t,
48
+ className: r(m, "humany-contact-method-email")
49
+ }
50
+ ) : n();
51
+ };
52
+ export {
53
+ E as default
54
+ };
@@ -0,0 +1,8 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),l=require("@emotion/react"),u=require("@emotion/styled"),n=require("@telia-ace/knowledge-widget-ui"),o=require("@telia-ace/widget-utilities"),d=require("./index-3c56a15f.js");require("react");require("@telia-ace/widget-forms");require("@telia-ace/knowledge-widget-core");const h=u(n.Html)`
2
+ ${n.genericHtml}
3
+
4
+ ${e=>{var t;return n.headingElement(e)("h1",l.css`
5
+ font-weight: normal;
6
+ font-size: ${(t=e.theme.fonts)==null?void 0:t.medium};
7
+ `)}}
8
+ `,f=e=>{const{className:t,renderDefault:s=()=>{},body:{form:a},confirmation:r,htmlParseInstruction:m,disabled:c}=e;return r?i.jsx(h,{className:o.appendClassNames(t,"humany-contact-method-confirmation","humany-contact-method-email"),html:r,htmlParseInstruction:m}):a&&!c?i.jsx(d.Form,{...e,className:o.appendClassNames(t,"humany-contact-method-email")}):s()};exports.default=f;
@@ -0,0 +1,3 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),l=require("@emotion/styled"),n=require("@telia-ace/knowledge-widget-ui"),u=require("@telia-ace/widget-utilities"),o=require("./index-3c56a15f.js");require("@telia-ace/widget-forms");require("react");require("@telia-ace/knowledge-widget-core");require("@emotion/react");const c=({className:s,description:t,body:{freetext:r},htmlParseInstruction:i})=>r?e.jsxs("div",{className:u.appendClassNames(s,"humany-contact-method-free-text"),children:[e.jsx(d,{html:r,htmlParseInstruction:i}),t&&e.jsx(o.Description,{html:t,htmlParseInstruction:i})]}):null,d=l(n.Html)`
2
+ ${n.genericHtml};
3
+ `;exports.default=c;
@@ -0,0 +1,35 @@
1
+ import { jsxs as p, jsx as r } from "react/jsx-runtime";
2
+ import i from "@emotion/styled";
3
+ import { Html as l, genericHtml as s } from "@telia-ace/knowledge-widget-ui";
4
+ import { appendClassNames as n } from "@telia-ace/widget-utilities";
5
+ import { D as a } from "./index-4b2ec2f4.mjs";
6
+ import "@telia-ace/widget-forms";
7
+ import "react";
8
+ import "@telia-ace/knowledge-widget-core";
9
+ import "@emotion/react";
10
+ const D = ({
11
+ className: e,
12
+ description: t,
13
+ body: { freetext: m },
14
+ htmlParseInstruction: o
15
+ }) => m ? /* @__PURE__ */ p(
16
+ "div",
17
+ {
18
+ className: n(e, "humany-contact-method-free-text"),
19
+ children: [
20
+ /* @__PURE__ */ r(d, { html: m, htmlParseInstruction: o }),
21
+ t && /* @__PURE__ */ r(
22
+ a,
23
+ {
24
+ html: t,
25
+ htmlParseInstruction: o
26
+ }
27
+ )
28
+ ]
29
+ }
30
+ ) : null, d = i(l)`
31
+ ${s};
32
+ `;
33
+ export {
34
+ D as default
35
+ };
@@ -0,0 +1,97 @@
1
+ "use strict";var Z=Object.defineProperty;var _=(t,e,n)=>e in t?Z(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var N=(t,e,n)=>(_(t,typeof e!="symbol"?e+"":e,n),n);const C=require("@telia-ace/widget-forms"),I=require("@telia-ace/knowledge-widget-core"),k=require("@telia-ace/widget-utilities"),P=require("react"),u=require("react/jsx-runtime"),w=require("@emotion/react"),f=require("@emotion/styled"),m=require("@telia-ace/knowledge-widget-ui"),S=(t,e,n=!1)=>t.getManyAsync("matchingClient","router").then(i=>{const{formData:o}=new C.FormReader(e.body.form).export(n),{router:c,matchingClient:r}=i,{params:s}=c.getRouteData();return e.guideId=e.body.guideId||s.guideId,r.customRequest(`contactmethods/${e.id}${n?"/validatedwithpayload":""}`,"POST",{body:o,configuration:{guideId:e.body.guideId||s.guideId}})}),A=(t,e,n)=>S(t,e).then(i=>n?n(i):i).then(({ConfirmationText:i})=>i),y=(t,e)=>S(t,e,!0).then(n=>({valid:n.Validation.IsValid,errors:n.Validation.Errors,errorTypes:n.Validation.ErrorTypes})),j=(t,e)=>S(t,e,!0).then(n=>C.FormBuilder.fromLegacyForm(e.id,n.ContactMethod.Form).get()),b=(t,e)=>t.getAsync("matchingClient").then(n=>{n.completeContactMethod(e.id,{guideId:e.guideId})});function F(t){t.getAsync("contactMethods").then(e=>{e.create({clientName:"email.form",render:Promise.resolve().then(()=>require("./email-form-component-d156932f.js")),onEvaluate:n=>j(t,n),onValidate:n=>y(t,n),onSubmit:n=>A(t,n),onComplete:n=>b(t,n)})})}const q=(t,e,n)=>{const{url:i,width:o,height:c}=e,r=n||{},s=document.createElement("a");return s.href=i,s.search.replace("?","").split("&").forEach(a=>{const[d,l]=a.split("=");typeof l<"u"&&(r[d]=l)}),s.search=Object.keys(r).map(a=>`${a}=${r[a]}`).join("&"),window.open(s.href,t,`width=${o},height=${c}`),""};function M(t){t.getAsync("contactMethods").then(e=>{e.create({clientName:"chat.popup",render:"email.form",handleClick:n=>{const{title:i,body:o}=n,{form:c,guideId:r,confirmationFallback:s,...a}=o;return c?()=>{}:d=>{d.preventDefault(),q(i,a)}},onValidate:n=>y(t,n),onComplete:n=>b(t,n),onSubmit:n=>{const{title:i,body:o}=n,{form:c,guideId:r,confirmationFallback:s,...a}=o,d=new C.FormReader(c).export().values;return q(i,a,d),s}})})}function V(t){t.getAsync("contactMethods").then(e=>{e.create({clientName:"custom.freetext",render:Promise.resolve().then(()=>require("./free-text-component-6da84bfa.js"))})})}function z(t){t.getAsync("contactMethods").then(e=>{e.create({clientName:"custom.link",render:Promise.resolve().then(()=>require("./link-component-6fbdc8fb.js"))})})}function H(t){t.getAsync("contactMethods").then(e=>{e.create({clientName:"phone.text",render:Promise.resolve().then(()=>require("./phone-component-ebf50e0d.js"))})})}const ee=async(t,e)=>{const n=t.get(e.clientName);let{description:i,disabled:o,onClick:c}=e;if(n){const{handleClick:r,handleDescription:s,handleDisabled:a}=n;typeof r=="function"&&(c=await Promise.resolve(r(e))),typeof s=="function"&&(i=await Promise.resolve(s(e))),typeof a=="function"&&(o=await Promise.resolve(a(e)))}return Promise.resolve({...e,description:i,disabled:o,onClick:c})};class x{constructor(e,n){N(this,"adapters",new Map);N(this,"subs",[]);if(this.container=e,this.componentPlatform=n,n){n.components().ofType("contact-list").select().actions.watch("contact-list.fetched",async(r,s)=>{const{contactMethods:a}=r;if(a){const d=Promise.all(a.map(l=>this.handleAdapters(l)));await Promise.resolve(d).then(l=>{r.contactMethods=l})}return s(r)});const o=n.components().ofType("guide").select();o.actions.watch("guide.fetched",async(r,s)=>{const{contactMethods:a}=r;if(a){const d=Promise.all(a.map(l=>this.handleAdapters(l)));await Promise.resolve(d).then(l=>{r.contactMethods=l})}return s(r)}),o.actions.watch("guide.handover",async(r,s)=>{const{handoverContactMethods:a}=r;if(a){const d=Promise.all(a.map(l=>this.handleAdapters(l)));await Promise.resolve(d).then(l=>{r.handoverContactMethods=l})}return s(r)}),n.components().ofType("contact-method").select().actions.watch("contact-method.fetched",async(r,s)=>{const{contactMethod:a}=r;return a?this.handleAdapters(a).then(d=>s({...r,contactMethod:d})):s(r)})}}static create(e){return I.ComponentPlatform.getInstance(e).then(n=>new x(e,n))}handleAdapters(e){return ee(this.adapters,e)}static getInstance(e,n="contactMethods"){return k.lock(e)(()=>e.getAsync(n).then(i=>{let o=i;return o||I.ComponentPlatform.getInstance(e).then(c=>(o=new x(e,c),e.registerAsync(n,()=>o),o))}))}track(e={},n){const{events:i}=this.container.get("$widget");i.dispatch("tracking:service-client-response",{type:n,data:e})}complete(e){const{id:n,title:i,clientName:o,expanded:c,body:r}=e;this.track({contactMethod:{id:n,title:i,expanded:c,type:o},hasGuide:!!r.guideId},"contact-method-complete");const s=this.adapters.get(o);if(s&&s.onComplete)return s.onComplete(e)}evaluate(e){const{clientName:n}=e,i=this.adapters.get(n);return i&&i.onEvaluate?Promise.resolve(i.onEvaluate(e)):Promise.resolve(e.body.form)}validate(e){const{id:n,title:i,clientName:o}=e,c=this.adapters.get(o);return c&&c.onValidate?Promise.resolve(c.onValidate(e)).then(r=>{this.track({contactMethod:{id:n,title:i,type:o},isValid:r.valid},"contact-method-validate");const{events:s}=this.container.get("$widget");return s.dispatch("form:validated",{isValid:r.valid}),r}):Promise.resolve({valid:!0})}submit(e){const{clientName:n}=e,i=this.adapters.get(n);return i&&i.onSubmit?Promise.resolve(i.onSubmit(e)).then(o=>(this.complete(e),o)):Promise.resolve("")}create(e){const{clientName:n,render:i}=e;return this.adapters.set(n,{onValidate:o=>y(this.container,o),onEvaluate:o=>j(this.container,o),onComplete:o=>b(this.container,o),...e}),this.container.getAsync("componentResolver").then(o=>{typeof i=="string"?this.subs.push(o.registerAlias(n,i)):this.subs.push(o.registerComponent(n,P.lazy(()=>i)))})}dispose(){this.subs.forEach(e=>e())}}f(m.Paragraph)`
2
+ ${t=>{var e;return m.headingElement(t)("h1",w.css`
3
+ font-weight: normal;
4
+ font-size: ${(e=t.theme.fonts)==null?void 0:e.medium};
5
+ `)}}
6
+ `;const O=f(m.Html)`
7
+ ${m.genericHtml}
8
+ font-weight: 300;
9
+ line-height: 1.5em;
10
+ button:focus-visible {
11
+ ${m.borderTabStyle};
12
+ }
13
+
14
+ a:focus-visible {
15
+ ${m.linkTabStyle};
16
+ }
17
+ `,U=t=>{const e=m.useComponent(t.clientName),{params:{contactCategory:n,guideCategory:i,phrase:o}}=m.useRouteData();if(typeof e>"u")return null;if(e===null)return process.env.NODE_ENV!=="production"?u.jsx(ne,{title:`client-name: ${t.clientName}, id: ${t.id}`,className:"humany-non-resolved-contact-method",children:u.jsx(m.Typography,{variant:"h5",children:"Non resolved Contact Method type"})}):null;const c=(r={})=>{const s={...t,...r},{id:a,title:d,clientName:l,symbol:p,inline:$,onClick:v=()=>{},description:g,htmlParseInstruction:T,className:J,disabled:Q,guideId:X,dispatch:E=()=>{},expanded:L}=s,Y=$?{onKeyDown:h=>{h.key&&h.key==="Enter"&&(v(h,s),h.defaultPrevented||!L&&E("expand",a))},onClick:h=>{v(h,s),h.defaultPrevented||!L&&E("expand",a)}}:{onClick:h=>v(h,s),routeName:"contact-method",params:k.createParams({contactCategory:n,guideId:X,guideCategory:i,phrase:o,contactMethod:a,uriName:k.formatUrl(d)})};let R;if(l==="phone.text"||l==="ace.phone"||l==="ace.callback"){const h=document.createElement("div");h.innerHTML=g,R=h.innerText}return u.jsxs(te,{title:d,"aria-label":l==="phone.text"||l==="ace.phone"||l==="ace.callback"?`${d} ${R}`:d,className:J,disabled:Q,description:g,"data-client-name":l,...r,...Y,children:[p&&u.jsx(m.SymbolBadge,{symbol:p}),g?u.jsxs("div",{className:"humany-contact-link-rich-content",children:[u.jsx(D,{children:d}),u.jsx(O,{html:g,htmlParseInstruction:T})]}):u.jsx(D,{children:d})]})};return t.expanded?u.jsx(P.Suspense,{fallback:null,children:u.jsx(e,{...t,renderDefault:c})}):c()},W=t=>{var e,n,i,o,c,r,s,a;return w.css`
18
+ display: flex;
19
+ padding: ${(e=t.theme.sizes)==null?void 0:e.large};
20
+ ${t.description?"":"align-items: center;"}
21
+ text-decoration: none;
22
+ span {
23
+ display: inline-block;
24
+ color: ${(n=t.theme.colors)==null?void 0:n.text};
25
+ }
26
+ i {
27
+ font-size: ${(i=t.theme.fonts)==null?void 0:i.large};
28
+ margin: 0 ${(o=t.theme.sizes)==null?void 0:o.large} 0 0;
29
+ min-height: ${(c=t.theme.fonts)==null?void 0:c.large};
30
+ min-width: ${(r=t.theme.fonts)==null?void 0:r.large};
31
+ line-height: ${(s=t.theme.fonts)==null?void 0:s.large};
32
+ display: inline-block;
33
+ vertical-align: bottom;
34
+ color: ${(a=t.theme.colors)==null?void 0:a.text};
35
+ }
36
+ `},D=f(m.StyledText)`
37
+ line-height: ${t=>{var e;return(e=t.theme.fonts)==null?void 0:e.large}};
38
+ `,te=f(m.Link)`
39
+ ${t=>W(t)}
40
+
41
+ &:focus-visible {
42
+ ${m.borderTabStyle};
43
+ }
44
+ `,ne=f.div`
45
+ text-align: center;
46
+ display: block;
47
+ ${t=>{var e,n;return typeof((e=t.theme.colors)==null?void 0:e.warning)<"u"&&`color: ${(n=t.theme.colors)==null?void 0:n.warning};`}}
48
+ `,B=t=>{var e,n,i;return w.css`
49
+ ${m.itemList(t)}
50
+
51
+ > div {
52
+ padding: ${(e=t.theme.sizes)==null?void 0:e.large};
53
+
54
+ ${m.headingElement(t)("h1",w.css`
55
+ margin: 0;
56
+ `)}
57
+ }
58
+
59
+ > ul {
60
+ &:not(:first-child) {
61
+ border-top: ${t.theme.border};
62
+ }
63
+
64
+ > li {
65
+ margin: 0;
66
+ white-space: normal;
67
+
68
+ > a {
69
+ overflow: hidden;
70
+ }
71
+
72
+ &:first-child > a {
73
+ border-radius: ${`${t.theme.borderRadius} ${t.theme.borderRadius} 0 0`};
74
+ }
75
+
76
+ &:last-child:not(:first-child) > a {
77
+ border-radius: ${`0 0 ${t.theme.borderRadius} ${t.theme.borderRadius}`};
78
+ }
79
+
80
+ &:not(:last-child) {
81
+ border-bottom: ${t.theme.border};
82
+ }
83
+
84
+ > div {
85
+ padding: ${(n=t.theme.sizes)==null?void 0:n.large};
86
+ }
87
+ }
88
+ }
89
+
90
+ @media (hover: hover) {
91
+ a:hover {
92
+ background-color: ${(i=t.theme.colors)==null?void 0:i.accent};
93
+ }
94
+ }
95
+ `},oe=f(m.ItemList)`
96
+ ${t=>B(t)}
97
+ `,ie=({contactMethods:t,children:e,guideId:n,dispatch:i,className:o="",itemRenderer:c,action:r=()=>{},header:s=""})=>{const a=m.useContainer(),{events:d}=a.get("$widget");return t.length?u.jsx(oe,{header:s,className:k.appendClassNames(o,"humany-contact-list"),items:t,renderItem:c?l=>u.jsx("li",{role:t.length===1&&t[0].expanded?"none":void 0,"data-contact-method":l.id,children:c(l,{action:r,dispatch:i,guideId:n})},l.id):l=>u.jsx("li",{role:t.length===1&&t[0].expanded?"none":void 0,"data-contact-method":l.id,onClick:()=>{d.dispatch("tracking:contact-list-item-clicked",l)},children:u.jsx(U,{...l,action:r,dispatch:i,guideId:n})},l.id),children:e}):null},K=(t,e)=>{if(t.actionKey===e)return t;if(!t.properties)return null;const n=Object.keys(t.properties);let i;for(let o=0;o<n.length;o++)if(i=K(t.properties[n[o]],e),i)return i;return!1},re=({className:t,body:{form:e},id:n,action:i,dispatch:o,disabled:c,autoFocus:r})=>{if(e&&!c){const{schema:s,layout:a,data:d,meta:l}=e,p=o||i||(()=>{});return u.jsx(C.FormComponent,{className:t,schema:s,layout:a,data:d,autoFocus:r,onChange:($,v)=>{const g={schema:s,layout:a,data:v,meta:l};$.toString()==="submit"?p("submit",{id:n,form:g}):K(s,$).evaluate?p("evaluate",{id:n,form:g}):p("validate",{id:n,form:g})}})}return null},se=t=>{const[e,n]=P.useState(null),i=m.useContainer();return P.useEffect(()=>{let o;return i.getAsync("componentResolver").then(c=>{o=c.registerResolver(t,r=>n(r))}),()=>{o&&o()}},[t]),e};function G(t){t.getAsync("contactMethods").then(e=>{e.create({clientName:"custom.webservice",render:"email.form",onValidate:n=>y(t,n),onComplete:n=>b(t,n),onSubmit:n=>A(t,n,i=>({...i,ConfirmationText:i.ResponseHtml}))})})}const ae=(t,e,n)=>t.getAsync("contactMethods").then(i=>{i.create({clientName:e,render:"email.form",handleClick:()=>(o,c)=>{const{body:{form:r,guideId:s,confirmationFallback:a,...d}}=c;r||(o.preventDefault(),n(d))},onValidate:o=>y(t,o),onComplete:o=>b(t,o),onSubmit:o=>{const{body:{form:c,guideId:r,confirmationFallback:s,...a}}=o,{values:d}=new C.FormReader(c).export();return Promise.resolve(n(a,d)).then(l=>l||s)}})});class ce extends I.Plugin{constructor(e,n){super(e,n),this.widget.implementation.configure(o=>{o.plugin(F).plugin(M).plugin(V).plugin(H).plugin(G).plugin(z)})}}exports.ContactList=ie;exports.ContactMethod=U;exports.ContactMethodPlatform=x;exports.DefaultContactMethodsPlugin=ce;exports.Description=O;exports.Form=re;exports.chatPopupPlugin=M;exports.complete=b;exports.contactItemList=B;exports.contactLink=W;exports.createSubmitAdapter=ae;exports.emailPlugin=F;exports.evaluate=j;exports.freeTextPlugin=V;exports.linkPlugin=z;exports.phonePlugin=H;exports.submit=A;exports.useContactMethod=se;exports.validate=y;exports.webServicePlugin=G;
@@ -0,0 +1,625 @@
1
+ var B = Object.defineProperty;
2
+ var K = (t, e, n) => e in t ? B(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
+ var $ = (t, e, n) => (K(t, typeof e != "symbol" ? e + "" : e, n), n);
4
+ import { FormBuilder as G, FormReader as w, FormComponent as U } from "@telia-ace/widget-forms";
5
+ import { ComponentPlatform as S, Plugin as W } from "@telia-ace/knowledge-widget-core";
6
+ import { lock as J, createParams as Q, formatUrl as X, appendClassNames as Y } from "@telia-ace/widget-utilities";
7
+ import { lazy as Z, Suspense as _, useState as ee, useEffect as te } from "react";
8
+ import { jsx as m, jsxs as E } from "react/jsx-runtime";
9
+ import { css as C } from "@emotion/react";
10
+ import f from "@emotion/styled";
11
+ import { Paragraph as ne, headingElement as D, Html as oe, genericHtml as ie, borderTabStyle as L, linkTabStyle as re, StyledText as ae, Link as se, useComponent as ce, useRouteData as le, Typography as de, SymbolBadge as me, ItemList as he, itemList as ue, useContainer as R } from "@telia-ace/knowledge-widget-ui";
12
+ const P = (t, e, n = !1) => t.getManyAsync("matchingClient", "router").then((i) => {
13
+ const { formData: o } = new w(e.body.form).export(
14
+ n
15
+ ), { router: c, matchingClient: r } = i, { params: a } = c.getRouteData();
16
+ return e.guideId = e.body.guideId || a.guideId, r.customRequest(
17
+ `contactmethods/${e.id}${n ? "/validatedwithpayload" : ""}`,
18
+ "POST",
19
+ {
20
+ body: o,
21
+ configuration: {
22
+ guideId: e.body.guideId || a.guideId
23
+ }
24
+ }
25
+ );
26
+ }), F = (t, e, n) => P(t, e).then((i) => n ? n(i) : i).then(({ ConfirmationText: i }) => i), y = (t, e) => P(t, e, !0).then(
27
+ (n) => ({
28
+ valid: n.Validation.IsValid,
29
+ errors: n.Validation.Errors,
30
+ errorTypes: n.Validation.ErrorTypes
31
+ })
32
+ ), M = (t, e) => P(t, e, !0).then(
33
+ (n) => G.fromLegacyForm(
34
+ e.id,
35
+ n.ContactMethod.Form
36
+ ).get()
37
+ ), b = (t, e) => t.getAsync("matchingClient").then((n) => {
38
+ n.completeContactMethod(e.id, {
39
+ guideId: e.guideId
40
+ });
41
+ });
42
+ function pe(t) {
43
+ t.getAsync("contactMethods").then((e) => {
44
+ e.create({
45
+ clientName: "email.form",
46
+ render: import("./email-form-component-b618db4a.mjs"),
47
+ onEvaluate: (n) => M(t, n),
48
+ onValidate: (n) => y(t, n),
49
+ onSubmit: (n) => F(t, n),
50
+ onComplete: (n) => b(t, n)
51
+ });
52
+ });
53
+ }
54
+ const T = (t, e, n) => {
55
+ const { url: i, width: o, height: c } = e, r = n || {}, a = document.createElement("a");
56
+ return a.href = i, a.search.replace("?", "").split("&").forEach((s) => {
57
+ const [d, l] = s.split("=");
58
+ typeof l < "u" && (r[d] = l);
59
+ }), a.search = Object.keys(r).map((s) => `${s}=${r[s]}`).join("&"), window.open(a.href, t, `width=${o},height=${c}`), "";
60
+ };
61
+ function fe(t) {
62
+ t.getAsync("contactMethods").then((e) => {
63
+ e.create({
64
+ clientName: "chat.popup",
65
+ render: "email.form",
66
+ handleClick: (n) => {
67
+ const { title: i, body: o } = n, { form: c, guideId: r, confirmationFallback: a, ...s } = o;
68
+ return c ? () => {
69
+ } : (d) => {
70
+ d.preventDefault(), T(i, s);
71
+ };
72
+ },
73
+ onValidate: (n) => y(t, n),
74
+ onComplete: (n) => b(t, n),
75
+ onSubmit: (n) => {
76
+ const { title: i, body: o } = n, { form: c, guideId: r, confirmationFallback: a, ...s } = o, d = new w(c).export().values;
77
+ return T(i, s, d), a;
78
+ }
79
+ });
80
+ });
81
+ }
82
+ function ge(t) {
83
+ t.getAsync("contactMethods").then((e) => {
84
+ e.create({
85
+ clientName: "custom.freetext",
86
+ render: import("./free-text-component-a4724ece.mjs")
87
+ });
88
+ });
89
+ }
90
+ function ye(t) {
91
+ t.getAsync("contactMethods").then((e) => {
92
+ e.create({
93
+ clientName: "custom.link",
94
+ render: import("./link-component-1c24e6af.mjs")
95
+ });
96
+ });
97
+ }
98
+ function be(t) {
99
+ t.getAsync("contactMethods").then((e) => {
100
+ e.create({
101
+ clientName: "phone.text",
102
+ render: import("./phone-component-25f3e937.mjs")
103
+ });
104
+ });
105
+ }
106
+ const ve = async (t, e) => {
107
+ const n = t.get(e.clientName);
108
+ let { description: i, disabled: o, onClick: c } = e;
109
+ if (n) {
110
+ const { handleClick: r, handleDescription: a, handleDisabled: s } = n;
111
+ typeof r == "function" && (c = await Promise.resolve(r(e))), typeof a == "function" && (i = await Promise.resolve(a(e))), typeof s == "function" && (o = await Promise.resolve(s(e)));
112
+ }
113
+ return Promise.resolve({
114
+ ...e,
115
+ description: i,
116
+ disabled: o,
117
+ onClick: c
118
+ });
119
+ };
120
+ class k {
121
+ constructor(e, n) {
122
+ $(this, "adapters", /* @__PURE__ */ new Map());
123
+ $(this, "subs", []);
124
+ if (this.container = e, this.componentPlatform = n, n) {
125
+ n.components().ofType("contact-list").select().actions.watch(
126
+ "contact-list.fetched",
127
+ async (r, a) => {
128
+ const { contactMethods: s } = r;
129
+ if (s) {
130
+ const d = Promise.all(
131
+ s.map(
132
+ (l) => this.handleAdapters(l)
133
+ )
134
+ );
135
+ await Promise.resolve(d).then((l) => {
136
+ r.contactMethods = l;
137
+ });
138
+ }
139
+ return a(r);
140
+ }
141
+ );
142
+ const o = n.components().ofType("guide").select();
143
+ o.actions.watch("guide.fetched", async (r, a) => {
144
+ const { contactMethods: s } = r;
145
+ if (s) {
146
+ const d = Promise.all(
147
+ s.map(
148
+ (l) => this.handleAdapters(l)
149
+ )
150
+ );
151
+ await Promise.resolve(d).then((l) => {
152
+ r.contactMethods = l;
153
+ });
154
+ }
155
+ return a(r);
156
+ }), o.actions.watch("guide.handover", async (r, a) => {
157
+ const { handoverContactMethods: s } = r;
158
+ if (s) {
159
+ const d = Promise.all(
160
+ s.map(
161
+ (l) => this.handleAdapters(l)
162
+ )
163
+ );
164
+ await Promise.resolve(d).then((l) => {
165
+ r.handoverContactMethods = l;
166
+ });
167
+ }
168
+ return a(r);
169
+ }), n.components().ofType("contact-method").select().actions.watch(
170
+ "contact-method.fetched",
171
+ async (r, a) => {
172
+ const { contactMethod: s } = r;
173
+ return s ? this.handleAdapters(s).then((d) => a({ ...r, contactMethod: d })) : a(r);
174
+ }
175
+ );
176
+ }
177
+ }
178
+ static create(e) {
179
+ return S.getInstance(e).then((n) => new k(e, n));
180
+ }
181
+ handleAdapters(e) {
182
+ return ve(this.adapters, e);
183
+ }
184
+ static getInstance(e, n = "contactMethods") {
185
+ return J(e)(() => e.getAsync(n).then((i) => {
186
+ let o = i;
187
+ return o || S.getInstance(e).then((c) => (o = new k(
188
+ e,
189
+ c
190
+ ), e.registerAsync(n, () => o), o));
191
+ }));
192
+ }
193
+ track(e = {}, n) {
194
+ const { events: i } = this.container.get("$widget");
195
+ i.dispatch("tracking:service-client-response", {
196
+ type: n,
197
+ data: e
198
+ });
199
+ }
200
+ complete(e) {
201
+ const { id: n, title: i, clientName: o, expanded: c, body: r } = e;
202
+ this.track(
203
+ {
204
+ contactMethod: { id: n, title: i, expanded: c, type: o },
205
+ hasGuide: !!r.guideId
206
+ },
207
+ "contact-method-complete"
208
+ /* ContactMethodComplete */
209
+ );
210
+ const a = this.adapters.get(o);
211
+ if (a && a.onComplete)
212
+ return a.onComplete(e);
213
+ }
214
+ evaluate(e) {
215
+ const { clientName: n } = e, i = this.adapters.get(n);
216
+ return i && i.onEvaluate ? Promise.resolve(i.onEvaluate(e)) : Promise.resolve(e.body.form);
217
+ }
218
+ validate(e) {
219
+ const { id: n, title: i, clientName: o } = e, c = this.adapters.get(o);
220
+ return c && c.onValidate ? Promise.resolve(c.onValidate(e)).then(
221
+ (r) => {
222
+ this.track(
223
+ {
224
+ contactMethod: { id: n, title: i, type: o },
225
+ isValid: r.valid
226
+ },
227
+ "contact-method-validate"
228
+ /* ContactMethodValidate */
229
+ );
230
+ const { events: a } = this.container.get("$widget");
231
+ return a.dispatch("form:validated", { isValid: r.valid }), r;
232
+ }
233
+ ) : Promise.resolve({ valid: !0 });
234
+ }
235
+ submit(e) {
236
+ const { clientName: n } = e, i = this.adapters.get(n);
237
+ return i && i.onSubmit ? Promise.resolve(i.onSubmit(e)).then((o) => (this.complete(e), o)) : Promise.resolve("");
238
+ }
239
+ create(e) {
240
+ const { clientName: n, render: i } = e;
241
+ return this.adapters.set(n, {
242
+ onValidate: (o) => y(this.container, o),
243
+ onEvaluate: (o) => M(this.container, o),
244
+ onComplete: (o) => b(this.container, o),
245
+ ...e
246
+ }), this.container.getAsync("componentResolver").then((o) => {
247
+ typeof i == "string" ? this.subs.push(o.registerAlias(n, i)) : this.subs.push(
248
+ o.registerComponent(
249
+ n,
250
+ Z(() => i)
251
+ )
252
+ );
253
+ });
254
+ }
255
+ dispose() {
256
+ this.subs.forEach((e) => e());
257
+ }
258
+ }
259
+ f(ne)`
260
+ ${(t) => {
261
+ var e;
262
+ return D(t)(
263
+ "h1",
264
+ C`
265
+ font-weight: normal;
266
+ font-size: ${(e = t.theme.fonts) == null ? void 0 : e.medium};
267
+ `
268
+ );
269
+ }}
270
+ `;
271
+ const Ce = f(oe)`
272
+ ${ie}
273
+ font-weight: 300;
274
+ line-height: 1.5em;
275
+ button:focus-visible {
276
+ ${L};
277
+ }
278
+
279
+ a:focus-visible {
280
+ ${re};
281
+ }
282
+ `, $e = (t) => {
283
+ const e = ce(t.clientName), {
284
+ params: { contactCategory: n, guideCategory: i, phrase: o }
285
+ } = le();
286
+ if (typeof e > "u")
287
+ return null;
288
+ if (e === null)
289
+ return process.env.NODE_ENV !== "production" ? /* @__PURE__ */ m(
290
+ Pe,
291
+ {
292
+ title: `client-name: ${t.clientName}, id: ${t.id}`,
293
+ className: "humany-non-resolved-contact-method",
294
+ children: /* @__PURE__ */ m(de, { variant: "h5", children: "Non resolved Contact Method type" })
295
+ }
296
+ ) : null;
297
+ const c = (r = {}) => {
298
+ const a = { ...t, ...r }, {
299
+ id: s,
300
+ title: d,
301
+ clientName: l,
302
+ symbol: p,
303
+ inline: v,
304
+ onClick: g = () => {
305
+ },
306
+ description: u,
307
+ htmlParseInstruction: x,
308
+ className: j,
309
+ disabled: H,
310
+ guideId: O,
311
+ dispatch: N = () => {
312
+ },
313
+ expanded: I
314
+ } = a, q = v ? {
315
+ onKeyDown: (h) => {
316
+ h.key && h.key === "Enter" && (g(h, a), h.defaultPrevented || !I && N("expand", s));
317
+ },
318
+ onClick: (h) => {
319
+ g(h, a), h.defaultPrevented || !I && N("expand", s);
320
+ }
321
+ } : {
322
+ onClick: (h) => g(h, a),
323
+ routeName: "contact-method",
324
+ params: Q({
325
+ contactCategory: n,
326
+ guideId: O,
327
+ guideCategory: i,
328
+ phrase: o,
329
+ contactMethod: s,
330
+ uriName: X(d)
331
+ })
332
+ };
333
+ let A;
334
+ if (l === "phone.text" || l === "ace.phone" || l === "ace.callback") {
335
+ const h = document.createElement("div");
336
+ h.innerHTML = u, A = h.innerText;
337
+ }
338
+ return /* @__PURE__ */ E(
339
+ we,
340
+ {
341
+ title: d,
342
+ "aria-label": l === "phone.text" || l === "ace.phone" || l === "ace.callback" ? `${d} ${A}` : d,
343
+ className: j,
344
+ disabled: H,
345
+ description: u,
346
+ "data-client-name": l,
347
+ ...r,
348
+ ...q,
349
+ children: [
350
+ p && /* @__PURE__ */ m(me, { symbol: p }),
351
+ u ? /* @__PURE__ */ E("div", { className: "humany-contact-link-rich-content", children: [
352
+ /* @__PURE__ */ m(V, { children: d }),
353
+ /* @__PURE__ */ m(
354
+ Ce,
355
+ {
356
+ html: u,
357
+ htmlParseInstruction: x
358
+ }
359
+ )
360
+ ] }) : /* @__PURE__ */ m(V, { children: d })
361
+ ]
362
+ }
363
+ );
364
+ };
365
+ return t.expanded ? /* @__PURE__ */ m(_, { fallback: null, children: /* @__PURE__ */ m(e, { ...t, renderDefault: c }) }) : c();
366
+ }, ke = (t) => {
367
+ var e, n, i, o, c, r, a, s;
368
+ return C`
369
+ display: flex;
370
+ padding: ${(e = t.theme.sizes) == null ? void 0 : e.large};
371
+ ${t.description ? "" : "align-items: center;"}
372
+ text-decoration: none;
373
+ span {
374
+ display: inline-block;
375
+ color: ${(n = t.theme.colors) == null ? void 0 : n.text};
376
+ }
377
+ i {
378
+ font-size: ${(i = t.theme.fonts) == null ? void 0 : i.large};
379
+ margin: 0 ${(o = t.theme.sizes) == null ? void 0 : o.large} 0 0;
380
+ min-height: ${(c = t.theme.fonts) == null ? void 0 : c.large};
381
+ min-width: ${(r = t.theme.fonts) == null ? void 0 : r.large};
382
+ line-height: ${(a = t.theme.fonts) == null ? void 0 : a.large};
383
+ display: inline-block;
384
+ vertical-align: bottom;
385
+ color: ${(s = t.theme.colors) == null ? void 0 : s.text};
386
+ }
387
+ `;
388
+ }, V = f(ae)`
389
+ line-height: ${(t) => {
390
+ var e;
391
+ return (e = t.theme.fonts) == null ? void 0 : e.large;
392
+ }};
393
+ `, we = f(se)`
394
+ ${(t) => ke(t)}
395
+
396
+ &:focus-visible {
397
+ ${L};
398
+ }
399
+ `, Pe = f.div`
400
+ text-align: center;
401
+ display: block;
402
+ ${(t) => {
403
+ var e, n;
404
+ return typeof ((e = t.theme.colors) == null ? void 0 : e.warning) < "u" && `color: ${(n = t.theme.colors) == null ? void 0 : n.warning};`;
405
+ }}
406
+ `, xe = (t) => {
407
+ var e, n, i;
408
+ return C`
409
+ ${ue(t)}
410
+
411
+ > div {
412
+ padding: ${(e = t.theme.sizes) == null ? void 0 : e.large};
413
+
414
+ ${D(t)(
415
+ "h1",
416
+ C`
417
+ margin: 0;
418
+ `
419
+ )}
420
+ }
421
+
422
+ > ul {
423
+ &:not(:first-child) {
424
+ border-top: ${t.theme.border};
425
+ }
426
+
427
+ > li {
428
+ margin: 0;
429
+ white-space: normal;
430
+
431
+ > a {
432
+ overflow: hidden;
433
+ }
434
+
435
+ &:first-child > a {
436
+ border-radius: ${`${t.theme.borderRadius} ${t.theme.borderRadius} 0 0`};
437
+ }
438
+
439
+ &:last-child:not(:first-child) > a {
440
+ border-radius: ${`0 0 ${t.theme.borderRadius} ${t.theme.borderRadius}`};
441
+ }
442
+
443
+ &:not(:last-child) {
444
+ border-bottom: ${t.theme.border};
445
+ }
446
+
447
+ > div {
448
+ padding: ${(n = t.theme.sizes) == null ? void 0 : n.large};
449
+ }
450
+ }
451
+ }
452
+
453
+ @media (hover: hover) {
454
+ a:hover {
455
+ background-color: ${(i = t.theme.colors) == null ? void 0 : i.accent};
456
+ }
457
+ }
458
+ `;
459
+ }, Ne = f(he)`
460
+ ${(t) => xe(t)}
461
+ `, Me = ({
462
+ contactMethods: t,
463
+ children: e,
464
+ guideId: n,
465
+ dispatch: i,
466
+ className: o = "",
467
+ itemRenderer: c,
468
+ action: r = () => {
469
+ },
470
+ header: a = ""
471
+ }) => {
472
+ const s = R(), { events: d } = s.get("$widget");
473
+ return t.length ? /* @__PURE__ */ m(
474
+ Ne,
475
+ {
476
+ header: a,
477
+ className: Y(o, "humany-contact-list"),
478
+ items: t,
479
+ renderItem: c ? (l) => /* @__PURE__ */ m(
480
+ "li",
481
+ {
482
+ role: t.length === 1 && t[0].expanded ? "none" : void 0,
483
+ "data-contact-method": l.id,
484
+ children: c(l, { action: r, dispatch: i, guideId: n })
485
+ },
486
+ l.id
487
+ ) : (l) => /* @__PURE__ */ m(
488
+ "li",
489
+ {
490
+ role: t.length === 1 && t[0].expanded ? "none" : void 0,
491
+ "data-contact-method": l.id,
492
+ onClick: () => {
493
+ d.dispatch("tracking:contact-list-item-clicked", l);
494
+ },
495
+ children: /* @__PURE__ */ m(
496
+ $e,
497
+ {
498
+ ...l,
499
+ action: r,
500
+ dispatch: i,
501
+ guideId: n
502
+ }
503
+ )
504
+ },
505
+ l.id
506
+ ),
507
+ children: e
508
+ }
509
+ ) : null;
510
+ }, z = (t, e) => {
511
+ if (t.actionKey === e)
512
+ return t;
513
+ if (!t.properties)
514
+ return null;
515
+ const n = Object.keys(t.properties);
516
+ let i;
517
+ for (let o = 0; o < n.length; o++)
518
+ if (i = z(t.properties[n[o]], e), i)
519
+ return i;
520
+ return !1;
521
+ }, ze = ({
522
+ className: t,
523
+ body: { form: e },
524
+ id: n,
525
+ action: i,
526
+ dispatch: o,
527
+ disabled: c,
528
+ autoFocus: r
529
+ }) => {
530
+ if (e && !c) {
531
+ const { schema: a, layout: s, data: d, meta: l } = e, p = o || i || (() => {
532
+ });
533
+ return /* @__PURE__ */ m(
534
+ U,
535
+ {
536
+ className: t,
537
+ schema: a,
538
+ layout: s,
539
+ data: d,
540
+ autoFocus: r,
541
+ onChange: (v, g) => {
542
+ const u = { schema: a, layout: s, data: g, meta: l };
543
+ v.toString() === "submit" ? p("submit", { id: n, form: u }) : z(a, v).evaluate ? p("evaluate", { id: n, form: u }) : p("validate", { id: n, form: u });
544
+ }
545
+ }
546
+ );
547
+ }
548
+ return null;
549
+ }, je = (t) => {
550
+ const [e, n] = ee(null), i = R();
551
+ return te(() => {
552
+ let o;
553
+ return i.getAsync("componentResolver").then((c) => {
554
+ o = c.registerResolver(
555
+ t,
556
+ (r) => n(r)
557
+ );
558
+ }), () => {
559
+ o && o();
560
+ };
561
+ }, [t]), e;
562
+ };
563
+ function Ie(t) {
564
+ t.getAsync("contactMethods").then((e) => {
565
+ e.create({
566
+ clientName: "custom.webservice",
567
+ render: "email.form",
568
+ onValidate: (n) => y(t, n),
569
+ onComplete: (n) => b(t, n),
570
+ onSubmit: (n) => F(t, n, (i) => ({
571
+ ...i,
572
+ ConfirmationText: i.ResponseHtml
573
+ }))
574
+ });
575
+ });
576
+ }
577
+ const He = (t, e, n) => t.getAsync("contactMethods").then((i) => {
578
+ i.create({
579
+ clientName: e,
580
+ render: "email.form",
581
+ handleClick: () => (o, c) => {
582
+ const {
583
+ body: { form: r, guideId: a, confirmationFallback: s, ...d }
584
+ } = c;
585
+ r || (o.preventDefault(), n(d));
586
+ },
587
+ onValidate: (o) => y(t, o),
588
+ onComplete: (o) => b(t, o),
589
+ onSubmit: (o) => {
590
+ const {
591
+ body: { form: c, guideId: r, confirmationFallback: a, ...s }
592
+ } = o, { values: d } = new w(c).export();
593
+ return Promise.resolve(n(s, d)).then((l) => l || a);
594
+ }
595
+ });
596
+ });
597
+ class Oe extends W {
598
+ constructor(e, n) {
599
+ super(e, n), this.widget.implementation.configure((o) => {
600
+ o.plugin(pe).plugin(fe).plugin(ge).plugin(be).plugin(Ie).plugin(ye);
601
+ });
602
+ }
603
+ }
604
+ export {
605
+ Me as C,
606
+ Ce as D,
607
+ ze as F,
608
+ xe as a,
609
+ ke as b,
610
+ fe as c,
611
+ $e as d,
612
+ k as e,
613
+ b as f,
614
+ M as g,
615
+ pe as h,
616
+ ge as i,
617
+ He as j,
618
+ Oe as k,
619
+ ye as l,
620
+ be as p,
621
+ F as s,
622
+ je as u,
623
+ y as v,
624
+ Ie as w
625
+ };
package/index.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ export { ChatPopupPlugin, contactItemList, contactLink, ContactList, ContactMethod, ContactMethodPlatform, defaultComplete, defaultEvaluate, DefaultForm, defaultSubmit, defaultValidate, EmailPlugin as EmailFormPlugin, FreeTextPlugin, LinkPlugin, PhonePlugin, useContactMethod, WebServicePlugin, } from './contact-methods';
2
+ export type { ContactMethodClick, ContactMethodType, ReactComponentImport, } from './contact-methods';
3
+ export { createSubmitAdapter } from './create-adapter';
4
+ export type { Callback } from './create-adapter';
5
+ export { DefaultContactMethodsPlugin } from './default-contact-methods-plugin';
package/index.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index-3c56a15f.js");require("@telia-ace/widget-forms");require("@telia-ace/knowledge-widget-core");require("@telia-ace/widget-utilities");require("react");require("react/jsx-runtime");require("@emotion/react");require("@emotion/styled");require("@telia-ace/knowledge-widget-ui");exports.ChatPopupPlugin=t.chatPopupPlugin;exports.ContactList=t.ContactList;exports.ContactMethod=t.ContactMethod;exports.ContactMethodPlatform=t.ContactMethodPlatform;exports.DefaultContactMethodsPlugin=t.DefaultContactMethodsPlugin;exports.DefaultForm=t.Form;exports.EmailFormPlugin=t.emailPlugin;exports.FreeTextPlugin=t.freeTextPlugin;exports.LinkPlugin=t.linkPlugin;exports.PhonePlugin=t.phonePlugin;exports.WebServicePlugin=t.webServicePlugin;exports.contactItemList=t.contactItemList;exports.contactLink=t.contactLink;exports.createSubmitAdapter=t.createSubmitAdapter;exports.defaultComplete=t.complete;exports.defaultEvaluate=t.evaluate;exports.defaultSubmit=t.submit;exports.defaultValidate=t.validate;exports.useContactMethod=t.useContactMethod;
package/index.mjs ADDED
@@ -0,0 +1,30 @@
1
+ import { c as r, C as p, d as c, e as d, k as P, F as f, h as g, i as C, l as h, p as b, w as F, a as L, b as M, j as k, f as v, g as S, s as x, v as D, u as E } from "./index-4b2ec2f4.mjs";
2
+ import "@telia-ace/widget-forms";
3
+ import "@telia-ace/knowledge-widget-core";
4
+ import "@telia-ace/widget-utilities";
5
+ import "react";
6
+ import "react/jsx-runtime";
7
+ import "@emotion/react";
8
+ import "@emotion/styled";
9
+ import "@telia-ace/knowledge-widget-ui";
10
+ export {
11
+ r as ChatPopupPlugin,
12
+ p as ContactList,
13
+ c as ContactMethod,
14
+ d as ContactMethodPlatform,
15
+ P as DefaultContactMethodsPlugin,
16
+ f as DefaultForm,
17
+ g as EmailFormPlugin,
18
+ C as FreeTextPlugin,
19
+ h as LinkPlugin,
20
+ b as PhonePlugin,
21
+ F as WebServicePlugin,
22
+ L as contactItemList,
23
+ M as contactLink,
24
+ k as createSubmitAdapter,
25
+ v as defaultComplete,
26
+ S as defaultEvaluate,
27
+ x as defaultSubmit,
28
+ D as defaultValidate,
29
+ E as useContactMethod
30
+ };
@@ -0,0 +1,17 @@
1
+ import { appendClassNames as s } from "@telia-ace/widget-utilities";
2
+ const c = ({
3
+ className: t,
4
+ body: o,
5
+ renderDefault: a = () => {
6
+ }
7
+ }) => {
8
+ const { uri: e, target: n, protocol: r } = o;
9
+ return a({
10
+ target: n,
11
+ className: s(t, "humany-contact-method-link"),
12
+ href: `${r}${e}`
13
+ });
14
+ };
15
+ export {
16
+ c as default
17
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("@telia-ace/widget-utilities"),s=({className:t,body:e,renderDefault:o=()=>{}})=>{const{uri:n,target:r,protocol:a}=e;return o({target:r,className:i.appendClassNames(t,"humany-contact-method-link"),href:`${a}${n}`})};exports.default=s;
package/package.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "@telia-ace/knowledge-widget-adapters",
3
+ "version": "0.0.1",
4
+ "main": "./index.js",
5
+ "types": "./index.d.ts",
6
+ "exports": {
7
+ ".": {
8
+ "import": "./index.mjs",
9
+ "require": "./index.js"
10
+ }
11
+ },
12
+ "dependencies": {
13
+ "@telia-ace/knowledge-serviceclient": "^1.0.31",
14
+ "@telia-ace/knowledge-widget-core": "*",
15
+ "@telia-ace/knowledge-widget-ui": "*",
16
+ "@telia-ace/widget-forms": "*",
17
+ "@telia-ace/widget-routing": "*",
18
+ "@telia-ace/widget-utilities": "*",
19
+ "@webprovisions/platform": "^1.1.4"
20
+ },
21
+ "peerDependencies": {
22
+ "@emotion/react": "11.11.1",
23
+ "@emotion/styled": "11.11.0",
24
+ "react": "18.2.0"
25
+ }
26
+ }
@@ -0,0 +1,14 @@
1
+ import { appendClassNames as a } from "@telia-ace/widget-utilities";
2
+ const s = ({
3
+ className: e,
4
+ body: { phoneNumber: t },
5
+ renderDefault: o = () => {
6
+ }
7
+ }) => o({
8
+ title: t,
9
+ className: a(e, "humany-contact-method-phone"),
10
+ href: `tel: ${t}`
11
+ });
12
+ export {
13
+ s as default
14
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("@telia-ace/widget-utilities"),a=({className:t,body:{phoneNumber:e},renderDefault:o=()=>{}})=>o({title:e,className:n.appendClassNames(t,"humany-contact-method-phone"),href:`tel: ${e}`});exports.default=a;