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.
- package/components.json +17 -0
- package/dist/assets/Arrow.d.ts +7 -0
- package/dist/assets/Arrow.js +5 -0
- package/dist/assets/CalenderIcon.d.ts +2 -0
- package/dist/assets/CalenderIcon.js +5 -0
- package/dist/assets/ClearAll.d.ts +2 -0
- package/dist/assets/ClearAll.js +5 -0
- package/dist/assets/CrossIcon.d.ts +8 -0
- package/dist/assets/CrossIcon.js +7 -0
- package/dist/assets/DropDown.d.ts +4 -0
- package/dist/assets/DropDown.js +5 -0
- package/dist/global.css +3213 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.js +25 -0
- package/dist/lib/CommonComponentsUtil.d.ts +7 -0
- package/dist/lib/CommonComponentsUtil.js +22 -0
- package/dist/lib/utils.d.ts +2 -0
- package/dist/lib/utils.js +5 -0
- package/dist/ui/BaseTable.d.ts +132 -0
- package/dist/ui/BaseTable.js +330 -0
- package/dist/ui/DateCalendar.d.ts +10 -0
- package/dist/ui/DateCalendar.js +47 -0
- package/dist/ui/DateField.d.ts +35 -0
- package/dist/ui/DateField.js +37 -0
- package/dist/ui/DateOfBirthSelector.d.ts +16 -0
- package/dist/ui/DateOfBirthSelector.js +42 -0
- package/dist/ui/DateRangePicker.d.ts +8 -0
- package/dist/ui/DateRangePicker.js +73 -0
- package/dist/ui/DobCalendar.d.ts +17 -0
- package/dist/ui/DobCalendar.js +86 -0
- package/dist/ui/Formfield.d.ts +12 -0
- package/dist/ui/Formfield.js +36 -0
- package/dist/ui/GetScrollAlert.d.ts +9 -0
- package/dist/ui/GetScrollAlert.js +37 -0
- package/dist/ui/RadioGroupContext/RadioGroupContext.d.ts +8 -0
- package/dist/ui/RadioGroupContext/RadioGroupContext.js +11 -0
- package/dist/ui/SelectCommand.d.ts +69 -0
- package/dist/ui/SelectCommand.js +260 -0
- package/dist/ui/SlashIcon.d.ts +2 -0
- package/dist/ui/SlashIcon.js +5 -0
- package/dist/ui/SortingArrows.d.ts +11 -0
- package/dist/ui/SortingArrows.js +11 -0
- package/dist/ui/TextTags.d.ts +39 -0
- package/dist/ui/TextTags.js +73 -0
- package/dist/ui/accordion.d.ts +10 -0
- package/dist/ui/accordion.js +77 -0
- package/dist/ui/alert-dialog.d.ts +20 -0
- package/dist/ui/alert-dialog.js +62 -0
- package/dist/ui/alert.d.ts +8 -0
- package/dist/ui/alert.js +42 -0
- package/dist/ui/avatar.d.ts +6 -0
- package/dist/ui/avatar.js +32 -0
- package/dist/ui/badge.d.ts +10 -0
- package/dist/ui/badge.js +58 -0
- package/dist/ui/button.d.ts +12 -0
- package/dist/ui/button.js +54 -0
- package/dist/ui/calendar.d.ts +8 -0
- package/dist/ui/calendar.js +45 -0
- package/dist/ui/card.d.ts +8 -0
- package/dist/ui/card.js +45 -0
- package/dist/ui/checkbox.d.ts +12 -0
- package/dist/ui/checkbox.js +44 -0
- package/dist/ui/command.d.ts +47 -0
- package/dist/ui/command.js +67 -0
- package/dist/ui/dialog.d.ts +31 -0
- package/dist/ui/dialog.js +57 -0
- package/dist/ui/dropdown-menu.d.ts +27 -0
- package/dist/ui/dropdown-menu.js +72 -0
- package/dist/ui/form.d.ts +23 -0
- package/dist/ui/form.js +72 -0
- package/dist/ui/hover-card.d.ts +7 -0
- package/dist/ui/hover-card.js +29 -0
- package/dist/ui/input.d.ts +3 -0
- package/dist/ui/input.js +20 -0
- package/dist/ui/label.d.ts +5 -0
- package/dist/ui/label.js +24 -0
- package/dist/ui/multi-select.d.ts +44 -0
- package/dist/ui/multi-select.js +191 -0
- package/dist/ui/navigation-menu.d.ts +11 -0
- package/dist/ui/navigation-menu.js +69 -0
- package/dist/ui/popover.d.ts +6 -0
- package/dist/ui/popover.js +24 -0
- package/dist/ui/radio-group.d.ts +7 -0
- package/dist/ui/radio-group.js +40 -0
- package/dist/ui/radioButtonCard.d.ts +9 -0
- package/dist/ui/radioButtonCard.js +23 -0
- package/dist/ui/scroll-area.d.ts +5 -0
- package/dist/ui/scroll-area.js +29 -0
- package/dist/ui/select.d.ts +57 -0
- package/dist/ui/select.js +148 -0
- package/dist/ui/separator.d.ts +4 -0
- package/dist/ui/separator.js +22 -0
- package/dist/ui/sheet.d.ts +25 -0
- package/dist/ui/sheet.js +65 -0
- package/dist/ui/switch.d.ts +10 -0
- package/dist/ui/switch.js +47 -0
- package/dist/ui/table.d.ts +10 -0
- package/dist/ui/table.js +55 -0
- package/dist/ui/tabs.d.ts +7 -0
- package/dist/ui/tabs.js +33 -0
- package/dist/ui/text.d.ts +11 -0
- package/dist/ui/text.js +45 -0
- package/dist/ui/textarea.d.ts +7 -0
- package/dist/ui/textarea.js +21 -0
- package/dist/ui/tooltip.d.ts +11 -0
- package/dist/ui/tooltip.js +26 -0
- package/package.json +123 -0
- package/postcss.config.js +6 -0
- package/src/assets/Arrow.js +5 -0
- package/src/assets/Arrow.tsx +25 -0
- package/src/assets/CalenderIcon.js +5 -0
- package/src/assets/CalenderIcon.tsx +28 -0
- package/src/assets/ClearAll.js +5 -0
- package/src/assets/ClearAll.tsx +20 -0
- package/src/assets/CrossIcon.js +7 -0
- package/src/assets/CrossIcon.tsx +34 -0
- package/src/assets/DropDown.js +5 -0
- package/src/assets/DropDown.tsx +23 -0
- package/src/global.css +560 -0
- package/src/index.ts +34 -0
- package/src/lib/CommonComponentsUtil.js +22 -0
- package/src/lib/CommonComponentsUtil.ts +30 -0
- package/src/lib/utils.js +5 -0
- package/src/lib/utils.ts +6 -0
- package/src/ui/BaseTable.js +330 -0
- package/src/ui/BaseTable.tsx +987 -0
- package/src/ui/DateCalendar.js +47 -0
- package/src/ui/DateCalendar.tsx +111 -0
- package/src/ui/DateField.js +37 -0
- package/src/ui/DateField.tsx +142 -0
- package/src/ui/DateOfBirthSelector.js +42 -0
- package/src/ui/DateOfBirthSelector.tsx +114 -0
- package/src/ui/DateRangePicker.js +73 -0
- package/src/ui/DateRangePicker.tsx +174 -0
- package/src/ui/DobCalendar.js +86 -0
- package/src/ui/DobCalendar.tsx +172 -0
- package/src/ui/Formfield.js +36 -0
- package/src/ui/Formfield.tsx +55 -0
- package/src/ui/GetScrollAlert.js +37 -0
- package/src/ui/GetScrollAlert.tsx +59 -0
- package/src/ui/RadioGroupContext/RadioGroupContext.js +11 -0
- package/src/ui/RadioGroupContext/RadioGroupContext.tsx +21 -0
- package/src/ui/SelectCommand.js +260 -0
- package/src/ui/SelectCommand.tsx +587 -0
- package/src/ui/SlashIcon.js +5 -0
- package/src/ui/SlashIcon.tsx +22 -0
- package/src/ui/SortingArrows.js +11 -0
- package/src/ui/SortingArrows.tsx +29 -0
- package/src/ui/TextTags.js +73 -0
- package/src/ui/TextTags.tsx +149 -0
- package/src/ui/accordion.js +77 -0
- package/src/ui/accordion.tsx +129 -0
- package/src/ui/alert-dialog.js +62 -0
- package/src/ui/alert-dialog.tsx +141 -0
- package/src/ui/alert.js +42 -0
- package/src/ui/alert.tsx +59 -0
- package/src/ui/avatar.js +32 -0
- package/src/ui/avatar.tsx +50 -0
- package/src/ui/badge.js +58 -0
- package/src/ui/badge.tsx +66 -0
- package/src/ui/button.js +54 -0
- package/src/ui/button.tsx +89 -0
- package/src/ui/calendar.js +45 -0
- package/src/ui/calendar.tsx +88 -0
- package/src/ui/card.js +45 -0
- package/src/ui/card.tsx +83 -0
- package/src/ui/checkbox.js +44 -0
- package/src/ui/checkbox.tsx +56 -0
- package/src/ui/command.js +67 -0
- package/src/ui/command.tsx +166 -0
- package/src/ui/dialog.js +57 -0
- package/src/ui/dialog.tsx +154 -0
- package/src/ui/dropdown-menu.js +72 -0
- package/src/ui/dropdown-menu.tsx +200 -0
- package/src/ui/form.js +72 -0
- package/src/ui/form.tsx +177 -0
- package/src/ui/hover-card.js +29 -0
- package/src/ui/hover-card.tsx +63 -0
- package/src/ui/input.js +20 -0
- package/src/ui/input.tsx +22 -0
- package/src/ui/label.js +24 -0
- package/src/ui/label.tsx +26 -0
- package/src/ui/multi-select.js +191 -0
- package/src/ui/multi-select.tsx +518 -0
- package/src/ui/navigation-menu.js +69 -0
- package/src/ui/navigation-menu.tsx +139 -0
- package/src/ui/popover.js +24 -0
- package/src/ui/popover.tsx +31 -0
- package/src/ui/radio-group.js +40 -0
- package/src/ui/radio-group.tsx +97 -0
- package/src/ui/radioButtonCard.js +23 -0
- package/src/ui/radioButtonCard.tsx +57 -0
- package/src/ui/scroll-area.js +29 -0
- package/src/ui/scroll-area.tsx +48 -0
- package/src/ui/select.js +148 -0
- package/src/ui/select.tsx +343 -0
- package/src/ui/separator.js +22 -0
- package/src/ui/separator.tsx +31 -0
- package/src/ui/sheet.js +65 -0
- package/src/ui/sheet.tsx +136 -0
- package/src/ui/switch.js +47 -0
- package/src/ui/switch.tsx +60 -0
- package/src/ui/table.js +55 -0
- package/src/ui/table.tsx +112 -0
- package/src/ui/tabs.js +33 -0
- package/src/ui/tabs.tsx +55 -0
- package/src/ui/text.js +45 -0
- package/src/ui/text.tsx +49 -0
- package/src/ui/textarea.js +21 -0
- package/src/ui/textarea.tsx +28 -0
- package/src/ui/tooltip.js +26 -0
- package/src/ui/tooltip.tsx +54 -0
- package/tailwind.config.js +214 -0
- package/tsconfig.json +35 -0
- package/tsconfig.tsbuildinfo +1 -0
package/src/ui/label.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
+
import * as React from "react";
|
|
15
|
+
import * as LabelPrimitive from "@radix-ui/react-label";
|
|
16
|
+
import { cva } from "class-variance-authority";
|
|
17
|
+
import { cn } from "../lib/utils";
|
|
18
|
+
const labelVariants = cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70");
|
|
19
|
+
const Label = React.forwardRef((_a, ref) => {
|
|
20
|
+
var { className } = _a, props = __rest(_a, ["className"]);
|
|
21
|
+
return (_jsx(LabelPrimitive.Root, Object.assign({ ref: ref, className: cn(labelVariants(), className) }, props)));
|
|
22
|
+
});
|
|
23
|
+
Label.displayName = LabelPrimitive.Root.displayName;
|
|
24
|
+
export { Label };
|
package/src/ui/label.tsx
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import * as LabelPrimitive from "@radix-ui/react-label";
|
|
5
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
6
|
+
|
|
7
|
+
import { cn } from "../lib/utils";
|
|
8
|
+
|
|
9
|
+
const labelVariants = cva(
|
|
10
|
+
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
const Label = React.forwardRef<
|
|
14
|
+
React.ElementRef<typeof LabelPrimitive.Root>,
|
|
15
|
+
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> &
|
|
16
|
+
VariantProps<typeof labelVariants>
|
|
17
|
+
>(({ className, ...props }, ref) => (
|
|
18
|
+
<LabelPrimitive.Root
|
|
19
|
+
ref={ref}
|
|
20
|
+
className={cn(labelVariants(), className)}
|
|
21
|
+
{...props}
|
|
22
|
+
/>
|
|
23
|
+
));
|
|
24
|
+
Label.displayName = LabelPrimitive.Root.displayName;
|
|
25
|
+
|
|
26
|
+
export { Label };
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import GetScrollTypesAlert from "../ui/GetScrollAlert";
|
|
4
|
+
import { uniqBy } from "lodash";
|
|
5
|
+
import { X } from "lucide-react";
|
|
6
|
+
import { useTranslation } from "next-i18next";
|
|
7
|
+
import * as React from "react";
|
|
8
|
+
import { useEffect, useState } from "react";
|
|
9
|
+
import { Badge } from "./badge";
|
|
10
|
+
import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, } from "./command";
|
|
11
|
+
import { cn } from "../lib/utils";
|
|
12
|
+
import { ccn } from "../lib/CommonComponentsUtil";
|
|
13
|
+
import DropDownArrow from "../../public/assets/DropDown";
|
|
14
|
+
// Main MultiSelect component
|
|
15
|
+
export function MultiSelect({ placeholder = "Select an item", data = [], onBottomReached, onSearch, onChange, value: propValue = [], getOptionProps, error, selectBoxStyles, searchBar = true, variant = "standard", isInitialLoading = false, isFiltering = false, disabled = false, secured = false, name = "", minLenToSearch = 1, searchPlaceholder, }) {
|
|
16
|
+
/**
|
|
17
|
+
* with cmdk package it's not possible pass value as object or array of object expect number | string
|
|
18
|
+
* So to override this we are going to stringify options whatever we are passing with the below conditions
|
|
19
|
+
*/
|
|
20
|
+
let modifiedData = data === null || data === void 0 ? void 0 : data.map((obj) => {
|
|
21
|
+
return {
|
|
22
|
+
label: obj.label,
|
|
23
|
+
value: typeof obj.value === "string" ? obj.value : JSON.stringify(obj.value),
|
|
24
|
+
};
|
|
25
|
+
});
|
|
26
|
+
const filteredData = uniqBy(modifiedData, "value");
|
|
27
|
+
// Refs to manage focus and detect clicks outside the component
|
|
28
|
+
const dropdownRef = React.useRef([]);
|
|
29
|
+
const popoverDropdownRef = React.useRef([]);
|
|
30
|
+
/**
|
|
31
|
+
* Allows to manage multiple references using a single ref handler.
|
|
32
|
+
* Here the add ref and popover ref are array of references
|
|
33
|
+
* Since each ref is a array, they can manage multiple references
|
|
34
|
+
* This function checks if the ref is not null and is not already included in the array before adding it.
|
|
35
|
+
* If the ref is not included, then it will be pushed into array
|
|
36
|
+
*/
|
|
37
|
+
const addRef = (ref) => {
|
|
38
|
+
if (ref && !dropdownRef.current.includes(ref)) {
|
|
39
|
+
dropdownRef.current.push(ref);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
const popoverRef = (ref) => {
|
|
43
|
+
if (ref && !popoverDropdownRef.current.includes(ref)) {
|
|
44
|
+
popoverDropdownRef.current.push(ref);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
// States to manage the component's behavior
|
|
48
|
+
const [open, setOpen] = React.useState(false);
|
|
49
|
+
const [popoverOpen, setPopoverOpen] = React.useState(false);
|
|
50
|
+
/**
|
|
51
|
+
* selected variable contains the selected values from multi select
|
|
52
|
+
* it holds array of value howevr user is passing from outside
|
|
53
|
+
* if user sends array or object it holds the same type
|
|
54
|
+
*/
|
|
55
|
+
const [selected, setSelected] = React.useState(propValue);
|
|
56
|
+
const [searchValue, setSearchValue] = React.useState("");
|
|
57
|
+
const headerStyles = (selectBoxStyles === null || selectBoxStyles === void 0 ? void 0 : selectBoxStyles.header) || "";
|
|
58
|
+
const dropdownStyles = (selectBoxStyles === null || selectBoxStyles === void 0 ? void 0 : selectBoxStyles.dropdown) || "";
|
|
59
|
+
// Requirement: Whenever the modal is closed, we need to clear the search value
|
|
60
|
+
// for this we can use useEffect
|
|
61
|
+
// and we are taking internal state variable to control the search bar
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
if (open === false) {
|
|
64
|
+
onSearch("");
|
|
65
|
+
setSearchValue("");
|
|
66
|
+
}
|
|
67
|
+
}, [open]);
|
|
68
|
+
const [isLoadingMore, setIsLoadingMore] = useState(false);
|
|
69
|
+
// Handling the is Loading More state variable to loading when ever we reach the bottom, Until data is fetched
|
|
70
|
+
useEffect(() => {
|
|
71
|
+
if (isFiltering === false && isLoadingMore) {
|
|
72
|
+
setIsLoadingMore(false);
|
|
73
|
+
}
|
|
74
|
+
}, [isFiltering]);
|
|
75
|
+
// Handle unselecting an item from the selected list
|
|
76
|
+
const handleUnselect = (item) => {
|
|
77
|
+
setSelected((prev) => prev.filter((s) => s !== item));
|
|
78
|
+
onChange(selected === null || selected === void 0 ? void 0 : selected.filter((s) => s !== item));
|
|
79
|
+
};
|
|
80
|
+
const handleOnSelect = (option) => {
|
|
81
|
+
onChange([...selected, option]);
|
|
82
|
+
setSelected((prev) => [...prev, option]);
|
|
83
|
+
};
|
|
84
|
+
//When prop values changes from external functions, we have to keep the selected state and prop value in sync.
|
|
85
|
+
//How use effect will work was when dependency was changed, it will run
|
|
86
|
+
//here we are doing stringify of propvalue becuase of below reasons
|
|
87
|
+
// reason 1: initially propValue is an empty array []==[] is false it will think like false so it willrun again and again.
|
|
88
|
+
// solution 1: keeping JSON.stringify(propValue) it means "[]"=="[]" is true it will not run again.
|
|
89
|
+
// solution 2: //TODO: In FUTURE we will do complete controlled component without any useEffects
|
|
90
|
+
useEffect(() => {
|
|
91
|
+
setSelected(propValue);
|
|
92
|
+
}, [JSON.stringify(propValue)]);
|
|
93
|
+
// Handle clicks outside the dropdown to close it
|
|
94
|
+
useEffect(() => {
|
|
95
|
+
const handleClickOutside = (event) => {
|
|
96
|
+
if (dropdownRef.current &&
|
|
97
|
+
!dropdownRef.current.some((ref) => ref && ref.contains(event.target)) &&
|
|
98
|
+
popoverDropdownRef.current &&
|
|
99
|
+
!popoverDropdownRef.current.some((ref) => ref && ref.contains(event.target))) {
|
|
100
|
+
setOpen(false);
|
|
101
|
+
setPopoverOpen(false); // Close the popover as well
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
105
|
+
return () => {
|
|
106
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
|
107
|
+
};
|
|
108
|
+
}, [open, popoverOpen]);
|
|
109
|
+
const findObjectById = (id) => {
|
|
110
|
+
// Find the object with the given id
|
|
111
|
+
return filteredData.find((obj) => obj.value == (typeof id === "string" ? id : JSON.stringify(id)));
|
|
112
|
+
};
|
|
113
|
+
// Filter out selected values from the dropdown
|
|
114
|
+
const selectables = filteredData.filter((obj) => !selected.find((selectedObj) => {
|
|
115
|
+
selectedObj =
|
|
116
|
+
typeof selectedObj === "string"
|
|
117
|
+
? selectedObj
|
|
118
|
+
: JSON.stringify(selectedObj);
|
|
119
|
+
return obj.value === selectedObj;
|
|
120
|
+
}));
|
|
121
|
+
const { t } = useTranslation(["common", "bx_v1"]);
|
|
122
|
+
return (_jsx("div", Object.assign({ className: "grid w-full items-center font-medium" }, { children: _jsxs(Command, Object.assign({ className: "overflow-visible bg-transparent" }, { children: [_jsxs("div", Object.assign({ className: cn(`relative flex h-[40px] items-center justify-between px-4 py-[10px] ${headerStyles}`, variant === "basic" && "cursor-pointer", disabled && "!cursor-not-allowed bg-grey2-light placeholder-grey2", ccn(error, propValue)),
|
|
123
|
+
// The dropdown should be clickable in the entire field space in the basic variant
|
|
124
|
+
onClick: () => {
|
|
125
|
+
if (variant === "basic" && !disabled) {
|
|
126
|
+
setOpen(!open);
|
|
127
|
+
setPopoverOpen(false);
|
|
128
|
+
}
|
|
129
|
+
}, ref: addRef, id: `${name}-multi-select` }, { children: [(selected === null || selected === void 0 ? void 0 : selected.length) == 0 ? (_jsx("div", { children: (selected === null || selected === void 0 ? void 0 : selected.length) <= 0 && (_jsx("div", Object.assign({ className: "font-normal text-[#999999]" }, { children: placeholder }))) })) : (
|
|
130
|
+
//Display selected items and provide options to remove them
|
|
131
|
+
_jsxs("div", Object.assign({ className: "flex items-center gap-2" }, { children: [selected === null || selected === void 0 ? void 0 : selected.map((item, index) => {
|
|
132
|
+
var _a, _b;
|
|
133
|
+
// Extracting option properties, including 'noIcon' to determine if a cross icon should be displayed
|
|
134
|
+
const optionProps = getOptionProps
|
|
135
|
+
? getOptionProps(item)
|
|
136
|
+
: {
|
|
137
|
+
noIcon: false,
|
|
138
|
+
};
|
|
139
|
+
const { disable: noIcon } = optionProps;
|
|
140
|
+
if (index > 1)
|
|
141
|
+
return null;
|
|
142
|
+
return (_jsxs(Badge, Object.assign({ variant: "outline", className: "flex h-6 w-[92px] items-center border border-[#D6D7D8]",
|
|
143
|
+
// When the user clicks on the selected chips, stop the click event from propagating to parent elements.
|
|
144
|
+
// This prevents the dropdown from toggling open/closed when clicking on a chip.
|
|
145
|
+
onClick: (e) => {
|
|
146
|
+
e.stopPropagation();
|
|
147
|
+
} }, { children: [_jsx("div", Object.assign({ className: "max-w-[63px] truncate" }, { children: _jsx("abbr", Object.assign({ className: "text-3 font-bold leading-4 text-[#333333] no-underline", title: (_a = findObjectById(item)) === null || _a === void 0 ? void 0 : _a.label }, { children: (_b = findObjectById(item)) === null || _b === void 0 ? void 0 : _b.label })) })), _jsx("button", Object.assign({ type: "button", className: cn("ml-1 flex items-center rounded-full outline-none", disabled && "cursor-not-allowed"), onClick: () => handleUnselect(item), disabled: disabled }, { children: !noIcon && (_jsx(X, { onClick: () => handleUnselect(item), className: "h-[14px] w-[14px]", stroke: "#7677F4", strokeWidth: 2.5 })) }))] }), item));
|
|
148
|
+
}), (selected === null || selected === void 0 ? void 0 : selected.length) > 2 && (_jsx("div", Object.assign({ className: `flex h-6 w-[29px] cursor-pointer items-center justify-center rounded-full bg-[#7677F4]/20 px-2 ${disabled ? "disabled" : ""}`, ref: popoverRef, onClick: (e) => {
|
|
149
|
+
setPopoverOpen(!popoverOpen);
|
|
150
|
+
setOpen(false);
|
|
151
|
+
e.stopPropagation();
|
|
152
|
+
} }, { children: _jsx("div", Object.assign({ className: "flex h-4 w-4 items-center justify-center text-[12px] font-bold text-[#7677F4]" }, { children: `+${(selected === null || selected === void 0 ? void 0 : selected.length) - 2}` })) })))] }))), _jsx("div", { children: variant === "basic" ? (_jsx("div", Object.assign({ className: "w-full", ref: addRef }, { children: _jsx("div", Object.assign({ className: "flex w-full flex-row justify-between" }, { children: _jsx("button", Object.assign({ type: "button", disabled: disabled, className: `h-5 h-fit w-5 w-fit focus:outline-keyboardTab ${disabled && "cursor-not-allowed"} ` }, { children: _jsx(DropDownArrow, {}) })) })) }))) : (_jsx("div", Object.assign({ ref: addRef }, { children: _jsxs("button", Object.assign({ type: "button", className: `ml-1 rounded-full text-[14px] font-medium leading-[18px] text-[#7677F4] ${disabled && "cursor-not-allowed"}`, onClick: () => {
|
|
153
|
+
setOpen(!open);
|
|
154
|
+
setPopoverOpen(false);
|
|
155
|
+
}, disabled: disabled }, { children: [_jsx("span", Object.assign({ className: "text-[16px] leading-none" }, { children: "+" })), " ", t("add_button")] })) }))) })] })), _jsx("div", Object.assign({ className: "relative mt-[2px]", ref: popoverRef }, { children: popoverOpen && (selected === null || selected === void 0 ? void 0 : selected.length) > 0 ? (_jsx("div", Object.assign({ className: `absolute z-50 w-full overflow-hidden rounded-xl border bg-popover text-popover-foreground shadow-md outline-none animate-in ${dropdownStyles}` }, { children: _jsx(CommandGroup, Object.assign({ className: "max-h-[224px] overflow-y-auto" }, { children: selected === null || selected === void 0 ? void 0 : selected.map((item, index) => {
|
|
156
|
+
var _a;
|
|
157
|
+
// Extracting option properties, including 'noIcon' to determine if a cross icon should be displayed
|
|
158
|
+
const optionProps = getOptionProps
|
|
159
|
+
? getOptionProps(item)
|
|
160
|
+
: {
|
|
161
|
+
noIcon: false,
|
|
162
|
+
};
|
|
163
|
+
const { disable: noIcon } = optionProps;
|
|
164
|
+
return (_jsxs("div", { children: [_jsxs("div", Object.assign({ className: "flex min-h-[44px] flex-row items-center justify-between gap-1 py-2 pl-2 pr-3" }, { children: [_jsx("div", Object.assign({ className: "line-clamp-2 text-[14px] text-[#333333]" }, { children: (_a = findObjectById(item)) === null || _a === void 0 ? void 0 : _a.label })), _jsx("div", { children: !noIcon && (_jsx(X, { onClick: () => handleUnselect(item), className: cn("h-[14px] w-[14px] cursor-pointer", disabled &&
|
|
165
|
+
"pointer-events-none cursor-not-allowed"), "aria-disabled": disabled, stroke: "#7677F4", strokeWidth: 2.5 })) })] })), index < (selected === null || selected === void 0 ? void 0 : selected.length) - 1 && (_jsx("hr", { className: "border-[#D6D7D8]" })), " "] }, item));
|
|
166
|
+
}) })) }))) : null })), _jsx("div", Object.assign({ className: "relative z-50 rounded-xl", ref: addRef }, { children: open && (_jsxs("div", Object.assign({ className: "absolute w-full overflow-hidden rounded-xl border bg-[#FFFFFF] text-popover-foreground shadow-md outline-none animate-in" }, { children: [(searchBar && data.length > 5) || searchValue || secured ? (_jsx("div", Object.assign({ className: "rounded-[12px] border-b border-gray-200" }, { children: _jsx(CommandInput, { onChange: (e) => {
|
|
167
|
+
onSearch(e.target.value);
|
|
168
|
+
setSearchValue(e.target.value);
|
|
169
|
+
}, autoFocus: true, className: "h-[44px] border-none text-[#999999] focus-visible:outline-none", placeholder: searchPlaceholder
|
|
170
|
+
? searchPlaceholder
|
|
171
|
+
: t("bx_v1:cm_search"), value: searchValue }) }))) : null, _jsx("div", { children: secured && (searchValue === null || searchValue === void 0 ? void 0 : searchValue.length) < minLenToSearch ? (_jsx("div", {})) : isInitialLoading ||
|
|
172
|
+
(isFiltering && isLoadingMore === false) ? (_jsx("div", Object.assign({ className: "flex h-16 items-center justify-center" }, { children: _jsx("div", Object.assign({ className: "loader-small" }, { children: _jsx("div", { className: "loader" }) })) }))) : (_jsx(_Fragment, { children: _jsxs(CommandList, Object.assign({ className: "max-h-[224px]" }, { children: [_jsx(CommandEmpty, { children: searchValue
|
|
173
|
+
? t("bx_v1:cm_no_search_results_found")
|
|
174
|
+
: t("bx_v1:cm_no_data") }), _jsx(GetScrollTypesAlert, Object.assign({ id: "multiselect", onBottom: () => {
|
|
175
|
+
onBottomReached();
|
|
176
|
+
setIsLoadingMore(true);
|
|
177
|
+
} }, { children: _jsx(CommandGroup, Object.assign({ id: "multiselect", className: "max-h-[224px] overflow-y-auto text-[#333333]", forceMount: true }, { children: selectables === null || selectables === void 0 ? void 0 : selectables.map((option, index) => {
|
|
178
|
+
return (_jsxs("div", { children: [_jsx(CommandItem, Object.assign({ onSelect: (value) => {
|
|
179
|
+
let selectedValue = option.value;
|
|
180
|
+
try {
|
|
181
|
+
selectedValue = JSON.parse(selectedValue);
|
|
182
|
+
}
|
|
183
|
+
catch (error) {
|
|
184
|
+
console.log("it is already string");
|
|
185
|
+
}
|
|
186
|
+
handleOnSelect(selectedValue);
|
|
187
|
+
}, value: typeof option.value === "string"
|
|
188
|
+
? option.value
|
|
189
|
+
: JSON.stringify(option.value), className: "px-5 hover:cursor-pointer" }, { children: _jsx("div", Object.assign({ className: "line-clamp-2" }, { children: option.label })) }), option.value), index < (selectables === null || selectables === void 0 ? void 0 : selectables.length) - 1 && (_jsx("hr", { className: "mx-[5px] bg-border" }))] }, index));
|
|
190
|
+
}) })) }))] })) })) })] }))) }))] })) })));
|
|
191
|
+
}
|