@monolith-forensics/monolith-ui 1.1.28 → 1.1.29

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 (135) hide show
  1. package/package.json +3 -2
  2. package/dist/Button/Button.d.ts +0 -19
  3. package/dist/Button/Button.js +0 -332
  4. package/dist/Button/index.d.ts +0 -2
  5. package/dist/Button/index.js +0 -8
  6. package/dist/Calendar/Calendar.d.ts +0 -15
  7. package/dist/Calendar/Calendar.js +0 -232
  8. package/dist/Calendar/CalendarStyles.d.ts +0 -36
  9. package/dist/Calendar/CalendarStyles.js +0 -170
  10. package/dist/Calendar/calendarHelpers.d.ts +0 -53
  11. package/dist/Calendar/calendarHelpers.js +0 -181
  12. package/dist/Calendar/index.d.ts +0 -1
  13. package/dist/Calendar/index.js +0 -8
  14. package/dist/CheckBox/CheckBox.d.ts +0 -13
  15. package/dist/CheckBox/CheckBox.js +0 -46
  16. package/dist/CheckBox/index.d.ts +0 -1
  17. package/dist/CheckBox/index.js +0 -8
  18. package/dist/DateInput/DateInput.d.ts +0 -24
  19. package/dist/DateInput/DateInput.js +0 -509
  20. package/dist/DateInput/index.d.ts +0 -1
  21. package/dist/DateInput/index.js +0 -8
  22. package/dist/DropDownMenu/DropDownMenu.d.ts +0 -36
  23. package/dist/DropDownMenu/DropDownMenu.js +0 -213
  24. package/dist/DropDownMenu/index.d.ts +0 -1
  25. package/dist/DropDownMenu/index.js +0 -8
  26. package/dist/Error/Error.d.ts +0 -4
  27. package/dist/Error/Error.js +0 -38
  28. package/dist/Error/index.d.ts +0 -1
  29. package/dist/Error/index.js +0 -8
  30. package/dist/FieldLabel/FieldLabel.d.ts +0 -19
  31. package/dist/FieldLabel/FieldLabel.js +0 -119
  32. package/dist/FieldLabel/index.d.ts +0 -1
  33. package/dist/FieldLabel/index.js +0 -8
  34. package/dist/FileInputField/FileInputField.d.ts +0 -19
  35. package/dist/FileInputField/FileInputField.js +0 -117
  36. package/dist/FileInputField/index.d.ts +0 -1
  37. package/dist/FileInputField/index.js +0 -8
  38. package/dist/Flyout/Flyout.d.ts +0 -11
  39. package/dist/Flyout/Flyout.js +0 -111
  40. package/dist/Flyout/FlyoutHeader.d.ts +0 -5
  41. package/dist/Flyout/FlyoutHeader.js +0 -12
  42. package/dist/Flyout/FlyoutTitle.d.ts +0 -2
  43. package/dist/Flyout/FlyoutTitle.js +0 -13
  44. package/dist/Flyout/index.d.ts +0 -3
  45. package/dist/Flyout/index.js +0 -12
  46. package/dist/FormSection/FormSection.d.ts +0 -9
  47. package/dist/FormSection/FormSection.js +0 -51
  48. package/dist/FormSection/index.d.ts +0 -1
  49. package/dist/FormSection/index.js +0 -8
  50. package/dist/Grid/Grid.d.ts +0 -8
  51. package/dist/Grid/Grid.js +0 -18
  52. package/dist/Grid/index.d.ts +0 -1
  53. package/dist/Grid/index.js +0 -8
  54. package/dist/IconButton/IconButton.d.ts +0 -5
  55. package/dist/IconButton/IconButton.js +0 -30
  56. package/dist/IconButton/index.d.ts +0 -1
  57. package/dist/IconButton/index.js +0 -8
  58. package/dist/Input/Input.d.ts +0 -21
  59. package/dist/Input/Input.js +0 -149
  60. package/dist/Input/index.d.ts +0 -1
  61. package/dist/Input/index.js +0 -8
  62. package/dist/Modal/Modal.d.ts +0 -14
  63. package/dist/Modal/Modal.js +0 -110
  64. package/dist/Modal/index.d.ts +0 -1
  65. package/dist/Modal/index.js +0 -8
  66. package/dist/MonolithUIProvider/GlobalStyle.d.ts +0 -4
  67. package/dist/MonolithUIProvider/GlobalStyle.js +0 -53
  68. package/dist/MonolithUIProvider/MonolithUIProvider.d.ts +0 -9
  69. package/dist/MonolithUIProvider/MonolithUIProvider.js +0 -29
  70. package/dist/MonolithUIProvider/index.d.ts +0 -2
  71. package/dist/MonolithUIProvider/index.js +0 -10
  72. package/dist/MonolithUIProvider/useMonolithUITheme.d.ts +0 -2
  73. package/dist/MonolithUIProvider/useMonolithUITheme.js +0 -12
  74. package/dist/Pill/Pill.d.ts +0 -11
  75. package/dist/Pill/Pill.js +0 -152
  76. package/dist/Pill/index.d.ts +0 -1
  77. package/dist/Pill/index.js +0 -8
  78. package/dist/SelectBox/SelectBox.d.ts +0 -45
  79. package/dist/SelectBox/SelectBox.js +0 -477
  80. package/dist/SelectBox/index.d.ts +0 -1
  81. package/dist/SelectBox/index.js +0 -8
  82. package/dist/Switch/Switch.d.ts +0 -18
  83. package/dist/Switch/Switch.js +0 -157
  84. package/dist/Switch/index.d.ts +0 -1
  85. package/dist/Switch/index.js +0 -8
  86. package/dist/Table/Table.d.ts +0 -91
  87. package/dist/Table/Table.js +0 -715
  88. package/dist/Table/index.d.ts +0 -2
  89. package/dist/Table/index.js +0 -10
  90. package/dist/TagBox/TagBox.d.ts +0 -39
  91. package/dist/TagBox/TagBox.js +0 -590
  92. package/dist/TagBox/TagBoxStyles.d.ts +0 -11
  93. package/dist/TagBox/TagBoxStyles.js +0 -113
  94. package/dist/TagBox/index.d.ts +0 -1
  95. package/dist/TagBox/index.js +0 -8
  96. package/dist/TextArea/TextArea.d.ts +0 -16
  97. package/dist/TextArea/TextArea.js +0 -81
  98. package/dist/TextArea/index.d.ts +0 -1
  99. package/dist/TextArea/index.js +0 -8
  100. package/dist/TextAreaInput/TextAreaInput.d.ts +0 -19
  101. package/dist/TextAreaInput/TextAreaInput.js +0 -11
  102. package/dist/TextAreaInput/index.d.ts +0 -1
  103. package/dist/TextAreaInput/index.js +0 -8
  104. package/dist/TextInput/TextInput.d.ts +0 -13
  105. package/dist/TextInput/TextInput.js +0 -31
  106. package/dist/TextInput/index.d.ts +0 -1
  107. package/dist/TextInput/index.js +0 -8
  108. package/dist/Tooltip/Tooltip.d.ts +0 -12
  109. package/dist/Tooltip/Tooltip.js +0 -53
  110. package/dist/Tooltip/index.d.ts +0 -1
  111. package/dist/Tooltip/index.js +0 -8
  112. package/dist/core/ArrowButton.d.ts +0 -6
  113. package/dist/core/ArrowButton.js +0 -48
  114. package/dist/core/ClearButton.d.ts +0 -6
  115. package/dist/core/ClearButton.js +0 -48
  116. package/dist/core/MonolithThemeProvider.d.ts +0 -4
  117. package/dist/core/MonolithThemeProvider.js +0 -20
  118. package/dist/core/StyledContent.d.ts +0 -7
  119. package/dist/core/StyledContent.js +0 -47
  120. package/dist/core/StyledFloatContainer.d.ts +0 -2
  121. package/dist/core/StyledFloatContainer.js +0 -10
  122. package/dist/core/Types/Size.d.ts +0 -2
  123. package/dist/core/Types/Size.js +0 -2
  124. package/dist/core/Types/Variant.d.ts +0 -2
  125. package/dist/core/Types/Variant.js +0 -2
  126. package/dist/core/index.d.ts +0 -6
  127. package/dist/core/index.js +0 -14
  128. package/dist/index.d.ts +0 -26
  129. package/dist/index.js +0 -59
  130. package/dist/theme/index.d.ts +0 -168
  131. package/dist/theme/index.js +0 -14
  132. package/dist/theme/typography.d.ts +0 -45
  133. package/dist/theme/typography.js +0 -59
  134. package/dist/theme/variants.d.ts +0 -172
  135. package/dist/theme/variants.js +0 -276
