master-components-react-ts 2.0.1 → 2.1.2

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 (70) hide show
  1. package/dist/assets/Icons/IconErrorDash.d.ts +2 -3
  2. package/dist/assets/Inter_24pt-SemiBold-DIQUEucn.woff2 +0 -0
  3. package/dist/components/Dropdown/Dropdown.types.d.ts +2 -2
  4. package/dist/components/InlineLoading/InlineLoading.d.ts +3 -0
  5. package/dist/components/InlineLoading/InlineLoading.types.d.ts +24 -0
  6. package/dist/index.d.ts +1 -0
  7. package/dist/index.js +3983 -1080
  8. package/dist/types/css-modules.d.ts +9 -0
  9. package/package.json +62 -60
  10. package/dist/_virtual/_commonjsHelpers.js +0 -8
  11. package/dist/_virtual/customParseFormat.js +0 -4
  12. package/dist/_virtual/jsx-runtime.js +0 -4
  13. package/dist/_virtual/react-jsx-runtime.production.js +0 -4
  14. package/dist/assets/Icons/IconArrowUp.js +0 -13
  15. package/dist/assets/Icons/IconCalendar.js +0 -32
  16. package/dist/assets/Icons/IconCheck.js +0 -15
  17. package/dist/assets/Icons/IconCheckCircle.js +0 -16
  18. package/dist/assets/Icons/IconCheckmark.js +0 -15
  19. package/dist/assets/Icons/IconCircularLoading.js +0 -36
  20. package/dist/assets/Icons/IconClose.js +0 -31
  21. package/dist/assets/Icons/IconCloseBackground.js +0 -15
  22. package/dist/assets/Icons/IconCloseCircle.js +0 -15
  23. package/dist/assets/Icons/IconExclamation.js +0 -15
  24. package/dist/assets/Icons/IconLeft.js +0 -13
  25. package/dist/assets/Icons/IconMinus.js +0 -7
  26. package/dist/assets/Icons/IconRadioChecked.js +0 -19
  27. package/dist/assets/Icons/IconRadioCheckedDisabled.js +0 -19
  28. package/dist/assets/Icons/IconRadioUnchecked.js +0 -16
  29. package/dist/assets/Icons/IconRadioUncheckedDisabled.js +0 -16
  30. package/dist/assets/Icons/IconRight.js +0 -13
  31. package/dist/assets/Icons/IconSave.js +0 -16
  32. package/dist/assets/Icons/IconSearch.js +0 -26
  33. package/dist/assets/Icons/IconTrash.js +0 -16
  34. package/dist/components/ActionDropdown/ActionDropdown.js +0 -74
  35. package/dist/components/ActionDropdown/ActionDropdown.module.scss.js +0 -29
  36. package/dist/components/Checkbox/Checkbox.js +0 -54
  37. package/dist/components/Checkbox/Checkbox.module.scss.js +0 -26
  38. package/dist/components/DatePicker/Calendar.js +0 -437
  39. package/dist/components/DatePicker/Calendar.module.scss.js +0 -83
  40. package/dist/components/DatePicker/DatePicker.js +0 -211
  41. package/dist/components/DatePicker/Datepicker.module.scss.js +0 -17
  42. package/dist/components/Dropdown/Dropdown.js +0 -336
  43. package/dist/components/Dropdown/Dropdown.module.scss.js +0 -74
  44. package/dist/components/FormInput/FormInput.js +0 -144
  45. package/dist/components/FormInput/FormInput.module.scss.js +0 -62
  46. package/dist/components/MainButton/MainButton.js +0 -72
  47. package/dist/components/MainButton/MainButton.module.scss.js +0 -56
  48. package/dist/components/NotificationToast/NotificationContext.js +0 -57
  49. package/dist/components/NotificationToast/NotificationToast.js +0 -66
  50. package/dist/components/NotificationToast/NotificationToast.module.scss.js +0 -59
  51. package/dist/components/NotificationToast/createNotificationToast.js +0 -10
  52. package/dist/components/Popup/Popup.js +0 -116
  53. package/dist/components/Popup/Popup.module.scss.js +0 -41
  54. package/dist/components/Radio/Radio.js +0 -46
  55. package/dist/components/Radio/Radio.module.scss.js +0 -8
  56. package/dist/components/Skeleton/Skeleton.js +0 -8
  57. package/dist/components/Skeleton/Skeleton.module.scss.js +0 -20
  58. package/dist/components/Textarea/Textarea.js +0 -149
  59. package/dist/components/Textarea/Textarea.module.scss.js +0 -41
  60. package/dist/components/TimePicker/TimePicker.js +0 -172
  61. package/dist/components/TimePicker/TimePicker.module.scss.js +0 -50
  62. package/dist/components/Toggle/Toggle.js +0 -20
  63. package/dist/components/Toggle/Toggle.module.scss.js +0 -29
  64. package/dist/components/Tooltip/Tooltip.js +0 -153
  65. package/dist/components/Tooltip/Tooltip.module.scss.js +0 -35
  66. package/dist/context/NamespaceContext.js +0 -7
  67. package/dist/node_modules/dayjs/plugin/customParseFormat.js +0 -129
  68. package/dist/node_modules/react/cjs/react-jsx-runtime.production.js +0 -35
  69. package/dist/node_modules/react/jsx-runtime.js +0 -10
  70. package/dist/utils/Helpers.js +0 -15
