@monolith-forensics/monolith-ui 1.7.1 → 1.8.1-dev.0

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 (176) hide show
  1. package/dist/BarChart/BarChart.d.ts +3 -0
  2. package/dist/BarChart/BarChart.js +511 -0
  3. package/dist/BarChart/BarChart.lib.d.ts +31 -0
  4. package/dist/BarChart/BarChart.lib.js +136 -0
  5. package/dist/BarChart/BarChart.styled.d.ts +49 -0
  6. package/dist/BarChart/BarChart.styled.js +111 -0
  7. package/dist/BarChart/BarChart.types.d.ts +170 -0
  8. package/dist/BarChart/BarChart.types.js +1 -0
  9. package/dist/BarChart/index.d.ts +3 -0
  10. package/dist/BarChart/index.js +2 -0
  11. package/dist/Button/Button.js +9 -58
  12. package/dist/Calendar/Calendar.d.ts +3 -1
  13. package/dist/Calendar/Calendar.js +134 -33
  14. package/dist/Calendar/CalendarStyles.d.ts +3 -0
  15. package/dist/Calendar/CalendarStyles.js +92 -14
  16. package/dist/Calendar/calendarHelpers.d.ts +5 -1
  17. package/dist/Calendar/calendarHelpers.js +13 -5
  18. package/dist/ChartPrimitives/chartLegend.styled.d.ts +12 -0
  19. package/dist/ChartPrimitives/chartLegend.styled.js +52 -0
  20. package/dist/ChartPrimitives/chartTooltip.styled.d.ts +19 -0
  21. package/dist/ChartPrimitives/chartTooltip.styled.js +61 -0
  22. package/dist/ChartPrimitives/index.d.ts +2 -0
  23. package/dist/ChartPrimitives/index.js +2 -0
  24. package/dist/ChartUtils/chartColors.d.ts +8 -0
  25. package/dist/ChartUtils/chartColors.js +65 -0
  26. package/dist/ChartUtils/chartMath.d.ts +3 -0
  27. package/dist/ChartUtils/chartMath.js +3 -0
  28. package/dist/ChartUtils/index.d.ts +2 -0
  29. package/dist/ChartUtils/index.js +2 -0
  30. package/dist/Charts/BarChart/BarChart.d.ts +5 -0
  31. package/dist/Charts/BarChart/BarChart.js +549 -0
  32. package/dist/Charts/BarChart/BarChart.lib.d.ts +31 -0
  33. package/dist/Charts/BarChart/BarChart.lib.js +136 -0
  34. package/dist/Charts/BarChart/BarChart.styled.d.ts +51 -0
  35. package/dist/Charts/BarChart/BarChart.styled.js +115 -0
  36. package/dist/Charts/BarChart/BarChart.types.d.ts +171 -0
  37. package/dist/Charts/BarChart/BarChart.types.js +1 -0
  38. package/dist/Charts/BarChart/index.d.ts +3 -0
  39. package/dist/Charts/BarChart/index.js +2 -0
  40. package/dist/Charts/ChartPrimitives/ChartExportControl.d.ts +11 -0
  41. package/dist/Charts/ChartPrimitives/ChartExportControl.js +29 -0
  42. package/dist/Charts/ChartPrimitives/chartActions.styled.d.ts +1 -0
  43. package/dist/Charts/ChartPrimitives/chartActions.styled.js +8 -0
  44. package/dist/Charts/ChartPrimitives/chartLegend.styled.d.ts +12 -0
  45. package/dist/Charts/ChartPrimitives/chartLegend.styled.js +52 -0
  46. package/dist/Charts/ChartPrimitives/chartTooltip.styled.d.ts +19 -0
  47. package/dist/Charts/ChartPrimitives/chartTooltip.styled.js +61 -0
  48. package/dist/Charts/ChartPrimitives/index.d.ts +4 -0
  49. package/dist/Charts/ChartPrimitives/index.js +4 -0
  50. package/dist/Charts/ChartUtils/chartColors.d.ts +8 -0
  51. package/dist/Charts/ChartUtils/chartColors.js +65 -0
  52. package/dist/Charts/ChartUtils/chartExport.d.ts +47 -0
  53. package/dist/Charts/ChartUtils/chartExport.js +311 -0
  54. package/dist/Charts/ChartUtils/chartMath.d.ts +3 -0
  55. package/dist/Charts/ChartUtils/chartMath.js +3 -0
  56. package/dist/Charts/ChartUtils/index.d.ts +3 -0
  57. package/dist/Charts/ChartUtils/index.js +3 -0
  58. package/dist/Charts/HeatMap/HeatMap.d.ts +5 -0
  59. package/dist/Charts/HeatMap/HeatMap.js +212 -0
  60. package/dist/Charts/HeatMap/HeatMap.lib.d.ts +30 -0
  61. package/dist/Charts/HeatMap/HeatMap.lib.js +115 -0
  62. package/dist/Charts/HeatMap/HeatMap.styled.d.ts +37 -0
  63. package/dist/Charts/HeatMap/HeatMap.styled.js +91 -0
  64. package/dist/Charts/HeatMap/HeatMap.types.d.ts +80 -0
  65. package/dist/Charts/HeatMap/HeatMap.types.js +1 -0
  66. package/dist/Charts/HeatMap/index.d.ts +3 -0
  67. package/dist/Charts/HeatMap/index.js +2 -0
  68. package/dist/Charts/LineChart/LineChart.d.ts +5 -0
  69. package/dist/Charts/LineChart/LineChart.js +529 -0
  70. package/dist/Charts/LineChart/LineChart.lib.d.ts +24 -0
  71. package/dist/Charts/LineChart/LineChart.lib.js +132 -0
  72. package/dist/Charts/LineChart/LineChart.styled.d.ts +59 -0
  73. package/dist/Charts/LineChart/LineChart.styled.js +147 -0
  74. package/dist/Charts/LineChart/LineChart.types.d.ts +193 -0
  75. package/dist/Charts/LineChart/LineChart.types.js +1 -0
  76. package/dist/Charts/LineChart/index.d.ts +3 -0
  77. package/dist/Charts/LineChart/index.js +2 -0
  78. package/dist/Charts/PieChart/PieChart.d.ts +4 -0
  79. package/dist/Charts/PieChart/PieChart.js +199 -0
  80. package/dist/Charts/PieChart/PieChart.lib.d.ts +5 -0
  81. package/dist/Charts/PieChart/PieChart.lib.js +19 -0
  82. package/dist/Charts/PieChart/PieChart.styled.d.ts +51 -0
  83. package/dist/Charts/PieChart/PieChart.styled.js +163 -0
  84. package/dist/Charts/PieChart/PieChart.types.d.ts +100 -0
  85. package/dist/Charts/PieChart/PieChart.types.js +1 -0
  86. package/dist/Charts/PieChart/index.d.ts +2 -0
  87. package/dist/Charts/PieChart/index.js +1 -0
  88. package/dist/Charts/index.d.ts +5 -0
  89. package/dist/Charts/index.js +4 -0
  90. package/dist/CheckBox/CheckBox.js +2 -16
  91. package/dist/DateInput/DateInput.js +198 -143
  92. package/dist/DropDownMenu/components/MenuComponent.js +2 -1
  93. package/dist/DropDownMenu/components/MenuItem.js +5 -14
  94. package/dist/DropDownMenu/components/MenuItemList.js +7 -24
  95. package/dist/DropDownMenu/components/StyledFloatContainer.js +1 -1
  96. package/dist/FieldLabel/FieldLabel.js +4 -12
  97. package/dist/FileInputField/FileInputField.js +4 -23
  98. package/dist/FormSection/FormSection.js +5 -25
  99. package/dist/HeatMap/HeatMap.d.ts +3 -0
  100. package/dist/HeatMap/HeatMap.js +174 -0
  101. package/dist/HeatMap/HeatMap.lib.d.ts +30 -0
  102. package/dist/HeatMap/HeatMap.lib.js +115 -0
  103. package/dist/HeatMap/HeatMap.styled.d.ts +34 -0
  104. package/dist/HeatMap/HeatMap.styled.js +83 -0
  105. package/dist/HeatMap/HeatMap.types.d.ts +79 -0
  106. package/dist/HeatMap/HeatMap.types.js +1 -0
  107. package/dist/HeatMap/index.d.ts +3 -0
  108. package/dist/HeatMap/index.js +2 -0
  109. package/dist/IconButton/IconButton.js +2 -16
  110. package/dist/Input/Input.js +7 -56
  111. package/dist/LineChart/LineChart.d.ts +3 -0
  112. package/dist/LineChart/LineChart.js +491 -0
  113. package/dist/LineChart/LineChart.lib.d.ts +24 -0
  114. package/dist/LineChart/LineChart.lib.js +132 -0
  115. package/dist/LineChart/LineChart.styled.d.ts +57 -0
  116. package/dist/LineChart/LineChart.styled.js +150 -0
  117. package/dist/LineChart/LineChart.types.d.ts +192 -0
  118. package/dist/LineChart/LineChart.types.js +1 -0
  119. package/dist/LineChart/index.d.ts +3 -0
  120. package/dist/LineChart/index.js +2 -0
  121. package/dist/PieChart/PieChart.d.ts +2 -0
  122. package/dist/PieChart/PieChart.js +161 -0
  123. package/dist/PieChart/PieChart.lib.d.ts +5 -0
  124. package/dist/PieChart/PieChart.lib.js +19 -0
  125. package/dist/PieChart/PieChart.styled.d.ts +49 -0
  126. package/dist/PieChart/PieChart.styled.js +161 -0
  127. package/dist/PieChart/PieChart.types.d.ts +99 -0
  128. package/dist/PieChart/PieChart.types.js +1 -0
  129. package/dist/PieChart/index.d.ts +2 -0
  130. package/dist/PieChart/index.js +1 -0
  131. package/dist/Pill/Pill.js +8 -79
  132. package/dist/Popover/Popover.context.d.ts +2 -1
  133. package/dist/Popover/Popover.js +5 -2
  134. package/dist/Popover/Popover.styles.d.ts +1 -6
  135. package/dist/Popover/Popover.styles.js +11 -28
  136. package/dist/Popover/Popover.transitions.d.ts +4 -2
  137. package/dist/Popover/Popover.transitions.js +23 -49
  138. package/dist/Popover/PopoverDropdown.js +6 -8
  139. package/dist/Popover/PopoverTarget.js +6 -3
  140. package/dist/SegmentedControl/SegmentedControl.utils.d.ts +2 -2
  141. package/dist/SegmentedControl/SegmentedControl.utils.js +3 -30
  142. package/dist/SelectBox/SelectBox.js +3 -3
  143. package/dist/SelectBox/select-box.styled-components.d.ts +3 -1
  144. package/dist/SelectBox/select-box.styled-components.js +10 -48
  145. package/dist/SuperDatePicker/SuperDatePicker.d.ts +74 -0
  146. package/dist/SuperDatePicker/SuperDatePicker.js +557 -0
  147. package/dist/SuperDatePicker/index.d.ts +2 -0
  148. package/dist/SuperDatePicker/index.js +2 -0
  149. package/dist/Switch/Switch.d.ts +2 -2
  150. package/dist/Switch/Switch.js +18 -83
  151. package/dist/Table/StateStorage.d.ts +4 -0
  152. package/dist/Table/StateStorage.js +13 -0
  153. package/dist/Table/Table.js +160 -12
  154. package/dist/Table/TableComponents.d.ts +10 -0
  155. package/dist/Table/TableComponents.js +57 -0
  156. package/dist/Table/TableDefaults.d.ts +7 -0
  157. package/dist/Table/TableDefaults.js +7 -0
  158. package/dist/Table/TableProvider.js +263 -71
  159. package/dist/Table/TableRow.js +15 -10
  160. package/dist/Table/types.d.ts +64 -0
  161. package/dist/Tabs/Tab.js +8 -0
  162. package/dist/TagBox/TagBox.js +18 -76
  163. package/dist/TextArea/TextArea.js +4 -23
  164. package/dist/TextInput/TextInput.js +12 -6
  165. package/dist/Utilities/parseTimestamp.js +11 -6
  166. package/dist/core/ArrowButton.d.ts +2 -0
  167. package/dist/core/ArrowButton.js +7 -3
  168. package/dist/core/ClearButton.d.ts +2 -0
  169. package/dist/core/ClearButton.js +7 -3
  170. package/dist/core/controlSizes.d.ts +34 -0
  171. package/dist/core/controlSizes.js +190 -0
  172. package/dist/core/index.d.ts +1 -0
  173. package/dist/core/index.js +1 -0
  174. package/dist/index.d.ts +1 -0
  175. package/dist/index.js +1 -0
  176. package/package.json +5 -1
