@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.
Files changed (171) hide show
  1. package/dist/Button/Button.js +58 -9
  2. package/dist/Calendar/Calendar.d.ts +2 -7
  3. package/dist/Calendar/Calendar.js +49 -226
  4. package/dist/Calendar/CalendarStyles.d.ts +2 -6
  5. package/dist/Calendar/CalendarStyles.js +33 -153
  6. package/dist/Calendar/calendarHelpers.d.ts +2 -6
  7. package/dist/Calendar/calendarHelpers.js +5 -13
  8. package/dist/Charts/BarChart/BarChart.js +28 -14
  9. package/dist/Charts/BarChart/BarChart.styled.d.ts +7 -2
  10. package/dist/Charts/BarChart/BarChart.styled.js +5 -1
  11. package/dist/Charts/BarChart/BarChart.types.d.ts +13 -5
  12. package/dist/Charts/ChartUtils/chartSizing.d.ts +20 -0
  13. package/dist/Charts/ChartUtils/chartSizing.js +83 -0
  14. package/dist/Charts/ChartUtils/index.d.ts +1 -0
  15. package/dist/Charts/ChartUtils/index.js +1 -0
  16. package/dist/Charts/HeatMap/HeatMap.js +28 -7
  17. package/dist/Charts/HeatMap/HeatMap.styled.d.ts +6 -2
  18. package/dist/Charts/HeatMap/HeatMap.styled.js +3 -0
  19. package/dist/Charts/HeatMap/HeatMap.types.d.ts +7 -1
  20. package/dist/Charts/LineChart/LineChart.js +34 -15
  21. package/dist/Charts/LineChart/LineChart.styled.d.ts +7 -2
  22. package/dist/Charts/LineChart/LineChart.styled.js +5 -1
  23. package/dist/Charts/LineChart/LineChart.types.d.ts +13 -5
  24. package/dist/Charts/PieChart/PieChart.js +48 -33
  25. package/dist/Charts/PieChart/PieChart.styled.d.ts +7 -2
  26. package/dist/Charts/PieChart/PieChart.styled.js +6 -1
  27. package/dist/Charts/PieChart/PieChart.types.d.ts +7 -3
  28. package/dist/CheckBox/CheckBox.js +19 -36
  29. package/dist/DateInput/DateInput.js +143 -198
  30. package/dist/DropDownMenu/DropDownMenu.js +15 -25
  31. package/dist/DropDownMenu/components/MenuComponent.js +2 -8
  32. package/dist/DropDownMenu/components/MenuItem.d.ts +0 -2
  33. package/dist/DropDownMenu/components/MenuItem.js +21 -25
  34. package/dist/DropDownMenu/components/MenuItemList.d.ts +0 -3
  35. package/dist/DropDownMenu/components/MenuItemList.js +86 -192
  36. package/dist/DropDownMenu/components/StyledContent.js +2 -1
  37. package/dist/DropDownMenu/components/StyledFloatContainer.js +1 -1
  38. package/dist/DropDownMenu/types.d.ts +0 -3
  39. package/dist/FieldLabel/FieldLabel.js +12 -4
  40. package/dist/FileInputField/FileInputField.js +23 -4
  41. package/dist/FileViewer/viewers/ImageViewer.js +18 -75
  42. package/dist/FormSection/FormSection.js +25 -5
  43. package/dist/IconButton/IconButton.js +16 -2
  44. package/dist/Input/Input.js +56 -7
  45. package/dist/MonolithUIProvider/MonolithUIProvider.d.ts +4 -1
  46. package/dist/Pill/Pill.js +79 -8
  47. package/dist/Popover/Popover.context.d.ts +1 -2
  48. package/dist/Popover/Popover.js +2 -5
  49. package/dist/Popover/Popover.styles.d.ts +6 -1
  50. package/dist/Popover/Popover.styles.js +28 -11
  51. package/dist/Popover/Popover.transitions.d.ts +2 -4
  52. package/dist/Popover/Popover.transitions.js +49 -23
  53. package/dist/Popover/PopoverDropdown.js +8 -6
  54. package/dist/Popover/PopoverTarget.js +3 -6
  55. package/dist/QueryFilter/DefaultOperators.d.ts +76 -1
  56. package/dist/QueryFilter/DefaultOperators.js +21 -1
  57. package/dist/QueryFilter/QueryFilter.d.ts +1 -1
  58. package/dist/QueryFilter/QueryFilter.js +303 -3
  59. package/dist/QueryFilter/index.d.ts +2 -3
  60. package/dist/QueryFilter/index.js +2 -3
  61. package/dist/QueryFilter/types.d.ts +52 -1
  62. package/dist/QueryFilter/types.js +1 -1
  63. package/dist/QueryFilter/useQueryFilter.d.ts +1 -1
  64. package/dist/QueryFilter/useQueryFilter.js +19 -23
  65. package/dist/RichTextEditor/Components/CodeBlockBaseButton.d.ts +18 -0
  66. package/dist/RichTextEditor/Components/CodeBlockBaseButton.js +6 -0
  67. package/dist/RichTextEditor/Components/CodeBlockCopyButton.d.ts +9 -0
  68. package/dist/RichTextEditor/Components/CodeBlockCopyButton.js +42 -0
  69. package/dist/RichTextEditor/Components/CodeBlockFormatButton.d.ts +10 -0
  70. package/dist/RichTextEditor/Components/CodeBlockFormatButton.js +60 -0
  71. package/dist/RichTextEditor/Components/CodeBlockLanguageSelect.d.ts +9 -0
  72. package/dist/RichTextEditor/Components/CodeBlockLanguageSelect.js +30 -0
  73. package/dist/RichTextEditor/Components/CodeBlockNodeView.d.ts +3 -0
  74. package/dist/RichTextEditor/Components/CodeBlockNodeView.js +28 -0
  75. package/dist/RichTextEditor/Components/CodeBlockWrapButton.d.ts +10 -0
  76. package/dist/RichTextEditor/Components/CodeBlockWrapButton.js +17 -0
  77. package/dist/RichTextEditor/Components/LinkEditor.d.ts +8 -0
  78. package/dist/RichTextEditor/Components/LinkEditor.js +94 -0
  79. package/dist/RichTextEditor/Components/TableTools/TableCornerMenu.d.ts +2 -0
  80. package/dist/RichTextEditor/Components/TableTools/TableCornerMenu.js +19 -0
  81. package/dist/RichTextEditor/Components/TableTools/TableInsertControls.d.ts +2 -0
  82. package/dist/RichTextEditor/Components/TableTools/TableInsertControls.js +24 -0
  83. package/dist/RichTextEditor/Components/TableTools/TableRails.d.ts +2 -0
  84. package/dist/RichTextEditor/Components/TableTools/TableRails.js +180 -0
  85. package/dist/RichTextEditor/Components/TableTools/TableToolMenu.d.ts +5 -0
  86. package/dist/RichTextEditor/Components/TableTools/TableToolMenu.js +6 -0
  87. package/dist/RichTextEditor/Components/TableTools/TableTools.actions.d.ts +5 -0
  88. package/dist/RichTextEditor/Components/TableTools/TableTools.actions.js +183 -0
  89. package/dist/RichTextEditor/Components/TableTools/TableTools.commands.d.ts +16 -0
  90. package/dist/RichTextEditor/Components/TableTools/TableTools.commands.js +217 -0
  91. package/dist/RichTextEditor/Components/TableTools/TableTools.constants.d.ts +8 -0
  92. package/dist/RichTextEditor/Components/TableTools/TableTools.constants.js +11 -0
  93. package/dist/RichTextEditor/Components/TableTools/TableTools.d.ts +3 -0
  94. package/dist/RichTextEditor/Components/TableTools/TableTools.geometry.d.ts +23 -0
  95. package/dist/RichTextEditor/Components/TableTools/TableTools.geometry.js +75 -0
  96. package/dist/RichTextEditor/Components/TableTools/TableTools.js +3 -0
  97. package/dist/RichTextEditor/Components/TableTools/TableTools.selectors.d.ts +16 -0
  98. package/dist/RichTextEditor/Components/TableTools/TableTools.selectors.js +53 -0
  99. package/dist/RichTextEditor/Components/TableTools/TableTools.styled.d.ts +40 -0
  100. package/dist/RichTextEditor/Components/TableTools/TableTools.styled.js +167 -0
  101. package/dist/RichTextEditor/Components/TableTools/TableTools.types.d.ts +76 -0
  102. package/dist/RichTextEditor/Components/TableTools/TableTools.types.js +1 -0
  103. package/dist/RichTextEditor/Components/TableTools/TableTools.utils.d.ts +4 -0
  104. package/dist/RichTextEditor/Components/TableTools/TableTools.utils.js +4 -0
  105. package/dist/RichTextEditor/Components/TableTools/TableToolsPopover.d.ts +2 -0
  106. package/dist/RichTextEditor/Components/TableTools/TableToolsPopover.js +12 -0
  107. package/dist/RichTextEditor/Components/TableTools/index.d.ts +3 -0
  108. package/dist/RichTextEditor/Components/TableTools/index.js +2 -0
  109. package/dist/RichTextEditor/Enums/HighlightColors.d.ts +9 -0
  110. package/dist/RichTextEditor/Enums/HighlightColors.js +10 -0
  111. package/dist/RichTextEditor/Extensions/getTiptapExtensions.js +15 -5
  112. package/dist/RichTextEditor/Plugins/ImageActionsPlugin.js +4 -7
  113. package/dist/RichTextEditor/Plugins/UploadImagesPlugin.d.ts +0 -15
  114. package/dist/RichTextEditor/Plugins/UploadImagesPlugin.js +51 -115
  115. package/dist/RichTextEditor/Plugins/index.d.ts +0 -1
  116. package/dist/RichTextEditor/Plugins/index.js +0 -1
  117. package/dist/RichTextEditor/RichTextEditor.d.ts +2 -3
  118. package/dist/RichTextEditor/RichTextEditor.js +35 -302
  119. package/dist/RichTextEditor/Utils/codeBlockUtils.d.ts +20 -0
  120. package/dist/RichTextEditor/Utils/codeBlockUtils.js +137 -0
  121. package/dist/RichTextEditor/Utils/codeUtils.d.ts +3 -0
  122. package/dist/RichTextEditor/Utils/codeUtils.js +12 -0
  123. package/dist/RichTextEditor/Utils/linkUtils.d.ts +19 -0
  124. package/dist/RichTextEditor/Utils/linkUtils.js +57 -0
  125. package/dist/RichTextEditor/Utils/tableUtils.d.ts +1 -0
  126. package/dist/RichTextEditor/Utils/tableUtils.js +1 -0
  127. package/dist/SegmentedControl/SegmentedControl.utils.d.ts +2 -2
  128. package/dist/SegmentedControl/SegmentedControl.utils.js +30 -3
  129. package/dist/SelectBox/SelectBox.js +5 -5
  130. package/dist/SelectBox/select-box.styled-components.d.ts +1 -4
  131. package/dist/SelectBox/select-box.styled-components.js +48 -11
  132. package/dist/SelectBox/types.d.ts +0 -1
  133. package/dist/Switch/Switch.d.ts +2 -2
  134. package/dist/Switch/Switch.js +83 -18
  135. package/dist/Table/ColumnResizer.d.ts +9 -6
  136. package/dist/Table/ColumnResizer.js +10 -30
  137. package/dist/Table/StateStorage.d.ts +0 -4
  138. package/dist/Table/StateStorage.js +0 -13
  139. package/dist/Table/Table.js +12 -160
  140. package/dist/Table/TableComponents.d.ts +0 -10
  141. package/dist/Table/TableComponents.js +10 -71
  142. package/dist/Table/TableDefaults.d.ts +0 -7
  143. package/dist/Table/TableDefaults.js +0 -7
  144. package/dist/Table/TableHeader.js +16 -31
  145. package/dist/Table/TableMenu/TableMenu.js +1 -1
  146. package/dist/Table/TableProvider.js +75 -354
  147. package/dist/Table/TableRow.js +16 -28
  148. package/dist/Table/Utils/index.d.ts +1 -0
  149. package/dist/Table/Utils/index.js +1 -0
  150. package/dist/Table/types.d.ts +19 -70
  151. package/dist/TagBox/TagBox.d.ts +1 -1
  152. package/dist/TagBox/TagBox.js +80 -22
  153. package/dist/TagBox/types.d.ts +0 -1
  154. package/dist/TextArea/TextArea.js +23 -9
  155. package/dist/TextInput/TextInput.js +6 -12
  156. package/dist/Utilities/parseTimestamp.js +6 -11
  157. package/dist/core/ArrowButton.d.ts +0 -2
  158. package/dist/core/ArrowButton.js +3 -7
  159. package/dist/core/ClearButton.d.ts +0 -2
  160. package/dist/core/ClearButton.js +3 -7
  161. package/dist/core/controlSizes.js +9 -9
  162. package/dist/core/index.d.ts +0 -1
  163. package/dist/core/index.js +0 -1
  164. package/dist/index.d.ts +0 -3
  165. package/dist/index.js +0 -2
  166. package/dist/theme/variants.js +8 -2
  167. package/package.json +18 -26
  168. package/dist/DateTimeRangePicker/DateTimeRangePicker.d.ts +0 -41
  169. package/dist/DateTimeRangePicker/DateTimeRangePicker.js +0 -363
  170. package/dist/DateTimeRangePicker/index.d.ts +0 -2
  171. package/dist/DateTimeRangePicker/index.js +0 -2
