@alfakit/vue 0.1.9 → 0.1.10

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.
Files changed (122) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/app/components.d.ts.map +1 -1
  3. package/dist/app/components.js +1 -0
  4. package/dist/app/components.js.map +1 -1
  5. package/dist/components/dev-tools/DevToolsInspector.js.map +1 -1
  6. package/dist/components/dev-tools/DevToolsInspector.vue.d.ts.map +1 -1
  7. package/dist/components/dev-tools/DevToolsInspector.vue_vue_type_script_setup_true_lang.js +1 -1
  8. package/dist/components/dev-tools/DevToolsInspector.vue_vue_type_script_setup_true_lang.js.map +1 -1
  9. package/dist/components/fields/CheckboxListField.js.map +1 -1
  10. package/dist/components/fields/CheckboxListField.vue.d.ts.map +1 -1
  11. package/dist/components/fields/CheckboxListField.vue_vue_type_script_setup_true_lang.js +2 -2
  12. package/dist/components/fields/CheckboxListField.vue_vue_type_script_setup_true_lang.js.map +1 -1
  13. package/dist/components/fields/DatePickerField.js.map +1 -1
  14. package/dist/components/fields/DatePickerField.vue.d.ts.map +1 -1
  15. package/dist/components/fields/DatePickerField.vue_vue_type_script_setup_true_lang.js +34 -32
  16. package/dist/components/fields/DatePickerField.vue_vue_type_script_setup_true_lang.js.map +1 -1
  17. package/dist/components/fields/RichEditorSuggestions.js.map +1 -1
  18. package/dist/components/fields/RichEditorSuggestions.vue.d.ts +1 -1
  19. package/dist/components/fields/RichEditorSuggestions.vue.d.ts.map +1 -1
  20. package/dist/components/fields/RichEditorSuggestions.vue_vue_type_script_setup_true_lang.js +29 -23
  21. package/dist/components/fields/RichEditorSuggestions.vue_vue_type_script_setup_true_lang.js.map +1 -1
  22. package/dist/components/fields/RichEditorToolbarGroup.js.map +1 -1
  23. package/dist/components/fields/RichEditorToolbarGroup.vue.d.ts.map +1 -1
  24. package/dist/components/fields/RichEditorToolbarGroup.vue_vue_type_script_setup_true_lang.js +9 -4
  25. package/dist/components/fields/RichEditorToolbarGroup.vue_vue_type_script_setup_true_lang.js.map +1 -1
  26. package/dist/components/file-manager/FileManagerView.js.map +1 -1
  27. package/dist/components/file-manager/FileManagerView.vue.d.ts.map +1 -1
  28. package/dist/components/file-manager/FileManagerView.vue_vue_type_script_setup_true_lang.js +5 -1
  29. package/dist/components/file-manager/FileManagerView.vue_vue_type_script_setup_true_lang.js.map +1 -1
  30. package/dist/components/layout/CalloutComponent.js.map +1 -1
  31. package/dist/components/layout/CalloutComponent.vue.d.ts.map +1 -1
  32. package/dist/components/layout/CalloutComponent.vue_vue_type_script_setup_true_lang.js +43 -39
  33. package/dist/components/layout/CalloutComponent.vue_vue_type_script_setup_true_lang.js.map +1 -1
  34. package/dist/components/layout/EmptyStateComponent.js.map +1 -1
  35. package/dist/components/layout/EmptyStateComponent.vue.d.ts.map +1 -1
  36. package/dist/components/layout/EmptyStateComponent.vue_vue_type_script_setup_true_lang.js +29 -26
  37. package/dist/components/layout/EmptyStateComponent.vue_vue_type_script_setup_true_lang.js.map +1 -1
  38. package/dist/components/layout/MixedContent.js.map +1 -1
  39. package/dist/components/layout/MixedContent.vue.d.ts +5 -3
  40. package/dist/components/layout/MixedContent.vue.d.ts.map +1 -1
  41. package/dist/components/layout/MixedContent.vue_vue_type_script_setup_true_lang.js +5 -4
  42. package/dist/components/layout/MixedContent.vue_vue_type_script_setup_true_lang.js.map +1 -1
  43. package/dist/components/layout/SectionComponent.js.map +1 -1
  44. package/dist/components/layout/SectionComponent.vue.d.ts.map +1 -1
  45. package/dist/components/layout/SectionComponent.vue_vue_type_script_setup_true_lang.js +12 -8
  46. package/dist/components/layout/SectionComponent.vue_vue_type_script_setup_true_lang.js.map +1 -1
  47. package/dist/components/notifications/NotificationsMenu.js.map +1 -1
  48. package/dist/components/notifications/NotificationsMenu.vue.d.ts.map +1 -1
  49. package/dist/components/notifications/NotificationsMenu.vue_vue_type_script_setup_true_lang.js +133 -104
  50. package/dist/components/notifications/NotificationsMenu.vue_vue_type_script_setup_true_lang.js.map +1 -1
  51. package/dist/components/panel/ShortcutsOverlay.js.map +1 -1
  52. package/dist/components/panel/ShortcutsOverlay.vue.d.ts.map +1 -1
  53. package/dist/components/panel/ShortcutsOverlay.vue_vue_type_script_setup_true_lang.js +20 -19
  54. package/dist/components/panel/ShortcutsOverlay.vue_vue_type_script_setup_true_lang.js.map +1 -1
  55. package/dist/components/table/ColumnManager.js.map +1 -1
  56. package/dist/components/table/ColumnManager.vue.d.ts.map +1 -1
  57. package/dist/components/table/ColumnManager.vue_vue_type_script_setup_true_lang.js +6 -6
  58. package/dist/components/table/ColumnManager.vue_vue_type_script_setup_true_lang.js.map +1 -1
  59. package/dist/components/table/Spreadsheet.js.map +1 -1
  60. package/dist/components/table/Spreadsheet.vue.d.ts.map +1 -1
  61. package/dist/components/table/Spreadsheet.vue_vue_type_script_setup_true_lang.js +37 -33
  62. package/dist/components/table/Spreadsheet.vue_vue_type_script_setup_true_lang.js.map +1 -1
  63. package/dist/components/translation-manager/TranslationManagerView.js.map +1 -1
  64. package/dist/components/translation-manager/TranslationManagerView.vue.d.ts.map +1 -1
  65. package/dist/components/translation-manager/TranslationManagerView.vue_vue_type_script_setup_true_lang.js +1 -1
  66. package/dist/components/translation-manager/TranslationManagerView.vue_vue_type_script_setup_true_lang.js.map +1 -1
  67. package/dist/components/ui/SidebarMenuButton.js.map +1 -1
  68. package/dist/components/ui/SidebarMenuButton.vue.d.ts.map +1 -1
  69. package/dist/components/ui/SidebarMenuButton.vue_vue_type_script_setup_true_lang.js +12 -12
  70. package/dist/components/ui/SidebarMenuButton.vue_vue_type_script_setup_true_lang.js.map +1 -1
  71. package/dist/components/widgets/StatCard.js.map +1 -1
  72. package/dist/components/widgets/StatCard.vue.d.ts.map +1 -1
  73. package/dist/components/widgets/StatCard.vue_vue_type_script_setup_true_lang.js +30 -30
  74. package/dist/components/widgets/StatCard.vue_vue_type_script_setup_true_lang.js.map +1 -1
  75. package/dist/eject-manifest.json +2 -2
  76. package/dist/pages/AlfakitPage.js.map +1 -1
  77. package/dist/pages/AlfakitPage.vue.d.ts.map +1 -1
  78. package/dist/pages/AlfakitPage.vue_vue_type_script_setup_true_lang.js +16 -19
  79. package/dist/pages/AlfakitPage.vue_vue_type_script_setup_true_lang.js.map +1 -1
  80. package/dist/standalone/AlfakitComponent.js.map +1 -1
  81. package/dist/standalone/AlfakitComponent.vue.d.ts.map +1 -1
  82. package/dist/standalone/AlfakitComponent.vue_vue_type_script_setup_true_lang.js +2 -2
  83. package/dist/standalone/AlfakitComponent.vue_vue_type_script_setup_true_lang.js.map +1 -1
  84. package/dist/standalone/runtime.d.ts.map +1 -1
  85. package/dist/standalone/runtime.js +25 -25
  86. package/dist/standalone/runtime.js.map +1 -1
  87. package/dist/standalone.css +2 -1
  88. package/dist/starter-kit/AlfakitStarterKitRoot.js.map +1 -1
  89. package/dist/starter-kit/AlfakitStarterKitRoot.vue.d.ts.map +1 -1
  90. package/dist/starter-kit/AlfakitStarterKitRoot.vue_vue_type_script_setup_true_lang.js +1 -1
  91. package/dist/starter-kit/AlfakitStarterKitRoot.vue_vue_type_script_setup_true_lang.js.map +1 -1
  92. package/dist/starter-kit/navigation.d.ts +6 -1
  93. package/dist/starter-kit/navigation.d.ts.map +1 -1
  94. package/dist/starter-kit/navigation.js +11 -10
  95. package/dist/starter-kit/navigation.js.map +1 -1
  96. package/dist/styles.css +2 -1
  97. package/dist/themes.css +4 -0
  98. package/package.json +2 -2
  99. package/src/app/components.ts +3 -0
  100. package/src/components/dev-tools/DevToolsInspector.vue +1 -1
  101. package/src/components/fields/CheckboxListField.vue +2 -2
  102. package/src/components/fields/DatePickerField.vue +1 -0
  103. package/src/components/fields/RichEditorSuggestions.vue +13 -6
  104. package/src/components/fields/RichEditorToolbarGroup.vue +16 -1
  105. package/src/components/file-manager/FileManagerView.vue +3 -1
  106. package/src/components/layout/CalloutComponent.vue +15 -2
  107. package/src/components/layout/EmptyStateComponent.vue +10 -1
  108. package/src/components/layout/MixedContent.vue +12 -4
  109. package/src/components/layout/SectionComponent.vue +20 -4
  110. package/src/components/notifications/NotificationsMenu.vue +45 -1
  111. package/src/components/panel/ShortcutsOverlay.vue +27 -22
  112. package/src/components/table/ColumnManager.vue +6 -4
  113. package/src/components/table/Spreadsheet.vue +9 -4
  114. package/src/components/translation-manager/TranslationManagerView.vue +1 -1
  115. package/src/components/ui/SidebarMenuButton.vue +6 -0
  116. package/src/components/widgets/StatCard.vue +6 -3
  117. package/src/pages/AlfakitPage.vue +13 -3
  118. package/src/standalone/AlfakitComponent.vue +8 -4
  119. package/src/standalone/runtime.ts +3 -0
  120. package/src/starter-kit/AlfakitStarterKitRoot.vue +3 -2
  121. package/src/starter-kit/navigation.ts +12 -1
  122. package/src/styles.css +2 -1