@@ -10,10 +10,11 @@ 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 { forwardRef, useEffect, useMemo, useRef, useState, } from "react";
13
+ import { CalendarDaysIcon } from "lucide-react";
14
+ import { forwardRef, useCallback, useEffect, useMemo, useRef, useState, } from "react";
14
15
  import styled from "styled-components";
15
16
  import { FieldLabel, Calendar } from "..";
16
- import { StyledContent, StyledFloatContainer, ArrowButton, ClearButton, } from "../core";
17
+ import { StyledContent, StyledFloatContainer, ArrowButton, ClearButton, getControlSizeTokens, } from "../core";
17
18
  import parseTimestamp from "../Utilities/parseTimestamp";
18
19
  const StyledContainer = styled.div.attrs({
19
20
  className: "mfui-DateInput",
@@ -53,45 +54,19 @@ const StyledInputContainer = styled.div `
53
54
  font-family: ${({ theme }) => theme.typography.fontFamily};
54
55
 
55
56
  color: ${(props) => props.theme.palette.text.primary};
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"};
57
+ font-size: ${({ size }) => `${getControlSizeTokens(size).fontSize}px`};
67
58
 
68
59
  width: 100%;
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"};
60
+ height: ${({ size }) => `${getControlSizeTokens(size).height}px`};
80
61
 
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"};
62
+ padding: ${({ size }) => `0px ${getControlSizeTokens(size).inputPaddingX}px`};
63
+
64
+ &[data-button-left="true"] {
65
+ padding-left: ${({ size }) => `${getControlSizeTokens(size).adornmentWidth}px`};
66
+ }
92
67
 
93
68
  &[data-button-right="true"] {
94
- padding-right: 36px;
69
+ padding-right: ${({ size }) => `${getControlSizeTokens(size).adornmentWidth}px`};
95
70
  }
96
71
 
97
72
  background-color: ${({ theme, variant }) => {
@@ -151,6 +126,44 @@ const StyledInputContainer = styled.div `
151
126
  }
152
127
  }
