pf-common-components 1.0.0

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.
Files changed (215) hide show
  1. package/components.json +17 -0
  2. package/dist/assets/Arrow.d.ts +7 -0
  3. package/dist/assets/Arrow.js +5 -0
  4. package/dist/assets/CalenderIcon.d.ts +2 -0
  5. package/dist/assets/CalenderIcon.js +5 -0
  6. package/dist/assets/ClearAll.d.ts +2 -0
  7. package/dist/assets/ClearAll.js +5 -0
  8. package/dist/assets/CrossIcon.d.ts +8 -0
  9. package/dist/assets/CrossIcon.js +7 -0
  10. package/dist/assets/DropDown.d.ts +4 -0
  11. package/dist/assets/DropDown.js +5 -0
  12. package/dist/global.css +3213 -0
  13. package/dist/index.d.ts +25 -0
  14. package/dist/index.js +25 -0
  15. package/dist/lib/CommonComponentsUtil.d.ts +7 -0
  16. package/dist/lib/CommonComponentsUtil.js +22 -0
  17. package/dist/lib/utils.d.ts +2 -0
  18. package/dist/lib/utils.js +5 -0
  19. package/dist/ui/BaseTable.d.ts +132 -0
  20. package/dist/ui/BaseTable.js +330 -0
  21. package/dist/ui/DateCalendar.d.ts +10 -0
  22. package/dist/ui/DateCalendar.js +47 -0
  23. package/dist/ui/DateField.d.ts +35 -0
  24. package/dist/ui/DateField.js +37 -0
  25. package/dist/ui/DateOfBirthSelector.d.ts +16 -0
  26. package/dist/ui/DateOfBirthSelector.js +42 -0
  27. package/dist/ui/DateRangePicker.d.ts +8 -0
  28. package/dist/ui/DateRangePicker.js +73 -0
  29. package/dist/ui/DobCalendar.d.ts +17 -0
  30. package/dist/ui/DobCalendar.js +86 -0
  31. package/dist/ui/Formfield.d.ts +12 -0
  32. package/dist/ui/Formfield.js +36 -0
  33. package/dist/ui/GetScrollAlert.d.ts +9 -0
  34. package/dist/ui/GetScrollAlert.js +37 -0
  35. package/dist/ui/RadioGroupContext/RadioGroupContext.d.ts +8 -0
  36. package/dist/ui/RadioGroupContext/RadioGroupContext.js +11 -0
  37. package/dist/ui/SelectCommand.d.ts +69 -0
  38. package/dist/ui/SelectCommand.js +260 -0
  39. package/dist/ui/SlashIcon.d.ts +2 -0
  40. package/dist/ui/SlashIcon.js +5 -0
  41. package/dist/ui/SortingArrows.d.ts +11 -0
  42. package/dist/ui/SortingArrows.js +11 -0
  43. package/dist/ui/TextTags.d.ts +39 -0
  44. package/dist/ui/TextTags.js +73 -0
  45. package/dist/ui/accordion.d.ts +10 -0
  46. package/dist/ui/accordion.js +77 -0
  47. package/dist/ui/alert-dialog.d.ts +20 -0
  48. package/dist/ui/alert-dialog.js +62 -0
  49. package/dist/ui/alert.d.ts +8 -0
  50. package/dist/ui/alert.js +42 -0
  51. package/dist/ui/avatar.d.ts +6 -0
  52. package/dist/ui/avatar.js +32 -0
  53. package/dist/ui/badge.d.ts +10 -0
  54. package/dist/ui/badge.js +58 -0
  55. package/dist/ui/button.d.ts +12 -0
  56. package/dist/ui/button.js +54 -0
  57. package/dist/ui/calendar.d.ts +8 -0
  58. package/dist/ui/calendar.js +45 -0
  59. package/dist/ui/card.d.ts +8 -0
  60. package/dist/ui/card.js +45 -0
  61. package/dist/ui/checkbox.d.ts +12 -0
  62. package/dist/ui/checkbox.js +44 -0
  63. package/dist/ui/command.d.ts +47 -0
  64. package/dist/ui/command.js +67 -0
  65. package/dist/ui/dialog.d.ts +31 -0
  66. package/dist/ui/dialog.js +57 -0
  67. package/dist/ui/dropdown-menu.d.ts +27 -0
  68. package/dist/ui/dropdown-menu.js +72 -0
  69. package/dist/ui/form.d.ts +23 -0
  70. package/dist/ui/form.js +72 -0
  71. package/dist/ui/hover-card.d.ts +7 -0
  72. package/dist/ui/hover-card.js +29 -0
  73. package/dist/ui/input.d.ts +3 -0
  74. package/dist/ui/input.js +20 -0
  75. package/dist/ui/label.d.ts +5 -0
  76. package/dist/ui/label.js +24 -0
  77. package/dist/ui/multi-select.d.ts +44 -0
  78. package/dist/ui/multi-select.js +191 -0
  79. package/dist/ui/navigation-menu.d.ts +11 -0
  80. package/dist/ui/navigation-menu.js +69 -0
  81. package/dist/ui/popover.d.ts +6 -0
  82. package/dist/ui/popover.js +24 -0
  83. package/dist/ui/radio-group.d.ts +7 -0
  84. package/dist/ui/radio-group.js +40 -0
  85. package/dist/ui/radioButtonCard.d.ts +9 -0
  86. package/dist/ui/radioButtonCard.js +23 -0
  87. package/dist/ui/scroll-area.d.ts +5 -0
  88. package/dist/ui/scroll-area.js +29 -0
  89. package/dist/ui/select.d.ts +57 -0
  90. package/dist/ui/select.js +148 -0
  91. package/dist/ui/separator.d.ts +4 -0
  92. package/dist/ui/separator.js +22 -0
  93. package/dist/ui/sheet.d.ts +25 -0
  94. package/dist/ui/sheet.js +65 -0
  95. package/dist/ui/switch.d.ts +10 -0
  96. package/dist/ui/switch.js +47 -0
  97. package/dist/ui/table.d.ts +10 -0
  98. package/dist/ui/table.js +55 -0
  99. package/dist/ui/tabs.d.ts +7 -0
  100. package/dist/ui/tabs.js +33 -0
  101. package/dist/ui/text.d.ts +11 -0
  102. package/dist/ui/text.js +45 -0
  103. package/dist/ui/textarea.d.ts +7 -0
  104. package/dist/ui/textarea.js +21 -0
  105. package/dist/ui/tooltip.d.ts +11 -0
  106. package/dist/ui/tooltip.js +26 -0
  107. package/package.json +123 -0
  108. package/postcss.config.js +6 -0
  109. package/src/assets/Arrow.js +5 -0
  110. package/src/assets/Arrow.tsx +25 -0
  111. package/src/assets/CalenderIcon.js +5 -0
  112. package/src/assets/CalenderIcon.tsx +28 -0
  113. package/src/assets/ClearAll.js +5 -0
  114. package/src/assets/ClearAll.tsx +20 -0
  115. package/src/assets/CrossIcon.js +7 -0
  116. package/src/assets/CrossIcon.tsx +34 -0
  117. package/src/assets/DropDown.js +5 -0
  118. package/src/assets/DropDown.tsx +23 -0
  119. package/src/global.css +560 -0
  120. package/src/index.ts +34 -0
  121. package/src/lib/CommonComponentsUtil.js +22 -0
  122. package/src/lib/CommonComponentsUtil.ts +30 -0
  123. package/src/lib/utils.js +5 -0
  124. package/src/lib/utils.ts +6 -0
  125. package/src/ui/BaseTable.js +330 -0
  126. package/src/ui/BaseTable.tsx +987 -0
  127. package/src/ui/DateCalendar.js +47 -0
  128. package/src/ui/DateCalendar.tsx +111 -0
  129. package/src/ui/DateField.js +37 -0
  130. package/src/ui/DateField.tsx +142 -0
  131. package/src/ui/DateOfBirthSelector.js +42 -0
  132. package/src/ui/DateOfBirthSelector.tsx +114 -0
  133. package/src/ui/DateRangePicker.js +73 -0
  134. package/src/ui/DateRangePicker.tsx +174 -0
  135. package/src/ui/DobCalendar.js +86 -0
  136. package/src/ui/DobCalendar.tsx +172 -0
  137. package/src/ui/Formfield.js +36 -0
  138. package/src/ui/Formfield.tsx +55 -0
  139. package/src/ui/GetScrollAlert.js +37 -0
  140. package/src/ui/GetScrollAlert.tsx +59 -0
  141. package/src/ui/RadioGroupContext/RadioGroupContext.js +11 -0
  142. package/src/ui/RadioGroupContext/RadioGroupContext.tsx +21 -0
  143. package/src/ui/SelectCommand.js +260 -0
  144. package/src/ui/SelectCommand.tsx +587 -0
  145. package/src/ui/SlashIcon.js +5 -0
  146. package/src/ui/SlashIcon.tsx +22 -0
  147. package/src/ui/SortingArrows.js +11 -0
  148. package/src/ui/SortingArrows.tsx +29 -0
  149. package/src/ui/TextTags.js +73 -0
  150. package/src/ui/TextTags.tsx +149 -0
  151. package/src/ui/accordion.js +77 -0
  152. package/src/ui/accordion.tsx +129 -0
  153. package/src/ui/alert-dialog.js +62 -0
  154. package/src/ui/alert-dialog.tsx +141 -0
  155. package/src/ui/alert.js +42 -0
  156. package/src/ui/alert.tsx +59 -0
  157. package/src/ui/avatar.js +32 -0
  158. package/src/ui/avatar.tsx +50 -0
  159. package/src/ui/badge.js +58 -0
  160. package/src/ui/badge.tsx +66 -0
  161. package/src/ui/button.js +54 -0
  162. package/src/ui/button.tsx +89 -0
  163. package/src/ui/calendar.js +45 -0
  164. package/src/ui/calendar.tsx +88 -0
  165. package/src/ui/card.js +45 -0
  166. package/src/ui/card.tsx +83 -0
  167. package/src/ui/checkbox.js +44 -0
  168. package/src/ui/checkbox.tsx +56 -0
  169. package/src/ui/command.js +67 -0
  170. package/src/ui/command.tsx +166 -0
  171. package/src/ui/dialog.js +57 -0
  172. package/src/ui/dialog.tsx +154 -0
  173. package/src/ui/dropdown-menu.js +72 -0
  174. package/src/ui/dropdown-menu.tsx +200 -0
  175. package/src/ui/form.js +72 -0
  176. package/src/ui/form.tsx +177 -0
  177. package/src/ui/hover-card.js +29 -0
  178. package/src/ui/hover-card.tsx +63 -0
  179. package/src/ui/input.js +20 -0
  180. package/src/ui/input.tsx +22 -0
  181. package/src/ui/label.js +24 -0
  182. package/src/ui/label.tsx +26 -0
  183. package/src/ui/multi-select.js +191 -0
  184. package/src/ui/multi-select.tsx +518 -0
  185. package/src/ui/navigation-menu.js +69 -0
  186. package/src/ui/navigation-menu.tsx +139 -0
  187. package/src/ui/popover.js +24 -0
  188. package/src/ui/popover.tsx +31 -0
  189. package/src/ui/radio-group.js +40 -0
  190. package/src/ui/radio-group.tsx +97 -0
  191. package/src/ui/radioButtonCard.js +23 -0
  192. package/src/ui/radioButtonCard.tsx +57 -0
  193. package/src/ui/scroll-area.js +29 -0
  194. package/src/ui/scroll-area.tsx +48 -0
  195. package/src/ui/select.js +148 -0
  196. package/src/ui/select.tsx +343 -0
  197. package/src/ui/separator.js +22 -0
  198. package/src/ui/separator.tsx +31 -0
  199. package/src/ui/sheet.js +65 -0
  200. package/src/ui/sheet.tsx +136 -0
  201. package/src/ui/switch.js +47 -0
  202. package/src/ui/switch.tsx +60 -0
  203. package/src/ui/table.js +55 -0
  204. package/src/ui/table.tsx +112 -0
  205. package/src/ui/tabs.js +33 -0
  206. package/src/ui/tabs.tsx +55 -0
  207. package/src/ui/text.js +45 -0
  208. package/src/ui/text.tsx +49 -0
  209. package/src/ui/textarea.js +21 -0
  210. package/src/ui/textarea.tsx +28 -0
  211. package/src/ui/tooltip.js +26 -0
  212. package/src/ui/tooltip.tsx +54 -0
  213. package/tailwind.config.js +214 -0
  214. package/tsconfig.json +35 -0
  215. package/tsconfig.tsbuildinfo +1 -0