@@ -1 +1 @@
1
- {"version":3,"file":"NotificationsMenu.js","names":["_sfc_main","NotificationsMenu_vue_vue_type_script_setup_true_lang_default","NotificationsMenu_default"],"sources":["../../../src/components/notifications/NotificationsMenu.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport {\n NotificationCenter,\n notificationTintStyles,\n onDatabaseNotificationsSent,\n onOpenDatabaseNotifications,\n} from '@alfakit/core'\nimport { BellIcon, CheckCheckIcon, Trash2Icon } from '@lucide/vue'\nimport { computed, onMounted, onScopeDispose, ref, watch } from 'vue'\nimport { useStore } from '../../composables/use-store'\nimport { useDirection, useFormatter, usePanel, useT } from '../../context'\nimport { cssColor, textColorClasses } from '../../lib/colors'\nimport { Icon } from '../../lib/icons'\nimport { cn } from '../../lib/utils'\nimport Button from '../ui/Button.vue'\nimport Popover from '../ui/Popover.vue'\nimport PopoverContent from '../ui/PopoverContent.vue'\nimport PopoverTrigger from '../ui/PopoverTrigger.vue'\nimport ScrollArea from '../ui/ScrollArea.vue'\nimport Spinner from '../ui/Spinner.vue'\nimport NotificationActionButton from './NotificationActionButton.vue'\n\n/**\n * Bell menu for database notifications. It also opens when something calls\n * `openDatabaseNotifications()` (or an action with `->openDatabaseNotifications()`).\n * `variant=\"sidebar\"`: a full-width row with a label, for layouts that put it in the sidebar.\n */\nconst props = withDefaults(defineProps<{ variant?: 'topbar' | 'sidebar' }>(), {\n variant: 'topbar',\n})\nconst t = useT()\nconst direction = useDirection()\nconst panel = usePanel()\nconst config = computed(() => panel.value.databaseNotifications)\nconst endpoints = panel.value.endpoints\n\nconst center =\n endpoints.notifications && endpoints.notificationsReadAll && endpoints.notificationsDestroyAll\n ? new NotificationCenter(\n {\n notifications: endpoints.notifications,\n notificationsReadAll: endpoints.notificationsReadAll,\n notificationsDestroyAll: endpoints.notificationsDestroyAll,\n },\n config.value?.unreadCount ?? 0,\n )\n : null\n\nconst open = ref(false)\nconst state = useStore(\n center?.store ?? {\n get: () => ({ notifications: [], unreadCount: 0, loading: false, hasMore: false, page: 0 }),\n subscribe: () => () => {},\n },\n)\n\n// Polling starts in the browser only: a server render must not leave timers behind.\nonMounted(() => {\n watch(\n () => config.value?.pollingInterval,\n (interval) => center?.startPolling(interval),\n { immediate: true },\n )\n})\n\nwatch(open, (isOpen) => {\n if (isOpen) void center?.load()\n})\n\n// Every visit brings the server's unread count (another user after impersonating, or\n// notifications read in another tab): follow it instead of waiting for the next poll.\nwatch(\n () => config.value?.unreadCount,\n (count) => {\n if (center && typeof count === 'number' && count !== center.store.get().unreadCount) {\n center.store.update({ unreadCount: count })\n }\n },\n)\n\n// Realtime notifications announce stored ones, so the unread count updates right away.\nlet stopListening: (() => void) | null = null\nonMounted(() => {\n stopListening = center ? onDatabaseNotificationsSent(() => void center.load()) : null\n})\nonScopeDispose(() => stopListening?.())\n\n// `openDatabaseNotifications()`: opened from code or an action.\nlet stopOpenListener: (() => void) | null = null\nonMounted(() => {\n stopOpenListener = onOpenDatabaseNotifications(() => (open.value = true))\n})\nonScopeDispose(() => stopOpenListener?.())\n\nonScopeDispose(() => center?.stopPolling())\nconst format = useFormatter()\n</script>\n\n<template>\n <Popover v-if=\"config && center\" :open=\"open\" @update:open=\"open = $event\">\n <PopoverTrigger as-child>\n <Button\n v-if=\"props.variant === 'sidebar'\"\n type=\"button\"\n variant=\"ghost\"\n class=\"relative w-full justify-start gap-2 group-data-[collapsible=icon]:size-8 group-data-[collapsible=icon]:justify-center group-data-[collapsible=icon]:p-0\"\n data-slot=\"notifications-trigger\"\n data-variant=\"sidebar\"\n >\n <!-- In a collapsed (icon) sidebar only the bell and its badge stay visible. -->\n <Icon\n name=\"alfakit::panels.topbar.open-database-notifications-button\"\n :fallback=\"BellIcon\"\n />\n <span class=\"flex-1 text-start group-data-[collapsible=icon]:sr-only\">{{\n t('notifications', {}, 'Notifications')\n }}</span>\n <span\n v-if=\"state.unreadCount > 0\"\n class=\"bg-primary text-primary-foreground flex h-5 min-w-5 items-center justify-center rounded-full px-1 text-xs font-medium group-data-[collapsible=icon]:absolute group-data-[collapsible=icon]:-end-1 group-data-[collapsible=icon]:-top-1 group-data-[collapsible=icon]:h-4 group-data-[collapsible=icon]:min-w-4 group-data-[collapsible=icon]:text-[10px]\"\n >{{ state.unreadCount > 99 ? '99+' : state.unreadCount }}\n <span class=\"sr-only\">{{ t('unread_notifications', {}, 'unread') }}</span></span\n >\n </Button>\n <Button\n v-else\n type=\"button\"\n variant=\"ghost\"\n size=\"icon\"\n class=\"relative\"\n data-slot=\"notifications-trigger\"\n :aria-label=\"t('notifications', {}, 'Notifications')\"\n >\n <Icon\n name=\"alfakit::panels.topbar.open-database-notifications-button\"\n :fallback=\"BellIcon\"\n />\n <span\n v-if=\"state.unreadCount > 0\"\n class=\"bg-primary text-primary-foreground absolute -end-0.5 -top-0.5 flex h-4 min-w-4 items-center justify-center rounded-full px-1 text-[10px] font-medium\"\n >{{ state.unreadCount > 99 ? '99+' : state.unreadCount }}</span\n >\n </Button>\n </PopoverTrigger>\n <PopoverContent\n :align=\"props.variant === 'sidebar' ? 'start' : 'end'\"\n :side=\"props.variant === 'sidebar' ? (direction === 'rtl' ? 'left' : 'right') : 'bottom'\"\n class=\"w-80 p-0 sm:w-96\"\n >\n <div class=\"flex items-center justify-between border-b px-3 py-2\">\n <span class=\"text-sm font-semibold\">{{ t('notifications', {}, 'Notifications') }}</span>\n <div class=\"flex items-center gap-1\">\n <Button\n v-if=\"state.unreadCount > 0\"\n type=\"button\"\n variant=\"ghost\"\n size=\"icon-sm\"\n :title=\"t('mark_all_read', {}, 'Mark all as read')\"\n @click=\"void center.markAllAsRead()\"\n ><CheckCheckIcon\n /></Button>\n <Button\n v-if=\"state.notifications.length > 0\"\n type=\"button\"\n variant=\"ghost\"\n size=\"icon-sm\"\n :title=\"t('clear_notifications', {}, 'Clear notifications')\"\n @click=\"void center.clear()\"\n ><Trash2Icon\n /></Button>\n </div>\n </div>\n <ScrollArea class=\"max-h-96\">\n <div\n v-if=\"state.loading && state.notifications.length === 0\"\n class=\"flex justify-center py-8\"\n >\n <Spinner />\n </div>\n <p\n v-else-if=\"state.notifications.length === 0\"\n class=\"text-muted-foreground px-3 py-8 text-center text-sm\"\n >\n {{ t('no_notifications', {}, 'You have no notifications.') }}\n </p>\n <ul v-else class=\"divide-y\">\n <li\n v-for=\"notification in state.notifications\"\n :key=\"notification.id\"\n :class=\"cn('flex gap-3 px-3 py-3', !notification.readAt && 'bg-primary/5')\"\n :style=\"\n notification.color\n ? notificationTintStyles(cssColor(notification.color)).item\n : undefined\n \"\n >\n <Icon\n v-if=\"notification.icon\"\n :name=\"notification.icon\"\n :class=\"\n cn(\n 'mt-0.5 size-5 shrink-0',\n notification.iconColor && textColorClasses[notification.iconColor],\n )\n \"\n />\n <div class=\"flex min-w-0 flex-1 flex-col gap-1\">\n <div class=\"flex items-start justify-between gap-2\">\n <p class=\"text-sm font-medium\">{{ notification.title }}</p>\n <button\n v-if=\"!notification.readAt\"\n type=\"button\"\n class=\"focus-visible:ring-ring/50 -me-2 -mt-0.5 flex size-6 shrink-0 items-center justify-center rounded-full outline-none focus-visible:ring-[3px]\"\n :aria-label=\"t('mark_as_read', {}, 'Mark as read')\"\n @click=\"void center.markAsRead(notification.id)\"\n >\n <span class=\"bg-primary size-2 rounded-full\" aria-hidden=\"true\" />\n </button>\n </div>\n <p\n v-if=\"notification.body\"\n class=\"text-muted-foreground text-sm\"\n v-html=\"notification.body\"\n />\n <time v-if=\"notification.date\" class=\"text-muted-foreground text-xs\">{{\n format.relative(notification.date)\n }}</time>\n <div v-if=\"notification.actions\" class=\"flex flex-wrap gap-1\">\n <NotificationActionButton\n v-for=\"action in notification.actions\"\n :key=\"action.name\"\n :action=\"action\"\n :on-mark-as-read=\"() => void center!.markAsRead(notification.id)\"\n :on-mark-as-unread=\"() => void center!.markAsUnread(notification.id)\"\n />\n </div>\n </div>\n </li>\n </ul>\n <div\n v-if=\"state.hasMore && state.notifications.length > 0\"\n class=\"flex justify-center border-t p-2\"\n >\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n :disabled=\"state.loading\"\n @click=\"void center!.loadMore()\"\n >\n <Spinner v-if=\"state.loading\" />\n {{ t('load_more', {}, 'Load more') }}\n </Button>\n </div>\n </ScrollArea>\n </PopoverContent>\n </Popover>\n</template>\n"],"mappings":""}
1
+ {"version":3,"file":"NotificationsMenu.js","names":["_sfc_main","NotificationsMenu_vue_vue_type_script_setup_true_lang_default","NotificationsMenu_default"],"sources":["../../../src/components/notifications/NotificationsMenu.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport {\n NotificationCenter,\n notificationTintStyles,\n onDatabaseNotificationsSent,\n onOpenDatabaseNotifications,\n pwaStore,\n startPwa,\n togglePushNotifications,\n} from '@alfakit/core'\nimport { BellIcon, BellOffIcon, BellRingIcon, CheckCheckIcon, Trash2Icon } from '@lucide/vue'\nimport { computed, onMounted, onScopeDispose, ref, watch } from 'vue'\nimport { toast } from 'vue-sonner'\nimport { useStore } from '../../composables/use-store'\nimport { useDirection, useFormatter, usePanel, useT } from '../../context'\nimport { cssColor, textColorClasses } from '../../lib/colors'\nimport { Icon } from '../../lib/icons'\nimport { cn } from '../../lib/utils'\nimport Button from '../ui/Button.vue'\nimport Popover from '../ui/Popover.vue'\nimport PopoverContent from '../ui/PopoverContent.vue'\nimport PopoverTrigger from '../ui/PopoverTrigger.vue'\nimport ScrollArea from '../ui/ScrollArea.vue'\nimport Spinner from '../ui/Spinner.vue'\nimport NotificationActionButton from './NotificationActionButton.vue'\n\n/**\n * Bell menu for database notifications. It also opens when something calls\n * `openDatabaseNotifications()` (or an action with `->openDatabaseNotifications()`).\n * `variant=\"sidebar\"`: a full-width row with a label, for layouts that put it in the sidebar.\n */\nconst props = withDefaults(defineProps<{ variant?: 'topbar' | 'sidebar' }>(), {\n variant: 'topbar',\n})\nconst t = useT()\nconst direction = useDirection()\nconst panel = usePanel()\nconst config = computed(() => panel.value.databaseNotifications)\nconst endpoints = panel.value.endpoints\n\nconst center =\n endpoints.notifications && endpoints.notificationsReadAll && endpoints.notificationsDestroyAll\n ? new NotificationCenter(\n {\n notifications: endpoints.notifications,\n notificationsReadAll: endpoints.notificationsReadAll,\n notificationsDestroyAll: endpoints.notificationsDestroyAll,\n },\n config.value?.unreadCount ?? 0,\n )\n : null\n\nconst open = ref(false)\nconst state = useStore(\n center?.store ?? {\n get: () => ({ notifications: [], unreadCount: 0, loading: false, hasMore: false, page: 0 }),\n subscribe: () => () => {},\n },\n)\n\n// Polling starts in the browser only: a server render must not leave timers behind.\nonMounted(() => {\n watch(\n () => config.value?.pollingInterval,\n (interval) => center?.startPolling(interval),\n { immediate: true },\n )\n})\n\nwatch(open, (isOpen) => {\n if (isOpen) void center?.load()\n})\n\n// Every visit brings the server's unread count (another user after impersonating, or\n// notifications read in another tab): follow it instead of waiting for the next poll.\nwatch(\n () => config.value?.unreadCount,\n (count) => {\n if (center && typeof count === 'number' && count !== center.store.get().unreadCount) {\n center.store.update({ unreadCount: count })\n }\n },\n)\n\n// Realtime notifications announce stored ones, so the unread count updates right away.\nlet stopListening: (() => void) | null = null\nonMounted(() => {\n stopListening = center ? onDatabaseNotificationsSent(() => void center.load()) : null\n})\nonScopeDispose(() => stopListening?.())\n\n// `openDatabaseNotifications()`: opened from code or an action.\nlet stopOpenListener: (() => void) | null = null\nonMounted(() => {\n stopOpenListener = onOpenDatabaseNotifications(() => (open.value = true))\n})\nonScopeDispose(() => stopOpenListener?.())\n\nonScopeDispose(() => center?.stopPolling())\nconst format = useFormatter()\n\n// `pwa(push: true)` in a starter kit: the app's user menu has no AlfaKit entries, so Web\n// Push is turned on or off from the bell's menu.\nconst pwa = useStore(pwaStore)\nconst pushToggle = computed(\n () =>\n Boolean(panel.value.starterKit && panel.value.pwa?.push) && pwa.value.push !== 'unsupported',\n)\nonMounted(() => {\n if (panel.value.starterKit && panel.value.pwa?.push) startPwa(panel.value.pwa)\n})\nasync function togglePush() {\n const { message } = await togglePushNotifications()\n const text = t(message.key, {}, message.fallback)\n\n if (message.error) toast.error(text)\n else toast.success(text)\n}\n</script>\n\n<template>\n <Popover v-if=\"config && center\" :open=\"open\" @update:open=\"open = $event\">\n <PopoverTrigger as-child>\n <Button\n v-if=\"props.variant === 'sidebar'\"\n type=\"button\"\n variant=\"ghost\"\n class=\"relative w-full justify-start gap-2 group-data-[collapsible=icon]:size-8 group-data-[collapsible=icon]:justify-center group-data-[collapsible=icon]:p-0\"\n data-slot=\"notifications-trigger\"\n data-variant=\"sidebar\"\n >\n <!-- In a collapsed (icon) sidebar only the bell and its badge stay visible. -->\n <Icon\n name=\"alfakit::panels.topbar.open-database-notifications-button\"\n :fallback=\"BellIcon\"\n />\n <span class=\"flex-1 text-start group-data-[collapsible=icon]:sr-only\">{{\n t('notifications', {}, 'Notifications')\n }}</span>\n <span\n v-if=\"state.unreadCount > 0\"\n class=\"bg-primary text-primary-foreground flex h-5 min-w-5 items-center justify-center rounded-full px-1 text-xs font-medium group-data-[collapsible=icon]:absolute group-data-[collapsible=icon]:-end-1 group-data-[collapsible=icon]:-top-1 group-data-[collapsible=icon]:h-4 group-data-[collapsible=icon]:min-w-4 group-data-[collapsible=icon]:text-[10px]\"\n >{{ state.unreadCount > 99 ? '99+' : state.unreadCount }}\n <span class=\"sr-only\">{{ t('unread_notifications', {}, 'unread') }}</span></span\n >\n </Button>\n <Button\n v-else\n type=\"button\"\n variant=\"ghost\"\n size=\"icon\"\n class=\"relative\"\n data-slot=\"notifications-trigger\"\n :aria-label=\"t('notifications', {}, 'Notifications')\"\n >\n <Icon\n name=\"alfakit::panels.topbar.open-database-notifications-button\"\n :fallback=\"BellIcon\"\n />\n <span\n v-if=\"state.unreadCount > 0\"\n class=\"bg-primary text-primary-foreground absolute -end-0.5 -top-0.5 flex h-4 min-w-4 items-center justify-center rounded-full px-1 text-[10px] font-medium\"\n >{{ state.unreadCount > 99 ? '99+' : state.unreadCount }}</span\n >\n </Button>\n </PopoverTrigger>\n <PopoverContent\n :align=\"props.variant === 'sidebar' ? 'start' : 'end'\"\n :side=\"props.variant === 'sidebar' ? (direction === 'rtl' ? 'left' : 'right') : 'bottom'\"\n class=\"w-80 p-0 sm:w-96\"\n >\n <div class=\"flex items-center justify-between border-b px-3 py-2\">\n <span class=\"text-sm font-semibold\">{{ t('notifications', {}, 'Notifications') }}</span>\n <div class=\"flex items-center gap-1\">\n <Button\n v-if=\"pushToggle\"\n type=\"button\"\n variant=\"ghost\"\n size=\"icon-sm\"\n data-slot=\"pwa-push\"\n :disabled=\"pwa.pushBusy || pwa.push === 'denied'\"\n :title=\"\n pwa.push === 'subscribed'\n ? t('pwa.notifications.disable', {}, 'Turn off notifications')\n : t('pwa.notifications.enable', {}, 'Turn on notifications')\n \"\n :aria-label=\"\n pwa.push === 'subscribed'\n ? t('pwa.notifications.disable', {}, 'Turn off notifications')\n : t('pwa.notifications.enable', {}, 'Turn on notifications')\n \"\n @click=\"void togglePush()\"\n >\n <BellOffIcon v-if=\"pwa.push === 'subscribed'\" />\n <BellRingIcon v-else />\n </Button>\n <Button\n v-if=\"state.unreadCount > 0\"\n type=\"button\"\n variant=\"ghost\"\n size=\"icon-sm\"\n :title=\"t('mark_all_read', {}, 'Mark all as read')\"\n @click=\"void center.markAllAsRead()\"\n ><CheckCheckIcon\n /></Button>\n <Button\n v-if=\"state.notifications.length > 0\"\n type=\"button\"\n variant=\"ghost\"\n size=\"icon-sm\"\n :title=\"t('clear_notifications', {}, 'Clear notifications')\"\n @click=\"void center.clear()\"\n ><Trash2Icon\n /></Button>\n </div>\n </div>\n <ScrollArea class=\"max-h-96\">\n <div\n v-if=\"state.loading && state.notifications.length === 0\"\n class=\"flex justify-center py-8\"\n >\n <Spinner />\n </div>\n <p\n v-else-if=\"state.notifications.length === 0\"\n class=\"text-muted-foreground px-3 py-8 text-center text-sm\"\n >\n {{ t('no_notifications', {}, 'You have no notifications.') }}\n </p>\n <ul v-else class=\"divide-y\">\n <li\n v-for=\"notification in state.notifications\"\n :key=\"notification.id\"\n :class=\"cn('flex gap-3 px-3 py-3', !notification.readAt && 'bg-primary/5')\"\n :style=\"\n notification.color\n ? notificationTintStyles(cssColor(notification.color)).item\n : undefined\n \"\n >\n <Icon\n v-if=\"notification.icon\"\n :name=\"notification.icon\"\n :class=\"\n cn(\n 'mt-0.5 size-5 shrink-0',\n notification.iconColor && textColorClasses[notification.iconColor],\n )\n \"\n />\n <div class=\"flex min-w-0 flex-1 flex-col gap-1\">\n <div class=\"flex items-start justify-between gap-2\">\n <p class=\"text-sm font-medium\">{{ notification.title }}</p>\n <button\n v-if=\"!notification.readAt\"\n type=\"button\"\n class=\"focus-visible:ring-ring/50 -me-2 -mt-0.5 flex size-6 shrink-0 items-center justify-center rounded-full outline-none focus-visible:ring-[3px]\"\n :aria-label=\"t('mark_as_read', {}, 'Mark as read')\"\n @click=\"void center.markAsRead(notification.id)\"\n >\n <span class=\"bg-primary size-2 rounded-full\" aria-hidden=\"true\" />\n </button>\n </div>\n <p\n v-if=\"notification.body\"\n class=\"text-muted-foreground text-sm\"\n v-html=\"notification.body\"\n />\n <time v-if=\"notification.date\" class=\"text-muted-foreground text-xs\">{{\n format.relative(notification.date)\n }}</time>\n <div v-if=\"notification.actions\" class=\"flex flex-wrap gap-1\">\n <NotificationActionButton\n v-for=\"action in notification.actions\"\n :key=\"action.name\"\n :action=\"action\"\n :on-mark-as-read=\"() => void center!.markAsRead(notification.id)\"\n :on-mark-as-unread=\"() => void center!.markAsUnread(notification.id)\"\n />\n </div>\n </div>\n </li>\n </ul>\n <div\n v-if=\"state.hasMore && state.notifications.length > 0\"\n class=\"flex justify-center border-t p-2\"\n >\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n :disabled=\"state.loading\"\n @click=\"void center!.loadMore()\"\n >\n <Spinner v-if=\"state.loading\" />\n {{ t('load_more', {}, 'Load more') }}\n </Button>\n </div>\n </ScrollArea>\n </PopoverContent>\n </Popover>\n</template>\n"],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"NotificationsMenu.vue.d.ts","sourceRoot":"","sources":["../../../src/components/notifications/NotificationsMenu.vue"],"names":[],"mappings":"AAyRA;;;;GAIG;AACH,KAAK,WAAW,GAAG;IAAE,OAAO,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAA;CAAE,CAAC;;aAAvB,QAAQ,GAAG,SAAS;;AAomBnD,wBAOG"}
1
+ {"version":3,"file":"NotificationsMenu.vue.d.ts","sourceRoot":"","sources":["../../../src/components/notifications/NotificationsMenu.vue"],"names":[],"mappings":"AAyUA;;;;GAIG;AACH,KAAK,WAAW,GAAG;IAAE,OAAO,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAA;CAAE,CAAC;;aAAvB,QAAQ,GAAG,SAAS;;AAgsBnD,wBAOG"}
@@ -1,52 +1,53 @@
1
- import { useDirection as e, useFormatter as t, usePanel as ee, useT as te } from "../../context.js";
2
- import { cn as n } from "../../lib/utils.js";
3
- import { useStore as ne } from "../../composables/use-store.js";
4
- import { cssColor as r, textColorClasses as i } from "../../lib/colors.js";
5
- import a from "../../lib/Icon.js";
6
- import o from "../ui/Button2.js";
7
- import s from "../ui/Spinner.js";
8
- import re from "./NotificationActionButton.js";
9
- import c from "../ui/Popover.js";
10
- import l from "../ui/PopoverContent.js";
11
- import u from "../ui/PopoverTrigger.js";
12
- import d from "../ui/ScrollArea.js";
13
- import { NotificationCenter as f, notificationTintStyles as ie, onDatabaseNotificationsSent as ae, onOpenDatabaseNotifications as oe } from "@alfakit/core";
14
- import { Fragment as p, computed as se, createBlock as m, createCommentVNode as h, createElementBlock as g, createElementVNode as _, createTextVNode as v, createVNode as y, defineComponent as b, normalizeClass as x, normalizeStyle as ce, onMounted as S, onScopeDispose as C, openBlock as w, ref as le, renderList as T, toDisplayString as E, unref as D, watch as O, withCtx as k } from "vue";
15
- import { BellIcon as A, CheckCheckIcon as j, Trash2Icon as M } from "@lucide/vue";
1
+ import { useDirection as e, useFormatter as t, usePanel as ee, useT as n } from "../../context.js";
2
+ import { cn as r } from "../../lib/utils.js";
3
+ import { useStore as i } from "../../composables/use-store.js";
4
+ import { cssColor as a, textColorClasses as te } from "../../lib/colors.js";
5
+ import o from "../../lib/Icon.js";
6
+ import s from "../ui/Button2.js";
7
+ import c from "../ui/Spinner.js";
8
+ import ne from "./NotificationActionButton.js";
9
+ import re from "../ui/Popover.js";
10
+ import ie from "../ui/PopoverContent.js";
11
+ import l from "../ui/PopoverTrigger.js";
12
+ import u from "../ui/ScrollArea.js";
13
+ import { NotificationCenter as d, notificationTintStyles as ae, onDatabaseNotificationsSent as oe, onOpenDatabaseNotifications as se, pwaStore as ce, startPwa as le, togglePushNotifications as ue } from "@alfakit/core";
14
+ import { Fragment as f, computed as p, createBlock as m, createCommentVNode as h, createElementBlock as g, createElementVNode as _, createTextVNode as v, createVNode as y, defineComponent as b, normalizeClass as x, normalizeStyle as S, onMounted as C, onScopeDispose as w, openBlock as T, ref as de, renderList as E, toDisplayString as D, unref as O, watch as k, withCtx as A } from "vue";
15
+ import { BellIcon as j, BellOffIcon as M, BellRingIcon as N, CheckCheckIcon as P, Trash2Icon as F } from "@lucide/vue";
16
+ import { toast as I } from "vue-sonner";
16
17
  //#region src/components/notifications/NotificationsMenu.vue?vue&type=script&setup=true&lang.ts
