@inploi/plugin-chatbot 3.24.0 → 3.26.0
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 +11 -11
- package/cdn/style.css +1 -1
- package/dist/{chatbot-body-66b0a30f.cjs → chatbot-body-224dcd7d.cjs} +446 -45
- package/dist/{chatbot-body-fe759b08.js → chatbot-body-dd9bb20f.js} +446 -45
- package/dist/chatbot.api.d.ts +11 -0
- package/dist/chatbot.state.d.ts +4 -1
- package/dist/chatbot.utils.d.ts +1 -0
- package/dist/{index-6d177413.cjs → index-00f143ae.cjs} +3 -2
- package/dist/{index-8bfa662b.js → index-0a6167b8.js} +8 -7
- package/dist/plugin-chatbot.cjs +1 -1
- package/dist/plugin-chatbot.js +2 -2
- package/dist/style.css +29 -0
- package/package.json +3 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { g as get$1, i as isString$1, k as kbToReadableSize, a as getHeadOrThrow, b as invariant, A as AbortedError, N, c as getFlowSubmissionsPayload, _, 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
|
|
1
|
+
import { g as get$1, i as isString$1, k as kbToReadableSize, a as getHeadOrThrow, b as invariant, A as AbortedError, N, c as getFlowSubmissionsPayload, _, 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-0a6167b8.js";
|
|
2
2
|
import "@inploi/sdk";
|
|
3
3
|
const isIfBlockConditionMet = (ifBlock, {
|
|
4
4
|
context,
|
|
@@ -428,9 +428,7 @@ async function interpretSubmitNode({
|
|
|
428
428
|
});
|
|
429
429
|
}
|
|
430
430
|
await chat.sendMessage({
|
|
431
|
-
type: "
|
|
432
|
-
variant: "info",
|
|
433
|
-
text: "Submitting…"
|
|
431
|
+
type: "loading"
|
|
434
432
|
});
|
|
435
433
|
const {
|
|
436
434
|
anonymous_id,
|
|
@@ -480,17 +478,25 @@ async function interpretSubmitNode({
|
|
|
480
478
|
});
|
|
481
479
|
}).otherwise(() => {
|
|
482
480
|
});
|
|
483
|
-
await N(response).with({
|
|
484
|
-
ats_data: {
|
|
481
|
+
await N(response).with(_.union({
|
|
482
|
+
ats_data: _.select("redirect", {
|
|
485
483
|
redirect_url: _.string
|
|
484
|
+
})
|
|
485
|
+
}, {
|
|
486
|
+
integration_response: {
|
|
487
|
+
data: _.select("redirect", {
|
|
488
|
+
redirect_url: _.string
|
|
489
|
+
})
|
|
486
490
|
}
|
|
487
|
-
}, async (response2) => {
|
|
491
|
+
}), async (response2) => {
|
|
492
|
+
if (response2.redirect === void 0)
|
|
493
|
+
return;
|
|
488
494
|
await chat.sendMessage({
|
|
489
495
|
type: "text",
|
|
490
496
|
author: "bot",
|
|
491
497
|
text: "Almost there! Please complete your submission here:"
|
|
492
498
|
});
|
|
493
|
-
const href = new URL(response2.
|
|
499
|
+
const href = new URL(response2.redirect.redirect_url);
|
|
494
500
|
if (anonymous_id && !href.searchParams.has("anonymous_id")) {
|
|
495
501
|
href.searchParams.set("anonymous_id", anonymous_id);
|
|
496
502
|
}
|
|
@@ -499,8 +505,10 @@ async function interpretSubmitNode({
|
|
|
499
505
|
href: href.toString(),
|
|
500
506
|
text: "Complete submission",
|
|
501
507
|
onClick: () => {
|
|
502
|
-
if (!session_id)
|
|
503
|
-
|
|
508
|
+
if (!session_id) {
|
|
509
|
+
logger.error("session_id not set, cannot log FLOW_REDIRECT event");
|
|
510
|
+
return;
|
|
511
|
+
}
|
|
504
512
|
analytics.log({
|
|
505
513
|
event: "FLOW_REDIRECT",
|
|
506
514
|
properties: {
|
|
@@ -524,17 +532,24 @@ async function interpretSubmitNode({
|
|
|
524
532
|
text: "Submission completed!"
|
|
525
533
|
});
|
|
526
534
|
next(node.nextId);
|
|
527
|
-
}).with({
|
|
528
|
-
|
|
529
|
-
ats_data: {
|
|
535
|
+
}).with(_.union({
|
|
536
|
+
success: false,
|
|
537
|
+
ats_data: _.select("error", {
|
|
530
538
|
message: _.string
|
|
539
|
+
})
|
|
540
|
+
}, {
|
|
541
|
+
integration_response: {
|
|
542
|
+
error: _.select("error", {
|
|
543
|
+
message: _.string
|
|
544
|
+
})
|
|
531
545
|
}
|
|
532
|
-
}, async (response2) => {
|
|
533
|
-
|
|
546
|
+
}), async (response2) => {
|
|
547
|
+
var _a;
|
|
548
|
+
logger.error(response2.error);
|
|
534
549
|
await chat.sendMessage({
|
|
535
550
|
type: "system",
|
|
536
551
|
variant: "error",
|
|
537
|
-
text: response2.
|
|
552
|
+
text: ((_a = response2.error) == null ? void 0 : _a.message) || "Failed to submit"
|
|
538
553
|
});
|
|
539
554
|
await submit(false);
|
|
540
555
|
}).otherwise(async (response2) => {
|
|
@@ -626,14 +641,24 @@ async function interpretQuestionTextNode({
|
|
|
626
641
|
context
|
|
627
642
|
})
|
|
628
643
|
});
|
|
629
|
-
const reply = await chat.userInput({
|
|
644
|
+
const reply = node.data.format === "phone" ? await chat.userInput({
|
|
645
|
+
key: node.data.key,
|
|
646
|
+
type: "phone",
|
|
647
|
+
config: {
|
|
648
|
+
optional: node.data.optional,
|
|
649
|
+
placeholder: node.data.placeholder,
|
|
650
|
+
maxChars: node.data.maxChars,
|
|
651
|
+
minChars: node.data.minChars
|
|
652
|
+
}
|
|
653
|
+
}) : await chat.userInput({
|
|
630
654
|
key: node.data.key,
|
|
631
655
|
type: "text",
|
|
632
656
|
config: {
|
|
633
657
|
optional: node.data.optional,
|
|
634
658
|
placeholder: node.data.placeholder,
|
|
635
659
|
format: node.data.format,
|
|
636
|
-
maxChars: node.data.maxChars
|
|
660
|
+
maxChars: node.data.maxChars,
|
|
661
|
+
minChars: node.data.minChars
|
|
637
662
|
}
|
|
638
663
|
});
|
|
639
664
|
if (reply === null) {
|
|
@@ -1230,7 +1255,256 @@ const SkipButton = ({
|
|
|
1230
1255
|
})]
|
|
1231
1256
|
}), "Skip"]
|
|
1232
1257
|
});
|
|
1233
|
-
const
|
|
1258
|
+
const countries = {
|
|
1259
|
+
Afghanistan: "93",
|
|
1260
|
+
Albania: "355",
|
|
1261
|
+
Algeria: "213",
|
|
1262
|
+
"American Samoa": "1",
|
|
1263
|
+
Andorra: "376",
|
|
1264
|
+
Angola: "244",
|
|
1265
|
+
Anguilla: "1",
|
|
1266
|
+
Antarctica: "672",
|
|
1267
|
+
"Antigua and Barbuda": "1",
|
|
1268
|
+
Argentina: "54",
|
|
1269
|
+
Armenia: "374",
|
|
1270
|
+
Aruba: "297",
|
|
1271
|
+
Australia: "61",
|
|
1272
|
+
Austria: "43",
|
|
1273
|
+
Azerbaijan: "994",
|
|
1274
|
+
Bahrain: "973",
|
|
1275
|
+
Bangladesh: "880",
|
|
1276
|
+
Barbados: "1",
|
|
1277
|
+
Belarus: "375",
|
|
1278
|
+
Belgium: "32",
|
|
1279
|
+
Belize: "501",
|
|
1280
|
+
Benin: "229",
|
|
1281
|
+
Bermuda: "1",
|
|
1282
|
+
Bhutan: "975",
|
|
1283
|
+
Bolivia: "591",
|
|
1284
|
+
"Bosnia and Herzegovina": "387",
|
|
1285
|
+
Botswana: "267",
|
|
1286
|
+
"Bouvet Island": "47",
|
|
1287
|
+
Brazil: "55",
|
|
1288
|
+
"British Indian Ocean Territory": "246",
|
|
1289
|
+
"British Virgin Islands": "1",
|
|
1290
|
+
Brunei: "673",
|
|
1291
|
+
Bulgaria: "359",
|
|
1292
|
+
"Burkina Faso": "226",
|
|
1293
|
+
Burundi: "257",
|
|
1294
|
+
"Cabo Verde": "238",
|
|
1295
|
+
Cambodia: "855",
|
|
1296
|
+
Cameroon: "237",
|
|
1297
|
+
Canada: "1",
|
|
1298
|
+
"Caribbean Netherlands": "599",
|
|
1299
|
+
"Cayman Islands": "1",
|
|
1300
|
+
"Central African Republic": "236",
|
|
1301
|
+
Chad: "235",
|
|
1302
|
+
Chile: "56",
|
|
1303
|
+
China: "86",
|
|
1304
|
+
"Christmas Island": "61",
|
|
1305
|
+
"Cocos (Keeling) Islands": "61",
|
|
1306
|
+
Colombia: "57",
|
|
1307
|
+
Comoros: "269",
|
|
1308
|
+
"Cook Islands": "682",
|
|
1309
|
+
"Costa Rica": "506",
|
|
1310
|
+
Croatia: "385",
|
|
1311
|
+
Cuba: "53",
|
|
1312
|
+
Curaçao: "599",
|
|
1313
|
+
Cyprus: "357",
|
|
1314
|
+
Czechia: "420",
|
|
1315
|
+
"Côte d'Ivoire": "225",
|
|
1316
|
+
"Democratic Republic of the Congo": "243",
|
|
1317
|
+
Denmark: "45",
|
|
1318
|
+
Djibouti: "253",
|
|
1319
|
+
"Dominican Republic": "1",
|
|
1320
|
+
Ecuador: "593",
|
|
1321
|
+
Egypt: "20",
|
|
1322
|
+
"El Salvador": "503",
|
|
1323
|
+
"Equatorial Guinea": "240",
|
|
1324
|
+
Eritrea: "291",
|
|
1325
|
+
Estonia: "372",
|
|
1326
|
+
Eswatini: "268",
|
|
1327
|
+
Ethiopia: "251",
|
|
1328
|
+
"Falkland Islands (Islas Malvinas)": "500",
|
|
1329
|
+
"Faroe Islands": "298",
|
|
1330
|
+
Fiji: "679",
|
|
1331
|
+
Finland: "358",
|
|
1332
|
+
France: "33",
|
|
1333
|
+
"French Guiana": "594",
|
|
1334
|
+
"French Polynesia": "689",
|
|
1335
|
+
"French Southern and Antarctic Lands": "260",
|
|
1336
|
+
Gabon: "241",
|
|
1337
|
+
Georgia: "995",
|
|
1338
|
+
Germany: "49",
|
|
1339
|
+
Ghana: "233",
|
|
1340
|
+
Gibraltar: "350",
|
|
1341
|
+
Greece: "30",
|
|
1342
|
+
Greenland: "299",
|
|
1343
|
+
Grenada: "1",
|
|
1344
|
+
Guadeloupe: "590",
|
|
1345
|
+
Guam: "1",
|
|
1346
|
+
Guatemala: "502",
|
|
1347
|
+
Guernsey: "44",
|
|
1348
|
+
Guinea: "224",
|
|
1349
|
+
"Guinea-Bissau": "245",
|
|
1350
|
+
Guyana: "592",
|
|
1351
|
+
Haiti: "509",
|
|
1352
|
+
"Heard Island and McDonald Islands": "334",
|
|
1353
|
+
Honduras: "504",
|
|
1354
|
+
"Hong Kong": "852",
|
|
1355
|
+
Hungary: "36",
|
|
1356
|
+
Iceland: "354",
|
|
1357
|
+
India: "91",
|
|
1358
|
+
Indonesia: "62",
|
|
1359
|
+
Iran: "98",
|
|
1360
|
+
Iraq: "964",
|
|
1361
|
+
Ireland: "352",
|
|
1362
|
+
"Isle of Man": "44",
|
|
1363
|
+
Israel: "972",
|
|
1364
|
+
Italy: "39",
|
|
1365
|
+
Jamaica: "1",
|
|
1366
|
+
Japan: "81",
|
|
1367
|
+
Jersey: "44",
|
|
1368
|
+
Jordan: "962",
|
|
1369
|
+
Kazakhstan: "7",
|
|
1370
|
+
Kenya: "254",
|
|
1371
|
+
Kiribati: "686",
|
|
1372
|
+
Kosovo: "383",
|
|
1373
|
+
Kuwait: "965",
|
|
1374
|
+
Kyrgyzstan: "996",
|
|
1375
|
+
Laos: "856",
|
|
1376
|
+
Latvia: "371",
|
|
1377
|
+
Lebanon: "961",
|
|
1378
|
+
Lesotho: "266",
|
|
1379
|
+
Liberia: "231",
|
|
1380
|
+
Libya: "218",
|
|
1381
|
+
Liechtenstein: "423",
|
|
1382
|
+
Lithuania: "370",
|
|
1383
|
+
Luxembourg: "352",
|
|
1384
|
+
Macao: "853",
|
|
1385
|
+
Madagascar: "261",
|
|
1386
|
+
Malawi: "265",
|
|
1387
|
+
Malaysia: "60",
|
|
1388
|
+
Maldives: "960",
|
|
1389
|
+
Mali: "223",
|
|
1390
|
+
Malta: "356",
|
|
1391
|
+
"Marshall Islands": "692",
|
|
1392
|
+
Martinique: "596",
|
|
1393
|
+
Mauritania: "222",
|
|
1394
|
+
Mauritius: "230",
|
|
1395
|
+
Mayotte: "262",
|
|
1396
|
+
Mexico: "52",
|
|
1397
|
+
Micronesia: "691",
|
|
1398
|
+
Moldova: "373",
|
|
1399
|
+
Monaco: "377",
|
|
1400
|
+
Mongolia: "976",
|
|
1401
|
+
Montenegro: "382",
|
|
1402
|
+
Montserrat: "1",
|
|
1403
|
+
Morocco: "212",
|
|
1404
|
+
Mozambique: "258",
|
|
1405
|
+
"Myanmar (Burma)": "95",
|
|
1406
|
+
Namibia: "264",
|
|
1407
|
+
Nauru: "674",
|
|
1408
|
+
Nepal: "977",
|
|
1409
|
+
Netherlands: "31",
|
|
1410
|
+
"New Caledonia": "687",
|
|
1411
|
+
"New Zealand": "64",
|
|
1412
|
+
Nicaragua: "505",
|
|
1413
|
+
Niger: "227",
|
|
1414
|
+
Nigeria: "234",
|
|
1415
|
+
Niue: "683",
|
|
1416
|
+
"Norfolk Island": "672",
|
|
1417
|
+
"North Korea": "852",
|
|
1418
|
+
"North Macedonia": "389",
|
|
1419
|
+
"Northern Mariana Islands": "1",
|
|
1420
|
+
Norway: "47",
|
|
1421
|
+
Oman: "968",
|
|
1422
|
+
Pakistan: "92",
|
|
1423
|
+
Palau: "680",
|
|
1424
|
+
Palestine: "970",
|
|
1425
|
+
Panama: "507",
|
|
1426
|
+
"Papua New Guinea": "675",
|
|
1427
|
+
Paraguay: "595",
|
|
1428
|
+
Peru: "51",
|
|
1429
|
+
Philippines: "63",
|
|
1430
|
+
"Pitcairn Islands": "64",
|
|
1431
|
+
Poland: "48",
|
|
1432
|
+
Portugal: "351",
|
|
1433
|
+
"Puerto Rico": "1",
|
|
1434
|
+
Qatar: "974",
|
|
1435
|
+
Romania: "40",
|
|
1436
|
+
Russia: "7",
|
|
1437
|
+
Rwanda: "250",
|
|
1438
|
+
Réunion: "262",
|
|
1439
|
+
"Saint Barthélemy": "590",
|
|
1440
|
+
"Saint Helena, Ascension and Tristan da Cunha": "290",
|
|
1441
|
+
"Saint Kitts and Nevis": "1",
|
|
1442
|
+
"Saint Lucia": "1",
|
|
1443
|
+
"Saint Martin": "590",
|
|
1444
|
+
"Saint Pierre and Miquelon": "508",
|
|
1445
|
+
"Saint Vincent and the Grenadines": "1",
|
|
1446
|
+
Samoa: "685",
|
|
1447
|
+
"San Marino": "378",
|
|
1448
|
+
"Saudi Arabia": "966",
|
|
1449
|
+
Senegal: "221",
|
|
1450
|
+
Serbia: "381",
|
|
1451
|
+
Seychelles: "248",
|
|
1452
|
+
"Sierra Leone": "232",
|
|
1453
|
+
Singapore: "65",
|
|
1454
|
+
"Sint Maarten": "1",
|
|
1455
|
+
Slovakia: "421",
|
|
1456
|
+
Slovenia: "386",
|
|
1457
|
+
"Solomon Islands": "677",
|
|
1458
|
+
Somalia: "252",
|
|
1459
|
+
"South Africa": "27",
|
|
1460
|
+
"South Georgia and the South Sandwich Islands": "500",
|
|
1461
|
+
"South Korea": "82",
|
|
1462
|
+
"South Sudan": "211",
|
|
1463
|
+
Spain: "34",
|
|
1464
|
+
"Sri Lanka": "94",
|
|
1465
|
+
Sudan: "249",
|
|
1466
|
+
Suriname: "597",
|
|
1467
|
+
"Svalbard and Jan Mayen": "47",
|
|
1468
|
+
Sweden: "46",
|
|
1469
|
+
Switzerland: "41",
|
|
1470
|
+
Syria: "963",
|
|
1471
|
+
"São Tomé and Príncipe": "293",
|
|
1472
|
+
Taiwan: "886",
|
|
1473
|
+
Tajikistan: "992",
|
|
1474
|
+
Tanzania: "255",
|
|
1475
|
+
Thailand: "66",
|
|
1476
|
+
"The Bahamas": "1",
|
|
1477
|
+
"The Gambia": "220",
|
|
1478
|
+
"Timor-Leste": "670",
|
|
1479
|
+
Togo: "228",
|
|
1480
|
+
Tokelau: "690",
|
|
1481
|
+
Tonga: "676",
|
|
1482
|
+
"Trinidad and Tobago": "1",
|
|
1483
|
+
Tunisia: "216",
|
|
1484
|
+
Turkmenistan: "993",
|
|
1485
|
+
"Turks and Caicos Islands": "1",
|
|
1486
|
+
Tuvalu: "688",
|
|
1487
|
+
Türkiye: "90",
|
|
1488
|
+
"U.S. Virgin Islands": "1",
|
|
1489
|
+
Uganda: "256",
|
|
1490
|
+
Ukraine: "380",
|
|
1491
|
+
"United Arab Emirates": "971",
|
|
1492
|
+
"United Kingdom": "44",
|
|
1493
|
+
"United States": "1",
|
|
1494
|
+
"United States Minor Outlying Islands": "1",
|
|
1495
|
+
Uruguay: "598",
|
|
1496
|
+
Uzbekistan: "998",
|
|
1497
|
+
Vanuatu: "678",
|
|
1498
|
+
"Vatican City": "379",
|
|
1499
|
+
Venezuela: "58",
|
|
1500
|
+
Vietnam: "84",
|
|
1501
|
+
"Wallis and Futuna": "681",
|
|
1502
|
+
"Western Sahara": "212",
|
|
1503
|
+
Yemen: "967",
|
|
1504
|
+
Zambia: "260",
|
|
1505
|
+
Zimbabwe: "263",
|
|
1506
|
+
"Åland Islands": "358"
|
|
1507
|
+
};
|
|
1234
1508
|
const keyToAddressComponents = {
|
|
1235
1509
|
line1: ["street_number", "floor", "room", "premise"],
|
|
1236
1510
|
line2: ["subpremise", "street_address", "route"],
|
|
@@ -1559,6 +1833,7 @@ const ChatInputAddressDetails = ({
|
|
|
1559
1833
|
}
|
|
1560
1834
|
}
|
|
1561
1835
|
}, []);
|
|
1836
|
+
const countryNames = Object.keys(countries);
|
|
1562
1837
|
return o$1("form", {
|
|
1563
1838
|
class: "bg-neutral-1/90 flex flex-col justify-end gap-2 p-2",
|
|
1564
1839
|
onSubmit: (e) => {
|
|
@@ -1587,7 +1862,7 @@ const ChatInputAddressDetails = ({
|
|
|
1587
1862
|
children: [key === "country" ? o$1("div", {
|
|
1588
1863
|
class: "relative",
|
|
1589
1864
|
children: [o$1("select", {
|
|
1590
|
-
class: "text-neutral-12
|
|
1865
|
+
class: "text-neutral-12 hover:bg-neutral-4 placeholder:text-neutral-8 focus:bg-neutral-5 w-full flex-1 appearance-none rounded-lg border-solid bg-transparent bg-none px-3 py-1.5 text-base transition-colors focus:outline-none",
|
|
1591
1866
|
name,
|
|
1592
1867
|
id: labelId,
|
|
1593
1868
|
defaultValue: addressFields[key],
|
|
@@ -1598,10 +1873,10 @@ const ChatInputAddressDetails = ({
|
|
|
1598
1873
|
}) : o$1("option", {
|
|
1599
1874
|
value: "",
|
|
1600
1875
|
children: "Select a country"
|
|
1601
|
-
}), countryNames.map((
|
|
1602
|
-
value:
|
|
1603
|
-
children:
|
|
1604
|
-
},
|
|
1876
|
+
}), countryNames.map((countryName) => o$1("option", {
|
|
1877
|
+
value: countryName,
|
|
1878
|
+
children: countryName
|
|
1879
|
+
}, countryName))]
|
|
1605
1880
|
}), o$1("svg", {
|
|
1606
1881
|
class: "text-neutral-12 absolute bottom-2.5 right-2 flex items-center justify-center",
|
|
1607
1882
|
width: "16",
|
|
@@ -3432,7 +3707,7 @@ const LABEL_HEIGHT = 27;
|
|
|
3432
3707
|
const GAP = 12;
|
|
3433
3708
|
const PADDING = 10;
|
|
3434
3709
|
const isMultipleChoiceSubmission = isSubmissionOfType("enum");
|
|
3435
|
-
const getResolver$
|
|
3710
|
+
const getResolver$3 = (config) => {
|
|
3436
3711
|
const length = {
|
|
3437
3712
|
min: config.minSelected ?? 0,
|
|
3438
3713
|
max: config.maxSelected ?? config.options.length
|
|
@@ -3486,7 +3761,7 @@ const ChatInputMultipleChoice = ({
|
|
|
3486
3761
|
defaultValues: {
|
|
3487
3762
|
checked: isSingleChoice ? {} : isMultipleChoiceSubmission(submission) ? Object.fromEntries(submission.value.map((key) => [key, true])) : {}
|
|
3488
3763
|
},
|
|
3489
|
-
resolver: getResolver$
|
|
3764
|
+
resolver: getResolver$3(input.config)
|
|
3490
3765
|
});
|
|
3491
3766
|
const focusRef = useFocusOnMount();
|
|
3492
3767
|
if (isBooleanLike) {
|
|
@@ -3587,7 +3862,7 @@ const errors$1 = {
|
|
|
3587
3862
|
max: (max) => `Please enter a number less than or equal to ${max}`,
|
|
3588
3863
|
decimalCases: (decimalCases) => `Please enter a number with at most ${decimalCases} decimal cases`
|
|
3589
3864
|
};
|
|
3590
|
-
const getResolver$
|
|
3865
|
+
const getResolver$2 = (config) => {
|
|
3591
3866
|
const min = config.min ?? Number.MIN_SAFE_INTEGER;
|
|
3592
3867
|
const max = config.max ?? Number.MAX_SAFE_INTEGER;
|
|
3593
3868
|
const decimalCases = config.decimalCases ?? 0;
|
|
@@ -3614,7 +3889,7 @@ const ChatInputNumber = ({
|
|
|
3614
3889
|
defaultValues: {
|
|
3615
3890
|
number: defaultValue ? Number(defaultValue) : isNumberSubmission(submission) ? submission.value : void 0
|
|
3616
3891
|
},
|
|
3617
|
-
resolver: getResolver$
|
|
3892
|
+
resolver: getResolver$2(input.config)
|
|
3618
3893
|
});
|
|
3619
3894
|
const {
|
|
3620
3895
|
ref: setRef,
|
|
@@ -3672,6 +3947,115 @@ const ChatInputNumber = ({
|
|
|
3672
3947
|
})]
|
|
3673
3948
|
});
|
|
3674
3949
|
};
|
|
3950
|
+
const invalidPhoneErrorMessage = "That doesn’t look like a valid phone number";
|
|
3951
|
+
const UK_CODE = "44";
|
|
3952
|
+
const PhoneSchema = string(invalidPhoneErrorMessage, [regex(/^\+?[0-9 -]+$/, invalidPhoneErrorMessage)]);
|
|
3953
|
+
const getResolver$1 = (config) => {
|
|
3954
|
+
const configErrors = {
|
|
3955
|
+
maxLength: `Please enter no more than ${config.maxChars ?? 999} characters`,
|
|
3956
|
+
minLength: `Please enter ${config.minChars ?? 1} or more characters`
|
|
3957
|
+
};
|
|
3958
|
+
return i(object({
|
|
3959
|
+
text: transform(PhoneSchema, (value) => value.replace(/[^0-9]/g, ""), [minLength(config.minChars ?? 1, configErrors.minLength), maxLength(config.maxChars ?? Infinity, configErrors.maxLength)])
|
|
3960
|
+
}));
|
|
3961
|
+
};
|
|
3962
|
+
const isTextSubmission$1 = isSubmissionOfType("string");
|
|
3963
|
+
const ChatInputPhoneNumber = ({
|
|
3964
|
+
input,
|
|
3965
|
+
onSubmitSuccess
|
|
3966
|
+
}) => {
|
|
3967
|
+
var _a;
|
|
3968
|
+
const submission = input.key ? (_a = store.current$.value.flow) == null ? void 0 : _a.data.submissions[input.key] : void 0;
|
|
3969
|
+
const defaultValue = input.config.defaultValue;
|
|
3970
|
+
const {
|
|
3971
|
+
register,
|
|
3972
|
+
handleSubmit,
|
|
3973
|
+
formState: {
|
|
3974
|
+
errors: errors2
|
|
3975
|
+
}
|
|
3976
|
+
} = useForm({
|
|
3977
|
+
defaultValues: {
|
|
3978
|
+
text: defaultValue ? defaultValue : isTextSubmission$1(submission) ? submission.value : ""
|
|
3979
|
+
},
|
|
3980
|
+
resolver: getResolver$1(input.config)
|
|
3981
|
+
});
|
|
3982
|
+
const {
|
|
3983
|
+
ref: setRef,
|
|
3984
|
+
...props
|
|
3985
|
+
} = register("text", {
|
|
3986
|
+
required: !input.config.optional
|
|
3987
|
+
});
|
|
3988
|
+
const defaultCode = UK_CODE;
|
|
3989
|
+
const [countryCode, setCountryCode] = h(defaultCode);
|
|
3990
|
+
const inputRef = _$1();
|
|
3991
|
+
const selectRef = _$1(null);
|
|
3992
|
+
y(() => {
|
|
3993
|
+
if (inputRef.current) {
|
|
3994
|
+
inputRef.current.focus();
|
|
3995
|
+
inputRef.current.select();
|
|
3996
|
+
}
|
|
3997
|
+
}, []);
|
|
3998
|
+
return o$1("form", {
|
|
3999
|
+
noValidate: true,
|
|
4000
|
+
class: "flex flex-col gap-1 p-2.5",
|
|
4001
|
+
onSubmit: handleSubmit((submission2) => {
|
|
4002
|
+
onSubmitSuccess({
|
|
4003
|
+
type: "string",
|
|
4004
|
+
value: countryCode + submission2.text
|
|
4005
|
+
});
|
|
4006
|
+
}),
|
|
4007
|
+
children: [o$1("div", {
|
|
4008
|
+
class: "flex items-center gap-2",
|
|
4009
|
+
children: [o$1("div", {
|
|
4010
|
+
class: "relative flex min-w-0 flex-1 flex-grow gap-2",
|
|
4011
|
+
children: [o$1("label", {
|
|
4012
|
+
class: "text-neutral-12 hover:bg-neutral-4 placeholder:text-neutral-8 focus-within:bg-neutral-5 focus-within:outline-accent-7 relative flex h-full w-12 appearance-none items-center justify-center overflow-hidden text-ellipsis whitespace-nowrap rounded-lg border-solid bg-transparent bg-none py-1.5 text-center text-base transition-colors focus-within:outline-none",
|
|
4013
|
+
htmlFor: `isdk_phone_${input.key}`,
|
|
4014
|
+
children: [o$1("span", {
|
|
4015
|
+
children: ["+", countryCode]
|
|
4016
|
+
}), o$1("select", {
|
|
4017
|
+
ref: selectRef,
|
|
4018
|
+
onChange: (e) => {
|
|
4019
|
+
var _a2;
|
|
4020
|
+
const selectedCode = (_a2 = e.currentTarget.selectedOptions[0]) == null ? void 0 : _a2.value;
|
|
4021
|
+
setCountryCode(selectedCode);
|
|
4022
|
+
},
|
|
4023
|
+
required: true,
|
|
4024
|
+
defaultValue: defaultCode,
|
|
4025
|
+
id: `isdk_phone_${input.key}`,
|
|
4026
|
+
class: "absolute inset-0 opacity-0",
|
|
4027
|
+
children: Object.entries(countries).map(([countryName, countryCode2]) => o$1("option", {
|
|
4028
|
+
value: countryCode2,
|
|
4029
|
+
children: [countryName, " (+", countryCode2, ")"]
|
|
4030
|
+
}, countryName))
|
|
4031
|
+
})]
|
|
4032
|
+
}), o$1("input", {
|
|
4033
|
+
...props,
|
|
4034
|
+
id: "chat-input",
|
|
4035
|
+
type: "tel",
|
|
4036
|
+
inputMode: "tel",
|
|
4037
|
+
autocomplete: "off",
|
|
4038
|
+
autoCapitalize: "off",
|
|
4039
|
+
autoCorrect: "off",
|
|
4040
|
+
autoFocus: true,
|
|
4041
|
+
ref: (element) => {
|
|
4042
|
+
if (element) {
|
|
4043
|
+
inputRef.current = element;
|
|
4044
|
+
}
|
|
4045
|
+
setRef(element);
|
|
4046
|
+
},
|
|
4047
|
+
class: "outline-divider ease-expo-out placeholder:text-neutral-10 text-neutral-12 focus-visible:outline-accent-7 caret-accent-9 bg-lowest flex-1 rounded-full px-3 py-1 text-base outline outline-2 transition-all",
|
|
4048
|
+
placeholder: input.config.placeholder
|
|
4049
|
+
}), input.config.optional && o$1(SkipButton, {
|
|
4050
|
+
class: "absolute right-0 top-0",
|
|
4051
|
+
onClick: () => onSubmitSuccess(null)
|
|
4052
|
+
})]
|
|
4053
|
+
}), o$1(SendButton, {})]
|
|
4054
|
+
}), o$1(InputError, {
|
|
4055
|
+
error: errors2.text
|
|
4056
|
+
})]
|
|
4057
|
+
});
|
|
4058
|
+
};
|
|
3675
4059
|
const ChatInputSubmit = ({
|
|
3676
4060
|
input,
|
|
3677
4061
|
onSubmitSuccess
|
|
@@ -3688,7 +4072,7 @@ const ChatInputSubmit = ({
|
|
|
3688
4072
|
class: "flex items-center gap-1.5",
|
|
3689
4073
|
children: [o$1("span", {
|
|
3690
4074
|
class: "inline-flex items-center text-sm font-medium",
|
|
3691
|
-
children: input.config.label
|
|
4075
|
+
children: input.config.label || "Submit"
|
|
3692
4076
|
}), o$1("svg", {
|
|
3693
4077
|
stroke: "currentColor",
|
|
3694
4078
|
"stroke-width": "1.5",
|
|
@@ -3713,17 +4097,12 @@ const errors = {
|
|
|
3713
4097
|
phone: "That doesn’t look like a valid phone number",
|
|
3714
4098
|
url: "That doesn’t look like a valid URL"
|
|
3715
4099
|
};
|
|
3716
|
-
const PhoneSchema = string(errors.phone, [regex(/^\+?[0-9 -]+$/, errors.phone)]);
|
|
3717
4100
|
const inputFormatToProps = {
|
|
3718
4101
|
email: {
|
|
3719
4102
|
type: "email",
|
|
3720
4103
|
inputMode: "email",
|
|
3721
4104
|
formNoValidate: true
|
|
3722
4105
|
},
|
|
3723
|
-
phone: {
|
|
3724
|
-
type: "tel",
|
|
3725
|
-
inputMode: "tel"
|
|
3726
|
-
},
|
|
3727
4106
|
text: {
|
|
3728
4107
|
type: "text",
|
|
3729
4108
|
inputMode: "text"
|
|
@@ -3736,13 +4115,15 @@ const inputFormatToProps = {
|
|
|
3736
4115
|
};
|
|
3737
4116
|
const isTextSubmission = isSubmissionOfType("string");
|
|
3738
4117
|
const getResolver = (config) => {
|
|
3739
|
-
const
|
|
4118
|
+
const configErrors = {
|
|
4119
|
+
maxLength: `Please enter no more than ${config.maxChars ?? 999} characters`,
|
|
4120
|
+
minLength: `Please enter ${config.minChars ?? 1} or more characters`
|
|
4121
|
+
};
|
|
3740
4122
|
return i(object({
|
|
3741
4123
|
text: {
|
|
3742
|
-
email: string(errors.email, [email(errors.email), maxLength(config.maxChars ?? Infinity,
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
url: string([url(errors.url), maxLength(config.maxChars ?? Infinity, maxLengthError)])
|
|
4124
|
+
email: string(errors.email, [email(errors.email), minLength(config.minChars ?? 1, configErrors.minLength), maxLength(config.maxChars ?? Infinity, configErrors.maxLength)]),
|
|
4125
|
+
text: string([minLength(config.minChars ?? 1, configErrors.minLength), maxLength(config.maxChars ?? Infinity, configErrors.maxLength)]),
|
|
4126
|
+
url: string([url(errors.url), minLength(config.minChars ?? 1, configErrors.minLength), maxLength(config.maxChars ?? Infinity, configErrors.maxLength)])
|
|
3746
4127
|
}[config.format]
|
|
3747
4128
|
}));
|
|
3748
4129
|
};
|
|
@@ -3771,11 +4152,11 @@ const ChatInputText = ({
|
|
|
3771
4152
|
} = register("text", {
|
|
3772
4153
|
required: !input.config.optional
|
|
3773
4154
|
});
|
|
3774
|
-
const
|
|
4155
|
+
const inputRef = _$1();
|
|
3775
4156
|
y(() => {
|
|
3776
|
-
if (
|
|
3777
|
-
|
|
3778
|
-
|
|
4157
|
+
if (inputRef.current) {
|
|
4158
|
+
inputRef.current.focus();
|
|
4159
|
+
inputRef.current.select();
|
|
3779
4160
|
}
|
|
3780
4161
|
}, []);
|
|
3781
4162
|
return o$1("form", {
|
|
@@ -3790,7 +4171,7 @@ const ChatInputText = ({
|
|
|
3790
4171
|
children: [o$1("div", {
|
|
3791
4172
|
class: "flex items-center gap-2",
|
|
3792
4173
|
children: [o$1("div", {
|
|
3793
|
-
class: "relative min-w-0 flex-
|
|
4174
|
+
class: "relative min-w-0 flex-1",
|
|
3794
4175
|
children: [o$1("input", {
|
|
3795
4176
|
id: "chat-input",
|
|
3796
4177
|
...props,
|
|
@@ -3801,7 +4182,7 @@ const ChatInputText = ({
|
|
|
3801
4182
|
autoFocus: true,
|
|
3802
4183
|
ref: (element) => {
|
|
3803
4184
|
if (element) {
|
|
3804
|
-
|
|
4185
|
+
inputRef.current = element;
|
|
3805
4186
|
}
|
|
3806
4187
|
setRef(element);
|
|
3807
4188
|
},
|
|
@@ -3868,6 +4249,13 @@ const ChatInput = () => {
|
|
|
3868
4249
|
}, (props) => o$1(ChatInputText, {
|
|
3869
4250
|
onSubmitSuccess: chatStore.onSubmitSuccessFn$.value,
|
|
3870
4251
|
...props
|
|
4252
|
+
})).with({
|
|
4253
|
+
input: {
|
|
4254
|
+
type: "phone"
|
|
4255
|
+
}
|
|
4256
|
+
}, (props) => o$1(ChatInputPhoneNumber, {
|
|
4257
|
+
onSubmitSuccess: chatStore.onSubmitSuccessFn$.value,
|
|
4258
|
+
...props
|
|
3871
4259
|
})).with({
|
|
3872
4260
|
input: {
|
|
3873
4261
|
type: "multiple-choice"
|
|
@@ -4069,6 +4457,19 @@ const Conversation = ({
|
|
|
4069
4457
|
sizeKb: file.fileSizeKb
|
|
4070
4458
|
}
|
|
4071
4459
|
});
|
|
4460
|
+
}).with({
|
|
4461
|
+
type: "loading"
|
|
4462
|
+
}, (message2) => {
|
|
4463
|
+
const lastMessage = messages[messages.length - 1];
|
|
4464
|
+
const isLastMessage = message2 === lastMessage;
|
|
4465
|
+
if (!isLastMessage || chatStore.isBotTyping$.value)
|
|
4466
|
+
return null;
|
|
4467
|
+
return o$1("div", {
|
|
4468
|
+
class: "flex flex-grow flex-col items-center justify-center",
|
|
4469
|
+
children: o$1(LoadingIndicator, {
|
|
4470
|
+
class: "text-neutral-6 h-8 w-8"
|
|
4471
|
+
})
|
|
4472
|
+
});
|
|
4072
4473
|
}).exhaustive()
|
|
4073
4474
|
})
|
|
4074
4475
|
}, i2);
|