@@ -1,477 +0,0 @@
1
- "use strict";
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
- var __importDefault = (this && this.__importDefault) || function (mod) {
14
- return (mod && mod.__esModule) ? mod : { "default": mod };
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.StyledInputContainer = void 0;
18
- const jsx_runtime_1 = require("react/jsx-runtime");
19
- const styled_components_1 = __importDefault(require("styled-components"));
20
- const react_1 = require("@floating-ui/react");
21
- const react_2 = require("react");
22
- const __1 = require("..");
23
- const use_debounce_1 = require("use-debounce");
24
- const core_1 = require("../core");
25
- exports.StyledInputContainer = styled_components_1.default.div `
26
- font-family: ${({ theme }) => theme.typography.fontFamily};
27
-
28
- position: relative;
29
- display: flex;
30
- flex-direction: row;
31
- border: none;
32
- outline: none;
33
- height: fit-content;
34
-
35
- width: ${({ width }) => {
36
- if (typeof width === "undefined")
37
- return "100%";
38
- if (width === null)
39
- return "100%";
40
- if (typeof width === "string")
41
- return width;
42
- if (typeof width === "number")
43
- return `${width}px`;
44
- }};
45
- `;
46
- const StyledInnerItemContainer = styled_components_1.default.div `
47
- overflow-y: auto;
48
-
49
- &[data-scroll-active="true"] {
50
- padding-right: 5px;
51
- }
52
- `;
53
- const GroupTitle = (0, styled_components_1.default)((_a) => {
54
- var { className, children } = _a, props = __rest(_a, ["className", "children"]);
55
- return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ className: className }, props, { children: [(0, jsx_runtime_1.jsx)("div", { className: "group-line" }), (0, jsx_runtime_1.jsx)("div", { className: "group-label", children: children }), (0, jsx_runtime_1.jsx)("div", { className: "group-line" })] })));
56
- }) `
57
- display: flex;
58
- flex-direction: row;
59
- align-items: center;
60
- justify-content: space-between;
61
- gap: 10px;
62
-
63
- color: ${(props) => props.theme.palette.text.secondary};
64
-
65
- padding: ${({ size }) => size === "xs"
66
- ? "2px 8px"
67
- : size === "sm"
68
- ? "4px 10px"
69
- : size === "md"
70
- ? "4px 12px"
71
- : size === "lg"
72
- ? "5px 14px"
73
- : size === "xl"
74
- ? "6px 16px"
75
- : "2px 8px"};
76
-
77
- .group-label {
78
- white-space: nowrap;
79
- overflow: hidden;
80
- text-overflow: ellipsis;
81
- width: fit-content;
82
- min-width: fit-content;
83
-
84
- font-weight: 500;
85
-
86
- font-size: ${({ size }) => size === "xs"
87
- ? "11px"
88
- : size === "sm"
89
- ? "13px"
90
- : size === "md"
91
- ? "15px"
92
- : size === "lg"
93
- ? "17px"
94
- : size === "xl"
95
- ? "19px"
96
- : "11px"};
97
- }
98
-
99
- .group-line {
100
- border-top: 1px solid ${(props) => props.theme.palette.divider};
101
- width: 100%;
102
- }
103
- `;
104
- const ActionMenu = styled_components_1.default.div ``;
105
- const StyledItem = styled_components_1.default.div `
106
- color: ${(props) => props.theme.palette.text.primary};
107
- border-radius: 3px;
108
- display: flex;
109
- align-items: center;
110
- min-height: 25px;
111
- padding: 7px 10px;
112
- position: relative;
113
- user-select: none;
114
- outline: none;
115
-
116
- cursor: pointer;
117
-
118
- font-family: ${({ theme }) => theme.typography.fontFamily};
119
-
120
- font-size: ${({ size }) => size === "xs"
121
- ? "11px"
122
- : size === "sm"
123
- ? "13px"
124
- : size === "md"
125
- ? "15px"
126
- : size === "lg"
127
- ? "17px"
128
- : size === "xl"
129
- ? "19px"
130
- : "11px"};
131
-
132
- padding: ${({ size }) => size === "xs"
133
- ? "2px 8px"
134
- : size === "sm"
135
- ? "4px 10px"
136
- : size === "md"
137
- ? "4px 12px"
138
- : size === "lg"
139
- ? "5px 14px"
140
- : size === "xl"
141
- ? "6px 16px"
142
- : "2px 8px"};
143
-
144
- &[data-disabled] {
145
- color: ${(props) => props.theme.palette.text.secondary};
146
- pointer-events: "none";
147
- }
148
-
149
- &:hover {
150
- background-color: ${(props) => props.theme.palette.action.hover};
151
- color: ${(props) => props.theme.palette.text.primary};
152
- }
153
-
154
- &[data-selected="true"] {
155
- background-color: ${(props) => props.theme.palette.divider};
156
- color: ${(props) => props.theme.palette.text.primary};
157
- }
158
- `;
159
- const SelectBox = (0, styled_components_1.default)(({ className, data = [], placeholder = "Select...", arrow = true, onChange, onSearch, searchFn, onScroll, loading, defaultValue, onItemAdded, size = "sm", variant = "outlined", width = "100%", allowCustomValue = false, searchable = false, clearable = false, label, description, required = false, error, openOnFocus = true, renderOption, actionComponent, focused, grouped, TooltipContent, DropDownProps = {}, }) => {
160
- var _a, _b, _c, _d, _e, _f, _g, _h;
161
- const isObjectArray = (_a = Object.keys((data === null || data === void 0 ? void 0 : data[0]) || {})) === null || _a === void 0 ? void 0 : _a.includes("label");
162
- const [isOpen, setIsOpen] = (0, react_2.useState)(false);
163
- const [selected, setSelected] = (0, react_2.useState)(null);
164
- const [searchValue, setSearchValue] = (0, react_2.useState)("");
165
- const [customItems, setCustomItems] = (0, react_2.useState)([]);
166
- const [placement, setPlacement] = (0, react_2.useState)("bottom-start");
167
- const [dropDownHeight, setDropDownHeight] = (0, react_2.useState)(null);
168
- const inputRef = (0, react_2.useRef)(null);
169
- const containerRef = (0, react_2.useRef)(null);
170
- const scrollContainerRef = (0, react_2.useRef)(null);
171
- const filteredItems = data
172
- .concat(customItems) // Add custom items to the list
173
- .filter((item) => {
174
- const itemValue = (isObjectArray ? item.label : item);
175
- return itemValue.toLowerCase().includes(searchValue.toLowerCase());
176
- })
177
- .sort((a, b) => {
178
- if (grouped) {
179
- const aValue = a.group;
180
- const bValue = b.group;
181
- return aValue.localeCompare(bValue);
182
- }
183
- // return current sort order
184
- return 0;
185
- });
186
- const groupedItems = grouped
187
- ? filteredItems.reduce((acc, item) => {
188
- if (!item.group) {
189
- item.group = "Other";
190
- }
191
- if (acc[item.group]) {
192
- acc[item.group].push(item);
193
- }
194
- else {
195
- acc[item.group] = [item];
196
- }
197
- return acc;
198
- }, {})
199
- : {};
200
- const groups = grouped
201
- ? Object.keys(groupedItems)
202
- .map((group) => ({
203
- label: group,
204
- items: groupedItems[group],
205
- }))
206
- .sort((a, b) => a.label.localeCompare(b.label))
207
- : [];
208
- const { refs, floatingStyles, update } = (0, react_1.useFloating)({
209
- open: isOpen,
210
- onOpenChange: setIsOpen,
211
- placement,
212
- strategy: "absolute",
213
- // Handle collisions with the viewport
214
- middleware: [(0, react_1.flip)(), (0, react_1.offset)(5)],
215
- });
216
- const toggleOpen = () => {
217
- setIsOpen((prev) => {
218
- if (!prev) {
219
- if (inputRef.current) {
220
- inputRef.current.focus();
221
- }
222
- }
223
- return !prev;
224
- });
225
- };
226
- const handleClear = (e) => {
227
- e.preventDefault();
228
- e.stopPropagation();
229
- if (inputRef.current)
230
- inputRef.current.value = "";
231
- handleChangeSelection(null);
232
- setSelected(null);
233
- setSearchValue("");
234
- searchFn === null || searchFn === void 0 ? void 0 : searchFn("");
235
- update();
236
- };
237
- const handleItemClick = (event, item) => {
238
- event.preventDefault();
239
- event.stopPropagation();
240
- handleChangeSelection(item);
241
- setIsOpen(false);
242
- };
243
- const handleChangeSelection = (0, react_2.useCallback)((option) => {
244
- setSelected(option);
245
- onChange === null || onChange === void 0 ? void 0 : onChange((option === null || option === void 0 ? void 0 : option.value) || option, option);
246
- }, [onChange]);
247
- const handleAddItem = (0, react_2.useCallback)((newItem) => {
248
- const isNewItem = data.every((item) => item.label.toLowerCase() !==
249
- newItem.toLowerCase());
250
- if (isNewItem) {
251
- const newValue = isObjectArray
252
- ? { label: newItem, value: newItem }
253
- : newItem;
254
- setCustomItems((prev) => {
255
- prev.push(newValue);
256
- return prev;
257
- });
258
- handleChangeSelection(newValue);
259
- onItemAdded === null || onItemAdded === void 0 ? void 0 : onItemAdded(newValue);
260
- }
261
- else {
262
- const item = data.find((item) => {
263
- return isObjectArray
264
- ? item.label.toLowerCase() === newItem.toLowerCase()
265
- : item.toLowerCase() === newItem.toLowerCase();
266
- });
267
- handleChangeSelection(item);
268
- }
269
- }, [onItemAdded, isObjectArray, data, handleChangeSelection]);
270
- const handleKeyDown = (e) => {
271
- var _a, _b;
272
- const currentInputValue = (_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.value;
273
- // Escape key
274
- if (e.key === "Escape") {
275
- const reference = (_b = refs === null || refs === void 0 ? void 0 : refs.reference) === null || _b === void 0 ? void 0 : _b.current;
276
- reference === null || reference === void 0 ? void 0 : reference.blur();
277
- setSearchValue("");
278
- update();
279
- setIsOpen(false);
280
- }
281
- // Enter key
282
- if (e.key === "Enter") {
283
- if (currentInputValue && currentInputValue !== "" && allowCustomValue) {
284
- handleAddItem(currentInputValue);
285
- setSearchValue("");
286
- update();
287
- }
288
- else {
289
- // TODO: decide what to do when user presses enter after typing a search value
290
- }
291
- toggleOpen();
292
- // setIsOpen(false);
293
- }
294
- // Arrow down
295
- if (e.key === "ArrowDown") {
296
- e.preventDefault();
297
- setSelected((prev) => {
298
- let newItem = filteredItems[0]; // Loop back to the first item
299
- const index = filteredItems.findIndex((item) => isObjectArray
300
- ? item.value === (prev === null || prev === void 0 ? void 0 : prev.value)
301
- : item === prev);
302
- if (index < filteredItems.length - 1) {
303
- newItem = filteredItems[index + 1];
304
- }
305
- onChange === null || onChange === void 0 ? void 0 : onChange((newItem === null || newItem === void 0 ? void 0 : newItem.value) || newItem, newItem);
306
- return newItem;
307
- });
308
- }
309
- // Arrow up
310
- if (e.key === "ArrowUp") {
311
- e.preventDefault();
312
- setSelected((prev) => {
313
- let newItem = filteredItems[filteredItems.length - 1]; // Loop back to the last item
314
- const index = filteredItems.findIndex((item) => isObjectArray
315
- ? item.value === (prev === null || prev === void 0 ? void 0 : prev.value)
316
- : item === prev);
317
- if (index > 0) {
318
- newItem = filteredItems[index - 1];
319
- }
320
- onChange === null || onChange === void 0 ? void 0 : onChange((newItem === null || newItem === void 0 ? void 0 : newItem.value) || newItem, newItem);
321
- return newItem;
322
- });
323
- }
324
- // Tab key
325
- if (e.key === "Tab") {
326
- if (allowCustomValue && currentInputValue && currentInputValue !== "") {
327
- handleAddItem(currentInputValue);
328
- setSearchValue("");
329
- }
330
- else if (!selected) {
331
- // clear input
332
- if (inputRef.current) {
333
- inputRef.current.value = "";
334
- }
335
- }
336
- setSearchValue("");
337
- setIsOpen(false);
338
- }
339
- };
340
- const handleOnChange = (e) => {
341
- // Simulate clear event when the input is changed to an empty string
342
- if (e.target.value === "") {
343
- handleClear(e);
344
- return;
345
- }
346
- if (searchFn !== undefined) {
347
- searchFn === null || searchFn === void 0 ? void 0 : searchFn(e.target.value);
348
- }
349
- else {
350
- setSearchValue(e.target.value);
351
- update();
352
- }
353
- };
354
- const debouncedHandleOnChange = (0, use_debounce_1.useDebouncedCallback)(handleOnChange, 300);
355
- const handleFocus = () => {
356
- if (openOnFocus) {
357
- setIsOpen(true);
358
- }
359
- };
360
- // Close on outside click
361
- (0, react_2.useEffect)(() => {
362
- const close = (e) => {
363
- var _a, _b;
364
- const target = e.target;
365
- const referenceElement = (_a = refs === null || refs === void 0 ? void 0 : refs.reference) === null || _a === void 0 ? void 0 : _a.current;
366
- const floatingElement = (_b = refs === null || refs === void 0 ? void 0 : refs.floating) === null || _b === void 0 ? void 0 : _b.current;
367
- if (floatingElement && // Check if the floating element exists
368
- target !== referenceElement && // Check if the target is not the reference (input)
369
- !referenceElement.contains(target) && // Check if the target is not inside the reference (input)
370
- !floatingElement.contains(target) // Check if the target is not inside the floating element (content)
371
- ) {
372
- setIsOpen(false);
373
- }
374
- };
375
- document.addEventListener("click", close);
376
- return () => document.removeEventListener("click", close);
377
- }, [refs.floating, refs.reference]);
378
- // Handle default value
379
- (0, react_2.useEffect)(() => {
380
- if (defaultValue) {
381
- const isOption = defaultValue.value !== undefined;
382
- const searchPattern = isOption
383
- ? defaultValue.value
384
- : defaultValue;
385
- setSelected(data.find((item) => isObjectArray
386
- ? item.value === searchPattern
387
- : item === searchPattern) || null);
388
- }
389
- }, [data, defaultValue, isObjectArray]);
390
- // handle input value change
391
- (0, react_2.useEffect)(() => {
392
- if (inputRef.current) {
393
- if (!selected) {
394
- inputRef.current.value = "";
395
- }
396
- else {
397
- inputRef.current.value = isObjectArray
398
- ? selected.label
399
- : selected;
400
- }
401
- }
402
- }, [selected]);
403
- // handle scroll item into view
404
- (0, react_2.useEffect)(() => {
405
- var _a, _b;
406
- const item = (_b = (_a = containerRef === null || containerRef === void 0 ? void 0 : containerRef.current) === null || _a === void 0 ? void 0 : _a.querySelector) === null || _b === void 0 ? void 0 : _b.call(_a, ".mfFloatingItem[data-selected=true]");
407
- if (item) {
408
- item.scrollIntoView({ block: "nearest" });
409
- }
410
- }, [selected]);
411
- // make calls to onSearch callback
412
- (0, react_2.useEffect)(() => {
413
- if (searchable) {
414
- update();
415
- onSearch === null || onSearch === void 0 ? void 0 : onSearch(searchValue);
416
- }
417
- }, [searchValue]);
418
- const referenceEl = (_b = refs === null || refs === void 0 ? void 0 : refs.reference) === null || _b === void 0 ? void 0 : _b.current;
419
- const contentWidth = ((_e = (_d = (_c = referenceEl === null || referenceEl === void 0 ? void 0 : referenceEl.getClientRects) === null || _c === void 0 ? void 0 : _c.call(referenceEl)) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.width) || "100%";
420
- const scrollEl = scrollContainerRef === null || scrollContainerRef === void 0 ? void 0 : scrollContainerRef.current;
421
- const scrollActive = scrollEl
422
- ? (scrollEl === null || scrollEl === void 0 ? void 0 : scrollEl.scrollHeight) > (scrollEl === null || scrollEl === void 0 ? void 0 : scrollEl.clientHeight)
423
- : false;
424
- // get height between bottom of the floating container and the bottom of the viewport
425
- const bottomHeight = window.innerHeight - ((_f = referenceEl === null || referenceEl === void 0 ? void 0 : referenceEl.getBoundingClientRect()) === null || _f === void 0 ? void 0 : _f.bottom) - 10;
426
- // get height between top of the floating container and the top of the viewport
427
- const topHeight = (((_g = referenceEl === null || referenceEl === void 0 ? void 0 : referenceEl.getBoundingClientRect()) === null || _g === void 0 ? void 0 : _g.top) -
428
- 10);
429
- (0, react_2.useEffect)(() => {
430
- if (bottomHeight < 250) {
431
- setPlacement("top-start");
432
- setDropDownHeight(topHeight);
433
- }
434
- else {
435
- setPlacement("bottom-start");
436
- setDropDownHeight(bottomHeight);
437
- }
438
- return () => {
439
- setPlacement("bottom-start");
440
- setDropDownHeight(bottomHeight);
441
- };
442
- }, [topHeight, bottomHeight, isOpen]);
443
- return ((0, jsx_runtime_1.jsxs)("div", { className: className, children: [label && ((0, jsx_runtime_1.jsx)(__1.FieldLabel, { error: error, asterisk: required, size: size, description: description, children: label })), (0, jsx_runtime_1.jsxs)(exports.StyledInputContainer, { ref: refs.setReference, onMouseDown: () => setIsOpen(true), width: width, onKeyDown: handleKeyDown, "data-open": isOpen, children: [(0, jsx_runtime_1.jsx)(__1.Input, { ref: inputRef, onChange: debouncedHandleOnChange, onFocus: handleFocus, autoFocus: focused, placeholder: placeholder, size: size, readOnly: !searchable, "data-button-right": arrow || clearable }), clearable && (selected || !!((_h = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _h === void 0 ? void 0 : _h.value)) ? ((0, jsx_runtime_1.jsx)(core_1.ClearButton, { className: "input-btn", onClick: handleClear })) : arrow ? ((0, jsx_runtime_1.jsx)(core_1.ArrowButton, { onClick: (e) => {
444
- e.preventDefault();
445
- // e.stopPropagation();
446
- }, onMouseDown: (e) => {
447
- e.preventDefault();
448
- e.stopPropagation();
449
- toggleOpen();
450
- } })) : null] }), isOpen && ((0, jsx_runtime_1.jsx)(react_1.FloatingPortal, { preserveTabOrder: true, children: (0, jsx_runtime_1.jsx)(core_1.StyledFloatContainer, { ref: (ref) => {
451
- containerRef.current = ref;
452
- refs.setFloating(ref);
453
- }, style: floatingStyles, className: "mfFloating", children: (0, jsx_runtime_1.jsxs)(core_1.StyledContent, Object.assign({ className: "mfFloatingContent", style: {
454
- width: contentWidth,
455
- maxWidth: contentWidth,
456
- maxHeight: DropDownProps.autoHeight
457
- ? (dropDownHeight || 250) - 10
458
- : "",
459
- }, variant: variant, "data-empty": filteredItems.length === 0 }, DropDownProps, { children: [actionComponent && (0, jsx_runtime_1.jsx)(ActionMenu, { children: actionComponent }), (0, jsx_runtime_1.jsxs)(StyledInnerItemContainer, { ref: scrollContainerRef, "data-scroll-active": scrollActive, onScroll: onScroll, children: [loading && (0, jsx_runtime_1.jsx)("div", { children: "Loading..." }), !loading && grouped
460
- ? groups.map((group, index) => ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)(GroupTitle, { size: size, children: group.label }), group.items.map((item, index) => {
461
- return ((0, jsx_runtime_1.jsx)(__1.Tooltip, { content: TooltipContent ? ((0, jsx_runtime_1.jsx)(TooltipContent, { data: item.data })) : null, side: "left", children: (0, jsx_runtime_1.jsx)(StyledItem, { className: "mfFloatingItem", onClick: (e) => handleItemClick(e, item), "data-selected": isObjectArray
462
- ? (selected === null || selected === void 0 ? void 0 : selected.value) ===
463
- item.value
464
- : selected === item, size: size, children: (renderOption === null || renderOption === void 0 ? void 0 : renderOption(item)) || ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (item === null || item === void 0 ? void 0 : item.label) || item })) }, index) }, index));
465
- })] }, group.label)))
466
- : filteredItems.map((item, index) => {
467
- return ((0, jsx_runtime_1.jsx)(__1.Tooltip, { content: TooltipContent ? ((0, jsx_runtime_1.jsx)(TooltipContent, { data: item.data })) : null, side: "left", children: (0, jsx_runtime_1.jsx)(StyledItem, { className: "mfFloatingItem", onClick: (e) => handleItemClick(e, item), "data-selected": isObjectArray
468
- ? (selected === null || selected === void 0 ? void 0 : selected.value) ===
469
- (item === null || item === void 0 ? void 0 : item.value)
470
- : selected === item, size: size, children: (renderOption === null || renderOption === void 0 ? void 0 : renderOption(item)) || ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (item === null || item === void 0 ? void 0 : item.label) || item })) }, index) }, index));
471
- })] })] })) }) }))] }));
472
- }) `
473
- position: relative;
474
- cursor: pointer;
475
- width: 100%;
476
- `;
477
- exports.default = SelectBox;
@@ -1 +0,0 @@
1
- export { default } from "./SelectBox";
@@ -1,8 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.default = void 0;
7
- var SelectBox_1 = require("./SelectBox");
8
- Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(SelectBox_1).default; } });
@@ -1,18 +0,0 @@
1
- import { CSSProperties } from "react";
2
- import { Size } from "../core";
3
- interface SwitchProps {
4
- className?: string;
5
- onChange: (e: any) => void;
6
- size?: Size;
7
- label?: string;
8
- labelPosition?: "left" | "right";
9
- description?: string;
10
- error?: string;
11
- required?: boolean;
12
- disabled?: boolean;
13
- defaultValue?: boolean;
14
- value?: boolean;
15
- style?: CSSProperties;
16
- }
17
- declare const Switch: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<SwitchProps, never>> & string & Omit<({ className, onChange, size, label, labelPosition, description, error, required, disabled, defaultValue, value, style, ...other }: SwitchProps) => import("react/jsx-runtime").JSX.Element, keyof import("react").Component<any, {}, any>>;
18
- export default Switch;
@@ -1,157 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __rest = (this && this.__rest) || function (s, e) {
26
- var t = {};
27
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
28
- t[p] = s[p];
29
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
30
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
31
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
32
- t[p[i]] = s[p[i]];
33
- }
34
- return t;
35
- };
36
- var __importDefault = (this && this.__importDefault) || function (mod) {
37
- return (mod && mod.__esModule) ? mod : { "default": mod };
38
- };
39
- Object.defineProperty(exports, "__esModule", { value: true });
40
- const jsx_runtime_1 = require("react/jsx-runtime");
41
- const styled_components_1 = __importDefault(require("styled-components"));
42
- const RadixSwitch = __importStar(require("@radix-ui/react-switch"));
43
- const __1 = require("..");
44
- const StyledRoot = (0, styled_components_1.default)(RadixSwitch.Root) `
45
- all: unset;
46
- cursor: pointer;
47
-
48
- height: ${({ size }) => size === "xs"
49
- ? "10px"
50
- : size === "sm"
51
- ? "16px"
52
- : size === "md"
53
- ? "22px"
54
- : size === "lg"
55
- ? "28px"
56
- : size === "xl"
57
- ? "32px"
58
- : "16px"};
59
-
60
- width: ${({ size }) => size === "xs"
61
- ? "26px"
62
- : size === "sm"
63
- ? "35px"
64
- : size === "md"
65
- ? "28px"
66
- : size === "lg"
67
- ? "34px"
68
- : size === "xl"
69
- ? "70px"
70
- : "26px"};
71
-
72
- background-color: ${({ theme }) => theme.name === "DARK" ? "#383838" : "#e3e3e3"};
73
- transition: background-color 100ms;
74
- border-radius: 9999px;
75
- border: 1px solid
76
- ${({ theme }) => theme.name === "DARK" ? theme.palette.input.border : "#e3e3e3"};
77
- position: relative;
78
- padding: ${({ size }) => size === "xs"
79
- ? "2px"
80
- : size === "sm"
81
- ? "2px"
82
- : size === "md"
83
- ? "28px"
84
- : size === "lg"
85
- ? "34px"
86
- : size === "xl"
87
- ? "2px 4px"
88
- : "2px"};
89
- -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
90
-
91
- &[data-state="checked"] {
92
- background-color: ${({ theme }) => theme.palette.primary.main};
93
- }
94
-
95
- // disabled styleing
96
- :disabled {
97
- pointer-events: none;
98
- opacity: 0.5;
99
- }
100
- `;
101
- const StyledThumb = (0, styled_components_1.default)(RadixSwitch.Thumb) `
102
- display: block;
103
- width: ${({ size }) => size === "xs"
104
- ? "9px"
105
- : size === "sm"
106
- ? "14px"
107
- : size === "md"
108
- ? "22px"
109
- : size === "lg"
110
- ? "28px"
111
- : size === "xl"
112
- ? "28px"
113
- : "14px"};
114
-
115
- height: ${({ size }) => size === "xs"
116
- ? "9px"
117
- : size === "sm"
118
- ? "14px"
119
- : size === "md"
120
- ? "22px"
121
- : size === "lg"
122
- ? "28px"
123
- : size === "xl"
124
- ? "28px"
125
- : "14px"};
126
-
127
- background-color: white;
128
- border: none;
129
- border-radius: 9999px;
130
- box-shadow: 0 2px 2px rgba(0, 0, 0, 0.1);
131
- transition: transform 100ms;
132
- will-change: transform;
133
-
134
- &[data-state="checked"] {
135
- transform: ${({ size }) => size === "xs"
136
- ? "translateX(17px)"
137
- : size === "sm"
138
- ? "translateX(20px)"
139
- : size === "md"
140
- ? "translateX(26px)"
141
- : size === "lg"
142
- ? "translateX(32px)"
143
- : size === "xl"
144
- ? "translateX(42px)"
145
- : "translateX(17px)"};
146
- }
147
- `;
148
- const Switch = (0, styled_components_1.default)((_a) => {
149
- var { className, onChange, size = "xs", label, labelPosition = "right", description, error, required, disabled = false, defaultValue, value, style = {} } = _a, other = __rest(_a, ["className", "onChange", "size", "label", "labelPosition", "description", "error", "required", "disabled", "defaultValue", "value", "style"]);
150
- return ((0, jsx_runtime_1.jsxs)("div", { className: className, children: [label && labelPosition === "left" && ((0, jsx_runtime_1.jsx)(__1.FieldLabel, { error: error, asterisk: required, size: size, description: description, children: label })), (0, jsx_runtime_1.jsx)(StyledRoot, Object.assign({ size: size, className: "SwitchRoot", onCheckedChange: onChange, defaultChecked: defaultValue, checked: value, disabled: disabled, style: style }, other, { children: (0, jsx_runtime_1.jsx)(StyledThumb, { size: size, className: "SwitchThumb" }) })), label && labelPosition === "right" && ((0, jsx_runtime_1.jsx)(__1.FieldLabel, { error: error, asterisk: required, size: size, description: description, children: label }))] }));
151
- }) `
152
- display: flex;
153
- flex-direction: row;
154
- align-items: center;
155
- gap: 10px;
156
- `;
157
- exports.default = Switch;
@@ -1 +0,0 @@
1
- export { default } from "./Switch";
@@ -1,8 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.default = void 0;
7
- var Switch_1 = require("./Switch");
8
- Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(Switch_1).default; } });