@monolith-forensics/monolith-ui 1.8.0 → 1.8.1-dev.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 (120) hide show
  1. package/dist/Button/Button.js +9 -58
  2. package/dist/Calendar/Calendar.d.ts +3 -1
  3. package/dist/Calendar/Calendar.js +134 -33
  4. package/dist/Calendar/CalendarStyles.d.ts +3 -0
  5. package/dist/Calendar/CalendarStyles.js +92 -14
  6. package/dist/Calendar/calendarHelpers.d.ts +5 -1
  7. package/dist/Calendar/calendarHelpers.js +13 -5
  8. package/dist/Charts/BarChart/BarChart.d.ts +5 -0
  9. package/dist/Charts/BarChart/BarChart.js +549 -0
  10. package/dist/Charts/BarChart/BarChart.lib.d.ts +31 -0
  11. package/dist/Charts/BarChart/BarChart.lib.js +136 -0
  12. package/dist/Charts/BarChart/BarChart.styled.d.ts +51 -0
  13. package/dist/Charts/BarChart/BarChart.styled.js +115 -0
  14. package/dist/Charts/BarChart/BarChart.types.d.ts +171 -0
  15. package/dist/Charts/BarChart/BarChart.types.js +1 -0
  16. package/dist/Charts/BarChart/index.d.ts +3 -0
  17. package/dist/Charts/BarChart/index.js +2 -0
  18. package/dist/Charts/ChartPrimitives/ChartExportControl.d.ts +11 -0
  19. package/dist/Charts/ChartPrimitives/ChartExportControl.js +29 -0
  20. package/dist/Charts/ChartPrimitives/chartActions.styled.d.ts +1 -0
  21. package/dist/Charts/ChartPrimitives/chartActions.styled.js +8 -0
  22. package/dist/Charts/ChartPrimitives/chartLegend.styled.d.ts +12 -0
  23. package/dist/Charts/ChartPrimitives/chartLegend.styled.js +52 -0
  24. package/dist/Charts/ChartPrimitives/chartTooltip.styled.d.ts +19 -0
  25. package/dist/Charts/ChartPrimitives/chartTooltip.styled.js +61 -0
  26. package/dist/Charts/ChartPrimitives/index.d.ts +4 -0
  27. package/dist/Charts/ChartPrimitives/index.js +4 -0
  28. package/dist/Charts/ChartUtils/chartColors.d.ts +8 -0
  29. package/dist/Charts/ChartUtils/chartColors.js +65 -0
  30. package/dist/Charts/ChartUtils/chartExport.d.ts +47 -0
  31. package/dist/Charts/ChartUtils/chartExport.js +311 -0
  32. package/dist/Charts/ChartUtils/chartMath.d.ts +3 -0
  33. package/dist/Charts/ChartUtils/chartMath.js +3 -0
  34. package/dist/Charts/ChartUtils/index.d.ts +3 -0
  35. package/dist/Charts/ChartUtils/index.js +3 -0
  36. package/dist/Charts/HeatMap/HeatMap.d.ts +5 -0
  37. package/dist/Charts/HeatMap/HeatMap.js +212 -0
  38. package/dist/Charts/HeatMap/HeatMap.lib.d.ts +30 -0
  39. package/dist/Charts/HeatMap/HeatMap.lib.js +115 -0
  40. package/dist/Charts/HeatMap/HeatMap.styled.d.ts +37 -0
  41. package/dist/Charts/HeatMap/HeatMap.styled.js +91 -0
  42. package/dist/Charts/HeatMap/HeatMap.types.d.ts +80 -0
  43. package/dist/Charts/HeatMap/HeatMap.types.js +1 -0
  44. package/dist/Charts/HeatMap/index.d.ts +3 -0
  45. package/dist/Charts/HeatMap/index.js +2 -0
  46. package/dist/Charts/LineChart/LineChart.d.ts +5 -0
  47. package/dist/Charts/LineChart/LineChart.js +529 -0
  48. package/dist/Charts/LineChart/LineChart.lib.d.ts +24 -0
  49. package/dist/Charts/LineChart/LineChart.lib.js +132 -0
  50. package/dist/Charts/LineChart/LineChart.styled.d.ts +59 -0
  51. package/dist/Charts/LineChart/LineChart.styled.js +147 -0
  52. package/dist/Charts/LineChart/LineChart.types.d.ts +193 -0
  53. package/dist/Charts/LineChart/LineChart.types.js +1 -0
  54. package/dist/Charts/LineChart/index.d.ts +3 -0
  55. package/dist/Charts/LineChart/index.js +2 -0
  56. package/dist/Charts/PieChart/PieChart.d.ts +4 -0
  57. package/dist/Charts/PieChart/PieChart.js +199 -0
  58. package/dist/Charts/PieChart/PieChart.lib.d.ts +5 -0
  59. package/dist/Charts/PieChart/PieChart.lib.js +19 -0
  60. package/dist/Charts/PieChart/PieChart.styled.d.ts +51 -0
  61. package/dist/Charts/PieChart/PieChart.styled.js +163 -0
  62. package/dist/Charts/PieChart/PieChart.types.d.ts +100 -0
  63. package/dist/Charts/PieChart/PieChart.types.js +1 -0
  64. package/dist/Charts/PieChart/index.d.ts +2 -0
  65. package/dist/Charts/PieChart/index.js +1 -0
  66. package/dist/Charts/index.d.ts +5 -0
  67. package/dist/Charts/index.js +4 -0
  68. package/dist/CheckBox/CheckBox.js +2 -16
  69. package/dist/DateInput/DateInput.js +198 -143
  70. package/dist/DropDownMenu/components/MenuComponent.js +2 -1
  71. package/dist/DropDownMenu/components/MenuItem.js +5 -14
  72. package/dist/DropDownMenu/components/MenuItemList.js +7 -24
  73. package/dist/DropDownMenu/components/StyledFloatContainer.js +1 -1
  74. package/dist/FieldLabel/FieldLabel.js +4 -12
  75. package/dist/FileInputField/FileInputField.js +4 -23
  76. package/dist/FormSection/FormSection.js +5 -25
  77. package/dist/IconButton/IconButton.js +2 -16
  78. package/dist/Input/Input.js +7 -56
  79. package/dist/Pill/Pill.js +8 -79
  80. package/dist/Popover/Popover.context.d.ts +2 -1
  81. package/dist/Popover/Popover.js +5 -2
  82. package/dist/Popover/Popover.styles.d.ts +1 -6
  83. package/dist/Popover/Popover.styles.js +11 -28
  84. package/dist/Popover/Popover.transitions.d.ts +4 -2
  85. package/dist/Popover/Popover.transitions.js +23 -49
  86. package/dist/Popover/PopoverDropdown.js +6 -8
  87. package/dist/Popover/PopoverTarget.js +6 -3
  88. package/dist/SegmentedControl/SegmentedControl.utils.d.ts +2 -2
  89. package/dist/SegmentedControl/SegmentedControl.utils.js +3 -30
  90. package/dist/SelectBox/SelectBox.js +5 -5
  91. package/dist/SelectBox/select-box.styled-components.d.ts +4 -1
  92. package/dist/SelectBox/select-box.styled-components.js +11 -48
  93. package/dist/SelectBox/types.d.ts +1 -0
  94. package/dist/Switch/Switch.d.ts +2 -2
  95. package/dist/Switch/Switch.js +18 -83
  96. package/dist/Table/StateStorage.d.ts +4 -0
  97. package/dist/Table/StateStorage.js +13 -0
  98. package/dist/Table/Table.js +160 -12
  99. package/dist/Table/TableComponents.d.ts +10 -0
  100. package/dist/Table/TableComponents.js +57 -0
  101. package/dist/Table/TableDefaults.d.ts +7 -0
  102. package/dist/Table/TableDefaults.js +7 -0
  103. package/dist/Table/TableProvider.js +263 -71
  104. package/dist/Table/TableRow.js +15 -10
  105. package/dist/Table/types.d.ts +64 -0
  106. package/dist/TagBox/TagBox.js +18 -76
  107. package/dist/TextArea/TextArea.js +4 -23
  108. package/dist/TextInput/TextInput.js +12 -6
  109. package/dist/Utilities/parseTimestamp.js +11 -6
  110. package/dist/core/ArrowButton.d.ts +2 -0
  111. package/dist/core/ArrowButton.js +7 -3
  112. package/dist/core/ClearButton.d.ts +2 -0
  113. package/dist/core/ClearButton.js +7 -3
  114. package/dist/core/controlSizes.d.ts +34 -0
  115. package/dist/core/controlSizes.js +190 -0
  116. package/dist/core/index.d.ts +1 -0
  117. package/dist/core/index.js +1 -0
  118. package/dist/index.d.ts +1 -0
  119. package/dist/index.js +1 -0
  120. package/package.json +5 -1
