@henriquepetrelli/hp-design-system 1.1.17 → 1.1.19

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,17 +1423,23 @@ const props = __props;
1423
1423
 
1424
1424
  const emit = __emit;
1425
1425
 
1426
- const isDarkMode = ref(localStorage.getItem('theme') === 'dark');
1426
+ const getStoredTheme = () => localStorage.getItem('theme');
1427
+ const isStoredDark = () => getStoredTheme() === 'dark';
1428
+
1429
+ const isDarkMode = ref(isStoredDark());
1427
1430
 
1428
1431
  const applyTheme = (isDark) => {
1429
- const theme = isDark ? 'dark' : 'light';
1430
- document.documentElement.setAttribute('data-theme', theme);
1431
- localStorage.setItem('theme', theme);
1432
+ const root = document.documentElement;
1433
+
1434
+ root.classList.toggle('dark', isDark);
1435
+ root.classList.remove('light'); // light é o default via :root
1436
+
1437
+ localStorage.setItem('theme', isDark ? 'dark' : 'light');
1432
1438
  };
1433
1439
 
1434
1440
  const toggleTheme = () => {
1435
- emit('update:modelValue', isDarkMode.value);
1436
1441
  applyTheme(isDarkMode.value);
1442
+ emit('update:modelValue', isDarkMode.value);
1437
1443
  };
1438
1444
 
1439
1445
  const handleKeydown = () => {
@@ -1442,16 +1448,20 @@ const handleKeydown = () => {
1442
1448
  };
1443
1449
 
1444
1450
  onMounted(() => {
1445
- applyTheme(isDarkMode.value);
1451
+ const isDark = isStoredDark();
1452
+ isDarkMode.value = isDark;
1453
+ applyTheme(isDark);
1454
+ emit('update:modelValue', isDark);
1446
1455
  });
1447
1456
 
1448
1457
  watch(
1449
1458
  () => props.modelValue,
1450
1459
  (value) => {
1451
- isDarkMode.value = value;
1452
- applyTheme(value);
1453
- },
1454
- { immediate: true }
1460
+ if (value !== isDarkMode.value) {
1461
+ isDarkMode.value = value;
1462
+ applyTheme(value);
1463
+ }
1464
+ }
1455
1465
  );
1456
1466
 
1457
1467
  const computedLightBorderColor = computed(
@@ -1507,7 +1517,7 @@ return (_ctx, _cache) => {
1507
1517
  }
1508
1518
 
1509
1519
  };
1510
- const ThemeSwitcher = /*#__PURE__*/_export_sfc(_sfc_main$4, [['__scopeId',"data-v-8b3eb905"]]);
1520
+ const ThemeSwitcher = /*#__PURE__*/_export_sfc(_sfc_main$4, [['__scopeId',"data-v-ed2b100c"]]);
1511
1521
 
1512
1522
  const _hoisted_1$3 = { class: "input__fieldset" };
1513
1523
  const _hoisted_2$3 = {