@bebranded/bb-contents 1.0.125 → 1.0.127
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 +65 -16
- 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.127
|
|
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.127');
|
|
36
36
|
|
|
37
37
|
// Configuration
|
|
38
38
|
const config = {
|
|
39
|
-
version: '1.0.
|
|
39
|
+
version: '1.0.127',
|
|
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)
|
|
@@ -1288,30 +1288,65 @@
|
|
|
1288
1288
|
defaultCountry = self.findCountry(element.value);
|
|
1289
1289
|
}
|
|
1290
1290
|
|
|
1291
|
-
// Trier les pays : préférés en haut dans l'ordre exact
|
|
1291
|
+
// Trier les pays : préférés en haut dans l'ordre exact spécifié, puis les autres par ordre alphabétique
|
|
1292
1292
|
let sortedCountries = self.countries.slice();
|
|
1293
1293
|
if (preferredCountries.length > 0) {
|
|
1294
|
-
//
|
|
1295
|
-
const
|
|
1296
|
-
preferredCountries.forEach(function(code, index) {
|
|
1297
|
-
preferredOrder[code] = index;
|
|
1298
|
-
});
|
|
1299
|
-
// Trier : préférés dans l'ordre exact, puis les autres
|
|
1300
|
-
sortedCountries = preferredCountries.map(function(code) {
|
|
1294
|
+
// Pays préférés dans l'ordre exact spécifié
|
|
1295
|
+
const preferred = preferredCountries.map(function(code) {
|
|
1301
1296
|
return self.countries.find(function(c) {
|
|
1302
1297
|
return c.alpha2 === code;
|
|
1303
1298
|
});
|
|
1304
1299
|
}).filter(function(c) {
|
|
1305
1300
|
return c !== undefined;
|
|
1306
|
-
})
|
|
1301
|
+
});
|
|
1302
|
+
|
|
1303
|
+
// Pays non-préférés triés par ordre alphabétique
|
|
1304
|
+
const others = sortedCountries.filter(function(c) {
|
|
1307
1305
|
return preferredCountries.indexOf(c.alpha2) === -1;
|
|
1308
|
-
}))
|
|
1306
|
+
}).sort(function(a, b) {
|
|
1307
|
+
const nameA = a.name[language].toLowerCase();
|
|
1308
|
+
const nameB = b.name[language].toLowerCase();
|
|
1309
|
+
if (nameA < nameB) return -1;
|
|
1310
|
+
if (nameA > nameB) return 1;
|
|
1311
|
+
return 0;
|
|
1312
|
+
});
|
|
1313
|
+
|
|
1314
|
+
sortedCountries = preferred.concat(others);
|
|
1315
|
+
} else {
|
|
1316
|
+
// Tous les pays par ordre alphabétique si pas de préférés
|
|
1317
|
+
sortedCountries = sortedCountries.sort(function(a, b) {
|
|
1318
|
+
const nameA = a.name[language].toLowerCase();
|
|
1319
|
+
const nameB = b.name[language].toLowerCase();
|
|
1320
|
+
if (nameA < nameB) return -1;
|
|
1321
|
+
if (nameA > nameB) return 1;
|
|
1322
|
+
return 0;
|
|
1323
|
+
});
|
|
1309
1324
|
}
|
|
1310
1325
|
|
|
1311
|
-
//
|
|
1326
|
+
// Récupérer les dimensions du select natif avant de le masquer
|
|
1327
|
+
const selectComputedStyle = window.getComputedStyle(element);
|
|
1328
|
+
const selectWidth = element.offsetWidth || parseFloat(selectComputedStyle.width) || 'auto';
|
|
1329
|
+
const selectHeight = element.offsetHeight || parseFloat(selectComputedStyle.height) || 'auto';
|
|
1330
|
+
const selectMinWidth = selectComputedStyle.minWidth !== 'none' ? selectComputedStyle.minWidth : null;
|
|
1331
|
+
const selectMaxWidth = selectComputedStyle.maxWidth !== 'none' ? selectComputedStyle.maxWidth : null;
|
|
1332
|
+
const selectMinHeight = selectComputedStyle.minHeight !== 'none' ? selectComputedStyle.minHeight : null;
|
|
1333
|
+
const selectMaxHeight = selectComputedStyle.maxHeight !== 'none' ? selectComputedStyle.maxHeight : null;
|
|
1334
|
+
|
|
1335
|
+
// Créer le wrapper avec les dimensions du select
|
|
1312
1336
|
const wrapper = document.createElement('div');
|
|
1313
1337
|
wrapper.className = 'bb-country-select-wrapper';
|
|
1314
|
-
|
|
1338
|
+
let wrapperStyle = 'position: relative;';
|
|
1339
|
+
if (selectWidth !== 'auto' && selectWidth > 0) {
|
|
1340
|
+
wrapperStyle += ' width: ' + selectWidth + 'px;';
|
|
1341
|
+
}
|
|
1342
|
+
if (selectHeight !== 'auto' && selectHeight > 0) {
|
|
1343
|
+
wrapperStyle += ' min-height: ' + selectHeight + 'px;';
|
|
1344
|
+
}
|
|
1345
|
+
if (selectMinWidth) wrapperStyle += ' min-width: ' + selectMinWidth + ';';
|
|
1346
|
+
if (selectMaxWidth) wrapperStyle += ' max-width: ' + selectMaxWidth + ';';
|
|
1347
|
+
if (selectMinHeight) wrapperStyle += ' min-height: ' + selectMinHeight + ';';
|
|
1348
|
+
if (selectMaxHeight) wrapperStyle += ' max-height: ' + selectMaxHeight + ';';
|
|
1349
|
+
wrapper.style.cssText = wrapperStyle;
|
|
1315
1350
|
|
|
1316
1351
|
// Masquer le select natif mais le garder fonctionnel
|
|
1317
1352
|
const selectStyle = element.style.cssText || '';
|
|
@@ -1332,7 +1367,21 @@
|
|
|
1332
1367
|
'';
|
|
1333
1368
|
|
|
1334
1369
|
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>';
|
|
1335
|
-
|
|
1370
|
+
let triggerStyle = 'display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; border: 1px solid #e5e7eb; border-radius: 6px; background: white; cursor: pointer; font-size: inherit; font-family: inherit; color: inherit; transition: border-color 0.2s; box-sizing: border-box;';
|
|
1371
|
+
// Utiliser les dimensions du select natif
|
|
1372
|
+
if (selectWidth !== 'auto' && selectWidth > 0) {
|
|
1373
|
+
triggerStyle += ' width: ' + selectWidth + 'px;';
|
|
1374
|
+
} else {
|
|
1375
|
+
triggerStyle += ' width: 100%;';
|
|
1376
|
+
}
|
|
1377
|
+
if (selectHeight !== 'auto' && selectHeight > 0) {
|
|
1378
|
+
triggerStyle += ' height: ' + selectHeight + 'px;';
|
|
1379
|
+
}
|
|
1380
|
+
if (selectMinWidth) triggerStyle += ' min-width: ' + selectMinWidth + ';';
|
|
1381
|
+
if (selectMaxWidth) triggerStyle += ' max-width: ' + selectMaxWidth + ';';
|
|
1382
|
+
if (selectMinHeight) triggerStyle += ' min-height: ' + selectMinHeight + ';';
|
|
1383
|
+
if (selectMaxHeight) triggerStyle += ' max-height: ' + selectMaxHeight + ';';
|
|
1384
|
+
trigger.style.cssText = triggerStyle;
|
|
1336
1385
|
|
|
1337
1386
|
// Variable pour stocker le pays sélectionné (pour chaque instance)
|
|
1338
1387
|
let currentSelectedCountry = defaultCountry;
|