@bebranded/bb-contents 1.0.123 → 1.0.125

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.
Files changed (2) hide show
  1. package/bb-contents.js +38 -13
  2. 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.123
4
+ * @version 1.0.125
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.123');
35
+ console.log('bb-contents | v1.0.125');
36
36
 
37
37
  // Configuration
38
38
  const config = {
39
- version: '1.0.123',
39
+ version: '1.0.125',
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)
@@ -134,7 +134,6 @@
134
134
  try {
135
135
  module.init(scope);
136
136
  } catch (error) {
137
- console.error('[BB Contents] Erreur dans le module', moduleName, error);
138
137
  // Continuer avec les autres modules même si un échoue
139
138
  }
140
139
  }
@@ -603,7 +602,6 @@
603
602
  } else if (waitTimeout >= maxWaitTime) {
604
603
  // Timeout atteint : forcer le démarrage mais c'est un fallback
605
604
  if (bbContents.config.debug) {
606
- console.warn('[MARQUEE] Timeout atteint, certaines images peuvent ne pas être chargées');
607
605
  }
608
606
  const renderDelay = isSafari && isMobile ? 1500 : (isMobile ? 1000 : 200);
609
607
  setTimeout(() => {
@@ -1261,7 +1259,6 @@
1261
1259
  elements.forEach(function(element) {
1262
1260
  if (element.bbProcessed || element.hasAttribute('data-bb-country-select-processed')) return;
1263
1261
  if (element.tagName !== 'SELECT') {
1264
- bbContents.utils.log('bb-country-select doit être utilisé sur un élément <select>');
1265
1262
  return;
1266
1263
  }
1267
1264
  element.bbProcessed = true;
@@ -1291,11 +1288,21 @@
1291
1288
  defaultCountry = self.findCountry(element.value);
1292
1289
  }
1293
1290
 
1294
- // Trier les pays : préférés en haut
1291
+ // Trier les pays : préférés en haut dans l'ordre exact spécifié
1295
1292
  let sortedCountries = self.countries.slice();
1296
1293
  if (preferredCountries.length > 0) {
1297
- sortedCountries = sortedCountries.filter(function(c) {
1298
- return preferredCountries.indexOf(c.alpha2) !== -1;
1294
+ // Créer un map pour l'ordre des préférés
1295
+ const preferredOrder = {};
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) {
1301
+ return self.countries.find(function(c) {
1302
+ return c.alpha2 === code;
1303
+ });
1304
+ }).filter(function(c) {
1305
+ return c !== undefined;
1299
1306
  }).concat(sortedCountries.filter(function(c) {
1300
1307
  return preferredCountries.indexOf(c.alpha2) === -1;
1301
1308
  }));
@@ -1327,6 +1334,9 @@
1327
1334
  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>';
1328
1335
  trigger.style.cssText = 'display: flex; align-items: center; justify-content: space-between; width: 100%; 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;';
1329
1336
 
1337
+ // Variable pour stocker le pays sélectionné (pour chaque instance)
1338
+ let currentSelectedCountry = defaultCountry;
1339
+
1330
1340
  // Créer le popover
1331
1341
  const popover = document.createElement('div');
1332
1342
  popover.className = 'bb-country-select-popover';
@@ -1364,7 +1374,7 @@
1364
1374
  }
1365
1375
 
1366
1376
  list.innerHTML = countries.map(function(country) {
1367
- const isSelected = selectedCountry && selectedCountry.alpha2 === country.alpha2;
1377
+ const isSelected = currentSelectedCountry && currentSelectedCountry.alpha2 === country.alpha2;
1368
1378
  return '<div class="bb-country-item" data-country="' + country.alpha2 + '" role="option" aria-selected="' + (isSelected ? 'true' : 'false') + '" style="display: flex; align-items: center; gap: 8px; padding: 8px 12px; cursor: pointer; font-size: inherit; font-family: inherit; transition: background-color 0.15s;' + (isSelected ? ' background-color: #f3f4f6;' : '') + '"><img src="https://hatscripts.github.io/circle-flags/flags/' + country.alpha2.toLowerCase() + '.svg" alt="' + bbContents.utils.sanitize(country.name[language]) + '" style="width: 20px; height: 20px; border-radius: 50%; object-fit: cover; flex-shrink: 0;"><span>' + bbContents.utils.sanitize(country.name[language]) + '</span></div>';
1369
1379
  }).join('');
1370
1380
 
@@ -1453,12 +1463,28 @@
1453
1463
  });
1454
1464
  if (!country) return;
1455
1465
 
1466
+ // Mettre à jour le pays sélectionné
1467
+ currentSelectedCountry = country;
1468
+
1456
1469
  // Mettre à jour l'affichage
1457
1470
  flagSpan.innerHTML = '<img src="https://hatscripts.github.io/circle-flags/flags/' + country.alpha2.toLowerCase() + '.svg" alt="' + bbContents.utils.sanitize(country.name[language]) + '" style="width: 20px; height: 20px; border-radius: 50%; object-fit: cover; flex-shrink: 0;">';
1458
1471
  nameSpan.textContent = country.name[language];
1459
1472
 
1460
- // Mettre à jour le select natif
1461
- element.value = country.alpha2;
1473
+ // Mettre à jour le select natif avec le nom du pays (pas le code ISO)
1474
+ const countryName = country.name[language];
1475
+ element.value = countryName;
1476
+ // Mettre aussi le texte de l'option
1477
+ const existingOption = Array.from(element.options).find(function(opt) {
1478
+ return opt.value === countryName;
1479
+ });
1480
+ if (!existingOption) {
1481
+ // Créer l'option si elle n'existe pas
1482
+ const newOption = document.createElement('option');
1483
+ newOption.value = countryName;
1484
+ newOption.textContent = countryName;
1485
+ element.innerHTML = '';
1486
+ element.appendChild(newOption);
1487
+ }
1462
1488
  const changeEvent = new Event('change', { bubbles: true });
1463
1489
  element.dispatchEvent(changeEvent);
1464
1490
 
@@ -1478,7 +1504,6 @@
1478
1504
  wrapper.setAttribute('data-bb-country-select-processed', 'true');
1479
1505
  });
1480
1506
 
1481
- bbContents.utils.log('Module CountrySelect initialisé:', elements.length, 'éléments');
1482
1507
  }
1483
1508
  },
1484
1509
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bebranded/bb-contents",
3
- "version": "1.0.123",
3
+ "version": "1.0.125",
4
4
  "description": "Contenus additionnels français pour Webflow",
5
5
  "main": "bb-contents.js",
6
6
  "scripts": {