153
128
  `;
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
+ `;
154
167
  const InputSegment = styled.div `
155
168
  user-select: none;
156
169
  display: flex;
@@ -161,17 +174,7 @@ const InputSegment = styled.div `
161
174
  border: none;
162
175
  padding: 0;
163
176
 
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"};
177
+ height: ${({ size }) => `${getControlSizeTokens(size).height}px`};
175
178
 
176
179
  height: 100%;
177
180
 
@@ -179,17 +182,7 @@ const InputSegment = styled.div `
179
182
  color: ${(props) => props.theme.palette.text.primary};
180
183
 
181
184
  ::placeholder {
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"};
185
+ font-size: ${({ size }) => `${getControlSizeTokens(size).placeholderFontSize}px`};
193
186
  }
194
187
  `;
195
188
  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) => {
@@ -212,23 +205,83 @@ const DateInput = forwardRef(({ className, style = {}, defaultValue, value, form
212
205
  middleware: [flip(), offset(5)],
213
206
  whileElementsMounted: autoUpdate,
214
207
  });
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) => {
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) => {
219
243
  if (!value)
220
244
  return false;
221
- if (min && moment(value).isBefore(min))
245
+ const parsed = parseValue(value);
246
+ if (!parsed)
247
+ return false;
248
+ if (min && parsed.isBefore(min))
222
249
  return false;
223
- if (max && moment(value).isAfter(max))
250
+ if (max && parsed.isAfter(max))
224
251
  return false;
225
252
  return true;
226
- };
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
+ ]);
227
281
  const handleClear = (e) => {
228
282
  e.preventDefault();
229
283
  e.stopPropagation();
230
- setUncontrolledValue(null);
231
- onChange === null || onChange === void 0 ? void 0 : onChange(null);
284
+ commitValue(null);
232
285
  setIsOpen(false);
233
286
  };
