@monolith-forensics/monolith-ui 1.8.1-dev.2 → 1.8.1-dev.4
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.
- package/dist/Calendar/Calendar.d.ts +4 -1
- package/dist/Calendar/Calendar.js +126 -50
- package/dist/Calendar/CalendarStyles.d.ts +3 -2
- package/dist/Calendar/CalendarStyles.js +62 -23
- package/dist/Calendar/calendarHelpers.d.ts +1 -1
- package/dist/CheckBox/CheckBox.js +35 -4
- package/dist/DropDownMenu/DropDownMenu.js +25 -15
- package/dist/DropDownMenu/components/MenuComponent.js +6 -1
- package/dist/DropDownMenu/components/MenuItem.js +6 -0
- package/dist/DropDownMenu/components/MenuItemList.d.ts +2 -0
- package/dist/DropDownMenu/components/MenuItemList.js +94 -13
- package/dist/DropDownMenu/components/StyledContent.js +1 -2
- package/dist/DropDownMenu/types.d.ts +1 -0
- package/dist/FileViewer/viewers/ImageViewer.js +75 -18
- package/dist/MonolithUIProvider/MonolithUIProvider.d.ts +1 -0
- package/dist/QueryFilter/QueryFilter.constants.d.ts +134 -0
- package/dist/QueryFilter/QueryFilter.constants.js +39 -0
- package/dist/QueryFilter/QueryFilter.d.ts +1 -1
- package/dist/QueryFilter/QueryFilter.js +3 -303
- package/dist/QueryFilter/QueryFilter.lib.d.ts +14 -0
- package/dist/QueryFilter/QueryFilter.lib.js +84 -0
- package/dist/QueryFilter/QueryFilter.styled.d.ts +89 -0
- package/dist/QueryFilter/QueryFilter.styled.js +184 -0
- package/dist/QueryFilter/{types.d.ts → QueryFilter.types.d.ts} +11 -2
- package/dist/QueryFilter/components/MultiSelectEditor.d.ts +7 -0
- package/dist/QueryFilter/components/MultiSelectEditor.js +44 -0
- package/dist/QueryFilter/components/RuleChip.d.ts +8 -0
- package/dist/QueryFilter/components/RuleChip.js +37 -0
- package/dist/QueryFilter/components/Rules.d.ts +11 -0
- package/dist/QueryFilter/components/Rules.js +41 -0
- package/dist/QueryFilter/components/UnavailableRuleChip.d.ts +5 -0
- package/dist/QueryFilter/components/UnavailableRuleChip.js +7 -0
- package/dist/QueryFilter/components/ValueEditor.d.ts +7 -0
- package/dist/QueryFilter/components/ValueEditor.js +45 -0
- package/dist/QueryFilter/components/ValueSelector.d.ts +7 -0
- package/dist/QueryFilter/components/ValueSelector.js +34 -0
- package/dist/QueryFilter/components/index.d.ts +6 -0
- package/dist/QueryFilter/components/index.js +6 -0
- package/dist/QueryFilter/index.d.ts +3 -2
- package/dist/QueryFilter/index.js +3 -2
- package/dist/QueryFilter/useQueryFilter.d.ts +1 -1
- package/dist/QueryFilter/useQueryFilter.js +23 -19
- package/dist/RichTextEditor/Extensions/getTiptapExtensions.js +5 -15
- package/dist/RichTextEditor/Plugins/ImageActionsPlugin.d.ts +3 -0
- package/dist/RichTextEditor/Plugins/ImageActionsPlugin.js +241 -0
- package/dist/RichTextEditor/Plugins/UploadImagesPlugin.d.ts +15 -0
- package/dist/RichTextEditor/Plugins/UploadImagesPlugin.js +115 -51
- package/dist/RichTextEditor/Plugins/index.d.ts +1 -0
- package/dist/RichTextEditor/Plugins/index.js +1 -0
- package/dist/RichTextEditor/RichTextEditor.d.ts +3 -2
- package/dist/RichTextEditor/RichTextEditor.js +309 -35
- package/dist/RichTextEditor/Toolbar/Toolbar.js +14 -2
- package/dist/SuperDatePicker/SuperDatePicker.constants.d.ts +24 -0
- package/dist/SuperDatePicker/SuperDatePicker.constants.js +30 -0
- package/dist/SuperDatePicker/SuperDatePicker.d.ts +3 -0
- package/dist/SuperDatePicker/SuperDatePicker.js +31 -0
- package/dist/SuperDatePicker/SuperDatePicker.lib.d.ts +17 -0
- package/dist/SuperDatePicker/SuperDatePicker.lib.js +206 -0
- package/dist/SuperDatePicker/SuperDatePicker.styled.d.ts +60 -0
- package/dist/SuperDatePicker/SuperDatePicker.styled.js +256 -0
- package/dist/SuperDatePicker/SuperDatePicker.types.d.ts +48 -0
- package/dist/SuperDatePicker/SuperDatePicker.types.js +1 -0
- package/dist/SuperDatePicker/components/CommonPresetGroups.d.ts +7 -0
- package/dist/SuperDatePicker/components/CommonPresetGroups.js +6 -0
- package/dist/SuperDatePicker/components/EndpointCalendarDropdown.d.ts +10 -0
- package/dist/SuperDatePicker/components/EndpointCalendarDropdown.js +9 -0
- package/dist/SuperDatePicker/components/EndpointDateInput.d.ts +16 -0
- package/dist/SuperDatePicker/components/EndpointDateInput.js +26 -0
- package/dist/SuperDatePicker/components/EndpointPopover.d.ts +18 -0
- package/dist/SuperDatePicker/components/EndpointPopover.js +11 -0
- package/dist/SuperDatePicker/components/QuickRangeDropdown.d.ts +14 -0
- package/dist/SuperDatePicker/components/QuickRangeDropdown.js +19 -0
- package/dist/SuperDatePicker/components/QuickRangePopover.d.ts +18 -0
- package/dist/SuperDatePicker/components/QuickRangePopover.js +12 -0
- package/dist/SuperDatePicker/components/index.d.ts +6 -0
- package/dist/SuperDatePicker/components/index.js +6 -0
- package/dist/SuperDatePicker/index.d.ts +3 -0
- package/dist/SuperDatePicker/index.js +3 -0
- package/dist/SuperDatePicker/useSuperDatePicker.d.ts +32 -0
- package/dist/SuperDatePicker/useSuperDatePicker.js +125 -0
- package/dist/Table/ColumnResizer.d.ts +6 -9
- package/dist/Table/ColumnResizer.js +30 -10
- package/dist/Table/TableComponents.js +14 -10
- package/dist/Table/TableHeader.js +31 -16
- package/dist/Table/TableMenu/TableMenu.js +1 -1
- package/dist/Table/TableProvider.js +91 -4
- package/dist/Table/TableRow.js +19 -12
- package/dist/Table/Utils/index.d.ts +0 -1
- package/dist/Table/Utils/index.js +0 -1
- package/dist/Table/types.d.ts +6 -19
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/theme/variants.js +2 -0
- package/package.json +22 -18
- package/dist/QueryFilter/DefaultOperators.d.ts +0 -76
- package/dist/QueryFilter/DefaultOperators.js +0 -21
- package/dist/Table/Utils/resizeHandler.d.ts +0 -3
- package/dist/Table/Utils/resizeHandler.js +0 -84
- /package/dist/QueryFilter/{types.js → QueryFilter.types.js} +0 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { SuperDatePickerProps } from "../SuperDatePicker.types";
|
|
2
|
+
type EndpointPopoverProps = {
|
|
3
|
+
opened: boolean;
|
|
4
|
+
disabled: boolean;
|
|
5
|
+
label: string;
|
|
6
|
+
value?: string | null;
|
|
7
|
+
onOpenChange: (opened: boolean) => void;
|
|
8
|
+
onInputChange: (value?: string | null) => void;
|
|
9
|
+
onCalendarChange: (date: Date | null) => void;
|
|
10
|
+
format: NonNullable<SuperDatePickerProps["format"]>;
|
|
11
|
+
size: NonNullable<SuperDatePickerProps["size"]>;
|
|
12
|
+
utc: boolean;
|
|
13
|
+
min?: Date;
|
|
14
|
+
max?: Date;
|
|
15
|
+
timeIntervalMinutes?: number;
|
|
16
|
+
};
|
|
17
|
+
declare const EndpointPopover: ({ opened, disabled, label, value, onOpenChange, onInputChange, onCalendarChange, format, size, utc, min, max, timeIntervalMinutes, }: EndpointPopoverProps) => import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
export default EndpointPopover;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Popover } from "../../Popover";
|
|
3
|
+
import EndpointCalendarDropdown from "./EndpointCalendarDropdown";
|
|
4
|
+
import EndpointDateInput from "./EndpointDateInput";
|
|
5
|
+
const EndpointPopover = ({ opened, disabled, label, value, onOpenChange, onInputChange, onCalendarChange, format, size, utc, min, max, timeIntervalMinutes, }) => {
|
|
6
|
+
return (_jsxs(Popover, { opened: opened, onChange: (nextOpened) => onOpenChange(!disabled && nextOpened), position: "bottom-start", offset: 5, withinPortal: true, children: [_jsx(Popover.Target, { children: _jsx(EndpointDateInput, { active: opened, ariaLabel: label, value: value, onChange: onInputChange, onOpen: () => onOpenChange(true), format: format, size: size, disabled: disabled, utc: utc, min: min, max: max }) }), _jsx(Popover.Dropdown, { style: {
|
|
7
|
+
border: "none",
|
|
8
|
+
padding: 0,
|
|
9
|
+
}, children: _jsx(EndpointCalendarDropdown, { value: value, onChange: onCalendarChange, min: min, max: max, timeIntervalMinutes: timeIntervalMinutes, utc: utc }) })] }));
|
|
10
|
+
};
|
|
11
|
+
export default EndpointPopover;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CommonRangeGroupConfig, QuickDirection, QuickUnit, SuperDatePickerPreset } from "../SuperDatePicker.types";
|
|
2
|
+
type QuickRangeDropdownProps = {
|
|
3
|
+
commonRangeGroups: CommonRangeGroupConfig[];
|
|
4
|
+
quickDirection: QuickDirection;
|
|
5
|
+
quickAmount: string;
|
|
6
|
+
quickUnit: QuickUnit;
|
|
7
|
+
onQuickDirectionChange: (direction: QuickDirection) => void;
|
|
8
|
+
onQuickAmountChange: (amount: string) => void;
|
|
9
|
+
onQuickAmountSubmit: () => void;
|
|
10
|
+
onQuickUnitChange: (unit: QuickUnit) => void;
|
|
11
|
+
onPresetClick: (preset: SuperDatePickerPreset) => void;
|
|
12
|
+
};
|
|
13
|
+
declare const QuickRangeDropdown: ({ commonRangeGroups, quickDirection, quickAmount, quickUnit, onQuickDirectionChange, onQuickAmountChange, onQuickAmountSubmit, onQuickUnitChange, onPresetClick, }: QuickRangeDropdownProps) => import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export default QuickRangeDropdown;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { SelectBox } from "../../SelectBox";
|
|
3
|
+
import { TextInput } from "../../TextInput";
|
|
4
|
+
import { StyledContent } from "../../core";
|
|
5
|
+
import { QUICK_DIRECTION_OPTIONS, QUICK_UNITS, } from "../SuperDatePicker.constants";
|
|
6
|
+
import { CommonRangesSection, PanelTitle, QuickRangePanel, QuickRangeSection, QuickSelectRow, } from "../SuperDatePicker.styled";
|
|
7
|
+
import CommonPresetGroups from "./CommonPresetGroups";
|
|
8
|
+
const QuickRangeDropdown = ({ commonRangeGroups, quickDirection, quickAmount, quickUnit, onQuickDirectionChange, onQuickAmountChange, onQuickAmountSubmit, onQuickUnitChange, onPresetClick, }) => {
|
|
9
|
+
const handleAmountKeyDown = (event) => {
|
|
10
|
+
if (event.key === "Enter") {
|
|
11
|
+
onQuickAmountSubmit();
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
const handleAmountChange = (event) => {
|
|
15
|
+
onQuickAmountChange(event.target.value);
|
|
16
|
+
};
|
|
17
|
+
return (_jsx(StyledContent, { maxDropdownHeight: "fit-content", children: _jsxs(QuickRangePanel, { children: [_jsxs(QuickRangeSection, { children: [_jsx(PanelTitle, { children: "Quick select" }), _jsxs(QuickSelectRow, { children: [_jsx(SelectBox, { data: QUICK_DIRECTION_OPTIONS, value: quickDirection, onChange: (value) => onQuickDirectionChange(value), size: "xs", variant: "outlined", width: "100%", openOnFocus: false, arrow: true }), _jsx(TextInput, { type: "number", min: 1, value: quickAmount, onChange: handleAmountChange, onKeyDown: handleAmountKeyDown, size: "xs", variant: "outlined" }), _jsx(SelectBox, { data: QUICK_UNITS, value: quickUnit, onChange: (value) => onQuickUnitChange(value), size: "xs", variant: "outlined", width: "100%", openOnFocus: false, arrow: true })] })] }), _jsxs(CommonRangesSection, { children: [_jsx(PanelTitle, { children: "Presets" }), _jsx(CommonPresetGroups, { groups: commonRangeGroups, onPresetClick: onPresetClick })] })] }) }));
|
|
18
|
+
};
|
|
19
|
+
export default QuickRangeDropdown;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { CommonRangeGroupConfig, QuickDirection, QuickUnit, SuperDatePickerPreset, SuperDatePickerProps } from "../SuperDatePicker.types";
|
|
2
|
+
type QuickRangePopoverProps = {
|
|
3
|
+
opened: boolean;
|
|
4
|
+
disabled: boolean;
|
|
5
|
+
size: NonNullable<SuperDatePickerProps["size"]>;
|
|
6
|
+
commonRangeGroups: CommonRangeGroupConfig[];
|
|
7
|
+
quickDirection: QuickDirection;
|
|
8
|
+
quickAmount: string;
|
|
9
|
+
quickUnit: QuickUnit;
|
|
10
|
+
onOpenChange: (opened: boolean) => void;
|
|
11
|
+
onQuickDirectionChange: (direction: QuickDirection) => void;
|
|
12
|
+
onQuickAmountChange: (amount: string) => void;
|
|
13
|
+
onQuickAmountSubmit: () => void;
|
|
14
|
+
onQuickUnitChange: (unit: QuickUnit) => void;
|
|
15
|
+
onPresetClick: (preset: SuperDatePickerPreset) => void;
|
|
16
|
+
};
|
|
17
|
+
declare const QuickRangePopover: ({ opened, disabled, size, commonRangeGroups, quickDirection, quickAmount, quickUnit, onOpenChange, onQuickDirectionChange, onQuickAmountChange, onQuickAmountSubmit, onQuickUnitChange, onPresetClick, }: QuickRangePopoverProps) => import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
export default QuickRangePopover;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { CalendarDaysIcon } from "lucide-react";
|
|
3
|
+
import { Popover } from "../../Popover";
|
|
4
|
+
import { SegmentButton, TriggerIcon, } from "../SuperDatePicker.styled";
|
|
5
|
+
import QuickRangeDropdown from "./QuickRangeDropdown";
|
|
6
|
+
const QuickRangePopover = ({ opened, disabled, size, commonRangeGroups, quickDirection, quickAmount, quickUnit, onOpenChange, onQuickDirectionChange, onQuickAmountChange, onQuickAmountSubmit, onQuickUnitChange, onPresetClick, }) => {
|
|
7
|
+
return (_jsxs(Popover, { opened: opened, onChange: (nextOpened) => onOpenChange(!disabled && nextOpened), position: "bottom-start", offset: 5, withinPortal: true, children: [_jsx(Popover.Target, { children: _jsx(SegmentButton, { type: "button", size: size, "$iconOnly": true, disabled: disabled, "aria-label": "Open quick date ranges", title: "Open quick date ranges", "data-active": opened, children: _jsx(TriggerIcon, { size: size, children: _jsx(CalendarDaysIcon, {}) }) }) }), _jsx(Popover.Dropdown, { style: {
|
|
8
|
+
border: "none",
|
|
9
|
+
padding: 0,
|
|
10
|
+
}, children: _jsx(QuickRangeDropdown, { commonRangeGroups: commonRangeGroups, quickDirection: quickDirection, quickAmount: quickAmount, quickUnit: quickUnit, onQuickDirectionChange: onQuickDirectionChange, onQuickAmountChange: onQuickAmountChange, onQuickAmountSubmit: onQuickAmountSubmit, onQuickUnitChange: onQuickUnitChange, onPresetClick: onPresetClick }) })] }));
|
|
11
|
+
};
|
|
12
|
+
export default QuickRangePopover;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { default as CommonPresetGroups } from "./CommonPresetGroups";
|
|
2
|
+
export { default as EndpointCalendarDropdown } from "./EndpointCalendarDropdown";
|
|
3
|
+
export { default as EndpointDateInput } from "./EndpointDateInput";
|
|
4
|
+
export { default as EndpointPopover } from "./EndpointPopover";
|
|
5
|
+
export { default as QuickRangeDropdown } from "./QuickRangeDropdown";
|
|
6
|
+
export { default as QuickRangePopover } from "./QuickRangePopover";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { default as CommonPresetGroups } from "./CommonPresetGroups";
|
|
2
|
+
export { default as EndpointCalendarDropdown } from "./EndpointCalendarDropdown";
|
|
3
|
+
export { default as EndpointDateInput } from "./EndpointDateInput";
|
|
4
|
+
export { default as EndpointPopover } from "./EndpointPopover";
|
|
5
|
+
export { default as QuickRangeDropdown } from "./QuickRangeDropdown";
|
|
6
|
+
export { default as QuickRangePopover } from "./QuickRangePopover";
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { MouseEvent } from "react";
|
|
2
|
+
import type { CommonRangeGroupConfig, Endpoint, OpenSegment, QuickDirection, QuickUnit, SuperDatePickerPreset, SuperDatePickerProps, SuperDatePickerValue } from "./SuperDatePicker.types";
|
|
3
|
+
type UseSuperDatePickerOptions = {
|
|
4
|
+
defaultValue: SuperDatePickerValue;
|
|
5
|
+
value?: SuperDatePickerValue;
|
|
6
|
+
onChange: NonNullable<SuperDatePickerProps["onChange"]>;
|
|
7
|
+
disabled: boolean;
|
|
8
|
+
min?: Date;
|
|
9
|
+
max?: Date;
|
|
10
|
+
utc: boolean;
|
|
11
|
+
presets?: SuperDatePickerPreset[];
|
|
12
|
+
};
|
|
13
|
+
declare const useSuperDatePicker: ({ defaultValue, value, onChange, disabled, min, max, utc, presets, }: UseSuperDatePickerOptions) => {
|
|
14
|
+
value: SuperDatePickerValue;
|
|
15
|
+
openSegment: OpenSegment;
|
|
16
|
+
quickDirection: QuickDirection;
|
|
17
|
+
quickAmount: string;
|
|
18
|
+
quickUnit: QuickUnit;
|
|
19
|
+
commonRangeGroups: CommonRangeGroupConfig[];
|
|
20
|
+
handleOpenSegmentChange: (segment: Endpoint | "quick", opened: boolean) => void;
|
|
21
|
+
handleClear: (event?: MouseEvent) => void;
|
|
22
|
+
handlePreset: (preset: SuperDatePickerPreset) => void;
|
|
23
|
+
handleQuickDirectionChange: (nextDirection: QuickDirection) => void;
|
|
24
|
+
handleQuickAmountChange: (nextAmount: string) => void;
|
|
25
|
+
handleQuickAmountSubmit: () => void;
|
|
26
|
+
handleQuickUnitChange: (nextUnit: QuickUnit) => void;
|
|
27
|
+
handleEndpointChange: (endpoint: Endpoint, nextValue?: string | null) => void;
|
|
28
|
+
handleCalendarChange: (endpoint: Endpoint, date: Date | null) => void;
|
|
29
|
+
getEndpointMin: (endpoint: Endpoint) => Date | undefined;
|
|
30
|
+
getEndpointMax: (endpoint: Endpoint) => Date | undefined;
|
|
31
|
+
};
|
|
32
|
+
export default useSuperDatePicker;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { useCallback, useMemo, useRef, useState } from "react";
|
|
2
|
+
import { DEFAULT_QUICK_AMOUNT, DEFAULT_QUICK_DIRECTION, DEFAULT_QUICK_UNIT, } from "./SuperDatePicker.constants";
|
|
3
|
+
import { calendarDateToMoment, createRange, getAdditionalCommonRangeGroups, getDefaultCommonRangeGroups, parseRangeMoment, resolveNow, serializeMoment, } from "./SuperDatePicker.lib";
|
|
4
|
+
const useSuperDatePicker = ({ defaultValue, value, onChange, disabled, min, max, utc, presets, }) => {
|
|
5
|
+
const isControlled = useRef(value !== undefined);
|
|
6
|
+
const [uncontrolledValue, setUncontrolledValue] = useState(defaultValue);
|
|
7
|
+
const pickerValue = isControlled.current ? value || {} : uncontrolledValue;
|
|
8
|
+
const [openSegment, setOpenSegment] = useState(null);
|
|
9
|
+
const [quickDirection, setQuickDirection] = useState(DEFAULT_QUICK_DIRECTION);
|
|
10
|
+
const [quickAmount, setQuickAmount] = useState(DEFAULT_QUICK_AMOUNT);
|
|
11
|
+
const [quickUnit, setQuickUnit] = useState(DEFAULT_QUICK_UNIT);
|
|
12
|
+
const commonRangeGroups = useMemo(() => presets
|
|
13
|
+
? [
|
|
14
|
+
{
|
|
15
|
+
label: "Presets",
|
|
16
|
+
ranges: presets,
|
|
17
|
+
},
|
|
18
|
+
]
|
|
19
|
+
: [
|
|
20
|
+
...getDefaultCommonRangeGroups(utc),
|
|
21
|
+
...getAdditionalCommonRangeGroups(utc),
|
|
22
|
+
], [presets, utc]);
|
|
23
|
+
const commitValue = useCallback((nextValue, meta) => {
|
|
24
|
+
if (!isControlled.current) {
|
|
25
|
+
setUncontrolledValue(nextValue);
|
|
26
|
+
}
|
|
27
|
+
onChange(nextValue, meta);
|
|
28
|
+
}, [onChange]);
|
|
29
|
+
const commitPartial = (patch, source) => {
|
|
30
|
+
commitValue(Object.assign(Object.assign({}, pickerValue), patch), { source });
|
|
31
|
+
};
|
|
32
|
+
const commitQuickRange = (direction = quickDirection, amountInput = quickAmount, unit = quickUnit) => {
|
|
33
|
+
if (disabled)
|
|
34
|
+
return;
|
|
35
|
+
const amount = Number(amountInput);
|
|
36
|
+
if (!Number.isFinite(amount) || amount <= 0)
|
|
37
|
+
return;
|
|
38
|
+
const now = resolveNow(utc);
|
|
39
|
+
const nextValue = direction === "last"
|
|
40
|
+
? createRange(now.clone().subtract(amount, unit), now, utc)
|
|
41
|
+
: createRange(now, now.clone().add(amount, unit), utc);
|
|
42
|
+
commitValue(nextValue, { source: "apply" });
|
|
43
|
+
};
|
|
44
|
+
const handleOpenSegmentChange = (segment, opened) => {
|
|
45
|
+
setOpenSegment((currentSegment) => {
|
|
46
|
+
if (opened)
|
|
47
|
+
return segment;
|
|
48
|
+
return currentSegment === segment ? null : currentSegment;
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
const handleClear = (event) => {
|
|
52
|
+
event === null || event === void 0 ? void 0 : event.preventDefault();
|
|
53
|
+
event === null || event === void 0 ? void 0 : event.stopPropagation();
|
|
54
|
+
commitValue({ start: null, end: null }, { source: "clear" });
|
|
55
|
+
setOpenSegment(null);
|
|
56
|
+
};
|
|
57
|
+
const handlePreset = (preset) => {
|
|
58
|
+
if (disabled)
|
|
59
|
+
return;
|
|
60
|
+
const nextValue = preset.getRange();
|
|
61
|
+
commitValue(nextValue, { source: "preset", preset });
|
|
62
|
+
setOpenSegment(null);
|
|
63
|
+
};
|
|
64
|
+
const handleQuickDirectionChange = (nextDirection) => {
|
|
65
|
+
setQuickDirection(nextDirection);
|
|
66
|
+
commitQuickRange(nextDirection);
|
|
67
|
+
};
|
|
68
|
+
const handleQuickAmountChange = (nextAmount) => {
|
|
69
|
+
setQuickAmount(nextAmount);
|
|
70
|
+
commitQuickRange(quickDirection, nextAmount, quickUnit);
|
|
71
|
+
};
|
|
72
|
+
const handleQuickAmountSubmit = () => {
|
|
73
|
+
commitQuickRange();
|
|
74
|
+
};
|
|
75
|
+
const handleQuickUnitChange = (nextUnit) => {
|
|
76
|
+
setQuickUnit(nextUnit);
|
|
77
|
+
commitQuickRange(quickDirection, quickAmount, nextUnit);
|
|
78
|
+
};
|
|
79
|
+
const handleEndpointChange = (endpoint, nextValue) => {
|
|
80
|
+
if (disabled)
|
|
81
|
+
return;
|
|
82
|
+
commitPartial({ [endpoint]: nextValue }, "apply");
|
|
83
|
+
};
|
|
84
|
+
const handleCalendarChange = (endpoint, date) => {
|
|
85
|
+
if (disabled)
|
|
86
|
+
return;
|
|
87
|
+
if (!date) {
|
|
88
|
+
handleEndpointChange(endpoint, null);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
handleEndpointChange(endpoint, serializeMoment(calendarDateToMoment(date, utc), utc));
|
|
92
|
+
};
|
|
93
|
+
const getEndpointMin = (endpoint) => {
|
|
94
|
+
var _a;
|
|
95
|
+
return endpoint === "end"
|
|
96
|
+
? ((_a = parseRangeMoment(pickerValue.start, utc)) === null || _a === void 0 ? void 0 : _a.toDate()) || min
|
|
97
|
+
: min;
|
|
98
|
+
};
|
|
99
|
+
const getEndpointMax = (endpoint) => {
|
|
100
|
+
var _a;
|
|
101
|
+
return endpoint === "start"
|
|
102
|
+
? ((_a = parseRangeMoment(pickerValue.end, utc)) === null || _a === void 0 ? void 0 : _a.toDate()) || max
|
|
103
|
+
: max;
|
|
104
|
+
};
|
|
105
|
+
return {
|
|
106
|
+
value: pickerValue,
|
|
107
|
+
openSegment,
|
|
108
|
+
quickDirection,
|
|
109
|
+
quickAmount,
|
|
110
|
+
quickUnit,
|
|
111
|
+
commonRangeGroups,
|
|
112
|
+
handleOpenSegmentChange,
|
|
113
|
+
handleClear,
|
|
114
|
+
handlePreset,
|
|
115
|
+
handleQuickDirectionChange,
|
|
116
|
+
handleQuickAmountChange,
|
|
117
|
+
handleQuickAmountSubmit,
|
|
118
|
+
handleQuickUnitChange,
|
|
119
|
+
handleEndpointChange,
|
|
120
|
+
handleCalendarChange,
|
|
121
|
+
getEndpointMin,
|
|
122
|
+
getEndpointMax,
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
export default useSuperDatePicker;
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
import { ColumnState
|
|
2
|
-
declare const ColumnResizer: ({ onResize,
|
|
1
|
+
import { ColumnState } from "./types";
|
|
2
|
+
declare const ColumnResizer: ({ onResizeStart, onResize, onResizeEnd, column, currentWidth, showOnHover, }: {
|
|
3
3
|
className?: string;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
width: number;
|
|
8
|
-
}[];
|
|
9
|
-
}) => void;
|
|
10
|
-
onResizeFinished?: (e: onResizeFinishedProps) => void;
|
|
4
|
+
onResizeStart?: () => void;
|
|
5
|
+
onResize?: (width: number) => void;
|
|
6
|
+
onResizeEnd?: (width: number) => void;
|
|
11
7
|
column: ColumnState;
|
|
8
|
+
currentWidth: number;
|
|
12
9
|
showOnHover?: boolean;
|
|
13
10
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
14
11
|
export default ColumnResizer;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import styled from "styled-components";
|
|
3
|
-
import { resizeHandler } from "./Utils";
|
|
4
3
|
const StyledContainer = styled.div `
|
|
5
4
|
position: absolute;
|
|
6
5
|
right: 0px;
|
|
@@ -24,22 +23,43 @@ const StyledContainer = styled.div `
|
|
|
24
23
|
background: ${(props) => props.theme.palette.primary.main};
|
|
25
24
|
}
|
|
26
25
|
`;
|
|
27
|
-
const ColumnResizer = ({ onResize
|
|
26
|
+
const ColumnResizer = ({ onResizeStart, onResize, onResizeEnd, column, currentWidth, showOnHover = false, }) => {
|
|
27
|
+
const getConstrainedWidth = (width) => {
|
|
28
|
+
const minWidth = column.minWidth;
|
|
29
|
+
const maxWidth = column.maxWidth;
|
|
30
|
+
if (typeof maxWidth === "number") {
|
|
31
|
+
return Math.min(Math.max(width, minWidth), maxWidth);
|
|
32
|
+
}
|
|
33
|
+
return Math.max(width, minWidth);
|
|
34
|
+
};
|
|
28
35
|
return (_jsx(StyledContainer, { className: `resizer col-${column.columnId}`, "data-show-on-hover": showOnHover, onClick: (e) => {
|
|
29
36
|
e.stopPropagation();
|
|
30
37
|
e.nativeEvent.stopImmediatePropagation();
|
|
31
38
|
e.preventDefault();
|
|
32
|
-
},
|
|
39
|
+
}, onPointerDown: (e) => {
|
|
33
40
|
e.stopPropagation();
|
|
34
41
|
e.nativeEvent.stopImmediatePropagation();
|
|
35
42
|
e.preventDefault();
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
+
const startX = e.clientX;
|
|
44
|
+
const startWidth = currentWidth;
|
|
45
|
+
const target = e.currentTarget;
|
|
46
|
+
const handlePointerMove = (event) => {
|
|
47
|
+
const nextWidth = getConstrainedWidth(startWidth + event.clientX - startX);
|
|
48
|
+
onResize === null || onResize === void 0 ? void 0 : onResize(nextWidth);
|
|
49
|
+
};
|
|
50
|
+
const handlePointerUp = (event) => {
|
|
51
|
+
const nextWidth = getConstrainedWidth(startWidth + event.clientX - startX);
|
|
52
|
+
target.classList.remove("isResizing");
|
|
53
|
+
document.removeEventListener("pointermove", handlePointerMove);
|
|
54
|
+
document.removeEventListener("pointerup", handlePointerUp);
|
|
55
|
+
document.removeEventListener("pointercancel", handlePointerUp);
|
|
56
|
+
onResizeEnd === null || onResizeEnd === void 0 ? void 0 : onResizeEnd(nextWidth);
|
|
57
|
+
};
|
|
58
|
+
target.classList.add("isResizing");
|
|
59
|
+
onResizeStart === null || onResizeStart === void 0 ? void 0 : onResizeStart();
|
|
60
|
+
document.addEventListener("pointermove", handlePointerMove);
|
|
61
|
+
document.addEventListener("pointerup", handlePointerUp);
|
|
62
|
+
document.addEventListener("pointercancel", handlePointerUp);
|
|
43
63
|
} }));
|
|
44
64
|
};
|
|
45
65
|
export default ColumnResizer;
|
|
@@ -8,18 +8,20 @@ export const TBody = styled.div `
|
|
|
8
8
|
overflow: hidden;
|
|
9
9
|
`;
|
|
10
10
|
export const TR = styled.div `
|
|
11
|
+
box-sizing: border-box;
|
|
11
12
|
display: flex;
|
|
12
13
|
flex-direction: row;
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
flex: 0 0 auto;
|
|
15
|
+
min-width: 100%;
|
|
15
16
|
|
|
16
17
|
height: ${({ height }) => {
|
|
17
18
|
const customHeight = height ? height + "px" : undefined;
|
|
18
19
|
return customHeight || `${TableDefaults.row.height.normal}px`;
|
|
19
20
|
}};
|
|
20
21
|
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
box-shadow:
|
|
23
|
+
inset 1px 0 ${({ theme }) => theme.palette.divider},
|
|
24
|
+
inset -1px 0 ${({ theme }) => theme.palette.divider};
|
|
23
25
|
|
|
24
26
|
.row-action {
|
|
25
27
|
visibility: hidden;
|
|
@@ -30,7 +32,6 @@ export const TR = styled.div `
|
|
|
30
32
|
}
|
|
31
33
|
|
|
32
34
|
&[data-focused="true"] {
|
|
33
|
-
border: 1px solid transparent;
|
|
34
35
|
outline: 1px solid ${({ theme }) => theme.palette.primary.main};
|
|
35
36
|
outline-offset: -1px;
|
|
36
37
|
|
|
@@ -59,21 +60,18 @@ export const THR = styled(TR) `
|
|
|
59
60
|
}
|
|
60
61
|
`;
|
|
61
62
|
export const TD = styled.div `
|
|
63
|
+
box-sizing: border-box;
|
|
62
64
|
position: relative;
|
|
63
65
|
display: flex;
|
|
64
66
|
flex-direction: row;
|
|
65
67
|
align-items: center;
|
|
66
|
-
flex:
|
|
68
|
+
flex: 0 0 auto;
|
|
67
69
|
|
|
68
70
|
padding: ${TableDefaults.td.padding.normal}px;
|
|
69
71
|
font-size: ${`${TableDefaults.td.fontSize.normal}px`};
|
|
70
72
|
|
|
71
73
|
min-width: ${TableDefaults.td.minWidth}px;
|
|
72
74
|
|
|
73
|
-
&:last-child {
|
|
74
|
-
flex: 1 !important; // ensure last column takes up remaining space
|
|
75
|
-
}
|
|
76
|
-
|
|
77
75
|
background-color: ${({ theme }) => theme.palette.background.default};
|
|
78
76
|
|
|
79
77
|
border-bottom: 1px solid ${({ theme }) => theme.palette.divider};
|
|
@@ -110,6 +108,7 @@ export const TH = styled(TD) `
|
|
|
110
108
|
`;
|
|
111
109
|
export const InnerCellContent = styled.div `
|
|
112
110
|
max-width: 100%;
|
|
111
|
+
min-width: 0;
|
|
113
112
|
|
|
114
113
|
white-space: nowrap;
|
|
115
114
|
overflow: hidden;
|
|
@@ -165,12 +164,16 @@ export const TreeCellContent = styled.div `
|
|
|
165
164
|
white-space: nowrap;
|
|
166
165
|
`;
|
|
167
166
|
export const TableViewPort = styled.div `
|
|
167
|
+
box-sizing: border-box;
|
|
168
168
|
display: flex;
|
|
169
169
|
flex-direction: column;
|
|
170
|
+
min-width: 0;
|
|
170
171
|
`;
|
|
171
172
|
export const TableListElement = styled.div `
|
|
173
|
+
box-sizing: border-box;
|
|
172
174
|
display: flex;
|
|
173
175
|
flex-direction: column;
|
|
176
|
+
min-width: 100%;
|
|
174
177
|
`;
|
|
175
178
|
export const TableWrapper = styled.div `
|
|
176
179
|
position: relative;
|
|
@@ -180,6 +183,7 @@ export const TableWrapper = styled.div `
|
|
|
180
183
|
flex-direction: column;
|
|
181
184
|
`;
|
|
182
185
|
export const StyledTable = styled.div `
|
|
186
|
+
box-sizing: border-box;
|
|
183
187
|
position: relative;
|
|
184
188
|
overflow: hidden;
|
|
185
189
|
display: flex;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useState } from "react";
|
|
2
|
+
import { useRef, useState } from "react";
|
|
3
3
|
import ColumnResizer from "./ColumnResizer";
|
|
4
4
|
import { InnerCellContent, TH, THead, THR } from "./TableComponents";
|
|
5
5
|
import { resolveColumnResize } from "./Utils";
|
|
@@ -16,45 +16,61 @@ const StyledCaption = styled.span `
|
|
|
16
16
|
`;
|
|
17
17
|
const TableHeader = ({ headerRowElm }) => {
|
|
18
18
|
var _a;
|
|
19
|
-
const { columnState, sortState, setColumnState: updateColumnState, onColumnResize, handleColumnReorder, enableColumnReorder, handleColumnHeaderClick, enableColumnResize, headerRowHeight, enableActionButton, enableSelection, selectionState, disableSelectAll, selectAllRows, clearSelections, compactState, } = useTable();
|
|
19
|
+
const { columnState, sortState, setColumnState: updateColumnState, onColumnResize, handleColumnReorder, enableColumnReorder, handleColumnHeaderClick, enableColumnResize, headerRowHeight, enableActionButton, enableSelection, selectionState, disableSelectAll, selectAllRows, clearSelections, compactState, tableLayout, setResizeColumnWidths, } = useTable();
|
|
20
20
|
const [dragColumn, setDragColumn] = useState(null);
|
|
21
21
|
const [dropColumn, setDropColumn] = useState(null);
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
const resizeStartWidths = useRef(null);
|
|
23
|
+
const getResizeWidths = (column, newWidth) => (Object.assign(Object.assign({}, (resizeStartWidths.current || tableLayout.columnWidths)), { [column.columnId]: newWidth }));
|
|
24
|
+
const handleResizeStart = () => {
|
|
25
|
+
resizeStartWidths.current = tableLayout.columnWidths;
|
|
26
|
+
setResizeColumnWidths(tableLayout.columnWidths);
|
|
27
|
+
};
|
|
28
|
+
const handleResize = (column, newWidth) => {
|
|
29
|
+
setResizeColumnWidths(getResizeWidths(column, newWidth));
|
|
30
|
+
};
|
|
31
|
+
const handleResizeEnd = (column, newWidth) => {
|
|
32
|
+
const nextWidths = getResizeWidths(column, newWidth);
|
|
25
33
|
updateColumnState((prevColumnState) => {
|
|
26
34
|
const nextColumnState = prevColumnState.map((col) => {
|
|
27
|
-
if (col.columnId === columnId) {
|
|
35
|
+
if (col.columnId === column.columnId) {
|
|
28
36
|
return Object.assign(Object.assign({}, col), { width: newWidth });
|
|
29
37
|
}
|
|
30
38
|
return col;
|
|
31
39
|
});
|
|
32
40
|
onColumnResize === null || onColumnResize === void 0 ? void 0 : onColumnResize({
|
|
33
|
-
column: Object.assign(Object.assign({},
|
|
41
|
+
column: Object.assign(Object.assign({}, column), { width: newWidth }),
|
|
34
42
|
columnState: nextColumnState,
|
|
35
43
|
});
|
|
36
44
|
return nextColumnState;
|
|
37
45
|
});
|
|
46
|
+
resizeStartWidths.current = null;
|
|
47
|
+
setResizeColumnWidths(null);
|
|
38
48
|
};
|
|
39
49
|
const handleChangeSelection = (e) => {
|
|
40
50
|
e ? selectAllRows() : clearSelections();
|
|
41
51
|
};
|
|
42
|
-
return (_jsx(THead, { className: "mfui-thead", children: _jsxs(THR, { className: "mfui-thr", ref: headerRowElm, height: headerRowHeight, "data-compact": compactState, children: [enableSelection && (_jsx(TH, { className: `mfui-th column-action`, style: {
|
|
52
|
+
return (_jsx(THead, { className: "mfui-thead", children: _jsxs(THR, { className: "mfui-thr", ref: headerRowElm, height: headerRowHeight, "data-compact": compactState, style: { width: tableLayout.contentWidth }, children: [enableSelection && (_jsx(TH, { className: `mfui-th column-action`, style: {
|
|
43
53
|
width: TableDefaults.actionCell.width,
|
|
44
54
|
minWidth: TableDefaults.actionCell.minWidth,
|
|
45
55
|
maxWidth: TableDefaults.actionCell.maxWidth,
|
|
46
|
-
|
|
56
|
+
flexBasis: TableDefaults.actionCell.width,
|
|
57
|
+
flexGrow: 0,
|
|
58
|
+
flexShrink: 0,
|
|
47
59
|
justifyContent: "center",
|
|
48
60
|
alignItems: "center",
|
|
49
61
|
}, children: _jsx(InnerCellContent, { className: "mfui inner-cell-content", children: disableSelectAll !== true && (_jsx(CheckBox, { value: selectionState.selectionStatus === "all", partialCheck: (_a = selectionState.selectionStatus) === null || _a === void 0 ? void 0 : _a.includes("some"), onChange: handleChangeSelection })) }) })), enableActionButton && (_jsx(TH, { className: `mfui-th column-action`, style: {
|
|
50
62
|
width: TableDefaults.actionCell.width,
|
|
51
63
|
minWidth: TableDefaults.actionCell.minWidth,
|
|
52
64
|
maxWidth: TableDefaults.actionCell.maxWidth,
|
|
65
|
+
flexBasis: TableDefaults.actionCell.width,
|
|
66
|
+
flexGrow: 0,
|
|
67
|
+
flexShrink: 0,
|
|
53
68
|
}, children: _jsx(InnerCellContent, { className: "mfui inner-cell-content" }) })), columnState.map((column) => {
|
|
54
69
|
if (column.visible === false)
|
|
55
70
|
return null;
|
|
56
71
|
const canReorder = resolveColumnReorder(column, enableColumnReorder);
|
|
57
72
|
const canResize = resolveColumnResize(column, enableColumnResize);
|
|
73
|
+
const columnWidth = tableLayout.columnWidths[column.columnId] || column.minWidth;
|
|
58
74
|
const dndEvents = canReorder
|
|
59
75
|
? {
|
|
60
76
|
onDragOver: (e) => {
|
|
@@ -86,14 +102,13 @@ const TableHeader = ({ headerRowElm }) => {
|
|
|
86
102
|
}
|
|
87
103
|
: {};
|
|
88
104
|
return (_jsxs(TH, Object.assign({ className: `mfui-th column-${column.columnId}`, "data-field": column.dataField, draggable: canReorder, onClick: () => handleColumnHeaderClick(column) }, dndEvents, { style: {
|
|
89
|
-
width:
|
|
105
|
+
width: columnWidth,
|
|
90
106
|
minWidth: column.minWidth,
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
} })), _jsxs(InnerCellContent, { className: "mfui inner-cell-content", children: [_jsx(StyledCaption, { style: { flex: 1 }, children: column.caption }), _jsx(StyledCaption, { children: (sortState === null || sortState === void 0 ? void 0 : sortState.dataField) === column.dataField &&
|
|
107
|
+
maxWidth: column.maxWidth,
|
|
108
|
+
flexBasis: columnWidth,
|
|
109
|
+
flexGrow: 0,
|
|
110
|
+
flexShrink: 0,
|
|
111
|
+
}, children: [canResize && (_jsx(ColumnResizer, { column: column, currentWidth: columnWidth, showOnHover: true, onResizeStart: handleResizeStart, onResize: (width) => handleResize(column, width), onResizeEnd: (width) => handleResizeEnd(column, width) })), _jsxs(InnerCellContent, { className: "mfui inner-cell-content", children: [_jsx(StyledCaption, { style: { flex: 1 }, children: column.caption }), _jsx(StyledCaption, { children: (sortState === null || sortState === void 0 ? void 0 : sortState.dataField) === column.dataField &&
|
|
97
112
|
(sortState.dir === "asc" ? (_jsx(ArrowUpIcon, { size: 14 })) : (_jsx(ArrowDownIcon, { size: 14 }))) })] })] }), column.columnId));
|
|
98
113
|
})] }) }));
|
|
99
114
|
};
|
|
@@ -36,7 +36,7 @@ const TableMenu = () => {
|
|
|
36
36
|
return null;
|
|
37
37
|
const { addButtonOptions, filterOptions, tableCountOptions, exportOptions, compactOptions, columnSelectorOptions, searchOptions, children, customMenuItems, } = tableMenuOptions;
|
|
38
38
|
const queryFilter = useQueryFilter({
|
|
39
|
-
|
|
39
|
+
value: filterState,
|
|
40
40
|
filterDefinitions: (filterOptions === null || filterOptions === void 0 ? void 0 : filterOptions.filterDefinitions) || [],
|
|
41
41
|
showCombinator: (_a = filterOptions === null || filterOptions === void 0 ? void 0 : filterOptions.showCombinator) !== null && _a !== void 0 ? _a : true,
|
|
42
42
|
onFilterChange: (q) => {
|