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,260 @@
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, Fragment as _Fragment } from "react/jsx-runtime";
14
+ import CrossIcon from "../../public/assets/CrossIcon";
15
+ import DropDownArrow from "../../public/assets/DropDown";
16
+ import * as PopoverPrimitive from "@radix-ui/react-popover";
17
+ import { Command as CommandPrimitive, useCommandState } from "cmdk";
18
+ import { Search } from "lucide-react";
19
+ import { useTranslation } from "next-i18next";
20
+ import * as React from "react";
21
+ import { useRef } from "react";
22
+ import { cn } from "../lib/utils";
23
+ import { Button } from "./button";
24
+ import { ccn } from "../lib/CommonComponentsUtil";
25
+ import { Input } from "./input";
26
+ // Here we have to create the context for sending the data to child components
27
+ const dropDownContext = React.createContext({
28
+ value: null,
29
+ onChange: () => { },
30
+ selectedLabel: "",
31
+ setSelectedLabel: () => { },
32
+ isFiltering: false,
33
+ searchValue: "",
34
+ setSearchValue: () => { },
35
+ isLoading: false,
36
+ open: false,
37
+ defaultOptions: [],
38
+ triggerRef: null,
39
+ contentWidth: 0,
40
+ setContentWidth: () => { },
41
+ secured: false,
42
+ showSeparator: true,
43
+ });
44
+ const MVPSelect = React.forwardRef((_a, ref) => {
45
+ var { value, onChange, isFiltering, isLoading, secured = false, defaultOptions = [], showSeparator = true } = _a, props = __rest(_a, ["value", "onChange", "isFiltering", "isLoading", "secured", "defaultOptions", "showSeparator"]);
46
+ // to track whether to show the list of options in the dropdown or not
47
+ const [open, setOpen] = React.useState(false);
48
+ const [searchValue, setSearchValue] = React.useState("");
49
+ /**
50
+ * while selecting any item in the options then we have to close the popover
51
+ * @param val
52
+ */
53
+ const handleClick = (open) => {
54
+ setOpen(open);
55
+ };
56
+ /**
57
+ * while selecting any item in the options then we have to store the id of the item and along with we have to close the popover
58
+ * @param val
59
+ */
60
+ const handleChange = (val) => {
61
+ onChange && onChange(val);
62
+ handleClick(false);
63
+ };
64
+ //we have to take the selected label and store in it to display it in the input
65
+ const [selectedLabel, setSelectedLabel] = React.useState("");
66
+ const triggerRef = useRef(null);
67
+ const [contentWidth, setContentWidth] = React.useState("auto");
68
+ React.useEffect(() => {
69
+ const updateContentWidth = () => {
70
+ var _a;
71
+ setContentWidth(`${(_a = triggerRef.current) === null || _a === void 0 ? void 0 : _a.offsetWidth}px`);
72
+ };
73
+ window.addEventListener("resize", updateContentWidth);
74
+ updateContentWidth(); // Call initially to set the width
75
+ return () => window.removeEventListener("resize", updateContentWidth);
76
+ }, []);
77
+ return (_jsx(dropDownContext.Provider, Object.assign({ value: {
78
+ value,
79
+ onChange: handleChange,
80
+ selectedLabel,
81
+ setSelectedLabel,
82
+ searchValue,
83
+ setSearchValue,
84
+ isLoading,
85
+ isFiltering,
86
+ open,
87
+ defaultOptions,
88
+ triggerRef,
89
+ setContentWidth,
90
+ contentWidth,
91
+ secured,
92
+ showSeparator,
93
+ } }, { children: _jsx(PopoverPrimitive.Root, Object.assign({ open: open, onOpenChange: handleClick }, props)) })));
94
+ });
95
+ MVPSelect.displayName = "MVPSelect";
96
+ const Trigger = PopoverPrimitive.Trigger;
97
+ const MVPSelectTrigger = React.forwardRef((_a, ref) => {
98
+ var { placeholder, error, disable, className, endIcon, crossIcon = true } = _a, props = __rest(_a, ["placeholder", "error", "disable", "className", "endIcon", "crossIcon"]);
99
+ const { selectedLabel, onChange, setSelectedLabel, defaultOptions, triggerRef, setContentWidth, value, } = React.useContext(dropDownContext);
100
+ React.useEffect(() => {
101
+ if (triggerRef && triggerRef.current) {
102
+ setContentWidth(`${triggerRef.current.offsetWidth}px`);
103
+ }
104
+ }, []);
105
+ React.useEffect(() => {
106
+ if (defaultOptions && defaultOptions.length > 0) {
107
+ setSelectedLabel(defaultOptions[0].label);
108
+ }
109
+ else if (defaultOptions.length === 0) {
110
+ setSelectedLabel("");
111
+ }
112
+ }, [JSON.stringify(defaultOptions)]);
113
+ return (_jsx(Trigger, Object.assign({ ref: triggerRef, asChild: true }, { children: _jsxs(Button, Object.assign({ disabled: disable, ref: ref, variant: "outline", type: "button", role: "combobox",
114
+ // aria-expanded={open}
115
+ className: cn("min-w-69 w-full justify-between gap-0 px-3 py-2", className, ccn(error, value)) }, props, { children: [_jsx("div", Object.assign({ className: selectedLabel === "" ||
116
+ selectedLabel === undefined ||
117
+ selectedLabel === null
118
+ ? "truncate font-normal text-[#999999]"
119
+ : "truncate" }, { children: selectedLabel || placeholder })), selectedLabel && crossIcon ? (_jsxs("div", Object.assign({ className: "flex items-center gap-1" }, { children: [endIcon && (_jsx("div", Object.assign({ onClick: (e) => {
120
+ e.stopPropagation(); // Prevent the outer button's click event
121
+ } }, { children: endIcon }))), _jsx("button", Object.assign({ onClick: (e) => {
122
+ e.stopPropagation(); // Prevent the outer button's click event
123
+ onChange && onChange("");
124
+ setSelectedLabel(null);
125
+ }, type: "button", className: cn("h-5 w-5 focus:outline-keyboardTab", disable && "cursor-not-allowed") }, { children: _jsx(CrossIcon, { height: 10, className: "text-grey" }) }))] }))) : (_jsx(DropDownArrow, {}))] })) })));
126
+ });
127
+ MVPSelectTrigger.displayName = "MVPSelectTrigger";
128
+ const MVPSelectContent = React.forwardRef((_a, ref) => {
129
+ var { className } = _a, props = __rest(_a, ["className"]);
130
+ const { contentWidth } = React.useContext(dropDownContext);
131
+ return (_jsx(PopoverPrimitive.Content, Object.assign({ ref: ref,
132
+ // align={align}
133
+ // sideOffset={sideOffset}
134
+ className: cn("min-w-69 z-50 mt-0.5 rounded-xl border bg-popover text-popover-foreground shadow-md outline-none 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", className), style: { width: contentWidth } }, props, { children: _jsx(CommandPrimitive, Object.assign({ ref: ref, className: cn("flex h-full w-full flex-col overflow-hidden rounded-xl bg-popover text-popover-foreground", className), shouldFilter: false }, props)) })));
135
+ });
136
+ MVPSelectContent.displayName = CommandPrimitive.displayName;
137
+ const MVPSelectLoading = React.forwardRef((_a, ref) => {
138
+ var props = __rest(_a, []);
139
+ return _jsx(CommandPrimitive.Loading, Object.assign({ ref: ref }, props));
140
+ });
141
+ MVPSelectLoading.displayName = CommandPrimitive.Loading.displayName;
142
+ const CommandGroup = React.forwardRef((_a, ref) => {
143
+ var { className } = _a, props = __rest(_a, ["className"]);
144
+ return (_jsx(CommandPrimitive.Group, Object.assign({ ref: ref, className: cn("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground", className) }, props)));
145
+ });
146
+ CommandGroup.displayName = CommandPrimitive.Group.displayName;
147
+ const MVPSelectInput = React.forwardRef((_a, ref) => {
148
+ var { className, onValueChange } = _a, props = __rest(_a, ["className", "onValueChange"]);
149
+ const { setSearchValue, open } = React.useContext(dropDownContext);
150
+ React.useEffect(() => {
151
+ if (open == false) {
152
+ onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange("");
153
+ setSearchValue("");
154
+ }
155
+ }, [open]);
156
+ const { t } = useTranslation("bx_v1");
157
+ return (_jsxs("div", Object.assign({ className: "flex h-[44px] items-center rounded-[12px] border-b border-gray-200 px-3" }, { children: [_jsx(Input, Object.assign({ ref: ref, className: cn("flex !h-11 w-full rounded-md border-none bg-transparent px-2 py-3 text-sm font-medium text-[#999999] !outline-none placeholder:font-[400] placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50", className), onChange: (value) => {
158
+ setSearchValue(value.target.value);
159
+ onValueChange && onValueChange(value.target.value);
160
+ } }, props, { placeholder: (props === null || props === void 0 ? void 0 : props.placeholder) ? props === null || props === void 0 ? void 0 : props.placeholder : t("bx_v1:cm_search") })), _jsx(Search, { className: "borde-[2px] mr-2 h-4 w-4 shrink-0 text-primary" })] })));
161
+ });
162
+ MVPSelectInput.displayName = CommandPrimitive.Input.displayName;
163
+ const MVPSelectItems = React.forwardRef((_a, ref) => {
164
+ var { className, onBottomReached, minLenToSearch = 1 } = _a, props = __rest(_a, ["className", "onBottomReached", "minLenToSearch"]);
165
+ const listRef = React.useRef(null);
166
+ const { isLoading, isFiltering, searchValue, secured } = React.useContext(dropDownContext);
167
+ const [isLoadingMore, setIsLoadingMore] = React.useState(false);
168
+ const handleScroll = React.useCallback(() => {
169
+ const listElement = listRef.current;
170
+ if (listElement) {
171
+ const { scrollTop, scrollHeight, clientHeight } = listElement;
172
+ const tolerance = 2;
173
+ const isAtBottom = scrollHeight - (scrollTop + clientHeight) <= tolerance;
174
+ if (isAtBottom) {
175
+ setIsLoadingMore(true);
176
+ onBottomReached && onBottomReached();
177
+ }
178
+ }
179
+ }, [onBottomReached]);
180
+ React.useEffect(() => {
181
+ if (isFiltering === false && isLoadingMore) {
182
+ setIsLoadingMore(false);
183
+ }
184
+ }, [isFiltering]);
185
+ React.useEffect(() => {
186
+ const listElement = listRef.current;
187
+ if (listElement) {
188
+ listElement.addEventListener("scroll", handleScroll);
189
+ }
190
+ return () => {
191
+ if (listElement) {
192
+ listElement.removeEventListener("scroll", handleScroll);
193
+ }
194
+ };
195
+ }, [handleScroll]);
196
+ return (_jsx(CommandPrimitive.List, Object.assign({ ref: (el) => {
197
+ listRef.current = el;
198
+ if (typeof ref === "function") {
199
+ ref(el);
200
+ }
201
+ else if (ref) {
202
+ ref.current = el;
203
+ }
204
+ }, className: cn("max-h-[224px] overflow-y-auto overflow-x-hidden", className) }, props, { children: !(secured && (searchValue === null || searchValue === void 0 ? void 0 : searchValue.length) < minLenToSearch) && (
205
+ /**
206
+ * Ticket #4235: We are using this condition for user security purposes.
207
+ *
208
+ * When the dropdown is in a secured state (secured is true) and the
209
+ * search term is empty (searchValue is ""):
210
+ * - We do not display any items to the user.
211
+ *
212
+ * This prevents exposing all available options without any filtering,
213
+ * ensuring that only relevant items are shown based on the user's input.
214
+ */
215
+ _jsx(_Fragment, { children: isLoading || (isFiltering && isLoadingMore === false) ? (_jsx("div", Object.assign({ className: "my-[10px] flex max-h-48 items-center justify-center" }, { children: _jsx("div", Object.assign({ className: "loader-small" }, { children: _jsx("div", { className: "loader" }) })) }))) : (_jsxs(_Fragment, { children: [_jsx(MVPSelectEmpty, {}), props.children] })) })) })));
216
+ });
217
+ MVPSelectItems.displayName = CommandPrimitive.List.displayName;
218
+ const MVPSelectEmpty = React.forwardRef((props, ref) => {
219
+ const { searchValue } = React.useContext(dropDownContext);
220
+ const { t } = useTranslation("bx_v1");
221
+ return (_jsx(CommandEmpty, Object.assign({ ref: ref, className: "py-6 text-center text-sm font-medium" }, { children: searchValue
222
+ ? t("bx_v1:cm_no_search_results_found")
223
+ : t("bx_v1:cm_no_data") })));
224
+ });
225
+ //Command Empty will not render initially, so we have return a custom function to render initially
226
+ const CommandEmpty = React.forwardRef((_a, forwardedRef) => {
227
+ var { className } = _a, props = __rest(_a, ["className"]);
228
+ const render = useCommandState((state) => state.filtered.count === 0);
229
+ if (!render)
230
+ return null;
231
+ return (_jsx("div", Object.assign({ ref: forwardedRef, className: cn("py-6 text-center text-sm", className), "cmdk-empty": "", role: "presentation" }, props)));
232
+ });
233
+ MVPSelectEmpty.displayName = CommandPrimitive.Empty.displayName;
234
+ const MVPSelectSeparator = React.forwardRef((_a, ref) => {
235
+ var { className } = _a, props = __rest(_a, ["className"]);
236
+ return (_jsx(CommandPrimitive.Separator, Object.assign({ ref: ref, className: cn("mx-[5px] h-[0.8px] bg-border", className) }, props)));
237
+ });
238
+ MVPSelectSeparator.displayName = CommandPrimitive.Separator.displayName;
239
+ const MVPSelectItem = React.forwardRef((_a, ref) => {
240
+ var { className, value, label, children } = _a, props = __rest(_a, ["className", "value", "label", "children"]);
241
+ const { onChange, setSelectedLabel } = React.useContext(dropDownContext);
242
+ const handleSelect = (val) => {
243
+ let selectedValue = val;
244
+ try {
245
+ selectedValue = JSON.parse(selectedValue);
246
+ }
247
+ catch (error) { }
248
+ setSelectedLabel(label);
249
+ onChange && onChange(selectedValue);
250
+ };
251
+ const { showSeparator } = React.useContext(dropDownContext);
252
+ return (_jsxs(_Fragment, { children: [_jsx(CommandPrimitive.Item, Object.assign({ ref: ref, className: cn("relative flex min-h-[44px] cursor-default select-none items-center px-5 py-1.5 text-sm font-semibold text-[#414141] outline-none hover:bg-[#7677F4]/10 aria-selected:text-accent-foreground data-[disabled]:pointer-events-none data-[selected=true]:bg-accent data-[disabled]:opacity-50", className) }, props, { value: typeof value === "string" ? value : JSON.stringify(value), onSelect: handleSelect }, { children: _jsx("div", Object.assign({ className: "line-clamp-2" }, { children: children })) })), showSeparator && _jsx(MVPSelectSeparator, { alwaysRender: true })] }));
253
+ });
254
+ MVPSelectItem.displayName = CommandPrimitive.Item.displayName;
255
+ const CommandShortcut = (_a) => {
256
+ var { className } = _a, props = __rest(_a, ["className"]);
257
+ return (_jsx("span", Object.assign({ className: cn("ml-auto text-xs tracking-widest text-muted-foreground", className) }, props)));
258
+ };
259
+ CommandShortcut.displayName = "CommandShortcut";
260
+ export { CommandShortcut, MVPSelect, MVPSelectContent, MVPSelectEmpty, MVPSelectInput, MVPSelectItem, MVPSelectItems, MVPSelectLoading, MVPSelectSeparator, MVPSelectTrigger, };