@meetelise/chat 1.20.81 → 1.20.83
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/public/dist/index.js +67 -67
- package/src/MEChat.ts +19 -7
- package/src/WebComponent/me-chat.ts +17 -4
- package/src/fetchWebchatPreferences.ts +10 -1
package/src/MEChat.ts
CHANGED
|
@@ -249,17 +249,27 @@ const overrideContactUsForm = async (
|
|
|
249
249
|
return false;
|
|
250
250
|
};
|
|
251
251
|
|
|
252
|
+
const validateFormElements = () => {
|
|
253
|
+
Object.values(getFormElements()).forEach((el) => {
|
|
254
|
+
if (el?.getAttribute("aria-required") === "true" && !el.value) {
|
|
255
|
+
el.className = "form-control required is-invalid";
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
};
|
|
259
|
+
|
|
252
260
|
const isValid = () => {
|
|
253
261
|
return Object.values(getFormElements()).every((el) => {
|
|
254
262
|
if (el === null) return false;
|
|
255
|
-
if (el.getAttribute("aria-
|
|
256
|
-
|
|
257
|
-
buildingSlug,
|
|
258
|
-
orgSlug,
|
|
259
|
-
"Missing aria-invalid attribute on " + el.id
|
|
260
|
-
);
|
|
263
|
+
if (el.getAttribute("aria-required") === "true" && !el.value) {
|
|
264
|
+
return false;
|
|
261
265
|
}
|
|
262
|
-
|
|
266
|
+
if (
|
|
267
|
+
(el.id === "email" || el.id === "phonenumber") &&
|
|
268
|
+
el.getAttribute("aria-invalid") === "true"
|
|
269
|
+
) {
|
|
270
|
+
return false;
|
|
271
|
+
}
|
|
272
|
+
return true;
|
|
263
273
|
});
|
|
264
274
|
};
|
|
265
275
|
|
|
@@ -280,6 +290,8 @@ const overrideContactUsForm = async (
|
|
|
280
290
|
btn.parentNode?.replaceChild(clonedButton, btn);
|
|
281
291
|
|
|
282
292
|
clonedButton.onclick = async function (event) {
|
|
293
|
+
validateFormElements();
|
|
294
|
+
|
|
283
295
|
if (!isValid()) return;
|
|
284
296
|
event.preventDefault();
|
|
285
297
|
|
|
@@ -14,8 +14,12 @@ import {
|
|
|
14
14
|
fetchFeatureFlagShowMarketingSourceDropdown,
|
|
15
15
|
fetchFeatureFlagUsePhoneNumberBySource,
|
|
16
16
|
} from "../fetchFeatureFlag";
|
|
17
|
-
import fetchWebchatPreferences
|
|
18
|
-
|
|
17
|
+
import fetchWebchatPreferences, {
|
|
18
|
+
DesignConcepts,
|
|
19
|
+
} from "../fetchWebchatPreferences";
|
|
20
|
+
import fetchBuildingABTestType, {
|
|
21
|
+
abTestTypes,
|
|
22
|
+
} from "../fetchBuildingABTestType";
|
|
19
23
|
import fetchCurrentParsedLeadSource from "../fetchCurrentParsedLeadSource";
|
|
20
24
|
import fetchPhoneNumberFromSource, {
|
|
21
25
|
NumberForSelectedSource,
|
|
@@ -202,8 +206,17 @@ export class MEChat extends LitElement {
|
|
|
202
206
|
if (this.brandColor === null) {
|
|
203
207
|
this.brandColor = webchatPreferences.primaryColor ?? null;
|
|
204
208
|
}
|
|
205
|
-
|
|
206
|
-
|
|
209
|
+
this.isMinimized = !!webchatPreferences.autoMinimize;
|
|
210
|
+
if (webchatPreferences.designConcept) {
|
|
211
|
+
if (webchatPreferences.designConcept === DesignConcepts.MINIMIZED) {
|
|
212
|
+
this.isMobile = true;
|
|
213
|
+
}
|
|
214
|
+
if (webchatPreferences.designConcept === DesignConcepts.PILLS) {
|
|
215
|
+
this.buildingABTestType = null; // default design concept is PILLS
|
|
216
|
+
}
|
|
217
|
+
if (webchatPreferences.designConcept === DesignConcepts.EMOJI) {
|
|
218
|
+
this.buildingABTestType = abTestTypes.ConceptEmoji;
|
|
219
|
+
}
|
|
207
220
|
}
|
|
208
221
|
}
|
|
209
222
|
|
|
@@ -2,8 +2,15 @@ import axios from "axios";
|
|
|
2
2
|
|
|
3
3
|
export interface WebchatPreferences {
|
|
4
4
|
primaryColor: string;
|
|
5
|
-
designConcept:
|
|
5
|
+
designConcept: DesignConcepts;
|
|
6
6
|
delayOpen: number;
|
|
7
|
+
autoMinimize: boolean;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export enum DesignConcepts {
|
|
11
|
+
EMOJI = "emoji",
|
|
12
|
+
PILLS = "pills",
|
|
13
|
+
MINIMIZED = "minimized", // this is also mobile
|
|
7
14
|
}
|
|
8
15
|
|
|
9
16
|
export default async function fetchWebchatPreferences(
|
|
@@ -19,6 +26,8 @@ export default async function fetchWebchatPreferences(
|
|
|
19
26
|
primaryColor: webchatPreferencesResponse.data["primaryColor"],
|
|
20
27
|
designConcept: webchatPreferencesResponse.data["designConcept"],
|
|
21
28
|
delayOpen: +webchatPreferencesResponse.data["delayOpen"],
|
|
29
|
+
autoMinimize:
|
|
30
|
+
webchatPreferencesResponse.data["autoMinimize"] === "true",
|
|
22
31
|
};
|
|
23
32
|
}
|
|
24
33
|
return null;
|