@@ -1,83 +0,0 @@
1
- const datePicker = "Calendar-module__datePicker";
2
- const dualCalendar = "Calendar-module__dualCalendar";
3
- const dualCalendarWithQuick = "Calendar-module__dualCalendarWithQuick";
4
- const border = "Calendar-module__border";
5
- const calendarWrapper = "Calendar-module__calendarWrapper";
6
- const quickPick = "Calendar-module__quickPick";
7
- const datePickerHeader = "Calendar-module__datePickerHeader";
8
- const div = "Calendar-module__div";
9
- const currentDateHeader = "Calendar-module__currentDateHeader";
10
- const left = "Calendar-module__left";
11
- const right = "Calendar-module__right";
12
- const singleIcon = "Calendar-module__singleIcon";
13
- const doubleIcon = "Calendar-module__doubleIcon";
14
- const spacerRow = "Calendar-module__spacerRow";
15
- const day = "Calendar-module__day";
16
- const today = "Calendar-module__today";
17
- const inRange = "Calendar-module__inRange";
18
- const selected = "Calendar-module__selected";
19
- const startDate = "Calendar-module__startDate";
20
- const endDate = "Calendar-module__endDate";
21
- const disabled = "Calendar-module__disabled";
22
- const otherMonth = "Calendar-module__otherMonth";
23
- const monthsWrapper = "Calendar-module__monthsWrapper";
24
- const month = "Calendar-module__month";
25
- const pickedMonth = "Calendar-module__pickedMonth";
26
- const buttonWrapper = "Calendar-module__buttonWrapper";
27
- const style = {
28
- datePicker,
29
- dualCalendar,
30
- dualCalendarWithQuick,
31
- border,
32
- calendarWrapper,
33
- quickPick,
34
- datePickerHeader,
35
- div,
36
- currentDateHeader,
37
- left,
38
- right,
39
- singleIcon,
40
- doubleIcon,
41
- spacerRow,
42
- day,
43
- today,
44
- inRange,
45
- selected,
46
- startDate,
47
- endDate,
48
- disabled,
49
- otherMonth,
50
- monthsWrapper,
51
- month,
52
- pickedMonth,
53
- buttonWrapper
54
- };
55
- export {
56
- border,
57
- buttonWrapper,
58
- calendarWrapper,
59
- currentDateHeader,
60
- datePicker,
61
- datePickerHeader,
62
- day,
63
- style as default,
64
- disabled,
65
- div,
66
- doubleIcon,
67
- dualCalendar,
68
- dualCalendarWithQuick,
69
- endDate,
70
- inRange,
71
- left,
72
- month,
73
- monthsWrapper,
74
- otherMonth,
75
- pickedMonth,
76
- quickPick,
77
- right,
78
- selected,
79
- singleIcon,
80
- spacerRow,
81
- startDate,
82
- today
83
- };
@@ -1,211 +0,0 @@
1
- import { j as jsxRuntimeExports } from "../../node_modules/react/jsx-runtime.js";
2
- import { useState, useRef, useEffect } from "react";
3
- import dayjs from "dayjs";
4
- import style from "./Datepicker.module.scss.js";
5
- import Calendar from "./Calendar.js";
6
- import { IconCalendar } from "../../assets/Icons/IconCalendar.js";
7
- import customParseFormat from "../../node_modules/dayjs/plugin/customParseFormat.js";
8
- import { useNamespace } from "../../context/NamespaceContext.js";
9
- import FormInput from "../FormInput/FormInput.js";
10
- import { IconCloseCircle } from "../../assets/Icons/IconCloseCircle.js";
11
- dayjs.extend(customParseFormat);
12
- const DatePicker = ({
13
- defaultValue,
14
- valueFormat = "DD-MM-YYYY",
15
- onChange,
16
- onBlur,
17
- onFocus,
18
- customYears,
19
- fixedDropdown = true,
20
- disabledDatesFrom,
21
- disabledDatesTill,
22
- disabledDatesRange,
23
- datepickerStyle,
24
- datepickerLabelStyle,
25
- requiredStyle,
26
- datepickerHelperTextStyle,
27
- selectedStyle,
28
- endDateStyle,
29
- startDateStyle,
30
- inRangeStyle,
31
- otherMonthStyle,
32
- todayStyle,
33
- weekDayStyle,
34
- quickPickStyle,
35
- monthStyle,
36
- quickPick,
37
- mode = "single",
38
- pickerType = "single",
39
- disabled = false,
40
- ...rest
41
- }) => {
42
- const namespace = useNamespace();
43
- const [IsFocused, setIsFocused] = useState(false);
44
- const [Value, setValue] = useState("");
45
- const DefaultValue = useRef({ state: false, value: "" });
46
- const CalendarRef = useRef(null);
47
- const [CurrentMonth, setCurrentMonth] = useState(() => {
48
- const thisYear = dayjs().year().toString();
49
- if (customYears?.length) {
50
- return customYears.includes(thisYear) ? dayjs() : dayjs(`${Math.min(...customYears.map(Number))}-01-01`);
51
- }
52
- return dayjs();
53
- });
54
- useEffect(() => {
55
- const thisYear = dayjs().year().toString();
56
- if (customYears?.length) {
57
- setCurrentMonth(customYears.includes(thisYear) ? dayjs() : dayjs(`${Math.min(...customYears.map(Number))}-01-01`));
58
- }
59
- }, [customYears]);
60
- const [SelectedDate, setSelectedDate] = useState("");
61
- const [RangeSelection, setRangeSelection] = useState({
62
- start: null,
63
- end: null
64
- });
65
- const ComponentRef = useRef(null);
66
- const Change = (value, singleQuickPick, withDefault) => {
67
- let dateValue = "";
68
- let objValue = { start: "", end: "" };
69
- if (mode === "single" || typeof value === "string") {
70
- dateValue = value;
71
- setValue(dateValue);
72
- }
73
- if (mode !== "single" || typeof value !== "string") {
74
- dateValue = `${dayjs(value?.start ?? "").format(valueFormat)} / ${value?.end ? dayjs(value?.end).format(valueFormat) : ""}`;
75
- objValue.start = dayjs(value?.start ?? "").format(valueFormat);
76
- objValue.end = value?.end ? dayjs(value?.end).format(valueFormat) : "";
77
- setValue(dateValue);
78
- }
79
- if (value?.end) {
80
- setIsFocused(false);
81
- }
82
- if (onChange && typeof onChange === "function" && !withDefault) {
83
- onChange(objValue.start !== "" ? objValue : dateValue);
84
- DefaultValue.current.value = objValue.start !== "" ? objValue : dateValue;
85
- }
86
- };
87
- const Clear = (e) => {
88
- e.stopPropagation();
89
- setSelectedDate("");
90
- DefaultValue.current.value = "";
91
- setValue("");
92
- setRangeSelection({
93
- start: null,
94
- end: null
95
- });
96
- if (onChange && typeof onChange === "function") {
97
- onChange("");
98
- }
99
- };
100
- const ClickHandler = (event) => {
101
- if (!ComponentRef.current) return;
102
- if (event.composedPath().includes(ComponentRef.current)) return;
103
- setIsFocused(false);
104
- };
105
- const ScrollHandler = (event) => {
106
- if (!ComponentRef.current || !CalendarRef.current) return;
107
- if (event.composedPath().includes(ComponentRef.current) || event.composedPath().includes(CalendarRef.current)) return;
108
- setIsFocused(false);
109
- };
110
- const CalculatePos = () => {
111
- if (!ComponentRef.current || !CalendarRef.current) return;
112
- const componentEl = ComponentRef.current;
113
- const calendarEl = CalendarRef.current;
114
- if (!calendarEl || !componentEl) return;
115
- const componentRect = componentEl.getBoundingClientRect();
116
- const windowHeight = window.innerHeight;
117
- const windowWidth = window.innerWidth;
118
- calendarEl.style.position = "fixed";
119
- if (componentRect.bottom + calendarEl.offsetHeight > windowHeight) {
120
- calendarEl.style.top = `${window.scrollY + componentRect.top - calendarEl.offsetHeight - 8}px`;
121
- calendarEl.style.bottom = "unset";
122
- } else {
123
- calendarEl.style.top = `${window.scrollY + componentRect.bottom + 8}px`;
124
- calendarEl.style.bottom = "unset";
125
- }
126
- if (componentRect.right + componentRect.width > windowWidth - 120) {
127
- calendarEl.style.left = `${window.scrollX + componentRect.left + componentRect.width - calendarEl.offsetWidth}px`;
128
- } else {
129
- calendarEl.style.left = `${window.scrollX + componentRect.left}px`;
130
- }
131
- };
132
- useEffect(() => {
133
- if (defaultValue && DefaultValue.current.value === "") {
134
- let value = Array.isArray(defaultValue) ? {
135
- start: dayjs(defaultValue[0], valueFormat),
136
- end: defaultValue.length > 1 ? dayjs(defaultValue[1], valueFormat) : ""
137
- } : dayjs(defaultValue, valueFormat).format(valueFormat);
138
- DefaultValue.current.value = defaultValue;
139
- DefaultValue.current.state = true;
140
- if (value) {
141
- Change(value, false, true);
142
- }
143
- }
144
- }, []);
145
- useEffect(() => {
146
- if (IsFocused) {
147
- CalculatePos();
148
- }
149
- }, [CalendarRef, IsFocused]);
150
- useEffect(() => {
151
- document.addEventListener("click", ClickHandler);
152
- document.addEventListener("wheel", ScrollHandler);
153
- return () => {
154
- document.removeEventListener("click", ClickHandler);
155
- document.removeEventListener("wheel", ScrollHandler);
156
- };
157
- }, []);
158
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `${namespace === "namespaceHr" ? style.namespaceHr : ""} ${style.datepickerContainer}`, children: [
159
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { ref: ComponentRef, className: style.datepickerInputWrapper, onClick: () => (setIsFocused((state) => !state), CalculatePos()), children: /* @__PURE__ */ jsxRuntimeExports.jsx(
160
- FormInput,
161
- {
162
- ...rest,
163
- customFocus: IsFocused,
164
- withActive: false,
165
- value: Value,
166
- toggleFocus: true,
167
- formInputStyle: { cursor: "pointer" },
168
- leftSlot: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: style.datepickerLeftIcon, children: /* @__PURE__ */ jsxRuntimeExports.jsx(IconCalendar, {}) }),
169
- rightSlot: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `${style.datepickerRightIcon}`, onClick: Clear, children: Value && /* @__PURE__ */ jsxRuntimeExports.jsx(IconCloseCircle, {}) }),
170
- readOnly: true
171
- }
172
- ) }),
173
- IsFocused && /* @__PURE__ */ jsxRuntimeExports.jsx(
174
- Calendar,
175
- {
176
- namespace,
177
- defaultValue: DefaultValue.current,
178
- CalendarRef,
179
- disabledDatesFrom,
180
- disabledDatesTill,
181
- disabledDatesRange,
182
- valueFormat,
183
- onChange: (value) => Change(value, false, false),
184
- customYears,
185
- CurrentMonth,
186
- setCurrentMonth,
187
- SelectedDate,
188
- setSelectedDate,
189
- IsFocused,
190
- setIsFocused,
191
- quickPick,
192
- mode,
193
- RangeSelection,
194
- setRangeSelection,
195
- pickerType,
196
- selectedStyle,
197
- endDateStyle,
198
- startDateStyle,
199
- inRangeStyle,
200
- otherMonthStyle,
201
- todayStyle,
202
- weekDayStyle,
203
- quickPickStyle,
204
- monthStyle
205
- }
206
- )
207
- ] });
208
- };
209
- export {
210
- DatePicker as default
211
- };
@@ -1,17 +0,0 @@
1
- const datepickerContainer = "Datepicker-module__datepickerContainer";
2
- const datepickerInputWrapper = "Datepicker-module__datepickerInputWrapper";
3
- const datepickerLeftIcon = "Datepicker-module__datepickerLeftIcon";
4
- const datepickerRightIcon = "Datepicker-module__datepickerRightIcon";
5
- const style = {
6
- datepickerContainer,
7
- datepickerInputWrapper,
8
- datepickerLeftIcon,
9
- datepickerRightIcon
10
- };
11
- export {
12
- datepickerContainer,
13
- datepickerInputWrapper,
14
- datepickerLeftIcon,
15
- datepickerRightIcon,
16
- style as default
17
- };
@@ -1,336 +0,0 @@
1
- import { j as jsxRuntimeExports } from "../../node_modules/react/jsx-runtime.js";
2
- import { useState, useRef, useEffect } from "react";
3
- import style from "./Dropdown.module.scss.js";
4
- import FormInput from "../FormInput/FormInput.js";
5
- import Checkbox from "../Checkbox/Checkbox.js";
6
- import { _filterUnique } from "../../utils/Helpers.js";
7
- import { IconClose } from "../../assets/Icons/IconClose.js";
8
- import { IconArrowUp } from "../../assets/Icons/IconArrowUp.js";
9
- import { IconCloseCircle } from "../../assets/Icons/IconCloseCircle.js";
10
- const Dropdown = ({
11
- data,
12
- withFilter = true,
13
- withClose = true,
14
- disableAll = false,
15
- withMultiselect = false,
16
- selectedOptionID,
17
- withInput = false,
18
- dropdownType = "country",
19
- onSelect,
20
- onFocus,
21
- onBlur,
22
- onValueChange,
23
- customInputSlot,
24
- dropdownWrapperStyle,
25
- dropdownInputWrapperStyle,
26
- dropdownInputSlotStyle,
27
- dropdownInputSlotItemStyle,
28
- dropdownInputSlotItemLabelStyle,
29
- dropdownInputSlotItemCloseStyle,
30
- dropdownInputSlotItemMoreStyle,
31
- dropdownItemStyle,
32
- dropdownItemLabelStyle,
33
- itemCheckboxStyle,
34
- dropdownItemLabelTextStyle,
35
- dropdownListStyle,
36
- ...rest
37
- }) => {
38
- const [Flag, setFlag] = useState(false);
39
- const [InputValue, setInputValue] = useState("");
40
- const [SelectAllKey, setSelectAllKey] = useState(false);
41
- const [ClickedSelectAll, setClickedSelectAll] = useState(false);
42
- const [IsFocused, setIsFocused] = useState(false);
43
- const DropdownRef = useRef(null);
44
- const ComponentRef = useRef(null);
45
- const ListRef = useRef(null);
46
- const ListItemRef = useRef(null);
47
- const [Data, setData] = useState([]);
48
- const SelectedData = useRef([]);
49
- const SelectedDataLength = useRef(0);
50
- const [SearchValue, setSearchValue] = useState("");
51
- const [SingleSelectValue, setSingleSelectValue] = useState(null);
52
- const getFlagIconUrl = (code) => {
53
- return `https://flagsapi.com/${code}/flat/64.png`;
54
- };
55
- const SelectItem = (object) => {
56
- object.selected = !object.selected;
57
- if (!withMultiselect) {
58
- onSelect?.(object);
59
- return;
60
- }
61
- SelectedData.current = [...SelectedData.current, ...Data.filter((el) => el.selected == true), ...Data.filter((el) => el.id === object.id)];
62
- SelectedData.current = _filterUnique(SelectedData.current, "id").filter((el) => el.selected).filter((el) => el.id !== "SELECT_ALL");
63
- if (object.id === "SELECT_ALL") {
64
- setSelectAllKey(object.selected);
65
- setClickedSelectAll(true);
66
- } else {
67
- setSelectAllKey(false);
68
- onSelect?.(SelectedData.current);
69
- setClickedSelectAll(false);
70
- }
71
- setFlag((state) => !state);
72
- };
73
- const SingleSelect = (object) => {
74
- setSingleSelectValue(object);
75
- onSelect?.(object);
76
- setIsFocused(false);
77
- };
78
- const Focus = () => {
79
- onFocus?.();
80
- };
81
- const CalculatePos = () => {
82
- const componentEl = ComponentRef.current;
83
- const dropdownEl = DropdownRef.current;
84
- if (!dropdownEl || !componentEl) return;
85
- const componentRect = componentEl.getBoundingClientRect();
86
- const windowHeight = window.innerHeight;
87
- dropdownEl.style.position = "fixed";
88
- dropdownEl.style.width = componentRect.width + "px";
89
- dropdownEl.style.left = `${componentRect.left + window.pageXOffset}px`;
90
- if (componentRect.bottom + dropdownEl.offsetHeight > windowHeight) {
91
- dropdownEl.style.top = `${window.scrollY + componentRect.top - dropdownEl.offsetHeight + 18}px`;
92
- dropdownEl.style.bottom = "unset";
93
- } else {
94
- dropdownEl.style.top = `${window.scrollY + componentRect.bottom + 8}px`;
95
- dropdownEl.style.bottom = "unset";
96
- }
97
- };
98
- useEffect(() => {
99
- CalculatePos();
100
- }, [DropdownRef, IsFocused]);
101
- useEffect(() => {
102
- SelectedData.current = data.filter((el) => el.selected);
103
- if (!withMultiselect) {
104
- setData(data);
105
- return;
106
- }
107
- const hasSelected = data.some((el) => "selected" in el);
108
- const firstItem = { id: "SELECT_ALL", label: "Select All", selected: SelectAllKey };
109
- if (hasSelected) {
110
- setData([firstItem, ...data]);
111
- } else {
112
- data.forEach((el) => {
113
- el.selected = false;
114
- });
115
- setData([firstItem, ...data]);
116
- }
117
- }, [JSON.stringify(data)]);
118
- useEffect(() => {
119
- if (!withMultiselect) return;
120
- if (!data.every((el) => el.selected)) {
121
- setSelectAllKey(false);
122
- }
123
- }, [SelectedData.current.length]);
124
- useEffect(() => {
125
- if (!withMultiselect && selectedOptionID) {
126
- setSingleSelectValue(data.find((el) => el.id === selectedOptionID));
127
- }
128
- }, [selectedOptionID]);
129
- useEffect(() => {
130
- if (!withMultiselect) return;
131
- if (Data.length > 0 && ClickedSelectAll) {
132
- const updated = Data.map((el) => {
133
- if (el.id === "SELECT_ALL") return { ...el, selected: SelectAllKey };
134
- if (el.disabled) return el;
135
- return { ...el, selected: SelectAllKey };
136
- });
137
- setData(updated);
138
- data.forEach((el) => {
139
- if (el.id === "SELECT_ALL") {
140
- el.selected = SelectAllKey;
141
- } else if (!el.disabled) {
142
- el.selected = SelectAllKey;
143
- }
144
- });
145
- SelectedData.current = updated.filter((el) => el.selected && el.id !== "SELECT_ALL");
146
- onSelect?.(SelectedData.current);
147
- }
148
- }, [Flag]);
149
- useEffect(() => {
150
- const ClickHandler = (event) => {
151
- if (!ComponentRef.current) return;
152
- if (event.composedPath().includes(ComponentRef.current)) return;
153
- setIsFocused(false);
154
- };
155
- const ScrollHandler = (event) => {
156
- if (!ComponentRef.current || !ListRef.current) return;
157
- if (ListRef.current.contains(event.target)) return;
158
- setIsFocused(false);
159
- };
160
- document.addEventListener("click", ClickHandler);
161
- document.addEventListener("wheel", ScrollHandler);
162
- return () => {
163
- document.removeEventListener("click", ClickHandler);
164
- document.removeEventListener("wheel", ScrollHandler);
165
- };
166
- }, []);
167
- useEffect(() => {
168
- if (!withMultiselect) return;
169
- const calculateSelectedLength = () => {
170
- const rect = ComponentRef.current?.getBoundingClientRect();
171
- if (!rect) return;
172
- const width = rect.width;
173
- if (width <= 150) SelectedDataLength.current = 0;
174
- else if (width <= 250) SelectedDataLength.current = 1;
175
- else if (width <= 350) SelectedDataLength.current = 2;
176
- else if (width <= 450) SelectedDataLength.current = 3;
177
- else SelectedDataLength.current = 4;
178
- };
179
- calculateSelectedLength();
180
- window.addEventListener("resize", calculateSelectedLength);
181
- return () => window.removeEventListener("resize", calculateSelectedLength);
182
- }, []);
183
- const isInitialRender = useRef(true);
184
- useEffect(() => {
185
- if (isInitialRender.current) {
186
- isInitialRender.current = false;
187
- return;
188
- }
189
- if (!IsFocused) {
190
- onBlur?.();
191
- }
192
- }, [IsFocused]);
193
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `${style.dropdownWrapper}`, style: dropdownWrapperStyle ?? {}, children: [
194
- /* @__PURE__ */ jsxRuntimeExports.jsx(
195
- "div",
196
- {
197
- ref: ComponentRef,
198
- className: style.dropdownInputWrapper,
199
- style: dropdownInputWrapperStyle ?? {},
200
- onClick: () => (setIsFocused((state) => !state), CalculatePos()),
201
- onFocus: Focus,
202
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(
203
- FormInput,
204
- {
205
- ...rest,
206
- onFocusChange: (value) => setIsFocused(value),
207
- customFocus: IsFocused,
208
- withActive: false,
209
- value: withInput ? InputValue : SingleSelectValue?.label ?? "",
210
- onChange: (value) => {
211
- setInputValue(value);
212
- onValueChange?.(value);
213
- },
214
- toggleFocus: true,
215
- formInputStyle: { cursor: withInput ? "text" : "pointer" },
216
- leftSlot: withInput && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: style.dropdownInputSlot, children: [
217
- dropdownType === "currency" ? /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: SingleSelectValue?.label }) : /* @__PURE__ */ jsxRuntimeExports.jsx("img", { src: getFlagIconUrl(SingleSelectValue?.code), alt: "flag" }),
218
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `${style.dropdownRightIconArrow} ${IsFocused ? style.focused : ""}`, children: /* @__PURE__ */ jsxRuntimeExports.jsx(IconArrowUp, {}) })
219
- ] }),
220
- rightSlot: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `${style.dropdownRightIcon} ${IsFocused ? style.focused : ""}`, children: [
221
- (withInput ? InputValue : !withMultiselect && SingleSelectValue) && /* @__PURE__ */ jsxRuntimeExports.jsx(
222
- "div",
223
- {
224
- onClick: (e) => {
225
- e.stopPropagation();
226
- if (withInput) {
227
- setInputValue("");
228
- setIsFocused(false);
229
- } else {
230
- setSingleSelectValue(null);
231
- }
232
- },
233
- className: style.dropdownRightIconClose,
234
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(IconCloseCircle, {})
235
- }
236
- ),
237
- !withInput && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: style.dropdownRightIconArrow, children: /* @__PURE__ */ jsxRuntimeExports.jsx(IconArrowUp, {}) })
238
- ] }),
239
- readOnly: !withInput,
240
- forDropdown: true,
241
- inputSlotStyle: { width: "100%" },
242
- inputSlot: withMultiselect && SelectedData.current.length > 0 ? customInputSlot || /* @__PURE__ */ jsxRuntimeExports.jsxs("ul", { className: style.dropdownInputSlot, style: dropdownInputSlotStyle ?? {}, children: [
243
- SelectedData.current.slice(0, SelectedDataLength.current).map((el, index) => {
244
- return /* @__PURE__ */ jsxRuntimeExports.jsxs(
245
- "li",
246
- {
247
- ref: ListItemRef,
248
- className: style.dropdownInputSlotItem,
249
- style: dropdownInputSlotItemStyle ?? {},
250
- onClick: (e) => e.stopPropagation(),
251
- children: [
252
- /* @__PURE__ */ jsxRuntimeExports.jsx("p", { title: el.label, className: style.dropdownInputSlotItemLabel, style: dropdownInputSlotItemLabelStyle ?? {}, children: el.customLabel ? el.customLabel(el) : el.label }),
253
- /* @__PURE__ */ jsxRuntimeExports.jsx(
254
- "div",
255
- {
256
- style: dropdownInputSlotItemCloseStyle ?? {},
257
- className: style.dropdownInputSlotItemClose,
258
- onClick: (e) => {
259
- e.stopPropagation();
260
- SelectItem(el);
261
- },
262
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(IconClose, { width: "16", height: "16", viewBox: "0 0 16 16", stroke: "#95969C" })
263
- }
264
- )
265
- ]
266
- },
267
- index
268
- );
269
- }),
270
- SelectedData.current.length > SelectedDataLength.current && /* @__PURE__ */ jsxRuntimeExports.jsx("li", { className: `${style.dropdownInputSlotItem} ${style.dropdownInputSlotItemMore}`, style: dropdownInputSlotItemMoreStyle ?? {}, children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: style.dropdownInputSlotItemLabel, style: dropdownInputSlotItemLabelStyle ?? {}, children: `+${SelectedData.current.length - SelectedDataLength.current}` }) })
271
- ] }) : null
272
- }
273
- )
274
- }
275
- ),
276
- data && data.length > 0 && IsFocused && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { ref: DropdownRef, onClick: (e) => e.stopPropagation(), className: style.dropdownListContainer, children: [
277
- withFilter && /* @__PURE__ */ jsxRuntimeExports.jsx(
278
- FormInput,
279
- {
280
- placeholder: "Search",
281
- searchComponent: true,
282
- withFocus: false,
283
- withActive: false,
284
- value: SearchValue,
285
- onChange: (value) => setSearchValue(value)
286
- }
287
- ),
288
- /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { onClick: (e) => e.stopPropagation(), className: style.dropdownList, ref: ListRef, style: dropdownListStyle ?? {}, children: Data.filter((item) => item?.label?.toLowerCase().includes(SearchValue.toLowerCase())).map((item, index) => {
289
- return /* @__PURE__ */ jsxRuntimeExports.jsxs(
290
- "li",
291
- {
292
- style: { ...dropdownItemStyle, cursor: !withMultiselect && item?.disabled ? "not-allowed" : "pointer" },
293
- className: `${style.dropdownItem} ${!withMultiselect && SingleSelectValue?.id === item.id ? style.selected : ""} ${!item?.label || item.label === void 0 || disableAll || item?.disabled ? style.disabled : ""} ${!withMultiselect && !item?.disabled ? style.hovered : ""}`,
294
- onClick: (e) => {
295
- e.stopPropagation();
296
- if (!withMultiselect && !item?.disabled) {
297
- SingleSelect(item);
298
- }
299
- },
300
- children: [
301
- withMultiselect && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: style.itemCheckbox, style: itemCheckboxStyle ?? {}, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
302
- Checkbox,
303
- {
304
- multipleChecked: item.id === "SELECT_ALL",
305
- disabled: disableAll || item?.disabled,
306
- checked: item?.selected,
307
- change: () => SelectItem(item)
308
- }
309
- ) }),
310
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: style.dropdownItemLabel, style: dropdownItemLabelStyle ?? {}, children: [
311
- withInput ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: style.dropdownItemLabelInput, children: [
312
- /* @__PURE__ */ jsxRuntimeExports.jsx("img", { src: getFlagIconUrl(item.code), style: { width: "1.375rem", height: "1.375rem", objectFit: "contain" }, alt: item.name }),
313
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { title: item.name, className: style.countryName, children: item.name || item.label }),
314
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: style.countryDialCode, children: dropdownType === "country" ? item.dialCode : item?.label })
315
- ] }) : /* @__PURE__ */ jsxRuntimeExports.jsx(
316
- "p",
317
- {
318
- title: typeof item.label === "string" ? item.label : "",
319
- className: `${item.id === "SELECT_ALL" ? style.selectAll : ""}`,
320
- style: dropdownItemLabelTextStyle ?? {},
321
- children: item.customLabel ? item.customLabel() : item.label
322
- }
323
- ),
324
- withMultiselect && /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: item.id === "SELECT_ALL" ? `${Data.filter((el) => el.id !== "SELECT_ALL" && el.selected).length}/${data.length}` : "" })
325
- ] })
326
- ]
327
- },
328
- index
329
- );
330
- }) }, Data.length)
331
- ] })
332
- ] });
333
- };
334
- export {
335
- Dropdown as default
336
- };