@@ -3,6 +3,7 @@ import { useCallback, useState } from "react";
3
3
  import styled from "styled-components";
4
4
  import { useDropzone } from "react-dropzone";
5
5
  import { Pill, FieldLabel } from "..";
6
+ import { getControlSizeTokens } from "../core";
6
7
  const FileInputField = styled(({ className, children, label, error, required, size, onChange, onFocus, dropZoneOptions = {}, colSpan, style = {}, }) => {
7
8
  const [files, setFiles] = useState([]);
8
9
  const onDrop = useCallback((acceptedFiles) => {
@@ -14,7 +15,7 @@ const FileInputField = styled(({ className, children, label, error, required, si
14
15
  setFiles((prev) => prev.filter((f) => f !== file));
15
16
  };
16
17
  const { getRootProps, getInputProps } = useDropzone(Object.assign({ onDrop }, dropZoneOptions));
17
- return (_jsxs("div", { className: className, children: [label && (_jsx(FieldLabel, { error: error, asterisk: required, size: size, children: label })), _jsxs("div", Object.assign({ className: "file-input-container" }, getRootProps(), { onFocus: onFocus, style: style, children: [_jsx("input", Object.assign({}, getInputProps())), children && children, !children && _jsx("div", { children: "Drop files here or click to select files ..." })] })), _jsx("div", { className: "file-selections", children: files.map((file, index) => (_jsx(Pill, { size: "sm", showRemoveIcon: true, onRemove: () => handleRemoveFile(file), children: file.name }, index))) })] }));
18
+ return (_jsxs("div", { className: className, children: [label && (_jsx(FieldLabel, { error: error, asterisk: required, size: size, children: label })), _jsxs("div", Object.assign({ className: "file-input-container" }, getRootProps(), { onFocus: onFocus, style: style, children: [_jsx("input", Object.assign({}, getInputProps())), children && children, !children && _jsx("div", { children: "Drop files here or click to select files ..." })] })), _jsx("div", { className: "file-selections", children: files.map((file, index) => (_jsx(Pill, { size: size, showRemoveIcon: true, onRemove: () => handleRemoveFile(file), children: file.name }, index))) })] }));
18
19
  }) `
19
20
  display: flex;
20
21
  flex-direction: column;
@@ -33,17 +34,7 @@ const FileInputField = styled(({ className, children, label, error, required, si
33
34
 
34
35
  color: ${({ theme }) => theme.palette.text.secondary};
35
36
 
36
- font-size: ${({ size }) => size === "xs"
37
- ? "12px"
38
- : size === "sm"
39
- ? "14px"
40
- : size === "md"
41
- ? "16px"
42
- : size === "lg"
43
- ? "18px"
44
- : size === "xl"
45
- ? "20px"
46
- : "12px"};
37
+ font-size: ${({ size }) => `${getControlSizeTokens(size).fontSize}px`};
47
38
 
48
39
  background-color: ${({ theme, variant }) => {
49
40
  switch (variant) {
@@ -77,17 +68,7 @@ const FileInputField = styled(({ className, children, label, error, required, si
77
68
  }
78
69
  }};
79
70
 
80
- padding: ${({ size }) => size === "xs"
81
- ? "0px 8px"
82
- : size === "sm"
83
- ? "0px 10px"
84
- : size === "md"
85
- ? "0px 12px"
86
- : size === "lg"
87
- ? "0px 14px"
88
- : size === "xl"
89
- ? "0px 16px"
90
- : "0px 8px"};
71
+ padding: ${({ size }) => `0px ${getControlSizeTokens(size).inputPaddingX}px`};
91
72
 
92
73
  max-width: 100%;
93
74
 
@@ -2,21 +2,14 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { ChevronDownIcon } from "lucide-react";
3
3
  import { useState } from "react";
4
4
  import styled from "styled-components";
5
+ import { getControlSizeTokens } from "../core";
5
6
  const StyledContainer = styled.div `
6
7
  display: flex;
7
8
  flex-direction: column;
8
9
 
9
10
  h3 {
10
11
  margin: 0;
11
- font-size: ${({ size = "md" }) => size === "xs"
12
- ? "x-small"
13
- : size === "sm"
14
- ? "small"
15
- : size === "md"
16
- ? "medium"
17
- : size === "lg"
18
- ? "large"
19
- : "x-large"};
12
+ font-size: ${({ size = "md" }) => `${getControlSizeTokens(size).sectionTitleFontSize}px`};
20
13
  }
21
14
 
22
15
  .section-header {
@@ -56,21 +49,8 @@ const StyledContainer = styled.div `
56
49
  }
57
50
  }
58
51
  `;
59
- const resolveIconSize = (size) => {
60
- switch (size) {
61
- case "xs":
62
- return 12;
63
- case "sm":
64
- return 14;
65
- case "md":
66
- return 18;
67
- case "lg":
68
- return 24;
69
- case "xl":
70
- return 28;
71
- default:
72
- return 18;
73
- }
52
+ const resolveIconSize = (size = "md") => {
53
+ return getControlSizeTokens(size).sectionIconSize;
74
54
  };
75
55
  export const FormSection = ({ title, children, open, defaultOpen = true, onOpenChange, allowCollapse = true, size, style, icon: Icon, iconColor, }) => {
76
56
  const [_open, setOpen] = useState(defaultOpen);
@@ -80,5 +60,5 @@ export const FormSection = ({ title, children, open, defaultOpen = true, onOpenC
80
60
  setOpen(!openState);
81
61
  onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(!openState);
82
62
  }
83
- }, children: [Icon && _jsx(Icon, { size: resolveIconSize(size), color: iconColor }), _jsx("h3", { children: title }), _jsx("div", { className: "section-line" }), !!allowCollapse ? (_jsx(ChevronDownIcon, { size: 18, className: openState ? "open" : "" })) : ("")] }), _jsx("div", { className: "section-content", "data-open": openState, children: children })] }));
63
+ }, children: [Icon && _jsx(Icon, { size: resolveIconSize(size), color: iconColor }), _jsx("h3", { children: title }), _jsx("div", { className: "section-line" }), !!allowCollapse ? (_jsx(ChevronDownIcon, { size: resolveIconSize(size), className: openState ? "open" : "" })) : ("")] }), _jsx("div", { className: "section-content", "data-open": openState, children: children })] }));
84
64
  };