234
287
  const handleSegmentClick = (e, segment) => {
@@ -256,6 +309,18 @@ const DateInput = forwardRef(({ className, style = {}, defaultValue, value, form
256
309
  setIsOpen(true);
257
310
  setSelectedSegment(segments[0]);
258
311
  };
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
+ };
259
324
  const nextSegment = () => {
260
325
  setSelectedSegment((prev) => {
261
326
  if (!prev)
@@ -302,34 +367,18 @@ const DateInput = forwardRef(({ className, style = {}, defaultValue, value, form
302
367
  // Up Arrow
303
368
  if (e.key === "ArrowUp") {
304
369
  e.preventDefault();
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
- }
370
+ const segmentType = selectedSegment.type;
371
+ if (segmentType === "separator")
372
+ return;
373
+ updateValue((_, currentMoment) => currentMoment.add(1, segmentType));
317
374
  }
318
375
  // Down Arrow
319
376
  if (e.key === "ArrowDown") {
320
377
  e.preventDefault();
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
- }
378
+ const segmentType = selectedSegment.type;
379
+ if (segmentType === "separator")
380
+ return;
381
+ updateValue((_, currentMoment) => currentMoment.subtract(1, segmentType));
333
382
  }
334
383
  // handle paste
335
384
  if (e.key === "v" && (e.metaKey || e.ctrlKey)) {
@@ -348,10 +397,7 @@ const DateInput = forwardRef(({ className, style = {}, defaultValue, value, form
348
397
  setUncontrolledValue((prev) => {
349
398
  if (!(selectedSegment === null || selectedSegment === void 0 ? void 0 : selectedSegment.momentType))
350
399
  return 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);
400
+ const momentValue = getEditableMoment(prev);
355
401
  let newValue = moment(momentValue)
356
402
  .set(selectedSegment.momentType, parseInt(tempValue, 10) -
357
403
  (selectedSegment.type === "month" ? 1 : 0))
@@ -359,7 +405,13 @@ const DateInput = forwardRef(({ className, style = {}, defaultValue, value, form
359
405
  if (!checkValidRange(newValue))
360
406
  return prev;
361
407
  if (isDateOnly) {
362
- newValue = moment(newValue).format("YYYY-MM-DD");
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;
363
415
  }
364
416
  onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
365
417
  return newValue;
@@ -374,66 +426,65 @@ const DateInput = forwardRef(({ className, style = {}, defaultValue, value, form
374
426
  if (!selectedSegment) {
375
427
  return;
376
428
  }
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
- }
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));
389
435
  };
390
436
  const handlePaste = (e) => __awaiter(void 0, void 0, void 0, function* () {
391
437
  const pastedText = yield window.navigator.clipboard.readText();
392
- let parsedTimestamp = null;
438
+ let parsedMoment = null;
393
439
  if (!pastedText)
394
440
  return; // do nothing if clipboard is empty
395
441
  // check for unix timestamp in seconds
396
442
  else if (pastedText.match(/^\d{10}$/)) {
397
- parsedTimestamp = moment.unix(parseInt(pastedText, 10)).toISOString();
443
+ parsedMoment = moment.unix(parseInt(pastedText, 10));
398
444
  }
399
445
  // check for unix timestamp in seconds with fractional seconds
400
446
  else if (pastedText.match(/^\d{10}\.\d{1,6}$/)) {
401
- parsedTimestamp = moment.unix(parseFloat(pastedText)).toISOString();
447
+ parsedMoment = moment.unix(parseFloat(pastedText));
402
448
  }
403
449
  // check for unix timestamp in milliseconds
404
450
  else if (pastedText.match(/^\d{13}$/)) {
405
- parsedTimestamp = moment
406
- .unix(parseInt(pastedText, 10) / 1000)
407
- .toISOString();
451
+ parsedMoment = moment.unix(parseInt(pastedText, 10) / 1000);
408
452
  }
409
453
  // check for windows ldap or filetime timestamp
410
454
  else if (pastedText.match(/^\d{18}$/)) {
411
- parsedTimestamp = moment
412
- .unix((parseInt(pastedText, 10) - 116444736000000000) / 10000000)
413
- .toISOString();
455
+ parsedMoment = moment.unix((parseInt(pastedText, 10) - 116444736000000000) / 10000000);
414
456
  }
415
457
  // check for YMD ldap timestamp in format YYYYMMDDHHMMSSZ
416
458
  else if (pastedText.match(/^\d{14}Z$/)) {
417
- parsedTimestamp = moment
418
- .utc(pastedText, "YYYYMMDDHHmmssZ")
419
- .toISOString();
459
+ parsedMoment = moment.utc(pastedText, "YYYYMMDDHHmmssZ");
420
460
  }
421
461
  // check if pasted text is any other valid timestamp
422
462
  else if (!moment(pastedText).isValid())
423
463
  return;
424
464
  else {
425
- parsedTimestamp = moment.utc(pastedText).toISOString();
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();
426
471
  }
427
- setUncontrolledValue(parsedTimestamp);
428
- onChange === null || onChange === void 0 ? void 0 : onChange(parsedTimestamp);
472
+ const parsedTimestamp = serializeMoment(parsedMoment);
473
+ if (!checkValidRange(parsedTimestamp))
474
+ return;
475
+ commitValue(parsedTimestamp);
429
476
  });
430
477
  // Close on outside click
431
478
  useEffect(() => {
432
479
  const close = (e) => {
433
- var _a, _b;
480
+ var _a, _b, _c, _d;
434
481
  const target = e.target;
435
482
  const referenceElement = (_a = refs === null || refs === void 0 ? void 0 : refs.reference) === null || _a === void 0 ? void 0 : _a.current;
436
483
  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
+ }
437
488
  if (floatingElement && // Check if the floating element exists
438
489
  e.target !== referenceElement && // Check if the target is not the reference (input)
439
490
  !referenceElement.contains(target) && // Check if the target is not inside the reference (input)
@@ -446,18 +497,18 @@ const DateInput = forwardRef(({ className, style = {}, defaultValue, value, form
446
497
  document.addEventListener("click", close);
447
498
  return () => document.removeEventListener("click", close);
448
499
  }, [refs.floating]);
449
- return (_jsxs(StyledContainer, { ref: (ref) => {
500
+ return (_jsxs(StyledContainer, Object.assign({ ref: (ref) => {
450
501
  if (typeof _ref === "function") {
451
502
  _ref(ref);
452
503
  }
453
504
  mainRef.current = ref;
454
505
  refs.setReference(ref);
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) => {
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) => {
456
507
  e.preventDefault();
457
508
  setSelectedSegment(segments[0]);
458
509
  }, onBlur: () => {
459
510
  setSelectedSegment(null);
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) => {
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) => {
461
512
  if (segment.type === "separator") {
462
513
  return (_jsx("div", { className: "separator", tabIndex: -1, onClick: (e) => {
463
514
  e.preventDefault();
@@ -465,21 +516,25 @@ const DateInput = forwardRef(({ className, style = {}, defaultValue, value, form
465
516
  }, 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));
466
517
  }
467
518
  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));
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) }) }) })) }))] }));
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) }) }) })) }))] })));
484
539
  });
