@mijn-ui/react-command 0.0.7 → 0.0.9
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 +15 -0
- package/dist/index.js +44 -128
- package/dist/metafile-esm.json +1 -1
- package/package.json +11 -4
package/README.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# @mijn-ui/react-command
|
|
2
|
+
|
|
3
|
+
A command palette for quick access to actions and navigation, often used for keyboard shortcuts.
|
|
4
|
+
|
|
5
|
+
[Documentation](https://mijn-ui.vercel.app/docs/components/command)
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm install @mijn-ui/react-command
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## License
|
|
14
|
+
|
|
15
|
+
This project is licensed under the terms of the [MIT license.](https://github.com/mijn-ui/mijn-ui-react/blob/main/LICENSE)
|
package/dist/index.js
CHANGED
|
@@ -2,181 +2,97 @@
|
|
|
2
2
|
|
|
3
3
|
// src/command.tsx
|
|
4
4
|
import { Dialog, DialogContent } from "@mijn-ui/react-dialog";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
applyUnstyled,
|
|
8
|
-
cn
|
|
9
|
-
} from "@mijn-ui/react-utilities/shared";
|
|
5
|
+
import { createContext } from "@mijn-ui/react-utilities/context";
|
|
6
|
+
import { applyUnstyled } from "@mijn-ui/react-utilities/shared";
|
|
10
7
|
import { Command as CommandPrimitive } from "cmdk";
|
|
11
8
|
import { SearchIcon } from "@mijn-ui/shared-icons";
|
|
9
|
+
import { commandStyles } from "@mijn-ui/react-theme";
|
|
10
|
+
import { useTVUnstyled } from "@mijn-ui/react-hooks";
|
|
12
11
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
13
|
-
var
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
12
|
+
var [CommandProvider, useCommandContext] = createContext({
|
|
13
|
+
name: "CommandContext",
|
|
14
|
+
strict: true,
|
|
15
|
+
errorMessage: "useCommandContext: `context` is undefined. Seems you forgot to wrap component within <Command />"
|
|
16
|
+
});
|
|
17
|
+
var useCommandStyles = (unstyledOverride) => {
|
|
18
|
+
const context = useCommandContext();
|
|
19
|
+
return useTVUnstyled(context, unstyledOverride);
|
|
20
|
+
};
|
|
21
|
+
var Command = ({ unstyled = false, className, ...props }) => {
|
|
22
|
+
const styles = commandStyles();
|
|
23
|
+
return /* @__PURE__ */ jsx(CommandProvider, { value: { unstyled, styles }, children: /* @__PURE__ */ jsx(
|
|
24
|
+
CommandPrimitive,
|
|
25
|
+
{
|
|
26
|
+
className: applyUnstyled(unstyled, styles.command({ className })),
|
|
27
|
+
...props
|
|
28
|
+
}
|
|
29
|
+
) });
|
|
30
|
+
};
|
|
23
31
|
var CommandDialog = ({
|
|
24
32
|
children,
|
|
25
33
|
unstyled,
|
|
26
34
|
...props
|
|
27
35
|
}) => {
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
return /* @__PURE__ */ jsx(Dialog, { ...props, children: /* @__PURE__ */ jsx(
|
|
36
|
+
const styles = commandStyles();
|
|
37
|
+
return /* @__PURE__ */ jsx(CommandProvider, { value: { unstyled, styles }, children: /* @__PURE__ */ jsx(Dialog, { ...props, children: /* @__PURE__ */ jsx(
|
|
31
38
|
DialogContent,
|
|
32
39
|
{
|
|
33
|
-
className: applyUnstyled(
|
|
34
|
-
children: /* @__PURE__ */ jsx(
|
|
35
|
-
Command,
|
|
36
|
-
{
|
|
37
|
-
className: applyUnstyled(
|
|
38
|
-
isUnstyled,
|
|
39
|
-
"[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-text [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5"
|
|
40
|
-
),
|
|
41
|
-
children
|
|
42
|
-
}
|
|
43
|
-
)
|
|
40
|
+
className: applyUnstyled(unstyled, styles.dialogContent()),
|
|
41
|
+
children: /* @__PURE__ */ jsx(Command, { className: applyUnstyled(unstyled, styles.dialogCommand()), children })
|
|
44
42
|
}
|
|
45
|
-
) });
|
|
43
|
+
) }) });
|
|
46
44
|
};
|
|
47
45
|
var CommandInput = ({ className, unstyled, ...props }) => {
|
|
48
|
-
const {
|
|
49
|
-
const isUnstyled = unstyled ?? contextUnstyled;
|
|
46
|
+
const { input, inputIcon, inputWrapper } = useCommandStyles(unstyled);
|
|
50
47
|
return /* @__PURE__ */ jsxs(
|
|
51
48
|
"div",
|
|
52
49
|
{
|
|
53
|
-
className:
|
|
54
|
-
isUnstyled,
|
|
55
|
-
"flex items-center border-b border-main-border px-3"
|
|
56
|
-
),
|
|
50
|
+
className: inputWrapper(),
|
|
57
51
|
"cmdk-input-wrapper": "",
|
|
58
52
|
children: [
|
|
59
|
-
/* @__PURE__ */ jsx(
|
|
60
|
-
|
|
61
|
-
{
|
|
62
|
-
className: applyUnstyled(
|
|
63
|
-
isUnstyled,
|
|
64
|
-
"mr-2 h-4 w-4 shrink-0 opacity-50"
|
|
65
|
-
)
|
|
66
|
-
}
|
|
67
|
-
),
|
|
68
|
-
/* @__PURE__ */ jsx(
|
|
69
|
-
CommandPrimitive.Input,
|
|
70
|
-
{
|
|
71
|
-
className: applyUnstyled(
|
|
72
|
-
isUnstyled,
|
|
73
|
-
"flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-text disabled:cursor-not-allowed disabled:opacity-50",
|
|
74
|
-
className
|
|
75
|
-
),
|
|
76
|
-
...props
|
|
77
|
-
}
|
|
78
|
-
)
|
|
53
|
+
/* @__PURE__ */ jsx(SearchIcon, { className: inputIcon() }),
|
|
54
|
+
/* @__PURE__ */ jsx(CommandPrimitive.Input, { className: input({ className }), ...props })
|
|
79
55
|
]
|
|
80
56
|
}
|
|
81
57
|
);
|
|
82
58
|
};
|
|
83
59
|
var CommandList = ({ className, unstyled, ...props }) => {
|
|
84
|
-
const {
|
|
85
|
-
|
|
86
|
-
return /* @__PURE__ */ jsx(
|
|
87
|
-
CommandPrimitive.List,
|
|
88
|
-
{
|
|
89
|
-
className: applyUnstyled(
|
|
90
|
-
isUnstyled,
|
|
91
|
-
"max-h-[300px] overflow-y-auto overflow-x-hidden",
|
|
92
|
-
className
|
|
93
|
-
),
|
|
94
|
-
...props
|
|
95
|
-
}
|
|
96
|
-
);
|
|
60
|
+
const { list } = useCommandStyles(unstyled);
|
|
61
|
+
return /* @__PURE__ */ jsx(CommandPrimitive.List, { className: list({ className }), ...props });
|
|
97
62
|
};
|
|
98
63
|
var CommandEmpty = ({ unstyled, className, ...props }) => {
|
|
99
|
-
const {
|
|
100
|
-
|
|
101
|
-
return /* @__PURE__ */ jsx(
|
|
102
|
-
CommandPrimitive.Empty,
|
|
103
|
-
{
|
|
104
|
-
className: applyUnstyled(
|
|
105
|
-
isUnstyled,
|
|
106
|
-
"py-6 text-center text-sm",
|
|
107
|
-
className
|
|
108
|
-
),
|
|
109
|
-
...props
|
|
110
|
-
}
|
|
111
|
-
);
|
|
64
|
+
const { empty } = useCommandStyles(unstyled);
|
|
65
|
+
return /* @__PURE__ */ jsx(CommandPrimitive.Empty, { className: empty({ className }), ...props });
|
|
112
66
|
};
|
|
113
67
|
var CommandGroup = ({ className, unstyled, ...props }) => {
|
|
114
|
-
const {
|
|
115
|
-
|
|
116
|
-
return /* @__PURE__ */ jsx(
|
|
117
|
-
CommandPrimitive.Group,
|
|
118
|
-
{
|
|
119
|
-
className: applyUnstyled(
|
|
120
|
-
isUnstyled,
|
|
121
|
-
"text-text overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-text",
|
|
122
|
-
className
|
|
123
|
-
),
|
|
124
|
-
...props
|
|
125
|
-
}
|
|
126
|
-
);
|
|
68
|
+
const { group } = useCommandStyles(unstyled);
|
|
69
|
+
return /* @__PURE__ */ jsx(CommandPrimitive.Group, { className: group({ className }), ...props });
|
|
127
70
|
};
|
|
128
71
|
var CommandSeparator = ({
|
|
129
72
|
className,
|
|
130
73
|
unstyled,
|
|
131
74
|
...props
|
|
132
75
|
}) => {
|
|
133
|
-
const {
|
|
134
|
-
const isUnstyled = unstyled ?? contextUnstyled;
|
|
76
|
+
const { separator } = useCommandStyles(unstyled);
|
|
135
77
|
return /* @__PURE__ */ jsx(
|
|
136
78
|
CommandPrimitive.Separator,
|
|
137
79
|
{
|
|
138
|
-
className:
|
|
139
|
-
isUnstyled,
|
|
140
|
-
"-mx-1 h-px bg-main-border",
|
|
141
|
-
className
|
|
142
|
-
),
|
|
80
|
+
className: separator({ className }),
|
|
143
81
|
...props
|
|
144
82
|
}
|
|
145
83
|
);
|
|
146
84
|
};
|
|
147
85
|
var CommandItem = ({ className, unstyled, ...props }) => {
|
|
148
|
-
const {
|
|
149
|
-
|
|
150
|
-
return /* @__PURE__ */ jsx(
|
|
151
|
-
CommandPrimitive.Item,
|
|
152
|
-
{
|
|
153
|
-
className: applyUnstyled(
|
|
154
|
-
isUnstyled,
|
|
155
|
-
"relative flex cursor-default select-none items-center rounded-md px-2 py-1.5 text-sm outline-none data-[disabled]:pointer-events-auto data-[selected='true']:bg-accent data-[selected=true]:text-accent-text data-[disabled=true]:opacity-50",
|
|
156
|
-
className
|
|
157
|
-
),
|
|
158
|
-
...props
|
|
159
|
-
}
|
|
160
|
-
);
|
|
86
|
+
const { item } = useCommandStyles(unstyled);
|
|
87
|
+
return /* @__PURE__ */ jsx(CommandPrimitive.Item, { className: item({ className }), ...props });
|
|
161
88
|
};
|
|
162
89
|
var CommandShortcut = ({
|
|
163
90
|
className,
|
|
164
91
|
unstyled,
|
|
165
92
|
...props
|
|
166
93
|
}) => {
|
|
167
|
-
const {
|
|
168
|
-
|
|
169
|
-
return /* @__PURE__ */ jsx(
|
|
170
|
-
"span",
|
|
171
|
-
{
|
|
172
|
-
className: applyUnstyled(
|
|
173
|
-
isUnstyled,
|
|
174
|
-
"ml-auto text-xs tracking-widest text-muted-text",
|
|
175
|
-
className
|
|
176
|
-
),
|
|
177
|
-
...props
|
|
178
|
-
}
|
|
179
|
-
);
|
|
94
|
+
const { shortcut } = useCommandStyles(unstyled);
|
|
95
|
+
return /* @__PURE__ */ jsx("span", { className: shortcut({ className }), ...props });
|
|
180
96
|
};
|
|
181
97
|
export {
|
|
182
98
|
Command,
|
package/dist/metafile-esm.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"src/command.tsx":{"bytes":
|
|
1
|
+
{"inputs":{"src/command.tsx":{"bytes":7293,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"@mijn-ui/react-dialog","kind":"import-statement","external":true},{"path":"@mijn-ui/react-utilities/context","kind":"import-statement","external":true},{"path":"@mijn-ui/react-utilities/shared","kind":"import-statement","external":true},{"path":"@radix-ui/react-dialog","kind":"import-statement","external":true},{"path":"cmdk","kind":"import-statement","external":true},{"path":"@mijn-ui/shared-icons","kind":"import-statement","external":true},{"path":"@mijn-ui/react-theme","kind":"import-statement","external":true},{"path":"@mijn-ui/react-hooks","kind":"import-statement","external":true},{"path":"react/jsx-runtime","kind":"import-statement","external":true}],"format":"esm"},"src/index.ts":{"bytes":26,"imports":[{"path":"src/command.tsx","kind":"import-statement","original":"./command"}],"format":"esm"}},"outputs":{"dist/index.js":{"imports":[{"path":"@mijn-ui/react-dialog","kind":"import-statement","external":true},{"path":"@mijn-ui/react-utilities/context","kind":"import-statement","external":true},{"path":"@mijn-ui/react-utilities/shared","kind":"import-statement","external":true},{"path":"cmdk","kind":"import-statement","external":true},{"path":"@mijn-ui/shared-icons","kind":"import-statement","external":true},{"path":"@mijn-ui/react-theme","kind":"import-statement","external":true},{"path":"@mijn-ui/react-hooks","kind":"import-statement","external":true},{"path":"react/jsx-runtime","kind":"import-statement","external":true}],"exports":["Command","CommandDialog","CommandEmpty","CommandGroup","CommandInput","CommandItem","CommandList","CommandSeparator","CommandShortcut"],"entryPoint":"src/index.ts","inputs":{"src/command.tsx":{"bytesInOutput":3406},"src/index.ts":{"bytesInOutput":0}},"bytes":3581}}}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mijn-ui/react-command",
|
|
3
3
|
"author": "Htet Aung Lin<htetaunglin.coder@gmail.com>",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.9",
|
|
5
5
|
"homepage": "https://mijn-ui.vercel.app",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"type": "module",
|
|
@@ -32,9 +32,11 @@
|
|
|
32
32
|
"react-dom": "19.0.0-rc-b01722d5-20241114",
|
|
33
33
|
"cmdk": "^1.0.4",
|
|
34
34
|
"@radix-ui/react-dialog": "^1.1.2",
|
|
35
|
-
"@mijn-ui/shared-icons": "0.0.
|
|
36
|
-
"@mijn-ui/react-
|
|
37
|
-
"@mijn-ui/react-
|
|
35
|
+
"@mijn-ui/shared-icons": "0.0.2",
|
|
36
|
+
"@mijn-ui/react-theme": "0.0.6",
|
|
37
|
+
"@mijn-ui/react-utilities": "0.0.7",
|
|
38
|
+
"@mijn-ui/react-hooks": "0.0.8",
|
|
39
|
+
"@mijn-ui/react-dialog": "0.0.9"
|
|
38
40
|
},
|
|
39
41
|
"peerDependencies": {
|
|
40
42
|
"react": "^19.0",
|
|
@@ -43,6 +45,11 @@
|
|
|
43
45
|
"publishConfig": {
|
|
44
46
|
"access": "public"
|
|
45
47
|
},
|
|
48
|
+
"keywords": [
|
|
49
|
+
"command",
|
|
50
|
+
"react",
|
|
51
|
+
"nextjs"
|
|
52
|
+
],
|
|
46
53
|
"scripts": {
|
|
47
54
|
"clean": "rimraf dist",
|
|
48
55
|
"build": "tsup",
|