@@ -1,25 +1,11 @@
1
1
  import styled from "styled-components";
2
2
  import { Button } from "..";
3
+ import { getControlSizeTokens } from "../core";
3
4
  const IconButton = styled(Button) `
4
5
  padding: ${({ size, variant }) => {
5
6
  if (variant === "text")
6
7
  return `0px 0px`;
7
- switch (size) {
8
- case "xxs":
9
- return `0px 4px`;
10
- case "xs":
11
- return `0px 4px`;
12
- case "sm":
13
- return `0px 6px`;
14
- case "md":
15
- return `0px 8px`;
16
- case "lg":
17
- return `0px 10px`;
18
- case "xl":
19
- return `0px 12px`;
20
- default:
21
- return `0px 6px`;
22
- }
8
+ return `0px ${getControlSizeTokens(size).iconButtonPaddingX}px`;
23
9
  }};
24
10
  `;
25
11
  export default IconButton;
@@ -11,6 +11,7 @@ var __rest = (this && this.__rest) || function (s, e) {
11
11
  };
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
13
  import styled from "styled-components";
14
+ import { getControlSizeTokens, } from "../core";
14
15
  import { forwardRef } from "react";
15
16
  const StyledInput = styled.input `
16
17
  font-family: ${({ theme }) => theme.typography.fontFamily};
@@ -20,41 +21,11 @@ const StyledInput = styled.input `
20
21
  box-sizing: border-box;
