@yassirbenmoussa/aicommerce-sdk 1.9.0 → 1.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai-commerce.min.js +55 -35
- package/dist/index.cjs +37 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/index.mjs +37 -10
- package/dist/index.mjs.map +1 -1
- package/dist/widget.min.js +37 -17
- package/dist/widget.min.js.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -905,7 +905,7 @@ function createWidgetStyles(config) {
|
|
|
905
905
|
Embedded Mode Styles - ChatGPT Style
|
|
906
906
|
============================================ */
|
|
907
907
|
|
|
908
|
-
/* Embedded container -
|
|
908
|
+
/* Embedded container - starts small, grows to max-height, then scrolls */
|
|
909
909
|
#aicommerce-widget.aicommerce-embedded {
|
|
910
910
|
position: relative;
|
|
911
911
|
bottom: auto;
|
|
@@ -913,6 +913,7 @@ function createWidgetStyles(config) {
|
|
|
913
913
|
right: auto;
|
|
914
914
|
width: 100%;
|
|
915
915
|
height: auto;
|
|
916
|
+
min-height: 80px;
|
|
916
917
|
max-height: var(--aic-max-height, 600px);
|
|
917
918
|
display: flex;
|
|
918
919
|
flex-direction: column;
|
|
@@ -934,11 +935,12 @@ function createWidgetStyles(config) {
|
|
|
934
935
|
display: none !important;
|
|
935
936
|
}
|
|
936
937
|
|
|
937
|
-
/* Embedded mode: chat
|
|
938
|
+
/* Embedded mode: chat container grows with content */
|
|
938
939
|
.aicommerce-embedded .aicommerce-chat {
|
|
939
940
|
position: relative;
|
|
940
941
|
width: 100%;
|
|
941
942
|
height: auto;
|
|
943
|
+
max-height: 100%;
|
|
942
944
|
max-width: 100%;
|
|
943
945
|
border-radius: 0;
|
|
944
946
|
background: transparent;
|
|
@@ -957,13 +959,15 @@ function createWidgetStyles(config) {
|
|
|
957
959
|
pointer-events: auto !important;
|
|
958
960
|
}
|
|
959
961
|
|
|
960
|
-
/* Embedded mode: messages area -
|
|
962
|
+
/* Embedded mode: messages area - scrollable when content overflows */
|
|
961
963
|
.aicommerce-embedded .aicommerce-messages {
|
|
964
|
+
flex: 1 1 auto;
|
|
965
|
+
min-height: 0;
|
|
966
|
+
max-height: calc(var(--aic-max-height, 600px) - 100px);
|
|
962
967
|
display: flex;
|
|
963
968
|
flex-direction: column;
|
|
964
|
-
justify-content: flex-
|
|
969
|
+
justify-content: flex-start;
|
|
965
970
|
overflow-y: auto;
|
|
966
|
-
max-height: calc(var(--aic-max-height, 600px) - 100px);
|
|
967
971
|
padding: 16px;
|
|
968
972
|
max-width: 700px;
|
|
969
973
|
margin: 0 auto;
|
|
@@ -1088,19 +1092,28 @@ function createWidgetStyles(config) {
|
|
|
1088
1092
|
color: var(--aic-text);
|
|
1089
1093
|
}
|
|
1090
1094
|
|
|
1091
|
-
/* Embedded mode: product cards styling */
|
|
1095
|
+
/* Embedded mode: product cards styling - horizontal scroll like widget mode */
|
|
1092
1096
|
.aicommerce-embedded .aicommerce-products {
|
|
1093
1097
|
display: flex;
|
|
1094
|
-
flex-wrap:
|
|
1098
|
+
flex-wrap: nowrap;
|
|
1095
1099
|
gap: 12px;
|
|
1096
1100
|
margin-top: 12px;
|
|
1101
|
+
overflow-x: auto;
|
|
1102
|
+
padding-bottom: 8px;
|
|
1103
|
+
cursor: grab;
|
|
1104
|
+
scrollbar-width: none;
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1107
|
+
.aicommerce-embedded .aicommerce-products::-webkit-scrollbar {
|
|
1108
|
+
display: none;
|
|
1097
1109
|
}
|
|
1098
1110
|
|
|
1099
1111
|
.aicommerce-embedded .aicommerce-product-card {
|
|
1112
|
+
flex-shrink: 0;
|
|
1113
|
+
width: 180px;
|
|
1100
1114
|
background: var(--aic-bg);
|
|
1101
1115
|
border: 1px solid var(--aic-border);
|
|
1102
1116
|
border-radius: 12px;
|
|
1103
|
-
max-width: 180px;
|
|
1104
1117
|
}
|
|
1105
1118
|
|
|
1106
1119
|
/* Embedded mode: typing indicator */
|
|
@@ -1326,13 +1339,20 @@ function createWidget(config) {
|
|
|
1326
1339
|
render();
|
|
1327
1340
|
}
|
|
1328
1341
|
async function addToShopifyCart(variantId, quantity = 1) {
|
|
1342
|
+
let numericVariantId = variantId;
|
|
1343
|
+
if (variantId.includes("gid://")) {
|
|
1344
|
+
const match = variantId.match(/\/(\d+)$/);
|
|
1345
|
+
if (match) {
|
|
1346
|
+
numericVariantId = match[1];
|
|
1347
|
+
}
|
|
1348
|
+
}
|
|
1329
1349
|
const response = await fetch("/cart/add.js", {
|
|
1330
1350
|
method: "POST",
|
|
1331
1351
|
headers: {
|
|
1332
1352
|
"Content-Type": "application/json"
|
|
1333
1353
|
},
|
|
1334
1354
|
body: JSON.stringify({
|
|
1335
|
-
id:
|
|
1355
|
+
id: numericVariantId,
|
|
1336
1356
|
quantity
|
|
1337
1357
|
})
|
|
1338
1358
|
});
|
|
@@ -1424,7 +1444,7 @@ function createWidget(config) {
|
|
|
1424
1444
|
${msg.products && msg.products.length > 0 ? `
|
|
1425
1445
|
<div class="aicommerce-products">
|
|
1426
1446
|
${msg.products.map((product) => `
|
|
1427
|
-
<div class="aicommerce-product-card" data-product-id="${product.id}">
|
|
1447
|
+
<div class="aicommerce-product-card" data-product-id="${product.id}" data-variant-id="${product.variantId || ""}">
|
|
1428
1448
|
${product.image || product.imageUrl ? `
|
|
1429
1449
|
<img src="${product.image || product.imageUrl}" alt="${escapeHtml(product.name)}" class="aicommerce-product-image" />
|
|
1430
1450
|
` : `
|
|
@@ -1434,6 +1454,13 @@ function createWidget(config) {
|
|
|
1434
1454
|
<span class="aicommerce-product-name" title="${escapeHtml(product.name)}">${escapeHtml(product.name)}</span>
|
|
1435
1455
|
${product.description ? `<p class="aicommerce-product-desc">${escapeHtml(product.description)}</p>` : ""}
|
|
1436
1456
|
<span class="aicommerce-product-price">${formatPrice(product.price, product.currency)}</span>
|
|
1457
|
+
<button class="aicommerce-add-to-cart" data-product-id="${product.id}">
|
|
1458
|
+
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
1459
|
+
<circle cx="9" cy="21" r="1"/><circle cx="20" cy="21" r="1"/>
|
|
1460
|
+
<path d="M1 1h4l2.68 13.39a2 2 0 0 0 2 1.61h9.72a2 2 0 0 0 2-1.61L23 6H6"/>
|
|
1461
|
+
</svg>
|
|
1462
|
+
${resolvedConfig.addToCartText || "Add to Cart"}
|
|
1463
|
+
</button>
|
|
1437
1464
|
</div>
|
|
1438
1465
|
</div>
|
|
1439
1466
|
`).join("")}
|