@veiag/payload-cmdk 1.0.2 → 1.0.3
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.
- package/README.md +10 -0
- package/dist/types.d.ts +3 -9
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,11 +7,17 @@ A powerful command menu plugin for [Payload CMS](https://payloadcms.com) that en
|
|
|
7
7
|
## Features
|
|
8
8
|
|
|
9
9
|
✨ **Quick Search** - Instantly search across all collections and globals
|
|
10
|
+
|
|
10
11
|
⌨️ **Keyboard Shortcuts** - Fully customizable keyboard shortcuts powered by [react-hotkeys-hook](https://react-hotkeys-hook.vercel.app/docs/intro)
|
|
12
|
+
|
|
11
13
|
🔍 **Collection Submenu** - Search within collection documents by their title field
|
|
14
|
+
|
|
12
15
|
🎨 **Custom Icons** - Use any [Lucide icon](https://lucide.dev/icons) for collections and globals
|
|
16
|
+
|
|
13
17
|
🎯 **Custom Items** - Add custom actions and menu groups
|
|
18
|
+
|
|
14
19
|
🌍 **i18n Support** - Built-in English and Ukrainian translations, easily add your own
|
|
20
|
+
|
|
15
21
|
🖥️ **Cross-platform** - Optimized shortcuts for both macOS and Windows/Linux
|
|
16
22
|
|
|
17
23
|
|
|
@@ -566,6 +572,9 @@ export default buildConfig({
|
|
|
566
572
|
})
|
|
567
573
|
```
|
|
568
574
|
|
|
575
|
+
## Troubleshooting
|
|
576
|
+
- `Objects are not valid as a React child` error: Ensure your `admin.useAsTitle` field is a string and not an object. Currently, plugin doesn't have any safeguards for non-string title fields.
|
|
577
|
+
|
|
569
578
|
## Contributing
|
|
570
579
|
|
|
571
580
|
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
@@ -586,6 +595,7 @@ MIT © [VeiaG](https://github.com/VeiaG)
|
|
|
586
595
|
|
|
587
596
|
## Links
|
|
588
597
|
|
|
598
|
+
- [cmdk Component](https://cmdk.paco.me/)
|
|
589
599
|
- [GitHub Repository](https://github.com/VeiaG/payload-cmdk/tree/main)
|
|
590
600
|
- [Payload CMS](https://payloadcms.com)
|
|
591
601
|
- [Lucide Icons](https://lucide.dev/icons)
|
package/dist/types.d.ts
CHANGED
|
@@ -56,16 +56,12 @@ export type PluginCommandMenuConfig = {
|
|
|
56
56
|
* Custom icons for collections.
|
|
57
57
|
* @default <Files/>
|
|
58
58
|
*/
|
|
59
|
-
collections?:
|
|
60
|
-
[K in CollectionSlug]: IconName;
|
|
61
|
-
};
|
|
59
|
+
collections?: Partial<Record<CollectionSlug, IconName>>;
|
|
62
60
|
/**
|
|
63
61
|
* Custom icons for globals.
|
|
64
62
|
* @default <Globe/>
|
|
65
63
|
*/
|
|
66
|
-
globals?:
|
|
67
|
-
[K in GlobalSlug]: IconName;
|
|
68
|
-
};
|
|
64
|
+
globals?: Partial<Record<GlobalSlug, IconName>>;
|
|
69
65
|
};
|
|
70
66
|
/**
|
|
71
67
|
* Configuration for the search button in the admin navigation.
|
|
@@ -122,9 +118,7 @@ export type PluginCommandMenuConfig = {
|
|
|
122
118
|
*
|
|
123
119
|
* @default null
|
|
124
120
|
*/
|
|
125
|
-
icons?:
|
|
126
|
-
[K in CollectionSlug]: IconName;
|
|
127
|
-
};
|
|
121
|
+
icons?: Partial<Record<CollectionSlug, IconName>>;
|
|
128
122
|
/**
|
|
129
123
|
* Keyboard shortcut to open collection submenu.
|
|
130
124
|
* - 'shift+enter': Shift+Enter opens submenu, Enter navigates to collection list
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type { icons, LucideIcon } from 'lucide-react'\nimport type { CollectionSlug, GlobalSlug } from 'payload'\n\nexport type IconName = keyof typeof icons\n\nexport type LocalizedString = { [locale: string]: string } | string\n\nexport type InternalIcon = IconName | LucideIcon\n\n/**\n * Custom menu item, for configuration.\n * Will be mapped to CommandMenuItem internally.\n */\nexport type CustomMenuItem = {\n action: CommandMenuAction\n icon?: IconName\n label: LocalizedString\n slug: string\n type: 'item'\n}\n\n/**\n * Custom menu group, for configuration.\n * Will be mapped to CommandMenuGroup internally.\n *\n * Groups will be merged if they have the same title.\n */\nexport type CustomMenuGroup = {\n items: CustomMenuItem[]\n title: LocalizedString\n type: 'group'\n}\n/**\n * Full serializable config for the plugin.\n */\nexport type PluginCommandMenuConfig = {\n /**\n * Enable backdrop blur effect\n * @default true\n */\n blurBg?: boolean\n /**\n * Custom items or groups to add to the command menu.\n */\n customItems?: (CustomMenuGroup | CustomMenuItem)[]\n /**\n * Disable the plugin functionality\n * @default false\n */\n disabled?: boolean\n /**\n * Custom icons for collections and globals.\n * Key is the collection slug, value is the icon name from lucide-react.\n * Collections default icon - Files,\n * Globals default icon - Globe.\n */\n icons?: {\n /**\n * Custom icons for collections.\n * @default <Files/>\n */\n collections?:
|
|
1
|
+
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type { icons, LucideIcon } from 'lucide-react'\nimport type { CollectionSlug, GlobalSlug } from 'payload'\n\nexport type IconName = keyof typeof icons\n\nexport type LocalizedString = { [locale: string]: string } | string\n\nexport type InternalIcon = IconName | LucideIcon\n\n/**\n * Custom menu item, for configuration.\n * Will be mapped to CommandMenuItem internally.\n */\nexport type CustomMenuItem = {\n action: CommandMenuAction\n icon?: IconName\n label: LocalizedString\n slug: string\n type: 'item'\n}\n\n/**\n * Custom menu group, for configuration.\n * Will be mapped to CommandMenuGroup internally.\n *\n * Groups will be merged if they have the same title.\n */\nexport type CustomMenuGroup = {\n items: CustomMenuItem[]\n title: LocalizedString\n type: 'group'\n}\n/**\n * Full serializable config for the plugin.\n */\nexport type PluginCommandMenuConfig = {\n /**\n * Enable backdrop blur effect\n * @default true\n */\n blurBg?: boolean\n /**\n * Custom items or groups to add to the command menu.\n */\n customItems?: (CustomMenuGroup | CustomMenuItem)[]\n /**\n * Disable the plugin functionality\n * @default false\n */\n disabled?: boolean\n /**\n * Custom icons for collections and globals.\n * Key is the collection slug, value is the icon name from lucide-react.\n * Collections default icon - Files,\n * Globals default icon - Globe.\n */\n icons?: {\n /**\n * Custom icons for collections.\n * @default <Files/>\n */\n collections?: Partial<Record<CollectionSlug, IconName>>\n /**\n * Custom icons for globals.\n * @default <Globe/>\n */\n globals?: Partial<Record<GlobalSlug, IconName>>\n }\n /**\n * Configuration for the search button in the admin navigation.\n * Set to false to disable the search button.\n * @default { position: 'actions' }\n */\n searchButton?:\n | {\n /**\n * Position of the search button in the admin navigation.\n * @default 'actions'\n */\n position?: 'actions' | 'nav'\n }\n | false\n /**\n * Keyboard shortcut to open the command menu.\n * Can be a single shortcut string or an array of shortcuts for cross-platform support.\n * @default ['meta+k', 'ctrl+k']\n * @example 'mod+k' or ['meta+k', 'ctrl+k']\n *\n * More details here - https://react-hotkeys-hook.vercel.app/docs/intro\n */\n shortcut?: string | string[]\n /**\n * Specify which collections slugs remove from the command menu.\n * @default ['payload-migrations','payload-preferences','payload-locked-documents']\n *\n * You can also provide an object with `ignoreList` and `replaceDefaults` properties.\n * `replaceDefaults` allows you to completely replace the default slugs to ignore instead of appending to them.\n */\n slugsToIgnore?:\n | {\n /**\n * List of collection/global slugs to ignore in the command menu.\n */\n ignoreList: CollectionSlug[]\n /**\n * Whether to replace the default slugs to ignore instead of appending to them.\n */\n replaceDefaults?: boolean\n }\n | CollectionSlug[]\n /**\n * Configure submenu behavior for collections.\n * When enabled, users can search within a collection's documents.\n * @default { enabled: true, shortcut: 'shift+enter' }\n */\n submenu?: {\n /**\n * Enable or disable submenu functionality.\n * @default true\n */\n enabled?: boolean\n /**\n * Custom icons for collection submenus.\n * Key is the collection slug, value is the icon name from lucide-react.\n *\n * @default null\n */\n icons?: Partial<Record<CollectionSlug, IconName>>\n /**\n * Keyboard shortcut to open collection submenu.\n * - 'shift+enter': Shift+Enter opens submenu, Enter navigates to collection list\n * - 'enter': Enter opens submenu, Shift+Enter navigates to collection list\n * @default 'shift+enter'\n */\n shortcut?: 'enter' | 'shift+enter'\n }\n}\n\nexport interface CommandMenuContextProps {\n children: React.ReactNode\n pluginConfig: PluginCommandMenuConfig\n}\n\nexport interface CommandMenuActionLink {\n href: string\n type: 'link'\n}\n\nexport interface CommandMenuActionAPICall {\n body?: {\n [key: string]: unknown\n }\n href: string\n /**\n * HTTP method to use for the API call.\n * @default 'GET'\n */\n method?: 'DELETE' | 'GET' | 'POST' | 'PUT'\n type: 'api'\n}\n\nexport type CommandMenuAction = CommandMenuActionAPICall | CommandMenuActionLink\n\nexport interface CommandMenuItem {\n /**\n * Action to perform when the command menu item is selected.\n */\n action: CommandMenuAction\n icon?: InternalIcon\n label: string\n slug: string\n /**\n * Type of the command menu item. Used for grouping and icons.\n * @default 'custom'\n */\n type: 'collection' | 'custom' | 'global'\n\n /**\n * Field name used as title for collection documents.\n * Only applicable for collection type items.\n * Defaults to 'id' if not specified.\n */\n useAsTitle?: string\n /**\n * Label for the field used as title for collection documents.\n * Only applicable for collection type items.\n *\n * Used in submenu search placeholder.\n */\n useAsTitleLabel?: string\n}\n\nexport interface CommandMenuGroup {\n items: CommandMenuItem[]\n title: string\n}\n\n/**\n * Page state for command menu navigation.\n * - 'main': Default view showing all collections/globals/custom items\n * - CollectionSearchPage: Submenu view for searching within a specific collection\n */\nexport type CommandMenuPage =\n | 'main'\n | {\n /**\n * Collection label for display\n */\n label: string\n /**\n * Collection slug\n */\n slug: string\n /**\n * Page type identifier\n */\n type: 'collection-search'\n /**\n * Field name to use as document title\n */\n useAsTitle: string\n /**\n * Label for the field used as title\n */\n useAsTitleLabel: string\n }\n\n/**\n * Generic document type for collections, with dynamic keys.\n * We assume values are either string or number for simplicity, useAsTitle is making sure of that.\n */\nexport type GenericCollectionDocument = {\n [key: string]: number | string\n id: string\n}\n"],"names":[],"mappings":"AAmOA;;;CAGC,GACD,WAGC"}
|
package/package.json
CHANGED