@monolith-forensics/monolith-ui 1.8.1-dev.4 → 1.9.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 (205) 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/CheckBox/CheckBox.js +19 -36
  9. package/dist/DateInput/DateInput.js +143 -198
  10. package/dist/DropDownMenu/DropDownMenu.js +15 -25
  11. package/dist/DropDownMenu/components/MenuComponent.js +2 -8
  12. package/dist/DropDownMenu/components/MenuItem.d.ts +0 -2
  13. package/dist/DropDownMenu/components/MenuItem.js +21 -25
  14. package/dist/DropDownMenu/components/MenuItemList.d.ts +0 -3
  15. package/dist/DropDownMenu/components/MenuItemList.js +86 -192
  16. package/dist/DropDownMenu/components/StyledContent.js +2 -1
  17. package/dist/DropDownMenu/components/StyledFloatContainer.js +1 -1
  18. package/dist/DropDownMenu/types.d.ts +0 -3
  19. package/dist/FieldLabel/FieldLabel.js +12 -4
  20. package/dist/FileInputField/FileInputField.js +23 -4
  21. package/dist/FileViewer/viewers/ImageViewer.js +18 -75
  22. package/dist/FormSection/FormSection.js +25 -5
  23. package/dist/IconButton/IconButton.js +16 -2
  24. package/dist/Input/Input.js +56 -7
  25. package/dist/MonolithUIProvider/MonolithUIProvider.d.ts +0 -1
  26. package/dist/Pill/Pill.js +79 -8
  27. package/dist/Popover/Popover.context.d.ts +1 -2
  28. package/dist/Popover/Popover.js +2 -5
  29. package/dist/Popover/Popover.styles.d.ts +6 -1
  30. package/dist/Popover/Popover.styles.js +28 -11
  31. package/dist/Popover/Popover.transitions.d.ts +2 -4
  32. package/dist/Popover/Popover.transitions.js +49 -23
  33. package/dist/Popover/PopoverDropdown.js +8 -6
  34. package/dist/Popover/PopoverTarget.js +3 -6
  35. package/dist/QueryFilter/DefaultOperators.d.ts +76 -0
  36. package/dist/QueryFilter/DefaultOperators.js +21 -0
  37. package/dist/QueryFilter/QueryFilter.d.ts +1 -1
  38. package/dist/QueryFilter/QueryFilter.js +303 -3
  39. package/dist/QueryFilter/index.d.ts +2 -3
  40. package/dist/QueryFilter/index.js +2 -3
  41. package/dist/QueryFilter/{QueryFilter.types.d.ts → types.d.ts} +2 -11
  42. package/dist/QueryFilter/useQueryFilter.d.ts +1 -1
  43. package/dist/QueryFilter/useQueryFilter.js +19 -23
  44. package/dist/RichTextEditor/Extensions/getTiptapExtensions.js +15 -5
  45. package/dist/RichTextEditor/Plugins/UploadImagesPlugin.d.ts +0 -15
  46. package/dist/RichTextEditor/Plugins/UploadImagesPlugin.js +51 -115
  47. package/dist/RichTextEditor/Plugins/index.d.ts +0 -1
  48. package/dist/RichTextEditor/Plugins/index.js +0 -1
  49. package/dist/RichTextEditor/RichTextEditor.d.ts +2 -3
  50. package/dist/RichTextEditor/RichTextEditor.js +35 -309
  51. package/dist/RichTextEditor/Toolbar/Toolbar.js +2 -14
  52. package/dist/SegmentedControl/SegmentedControl.utils.d.ts +2 -2
  53. package/dist/SegmentedControl/SegmentedControl.utils.js +30 -3
  54. package/dist/SelectBox/SelectBox.js +5 -5
  55. package/dist/SelectBox/select-box.styled-components.d.ts +1 -4
  56. package/dist/SelectBox/select-box.styled-components.js +48 -11
  57. package/dist/SelectBox/types.d.ts +0 -1
  58. package/dist/Switch/Switch.d.ts +2 -2
  59. package/dist/Switch/Switch.js +83 -18
  60. package/dist/Table/ColumnResizer.d.ts +9 -6
  61. package/dist/Table/ColumnResizer.js +10 -30
  62. package/dist/Table/StateStorage.d.ts +0 -4
  63. package/dist/Table/StateStorage.js +0 -13
  64. package/dist/Table/Table.js +12 -160
  65. package/dist/Table/TableComponents.d.ts +0 -10
  66. package/dist/Table/TableComponents.js +10 -71
  67. package/dist/Table/TableDefaults.d.ts +0 -7
  68. package/dist/Table/TableDefaults.js +0 -7
  69. package/dist/Table/TableHeader.js +16 -31
  70. package/dist/Table/TableMenu/TableMenu.js +1 -1
  71. package/dist/Table/TableProvider.js +75 -354
  72. package/dist/Table/TableRow.js +16 -28
  73. package/dist/Table/Utils/index.d.ts +1 -0
  74. package/dist/Table/Utils/index.js +1 -0
  75. package/dist/Table/Utils/resizeHandler.d.ts +3 -0
  76. package/dist/Table/Utils/resizeHandler.js +84 -0
  77. package/dist/Table/types.d.ts +19 -70
  78. package/dist/Tabs/Tab.js +0 -8
  79. package/dist/TagBox/TagBox.d.ts +1 -1
  80. package/dist/TagBox/TagBox.js +208 -50
  81. package/dist/TagBox/types.d.ts +13 -1
  82. package/dist/TextArea/TextArea.js +23 -9
  83. package/dist/TextInput/TextInput.js +6 -12
  84. package/dist/Utilities/parseTimestamp.js +6 -11
  85. package/dist/core/ArrowButton.d.ts +0 -2
  86. package/dist/core/ArrowButton.js +3 -7
  87. package/dist/core/ClearButton.d.ts +0 -2
  88. package/dist/core/ClearButton.js +3 -7
  89. package/dist/core/controlSizes.d.ts +0 -26
  90. package/dist/core/controlSizes.js +0 -156
  91. package/dist/index.d.ts +0 -3
  92. package/dist/index.js +0 -2
  93. package/dist/theme/variants.js +0 -2
  94. package/package.json +18 -26
  95. package/dist/Charts/BarChart/BarChart.d.ts +0 -5
  96. package/dist/Charts/BarChart/BarChart.js +0 -549
  97. package/dist/Charts/BarChart/BarChart.lib.d.ts +0 -31
  98. package/dist/Charts/BarChart/BarChart.lib.js +0 -136
  99. package/dist/Charts/BarChart/BarChart.styled.d.ts +0 -51
  100. package/dist/Charts/BarChart/BarChart.styled.js +0 -115
  101. package/dist/Charts/BarChart/BarChart.types.d.ts +0 -171
  102. package/dist/Charts/BarChart/index.d.ts +0 -3
  103. package/dist/Charts/BarChart/index.js +0 -2
  104. package/dist/Charts/ChartPrimitives/ChartExportControl.d.ts +0 -11
  105. package/dist/Charts/ChartPrimitives/ChartExportControl.js +0 -29
  106. package/dist/Charts/ChartPrimitives/chartActions.styled.d.ts +0 -1
  107. package/dist/Charts/ChartPrimitives/chartActions.styled.js +0 -8
  108. package/dist/Charts/ChartPrimitives/chartLegend.styled.d.ts +0 -12
  109. package/dist/Charts/ChartPrimitives/chartLegend.styled.js +0 -52
  110. package/dist/Charts/ChartPrimitives/chartTooltip.styled.d.ts +0 -19
  111. package/dist/Charts/ChartPrimitives/chartTooltip.styled.js +0 -61
  112. package/dist/Charts/ChartPrimitives/index.d.ts +0 -4
  113. package/dist/Charts/ChartPrimitives/index.js +0 -4
  114. package/dist/Charts/ChartUtils/chartColors.d.ts +0 -8
  115. package/dist/Charts/ChartUtils/chartColors.js +0 -65
  116. package/dist/Charts/ChartUtils/chartExport.d.ts +0 -47
  117. package/dist/Charts/ChartUtils/chartExport.js +0 -311
  118. package/dist/Charts/ChartUtils/chartMath.d.ts +0 -3
  119. package/dist/Charts/ChartUtils/chartMath.js +0 -3
  120. package/dist/Charts/ChartUtils/index.d.ts +0 -3
  121. package/dist/Charts/ChartUtils/index.js +0 -3
  122. package/dist/Charts/HeatMap/HeatMap.d.ts +0 -5
  123. package/dist/Charts/HeatMap/HeatMap.js +0 -212
  124. package/dist/Charts/HeatMap/HeatMap.lib.d.ts +0 -30
  125. package/dist/Charts/HeatMap/HeatMap.lib.js +0 -115
  126. package/dist/Charts/HeatMap/HeatMap.styled.d.ts +0 -37
  127. package/dist/Charts/HeatMap/HeatMap.styled.js +0 -91
  128. package/dist/Charts/HeatMap/HeatMap.types.d.ts +0 -80
  129. package/dist/Charts/HeatMap/HeatMap.types.js +0 -1
  130. package/dist/Charts/HeatMap/index.d.ts +0 -3
  131. package/dist/Charts/HeatMap/index.js +0 -2
  132. package/dist/Charts/LineChart/LineChart.d.ts +0 -5
  133. package/dist/Charts/LineChart/LineChart.js +0 -529
  134. package/dist/Charts/LineChart/LineChart.lib.d.ts +0 -24
  135. package/dist/Charts/LineChart/LineChart.lib.js +0 -132
  136. package/dist/Charts/LineChart/LineChart.styled.d.ts +0 -59
  137. package/dist/Charts/LineChart/LineChart.styled.js +0 -147
  138. package/dist/Charts/LineChart/LineChart.types.d.ts +0 -193
  139. package/dist/Charts/LineChart/LineChart.types.js +0 -1
  140. package/dist/Charts/LineChart/index.d.ts +0 -3
  141. package/dist/Charts/LineChart/index.js +0 -2
  142. package/dist/Charts/PieChart/PieChart.d.ts +0 -4
  143. package/dist/Charts/PieChart/PieChart.js +0 -199
  144. package/dist/Charts/PieChart/PieChart.lib.d.ts +0 -5
  145. package/dist/Charts/PieChart/PieChart.lib.js +0 -19
  146. package/dist/Charts/PieChart/PieChart.styled.d.ts +0 -51
  147. package/dist/Charts/PieChart/PieChart.styled.js +0 -163
  148. package/dist/Charts/PieChart/PieChart.types.d.ts +0 -100
  149. package/dist/Charts/PieChart/PieChart.types.js +0 -1
  150. package/dist/Charts/PieChart/index.d.ts +0 -2
  151. package/dist/Charts/PieChart/index.js +0 -1
  152. package/dist/Charts/index.d.ts +0 -5
  153. package/dist/Charts/index.js +0 -4
  154. package/dist/QueryFilter/QueryFilter.constants.d.ts +0 -134
  155. package/dist/QueryFilter/QueryFilter.constants.js +0 -39
  156. package/dist/QueryFilter/QueryFilter.lib.d.ts +0 -14
  157. package/dist/QueryFilter/QueryFilter.lib.js +0 -84
  158. package/dist/QueryFilter/QueryFilter.styled.d.ts +0 -89
  159. package/dist/QueryFilter/QueryFilter.styled.js +0 -184
  160. package/dist/QueryFilter/QueryFilter.types.js +0 -1
  161. package/dist/QueryFilter/components/MultiSelectEditor.d.ts +0 -7
  162. package/dist/QueryFilter/components/MultiSelectEditor.js +0 -44
  163. package/dist/QueryFilter/components/RuleChip.d.ts +0 -8
  164. package/dist/QueryFilter/components/RuleChip.js +0 -37
  165. package/dist/QueryFilter/components/Rules.d.ts +0 -11
  166. package/dist/QueryFilter/components/Rules.js +0 -41
  167. package/dist/QueryFilter/components/UnavailableRuleChip.d.ts +0 -5
  168. package/dist/QueryFilter/components/UnavailableRuleChip.js +0 -7
  169. package/dist/QueryFilter/components/ValueEditor.d.ts +0 -7
  170. package/dist/QueryFilter/components/ValueEditor.js +0 -45
  171. package/dist/QueryFilter/components/ValueSelector.d.ts +0 -7
  172. package/dist/QueryFilter/components/ValueSelector.js +0 -34
  173. package/dist/QueryFilter/components/index.d.ts +0 -6
  174. package/dist/QueryFilter/components/index.js +0 -6
  175. package/dist/RichTextEditor/Plugins/ImageActionsPlugin.d.ts +0 -3
  176. package/dist/RichTextEditor/Plugins/ImageActionsPlugin.js +0 -241
  177. package/dist/SuperDatePicker/SuperDatePicker.constants.d.ts +0 -24
  178. package/dist/SuperDatePicker/SuperDatePicker.constants.js +0 -30
  179. package/dist/SuperDatePicker/SuperDatePicker.d.ts +0 -3
  180. package/dist/SuperDatePicker/SuperDatePicker.js +0 -31
  181. package/dist/SuperDatePicker/SuperDatePicker.lib.d.ts +0 -17
  182. package/dist/SuperDatePicker/SuperDatePicker.lib.js +0 -206
  183. package/dist/SuperDatePicker/SuperDatePicker.styled.d.ts +0 -60
  184. package/dist/SuperDatePicker/SuperDatePicker.styled.js +0 -256
  185. package/dist/SuperDatePicker/SuperDatePicker.types.d.ts +0 -48
  186. package/dist/SuperDatePicker/SuperDatePicker.types.js +0 -1
  187. package/dist/SuperDatePicker/components/CommonPresetGroups.d.ts +0 -7
  188. package/dist/SuperDatePicker/components/CommonPresetGroups.js +0 -6
  189. package/dist/SuperDatePicker/components/EndpointCalendarDropdown.d.ts +0 -10
  190. package/dist/SuperDatePicker/components/EndpointCalendarDropdown.js +0 -9
  191. package/dist/SuperDatePicker/components/EndpointDateInput.d.ts +0 -16
  192. package/dist/SuperDatePicker/components/EndpointDateInput.js +0 -26
  193. package/dist/SuperDatePicker/components/EndpointPopover.d.ts +0 -18
  194. package/dist/SuperDatePicker/components/EndpointPopover.js +0 -11
  195. package/dist/SuperDatePicker/components/QuickRangeDropdown.d.ts +0 -14
  196. package/dist/SuperDatePicker/components/QuickRangeDropdown.js +0 -19
  197. package/dist/SuperDatePicker/components/QuickRangePopover.d.ts +0 -18
  198. package/dist/SuperDatePicker/components/QuickRangePopover.js +0 -12
  199. package/dist/SuperDatePicker/components/index.d.ts +0 -6
  200. package/dist/SuperDatePicker/components/index.js +0 -6
  201. package/dist/SuperDatePicker/index.d.ts +0 -3
  202. package/dist/SuperDatePicker/index.js +0 -3
  203. package/dist/SuperDatePicker/useSuperDatePicker.d.ts +0 -32
  204. package/dist/SuperDatePicker/useSuperDatePicker.js +0 -125
  205. /package/dist/{Charts/BarChart/BarChart.types.js → QueryFilter/types.js} +0 -0