485
540
  export default DateInput;
@@ -13,6 +13,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
13
  import { forwardRef, useContext, useEffect, useRef, useState } from "react";
14
14
  import { autoUpdate, flip, FloatingFocusManager, FloatingList, FloatingNode, FloatingPortal, offset, safePolygon, shift, useClick, useDismiss, useFloating, useFloatingNodeId, useFloatingParentNodeId, useFloatingTree, useHover, useInteractions, useListItem, useListNavigation, useMergeRefs, useRole, useTypeahead, } from "@floating-ui/react";
15
15
  import { ChevronDownIcon, ChevronRightIcon } from "lucide-react";
16
+ import { getControlSizeTokens } from "../../core";
16
17
  import { MenuContext } from "./MenuContext";
17
18
  import { StyledFloatContainer } from "./StyledFloatContainer";
18
19
  import { StyledContent } from "./StyledContent";
@@ -107,7 +108,7 @@ export const MenuComponent = forwardRef((_a, forwardedRef) => {
107
108
  (_a = props.onFocus) === null || _a === void 0 ? void 0 : _a.call(props, event);
108
109
  setHasFocusInside(false);
109
110
  parent.setHasFocusInside(true);
110
- } }))), { rightSection: arrow ? (_jsx(ChevronDownIcon, { size: 12 })) : isNested ? (_jsx(ChevronRightIcon, { size: 12 })) : null, size: buttonSize, variant: variant, selected: isOpen, nested: isNested }, buttonProps, { children: label })), _jsx(MenuContext.Provider, { value: {
111
+ } }))), { rightSection: arrow ? (_jsx(ChevronDownIcon, { size: getControlSizeTokens(buttonSize).iconSize })) : isNested ? (_jsx(ChevronRightIcon, { size: getControlSizeTokens(buttonSize).iconSize })) : null, size: buttonSize, variant: variant, selected: isOpen, nested: isNested }, buttonProps, { children: label })), _jsx(MenuContext.Provider, { value: {
111
112
  activeIndex,
112
113
  setActiveIndex,
113
114
  getItemProps,
@@ -13,6 +13,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
13
13
  import { forwardRef, useContext } from "react";
14
14
  import styled from "styled-components";
15
15
  import { Button } from "../../Button";
16
+ import { getControlSizeTokens } from "../../core";
16
17
  import { useFloatingTree, useListItem, useMergeRefs } from "@floating-ui/react";
17
18
  import { MenuContext } from "./MenuContext";
18
19
  import Tooltip from "../../Tooltip";
@@ -43,12 +44,12 @@ export const MenuItem = styled(forwardRef((_a, forwardedRef) => {
43
44
  border-radius: 3px;
44
45
  display: flex;
45
46
  flex-direction: row;
46
- gap: 5px;
47
+ gap: ${({ size = "sm" }) => `${getControlSizeTokens(size).iconGap}px`};
47
48
  align-items: center;
48
- min-height: 25px;
49
+ min-height: ${({ size = "sm" }) => `${getControlSizeTokens(size).menuRowHeight}px`};
49
50
  width: 100%;
50
51
  min-width: 100%;
51
- height: auto;
52
+ height: ${({ size = "sm" }) => `${getControlSizeTokens(size).menuRowHeight}px`};
52
53
  position: relative;
53
54
  user-select: none;
54
55
  outline: none;
@@ -65,17 +66,7 @@ export const MenuItem = styled(forwardRef((_a, forwardedRef) => {
65
66
  font-weight: normal;
66
67
  letter-spacing: normal;
67
68
 
68
- padding: ${({ size }) => size === "xs"
69
- ? "2px 8px"
70
- : size === "sm"
71
- ? "4px 10px"
72
- : size === "md"
73
- ? "4px 12px"
74
- : size === "lg"
75
- ? "5px 14px"
76
- : size === "xl"
77
- ? "6px 16px"
78
- : "2px 8px"};
69
+ padding: ${({ size = "sm" }) => `0px ${getControlSizeTokens(size).menuItemPaddingX}px`};
79
70
 
80
71
  &[data-disabled="true"] {
81
72
  opacity: 0.5;
@@ -15,6 +15,7 @@ import styled from "styled-components";
15
15
  import { FixedSizeList } from "react-window";
16
16
  import { Plus } from "lucide-react";
17
17
  import CheckBox from "../../CheckBox";
18
+ import { getControlSizeTokens } from "../../core";
18
19
  import { DropDownMenu } from "../DropDownMenu";
19
20
  import { MenuItem } from "./MenuItem";
20
21
  import { useInfiniteQuery } from "@tanstack/react-query";
@@ -62,28 +63,9 @@ const GroupHeader = styled.div `
62
63
  color: ${(props) => props.theme.palette.text.secondary};
63
64
  font-weight: 500;
64
65
  user-select: none;
65
- padding: ${({ $size }) => $size === "xs"
66
- ? "2px 8px"
67
- : $size === "sm"
68
- ? "4px 10px"
69
- : $size === "md"
70
- ? "4px 12px"
71
- : $size === "lg"
72
- ? "5px 14px"
73
- : $size === "xl"
74
- ? "6px 16px"
75
- : "2px 8px"};
76
- font-size: ${({ $size }) => $size === "xs"
77
- ? "10px"
78
- : $size === "sm"
79
- ? "11px"
80
- : $size === "md"
81
- ? "13px"
82
- : $size === "lg"
83
- ? "15px"
84
- : $size === "xl"
85
- ? "17px"
86
- : "10px"};
66
+ min-height: ${({ $size = "sm" }) => `${getControlSizeTokens($size).menuRowHeight}px`};
67
+ padding: ${({ $size = "sm" }) => `0px ${getControlSizeTokens($size).menuItemPaddingX}px`};
68
+ font-size: ${({ $size = "sm" }) => `${getControlSizeTokens($size).menuGroupFontSize}px`};
87
69
 
88
70
  .group-line {
89
71
  border-top: 1px solid ${(props) => props.theme.palette.divider};
@@ -197,7 +179,8 @@ export const MenuItemList = ({ menuItems, searchable, onSearch, manualSearch, se
197
179
  }
198
180
  }, [targetElm.current, isLoading]);
199
181
  const overscanCount = 10;
200
- const itemHeight = 25;
182
+ const sizeTokens = getControlSizeTokens(size || "sm");
183
+ const itemHeight = sizeTokens.menuRowHeight;
201
184
  const itemCount = (displayItems === null || displayItems === void 0 ? void 0 : displayItems.length) || 0;
202
185
  const height = viewPortDimensions.height
203
186
  ? viewPortDimensions.height
@@ -218,7 +201,7 @@ export const MenuItemList = ({ menuItems, searchable, onSearch, manualSearch, se
218
201
  alignItems: "center",
219
202
  height: "100%",
220
203
  padding: "10px 0",
221
- }, children: [_jsx("div", { style: { fontSize: "12px" }, children: "Loading..." }), _jsx(Loader, {})] })), !isLoading && (_jsx(ListViewPort, { ref: targetElm, children: _jsx(FixedSizeList, { itemData: displayItems, overscanCount: overscanCount, height: height, width: width, itemCount: itemCount, itemSize: itemHeight, outerRef: listElm, children: ({ data, index, style }) => {
204
+ }, children: [_jsx("div", { style: { fontSize: `${sizeTokens.supportingFontSize}px` }, children: "Loading..." }), _jsx(Loader, {})] })), !isLoading && (_jsx(ListViewPort, { ref: targetElm, children: _jsx(FixedSizeList, { itemData: displayItems, overscanCount: overscanCount, height: height, width: width, itemCount: itemCount, itemSize: itemHeight, outerRef: listElm, children: ({ data, index, style }) => {
222
205
  const item = data === null || data === void 0 ? void 0 : data[index];
223
206
  if (!item)
224
207
  return null;
@@ -1,5 +1,5 @@
1
1
  import styled from "styled-components";
2
2
  export const StyledFloatContainer = styled.div `
3
- z-index: 1500;
3
+ z-index: 100002;
4
4
  outline: none;
5
5
  `;
@@ -1,6 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import styled from "styled-components";
3
3
  import * as Tooltip from "@radix-ui/react-tooltip";
4
+ import { getControlSizeTokens } from "../core";
4
5
  export const InfoComponent = styled(({ className, children, description, label }) => {
5
6
  if (!description)
6
7
  return children;
@@ -56,17 +57,8 @@ const FieldLabel = styled(({ className, children, error, description, size = "sm
56
57
  margin-left: 8px;
57
58
  }
58
59
 
59
- font-size: ${({ size = "sm" }) => size === "xs"
60
- ? "10px"
61
- : size === "sm"
62
- ? "12px"
63
- : size === "md"
64
- ? "14px"
65
- : size === "lg"
66
- ? "16px"
67
- : size === "xl"
68
- ? "18px"
69
- : "12px"};
60
+ font-size: ${({ size = "sm" }) => `${getControlSizeTokens(size).labelFontSize}px`};
61
+ line-height: 1.3;
70
62
 
71
63
  transition: all 0.2s ease;
72
64
  color: ${({ theme, error }) => theme.palette.text.secondary};
@@ -92,7 +84,7 @@ const FieldLabel = styled(({ className, children, error, description, size = "sm
92
84
  transition: all 0.2s ease;
93
85
  cursor: pointer;
94
86
  color: ${({ theme }) => theme.palette.error.main};
95
- font-size: 10px;
87
+ font-size: ${({ size = "sm" }) => `${getControlSizeTokens(size).supportingFontSize}px`};
96
88
  max-width: 85%;
97
89
  white-space: nowrap;
98
90
  overflow: hidden;