21
22
 
22
23
  color: ${({ theme }) => theme.palette.text.primary};
23
- font-size: ${({ size }) => size === "xs"
24
- ? "11px"
25
- : size === "sm"
26
- ? "13px"
27
- : size === "md"
28
- ? "15px"
29
- : size === "lg"
30
- ? "17px"
31
- : size === "xl"
32
- ? "19px"
33
- : "13px"};
24
+ font-size: ${({ size }) => `${getControlSizeTokens(size).fontSize}px`};
34
25
 
35
- height: ${({ size }) => size === "xs"
36
- ? "26px"
37
- : size === "sm"
38
- ? "30px"
39
- : size === "md"
40
- ? "36px"
41
- : size === "lg"
42
- ? "42px"
43
- : size === "xl"
44
- ? "50px"
45
- : "30px"};
26
+ height: ${({ size }) => `${getControlSizeTokens(size).height}px`};
46
27
 
47
- min-height: ${({ size }) => size === "xs"
48
- ? "26px"
49
- : size === "sm"
50
- ? "30px"
51
- : size === "md"
52
- ? "36px"
53
- : size === "lg"
54
- ? "42px"
55
- : size === "xl"
56
- ? "50px"
57
- : "30px"};
28
+ min-height: ${({ size }) => `${getControlSizeTokens(size).height}px`};
58
29
 
59
30
  transition: border 0.1s ease-in-out;
60
31
  border-radius: 4px;
@@ -74,17 +45,7 @@ const StyledInput = styled.input `
74
45
  }
75
46
  }};
76
47
 
77
- padding: ${({ size }) => size === "xs"
78
- ? "0px 8px"
79
- : size === "sm"
80
- ? "0px 10px"
81
- : size === "md"
82
- ? "0px 12px"
83
- : size === "lg"
84
- ? "0px 14px"
85
- : size === "xl"
86
- ? "0px 16px"
87
- : "0px 10px"};
48
+ padding: ${({ size }) => `0px ${getControlSizeTokens(size).inputPaddingX}px`};
88
49
 
89
50
  width: ${({ width }) => {
90
51
  if (typeof width === "undefined")
@@ -113,17 +74,7 @@ const StyledInput = styled.input `
113
74
  }};
114
75
 
115
76
  ::placeholder {
116
- font-size: ${({ size }) => size === "xs"
117
- ? "10px"
118
- : size === "sm"
119
- ? "12px"
120
- : size === "md"
121
- ? "14px"
122
- : size === "lg"
123
- ? "16px"
124
- : size === "xl"
125
- ? "18px"
126
- : "12px"};
77
+ font-size: ${({ size }) => `${getControlSizeTokens(size).placeholderFontSize}px`};
127
78
  }
128
79
 