@@ -1,18 +0,0 @@
1
- import type { SuperDatePickerProps } from "../SuperDatePicker.types";
2
- type EndpointPopoverProps = {
3
- opened: boolean;
4
- disabled: boolean;
5
- label: string;
6
- value?: string | null;
7
- onOpenChange: (opened: boolean) => void;
8
- onInputChange: (value?: string | null) => void;
9
- onCalendarChange: (date: Date | null) => void;
10
- format: NonNullable<SuperDatePickerProps["format"]>;
11
- size: NonNullable<SuperDatePickerProps["size"]>;
12
- utc: boolean;
13
- min?: Date;
14
- max?: Date;
15
- timeIntervalMinutes?: number;
16
- };
17
- declare const EndpointPopover: ({ opened, disabled, label, value, onOpenChange, onInputChange, onCalendarChange, format, size, utc, min, max, timeIntervalMinutes, }: EndpointPopoverProps) => import("react/jsx-runtime").JSX.Element;
18
- export default EndpointPopover;
@@ -1,11 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Popover } from "../../Popover";
3
- import EndpointCalendarDropdown from "./EndpointCalendarDropdown";
4
- import EndpointDateInput from "./EndpointDateInput";
5
- const EndpointPopover = ({ opened, disabled, label, value, onOpenChange, onInputChange, onCalendarChange, format, size, utc, min, max, timeIntervalMinutes, }) => {
6
- return (_jsxs(Popover, { opened: opened, onChange: (nextOpened) => onOpenChange(!disabled && nextOpened), position: "bottom-start", offset: 5, withinPortal: true, children: [_jsx(Popover.Target, { children: _jsx(EndpointDateInput, { active: opened, ariaLabel: label, value: value, onChange: onInputChange, onOpen: () => onOpenChange(true), format: format, size: size, disabled: disabled, utc: utc, min: min, max: max }) }), _jsx(Popover.Dropdown, { style: {
7
- border: "none",
8
- padding: 0,
9
- }, children: _jsx(EndpointCalendarDropdown, { value: value, onChange: onCalendarChange, min: min, max: max, timeIntervalMinutes: timeIntervalMinutes, utc: utc }) })] }));
10
- };
11
- export default EndpointPopover;
@@ -1,14 +0,0 @@
1
- import type { CommonRangeGroupConfig, QuickDirection, QuickUnit, SuperDatePickerPreset } from "../SuperDatePicker.types";
2
- type QuickRangeDropdownProps = {
3
- commonRangeGroups: CommonRangeGroupConfig[];
4
- quickDirection: QuickDirection;
5
- quickAmount: string;
6
- quickUnit: QuickUnit;
7
- onQuickDirectionChange: (direction: QuickDirection) => void;
8
- onQuickAmountChange: (amount: string) => void;
9
- onQuickAmountSubmit: () => void;
10
- onQuickUnitChange: (unit: QuickUnit) => void;
11
- onPresetClick: (preset: SuperDatePickerPreset) => void;
12
- };
13
- declare const QuickRangeDropdown: ({ commonRangeGroups, quickDirection, quickAmount, quickUnit, onQuickDirectionChange, onQuickAmountChange, onQuickAmountSubmit, onQuickUnitChange, onPresetClick, }: QuickRangeDropdownProps) => import("react/jsx-runtime").JSX.Element;
14
- export default QuickRangeDropdown;
@@ -1,19 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { SelectBox } from "../../SelectBox";
3
- import { TextInput } from "../../TextInput";
4
- import { StyledContent } from "../../core";
5
- import { QUICK_DIRECTION_OPTIONS, QUICK_UNITS, } from "../SuperDatePicker.constants";
6
- import { CommonRangesSection, PanelTitle, QuickRangePanel, QuickRangeSection, QuickSelectRow, } from "../SuperDatePicker.styled";
7
- import CommonPresetGroups from "./CommonPresetGroups";
8
- const QuickRangeDropdown = ({ commonRangeGroups, quickDirection, quickAmount, quickUnit, onQuickDirectionChange, onQuickAmountChange, onQuickAmountSubmit, onQuickUnitChange, onPresetClick, }) => {
9
- const handleAmountKeyDown = (event) => {
10
- if (event.key === "Enter") {
11
- onQuickAmountSubmit();
12
- }
13
- };
14
- const handleAmountChange = (event) => {
15
- onQuickAmountChange(event.target.value);
16
- };
17
- return (_jsx(StyledContent, { maxDropdownHeight: "fit-content", children: _jsxs(QuickRangePanel, { children: [_jsxs(QuickRangeSection, { children: [_jsx(PanelTitle, { children: "Quick select" }), _jsxs(QuickSelectRow, { children: [_jsx(SelectBox, { data: QUICK_DIRECTION_OPTIONS, value: quickDirection, onChange: (value) => onQuickDirectionChange(value), size: "xs", variant: "outlined", width: "100%", openOnFocus: false, arrow: true }), _jsx(TextInput, { type: "number", min: 1, value: quickAmount, onChange: handleAmountChange, onKeyDown: handleAmountKeyDown, size: "xs", variant: "outlined" }), _jsx(SelectBox, { data: QUICK_UNITS, value: quickUnit, onChange: (value) => onQuickUnitChange(value), size: "xs", variant: "outlined", width: "100%", openOnFocus: false, arrow: true })] })] }), _jsxs(CommonRangesSection, { children: [_jsx(PanelTitle, { children: "Presets" }), _jsx(CommonPresetGroups, { groups: commonRangeGroups, onPresetClick: onPresetClick })] })] }) }));
18
- };
19
- export default QuickRangeDropdown;
@@ -1,18 +0,0 @@
1
- import type { CommonRangeGroupConfig, QuickDirection, QuickUnit, SuperDatePickerPreset, SuperDatePickerProps } from "../SuperDatePicker.types";
2
- type QuickRangePopoverProps = {
3
- opened: boolean;
4
- disabled: boolean;
5
- size: NonNullable<SuperDatePickerProps["size"]>;
6
- commonRangeGroups: CommonRangeGroupConfig[];
7
- quickDirection: QuickDirection;
8
- quickAmount: string;
9
- quickUnit: QuickUnit;
10
- onOpenChange: (opened: boolean) => void;
11
- onQuickDirectionChange: (direction: QuickDirection) => void;
12
- onQuickAmountChange: (amount: string) => void;
13
- onQuickAmountSubmit: () => void;
14
- onQuickUnitChange: (unit: QuickUnit) => void;
15
- onPresetClick: (preset: SuperDatePickerPreset) => void;
16
- };
17
- declare const QuickRangePopover: ({ opened, disabled, size, commonRangeGroups, quickDirection, quickAmount, quickUnit, onOpenChange, onQuickDirectionChange, onQuickAmountChange, onQuickAmountSubmit, onQuickUnitChange, onPresetClick, }: QuickRangePopoverProps) => import("react/jsx-runtime").JSX.Element;
18
- export default QuickRangePopover;
@@ -1,12 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { CalendarDaysIcon } from "lucide-react";
3
- import { Popover } from "../../Popover";
4
- import { SegmentButton, TriggerIcon, } from "../SuperDatePicker.styled";
5
- import QuickRangeDropdown from "./QuickRangeDropdown";
6
- const QuickRangePopover = ({ opened, disabled, size, commonRangeGroups, quickDirection, quickAmount, quickUnit, onOpenChange, onQuickDirectionChange, onQuickAmountChange, onQuickAmountSubmit, onQuickUnitChange, onPresetClick, }) => {
7
- return (_jsxs(Popover, { opened: opened, onChange: (nextOpened) => onOpenChange(!disabled && nextOpened), position: "bottom-start", offset: 5, withinPortal: true, children: [_jsx(Popover.Target, { children: _jsx(SegmentButton, { type: "button", size: size, "$iconOnly": true, disabled: disabled, "aria-label": "Open quick date ranges", title: "Open quick date ranges", "data-active": opened, children: _jsx(TriggerIcon, { size: size, children: _jsx(CalendarDaysIcon, {}) }) }) }), _jsx(Popover.Dropdown, { style: {
8
- border: "none",
9
- padding: 0,
10
- }, children: _jsx(QuickRangeDropdown, { commonRangeGroups: commonRangeGroups, quickDirection: quickDirection, quickAmount: quickAmount, quickUnit: quickUnit, onQuickDirectionChange: onQuickDirectionChange, onQuickAmountChange: onQuickAmountChange, onQuickAmountSubmit: onQuickAmountSubmit, onQuickUnitChange: onQuickUnitChange, onPresetClick: onPresetClick }) })] }));
11
- };
12
- export default QuickRangePopover;
@@ -1,6 +0,0 @@
1
- export { default as CommonPresetGroups } from "./CommonPresetGroups";
2
- export { default as EndpointCalendarDropdown } from "./EndpointCalendarDropdown";
3
- export { default as EndpointDateInput } from "./EndpointDateInput";
4
- export { default as EndpointPopover } from "./EndpointPopover";
5
- export { default as QuickRangeDropdown } from "./QuickRangeDropdown";
6
- export { default as QuickRangePopover } from "./QuickRangePopover";
@@ -1,6 +0,0 @@
1
- export { default as CommonPresetGroups } from "./CommonPresetGroups";
2
- export { default as EndpointCalendarDropdown } from "./EndpointCalendarDropdown";
3
- export { default as EndpointDateInput } from "./EndpointDateInput";
4
- export { default as EndpointPopover } from "./EndpointPopover";
5
- export { default as QuickRangeDropdown } from "./QuickRangeDropdown";
6
- export { default as QuickRangePopover } from "./QuickRangePopover";
@@ -1,3 +0,0 @@
1
- export { default } from "./SuperDatePicker";
2
- export * from "./SuperDatePicker";
3
- export * from "./SuperDatePicker.types";
@@ -1,3 +0,0 @@
1
- export { default } from "./SuperDatePicker";
2
- export * from "./SuperDatePicker";
3
- export * from "./SuperDatePicker.types";
@@ -1,32 +0,0 @@
1
- import type { MouseEvent } from "react";
2
- import type { CommonRangeGroupConfig, Endpoint, OpenSegment, QuickDirection, QuickUnit, SuperDatePickerPreset, SuperDatePickerProps, SuperDatePickerValue } from "./SuperDatePicker.types";
3
- type UseSuperDatePickerOptions = {
4
- defaultValue: SuperDatePickerValue;
5
- value?: SuperDatePickerValue;
6
- onChange: NonNullable<SuperDatePickerProps["onChange"]>;
7
- disabled: boolean;
8
- min?: Date;
9
- max?: Date;
10
- utc: boolean;
11
- presets?: SuperDatePickerPreset[];
12
- };
13
- declare const useSuperDatePicker: ({ defaultValue, value, onChange, disabled, min, max, utc, presets, }: UseSuperDatePickerOptions) => {
14
- value: SuperDatePickerValue;
15
- openSegment: OpenSegment;
16
- quickDirection: QuickDirection;
17
- quickAmount: string;
18
- quickUnit: QuickUnit;
19
- commonRangeGroups: CommonRangeGroupConfig[];
20
- handleOpenSegmentChange: (segment: Endpoint | "quick", opened: boolean) => void;
21
- handleClear: (event?: MouseEvent) => void;
22
- handlePreset: (preset: SuperDatePickerPreset) => void;
23
- handleQuickDirectionChange: (nextDirection: QuickDirection) => void;
24
- handleQuickAmountChange: (nextAmount: string) => void;
25
- handleQuickAmountSubmit: () => void;
26
- handleQuickUnitChange: (nextUnit: QuickUnit) => void;
27
- handleEndpointChange: (endpoint: Endpoint, nextValue?: string | null) => void;
28
- handleCalendarChange: (endpoint: Endpoint, date: Date | null) => void;
29
- getEndpointMin: (endpoint: Endpoint) => Date | undefined;
30
- getEndpointMax: (endpoint: Endpoint) => Date | undefined;
31
- };
32
- export default useSuperDatePicker;
@@ -1,125 +0,0 @@
1
- import { useCallback, useMemo, useRef, useState } from "react";
2
- import { DEFAULT_QUICK_AMOUNT, DEFAULT_QUICK_DIRECTION, DEFAULT_QUICK_UNIT, } from "./SuperDatePicker.constants";
3
- import { calendarDateToMoment, createRange, getAdditionalCommonRangeGroups, getDefaultCommonRangeGroups, parseRangeMoment, resolveNow, serializeMoment, } from "./SuperDatePicker.lib";
4
- const useSuperDatePicker = ({ defaultValue, value, onChange, disabled, min, max, utc, presets, }) => {
5
- const isControlled = useRef(value !== undefined);
6
- const [uncontrolledValue, setUncontrolledValue] = useState(defaultValue);
7
- const pickerValue = isControlled.current ? value || {} : uncontrolledValue;
8
- const [openSegment, setOpenSegment] = useState(null);
9
- const [quickDirection, setQuickDirection] = useState(DEFAULT_QUICK_DIRECTION);
10
- const [quickAmount, setQuickAmount] = useState(DEFAULT_QUICK_AMOUNT);
11
- const [quickUnit, setQuickUnit] = useState(DEFAULT_QUICK_UNIT);
12
- const commonRangeGroups = useMemo(() => presets
13
- ? [
14
- {
15
- label: "Presets",
16
- ranges: presets,
17
- },
18
- ]
19
- : [
20
- ...getDefaultCommonRangeGroups(utc),
21
- ...getAdditionalCommonRangeGroups(utc),
22
- ], [presets, utc]);
23
- const commitValue = useCallback((nextValue, meta) => {
24
- if (!isControlled.current) {
25
- setUncontrolledValue(nextValue);
26
- }
27
- onChange(nextValue, meta);
28
- }, [onChange]);
29
- const commitPartial = (patch, source) => {
30
- commitValue(Object.assign(Object.assign({}, pickerValue), patch), { source });
31
- };
32
- const commitQuickRange = (direction = quickDirection, amountInput = quickAmount, unit = quickUnit) => {
33
- if (disabled)
34
- return;
35
- const amount = Number(amountInput);
36
- if (!Number.isFinite(amount) || amount <= 0)
37
- return;
38
- const now = resolveNow(utc);
39
- const nextValue = direction === "last"
40
- ? createRange(now.clone().subtract(amount, unit), now, utc)
41
- : createRange(now, now.clone().add(amount, unit), utc);
42
- commitValue(nextValue, { source: "apply" });
43
- };
44
- const handleOpenSegmentChange = (segment, opened) => {
45
- setOpenSegment((currentSegment) => {
46
- if (opened)
47
- return segment;
48
- return currentSegment === segment ? null : currentSegment;
49
- });
50
- };
51
- const handleClear = (event) => {
52
- event === null || event === void 0 ? void 0 : event.preventDefault();
53
- event === null || event === void 0 ? void 0 : event.stopPropagation();
54
- commitValue({ start: null, end: null }, { source: "clear" });
55
- setOpenSegment(null);
56
- };
57
- const handlePreset = (preset) => {
58
- if (disabled)
59
- return;
60
- const nextValue = preset.getRange();
61
- commitValue(nextValue, { source: "preset", preset });
62
- setOpenSegment(null);
63
- };
64
- const handleQuickDirectionChange = (nextDirection) => {
65
- setQuickDirection(nextDirection);
66
- commitQuickRange(nextDirection);
67
- };
68
- const handleQuickAmountChange = (nextAmount) => {
69
- setQuickAmount(nextAmount);
70
- commitQuickRange(quickDirection, nextAmount, quickUnit);
71
- };
72
- const handleQuickAmountSubmit = () => {
73
- commitQuickRange();
74
- };
75
- const handleQuickUnitChange = (nextUnit) => {
76
- setQuickUnit(nextUnit);
77
- commitQuickRange(quickDirection, quickAmount, nextUnit);
78
- };
79
- const handleEndpointChange = (endpoint, nextValue) => {
80
- if (disabled)
81
- return;
82
- commitPartial({ [endpoint]: nextValue }, "apply");
83
- };
84
- const handleCalendarChange = (endpoint, date) => {
85
- if (disabled)
86
- return;
87
- if (!date) {
88
- handleEndpointChange(endpoint, null);
89
- return;
90
- }
91
- handleEndpointChange(endpoint, serializeMoment(calendarDateToMoment(date, utc), utc));
92
- };
93
- const getEndpointMin = (endpoint) => {
94
- var _a;
95
- return endpoint === "end"
96
- ? ((_a = parseRangeMoment(pickerValue.start, utc)) === null || _a === void 0 ? void 0 : _a.toDate()) || min
97
- : min;
98
- };
99
- const getEndpointMax = (endpoint) => {
100
- var _a;
101
- return endpoint === "start"
102
- ? ((_a = parseRangeMoment(pickerValue.end, utc)) === null || _a === void 0 ? void 0 : _a.toDate()) || max
103
- : max;
104
- };
105
- return {
106
- value: pickerValue,
107
- openSegment,
108
- quickDirection,
109
- quickAmount,
110
- quickUnit,
111
- commonRangeGroups,
112
- handleOpenSegmentChange,
113
- handleClear,
114
- handlePreset,
115
- handleQuickDirectionChange,
116
- handleQuickAmountChange,
117
- handleQuickAmountSubmit,
118
- handleQuickUnitChange,
119
- handleEndpointChange,
120
- handleCalendarChange,
121
- getEndpointMin,
122
- getEndpointMax,
123
- };
124
- };
125
- export default useSuperDatePicker;