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,47 @@
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 { DayPicker } from "react-day-picker";
14
+ import { cn } from "../lib/utils";
15
+ import dayjs from "dayjs";
16
+ import { buttonVariants } from "./button";
17
+ function DateCalendar(_a) {
18
+ var { className, classNames, showOutsideDays = true, count, captionLayout, fromDate, toDate } = _a, props = __rest(_a, ["className", "classNames", "showOutsideDays", "count", "captionLayout", "fromDate", "toDate"]);
19
+ return (_jsx(DayPicker, Object.assign({ weekStartsOn: 1, formatters: {
20
+ formatWeekdayName: (date, options) => {
21
+ return dayjs(date).format("ddd");
22
+ },
23
+ }, disabled: {
24
+ before: fromDate,
25
+ after: toDate,
26
+ }, showOutsideDays: showOutsideDays, className: cn("", className), 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 pt-2 relative items-center", caption_label: "text-md font-medium", nav: "space-x-2 flex items-center", nav_button: cn(buttonVariants({ variant: "outline" }), "h-8 w-8 p-2 border border-[1px] border-grey-light-hover"), nav_button_previous: "absolute left-2 !text-grey1", nav_button_next: "absolute right-3 !text-grey1", table: "w-full border-collapse ", head_row: "flex capitalize w-full gap-[12px] mx-[6px] text-sm", head_cell: "text-muted-foreground !rounded-full w-10 font-normal text-sm", row: "flex w-full ", cell: "h-10 w-10 text-center m-[6px] !rounded-full text-lg relative [&:has([aria-selected].day-range-end)]:rounded-full [&:has([aria-selected].day-outside)]:bg-accent/50 [&:has([aria-selected])]:bg-accent first:[&:has([aria-selected])]:rounded-full last:[&:has([aria-selected])]:rounded-full hover:rounded-full focus-within:relative focus-within:z-20", day: cn(buttonVariants({ variant: "ghost" }), "h-10 w-10 p-0 font-normal aria-selected:opacity-100 hover:rounded-full "), day_range_end: "day-range-end", day_selected: "aria-selected:bg-primary text-white !rounded-full hover:bg-primary focus:bg-primary focus:text-white hover:text-white", day_today: "bg-accent text-accent-foreground !rounded-full", day_outside: "day-outside text-muted-foreground opacity-50 aria-selected:!bg-primary aria-selected:text-primary-foreground aria-selected:opacity-30", day_disabled: "text-muted-foreground opacity-50", day_range_middle: "aria-selected:bg-primary-light aria-selected:text-accent-foreground", day_hidden: "invisible" }, classNames), components: {
27
+ CaptionLabel: (_a) => {
28
+ var props = __rest(_a, []);
29
+ // Extract the month from the props
30
+ const { displayMonth } = props;
31
+ const month = dayjs(displayMonth).format("MMMM");
32
+ const year = displayMonth.getFullYear();
33
+ return (_jsxs("div", Object.assign({ className: "flex flex-col items-center gap-1 font-semibold" }, { children: [_jsx("div", Object.assign({ className: "text-[20px] capitalize" }, { children: month })), _jsx("div", Object.assign({ className: "text-[12px] text-[#999999]" }, { children: year }))] })));
34
+ },
35
+ DayContent: (_a) => {
36
+ var { date } = _a, dayprops = __rest(_a, ["date"]);
37
+ const isSelected = props.selected instanceof Date &&
38
+ date.getDate() === props.selected.getDate() &&
39
+ date.getMonth() === props.selected.getMonth() &&
40
+ date.getFullYear() === props.selected.getFullYear();
41
+ const showCount = count !== undefined;
42
+ return (_jsxs("div", { children: [date === null || date === void 0 ? void 0 : date.getDate(), isSelected && showCount && (_jsx("div", Object.assign({ className: "absolute right-[-4px] top-[-4px] flex h-5 w-5 items-center justify-center rounded-full bg-[#FF6D6D] text-xs text-white" }, { children: count })))] }));
43
+ },
44
+ } }, props)));
45
+ }
46
+ DateCalendar.displayName = "Calendar";
47
+ export { DateCalendar };
@@ -0,0 +1,111 @@
1
+ import * as React from "react";
2
+ import { ChevronLeft, ChevronRight } from "lucide-react";
3
+ import { DayPicker } from "react-day-picker";
4
+
5
+ import { cn } from "../lib/utils";
6
+ import dayjs from "dayjs";
7
+ import { buttonVariants } from "./button";
8
+
9
+ export type DateCalendarProps = React.ComponentProps<typeof DayPicker>;
10
+
11
+ function DateCalendar({
12
+ className,
13
+ classNames,
14
+ showOutsideDays = true,
15
+ count,
16
+ captionLayout,
17
+ fromDate,
18
+ toDate,
19
+ ...props
20
+ }: DateCalendarProps & { count?: number }) {
21
+ return (
22
+ <DayPicker
23
+ weekStartsOn={1}
24
+ formatters={{
25
+ formatWeekdayName: (date, options) => {
26
+ return dayjs(date).format("ddd");
27
+ },
28
+ }}
29
+ disabled={{
30
+ before: fromDate as Date,
31
+ after: toDate as Date,
32
+ }}
33
+ showOutsideDays={showOutsideDays}
34
+ className={cn("", className)}
35
+ classNames={{
36
+ months: "flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0",
37
+ month: "space-y-4",
38
+ caption: "flex justify-center pt-2 relative items-center",
39
+ caption_label: "text-md font-medium",
40
+ nav: "space-x-2 flex items-center",
41
+ nav_button: cn(
42
+ buttonVariants({ variant: "outline" }),
43
+ "h-8 w-8 p-2 border border-[1px] border-grey-light-hover"
44
+ ),
45
+ nav_button_previous: "absolute left-2 !text-grey1",
46
+ nav_button_next: "absolute right-3 !text-grey1",
47
+ table: "w-full border-collapse ",
48
+ head_row: "flex capitalize w-full gap-[12px] mx-[6px] text-sm",
49
+ head_cell:
50
+ "text-muted-foreground !rounded-full w-10 font-normal text-sm",
51
+ row: "flex w-full ",
52
+ cell: "h-10 w-10 text-center m-[6px] !rounded-full text-lg relative [&:has([aria-selected].day-range-end)]:rounded-full [&:has([aria-selected].day-outside)]:bg-accent/50 [&:has([aria-selected])]:bg-accent first:[&:has([aria-selected])]:rounded-full last:[&:has([aria-selected])]:rounded-full hover:rounded-full focus-within:relative focus-within:z-20",
53
+ day: cn(
54
+ buttonVariants({ variant: "ghost" }),
55
+ "h-10 w-10 p-0 font-normal aria-selected:opacity-100 hover:rounded-full "
56
+ ),
57
+ day_range_end: "day-range-end",
58
+ day_selected:
59
+ "aria-selected:bg-primary text-white !rounded-full hover:bg-primary focus:bg-primary focus:text-white hover:text-white",
60
+ day_today: "bg-accent text-accent-foreground !rounded-full",
61
+ day_outside:
62
+ "day-outside text-muted-foreground opacity-50 aria-selected:!bg-primary aria-selected:text-primary-foreground aria-selected:opacity-30",
63
+ day_disabled: "text-muted-foreground opacity-50",
64
+ day_range_middle:
65
+ "aria-selected:bg-primary-light aria-selected:text-accent-foreground",
66
+ day_hidden: "invisible",
67
+ ...classNames,
68
+ }}
69
+ components={{
70
+ CaptionLabel: ({ ...props }) => {
71
+ // Extract the month from the props
72
+ const { displayMonth } = props;
73
+
74
+ const month = dayjs(displayMonth).format("MMMM");
75
+
76
+ const year = displayMonth.getFullYear();
77
+
78
+ return (
79
+ <div className="flex flex-col items-center gap-1 font-semibold">
80
+ <div className="text-[20px] capitalize">{month}</div>
81
+ <div className="text-[12px] text-[#999999]">{year}</div>
82
+ </div>
83
+ );
84
+ },
85
+ DayContent: ({ date, ...dayprops }) => {
86
+ const isSelected =
87
+ props.selected instanceof Date &&
88
+ date.getDate() === props.selected.getDate() &&
89
+ date.getMonth() === props.selected.getMonth() &&
90
+ date.getFullYear() === props.selected.getFullYear();
91
+
92
+ const showCount = count !== undefined;
93
+ return (
94
+ <div>
95
+ {date?.getDate()}
96
+ {isSelected && showCount && (
97
+ <div className="absolute right-[-4px] top-[-4px] flex h-5 w-5 items-center justify-center rounded-full bg-[#FF6D6D] text-xs text-white">
98
+ {count}
99
+ </div>
100
+ )}
101
+ </div>
102
+ );
103
+ },
104
+ }}
105
+ {...props}
106
+ />
107
+ );
108
+ }
109
+ DateCalendar.displayName = "Calendar";
110
+
111
+ export { DateCalendar };
@@ -0,0 +1,37 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import CalenderIcon from "../../public/assets/CalenderIcon";
3
+ import { useState } from "react";
4
+ import { cn } from "../lib/utils";
5
+ import { Button, buttonVariants } from "./button";
6
+ import { Popover, PopoverContent, PopoverTrigger } from "./popover";
7
+ import dayjs from "dayjs";
8
+ import { DateRangePicker } from "./DateRangePicker";
9
+ export const DateField = ({ value, onChange, placeholder, className, disabled, fromDate, toDate, error = false, formatType = "DD MMM, YYYY", onBlur, onFocus, }) => {
10
+ // State to manage the visibility of the popover
11
+ const [isOpen, setIsOpen] = useState(false);
12
+ const fromYear = fromDate ? fromDate.getFullYear() : 1900;
13
+ const toYear = toDate ? toDate.getFullYear() : 2030;
14
+ /**
15
+ * Function to handle the selected date
16
+ */
17
+ const handleSelectDate = (value) => {
18
+ if (value)
19
+ onChange(value);
20
+ setIsOpen(false);
21
+ };
22
+ return (_jsxs(Popover, Object.assign({ open: isOpen, onOpenChange: setIsOpen }, { children: [_jsx(PopoverTrigger, Object.assign({ asChild: true }, { children: _jsxs(Button, Object.assign({ variant: "outline", className: cn(`flex flex-row justify-start gap-2 px-3`, error && "border border-red", className, value ? "text-grey" : "font-normal text-grey2"), onClick: () => setIsOpen(!isOpen), disabled: disabled ? true : false, onBlur: onBlur, onFocus: onFocus }, { children: [_jsx(CalenderIcon, { color: "#666666", className: "mr-2 h-4 w-4" }), value ? (_jsx("div", Object.assign({ className: "capitalize" }, { children: value && dayjs(value).format(formatType) }))) : (_jsx("span", { children: placeholder ? placeholder : "Pick a date" }))] })) })), _jsx(PopoverContent, Object.assign({ className: "w-[320px] rounded-3xl p-0" }, { children: _jsx(DateRangePicker, { mode: "single", selected: value, onSelect: (val) => {
23
+ handleSelectDate(val);
24
+ }, captionLayout: "dropdown-buttons", fromYear: fromYear, toYear: toYear, fromDate: fromDate, toDate: toDate, yearMonthDropdownClassName: "!w-[80px]", classNames: {
25
+ month: "border-none border border-stroke min-w-[320px] rounded-3xl",
26
+ cell: "h-10 w-10 text-center rounded-full 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",
27
+ day: cn(buttonVariants({ variant: "ghost" }), "h-10 w-10 text-xs px-2 !rounded-full text-grey font-semibold aria-selected:opacity-100"),
28
+ head_cell: "text-grey2 rounded-md w-10 font-normal text-xs",
29
+ head_row: "flex capitalize text-grey2 items-center justify-center text-xs h-[44px]",
30
+ nav_button: cn(buttonVariants({ variant: "outline" }), "h-8 w-8 p-2 border border-grey-light-hover"),
31
+ table: "w-full border-collapse space-y-2 min-h-[250px]",
32
+ }, disabled: (date) => {
33
+ const isAfterDisableDate = toDate ? date > toDate : false;
34
+ const isBeforeEnableDate = fromDate ? date < fromDate : false;
35
+ return isAfterDisableDate || isBeforeEnableDate;
36
+ }, defaultMonth: value }) }))] })));
37
+ };
@@ -0,0 +1,142 @@
1
+ import CalenderIcon from "../assets/CalenderIcon";
2
+ import { format } from "date-fns";
3
+ import { useEffect, useRef, useState } from "react";
4
+ import { cn } from "../lib/utils";
5
+ import { Button, buttonVariants } from "./button";
6
+ import { Popover, PopoverContent, PopoverTrigger } from "./popover";
7
+ import dayjs from "dayjs";
8
+ import { DateRangePicker } from "./DateRangePicker";
9
+ interface DateFieldProps {
10
+ /**
11
+ * The selected date to be displayed in the calendar.
12
+ */
13
+ value?: Date;
14
+ /**
15
+ * Function to set the selected date.
16
+ * @param value - The date to set as the selected date.
17
+ */
18
+ onChange: (value: Date) => void;
19
+ /**
20
+ * Placeholder text to display when no date is selected.
21
+ */
22
+ placeholder?: string;
23
+ /**
24
+ * className to change stylings of the calendar.
25
+ */
26
+ className?: string;
27
+
28
+ // Enable or disable the date picker
29
+
30
+ disabled?: boolean;
31
+
32
+ fromDate?: Date;
33
+
34
+ toDate?: Date;
35
+ /**
36
+ * This is to define the format to be displayed in input when we select the date
37
+ */
38
+ formatType?: string;
39
+ /**
40
+ * If error is true, then make border will be red
41
+ */
42
+ error?: boolean;
43
+
44
+ onBlur?: (event: React.FocusEvent<HTMLButtonElement>) => void;
45
+
46
+ onFocus?: (event: React.FocusEvent<HTMLButtonElement>) => void;
47
+ }
48
+ export const DateField = ({
49
+ value,
50
+ onChange,
51
+ placeholder,
52
+ className,
53
+ disabled,
54
+ fromDate,
55
+ toDate,
56
+ error = false,
57
+ formatType = "DD MMM, YYYY",
58
+ onBlur,
59
+ onFocus,
60
+ }: DateFieldProps) => {
61
+ // State to manage the visibility of the popover
62
+ const [isOpen, setIsOpen] = useState(false);
63
+
64
+ const fromYear = fromDate ? fromDate.getFullYear() : 1900;
65
+ const toYear = toDate ? toDate.getFullYear() : 2030;
66
+
67
+ /**
68
+ * Function to handle the selected date
69
+ */
70
+ const handleSelectDate = (value: any) => {
71
+ if (value) onChange(value);
72
+ setIsOpen(false);
73
+ };
74
+
75
+ return (
76
+ <Popover open={isOpen} onOpenChange={setIsOpen}>
77
+ <PopoverTrigger asChild>
78
+ <Button
79
+ variant={"outline"}
80
+ className={cn(
81
+ `flex flex-row justify-start gap-2 px-3`,
82
+ error && "border border-red",
83
+ className,
84
+ value ? "text-grey" : "font-normal text-grey2"
85
+ )}
86
+ onClick={() => setIsOpen(!isOpen)}
87
+ disabled={disabled ? true : false}
88
+ onBlur={onBlur}
89
+ onFocus={onFocus}
90
+ >
91
+ <CalenderIcon color="#666666" className="mr-2 h-4 w-4" />
92
+
93
+ {/* Render the formatted date if date is selected, otherwise render the placeholder */}
94
+ {value ? (
95
+ <div className="capitalize">
96
+ {value && dayjs(value).format(formatType)}
97
+ </div>
98
+ ) : (
99
+ <span>{placeholder ? placeholder : "Pick a date"}</span>
100
+ )}
101
+ </Button>
102
+ </PopoverTrigger>
103
+ <PopoverContent className="w-[320px] rounded-3xl p-0">
104
+ <DateRangePicker
105
+ mode="single"
106
+ selected={value}
107
+ onSelect={(val: any) => {
108
+ handleSelectDate(val);
109
+ }}
110
+ captionLayout="dropdown-buttons"
111
+ fromYear={fromYear}
112
+ toYear={toYear}
113
+ fromDate={fromDate}
114
+ toDate={toDate}
115
+ yearMonthDropdownClassName="!w-[80px]"
116
+ classNames={{
117
+ month: "border-none border border-stroke min-w-[320px] rounded-3xl",
118
+ cell: "h-10 w-10 text-center rounded-full 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",
119
+ day: cn(
120
+ buttonVariants({ variant: "ghost" }),
121
+ "h-10 w-10 text-xs px-2 !rounded-full text-grey font-semibold aria-selected:opacity-100"
122
+ ),
123
+ head_cell: "text-grey2 rounded-md w-10 font-normal text-xs",
124
+ head_row:
125
+ "flex capitalize text-grey2 items-center justify-center text-xs h-[44px]",
126
+ nav_button: cn(
127
+ buttonVariants({ variant: "outline" }),
128
+ "h-8 w-8 p-2 border border-grey-light-hover"
129
+ ),
130
+ table: "w-full border-collapse space-y-2 min-h-[250px]",
131
+ }}
132
+ disabled={(date) => {
133
+ const isAfterDisableDate = toDate ? date > toDate : false;
134
+ const isBeforeEnableDate = fromDate ? date < fromDate : false;
135
+ return isAfterDisableDate || isBeforeEnableDate;
136
+ }}
137
+ defaultMonth={value}
138
+ />
139
+ </PopoverContent>
140
+ </Popover>
141
+ );
142
+ };
@@ -0,0 +1,42 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { format } from "date-fns";
3
+ import { useTranslation } from "next-i18next";
4
+ import CalenderIcon from "../../public/assets/CalenderIcon";
5
+ import * as React from "react";
6
+ import { Button } from "./button";
7
+ import { Popover, PopoverContent, PopoverTrigger } from "./popover";
8
+ import { cn } from "../lib/utils";
9
+ import { Calendar } from "./DobCalendar";
10
+ /**
11
+ * This is the function of complete date picker,Which contains a button and a calendar
12
+ * @returns complete date picker
13
+ */
14
+ export function DateOfBirthSelector({ onChange, value, onBlur, onFocus, error, className, placeholder, fromDate, toDate, disabled, }) {
15
+ const { t } = useTranslation("common");
16
+ const [date, setDate] = React.useState(value);
17
+ const [calendarOpen, setCalendarOpen] = React.useState(false);
18
+ const thisYear = new Date().getFullYear(); //present year
19
+ const handleDateChange = (newDate) => {
20
+ setDate(newDate);
21
+ if (newDate)
22
+ onChange(format(newDate, "yyyy/MM/dd"));
23
+ else
24
+ onChange("");
25
+ setCalendarOpen(false);
26
+ };
27
+ React.useEffect(() => {
28
+ setDate(value ? new Date(value) : value);
29
+ }, [value]);
30
+ return (_jsxs(Popover, Object.assign({ open: disabled ? false : calendarOpen, onOpenChange: setCalendarOpen }, { children: [_jsx(PopoverTrigger, Object.assign({ asChild: true }, { children: _jsxs(Button, Object.assign({ className: cn("border border-input bg-[white] text-left font-normal sm:h-[40px] sm:w-full", className, error && "border-[#FF6D6D]", disabled && "cursor-not-allowed"), onBlur: onBlur, onFocus: onFocus }, { children: [_jsx("div", Object.assign({ className: `flex w-full flex-col ${date ? "text-[#333333]" : "text-[#999999]"}` }, { children: date ? format(date, "dd-MM-yyyy") : placeholder })), _jsx("div", { children: _jsx(CalenderIcon, { color: "#666666", className: "mr-2 h-4 w-4" }) })] })) })), _jsx(PopoverContent, Object.assign({ align: "center", className: "h-auto w-[270px] rounded-[21px] border-[#D7D7D7] p-0" }, { children: _jsx(Calendar, { mode: "single" // Here single mode represents that we can pick a single date from calendar
31
+ , captionLayout: "dropdown-buttons" //The calendar contains both dropdowns of months, years and previous, next buttons
32
+ , selected: date, showOutsideDays: false, weekStartsOn: 1, onSelect: handleDateChange, fromDate: fromDate, toDate: toDate, disabled: (date) => {
33
+ const todayDate = new Date();
34
+ todayDate.setHours(0, 0, 0, 0);
35
+ const selectDate = new Date(date);
36
+ return fromDate && toDate
37
+ ? false
38
+ : fromDate
39
+ ? selectDate < todayDate
40
+ : selectDate > todayDate;
41
+ }, defaultMonth: date }) }))] })));
42
+ }
@@ -0,0 +1,114 @@
1
+ import { format } from "date-fns";
2
+ import { useTranslation } from "next-i18next";
3
+ import CalenderIcon from "../assets/CalenderIcon";
4
+ import * as React from "react";
5
+ import { Button } from "./button";
6
+ import { Popover, PopoverContent, PopoverTrigger } from "./popover";
7
+ import { cn } from "../lib/utils";
8
+ import { Calendar } from "./DobCalendar";
9
+
10
+ /**
11
+ * This is the function of complete date picker,Which contains a button and a calendar
12
+ * @returns complete date picker
13
+ */
14
+ export function DateOfBirthSelector({
15
+ onChange,
16
+ value,
17
+ onBlur,
18
+ onFocus,
19
+ error,
20
+ className,
21
+ placeholder,
22
+ fromDate,
23
+ toDate,
24
+ disabled,
25
+ }: {
26
+ onChange: any;
27
+ value: any;
28
+ onBlur?: any;
29
+ onFocus?: any;
30
+ error?: any;
31
+ className?: string;
32
+ placeholder?: string;
33
+ fromDate: Date;
34
+ toDate: Date;
35
+ disabled?: boolean;
36
+ }) {
37
+ const { t } = useTranslation("common");
38
+ const [date, setDate] = React.useState<Date | undefined>(value);
39
+ const [calendarOpen, setCalendarOpen] = React.useState(false);
40
+
41
+ const thisYear = new Date().getFullYear(); //present year
42
+
43
+ const handleDateChange = (newDate: Date | undefined) => {
44
+ setDate(newDate);
45
+
46
+ if (newDate) onChange(format(newDate, "yyyy/MM/dd"));
47
+ else onChange("");
48
+ setCalendarOpen(false);
49
+ };
50
+ React.useEffect(() => {
51
+ setDate(value ? new Date(value) : value);
52
+ }, [value]);
53
+
54
+ return (
55
+ <Popover
56
+ open={disabled ? false : calendarOpen}
57
+ onOpenChange={setCalendarOpen}
58
+ >
59
+ <PopoverTrigger asChild>
60
+ <Button
61
+ className={cn(
62
+ "border border-input bg-[white] text-left font-normal sm:h-[40px] sm:w-full",
63
+ className,
64
+ error && "border-[#FF6D6D]",
65
+ disabled && "cursor-not-allowed"
66
+ )}
67
+ onBlur={onBlur}
68
+ onFocus={onFocus}
69
+ >
70
+ <div
71
+ className={`flex w-full flex-col ${
72
+ date ? "text-[#333333]" : "text-[#999999]"
73
+ }`}
74
+ >
75
+ {/* <span className={`${date ? "text-primary" : "text-secondary"}`}>
76
+ {date ? format(date, "dd MMM yyyy") : t("dateOfBirth")}
77
+ </span> */}
78
+ {date ? format(date, "dd-MM-yyyy") : placeholder}
79
+ {/* {date ? date : placeholder} */}
80
+ </div>
81
+ <div>
82
+ <CalenderIcon color="#666666" className="mr-2 h-4 w-4" />
83
+ </div>
84
+ </Button>
85
+ </PopoverTrigger>
86
+ <PopoverContent
87
+ align="center"
88
+ className="h-auto w-[270px] rounded-[21px] border-[#D7D7D7] p-0"
89
+ >
90
+ <Calendar
91
+ mode="single" // Here single mode represents that we can pick a single date from calendar
92
+ captionLayout="dropdown-buttons" //The calendar contains both dropdowns of months, years and previous, next buttons
93
+ selected={date} // Shows the selected date in the calendar
94
+ showOutsideDays={false} // Whether need to show the days not present in the month
95
+ weekStartsOn={1} // Sequence of days in a week starts from monday
96
+ onSelect={handleDateChange} // Selected date is set to the date after selected from the calendar
97
+ fromDate={fromDate} //The earliest day to start the month navigation.
98
+ toDate={toDate} //The latest day to end the month navigation.
99
+ disabled={(date) => {
100
+ const todayDate = new Date();
101
+ todayDate.setHours(0, 0, 0, 0);
102
+ const selectDate = new Date(date);
103
+ return fromDate && toDate
104
+ ? false
105
+ : fromDate
106
+ ? selectDate < todayDate
107
+ : selectDate > todayDate;
108
+ }}
109
+ defaultMonth={date}
110
+ />
111
+ </PopoverContent>
112
+ </Popover>
113
+ );
114
+ }
@@ -0,0 +1,73 @@
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 React from "react";
15
+ import { DayPicker } from "react-day-picker";
16
+ import { cn } from "../lib/utils";
17
+ import { buttonVariants } from "./button";
18
+ import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "./select";
19
+ import { useState } from "react";
20
+ import dayjs from "dayjs";
21
+ import * as loc from "date-fns/locale";
22
+ function DateRangePicker(_a) {
23
+ var { className, classNames, showOutsideDays = false, yearMonthDropdownClassName } = _a, props = __rest(_a, ["className", "classNames", "showOutsideDays", "yearMonthDropdownClassName"]);
24
+ const handleCalendarChange = (_value, _e) => {
25
+ const _event = {
26
+ target: {
27
+ value: String(_value),
28
+ },
29
+ };
30
+ _e(_event);
31
+ };
32
+ const languageCode = 'en';
33
+ const locale = languageCode === "en"
34
+ ? loc["enUS"]
35
+ : Object.values(loc).find((language) => language.code === languageCode);
36
+ return (_jsx(DayPicker, Object.assign({ locale: locale, formatters: {
37
+ formatWeekdayName: (date, options) => {
38
+ return dayjs(date).format("ddd");
39
+ },
40
+ }, showOutsideDays: showOutsideDays, className: cn("", className), classNames: Object.assign({ months: "flex flex-col justify-center sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0", month: "space-y-4 border border-stroke min-w-[374px] rounded-3xl", caption: "flex flex-row relative items-center border-b border-grey-light-hover h-[60px]", caption_dropdowns: "flex flex-row-reverse justify-center gap-2 grow dropdowns", nav: "space-x-1 flex items-center", nav_button: cn(buttonVariants({ variant: "outline" }), "h-8 w-8 p-2 border border-grey-light-hover"), nav_button_previous: "absolute left-5 !text-grey1 w-6 h-6", nav_button_next: "absolute right-5 !text-grey1 w-6 h-6", table: "w-full border-collapse space-y-2 min-h-[284px]", head_row: "flex capitalize gap-6 text-grey2 items-center justify-center text-xs h-[44px]", head_cell: "text-grey2 rounded-md w-6 font-normal text-xs", row: "flex flex-row w-full px-4", 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", day: cn(buttonVariants({ variant: "ghost" }), "h-11 w-12 text-xs !rounded-full text-grey font-semibold aria-selected:opacity-100"), day_range_end: "day-range-end", day_selected: "aria-selected:bg-primary text-white hover:bg-primary focus:bg-primary focus:text-white hover:text-white", day_today: "bg-primary-light text-accent-foreground", day_outside: "day-outside text-muted-foreground opacity-50 aria-selected:bg-primary aria-selected:text-muted-foreground aria-selected:opacity-30", day_disabled: "text-muted-foreground opacity-50", day_range_middle: "aria-selected:bg-primary-light aria-selected:text-accent-foreground", day_hidden: "invisible" }, classNames), components: {
41
+ // IconLeft: ({ ...props }) => <ChevronLeft className="h-5 !w-6" />,
42
+ // IconRight: ({ ...props }) => <ChevronRight className="h-5 !w-6" />,
43
+ Dropdown: (_a) => {
44
+ var props = __rest(_a, []);
45
+ const [selectedValue, setSelectedValue] = useState(props.value);
46
+ const handleValueChange = (value) => {
47
+ setSelectedValue(value);
48
+ if (props.onChange) {
49
+ handleCalendarChange(value, props.onChange);
50
+ }
51
+ };
52
+ const selectedYearOrMOnth = (props === null || props === void 0 ? void 0 : props.name) == "months"
53
+ ? dayjs()
54
+ .month(props.value)
55
+ .format("MMM")
56
+ : props === null || props === void 0 ? void 0 : props.caption;
57
+ return (_jsx("div", Object.assign({ className: "dropdowns-dob" }, { children: _jsxs(Select, Object.assign({}, props, { onValueChange: (value) => {
58
+ handleValueChange(value);
59
+ }, value: selectedValue !== null && selectedValue !== void 0 ? selectedValue : props.value }, { children: [_jsx(SelectTrigger, Object.assign({ className: cn(`${yearMonthDropdownClassName} h-10 w-[105px] rounded-xl font-medium capitalize [.is-between_&]:hidden [.is-end_&]:hidden [.is-start.is-end_&]:flex`) }, { children: _jsx(SelectValue, Object.assign({ placeholder: selectedYearOrMOnth, className: "capitalize" }, { children: selectedYearOrMOnth })) })), _jsx(SelectContent, Object.assign({ className: "max-h-[269px] min-w-[109px] p-1" }, { children: _jsx("div", Object.assign({ className: "scrollbar max-h-[var(--radix-popper-available-height);] overflow-y-auto capitalize" }, { children: props.children &&
60
+ React.Children.map(props.children, (child) => {
61
+ var _a, _b, _c;
62
+ return (_jsx(SelectItem, Object.assign({ value: (_a = child === null || child === void 0 ? void 0 : child.props) === null || _a === void 0 ? void 0 : _a.value, className: cn({
63
+ "bg-[#7677F4]/10 capitalize text-[#7677F4] hover:!bg-[#7677F4]/10": selectedValue ===
64
+ ((_b = child === null || child === void 0 ? void 0 : child.props) === null || _b === void 0 ? void 0 : _b.value),
65
+ }) }, { children: (_c = child === null || child === void 0 ? void 0 : child.props) === null || _c === void 0 ? void 0 : _c.children })));
66
+ }) })) }))] })) })));
67
+ },
68
+ CaptionLabel: () => {
69
+ return null;
70
+ },
71
+ } }, props)));
72
+ }
73
+ export { DateRangePicker };