@@ -0,0 +1,343 @@
1
+ "use client";
2
+
3
+ import * as SelectPrimitive from "@radix-ui/react-select";
4
+ import { ChevronDown, ChevronUp } from "lucide-react";
5
+ import * as React from "react";
6
+
7
+ import { useRef } from "react";
8
+ import { cn } from "../lib/utils";
9
+ import { Input } from "./input";
10
+ import { InputProps } from "react-day-picker";
11
+ /**
12
+ * Select Context interface
13
+ */
14
+ interface ISelectContext {
15
+ /**
16
+ * value of a select component
17
+ * undefined | null | or empty string means the user has not selected any value
18
+ * any other than above value means it has value
19
+ */
20
+ value?: string | undefined | null | object;
21
+ }
22
+
23
+ const SelectContext = React.createContext({});
24
+
25
+ /**
26
+ * Select is a wrapper component around the `@radix-ui/react-select` package.
27
+ * It provides a unified API for working with select components and hides
28
+ * implementation details specific to the `radix-ui/react-select` package.
29
+ *
30
+ * The component is designed to be highly customizable and can be used in
31
+ * different contexts. This is achieved by omitting the `value` and
32
+ * `onValueChange` props from the underlying `radix-ui/react-select` component.
33
+ * These props are managed internally within the `Select` component to provide
34
+ * a consistent API for all select components.
35
+ *
36
+ * This component also handles the conversion of the value to and from a
37
+ * JSON string. This ensures that the value passed to and from the `onValueChange`
38
+ * callback is always a valid JSON object or string. This is important for
39
+ * consistency and to avoid any potential issues with data manipulation.
40
+ */
41
+ type SelectProps = Omit<
42
+ React.ComponentPropsWithoutRef<typeof SelectPrimitive.Root>,
43
+ "value" | "onValueChange" | "defaultValue"
44
+ > & {
45
+ value?: unknown;
46
+ onValueChange?: (value: unknown) => void;
47
+ defaultValue?: unknown;
48
+ };
49
+
50
+ const Select: React.FC<SelectProps> = ({
51
+ children,
52
+ value,
53
+ onValueChange,
54
+ defaultValue,
55
+ ...props
56
+ }) => {
57
+ // Convert the value to a JSON string to ensure it can be safely stored and
58
+ // manipulated.
59
+ value = typeof value !== "string" ? JSON.stringify(value) : value;
60
+ defaultValue =
61
+ typeof defaultValue !== "string"
62
+ ? JSON.stringify(defaultValue)
63
+ : defaultValue;
64
+
65
+ return (
66
+ <SelectContext.Provider value={{ value }}>
67
+ <SelectPrimitive.Root
68
+ // Set the internal value of the select component.
69
+ value={value as string}
70
+ defaultValue={defaultValue as string}
71
+ // Handle the onValueChange event and convert the value back to its
72
+ // original type before passing it to the consumer.
73
+ onValueChange={(e) => {
74
+ // there are total three possible values for e
75
+ // 1. e can be pure string ex: e="IN" | "CA" | "ng"
76
+ // 2. e can be pure object ex: e={label:"IN", value:"IN"} | {label:"CA", value:"CA"} | {label:"ng", value:"ng"}
77
+ // 3. e can be number ex: e=1 | 2 | 3
78
+ // Explanation: JSON.parse will throw error for pure string for point 1.
79
+ // so for that we can pass as it is
80
+ try {
81
+ onValueChange?.(JSON.parse(e));
82
+ } catch (error) {
83
+ onValueChange?.(e);
84
+ }
85
+ }}
86
+ // Pass all other props to the underlying select component.
87
+ {...props}
88
+ >
89
+ {children}
90
+ </SelectPrimitive.Root>
91
+ </SelectContext.Provider>
92
+ );
93
+ };
94
+
95
+ const SelectGroup = SelectPrimitive.Group;
96
+
97
+ const SelectValue = SelectPrimitive.Value;
98
+
99
+ const SelectTrigger = React.forwardRef<
100
+ React.ElementRef<typeof SelectPrimitive.Trigger>,
101
+ React.ComponentPropsWithoutRef<typeof SelectPrimitive.Trigger> & {
102
+ error?: boolean;
103
+ }
104
+ >(({ className, children, error, ...props }, ref) => {
105
+ const { value }: ISelectContext = React.useContext(SelectContext);
106
+
107
+ return (
108
+ <SelectPrimitive.Trigger
109
+ ref={ref}
110
+ className={cn(
111
+ "flex h-10 w-full items-center justify-between rounded-[12px] border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",
112
+ className,
113
+ `${error ? "!border-[#FF6D6D]" : ""}`,
114
+ // Requirement: We have to display light color placeholder if user has not selcted the value
115
+ // Implementation: We have taken one context to access the value of select inside children compound components
116
+ // Condition: when value is null or undefined or empty string then display light color
117
+ (value === "" || value === undefined || value === null) &&
118
+ "font-normal text-[#999999]"
119
+ )}
120
+ {...props}
121
+ >
122
+ {children}
123
+ <SelectPrimitive.Icon asChild className="">
124
+ <ChevronDown className="h-5 w-5 text-black" />
125
+ </SelectPrimitive.Icon>
126
+ </SelectPrimitive.Trigger>
127
+ );
128
+ });
129
+ SelectTrigger.displayName = SelectPrimitive.Trigger.displayName;
130
+
131
+ const SelectItems = React.forwardRef<
132
+ React.ElementRef<typeof SelectPrimitive.Viewport>,
133
+ React.ComponentPropsWithoutRef<typeof SelectPrimitive.Viewport> & {
134
+ onBottomReached?: () => void;
135
+ }
136
+ >(({ children, className, onBottomReached, ...props }, ref) => {
137
+ const scrollRef = React.useRef<HTMLDivElement>(null);
138
+
139
+ /**
140
+ * Calculate the position of the bottom of the last child element
141
+ *
142
+ * @return {void}
143
+ */
144
+ const handleScroll = () => {
145
+ const element: any = scrollRef.current;
146
+ if (!element) return;
147
+
148
+ // Calculate the position of the bottom of the last child element
149
+ const lastChildPosition =
150
+ element.children[element.children.length - 1].offsetTop +
151
+ element.children[element.children.length - 1].offsetHeight;
152
+
153
+ // Calculate the scroll position of the bottom of the element
154
+ const scrollPosition = element.scrollTop + element.clientHeight;
155
+ // If the user has scrolled to the bottom, call the onBottomReached function
156
+ if (scrollPosition >= lastChildPosition - 5) {
157
+ onBottomReached?.();
158
+ }
159
+ };
160
+
161
+ React.useEffect(() => {
162
+ const element = scrollRef.current;
163
+ if (!element) return undefined;
164
+
165
+ element.addEventListener("scroll", handleScroll);
166
+ return () => {
167
+ element.removeEventListener("scroll", handleScroll);
168
+ };
169
+ }, []);
170
+
171
+ return (
172
+ <SelectPrimitive.Viewport
173
+ className={cn(
174
+ "p-1",
175
+ "h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"
176
+ )}
177
+ {...props}
178
+ >
179
+ <div
180
+ className={cn("max-h-[200px] overflow-y-auto", className)}
181
+ ref={scrollRef}
182
+ >
183
+ {children}
184
+ </div>
185
+ </SelectPrimitive.Viewport>
186
+ );
187
+ });
188
+
189
+ const SelectScrollUpButton = React.forwardRef<
190
+ React.ElementRef<typeof SelectPrimitive.ScrollUpButton>,
191
+ React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollUpButton>
192
+ >(({ className, ...props }, ref) => (
193
+ <SelectPrimitive.ScrollUpButton
194
+ ref={ref}
195
+ className={cn(
196
+ "flex cursor-default items-center justify-center py-1",
197
+ className
198
+ )}
199
+ {...props}
200
+ >
201
+ <ChevronUp className="h-4 w-4" />
202
+ </SelectPrimitive.ScrollUpButton>
203
+ ));
204
+ SelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName;
205
+
206
+ const SelectScrollDownButton = React.forwardRef<
207
+ React.ElementRef<typeof SelectPrimitive.ScrollDownButton>,
208
+ React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollDownButton>
209
+ >(({ className, ...props }, ref) => (
210
+ <SelectPrimitive.ScrollDownButton
211
+ ref={ref}
212
+ className={cn(
213
+ "flex cursor-default items-center justify-center py-1",
214
+ className
215
+ )}
216
+ {...props}
217
+ >
218
+ <ChevronDown className="h-4 w-4" />
219
+ </SelectPrimitive.ScrollDownButton>
220
+ ));
221
+ SelectScrollDownButton.displayName =
222
+ SelectPrimitive.ScrollDownButton.displayName;
223
+
224
+ const SelectContent = React.forwardRef<
225
+ React.ElementRef<typeof SelectPrimitive.Content>,
226
+ React.ComponentPropsWithoutRef<typeof SelectPrimitive.Content>
227
+ >(({ className, children, position = "popper", ...props }, ref) => (
228
+ <SelectPrimitive.Portal>
229
+ <SelectPrimitive.Content
230
+ ref={ref}
231
+ className={cn(
232
+ "relative z-50 min-w-[8rem] overflow-hidden rounded-[12px] border bg-popover text-popover-foreground 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",
233
+ position === "popper" &&
234
+ "data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",
235
+ className
236
+ )}
237
+ position={position}
238
+ {...props}
239
+ >
240
+ {/* <SelectScrollUpButton /> */}
241
+ {/* <SelectPrimitive.Viewport
242
+ className={cn(
243
+ "p-1",
244
+ position === "popper" &&
245
+ "h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"
246
+ )}
247
+ > */}
248
+ {children}
249
+ {/* </SelectPrimitive.Viewport> */}
250
+ {/* <SelectScrollDownButton /> */}
251
+ </SelectPrimitive.Content>
252
+ </SelectPrimitive.Portal>
253
+ ));
254
+ SelectContent.displayName = SelectPrimitive.Content.displayName;
255
+
256
+ const SelectLabel = React.forwardRef<
257
+ React.ElementRef<typeof SelectPrimitive.Label>,
258
+ React.ComponentPropsWithoutRef<typeof SelectPrimitive.Label>
259
+ >(({ className, ...props }, ref) => (
260
+ <SelectPrimitive.Label
261
+ ref={ref}
262
+ className={cn("py-1.5 pl-8 pr-2 text-sm font-semibold", className)}
263
+ {...props}
264
+ />
265
+ ));
266
+ SelectLabel.displayName = SelectPrimitive.Label.displayName;
267
+
268
+ type SelectItemProps = Omit<
269
+ React.ComponentPropsWithoutRef<typeof SelectPrimitive.Item>,
270
+ "value"
271
+ >;
272
+
273
+ const SelectItem = React.forwardRef<
274
+ React.ElementRef<typeof SelectPrimitive.Item>,
275
+ SelectItemProps & { value: unknown }
276
+ >(({ className, children, value, ...props }, ref) => {
277
+ value = typeof value !== "string" ? JSON.stringify(value) : value;
278
+ return (
279
+ <>
280
+ <SelectPrimitive.Item
281
+ ref={ref}
282
+ className={cn(
283
+ "relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-3 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
284
+ className
285
+ )}
286
+ value={value as string}
287
+ {...props}
288
+ >
289
+ <SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>
290
+ </SelectPrimitive.Item>
291
+ {/* <hr className="border-[#D6D7D8]" /> */}
292
+ </>
293
+ );
294
+ });
295
+
296
+ SelectItem.displayName = SelectPrimitive.Item.displayName;
297
+
298
+ const SelectSeparator = React.forwardRef<
299
+ React.ElementRef<typeof SelectPrimitive.Separator>,
300
+ React.ComponentPropsWithoutRef<typeof SelectPrimitive.Separator>
301
+ >(({ className, ...props }, ref) => (
302
+ <SelectPrimitive.Separator
303
+ ref={ref}
304
+ className={cn("-mx-1 my-1 h-px bg-muted", className)}
305
+ {...props}
306
+ />
307
+ ));
308
+ SelectSeparator.displayName = SelectPrimitive.Separator.displayName;
309
+
310
+ /**
311
+ * Requirement : dropdowns are loosing focus everwhere so to gain focus, we are using
312
+ * SelectInput Component, designed to be used as a wrapper around an Input component
313
+ *
314
+ * Bug no : 1149
315
+ *
316
+ * Implementation : Initially created functional component named SelectInput that accepts props of type InputProps,
317
+ * and used useRef hook to create a reference to the input element, and initially set to null, and added
318
+ * onBlur event handler to the Input component, and Return an Input component with the ref attribute set to the
319
+ * inputRef which triggers a function to focus on the input element when it looses focus.
320
+ *
321
+ * @returns
322
+ */
323
+ const SelectInput = (props: InputProps) => {
324
+ const inputRef = useRef<HTMLInputElement | null>(null);
325
+ return (
326
+ <Input ref={inputRef} onBlur={() => inputRef.current?.focus()} {...props} />
327
+ );
328
+ };
329
+
330
+ export {
331
+ Select,
332
+ SelectContent,
333
+ SelectGroup,
334
+ SelectInput,
335
+ SelectItem,
336
+ SelectItems,
337
+ SelectLabel,
338
+ SelectScrollDownButton,
339
+ SelectScrollUpButton,
340
+ SelectSeparator,
341
+ SelectTrigger,
342
+ SelectValue,
343
+ };
@@ -0,0 +1,22 @@
1
+ "use client";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
13
+ import { jsx as _jsx } from "react/jsx-runtime";
14
+ import * as React from "react";
15
+ import * as SeparatorPrimitive from "@radix-ui/react-separator";
16
+ import { cn } from "../lib/utils";
17
+ const Separator = React.forwardRef((_a, ref) => {
18
+ var { className, orientation = "horizontal", decorative = true } = _a, props = __rest(_a, ["className", "orientation", "decorative"]);
19
+ return (_jsx(SeparatorPrimitive.Root, Object.assign({ ref: ref, decorative: decorative, orientation: orientation, className: cn("shrink-0 bg-border", orientation === "horizontal" ? "h-[1px] w-full" : "h-full w-[1px]", className) }, props)));
20
+ });
21
+ Separator.displayName = SeparatorPrimitive.Root.displayName;
22
+ export { Separator };
@@ -0,0 +1,31 @@
1
+ "use client";
2
+
3
+ import * as React from "react";
4
+ import * as SeparatorPrimitive from "@radix-ui/react-separator";
5
+
6
+ import { cn } from "../lib/utils";
7
+
8
+ const Separator = React.forwardRef<
9
+ React.ElementRef<typeof SeparatorPrimitive.Root>,
10
+ React.ComponentPropsWithoutRef<typeof SeparatorPrimitive.Root>
11
+ >(
12
+ (
13
+ { className, orientation = "horizontal", decorative = true, ...props },
14
+ ref
15
+ ) => (
16
+ <SeparatorPrimitive.Root
17
+ ref={ref}
18
+ decorative={decorative}
19
+ orientation={orientation}
20
+ className={cn(
21
+ "shrink-0 bg-border",
22
+ orientation === "horizontal" ? "h-[1px] w-full" : "h-full w-[1px]",
23
+ className
24
+ )}
25
+ {...props}
26
+ />
27
+ )
28
+ );
29
+ Separator.displayName = SeparatorPrimitive.Root.displayName;
30
+
31
+ export { Separator };
@@ -0,0 +1,65 @@
1
+ "use client";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
13
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
+ import * as SheetPrimitive from "@radix-ui/react-dialog";
15
+ import { cva } from "class-variance-authority";
16
+ import * as React from "react";
17
+ import { cn } from "../lib/utils";
18
+ const Sheet = SheetPrimitive.Root;
19
+ const SheetTrigger = SheetPrimitive.Trigger;
20
+ const SheetClose = SheetPrimitive.Close;
21
+ const SheetPortal = SheetPrimitive.Portal;
22
+ const SheetOverlay = React.forwardRef((_a, ref) => {
23
+ var { className } = _a, props = __rest(_a, ["className"]);
24
+ return (_jsx(SheetPrimitive.Overlay, Object.assign({ className: cn("fixed inset-0 z-50 bg-black/30 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0", className) }, props, { ref: ref })));
25
+ });
26
+ SheetOverlay.displayName = SheetPrimitive.Overlay.displayName;
27
+ const sheetVariants = cva("fixed z-50 gap-4 bg-white p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500", {
28
+ variants: {
29
+ side: {
30
+ top: "inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",
31
+ bottom: "inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",
32
+ left: "inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",
33
+ right: "inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm",
34
+ },
35
+ },
36
+ defaultVariants: {
37
+ side: "right",
38
+ },
39
+ });
40
+ const SheetContent = React.forwardRef((_a, ref) => {
41
+ var { side = "right", className, children } = _a, props = __rest(_a, ["side", "className", "children"]);
42
+ return (_jsxs(SheetPortal, { children: [_jsx(SheetOverlay, {}), _jsxs(SheetPrimitive.Content, Object.assign({ ref: ref, className: cn(sheetVariants({ side }), className) }, props, { children: [children, _jsx(SheetPrimitive.Close, { className: "absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary" })] }))] }));
43
+ });
44
+ SheetContent.displayName = SheetPrimitive.Content.displayName;
45
+ const SheetHeader = (_a) => {
46
+ var { className } = _a, props = __rest(_a, ["className"]);
47
+ return (_jsx("div", Object.assign({ className: cn("flex flex-col space-y-2 text-center sm:text-left", className) }, props)));
48
+ };
49
+ SheetHeader.displayName = "SheetHeader";
50
+ const SheetFooter = (_a) => {
51
+ var { className } = _a, props = __rest(_a, ["className"]);
52
+ return (_jsx("div", Object.assign({ className: cn("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2", className) }, props)));
53
+ };
54
+ SheetFooter.displayName = "SheetFooter";
55
+ const SheetTitle = React.forwardRef((_a, ref) => {
56
+ var { className } = _a, props = __rest(_a, ["className"]);
57
+ return (_jsx(SheetPrimitive.Title, Object.assign({ ref: ref, className: cn("text-lg font-semibold text-foreground", className) }, props)));
58
+ });
59
+ SheetTitle.displayName = SheetPrimitive.Title.displayName;
60
+ const SheetDescription = React.forwardRef((_a, ref) => {
61
+ var { className } = _a, props = __rest(_a, ["className"]);
62
+ return (_jsx(SheetPrimitive.Description, Object.assign({ ref: ref, className: cn("text-sm text-muted-foreground", className) }, props)));
63
+ });
64
+ SheetDescription.displayName = SheetPrimitive.Description.displayName;
65
+ export { Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetOverlay, SheetPortal, SheetTitle, SheetTrigger, };
@@ -0,0 +1,136 @@
1
+ "use client";
2
+
3
+ import * as SheetPrimitive from "@radix-ui/react-dialog";
4
+ import { cva, type VariantProps } from "class-variance-authority";
5
+ import * as React from "react";
6
+
7
+ import { cn } from "../lib/utils";
8
+
9
+ const Sheet = SheetPrimitive.Root;
10
+
11
+ const SheetTrigger = SheetPrimitive.Trigger;
12
+
13
+ const SheetClose = SheetPrimitive.Close;
14
+
15
+ const SheetPortal = SheetPrimitive.Portal;
16
+
17
+ const SheetOverlay = React.forwardRef<
18
+ React.ElementRef<typeof SheetPrimitive.Overlay>,
19
+ React.ComponentPropsWithoutRef<typeof SheetPrimitive.Overlay>
20
+ >(({ className, ...props }, ref) => (
21
+ <SheetPrimitive.Overlay
22
+ className={cn(
23
+ "fixed inset-0 z-50 bg-black/30 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
24
+ className
25
+ )}
26
+ {...props}
27
+ ref={ref}
28
+ />
29
+ ));
30
+ SheetOverlay.displayName = SheetPrimitive.Overlay.displayName;
31
+
32
+ const sheetVariants = cva(
33
+ "fixed z-50 gap-4 bg-white p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",
34
+ {
35
+ variants: {
36
+ side: {
37
+ top: "inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",
38
+ bottom:
39
+ "inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",
40
+ left: "inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",
41
+ right:
42
+ "inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm",
43
+ },
44
+ },
45
+ defaultVariants: {
46
+ side: "right",
47
+ },
48
+ }
49
+ );
50
+
51
+ interface SheetContentProps
52
+ extends React.ComponentPropsWithoutRef<typeof SheetPrimitive.Content>,
53
+ VariantProps<typeof sheetVariants> {}
54
+
55
+ const SheetContent = React.forwardRef<
56
+ React.ElementRef<typeof SheetPrimitive.Content>,
57
+ SheetContentProps
58
+ >(({ side = "right", className, children, ...props }, ref) => (
59
+ <SheetPortal>
60
+ <SheetOverlay />
61
+ <SheetPrimitive.Content
62
+ ref={ref}
63
+ className={cn(sheetVariants({ side }), className)}
64
+ {...props}
65
+ >
66
+ {children}
67
+ <SheetPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary"></SheetPrimitive.Close>
68
+ </SheetPrimitive.Content>
69
+ </SheetPortal>
70
+ ));
71
+ SheetContent.displayName = SheetPrimitive.Content.displayName;
72
+
73
+ const SheetHeader = ({
74
+ className,
75
+ ...props
76
+ }: React.HTMLAttributes<HTMLDivElement>) => (
77
+ <div
78
+ className={cn(
79
+ "flex flex-col space-y-2 text-center sm:text-left",
80
+ className
81
+ )}
82
+ {...props}
83
+ />
84
+ );
85
+ SheetHeader.displayName = "SheetHeader";
86
+
87
+ const SheetFooter = ({
88
+ className,
89
+ ...props
90
+ }: React.HTMLAttributes<HTMLDivElement>) => (
91
+ <div
92
+ className={cn(
93
+ "flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
94
+ className
95
+ )}
96
+ {...props}
97
+ />
98
+ );
99
+ SheetFooter.displayName = "SheetFooter";
100
+
101
+ const SheetTitle = React.forwardRef<
102
+ React.ElementRef<typeof SheetPrimitive.Title>,
103
+ React.ComponentPropsWithoutRef<typeof SheetPrimitive.Title>
104
+ >(({ className, ...props }, ref) => (
105
+ <SheetPrimitive.Title
106
+ ref={ref}
107
+ className={cn("text-lg font-semibold text-foreground", className)}
108
+ {...props}
109
+ />
110
+ ));
111
+ SheetTitle.displayName = SheetPrimitive.Title.displayName;
112
+
113
+ const SheetDescription = React.forwardRef<
114
+ React.ElementRef<typeof SheetPrimitive.Description>,
115
+ React.ComponentPropsWithoutRef<typeof SheetPrimitive.Description>
116
+ >(({ className, ...props }, ref) => (
117
+ <SheetPrimitive.Description
118
+ ref={ref}
119
+ className={cn("text-sm text-muted-foreground", className)}
120
+ {...props}
121
+ />
122
+ ));
123
+ SheetDescription.displayName = SheetPrimitive.Description.displayName;
124
+
125
+ export {
126
+ Sheet,
127
+ SheetClose,
128
+ SheetContent,
129
+ SheetDescription,
130
+ SheetFooter,
131
+ SheetHeader,
132
+ SheetOverlay,
133
+ SheetPortal,
134
+ SheetTitle,
135
+ SheetTrigger,
136
+ };
@@ -0,0 +1,47 @@
1
+ "use client";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
13
+ import { jsx as _jsx } from "react/jsx-runtime";
14
+ import * as SwitchPrimitives from "@radix-ui/react-switch";
15
+ import { cva } from "class-variance-authority";
16
+ import * as React from "react";
17
+ import { cn } from "../lib/utils";
18
+ const switchVariants = cva("peer inline-flex shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus:outline-keyboardTab disabled:cursor-not-allowed disabled:opacity-50", {
19
+ variants: {
20
+ size: {
21
+ default: "h-6 w-14 data-[state=checked]:bg-primary data-[state=unchecked]:bg-grey1-light-active",
22
+ sm: "h-6 w-12 data-[state=checked]:bg-primary data-[state=unchecked]:bg-grey1-light-active",
23
+ md: "h-8 w-16 data-[state=checked]:bg-primary data-[state=unchecked]:bg-grey1-light-active",
24
+ },
25
+ },
26
+ defaultVariants: {
27
+ size: "default", // Your current style as the default
28
+ },
29
+ });
30
+ const thumbVariants = cva("pointer-events-none block rounded-full bg-white shadow-lg ring-0 transition-transform", {
31
+ variants: {
32
+ size: {
33
+ default: "h-4 w-4 data-[state=checked]:translate-x-8 data-[state=unchecked]:translate-x-1",
34
+ sm: "h-4 w-4 data-[state=checked]:translate-x-6 data-[state=unchecked]:translate-x-1",
35
+ md: "h-6 w-6 data-[state=checked]:translate-x-8 data-[state=unchecked]:translate-x-1",
36
+ },
37
+ },
38
+ defaultVariants: {
39
+ size: "default", // Your current style as the default
40
+ },
41
+ });
42
+ const Switch = React.forwardRef((_a, ref) => {
43
+ var { className, size } = _a, props = __rest(_a, ["className", "size"]);
44
+ return (_jsx(SwitchPrimitives.Root, Object.assign({ className: cn(switchVariants({ size, className })), ref: ref }, props, { children: _jsx(SwitchPrimitives.Thumb, { className: cn(thumbVariants({ size })) }) })));
45
+ });
46
+ Switch.displayName = SwitchPrimitives.Root.displayName;
47
+ export { Switch };