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,174 @@
1
+ "use client";
2
+
3
+ import * as React from "react";
4
+ import { ChevronLeft, ChevronRight } from "lucide-react";
5
+ import { DayPicker } from "react-day-picker";
6
+
7
+ import { cn } from "../lib/utils";
8
+ import { buttonVariants } from "./button";
9
+ import {
10
+ Select,
11
+ SelectContent,
12
+ SelectItem,
13
+ SelectTrigger,
14
+ SelectValue,
15
+ } from "./select";
16
+ import { useEffect, useState } from "react";
17
+ import dayjs from "dayjs";
18
+ import * as loc from "date-fns/locale";
19
+
20
+ export type CalendarProps = React.ComponentProps<typeof DayPicker>;
21
+
22
+ export type ExtendedCalendarProps = React.ComponentProps<typeof DayPicker> & {
23
+ yearMonthDropdownClassName?: React.ReactNode; // Add customField prop
24
+ };
25
+
26
+ function DateRangePicker({
27
+ className,
28
+ classNames,
29
+ showOutsideDays = false,
30
+ yearMonthDropdownClassName,
31
+ ...props
32
+ }: ExtendedCalendarProps) {
33
+ const handleCalendarChange = (
34
+ _value: string | number,
35
+ _e: React.ChangeEventHandler<HTMLSelectElement>
36
+ ) => {
37
+ const _event = {
38
+ target: {
39
+ value: String(_value),
40
+ },
41
+ } as React.ChangeEvent<HTMLSelectElement>;
42
+ _e(_event);
43
+ };
44
+
45
+ const languageCode = 'en'
46
+
47
+ const locale =
48
+ languageCode === "en"
49
+ ? loc["enUS"]
50
+ : Object.values(loc).find((language) => language.code === languageCode);
51
+
52
+ return (
53
+ <DayPicker
54
+ locale={locale}
55
+ formatters={{
56
+ formatWeekdayName: (date, options) => {
57
+ return dayjs(date).format("ddd");
58
+ },
59
+ }}
60
+ showOutsideDays={showOutsideDays}
61
+ className={cn("", className)}
62
+ classNames={{
63
+ months:
64
+ "flex flex-col justify-center sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0",
65
+ month: "space-y-4 border border-stroke min-w-[374px] rounded-3xl",
66
+ caption:
67
+ "flex flex-row relative items-center border-b border-grey-light-hover h-[60px]",
68
+ caption_dropdowns:
69
+ "flex flex-row-reverse justify-center gap-2 grow dropdowns",
70
+ nav: "space-x-1 flex items-center",
71
+ nav_button: cn(
72
+ buttonVariants({ variant: "outline" }),
73
+ "h-8 w-8 p-2 border border-grey-light-hover"
74
+ ),
75
+ nav_button_previous: "absolute left-5 !text-grey1 w-6 h-6",
76
+ nav_button_next: "absolute right-5 !text-grey1 w-6 h-6",
77
+ table: "w-full border-collapse space-y-2 min-h-[284px]",
78
+ head_row:
79
+ "flex capitalize gap-6 text-grey2 items-center justify-center text-xs h-[44px]",
80
+ head_cell: "text-grey2 rounded-md w-6 font-normal text-xs",
81
+ row: "flex flex-row w-full px-4",
82
+ cell: "h-11 w-12 text-center text-xs p-0 relative [&:has([aria-selected].day-range-end)]:rounded-r-md [&:has([aria-selected].day-outside)]:bg-primary [&:has([aria-selected])]:bg-primary-light first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md focus-within:relative focus-within:z-20 flex justify-center items-center",
83
+ day: cn(
84
+ buttonVariants({ variant: "ghost" }),
85
+ "h-11 w-12 text-xs !rounded-full text-grey font-semibold aria-selected:opacity-100"
86
+ ),
87
+ day_range_end: "day-range-end",
88
+ day_selected:
89
+ "aria-selected:bg-primary text-white hover:bg-primary focus:bg-primary focus:text-white hover:text-white",
90
+ day_today: "bg-primary-light text-accent-foreground",
91
+ day_outside:
92
+ "day-outside text-muted-foreground opacity-50 aria-selected:bg-primary aria-selected:text-muted-foreground aria-selected:opacity-30",
93
+ day_disabled: "text-muted-foreground opacity-50",
94
+ day_range_middle:
95
+ "aria-selected:bg-primary-light aria-selected:text-accent-foreground",
96
+ day_hidden: "invisible",
97
+ ...classNames,
98
+ }}
99
+ components={{
100
+ // IconLeft: ({ ...props }) => <ChevronLeft className="h-5 !w-6" />,
101
+ // IconRight: ({ ...props }) => <ChevronRight className="h-5 !w-6" />,
102
+ Dropdown: ({ ...props }) => {
103
+ const [selectedValue, setSelectedValue] = useState<string | null>(
104
+ props.value as string
105
+ );
106
+
107
+ const handleValueChange = (value: string) => {
108
+ setSelectedValue(value);
109
+ if (props.onChange) {
110
+ handleCalendarChange(value, props.onChange);
111
+ }
112
+ };
113
+
114
+ const selectedYearOrMOnth =
115
+ props?.name == "months"
116
+ ? dayjs()
117
+ .month(props.value as number)
118
+ .format("MMM")
119
+ : props?.caption;
120
+
121
+ return (
122
+ <div className="dropdowns-dob">
123
+ <Select
124
+ {...props}
125
+ onValueChange={(value) => {
126
+ handleValueChange(value as string);
127
+ }}
128
+ value={selectedValue ?? (props.value as string)}
129
+ >
130
+ <SelectTrigger
131
+ className={cn(
132
+ `${yearMonthDropdownClassName} h-10 w-[105px] rounded-xl font-medium capitalize [.is-between_&]:hidden [.is-end_&]:hidden [.is-start.is-end_&]:flex`
133
+ )}
134
+ >
135
+ <SelectValue
136
+ placeholder={selectedYearOrMOnth}
137
+ className="capitalize"
138
+ >
139
+ {selectedYearOrMOnth}
140
+ </SelectValue>
141
+ </SelectTrigger>
142
+ <SelectContent className="max-h-[269px] min-w-[109px] p-1">
143
+ <div className="scrollbar max-h-[var(--radix-popper-available-height);] overflow-y-auto capitalize">
144
+ {props.children &&
145
+ React.Children.map(props.children, (child) => (
146
+ <SelectItem
147
+ value={
148
+ (child as React.ReactElement<any>)?.props?.value
149
+ }
150
+ className={cn({
151
+ "bg-[#7677F4]/10 capitalize text-[#7677F4] hover:!bg-[#7677F4]/10":
152
+ selectedValue ===
153
+ (child as React.ReactElement<any>)?.props?.value,
154
+ })}
155
+ >
156
+ {(child as React.ReactElement<any>)?.props?.children}
157
+ </SelectItem>
158
+ ))}
159
+ </div>
160
+ </SelectContent>
161
+ </Select>
162
+ </div>
163
+ );
164
+ },
165
+ CaptionLabel: () => {
166
+ return null;
167
+ },
168
+ }}
169
+ {...props}
170
+ />
171
+ );
172
+ }
173
+
174
+ export { DateRangePicker };
@@ -0,0 +1,86 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import classNames from "classnames";
14
+ import dayjs from "dayjs";
15
+ import { ChevronLeft, ChevronRight } from "lucide-react";
16
+ import * as React from "react";
17
+ import { DayPicker, } from "react-day-picker";
18
+ import { buttonVariants } from "./button";
19
+ import * as loc from "date-fns/locale";
20
+ import { Select, SelectContent, SelectItem, SelectItems, SelectTrigger, SelectValue, } from "./select";
21
+ import { cn } from "../lib/utils";
22
+ /**
23
+ * This is the function,contains a select dropdowns of list of months and year, a previous and next buttons
24
+ * @param showOutsideDays boolean which represents whether to show outside month days or not
25
+ * @param formatters represents format of displaying the week days
26
+ * @param classnames represents the stylings of complete calendar
27
+ * @param components we can add extra components if needed into the calender
28
+ * @returns the calender to select the date with month and year dropdowns
29
+ */
30
+ function Calendar(_a) {
31
+ var { className, classNames, showOutsideDays = true } = _a, props = __rest(_a, ["className", "classNames", "showOutsideDays"]);
32
+ const languageCode = 'en';
33
+ const localeObject = languageCode === "en"
34
+ ? loc["enUS"]
35
+ : Object.values(loc).find((language) => language.code === languageCode);
36
+ const formatWeekdayName = (date) => {
37
+ return dayjs(date).format("ddd").charAt(0);
38
+ };
39
+ const handleDayKeyDown = (day, modifiers, event) => {
40
+ if (event.key === "Enter" || event.key === " ") {
41
+ event.preventDefault();
42
+ const customEvent = new MouseEvent("click", {
43
+ bubbles: true,
44
+ cancelable: true,
45
+ view: window,
46
+ });
47
+ const dayElement = event.target;
48
+ dayElement.dispatchEvent(customEvent);
49
+ }
50
+ };
51
+ return (_jsx(DayPicker, Object.assign({ locale: localeObject, showOutsideDays: showOutsideDays, className: cn("p-3", className), formatters: { formatWeekdayName }, classNames: Object.assign({ months: "flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0", month: "space-y-4", caption: "flex justify-center relative items-center", caption_label: "hidden", caption_dropdowns: "flex justify-center gap-2", nav: "space-x-1 flex items-center", nav_button: cn(buttonVariants({ variant: "outline" }), "h-7 w-7 bg-transparent p-0 opacity-100 !size-[30px] border rounded-[10px]"), nav_button_previous: "absolute left-1", nav_button_next: "absolute right-1", table: "w-full border-collapse space-y-1", head_row: "flex w-1 gap-[25px] px-3 ", head_cell: "text-foreground rounded-full w-9 font-semibold text-sm", cell: "h-9 w-9 text-center text-sm !rounded-full p-0 relative [&:has([aria-selected].day-range-end)]:rounded-r-md [&:has([aria-selected].day-outside)]:bg-accent/50 [&:has([aria-selected])]:bg-accent first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md focus-within:relative focus-within:z-20", day: cn(buttonVariants({ variant: "ghost" }), "h-9 w-9 p-0 font-normal aria-selected:opacity-100 hover:bg-accent disabled:bg-transparent rounded-full"), day_selected: "!bg-primary !rounded-full !size-[33px] text-white hover:!bg-primary", day_today: "bg-accent text-accent-foreground !rounded-full !size-[33px] " }, classNames), components: {
52
+ Dropdown: (_a) => {
53
+ var { value, onChange, children } = _a, props = __rest(_a, ["value", "onChange", "children"]);
54
+ return (_jsx(YearsAndMonthsDropdown, Object.assign({}, props, { value: value, onChange: onChange }, { children: children })));
55
+ },
56
+ IconLeft: () => _jsx(ChevronLeft, { className: "size-4 text-foreground" }),
57
+ IconRight: () => _jsx(ChevronRight, { className: "size-4 text-foreground" }),
58
+ }, onDayKeyDown: handleDayKeyDown }, props)));
59
+ }
60
+ Calendar.displayName = "Calendar";
61
+ export const YearsAndMonthsDropdown = (_a) => {
62
+ var _b, _c, _d, _e;
63
+ var { value, onChange, children } = _a, props = __rest(_a, ["value", "onChange", "children"]);
64
+ const selectClasses = classNames("pr-1.5 h-[30px] text-sm font-semibold focus:border-transparent focus:bg-primary/10 focus:text-primary outline-none border-secondary/20 text-foreground", {
65
+ "rounded-l-[10px] rounded-r-none": (props === null || props === void 0 ? void 0 : props.name) === "months",
66
+ }, { "rounded-l-none rounded-r-[10px]": (props === null || props === void 0 ? void 0 : props.name) === "years" });
67
+ const options = React.Children.toArray(children);
68
+ const selected = options.find((child) => child.props.value === value);
69
+ const handleChange = (value) => {
70
+ const changeEvent = {
71
+ target: { value },
72
+ };
73
+ onChange === null || onChange === void 0 ? void 0 : onChange(changeEvent);
74
+ };
75
+ return (_jsx("div", Object.assign({ className: "border-1 rounded-lg border" }, { children: _jsxs(Select, Object.assign({ value: value === null || value === void 0 ? void 0 : value.toString(), onValueChange: (value) => {
76
+ handleChange(value);
77
+ } }, { children: [_jsx(SelectTrigger, Object.assign({ className: selectClasses }, { children: _jsx(SelectValue, { children: props.name === "months"
78
+ ? (_c = (_b = selected === null || selected === void 0 ? void 0 : selected.props) === null || _b === void 0 ? void 0 : _b.children) === null || _c === void 0 ? void 0 : _c.toString().substring(0, 3)
79
+ : (_e = (_d = selected === null || selected === void 0 ? void 0 : selected.props) === null || _d === void 0 ? void 0 : _d.children) === null || _e === void 0 ? void 0 : _e.toString() }) })), _jsx(SelectContent, Object.assign({ position: "popper", className: "scrollbar max-h-[400px] max-h-[var(--radix-popper-available-height);] overflow-y-auto capitalize" }, { children: _jsx(SelectItems, { children: options.map((option, id) => {
80
+ var _a, _b, _c, _d;
81
+ return (_jsx(SelectItem, Object.assign({ value: (_b = (_a = option.props.value) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : "" }, { children: props.name === "months"
82
+ ? (_c = option.props.children) === null || _c === void 0 ? void 0 : _c.toString().substring(0, 3)
83
+ : (_d = option.props.children) === null || _d === void 0 ? void 0 : _d.toString() }), `${option.props.value}-${id}`));
84
+ }) }) }))] })) })));
85
+ };
86
+ export { Calendar };
@@ -0,0 +1,172 @@
1
+ import classNames from "classnames";
2
+ import dayjs from "dayjs";
3
+ import { ChevronLeft, ChevronRight } from "lucide-react";
4
+ import * as React from "react";
5
+ import {
6
+ DayKeyboardEventHandler,
7
+ DayPicker,
8
+ DropdownProps,
9
+ } from "react-day-picker";
10
+ import { buttonVariants } from "./button";
11
+ import * as loc from "date-fns/locale";
12
+ import {
13
+ Select,
14
+ SelectContent,
15
+ SelectItem,
16
+ SelectItems,
17
+ SelectTrigger,
18
+ SelectValue,
19
+ } from "./select";
20
+ import { cn } from "../lib/utils";
21
+ export type CalendarProps = React.ComponentProps<typeof DayPicker>;
22
+
23
+ /**
24
+ * This is the function,contains a select dropdowns of list of months and year, a previous and next buttons
25
+ * @param showOutsideDays boolean which represents whether to show outside month days or not
26
+ * @param formatters represents format of displaying the week days
27
+ * @param classnames represents the stylings of complete calendar
28
+ * @param components we can add extra components if needed into the calender
29
+ * @returns the calender to select the date with month and year dropdowns
30
+ */
31
+ function Calendar({
32
+ className,
33
+ classNames,
34
+ showOutsideDays = true,
35
+ ...props
36
+ }: CalendarProps) {
37
+ const languageCode = 'en';
38
+ const localeObject =
39
+ languageCode === "en"
40
+ ? loc["enUS"]
41
+ : Object.values(loc).find((language) => language.code === languageCode);
42
+
43
+ const formatWeekdayName = (date: Date) => {
44
+ return dayjs(date).format("ddd").charAt(0);
45
+ };
46
+
47
+ const handleDayKeyDown: DayKeyboardEventHandler = (day, modifiers, event) => {
48
+ if (event.key === "Enter" || event.key === " ") {
49
+ event.preventDefault();
50
+ const customEvent = new MouseEvent("click", {
51
+ bubbles: true,
52
+ cancelable: true,
53
+ view: window,
54
+ });
55
+ const dayElement = event.target as HTMLElement;
56
+ dayElement.dispatchEvent(customEvent);
57
+ }
58
+ };
59
+
60
+ return (
61
+ <DayPicker
62
+ locale={localeObject}
63
+ showOutsideDays={showOutsideDays}
64
+ className={cn("p-3", className)}
65
+ formatters={{ formatWeekdayName }}
66
+ classNames={{
67
+ months: "flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0",
68
+ month: "space-y-4",
69
+ caption: "flex justify-center relative items-center",
70
+ caption_label: "hidden",
71
+ caption_dropdowns: "flex justify-center gap-2",
72
+ nav: "space-x-1 flex items-center",
73
+ nav_button: cn(
74
+ buttonVariants({ variant: "outline" }),
75
+ "h-7 w-7 bg-transparent p-0 opacity-100 !size-[30px] border rounded-[10px]"
76
+ ),
77
+ nav_button_previous: "absolute left-1",
78
+ nav_button_next: "absolute right-1",
79
+ table: "w-full border-collapse space-y-1",
80
+ head_row: "flex w-1 gap-[25px] px-3 ",
81
+ head_cell: "text-foreground rounded-full w-9 font-semibold text-sm",
82
+ cell: "h-9 w-9 text-center text-sm !rounded-full p-0 relative [&:has([aria-selected].day-range-end)]:rounded-r-md [&:has([aria-selected].day-outside)]:bg-accent/50 [&:has([aria-selected])]:bg-accent first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md focus-within:relative focus-within:z-20",
83
+ day: cn(
84
+ buttonVariants({ variant: "ghost" }),
85
+ "h-9 w-9 p-0 font-normal aria-selected:opacity-100 hover:bg-accent disabled:bg-transparent rounded-full"
86
+ ),
87
+ day_selected:
88
+ "!bg-primary !rounded-full !size-[33px] text-white hover:!bg-primary",
89
+ day_today:
90
+ "bg-accent text-accent-foreground !rounded-full !size-[33px] ",
91
+ ...classNames,
92
+ }}
93
+ components={{
94
+ Dropdown: ({ value, onChange, children, ...props }) => (
95
+ <YearsAndMonthsDropdown {...props} value={value} onChange={onChange}>
96
+ {children}
97
+ </YearsAndMonthsDropdown>
98
+ ),
99
+ IconLeft: () => <ChevronLeft className="size-4 text-foreground" />,
100
+ IconRight: () => <ChevronRight className="size-4 text-foreground" />,
101
+ }}
102
+ onDayKeyDown={handleDayKeyDown}
103
+ {...props}
104
+ />
105
+ );
106
+ }
107
+ Calendar.displayName = "Calendar";
108
+
109
+ export const YearsAndMonthsDropdown = ({
110
+ value,
111
+ onChange,
112
+ children,
113
+ ...props
114
+ }: DropdownProps) => {
115
+ const selectClasses = classNames(
116
+ "pr-1.5 h-[30px] text-sm font-semibold focus:border-transparent focus:bg-primary/10 focus:text-primary outline-none border-secondary/20 text-foreground",
117
+ {
118
+ "rounded-l-[10px] rounded-r-none": props?.name === "months",
119
+ },
120
+ { "rounded-l-none rounded-r-[10px]": props?.name === "years" }
121
+ );
122
+
123
+ const options = React.Children.toArray(children) as React.ReactElement<
124
+ React.HTMLProps<HTMLOptionElement>
125
+ >[];
126
+ const selected = options.find((child) => child.props.value === value);
127
+
128
+ const handleChange = (value: string) => {
129
+ const changeEvent = {
130
+ target: { value },
131
+ } as React.ChangeEvent<HTMLSelectElement>;
132
+ onChange?.(changeEvent);
133
+ };
134
+
135
+ return (
136
+ <div className="border-1 rounded-lg border">
137
+ <Select
138
+ value={value?.toString()}
139
+ onValueChange={(value: unknown) => {
140
+ handleChange(value as string);
141
+ }}
142
+ >
143
+ <SelectTrigger className={selectClasses}>
144
+ <SelectValue>
145
+ {props.name === "months"
146
+ ? selected?.props?.children?.toString().substring(0, 3)
147
+ : selected?.props?.children?.toString()}
148
+ </SelectValue>
149
+ </SelectTrigger>
150
+ <SelectContent
151
+ position="popper"
152
+ className="scrollbar max-h-[400px] max-h-[var(--radix-popper-available-height);] overflow-y-auto capitalize"
153
+ >
154
+ <SelectItems>
155
+ {options.map((option, id: number) => (
156
+ <SelectItem
157
+ key={`${option.props.value}-${id}`}
158
+ value={option.props.value?.toString() ?? ""}
159
+ >
160
+ {props.name === "months"
161
+ ? option.props.children?.toString().substring(0, 3)
162
+ : option.props.children?.toString()}
163
+ </SelectItem>
164
+ ))}
165
+ </SelectItems>
166
+ </SelectContent>
167
+ </Select>
168
+ </div>
169
+ );
170
+ };
171
+
172
+ export { Calendar };
@@ -0,0 +1,36 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ import { zodResolver } from "@hookform/resolvers/zod";
14
+ import { useEffect } from "react";
15
+ import { FormProvider, useForm } from "react-hook-form";
16
+ import { z } from "zod";
17
+ const Form = (_a) => {
18
+ var { children, onSubmit, schema = z.object({}), defaultValues, mode = "all", useFormMethodsRef } = _a, props = __rest(_a, ["children", "onSubmit", "schema", "defaultValues", "mode", "useFormMethodsRef"]);
19
+ const methods = useForm({
20
+ resolver: zodResolver(schema),
21
+ mode: mode,
22
+ defaultValues,
23
+ });
24
+ if (useFormMethodsRef)
25
+ useFormMethodsRef.current = methods;
26
+ const { handleSubmit, watch } = methods;
27
+ useEffect(() => {
28
+ watch();
29
+ }, [watch]);
30
+ const checkKeyDown = (e) => {
31
+ if (e.key === "Enter")
32
+ e.preventDefault();
33
+ };
34
+ return (_jsx(FormProvider, Object.assign({}, methods, { children: _jsx("form", Object.assign({ onSubmit: onSubmit != undefined ? handleSubmit(onSubmit) : () => { }, onKeyDown: (e) => checkKeyDown(e) }, props, { children: children })) })));
35
+ };
36
+ export default Form;
@@ -0,0 +1,55 @@
1
+ import { zodResolver } from "@hookform/resolvers/zod";
2
+ import { ReactNode, useEffect } from "react";
3
+ import { FormProvider, useForm } from "react-hook-form";
4
+ import { z, ZodSchema } from "zod";
5
+
6
+ interface FormProps {
7
+ children: ReactNode;
8
+ onSubmit: (data: any) => void;
9
+ defaultValues?: Record<string, any>;
10
+ schema?: ZodSchema<any, any, any>;
11
+ mode?: "all" | "onBlur" | "onChange" | "onSubmit" | "onTouched" | undefined;
12
+ useFormMethodsRef?: React.MutableRefObject<any>;
13
+ }
14
+
15
+ const Form: React.FC<FormProps> = ({
16
+ children,
17
+ onSubmit,
18
+ schema = z.object({}),
19
+ defaultValues,
20
+ mode = "all",
21
+ useFormMethodsRef,
22
+ ...props
23
+ }) => {
24
+ const methods = useForm({
25
+ resolver: zodResolver(schema),
26
+ mode: mode,
27
+ defaultValues,
28
+ });
29
+
30
+ if (useFormMethodsRef) useFormMethodsRef.current = methods;
31
+
32
+ const { handleSubmit, watch } = methods;
33
+
34
+ useEffect(() => {
35
+ watch();
36
+ }, [watch]);
37
+
38
+ const checkKeyDown = (e: any) => {
39
+ if (e.key === "Enter") e.preventDefault();
40
+ };
41
+
42
+ return (
43
+ <FormProvider {...methods}>
44
+ <form
45
+ onSubmit={onSubmit != undefined ? handleSubmit(onSubmit) : () => {}}
46
+ onKeyDown={(e) => checkKeyDown(e)}
47
+ {...props}
48
+ >
49
+ {children}
50
+ </form>
51
+ </FormProvider>
52
+ );
53
+ };
54
+
55
+ export default Form;
@@ -0,0 +1,37 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { debounce } from "lodash";
3
+ import { useEffect, useState } from "react";
4
+ const GetScrollTypesAlert = ({ id, children, onBottom, onTop, }) => {
5
+ const [onBottomReach, setOnBottomReach] = useState(false);
6
+ const [onTopReach, setOnTopReach] = useState(false);
7
+ const handleScroll = debounce(() => {
8
+ let scrollContainer = document.getElementById(id);
9
+ const scrollDifferenceTop = Math.abs((scrollContainer === null || scrollContainer === void 0 ? void 0 : scrollContainer.scrollTop) || 0);
10
+ const scrollDifferenceBottom = Math.abs(((scrollContainer === null || scrollContainer === void 0 ? void 0 : scrollContainer.scrollHeight) || 0) -
11
+ ((scrollContainer === null || scrollContainer === void 0 ? void 0 : scrollContainer.scrollTop) || 0) -
12
+ ((scrollContainer === null || scrollContainer === void 0 ? void 0 : scrollContainer.clientHeight) || 0));
13
+ if (scrollDifferenceBottom <= 2) {
14
+ onBottom();
15
+ setOnBottomReach(true);
16
+ }
17
+ else if (onTop && scrollDifferenceTop <= 2) {
18
+ onTop();
19
+ setOnTopReach(true);
20
+ }
21
+ }, 100); // Adjust the debounce delay as needed
22
+ useEffect(() => {
23
+ let scrollContainer = document.getElementById(id);
24
+ if (scrollContainer) {
25
+ scrollContainer.addEventListener("scroll", handleScroll);
26
+ }
27
+ return () => {
28
+ setOnBottomReach(false);
29
+ setOnTopReach(false);
30
+ if (scrollContainer) {
31
+ scrollContainer.removeEventListener("scroll", handleScroll);
32
+ }
33
+ };
34
+ }, [onBottomReach, onTopReach, id, handleScroll]);
35
+ return _jsx("div", { children: children });
36
+ };
37
+ export default GetScrollTypesAlert;
@@ -0,0 +1,59 @@
1
+ import { debounce } from "lodash";
2
+ import PropTypes from "prop-types";
3
+ import React, { useEffect, useState } from "react";
4
+
5
+ interface GetScrollTypesAlertProps {
6
+ id: string;
7
+ children?: React.ReactNode;
8
+ onBottom: () => void;
9
+ onTop?: () => void;
10
+ }
11
+
12
+ const GetScrollTypesAlert: React.FC<GetScrollTypesAlertProps> = ({
13
+ id,
14
+ children,
15
+ onBottom,
16
+ onTop,
17
+ }) => {
18
+ const [onBottomReach, setOnBottomReach] = useState<boolean>(false);
19
+ const [onTopReach, setOnTopReach] = useState<boolean>(false);
20
+
21
+ const handleScroll = debounce(() => {
22
+ let scrollContainer = document.getElementById(id);
23
+
24
+ const scrollDifferenceTop = Math.abs(scrollContainer?.scrollTop || 0);
25
+ const scrollDifferenceBottom = Math.abs(
26
+ (scrollContainer?.scrollHeight || 0) -
27
+ (scrollContainer?.scrollTop || 0) -
28
+ (scrollContainer?.clientHeight || 0)
29
+ );
30
+
31
+ if (scrollDifferenceBottom <= 2) {
32
+ onBottom();
33
+ setOnBottomReach(true);
34
+ } else if (onTop && scrollDifferenceTop <= 2) {
35
+ onTop();
36
+ setOnTopReach(true);
37
+ }
38
+ }, 100); // Adjust the debounce delay as needed
39
+
40
+ useEffect(() => {
41
+ let scrollContainer = document.getElementById(id);
42
+ if (scrollContainer) {
43
+ scrollContainer.addEventListener("scroll", handleScroll);
44
+ }
45
+ return () => {
46
+ setOnBottomReach(false);
47
+ setOnTopReach(false);
48
+ if (scrollContainer) {
49
+ scrollContainer.removeEventListener("scroll", handleScroll);
50
+ }
51
+ };
52
+ }, [onBottomReach, onTopReach, id, handleScroll]);
53
+
54
+ return <div>{children}</div>;
55
+ };
56
+
57
+ export default GetScrollTypesAlert;
58
+
59
+
@@ -0,0 +1,11 @@
1
+ import { createContext, useContext } from "react";
2
+ // Create the context
3
+ export const RadioGroupContext = createContext(undefined);
4
+ // Custom hook to use the context
5
+ export const useRadioGroupContext = () => {
6
+ const context = useContext(RadioGroupContext);
7
+ if (context === undefined) {
8
+ throw new Error("useRadioGroupContext must be used within a MyProvider");
9
+ }
10
+ return context;
11
+ };
@@ -0,0 +1,21 @@
1
+ import { createContext, useContext } from "react";
2
+
3
+ // Define the type of the context value
4
+ interface RadioGroupContextType {
5
+ value?: string;
6
+ disabled?: boolean;
7
+ }
8
+
9
+ // Create the context
10
+ export const RadioGroupContext = createContext<
11
+ RadioGroupContextType | undefined
12
+ >(undefined);
13
+
14
+ // Custom hook to use the context
15
+ export const useRadioGroupContext = () => {
16
+ const context = useContext(RadioGroupContext);
17
+ if (context === undefined) {
18
+ throw new Error("useRadioGroupContext must be used within a MyProvider");
19
+ }
20
+ return context;
21
+ };