@henriquepetrelli/hp-design-system 1.1.16 → 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.
@@ -1423,24 +1423,22 @@ const props = __props;
1423
1423
 
1424
1424
  const emit = __emit;
1425
1425
 
1426
- const isDarkMode = ref(
1427
- typeof window !== 'undefined' && localStorage.getItem('theme') === 'dark'
1428
- );
1429
-
1430
- const applyTheme = (isDark) => {
1431
- if (typeof document === 'undefined') return
1432
-
1433
- const theme = isDark ? 'dark' : 'light';
1426
+ /**
1427
+ * 🔑 Fonte única da verdade
1428
+ */
1429
+ const getInitialTheme = () => localStorage.getItem('theme') === 'dark';
1434
1430
 
1435
- document.documentElement.classList.remove('dark', 'light');
1436
- document.documentElement.classList.add(theme);
1431
+ const isDarkMode = ref(getInitialTheme());
1437
1432
 
1438
- localStorage.setItem('theme', theme);
1433
+ const applyTheme = (isDark) => {
1434
+ document.documentElement.classList.toggle('dark', isDark);
1435
+ document.documentElement.classList.toggle('light', !isDark);
1436
+ localStorage.setItem('theme', isDark ? 'dark' : 'light');
1439
1437
  };
1440
1438
 
1441
1439
  const toggleTheme = () => {
1442
- emit('update:modelValue', isDarkMode.value);
1443
1440
  applyTheme(isDarkMode.value);
1441
+ emit('update:modelValue', isDarkMode.value);
1444
1442
  };
1445
1443
 
1446
1444
  const handleKeydown = () => {
@@ -1448,13 +1446,23 @@ const handleKeydown = () => {
1448
1446
  toggleTheme();
1449
1447
  };
1450
1448
 
1449
+ /**
1450
+ * ✅ Sincroniza o toggle com o tema real após F5
1451
+ */
1452
+ onMounted(() => {
1453
+ const isDark = getInitialTheme();
1454
+ isDarkMode.value = isDark;
1455
+ emit('update:modelValue', isDark);
1456
+ });
1457
+
1451
1458
  watch(
1452
1459
  () => props.modelValue,
1453
1460
  (value) => {
1454
- isDarkMode.value = value;
1455
- applyTheme(value);
1456
- },
1457
- { immediate: true }
1461
+ if (value !== isDarkMode.value) {
1462
+ isDarkMode.value = value;
1463
+ applyTheme(value);
1464
+ }
1465
+ }
1458
1466
  );
1459
1467
 
1460
1468
  const computedLightBorderColor = computed(
@@ -1510,7 +1518,7 @@ return (_ctx, _cache) => {
1510
1518
  }
1511
1519
 
1512
1520
  };
1513
- const ThemeSwitcher = /*#__PURE__*/_export_sfc(_sfc_main$4, [['__scopeId',"data-v-ba2225dd"]]);
1521
+ const ThemeSwitcher = /*#__PURE__*/_export_sfc(_sfc_main$4, [['__scopeId',"data-v-f9bbbf36"]]);
1514
1522
 
1515
1523
  const _hoisted_1$3 = { class: "input__fieldset" };
1516
1524
  const _hoisted_2$3 = {