@choice-ui/command 0.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.
@@ -0,0 +1,130 @@
1
+ import * as _choice_ui_tabs from '@choice-ui/tabs';
2
+ import * as react from 'react';
3
+ import react__default, { HTMLProps, ReactNode } from 'react';
4
+ import { InputProps } from '@choice-ui/input';
5
+ import { KbdKey } from '@choice-ui/kbd';
6
+ import { ScrollAreaProps } from '@choice-ui/scroll-area';
7
+
8
+ interface CommandEmptyProps extends HTMLProps<HTMLDivElement> {
9
+ className?: string;
10
+ }
11
+
12
+ interface CommandGroupProps extends HTMLProps<HTMLDivElement> {
13
+ forceMount?: boolean;
14
+ heading?: react__default.ReactNode;
15
+ value?: string;
16
+ }
17
+
18
+ interface CommandInputProps extends Omit<InputProps, "value" | "onChange" | "type"> {
19
+ onChange?: (search: string) => void;
20
+ prefixElement?: ReactNode;
21
+ suffixElement?: ReactNode;
22
+ value?: string;
23
+ }
24
+
25
+ interface CommandItemProps extends Omit<HTMLProps<HTMLDivElement>, "onSelect"> {
26
+ disabled?: boolean;
27
+ forceMount?: boolean;
28
+ keywords?: string[];
29
+ onSelect?: (value: string) => void;
30
+ prefixElement?: ReactNode;
31
+ shortcut?: {
32
+ keys?: ReactNode;
33
+ modifier?: KbdKey | KbdKey[] | undefined;
34
+ };
35
+ suffixElement?: ReactNode;
36
+ value?: string;
37
+ }
38
+
39
+ interface CommandListProps extends ScrollAreaProps {
40
+ children: React.ReactNode;
41
+ className?: string;
42
+ label?: string;
43
+ }
44
+
45
+ interface CommandLoadingProps extends react__default.HTMLAttributes<HTMLDivElement> {
46
+ label?: string;
47
+ progress?: number;
48
+ }
49
+
50
+ interface CommandDividerProps extends HTMLProps<HTMLDivElement> {
51
+ /** 是否始终渲染此分隔符。当禁用自动过滤功能时特别有用。 */
52
+ alwaysRender?: boolean;
53
+ }
54
+
55
+ type CommandFilter = (value: string, search: string, keywords?: string[]) => number;
56
+ interface CommandProps extends Omit<react__default.HTMLAttributes<HTMLDivElement>, "onChange"> {
57
+ /**
58
+ * Optional default item value when it is initially rendered.
59
+ */
60
+ defaultValue?: string;
61
+ /**
62
+ * Optionally set to `true` to disable selection via pointer events.
63
+ */
64
+ disablePointerSelection?: boolean;
65
+ /**
66
+ * Custom filter function for whether each command menu item should matches the given search query.
67
+ * It should return a number between 0 and 1, with 1 being the best match and 0 being hidden entirely.
68
+ * By default, uses the `command-score` library.
69
+ */
70
+ filter?: CommandFilter;
71
+ /**
72
+ * Accessible label for this command menu. Not shown visibly.
73
+ */
74
+ label?: string;
75
+ /**
76
+ * Optionally set to `true` to turn on looping around when using the arrow keys.
77
+ */
78
+ loop?: boolean;
79
+ /**
80
+ * Event handler called when the selected item of the menu changes.
81
+ */
82
+ onChange?: (value: string) => void;
83
+ /**
84
+ * Optionally set to `false` to turn off the automatic filtering and sorting.
85
+ * If `false`, you must conditionally render valid items based on the search query yourself.
86
+ */
87
+ shouldFilter?: boolean;
88
+ size?: "default" | "large";
89
+ /**
90
+ * Optional controlled state of the selected command menu item.
91
+ */
92
+ value?: string;
93
+ variant?: "default" | "dark";
94
+ /**
95
+ * Set to `false` to disable ctrl+n/j/p/k shortcuts. Defaults to `true`.
96
+ */
97
+ vimBindings?: boolean;
98
+ }
99
+ type State = {
100
+ filtered: {
101
+ count: number;
102
+ groups: Set<string>;
103
+ items: Map<string, number>;
104
+ };
105
+ search: string;
106
+ selectedItemId?: string;
107
+ value: string;
108
+ };
109
+
110
+ declare const defaultFilter: CommandFilter;
111
+ declare const Command$1: react__default.ForwardRefExoticComponent<CommandProps & react__default.RefAttributes<HTMLDivElement>>;
112
+
113
+ /** Run a selector against the store state. */
114
+ declare function useCommandState<T>(selector: (state: State) => T): T;
115
+
116
+ declare const Command: react.ForwardRefExoticComponent<CommandProps & react.RefAttributes<HTMLDivElement>> & {
117
+ Empty: react.ForwardRefExoticComponent<Omit<CommandEmptyProps, "ref"> & react.RefAttributes<HTMLDivElement>>;
118
+ Footer: react.ForwardRefExoticComponent<Omit<react.HTMLProps<HTMLDivElement>, "ref"> & react.RefAttributes<HTMLDivElement>>;
119
+ Group: react.ForwardRefExoticComponent<Omit<CommandGroupProps, "ref"> & react.RefAttributes<HTMLDivElement>>;
120
+ Input: react.ForwardRefExoticComponent<Omit<CommandInputProps, "ref"> & react.RefAttributes<HTMLInputElement>>;
121
+ Item: react.ForwardRefExoticComponent<Omit<CommandItemProps, "ref"> & react.RefAttributes<HTMLDivElement>>;
122
+ List: react.ForwardRefExoticComponent<CommandListProps & react.RefAttributes<HTMLDivElement>>;
123
+ Loading: react.ForwardRefExoticComponent<CommandLoadingProps & react.RefAttributes<HTMLDivElement>>;
124
+ Divider: react.ForwardRefExoticComponent<Omit<CommandDividerProps, "ref"> & react.RefAttributes<HTMLDivElement>>;
125
+ Value: react.ForwardRefExoticComponent<Omit<react.HTMLProps<HTMLDivElement>, "ref"> & react.RefAttributes<HTMLDivElement>>;
126
+ Tabs: react.ForwardRefExoticComponent<Omit<_choice_ui_tabs.TabsProps, "ref"> & react.RefAttributes<HTMLDivElement>>;
127
+ TabItem: react.MemoExoticComponent<react.ForwardRefExoticComponent<Omit<_choice_ui_tabs.TabItemProps, "ref"> & react.RefAttributes<HTMLElement>>>;
128
+ };
129
+
130
+ export { Command, Command$1 as CommandRoot, defaultFilter, useCommandState };
@@ -0,0 +1,130 @@
1
+ import * as _choice_ui_tabs from '@choice-ui/tabs';
2
+ import * as react from 'react';
3
+ import react__default, { HTMLProps, ReactNode } from 'react';
4
+ import { InputProps } from '@choice-ui/input';
5
+ import { KbdKey } from '@choice-ui/kbd';
6
+ import { ScrollAreaProps } from '@choice-ui/scroll-area';
7
+
8
+ interface CommandEmptyProps extends HTMLProps<HTMLDivElement> {
9
+ className?: string;
10
+ }
11
+
12
+ interface CommandGroupProps extends HTMLProps<HTMLDivElement> {
13
+ forceMount?: boolean;
14
+ heading?: react__default.ReactNode;
15
+ value?: string;
16
+ }
17
+
18
+ interface CommandInputProps extends Omit<InputProps, "value" | "onChange" | "type"> {
19
+ onChange?: (search: string) => void;
20
+ prefixElement?: ReactNode;
21
+ suffixElement?: ReactNode;
22
+ value?: string;
23
+ }
24
+
25
+ interface CommandItemProps extends Omit<HTMLProps<HTMLDivElement>, "onSelect"> {
26
+ disabled?: boolean;
27
+ forceMount?: boolean;
28
+ keywords?: string[];
29
+ onSelect?: (value: string) => void;
30
+ prefixElement?: ReactNode;
31
+ shortcut?: {
32
+ keys?: ReactNode;
33
+ modifier?: KbdKey | KbdKey[] | undefined;
34
+ };
35
+ suffixElement?: ReactNode;
36
+ value?: string;
37
+ }
38
+
39
+ interface CommandListProps extends ScrollAreaProps {
40
+ children: React.ReactNode;
41
+ className?: string;
42
+ label?: string;
43
+ }
44
+
45
+ interface CommandLoadingProps extends react__default.HTMLAttributes<HTMLDivElement> {
46
+ label?: string;
47
+ progress?: number;
48
+ }
49
+
50
+ interface CommandDividerProps extends HTMLProps<HTMLDivElement> {
51
+ /** 是否始终渲染此分隔符。当禁用自动过滤功能时特别有用。 */
52
+ alwaysRender?: boolean;
53
+ }
54
+
55
+ type CommandFilter = (value: string, search: string, keywords?: string[]) => number;
56
+ interface CommandProps extends Omit<react__default.HTMLAttributes<HTMLDivElement>, "onChange"> {
57
+ /**
58
+ * Optional default item value when it is initially rendered.
59
+ */
60
+ defaultValue?: string;
61
+ /**
62
+ * Optionally set to `true` to disable selection via pointer events.
63
+ */
64
+ disablePointerSelection?: boolean;
65
+ /**
66
+ * Custom filter function for whether each command menu item should matches the given search query.
67
+ * It should return a number between 0 and 1, with 1 being the best match and 0 being hidden entirely.
68
+ * By default, uses the `command-score` library.
69
+ */
70
+ filter?: CommandFilter;
71
+ /**
72
+ * Accessible label for this command menu. Not shown visibly.
73
+ */
74
+ label?: string;
75
+ /**
76
+ * Optionally set to `true` to turn on looping around when using the arrow keys.
77
+ */
78
+ loop?: boolean;
79
+ /**
80
+ * Event handler called when the selected item of the menu changes.
81
+ */
82
+ onChange?: (value: string) => void;
83
+ /**
84
+ * Optionally set to `false` to turn off the automatic filtering and sorting.
85
+ * If `false`, you must conditionally render valid items based on the search query yourself.
86
+ */
87
+ shouldFilter?: boolean;
88
+ size?: "default" | "large";
89
+ /**
90
+ * Optional controlled state of the selected command menu item.
91
+ */
92
+ value?: string;
93
+ variant?: "default" | "dark";
94
+ /**
95
+ * Set to `false` to disable ctrl+n/j/p/k shortcuts. Defaults to `true`.
96
+ */
97
+ vimBindings?: boolean;
98
+ }
99
+ type State = {
100
+ filtered: {
101
+ count: number;
102
+ groups: Set<string>;
103
+ items: Map<string, number>;
104
+ };
105
+ search: string;
106
+ selectedItemId?: string;
107
+ value: string;
108
+ };
109
+
110
+ declare const defaultFilter: CommandFilter;
111
+ declare const Command$1: react__default.ForwardRefExoticComponent<CommandProps & react__default.RefAttributes<HTMLDivElement>>;
112
+
113
+ /** Run a selector against the store state. */
114
+ declare function useCommandState<T>(selector: (state: State) => T): T;
115
+
116
+ declare const Command: react.ForwardRefExoticComponent<CommandProps & react.RefAttributes<HTMLDivElement>> & {
117
+ Empty: react.ForwardRefExoticComponent<Omit<CommandEmptyProps, "ref"> & react.RefAttributes<HTMLDivElement>>;
118
+ Footer: react.ForwardRefExoticComponent<Omit<react.HTMLProps<HTMLDivElement>, "ref"> & react.RefAttributes<HTMLDivElement>>;
119
+ Group: react.ForwardRefExoticComponent<Omit<CommandGroupProps, "ref"> & react.RefAttributes<HTMLDivElement>>;
120
+ Input: react.ForwardRefExoticComponent<Omit<CommandInputProps, "ref"> & react.RefAttributes<HTMLInputElement>>;
121
+ Item: react.ForwardRefExoticComponent<Omit<CommandItemProps, "ref"> & react.RefAttributes<HTMLDivElement>>;
122
+ List: react.ForwardRefExoticComponent<CommandListProps & react.RefAttributes<HTMLDivElement>>;
123
+ Loading: react.ForwardRefExoticComponent<CommandLoadingProps & react.RefAttributes<HTMLDivElement>>;
124
+ Divider: react.ForwardRefExoticComponent<Omit<CommandDividerProps, "ref"> & react.RefAttributes<HTMLDivElement>>;
125
+ Value: react.ForwardRefExoticComponent<Omit<react.HTMLProps<HTMLDivElement>, "ref"> & react.RefAttributes<HTMLDivElement>>;
126
+ Tabs: react.ForwardRefExoticComponent<Omit<_choice_ui_tabs.TabsProps, "ref"> & react.RefAttributes<HTMLDivElement>>;
127
+ TabItem: react.MemoExoticComponent<react.ForwardRefExoticComponent<Omit<_choice_ui_tabs.TabItemProps, "ref"> & react.RefAttributes<HTMLElement>>>;
128
+ };
129
+
130
+ export { Command, Command$1 as CommandRoot, defaultFilter, useCommandState };