@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,2 +0,0 @@
1
- export { default } from "./Table";
2
- export { Column } from "./Table";
@@ -1,10 +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.Column = exports.default = void 0;
7
- var Table_1 = require("./Table");
8
- Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(Table_1).default; } });
9
- var Table_2 = require("./Table");
10
- Object.defineProperty(exports, "Column", { enumerable: true, get: function () { return Table_2.Column; } });
@@ -1,39 +0,0 @@
1
- import { ReactNode } from "react";
2
- import { Variant, Size } from "../core";
3
- type Option = {
4
- label: string;
5
- value: any;
6
- group?: string;
7
- data?: any;
8
- };
9
- interface TagBoxProps {
10
- className?: string;
11
- data?: Option[] | string[];
12
- placeholder?: string;
13
- arrow?: boolean;
14
- defaultValue?: Option[];
15
- grouped?: boolean;
16
- searchFn?: (value: string) => void;
17
- onChange?: (value: any[]) => void;
18
- onScroll?: () => void;
19
- onSearch?: (value: string) => void;
20
- onItemAdded?: (value: any) => void;
21
- size?: Size;
22
- variant?: Variant;
23
- width?: string;
24
- allowCustomValue?: boolean;
25
- searchable?: boolean;
26
- clearable?: boolean;
27
- openOnFocus?: boolean;
28
- label?: string;
29
- description?: string;
30
- required?: boolean;
31
- error?: string;
32
- loading?: boolean;
33
- renderOption?: (item: Option | string) => ReactNode;
34
- TooltipContent?: (props: {
35
- data: any;
36
- }) => JSX.Element;
37
- }
38
- declare const TagBox: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<TagBoxProps, never>> & string & Omit<({ className, data, placeholder, arrow, defaultValue, grouped, searchFn, onChange, onScroll, onSearch, onItemAdded, size, variant, width, allowCustomValue, searchable, clearable, openOnFocus, label, description, required, error, loading, renderOption, TooltipContent, }: TagBoxProps) => import("react/jsx-runtime").JSX.Element, keyof import("react").Component<any, {}, any>>;
39
- export default TagBox;
@@ -1,590 +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
- const jsx_runtime_1 = require("react/jsx-runtime");
18
- const styled_components_1 = __importDefault(require("styled-components"));
19
- const react_1 = require("@floating-ui/react");
20
- const react_2 = require("react");
21
- const __1 = require("..");
22
- const core_1 = require("../core");
23
- const StyledInputContainer = styled_components_1.default.div `
24
- position: relative;
25
- cursor: pointer;
26
-
27
- user-select: none;
28
-
29
- display: flex;
30
- flex-direction: row;
31
- align-items: center;
32
- user-select: none;
33
-
34
- pointer-events: all;
35
- outline: none;
36
-
37
- padding: ${({ size }) => size === "xs"
38
- ? "2px 8px"
39
- : size === "sm"
40
- ? "4px 10px"
41
- : size === "md"
42
- ? "6px 12px"
43
- : size === "lg"
44
- ? "7px 14px"
45
- : size === "xl"
46
- ? "8px 16px"
47
- : "4px 10px"};
48
-
49
- border-radius: 5px;
50
- transition: border 0.1s ease-in-out;
51
- border: 1px solid
52
- ${({ theme, variant }) => {
53
- switch (variant) {
54
- case "filled":
55
- return "transparent";
56
- case "outlined":
57
- return theme.palette.input.border;
58
- case "text":
59
- return "transparent";
60
- default:
61
- return theme.palette.input.border;
62
- }
63
- }};
64
- font-weight: 500;
65
- color: ${(props) => props.theme.palette.text.primary};
66
- font-size: ${({ size }) => size === "xs"
67
- ? "12px"
68
- : size === "sm"
69
- ? "14px"
70
- : size === "md"
71
- ? "16px"
72
- : size === "lg"
73
- ? "18px"
74
- : size === "xl"
75
- ? "20px"
76
- : "12px"};
77
-
78
- width: 100%;
79
- min-height: ${({ size }) => size === "xs"
80
- ? "26px"
81
- : size === "sm"
82
- ? "30px"
83
- : size === "md"
84
- ? "36px"
85
- : size === "lg"
86
- ? "42px"
87
- : size === "xl"
88
- ? "50px"
89
- : "26px"};
90
-
91
- &[data-button-right="true"] {
92
- padding-right: 36px;
93
- }
94
-
95
- background-color: ${({ theme, variant }) => {
96
- switch (variant) {
97
- case "filled":
98
- return theme.palette.input.background;
99
- case "outlined":
100
- return theme.palette.input.background;
101
- case "text":
102
- return "transparent";
103
- default:
104
- return theme.palette.input.background;
105
- }
106
- }};
107
-
108
- &[readOnly] {
109
- cursor: pointer;
110
- }
111
-
112
- & [data-has-space="true"] {
113
- padding-left: 4px;
114
- }
115
-
116
- & [data-selected="true"] {
117
- background-color: ${(props) => props.theme.palette.primary.main}50;
118
- }
119
-
120
- &[data-empty="true"] {
121
- color: ${(props) => props.theme.palette.input.placeholder};
122
- div {
123
- color: ${(props) => props.theme.palette.input.placeholder};
124
- }
125
- }
126
-
127
- & [data-default-btn="true"] {
128
- color: ${(props) => props.theme.palette.text.secondary};
129
- div {
130
- color: ${(props) => props.theme.palette.text.secondary};
131
- }
132
- }
133
-
134
- &[data-open="true"] {
135
- border: 1px solid ${(props) => props.theme.palette.primary.main};
136
- }
137
-
138
- &:focus-within {
139
- border: 1px solid ${(props) => props.theme.palette.primary.main};
140
- }
141
-
142
- &:focus {
143
- border: 1px solid ${(props) => props.theme.palette.primary.main};
144
- }
145
- `;
146
- // styled input with forwardRef
147
- const StyledInput = (0, styled_components_1.default)((_a) => {
148
- var { className, inputRef } = _a, props = __rest(_a, ["className", "inputRef"]);
149
- return ((0, jsx_runtime_1.jsx)(__1.Input, Object.assign({ ref: inputRef, className: className + " mfTagBox-input" }, props)));
150
- }) `
151
- &.mfTagBox-input {
152
- pointer-events: all;
153
- outline: none;
154
- background: transparent;
155
- flex: 1;
156
- appearance: none;
157
- border: 0;
158
- color: inherit;
159
-
160
- height: 100%;
161
- padding: 0px;
162
- min-height: 0px;
163
-
164
- min-width: 100px;
165
-
166
- &:focus {
167
- border: 0;
168
- }
169
- }
170
- `;
171
- const GroupTitle = (0, styled_components_1.default)((_a) => {
172
- var { className, children } = _a, props = __rest(_a, ["className", "children"]);
173
- 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" })] })));
174
- }) `
175
- display: flex;
176
- flex-direction: row;
177
- align-items: center;
178
- justify-content: space-between;
179
- gap: 10px;
180
-
181
- color: ${(props) => props.theme.palette.text.secondary};
182
-
183
- padding: ${({ size }) => size === "xs"
184
- ? "2px 8px"
185
- : size === "sm"
186
- ? "4px 10px"
187
- : size === "md"
188
- ? "4px 12px"
189
- : size === "lg"
190
- ? "5px 14px"
191
- : size === "xl"
192
- ? "6px 16px"
193
- : "2px 8px"};
194
-
195
- .group-label {
196
- white-space: nowrap;
197
- overflow: hidden;
198
- text-overflow: ellipsis;
199
- width: fit-content;
200
- min-width: fit-content;
201
-
202
- font-weight: 500;
203
-
204
- font-size: ${({ size }) => size === "xs"
205
- ? "11px"
206
- : size === "sm"
207
- ? "13px"
208
- : size === "md"
209
- ? "15px"
210
- : size === "lg"
211
- ? "17px"
212
- : size === "xl"
213
- ? "19px"
214
- : "11px"};
215
- }
216
-
217
- .group-line {
218
- border-top: 1px solid ${(props) => props.theme.palette.divider};
219
- width: 100%;
220
- }
221
- `;
222
- const PillContainer = styled_components_1.default.div `
223
- display: flex;
224
- align-items: center;
225
- gap: 5px;
226
- flex-wrap: wrap;
227
- flex-grow: 1;
228
-
229
- &[data-empty="true"] {
230
- display: none;
231
- }
232
- `;
233
- const StyledInnerContainer = styled_components_1.default.div `
234
- display: flex;
235
- flex-direction: column;
236
- width: 100%;
237
-
238
- &[data-button-right="true"] {
239
- padding-right: 30px;
240
- }
241
- `;
242
- const ExtendedStyledContent = (0, styled_components_1.default)(core_1.StyledContent) `
243
- overflow-y: auto;
244
- `;
245
- const StyledItem = styled_components_1.default.div `
246
- line-height: 1;
247
- color: ${(props) => props.theme.palette.text.primary};
248
- border-radius: 3px;
249
- display: flex;
250
- align-items: center;
251
- min-height: 25px;
252
- padding: 7px 10px;
253
- position: relative;
254
- user-select: none;
255
- outline: none;
256
-
257
- cursor: pointer;
258
-
259
- font-family: "Arial", sans-serif;
260
- font-size: ${({ size }) => size === "xs"
261
- ? "11px"
262
- : size === "sm"
263
- ? "13px"
264
- : size === "md"
265
- ? "15px"
266
- : size === "lg"
267
- ? "17px"
268
- : size === "xl"
269
- ? "19px"
270
- : "11px"};
271
-
272
- &[data-disabled] {
273
- color: ${(props) => props.theme.palette.text.secondary};
274
- pointer-events: "none";
275
- }
276
-
277
- &:hover {
278
- background-color: ${(props) => props.theme.palette.action.hover};
279
- color: ${(props) => props.theme.palette.text.primary};
280
- }
281
-
282
- &[data-selected="true"] {
283
- display: none;
284
- color: ${(props) => props.theme.palette.primary.main};
285
- }
286
-
287
- &[data-highlighted="true"] {
288
- background-color: ${(props) => props.theme.palette.divider};
289
- color: ${(props) => props.theme.palette.text.primary};
290
- }
291
- `;
292
- const TagBox = (0, styled_components_1.default)(({ className, data = [], placeholder = "Select tags", arrow = true, defaultValue = [], grouped, searchFn, onChange, onScroll, onSearch, onItemAdded, size = "sm", variant = "outlined", width = "100%", allowCustomValue = false, searchable = false, clearable = false, openOnFocus = true, label, description, required = false, error, loading = false, renderOption, TooltipContent, }) => {
293
- var _a, _b, _c, _d, _e, _f;
294
- const isObjectArray = (_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.hasOwnProperty("label");
295
- const [isOpen, setIsOpen] = (0, react_2.useState)(false);
296
- const [selectedItems, setSelectedItems] = (0, react_2.useState)(defaultValue);
297
- const [preSelected, setPreSelected] = (0, react_2.useState)(null);
298
- const [customItems, setCustomItems] = (0, react_2.useState)([]);
299
- const [searchValue, setSearchValue] = (0, react_2.useState)("");
300
- const inputRef = (0, react_2.useRef)(null);
301
- const scrollContainerRef = (0, react_2.useRef)(null);
302
- const filteredItems = data
303
- .concat(customItems) // Add custom items to the list
304
- .filter((item) => {
305
- const isSelected = !!selectedItems.find((selectedItem) => isObjectArray
306
- ? selectedItem.value === item.value
307
- : selectedItem === item);
308
- return !isSelected;
309
- })
310
- .filter((item) => {
311
- const itemValue = (isObjectArray ? item.label : item);
312
- return itemValue.toLowerCase().includes(searchValue.toLowerCase());
313
- })
314
- .sort((a, b) => {
315
- if (grouped) {
316
- const aValue = a.group;
317
- const bValue = b.group;
318
- return aValue.localeCompare(bValue);
319
- }
320
- // return current sort order
321
- return 0;
322
- });
323
- const groupedItems = grouped
324
- ? filteredItems.reduce((acc, item) => {
325
- if (!item.group) {
326
- item.group = "Other";
327
- }
328
- if (acc[item.group]) {
329
- acc[item.group].push(item);
330
- }
331
- else {
332
- acc[item.group] = [item];
333
- }
334
- return acc;
335
- }, {})
336
- : {};
337
- const groups = grouped
338
- ? Object.keys(groupedItems)
339
- .map((group) => ({
340
- label: group,
341
- items: groupedItems[group],
342
- }))
343
- .sort((a, b) => a.label.localeCompare(b.label))
344
- : [];
345
- const { refs, floatingStyles, update } = (0, react_1.useFloating)({
346
- open: isOpen,
347
- onOpenChange: setIsOpen,
348
- placement: "bottom-start",
349
- strategy: "absolute",
350
- // Handle collisions with the viewport
351
- middleware: [(0, react_1.flip)(), (0, react_1.offset)(5)],
352
- });
353
- const toggleOpen = () => {
354
- setIsOpen((prev) => {
355
- var _a;
356
- if (!prev) {
357
- if (inputRef.current) {
358
- const inputEl = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current;
359
- (_a = inputEl === null || inputEl === void 0 ? void 0 : inputEl.focus) === null || _a === void 0 ? void 0 : _a.call(inputEl);
360
- }
361
- }
362
- return !prev;
363
- });
364
- };
365
- const handleClear = (e) => {
366
- e.preventDefault();
367
- e.stopPropagation();
368
- if (inputRef === null || inputRef === void 0 ? void 0 : inputRef.current)
369
- inputRef.current.value = "";
370
- onChange === null || onChange === void 0 ? void 0 : onChange([]);
371
- setSelectedItems([]);
372
- setSearchValue("");
373
- searchFn === null || searchFn === void 0 ? void 0 : searchFn("");
374
- setIsOpen(false);
375
- };
376
- const handleChangeSelection = (0, react_2.useCallback)((option) => {
377
- setSelectedItems((prev) => {
378
- onChange === null || onChange === void 0 ? void 0 : onChange([...prev, option]);
379
- return [...prev, option];
380
- });
381
- }, [onChange]);
382
- const handleFocus = () => {
383
- var _a, _b;
384
- if (openOnFocus) {
385
- setIsOpen(true);
386
- }
387
- if (searchable) {
388
- (_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
389
- }
390
- else if (allowCustomValue) {
391
- (_b = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _b === void 0 ? void 0 : _b.focus();
392
- }
393
- };
394
- const handleItemClick = (item) => {
395
- var _a;
396
- if ((_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.value)
397
- inputRef.current.value = "";
398
- setSearchValue("");
399
- handleChangeSelection(item);
400
- };
401
- const handleRemoveItem = (item, index) => {
402
- setSelectedItems((prev) => {
403
- const newItems = prev.filter((prevItem, idx) => isObjectArray
404
- ? prevItem.value !== item.value
405
- : idx !== index);
406
- onChange === null || onChange === void 0 ? void 0 : onChange(newItems);
407
- return newItems;
408
- });
409
- };
410
- const handleAddItem = (0, react_2.useCallback)((newItem) => {
411
- const existingItem = data.concat(customItems).find((item) => {
412
- return isObjectArray
413
- ? item.label.toLowerCase() === newItem.toLowerCase()
414
- : item.toLowerCase() === newItem.toLowerCase();
415
- });
416
- if (!existingItem) {
417
- const newValue = isObjectArray
418
- ? { label: newItem, value: newItem }
419
- : newItem;
420
- setCustomItems([...customItems, newValue]);
421
- handleChangeSelection(newValue);
422
- onItemAdded === null || onItemAdded === void 0 ? void 0 : onItemAdded(newValue);
423
- }
424
- else {
425
- // check if the item is already selected
426
- const isSelected = !!selectedItems.find((selectedItem) => isObjectArray
427
- ? selectedItem.value ===
428
- existingItem.value
429
- : selectedItem === existingItem);
430
- if (!isSelected) {
431
- handleChangeSelection(existingItem);
432
- }
433
- }
434
- }, [
435
- onItemAdded,
436
- isObjectArray,
437
- data,
438
- handleChangeSelection,
439
- selectedItems,
440
- customItems,
441
- ]);
442
- const handleKeyDown = (e) => {
443
- var _a, _b;
444
- const currentInputValue = (_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.value;
445
- // Escape key
446
- if (e.key === "Escape") {
447
- const reference = (_b = refs === null || refs === void 0 ? void 0 : refs.reference) === null || _b === void 0 ? void 0 : _b.current;
448
- reference === null || reference === void 0 ? void 0 : reference.blur();
449
- setSearchValue("");
450
- update();
451
- setIsOpen(false);
452
- }
453
- // Enter key
454
- if (e.key === "Enter") {
455
- if (preSelected) {
456
- handleItemClick(preSelected);
457
- setPreSelected(null);
458
- setSearchValue("");
459
- update();
460
- return;
461
- }
462
- else if (currentInputValue &&
463
- currentInputValue !== "" &&
464
- allowCustomValue) {
465
- handleAddItem(currentInputValue);
466
- inputRef.current.value = "";
467
- setSearchValue("");
468
- update();
469
- }
470
- else {
471
- // TODO: decide what to do when user presses enter after typing a search value
472
- }
473
- // toggleOpen();
474
- // setIsOpen(false);
475
- }
476
- // Backspace key
477
- if (e.key === "Backspace" && currentInputValue === "") {
478
- setSelectedItems((prev) => {
479
- const newItems = prev.slice(0, prev.length - 1);
480
- onChange === null || onChange === void 0 ? void 0 : onChange(newItems);
481
- return newItems;
482
- });
483
- }
484
- // Arrow down
485
- if (e.key === "ArrowDown") {
486
- e.preventDefault();
487
- setPreSelected((prev) => {
488
- let newItem = filteredItems[0]; // Loop back to the first item
489
- const index = filteredItems.findIndex((item) => isObjectArray
490
- ? item.value === (prev === null || prev === void 0 ? void 0 : prev.value)
491
- : item === prev);
492
- if (index < filteredItems.length - 1) {
493
- newItem = filteredItems[index + 1];
494
- }
495
- return newItem;
496
- });
497
- }
498
- // Arrow up
499
- if (e.key === "ArrowUp") {
500
- e.preventDefault();
501
- setPreSelected((prev) => {
502
- let newItem = filteredItems[filteredItems.length - 1]; // Loop back to the last item
503
- const index = filteredItems.findIndex((item) => isObjectArray
504
- ? item.value === (prev === null || prev === void 0 ? void 0 : prev.value)
505
- : item === prev);
506
- if (index > 0) {
507
- newItem = filteredItems[index - 1];
508
- }
509
- return newItem;
510
- });
511
- }
512
- // Tab key
513
- if (e.key === "Tab") {
514
- setIsOpen(false);
515
- }
516
- };
517
- // Close on outside click
518
- (0, react_2.useEffect)(() => {
519
- const close = (e) => {
520
- var _a, _b;
521
- const target = e.target;
522
- const referenceElement = (_a = refs === null || refs === void 0 ? void 0 : refs.reference) === null || _a === void 0 ? void 0 : _a.current;
523
- const floatingElement = (_b = refs === null || refs === void 0 ? void 0 : refs.floating) === null || _b === void 0 ? void 0 : _b.current;
524
- if (floatingElement && // Check if the floating element exists
525
- target !== referenceElement && // Check if the target is not the reference (input)
526
- !referenceElement.contains(target) && // Check if the target is not inside the reference (input)
527
- !floatingElement.contains(target) // Check if the target is not inside the floating element (content)
528
- ) {
529
- setIsOpen(false);
530
- }
531
- };
532
- document.addEventListener("click", close);
533
- return () => document.removeEventListener("click", close);
534
- }, [refs.floating, refs.reference]);
535
- // update when selection changes
536
- (0, react_2.useEffect)(() => {
537
- update();
538
- }, [selectedItems]);
539
- const referenceEl = (_b = refs === null || refs === void 0 ? void 0 : refs.reference) === null || _b === void 0 ? void 0 : _b.current;
540
- 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%";
541
- const scrollEl = scrollContainerRef === null || scrollContainerRef === void 0 ? void 0 : scrollContainerRef.current;
542
- const scrollActive = scrollEl
543
- ? (scrollEl === null || scrollEl === void 0 ? void 0 : scrollEl.scrollHeight) > (scrollEl === null || scrollEl === void 0 ? void 0 : scrollEl.clientHeight)
544
- : false;
545
- return ((0, jsx_runtime_1.jsxs)("div", { className: className + " mfTagBox", children: [label && ((0, jsx_runtime_1.jsx)(__1.FieldLabel, { error: error, asterisk: required, size: size, description: description, children: label })), (0, jsx_runtime_1.jsxs)(StyledInputContainer, { className: "styledInputContainer", ref: refs.setReference, onMouseDown: () => {
546
- setIsOpen(true);
547
- handleFocus();
548
- }, onFocus: handleFocus, size: size, variant: variant, onKeyDown: handleKeyDown, "data-open": isOpen, children: [(0, jsx_runtime_1.jsx)(StyledInnerContainer, { size: size, "data-button-right": arrow || clearable, children: (0, jsx_runtime_1.jsxs)(PillContainer, { size: size, children: [selectedItems.map((item, index) => ((0, jsx_runtime_1.jsx)(__1.Pill, { size: "xs", onRemove: () => handleRemoveItem(item, index), 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))), (searchable ||
549
- allowCustomValue ||
550
- selectedItems.length === 0) && ((0, jsx_runtime_1.jsx)(StyledInput, { inputRef: inputRef, onChange: (e) => {
551
- if (searchFn !== undefined) {
552
- searchFn === null || searchFn === void 0 ? void 0 : searchFn(e.target.value);
553
- }
554
- else {
555
- setSearchValue(e.target.value);
556
- }
557
- update();
558
- }, placeholder: placeholder, size: size, readOnly: !(searchable || allowCustomValue) }))] }) }), clearable &&
559
- (selectedItems.length > 0 || !!((_f = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _f === void 0 ? void 0 : _f.value)) ? ((0, jsx_runtime_1.jsx)(core_1.ClearButton, { onClick: handleClear })) : arrow ? ((0, jsx_runtime_1.jsx)(core_1.ArrowButton, { onClick: (e) => {
560
- e.preventDefault();
561
- }, onMouseDown: (e) => {
562
- e.preventDefault();
563
- e.stopPropagation();
564
- toggleOpen();
565
- } })) : null] }), isOpen && ((0, jsx_runtime_1.jsx)(core_1.StyledFloatContainer, { ref: refs.setFloating, style: floatingStyles, className: "mfFloating", children: (0, jsx_runtime_1.jsx)(ExtendedStyledContent, { className: "mfFloatingContent", style: { width: contentWidth, maxWidth: contentWidth }, variant: variant, onScroll: onScroll, "data-scroll-active": scrollActive, "data-empty": filteredItems.length === 0, children: !loading && grouped
566
- ? groups.map((group) => ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)(GroupTitle, { size: size, children: group.label }), group.items.map((item, index) => {
567
- 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) => {
568
- e.preventDefault();
569
- e.stopPropagation();
570
- handleItemClick(item);
571
- }, "data-highlighted": isObjectArray
572
- ? (preSelected === null || preSelected === void 0 ? void 0 : preSelected.value) ===
573
- item.value
574
- : preSelected === 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));
575
- })] }, group.label)))
576
- : filteredItems.map((item, index) => {
577
- 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) => {
578
- e.preventDefault();
579
- e.stopPropagation();
580
- handleItemClick(item);
581
- }, "data-highlighted": isObjectArray
582
- ? (preSelected === null || preSelected === void 0 ? void 0 : preSelected.value) ===
583
- item.value
584
- : preSelected === 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));
585
- }) }) }))] }));
586
- }) `
587
- position: relative;
588
- cursor: pointer;
589
- `;
590
- exports.default = TagBox;
@@ -1,11 +0,0 @@
1
- export declare const TagBoxContainer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
2
- export declare const TagBoxInner: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
3
- export declare const TagsContainer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
4
- export declare const TagBoxInput: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, never>> & string;
5
- export declare const Tag: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
6
- export declare const TagText: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
7
- export declare const TagKillButton: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<Omit<Omit<import("lucide-react").LucideProps, "ref"> & import("react").RefAttributes<SVGSVGElement>, "ref"> & {
8
- ref?: ((instance: SVGSVGElement | null) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import("react").RefObject<SVGSVGElement> | null | undefined;
9
- }, never>> & string & Omit<import("react").ForwardRefExoticComponent<Omit<import("lucide-react").LucideProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>, keyof import("react").Component<any, {}, any>>;
10
- export declare const TagBoxOptions: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
11
- export declare const TagBoxOption: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;