@mijn-ui/react-dropdown-menu 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 ADDED
@@ -0,0 +1,15 @@
1
+ # @mijn-ui/react-dropdown-menu
2
+
3
+ A contextual menu for displaying a list of actions or options.
4
+
5
+ [Documentation](https://mijn-ui.vercel.app/docs/components/dropdown-menu)
6
+
7
+ ## Installation
8
+
9
+ ```sh
10
+ npm install @mijn-ui/react-dropdown-menu
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
@@ -1,37 +1,39 @@
1
1
  "use client"
2
2
 
3
3
  // src/dropdown-menu.tsx
4
- import { buttonStyles } from "@mijn-ui/react-button";
5
- import { UnstyledProvider, useUnstyled } from "@mijn-ui/react-utilities/context";
6
- import {
7
- applyUnstyled,
8
- cn
9
- } from "@mijn-ui/react-utilities/shared";
4
+ import { createContext } from "@mijn-ui/react-utilities/context";
10
5
  import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
11
6
  import { CheckIcon, ChevronRightIcon, CircleIcon } from "@mijn-ui/shared-icons";
7
+ import { dropdownMenuStyles } from "@mijn-ui/react-theme";
8
+ import { useTVUnstyled } from "@mijn-ui/react-hooks";
12
9
  import { jsx, jsxs } from "react/jsx-runtime";
13
10
  var DropdownMenuGroup = DropdownMenuPrimitive.Group;
14
11
  var DropdownMenuPortal = DropdownMenuPrimitive.Portal;
15
12
  var DropdownMenuSub = DropdownMenuPrimitive.Sub;
16
13
  var DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup;
14
+ var [DropdownProvider, useDropdownContext] = createContext({
15
+ name: "DropdownContext",
16
+ strict: true,
17
+ errorMessage: "useDropdownContext: `context` is undefined. Seems you forgot to wrap component within <Dropdown />"
18
+ });
19
+ var useDropdownStyles = (unstyledOverride) => {
20
+ const context = useDropdownContext();
21
+ return useTVUnstyled(context, unstyledOverride);
22
+ };
17
23
  var DropdownMenu = ({ unstyled = false, ...props }) => {
18
- return /* @__PURE__ */ jsx(UnstyledProvider, { unstyled, children: /* @__PURE__ */ jsx(DropdownMenuPrimitive.Root, { ...props }) });
24
+ const styles = dropdownMenuStyles();
25
+ return /* @__PURE__ */ jsx(DropdownProvider, { value: { unstyled, styles }, children: /* @__PURE__ */ jsx(DropdownMenuPrimitive.Root, { ...props }) });
19
26
  };
20
27
  var DropdownMenuTrigger = ({
21
28
  unstyled,
22
29
  className,
23
30
  ...props
24
31
  }) => {
25
- const { unstyled: contextUnstyled } = useUnstyled();
26
- const isUnstyled = unstyled ?? contextUnstyled;
32
+ const { trigger } = useDropdownStyles(unstyled);
27
33
  return /* @__PURE__ */ jsx(
28
34
  DropdownMenuPrimitive.Trigger,
29
35
  {
30
- className: applyUnstyled(
31
- isUnstyled,
32
- buttonStyles({ color: "secondary" }),
33
- className
34
- ),
36
+ className: trigger({ className }),
35
37
  ...props
36
38
  }
37
39
  );
@@ -43,21 +45,11 @@ var DropdownMenuSubTrigger = ({
43
45
  children,
44
46
  ...props
45
47
  }) => {
46
- const { unstyled: contextUnstyled } = useUnstyled();
47
- const isUnstyled = unstyled ?? contextUnstyled;
48
+ const { subTrigger } = useDropdownStyles(unstyled);
48
49
  return /* @__PURE__ */ jsxs(
49
50
  DropdownMenuPrimitive.SubTrigger,
50
51
  {
51
- className: cn(
52
- applyUnstyled(
53
- isUnstyled,
54
- cn(
55
- "focus:bg-accent data-[state=open]:bg-accent flex cursor-default select-none items-center gap-2 rounded-md px-2 py-1.5 text-sm outline-none [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
56
- inset && "pl-8"
57
- ),
58
- className
59
- )
60
- ),
52
+ className: subTrigger({ className, inset }),
61
53
  ...props,
62
54
  children: [
63
55
  children,
@@ -71,16 +63,11 @@ var DropdownMenuSubContent = ({
71
63
  className,
72
64
  ...props
73
65
  }) => {
74
- const { unstyled: contextUnstyled } = useUnstyled();
75
- const isUnstyled = unstyled ?? contextUnstyled;
66
+ const { subContent } = useDropdownStyles(unstyled);
76
67
  return /* @__PURE__ */ jsx(
77
68
  DropdownMenuPrimitive.SubContent,
78
69
  {
79
- className: applyUnstyled(
80
- isUnstyled,
81
- "z-50 min-w-[8rem] overflow-hidden rounded-md border bg-surface p-1 text-surface-text shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
82
- className
83
- ),
70
+ className: subContent({ className }),
84
71
  ...props
85
72
  }
86
73
  );
@@ -91,17 +78,12 @@ var DropdownMenuContent = ({
91
78
  sideOffset = 4,
92
79
  ...props
93
80
  }) => {
94
- const { unstyled: contextUnstyled } = useUnstyled();
95
- const isUnstyled = unstyled ?? contextUnstyled;
81
+ const { content } = useDropdownStyles(unstyled);
96
82
  return /* @__PURE__ */ jsx(DropdownMenuPrimitive.Portal, { children: /* @__PURE__ */ jsx(
97
83
  DropdownMenuPrimitive.Content,
98
84
  {
99
85
  sideOffset,
100
- className: applyUnstyled(
101
- isUnstyled,
102
- "z-50 min-w-[8rem] overflow-hidden rounded-md border bg-surface p-1 text-surface-text shadow-md !duration-300 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-bottom-6 data-[side=left]:slide-in-from-left-6 data-[side=right]:slide-in-from-right-6 data-[side=top]:slide-in-from-top-6",
103
- className
104
- ),
86
+ className: content({ className }),
105
87
  ...props
106
88
  }
107
89
  ) });
@@ -112,19 +94,11 @@ var DropdownMenuItem = ({
112
94
  inset,
113
95
  ...props
114
96
  }) => {
115
- const { unstyled: contextUnstyled } = useUnstyled();
116
- const isUnstyled = unstyled ?? contextUnstyled;
97
+ const { item } = useDropdownStyles(unstyled);
117
98
  return /* @__PURE__ */ jsx(
118
99
  DropdownMenuPrimitive.Item,
119
100
  {
120
- className: applyUnstyled(
121
- isUnstyled,
122
- cn(
123
- "focus:bg-accent focus:text-accent-text relative flex cursor-default select-none items-center gap-2 rounded-md px-2 py-1.5 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
124
- inset && "pl-8"
125
- ),
126
- className
127
- ),
101
+ className: item({ className, inset }),
128
102
  ...props
129
103
  }
130
104
  );
@@ -136,29 +110,15 @@ var DropdownMenuCheckboxItem = ({
136
110
  checked,
137
111
  ...props
138
112
  }) => {
139
- const { unstyled: contextUnstyled } = useUnstyled();
140
- const isUnstyled = unstyled ?? contextUnstyled;
113
+ const { checkboxItem, checkboxItemIconWrapper, checkboxItemIcon } = useDropdownStyles(unstyled);
141
114
  return /* @__PURE__ */ jsxs(
142
115
  DropdownMenuPrimitive.CheckboxItem,
143
116
  {
144
- className: applyUnstyled(
145
- isUnstyled,
146
- "relative flex cursor-default select-none items-center rounded-md py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-text data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
147
- className
148
- ),
117
+ className: checkboxItem({ className }),
149
118
  checked,
150
119
  ...props,
151
120
  children: [
152
- /* @__PURE__ */ jsx(
153
- "span",
154
- {
155
- className: applyUnstyled(
156
- isUnstyled,
157
- "absolute left-2 flex h-3.5 w-3.5 items-center justify-center"
158
- ),
159
- children: /* @__PURE__ */ jsx(DropdownMenuPrimitive.ItemIndicator, { children: /* @__PURE__ */ jsx(CheckIcon, { className: "size-4" }) })
160
- }
161
- ),
121
+ /* @__PURE__ */ jsx("span", { className: checkboxItemIconWrapper(), children: /* @__PURE__ */ jsx(DropdownMenuPrimitive.ItemIndicator, { children: /* @__PURE__ */ jsx(CheckIcon, { className: checkboxItemIcon() }) }) }),
162
122
  children
163
123
  ]
164
124
  }
@@ -170,27 +130,14 @@ var DropdownMenuRadioItem = ({
170
130
  children,
171
131
  ...props
172
132
  }) => {
173
- const { unstyled: contextUnstyled } = useUnstyled();
174
- const isUnstyled = unstyled ?? contextUnstyled;
133
+ const { radioItem, radioItemIconWrapper, radioItemIcon } = useDropdownStyles(unstyled);
175
134
  return /* @__PURE__ */ jsxs(
176
135
  DropdownMenuPrimitive.RadioItem,
177
136
  {
178
- className: cn(
179
- "focus:bg-accent focus:text-accent-text relative flex cursor-default select-none items-center rounded-md py-1.5 pl-8 pr-2 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
180
- className
181
- ),
137
+ className: radioItem({ className }),
182
138
  ...props,
183
139
  children: [
184
- /* @__PURE__ */ jsx(
185
- "span",
186
- {
187
- className: applyUnstyled(
188
- isUnstyled,
189
- "absolute left-2 flex h-3.5 w-3.5 items-center justify-center"
190
- ),
191
- children: /* @__PURE__ */ jsx(DropdownMenuPrimitive.ItemIndicator, { children: /* @__PURE__ */ jsx(CircleIcon, { className: "size-2 fill-current" }) })
192
- }
193
- ),
140
+ /* @__PURE__ */ jsx("span", { className: radioItemIconWrapper(), children: /* @__PURE__ */ jsx(DropdownMenuPrimitive.ItemIndicator, { children: /* @__PURE__ */ jsx(CircleIcon, { className: radioItemIcon() }) }) }),
194
141
  children
195
142
  ]
196
143
  }
@@ -202,16 +149,11 @@ var DropdownMenuLabel = ({
202
149
  inset,
203
150
  ...props
204
151
  }) => {
205
- const { unstyled: contextUnstyled } = useUnstyled();
206
- const isUnstyled = unstyled ?? contextUnstyled;
152
+ const { label } = useDropdownStyles(unstyled);
207
153
  return /* @__PURE__ */ jsx(
208
154
  DropdownMenuPrimitive.Label,
209
155
  {
210
- className: applyUnstyled(
211
- isUnstyled,
212
- cn("px-2 py-1.5 text-sm font-semibold", inset && "pl-8"),
213
- className
214
- ),
156
+ className: label({ className, inset }),
215
157
  ...props
216
158
  }
217
159
  );
@@ -221,16 +163,11 @@ var DropdownMenuSeparator = ({
221
163
  unstyled,
222
164
  ...props
223
165
  }) => {
224
- const { unstyled: contextUnstyled } = useUnstyled();
225
- const isUnstyled = unstyled ?? contextUnstyled;
166
+ const { separator } = useDropdownStyles(unstyled);
226
167
  return /* @__PURE__ */ jsx(
227
168
  DropdownMenuPrimitive.Separator,
228
169
  {
229
- className: applyUnstyled(
230
- isUnstyled,
231
- "-mx-1 my-1 h-px bg-muted",
232
- className
233
- ),
170
+ className: separator({ className }),
234
171
  ...props
235
172
  }
236
173
  );
@@ -240,19 +177,8 @@ var DropdownMenuShortcut = ({
240
177
  unstyled,
241
178
  ...props
242
179
  }) => {
243
- const { unstyled: contextUnstyled } = useUnstyled();
244
- const isUnstyled = unstyled ?? contextUnstyled;
245
- return /* @__PURE__ */ jsx(
246
- "span",
247
- {
248
- className: applyUnstyled(
249
- isUnstyled,
250
- "ml-auto text-xs tracking-widest opacity-60",
251
- className
252
- ),
253
- ...props
254
- }
255
- );
180
+ const { shortcut } = useDropdownStyles(unstyled);
181
+ return /* @__PURE__ */ jsx("span", { className: shortcut({ className }), ...props });
256
182
  };
257
183
  DropdownMenuShortcut.displayName = "DropdownMenuShortcut";
258
184
  export {
@@ -1 +1 @@
1
- {"inputs":{"src/dropdown-menu.tsx":{"bytes":12057,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"@mijn-ui/react-button","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-dropdown-menu","kind":"import-statement","external":true},{"path":"@mijn-ui/shared-icons","kind":"import-statement","external":true},{"path":"react/jsx-runtime","kind":"import-statement","external":true}],"format":"esm"},"src/index.ts":{"bytes":32,"imports":[{"path":"src/dropdown-menu.tsx","kind":"import-statement","original":"./dropdown-menu"}],"format":"esm"}},"outputs":{"dist/index.js":{"imports":[{"path":"@mijn-ui/react-button","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-dropdown-menu","kind":"import-statement","external":true},{"path":"@mijn-ui/shared-icons","kind":"import-statement","external":true},{"path":"react/jsx-runtime","kind":"import-statement","external":true}],"exports":["DropdownMenu","DropdownMenuCheckboxItem","DropdownMenuContent","DropdownMenuGroup","DropdownMenuItem","DropdownMenuLabel","DropdownMenuPortal","DropdownMenuRadioGroup","DropdownMenuRadioItem","DropdownMenuSeparator","DropdownMenuShortcut","DropdownMenuSub","DropdownMenuSubContent","DropdownMenuSubTrigger","DropdownMenuTrigger"],"entryPoint":"src/index.ts","inputs":{"src/dropdown-menu.tsx":{"bytesInOutput":7819},"src/index.ts":{"bytesInOutput":0}},"bytes":8200}}}
1
+ {"inputs":{"src/dropdown-menu.tsx":{"bytes":9896,"imports":[{"path":"react","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-dropdown-menu","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":32,"imports":[{"path":"src/dropdown-menu.tsx","kind":"import-statement","original":"./dropdown-menu"}],"format":"esm"}},"outputs":{"dist/index.js":{"imports":[{"path":"@mijn-ui/react-utilities/context","kind":"import-statement","external":true},{"path":"@radix-ui/react-dropdown-menu","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":["DropdownMenu","DropdownMenuCheckboxItem","DropdownMenuContent","DropdownMenuGroup","DropdownMenuItem","DropdownMenuLabel","DropdownMenuPortal","DropdownMenuRadioGroup","DropdownMenuRadioItem","DropdownMenuSeparator","DropdownMenuShortcut","DropdownMenuSub","DropdownMenuSubContent","DropdownMenuSubTrigger","DropdownMenuTrigger"],"entryPoint":"src/index.ts","inputs":{"src/dropdown-menu.tsx":{"bytesInOutput":4870},"src/index.ts":{"bytesInOutput":0}},"bytes":5251}}}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mijn-ui/react-dropdown-menu",
3
3
  "author": "Htet Aung Lin<htetaunglin.coder@gmail.com>",
4
- "version": "0.0.7",
4
+ "version": "0.0.9",
5
5
  "homepage": "https://mijn-ui.vercel.app",
6
6
  "license": "MIT",
7
7
  "type": "module",
@@ -31,9 +31,10 @@
31
31
  "react": "19.0.0-rc-b01722d5-20241114",
32
32
  "react-dom": "19.0.0-rc-b01722d5-20241114",
33
33
  "@radix-ui/react-dropdown-menu": "^2.1.2",
34
- "@mijn-ui/shared-icons": "0.0.1",
35
- "@mijn-ui/react-button": "0.0.7",
36
- "@mijn-ui/react-utilities": "0.0.5"
34
+ "@mijn-ui/shared-icons": "0.0.2",
35
+ "@mijn-ui/react-utilities": "0.0.7",
36
+ "@mijn-ui/react-hooks": "0.0.8",
37
+ "@mijn-ui/react-theme": "0.0.6"
37
38
  },
38
39
  "peerDependencies": {
39
40
  "react": "^19.0",
@@ -42,6 +43,11 @@
42
43
  "publishConfig": {
43
44
  "access": "public"
44
45
  },
46
+ "keywords": [
47
+ "dropdown-menu",
48
+ "react",
49
+ "nextjs"
50
+ ],
45
51
  "scripts": {
46
52
  "clean": "rimraf dist",
47
53
  "build": "tsup",