129
80
  &:focus {
@@ -131,7 +82,7 @@ const StyledInput = styled.input `
131
82
  }
132
83
 
133
84
  &[data-button-right="true"] {
134
- padding-right: 36px;
85
+ padding-right: ${({ size }) => `${getControlSizeTokens(size).adornmentWidth}px`};
135
86
  }
136
87
 
137
88
  &[readOnly] {
package/dist/Pill/Pill.js CHANGED
@@ -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 { X } from "lucide-react";
4
+ import { getControlSizeTokens } from "../core";
4
5
  const StyledButton = styled.button `
5
6
  background-color: transparent;
6
7
  border: none;
@@ -35,7 +36,7 @@ const Pill = styled(({ className, children, title, size = "md", showRemoveIcon =
35
36
  flex-direction: row;
36
37
  width: fit-content;
37
38
  max-width: 250px;
38
- gap: 5px;
39
+ gap: ${({ size }) => `${getControlSizeTokens(size).pillGap}px`};
39
40
  flex: 0;
40
41
 
41
42
  font-weight: 500;
@@ -45,55 +46,12 @@ const Pill = styled(({ className, children, title, size = "md", showRemoveIcon =
45
46
  if (showRemoveIcon !== false) {
46
47
  return "0px";
47
48
  }
48
- switch (size) {
49
- case "xs":
50
- return "8px";
51
- case "sm":
52
- return "10px";
53
- case "md":
54
- return "12px";
55
- case "lg":
56
- return "14px";
57
- case "xl":
58
- return "16px";
59
- default:
60
- return "10px";
61
- }
49
+ return `${getControlSizeTokens(size).pillPaddingX}px`;
62
50
  }};
63
51
 
64
- padding-inline-start: ${({ size }) => {
65
- switch (size) {
66
- case "xs":
67
- return "8px";
68
- case "sm":
69
- return "10px";
70
- case "md":
71
- return "12px";
72
- case "lg":
73
- return "14px";
74
- case "xl":
75
- return "16px";
76
- default:
77
- return "10px";
78
- }
79
- }};
52
+ padding-inline-start: ${({ size }) => `${getControlSizeTokens(size).pillPaddingX}px`};
80
53
 
81
- height: ${({ size }) => {
82
- switch (size) {
83
- case "xs":
84
- return "20px";
85
- case "sm":
86
- return "22px";
87
- case "md":
88
- return "24px";
89
- case "lg":
90
- return "26px";
91
- case "xl":
92
- return "28px";
93
- default:
94
- return "22px";
95
- }
96
- }};
54
+ height: ${({ size }) => `${getControlSizeTokens(size).pillHeight}px`};
97
55
 
98
56
  border: 1px solid ${({ theme }) => theme.palette.divider};
99
57
  border-radius: 1000px;
@@ -105,43 +63,14 @@ const Pill = styled(({ className, children, title, size = "md", showRemoveIcon =
105
63
  overflow: hidden;
106
64
  text-overflow: ellipsis;
107
65
 
108
- font-size: ${({ size }) => {
109
- switch (size) {
110
- case "xs":
111
- return "10px";
112
- case "sm":
113
- return "12px";
114
- case "md":
115
- return "14px";
116
- case "lg":
117
- return "16px";
118
- case "xl":
119
- return "18px";
120
- default:
121
- return "12px";
122
- }
123
- }};
66
+ font-size: ${({ size }) => `${getControlSizeTokens(size).pillFontSize}px`};
124
67
  }
125
68
 
126
69
  svg {
127
70
  color: ${({ theme }) => theme.palette.text.primary};
128
71
 
129
- width: ${({ size }) => {
130
- switch (size) {
131
- case "xs":
132
- return "12px";
133
- case "sm":
134
- return "14px";
135
- case "md":
136
- return "16px";
137
- case "lg":
138
- return "18px";
139
- case "xl":
140
- return "20px";
141
- default:
142
- return "14px";
143
- }
144
- }};
72
+ width: ${({ size }) => `${getControlSizeTokens(size).pillIconSize}px`};
73
+ height: ${({ size }) => `${getControlSizeTokens(size).pillIconSize}px`};
145
74
  }
146
75
  `;
147
76
  export default Pill;
@@ -10,12 +10,13 @@ export interface PopoverContextValue {
10
10
  withArrow: boolean;
11
11
  arrowSize: number;
12
12
  arrowRadius: number;
13
- arrowRef: React.MutableRefObject<HTMLDivElement | null>;
13
+ arrowRef: React.MutableRefObject<SVGSVGElement | null>;
14
14
  withinPortal: boolean;
15
15
  trapFocus: boolean;
16
16
  returnFocus: boolean;
17
17
  keepMounted: boolean;
18
18
  zIndex: number;
19
+ role: "dialog" | "menu" | "tooltip";
19
20
  dropdownId: string;
20
21
  transitionProps: PopoverTransitionProps;
21
22
  }
@@ -23,8 +23,9 @@ const PopoverRoot = ({ children, opened, defaultOpened = false, onChange, trigge
23
23
  }
24
24
  },
25
25
  placement: position,
26
+ transform: false,
26
27
  middleware: [
27
- offset(offsetValue + (withArrow ? resolvedArrowSize / 2 : 0)),
28
+ offset(offsetValue + (withArrow ? resolvedArrowSize : 0)),
28
29
  flip({ padding: flipPadding }),
29
30
  shift({ padding: shiftPadding }),
30
31
  size({
@@ -42,7 +43,7 @@ const PopoverRoot = ({ children, opened, defaultOpened = false, onChange, trigge
42
43
  ? [
43
44
  arrow({
44
45
  element: arrowRef,
45
- padding: 8,
46
+ padding: Math.max(8, resolvedArrowSize),
46
47
  }),
47
48
  ]
48
49
  : []),
@@ -92,6 +93,7 @@ const PopoverRoot = ({ children, opened, defaultOpened = false, onChange, trigge
92
93
  returnFocus,
93
94
  keepMounted,
94
95
  zIndex,
96
+ role,
95
97
  dropdownId,
96
98
  transitionProps,
97
99
  }), [
@@ -109,6 +111,7 @@ const PopoverRoot = ({ children, opened, defaultOpened = false, onChange, trigge
109
111
  returnFocus,
110
112
  keepMounted,
111
113
  zIndex,
114
+ role,
112
115
  dropdownId,
113
116
  transitionProps,
114
117
  ]);
@@ -1,7 +1,2 @@
1
1
  export declare const StyledDropdown: 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 ARROW_STYLES: Record<"top" | "right" | "bottom" | "left", {
3
- clipPath: string;
4
- borderTransparent: string[];
5
- radiusCorner: string;
6
- staticProp: string;
7
- }>;
2
+ export declare const StyledArrow: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<Omit<import("@floating-ui/react").FloatingArrowProps, "ref"> & import("react").RefAttributes<SVGSVGElement>, never>> & string & Omit<import("react").ForwardRefExoticComponent<Omit<import("@floating-ui/react").FloatingArrowProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>, keyof import("react").Component<any, {}, any>>;
@@ -1,10 +1,14 @@
1
+ import { FloatingArrow } from "@floating-ui/react";
1
2
  import styled from "styled-components";
2
3
  export const StyledDropdown = styled.div `
4
+ --mf-popover-arrow-fill: ${({ theme }) => theme.palette.background.default};
5
+ --mf-popover-arrow-border: ${({ theme }) => theme.palette.divider};
6
+
3
7
  position: relative;
4
8
  min-width: 180px;
5
9
  border-radius: 8px;
6
- border: 1px solid ${({ theme }) => theme.palette.divider};
7
- background-color: ${({ theme }) => theme.palette.background.default};
10
+ border: 1px solid var(--mf-popover-arrow-border);
11
+ background-color: var(--mf-popover-arrow-fill);
8
12
  color: ${({ theme }) => theme.palette.text.primary};
9
13
  box-shadow:
10
14
  rgba(15, 23, 42, 0.1) 0px 10px 15px -3px,
@@ -12,29 +16,8 @@ export const StyledDropdown = styled.div `
12
16
  padding: 10px 12px;
13
17
  outline: none;
14
18
  `;
15
- export const ARROW_STYLES = {
16
- bottom: {
17
- clipPath: "polygon(0 100%, 0 0, 100% 0)",
18
- borderTransparent: ["borderBottomColor", "borderRightColor"],
19
- radiusCorner: "borderTopLeftRadius",
20
- staticProp: "top",
21
- },
22
- top: {
23
- clipPath: "polygon(0 100%, 100% 100%, 100% 0)",
24
- borderTransparent: ["borderTopColor", "borderLeftColor"],
25
- radiusCorner: "borderBottomRightRadius",
26
- staticProp: "bottom",
27
- },
28
- left: {
29
- clipPath: "polygon(100% 0, 0 0, 100% 100%)",
30
- borderTransparent: ["borderLeftColor", "borderBottomColor"],
31
- radiusCorner: "borderTopRightRadius",
32
- staticProp: "right",
33
- },
34
- right: {
35
- clipPath: "polygon(0 100%, 0 0, 100% 100%)",
36
- borderTransparent: ["borderRightColor", "borderTopColor"],
37
- radiusCorner: "borderBottomLeftRadius",
38
- staticProp: "left",
39
- },
40
- };
19
+ export const StyledArrow = styled(FloatingArrow) `
20
+ display: block;
21
+ overflow: visible;
22
+ z-index: 1;
23
+ `;
@@ -1,5 +1,7 @@
1
+ import { FloatingContext } from "@floating-ui/react";
2
+ import { CSSProperties } from "react";
1
3
  import { PopoverTransitionProps } from "./Popover.types";
2
- export declare function usePopoverTransition(opened: boolean, { transition, duration, timingFunction }: PopoverTransitionProps): {
4
+ export declare function usePopoverTransition(context: FloatingContext, { transition, duration, timingFunction, }: PopoverTransitionProps): {
3
5
  mounted: boolean;
4
- styles: React.CSSProperties;
6
+ styles: CSSProperties;
5
7
  };
@@ -1,63 +1,37 @@
1
- import { useEffect, useRef, useState } from "react";
1
+ import { useTransitionStyles } from "@floating-ui/react";
2
2
  const TRANSITION_PRESETS = {
3
3
  fade: {
4
- from: { opacity: 0 },
5
- to: { opacity: 1 },
4
+ initial: { opacity: 0 },
5
+ open: { opacity: 1 },
6
6
  },
7
7
  scale: {
8
- from: { opacity: 0, scale: "0.85" },
9
- to: { opacity: 1, scale: "1" },
8
+ initial: { opacity: 0, transform: "scale(0.85)" },
9
+ open: { opacity: 1, transform: "scale(1)" },
10
10
  },
11
11
  "scale-y": {
12
- from: { opacity: 0, scale: "1 0.7" },
13
- to: { opacity: 1, scale: "1 1" },
12
+ initial: { opacity: 0, transform: "scaleY(0.7)" },
13
+ open: { opacity: 1, transform: "scaleY(1)" },
14
14
  },
15
15
  pop: {
16
- from: { opacity: 0, scale: "0.6" },
17
- to: { opacity: 1, scale: "1" },
16
+ initial: { opacity: 0, transform: "scale(0.6)" },
17
+ open: { opacity: 1, transform: "scale(1)" },
18
18
  },
19
19
  };
20
- export function usePopoverTransition(opened, { transition = "fade", duration = 150, timingFunction = "ease" }) {
21
- const [mounted, setMounted] = useState(opened);
22
- const [transitionEnabled, setTransitionEnabled] = useState(false);
23
- const [phase, setPhase] = useState(opened ? "enter" : "exit");
24
- const frameRef = useRef(0);
25
- useEffect(() => {
26
- cancelAnimationFrame(frameRef.current);
27
- if (opened) {
28
- setMounted(true);
29
- setTransitionEnabled(false);
30
- setPhase("exit");
31
- frameRef.current = requestAnimationFrame(() => {
32
- frameRef.current = requestAnimationFrame(() => {
33
- setTransitionEnabled(true);
34
- setPhase("enter");
35
- });
36
- });
37
- }
38
- else {
39
- setTransitionEnabled(true);
40
- setPhase("exit");
41
- const timer = setTimeout(() => {
42
- setMounted(false);
43
- setTransitionEnabled(false);
44
- }, duration);
45
- return () => clearTimeout(timer);
46
- }
47
- }, [opened, duration]);
48
- useEffect(() => {
49
- return () => cancelAnimationFrame(frameRef.current);
50
- }, []);
20
+ export function usePopoverTransition(context, { transition = "fade", duration = 150, timingFunction = "ease", }) {
21
+ var _a;
51
22
  const preset = TRANSITION_PRESETS[transition];
52
- const transitionStyles = phase === "enter" ? preset.to : preset.from;
53
- const properties = [
54
- ...new Set([...Object.keys(preset.from), ...Object.keys(preset.to)]),
55
- ];
56
- const transitionValue = properties
57
- .map((prop) => `${prop} ${duration}ms ${timingFunction}`)
58
- .join(", ");
23
+ const { isMounted, styles } = useTransitionStyles(context, {
24
+ duration,
25
+ initial: preset.initial,
26
+ open: preset.open,
27
+ close: (_a = preset.close) !== null && _a !== void 0 ? _a : preset.initial,
28
+ common: {
29
+ transitionTimingFunction: timingFunction,
30
+ willChange: transition === "fade" ? "opacity" : "opacity, transform",
31
+ },
32
+ });
59
33
  return {
60
- mounted: mounted || opened,
61
- styles: Object.assign(Object.assign({}, transitionStyles), (transitionEnabled ? { transition: transitionValue } : {})),
34
+ mounted: isMounted,
35
+ styles,
62
36
  };
63
37
  }
@@ -12,17 +12,15 @@ var __rest = (this && this.__rest) || function (s, e) {
12
12
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
13
  import { FloatingFocusManager, FloatingPortal } from "@floating-ui/react";
14
14
  import { usePopoverContext } from "./Popover.context";
15
- import { ARROW_STYLES, StyledDropdown } from "./Popover.styles";
15
+ import { StyledArrow, StyledDropdown } from "./Popover.styles";
16
16
  import { usePopoverTransition } from "./Popover.transitions";
17
17
  export const PopoverDropdown = (_a) => {
18
- var _b, _c;
19
18
  var { children, className, style } = _a, props = __rest(_a, ["children", "className", "style"]);
20
- const { opened, refs, context, floatingStyles, getFloatingProps, withArrow, arrowSize, arrowRadius, arrowRef, withinPortal, trapFocus, returnFocus, keepMounted, zIndex, dropdownId, transitionProps: ctxTransitionProps, } = usePopoverContext();
21
- const { mounted, styles: transitionStyles } = usePopoverTransition(opened, ctxTransitionProps);
22
- const arrowX = (_b = context.middlewareData.arrow) === null || _b === void 0 ? void 0 : _b.x;
23
- const arrowY = (_c = context.middlewareData.arrow) === null || _c === void 0 ? void 0 : _c.y;
19
+ const { refs, context, floatingStyles, getFloatingProps, withArrow, arrowSize, arrowRadius, arrowRef, withinPortal, trapFocus, returnFocus, keepMounted, zIndex, dropdownId, transitionProps: ctxTransitionProps, } = usePopoverContext();
20
+ const { mounted, styles: transitionStyles } = usePopoverTransition(context, ctxTransitionProps);
21
+ const resolvedArrowSize = Math.max(arrowSize, 6);
22
+ const resolvedArrowRadius = Math.min(Math.max(arrowRadius, 0), resolvedArrowSize / 2);
24
23
  const [placementSide, placementAlignment] = context.placement.split("-");
25
- const arrowConfig = ARROW_STYLES[placementSide];
26
24
  const originSide = {
27
25
  top: "bottom",
28
26
  bottom: "top",
@@ -44,7 +42,7 @@ export const PopoverDropdown = (_a) => {
44
42
  }
45
43
  const dropdown = (_jsx(FloatingFocusManager, { context: context, modal: trapFocus, returnFocus: returnFocus, children: _jsxs(StyledDropdown, Object.assign({}, getFloatingProps(props), { id: dropdownId, ref: refs.setFloating, className: className, style: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, floatingStyles), transitionStyles), { transformOrigin }), style), { zIndex }), (keepMounted && !mounted
46
44
  ? { visibility: "hidden", pointerEvents: "none" }
47
- : {})), children: [children, withArrow && (_jsx("div", { ref: arrowRef, style: Object.assign(Object.assign(Object.assign({ position: "absolute", width: Math.max(arrowSize, 6), height: Math.max(arrowSize, 6), transform: "rotate(45deg)", background: "inherit", border: "1px solid", borderColor: "inherit", pointerEvents: "none", zIndex: 1 }, (arrowX != null ? { left: arrowX } : {})), (arrowY != null ? { top: arrowY } : {})), { [arrowConfig.staticProp]: -Math.max(arrowSize, 6) / 2, [arrowConfig.radiusCorner]: arrowRadius, [arrowConfig.borderTransparent[0]]: "transparent", [arrowConfig.borderTransparent[1]]: "transparent", clipPath: arrowConfig.clipPath }) }))] })) }));
45
+ : {})), children: [children, withArrow && (_jsx(StyledArrow, { ref: arrowRef, context: context, width: resolvedArrowSize * 2, height: resolvedArrowSize, tipRadius: resolvedArrowRadius, strokeWidth: 1, fill: "var(--mf-popover-arrow-fill)", stroke: "var(--mf-popover-arrow-border)" }))] })) }));
48
46
  if (!withinPortal) {
49
47
  return dropdown;
50
48
  }
