list-page.ts52 lines · main
1// @ts-nocheck
2import { RegistryDefinations } from '../types'
3
4/**
5 * Shared shortcuts for "list pages" — the conventional Database/* page shape
6 * with a schema selector, a search input, a primary "create new" action, and
7 * one or more facet filters.
8 *
9 * Pages register their per-page handlers via `useShortcut`. Pass a `label`
10 * override to make the Cmd+K entry and hover tooltip read e.g. "Search tables"
11 * instead of the generic "Focus search" stored here.
12 */
13export const LIST_PAGE_SHORTCUT_IDS = {
14 LIST_PAGE_FOCUS_SCHEMA: 'list-page.focus-schema',
15 LIST_PAGE_FOCUS_SEARCH: 'list-page.focus-search',
16 LIST_PAGE_NEW_ITEM: 'list-page.new-item',
17 LIST_PAGE_RESET_FILTERS: 'list-page.reset-filters',
18}
19
20export type ListPageShortcutId =
21 (typeof LIST_PAGE_SHORTCUT_IDS)[keyof typeof LIST_PAGE_SHORTCUT_IDS]
22
23export const listPageRegistry: RegistryDefinations<ListPageShortcutId> = {
24 [LIST_PAGE_SHORTCUT_IDS.LIST_PAGE_FOCUS_SCHEMA]: {
25 id: LIST_PAGE_SHORTCUT_IDS.LIST_PAGE_FOCUS_SCHEMA,
26 label: 'Open schema selector',
27 sequence: ['O', 'S'],
28 showInSettings: false,
29 options: { ignoreInputs: true, registerInCommandMenu: true },
30 },
31 [LIST_PAGE_SHORTCUT_IDS.LIST_PAGE_FOCUS_SEARCH]: {
32 id: LIST_PAGE_SHORTCUT_IDS.LIST_PAGE_FOCUS_SEARCH,
33 label: 'Focus search',
34 sequence: ['Shift+F'],
35 showInSettings: false,
36 options: { registerInCommandMenu: true },
37 },
38 [LIST_PAGE_SHORTCUT_IDS.LIST_PAGE_NEW_ITEM]: {
39 id: LIST_PAGE_SHORTCUT_IDS.LIST_PAGE_NEW_ITEM,
40 label: 'Create new item',
41 sequence: ['Shift+N'],
42 showInSettings: false,
43 options: { registerInCommandMenu: true },
44 },
45 [LIST_PAGE_SHORTCUT_IDS.LIST_PAGE_RESET_FILTERS]: {
46 id: LIST_PAGE_SHORTCUT_IDS.LIST_PAGE_RESET_FILTERS,
47 label: 'Reset filters',
48 sequence: ['F', 'C'],
49 showInSettings: false,
50 options: { ignoreInputs: true, registerInCommandMenu: true },
51 },
52}