@inploi/plugin-chatbot 3.28.2 → 3.28.4
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/cdn/index.js +7 -7
- package/dist/{chatbot-body-bed76074.cjs → chatbot-body-30a036fc.cjs} +49 -28
- package/dist/{chatbot-body-1f775f40.js → chatbot-body-51e9bd34.js} +49 -28
- package/dist/chatbot.api.d.ts +220 -22
- package/dist/chatbot.utils.d.ts +20 -2
- package/dist/components/chat-bubble.d.ts +10 -0
- package/dist/components/chat-error.d.ts +3 -0
- package/dist/components/chat-input/chat-input.address.d.ts +16 -0
- package/dist/components/chat-input/chat-input.boolean.d.ts +21 -0
- package/dist/components/chat-input/chat-input.constants.d.ts +249 -0
- package/dist/components/chat-input/chat-input.d.ts +18 -0
- package/dist/components/chat-input/chat-input.file.d.ts +18 -0
- package/dist/components/chat-input/chat-input.multiple-choice.d.ts +16 -0
- package/dist/components/chat-input/chat-input.number.d.ts +16 -0
- package/dist/components/chat-input/chat-input.phone-number.d.ts +15 -0
- package/dist/components/chat-input/chat-input.phone-number.utils.d.ts +4 -0
- package/dist/components/chat-input/chat-input.submit.d.ts +10 -0
- package/dist/components/chat-input/chat-input.text.d.ts +17 -0
- package/dist/components/chat-loading.d.ts +1 -0
- package/dist/components/chatbot-body.d.ts +8 -0
- package/dist/components/chatbot.d.ts +8 -0
- package/dist/components/conversation.d.ts +4 -0
- package/dist/components/input-error.d.ts +5 -0
- package/dist/components/loading-indicator.d.ts +2 -0
- package/dist/components/message.link.d.ts +4 -0
- package/dist/components/palette-debugger.d.ts +1 -0
- package/dist/components/send-button.d.ts +2 -0
- package/dist/components/skip-button.d.ts +2 -0
- package/dist/components/status-bar.d.ts +4 -0
- package/dist/components/transition.d.ts +1 -0
- package/dist/components/typing-indicator.d.ts +2 -0
- package/dist/components/useChatService.d.ts +14 -0
- package/dist/components/useFocus.d.ts +1 -0
- package/dist/{index-8f799f13.cjs → index-251fe248.cjs} +1 -1
- package/dist/{index-5230f617.js → index-5e2a3998.js} +1 -1
- package/dist/mocks/browser.d.ts +1 -0
- package/dist/mocks/flows.mocks.d.ts +71 -0
- package/dist/mocks/handlers.d.ts +14 -0
- package/dist/mocks/mocks.utils.d.ts +2 -0
- package/dist/plugin-chatbot.cjs +1 -1
- package/dist/plugin-chatbot.js +1 -1
- package/dist/style/theme.d.ts +2 -0
- package/dist/style/theme.utils.d.ts +5 -0
- package/dist/style/tokens.d.ts +88 -0
- package/package.json +2 -2
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const index = require("./index-
|
|
3
|
+
const index = require("./index-251fe248.cjs");
|
|
4
4
|
require("@inploi/sdk");
|
|
5
|
-
const
|
|
5
|
+
const isConditionMet = ({
|
|
6
|
+
condition,
|
|
6
7
|
context,
|
|
7
|
-
submissions
|
|
8
|
+
submissions,
|
|
9
|
+
ifBlock
|
|
8
10
|
}) => {
|
|
9
|
-
const [firstSegment, ...path] =
|
|
11
|
+
const [firstSegment, ...path] = condition.compareKey.split(".");
|
|
10
12
|
if (!firstSegment)
|
|
11
13
|
return false;
|
|
12
14
|
const answer = getSubmissionValueToCheck({
|
|
@@ -20,19 +22,19 @@ const isIfBlockConditionMet = (ifBlock, {
|
|
|
20
22
|
switch (answer.type) {
|
|
21
23
|
case "address": {
|
|
22
24
|
const value = index.get(answer.value, path.join("."));
|
|
23
|
-
switch (
|
|
25
|
+
switch (condition.compare) {
|
|
24
26
|
case "equals":
|
|
25
|
-
return value ===
|
|
27
|
+
return value === condition.compareValue;
|
|
26
28
|
case "contains":
|
|
27
29
|
if (!value)
|
|
28
30
|
return false;
|
|
29
|
-
return value.includes(
|
|
31
|
+
return value.includes(condition.compareValue);
|
|
30
32
|
case "notEquals":
|
|
31
|
-
return value !==
|
|
33
|
+
return value !== condition.compareValue;
|
|
32
34
|
case "notContains":
|
|
33
35
|
if (!value)
|
|
34
36
|
return true;
|
|
35
|
-
return !value.includes(
|
|
37
|
+
return !value.includes(condition.compareValue);
|
|
36
38
|
}
|
|
37
39
|
break;
|
|
38
40
|
}
|
|
@@ -97,8 +99,8 @@ const isIfBlockConditionMet = (ifBlock, {
|
|
|
97
99
|
break;
|
|
98
100
|
}
|
|
99
101
|
case "boolean": {
|
|
100
|
-
const compareBoolean =
|
|
101
|
-
switch (
|
|
102
|
+
const compareBoolean = condition.compareValue === "true";
|
|
103
|
+
switch (condition.compare) {
|
|
102
104
|
case "equals":
|
|
103
105
|
return answer.value === compareBoolean;
|
|
104
106
|
case "notEquals":
|
|
@@ -107,25 +109,25 @@ const isIfBlockConditionMet = (ifBlock, {
|
|
|
107
109
|
break;
|
|
108
110
|
}
|
|
109
111
|
case "string":
|
|
110
|
-
switch (
|
|
112
|
+
switch (condition.compare) {
|
|
111
113
|
case "equals":
|
|
112
|
-
return answer.value ===
|
|
114
|
+
return answer.value === condition.compareValue;
|
|
113
115
|
case "contains":
|
|
114
116
|
if (!answer.value)
|
|
115
117
|
return false;
|
|
116
|
-
return answer.value.includes(
|
|
118
|
+
return answer.value.includes(condition.compareValue);
|
|
117
119
|
case "notEquals":
|
|
118
|
-
return answer.value !==
|
|
120
|
+
return answer.value !== condition.compareValue;
|
|
119
121
|
case "notContains":
|
|
120
122
|
if (!answer.value)
|
|
121
123
|
return true;
|
|
122
|
-
return !answer.value.includes(
|
|
124
|
+
return !answer.value.includes(condition.compareValue);
|
|
123
125
|
}
|
|
124
126
|
break;
|
|
125
127
|
case "number": {
|
|
126
128
|
try {
|
|
127
|
-
const compareNumber = Number(
|
|
128
|
-
switch (
|
|
129
|
+
const compareNumber = Number(condition.compareValue);
|
|
130
|
+
switch (condition.compare) {
|
|
129
131
|
case "equals":
|
|
130
132
|
return answer.value === compareNumber;
|
|
131
133
|
case "notEquals":
|
|
@@ -146,19 +148,38 @@ const isIfBlockConditionMet = (ifBlock, {
|
|
|
146
148
|
break;
|
|
147
149
|
}
|
|
148
150
|
case "enum":
|
|
149
|
-
switch (
|
|
151
|
+
switch (condition.compare) {
|
|
150
152
|
case "equals":
|
|
151
|
-
return answer.value.length === 1 && answer.value[0] ===
|
|
153
|
+
return answer.value.length === 1 && answer.value[0] === condition.compareValue;
|
|
152
154
|
case "notEquals":
|
|
153
|
-
return answer.value.length === 1 && answer.value[0] !==
|
|
155
|
+
return answer.value.length === 1 && answer.value[0] !== condition.compareValue;
|
|
154
156
|
case "contains":
|
|
155
|
-
return answer.value.includes(
|
|
157
|
+
return answer.value.includes(condition.compareValue);
|
|
156
158
|
case "notContains":
|
|
157
|
-
return !answer.value.includes(
|
|
159
|
+
return !answer.value.includes(condition.compareValue);
|
|
158
160
|
}
|
|
159
161
|
break;
|
|
160
162
|
}
|
|
161
|
-
|
|
163
|
+
};
|
|
164
|
+
const isIfBlockConditionMet = (ifBlock, {
|
|
165
|
+
context,
|
|
166
|
+
submissions
|
|
167
|
+
}) => {
|
|
168
|
+
const conditions = "combinator" in ifBlock.data ? ifBlock.data.conditions : [ifBlock.data];
|
|
169
|
+
const combinator = "combinator" in ifBlock.data ? ifBlock.data.combinator : "and";
|
|
170
|
+
for (const condition of conditions) {
|
|
171
|
+
const isMet = isConditionMet({
|
|
172
|
+
condition,
|
|
173
|
+
context,
|
|
174
|
+
submissions,
|
|
175
|
+
ifBlock
|
|
176
|
+
});
|
|
177
|
+
if (combinator === "or" && isMet)
|
|
178
|
+
return true;
|
|
179
|
+
if (combinator === "and" && !isMet)
|
|
180
|
+
return false;
|
|
181
|
+
}
|
|
182
|
+
return true;
|
|
162
183
|
};
|
|
163
184
|
const HANDLEBARS_REGEXP = /{{\s*([^}]+?)\s*(?:\|\s*([^}]+?)\s*)?}}/g;
|
|
164
185
|
const interpolateWithData = (str, {
|
|
@@ -1414,7 +1435,7 @@ const countries = {
|
|
|
1414
1435
|
France: "33",
|
|
1415
1436
|
"French Guiana": "594",
|
|
1416
1437
|
"French Polynesia": "689",
|
|
1417
|
-
"French Southern and Antarctic Lands": "
|
|
1438
|
+
"French Southern and Antarctic Lands": "262",
|
|
1418
1439
|
Gabon: "241",
|
|
1419
1440
|
Georgia: "995",
|
|
1420
1441
|
Germany: "49",
|
|
@@ -1439,7 +1460,7 @@ const countries = {
|
|
|
1439
1460
|
Indonesia: "62",
|
|
1440
1461
|
Iran: "98",
|
|
1441
1462
|
Iraq: "964",
|
|
1442
|
-
Ireland: "
|
|
1463
|
+
Ireland: "353",
|
|
1443
1464
|
"Isle of Man": "44",
|
|
1444
1465
|
Israel: "972",
|
|
1445
1466
|
Italy: "39",
|
|
@@ -1495,7 +1516,7 @@ const countries = {
|
|
|
1495
1516
|
Nigeria: "234",
|
|
1496
1517
|
Niue: "683",
|
|
1497
1518
|
"Norfolk Island": "672",
|
|
1498
|
-
"North Korea": "
|
|
1519
|
+
"North Korea": "850",
|
|
1499
1520
|
"North Macedonia": "389",
|
|
1500
1521
|
"Northern Mariana Islands": "1 670",
|
|
1501
1522
|
Norway: "47",
|
|
@@ -1549,7 +1570,7 @@ const countries = {
|
|
|
1549
1570
|
Sweden: "46",
|
|
1550
1571
|
Switzerland: "41",
|
|
1551
1572
|
Syria: "963",
|
|
1552
|
-
"São Tomé and Príncipe": "
|
|
1573
|
+
"São Tomé and Príncipe": "239",
|
|
1553
1574
|
Taiwan: "886",
|
|
1554
1575
|
Tajikistan: "992",
|
|
1555
1576
|
Tanzania: "255",
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { g as get$1, i as isString$2, k as kbToReadableSize, a as getHeadOrThrow, b as invariant, A as AbortedError, c as getFlowSubmissionsPayload, N, _, d as getDefaultExportFromCjs, h, e as _$1, p, F, o as o$1, f as clsx, y, s as store, j as a$2, l as k, m as k$1, n as getFormSubmitter, q as parse, r as picklist, t as isSubmissionOfType, C as Cn, u as parseAsync, V as ValiError, v as object, w as transform, x as cva, z as maxLength, B as minLength, D as record, E as boolean, G as number, H as minValue, I as maxValue, J as custom, K as string, L as regex, M as email, O as url, P as LoadingIndicator, Q as ERROR_MESSAGES } from "./index-
|
|
1
|
+
import { g as get$1, i as isString$2, k as kbToReadableSize, a as getHeadOrThrow, b as invariant, A as AbortedError, c as getFlowSubmissionsPayload, N, _, d as getDefaultExportFromCjs, h, e as _$1, p, F, o as o$1, f as clsx, y, s as store, j as a$2, l as k, m as k$1, n as getFormSubmitter, q as parse, r as picklist, t as isSubmissionOfType, C as Cn, u as parseAsync, V as ValiError, v as object, w as transform, x as cva, z as maxLength, B as minLength, D as record, E as boolean, G as number, H as minValue, I as maxValue, J as custom, K as string, L as regex, M as email, O as url, P as LoadingIndicator, Q as ERROR_MESSAGES } from "./index-5e2a3998.js";
|
|
2
2
|
import "@inploi/sdk";
|
|
3
|
-
const
|
|
3
|
+
const isConditionMet = ({
|
|
4
|
+
condition,
|
|
4
5
|
context,
|
|
5
|
-
submissions
|
|
6
|
+
submissions,
|
|
7
|
+
ifBlock
|
|
6
8
|
}) => {
|
|
7
|
-
const [firstSegment, ...path] =
|
|
9
|
+
const [firstSegment, ...path] = condition.compareKey.split(".");
|
|
8
10
|
if (!firstSegment)
|
|
9
11
|
return false;
|
|
10
12
|
const answer = getSubmissionValueToCheck({
|
|
@@ -18,19 +20,19 @@ const isIfBlockConditionMet = (ifBlock, {
|
|
|
18
20
|
switch (answer.type) {
|
|
19
21
|
case "address": {
|
|
20
22
|
const value = get$1(answer.value, path.join("."));
|
|
21
|
-
switch (
|
|
23
|
+
switch (condition.compare) {
|
|
22
24
|
case "equals":
|
|
23
|
-
return value ===
|
|
25
|
+
return value === condition.compareValue;
|
|
24
26
|
case "contains":
|
|
25
27
|
if (!value)
|
|
26
28
|
return false;
|
|
27
|
-
return value.includes(
|
|
29
|
+
return value.includes(condition.compareValue);
|
|
28
30
|
case "notEquals":
|
|
29
|
-
return value !==
|
|
31
|
+
return value !== condition.compareValue;
|
|
30
32
|
case "notContains":
|
|
31
33
|
if (!value)
|
|
32
34
|
return true;
|
|
33
|
-
return !value.includes(
|
|
35
|
+
return !value.includes(condition.compareValue);
|
|
34
36
|
}
|
|
35
37
|
break;
|
|
36
38
|
}
|
|
@@ -95,8 +97,8 @@ const isIfBlockConditionMet = (ifBlock, {
|
|
|
95
97
|
break;
|
|
96
98
|
}
|
|
97
99
|
case "boolean": {
|
|
98
|
-
const compareBoolean =
|
|
99
|
-
switch (
|
|
100
|
+
const compareBoolean = condition.compareValue === "true";
|
|
101
|
+
switch (condition.compare) {
|
|
100
102
|
case "equals":
|
|
101
103
|
return answer.value === compareBoolean;
|
|
102
104
|
case "notEquals":
|
|
@@ -105,25 +107,25 @@ const isIfBlockConditionMet = (ifBlock, {
|
|
|
105
107
|
break;
|
|
106
108
|
}
|
|
107
109
|
case "string":
|
|
108
|
-
switch (
|
|
110
|
+
switch (condition.compare) {
|
|
109
111
|
case "equals":
|
|
110
|
-
return answer.value ===
|
|
112
|
+
return answer.value === condition.compareValue;
|
|
111
113
|
case "contains":
|
|
112
114
|
if (!answer.value)
|
|
113
115
|
return false;
|
|
114
|
-
return answer.value.includes(
|
|
116
|
+
return answer.value.includes(condition.compareValue);
|
|
115
117
|
case "notEquals":
|
|
116
|
-
return answer.value !==
|
|
118
|
+
return answer.value !== condition.compareValue;
|
|
117
119
|
case "notContains":
|
|
118
120
|
if (!answer.value)
|
|
119
121
|
return true;
|
|
120
|
-
return !answer.value.includes(
|
|
122
|
+
return !answer.value.includes(condition.compareValue);
|
|
121
123
|
}
|
|
122
124
|
break;
|
|
123
125
|
case "number": {
|
|
124
126
|
try {
|
|
125
|
-
const compareNumber = Number(
|
|
126
|
-
switch (
|
|
127
|
+
const compareNumber = Number(condition.compareValue);
|
|
128
|
+
switch (condition.compare) {
|
|
127
129
|
case "equals":
|
|
128
130
|
return answer.value === compareNumber;
|
|
129
131
|
case "notEquals":
|
|
@@ -144,19 +146,38 @@ const isIfBlockConditionMet = (ifBlock, {
|
|
|
144
146
|
break;
|
|
145
147
|
}
|
|
146
148
|
case "enum":
|
|
147
|
-
switch (
|
|
149
|
+
switch (condition.compare) {
|
|
148
150
|
case "equals":
|
|
149
|
-
return answer.value.length === 1 && answer.value[0] ===
|
|
151
|
+
return answer.value.length === 1 && answer.value[0] === condition.compareValue;
|
|
150
152
|
case "notEquals":
|
|
151
|
-
return answer.value.length === 1 && answer.value[0] !==
|
|
153
|
+
return answer.value.length === 1 && answer.value[0] !== condition.compareValue;
|
|
152
154
|
case "contains":
|
|
153
|
-
return answer.value.includes(
|
|
155
|
+
return answer.value.includes(condition.compareValue);
|
|
154
156
|
case "notContains":
|
|
155
|
-
return !answer.value.includes(
|
|
157
|
+
return !answer.value.includes(condition.compareValue);
|
|
156
158
|
}
|
|
157
159
|
break;
|
|
158
160
|
}
|
|
159
|
-
|
|
161
|
+
};
|
|
162
|
+
const isIfBlockConditionMet = (ifBlock, {
|
|
163
|
+
context,
|
|
164
|
+
submissions
|
|
165
|
+
}) => {
|
|
166
|
+
const conditions = "combinator" in ifBlock.data ? ifBlock.data.conditions : [ifBlock.data];
|
|
167
|
+
const combinator = "combinator" in ifBlock.data ? ifBlock.data.combinator : "and";
|
|
168
|
+
for (const condition of conditions) {
|
|
169
|
+
const isMet = isConditionMet({
|
|
170
|
+
condition,
|
|
171
|
+
context,
|
|
172
|
+
submissions,
|
|
173
|
+
ifBlock
|
|
174
|
+
});
|
|
175
|
+
if (combinator === "or" && isMet)
|
|
176
|
+
return true;
|
|
177
|
+
if (combinator === "and" && !isMet)
|
|
178
|
+
return false;
|
|
179
|
+
}
|
|
180
|
+
return true;
|
|
160
181
|
};
|
|
161
182
|
const HANDLEBARS_REGEXP = /{{\s*([^}]+?)\s*(?:\|\s*([^}]+?)\s*)?}}/g;
|
|
162
183
|
const interpolateWithData = (str, {
|
|
@@ -1412,7 +1433,7 @@ const countries = {
|
|
|
1412
1433
|
France: "33",
|
|
1413
1434
|
"French Guiana": "594",
|
|
1414
1435
|
"French Polynesia": "689",
|
|
1415
|
-
"French Southern and Antarctic Lands": "
|
|
1436
|
+
"French Southern and Antarctic Lands": "262",
|
|
1416
1437
|
Gabon: "241",
|
|
1417
1438
|
Georgia: "995",
|
|
1418
1439
|
Germany: "49",
|
|
@@ -1437,7 +1458,7 @@ const countries = {
|
|
|
1437
1458
|
Indonesia: "62",
|
|
1438
1459
|
Iran: "98",
|
|
1439
1460
|
Iraq: "964",
|
|
1440
|
-
Ireland: "
|
|
1461
|
+
Ireland: "353",
|
|
1441
1462
|
"Isle of Man": "44",
|
|
1442
1463
|
Israel: "972",
|
|
1443
1464
|
Italy: "39",
|
|
@@ -1493,7 +1514,7 @@ const countries = {
|
|
|
1493
1514
|
Nigeria: "234",
|
|
1494
1515
|
Niue: "683",
|
|
1495
1516
|
"Norfolk Island": "672",
|
|
1496
|
-
"North Korea": "
|
|
1517
|
+
"North Korea": "850",
|
|
1497
1518
|
"North Macedonia": "389",
|
|
1498
1519
|
"Northern Mariana Islands": "1 670",
|
|
1499
1520
|
Norway: "47",
|
|
@@ -1547,7 +1568,7 @@ const countries = {
|
|
|
1547
1568
|
Sweden: "46",
|
|
1548
1569
|
Switzerland: "41",
|
|
1549
1570
|
Syria: "963",
|
|
1550
|
-
"São Tomé and Príncipe": "
|
|
1571
|
+
"São Tomé and Príncipe": "239",
|
|
1551
1572
|
Taiwan: "886",
|
|
1552
1573
|
Tajikistan: "992",
|
|
1553
1574
|
Tanzania: "255",
|