@mijn-ui/react-select 0.0.7 → 0.0.8

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 CHANGED
@@ -1,4 +1,3 @@
1
-
2
1
  # @mijn-ui/react-select
3
2
 
4
3
  A dropdown selector for single or multiple options.
package/dist/index.d.ts CHANGED
@@ -7,9 +7,7 @@ declare const SelectGroup: React.ForwardRefExoticComponent<SelectPrimitive.Selec
7
7
  declare const SelectValue: React.ForwardRefExoticComponent<SelectPrimitive.SelectValueProps & React.RefAttributes<HTMLSpanElement>>;
8
8
  type SelectProps = React.ComponentProps<typeof SelectPrimitive.Root> & UnstyledProps;
9
9
  declare const Select: ({ unstyled, ...props }: SelectProps) => react_jsx_runtime.JSX.Element;
10
- type SelectTriggerProps = React.ComponentPropsWithRef<typeof SelectPrimitive.Trigger> & UnstyledProps & {
11
- icon?: React.ReactNode;
12
- };
10
+ type SelectTriggerProps = React.ComponentPropsWithRef<typeof SelectPrimitive.Trigger> & UnstyledProps;
13
11
  declare const SelectTrigger: ({ unstyled, className, children, ...props }: SelectTriggerProps) => react_jsx_runtime.JSX.Element;
14
12
  type SelectScrollUpButtonProps = React.ComponentPropsWithRef<typeof SelectPrimitive.ScrollUpButton> & UnstyledProps;
15
13
  declare const SelectScrollUpButton: ({ unstyled, className, ...props }: SelectScrollUpButtonProps) => react_jsx_runtime.JSX.Element;
package/dist/index.js CHANGED
@@ -1,22 +1,30 @@
1
1
  "use client"
2
2
 
3
3
  // src/select.tsx
4
- import { UnstyledProvider, useUnstyled } from "@mijn-ui/react-utilities/context";
5
- import {
6
- applyUnstyled,
7
- cn
8
- } from "@mijn-ui/react-utilities/shared";
4
+ import { createContext } from "@mijn-ui/react-utilities/context";
9
5
  import * as SelectPrimitive from "@radix-ui/react-select";
10
6
  import {
11
7
  CheckIcon,
12
8
  ChevronDownIcon,
13
9
  ChevronUpIcon
14
10
  } from "@mijn-ui/shared-icons";
11
+ import { selectStyles } from "@mijn-ui/react-theme";
12
+ import { useTVUnstyled } from "@mijn-ui/react-hooks";
15
13
  import { jsx, jsxs } from "react/jsx-runtime";
14
+ var [SelectProvider, useSelectContext] = createContext({
15
+ name: "SelectContext",
16
+ strict: true,
17
+ errorMessage: "useSelectContext: `context` is undefined. Seems you forgot to wrap component within <Select />"
18
+ });
19
+ var useSelectStyles = (unstyledOverride) => {
20
+ const context = useSelectContext();
21
+ return useTVUnstyled(context, unstyledOverride);
22
+ };
16
23
  var SelectGroup = SelectPrimitive.Group;
17
24
  var SelectValue = SelectPrimitive.Value;
18
25
  var Select = ({ unstyled = false, ...props }) => {
19
- return /* @__PURE__ */ jsx(UnstyledProvider, { unstyled, children: /* @__PURE__ */ jsx(SelectPrimitive.Root, { ...props }) });
26
+ const styles = selectStyles();
27
+ return /* @__PURE__ */ jsx(SelectProvider, { value: { unstyled, styles }, children: /* @__PURE__ */ jsx(SelectPrimitive.Root, { ...props }) });
20
28
  };
