@solidpepper/solidpepper-solidgeneration 0.2.1 → 0.2.3
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.
|
@@ -3445,19 +3445,16 @@ class DataSheetSVG {
|
|
|
3445
3445
|
newVal = '';
|
|
3446
3446
|
}
|
|
3447
3447
|
}
|
|
3448
|
-
let urlBase =
|
|
3449
|
-
if (jRowSku['skuImagesDetail'] != null &&
|
|
3450
|
-
jRowSku['skuImagesDetail'] != '') {
|
|
3451
|
-
if (jRowSku['skuImagesDetail'][0] != null &&
|
|
3452
|
-
jRowSku['skuImagesDetail'][0] != '') {
|
|
3453
|
-
urlBase = jRowSku['skuImagesDetail'][0].assetUrlOriginal;
|
|
3454
|
-
urlBase = urlBase.substring(0, urlBase.lastIndexOf('/') + 1);
|
|
3455
|
-
}
|
|
3456
|
-
}
|
|
3448
|
+
let urlBase = this.getUrlBase(jRowSku);
|
|
3457
3449
|
if (urlBase != null &&
|
|
3458
3450
|
urlBase != '' &&
|
|
3459
3451
|
newVal != null &&
|
|
3460
|
-
newVal != ''
|
|
3452
|
+
newVal != '' &&
|
|
3453
|
+
typeof newVal === 'string' &&
|
|
3454
|
+
!newVal.startsWith('http://') &&
|
|
3455
|
+
!newVal.startsWith('https://') &&
|
|
3456
|
+
!newVal.startsWith('data:') &&
|
|
3457
|
+
!newVal.startsWith('/')) {
|
|
3461
3458
|
newVal = urlBase + newVal;
|
|
3462
3459
|
}
|
|
3463
3460
|
}
|
|
@@ -3514,19 +3511,16 @@ class DataSheetSVG {
|
|
|
3514
3511
|
newVal = '';
|
|
3515
3512
|
}
|
|
3516
3513
|
}
|
|
3517
|
-
let urlBase =
|
|
3518
|
-
if (jRowSku['skuImagesDetail'] != null &&
|
|
3519
|
-
jRowSku['skuImagesDetail'] != '') {
|
|
3520
|
-
if (jRowSku['skuImagesDetail'][0] != null &&
|
|
3521
|
-
jRowSku['skuImagesDetail'][0] != '') {
|
|
3522
|
-
urlBase = jRowSku['skuImagesDetail'][0].assetUrlOriginal;
|
|
3523
|
-
urlBase = urlBase.substring(0, urlBase.lastIndexOf('/') + 1);
|
|
3524
|
-
}
|
|
3525
|
-
}
|
|
3514
|
+
let urlBase = this.getUrlBase(jRowSku);
|
|
3526
3515
|
if (urlBase != null &&
|
|
3527
3516
|
urlBase != '' &&
|
|
3528
3517
|
newVal != null &&
|
|
3529
|
-
newVal != ''
|
|
3518
|
+
newVal != '' &&
|
|
3519
|
+
typeof newVal === 'string' &&
|
|
3520
|
+
!newVal.startsWith('http://') &&
|
|
3521
|
+
!newVal.startsWith('https://') &&
|
|
3522
|
+
!newVal.startsWith('data:') &&
|
|
3523
|
+
!newVal.startsWith('/')) {
|
|
3530
3524
|
newVal = urlBase + newVal;
|
|
3531
3525
|
}
|
|
3532
3526
|
}
|
|
@@ -4377,20 +4371,79 @@ class DataSheetSVG {
|
|
|
4377
4371
|
let skuImagesDetail = [];
|
|
4378
4372
|
if (jRowSku &&
|
|
4379
4373
|
jRowSku['skuImagesDetail'] &&
|
|
4374
|
+
Array.isArray(jRowSku['skuImagesDetail']) &&
|
|
4380
4375
|
jRowSku['skuImagesDetail'].length > 0) {
|
|
4381
|
-
|
|
4382
|
-
|
|
4383
|
-
|
|
4384
|
-
|
|
4385
|
-
|
|
4376
|
+
const cleanNewVal = this.getCleanFilename(newVal);
|
|
4377
|
+
const cleanNewValNoExt = this.getFileNameWithoutExt(newVal).toLowerCase();
|
|
4378
|
+
skuImagesDetail = jRowSku['skuImagesDetail'].filter((image) => {
|
|
4379
|
+
if (!image)
|
|
4380
|
+
return false;
|
|
4381
|
+
if (image.assetName === newVal || image.assetGuid === newVal)
|
|
4382
|
+
return true;
|
|
4383
|
+
if (image.assetName && this.getCleanFilename(image.assetName).toLowerCase() === cleanNewVal.toLowerCase()) {
|
|
4384
|
+
return true;
|
|
4386
4385
|
}
|
|
4387
|
-
|
|
4388
|
-
|
|
4389
|
-
|
|
4386
|
+
if (image.assetName && this.getFileNameWithoutExt(image.assetName).toLowerCase() === cleanNewValNoExt) {
|
|
4387
|
+
return true;
|
|
4388
|
+
}
|
|
4389
|
+
const urls = [
|
|
4390
|
+
image.assetUrlOriginal,
|
|
4391
|
+
image.assetUrlMedium,
|
|
4392
|
+
image.assetUrlSmall,
|
|
4393
|
+
image.assetUrlBig,
|
|
4394
|
+
].filter(Boolean);
|
|
4395
|
+
for (const url of urls) {
|
|
4396
|
+
if (url === newVal)
|
|
4397
|
+
return true;
|
|
4398
|
+
if (this.getCleanFilename(url).toLowerCase() === cleanNewVal.toLowerCase())
|
|
4399
|
+
return true;
|
|
4400
|
+
if (this.getFileNameWithoutExt(url).toLowerCase() === cleanNewValNoExt)
|
|
4401
|
+
return true;
|
|
4402
|
+
}
|
|
4403
|
+
return false;
|
|
4404
|
+
});
|
|
4405
|
+
}
|
|
4406
|
+
if (skuImagesDetail.length === 0 && jRowSku && jRowSku['skuDefaultImage']) {
|
|
4407
|
+
const defaultImg = jRowSku['skuDefaultImage'];
|
|
4408
|
+
const cleanNewValNoExt = this.getFileNameWithoutExt(newVal).toLowerCase();
|
|
4409
|
+
const defaultNameNoExt = this.getFileNameWithoutExt(defaultImg.assetName || defaultImg.assetUrlOriginal || '').toLowerCase();
|
|
4410
|
+
if (!cleanNewValNoExt || cleanNewValNoExt === defaultNameNoExt || defaultImg.assetGuid === newVal) {
|
|
4411
|
+
skuImagesDetail = [defaultImg];
|
|
4412
|
+
}
|
|
4413
|
+
}
|
|
4414
|
+
if (skuImagesDetail.length > 0) {
|
|
4415
|
+
const matchedAsset = skuImagesDetail[0];
|
|
4416
|
+
if (this.DataSheet.preview &&
|
|
4417
|
+
this.DataSheet.imageFastPreview == true) {
|
|
4418
|
+
newVal = matchedAsset.assetUrlSmall || matchedAsset.assetUrlMedium || matchedAsset.assetUrlBig || matchedAsset.assetUrlOriginal || newVal;
|
|
4419
|
+
urlHD = matchedAsset.assetUrlOriginal || matchedAsset.assetUrlBig || matchedAsset.assetUrlMedium || matchedAsset.assetUrlSmall || newVal;
|
|
4420
|
+
}
|
|
4421
|
+
else if (this.DataSheet.highDefinition == false) {
|
|
4422
|
+
newVal = matchedAsset.assetUrlMedium || matchedAsset.assetUrlSmall || matchedAsset.assetUrlBig || matchedAsset.assetUrlOriginal || newVal;
|
|
4423
|
+
urlHD = matchedAsset.assetUrlOriginal || matchedAsset.assetUrlBig || matchedAsset.assetUrlMedium || matchedAsset.assetUrlSmall || newVal;
|
|
4424
|
+
}
|
|
4425
|
+
else {
|
|
4426
|
+
newVal = matchedAsset.assetUrlOriginal || matchedAsset.assetUrlBig || matchedAsset.assetUrlMedium || matchedAsset.assetUrlSmall || newVal;
|
|
4427
|
+
urlHD = matchedAsset.assetUrlOriginal || matchedAsset.assetUrlBig || matchedAsset.assetUrlMedium || matchedAsset.assetUrlSmall || newVal;
|
|
4428
|
+
}
|
|
4429
|
+
}
|
|
4430
|
+
else {
|
|
4431
|
+
let urlBase = this.getUrlBase(jRowSku);
|
|
4432
|
+
if (urlBase && typeof newVal === 'string' && !newVal.startsWith('http://') && !newVal.startsWith('https://') && !newVal.startsWith('data:') && !newVal.startsWith('/')) {
|
|
4433
|
+
newVal = urlBase + newVal;
|
|
4434
|
+
}
|
|
4435
|
+
urlHD = newVal;
|
|
4436
|
+
if (typeof newVal === 'string' &&
|
|
4437
|
+
(this.DataSheet.highDefinition == false || (this.DataSheet.preview && this.DataSheet.imageFastPreview == true))) {
|
|
4438
|
+
if (this.DataSheet.preview && this.DataSheet.imageFastPreview == true) {
|
|
4439
|
+
newVal = newVal
|
|
4440
|
+
.replace(/\/original\//i, '/small/')
|
|
4441
|
+
.replace(/\.[a-zA-Z0-9]+(?=\?|#|$)/i, '.webp');
|
|
4390
4442
|
}
|
|
4391
4443
|
else {
|
|
4392
|
-
newVal =
|
|
4393
|
-
|
|
4444
|
+
newVal = newVal
|
|
4445
|
+
.replace(/\/original\//i, '/medium/')
|
|
4446
|
+
.replace(/\.[a-zA-Z0-9]+(?=\?|#|$)/i, '.webp');
|
|
4394
4447
|
}
|
|
4395
4448
|
}
|
|
4396
4449
|
}
|
|
@@ -5043,6 +5096,42 @@ class DataSheetSVG {
|
|
|
5043
5096
|
let cleanActual = cleanValueForHide(actualValue).toLowerCase();
|
|
5044
5097
|
let cleanCompare = cleanValueForHide(compareVal).toLowerCase();
|
|
5045
5098
|
let shouldHide = false;
|
|
5099
|
+
// Vérifier si l'attribut est de type multiSelect
|
|
5100
|
+
const normAttr = attrName.toLowerCase().trim();
|
|
5101
|
+
const allAttrs = (this.DataSheet && this.DataSheet.attributes) || DataSheetSingleton.getInstance().attributes || [];
|
|
5102
|
+
const getAttrString = (val) => {
|
|
5103
|
+
if (!val)
|
|
5104
|
+
return '';
|
|
5105
|
+
if (typeof val === 'string')
|
|
5106
|
+
return val.toLowerCase().trim();
|
|
5107
|
+
if (typeof val === 'object' && val.fr)
|
|
5108
|
+
return String(val.fr).toLowerCase().trim();
|
|
5109
|
+
return String(val).toLowerCase().trim();
|
|
5110
|
+
};
|
|
5111
|
+
const matchedAttr = allAttrs.find((a) => (a && a.id && getAttrString(a.id) === normAttr) ||
|
|
5112
|
+
(a && a.attributeId && getAttrString(a.attributeId) === normAttr) ||
|
|
5113
|
+
(a && a.guid && getAttrString(a.guid) === normAttr) ||
|
|
5114
|
+
(a && a.attributeGuid && getAttrString(a.attributeGuid) === normAttr) ||
|
|
5115
|
+
(a && a.attributeName && getAttrString(a.attributeName) === normAttr) ||
|
|
5116
|
+
(a && a.code && getAttrString(a.code) === normAttr) ||
|
|
5117
|
+
(a && a.attributeCode && getAttrString(a.attributeCode) === normAttr));
|
|
5118
|
+
const isMultiSelectAttr = !!(matchedAttr &&
|
|
5119
|
+
(matchedAttr.attributeType === 'multiSelect' || matchedAttr.type === 'multiSelect'));
|
|
5120
|
+
let actualValues = [];
|
|
5121
|
+
if (isMultiSelectAttr) {
|
|
5122
|
+
if (Array.isArray(actualValue)) {
|
|
5123
|
+
actualValues = actualValue.map((v) => cleanValueForHide(v).toLowerCase().trim());
|
|
5124
|
+
}
|
|
5125
|
+
else if (cleanActual) {
|
|
5126
|
+
actualValues = cleanActual
|
|
5127
|
+
.split(/[#;,\n|]+/)
|
|
5128
|
+
.map((item) => item.trim())
|
|
5129
|
+
.filter((item) => item.length > 0);
|
|
5130
|
+
}
|
|
5131
|
+
}
|
|
5132
|
+
else {
|
|
5133
|
+
actualValues = [cleanActual];
|
|
5134
|
+
}
|
|
5046
5135
|
switch (op) {
|
|
5047
5136
|
case 'is_null':
|
|
5048
5137
|
shouldHide = cleanActual === '';
|
|
@@ -5051,10 +5140,14 @@ class DataSheetSVG {
|
|
|
5051
5140
|
shouldHide = cleanActual !== '';
|
|
5052
5141
|
break;
|
|
5053
5142
|
case 'equals':
|
|
5054
|
-
shouldHide =
|
|
5143
|
+
shouldHide = isMultiSelectAttr
|
|
5144
|
+
? actualValues.includes(cleanCompare)
|
|
5145
|
+
: cleanActual === cleanCompare;
|
|
5055
5146
|
break;
|
|
5056
5147
|
case 'not_equals':
|
|
5057
|
-
shouldHide =
|
|
5148
|
+
shouldHide = isMultiSelectAttr
|
|
5149
|
+
? !actualValues.includes(cleanCompare)
|
|
5150
|
+
: cleanActual !== cleanCompare;
|
|
5058
5151
|
break;
|
|
5059
5152
|
}
|
|
5060
5153
|
if (shouldHide) {
|
|
@@ -5115,6 +5208,56 @@ class DataSheetSVG {
|
|
|
5115
5208
|
const textareaElement = tempDiv.querySelector(`#${textareaId}`);
|
|
5116
5209
|
if (textareaElement) {
|
|
5117
5210
|
let parentFo = textareaElement.closest('foreignObject');
|
|
5211
|
+
const splitDivAtBr = (div) => {
|
|
5212
|
+
const br = div.querySelector('br');
|
|
5213
|
+
if (!br || !div.parentNode)
|
|
5214
|
+
return false;
|
|
5215
|
+
const nextDiv = div.cloneNode(true);
|
|
5216
|
+
let currInDiv = div.querySelector('br');
|
|
5217
|
+
while (currInDiv && currInDiv !== div) {
|
|
5218
|
+
const parent = currInDiv.parentNode;
|
|
5219
|
+
if (!parent)
|
|
5220
|
+
break;
|
|
5221
|
+
while (currInDiv.nextSibling) {
|
|
5222
|
+
parent.removeChild(currInDiv.nextSibling);
|
|
5223
|
+
}
|
|
5224
|
+
const toRemove = currInDiv;
|
|
5225
|
+
currInDiv = parent;
|
|
5226
|
+
if (toRemove.nodeName.toLowerCase() === 'br') {
|
|
5227
|
+
parent.removeChild(toRemove);
|
|
5228
|
+
}
|
|
5229
|
+
}
|
|
5230
|
+
let currInNext = nextDiv.querySelector('br');
|
|
5231
|
+
while (currInNext && currInNext !== nextDiv) {
|
|
5232
|
+
const parent = currInNext.parentNode;
|
|
5233
|
+
if (!parent)
|
|
5234
|
+
break;
|
|
5235
|
+
while (currInNext.previousSibling) {
|
|
5236
|
+
parent.removeChild(currInNext.previousSibling);
|
|
5237
|
+
}
|
|
5238
|
+
const toRemove = currInNext;
|
|
5239
|
+
currInNext = parent;
|
|
5240
|
+
if (toRemove.nodeName.toLowerCase() === 'br') {
|
|
5241
|
+
parent.removeChild(toRemove);
|
|
5242
|
+
}
|
|
5243
|
+
}
|
|
5244
|
+
div.parentNode.insertBefore(nextDiv, div.nextSibling);
|
|
5245
|
+
if (!nextDiv.textContent || !nextDiv.textContent.trim()) {
|
|
5246
|
+
nextDiv.remove();
|
|
5247
|
+
}
|
|
5248
|
+
return true;
|
|
5249
|
+
};
|
|
5250
|
+
let hasBr = true;
|
|
5251
|
+
while (hasBr) {
|
|
5252
|
+
hasBr = false;
|
|
5253
|
+
const divsWithBr = Array.from(textareaElement.querySelectorAll('div')).filter((d) => d.querySelector('br') !== null);
|
|
5254
|
+
for (const d of divsWithBr) {
|
|
5255
|
+
if (splitDivAtBr(d)) {
|
|
5256
|
+
hasBr = true;
|
|
5257
|
+
break;
|
|
5258
|
+
}
|
|
5259
|
+
}
|
|
5260
|
+
}
|
|
5118
5261
|
// Split long text wrapping into separate divs to prevent overlap and highlight blockiness
|
|
5119
5262
|
const lineDivs = Array.from(textareaElement.querySelectorAll('div')).filter((d) => {
|
|
5120
5263
|
return d.querySelectorAll('div').length === 0;
|
|
@@ -5833,6 +5976,11 @@ class DataSheetSVG {
|
|
|
5833
5976
|
getActualBlockHeight(svgContent, initialBlockHeight, blockY = 0) {
|
|
5834
5977
|
if (!svgContent)
|
|
5835
5978
|
return { actualHeight: initialBlockHeight, updatedSvg: svgContent };
|
|
5979
|
+
const hasVariantTable = /id=["']tableVariant["']/i.test(svgContent) ||
|
|
5980
|
+
/data-info=["']variantTable["']/i.test(svgContent);
|
|
5981
|
+
if (!hasVariantTable) {
|
|
5982
|
+
return { actualHeight: initialBlockHeight, updatedSvg: svgContent };
|
|
5983
|
+
}
|
|
5836
5984
|
let maxBottom = 0;
|
|
5837
5985
|
try {
|
|
5838
5986
|
// 1. Measure foreignObjects (tables, textareas, etc.)
|
|
@@ -5882,7 +6030,7 @@ class DataSheetSVG {
|
|
|
5882
6030
|
}
|
|
5883
6031
|
let calculatedHeight = initialBlockHeight;
|
|
5884
6032
|
if (maxBottom > 0) {
|
|
5885
|
-
calculatedHeight = Math.ceil(maxBottom - blockY);
|
|
6033
|
+
calculatedHeight = Math.max(initialBlockHeight, Math.ceil(maxBottom - blockY));
|
|
5886
6034
|
}
|
|
5887
6035
|
// Update background block rect height in svgContent if present
|
|
5888
6036
|
let updatedSvg = svgContent;
|
|
@@ -6330,6 +6478,47 @@ class DataSheetSVG {
|
|
|
6330
6478
|
el.setAttribute('y', newY.toString());
|
|
6331
6479
|
});
|
|
6332
6480
|
}
|
|
6481
|
+
getUrlBase(sku) {
|
|
6482
|
+
if (!sku)
|
|
6483
|
+
return '';
|
|
6484
|
+
if (Array.isArray(sku['skuImagesDetail']) &&
|
|
6485
|
+
sku['skuImagesDetail'].length > 0) {
|
|
6486
|
+
for (const img of sku['skuImagesDetail']) {
|
|
6487
|
+
if (!img)
|
|
6488
|
+
continue;
|
|
6489
|
+
const url = img.assetUrlOriginal ||
|
|
6490
|
+
img.assetUrlMedium ||
|
|
6491
|
+
img.assetUrlSmall ||
|
|
6492
|
+
img.assetUrlBig;
|
|
6493
|
+
if (url && typeof url === 'string' && url.includes('/')) {
|
|
6494
|
+
return url.substring(0, url.lastIndexOf('/') + 1);
|
|
6495
|
+
}
|
|
6496
|
+
}
|
|
6497
|
+
}
|
|
6498
|
+
if (sku['skuDefaultImage']) {
|
|
6499
|
+
const defaultImg = sku['skuDefaultImage'];
|
|
6500
|
+
const url = defaultImg.assetUrlOriginal ||
|
|
6501
|
+
defaultImg.assetUrlMedium ||
|
|
6502
|
+
defaultImg.assetUrlSmall ||
|
|
6503
|
+
defaultImg.assetUrlBig;
|
|
6504
|
+
if (url && typeof url === 'string' && url.includes('/')) {
|
|
6505
|
+
return url.substring(0, url.lastIndexOf('/') + 1);
|
|
6506
|
+
}
|
|
6507
|
+
}
|
|
6508
|
+
return '';
|
|
6509
|
+
}
|
|
6510
|
+
getCleanFilename(str) {
|
|
6511
|
+
if (!str || typeof str !== 'string')
|
|
6512
|
+
return '';
|
|
6513
|
+
const noQuery = str.split('?')[0].split('#')[0];
|
|
6514
|
+
const lastSlash = noQuery.lastIndexOf('/');
|
|
6515
|
+
return lastSlash !== -1 ? noQuery.substring(lastSlash + 1) : noQuery;
|
|
6516
|
+
}
|
|
6517
|
+
getFileNameWithoutExt(str) {
|
|
6518
|
+
const fn = this.getCleanFilename(str);
|
|
6519
|
+
const lastDot = fn.lastIndexOf('.');
|
|
6520
|
+
return lastDot !== -1 ? fn.substring(0, lastDot) : fn;
|
|
6521
|
+
}
|
|
6333
6522
|
}
|
|
6334
6523
|
|
|
6335
6524
|
class DataSheetSku {
|