@monolith-forensics/monolith-ui 1.1.27 → 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 -1
  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 -90
  87. package/dist/Table/Table.js +0 -714
  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,509 +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
- const jsx_runtime_1 = require("react/jsx-runtime");
7
- const moment_1 = __importDefault(require("moment"));
8
- const react_1 = require("@floating-ui/react");
9
- const react_2 = require("react");
10
- const styled_components_1 = __importDefault(require("styled-components"));
11
- const __1 = require("..");
12
- const core_1 = require("../core");
13
- const StyledInputContainer = styled_components_1.default.div `
14
- position: relative;
15
-
16
- caret-color: transparent;
17
- user-select: none;
18
-
19
- display: flex;
20
- flex-direction: row;
21
- align-items: center;
22
- user-select: none;
23
-
24
- pointer-events: all;
25
- outline: none;
26
-
27
- border-radius: 5px;
28
- transition: border 0.1s ease-in-out;
29
- border: 1px solid
30
- ${({ theme, variant }) => {
31
- switch (variant) {
32
- case "filled":
33
- return "transparent";
34
- case "outlined":
35
- return theme.palette.input.border;
36
- case "text":
37
- return "transparent";
38
- default:
39
- return theme.palette.input.border;
40
- }
41
- }};
42
-
43
- font-family: ${({ theme }) => theme.typography.fontFamily};
44
-
45
- color: ${(props) => props.theme.palette.text.primary};
46
- font-size: ${({ size }) => size === "xs"
47
- ? "11px"
48
- : size === "sm"
49
- ? "13px"
50
- : size === "md"
51
- ? "15px"
52
- : size === "lg"
53
- ? "17px"
54
- : size === "xl"
55
- ? "19px"
56
- : "11px"};
57
-
58
- width: 100%;
59
- height: ${({ size }) => size === "xs"
60
- ? "26px"
61
- : size === "sm"
62
- ? "30px"
63
- : size === "md"
64
- ? "36px"
65
- : size === "lg"
66
- ? "42px"
67
- : size === "xl"
68
- ? "50px"
69
- : "26px"};
70
-
71
- padding: ${({ size }) => size === "xs"
72
- ? "0px 8px"
73
- : size === "sm"
74
- ? "0px 10px"
75
- : size === "md"
76
- ? "0px 12px"
77
- : size === "lg"
78
- ? "0px 14px"
79
- : size === "xl"
80
- ? "0px 16px"
81
- : "0px 8px"};
82
-
83
- &[data-button-right="true"] {
84
- padding-right: 36px;
85
- }
86
-
87
- background-color: ${({ theme, variant }) => {
88
- switch (variant) {
89
- case "filled":
90
- return theme.palette.input.background;
91
- case "outlined":
92
- return theme.palette.input.background;
93
- case "text":
94
- return "transparent";
95
- default:
96
- return theme.palette.input.background;
97
- }
98
- }};
99
-
100
- &[readOnly] {
101
- cursor: pointer;
102
- }
103
-
104
- & [data-has-space="true"] {
105
- padding-left: 4px;
106
- }
107
-
108
- & [data-selected="true"] {
109
- background-color: ${(props) => props.theme.palette.primary.main}50;
110
- }
111
-
112
- &[data-empty="true"] {
113
- color: ${(props) => props.theme.palette.input.placeholder};
114
- div {
115
- color: ${(props) => props.theme.palette.input.placeholder};
116
- }
117
- }
118
-
119
- & [data-default-btn="true"] {
120
- color: ${(props) => props.theme.palette.text.secondary};
121
- div {
122
- color: ${(props) => props.theme.palette.text.secondary};
123
- }
124
- }
125
-
126
- &:focus {
127
- border: 1px solid ${(props) => props.theme.palette.primary.main};
128
- }
129
- `;
130
- const InputSegment = styled_components_1.default.div `
131
- user-select: none;
132
- display: flex;
133
- flex-direction: row;
134
- align-items: center;
135
- pointer-events: all;
136
- outline: none;
137
- border: none;
138
- padding: 0;
139
-
140
- height: ${({ size }) => size === "xs"
141
- ? "22px"
142
- : size === "sm"
143
- ? "26px"
144
- : size === "md"
145
- ? "32px"
146
- : size === "lg"
147
- ? "38px"
148
- : size === "xl"
149
- ? "46px"
150
- : "22px"};
151
-
152
- height: 100%;
153
-
154
- background-color: transparent;
155
- color: ${(props) => props.theme.palette.text.primary};
156
-
157
- ::placeholder {
158
- font-size: ${({ size }) => size === "xs"
159
- ? "10px"
160
- : size === "sm"
161
- ? "12px"
162
- : size === "md"
163
- ? "14px"
164
- : size === "lg"
165
- ? "16px"
166
- : size === "xl"
167
- ? "18px"
168
- : "10px"};
169
- }
170
- `;
171
- function parseTimestamp(timestamp, format, utc = false) {
172
- // Define patterns to identify datetime components and their placeholders
173
- const patterns = [
174
- { pattern: "YYYY", placeholder: "YYYY", type: "year", momentType: "year" },
175
- { pattern: "MM", placeholder: "MM", type: "month", momentType: "month" },
176
- { pattern: "DD", placeholder: "DD", type: "day", momentType: "date" },
177
- { pattern: "HH", placeholder: "HH", type: "hour", momentType: "hour" },
178
- { pattern: "h", placeholder: "h", type: "hour", momentType: "hour" },
179
- { pattern: "mm", placeholder: "mm", type: "minute", momentType: "minute" },
180
- { pattern: "ss", placeholder: "ss", type: "second", momentType: "second" },
181
- {
182
- pattern: "SSS",
183
- placeholder: "SSS",
184
- type: "millisecond",
185
- momentType: "millisecond",
186
- },
187
- {
188
- pattern: "A",
189
- placeholder: "AM/PM",
190
- type: "meridiem",
191
- momentType: "meridiem",
192
- },
193
- {
194
- pattern: "Z",
195
- placeholder: "Z",
196
- type: "timezone",
197
- momentType: "timezone",
198
- },
199
- ];
200
- // Helper function to split format into datetime components and separators
201
- function splitFormat(format) {
202
- return format.split(/(YYYY|MM|DD|HH|h|mm|ss|SSS|Z)/).filter((s) => s);
203
- }
204
- // Helper function to match segments to their placeholders and types
205
- function matchSegment(segment) {
206
- const pattern = patterns.find((p) => p.pattern === segment);
207
- return pattern
208
- ? pattern
209
- : {
210
- pattern: segment,
211
- placeholder: segment,
212
- type: "separator",
213
- value: "",
214
- text: "",
215
- index: -1,
216
- };
217
- }
218
- const segments = splitFormat(format).map((segment, i) => {
219
- const { pattern, placeholder, type, momentType } = matchSegment(segment);
220
- const value = timestamp
221
- ? utc === true
222
- ? moment_1.default.utc(timestamp).format(pattern)
223
- : (0, moment_1.default)(timestamp).format(pattern)
224
- : placeholder;
225
- return {
226
- value,
227
- text: value,
228
- placeholder,
229
- type,
230
- momentType,
231
- index: i,
232
- };
233
- });
234
- return segments;
235
- }
236
- const DateInput = (0, styled_components_1.default)(({ className, defaultValue, format = "YYYY-MM-DD HH:mm:ss", label, description, arrow = true, size = "sm", variant = "outlined", clearable = false, required = false, onChange = () => { }, min, max, error, enableCalendar = false, utc = false, closeOnSelect = true, }) => {
237
- const [value, setValue] = (0, react_2.useState)(defaultValue);
238
- const [selectedSegment, setSelectedSegment] = (0, react_2.useState)();
239
- const [isOpen, setIsOpen] = (0, react_2.useState)(false);
240
- // Check if format is date only and does not include time
241
- const isDateOnly = format.match(/(HH|h|mm|ss|SSS|A|Z)/) === null;
242
- const mainRef = (0, react_2.useRef)(null);
243
- const typedKeys = (0, react_2.useRef)("");
244
- const { refs, floatingStyles } = (0, react_1.useFloating)({
245
- open: isOpen,
246
- onOpenChange: setIsOpen,
247
- placement: "bottom-start",
248
- strategy: "absolute",
249
- // Handle collisions with the viewport
250
- middleware: [(0, react_1.flip)(), (0, react_1.offset)(5)],
251
- });
252
- const segments = (0, react_2.useMemo)(() => parseTimestamp((0, moment_1.default)(value).toISOString(), format, utc), [value, format, utc]);
253
- const checkValidRange = (value) => {
254
- if (min && (0, moment_1.default)(value).isBefore(min))
255
- return false;
256
- if (max && (0, moment_1.default)(value).isAfter(max))
257
- return false;
258
- return true;
259
- };
260
- const toggleOpen = () => {
261
- setIsOpen((prev) => {
262
- return !prev;
263
- });
264
- };
265
- const handleClear = (e) => {
266
- e.preventDefault();
267
- e.stopPropagation();
268
- setValue(null);
269
- onChange === null || onChange === void 0 ? void 0 : onChange(null);
270
- setIsOpen(false);
271
- };
272
- const handleSegmentClick = (e, segment) => {
273
- e.stopPropagation();
274
- e.preventDefault();
275
- if (segment.type === "separator")
276
- return;
277
- if (mainRef === null || mainRef === void 0 ? void 0 : mainRef.current) {
278
- const input = mainRef.current.querySelector("div[data-type='input']");
279
- if (input) {
280
- input.focus();
281
- }
282
- }
283
- setSelectedSegment(segment);
284
- };
285
- const handleContainerClick = (e) => {
286
- e.stopPropagation();
287
- e.preventDefault();
288
- if (mainRef === null || mainRef === void 0 ? void 0 : mainRef.current) {
289
- const input = mainRef.current.querySelector("div[data-type='input']");
290
- if (input) {
291
- input.focus();
292
- }
293
- }
294
- toggleOpen();
295
- setIsOpen(true);
296
- setSelectedSegment(segments[0]);
297
- };
298
- const nextSegment = () => {
299
- setSelectedSegment((prev) => {
300
- if (!prev)
301
- return segments[0];
302
- const next = segments[prev.index + 2];
303
- return next || prev;
304
- });
305
- };
306
- // prevent click and drag selection
307
- const handleMouseDown = (e) => {
308
- e.preventDefault();
309
- };
310
- const handleKeyDown = (e) => {
311
- if (!selectedSegment)
312
- return;
313
- // tab
314
- if (e.key === "Tab") {
315
- setSelectedSegment(null);
316
- setIsOpen(false);
317
- return;
318
- }
319
- // Right Arrow
320
- if (e.key === "ArrowRight") {
321
- e.preventDefault();
322
- setSelectedSegment((prev) => {
323
- if (!prev)
324
- return segments[0];
325
- const next = segments[prev.index + 2];
326
- return next || prev;
327
- });
328
- }
329
- // Left Arrow
330
- if (e.key === "ArrowLeft") {
331
- e.preventDefault();
332
- setSelectedSegment((prev) => {
333
- if (!prev)
334
- return segments[0];
335
- const next = segments[prev.index - 2];
336
- return next || prev;
337
- });
338
- }
339
- // Up Arrow
340
- if (e.key === "ArrowUp") {
341
- e.preventDefault();
342
- setValue((prev) => {
343
- if (selectedSegment.type === "separator")
344
- return prev;
345
- let newValue = prev
346
- ? (0, moment_1.default)(prev).add(1, selectedSegment.type).toISOString()
347
- : (0, moment_1.default)().toISOString();
348
- if (!checkValidRange(newValue))
349
- return prev;
350
- if (isDateOnly) {
351
- newValue = (0, moment_1.default)(newValue).format("YYYY-MM-DD");
352
- }
353
- onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
354
- return newValue;
355
- });
356
- }
357
- // Down Arrow
358
- if (e.key === "ArrowDown") {
359
- e.preventDefault();
360
- setValue((prev) => {
361
- if (selectedSegment.type === "separator")
362
- return prev;
363
- let newValue = prev
364
- ? (0, moment_1.default)(prev).subtract(1, selectedSegment.type).toISOString()
365
- : (0, moment_1.default)().toISOString();
366
- if (!checkValidRange(newValue))
367
- return prev;
368
- if (isDateOnly) {
369
- newValue = (0, moment_1.default)(newValue).format("YYYY-MM-DD");
370
- }
371
- onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
372
- return newValue;
373
- });
374
- }
375
- // handle paste
376
- if (e.key === "v" && (e.metaKey || e.ctrlKey)) {
377
- return;
378
- }
379
- // only allow numbers
380
- if (e.key.match(/[0-9]/)) {
381
- e.preventDefault();
382
- const segmentLength = selectedSegment.text.length;
383
- typedKeys.current += e.key;
384
- let tempValue = typedKeys.current;
385
- if (["month", "day"].includes(selectedSegment.type) &&
386
- Array.from(tempValue).every((c) => c === "0")) {
387
- tempValue = "01";
388
- }
389
- setValue((prev) => {
390
- if (!(selectedSegment === null || selectedSegment === void 0 ? void 0 : selectedSegment.momentType))
391
- return prev;
392
- const newValue = (0, moment_1.default)(prev)
393
- .set(selectedSegment.momentType, parseInt(tempValue, 10) -
394
- (selectedSegment.type === "month" ? 1 : 0))
395
- .toISOString();
396
- if (!checkValidRange(newValue))
397
- return prev;
398
- onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
399
- return newValue;
400
- });
401
- if (typedKeys.current.length === segmentLength) {
402
- nextSegment();
403
- typedKeys.current = "";
404
- }
405
- }
406
- e.preventDefault();
407
- };
408
- const handleWheelEvent = (e) => {
409
- if (!selectedSegment)
410
- return;
411
- if (e.deltaY > 0) {
412
- setValue((prev) => {
413
- if (selectedSegment.type === "separator")
414
- return prev;
415
- const newValue = prev
416
- ? (0, moment_1.default)(prev).subtract(1, selectedSegment.type).toISOString()
417
- : (0, moment_1.default)().toISOString();
418
- if (!checkValidRange(newValue))
419
- return prev;
420
- onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
421
- return newValue;
422
- });
423
- }
424
- else {
425
- setValue((prev) => {
426
- if (selectedSegment.type === "separator")
427
- return prev;
428
- const newValue = prev
429
- ? (0, moment_1.default)(prev).add(1, selectedSegment.type).toISOString()
430
- : (0, moment_1.default)().toISOString();
431
- if (!checkValidRange(newValue))
432
- return prev;
433
- onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
434
- return newValue;
435
- });
436
- }
437
- };
438
- const handlePaste = (e) => {
439
- var _a, _b;
440
- e.preventDefault();
441
- const pastedText = (_b = (_a = e === null || e === void 0 ? void 0 : e.clipboardData) === null || _a === void 0 ? void 0 : _a.getData) === null || _b === void 0 ? void 0 : _b.call(_a, "text");
442
- if (!pastedText)
443
- return;
444
- // check if pasted text is a valid timestamp
445
- if (!(0, moment_1.default)(pastedText).isValid())
446
- return;
447
- const parsedTimestamp = moment_1.default.utc(pastedText).toISOString();
448
- setValue(parsedTimestamp);
449
- };
450
- // Close on outside click
451
- (0, react_2.useEffect)(() => {
452
- const close = (e) => {
453
- var _a, _b;
454
- const target = e.target;
455
- const referenceElement = (_a = refs === null || refs === void 0 ? void 0 : refs.reference) === null || _a === void 0 ? void 0 : _a.current;
456
- const floatingElement = (_b = refs === null || refs === void 0 ? void 0 : refs.floating) === null || _b === void 0 ? void 0 : _b.current;
457
- if (floatingElement && // Check if the floating element exists
458
- e.target !== referenceElement && // Check if the target is not the reference (input)
459
- !referenceElement.contains(target) && // Check if the target is not inside the reference (input)
460
- !floatingElement.contains(target) // Check if the target is not inside the floating element (content)
461
- ) {
462
- setIsOpen(false);
463
- }
464
- setSelectedSegment(null); // clear selected segment when clicked outside component
465
- };
466
- document.addEventListener("click", close);
467
- return () => document.removeEventListener("click", close);
468
- }, [refs.floating]);
469
- // Global Wheel Event when segement selected
470
- (0, react_2.useEffect)(() => {
471
- if (selectedSegment) {
472
- document.addEventListener("wheel", handleWheelEvent);
473
- }
474
- return () => {
475
- document.removeEventListener("wheel", handleWheelEvent);
476
- };
477
- }, [selectedSegment]);
478
- 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)(StyledInputContainer, { ref: (ref) => {
479
- mainRef.current = ref;
480
- refs.setReference(ref);
481
- }, onClick: handleContainerClick, onMouseDown: handleMouseDown, onKeyDown: handleKeyDown, onPaste: handlePaste, onFocus: (e) => {
482
- e.preventDefault();
483
- setSelectedSegment(segments[0]);
484
- }, "data-empty": !value, role: "textbox", size: size, variant: variant, "data-button-right": arrow || clearable, children: [segments.map((segment, i) => {
485
- if (segment.type === "separator") {
486
- return ((0, jsx_runtime_1.jsx)("div", { className: "separator", tabIndex: -1, onClick: (e) => {
487
- e.preventDefault();
488
- e.stopPropagation();
489
- }, onFocus: (e) => e.preventDefault(), onPointerDown: (e) => e.preventDefault(), "data-type": "separator", "data-identifier": segment.type, "data-has-space": segment.text.includes(" "), "data-placeholder": segment.placeholder, "data-value": segment.value, children: segment.text }, i));
490
- }
491
- return ((0, jsx_runtime_1.jsx)(InputSegment, { className: "input", contentEditable: true, suppressContentEditableWarning: true, tabIndex: i === 0 ? 0 : -1, onClick: (e) => handleSegmentClick(e, segment), "data-type": "input", size: size, "data-identifier": segment.type, "data-has-space": segment.text.includes(" "), "data-placeholder": segment.placeholder, "data-value": segment.value, "data-selected": (selectedSegment === null || selectedSegment === void 0 ? void 0 : selectedSegment.index) === segment.index, children: value ? segment.text : segment.placeholder }, i));
492
- }), utc && (0, jsx_runtime_1.jsx)("div", { style: { marginLeft: 5 }, children: "UTC" }), clearable && value ? ((0, jsx_runtime_1.jsx)(core_1.ClearButton, { onClick: handleClear })) : arrow ? ((0, jsx_runtime_1.jsx)(core_1.ArrowButton, {})) : null] }), enableCalendar && isOpen && ((0, jsx_runtime_1.jsx)(react_1.FloatingPortal, { preserveTabOrder: true, children: (0, jsx_runtime_1.jsx)(core_1.StyledFloatContainer, { ref: refs.setFloating, style: floatingStyles, children: (0, jsx_runtime_1.jsx)(core_1.StyledContent, { maxDropdownHeight: "fit-content", children: (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(__1.Calendar, { defaultValue: value ? (0, moment_1.default)(value).toDate() : undefined, clearable: false, min: min, max: max, onChange: (date) => {
493
- setValue((prev) => {
494
- // make copy of prev variable
495
- const oldValue = (0, moment_1.default)(prev).toISOString();
496
- const result = `${(0, moment_1.default)(date).format("YYYY-MM-DD")}T${(0, moment_1.default)(prev || undefined).format("HH:mm:ss")}`;
497
- let isoResult = (0, moment_1.default)(result).toISOString();
498
- if (!checkValidRange(result))
499
- return oldValue;
500
- if (isDateOnly) {
501
- isoResult = (0, moment_1.default)(result).format("YYYY-MM-DD");
502
- }
503
- onChange === null || onChange === void 0 ? void 0 : onChange(isoResult);
504
- setIsOpen(closeOnSelect ? false : true);
505
- return isoResult;
506
- });
507
- }, includeTime: false }, 1) }) }) }) }))] }));
508
- }) ``;
509
- exports.default = DateInput;
@@ -1 +0,0 @@
1
- export { default } from "./DateInput";
@@ -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 DateInput_1 = require("./DateInput");
8
- Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(DateInput_1).default; } });
@@ -1,36 +0,0 @@
1
- import { ComponentPropsWithoutRef, ComponentType, ReactNode, UIEvent } from "react";
2
- import { ButtonProps } from "../Button";
3
- import { Size, Variant } from "../core";
4
- interface StyledContentProps {
5
- maxDropdownHeight?: number | string;
6
- variant?: Variant;
7
- }
8
- declare const StyledContent: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, StyledContentProps>> & string;
9
- interface DropDownItem {
10
- toLowerCase?: () => string;
11
- label: string;
12
- value: string;
13
- data?: any;
14
- }
15
- interface DropDownMenuProps {
16
- className?: string;
17
- children?: ReactNode;
18
- data?: DropDownItem[];
19
- variant?: Variant;
20
- defaultValue?: DropDownItem[];
21
- multiselect?: boolean;
22
- size?: Size;
23
- title?: string;
24
- TooltipContent?: ComponentType<any>;
25
- renderOption?: (item: DropDownItem) => ReactNode;
26
- onChange?: (selected: DropDownItem[], diff: DropDownItem[]) => void;
27
- onItemSelect?: (item: DropDownItem) => void;
28
- onScroll?: (e: UIEvent<HTMLDivElement>) => void;
29
- loading?: boolean;
30
- arrow?: boolean;
31
- searchable?: boolean;
32
- dropDownProps?: ComponentPropsWithoutRef<typeof StyledContent>;
33
- buttonProps?: ButtonProps;
34
- }
35
- declare const DropDownMenu: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<DropDownMenuProps, never>> & string & Omit<({ className, children, data, variant, defaultValue, multiselect, size, TooltipContent, renderOption, onChange, onItemSelect, onScroll, loading, arrow, searchable, dropDownProps, buttonProps, }: DropDownMenuProps) => import("react/jsx-runtime").JSX.Element, keyof import("react").Component<any, {}, any>>;
36
- export default DropDownMenu;