master-components-react-ts 2.1.7 → 2.1.8

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 (68) hide show
  1. package/dist/index.js +2894 -2292
  2. package/dist/style.css +2249 -0
  3. package/package.json +2 -2
  4. package/dist/_virtual/_commonjsHelpers.js +0 -8
  5. package/dist/_virtual/customParseFormat.js +0 -4
  6. package/dist/assets/Icons/IconArrowUp.js +0 -13
  7. package/dist/assets/Icons/IconCalendar.js +0 -32
  8. package/dist/assets/Icons/IconCheck.js +0 -15
  9. package/dist/assets/Icons/IconCheckCircle.js +0 -16
  10. package/dist/assets/Icons/IconCheckmark.js +0 -15
  11. package/dist/assets/Icons/IconCircularLoading.js +0 -36
  12. package/dist/assets/Icons/IconClose.js +0 -31
  13. package/dist/assets/Icons/IconCloseBackground.js +0 -15
  14. package/dist/assets/Icons/IconCloseCircle.js +0 -15
  15. package/dist/assets/Icons/IconErrorDash.js +0 -15
  16. package/dist/assets/Icons/IconExclamation.js +0 -15
  17. package/dist/assets/Icons/IconLeft.js +0 -13
  18. package/dist/assets/Icons/IconLoading.js +0 -22
  19. package/dist/assets/Icons/IconMinus.js +0 -7
  20. package/dist/assets/Icons/IconRadioChecked.js +0 -19
  21. package/dist/assets/Icons/IconRadioCheckedDisabled.js +0 -19
  22. package/dist/assets/Icons/IconRadioUnchecked.js +0 -16
  23. package/dist/assets/Icons/IconRadioUncheckedDisabled.js +0 -16
  24. package/dist/assets/Icons/IconRight.js +0 -13
  25. package/dist/assets/Icons/IconSave.js +0 -16
  26. package/dist/assets/Icons/IconSearch.js +0 -26
  27. package/dist/assets/Icons/IconSuccess.js +0 -15
  28. package/dist/assets/Icons/IconTrash.js +0 -16
  29. package/dist/assets/Inter_24pt-Medium-C1cYvkz2.woff2 +0 -0
  30. package/dist/assets/Inter_24pt-Regular-C7SEt4-L.woff2 +0 -0
  31. package/dist/assets/Inter_24pt-SemiBold-DIQUEucn.woff2 +0 -0
  32. package/dist/components/ActionDropdown/ActionDropdown.js +0 -74
  33. package/dist/components/ActionDropdown/ActionDropdown.module.scss.js +0 -29
  34. package/dist/components/Checkbox/Checkbox.js +0 -54
  35. package/dist/components/Checkbox/Checkbox.module.scss.js +0 -26
  36. package/dist/components/DatePicker/Calendar.js +0 -437
  37. package/dist/components/DatePicker/Calendar.module.scss.js +0 -83
  38. package/dist/components/DatePicker/DatePicker.js +0 -211
  39. package/dist/components/DatePicker/Datepicker.module.scss.js +0 -17
  40. package/dist/components/Dropdown/Dropdown.js +0 -337
  41. package/dist/components/Dropdown/Dropdown.module.scss.js +0 -74
  42. package/dist/components/FormInput/FormInput.js +0 -151
  43. package/dist/components/FormInput/FormInput.module.scss.js +0 -62
  44. package/dist/components/InlineLoading/InlineLoading.js +0 -24
  45. package/dist/components/InlineLoading/InlineLoading.module.scss.js +0 -11
  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/utils/Helpers.js +0 -15
