@henriquepetrelli/hp-design-system 1.1.17 → 1.1.18

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.
@@ -1427,17 +1427,22 @@
1427
1427
 
1428
1428
  const emit = __emit;
1429
1429
 
1430
- const isDarkMode = vue.ref(localStorage.getItem('theme') === 'dark');
1430
+ /**
1431
+ * 🔑 Fonte única da verdade
1432
+ */
1433
+ const getInitialTheme = () => localStorage.getItem('theme') === 'dark';
1434
+
1435
+ const isDarkMode = vue.ref(getInitialTheme());
1431
1436
 
1432
1437
  const applyTheme = (isDark) => {
1433
- const theme = isDark ? 'dark' : 'light';
1434
- document.documentElement.setAttribute('data-theme', theme);
1435
- localStorage.setItem('theme', theme);
1438
+ document.documentElement.classList.toggle('dark', isDark);
1439
+ document.documentElement.classList.toggle('light', !isDark);
1440
+ localStorage.setItem('theme', isDark ? 'dark' : 'light');
1436
1441
  };
1437
1442
 
1438
1443
  const toggleTheme = () => {
1439
- emit('update:modelValue', isDarkMode.value);
1440
1444
  applyTheme(isDarkMode.value);
1445
+ emit('update:modelValue', isDarkMode.value);
1441
1446
  };
1442
1447
 
1443
1448
  const handleKeydown = () => {
@@ -1445,17 +1450,23 @@
1445
1450
  toggleTheme();
1446
1451
  };
1447
1452
 
1453
+ /**
1454
+ * ✅ Sincroniza o toggle com o tema real após F5
1455
+ */
1448
1456
  vue.onMounted(() => {
1449
- applyTheme(isDarkMode.value);
1457
+ const isDark = getInitialTheme();
1458
+ isDarkMode.value = isDark;
1459
+ emit('update:modelValue', isDark);
1450
1460
  });
1451
1461
 
1452
1462
  vue.watch(
1453
1463
  () => props.modelValue,
1454
1464
  (value) => {
1455
- isDarkMode.value = value;
1456
- applyTheme(value);
1457
- },
1458
- { immediate: true }
1465
+ if (value !== isDarkMode.value) {
1466
+ isDarkMode.value = value;
1467
+ applyTheme(value);
1468
+ }
1469
+ }
1459
1470
  );
1460
1471
 
1461
1472
  const computedLightBorderColor = vue.computed(
@@ -1511,7 +1522,7 @@
1511
1522
  }
1512
1523
 
1513
1524
  };
1514
- const ThemeSwitcher = /*#__PURE__*/_export_sfc(_sfc_main$4, [['__scopeId',"data-v-8b3eb905"]]);
1525
+ const ThemeSwitcher = /*#__PURE__*/_export_sfc(_sfc_main$4, [['__scopeId',"data-v-f9bbbf36"]]);
1515
1526
 
1516
1527
  const _hoisted_1$3 = { class: "input__fieldset" };
1517
1528
  const _hoisted_2$3 = {