@henriquepetrelli/hp-design-system 1.1.6 → 1.1.8

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.
@@ -1286,7 +1286,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
1286
1286
  const ToggleSwitch = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["__scopeId", "data-v-14c54b46"]]);
1287
1287
 
1288
1288
  const _hoisted_1$4 = { class: "theme-switcher-container" };
1289
- const _hoisted_2$4 = ["id", "checked", "aria-checked"];
1289
+ const _hoisted_2$4 = ["id", "aria-checked"];
1290
1290
  const _hoisted_3$4 = ["for", "onKeydown"];
1291
1291
 
1292
1292
 
@@ -1301,39 +1301,29 @@ const _sfc_main$4 = {
1301
1301
  type: String,
1302
1302
  default: () => `theme-${Math.random().toString(36).substring(2, 9)}`
1303
1303
  },
1304
- lightBorderColor: {
1305
- type: String,
1306
- default: ''
1307
- },
1308
- lightBackgroundColor: {
1309
- type: String,
1310
- default: ''
1311
- },
1312
- darkBorderColor: {
1313
- type: String,
1314
- default: ''
1315
- },
1316
- darkBackgroundColor: {
1317
- type: String,
1318
- default: ''
1319
- }
1304
+ lightBorderColor: String,
1305
+ lightBackgroundColor: String,
1306
+ darkBorderColor: String,
1307
+ darkBackgroundColor: String
1320
1308
  },
1321
- setup(__props) {
1309
+ emits: ['update:modelValue'],
1310
+ setup(__props, { emit: __emit }) {
1322
1311
 
1323
1312
  const props = __props;
1324
1313
 
1314
+ const emit = __emit;
1315
+
1325
1316
  const isDarkMode = ref(false);
1326
1317
 
1318
+ const applyTheme = (isDark) => {
1319
+ document.documentElement.classList.toggle('dark', isDark);
1320
+ document.documentElement.classList.toggle('light', !isDark);
1321
+ localStorage.setItem('theme', isDark ? 'dark' : 'light');
1322
+ };
1323
+
1327
1324
  const toggleTheme = () => {
1328
- if (isDarkMode.value) {
1329
- document.documentElement.classList.remove('light');
1330
- document.documentElement.classList.add('dark');
1331
- localStorage.setItem('theme', 'dark');
1332
- } else {
1333
- document.documentElement.classList.remove('dark');
1334
- document.documentElement.classList.add('light');
1335
- localStorage.setItem('theme', 'light');
1336
- }
1325
+ emit('update:modelValue', isDarkMode.value);
1326
+ applyTheme(isDarkMode.value);
1337
1327
  };
1338
1328
 
1339
1329
  const handleKeydown = () => {
@@ -1347,29 +1337,35 @@ onMounted(() => {
1347
1337
  (window.matchMedia('(prefers-color-scheme: dark)').matches
1348
1338
  ? 'dark'
1349
1339
  : 'light');
1340
+
1350
1341
  isDarkMode.value = savedTheme === 'dark';
1351
- if (isDarkMode.value) {
1352
- document.documentElement.classList.add('dark');
1353
- } else {
1354
- document.documentElement.classList.add('light');
1355
- }
1342
+ applyTheme(isDarkMode.value);
1356
1343
  });
1357
1344
 
1358
- const computedLightBorderColor = computed(() => {
1359
- return props.lightBorderColor || '#72cce3'
1360
- });
1345
+ watch(
1346
+ () => props.modelValue,
1347
+ (value) => {
1348
+ isDarkMode.value = value;
1349
+ applyTheme(value);
1350
+ },
1351
+ { immediate: true }
1352
+ );
1361
1353
 
1362
- const computedLightBackgroundColor = computed(() => {
1363
- return props.lightBackgroundColor || '#96dcee'
1364
- });
1354
+ const computedLightBorderColor = computed(
1355
+ () => props.lightBorderColor || '#72cce3'
1356
+ );
1365
1357
 
1366
- const computedDarkBorderColor = computed(() => {
1367
- return props.darkBorderColor || '#072f5f'
1368
- });
1358
+ const computedLightBackgroundColor = computed(
1359
+ () => props.lightBackgroundColor || '#96dcee'
1360
+ );
1369
1361
 
1370
- const computedDarkBackgroundColor = computed(() => {
1371
- return props.darkBackgroundColor || '#1261a0'
1372
- });
1362
+ const computedDarkBorderColor = computed(
1363
+ () => props.darkBorderColor || '#072f5f'
1364
+ );
1365
+
1366
+ const computedDarkBackgroundColor = computed(
1367
+ () => props.darkBackgroundColor || '#1261a0'
1368
+ );
1373
1369
 
1374
1370
  return (_ctx, _cache) => {
1375
1371
  return (openBlock(), createElementBlock("div", _hoisted_1$4, [
@@ -1378,7 +1374,6 @@ return (_ctx, _cache) => {
1378
1374
  id: __props.id,
1379
1375
  class: "toggle--checkbox",
1380
1376
  "onUpdate:modelValue": _cache[0] || (_cache[0] = $event => ((isDarkMode).value = $event)),
1381
- checked: __props.modelValue,
1382
1377
  onChange: toggleTheme,
1383
1378
  role: "switch",
1384
1379
  "aria-checked": isDarkMode.value,
@@ -1409,7 +1404,7 @@ return (_ctx, _cache) => {
1409
1404
  }
1410
1405
 
1411
1406
  };
1412
- const ThemeSwitcher = /*#__PURE__*/_export_sfc(_sfc_main$4, [['__scopeId',"data-v-715118dd"]]);
1407
+ const ThemeSwitcher = /*#__PURE__*/_export_sfc(_sfc_main$4, [['__scopeId',"data-v-699fb0fe"]]);
1413
1408
 
1414
1409
  const _hoisted_1$3 = { class: "input__fieldset" };
1415
1410
  const _hoisted_2$3 = {