@@ -1,211 +0,0 @@
1
- import { jsxs, jsx } from "react/jsx-runtime";
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__ */ jsxs("div", { className: `${namespace === "namespaceHr" ? style.namespaceHr : ""} ${style.datepickerContainer}`, children: [
159
- /* @__PURE__ */ jsx("div", { ref: ComponentRef, className: style.datepickerInputWrapper, onClick: () => (setIsFocused((state) => !state), CalculatePos()), children: /* @__PURE__ */ 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__ */ jsx("div", { className: style.datepickerLeftIcon, children: /* @__PURE__ */ jsx(IconCalendar, {}) }),
169
- rightSlot: /* @__PURE__ */ jsx("div", { className: `${style.datepickerRightIcon}`, onClick: Clear, children: Value && /* @__PURE__ */ jsx(IconCloseCircle, {}) }),
170
- readOnly: true
171
- }
172
- ) }),
173
- IsFocused && /* @__PURE__ */ 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,337 +0,0 @@
1
- import { jsxs, jsx } from "react/jsx-runtime";
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.zIndex = "100";
88
- dropdownEl.style.position = "fixed";
89
- dropdownEl.style.width = componentRect.width + "px";
90
- dropdownEl.style.left = `${componentRect.left + window.pageXOffset}px`;
91
- if (componentRect.bottom + dropdownEl.offsetHeight > windowHeight) {
92
- dropdownEl.style.top = `${window.scrollY + componentRect.top - dropdownEl.offsetHeight + 18}px`;
93
- dropdownEl.style.bottom = "unset";
94
- } else {
95
- dropdownEl.style.top = `${window.scrollY + componentRect.bottom + 8}px`;
96
- dropdownEl.style.bottom = "unset";
97
- }
98
- };
99
- useEffect(() => {
100
- CalculatePos();
101
- }, [DropdownRef, IsFocused]);
102
- useEffect(() => {
103
- SelectedData.current = data.filter((el) => el.selected);
104
- if (!withMultiselect) {
105
- setData(data);
106
- return;
107
- }
108
- const hasSelected = data.some((el) => "selected" in el);
109
- const firstItem = { id: "SELECT_ALL", label: "Select All", selected: SelectAllKey };
110
- if (hasSelected) {
111
- setData([firstItem, ...data]);
112
- } else {
113
- data.forEach((el) => {
114
- el.selected = false;
115
- });
116
- setData([firstItem, ...data]);
117
- }
118
- }, [JSON.stringify(data)]);
119
- useEffect(() => {
120
- if (!withMultiselect) return;
121
- if (!data.every((el) => el.selected)) {
122
- setSelectAllKey(false);
123
- }
124
- }, [SelectedData.current.length]);
125
- useEffect(() => {
126
- if (!withMultiselect && selectedOptionID) {
127
- setSingleSelectValue(data.find((el) => el.id === selectedOptionID));
128
- }
129
- }, [selectedOptionID]);
130
- useEffect(() => {
131
- if (!withMultiselect) return;
132
- if (Data.length > 0 && ClickedSelectAll) {
133
- const updated = Data.map((el) => {
134
- if (el.id === "SELECT_ALL") return { ...el, selected: SelectAllKey };
135
- if (el.disabled) return el;
136
- return { ...el, selected: SelectAllKey };
137
- });
138
- setData(updated);
139
- data.forEach((el) => {
140
- if (el.id === "SELECT_ALL") {
141
- el.selected = SelectAllKey;
142
- } else if (!el.disabled) {
143
- el.selected = SelectAllKey;
144
- }
145
- });
146
- SelectedData.current = updated.filter((el) => el.selected && el.id !== "SELECT_ALL");
147
- onSelect?.(SelectedData.current);
148
- }
149
- }, [Flag]);
150
- useEffect(() => {
151
- const ClickHandler = (event) => {
152
- if (!ComponentRef.current) return;
153
- if (event.composedPath().includes(ComponentRef.current)) return;
154
- setIsFocused(false);
155
- };
156
- const ScrollHandler = (event) => {
157
- if (!ComponentRef.current || !ListRef.current) return;
158
- if (ListRef.current.contains(event.target)) return;
159
- setIsFocused(false);
160
- };
161
- document.addEventListener("click", ClickHandler);
162
- document.addEventListener("wheel", ScrollHandler);
163
- return () => {
164
- document.removeEventListener("click", ClickHandler);
165
- document.removeEventListener("wheel", ScrollHandler);
166
- };
167
- }, []);
168
- useEffect(() => {
169
- if (!withMultiselect) return;
170
- const calculateSelectedLength = () => {
171
- const rect = ComponentRef.current?.getBoundingClientRect();
172
- if (!rect) return;
173
- const width = rect.width;
174
- if (width <= 150) SelectedDataLength.current = 0;
175
- else if (width <= 250) SelectedDataLength.current = 1;
176
- else if (width <= 350) SelectedDataLength.current = 2;
177
- else if (width <= 450) SelectedDataLength.current = 3;
178
- else SelectedDataLength.current = 4;
179
- };
180
- calculateSelectedLength();
181
- window.addEventListener("resize", calculateSelectedLength);
182
- return () => window.removeEventListener("resize", calculateSelectedLength);
183
- }, []);
184
- const isInitialRender = useRef(true);
185
- useEffect(() => {
186
- if (isInitialRender.current) {
187
- isInitialRender.current = false;
188
- return;
189
- }
190
- if (!IsFocused) {
191
- onBlur?.();
192
- }
193
- }, [IsFocused]);
194
- return /* @__PURE__ */ jsxs("div", { className: `${style.dropdownWrapper}`, style: dropdownWrapperStyle ?? {}, children: [
195
- /* @__PURE__ */ jsx(
196
- "div",
197
- {
198
- ref: ComponentRef,
199
- className: style.dropdownInputWrapper,
200
- style: dropdownInputWrapperStyle ?? {},
201
- onClick: () => (setIsFocused((state) => !state), CalculatePos()),
202
- onFocus: Focus,
203
- children: /* @__PURE__ */ jsx(
204
- FormInput,
205
- {
206
- ...rest,
207
- onFocusChange: (value) => setIsFocused(value),
208
- customFocus: IsFocused,
209
- withActive: false,
210
- value: withInput ? InputValue : SingleSelectValue?.label ?? "",
211
- onChange: (value) => {
212
- setInputValue(value);
213
- onValueChange?.(value);
214
- },
215
- toggleFocus: true,
216
- formInputStyle: { cursor: withInput ? "text" : "pointer" },
217
- leftSlot: withInput && /* @__PURE__ */ jsxs("div", { className: style.dropdownInputSlot, children: [
218
- dropdownType === "currency" ? /* @__PURE__ */ jsx("p", { children: SingleSelectValue?.label }) : /* @__PURE__ */ jsx("img", { src: getFlagIconUrl(SingleSelectValue?.code), alt: "flag" }),
219
- /* @__PURE__ */ jsx("div", { className: `${style.dropdownRightIconArrow} ${IsFocused ? style.focused : ""}`, children: /* @__PURE__ */ jsx(IconArrowUp, {}) })
220
- ] }),
221
- rightSlot: /* @__PURE__ */ jsxs("div", { className: `${style.dropdownRightIcon} ${IsFocused ? style.focused : ""}`, children: [
222
- (withInput ? InputValue : !withMultiselect && SingleSelectValue) && /* @__PURE__ */ jsx(
223
- "div",
224
- {
225
- onClick: (e) => {
226
- e.stopPropagation();
227
- if (withInput) {
228
- setInputValue("");
229
- setIsFocused(false);
230
- } else {
231
- setSingleSelectValue(null);
232
- }
233
- },
234
- className: style.dropdownRightIconClose,
235
- children: /* @__PURE__ */ jsx(IconCloseCircle, {})
236
- }
237
- ),
238
- !withInput && /* @__PURE__ */ jsx("div", { className: style.dropdownRightIconArrow, children: /* @__PURE__ */ jsx(IconArrowUp, {}) })
239
- ] }),
240
- readOnly: !withInput,
241
- forDropdown: true,
242
- inputSlotStyle: { width: "100%" },
243
- inputSlot: withMultiselect && SelectedData.current.length > 0 ? customInputSlot || /* @__PURE__ */ jsxs("ul", { className: style.dropdownInputSlot, style: dropdownInputSlotStyle ?? {}, children: [
244
- SelectedData.current.slice(0, SelectedDataLength.current).map((el, index) => {
245
- return /* @__PURE__ */ jsxs(
246
- "li",
247
- {
248
- ref: ListItemRef,
249
- className: style.dropdownInputSlotItem,
250
- style: dropdownInputSlotItemStyle ?? {},
251
- onClick: (e) => e.stopPropagation(),
252
- children: [
253
- /* @__PURE__ */ jsx("p", { title: el.label, className: style.dropdownInputSlotItemLabel, style: dropdownInputSlotItemLabelStyle ?? {}, children: typeof el.customLabel === "function" ? el.customLabel(el) : el.label }),
254
- /* @__PURE__ */ jsx(
255
- "div",
256
- {
257
- style: dropdownInputSlotItemCloseStyle ?? {},
258
- className: style.dropdownInputSlotItemClose,
259
- onClick: (e) => {
260
- e.stopPropagation();
261
- SelectItem(el);
262
- },
263
- children: /* @__PURE__ */ jsx(IconClose, { width: "16", height: "16", viewBox: "0 0 16 16", stroke: "#95969C" })
264
- }
265
- )
266
- ]
267
- },
268
- index
269
- );
270
- }),
271
- SelectedData.current.length > SelectedDataLength.current && /* @__PURE__ */ jsx("li", { className: `${style.dropdownInputSlotItem} ${style.dropdownInputSlotItemMore}`, style: dropdownInputSlotItemMoreStyle ?? {}, children: /* @__PURE__ */ jsx("p", { className: style.dropdownInputSlotItemLabel, style: dropdownInputSlotItemLabelStyle ?? {}, children: `+${SelectedData.current.length - SelectedDataLength.current}` }) })
272
- ] }) : null
273
- }
274
- )
275
- }
276
- ),
277
- data && data.length > 0 && IsFocused && /* @__PURE__ */ jsxs("div", { ref: DropdownRef, onClick: (e) => e.stopPropagation(), className: style.dropdownListContainer, children: [
278
- withFilter && /* @__PURE__ */ jsx(
279
- FormInput,
280
- {
281
- placeholder: "Search",
282
- searchComponent: true,
283
- withFocus: false,
284
- withActive: false,
285
- value: SearchValue,
286
- onChange: (value) => setSearchValue(value)
287
- }
288
- ),
289
- /* @__PURE__ */ 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) => {
290
- return /* @__PURE__ */ jsxs(
291
- "li",
292
- {
293
- style: { ...dropdownItemStyle, cursor: !withMultiselect && item?.disabled ? "not-allowed" : "pointer" },
294
- 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 : ""}`,
295
- onClick: (e) => {
296
- e.stopPropagation();
297
- if (!withMultiselect && !item?.disabled) {
298
- SingleSelect(item);
299
- }
300
- },
301
- children: [
302
- withMultiselect && /* @__PURE__ */ jsx("div", { className: style.itemCheckbox, style: itemCheckboxStyle ?? {}, children: /* @__PURE__ */ jsx(
303
- Checkbox,
304
- {
305
- multipleChecked: item.id === "SELECT_ALL",
306
- disabled: disableAll || item?.disabled,
307
- checked: item?.selected,
308
- change: () => SelectItem(item)
309
- }
310
- ) }),
311
- /* @__PURE__ */ jsxs("div", { className: style.dropdownItemLabel, style: dropdownItemLabelStyle ?? {}, children: [
312
- withInput ? /* @__PURE__ */ jsxs("div", { className: style.dropdownItemLabelInput, children: [
313
- /* @__PURE__ */ jsx("img", { src: getFlagIconUrl(item.code), style: { width: "1.375rem", height: "1.375rem", objectFit: "contain" }, alt: item.name }),
314
- /* @__PURE__ */ jsx("span", { title: item.name, className: style.countryName, children: item.name || item.label }),
315
- /* @__PURE__ */ jsx("span", { className: style.countryDialCode, children: dropdownType === "country" ? item.dialCode : item?.label })
316
- ] }) : /* @__PURE__ */ jsx(
317
- "p",
318
- {
319
- title: typeof item.label === "string" ? item.label : "",
320
- className: `${item.id === "SELECT_ALL" ? style.selectAll : ""}`,
321
- style: dropdownItemLabelTextStyle ?? {},
322
- children: typeof item.customLabel === "function" ? item.customLabel(item) : item.label
323
- }
324
- ),
325
- withMultiselect && /* @__PURE__ */ jsx("p", { children: item.id === "SELECT_ALL" ? `${Data.filter((el) => el.id !== "SELECT_ALL" && el.selected).length}/${data.length}` : "" })
326
- ] })
327
- ]
328
- },
329
- index
330
- );
331
- }) }, Data.length)
332
- ] })
333
- ] });
334
- };
335
- export {
336
- Dropdown as default
337
- };
@@ -1,74 +0,0 @@
1
- const dropdownWrapper = "Dropdown-module__dropdownWrapper";
2
- const dropdownInputWrapper = "Dropdown-module__dropdownInputWrapper";
3
- const dropdownInputSlot = "Dropdown-module__dropdownInputSlot";
4
- const dropdownRightIconArrow = "Dropdown-module__dropdownRightIconArrow";
5
- const focused = "Dropdown-module__focused";
6
- const dropdownInputSlotItem = "Dropdown-module__dropdownInputSlotItem";
7
- const dropdownInputSlotItemLabel = "Dropdown-module__dropdownInputSlotItemLabel";
8
- const dropdownInputSlotItemClose = "Dropdown-module__dropdownInputSlotItemClose";
9
- const dropdownInputSlotItemMore = "Dropdown-module__dropdownInputSlotItemMore";
10
- const dropdownRightIcon = "Dropdown-module__dropdownRightIcon";
11
- const dropdownRightIconClose = "Dropdown-module__dropdownRightIconClose";
12
- const dropdownListContainer = "Dropdown-module__dropdownListContainer";
13
- const dropdownList = "Dropdown-module__dropdownList";
14
- const dropdownItem = "Dropdown-module__dropdownItem";
15
- const selected = "Dropdown-module__selected";
16
- const dropdownItemLabel = "Dropdown-module__dropdownItemLabel";
17
- const hovered = "Dropdown-module__hovered";
18
- const disabled = "Dropdown-module__disabled";
19
- const itemCheckbox = "Dropdown-module__itemCheckbox";
20
- const dropdownItemLabelInput = "Dropdown-module__dropdownItemLabelInput";
21
- const countryName = "Dropdown-module__countryName";
22
- const countryDialCode = "Dropdown-module__countryDialCode";
23
- const selectAll = "Dropdown-module__selectAll";
24
- const style = {
25
- dropdownWrapper,
26
- dropdownInputWrapper,
27
- dropdownInputSlot,
28
- dropdownRightIconArrow,
29
- focused,
30
- dropdownInputSlotItem,
31
- dropdownInputSlotItemLabel,
32
- dropdownInputSlotItemClose,
33
- dropdownInputSlotItemMore,
34
- dropdownRightIcon,
35
- dropdownRightIconClose,
36
- dropdownListContainer,
37
- dropdownList,
38
- dropdownItem,
39
- selected,
40
- dropdownItemLabel,
41
- hovered,
42
- disabled,
43
- itemCheckbox,
44
- dropdownItemLabelInput,
45
- countryName,
46
- countryDialCode,
47
- selectAll
48
- };
49
- export {
50
- countryDialCode,
51
- countryName,
52
- style as default,
53
- disabled,
54
- dropdownInputSlot,
55
- dropdownInputSlotItem,
56
- dropdownInputSlotItemClose,
57
- dropdownInputSlotItemLabel,
58
- dropdownInputSlotItemMore,
59
- dropdownInputWrapper,
60
- dropdownItem,
61
- dropdownItemLabel,
62
- dropdownItemLabelInput,
63
- dropdownList,
64
- dropdownListContainer,
65
- dropdownRightIcon,
66
- dropdownRightIconArrow,
67
- dropdownRightIconClose,
68
- dropdownWrapper,
69
- focused,
70
- hovered,
71
- itemCheckbox,
72
- selectAll,
73
- selected
74
- };