adminforth 4.14.0 → 4.15.1

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.
@@ -70,8 +70,8 @@
70
70
  <div v-else-if="item.type === 'heading'" class="flex items-center justify-left px-3 pt-3 pb-1 text-xs font-medium tracking-wide text-lightSidebarHeading dark:text-darkSidebarHeading
71
71
  ">{{ item.label }}</div>
72
72
  <li v-else-if="item.children" class="af-sidebar-expand-container">
73
- <button @click="clickOnMenuItem(i)" type="button" class="af-sidebar-expand-button flex items-center w-full px-3 py-1.5 text-sm text-lightSidebarText rounded-default transition duration-75 group hover:bg-lightSidebarItemHover hover:text-lightSidebarTextHover dark:text-darkSidebarText dark:hover:bg-darkSidebarItemHover dark:hover:text-darkSidebarTextHover"
74
- :class="opened.includes(i) ? 'af-sidebar-dropdown-expanded' : 'af-sidebar-dropdown-collapsed'"
73
+ <button @click="clickOnMenuItem(item)" type="button" class="af-sidebar-expand-button flex items-center w-full px-3 py-1.5 text-sm text-lightSidebarText rounded-default transition duration-75 group hover:bg-lightSidebarItemHover hover:text-lightSidebarTextHover dark:text-darkSidebarText dark:hover:bg-darkSidebarItemHover dark:hover:text-darkSidebarTextHover"
74
+ :class="isGroupOpened(item) ? 'af-sidebar-dropdown-expanded' : 'af-sidebar-dropdown-collapsed'"
75
75
  :aria-controls="`dropdown-example${i}`"
76
76
  >
77
77
  <component v-if="item.icon" :is="getIcon(item.icon)" class="w-4 h-4 text-lightSidebarIcons group-hover:text-lightSidebarIconsHover transition duration-75 dark:group-hover:text-darkSidebarIconsHover dark:text-darkSidebarIcons" ></component>
@@ -90,12 +90,12 @@
90
90
  </span>
91
91
  </span>
92
92
 
93
- <IconChevronDown :class="{'rotate-180': opened.includes(i) }" class="w-3 h-3 text-lightSidebarIcons dark:text-darkSidebarIcons transition-transform duration-200" aria-hidden="true" />
93
+ <IconChevronDown :class="{'rotate-180': isGroupOpened(item) }" class="w-3 h-3 text-lightSidebarIcons dark:text-darkSidebarIcons transition-transform duration-200" aria-hidden="true" />
94
94
  </button>
95
95
 
96
96
  <div class="grid transition-[grid-template-rows,opacity] duration-200 ease-in-out"
97
- :class="opened.includes(i) ? 'grid-rows-[1fr] opacity-100' : 'grid-rows-[0fr] opacity-0'"
98
- :inert="!opened.includes(i)"
97
+ :class="isGroupOpened(item) ? 'grid-rows-[1fr] opacity-100' : 'grid-rows-[0fr] opacity-0'"
98
+ :inert="!isGroupOpened(item)"
99
99
  >
100
100
  <div class="min-h-0 overflow-hidden">
101
101
  <ul :id="`dropdown-example${i}`" role="none" class="af-sidebar-dropdown mt-0.5 ml-[1.25rem] pl-2 border-l border-lightSidebarDevider dark:border-darkSidebarDevider space-y-0.5">
@@ -119,9 +119,9 @@
119
119
  ">{{ item.label }}</div>
120
120
  <div v-else-if="item.type === 'heading' && !isSidebarHovering" class="opacity-0 w-1 h-8">{{ item.label }}</div>
121
121
  <li v-else-if="item.children" class="af-sidebar-expand-container">
122
- <button @click="clickOnMenuItem(i)" type="button" class="af-sidebar-expand-button relative flex items-center h-9 py-2 text-sm text-lightSidebarText rounded-default group hover:bg-lightSidebarItemHover hover:text-lightSidebarTextHover dark:text-darkSidebarText dark:hover:bg-darkSidebarItemHover dark:hover:text-darkSidebarTextHover"
122
+ <button @click="clickOnMenuItem(item)" type="button" class="af-sidebar-expand-button relative flex items-center h-9 py-2 text-sm text-lightSidebarText rounded-default group hover:bg-lightSidebarItemHover hover:text-lightSidebarTextHover dark:text-darkSidebarText dark:hover:bg-darkSidebarItemHover dark:hover:text-darkSidebarTextHover"
123
123
  :class="[
124
- opened.includes(i) ? 'af-sidebar-dropdown-expanded' : 'af-sidebar-dropdown-collapsed',
124
+ isGroupOpened(item) ? 'af-sidebar-dropdown-expanded' : 'af-sidebar-dropdown-collapsed',
125
125
  isSidebarIconOnly && !isSidebarHovering ? 'w-10 ml-1 px-3' : 'w-full px-3'
126
126
  ]"
127
127
  :aria-controls="`dropdown-example${i}`"
@@ -155,10 +155,10 @@
155
155
  </span>
156
156
  </span>
