@snapdragonsnursery/react-components 1.17.0 → 1.17.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@snapdragonsnursery/react-components",
3
- "version": "1.17.0",
3
+ "version": "1.17.1",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -45,6 +45,7 @@
45
45
  "@radix-ui/react-dialog": "^1.1.15",
46
46
  "@radix-ui/react-dropdown-menu": "^2.1.16",
47
47
  "@radix-ui/react-popover": "^1.1.14",
48
+ "@radix-ui/react-select": "^2.2.5",
48
49
  "@radix-ui/react-separator": "^1.1.7",
49
50
  "@radix-ui/react-slot": "^1.2.3",
50
51
  "@radix-ui/react-tooltip": "^1.2.8",
@@ -1,34 +1,155 @@
1
- // shadcn-style Select component
2
- // Provides consistent select styling across the application
1
+ //
2
+ // select.jsx
3
+ // -----------
4
+ // shadcn/ui Select component wrappers using @radix-ui/react-select.
5
+ // Import and use in forms for consistent dropdown styling.
6
+ //
7
+ // Example:
8
+ // <Select value={value} onValueChange={setValue}>
9
+ // <SelectTrigger className="w-full"><SelectValue placeholder="Select..." /></SelectTrigger>
10
+ // <SelectContent>
11
+ // <SelectItem value="site">Nursery site</SelectItem>
12
+ // <SelectItem value="custom">Custom address</SelectItem>
13
+ // </SelectContent>
14
+ // </Select>
3
15
 
4
16
  import * as React from "react";
17
+ import * as SelectPrimitive from "@radix-ui/react-select";
18
+ import { Check, ChevronDown, ChevronUp } from "lucide-react";
5
19
  import { cn } from "../../lib/utils";
6
20
 
7
- const Select = React.forwardRef(({ className, children, ...props }, ref) => {
8
- return (
9
- <select
21
+ const Select = SelectPrimitive.Root;
22
+
23
+ const SelectGroup = SelectPrimitive.Group;
24
+
25
+ const SelectValue = SelectPrimitive.Value;
26
+
27
+ const SelectTrigger = React.forwardRef(({ className, children, ...props }, ref) => (
28
+ <SelectPrimitive.Trigger
29
+ ref={ref}
30
+ className={cn(
31
+ "flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background",
32
+ "placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
33
+ "disabled:cursor-not-allowed disabled:opacity-50",
34
+ "[&>span]:line-clamp-1",
35
+ className
36
+ )}
37
+ {...props}
38
+ >
39
+ {children}
40
+ <SelectPrimitive.Icon asChild>
41
+ <ChevronDown className="h-4 w-4 opacity-50" />
42
+ </SelectPrimitive.Icon>
43
+ </SelectPrimitive.Trigger>
44
+ ));
45
+ SelectTrigger.displayName = SelectPrimitive.Trigger.displayName;
46
+
47
+ const SelectScrollUpButton = React.forwardRef(({ className, ...props }, ref) => (
48
+ <SelectPrimitive.ScrollUpButton
49
+ ref={ref}
50
+ className={cn(
51
+ "flex cursor-default items-center justify-center py-1",
52
+ className
53
+ )}
54
+ {...props}
55
+ >
56
+ <ChevronUp className="h-4 w-4" />
57
+ </SelectPrimitive.ScrollUpButton>
58
+ ));
59
+ SelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName;
60
+
61
+ const SelectScrollDownButton = React.forwardRef(({ className, ...props }, ref) => (
62
+ <SelectPrimitive.ScrollDownButton
63
+ ref={ref}
64
+ className={cn(
65
+ "flex cursor-default items-center justify-center py-1",
66
+ className
67
+ )}
68
+ {...props}
69
+ >
70
+ <ChevronDown className="h-4 w-4" />
71
+ </SelectPrimitive.ScrollDownButton>
72
+ ));
73
+ SelectScrollDownButton.displayName = SelectPrimitive.ScrollDownButton.displayName;
74
+
75
+ const SelectContent = React.forwardRef(({ className, children, position = "popper", ...props }, ref) => (
76
+ <SelectPrimitive.Portal>
77
+ <SelectPrimitive.Content
78
+ ref={ref}
10
79
  className={cn(
11
- "flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
80
+ "relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md",
81
+ "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
82
+ "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",
83
+ position === "popper" &&
84
+ "data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",
12
85
  className
13
86
  )}
14
- ref={ref}
87
+ position={position}
15
88
  {...props}
16
89
  >
17
- {children}
18
- </select>
19
- );
20
- });
21
- Select.displayName = "Select";
22
-
23
- const SelectOption = React.forwardRef(
24
- ({ className, children, ...props }, ref) => {
25
- return (
26
- <option className={cn("", className)} ref={ref} {...props}>
90
+ <SelectScrollUpButton />
91
+ <SelectPrimitive.Viewport
92
+ className={cn(
93
+ "p-1",
94
+ position === "popper" &&
95
+ "h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"
96
+ )}
97
+ >
27
98
  {children}
28
- </option>
29
- );
30
- }
31
- );
32
- SelectOption.displayName = "SelectOption";
99
+ </SelectPrimitive.Viewport>
100
+ <SelectScrollDownButton />
101
+ </SelectPrimitive.Content>
102
+ </SelectPrimitive.Portal>
103
+ ));
104
+ SelectContent.displayName = SelectPrimitive.Content.displayName;
105
+
106
+ const SelectLabel = React.forwardRef(({ className, ...props }, ref) => (
107
+ <SelectPrimitive.Label
108
+ ref={ref}
109
+ className={cn("px-2 py-1.5 text-sm font-semibold", className)}
110
+ {...props}
111
+ />
112
+ ));
113
+ SelectLabel.displayName = SelectPrimitive.Label.displayName;
114
+
115
+ const SelectItem = React.forwardRef(({ className, children, ...props }, ref) => (
116
+ <SelectPrimitive.Item
117
+ ref={ref}
118
+ className={cn(
119
+ "relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none",
120
+ "focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
121
+ className
122
+ )}
123
+ {...props}
124
+ >
125
+ <span className="absolute right-2 flex h-3.5 w-3.5 items-center justify-center">
126
+ <SelectPrimitive.ItemIndicator>
127
+ <Check className="h-4 w-4" />
128
+ </SelectPrimitive.ItemIndicator>
129
+ </span>
130
+ <SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>
131
+ </SelectPrimitive.Item>
132
+ ));
133
+ SelectItem.displayName = SelectPrimitive.Item.displayName;
134
+
135
+ const SelectSeparator = React.forwardRef(({ className, ...props }, ref) => (
136
+ <SelectPrimitive.Separator
137
+ ref={ref}
138
+ className={cn("-mx-1 my-1 h-px bg-muted", className)}
139
+ {...props}
140
+ />
141
+ ));
142
+ SelectSeparator.displayName = SelectPrimitive.Separator.displayName;
33
143
 
34
- export { Select, SelectOption };
144
+ export {
145
+ Select,
146
+ SelectGroup,
147
+ SelectValue,
148
+ SelectTrigger,
149
+ SelectScrollUpButton,
150
+ SelectScrollDownButton,
151
+ SelectContent,
152
+ SelectLabel,
153
+ SelectItem,
154
+ SelectSeparator,
155
+ };