@@ -1,6 +1,11 @@
1
1
  import { StyledChartActions } from "../ChartPrimitives";
2
- export declare const StyledContainer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
3
- export declare const StyledChartWrap: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
2
+ export declare const StyledContainer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
3
+ $fillAvailableWidth: boolean;
4
+ }>> & string;
5
+ export declare const StyledChartWrap: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
6
+ $width?: string;
7
+ $height?: string;
8
+ }>> & string;
4
9
  export { StyledChartActions };
5
10
  export declare const StyledSvg: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").SVGProps<SVGSVGElement>, never>> & string;
6
11
  export declare const StyledSlice: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").SVGProps<SVGPathElement>, {
@@ -11,7 +11,7 @@ export const StyledContainer = styled.div `
11
11
  align-items: center;
12
12
  flex-wrap: wrap;
13
13
  gap: 20px;
14
- width: fit-content;
14
+ width: ${({ $fillAvailableWidth }) => $fillAvailableWidth ? "100%" : "fit-content"};
15
15
  max-width: 100%;
16
16
  color: ${({ theme }) => theme.palette.text.primary};
17
17
  box-sizing: border-box;
@@ -24,6 +24,10 @@ export const StyledChartWrap = styled.div `
24
24
  align-items: stretch;
25
25
  justify-content: center;