17
- var N = { class: "flex-1 text-start group-data-[collapsible=icon]:sr-only" }, P = {
18
+ var L = { class: "flex-1 text-start group-data-[collapsible=icon]:sr-only" }, R = {
18
19
  key: 0,
19
20
  class: "bg-primary text-primary-foreground flex h-5 min-w-5 items-center justify-center rounded-full px-1 text-xs font-medium group-data-[collapsible=icon]:absolute group-data-[collapsible=icon]:-end-1 group-data-[collapsible=icon]:-top-1 group-data-[collapsible=icon]:h-4 group-data-[collapsible=icon]:min-w-4 group-data-[collapsible=icon]:text-[10px]"
20
- }, F = { class: "sr-only" }, I = {
21
+ }, z = { class: "sr-only" }, B = {
21
22
  key: 0,
22
23
  class: "bg-primary text-primary-foreground absolute -end-0.5 -top-0.5 flex h-4 min-w-4 items-center justify-center rounded-full px-1 text-[10px] font-medium"
23
- }, L = { class: "flex items-center justify-between border-b px-3 py-2" }, R = { class: "text-sm font-semibold" }, z = { class: "flex items-center gap-1" }, B = {
24
+ }, V = { class: "flex items-center justify-between border-b px-3 py-2" }, H = { class: "text-sm font-semibold" }, fe = { class: "flex items-center gap-1" }, pe = {
24
25
  key: 0,
25
26
  class: "flex justify-center py-8"
26
- }, ue = {
27
+ }, me = {
27
28
  key: 1,
28
29
  class: "text-muted-foreground px-3 py-8 text-center text-sm"
29
- }, V = {
30
+ }, he = {
30
31
  key: 2,
31
32
  class: "divide-y"
32
- }, H = { class: "flex min-w-0 flex-1 flex-col gap-1" }, U = { class: "flex items-start justify-between gap-2" }, de = { class: "text-sm font-medium" }, fe = ["aria-label", "onClick"], pe = ["innerHTML"], me = {
33
+ }, ge = { class: "flex min-w-0 flex-1 flex-col gap-1" }, _e = { class: "flex items-start justify-between gap-2" }, ve = { class: "text-sm font-medium" }, ye = ["aria-label", "onClick"], be = ["innerHTML"], xe = {
33
34
  key: 1,
34
35
  class: "text-muted-foreground text-xs"
35
- }, he = {
36
+ }, Se = {
36
37
  key: 2,
37
38
  class: "flex flex-wrap gap-1"
38
- }, ge = {
39
+ }, Ce = {
39
40
  key: 3,
40
41
  class: "flex justify-center border-t p-2"
41
- }, W = /*@__PURE__*/ b({
42
+ }, U = /*@__PURE__*/ b({
42
43
  __name: "NotificationsMenu",
43
44
  props: { variant: { default: "topbar" } },
44
45
  setup(b) {
45
- let W = b, G = te(), _e = e(), K = ee(), q = se(() => K.value.databaseNotifications), J = K.value.endpoints, Y = J.notifications && J.notificationsReadAll && J.notificationsDestroyAll ? new f({
46
- notifications: J.notifications,
47
- notificationsReadAll: J.notificationsReadAll,
48
- notificationsDestroyAll: J.notificationsDestroyAll
49
- }, q.value?.unreadCount ?? 0) : null, X = le(!1), Z = ne(Y?.store ?? {
46
+ let U = b, W = n(), we = e(), G = ee(), K = p(() => G.value.databaseNotifications), q = G.value.endpoints, J = q.notifications && q.notificationsReadAll && q.notificationsDestroyAll ? new d({
47
+ notifications: q.notifications,
48
+ notificationsReadAll: q.notificationsReadAll,
49
+ notificationsDestroyAll: q.notificationsDestroyAll
50
+ }, K.value?.unreadCount ?? 0) : null, Y = de(!1), X = i(J?.store ?? {
50
51
  get: () => ({
51
52
  notifications: [],
52
53
  unreadCount: 0,
@@ -56,29 +57,36 @@ var N = { class: "flex-1 text-start group-data-[collapsible=icon]:sr-only" }, P
56
57
  }),
57
58
  subscribe: () => () => {}
58
59
  });
59
- S(() => {
60
- O(() => q.value?.pollingInterval, (e) => Y?.startPolling(e), { immediate: !0 });
61
- }), O(X, (e) => {
62
- e && Y?.load();
63
- }), O(() => q.value?.unreadCount, (e) => {
64
- Y && typeof e == "number" && e !== Y.store.get().unreadCount && Y.store.update({ unreadCount: e });
60
+ C(() => {
61
+ k(() => K.value?.pollingInterval, (e) => J?.startPolling(e), { immediate: !0 });
62
+ }), k(Y, (e) => {
63
+ e && J?.load();
64
+ }), k(() => K.value?.unreadCount, (e) => {
65
+ J && typeof e == "number" && e !== J.store.get().unreadCount && J.store.update({ unreadCount: e });
65
66
  });
67
+ let Z = null;
68
+ C(() => {
69
+ Z = J ? oe(() => void J.load()) : null;
70
+ }), w(() => Z?.());
66
71
  let Q = null;
67
- S(() => {
68
- Q = Y ? ae(() => void Y.load()) : null;
69
- }), C(() => Q?.());
70
- let $ = null;
71
- S(() => {
72
- $ = oe(() => X.value = !0);
73
- }), C(() => $?.()), C(() => Y?.stopPolling());
74
- let ve = t();
75
- return (e, t) => q.value && D(Y) ? (w(), m(c, {
72
+ C(() => {
73
+ Q = se(() => Y.value = !0);
74
+ }), w(() => Q?.()), w(() => J?.stopPolling());
75
+ let Te = t(), $ = i(ce), Ee = p(() => !!(G.value.starterKit && G.value.pwa?.push) && $.value.push !== "unsupported");
76
+ C(() => {
77
+ G.value.starterKit && G.value.pwa?.push && le(G.value.pwa);
78
+ });
79
+ async function De() {
80
+ let { message: e } = await ue(), t = W(e.key, {}, e.fallback);
81
+ e.error ? I.error(t) : I.success(t);
82
+ }
83
+ return (e, t) => K.value && O(J) ? (T(), m(re, {
76
84
  key: 0,
77
- open: X.value,
78
- "onUpdate:open": t[3] ||= (e) => X.value = e
85
+ open: Y.value,
86
+ "onUpdate:open": t[4] ||= (e) => Y.value = e
79
87
  }, {
80
- default: k(() => [y(u, { "as-child": "" }, {
81
- default: k(() => [W.variant === "sidebar" ? (w(), m(o, {
88
+ default: A(() => [y(l, { "as-child": "" }, {
89
+ default: A(() => [U.variant === "sidebar" ? (T(), m(s, {
82
90
  key: 0,
83
91
  type: "button",
84
92
  variant: "ghost",
@@ -86,100 +94,121 @@ var N = { class: "flex-1 text-start group-data-[collapsible=icon]:sr-only" }, P
86
94
  "data-slot": "notifications-trigger",
87
95
  "data-variant": "sidebar"
88
96
  }, {
89
- default: k(() => [
90
- y(D(a), {
97
+ default: A(() => [
98
+ y(O(o), {
91
99
  name: "alfakit::panels.topbar.open-database-notifications-button",
92
- fallback: D(A)
100
+ fallback: O(j)
93
101
  }, null, 8, ["fallback"]),
94
- _("span", N, E(D(G)("notifications", {}, "Notifications")), 1),
95
- D(Z).unreadCount > 0 ? (w(), g("span", P, [v(E(D(Z).unreadCount > 99 ? "99+" : D(Z).unreadCount) + " ", 1), _("span", F, E(D(G)("unread_notifications", {}, "unread")), 1)])) : h("", !0)
102
+ _("span", L, D(O(W)("notifications", {}, "Notifications")), 1),
103
+ O(X).unreadCount > 0 ? (T(), g("span", R, [v(D(O(X).unreadCount > 99 ? "99+" : O(X).unreadCount) + " ", 1), _("span", z, D(O(W)("unread_notifications", {}, "unread")), 1)])) : h("", !0)
96
104
  ]),
97
105
  _: 1
98
- })) : (w(), m(o, {
106
+ })) : (T(), m(s, {
99
107
  key: 1,
100
108
  type: "button",
101
109
  variant: "ghost",
102
110
  size: "icon",
103
111
  class: "relative",
104
112
  "data-slot": "notifications-trigger",
105
- "aria-label": D(G)("notifications", {}, "Notifications")
113
+ "aria-label": O(W)("notifications", {}, "Notifications")
106
114
  }, {
107
- default: k(() => [y(D(a), {
115
+ default: A(() => [y(O(o), {
108
116
  name: "alfakit::panels.topbar.open-database-notifications-button",
109
- fallback: D(A)
110
- }, null, 8, ["fallback"]), D(Z).unreadCount > 0 ? (w(), g("span", I, E(D(Z).unreadCount > 99 ? "99+" : D(Z).unreadCount), 1)) : h("", !0)]),
117
+ fallback: O(j)
118
+ }, null, 8, ["fallback"]), O(X).unreadCount > 0 ? (T(), g("span", B, D(O(X).unreadCount > 99 ? "99+" : O(X).unreadCount), 1)) : h("", !0)]),
111
119
  _: 1
112
120
  }, 8, ["aria-label"]))]),
113
121
  _: 1
114
- }), y(l, {
115
- align: W.variant === "sidebar" ? "start" : "end",
116
- side: W.variant === "sidebar" ? D(_e) === "rtl" ? "left" : "right" : "bottom",
122
+ }), y(ie, {
123
+ align: U.variant === "sidebar" ? "start" : "end",
124
+ side: U.variant === "sidebar" ? O(we) === "rtl" ? "left" : "right" : "bottom",
117
125
  class: "w-80 p-0 sm:w-96"
118
126
  }, {
119
- default: k(() => [_("div", L, [_("span", R, E(D(G)("notifications", {}, "Notifications")), 1), _("div", z, [D(Z).unreadCount > 0 ? (w(), m(o, {
120
- key: 0,
121
- type: "button",
122
- variant: "ghost",
123
- size: "icon-sm",
124
- title: D(G)("mark_all_read", {}, "Mark all as read"),
125
- onClick: t[0] ||= (e) => void D(Y).markAllAsRead()
126
- }, {
127
- default: k(() => [y(D(j))]),
128
- _: 1
129
- }, 8, ["title"])) : h("", !0), D(Z).notifications.length > 0 ? (w(), m(o, {
130
- key: 1,
131
- type: "button",
132
- variant: "ghost",
133
- size: "icon-sm",
134
- title: D(G)("clear_notifications", {}, "Clear notifications"),
135
- onClick: t[1] ||= (e) => void D(Y).clear()
136
- }, {
137
- default: k(() => [y(D(M))]),
138
- _: 1
139
- }, 8, ["title"])) : h("", !0)])]), y(d, { class: "max-h-96" }, {
140
- default: k(() => [D(Z).loading && D(Z).notifications.length === 0 ? (w(), g("div", B, [y(s)])) : D(Z).notifications.length === 0 ? (w(), g("p", ue, E(D(G)("no_notifications", {}, "You have no notifications.")), 1)) : (w(), g("ul", V, [(w(!0), g(p, null, T(D(Z).notifications, (e) => (w(), g("li", {
127
+ default: A(() => [_("div", V, [_("span", H, D(O(W)("notifications", {}, "Notifications")), 1), _("div", fe, [
128
+ Ee.value ? (T(), m(s, {
129
+ key: 0,
130
+ type: "button",
131
+ variant: "ghost",
132
+ size: "icon-sm",
133
+ "data-slot": "pwa-push",
134
+ disabled: O($).pushBusy || O($).push === "denied",
135
+ title: O($).push === "subscribed" ? O(W)("pwa.notifications.disable", {}, "Turn off notifications") : O(W)("pwa.notifications.enable", {}, "Turn on notifications"),
136
+ "aria-label": O($).push === "subscribed" ? O(W)("pwa.notifications.disable", {}, "Turn off notifications") : O(W)("pwa.notifications.enable", {}, "Turn on notifications"),
137
+ onClick: t[0] ||= (e) => void De()
138
+ }, {
139
+ default: A(() => [O($).push === "subscribed" ? (T(), m(O(M), { key: 0 })) : (T(), m(O(N), { key: 1 }))]),
140
+ _: 1
141
+ }, 8, [
142
+ "disabled",
143
+ "title",
144
+ "aria-label"
145
+ ])) : h("", !0),
146
+ O(X).unreadCount > 0 ? (T(), m(s, {
147
+ key: 1,
148
+ type: "button",
149
+ variant: "ghost",
150
+ size: "icon-sm",
151
+ title: O(W)("mark_all_read", {}, "Mark all as read"),
152
+ onClick: t[1] ||= (e) => void O(J).markAllAsRead()
153
+ }, {
154
+ default: A(() => [y(O(P))]),
155
+ _: 1
156
+ }, 8, ["title"])) : h("", !0),
157
+ O(X).notifications.length > 0 ? (T(), m(s, {
158
+ key: 2,
159
+ type: "button",
160
+ variant: "ghost",
161
+ size: "icon-sm",
162
+ title: O(W)("clear_notifications", {}, "Clear notifications"),
163
+ onClick: t[2] ||= (e) => void O(J).clear()
164
+ }, {
165
+ default: A(() => [y(O(F))]),
166
+ _: 1
167
+ }, 8, ["title"])) : h("", !0)
168
+ ])]), y(u, { class: "max-h-96" }, {
169
+ default: A(() => [O(X).loading && O(X).notifications.length === 0 ? (T(), g("div", pe, [y(c)])) : O(X).notifications.length === 0 ? (T(), g("p", me, D(O(W)("no_notifications", {}, "You have no notifications.")), 1)) : (T(), g("ul", he, [(T(!0), g(f, null, E(O(X).notifications, (e) => (T(), g("li", {
141
170
  key: e.id,
142
- class: x(D(n)("flex gap-3 px-3 py-3", !e.readAt && "bg-primary/5")),
143
- style: ce(e.color ? D(ie)(D(r)(e.color)).item : void 0)
144
- }, [e.icon ? (w(), m(D(a), {
171
+ class: x(O(r)("flex gap-3 px-3 py-3", !e.readAt && "bg-primary/5")),
172
+ style: S(e.color ? O(ae)(O(a)(e.color)).item : void 0)
173
+ }, [e.icon ? (T(), m(O(o), {
145
174
  key: 0,
146
175
  name: e.icon,
147
- class: x(D(n)("mt-0.5 size-5 shrink-0", e.iconColor && D(i)[e.iconColor]))
148
- }, null, 8, ["name", "class"])) : h("", !0), _("div", H, [
149
- _("div", U, [_("p", de, E(e.title), 1), e.readAt ? h("", !0) : (w(), g("button", {
176
+ class: x(O(r)("mt-0.5 size-5 shrink-0", e.iconColor && O(te)[e.iconColor]))
177
+ }, null, 8, ["name", "class"])) : h("", !0), _("div", ge, [
178
+ _("div", _e, [_("p", ve, D(e.title), 1), e.readAt ? h("", !0) : (T(), g("button", {
150
179
  key: 0,
151
180
  type: "button",
152
181
  class: "focus-visible:ring-ring/50 -me-2 -mt-0.5 flex size-6 shrink-0 items-center justify-center rounded-full outline-none focus-visible:ring-[3px]",
153
- "aria-label": D(G)("mark_as_read", {}, "Mark as read"),
154
- onClick: (t) => void D(Y).markAsRead(e.id)
155
- }, [...t[4] ||= [_("span", {
182
+ "aria-label": O(W)("mark_as_read", {}, "Mark as read"),
183
+ onClick: (t) => void O(J).markAsRead(e.id)
184
+ }, [...t[5] ||= [_("span", {
156
185
  class: "bg-primary size-2 rounded-full",
157
186
  "aria-hidden": "true"
158
- }, null, -1)]], 8, fe))]),
159
- e.body ? (w(), g("p", {
187
+ }, null, -1)]], 8, ye))]),
188
+ e.body ? (T(), g("p", {
160
189
  key: 0,
161
190
  class: "text-muted-foreground text-sm",
162
191
  innerHTML: e.body
163
- }, null, 8, pe)) : h("", !0),
164
- e.date ? (w(), g("time", me, E(D(ve).relative(e.date)), 1)) : h("", !0),
165
- e.actions ? (w(), g("div", he, [(w(!0), g(p, null, T(e.actions, (t) => (w(), m(re, {
192
+ }, null, 8, be)) : h("", !0),
193
+ e.date ? (T(), g("time", xe, D(O(Te).relative(e.date)), 1)) : h("", !0),
194
+ e.actions ? (T(), g("div", Se, [(T(!0), g(f, null, E(e.actions, (t) => (T(), m(ne, {
166
195
  key: t.name,
167
196
  action: t,
168
- "on-mark-as-read": () => void D(Y).markAsRead(e.id),
169
- "on-mark-as-unread": () => void D(Y).markAsUnread(e.id)
197
+ "on-mark-as-read": () => void O(J).markAsRead(e.id),
198
+ "on-mark-as-unread": () => void O(J).markAsUnread(e.id)
170
199
  }, null, 8, [
171
200
  "action",
172
201
  "on-mark-as-read",
173
202
  "on-mark-as-unread"
174
203
  ]))), 128))])) : h("", !0)
175
- ])], 6))), 128))])), D(Z).hasMore && D(Z).notifications.length > 0 ? (w(), g("div", ge, [y(o, {
204
+ ])], 6))), 128))])), O(X).hasMore && O(X).notifications.length > 0 ? (T(), g("div", Ce, [y(s, {
176
205
  type: "button",
177
206
  variant: "ghost",
178
207
  size: "sm",
179
- disabled: D(Z).loading,
180
- onClick: t[2] ||= (e) => void D(Y).loadMore()
208
+ disabled: O(X).loading,
209
+ onClick: t[3] ||= (e) => void O(J).loadMore()
181
210
  }, {
182
- default: k(() => [D(Z).loading ? (w(), m(s, { key: 0 })) : h("", !0), v(" " + E(D(G)("load_more", {}, "Load more")), 1)]),
211
+ default: A(() => [O(X).loading ? (T(), m(c, { key: 0 })) : h("", !0), v(" " + D(O(W)("load_more", {}, "Load more")), 1)]),
183
212
  _: 1
184
213
  }, 8, ["disabled"])])) : h("", !0)]),
185
214
  _: 1
@@ -191,6 +220,6 @@ var N = { class: "flex-1 text-start group-data-[collapsible=icon]:sr-only" }, P
191
220
  }
192
221
  });
193
222
  //#endregion
194
- export { W as default };
223
+ export { U as default };
195
224
 
196
225
  //# sourceMappingURL=NotificationsMenu.vue_vue_type_script_setup_true_lang.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"NotificationsMenu.vue_vue_type_script_setup_true_lang.js","names":["_unref","_openBlock","_createBlock","Popover","_withCtx","_createVNode","PopoverTrigger","Button","Icon","_createElementVNode","_toDisplayString","_createElementBlock","_createTextVNode","_createCommentVNode","PopoverContent","ScrollArea","Spinner","_Fragment","_renderList","_normalizeClass","_normalizeStyle","NotificationActionButton","Icon_default","Button_default","Spinner_default","NotificationActionButton_default","Popover_default","PopoverContent_default","PopoverTrigger_default","ScrollArea_default","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","_hoisted_7","_hoisted_8","_hoisted_9","_hoisted_10","_hoisted_11","_hoisted_12","_hoisted_13","_hoisted_14","_hoisted_15","_hoisted_16","_hoisted_17","_hoisted_18","NotificationsMenu_vue_vue_type_script_setup_true_lang_default","props","__props","t","useT","direction","useDirection","panel","usePanel","config","computed","endpoints","center","NotificationCenter","open","ref","state","useStore","onMounted","interval","watch","isOpen","count","stopListening","onDatabaseNotificationsSent","onScopeDispose","stopOpenListener","onOpenDatabaseNotifications","format","useFormatter","unref","openBlock","createBlock","_cache","$event","withCtx","createVNode","BellIcon","createElementVNode","toDisplayString","createElementBlock","createTextVNode","createCommentVNode","CheckCheckIcon","Trash2Icon","Fragment","renderList","notification","normalizeClass","cn","normalizeStyle","notificationTintStyles","cssColor","textColorClasses","action"],"sources":["../../../src/components/notifications/NotificationsMenu.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport {\n NotificationCenter,\n notificationTintStyles,\n onDatabaseNotificationsSent,\n onOpenDatabaseNotifications,\n} from '@alfakit/core'\nimport { BellIcon, CheckCheckIcon, Trash2Icon } from '@lucide/vue'\nimport { computed, onMounted, onScopeDispose, ref, watch } from 'vue'\nimport { useStore } from '../../composables/use-store'\nimport { useDirection, useFormatter, usePanel, useT } from '../../context'\nimport { cssColor, textColorClasses } from '../../lib/colors'\nimport { Icon } from '../../lib/icons'\nimport { cn } from '../../lib/utils'\nimport Button from '../ui/Button.vue'\nimport Popover from '../ui/Popover.vue'\nimport PopoverContent from '../ui/PopoverContent.vue'\nimport PopoverTrigger from '../ui/PopoverTrigger.vue'\nimport ScrollArea from '../ui/ScrollArea.vue'\nimport Spinner from '../ui/Spinner.vue'\nimport NotificationActionButton from './NotificationActionButton.vue'\n\n/**\n * Bell menu for database notifications. It also opens when something calls\n * `openDatabaseNotifications()` (or an action with `->openDatabaseNotifications()`).\n * `variant=\"sidebar\"`: a full-width row with a label, for layouts that put it in the sidebar.\n */\nconst props = withDefaults(defineProps<{ variant?: 'topbar' | 'sidebar' }>(), {\n variant: 'topbar',\n})\nconst t = useT()\nconst direction = useDirection()\nconst panel = usePanel()\nconst config = computed(() => panel.value.databaseNotifications)\nconst endpoints = panel.value.endpoints\n\nconst center =\n endpoints.notifications && endpoints.notificationsReadAll && endpoints.notificationsDestroyAll\n ? new NotificationCenter(\n {\n notifications: endpoints.notifications,\n notificationsReadAll: endpoints.notificationsReadAll,\n notificationsDestroyAll: endpoints.notificationsDestroyAll,\n },\n config.value?.unreadCount ?? 0,\n )\n : null\n\nconst open = ref(false)\nconst state = useStore(\n center?.store ?? {\n get: () => ({ notifications: [], unreadCount: 0, loading: false, hasMore: false, page: 0 }),\n subscribe: () => () => {},\n },\n)\n\n// Polling starts in the browser only: a server render must not leave timers behind.\nonMounted(() => {\n watch(\n () => config.value?.pollingInterval,\n (interval) => center?.startPolling(interval),\n { immediate: true },\n )\n})\n\nwatch(open, (isOpen) => {\n if (isOpen) void center?.load()\n})\n\n// Every visit brings the server's unread count (another user after impersonating, or\n// notifications read in another tab): follow it instead of waiting for the next poll.\nwatch(\n () => config.value?.unreadCount,\n (count) => {\n if (center && typeof count === 'number' && count !== center.store.get().unreadCount) {\n center.store.update({ unreadCount: count })\n }\n },\n)\n\n// Realtime notifications announce stored ones, so the unread count updates right away.\nlet stopListening: (() => void) | null = null\nonMounted(() => {\n stopListening = center ? onDatabaseNotificationsSent(() => void center.load()) : null\n})\nonScopeDispose(() => stopListening?.())\n\n// `openDatabaseNotifications()`: opened from code or an action.\nlet stopOpenListener: (() => void) | null = null\nonMounted(() => {\n stopOpenListener = onOpenDatabaseNotifications(() => (open.value = true))\n})\nonScopeDispose(() => stopOpenListener?.())\n\nonScopeDispose(() => center?.stopPolling())\nconst format = useFormatter()\n</script>\n\n<template>\n <Popover v-if=\"config && center\" :open=\"open\" @update:open=\"open = $event\">\n <PopoverTrigger as-child>\n <Button\n v-if=\"props.variant === 'sidebar'\"\n type=\"button\"\n variant=\"ghost\"\n class=\"relative w-full justify-start gap-2 group-data-[collapsible=icon]:size-8 group-data-[collapsible=icon]:justify-center group-data-[collapsible=icon]:p-0\"\n data-slot=\"notifications-trigger\"\n data-variant=\"sidebar\"\n >\n <!-- In a collapsed (icon) sidebar only the bell and its badge stay visible. -->\n <Icon\n name=\"alfakit::panels.topbar.open-database-notifications-button\"\n :fallback=\"BellIcon\"\n />\n <span class=\"flex-1 text-start group-data-[collapsible=icon]:sr-only\">{{\n t('notifications', {}, 'Notifications')\n }}</span>\n <span\n v-if=\"state.unreadCount > 0\"\n class=\"bg-primary text-primary-foreground flex h-5 min-w-5 items-center justify-center rounded-full px-1 text-xs font-medium group-data-[collapsible=icon]:absolute group-data-[collapsible=icon]:-end-1 group-data-[collapsible=icon]:-top-1 group-data-[collapsible=icon]:h-4 group-data-[collapsible=icon]:min-w-4 group-data-[collapsible=icon]:text-[10px]\"\n >{{ state.unreadCount > 99 ? '99+' : state.unreadCount }}\n <span class=\"sr-only\">{{ t('unread_notifications', {}, 'unread') }}</span></span\n >\n </Button>\n <Button\n v-else\n type=\"button\"\n variant=\"ghost\"\n size=\"icon\"\n class=\"relative\"\n data-slot=\"notifications-trigger\"\n :aria-label=\"t('notifications', {}, 'Notifications')\"\n >\n <Icon\n name=\"alfakit::panels.topbar.open-database-notifications-button\"\n :fallback=\"BellIcon\"\n />\n <span\n v-if=\"state.unreadCount > 0\"\n class=\"bg-primary text-primary-foreground absolute -end-0.5 -top-0.5 flex h-4 min-w-4 items-center justify-center rounded-full px-1 text-[10px] font-medium\"\n >{{ state.unreadCount > 99 ? '99+' : state.unreadCount }}</span\n >\n </Button>\n </PopoverTrigger>\n <PopoverContent\n :align=\"props.variant === 'sidebar' ? 'start' : 'end'\"\n :side=\"props.variant === 'sidebar' ? (direction === 'rtl' ? 'left' : 'right') : 'bottom'\"\n class=\"w-80 p-0 sm:w-96\"\n >\n <div class=\"flex items-center justify-between border-b px-3 py-2\">\n <span class=\"text-sm font-semibold\">{{ t('notifications', {}, 'Notifications') }}</span>\n <div class=\"flex items-center gap-1\">\n <Button\n v-if=\"state.unreadCount > 0\"\n type=\"button\"\n variant=\"ghost\"\n size=\"icon-sm\"\n :title=\"t('mark_all_read', {}, 'Mark all as read')\"\n @click=\"void center.markAllAsRead()\"\n ><CheckCheckIcon\n /></Button>\n <Button\n v-if=\"state.notifications.length > 0\"\n type=\"button\"\n variant=\"ghost\"\n size=\"icon-sm\"\n :title=\"t('clear_notifications', {}, 'Clear notifications')\"\n @click=\"void center.clear()\"\n ><Trash2Icon\n /></Button>\n </div>\n </div>\n <ScrollArea class=\"max-h-96\">\n <div\n v-if=\"state.loading && state.notifications.length === 0\"\n class=\"flex justify-center py-8\"\n >\n <Spinner />\n </div>\n <p\n v-else-if=\"state.notifications.length === 0\"\n class=\"text-muted-foreground px-3 py-8 text-center text-sm\"\n >\n {{ t('no_notifications', {}, 'You have no notifications.') }}\n </p>\n <ul v-else class=\"divide-y\">\n <li\n v-for=\"notification in state.notifications\"\n :key=\"notification.id\"\n :class=\"cn('flex gap-3 px-3 py-3', !notification.readAt && 'bg-primary/5')\"\n :style=\"\n notification.color\n ? notificationTintStyles(cssColor(notification.color)).item\n : undefined\n \"\n >\n <Icon\n v-if=\"notification.icon\"\n :name=\"notification.icon\"\n :class=\"\n cn(\n 'mt-0.5 size-5 shrink-0',\n notification.iconColor && textColorClasses[notification.iconColor],\n )\n \"\n />\n <div class=\"flex min-w-0 flex-1 flex-col gap-1\">\n <div class=\"flex items-start justify-between gap-2\">\n <p class=\"text-sm font-medium\">{{ notification.title }}</p>\n <button\n v-if=\"!notification.readAt\"\n type=\"button\"\n class=\"focus-visible:ring-ring/50 -me-2 -mt-0.5 flex size-6 shrink-0 items-center justify-center rounded-full outline-none focus-visible:ring-[3px]\"\n :aria-label=\"t('mark_as_read', {}, 'Mark as read')\"\n @click=\"void center.markAsRead(notification.id)\"\n >\n <span class=\"bg-primary size-2 rounded-full\" aria-hidden=\"true\" />\n </button>\n </div>\n <p\n v-if=\"notification.body\"\n class=\"text-muted-foreground text-sm\"\n v-html=\"notification.body\"\n />\n <time v-if=\"notification.date\" class=\"text-muted-foreground text-xs\">{{\n format.relative(notification.date)\n }}</time>\n <div v-if=\"notification.actions\" class=\"flex flex-wrap gap-1\">\n <NotificationActionButton\n v-for=\"action in notification.actions\"\n :key=\"action.name\"\n :action=\"action\"\n :on-mark-as-read=\"() => void center!.markAsRead(notification.id)\"\n :on-mark-as-unread=\"() => void center!.markAsUnread(notification.id)\"\n />\n </div>\n </div>\n </li>\n </ul>\n <div\n v-if=\"state.hasMore && state.notifications.length > 0\"\n class=\"flex justify-center border-t p-2\"\n >\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n :disabled=\"state.loading\"\n @click=\"void center!.loadMore()\"\n >\n <Spinner v-if=\"state.loading\" />\n {{ t('load_more', {}, 'Load more') }}\n </Button>\n </div>\n </ScrollArea>\n </PopoverContent>\n </Popover>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2BA,IAAMiD,IAAQC,GAGRC,IAAIC,GAAK,GACTC,KAAYC,EAAa,GACzBC,IAAQC,GAAS,GACjBC,IAASC,SAAeH,EAAM,MAAM,qBAAqB,GACzDI,IAAYJ,EAAM,MAAM,WAExBK,IACJD,EAAU,iBAAiBA,EAAU,wBAAwBA,EAAU,0BACnE,IAAIE,EACF;GACE,eAAeF,EAAU;GACzB,sBAAsBA,EAAU;GAChC,yBAAyBA,EAAU;EACrC,GACAF,EAAO,OAAO,eAAe,CAC/B,IACA,MAEAK,IAAOC,GAAI,EAAK,GAChBC,IAAQC,GACZL,GAAQ,SAAS;GACf,YAAY;IAAE,eAAe,CAAC;IAAG,aAAa;IAAG,SAAS;IAAO,SAAS;IAAO,MAAM;GAAE;GACzF,uBAAuB,CAAC;EAC1B,CACF;EAiBA,AAdAM,QAAgB;GACd,QACQT,EAAO,OAAO,kBACnB,MAAaG,GAAQ,aAAaO,CAAQ,GAC3C,EAAE,WAAW,GAAK,CACpB;EACF,CAAC,GAEDC,EAAMN,IAAO,MAAW;GACtB,AAAIO,KAAQT,GAAa,KAAK;EAChC,CAAC,GAIDQ,QACQX,EAAO,OAAO,cACnB,MAAU;GACT,AAAIG,KAAU,OAAOU,KAAU,YAAYA,MAAUV,EAAO,MAAM,IAAI,CAAC,CAAC,eACtEA,EAAO,MAAM,OAAO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AC,EALiB6E,EAAa,UAAvB,OADT9F,EAAA,GAAAC,EAMEmB,IAAA;OAJC,KAAKiF,EAAO;OACJ;OACR,yBAAe,KAAatG,EAAA4D,CAAA,CAAM,CAAE,WAAWmC,EAAa,EAAE;OAC9D,2BAAiB,KAAa/F,EAAA4D,CAAA,CAAM,CAAE,aAAamC,EAAa,EAAE;;;;;;aAOrE/F,GAAAA,GAAAA,EAAAA,CAAAA,IAAAA,EAAAgE,CAAA,CAAK,CAAC,WAAWhE,EAAAgE,CAAA,CAAK,CAAC,cAAc,SAAM,KADnD/D,EAAA,GAAAU,EAcM,OAdNoC,IAcM,CAVJ1C,EASSE,GAAA;MARP,MAAK;MACL,SAAQ;MACR,MAAK;MACJ,UAAUP,EAAAgE,CAAA,CAAK,CAAC;MAChB,SAAK,AAAAiB,EAAA,QAAA,MAAA,KAAOjF,EAAA4D,CAAA,CAAM,CAAE,SAAQ;;MAE7B,SAAAxD,QAAgC,CAAjBJ,EAAAgE,CAAA,CAAK,CAAC,WAArB/D,EAAA,GAAAC,EAAgCc,GAAA,EAAA,KAAA,EAAA,CAAA,KAAA0E,EAAA,IAAA,EAAA,GAAA9E,EAAA,MAChCF,EAAGV,EAAAmD,CAAA,CAAC,CAAA,aAAA,CAAA,GAAA,WAAA,CAAA,GAAA,CAAA,CAAA,CAAA"}
1
+ {"version":3,"file":"NotificationsMenu.vue_vue_type_script_setup_true_lang.js","names":["_unref","_openBlock","_createBlock","Popover","_withCtx","_createVNode","PopoverTrigger","Button","Icon","_createElementVNode","_toDisplayString","_createElementBlock","_createTextVNode","_createCommentVNode","PopoverContent","ScrollArea","Spinner","_Fragment","_renderList","_normalizeClass","_normalizeStyle","NotificationActionButton","Icon_default","Button_default","Spinner_default","NotificationActionButton_default","Popover_default","PopoverContent_default","PopoverTrigger_default","ScrollArea_default","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","_hoisted_7","_hoisted_8","_hoisted_9","_hoisted_10","_hoisted_11","_hoisted_12","_hoisted_13","_hoisted_14","_hoisted_15","_hoisted_16","_hoisted_17","_hoisted_18","NotificationsMenu_vue_vue_type_script_setup_true_lang_default","props","__props","t","useT","direction","useDirection","panel","usePanel","config","computed","endpoints","center","NotificationCenter","open","ref","state","useStore","onMounted","interval","watch","isOpen","count","stopListening","onDatabaseNotificationsSent","onScopeDispose","stopOpenListener","onOpenDatabaseNotifications","format","useFormatter","pwa","pwaStore","pushToggle","startPwa","togglePush","togglePushNotifications","text","message","toast","unref","openBlock","createBlock","_cache","$event","withCtx","createVNode","BellIcon","createElementVNode","toDisplayString","createElementBlock","createTextVNode","createCommentVNode","BellOffIcon","BellRingIcon","CheckCheckIcon","Trash2Icon","Fragment","renderList","notification","normalizeClass","cn","normalizeStyle","notificationTintStyles","cssColor","textColorClasses","action"],"sources":["../../../src/components/notifications/NotificationsMenu.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport {\n NotificationCenter,\n notificationTintStyles,\n onDatabaseNotificationsSent,\n onOpenDatabaseNotifications,\n pwaStore,\n startPwa,\n togglePushNotifications,\n} from '@alfakit/core'\nimport { BellIcon, BellOffIcon, BellRingIcon, CheckCheckIcon, Trash2Icon } from '@lucide/vue'\nimport { computed, onMounted, onScopeDispose, ref, watch } from 'vue'\nimport { toast } from 'vue-sonner'\nimport { useStore } from '../../composables/use-store'\nimport { useDirection, useFormatter, usePanel, useT } from '../../context'\nimport { cssColor, textColorClasses } from '../../lib/colors'\nimport { Icon } from '../../lib/icons'\nimport { cn } from '../../lib/utils'\nimport Button from '../ui/Button.vue'\nimport Popover from '../ui/Popover.vue'\nimport PopoverContent from '../ui/PopoverContent.vue'\nimport PopoverTrigger from '../ui/PopoverTrigger.vue'\nimport ScrollArea from '../ui/ScrollArea.vue'\nimport Spinner from '../ui/Spinner.vue'\nimport NotificationActionButton from './NotificationActionButton.vue'\n\n/**\n * Bell menu for database notifications. It also opens when something calls\n * `openDatabaseNotifications()` (or an action with `->openDatabaseNotifications()`).\n * `variant=\"sidebar\"`: a full-width row with a label, for layouts that put it in the sidebar.\n */\nconst props = withDefaults(defineProps<{ variant?: 'topbar' | 'sidebar' }>(), {\n variant: 'topbar',\n})\nconst t = useT()\nconst direction = useDirection()\nconst panel = usePanel()\nconst config = computed(() => panel.value.databaseNotifications)\nconst endpoints = panel.value.endpoints\n\nconst center =\n endpoints.notifications && endpoints.notificationsReadAll && endpoints.notificationsDestroyAll\n ? new NotificationCenter(\n {\n notifications: endpoints.notifications,\n notificationsReadAll: endpoints.notificationsReadAll,\n notificationsDestroyAll: endpoints.notificationsDestroyAll,\n },\n config.value?.unreadCount ?? 0,\n )\n : null\n\nconst open = ref(false)\nconst state = useStore(\n center?.store ?? {\n get: () => ({ notifications: [], unreadCount: 0, loading: false, hasMore: false, page: 0 }),\n subscribe: () => () => {},\n },\n)\n\n// Polling starts in the browser only: a server render must not leave timers behind.\nonMounted(() => {\n watch(\n () => config.value?.pollingInterval,\n (interval) => center?.startPolling(interval),\n { immediate: true },\n )\n})\n\nwatch(open, (isOpen) => {\n if (isOpen) void center?.load()\n})\n\n// Every visit brings the server's unread count (another user after impersonating, or\n// notifications read in another tab): follow it instead of waiting for the next poll.\nwatch(\n () => config.value?.unreadCount,\n (count) => {\n if (center && typeof count === 'number' && count !== center.store.get().unreadCount) {\n center.store.update({ unreadCount: count })\n }\n },\n)\n\n// Realtime notifications announce stored ones, so the unread count updates right away.\nlet stopListening: (() => void) | null = null\nonMounted(() => {\n stopListening = center ? onDatabaseNotificationsSent(() => void center.load()) : null\n})\nonScopeDispose(() => stopListening?.())\n\n// `openDatabaseNotifications()`: opened from code or an action.\nlet stopOpenListener: (() => void) | null = null\nonMounted(() => {\n stopOpenListener = onOpenDatabaseNotifications(() => (open.value = true))\n})\nonScopeDispose(() => stopOpenListener?.())\n\nonScopeDispose(() => center?.stopPolling())\nconst format = useFormatter()\n\n// `pwa(push: true)` in a starter kit: the app's user menu has no AlfaKit entries, so Web\n// Push is turned on or off from the bell's menu.\nconst pwa = useStore(pwaStore)\nconst pushToggle = computed(\n () =>\n Boolean(panel.value.starterKit && panel.value.pwa?.push) && pwa.value.push !== 'unsupported',\n)\nonMounted(() => {\n if (panel.value.starterKit && panel.value.pwa?.push) startPwa(panel.value.pwa)\n})\nasync function togglePush() {\n const { message } = await togglePushNotifications()\n const text = t(message.key, {}, message.fallback)\n\n if (message.error) toast.error(text)\n else toast.success(text)\n}\n</script>\n\n<template>\n <Popover v-if=\"config && center\" :open=\"open\" @update:open=\"open = $event\">\n <PopoverTrigger as-child>\n <Button\n v-if=\"props.variant === 'sidebar'\"\n type=\"button\"\n variant=\"ghost\"\n class=\"relative w-full justify-start gap-2 group-data-[collapsible=icon]:size-8 group-data-[collapsible=icon]:justify-center group-data-[collapsible=icon]:p-0\"\n data-slot=\"notifications-trigger\"\n data-variant=\"sidebar\"\n >\n <!-- In a collapsed (icon) sidebar only the bell and its badge stay visible. -->\n <Icon\n name=\"alfakit::panels.topbar.open-database-notifications-button\"\n :fallback=\"BellIcon\"\n />\n <span class=\"flex-1 text-start group-data-[collapsible=icon]:sr-only\">{{\n t('notifications', {}, 'Notifications')\n }}</span>\n <span\n v-if=\"state.unreadCount > 0\"\n class=\"bg-primary text-primary-foreground flex h-5 min-w-5 items-center justify-center rounded-full px-1 text-xs font-medium group-data-[collapsible=icon]:absolute group-data-[collapsible=icon]:-end-1 group-data-[collapsible=icon]:-top-1 group-data-[collapsible=icon]:h-4 group-data-[collapsible=icon]:min-w-4 group-data-[collapsible=icon]:text-[10px]\"\n >{{ state.unreadCount > 99 ? '99+' : state.unreadCount }}\n <span class=\"sr-only\">{{ t('unread_notifications', {}, 'unread') }}</span></span\n >\n </Button>\n <Button\n v-else\n type=\"button\"\n variant=\"ghost\"\n size=\"icon\"\n class=\"relative\"\n data-slot=\"notifications-trigger\"\n :aria-label=\"t('notifications', {}, 'Notifications')\"\n >\n <Icon\n name=\"alfakit::panels.topbar.open-database-notifications-button\"\n :fallback=\"BellIcon\"\n />\n <span\n v-if=\"state.unreadCount > 0\"\n class=\"bg-primary text-primary-foreground absolute -end-0.5 -top-0.5 flex h-4 min-w-4 items-center justify-center rounded-full px-1 text-[10px] font-medium\"\n >{{ state.unreadCount > 99 ? '99+' : state.unreadCount }}</span\n >\n </Button>\n </PopoverTrigger>\n <PopoverContent\n :align=\"props.variant === 'sidebar' ? 'start' : 'end'\"\n :side=\"props.variant === 'sidebar' ? (direction === 'rtl' ? 'left' : 'right') : 'bottom'\"\n class=\"w-80 p-0 sm:w-96\"\n >\n <div class=\"flex items-center justify-between border-b px-3 py-2\">\n <span class=\"text-sm font-semibold\">{{ t('notifications', {}, 'Notifications') }}</span>\n <div class=\"flex items-center gap-1\">\n <Button\n v-if=\"pushToggle\"\n type=\"button\"\n variant=\"ghost\"\n size=\"icon-sm\"\n data-slot=\"pwa-push\"\n :disabled=\"pwa.pushBusy || pwa.push === 'denied'\"\n :title=\"\n pwa.push === 'subscribed'\n ? t('pwa.notifications.disable', {}, 'Turn off notifications')\n : t('pwa.notifications.enable', {}, 'Turn on notifications')\n \"\n :aria-label=\"\n pwa.push === 'subscribed'\n ? t('pwa.notifications.disable', {}, 'Turn off notifications')\n : t('pwa.notifications.enable', {}, 'Turn on notifications')\n \"\n @click=\"void togglePush()\"\n >\n <BellOffIcon v-if=\"pwa.push === 'subscribed'\" />\n <BellRingIcon v-else />\n </Button>\n <Button\n v-if=\"state.unreadCount > 0\"\n type=\"button\"\n variant=\"ghost\"\n size=\"icon-sm\"\n :title=\"t('mark_all_read', {}, 'Mark all as read')\"\n @click=\"void center.markAllAsRead()\"\n ><CheckCheckIcon\n /></Button>\n <Button\n v-if=\"state.notifications.length > 0\"\n type=\"button\"\n variant=\"ghost\"\n size=\"icon-sm\"\n :title=\"t('clear_notifications', {}, 'Clear notifications')\"\n @click=\"void center.clear()\"\n ><Trash2Icon\n /></Button>\n </div>\n </div>\n <ScrollArea class=\"max-h-96\">\n <div\n v-if=\"state.loading && state.notifications.length === 0\"\n class=\"flex justify-center py-8\"\n >\n <Spinner />\n </div>\n <p\n v-else-if=\"state.notifications.length === 0\"\n class=\"text-muted-foreground px-3 py-8 text-center text-sm\"\n >\n {{ t('no_notifications', {}, 'You have no notifications.') }}\n </p>\n <ul v-else class=\"divide-y\">\n <li\n v-for=\"notification in state.notifications\"\n :key=\"notification.id\"\n :class=\"cn('flex gap-3 px-3 py-3', !notification.readAt && 'bg-primary/5')\"\n :style=\"\n notification.color\n ? notificationTintStyles(cssColor(notification.color)).item\n : undefined\n \"\n >\n <Icon\n v-if=\"notification.icon\"\n :name=\"notification.icon\"\n :class=\"\n cn(\n 'mt-0.5 size-5 shrink-0',\n notification.iconColor && textColorClasses[notification.iconColor],\n )\n \"\n />\n <div class=\"flex min-w-0 flex-1 flex-col gap-1\">\n <div class=\"flex items-start justify-between gap-2\">\n <p class=\"text-sm font-medium\">{{ notification.title }}</p>\n <button\n v-if=\"!notification.readAt\"\n type=\"button\"\n class=\"focus-visible:ring-ring/50 -me-2 -mt-0.5 flex size-6 shrink-0 items-center justify-center rounded-full outline-none focus-visible:ring-[3px]\"\n :aria-label=\"t('mark_as_read', {}, 'Mark as read')\"\n @click=\"void center.markAsRead(notification.id)\"\n >\n <span class=\"bg-primary size-2 rounded-full\" aria-hidden=\"true\" />\n </button>\n </div>\n <p\n v-if=\"notification.body\"\n class=\"text-muted-foreground text-sm\"\n v-html=\"notification.body\"\n />\n <time v-if=\"notification.date\" class=\"text-muted-foreground text-xs\">{{\n format.relative(notification.date)\n }}</time>\n <div v-if=\"notification.actions\" class=\"flex flex-wrap gap-1\">\n <NotificationActionButton\n v-for=\"action in notification.actions\"\n :key=\"action.name\"\n :action=\"action\"\n :on-mark-as-read=\"() => void center!.markAsRead(notification.id)\"\n :on-mark-as-unread=\"() => void center!.markAsUnread(notification.id)\"\n />\n </div>\n </div>\n </li>\n </ul>\n <div\n v-if=\"state.hasMore && state.notifications.length > 0\"\n class=\"flex justify-center border-t p-2\"\n >\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n :disabled=\"state.loading\"\n @click=\"void center!.loadMore()\"\n >\n <Spinner v-if=\"state.loading\" />\n {{ t('load_more', {}, 'Load more') }}\n </Button>\n </div>\n </ScrollArea>\n </PopoverContent>\n </Popover>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+BA,IAAMiD,IAAQC,GAGRC,IAAIC,EAAK,GACTC,KAAYC,EAAa,GACzBC,IAAQC,GAAS,GACjBC,IAASC,QAAeH,EAAM,MAAM,qBAAqB,GACzDI,IAAYJ,EAAM,MAAM,WAExBK,IACJD,EAAU,iBAAiBA,EAAU,wBAAwBA,EAAU,0BACnE,IAAIE,EACF;GACE,eAAeF,EAAU;GACzB,sBAAsBA,EAAU;GAChC,yBAAyBA,EAAU;EACrC,GACAF,EAAO,OAAO,eAAe,CAC/B,IACA,MAEAK,IAAOC,GAAI,EAAK,GAChBC,IAAQC,EACZL,GAAQ,SAAS;GACf,YAAY;IAAE,eAAe,CAAC;IAAG,aAAa;IAAG,SAAS;IAAO,SAAS;IAAO,MAAM;GAAE;GACzF,uBAAuB,CAAC;EAC1B,CACF;EAiBA,AAdAM,QAAgB;GACd,QACQT,EAAO,OAAO,kBACnB,MAAaG,GAAQ,aAAaO,CAAQ,GAC3C,EAAE,WAAW,GAAK,CACpB;EACF,CAAC,GAEDC,EAAMN,IAAO,MAAW;GACtB,AAAIO,KAAQT,GAAa,KAAK;EAChC,CAAC,GAIDQ,QACQX,EAAO,OAAO,cACnB,MAAU;GACT,AAAIG,KAAU,OAAOU,KAAU,YAAYA,MAAUV,EAAO,MAAM,IAAI,CAAC,CAAC,eACtEA,EAAO,MAAM,OAAO,EAAE,aAAaU,EAAM,CAAC;EAE9C,CACF;EAGA,IAAIC,IAAqC;EAIzC,AAHAL,QAAgB;GACd,IAAgBN,IAASY,SAAkC,KAAKZ,EAAO,KAAK,CAAC,IAAI;EACnF,CAAC,GACDa,QAAqBF,IA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gE,CAAA,CAAK,CAAC,WAAWhE,EAAAgE,CAAA,CAAK,CAAC,cAAc,SAAM,KADnD/D,EAAA,GAAAU,EAcM,OAdNoC,IAcM,CAVJ1C,EASSE,GAAA;MARP,MAAK;MACL,SAAQ;MACR,MAAK;MACJ,UAAUP,EAAAgE,CAAA,CAAK,CAAC;MAChB,SAAK,AAAA0B,EAAA,QAAA,MAAA,KAAO1F,EAAA4D,CAAA,CAAM,CAAE,SAAQ;;MAE7B,SAAAxD,QAAgC,CAAjBJ,EAAAgE,CAAA,CAAK,CAAC,WAArB/D,EAAA,GAAAC,EAAgCc,GAAA,EAAA,KAAA,EAAA,CAAA,KAAAmF,EAAA,IAAA,EAAA,GAAAvF,EAAA,MAChCF,EAAGV,EAAAmD,CAAA,CAAC,CAAA,aAAA,CAAA,GAAA,WAAA,CAAA,GAAA,CAAA,CAAA,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"ShortcutsOverlay.js","names":["_sfc_main","ShortcutsOverlay_vue_vue_type_script_setup_true_lang_default","ShortcutsOverlay_default"],"sources":["../../../src/components/panel/ShortcutsOverlay.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { ShortcutListGroup, ShortcutListItem } from '@alfakit/core'\nimport {\n bindingFromEvent,\n flattenActionGroup,\n saveShortcutOverrides,\n shortcutOverlayGroups,\n shortcuts,\n} from '@alfakit/core'\nimport { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue'\nimport { usePageSchema, useT } from '../../context'\nimport Button from '../ui/Button.vue'\nimport Dialog from '../ui/Dialog.vue'\nimport DialogContent from '../ui/DialogContent.vue'\nimport DialogDescription from '../ui/DialogDescription.vue'\nimport DialogHeader from '../ui/DialogHeader.vue'\nimport DialogTitle from '../ui/DialogTitle.vue'\nimport ShortcutKeys from './ShortcutKeys.vue'\n\n/** The `?` overlay: every shortcut on the page, grouped; users may change their keys. */\nconst props = defineProps<{ open: boolean; customizable: boolean; endpoint?: string }>()\nconst emit = defineEmits<{ 'update:open': [open: boolean] }>()\n\nconst t = useT()\nconst page = usePageSchema()\nconst version = ref(shortcuts.getVersion())\nconst recording = ref<string | null>(null)\nconst message = ref('')\n\n// Subscribed once mounted: a server render must not leave listeners on the shared registry.\nlet unsubscribe = () => {}\n\nonMounted(() => {\n version.value = shortcuts.getVersion()\n unsubscribe = shortcuts.subscribe(() => {\n version.value = shortcuts.getVersion()\n })\n})\n\nonBeforeUnmount(() => unsubscribe())\n\nconst groups = computed(() => {\n void version.value\n\n return shortcutOverlayGroups(\n shortcuts.list(),\n flattenActionGroup(page.value?.headerActions ?? []),\n )\n})\n\nconst groupLabel = (group: ShortcutListGroup['group']) =>\n ({\n general: t('shortcuts.groups.general', {}, 'General'),\n navigation: t('shortcuts.groups.navigation', {}, 'Navigation'),\n commands: t('shortcuts.groups.commands', {}, 'Commands'),\n actions: t('shortcuts.groups.actions', {}, 'Actions on this page'),\n })[group]\n\nconst save = async (id: string, keys: string[] | null) => {\n if (!props.endpoint) return\n\n try {\n shortcuts.setOverrides(await saveShortcutOverrides(props.endpoint, { [id]: keys }))\n message.value = t('shortcuts.saved', {}, 'Shortcut saved.')\n } catch {\n message.value = t('shortcuts.save_failed', {}, 'The shortcut could not be saved.')\n }\n}\n\nconst change = (item: ShortcutListItem) => {\n message.value = t(\n 'shortcuts.recording',\n { label: item.label },\n `Press the new keys for “${item.label}”. Escape cancels.`,\n )\n recording.value = item.id\n}\n\n// While recording, the next key press is the new binding (Escape cancels). Listening in the\n// capture phase keeps the key from closing the dialog or running another shortcut.\nwatch(recording, (id, _old, onCleanup) => {\n if (!id || typeof window === 'undefined') return\n\n shortcuts.setPaused(true)\n\n const listener = (event: KeyboardEvent) => {\n event.preventDefault()\n event.stopPropagation()\n\n if (event.key === 'Escape') {\n recording.value = null\n message.value = t('shortcuts.cancelled', {}, 'Change cancelled.')\n\n return\n }\n\n const binding = bindingFromEvent(event)\n\n if (!binding) return\n\n const conflict = shortcuts.conflict([binding], id)\n\n recording.value = null\n\n if (conflict) {\n message.value = t(\n 'shortcuts.conflict',\n { label: conflict.label },\n `Already used by “${conflict.label}”.`,\n )\n\n return\n }\n\n void save(id, [binding])\n }\n\n window.addEventListener('keydown', listener, true)\n onCleanup(() => {\n window.removeEventListener('keydown', listener, true)\n shortcuts.setPaused(false)\n })\n})\n\nconst update = (next: boolean) => {\n recording.value = null\n message.value = ''\n emit('update:open', next)\n}\n</script>\n\n<template>\n <Dialog :open=\"props.open\" @update:open=\"update\">\n <DialogContent class=\"max-h-[85vh] overflow-y-auto sm:max-w-lg\">\n <div data-slot=\"shortcuts-overlay\" class=\"flex flex-col gap-4\">\n <DialogHeader>\n <DialogTitle>{{ t('shortcuts.title', {}, 'Keyboard shortcuts') }}</DialogTitle>\n <DialogDescription>{{\n t('shortcuts.description', {}, 'Shortcuts available on this page.')\n }}</DialogDescription>\n </DialogHeader>\n <div role=\"status\" aria-live=\"polite\" class=\"text-muted-foreground min-h-5 text-sm\">\n {{ message }}\n </div>\n <div class=\"flex flex-col gap-5\">\n <section\n v-for=\"group in groups\"\n :key=\"group.group\"\n :data-group=\"group.group\"\n :aria-labelledby=\"`shortcuts-${group.group}`\"\n >\n <h3\n :id=\"`shortcuts-${group.group}`\"\n class=\"text-muted-foreground mb-2 text-xs font-medium uppercase\"\n >\n {{ groupLabel(group.group) }}\n </h3>\n <ul class=\"flex flex-col divide-y rounded-md border\">\n <li\n v-for=\"item in group.items\"\n :key=\"item.id\"\n :data-shortcut=\"item.id\"\n class=\"flex items-center gap-3 px-3 py-2 text-sm\"\n >\n <span class=\"min-w-0 flex-1 truncate\">{{ item.label }}</span>\n <span v-if=\"recording === item.id\" class=\"text-primary text-xs\">{{\n t('shortcuts.press_keys', {}, 'Press keys…')\n }}</span>\n <span v-else-if=\"item.keys.length === 0\" class=\"text-muted-foreground text-xs\">{{\n t('shortcuts.off', {}, 'Off')\n }}</span>\n <span v-else class=\"flex flex-wrap items-center justify-end gap-2\">\n <ShortcutKeys v-for=\"key in item.keys\" :key=\"key\" :binding=\"key\" />\n </span>\n <span v-if=\"props.customizable && item.customizable\" class=\"flex shrink-0 gap-1\">\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"xs\"\n :aria-label=\"\n t(\n 'shortcuts.change_label',\n { label: item.label },\n `Change the shortcut for ${item.label}`,\n )\n \"\n @click=\"change(item)\"\n >{{ t('shortcuts.change', {}, 'Change') }}</Button\n >\n <Button\n v-if=\"item.keys.length > 0\"\n type=\"button\"\n variant=\"ghost\"\n size=\"xs\"\n :aria-label=\"\n t(\n 'shortcuts.turn_off_label',\n { label: item.label },\n `Turn off the shortcut for ${item.label}`,\n )\n \"\n @click=\"save(item.id, [])\"\n >{{ t('shortcuts.turn_off', {}, 'Turn off') }}</Button\n >\n <Button\n v-if=\"item.customized\"\n type=\"button\"\n variant=\"ghost\"\n size=\"xs\"\n :aria-label=\"\n t(\n 'shortcuts.reset_label',\n { label: item.label },\n `Restore the default shortcut for ${item.label}`,\n )\n \"\n @click=\"save(item.id, null)\"\n >{{ t('shortcuts.reset', {}, 'Reset') }}</Button\n >\n </span>\n </li>\n </ul>\n </section>\n </div>\n </div>\n </DialogContent>\n </Dialog>\n</template>\n"],"mappings":""}
1
+ {"version":3,"file":"ShortcutsOverlay.js","names":["_sfc_main","ShortcutsOverlay_vue_vue_type_script_setup_true_lang_default","ShortcutsOverlay_default"],"sources":["../../../src/components/panel/ShortcutsOverlay.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { ShortcutListGroup, ShortcutListItem } from '@alfakit/core'\nimport {\n ShortcutRecorder,\n flattenActionGroup,\n saveShortcutOverrides,\n shortcutOverlayGroups,\n shortcuts,\n} from '@alfakit/core'\nimport { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue'\nimport { usePageSchema, useT } from '../../context'\nimport Button from '../ui/Button.vue'\nimport Dialog from '../ui/Dialog.vue'\nimport DialogContent from '../ui/DialogContent.vue'\nimport DialogDescription from '../ui/DialogDescription.vue'\nimport DialogHeader from '../ui/DialogHeader.vue'\nimport DialogTitle from '../ui/DialogTitle.vue'\nimport ShortcutKeys from './ShortcutKeys.vue'\n\n/** The `?` overlay: every shortcut on the page, grouped; users may change their keys. */\nconst props = defineProps<{ open: boolean; customizable: boolean; endpoint?: string }>()\nconst emit = defineEmits<{ 'update:open': [open: boolean] }>()\n\nconst t = useT()\nconst page = usePageSchema()\nconst version = ref(shortcuts.getVersion())\nconst recording = ref<string | null>(null)\nconst message = ref('')\n\n// Subscribed once mounted: a server render must not leave listeners on the shared registry.\nlet unsubscribe = () => {}\n\nonMounted(() => {\n version.value = shortcuts.getVersion()\n unsubscribe = shortcuts.subscribe(() => {\n version.value = shortcuts.getVersion()\n })\n})\n\nonBeforeUnmount(() => unsubscribe())\n\nconst groups = computed(() => {\n void version.value\n\n return shortcutOverlayGroups(\n shortcuts.list(),\n flattenActionGroup(page.value?.headerActions ?? []),\n )\n})\n\nconst groupLabel = (group: ShortcutListGroup['group']) =>\n ({\n general: t('shortcuts.groups.general', {}, 'General'),\n navigation: t('shortcuts.groups.navigation', {}, 'Navigation'),\n commands: t('shortcuts.groups.commands', {}, 'Commands'),\n actions: t('shortcuts.groups.actions', {}, 'Actions on this page'),\n })[group]\n\nconst save = async (id: string, keys: string[] | null) => {\n if (!props.endpoint) return\n\n try {\n shortcuts.setOverrides(await saveShortcutOverrides(props.endpoint, { [id]: keys }))\n message.value = t('shortcuts.saved', {}, 'Shortcut saved.')\n } catch {\n message.value = t('shortcuts.save_failed', {}, 'The shortcut could not be saved.')\n }\n}\n\nconst change = (item: ShortcutListItem) => {\n message.value = t(\n 'shortcuts.recording',\n { label: item.label },\n `Press the new keys for “${item.label}”. Escape cancels.`,\n )\n recording.value = item.id\n}\n\n// While recording, the keys pressed are the new binding: one key (with modifiers) or a\n// sequence (\"g o\"), finished a second after the last key (Escape cancels). Listening in\n// the capture phase keeps the keys from closing the dialog or running another shortcut.\nwatch(recording, (id, _old, onCleanup) => {\n if (!id || typeof window === 'undefined') return\n\n shortcuts.setPaused(true)\n\n const recorder = new ShortcutRecorder({\n onDone: (binding) => {\n recording.value = null\n\n const conflict = shortcuts.conflict([binding], id)\n\n if (conflict) {\n message.value = t(\n 'shortcuts.conflict',\n { label: conflict.label },\n `Already used by “${conflict.label}”.`,\n )\n\n return\n }\n\n void save(id, [binding])\n },\n })\n\n const listener = (event: KeyboardEvent) => {\n event.preventDefault()\n event.stopPropagation()\n\n if (event.key === 'Escape') {\n recorder.cancel()\n recording.value = null\n message.value = t('shortcuts.cancelled', {}, 'Change cancelled.')\n\n return\n }\n\n recorder.press(event)\n }\n\n window.addEventListener('keydown', listener, true)\n onCleanup(() => {\n recorder.cancel()\n window.removeEventListener('keydown', listener, true)\n shortcuts.setPaused(false)\n })\n})\n\nconst update = (next: boolean) => {\n recording.value = null\n message.value = ''\n emit('update:open', next)\n}\n</script>\n\n<template>\n <Dialog :open=\"props.open\" @update:open=\"update\">\n <DialogContent class=\"max-h-[85vh] overflow-y-auto sm:max-w-lg\">\n <div data-slot=\"shortcuts-overlay\" class=\"flex flex-col gap-4\">\n <DialogHeader>\n <DialogTitle>{{ t('shortcuts.title', {}, 'Keyboard shortcuts') }}</DialogTitle>\n <DialogDescription>{{\n t('shortcuts.description', {}, 'Shortcuts available on this page.')\n }}</DialogDescription>\n </DialogHeader>\n <div role=\"status\" aria-live=\"polite\" class=\"text-muted-foreground min-h-5 text-sm\">\n {{ message }}\n </div>\n <div class=\"flex flex-col gap-5\">\n <section\n v-for=\"group in groups\"\n :key=\"group.group\"\n :data-group=\"group.group\"\n :aria-labelledby=\"`shortcuts-${group.group}`\"\n >\n <h3\n :id=\"`shortcuts-${group.group}`\"\n class=\"text-muted-foreground mb-2 text-xs font-medium uppercase\"\n >\n {{ groupLabel(group.group) }}\n </h3>\n <ul class=\"flex flex-col divide-y rounded-md border\">\n <li\n v-for=\"item in group.items\"\n :key=\"item.id\"\n :data-shortcut=\"item.id\"\n class=\"flex items-center gap-3 px-3 py-2 text-sm\"\n >\n <span class=\"min-w-0 flex-1 truncate\">{{ item.label }}</span>\n <span v-if=\"recording === item.id\" class=\"text-primary text-xs\">{{\n t('shortcuts.press_keys', {}, 'Press keys…')\n }}</span>\n <span v-else-if=\"item.keys.length === 0\" class=\"text-muted-foreground text-xs\">{{\n t('shortcuts.off', {}, 'Off')\n }}</span>\n <span v-else class=\"flex flex-wrap items-center justify-end gap-2\">\n <ShortcutKeys v-for=\"key in item.keys\" :key=\"key\" :binding=\"key\" />\n </span>\n <span v-if=\"props.customizable && item.customizable\" class=\"flex shrink-0 gap-1\">\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"xs\"\n :aria-label=\"\n t(\n 'shortcuts.change_label',\n { label: item.label },\n `Change the shortcut for ${item.label}`,\n )\n \"\n @click=\"change(item)\"\n >{{ t('shortcuts.change', {}, 'Change') }}</Button\n >\n <Button\n v-if=\"item.keys.length > 0\"\n type=\"button\"\n variant=\"ghost\"\n size=\"xs\"\n :aria-label=\"\n t(\n 'shortcuts.turn_off_label',\n { label: item.label },\n `Turn off the shortcut for ${item.label}`,\n )\n \"\n @click=\"save(item.id, [])\"\n >{{ t('shortcuts.turn_off', {}, 'Turn off') }}</Button\n >\n <Button\n v-if=\"item.customized\"\n type=\"button\"\n variant=\"ghost\"\n size=\"xs\"\n :aria-label=\"\n t(\n 'shortcuts.reset_label',\n { label: item.label },\n `Restore the default shortcut for ${item.label}`,\n )\n \"\n @click=\"save(item.id, null)\"\n >{{ t('shortcuts.reset', {}, 'Reset') }}</Button\n >\n </span>\n </li>\n </ul>\n </section>\n </div>\n </div>\n </DialogContent>\n </Dialog>\n</template>\n"],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"ShortcutsOverlay.vue.d.ts","sourceRoot":"","sources":["../../../src/components/panel/ShortcutsOverlay.vue"],"names":[],"mappings":"AAwPA,yFAAyF;AACzF,KAAK,WAAW,GAAG;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,YAAY,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;;;;;;AAsc/E,wBAOG"}
1
+ {"version":3,"file":"ShortcutsOverlay.vue.d.ts","sourceRoot":"","sources":["../../../src/components/panel/ShortcutsOverlay.vue"],"names":[],"mappings":"AA6PA,yFAAyF;AACzF,KAAK,WAAW,GAAG;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,YAAY,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;;;;;;AA2c/E,wBAOG"}