@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.
- package/dist/Button/Button.js +9 -58
- package/dist/Calendar/Calendar.d.ts +3 -1
- package/dist/Calendar/Calendar.js +134 -33
- package/dist/Calendar/CalendarStyles.d.ts +3 -0
- package/dist/Calendar/CalendarStyles.js +92 -14
- package/dist/Calendar/calendarHelpers.d.ts +5 -1
- package/dist/Calendar/calendarHelpers.js +13 -5
- package/dist/Charts/BarChart/BarChart.d.ts +5 -0
- package/dist/Charts/BarChart/BarChart.js +549 -0
- package/dist/Charts/BarChart/BarChart.lib.d.ts +31 -0
- package/dist/Charts/BarChart/BarChart.lib.js +136 -0
- package/dist/Charts/BarChart/BarChart.styled.d.ts +51 -0
- package/dist/Charts/BarChart/BarChart.styled.js +115 -0
- package/dist/Charts/BarChart/BarChart.types.d.ts +171 -0
- package/dist/Charts/BarChart/BarChart.types.js +1 -0
- package/dist/Charts/BarChart/index.d.ts +3 -0
- package/dist/Charts/BarChart/index.js +2 -0
- package/dist/Charts/ChartPrimitives/ChartExportControl.d.ts +11 -0
- package/dist/Charts/ChartPrimitives/ChartExportControl.js +29 -0
- package/dist/Charts/ChartPrimitives/chartActions.styled.d.ts +1 -0
- package/dist/Charts/ChartPrimitives/chartActions.styled.js +8 -0
- package/dist/Charts/ChartPrimitives/chartLegend.styled.d.ts +12 -0
- package/dist/Charts/ChartPrimitives/chartLegend.styled.js +52 -0
- package/dist/Charts/ChartPrimitives/chartTooltip.styled.d.ts +19 -0
- package/dist/Charts/ChartPrimitives/chartTooltip.styled.js +61 -0
- package/dist/Charts/ChartPrimitives/index.d.ts +4 -0
- package/dist/Charts/ChartPrimitives/index.js +4 -0
- package/dist/Charts/ChartUtils/chartColors.d.ts +8 -0
- package/dist/Charts/ChartUtils/chartColors.js +65 -0
- package/dist/Charts/ChartUtils/chartExport.d.ts +47 -0
- package/dist/Charts/ChartUtils/chartExport.js +311 -0
- package/dist/Charts/ChartUtils/chartMath.d.ts +3 -0
- package/dist/Charts/ChartUtils/chartMath.js +3 -0
- package/dist/Charts/ChartUtils/index.d.ts +3 -0
- package/dist/Charts/ChartUtils/index.js +3 -0
- package/dist/Charts/HeatMap/HeatMap.d.ts +5 -0
- package/dist/Charts/HeatMap/HeatMap.js +212 -0
- package/dist/Charts/HeatMap/HeatMap.lib.d.ts +30 -0
- package/dist/Charts/HeatMap/HeatMap.lib.js +115 -0
- package/dist/Charts/HeatMap/HeatMap.styled.d.ts +37 -0
- package/dist/Charts/HeatMap/HeatMap.styled.js +91 -0
- package/dist/Charts/HeatMap/HeatMap.types.d.ts +80 -0
- package/dist/Charts/HeatMap/HeatMap.types.js +1 -0
- package/dist/Charts/HeatMap/index.d.ts +3 -0
- package/dist/Charts/HeatMap/index.js +2 -0
- package/dist/Charts/LineChart/LineChart.d.ts +5 -0
- package/dist/Charts/LineChart/LineChart.js +529 -0
- package/dist/Charts/LineChart/LineChart.lib.d.ts +24 -0
- package/dist/Charts/LineChart/LineChart.lib.js +132 -0
- package/dist/Charts/LineChart/LineChart.styled.d.ts +59 -0
- package/dist/Charts/LineChart/LineChart.styled.js +147 -0
- package/dist/Charts/LineChart/LineChart.types.d.ts +193 -0
- package/dist/Charts/LineChart/LineChart.types.js +1 -0
- package/dist/Charts/LineChart/index.d.ts +3 -0
- package/dist/Charts/LineChart/index.js +2 -0
- package/dist/Charts/PieChart/PieChart.d.ts +4 -0
- package/dist/Charts/PieChart/PieChart.js +199 -0
- package/dist/Charts/PieChart/PieChart.lib.d.ts +5 -0
- package/dist/Charts/PieChart/PieChart.lib.js +19 -0
- package/dist/Charts/PieChart/PieChart.styled.d.ts +51 -0
- package/dist/Charts/PieChart/PieChart.styled.js +163 -0
- package/dist/Charts/PieChart/PieChart.types.d.ts +100 -0
- package/dist/Charts/PieChart/PieChart.types.js +1 -0
- package/dist/Charts/PieChart/index.d.ts +2 -0
- package/dist/Charts/PieChart/index.js +1 -0
- package/dist/Charts/index.d.ts +5 -0
- package/dist/Charts/index.js +4 -0
- package/dist/CheckBox/CheckBox.js +2 -16
- package/dist/DateInput/DateInput.js +198 -143
- package/dist/DropDownMenu/components/MenuComponent.js +2 -1
- package/dist/DropDownMenu/components/MenuItem.js +5 -14
- package/dist/DropDownMenu/components/MenuItemList.js +7 -24
- package/dist/DropDownMenu/components/StyledFloatContainer.js +1 -1
- package/dist/FieldLabel/FieldLabel.js +4 -12
- package/dist/FileInputField/FileInputField.js +4 -23
- package/dist/FormSection/FormSection.js +5 -25
- package/dist/IconButton/IconButton.js +2 -16
- package/dist/Input/Input.js +7 -56
- package/dist/Pill/Pill.js +8 -79
- package/dist/Popover/Popover.context.d.ts +2 -1
- package/dist/Popover/Popover.js +5 -2
- package/dist/Popover/Popover.styles.d.ts +1 -6
- package/dist/Popover/Popover.styles.js +11 -28
- package/dist/Popover/Popover.transitions.d.ts +4 -2
- package/dist/Popover/Popover.transitions.js +23 -49
- package/dist/Popover/PopoverDropdown.js +6 -8
- package/dist/Popover/PopoverTarget.js +6 -3
- package/dist/SegmentedControl/SegmentedControl.utils.d.ts +2 -2
- package/dist/SegmentedControl/SegmentedControl.utils.js +3 -30
- package/dist/SelectBox/SelectBox.js +5 -5
- package/dist/SelectBox/select-box.styled-components.d.ts +4 -1
- package/dist/SelectBox/select-box.styled-components.js +11 -48
- package/dist/SelectBox/types.d.ts +1 -0
- package/dist/Switch/Switch.d.ts +2 -2
- package/dist/Switch/Switch.js +18 -83
- package/dist/Table/StateStorage.d.ts +4 -0
- package/dist/Table/StateStorage.js +13 -0
- package/dist/Table/Table.js +160 -12
- package/dist/Table/TableComponents.d.ts +10 -0
- package/dist/Table/TableComponents.js +57 -0
- package/dist/Table/TableDefaults.d.ts +7 -0
- package/dist/Table/TableDefaults.js +7 -0
- package/dist/Table/TableProvider.js +263 -71
- package/dist/Table/TableRow.js +15 -10
- package/dist/Table/types.d.ts +64 -0
- package/dist/TagBox/TagBox.js +18 -76
- package/dist/TextArea/TextArea.js +4 -23
- package/dist/TextInput/TextInput.js +12 -6
- package/dist/Utilities/parseTimestamp.js +11 -6
- package/dist/core/ArrowButton.d.ts +2 -0
- package/dist/core/ArrowButton.js +7 -3
- package/dist/core/ClearButton.d.ts +2 -0
- package/dist/core/ClearButton.js +7 -3
- package/dist/core/controlSizes.d.ts +34 -0
- package/dist/core/controlSizes.js +190 -0
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.js +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- 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:
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
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:
|
|
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
|
-
|
|
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;
|
package/dist/Input/Input.js
CHANGED
|
@@ -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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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:
|
|
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:
|
|
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
|
-
|
|
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
|
-
|
|
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<
|
|
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
|
}
|
package/dist/Popover/Popover.js
CHANGED
|
@@ -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
|
|
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
|
|
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
|
|
7
|
-
background-color:
|
|
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
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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(
|
|
4
|
+
export declare function usePopoverTransition(context: FloatingContext, { transition, duration, timingFunction, }: PopoverTransitionProps): {
|
|
3
5
|
mounted: boolean;
|
|
4
|
-
styles:
|
|
6
|
+
styles: CSSProperties;
|
|
5
7
|
};
|
|
@@ -1,63 +1,37 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useTransitionStyles } from "@floating-ui/react";
|
|
2
2
|
const TRANSITION_PRESETS = {
|
|
3
3
|
fade: {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
initial: { opacity: 0 },
|
|
5
|
+
open: { opacity: 1 },
|
|
6
6
|
},
|
|
7
7
|
scale: {
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
initial: { opacity: 0, transform: "scale(0.85)" },
|
|
9
|
+
open: { opacity: 1, transform: "scale(1)" },
|
|
10
10
|
},
|
|
11
11
|
"scale-y": {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
initial: { opacity: 0, transform: "scaleY(0.7)" },
|
|
13
|
+
open: { opacity: 1, transform: "scaleY(1)" },
|
|
14
14
|
},
|
|
15
15
|
pop: {
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
initial: { opacity: 0, transform: "scale(0.6)" },
|
|
17
|
+
open: { opacity: 1, transform: "scale(1)" },
|
|
18
18
|
},
|
|
19
19
|
};
|
|
20
|
-
export function usePopoverTransition(
|
|
21
|
-
|
|
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
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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:
|
|
61
|
-
styles
|
|
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 {
|
|
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 {
|
|
21
|
-
const { mounted, styles: transitionStyles } = usePopoverTransition(
|
|
22
|
-
const
|
|
23
|
-
const
|
|
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(
|
|
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([
|
|
10
|
-
|
|
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) =>
|
|
8
|
-
export declare const getSegmentFontSize: (size?: Size) =>
|
|
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;
|