26
26
  flex: 0 0 auto;
27
+ width: ${({ $width }) => $width !== null && $width !== void 0 ? $width : "auto"};
28
+ height: ${({ $height }) => $height !== null && $height !== void 0 ? $height : "auto"};
29
+ max-width: 100%;
30
+ box-sizing: border-box;
27
31
  `;
28
32
  export { StyledChartActions };
29
33
  export const StyledSvg = styled.svg `
@@ -146,6 +150,7 @@ export const StyledEmptyState = styled.div `
146
150
  justify-content: center;
147
151
  width: ${({ $size }) => $size}px;
148
152
  height: ${({ $size }) => $size}px;
153
+ box-sizing: border-box;
149
154
  border: 1px dashed ${({ theme }) => theme.palette.divider};
150
155
  border-radius: 50%;
151
156
  background: radial-gradient(
@@ -1,6 +1,6 @@
1
1
  import React, { HTMLAttributes } from "react";
2
2
  import { PieArcDatum } from "d3-shape";
3
- import type { ChartExportOptions } from "../ChartUtils";
3
+ import type { ChartDimension, ChartExportOptions } from "../ChartUtils";
4
4
  export type PieChartDatum<TData = unknown> = {
5
5
  /** Stable identifier for the slice. Falls back to label and index when omitted. */
6
6
  id?: string | number;
@@ -26,8 +26,12 @@ string[]
26
26
  export type PieChartProps<TData = unknown> = HTMLAttributes<HTMLDivElement> & ChartExportOptions & {
27
27
  /** Slice data rendered by the chart. Only positive finite values are displayed. */
28
28
  data: PieChartDatum<TData>[];
29
- /** SVG width and height in pixels. Defaults to 220. */
30
- size?: number;
29
+ /** SVG width and height in pixels or any CSS length measured from the chart frame. Defaults to 220. */
30
+ size?: ChartDimension;
31
+ /** Measures the chart frame and fits the square SVG to its available width. Defaults to false. */
32
+ responsive?: boolean;
33
+ /** Minimum rendered SVG size in pixels. Defaults to 120. */
34
+ minSize?: number;
31
35
  /** Inner radius in pixels. Set to 0 for a solid pie. Defaults to 58. */
32
36
  innerRadius?: number;
33
37
  /** Outer radius in pixels. Defaults to half the size minus chart padding. */
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import styled from "styled-components";
3
3
  import { useState, useEffect } from "react";
4
- import { getControlSizeTokens } from "../core";
4
+ import { FaCheckSquare, FaRegSquare, FaRegMinusSquare } from "react-icons/fa";
5
5
  const CheckBox = styled(({ className, defaultValue = false, value, partialCheck = false, onChange = () => { }, }) => {
6
6
  const [checkedState, setCheckedState] = useState(defaultValue);
7
7
  const handleChange = (e) => {
@@ -14,47 +14,30 @@ const CheckBox = styled(({ className, defaultValue = false, value, partialCheck
14
14
  setCheckedState(value);
15
15
  }, [value]);
16
16
  const _checked = value === undefined ? checkedState : value;
17
- return (_jsx("div", { className: className, onClick: handleChange, children: partialCheck === true ? (_jsx("span", { className: "checkbox partial" })) : _checked === true ? (_jsx("span", { className: "checkbox checked" })) : (_jsx("span", { className: "checkbox unchecked" })) }));
17
+ return (_jsx("div", { className: className, onClick: handleChange, children: partialCheck === true ? (_jsx(FaRegMinusSquare, { className: "checkbox partial" })) : _checked === true ? (_jsx(FaCheckSquare, { className: "checkbox checked" })) : (_jsx(FaRegSquare, { className: "checkbox unchecked" })) }));
18
18
  }) `