21
29
  var SelectTrigger = ({
22
30
  unstyled,
@@ -24,41 +32,24 @@ var SelectTrigger = ({
24
32
  children,
25
33
  ...props
26
34
  }) => {
27
- const { unstyled: contextUnstyled } = useUnstyled();
28
- const isUnstyled = unstyled ?? contextUnstyled;
29
- return /* @__PURE__ */ jsxs(
30
- SelectPrimitive.Trigger,
31
- {
32
- className: applyUnstyled(
33
- isUnstyled,
34
- "flex h-10 w-full items-center justify-between rounded-md border border-main-border bg-surface px-3 py-2 text-sm placeholder:text-muted-text focus:border-input-border focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1 hover:bg-accent",
35
- className
36
- ),
37
- ...props,
38
- children: [
39
- children,
40
- /* @__PURE__ */ jsx(SelectPrimitive.Icon, { asChild: true, children: /* @__PURE__ */ jsx(ChevronDownIcon, { className: "size-4 opacity-50" }) })
41
- ]
42
- }
43
- );
35
+ const { trigger } = useSelectStyles(unstyled);
36
+ return /* @__PURE__ */ jsxs(SelectPrimitive.Trigger, { className: trigger({ className }), ...props, children: [
37
+ children,
38
+ /* @__PURE__ */ jsx(SelectPrimitive.Icon, { asChild: true, children: /* @__PURE__ */ jsx(ChevronDownIcon, {}) })
39
+ ] });
44
40
  };
45
41
  var SelectScrollUpButton = ({
46
42
  unstyled,
47
43
  className,
48
44
  ...props
49
45
  }) => {
50
- const { unstyled: contextUnstyled } = useUnstyled();
51
- const isUnstyled = unstyled ?? contextUnstyled;
46
+ const { scrollUpBtn } = useSelectStyles(unstyled);
52
47
  return /* @__PURE__ */ jsx(
53
48
  SelectPrimitive.ScrollUpButton,
54
49
  {
55
- className: applyUnstyled(
56
- isUnstyled,
57
- "flex cursor-default items-center justify-center py-1",
58
- className
59
- ),
50
+ className: scrollUpBtn({ className }),
60
51
  ...props,
61
- children: /* @__PURE__ */ jsx(ChevronUpIcon, { className: "size-4" })
52
+ children: /* @__PURE__ */ jsx(ChevronUpIcon, { className: "" })
62
53
  }
63
54
  );
64
55
  };
@@ -67,16 +58,11 @@ var SelectScrollDownButton = ({
67
58
  className,
68
59
  ...props
69
60
  }) => {
70
- const { unstyled: contextUnstyled } = useUnstyled();
71
- const isUnstyled = unstyled ?? contextUnstyled;
61
+ const { scrollDownBtn } = useSelectStyles(unstyled);
72
62
  return /* @__PURE__ */ jsx(
73
63
  SelectPrimitive.ScrollDownButton,
74
64
  {
75
- className: applyUnstyled(
76
- isUnstyled,
77
- "flex cursor-default items-center justify-center py-1",
78
- className
79
- ),
65
+ className: scrollDownBtn({ className }),
80
66
  ...props,
81
67
  children: /* @__PURE__ */ jsx(ChevronDownIcon, { className: "size-4" })
82
68
  }
@@ -89,52 +75,24 @@ var SelectContent = ({
89
75
  position = "popper",
90
76
  ...props
91
77
  }) => {
92
- const { unstyled: contextUnstyled } = useUnstyled();
93
- const isUnstyled = unstyled ?? contextUnstyled;
78
+ const { content, viewport } = useSelectStyles(unstyled);
94
79
  return /* @__PURE__ */ jsx(SelectPrimitive.Portal, { children: /* @__PURE__ */ jsxs(
95
80
  SelectPrimitive.Content,
96
81
  {
97
- className: applyUnstyled(
98
- isUnstyled,
99
- cn(
100
- "border-main-border bg-surface text-surface-text 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 relative z-50 max-h-96 min-w-32 overflow-hidden rounded-lg border shadow-md !duration-300",
101
- position === "popper" && "data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1"
102
- ),
103
- className
104
- ),
82
+ className: content({ position, className }),
105
83
  position,
106
84
  ...props,
107
85
  children: [
108
86
  /* @__PURE__ */ jsx(SelectScrollUpButton, {}),
109
- /* @__PURE__ */ jsx(
110
- SelectPrimitive.Viewport,
111
- {
112
- className: cn(
113
- "p-1",
114
- position === "popper" && "h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"
115
- ),
116
- children
117
- }
118
- ),
87
+ /* @__PURE__ */ jsx(SelectPrimitive.Viewport, { className: viewport({ position }), children }),
119
88
  /* @__PURE__ */ jsx(SelectScrollDownButton, {})
120
89
  ]
121
90
  }
122
91
  ) });
123
92
  };
124
93
  var SelectLabel = ({ unstyled, className, ...props }) => {
125
- const { unstyled: contextUnstyled } = useUnstyled();
126
- const isUnstyled = unstyled ?? contextUnstyled;
127
- return /* @__PURE__ */ jsx(
128
- SelectPrimitive.Label,
129
- {
130
- className: applyUnstyled(
131
- isUnstyled,
132
- "py-1.5 pr-8 pl-2 text-sm font-semibold",
133
- className
134
- ),
135
- ...props
136
- }
137
- );
94
+ const { label } = useSelectStyles(unstyled);
95
+ return /* @__PURE__ */ jsx(SelectPrimitive.Label, { className: label({ className }), ...props });
138
96
  };
139
97
  var SelectItem = ({
140
98
  unstyled,
@@ -142,48 +100,22 @@ var SelectItem = ({
142
100
  children,
143
101
  ...props
144
102
  }) => {
145
- const { unstyled: contextUnstyled } = useUnstyled();
146
- const isUnstyled = unstyled ?? contextUnstyled;
147
- return /* @__PURE__ */ jsxs(
148
- SelectPrimitive.Item,
149
- {
150
- className: applyUnstyled(
151
- isUnstyled,
152
- "relative flex w-full cursor-default select-none items-center rounded-md py-1.5 pr-8 pl-2 text-sm outline-none focus:bg-accent focus:text-accent-text data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[state=checked]:text-primary data-[state=checked]:bg-primary/10",
153
- className
154
- ),
155
- ...props,
156
- children: [
157
- /* @__PURE__ */ jsx(SelectPrimitive.ItemText, { children }),
158
- /* @__PURE__ */ jsx(
159
- "span",
160
- {
161
- className: applyUnstyled(
162
- isUnstyled,
163
- "absolute right-2 flex h-3.5 w-3.5 items-center justify-center"
164
- ),
165
- children: /* @__PURE__ */ jsx(SelectPrimitive.ItemIndicator, { children: /* @__PURE__ */ jsx(CheckIcon, { className: "size-4" }) })
166
- }
167
- )
168
- ]
169
- }
170
- );
103
+ const { item, itemIndicator } = useSelectStyles(unstyled);
104
+ return /* @__PURE__ */ jsxs(SelectPrimitive.Item, { className: item({ className }), ...props, children: [
105
+ /* @__PURE__ */ jsx(SelectPrimitive.ItemText, { children }),
106
+ /* @__PURE__ */ jsx("span", { className: itemIndicator(), children: /* @__PURE__ */ jsx(SelectPrimitive.ItemIndicator, { children: /* @__PURE__ */ jsx(CheckIcon, {}) }) })
107
+ ] });
171
108
  };
172
109
  var SelectSeparator = ({
173
110
  unstyled,
174
111
  className,
175
112
  ...props
176
113
  }) => {
177
- const { unstyled: contextUnstyled } = useUnstyled();
178
- const isUnstyled = unstyled ?? contextUnstyled;
114
+ const { separator } = useSelectStyles(unstyled);
179
115
  return /* @__PURE__ */ jsx(
180
116
  SelectPrimitive.Separator,
181
117
  {
182
- className: applyUnstyled(
183
- isUnstyled,
184
- "-mx-1 my-1 h-px bg-muted",
185
- className
186
- ),
118
+ className: separator({ className }),
187
119
  ...props
188
120
  }
189
121
  );
@@ -1 +1 @@
1
- {"inputs":{"src/select.tsx":{"bytes":8941,"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-select","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":25,"imports":[{"path":"src/select.tsx","kind":"import-statement","original":"./select"}],"format":"esm"}},"outputs":{"dist/index.js":{"imports":[{"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-select","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":["Select","SelectContent","SelectGroup","SelectItem","SelectLabel","SelectScrollDownButton","SelectScrollUpButton","SelectSeparator","SelectTrigger","SelectValue"],"entryPoint":"src/index.ts","inputs":{"src/select.tsx":{"bytesInOutput":5963},"src/index.ts":{"bytesInOutput":0}},"bytes":6164}}}
1
+ {"inputs":{"src/select.tsx":{"bytes":7432,"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-select","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":25,"imports":[{"path":"src/select.tsx","kind":"import-statement","original":"./select"}],"format":"esm"}},"outputs":{"dist/index.js":{"imports":[{"path":"@mijn-ui/react-utilities/context","kind":"import-statement","external":true},{"path":"@radix-ui/react-select","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":["Select","SelectContent","SelectGroup","SelectItem","SelectLabel","SelectScrollDownButton","SelectScrollUpButton","SelectSeparator","SelectTrigger","SelectValue"],"entryPoint":"src/index.ts","inputs":{"src/select.tsx":{"bytesInOutput":3713},"src/index.ts":{"bytesInOutput":0}},"bytes":3914}}}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mijn-ui/react-select",
3
3
  "author": "Htet Aung Lin<htetaunglin.coder@gmail.com>",
4
- "version": "0.0.7",
4
+ "version": "0.0.8",
5
5
  "homepage": "https://mijn-ui.vercel.app",
6
6
  "license": "MIT",
7
7
  "type": "module",
@@ -31,7 +31,9 @@
31
31
  "react": "19.0.0-rc-b01722d5-20241114",
32
32
  "react-dom": "19.0.0-rc-b01722d5-20241114",
33
33
  "@radix-ui/react-select": "^2.1.2",
34
- "@mijn-ui/react-utilities": "0.0.6",
34
+ "@mijn-ui/react-utilities": "0.0.7",
35
+ "@mijn-ui/react-hooks": "0.0.8",
36
+ "@mijn-ui/react-theme": "0.0.6",
35
37
  "@mijn-ui/shared-icons": "0.0.2"
36
38
  },
37
39
  "peerDependencies": {