@telia-ace/knowledge-widget-adapters 1.1.5 → 1.1.6

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