157
157
 
158
- <IconChevronDown :class="{'rotate-180': opened.includes(i) }" class="w-3 h-3 ml-2 absolute right-3 text-lightSidebarIcons dark:text-darkSidebarIcons transition-transform duration-200" aria-hidden="true" />
158
+ <IconChevronDown :class="{'rotate-180': isGroupOpened(item) }" class="w-3 h-3 ml-2 absolute right-3 text-lightSidebarIcons dark:text-darkSidebarIcons transition-transform duration-200" aria-hidden="true" />
159
159
  </button>
160
160
 
161
- <ul :id="`dropdown-example${i}`" role="none" class="af-sidebar-dropdown pt-0.5 space-y-0.5" :class="{ 'hidden': !opened.includes(i) }">
161
+ <ul :id="`dropdown-example${i}`" role="none" class="af-sidebar-dropdown pt-0.5 space-y-0.5" :class="{ 'hidden': !isGroupOpened(item) }">
162
162
  <template v-for="(child, j) in item.children" :key="`menu-${i}-${j}`">
163
163
  <li class="af-sidebar-menu-link">
164
164
  <MenuLink :item="child" isChild="true" @click="$emit('hideSidebar')" :isSidebarIconOnly="isSidebarIconOnly" :isSidebarHovering="isSidebarHovering"/>
@@ -314,7 +314,7 @@ import MenuLink from './MenuLink.vue';
314
314
  import { IconPanelLeftClose, IconPanelLeftOpen, IconChevronDown, IconX, IconCircleAlert } from '@iconify-prerendered/vue-lucide';
315
315
  import { getIcon, verySimpleHash, loadFile, getCustomComponent } from '@/utils';
316
316
  import { Tooltip } from '@/afcl';
317
- import type { AnnouncementBadgeResponse } from '@/types/Common';
317
+ import type { AnnouncementBadgeResponse, AdminForthConfigMenuItem } from '@/types/Common';
318
318
  import { useAdminforth } from '@/adminforth';
319
319
  import { useI18n } from 'vue-i18n';
320
320
 
@@ -338,8 +338,9 @@ const emit = defineEmits<{
338
338
 
339
339
  const coreStore = useCoreStore();
340
340
 
341
- //create a ref to store the opened menu items with ts type;
342
- const opened = ref<(string|number)[]>([]);
341
+ const OPENED_GROUPS_LS_KEY = 'afSidebarOpenedGroups';
342
+ // expanded/collapsed state of groups toggled by user, by itemId, untouched groups fall back to item.open
343
+ const openedGroups = ref<Record<string, boolean>>(JSON.parse(localStorage.getItem(OPENED_GROUPS_LS_KEY) || '{}'));
343
344
  const sidebarAside = ref(null);
344
345
 
345
346
  const smQuery = window.matchMedia('(min-width: 640px)');
@@ -390,21 +391,14 @@ function toggleSidebar() {
390
391
  }, 100);
391
392
  }
392
393
 
393
- function clickOnMenuItem(label: string | number) {
394
- if (opened.value.includes(label)) {
395
- opened.value = opened.value.filter((item) => item !== label);
396
- } else {
397
- opened.value.push(label);
398
- }
394
+ function isGroupOpened(item: AdminForthConfigMenuItem) {
395
+ return openedGroups.value[item.itemId!] ?? item.open;
399
396
  }
400
397
 
401
- watch(()=>coreStore.menu, () => {
402
- coreStore.menu.forEach((item, i) => {
403
- if (item.open) {
404
- opened.value.push(i);
405
- };
406
- });
407
- })
398
+ function clickOnMenuItem(item: AdminForthConfigMenuItem) {
399
+ openedGroups.value[item.itemId!] = !isGroupOpened(item);
400
+ localStorage.setItem(OPENED_GROUPS_LS_KEY, JSON.stringify(openedGroups.value));
401
+ }
408
402
 
409
403
 
410
404
 
@@ -455,11 +449,6 @@ onMounted(() => {
455
449
  isSidebarIconOnly.value = false;
456
450
  }
457
451
 
458
- coreStore.menu.forEach((item, i) => {
459
- if (item.open) {
460
- opened.value.push(i);
461
- };
462
- });
463
452
  // Emit initial state
464
453
  emit('sidebarStateChange', { isSidebarIconOnly: isSidebarIconOnly.value, isSidebarHovering: isSidebarHovering.value });
465
454
  })
@@ -25,6 +25,11 @@
25
25
  // }
26
26
  // }
27
27
 
28
+ // native parts the browser draws itself (page scrollbar, date picker popups) follow the dark theme
29
+ html.dark {
30
+ color-scheme: dark;
31
+ }
32
+
28
33
  body {
29
34
  -webkit-font-smoothing: antialiased;
30
35
  -moz-osx-font-smoothing: grayscale;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adminforth",
3
- "version": "4.14.0",
3
+ "version": "4.15.1",
4
4
  "description": "OpenSource Agent-Native forth-generation admin panel",
5
5
  "keywords": [
6
6
  "adminforth",