19
19
  display: flex;
20
20
  align-items: center;
21
21
  cursor: pointer;
22
22
 
23
23
  .checkbox {
24
- position: relative;
25
- display: inline-flex;
26
- align-items: center;
27
- justify-content: center;
28
- box-sizing: border-box;
29
- width: ${({ size }) => `${getControlSizeTokens(size).checkboxIconSize}px`};
30
- height: ${({ size }) => `${getControlSizeTokens(size).checkboxIconSize}px`};
31
- border: 1px solid ${(props) => props.theme.palette.primary.main};
32
- border-radius: 2px;
33
- }
34
-
35
- .checked,
36
- .partial {
37
- background-color: ${(props) => props.theme.palette.primary.main};
38
- }
39
-
40
- .checked::after {
41
- content: "";
42
- position: absolute;
43
- left: 50%;
44
- top: 45%;
45
- width: 32%;
46
- height: 56%;
47
- border: solid #fff;
48
- border-width: 0 2px 2px 0;
49
- transform: translate(-50%, -50%) rotate(45deg);
50
- transform-origin: center;
51
- }
52
-
53
- .partial::after {
54
- content: "";
55
- width: 60%;
56
- height: 2px;
57
- background-color: #fff;
24
+ color: ${(props) => props.theme.palette.primary.main};
25
+ font-size: ${({ size }) => {
26
+ switch (size) {
27
+ case "xxs":
28
+ return "12px";
29
+ case "xs":
30
+ return "14px";
31
+ case "sm":
32
+ return "16px";
33
+ case "md":
34
+ return "18px";
35
+ case "lg":
36
+ return "20px";
37
+ default:
38
+ return "14px";
39
+ }
40
+ }};
58
41
  }
59
42
  `;
60
43
  export default CheckBox;
@@ -10,11 +10,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
11
  import moment from "moment";
12
12
  import { useFloating, flip, offset, FloatingPortal, useDismiss, useInteractions, autoUpdate, } from "@floating-ui/react";
13
- import { CalendarDaysIcon } from "lucide-react";
14
- import { forwardRef, useCallback, useEffect, useMemo, useRef, useState, } from "react";
13
+ import { forwardRef, useEffect, useMemo, useRef, useState, } from "react";
15
14
  import styled from "styled-components";
16
15
  import { FieldLabel, Calendar } from "..";
17
- import { StyledContent, StyledFloatContainer, ArrowButton, ClearButton, getControlSizeTokens, } from "../core";
16
+ import { StyledContent, StyledFloatContainer, ArrowButton, ClearButton, } from "../core";
18
17
  import parseTimestamp from "../Utilities/parseTimestamp";
19
18
  const StyledContainer = styled.div.attrs({
20
19
  className: "mfui-DateInput",
@@ -54,19 +53,45 @@ const StyledInputContainer = styled.div `
54
53
  font-family: ${({ theme }) => theme.typography.fontFamily};
55
54
 
56
55
  color: ${(props) => props.theme.palette.text.primary};
57
- font-size: ${({ size }) => `${getControlSizeTokens(size).fontSize}px`};
56
+ font-size: ${({ size }) => size === "xs"
57
+ ? "11px"
58
+ : size === "sm"
59
+ ? "13px"
60
+ : size === "md"
61
+ ? "15px"
62
+ : size === "lg"
63
+ ? "17px"
64
+ : size === "xl"
65
+ ? "19px"
66
+ : "11px"};
58
67
 
59
68
  width: 100%;
60
- height: ${({ size }) => `${getControlSizeTokens(size).height}px`};
69
+ height: ${({ size }) => size === "xs"
70
+ ? "26px"
71
+ : size === "sm"
72
+ ? "30px"
73
+ : size === "md"
74
+ ? "36px"
75
+ : size === "lg"
76
+ ? "42px"
77
+ : size === "xl"
78
+ ? "50px"
79
+ : "26px"};
61
80
 