@@ -2,10 +2,13 @@ import { useMergeRefs } from "@floating-ui/react";
2
2
  import { cloneElement, isValidElement } from "react";
3
3
  import { usePopoverContext } from "./Popover.context";
4
4
  export const PopoverTarget = ({ children }) => {
5
- const { refs, getReferenceProps, opened, dropdownId } = usePopoverContext();
5
+ const { refs, getReferenceProps, opened, dropdownId, role } = usePopoverContext();
6
6
  if (!isValidElement(children)) {
7
7
  return null;
8
8
  }
9
- const mergedRef = useMergeRefs([refs.setReference, children.ref]);
10
- return cloneElement(children, getReferenceProps(Object.assign({ ref: mergedRef, "aria-expanded": opened, "aria-controls": dropdownId, "aria-haspopup": "dialog" }, children.props)));
9
+ const mergedRef = useMergeRefs([
10
+ refs.setReference,
11
+ children.ref,
12
+ ]);
13
+ return cloneElement(children, getReferenceProps(Object.assign({ ref: mergedRef, "aria-expanded": opened, "aria-controls": dropdownId, "aria-haspopup": role === "tooltip" ? undefined : role }, children.props)));
11
14
  };
@@ -4,8 +4,8 @@ export declare const resolveActiveColor: (theme: any, activeColor?: string) => {
4
4
  main: any;
5
5
  contrastText: any;
6
6
  };
7
- export declare const getSegmentHeight: (size?: Size) => 32 | 38 | 22 | 26 | 46 | 56;
8
- export declare const getSegmentFontSize: (size?: Size) => "11px" | "12px" | "14px" | "16px" | "18px" | "20px";
7
+ export declare const getSegmentHeight: (size?: Size) => number;
8
+ export declare const getSegmentFontSize: (size?: Size) => string;
9
9
  export declare const normalizeSegmentedData: (data: SegmentedControlDataItem[]) => NormalizedSegmentedItem[];
10
10
  export declare const getFirstEnabledIndex: (data: NormalizedSegmentedItem[]) => number;
11
11
  export declare const getNextEnabledIndex: (data: NormalizedSegmentedItem[], startIndex: number, direction: 1 | -1) => number;