@monolith-forensics/monolith-ui 1.1.55 → 1.1.56
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import moment from "moment";
|
|
3
|
-
import { useFloating, flip, offset, FloatingPortal } from "@floating-ui/react";
|
|
3
|
+
import { useFloating, flip, offset, FloatingPortal, useDismiss, useInteractions, autoUpdate } from "@floating-ui/react";
|
|
4
4
|
import { useEffect, useMemo, useRef, useState, } from "react";
|
|
5
5
|
import styled from "styled-components";
|
|
6
6
|
import { FieldLabel, Calendar } from "..";
|
|
@@ -236,14 +236,19 @@ const DateInput = styled(({ className, defaultValue, format = "YYYY-MM-DD HH:mm:
|
|
|
236
236
|
const isDateOnly = format.match(/(HH|h|mm|ss|SSS|A|Z)/) === null;
|
|
237
237
|
const mainRef = useRef(null);
|
|
238
238
|
const typedKeys = useRef("");
|
|
239
|
-
const { refs, floatingStyles } = useFloating({
|
|
239
|
+
const { refs, floatingStyles, context } = useFloating({
|
|
240
240
|
open: isOpen,
|
|
241
241
|
onOpenChange: setIsOpen,
|
|
242
242
|
placement: "bottom-start",
|
|
243
243
|
strategy: "absolute",
|
|
244
244
|
// Handle collisions with the viewport
|
|
245
245
|
middleware: [flip(), offset(5)],
|
|
246
|
+
whileElementsMounted: autoUpdate,
|
|
246
247
|
});
|
|
248
|
+
const dismiss = useDismiss(context);
|
|
249
|
+
const { getReferenceProps } = useInteractions([
|
|
250
|
+
dismiss,
|
|
251
|
+
]);
|
|
247
252
|
const segments = useMemo(() => parseTimestamp(moment(value).toISOString(), format, utc), [value, format, utc]);
|
|
248
253
|
const checkValidRange = (value) => {
|
|
249
254
|
if (min && moment(value).isBefore(min))
|
|
@@ -252,11 +257,6 @@ const DateInput = styled(({ className, defaultValue, format = "YYYY-MM-DD HH:mm:
|
|
|
252
257
|
return false;
|
|
253
258
|
return true;
|
|
254
259
|
};
|
|
255
|
-
const toggleOpen = () => {
|
|
256
|
-
setIsOpen((prev) => {
|
|
257
|
-
return !prev;
|
|
258
|
-
});
|
|
259
|
-
};
|
|
260
260
|
const handleClear = (e) => {
|
|
261
261
|
e.preventDefault();
|
|
262
262
|
e.stopPropagation();
|
|
@@ -286,7 +286,6 @@ const DateInput = styled(({ className, defaultValue, format = "YYYY-MM-DD HH:mm:
|
|
|
286
286
|
input.focus();
|
|
287
287
|
}
|
|
288
288
|
}
|
|
289
|
-
toggleOpen();
|
|
290
289
|
setIsOpen(true);
|
|
291
290
|
setSelectedSegment(segments[0]);
|
|
292
291
|
};
|
|
@@ -403,32 +402,18 @@ const DateInput = styled(({ className, defaultValue, format = "YYYY-MM-DD HH:mm:
|
|
|
403
402
|
const handleWheelEvent = (e) => {
|
|
404
403
|
if (!selectedSegment)
|
|
405
404
|
return;
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
}
|
|
419
|
-
else {
|
|
420
|
-
setValue((prev) => {
|
|
421
|
-
if (selectedSegment.type === "separator")
|
|
422
|
-
return prev;
|
|
423
|
-
const newValue = prev
|
|
424
|
-
? moment(prev).add(1, selectedSegment.type).toISOString()
|
|
425
|
-
: moment().toISOString();
|
|
426
|
-
if (!checkValidRange(newValue))
|
|
427
|
-
return prev;
|
|
428
|
-
onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
|
|
429
|
-
return newValue;
|
|
430
|
-
});
|
|
431
|
-
}
|
|
405
|
+
setValue((prev) => {
|
|
406
|
+
if (selectedSegment.type === "separator")
|
|
407
|
+
return prev;
|
|
408
|
+
if (!prev)
|
|
409
|
+
return isDateOnly ? moment().format(format) : moment().toISOString();
|
|
410
|
+
let newValue = e.deltaY > 0 ? moment(prev).subtract(1, selectedSegment.type).toISOString() : moment(prev).add(1, selectedSegment.type).toISOString();
|
|
411
|
+
if (!checkValidRange(newValue))
|
|
412
|
+
return prev;
|
|
413
|
+
newValue = isDateOnly ? moment(newValue).format(format) : newValue;
|
|
414
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
|
|
415
|
+
return newValue;
|
|
416
|
+
});
|
|
432
417
|
};
|
|
433
418
|
const handlePaste = (e) => {
|
|
434
419
|
var _a, _b;
|
|
@@ -476,6 +461,8 @@ const DateInput = styled(({ className, defaultValue, format = "YYYY-MM-DD HH:mm:
|
|
|
476
461
|
}, onClick: handleContainerClick, onMouseDown: handleMouseDown, onKeyDown: handleKeyDown, onPaste: handlePaste, onFocus: (e) => {
|
|
477
462
|
e.preventDefault();
|
|
478
463
|
setSelectedSegment(segments[0]);
|
|
464
|
+
}, onBlur: () => {
|
|
465
|
+
setSelectedSegment(null);
|
|
479
466
|
}, "data-empty": !value, role: "textbox", size: size, variant: variant, "data-button-right": arrow || clearable, children: [segments.map((segment, i) => {
|
|
480
467
|
if (segment.type === "separator") {
|
|
481
468
|
return (_jsx("div", { className: "separator", tabIndex: -1, onClick: (e) => {
|
|
@@ -483,8 +470,8 @@ const DateInput = styled(({ className, defaultValue, format = "YYYY-MM-DD HH:mm:
|
|
|
483
470
|
e.stopPropagation();
|
|
484
471
|
}, 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));
|
|
485
472
|
}
|
|
486
|
-
return (_jsx(InputSegment, { className: "input",
|
|
487
|
-
}), utc && _jsx("div", { style: { marginLeft: 5 }, children: "UTC" }), clearable && value ? (_jsx(ClearButton, { onClick: handleClear })) : arrow ? (_jsx(ArrowButton, {})) : null] }), enableCalendar && isOpen && (_jsx(FloatingPortal, { preserveTabOrder: true, children: _jsx(StyledFloatContainer, { ref: refs.setFloating, style: floatingStyles, children: _jsx(StyledContent, { maxDropdownHeight: "fit-content", children: _jsx("div", { children: _jsx(Calendar, { defaultValue: value ? moment(value).toDate() : undefined, clearable: false, min: min, max: max, onChange: (date) => {
|
|
473
|
+
return (_jsx(InputSegment, { className: "input", 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));
|
|
474
|
+
}), utc && _jsx("div", { style: { marginLeft: 5 }, children: "UTC" }), clearable && value ? (_jsx(ClearButton, { onClick: handleClear })) : arrow ? (_jsx(ArrowButton, {})) : null] }), enableCalendar && isOpen && (_jsx(FloatingPortal, { preserveTabOrder: true, children: _jsx(StyledFloatContainer, Object.assign({ ref: refs.setFloating, style: floatingStyles }, getReferenceProps(), { children: _jsx(StyledContent, { maxDropdownHeight: "fit-content", children: _jsx("div", { children: _jsx(Calendar, { defaultValue: value ? moment(value).toDate() : undefined, clearable: false, min: min, max: max, onChange: (date) => {
|
|
488
475
|
setValue((prev) => {
|
|
489
476
|
// make copy of prev variable
|
|
490
477
|
const oldValue = moment(prev).toISOString();
|
|
@@ -499,6 +486,6 @@ const DateInput = styled(({ className, defaultValue, format = "YYYY-MM-DD HH:mm:
|
|
|
499
486
|
setIsOpen(closeOnSelect ? false : true);
|
|
500
487
|
return isoResult;
|
|
501
488
|
});
|
|
502
|
-
}, includeTime: false }, 1) }) }) }) }))] }));
|
|
489
|
+
}, includeTime: false }, 1) }) }) })) }))] }));
|
|
503
490
|
}) ``;
|
|
504
491
|
export default DateInput;
|
|
@@ -11,7 +11,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
13
13
|
import styled from "styled-components";
|
|
14
|
-
import { useFloating, flip, offset, FloatingPortal, } from "@floating-ui/react";
|
|
14
|
+
import { useFloating, flip, offset, FloatingPortal, autoUpdate, } from "@floating-ui/react";
|
|
15
15
|
import { useCallback, useEffect, useRef, useState, } from "react";
|
|
16
16
|
import { Input, FieldLabel, Tooltip } from "..";
|
|
17
17
|
import { useDebouncedCallback } from "use-debounce";
|
|
@@ -206,6 +206,7 @@ const SelectBox = styled(({ className, data = [], placeholder = "Select...", arr
|
|
|
206
206
|
strategy: "absolute",
|
|
207
207
|
// Handle collisions with the viewport
|
|
208
208
|
middleware: [flip(), offset(5)],
|
|
209
|
+
whileElementsMounted: autoUpdate,
|
|
209
210
|
});
|
|
210
211
|
const toggleOpen = () => {
|
|
211
212
|
setIsOpen((prev) => {
|
package/dist/TagBox/TagBox.js
CHANGED
|
@@ -11,7 +11,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
13
13
|
import styled from "styled-components";
|
|
14
|
-
import { useFloating, flip, offset } from "@floating-ui/react";
|
|
14
|
+
import { useFloating, flip, offset, autoUpdate } from "@floating-ui/react";
|
|
15
15
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
16
16
|
import { Input, Tooltip, FieldLabel, Pill } from "..";
|
|
17
17
|
import { ArrowButton, ClearButton, StyledFloatContainer, StyledContent, } from "../core";
|
|
@@ -344,6 +344,7 @@ const TagBox = styled(({ className, data = [], placeholder = "Select tags", arro
|
|
|
344
344
|
strategy: "absolute",
|
|
345
345
|
// Handle collisions with the viewport
|
|
346
346
|
middleware: [flip(), offset(5)],
|
|
347
|
+
whileElementsMounted: autoUpdate,
|
|
347
348
|
});
|
|
348
349
|
const toggleOpen = () => {
|
|
349
350
|
setIsOpen((prev) => {
|