62
- padding: ${({ size }) => `0px ${getControlSizeTokens(size).inputPaddingX}px`};
63
-
64
- &[data-button-left="true"] {
65
- padding-left: ${({ size }) => `${getControlSizeTokens(size).adornmentWidth}px`};
66
- }
81
+ padding: ${({ size }) => size === "xs"
82
+ ? "0px 8px"
83
+ : size === "sm"
84
+ ? "0px 10px"
85
+ : size === "md"
86
+ ? "0px 12px"
87
+ : size === "lg"
88
+ ? "0px 14px"
89
+ : size === "xl"
90
+ ? "0px 16px"
91
+ : "0px 8px"};
67
92
 
68
93
  &[data-button-right="true"] {
69
- padding-right: ${({ size }) => `${getControlSizeTokens(size).adornmentWidth}px`};
94
+ padding-right: 36px;
70
95
  }
71
96
 
72
97
  background-color: ${({ theme, variant }) => {
@@ -126,44 +151,6 @@ const StyledInputContainer = styled.div `
126
151
  }
127
152
  }
128
153
  `;
129
- const CalendarTriggerButton = styled.button `
130
- position: absolute;
131
- left: 0;
132
- height: 100%;
133
- width: ${({ size }) => `${getControlSizeTokens(size).adornmentWidth}px`};
134
- background: none;
135
- border: none;
136
- cursor: pointer;
137
- margin: 0;
138
- outline: none;
139
- display: flex;
140
- align-items: center;
141
- justify-content: center;
142
- color: ${(props) => props.theme.palette.text.secondary};
143
- transition:
144
- color 0.15s ease-in-out,
145
- background-color 0.15s ease-in-out,
146
- transform 0.1s ease-in-out;
147
-
148
- &:hover {
149
- color: ${(props) => props.theme.palette.text.primary};
150
- background: ${(props) => props.theme.palette.action.hover};
151
- }
152
-
153
- &:active {
154
- transform: scale(0.95);
155
- }
156
-
157
- &:focus-visible {
158
- color: ${(props) => props.theme.palette.primary.main};
159
- background: ${(props) => props.theme.palette.action.hover};
160
- }
161
-
162
- svg {
163
- width: ${({ size }) => `${getControlSizeTokens(size).iconSize}px`};
164
- height: ${({ size }) => `${getControlSizeTokens(size).iconSize}px`};
165
- }
166
- `;
167
154
  const InputSegment = styled.div `
168
155
  user-select: none;
169
156
  display: flex;
@@ -174,7 +161,17 @@ const InputSegment = styled.div `
174
161
  border: none;
175
162
  padding: 0;
176
163
 
177
- height: ${({ size }) => `${getControlSizeTokens(size).height}px`};
164
+ height: ${({ size }) => size === "xs"
165
+ ? "22px"
166
+ : size === "sm"
167
+ ? "26px"
168
+ : size === "md"
169
+ ? "32px"
170
+ : size === "lg"
171
+ ? "38px"
172
+ : size === "xl"
173
+ ? "46px"
174
+ : "22px"};
178
175
 
179
176
  height: 100%;
180
177
 
@@ -182,7 +179,17 @@ const InputSegment = styled.div `
182
179
  color: ${(props) => props.theme.palette.text.primary};
183
180
 
184
181
  ::placeholder {
185
- font-size: ${({ size }) => `${getControlSizeTokens(size).placeholderFontSize}px`};
182
+ font-size: ${({ size }) => size === "xs"
183
+ ? "10px"
184
+ : size === "sm"
185
+ ? "12px"
186
+ : size === "md"
187
+ ? "14px"
188
+ : size === "lg"
189
+ ? "16px"
190
+ : size === "xl"
191
+ ? "18px"
192
+ : "10px"};
186
193
  }
187
194
  `;
188
195
  const DateInput = forwardRef(({ className, style = {}, defaultValue, value, 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, disabled = false, }, _ref) => {
@@ -205,83 +212,23 @@ const DateInput = forwardRef(({ className, style = {}, defaultValue, value, form
205
212
  middleware: [flip(), offset(5)],
206
213
  whileElementsMounted: autoUpdate,
207
214
  });
208
- const dismiss = useDismiss(context, {
209
- outsidePress: (event) => {
210
- var _a, _b;
211
- const target = event.target;
212
- if (((_a = target === null || target === void 0 ? void 0 : target.closest) === null || _a === void 0 ? void 0 : _a.call(target, ".mfui-DropDownMenu")) ||
213
- ((_b = target === null || target === void 0 ? void 0 : target.closest) === null || _b === void 0 ? void 0 : _b.call(target, ".Menu"))) {
214
- return false;
215
- }
216
- return true;
217
- },
218
- });
219
- const { getReferenceProps, getFloatingProps } = useInteractions([dismiss]);
220
- const parseValue = useCallback((input) => {
221
- if (!input)
222
- return null;
223
- const parsed = utc ? moment.utc(input) : moment(input);
224
- return parsed.isValid() ? parsed : null;
225
- }, [utc]);
226
- const getEditableMoment = useCallback((input) => {
227
- var _a;
228
- return (_a = parseValue(input)) !== null && _a !== void 0 ? _a : (utc ? moment.utc() : moment());
229
- }, [parseValue, utc]);
230
- const serializeMoment = useCallback((nextMoment) => {
231
- return isDateOnly
232
- ? nextMoment.format("YYYY-MM-DD")
233
- : nextMoment.toISOString();
234
- }, [isDateOnly]);
235
- const commitValue = useCallback((nextValue) => {
236
- if (!isControlled.current) {
237
- setUncontrolledValue(nextValue);
238
- }
239
- onChange === null || onChange === void 0 ? void 0 : onChange(nextValue);
240
- }, [onChange]);
241
- const segments = useMemo(() => parseTimestamp(_value || "", format, utc), [_value, format, utc]);
242
- const checkValidRange = useCallback((value) => {
215
+ const dismiss = useDismiss(context);
216
+ const { getReferenceProps } = useInteractions([dismiss]);
217
+ const segments = useMemo(() => parseTimestamp(moment(_value).toISOString(), format, utc), [_value, format, utc]);
218
+ const checkValidRange = (value) => {
243
219
  if (!value)
244
220
  return false;
245
- const parsed = parseValue(value);
246
- if (!parsed)
247
- return false;
248
- if (min && parsed.isBefore(min))
221
+ if (min && moment(value).isBefore(min))
249
222
  return false;
250
- if (max && parsed.isAfter(max))
223
+ if (max && moment(value).isAfter(max))
251
224
  return false;
252
225
  return true;
253
- }, [parseValue, min, max]);
254
- const getCalendarValue = useCallback(() => {
255
- const parsed = parseValue(_value);
256
- if (!parsed)
257
- return undefined;
258
- if (!utc) {
259
- return parsed.toDate();
260
- }
261
- // Convert UTC date parts into a local Date so the Calendar highlights
262
- // the same wall-clock day the input is displaying.
263
- return new Date(parsed.year(), parsed.month(), parsed.date(), parsed.hour(), parsed.minute(), parsed.second(), parsed.millisecond());
264
- }, [_value, parseValue, utc]);
265
- const updateValue = useCallback((updater) => {
266
- const currentMoment = getEditableMoment(_value);
267
- const nextMoment = updater(_value, currentMoment.clone());
268
- if (!nextMoment || !nextMoment.isValid())
269
- return;
270
- const nextValue = serializeMoment(nextMoment);
271
- if (!checkValidRange(nextValue))
272
- return;
273
- commitValue(nextValue);
274
- }, [
275
- _value,
276
- getEditableMoment,
277
- serializeMoment,
278
- checkValidRange,
279
- commitValue,
280
- ]);
226
+ };
281
227
  const handleClear = (e) => {
282
228
  e.preventDefault();
283
229
  e.stopPropagation();
284
- commitValue(null);
230
+ setUncontrolledValue(null);
231
+ onChange === null || onChange === void 0 ? void 0 : onChange(null);
285
232
  setIsOpen(false);
286
233
  };
287
234
  const handleSegmentClick = (e, segment) => {
@@ -309,18 +256,6 @@ const DateInput = forwardRef(({ className, style = {}, defaultValue, value, form
309
256
  setIsOpen(true);
310
257
  setSelectedSegment(segments[0]);
311
258
  };
312
- const handleCalendarTriggerClick = (e) => {
313
- e.stopPropagation();
314
- e.preventDefault();
315
- if (mainRef === null || mainRef === void 0 ? void 0 : mainRef.current) {
316
- const input = mainRef.current.querySelector("div[data-type='input']");
317
- if (input) {
318
- input.focus();
319
- }
320
- }
321
- setIsOpen((prev) => !prev);
322
- setSelectedSegment(segments[0]);
323
- };
324
259
  const nextSegment = () => {
325
260
  setSelectedSegment((prev) => {
326
261
  if (!prev)
@@ -367,18 +302,34 @@ const DateInput = forwardRef(({ className, style = {}, defaultValue, value, form
367
302
  // Up Arrow
368
303
  if (e.key === "ArrowUp") {
369
304
  e.preventDefault();
370
- const segmentType = selectedSegment.type;
371
- if (segmentType === "separator")
372
- return;
373
- updateValue((_, currentMoment) => currentMoment.add(1, segmentType));
305
+ if (selectedSegment.type !== "separator") {
306
+ let newValue = _value
307
+ ? moment(_value).add(1, selectedSegment.type).toISOString()
308
+ : moment().toISOString();
309
+ if (!checkValidRange(newValue))
310
+ return;
311
+ if (isDateOnly) {
312
+ newValue = moment(newValue).format("YYYY-MM-DD");
313
+ }
314
+ setUncontrolledValue(newValue);
315
+ onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
316
+ }
374
317
  }
375
318
  // Down Arrow
376
319
  if (e.key === "ArrowDown") {
377
320
  e.preventDefault();
378
- const segmentType = selectedSegment.type;
379
- if (segmentType === "separator")
380
- return;
381
- updateValue((_, currentMoment) => currentMoment.subtract(1, segmentType));
321
+ if (selectedSegment.type !== "separator") {
322
+ let newValue = _value
323
+ ? moment(_value).subtract(1, selectedSegment.type).toISOString()
324
+ : moment().toISOString();
325
+ if (!checkValidRange(newValue))
326
+ return;
327
+ if (isDateOnly) {
328
+ newValue = moment(newValue).format("YYYY-MM-DD");
329
+ }
330
+ setUncontrolledValue(newValue);
331
+ onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
332
+ }
382
333
  }
383
334
  // handle paste
384
335
  if (e.key === "v" && (e.metaKey || e.ctrlKey)) {
@@ -397,7 +348,10 @@ const DateInput = forwardRef(({ className, style = {}, defaultValue, value, form
397
348
  setUncontrolledValue((prev) => {
398
349
  if (!(selectedSegment === null || selectedSegment === void 0 ? void 0 : selectedSegment.momentType))
399
350
  return prev;
400
- const momentValue = getEditableMoment(prev);
351
+ // if prev is null, use undefined - passing null to moment returns a null moment value
352
+ const momentValue = utc
353
+ ? moment.utc(prev || undefined)
354
+ : moment(prev || undefined);
401
355
  let newValue = moment(momentValue)
402
356
  .set(selectedSegment.momentType, parseInt(tempValue, 10) -
403
357
  (selectedSegment.type === "month" ? 1 : 0))
@@ -405,13 +359,7 @@ const DateInput = forwardRef(({ className, style = {}, defaultValue, value, form
405
359
  if (!checkValidRange(newValue))
406
360
  return prev;
407
361
  if (isDateOnly) {
408
- newValue = utc
409
- ? moment.utc(newValue).format("YYYY-MM-DD")
410
- : moment(newValue).format("YYYY-MM-DD");
411
- }
412
- if (isControlled.current) {
413
- onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
414
- return prev;
362
+ newValue = moment(newValue).format("YYYY-MM-DD");
415
363
  }
416
364
  onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
417
365
  return newValue;
@@ -426,65 +374,66 @@ const DateInput = forwardRef(({ className, style = {}, defaultValue, value, form
426
374
  if (!selectedSegment) {
427
375
  return;
428
376
  }
429
- const segmentType = selectedSegment.type;
430
- if (segmentType === "separator")
431
- return;
432
- updateValue((_, currentMoment) => e.deltaY > 0
433
- ? currentMoment.subtract(1, segmentType)
434
- : currentMoment.add(1, segmentType));
377
+ if (selectedSegment.type !== "separator") {
378
+ let newValue = e.deltaY > 0
379
+ ? moment(_value).subtract(1, selectedSegment.type).toISOString()
380
+ : moment(_value).add(1, selectedSegment.type).toISOString();
381
+ if (!checkValidRange(newValue))
382
+ return;
383
+ if (isDateOnly) {
384
+ newValue = moment(newValue).format("YYYY-MM-DD");
385
+ }
386
+ setUncontrolledValue(newValue);
387
+ onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
388
+ }
435
389
  };
436
390
  const handlePaste = (e) => __awaiter(void 0, void 0, void 0, function* () {
437
391
  const pastedText = yield window.navigator.clipboard.readText();
438
- let parsedMoment = null;
392
+ let parsedTimestamp = null;
439
393
  if (!pastedText)
440
394
  return; // do nothing if clipboard is empty
441
395
  // check for unix timestamp in seconds
442
396
  else if (pastedText.match(/^\d{10}$/)) {
443
- parsedMoment = moment.unix(parseInt(pastedText, 10));
397
+ parsedTimestamp = moment.unix(parseInt(pastedText, 10)).toISOString();
444
398
  }
445
399
  // check for unix timestamp in seconds with fractional seconds
446
400
  else if (pastedText.match(/^\d{10}\.\d{1,6}$/)) {
447
- parsedMoment = moment.unix(parseFloat(pastedText));
401
+ parsedTimestamp = moment.unix(parseFloat(pastedText)).toISOString();
448
402
  }
449
403
  // check for unix timestamp in milliseconds
450
404
  else if (pastedText.match(/^\d{13}$/)) {
451
- parsedMoment = moment.unix(parseInt(pastedText, 10) / 1000);
405
+ parsedTimestamp = moment
406
+ .unix(parseInt(pastedText, 10) / 1000)
407
+ .toISOString();
452
408
  }
453
409
  // check for windows ldap or filetime timestamp
454
410
  else if (pastedText.match(/^\d{18}$/)) {
455
- parsedMoment = moment.unix((parseInt(pastedText, 10) - 116444736000000000) / 10000000);
411
+ parsedTimestamp = moment
412
+ .unix((parseInt(pastedText, 10) - 116444736000000000) / 10000000)
413
+ .toISOString();
456
414
  }
457
415
  // check for YMD ldap timestamp in format YYYYMMDDHHMMSSZ
458
416
  else if (pastedText.match(/^\d{14}Z$/)) {
459
- parsedMoment = moment.utc(pastedText, "YYYYMMDDHHmmssZ");
417
+ parsedTimestamp = moment
418
+ .utc(pastedText, "YYYYMMDDHHmmssZ")
419
+ .toISOString();
460
420
  }
461
421
  // check if pasted text is any other valid timestamp
462
422
  else if (!moment(pastedText).isValid())
463
423
  return;
464
424
  else {
465
- parsedMoment = utc ? moment.utc(pastedText) : moment(pastedText);
466
- }
467
- if (!(parsedMoment === null || parsedMoment === void 0 ? void 0 : parsedMoment.isValid()))
468
- return;
469
- if (utc) {
470
- parsedMoment = parsedMoment.clone().utc();
425
+ parsedTimestamp = moment.utc(pastedText).toISOString();
471
426
  }
472
- const parsedTimestamp = serializeMoment(parsedMoment);
473
- if (!checkValidRange(parsedTimestamp))
474
- return;
475
- commitValue(parsedTimestamp);
427
+ setUncontrolledValue(parsedTimestamp);
428
+ onChange === null || onChange === void 0 ? void 0 : onChange(parsedTimestamp);
476
429
  });
477
430
  // Close on outside click
478
431
  useEffect(() => {
479
432
  const close = (e) => {
480
- var _a, _b, _c, _d;
433
+ var _a, _b;
481
434
  const target = e.target;
482
435
  const referenceElement = (_a = refs === null || refs === void 0 ? void 0 : refs.reference) === null || _a === void 0 ? void 0 : _a.current;
483
436
  const floatingElement = (_b = refs === null || refs === void 0 ? void 0 : refs.floating) === null || _b === void 0 ? void 0 : _b.current;
484
- if (((_c = target === null || target === void 0 ? void 0 : target.closest) === null || _c === void 0 ? void 0 : _c.call(target, ".mfui-DropDownMenu")) ||
485
- ((_d = target === null || target === void 0 ? void 0 : target.closest) === null || _d === void 0 ? void 0 : _d.call(target, ".Menu"))) {
486
- return;
487
- }
488
437
  if (floatingElement && // Check if the floating element exists
489
438
  e.target !== referenceElement && // Check if the target is not the reference (input)
490
439
  !referenceElement.contains(target) && // Check if the target is not inside the reference (input)
@@ -497,18 +446,18 @@ const DateInput = forwardRef(({ className, style = {}, defaultValue, value, form
497
446
  document.addEventListener("click", close);
498
447
  return () => document.removeEventListener("click", close);
499
448
  }, [refs.floating]);
500
- return (_jsxs(StyledContainer, Object.assign({ ref: (ref) => {
449
+ return (_jsxs(StyledContainer, { ref: (ref) => {
501
450
  if (typeof _ref === "function") {
502
451
  _ref(ref);
503
452
  }
504
453
  mainRef.current = ref;
505
454
  refs.setReference(ref);
506
- }, onWheel: (e) => handleWheelEvent(e), className: className }, getReferenceProps(), { children: [label && (_jsx(FieldLabel, { error: error, asterisk: required, size: size, description: description, children: label })), _jsxs(StyledInputContainer, { className: "input-container", onClick: handleContainerClick, onMouseDown: handleMouseDown, onKeyDown: handleKeyDown, onFocus: (e) => {
455
+ }, onWheel: (e) => handleWheelEvent(e), className: className, children: [label && (_jsx(FieldLabel, { error: error, asterisk: required, size: size, description: description, children: label })), _jsxs(StyledInputContainer, { className: "input-container", onClick: handleContainerClick, onMouseDown: handleMouseDown, onKeyDown: handleKeyDown, onFocus: (e) => {
507
456
  e.preventDefault();
508
457
  setSelectedSegment(segments[0]);
509
458
  }, onBlur: () => {
510
459
  setSelectedSegment(null);
511
- }, "data-empty": !_value, "data-disabled": disabled, role: "textbox", size: size, variant: variant, "data-button-left": enableCalendar, "data-button-right": arrow || clearable, style: style, children: [enableCalendar && (_jsx(CalendarTriggerButton, { size: size, type: "button", "aria-label": "Toggle calendar", onClick: handleCalendarTriggerClick, "data-default-btn": true, children: _jsx(CalendarDaysIcon, {}) })), segments.map((segment, i) => {
460
+ }, "data-empty": !_value, "data-disabled": disabled, role: "textbox", size: size, variant: variant, "data-button-right": arrow || clearable, style: style, children: [segments.map((segment, i) => {
512
461
  if (segment.type === "separator") {
513
462
  return (_jsx("div", { className: "separator", tabIndex: -1, onClick: (e) => {
514
463
  e.preventDefault();
@@ -516,25 +465,21 @@ const DateInput = forwardRef(({ className, style = {}, defaultValue, value, form
516
465
  }, 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));
517
466
  }
518
467
  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));
519
- }), utc && _jsx("div", { style: { marginLeft: 5 }, children: "UTC" }), clearable && _value ? (_jsx(ClearButton, { size: size, onClick: handleClear })) : arrow ? (_jsx(ArrowButton, { size: size })) : null] }), !disabled && enableCalendar && isOpen && (_jsx(FloatingPortal, { preserveTabOrder: true, children: _jsx(StyledFloatContainer, Object.assign({ ref: refs.setFloating, style: floatingStyles }, getFloatingProps(), { children: _jsx(StyledContent, { maxDropdownHeight: "fit-content", children: _jsx("div", { children: _jsx(Calendar, { value: getCalendarValue(), clearable: false, min: min, max: max, onChange: (date, meta) => {
520
- if (!date) {
521
- commitValue(null);
522
- setIsOpen((meta === null || meta === void 0 ? void 0 : meta.source) === "month" || (meta === null || meta === void 0 ? void 0 : meta.source) === "year"
523
- ? true
524
- : closeOnSelect
525
- ? false
526
- : true);
527
- return;
528
- }
529
- updateValue((_, currentMoment) => currentMoment
530
- .year(date.getFullYear())
531
- .month(date.getMonth())
532
- .date(date.getDate()));
533
- setIsOpen((meta === null || meta === void 0 ? void 0 : meta.source) === "month" || (meta === null || meta === void 0 ? void 0 : meta.source) === "year"
534
- ? true
535
- : closeOnSelect
536
- ? false
537
- : true);
538
- }, includeTime: false }, 1) }) }) })) }))] })));
468
+ }), utc && _jsx("div", { style: { marginLeft: 5 }, children: "UTC" }), clearable && _value ? (_jsx(ClearButton, { onClick: handleClear })) : arrow ? (_jsx(ArrowButton, {})) : null] }), !disabled && 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, { value: _value ? moment(_value).toDate() : undefined, clearable: false, min: min, max: max, onChange: (date) => {
469
+ setUncontrolledValue((prev) => {
470
+ // make copy of prev variable
471
+ const oldValue = moment(prev).toISOString();
472
+ const result = `${moment(date).format("YYYY-MM-DD")}T${moment(prev || undefined).format("HH:mm:ss")}`;
473
+ let isoResult = moment(result).toISOString();
474
+ if (!checkValidRange(result))
475
+ return oldValue;
476
+ if (isDateOnly) {
477
+ isoResult = moment(result).format("YYYY-MM-DD");
478
+ }
479
+ onChange === null || onChange === void 0 ? void 0 : onChange(isoResult);
480
+ setIsOpen(closeOnSelect ? false : true);
481
+ return isoResult;
482
+ });
483
+ }, includeTime: false }, 1) }) }) })) }))] }));
539
484
  });
540
485
  export default DateInput;