@monolith-forensics/monolith-ui 1.8.1-dev.3 → 1.8.1
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/Button/Button.js +58 -9
- package/dist/Calendar/Calendar.d.ts +2 -7
- package/dist/Calendar/Calendar.js +49 -226
- package/dist/Calendar/CalendarStyles.d.ts +2 -6
- package/dist/Calendar/CalendarStyles.js +33 -153
- package/dist/Calendar/calendarHelpers.d.ts +2 -6
- package/dist/Calendar/calendarHelpers.js +5 -13
- package/dist/Charts/BarChart/BarChart.js +28 -14
- package/dist/Charts/BarChart/BarChart.styled.d.ts +7 -2
- package/dist/Charts/BarChart/BarChart.styled.js +5 -1
- package/dist/Charts/BarChart/BarChart.types.d.ts +13 -5
- package/dist/Charts/ChartUtils/chartSizing.d.ts +20 -0
- package/dist/Charts/ChartUtils/chartSizing.js +83 -0
- package/dist/Charts/ChartUtils/index.d.ts +1 -0
- package/dist/Charts/ChartUtils/index.js +1 -0
- package/dist/Charts/HeatMap/HeatMap.js +28 -7
- package/dist/Charts/HeatMap/HeatMap.styled.d.ts +6 -2
- package/dist/Charts/HeatMap/HeatMap.styled.js +3 -0
- package/dist/Charts/HeatMap/HeatMap.types.d.ts +7 -1
- package/dist/Charts/LineChart/LineChart.js +34 -15
- package/dist/Charts/LineChart/LineChart.styled.d.ts +7 -2
- package/dist/Charts/LineChart/LineChart.styled.js +5 -1
- package/dist/Charts/LineChart/LineChart.types.d.ts +13 -5
- package/dist/Charts/PieChart/PieChart.js +48 -33
- package/dist/Charts/PieChart/PieChart.styled.d.ts +7 -2
- package/dist/Charts/PieChart/PieChart.styled.js +6 -1
- package/dist/Charts/PieChart/PieChart.types.d.ts +7 -3
- package/dist/CheckBox/CheckBox.js +19 -36
- package/dist/DateInput/DateInput.js +143 -198
- package/dist/DropDownMenu/DropDownMenu.js +15 -25
- package/dist/DropDownMenu/components/MenuComponent.js +2 -8
- package/dist/DropDownMenu/components/MenuItem.d.ts +0 -2
- package/dist/DropDownMenu/components/MenuItem.js +21 -25
- package/dist/DropDownMenu/components/MenuItemList.d.ts +0 -3
- package/dist/DropDownMenu/components/MenuItemList.js +86 -192
- package/dist/DropDownMenu/components/StyledContent.js +2 -1
- package/dist/DropDownMenu/components/StyledFloatContainer.js +1 -1
- package/dist/DropDownMenu/types.d.ts +0 -3
- package/dist/FieldLabel/FieldLabel.js +12 -4
- package/dist/FileInputField/FileInputField.js +23 -4
- package/dist/FileViewer/viewers/ImageViewer.js +18 -75
- package/dist/FormSection/FormSection.js +25 -5
- package/dist/IconButton/IconButton.js +16 -2
- package/dist/Input/Input.js +56 -7
- package/dist/MonolithUIProvider/MonolithUIProvider.d.ts +4 -1
- package/dist/Pill/Pill.js +79 -8
- package/dist/Popover/Popover.context.d.ts +1 -2
- package/dist/Popover/Popover.js +2 -5
- package/dist/Popover/Popover.styles.d.ts +6 -1
- package/dist/Popover/Popover.styles.js +28 -11
- package/dist/Popover/Popover.transitions.d.ts +2 -4
- package/dist/Popover/Popover.transitions.js +49 -23
- package/dist/Popover/PopoverDropdown.js +8 -6
- package/dist/Popover/PopoverTarget.js +3 -6
- package/dist/QueryFilter/DefaultOperators.d.ts +76 -1
- package/dist/QueryFilter/DefaultOperators.js +21 -1
- package/dist/QueryFilter/QueryFilter.d.ts +1 -1
- package/dist/QueryFilter/QueryFilter.js +303 -3
- package/dist/QueryFilter/index.d.ts +2 -3
- package/dist/QueryFilter/index.js +2 -3
- package/dist/QueryFilter/types.d.ts +52 -1
- package/dist/QueryFilter/types.js +1 -1
- package/dist/QueryFilter/useQueryFilter.d.ts +1 -1
- package/dist/QueryFilter/useQueryFilter.js +19 -23
- package/dist/RichTextEditor/Components/CodeBlockBaseButton.d.ts +18 -0
- package/dist/RichTextEditor/Components/CodeBlockBaseButton.js +6 -0
- package/dist/RichTextEditor/Components/CodeBlockCopyButton.d.ts +9 -0
- package/dist/RichTextEditor/Components/CodeBlockCopyButton.js +42 -0
- package/dist/RichTextEditor/Components/CodeBlockFormatButton.d.ts +10 -0
- package/dist/RichTextEditor/Components/CodeBlockFormatButton.js +60 -0
- package/dist/RichTextEditor/Components/CodeBlockLanguageSelect.d.ts +9 -0
- package/dist/RichTextEditor/Components/CodeBlockLanguageSelect.js +30 -0
- package/dist/RichTextEditor/Components/CodeBlockNodeView.d.ts +3 -0
- package/dist/RichTextEditor/Components/CodeBlockNodeView.js +28 -0
- package/dist/RichTextEditor/Components/CodeBlockWrapButton.d.ts +10 -0
- package/dist/RichTextEditor/Components/CodeBlockWrapButton.js +17 -0
- package/dist/RichTextEditor/Components/LinkEditor.d.ts +8 -0
- package/dist/RichTextEditor/Components/LinkEditor.js +94 -0
- package/dist/RichTextEditor/Components/TableTools/TableCornerMenu.d.ts +2 -0
- package/dist/RichTextEditor/Components/TableTools/TableCornerMenu.js +19 -0
- package/dist/RichTextEditor/Components/TableTools/TableInsertControls.d.ts +2 -0
- package/dist/RichTextEditor/Components/TableTools/TableInsertControls.js +24 -0
- package/dist/RichTextEditor/Components/TableTools/TableRails.d.ts +2 -0
- package/dist/RichTextEditor/Components/TableTools/TableRails.js +180 -0
- package/dist/RichTextEditor/Components/TableTools/TableToolMenu.d.ts +5 -0
- package/dist/RichTextEditor/Components/TableTools/TableToolMenu.js +6 -0
- package/dist/RichTextEditor/Components/TableTools/TableTools.actions.d.ts +5 -0
- package/dist/RichTextEditor/Components/TableTools/TableTools.actions.js +183 -0
- package/dist/RichTextEditor/Components/TableTools/TableTools.commands.d.ts +16 -0
- package/dist/RichTextEditor/Components/TableTools/TableTools.commands.js +217 -0
- package/dist/RichTextEditor/Components/TableTools/TableTools.constants.d.ts +8 -0
- package/dist/RichTextEditor/Components/TableTools/TableTools.constants.js +11 -0
- package/dist/RichTextEditor/Components/TableTools/TableTools.d.ts +3 -0
- package/dist/RichTextEditor/Components/TableTools/TableTools.geometry.d.ts +23 -0
- package/dist/RichTextEditor/Components/TableTools/TableTools.geometry.js +75 -0
- package/dist/RichTextEditor/Components/TableTools/TableTools.js +3 -0
- package/dist/RichTextEditor/Components/TableTools/TableTools.selectors.d.ts +16 -0
- package/dist/RichTextEditor/Components/TableTools/TableTools.selectors.js +53 -0
- package/dist/RichTextEditor/Components/TableTools/TableTools.styled.d.ts +40 -0
- package/dist/RichTextEditor/Components/TableTools/TableTools.styled.js +167 -0
- package/dist/RichTextEditor/Components/TableTools/TableTools.types.d.ts +76 -0
- package/dist/RichTextEditor/Components/TableTools/TableTools.types.js +1 -0
- package/dist/RichTextEditor/Components/TableTools/TableTools.utils.d.ts +4 -0
- package/dist/RichTextEditor/Components/TableTools/TableTools.utils.js +4 -0
- package/dist/RichTextEditor/Components/TableTools/TableToolsPopover.d.ts +2 -0
- package/dist/RichTextEditor/Components/TableTools/TableToolsPopover.js +12 -0
- package/dist/RichTextEditor/Components/TableTools/index.d.ts +3 -0
- package/dist/RichTextEditor/Components/TableTools/index.js +2 -0
- package/dist/RichTextEditor/Enums/HighlightColors.d.ts +9 -0
- package/dist/RichTextEditor/Enums/HighlightColors.js +10 -0
- package/dist/RichTextEditor/Extensions/getTiptapExtensions.js +15 -5
- package/dist/RichTextEditor/Plugins/ImageActionsPlugin.js +4 -7
- package/dist/RichTextEditor/Plugins/UploadImagesPlugin.d.ts +0 -15
- package/dist/RichTextEditor/Plugins/UploadImagesPlugin.js +51 -115
- package/dist/RichTextEditor/Plugins/index.d.ts +0 -1
- package/dist/RichTextEditor/Plugins/index.js +0 -1
- package/dist/RichTextEditor/RichTextEditor.d.ts +2 -3
- package/dist/RichTextEditor/RichTextEditor.js +35 -302
- package/dist/RichTextEditor/Utils/codeBlockUtils.d.ts +20 -0
- package/dist/RichTextEditor/Utils/codeBlockUtils.js +137 -0
- package/dist/RichTextEditor/Utils/codeUtils.d.ts +3 -0
- package/dist/RichTextEditor/Utils/codeUtils.js +12 -0
- package/dist/RichTextEditor/Utils/linkUtils.d.ts +19 -0
- package/dist/RichTextEditor/Utils/linkUtils.js +57 -0
- package/dist/RichTextEditor/Utils/tableUtils.d.ts +1 -0
- package/dist/RichTextEditor/Utils/tableUtils.js +1 -0
- package/dist/SegmentedControl/SegmentedControl.utils.d.ts +2 -2
- package/dist/SegmentedControl/SegmentedControl.utils.js +30 -3
- package/dist/SelectBox/SelectBox.js +5 -5
- package/dist/SelectBox/select-box.styled-components.d.ts +1 -4
- package/dist/SelectBox/select-box.styled-components.js +48 -11
- package/dist/SelectBox/types.d.ts +0 -1
- package/dist/Switch/Switch.d.ts +2 -2
- package/dist/Switch/Switch.js +83 -18
- package/dist/Table/ColumnResizer.d.ts +9 -6
- package/dist/Table/ColumnResizer.js +10 -30
- package/dist/Table/StateStorage.d.ts +0 -4
- package/dist/Table/StateStorage.js +0 -13
- package/dist/Table/Table.js +12 -160
- package/dist/Table/TableComponents.d.ts +0 -10
- package/dist/Table/TableComponents.js +10 -71
- package/dist/Table/TableDefaults.d.ts +0 -7
- package/dist/Table/TableDefaults.js +0 -7
- package/dist/Table/TableHeader.js +16 -31
- package/dist/Table/TableMenu/TableMenu.js +1 -1
- package/dist/Table/TableProvider.js +75 -354
- package/dist/Table/TableRow.js +16 -28
- package/dist/Table/Utils/index.d.ts +1 -0
- package/dist/Table/Utils/index.js +1 -0
- package/dist/Table/types.d.ts +19 -70
- package/dist/TagBox/TagBox.d.ts +1 -1
- package/dist/TagBox/TagBox.js +80 -22
- package/dist/TagBox/types.d.ts +0 -1
- package/dist/TextArea/TextArea.js +23 -9
- package/dist/TextInput/TextInput.js +6 -12
- package/dist/Utilities/parseTimestamp.js +6 -11
- package/dist/core/ArrowButton.d.ts +0 -2
- package/dist/core/ArrowButton.js +3 -7
- package/dist/core/ClearButton.d.ts +0 -2
- package/dist/core/ClearButton.js +3 -7
- package/dist/core/controlSizes.js +9 -9
- package/dist/core/index.d.ts +0 -1
- package/dist/core/index.js +0 -1
- package/dist/index.d.ts +0 -3
- package/dist/index.js +0 -2
- package/dist/theme/variants.js +8 -2
- package/package.json +18 -26
- package/dist/DateTimeRangePicker/DateTimeRangePicker.d.ts +0 -41
- package/dist/DateTimeRangePicker/DateTimeRangePicker.js +0 -363
- package/dist/DateTimeRangePicker/index.d.ts +0 -2
- package/dist/DateTimeRangePicker/index.js +0 -2
package/dist/core/index.d.ts
CHANGED
|
@@ -2,6 +2,5 @@ export { default as StyledContent } from "./StyledContent";
|
|
|
2
2
|
export { default as StyledFloatContainer } from "./StyledFloatContainer";
|
|
3
3
|
export { default as ArrowButton } from "./ArrowButton";
|
|
4
4
|
export { default as ClearButton } from "./ClearButton";
|
|
5
|
-
export * from "./controlSizes";
|
|
6
5
|
export type { default as Size } from "./Types/Size";
|
|
7
6
|
export type { default as Variant } from "./Types/Variant";
|
package/dist/core/index.js
CHANGED
|
@@ -2,4 +2,3 @@ export { default as StyledContent } from "./StyledContent";
|
|
|
2
2
|
export { default as StyledFloatContainer } from "./StyledFloatContainer";
|
|
3
3
|
export { default as ArrowButton } from "./ArrowButton";
|
|
4
4
|
export { default as ClearButton } from "./ClearButton";
|
|
5
|
-
export * from "./controlSizes";
|
package/dist/index.d.ts
CHANGED
|
@@ -14,8 +14,6 @@ export * from "./Alert";
|
|
|
14
14
|
export * from "./Kanban";
|
|
15
15
|
export { default as IconButton } from "./IconButton";
|
|
16
16
|
export { default as DateInput } from "./DateInput";
|
|
17
|
-
export { default as SuperDatePicker } from "./SuperDatePicker";
|
|
18
|
-
export type { SuperDatePickerChangeMeta, SuperDatePickerProps, SuperDatePickerPreset, SuperDatePickerValue, } from "./SuperDatePicker";
|
|
19
17
|
export { default as TextArea } from "./TextArea";
|
|
20
18
|
export { default as TextAreaInput } from "./TextAreaInput";
|
|
21
19
|
export type { ActionMenuOptions, TextAreaInputProps } from "./TextAreaInput";
|
|
@@ -46,5 +44,4 @@ export * from "./Tabs";
|
|
|
46
44
|
export * from "./Divider";
|
|
47
45
|
export * from "./SegmentedControl";
|
|
48
46
|
export * from "./Popover";
|
|
49
|
-
export * from "./Charts";
|
|
50
47
|
export * from "./Utilities";
|
package/dist/index.js
CHANGED
|
@@ -9,7 +9,6 @@ export * from "./Alert";
|
|
|
9
9
|
export * from "./Kanban";
|
|
10
10
|
export { default as IconButton } from "./IconButton";
|
|
11
11
|
export { default as DateInput } from "./DateInput";
|
|
12
|
-
export { default as SuperDatePicker } from "./SuperDatePicker";
|
|
13
12
|
export { default as TextArea } from "./TextArea";
|
|
14
13
|
export { default as TextAreaInput } from "./TextAreaInput";
|
|
15
14
|
export { default as TagBox } from "./TagBox";
|
|
@@ -36,5 +35,4 @@ export * from "./Tabs";
|
|
|
36
35
|
export * from "./Divider";
|
|
37
36
|
export * from "./SegmentedControl";
|
|
38
37
|
export * from "./Popover";
|
|
39
|
-
export * from "./Charts";
|
|
40
38
|
export * from "./Utilities";
|
package/dist/theme/variants.js
CHANGED
|
@@ -73,13 +73,16 @@ const lightVariant = {
|
|
|
73
73
|
main: green[700],
|
|
74
74
|
contrastText: "#FFF",
|
|
75
75
|
},
|
|
76
|
+
warning: {
|
|
77
|
+
main: "#ffa726",
|
|
78
|
+
contrastText: "#FFF",
|
|
79
|
+
},
|
|
76
80
|
background: {
|
|
77
81
|
default: "#FFF",
|
|
78
82
|
paper: "#FFF",
|
|
79
83
|
alt: "#ededed",
|
|
80
84
|
secondary: "#f0f0f0",
|
|
81
85
|
gradient: "linear-gradient(#FFFFFF 0%, #ccdcf9 50%)",
|
|
82
|
-
subtle: "#ededed",
|
|
83
86
|
},
|
|
84
87
|
menu: {
|
|
85
88
|
background: "#FFF",
|
|
@@ -237,13 +240,16 @@ const darkVariant = merge(lightVariant, {
|
|
|
237
240
|
main: green[500],
|
|
238
241
|
contrastText: "#FFF",
|
|
239
242
|
},
|
|
243
|
+
warning: {
|
|
244
|
+
main: "#ffa726",
|
|
245
|
+
contrastText: "#FFF",
|
|
246
|
+
},
|
|
240
247
|
background: {
|
|
241
248
|
default: "#222222",
|
|
242
249
|
paper: "#333333",
|
|
243
250
|
alt: "#1e1e1e",
|
|
244
251
|
secondary: "#303030",
|
|
245
252
|
gradient: "linear-gradient(#333333 0%, #1e1e1e 50%)",
|
|
246
|
-
subtle: "#333333",
|
|
247
253
|
},
|
|
248
254
|
menu: {
|
|
249
255
|
background: "#222222",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@monolith-forensics/monolith-ui",
|
|
3
|
-
"version": "1.8.1
|
|
3
|
+
"version": "1.8.1",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"author": "Matt Danner (Monolith Forensics LLC)",
|
|
@@ -40,22 +40,24 @@
|
|
|
40
40
|
"@radix-ui/react-switch": "^1.0.7",
|
|
41
41
|
"@radix-ui/react-tooltip": "^1.0.7",
|
|
42
42
|
"@tabler/icons-react": "^3.11.0",
|
|
43
|
-
"@tiptap/
|
|
44
|
-
"@tiptap/extension-
|
|
45
|
-
"@tiptap/extension-horizontal-rule": "
|
|
46
|
-
"@tiptap/extension-image": "
|
|
47
|
-
"@tiptap/extension-
|
|
48
|
-
"@tiptap/extension-
|
|
49
|
-
"@tiptap/extension-
|
|
50
|
-
"@tiptap/
|
|
51
|
-
"@tiptap/
|
|
52
|
-
"@tiptap/
|
|
53
|
-
"@tiptap/
|
|
54
|
-
"@tiptap/
|
|
43
|
+
"@tiptap/extension-color": "^2.9.1",
|
|
44
|
+
"@tiptap/extension-focus": "^2.5.9",
|
|
45
|
+
"@tiptap/extension-horizontal-rule": "^2.5.9",
|
|
46
|
+
"@tiptap/extension-image": "^2.5.9",
|
|
47
|
+
"@tiptap/extension-placeholder": "^2.5.9",
|
|
48
|
+
"@tiptap/extension-table": "^2.5.8",
|
|
49
|
+
"@tiptap/extension-table-cell": "^2.5.8",
|
|
50
|
+
"@tiptap/extension-table-header": "^2.5.8",
|
|
51
|
+
"@tiptap/extension-table-row": "^2.5.8",
|
|
52
|
+
"@tiptap/extension-text-align": "^2.5.8",
|
|
53
|
+
"@tiptap/extension-text-style": "^2.9.1",
|
|
54
|
+
"@tiptap/extension-underline": "^2.5.8",
|
|
55
|
+
"@tiptap/pm": "^2.5.8",
|
|
56
|
+
"@tiptap/react": "^2.5.8",
|
|
57
|
+
"@tiptap/starter-kit": "^2.5.8",
|
|
58
|
+
"@tiptap/suggestion": "^2.5.9",
|
|
55
59
|
"@uiw/codemirror-theme-vscode": "^4.23.6",
|
|
56
60
|
"@uiw/react-codemirror": "^4.23.6",
|
|
57
|
-
"d3-scale": "^4.0.2",
|
|
58
|
-
"d3-shape": "^3.2.0",
|
|
59
61
|
"deepmerge": "^4.3.1",
|
|
60
62
|
"exceljs": "^4.4.0",
|
|
61
63
|
"lucide-react": "^0.469.0",
|
|
@@ -81,22 +83,12 @@
|
|
|
81
83
|
},
|
|
82
84
|
"devDependencies": {
|
|
83
85
|
"@tanstack/react-query": "5.59.16",
|
|
84
|
-
"@types/d3-scale": "^4.0.9",
|
|
85
|
-
"@types/d3-shape": "^3.1.8",
|
|
86
86
|
"@types/overlayscrollbars": "^1.12.5",
|
|
87
|
-
"@types/react": "
|
|
88
|
-
"@types/react-dom": "19.0.3",
|
|
87
|
+
"@types/react-dom": "^18.3.0",
|
|
89
88
|
"@types/react-window": "^1.8.8",
|
|
90
89
|
"@types/spark-md5": "^3.0.4",
|
|
91
90
|
"chokidar-cli": "^3.0.0",
|
|
92
91
|
"typescript": "^5.5.4",
|
|
93
92
|
"yalc": "^1.0.0-pre.53"
|
|
94
|
-
},
|
|
95
|
-
"resolutions": {
|
|
96
|
-
"@types/react": "19.0.8",
|
|
97
|
-
"prosemirror-model": "1.25.4",
|
|
98
|
-
"prosemirror-state": "1.4.4",
|
|
99
|
-
"prosemirror-transform": "1.12.0",
|
|
100
|
-
"prosemirror-view": "1.41.8"
|
|
101
93
|
}
|
|
102
94
|
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { ReactNode } from "react";
|
|
2
|
-
import type { FormatOptions } from "../DateInput/DateInput";
|
|
3
|
-
import { Size, Variant } from "../core";
|
|
4
|
-
export type DateTimeRangeValue = {
|
|
5
|
-
start?: string | null;
|
|
6
|
-
end?: string | null;
|
|
7
|
-
};
|
|
8
|
-
export type DateTimeRangePreset = {
|
|
9
|
-
label: string;
|
|
10
|
-
getRange: () => Required<DateTimeRangeValue>;
|
|
11
|
-
};
|
|
12
|
-
export type DateTimeRangePickerChangeMeta = {
|
|
13
|
-
source: "apply" | "clear" | "preset";
|
|
14
|
-
preset?: DateTimeRangePreset;
|
|
15
|
-
};
|
|
16
|
-
export type DateTimeRangePickerProps = {
|
|
17
|
-
className?: string;
|
|
18
|
-
style?: React.CSSProperties;
|
|
19
|
-
defaultValue?: DateTimeRangeValue;
|
|
20
|
-
value?: DateTimeRangeValue;
|
|
21
|
-
onChange?: (value: DateTimeRangeValue, meta: DateTimeRangePickerChangeMeta) => void;
|
|
22
|
-
label?: string;
|
|
23
|
-
description?: ReactNode;
|
|
24
|
-
placeholder?: string;
|
|
25
|
-
startLabel?: string;
|
|
26
|
-
endLabel?: string;
|
|
27
|
-
format?: FormatOptions;
|
|
28
|
-
size?: Size;
|
|
29
|
-
variant?: Variant;
|
|
30
|
-
required?: boolean;
|
|
31
|
-
clearable?: boolean;
|
|
32
|
-
disabled?: boolean;
|
|
33
|
-
error?: string;
|
|
34
|
-
width?: string | number;
|
|
35
|
-
min?: Date;
|
|
36
|
-
max?: Date;
|
|
37
|
-
utc?: boolean;
|
|
38
|
-
presets?: DateTimeRangePreset[];
|
|
39
|
-
};
|
|
40
|
-
declare const DateTimeRangePicker: import("react").ForwardRefExoticComponent<DateTimeRangePickerProps & import("react").RefAttributes<HTMLElement>>;
|
|
41
|
-
export default DateTimeRangePicker;
|
|
@@ -1,363 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { autoUpdate, flip, FloatingPortal, offset, shift, useDismiss, useFloating, useInteractions, } from "@floating-ui/react";
|
|
3
|
-
import moment from "moment";
|
|
4
|
-
import { CalendarDaysIcon, Clock3Icon } from "lucide-react";
|
|
5
|
-
import { forwardRef, useCallback, useEffect, useMemo, useRef, useState, } from "react";
|
|
6
|
-
import styled from "styled-components";
|
|
7
|
-
import { Button, Calendar, DateInput, FieldLabel, SegmentedControl } from "..";
|
|
8
|
-
import { ArrowButton, ClearButton, getControlSizeTokens, StyledContent, StyledFloatContainer, } from "../core";
|
|
9
|
-
const DEFAULT_FORMAT = "YYYY-MM-DD HH:mm:ss";
|
|
10
|
-
const resolveNow = (utc) => (utc ? moment.utc() : moment());
|
|
11
|
-
const serializeMoment = (value, utc) => {
|
|
12
|
-
const next = utc ? value.clone().utc() : value.clone();
|
|
13
|
-
return next.toISOString();
|
|
14
|
-
};
|
|
15
|
-
const getDefaultPresets = (utc) => {
|
|
16
|
-
const makePreset = (label, amount, unit) => ({
|
|
17
|
-
label,
|
|
18
|
-
getRange: () => {
|
|
19
|
-
const end = resolveNow(utc);
|
|
20
|
-
const start = end.clone().subtract(amount, unit);
|
|
21
|
-
return {
|
|
22
|
-
start: serializeMoment(start, utc),
|
|
23
|
-
end: serializeMoment(end, utc),
|
|
24
|
-
};
|
|
25
|
-
},
|
|
26
|
-
});
|
|
27
|
-
return [
|
|
28
|
-
makePreset("Last 15 minutes", 15, "minutes"),
|
|
29
|
-
makePreset("Last 30 minutes", 30, "minutes"),
|
|
30
|
-
makePreset("Last 1 hour", 1, "hour"),
|
|
31
|
-
makePreset("Last 24 hours", 24, "hours"),
|
|
32
|
-
makePreset("Last 7 days", 7, "days"),
|
|
33
|
-
makePreset("Last 30 days", 30, "days"),
|
|
34
|
-
];
|
|
35
|
-
};
|
|
36
|
-
const parseRangeMoment = (value, utc) => {
|
|
37
|
-
if (!value)
|
|
38
|
-
return null;
|
|
39
|
-
const parsed = utc ? moment.utc(value) : moment(value);
|
|
40
|
-
return parsed.isValid() ? parsed : null;
|
|
41
|
-
};
|
|
42
|
-
const momentToCalendarDate = (value, utc) => {
|
|
43
|
-
const parsed = parseRangeMoment(value, utc);
|
|
44
|
-
if (!parsed)
|
|
45
|
-
return undefined;
|
|
46
|
-
if (!utc)
|
|
47
|
-
return parsed.toDate();
|
|
48
|
-
return new Date(parsed.year(), parsed.month(), parsed.date(), parsed.hour(), parsed.minute(), parsed.second(), parsed.millisecond());
|
|
49
|
-
};
|
|
50
|
-
const calendarDateToMoment = (value, utc) => {
|
|
51
|
-
if (!utc)
|
|
52
|
-
return moment(value);
|
|
53
|
-
return moment.utc({
|
|
54
|
-
year: value.getFullYear(),
|
|
55
|
-
month: value.getMonth(),
|
|
56
|
-
date: value.getDate(),
|
|
57
|
-
hour: value.getHours(),
|
|
58
|
-
minute: value.getMinutes(),
|
|
59
|
-
second: value.getSeconds(),
|
|
60
|
-
millisecond: value.getMilliseconds(),
|
|
61
|
-
});
|
|
62
|
-
};
|
|
63
|
-
const formatDisplay = (value, format, utc) => {
|
|
64
|
-
const parsed = parseRangeMoment(value, utc);
|
|
65
|
-
if (!parsed)
|
|
66
|
-
return "";
|
|
67
|
-
return parsed.format(format);
|
|
68
|
-
};
|
|
69
|
-
const StyledContainer = styled.div.attrs({
|
|
70
|
-
className: "mfui-DateTimeRangePicker",
|
|
71
|
-
}) `
|
|
72
|
-
width: ${({ $width }) => {
|
|
73
|
-
if ($width === undefined || $width === null)
|
|
74
|
-
return "100%";
|
|
75
|
-
return typeof $width === "number" ? `${$width}px` : $width;
|
|
76
|
-
}};
|
|
77
|
-
`;
|
|
78
|
-
const StyledTrigger = styled.button `
|
|
79
|
-
position: relative;
|
|
80
|
-
display: flex;
|
|
81
|
-
align-items: center;
|
|
82
|
-
gap: ${({ size }) => `${getControlSizeTokens(size).iconGap}px`};
|
|
83
|
-
width: 100%;
|
|
84
|
-
height: ${({ size }) => `${getControlSizeTokens(size).height}px`};
|
|
85
|
-
padding: ${({ size }) => `0 ${getControlSizeTokens(size).adornmentWidth}px 0 ${getControlSizeTokens(size).inputPaddingX}px`};
|
|
86
|
-
border-radius: 5px;
|
|
87
|
-
border: 1px solid
|
|
88
|
-
${({ theme, variant }) => variant === "filled" || variant === "text"
|
|
89
|
-
? "transparent"
|
|
90
|
-
: theme.palette.input.border};
|
|
91
|
-
outline: none;
|
|
92
|
-
background: ${({ theme, variant }) => variant === "text" ? "transparent" : theme.palette.input.background};
|
|
93
|
-
color: ${({ theme }) => theme.palette.text.primary};
|
|
94
|
-
font-family: ${({ theme }) => theme.typography.fontFamily};
|
|
95
|
-
font-size: ${({ size }) => `${getControlSizeTokens(size).fontSize}px`};
|
|
96
|
-
text-align: left;
|
|
97
|
-
cursor: pointer;
|
|
98
|
-
transition: border 0.1s ease-in-out;
|
|
99
|
-
|
|
100
|
-
&:focus-visible,
|
|
101
|
-
&:focus {
|
|
102
|
-
border-color: ${({ theme }) => theme.palette.primary.main};
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
&:disabled {
|
|
106
|
-
cursor: not-allowed;
|
|
107
|
-
opacity: 0.5;
|
|
108
|
-
}
|
|
109
|
-
`;
|
|
110
|
-
const TriggerIcon = styled.span `
|
|
111
|
-
display: inline-flex;
|
|
112
|
-
align-items: center;
|
|
113
|
-
color: ${({ theme }) => theme.palette.text.secondary};
|
|
114
|
-
|
|
115
|
-
svg {
|
|
116
|
-
width: ${({ size }) => `${getControlSizeTokens(size).iconSize}px`};
|
|
117
|
-
height: ${({ size }) => `${getControlSizeTokens(size).iconSize}px`};
|
|
118
|
-
}
|
|
119
|
-
`;
|
|
120
|
-
const TriggerText = styled.span `
|
|
121
|
-
min-width: 0;
|
|
122
|
-
overflow: hidden;
|
|
123
|
-
text-overflow: ellipsis;
|
|
124
|
-
white-space: nowrap;
|
|
125
|
-
color: ${({ theme, $empty }) => $empty ? theme.palette.input.placeholder : theme.palette.text.primary};
|
|
126
|
-
`;
|
|
127
|
-
const TriggerActions = styled.span `
|
|
128
|
-
position: absolute;
|
|
129
|
-
right: 0;
|
|
130
|
-
top: 0;
|
|
131
|
-
display: flex;
|
|
132
|
-
height: 100%;
|
|
133
|
-
`;
|
|
134
|
-
const PickerPanel = styled.div `
|
|
135
|
-
display: grid;
|
|
136
|
-
grid-template-columns: 172px minmax(430px, 1fr);
|
|
137
|
-
gap: 10px;
|
|
138
|
-
width: min(720px, calc(100vw - 32px));
|
|
139
|
-
|
|
140
|
-
@media (max-width: 640px) {
|
|
141
|
-
grid-template-columns: minmax(0, 1fr);
|
|
142
|
-
width: calc(100vw - 32px);
|
|
143
|
-
}
|
|
144
|
-
`;
|
|
145
|
-
const PresetColumn = styled.div `
|
|
146
|
-
display: flex;
|
|
147
|
-
flex-direction: column;
|
|
148
|
-
gap: 4px;
|
|
149
|
-
padding-right: 10px;
|
|
150
|
-
border-right: 1px solid ${({ theme }) => theme.palette.divider};
|
|
151
|
-
|
|
152
|
-
@media (max-width: 640px) {
|
|
153
|
-
padding-right: 0;
|
|
154
|
-
padding-bottom: 10px;
|
|
155
|
-
border-right: none;
|
|
156
|
-
border-bottom: 1px solid ${({ theme }) => theme.palette.divider};
|
|
157
|
-
}
|
|
158
|
-
`;
|
|
159
|
-
const PanelTitle = styled.div `
|
|
160
|
-
font-size: 11px;
|
|
161
|
-
font-weight: 700;
|
|
162
|
-
line-height: 1.2;
|
|
163
|
-
text-transform: uppercase;
|
|
164
|
-
color: ${({ theme }) => theme.palette.text.secondary};
|
|
165
|
-
margin-bottom: 4px;
|
|
166
|
-
`;
|
|
167
|
-
const PresetButton = styled.button `
|
|
168
|
-
display: flex;
|
|
169
|
-
align-items: center;
|
|
170
|
-
width: 100%;
|
|
171
|
-
min-height: 28px;
|
|
172
|
-
padding: 0 8px;
|
|
173
|
-
border: none;
|
|
174
|
-
border-radius: 4px;
|
|
175
|
-
background: transparent;
|
|
176
|
-
color: ${({ theme }) => theme.palette.text.primary};
|
|
177
|
-
font: inherit;
|
|
178
|
-
font-size: 12px;
|
|
179
|
-
text-align: left;
|
|
180
|
-
cursor: pointer;
|
|
181
|
-
|
|
182
|
-
&:hover,
|
|
183
|
-
&:focus-visible {
|
|
184
|
-
background: ${({ theme }) => theme.palette.action.hover};
|
|
185
|
-
outline: none;
|
|
186
|
-
}
|
|
187
|
-
`;
|
|
188
|
-
const CustomColumn = styled.div `
|
|
189
|
-
display: flex;
|
|
190
|
-
flex-direction: column;
|
|
191
|
-
gap: 10px;
|
|
192
|
-
min-width: 0;
|
|
193
|
-
`;
|
|
194
|
-
const InputGrid = styled.div `
|
|
195
|
-
display: grid;
|
|
196
|
-
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
197
|
-
gap: 8px;
|
|
198
|
-
|
|
199
|
-
@media (max-width: 640px) {
|
|
200
|
-
grid-template-columns: minmax(0, 1fr);
|
|
201
|
-
}
|
|
202
|
-
`;
|
|
203
|
-
const EndpointField = styled.div `
|
|
204
|
-
min-width: 0;
|
|
205
|
-
`;
|
|
206
|
-
const ActiveControlRow = styled.div `
|
|
207
|
-
display: flex;
|
|
208
|
-
align-items: center;
|
|
209
|
-
justify-content: space-between;
|
|
210
|
-
gap: 10px;
|
|
211
|
-
`;
|
|
212
|
-
const CalendarShell = styled.div `
|
|
213
|
-
display: flex;
|
|
214
|
-
justify-content: center;
|
|
215
|
-
padding: 8px;
|
|
216
|
-
overflow-x: auto;
|
|
217
|
-
border: 1px solid ${({ theme }) => theme.palette.divider};
|
|
218
|
-
border-radius: 5px;
|
|
219
|
-
background: ${({ theme }) => theme.palette.background.paper};
|
|
220
|
-
`;
|
|
221
|
-
const ValidationText = styled.div `
|
|
222
|
-
min-height: 16px;
|
|
223
|
-
font-size: 11px;
|
|
224
|
-
color: ${({ theme }) => theme.palette.error.main};
|
|
225
|
-
`;
|
|
226
|
-
const ActionRow = styled.div `
|
|
227
|
-
display: flex;
|
|
228
|
-
justify-content: flex-end;
|
|
229
|
-
gap: 8px;
|
|
230
|
-
`;
|
|
231
|
-
const FooterMeta = styled.div `
|
|
232
|
-
display: flex;
|
|
233
|
-
align-items: center;
|
|
234
|
-
gap: 5px;
|
|
235
|
-
margin-right: auto;
|
|
236
|
-
color: ${({ theme }) => theme.palette.text.secondary};
|
|
237
|
-
font-size: 11px;
|
|
238
|
-
|
|
239
|
-
svg {
|
|
240
|
-
width: 13px;
|
|
241
|
-
height: 13px;
|
|
242
|
-
}
|
|
243
|
-
`;
|
|
244
|
-
const DateTimeRangePicker = forwardRef(({ className, style, defaultValue = { start: null, end: null }, value, onChange = () => { }, label, description, placeholder = "Select date/time range", startLabel = "Start", endLabel = "End", format = DEFAULT_FORMAT, size = "sm", variant = "outlined", required = false, clearable = true, disabled = false, error, width, min, max, utc = false, presets, }, ref) => {
|
|
245
|
-
var _a, _b;
|
|
246
|
-
const isControlled = useRef(value !== undefined);
|
|
247
|
-
const [uncontrolledValue, setUncontrolledValue] = useState(defaultValue);
|
|
248
|
-
const _value = isControlled.current ? value || {} : uncontrolledValue;
|
|
249
|
-
const [isOpen, setIsOpen] = useState(false);
|
|
250
|
-
const [draftValue, setDraftValue] = useState(_value);
|
|
251
|
-
const [activeEndpoint, setActiveEndpoint] = useState("start");
|
|
252
|
-
const resolvedPresets = useMemo(() => presets || getDefaultPresets(utc), [presets, utc]);
|
|
253
|
-
const { refs, floatingStyles, context } = useFloating({
|
|
254
|
-
open: isOpen,
|
|
255
|
-
onOpenChange: setIsOpen,
|
|
256
|
-
placement: "bottom-start",
|
|
257
|
-
strategy: "absolute",
|
|
258
|
-
middleware: [offset(5), flip(), shift({ padding: 8 })],
|
|
259
|
-
whileElementsMounted: autoUpdate,
|
|
260
|
-
});
|
|
261
|
-
const dismiss = useDismiss(context, {
|
|
262
|
-
outsidePress: (event) => {
|
|
263
|
-
var _a, _b, _c;
|
|
264
|
-
const target = event.target;
|
|
265
|
-
if (((_a = target === null || target === void 0 ? void 0 : target.closest) === null || _a === void 0 ? void 0 : _a.call(target, ".mfui-DateInput")) ||
|
|
266
|
-
((_b = target === null || target === void 0 ? void 0 : target.closest) === null || _b === void 0 ? void 0 : _b.call(target, ".mfui-DropDownMenu")) ||
|
|
267
|
-
((_c = target === null || target === void 0 ? void 0 : target.closest) === null || _c === void 0 ? void 0 : _c.call(target, ".Menu"))) {
|
|
268
|
-
return false;
|
|
269
|
-
}
|
|
270
|
-
return true;
|
|
271
|
-
},
|
|
272
|
-
});
|
|
273
|
-
const { getReferenceProps, getFloatingProps } = useInteractions([dismiss]);
|
|
274
|
-
useEffect(() => {
|
|
275
|
-
if (isOpen) {
|
|
276
|
-
setDraftValue(_value);
|
|
277
|
-
setActiveEndpoint(_value.start ? "end" : "start");
|
|
278
|
-
}
|
|
279
|
-
}, [isOpen, _value.start, _value.end]);
|
|
280
|
-
const commitValue = useCallback((nextValue, meta) => {
|
|
281
|
-
if (!isControlled.current) {
|
|
282
|
-
setUncontrolledValue(nextValue);
|
|
283
|
-
}
|
|
284
|
-
onChange(nextValue, meta);
|
|
285
|
-
}, [onChange]);
|
|
286
|
-
const displayValue = useMemo(() => {
|
|
287
|
-
if (!_value.start && !_value.end)
|
|
288
|
-
return "";
|
|
289
|
-
const start = formatDisplay(_value.start, format, utc) || "Start";
|
|
290
|
-
const end = formatDisplay(_value.end, format, utc) || "End";
|
|
291
|
-
return `${start} - ${end}${utc ? " UTC" : ""}`;
|
|
292
|
-
}, [_value.start, _value.end, format, utc]);
|
|
293
|
-
const validationError = useMemo(() => {
|
|
294
|
-
const start = parseRangeMoment(draftValue.start, utc);
|
|
295
|
-
const end = parseRangeMoment(draftValue.end, utc);
|
|
296
|
-
if (!start || !end)
|
|
297
|
-
return "Select both a start and end timestamp.";
|
|
298
|
-
if (start.isAfter(end))
|
|
299
|
-
return "Start timestamp must be before end.";
|
|
300
|
-
if (min && start.isBefore(moment(min)))
|
|
301
|
-
return "Start is before minimum.";
|
|
302
|
-
if (max && end.isAfter(moment(max)))
|
|
303
|
-
return "End is after maximum.";
|
|
304
|
-
return "";
|
|
305
|
-
}, [draftValue.start, draftValue.end, min, max, utc]);
|
|
306
|
-
const patchDraft = (patch) => {
|
|
307
|
-
setDraftValue((prev) => (Object.assign(Object.assign({}, prev), patch)));
|
|
308
|
-
};
|
|
309
|
-
const handleClear = (event) => {
|
|
310
|
-
event === null || event === void 0 ? void 0 : event.preventDefault();
|
|
311
|
-
event === null || event === void 0 ? void 0 : event.stopPropagation();
|
|
312
|
-
const emptyValue = { start: null, end: null };
|
|
313
|
-
setDraftValue(emptyValue);
|
|
314
|
-
commitValue(emptyValue, { source: "clear" });
|
|
315
|
-
setIsOpen(false);
|
|
316
|
-
};
|
|
317
|
-
const handleApply = () => {
|
|
318
|
-
if (validationError)
|
|
319
|
-
return;
|
|
320
|
-
commitValue(draftValue, { source: "apply" });
|
|
321
|
-
setIsOpen(false);
|
|
322
|
-
};
|
|
323
|
-
const handleCancel = () => {
|
|
324
|
-
setDraftValue(_value);
|
|
325
|
-
setIsOpen(false);
|
|
326
|
-
};
|
|
327
|
-
const handlePreset = (preset) => {
|
|
328
|
-
const nextValue = preset.getRange();
|
|
329
|
-
setDraftValue(nextValue);
|
|
330
|
-
commitValue(nextValue, { source: "preset", preset });
|
|
331
|
-
setIsOpen(false);
|
|
332
|
-
};
|
|
333
|
-
const handleCalendarChange = (date) => {
|
|
334
|
-
if (!date) {
|
|
335
|
-
patchDraft({ [activeEndpoint]: null });
|
|
336
|
-
return;
|
|
337
|
-
}
|
|
338
|
-
patchDraft({
|
|
339
|
-
[activeEndpoint]: serializeMoment(calendarDateToMoment(date, utc), utc),
|
|
340
|
-
});
|
|
341
|
-
};
|
|
342
|
-
const activeValue = draftValue[activeEndpoint];
|
|
343
|
-
const activeMin = activeEndpoint === "end"
|
|
344
|
-
? ((_a = parseRangeMoment(draftValue.start, utc)) === null || _a === void 0 ? void 0 : _a.toDate()) || min
|
|
345
|
-
: min;
|
|
346
|
-
const activeMax = activeEndpoint === "start"
|
|
347
|
-
? ((_b = parseRangeMoment(draftValue.end, utc)) === null || _b === void 0 ? void 0 : _b.toDate()) || max
|
|
348
|
-
: max;
|
|
349
|
-
return (_jsxs(StyledContainer, Object.assign({ ref: (node) => {
|
|
350
|
-
if (typeof ref === "function") {
|
|
351
|
-
ref(node);
|
|
352
|
-
}
|
|
353
|
-
else if (ref) {
|
|
354
|
-
ref.current = node;
|
|
355
|
-
}
|
|
356
|
-
refs.setReference(node);
|
|
357
|
-
}, className: className, "$width": width }, getReferenceProps(), { children: [label && (_jsx(FieldLabel, { error: error, asterisk: required, size: size, description: description, children: label })), _jsxs(StyledTrigger, { type: "button", size: size, variant: variant, disabled: disabled, style: style, "aria-haspopup": "dialog", "aria-expanded": isOpen, onClick: () => setIsOpen((prev) => !prev), children: [_jsx(TriggerIcon, { size: size, children: _jsx(CalendarDaysIcon, {}) }), _jsx(TriggerText, { "$empty": !displayValue, children: displayValue || placeholder }), _jsx(TriggerActions, { children: clearable && (_value.start || _value.end) ? (_jsx(ClearButton, { size: size, onClick: handleClear })) : (_jsx(ArrowButton, { size: size })) })] }), !disabled && isOpen && (_jsx(FloatingPortal, { preserveTabOrder: true, children: _jsx(StyledFloatContainer, Object.assign({ ref: refs.setFloating, style: floatingStyles }, getFloatingProps(), { children: _jsx(StyledContent, { maxDropdownHeight: "fit-content", children: _jsxs(PickerPanel, { children: [_jsxs(PresetColumn, { children: [_jsx(PanelTitle, { children: "Quick ranges" }), resolvedPresets.map((preset) => (_jsx(PresetButton, { type: "button", onClick: () => handlePreset(preset), children: preset.label }, preset.label)))] }), _jsxs(CustomColumn, { children: [_jsxs(InputGrid, { children: [_jsx(EndpointField, { onClick: () => setActiveEndpoint("start"), children: _jsx(DateInput, { label: startLabel, value: draftValue.start, onChange: (next) => patchDraft({ start: next }), format: format, size: size, variant: variant, clearable: true, utc: utc, min: min, max: activeEndpoint === "start" ? activeMax : max }) }), _jsx(EndpointField, { onClick: () => setActiveEndpoint("end"), children: _jsx(DateInput, { label: endLabel, value: draftValue.end, onChange: (next) => patchDraft({ end: next }), format: format, size: size, variant: variant, clearable: true, utc: utc, min: activeEndpoint === "end" ? activeMin : min, max: max }) })] }), _jsxs(ActiveControlRow, { children: [_jsxs(PanelTitle, { children: ["Editing ", activeEndpoint === "start" ? startLabel : endLabel] }), _jsx(SegmentedControl, { data: [
|
|
358
|
-
{ label: startLabel, value: "start" },
|
|
359
|
-
{ label: endLabel, value: "end" },
|
|
360
|
-
], value: activeEndpoint, onChange: (next) => setActiveEndpoint(next), size: "xs" })] }), _jsx(CalendarShell, { children: _jsx(Calendar, { value: momentToCalendarDate(activeValue, utc), onChange: handleCalendarChange, includeTime: true, clearable: false, min: activeMin, max: activeMax }) }), _jsx(ValidationText, { children: validationError }), _jsxs(ActionRow, { children: [_jsxs(FooterMeta, { children: [_jsx(Clock3Icon, {}), utc ? "UTC" : "Local time"] }), clearable && (_jsx(Button, { type: "button", size: size, variant: "subtle", onClick: handleClear, children: "Clear" })), _jsx(Button, { type: "button", size: size, variant: "outlined", onClick: handleCancel, children: "Cancel" }), _jsx(Button, { type: "button", size: size, variant: "contained", onClick: handleApply, disabled: Boolean(validationError), children: "Apply" })] })] })] }) }) })) }))] })));
|
|
361
|
-
});
|
|
362
|
-
DateTimeRangePicker.displayName = "DateTimeRangePicker";
|
|
363
|
-
export default DateTimeRangePicker;
|