@bebranded/bb-contents 1.0.131 → 1.0.133
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/bb-contents.js +97 -8
- package/package.json +1 -1
package/bb-contents.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* BeBranded Contents
|
|
3
3
|
* Contenus additionnels français pour Webflow
|
|
4
|
-
* @version 1.0.
|
|
4
|
+
* @version 1.0.133
|
|
5
5
|
* @author BeBranded
|
|
6
6
|
* @license MIT
|
|
7
7
|
* @website https://www.bebranded.xyz
|
|
@@ -32,11 +32,11 @@
|
|
|
32
32
|
window._bbContentsInitialized = true;
|
|
33
33
|
|
|
34
34
|
// Log de démarrage simple (une seule fois)
|
|
35
|
-
console.log('bb-contents | v1.0.
|
|
35
|
+
console.log('bb-contents | v1.0.133');
|
|
36
36
|
|
|
37
37
|
// Configuration
|
|
38
38
|
const config = {
|
|
39
|
-
version: '1.0.
|
|
39
|
+
version: '1.0.133',
|
|
40
40
|
debug: false, // Debug désactivé pour rendu propre
|
|
41
41
|
prefix: 'bb-', // utilisé pour générer les sélecteurs (data-bb-*)
|
|
42
42
|
youtubeEndpoint: null, // URL du worker YouTube (à définir par l'utilisateur)
|
|
@@ -1340,7 +1340,7 @@
|
|
|
1340
1340
|
});
|
|
1341
1341
|
}
|
|
1342
1342
|
|
|
1343
|
-
// Récupérer les
|
|
1343
|
+
// Récupérer les styles du select natif avant de le masquer
|
|
1344
1344
|
const selectComputedStyle = window.getComputedStyle(element);
|
|
1345
1345
|
const selectWidth = element.offsetWidth || parseFloat(selectComputedStyle.width) || 'auto';
|
|
1346
1346
|
const selectHeight = element.offsetHeight || parseFloat(selectComputedStyle.height) || 'auto';
|
|
@@ -1349,6 +1349,16 @@
|
|
|
1349
1349
|
const selectMinHeight = selectComputedStyle.minHeight !== 'none' ? selectComputedStyle.minHeight : null;
|
|
1350
1350
|
const selectMaxHeight = selectComputedStyle.maxHeight !== 'none' ? selectComputedStyle.maxHeight : null;
|
|
1351
1351
|
|
|
1352
|
+
// Récupérer les styles visuels du select pour les appliquer au dropdown custom
|
|
1353
|
+
const selectBgColor = selectComputedStyle.backgroundColor;
|
|
1354
|
+
const selectBorder = selectComputedStyle.border || selectComputedStyle.borderWidth + ' ' + selectComputedStyle.borderStyle + ' ' + selectComputedStyle.borderColor;
|
|
1355
|
+
const selectBorderColor = selectComputedStyle.borderColor;
|
|
1356
|
+
const selectBorderRadius = selectComputedStyle.borderRadius;
|
|
1357
|
+
const selectColor = selectComputedStyle.color;
|
|
1358
|
+
const selectFontSize = selectComputedStyle.fontSize;
|
|
1359
|
+
const selectFontFamily = selectComputedStyle.fontFamily;
|
|
1360
|
+
const selectPadding = selectComputedStyle.padding || (selectComputedStyle.paddingTop + ' ' + selectComputedStyle.paddingRight + ' ' + selectComputedStyle.paddingBottom + ' ' + selectComputedStyle.paddingLeft);
|
|
1361
|
+
|
|
1352
1362
|
// Créer le wrapper avec les dimensions du select
|
|
1353
1363
|
const wrapper = document.createElement('div');
|
|
1354
1364
|
wrapper.className = 'bb-country-select-wrapper';
|
|
@@ -1384,7 +1394,32 @@
|
|
|
1384
1394
|
'';
|
|
1385
1395
|
|
|
1386
1396
|
trigger.innerHTML = '<div style="display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0;"><span class="bb-country-flag" style="flex-shrink: 0;">' + selectedFlag + '</span><span class="bb-country-name" style="flex: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">' + bbContents.utils.sanitize(selectedName) + '</span></div><svg width="16" height="16" viewBox="0 0 16 16" fill="none" style="flex-shrink: 0; transition: transform 0.2s;"><path d="M4 6L8 10L12 6" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>';
|
|
1387
|
-
let triggerStyle = 'display: flex; align-items: center; justify-content: space-between;
|
|
1397
|
+
let triggerStyle = 'display: flex; align-items: center; justify-content: space-between; cursor: pointer; box-sizing: border-box; transition: border-color 0.2s;';
|
|
1398
|
+
// Appliquer les styles du select natif (récupérés depuis CET élément spécifique)
|
|
1399
|
+
if (selectBgColor && selectBgColor !== 'rgba(0, 0, 0, 0)' && selectBgColor !== 'transparent') {
|
|
1400
|
+
triggerStyle += ' background-color: ' + selectBgColor + ';';
|
|
1401
|
+
}
|
|
1402
|
+
if (selectBorder && selectBorder !== 'none' && selectBorder !== '0px none rgb(0, 0, 0)') {
|
|
1403
|
+
triggerStyle += ' border: ' + selectBorder + ';';
|
|
1404
|
+
} else if (selectBorderColor && selectBorderColor !== 'rgba(0, 0, 0, 0)') {
|
|
1405
|
+
triggerStyle += ' border-color: ' + selectBorderColor + ';';
|
|
1406
|
+
}
|
|
1407
|
+
if (selectBorderRadius && selectBorderRadius !== '0px') {
|
|
1408
|
+
triggerStyle += ' border-radius: ' + selectBorderRadius + ';';
|
|
1409
|
+
}
|
|
1410
|
+
// Toujours appliquer la couleur du texte (même si héritée)
|
|
1411
|
+
if (selectColor && selectColor !== 'rgba(0, 0, 0, 0)') {
|
|
1412
|
+
triggerStyle += ' color: ' + selectColor + ';';
|
|
1413
|
+
}
|
|
1414
|
+
if (selectFontSize) {
|
|
1415
|
+
triggerStyle += ' font-size: ' + selectFontSize + ';';
|
|
1416
|
+
}
|
|
1417
|
+
if (selectFontFamily) {
|
|
1418
|
+
triggerStyle += ' font-family: ' + selectFontFamily + ';';
|
|
1419
|
+
}
|
|
1420
|
+
if (selectPadding && selectPadding !== '0px') {
|
|
1421
|
+
triggerStyle += ' padding: ' + selectPadding + ';';
|
|
1422
|
+
}
|
|
1388
1423
|
// Utiliser les dimensions du select natif
|
|
1389
1424
|
if (selectWidth !== 'auto' && selectWidth > 0) {
|
|
1390
1425
|
triggerStyle += ' width: ' + selectWidth + 'px;';
|
|
@@ -1407,19 +1442,73 @@
|
|
|
1407
1442
|
const popover = document.createElement('div');
|
|
1408
1443
|
popover.className = 'bb-country-select-popover';
|
|
1409
1444
|
popover.setAttribute('role', 'listbox');
|
|
1410
|
-
|
|
1445
|
+
let popoverStyle = 'position: absolute; top: 100%; left: 0; right: 0; margin-top: 4px; max-height: 300px; overflow: hidden; display: none; z-index: 50;';
|
|
1446
|
+
// Appliquer les styles du select natif au popover
|
|
1447
|
+
if (selectBgColor && selectBgColor !== 'rgba(0, 0, 0, 0)' && selectBgColor !== 'transparent') {
|
|
1448
|
+
popoverStyle += ' background-color: ' + selectBgColor + ';';
|
|
1449
|
+
} else {
|
|
1450
|
+
popoverStyle += ' background-color: white;';
|
|
1451
|
+
}
|
|
1452
|
+
if (selectBorder && selectBorder !== 'none' && selectBorder !== '0px none rgb(0, 0, 0)') {
|
|
1453
|
+
popoverStyle += ' border: ' + selectBorder + ';';
|
|
1454
|
+
} else if (selectBorderColor && selectBorderColor !== 'rgba(0, 0, 0, 0)') {
|
|
1455
|
+
popoverStyle += ' border: 1px solid ' + selectBorderColor + ';';
|
|
1456
|
+
} else {
|
|
1457
|
+
popoverStyle += ' border: 1px solid #e5e7eb;';
|
|
1458
|
+
}
|
|
1459
|
+
if (selectBorderRadius && selectBorderRadius !== '0px') {
|
|
1460
|
+
popoverStyle += ' border-radius: ' + selectBorderRadius + ';';
|
|
1461
|
+
} else {
|
|
1462
|
+
popoverStyle += ' border-radius: 6px;';
|
|
1463
|
+
}
|
|
1464
|
+
popoverStyle += ' box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);';
|
|
1465
|
+
popover.style.cssText = popoverStyle;
|
|
1411
1466
|
|
|
1412
1467
|
// Barre de recherche
|
|
1413
1468
|
const searchWrapper = document.createElement('div');
|
|
1414
1469
|
searchWrapper.className = 'bb-country-search';
|
|
1415
|
-
|
|
1470
|
+
let searchWrapperStyle = 'position: sticky; top: 0; padding: 8px; z-index: 1;';
|
|
1471
|
+
if (selectBgColor && selectBgColor !== 'rgba(0, 0, 0, 0)' && selectBgColor !== 'transparent') {
|
|
1472
|
+
searchWrapperStyle += ' background-color: ' + selectBgColor + ';';
|
|
1473
|
+
} else {
|
|
1474
|
+
searchWrapperStyle += ' background-color: white;';
|
|
1475
|
+
}
|
|
1476
|
+
if (selectBorderColor && selectBorderColor !== 'rgba(0, 0, 0, 0)') {
|
|
1477
|
+
searchWrapperStyle += ' border-bottom: 1px solid ' + selectBorderColor + ';';
|
|
1478
|
+
} else {
|
|
1479
|
+
searchWrapperStyle += ' border-bottom: 1px solid #e5e7eb;';
|
|
1480
|
+
}
|
|
1481
|
+
searchWrapper.style.cssText = searchWrapperStyle;
|
|
1416
1482
|
|
|
1417
1483
|
const searchInput = document.createElement('input');
|
|
1418
1484
|
searchInput.type = 'text';
|
|
1419
1485
|
searchInput.className = 'bb-country-search-input';
|
|
1420
1486
|
searchInput.placeholder = searchPlaceholder;
|
|
1421
1487
|
searchInput.setAttribute('aria-label', searchPlaceholder);
|
|
1422
|
-
|
|
1488
|
+
let searchInputStyle = 'width: 100%; padding: 8px 12px; box-sizing: border-box;';
|
|
1489
|
+
if (selectFontSize) {
|
|
1490
|
+
searchInputStyle += ' font-size: ' + selectFontSize + ';';
|
|
1491
|
+
}
|
|
1492
|
+
if (selectFontFamily) {
|
|
1493
|
+
searchInputStyle += ' font-family: ' + selectFontFamily + ';';
|
|
1494
|
+
}
|
|
1495
|
+
if (selectColor) {
|
|
1496
|
+
searchInputStyle += ' color: ' + selectColor + ';';
|
|
1497
|
+
}
|
|
1498
|
+
if (selectBorderColor && selectBorderColor !== 'rgba(0, 0, 0, 0)') {
|
|
1499
|
+
searchInputStyle += ' border: 1px solid ' + selectBorderColor + ';';
|
|
1500
|
+
} else {
|
|
1501
|
+
searchInputStyle += ' border: 1px solid #e5e7eb;';
|
|
1502
|
+
}
|
|
1503
|
+
if (selectBorderRadius && selectBorderRadius !== '0px') {
|
|
1504
|
+
const borderRadiusValue = parseFloat(selectBorderRadius);
|
|
1505
|
+
if (!isNaN(borderRadiusValue)) {
|
|
1506
|
+
searchInputStyle += ' border-radius: ' + (borderRadiusValue * 0.75) + 'px;';
|
|
1507
|
+
}
|
|
1508
|
+
} else {
|
|
1509
|
+
searchInputStyle += ' border-radius: 4px;';
|
|
1510
|
+
}
|
|
1511
|
+
searchInput.style.cssText = searchInputStyle;
|
|
1423
1512
|
|
|
1424
1513
|
searchWrapper.appendChild(searchInput);
|
|
1425
1514
|
popover.appendChild(searchWrapper);
|