@monolith-forensics/monolith-ui 1.9.1-dev.9 → 1.9.3-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/Charts/BarChart/BarChart.js +28 -14
- package/dist/Charts/BarChart/BarChart.styled.d.ts +7 -2
- package/dist/Charts/BarChart/BarChart.styled.js +5 -1
- package/dist/Charts/BarChart/BarChart.types.d.ts +13 -5
- package/dist/Charts/ChartUtils/chartSizing.d.ts +20 -0
- package/dist/Charts/ChartUtils/chartSizing.js +83 -0
- package/dist/Charts/ChartUtils/index.d.ts +1 -0
- package/dist/Charts/ChartUtils/index.js +1 -0
- package/dist/Charts/HeatMap/HeatMap.js +28 -7
- package/dist/Charts/HeatMap/HeatMap.styled.d.ts +6 -2
- package/dist/Charts/HeatMap/HeatMap.styled.js +3 -0
- package/dist/Charts/HeatMap/HeatMap.types.d.ts +7 -1
- package/dist/Charts/LineChart/LineChart.js +34 -15
- package/dist/Charts/LineChart/LineChart.styled.d.ts +7 -2
- package/dist/Charts/LineChart/LineChart.styled.js +5 -1
- package/dist/Charts/LineChart/LineChart.types.d.ts +13 -5
- package/dist/Charts/PieChart/PieChart.js +48 -33
- package/dist/Charts/PieChart/PieChart.styled.d.ts +7 -2
- package/dist/Charts/PieChart/PieChart.styled.js +6 -1
- package/dist/Charts/PieChart/PieChart.types.d.ts +7 -3
- package/dist/DropDownMenu/components/MenuItemList.js +32 -12
- package/dist/DropDownMenu/components/StyledContent.js +1 -1
- package/dist/DropDownMenu/components/StyledInnerItemContainer.js +1 -0
- package/dist/FieldLabel/FieldLabel.js +3 -18
- package/dist/FileViewer/FileViewer.js +32 -8
- package/dist/FileViewer/viewers/ImageViewer.d.ts +1 -0
- package/dist/FileViewer/viewers/ImageViewer.js +36 -15
- package/dist/MonolithUIProvider/MonolithUIProvider.d.ts +23 -0
- package/dist/RichTextEditor/Components/BubbleMenu.d.ts +3 -3
- package/dist/RichTextEditor/Components/BubbleMenu.js +190 -51
- package/dist/RichTextEditor/Components/CodeBlockBaseButton.d.ts +18 -0
- package/dist/RichTextEditor/Components/CodeBlockBaseButton.js +6 -0
- package/dist/RichTextEditor/Components/CodeBlockCopyButton.d.ts +9 -0
- package/dist/RichTextEditor/Components/CodeBlockCopyButton.js +42 -0
- package/dist/RichTextEditor/Components/CodeBlockFormatButton.d.ts +10 -0
- package/dist/RichTextEditor/Components/CodeBlockFormatButton.js +60 -0
- package/dist/RichTextEditor/Components/CodeBlockLanguageSelect.d.ts +9 -0
- package/dist/RichTextEditor/Components/CodeBlockLanguageSelect.js +30 -0
- package/dist/RichTextEditor/Components/CodeBlockNodeView.d.ts +3 -0
- package/dist/RichTextEditor/Components/CodeBlockNodeView.js +28 -0
- package/dist/RichTextEditor/Components/CodeBlockWrapButton.d.ts +10 -0
- package/dist/RichTextEditor/Components/CodeBlockWrapButton.js +17 -0
- package/dist/RichTextEditor/Components/LinkEditor.d.ts +8 -0
- package/dist/RichTextEditor/Components/LinkEditor.js +94 -0
- package/dist/RichTextEditor/Components/TableTools/TableCornerMenu.d.ts +2 -0
- package/dist/RichTextEditor/Components/TableTools/TableCornerMenu.js +19 -0
- package/dist/RichTextEditor/Components/TableTools/TableInsertControls.d.ts +2 -0
- package/dist/RichTextEditor/Components/TableTools/TableInsertControls.js +24 -0
- package/dist/RichTextEditor/Components/TableTools/TableRails.d.ts +2 -0
- package/dist/RichTextEditor/Components/TableTools/TableRails.js +180 -0
- package/dist/RichTextEditor/Components/TableTools/TableToolMenu.d.ts +5 -0
- package/dist/RichTextEditor/Components/TableTools/TableToolMenu.js +6 -0
- package/dist/RichTextEditor/Components/TableTools/TableTools.actions.d.ts +5 -0
- package/dist/RichTextEditor/Components/TableTools/TableTools.actions.js +183 -0
- package/dist/RichTextEditor/Components/TableTools/TableTools.commands.d.ts +16 -0
- package/dist/RichTextEditor/Components/TableTools/TableTools.commands.js +217 -0
- package/dist/RichTextEditor/Components/TableTools/TableTools.constants.d.ts +8 -0
- package/dist/RichTextEditor/Components/TableTools/TableTools.constants.js +11 -0
- package/dist/RichTextEditor/Components/TableTools/TableTools.d.ts +3 -0
- package/dist/RichTextEditor/Components/TableTools/TableTools.geometry.d.ts +23 -0
- package/dist/RichTextEditor/Components/TableTools/TableTools.geometry.js +75 -0
- package/dist/RichTextEditor/Components/TableTools/TableTools.js +3 -0
- package/dist/RichTextEditor/Components/TableTools/TableTools.selectors.d.ts +16 -0
- package/dist/RichTextEditor/Components/TableTools/TableTools.selectors.js +53 -0
- package/dist/RichTextEditor/Components/TableTools/TableTools.styled.d.ts +40 -0
- package/dist/RichTextEditor/Components/TableTools/TableTools.styled.js +167 -0
- package/dist/RichTextEditor/Components/TableTools/TableTools.types.d.ts +76 -0
- package/dist/RichTextEditor/Components/TableTools/TableTools.types.js +1 -0
- package/dist/RichTextEditor/Components/TableTools/TableTools.utils.d.ts +4 -0
- package/dist/RichTextEditor/Components/TableTools/TableTools.utils.js +4 -0
- package/dist/RichTextEditor/Components/TableTools/TableToolsPopover.d.ts +2 -0
- package/dist/RichTextEditor/Components/TableTools/TableToolsPopover.js +12 -0
- package/dist/RichTextEditor/Components/TableTools/index.d.ts +3 -0
- package/dist/RichTextEditor/Components/TableTools/index.js +2 -0
- package/dist/RichTextEditor/Enums/Controls.d.ts +7 -1
- package/dist/RichTextEditor/Enums/Controls.js +6 -0
- package/dist/RichTextEditor/Enums/Extensions.d.ts +4 -0
- package/dist/RichTextEditor/Enums/Extensions.js +4 -0
- package/dist/RichTextEditor/Enums/HighlightColors.d.ts +9 -0
- package/dist/RichTextEditor/Enums/HighlightColors.js +10 -0
- package/dist/RichTextEditor/Enums/SlashCommands.d.ts +4 -1
- package/dist/RichTextEditor/Enums/SlashCommands.js +3 -0
- package/dist/RichTextEditor/Extensions/SlashCommandList.js +0 -1
- package/dist/RichTextEditor/Extensions/getSlashCommand.d.ts +23 -3
- package/dist/RichTextEditor/Extensions/getSlashCommand.js +53 -7
- package/dist/RichTextEditor/Extensions/getTiptapExtensions.d.ts +15 -2
- package/dist/RichTextEditor/Extensions/getTiptapExtensions.js +159 -24
- package/dist/RichTextEditor/Plugins/ImageActionsPlugin.js +4 -7
- package/dist/RichTextEditor/RichTextEditor.d.ts +9 -4
- package/dist/RichTextEditor/RichTextEditor.js +352 -14
- package/dist/RichTextEditor/Toolbar/Control.d.ts +6 -2
- package/dist/RichTextEditor/Toolbar/Control.js +13 -6
- package/dist/RichTextEditor/Toolbar/Controls.d.ts +6 -0
- package/dist/RichTextEditor/Toolbar/Controls.js +118 -1
- package/dist/RichTextEditor/Toolbar/ControlsGroup.js +17 -6
- package/dist/RichTextEditor/Toolbar/Labels.d.ts +1 -0
- package/dist/RichTextEditor/Toolbar/Labels.js +1 -0
- package/dist/RichTextEditor/Toolbar/Toolbar.d.ts +1 -2
- package/dist/RichTextEditor/Toolbar/Toolbar.js +32 -67
- package/dist/RichTextEditor/Utils/codeBlockUtils.d.ts +20 -0
- package/dist/RichTextEditor/Utils/codeBlockUtils.js +137 -0
- package/dist/RichTextEditor/Utils/codeUtils.d.ts +3 -0
- package/dist/RichTextEditor/Utils/codeUtils.js +12 -0
- package/dist/RichTextEditor/Utils/linkUtils.d.ts +19 -0
- package/dist/RichTextEditor/Utils/linkUtils.js +57 -0
- package/dist/RichTextEditor/Utils/tableUtils.d.ts +1 -0
- package/dist/RichTextEditor/Utils/tableUtils.js +1 -0
- package/dist/SegmentedControl/SegmentedControl.js +1 -1
- package/dist/SegmentedControl/SegmentedControl.styles.d.ts +1 -0
- package/dist/SegmentedControl/SegmentedControl.styles.js +30 -14
- package/dist/SegmentedControl/SegmentedControl.utils.d.ts +1 -0
- package/dist/SegmentedControl/SegmentedControl.utils.js +5 -2
- package/dist/Table/Table.js +4 -3
- package/dist/Table/TableComponents.d.ts +3 -0
- package/dist/Table/TableComponents.js +47 -0
- package/dist/Table/TableHeader.js +1 -1
- package/dist/Table/TableMenu/TableMenu.js +4 -3
- package/dist/Table/TableProvider.js +39 -0
- package/dist/Table/TableRow.js +1 -1
- package/dist/Table/types.d.ts +6 -0
- package/dist/Utilities/getImageTextContent.d.ts +78 -0
- package/dist/Utilities/getImageTextContent.js +222 -0
- package/dist/core/controlSizes.js +9 -9
- package/dist/theme/variants.js +46 -0
- package/package.json +8 -1
|
@@ -1,29 +1,40 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef } from "react";
|
|
2
|
+
import { Children, forwardRef } from "react";
|
|
3
3
|
import styled from "styled-components";
|
|
4
4
|
const ControlsGroup = styled(forwardRef(({ className, children }, ref) => {
|
|
5
|
-
if (
|
|
5
|
+
if (Children.toArray(children).length === 0) {
|
|
6
6
|
return null;
|
|
7
7
|
}
|
|
8
8
|
return (_jsx("div", { className: className + " controls-group", ref: ref, children: children }));
|
|
9
9
|
})) `
|
|
10
10
|
& {
|
|
11
11
|
display: flex;
|
|
12
|
+
flex: 0 0 auto;
|
|
12
13
|
justify-content: flex-start;
|
|
13
14
|
align-items: center;
|
|
14
15
|
}
|
|
15
|
-
|
|
16
|
+
|
|
17
|
+
& > button {
|
|
16
18
|
border-radius: 0;
|
|
17
19
|
border: 1px solid ${({ theme }) => theme.palette.divider};
|
|
18
|
-
border-right: none;
|
|
19
20
|
}
|
|
20
|
-
|
|
21
|
+
|
|
22
|
+
& > button:not(:last-of-type) {
|
|
23
|
+
border-right: 1px solid transparent;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
& > button:first-child {
|
|
21
27
|
border-radius: 5px 0 0 5px;
|
|
22
28
|
}
|
|
23
|
-
|
|
29
|
+
|
|
30
|
+
& > button:last-of-type {
|
|
24
31
|
border-radius: 0 5px 5px 0;
|
|
25
32
|
border-right: 1px solid ${({ theme }) => theme.palette.divider};
|
|
26
33
|
}
|
|
34
|
+
|
|
35
|
+
& > button:active {
|
|
36
|
+
translate: none;
|
|
37
|
+
}
|
|
27
38
|
`;
|
|
28
39
|
ControlsGroup.displayName = "ControlsGroup";
|
|
29
40
|
export default ControlsGroup;
|
|
@@ -29,6 +29,7 @@ const Labels = {
|
|
|
29
29
|
superscriptControlLabel: "Superscript",
|
|
30
30
|
unsetColorControlLabel: "Unset color",
|
|
31
31
|
hrControlLabel: "Horizontal line",
|
|
32
|
+
tableControlLabel: "Table",
|
|
32
33
|
// Link editor
|
|
33
34
|
linkEditorInputLabel: "Enter URL",
|
|
34
35
|
linkEditorInputPlaceholder: "https://example.com/",
|
|
@@ -17,8 +17,7 @@ export type ToolbarOptions = {
|
|
|
17
17
|
customItems?: CustomItem[];
|
|
18
18
|
};
|
|
19
19
|
export type ToolbarProps = {
|
|
20
|
-
className?: string;
|
|
21
20
|
editor: Editor | null;
|
|
22
21
|
toolbarOptions?: ToolbarOptions;
|
|
23
22
|
};
|
|
24
|
-
export declare const Toolbar:
|
|
23
|
+
export declare const Toolbar: ({ editor, toolbarOptions }: ToolbarProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,85 +1,50 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import styled
|
|
2
|
+
import styled from "styled-components";
|
|
3
3
|
import ControlsGroup from "./ControlsGroup";
|
|
4
|
-
import { UndoControl, RedoControl, BoldControl, ItalicControl, UnderlineControl, StrikeThroughControl, Heading1Control, Heading2Control, Heading3Control, Heading4Control, BulletListControl, OrderedListControl, AlignLeftControl, AlignCenterControl, AlignRightControl, AlignJustifiedControl, } from "./Controls";
|
|
4
|
+
import { UndoControl, RedoControl, FontControl, TextColorControl, HighlightControl, BoldControl, ItalicControl, UnderlineControl, StrikeThroughControl, ClearFormattingControl, CodeControl, CodeBlockControl, Heading1Control, Heading2Control, Heading3Control, Heading4Control, BulletListControl, OrderedListControl, AlignLeftControl, AlignCenterControl, AlignRightControl, AlignJustifiedControl, } from "./Controls";
|
|
5
5
|
import { Controls } from "../Enums";
|
|
6
6
|
import { DropDownMenu } from "../../DropDownMenu";
|
|
7
|
-
import
|
|
8
|
-
import { useContext } from "react";
|
|
9
|
-
import RichTextEditorContext from "../Contexts/RichTextEditorContext";
|
|
7
|
+
import { useState } from "react";
|
|
10
8
|
import { Button } from "../../Button";
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
|
|
9
|
+
import { Popover } from "../../Popover";
|
|
10
|
+
import LinkEditor from "../Components/LinkEditor";
|
|
11
|
+
import { TableToolsPopover } from "../Components/TableTools";
|
|
12
|
+
import { LinkIcon } from "lucide-react";
|
|
13
|
+
const ToolbarContainer = styled.div `
|
|
14
|
+
display: flex;
|
|
15
|
+
flex-direction: row;
|
|
16
|
+
flex-wrap: wrap;
|
|
17
|
+
justify-content: center;
|
|
18
|
+
align-items: center;
|
|
19
|
+
gap: 5px;
|
|
20
|
+
row-gap: 6px;
|
|
21
|
+
width: 100%;
|
|
22
|
+
margin-bottom: 10px;
|
|
23
|
+
border-radius: 5px 5px 0 0;
|
|
24
|
+
border: 1px solid transparent;
|
|
25
|
+
|
|
26
|
+
> button,
|
|
27
|
+
> .mfui-DropDownMenu {
|
|
28
|
+
flex: 0 0 auto;
|
|
29
|
+
}
|
|
30
|
+
`;
|
|
31
|
+
export const Toolbar = ({ editor, toolbarOptions }) => {
|
|
14
32
|
var _a;
|
|
15
|
-
const theme = useTheme();
|
|
16
33
|
const { controls } = toolbarOptions || {};
|
|
34
|
+
const [linkPopoverOpen, setLinkPopoverOpen] = useState(false);
|
|
17
35
|
const customItems = controls === null || controls === void 0 ? void 0 : controls.filter((control) => typeof control !== "string" &&
|
|
18
36
|
(control.type === "menu" || control.type === "button"));
|
|
19
|
-
|
|
20
|
-
return (_jsxs("div", { className: className, children: [(_a = customItems === null || customItems === void 0 ? void 0 : customItems.map) === null || _a === void 0 ? void 0 : _a.call(customItems, (item, index) => {
|
|
37
|
+
return (_jsxs(ToolbarContainer, { children: [(_a = customItems === null || customItems === void 0 ? void 0 : customItems.map) === null || _a === void 0 ? void 0 : _a.call(customItems, (item, index) => {
|
|
21
38
|
var _a, _b;
|
|
22
39
|
if (item.type === "button") {
|
|
23
|
-
return (_jsx(Button, Object.assign({}, item.options, { children: (_a = item === null || item === void 0 ? void 0 : item.options) === null || _a === void 0 ? void 0 : _a.label }), index));
|
|
40
|
+
return (_jsx(Button, Object.assign({ size: "xs" }, item.options, { children: (_a = item === null || item === void 0 ? void 0 : item.options) === null || _a === void 0 ? void 0 : _a.label }), index));
|
|
24
41
|
}
|
|
25
42
|
else if (item.type === "menu") {
|
|
26
43
|
return (_jsx(DropDownMenu, Object.assign({ dropDownProps: {
|
|
27
44
|
style: {
|
|
28
45
|
width: 135,
|
|
29
46
|
},
|
|
30
|
-
} }, item.options, { children: (_b = item === null || item === void 0 ? void 0 : item.options) === null || _b === void 0 ? void 0 : _b.label }), index));
|
|
47
|
+
} }, item.options, { size: "xs", children: (_b = item === null || item === void 0 ? void 0 : item.options) === null || _b === void 0 ? void 0 : _b.label }), index));
|
|
31
48
|
}
|
|
32
|
-
}), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.FONT)) && (_jsx(
|
|
33
|
-
|
|
34
|
-
value: font,
|
|
35
|
-
onClick: () => {
|
|
36
|
-
setFont(font);
|
|
37
|
-
},
|
|
38
|
-
})), size: "xxs", variant: "outlined", arrow: true, dropDownProps: {
|
|
39
|
-
style: {
|
|
40
|
-
width: 135,
|
|
41
|
-
},
|
|
42
|
-
}, buttonProps: {
|
|
43
|
-
title: "Select Font",
|
|
44
|
-
}, children: (font || Fonts.DEFAULT) })), _jsxs(ControlsGroup, { children: [(controls === null || controls === void 0 ? void 0 : controls.includes(Controls.UNDO)) && _jsx(UndoControl, { editor: editor }), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.REDO)) && _jsx(RedoControl, { editor: editor })] }), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.COLOR)) && (_jsx(DropDownMenu, { data: [
|
|
45
|
-
{
|
|
46
|
-
label: "Default",
|
|
47
|
-
value: "default",
|
|
48
|
-
onClick: () => {
|
|
49
|
-
editor === null || editor === void 0 ? void 0 : editor.chain().focus().unsetColor().run();
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
...Object.keys(TextColors).map((color) => {
|
|
53
|
-
const colorKey = color;
|
|
54
|
-
return {
|
|
55
|
-
label: color,
|
|
56
|
-
value: TextColors[colorKey],
|
|
57
|
-
onClick: () => {
|
|
58
|
-
editor === null || editor === void 0 ? void 0 : editor.chain().focus().setColor(TextColors[colorKey]).run();
|
|
59
|
-
},
|
|
60
|
-
};
|
|
61
|
-
}),
|
|
62
|
-
], renderOption: (item) => (_jsxs("div", { style: { display: "flex", alignItems: "center", gap: 5 }, children: [_jsx(SquircleIcon, { size: 12, color: item.value === "default"
|
|
63
|
-
? theme.palette.text.primary
|
|
64
|
-
: item.value, style: {
|
|
65
|
-
backgroundColor: item.value === "default"
|
|
66
|
-
? theme.palette.text.primary
|
|
67
|
-
: item.value,
|
|
68
|
-
borderRadius: "3px",
|
|
69
|
-
} }), item.label] })), size: "xxs", variant: "outlined", arrow: true, buttonProps: {
|
|
70
|
-
title: "Select Color",
|
|
71
|
-
}, dropDownProps: {
|
|
72
|
-
style: {
|
|
73
|
-
width: 100,
|
|
74
|
-
},
|
|
75
|
-
}, children: "Color" })), _jsxs(ControlsGroup, { children: [(controls === null || controls === void 0 ? void 0 : controls.includes(Controls.BOLD)) && _jsx(BoldControl, { editor: editor }), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.ITALIC)) && (_jsx(ItalicControl, { editor: editor })), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.UNDERLINE)) && (_jsx(UnderlineControl, { editor: editor })), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.STRIKE)) && (_jsx(StrikeThroughControl, { editor: editor }))] }), _jsxs(ControlsGroup, { children: [(controls === null || controls === void 0 ? void 0 : controls.includes(Controls.HEADING_1)) && (_jsx(Heading1Control, { editor: editor })), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.HEADING_2)) && (_jsx(Heading2Control, { editor: editor })), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.HEADING_3)) && (_jsx(Heading3Control, { editor: editor })), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.HEADING_4)) && (_jsx(Heading4Control, { editor: editor }))] }), _jsxs(ControlsGroup, { children: [(controls === null || controls === void 0 ? void 0 : controls.includes(Controls.BULLET_LIST)) && (_jsx(BulletListControl, { editor: editor })), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.ORDERED_LIST)) && (_jsx(OrderedListControl, { editor: editor }))] }), _jsxs(ControlsGroup, { children: [(controls === null || controls === void 0 ? void 0 : controls.includes(Controls.TEXT_ALIGN_LEFT)) && (_jsx(AlignLeftControl, { editor: editor })), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.TEXT_ALIGN_CENTER)) && (_jsx(AlignCenterControl, { editor: editor })), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.TEXT_ALIGN_RIGHT)) && (_jsx(AlignRightControl, { editor: editor })), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.TEXT_ALIGN_JUSTIFIED)) && (_jsx(AlignJustifiedControl, { editor: editor }))] })] }));
|
|
76
|
-
}) `
|
|
77
|
-
display: flex;
|
|
78
|
-
flex-direction: row;
|
|
79
|
-
justify-content: center;
|
|
80
|
-
align-items: center;
|
|
81
|
-
gap: 5px;
|
|
82
|
-
margin-bottom: 10px;
|
|
83
|
-
border-radius: 5px 5px 0 0;
|
|
84
|
-
border: 1px solid transparent;
|
|
85
|
-
`;
|
|
49
|
+
}), _jsxs(ControlsGroup, { children: [(controls === null || controls === void 0 ? void 0 : controls.includes(Controls.UNDO)) && _jsx(UndoControl, { editor: editor }), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.REDO)) && _jsx(RedoControl, { editor: editor })] }), _jsxs(ControlsGroup, { children: [(controls === null || controls === void 0 ? void 0 : controls.includes(Controls.FONT)) && _jsx(FontControl, {}), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.COLOR)) && (_jsx(TextColorControl, { editor: editor })), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.HIGHLIGHT)) && (_jsx(HighlightControl, { editor: editor }))] }), _jsxs(ControlsGroup, { children: [(controls === null || controls === void 0 ? void 0 : controls.includes(Controls.BOLD)) && _jsx(BoldControl, { editor: editor }), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.ITALIC)) && (_jsx(ItalicControl, { editor: editor })), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.UNDERLINE)) && (_jsx(UnderlineControl, { editor: editor })), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.STRIKE)) && (_jsx(StrikeThroughControl, { editor: editor }))] }), _jsxs(ControlsGroup, { children: [(controls === null || controls === void 0 ? void 0 : controls.includes(Controls.HEADING_1)) && (_jsx(Heading1Control, { editor: editor })), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.HEADING_2)) && (_jsx(Heading2Control, { editor: editor })), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.HEADING_3)) && (_jsx(Heading3Control, { editor: editor })), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.HEADING_4)) && (_jsx(Heading4Control, { editor: editor }))] }), _jsxs(ControlsGroup, { children: [(controls === null || controls === void 0 ? void 0 : controls.includes(Controls.BULLET_LIST)) && (_jsx(BulletListControl, { editor: editor })), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.ORDERED_LIST)) && (_jsx(OrderedListControl, { editor: editor }))] }), _jsxs(ControlsGroup, { children: [(controls === null || controls === void 0 ? void 0 : controls.includes(Controls.TEXT_ALIGN_LEFT)) && (_jsx(AlignLeftControl, { editor: editor })), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.TEXT_ALIGN_CENTER)) && (_jsx(AlignCenterControl, { editor: editor })), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.TEXT_ALIGN_RIGHT)) && (_jsx(AlignRightControl, { editor: editor })), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.TEXT_ALIGN_JUSTIFIED)) && (_jsx(AlignJustifiedControl, { editor: editor }))] }), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.LINK)) && (_jsxs(Popover, { opened: linkPopoverOpen, onChange: setLinkPopoverOpen, position: "bottom", width: 330, trapFocus: true, children: [_jsx(Popover.Target, { children: _jsx(Button, { size: "xs", variant: "outlined", title: "Link", "aria-label": "Link", selected: linkPopoverOpen || Boolean(editor === null || editor === void 0 ? void 0 : editor.isActive("link")), disabled: !editor, style: { padding: "1px 6px" }, children: _jsx(LinkIcon, { size: 14 }) }) }), _jsx(Popover.Dropdown, { children: editor && (_jsx(LinkEditor, { editor: editor, autoFocus: linkPopoverOpen, onClose: () => setLinkPopoverOpen(false) })) })] })), _jsxs(ControlsGroup, { children: [(controls === null || controls === void 0 ? void 0 : controls.includes(Controls.CODE)) && _jsx(CodeControl, { editor: editor }), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.CODE_BLOCK)) && (_jsx(CodeBlockControl, { editor: editor }))] }), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.TABLE)) && (_jsx(TableToolsPopover, { editor: editor })), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.CLEAR_FORMATTING)) && (_jsx(ClearFormattingControl, { editor: editor }))] }));
|
|
50
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Editor } from "@tiptap/react";
|
|
2
|
+
export type CodeBlockLanguage = {
|
|
3
|
+
label: string;
|
|
4
|
+
value: string;
|
|
5
|
+
};
|
|
6
|
+
export declare const DEFAULT_CODE_BLOCK_LANGUAGE = "plaintext";
|
|
7
|
+
export declare const CODE_BLOCK_LANGUAGES: CodeBlockLanguage[];
|
|
8
|
+
export declare const getCodeBlockLanguage: (editor: Editor | null) => string;
|
|
9
|
+
export declare const getCodeBlockLanguageOption: (language?: string) => CodeBlockLanguage;
|
|
10
|
+
export declare const canFormatCodeBlockLanguage: (language?: string) => boolean;
|
|
11
|
+
export declare const formatCodeBlockText: (text: string, language?: string) => Promise<string>;
|
|
12
|
+
export declare const hasSyntaxHighlightedCodeBlock: (editor: Editor | null) => boolean;
|
|
13
|
+
export declare const setCodeBlockLanguage: (editor: Editor | null, language: string) => void;
|
|
14
|
+
export declare const getCodeBlockWrap: (editor: Editor | null) => boolean;
|
|
15
|
+
export declare const toggleCodeBlockWrap: (editor: Editor | null) => void;
|
|
16
|
+
export declare const toggleCodeBlock: (editor: Editor | null) => void;
|
|
17
|
+
export declare const getActiveCodeBlockText: (editor: Editor | null) => string;
|
|
18
|
+
export declare const replaceCodeBlockContent: (editor: Editor, from: number, to: number, text: string) => boolean;
|
|
19
|
+
export declare const formatActiveCodeBlock: (editor: Editor | null) => Promise<void>;
|
|
20
|
+
export declare const copyCodeBlockText: (text: string) => Promise<void>;
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import prettier from "prettier/standalone";
|
|
11
|
+
import * as prettierBabelPlugin from "prettier/plugins/babel";
|
|
12
|
+
import * as prettierEstreePlugin from "prettier/plugins/estree";
|
|
13
|
+
import * as prettierHtmlPlugin from "prettier/plugins/html";
|
|
14
|
+
import * as prettierMarkdownPlugin from "prettier/plugins/markdown";
|
|
15
|
+
import * as prettierPostcssPlugin from "prettier/plugins/postcss";
|
|
16
|
+
import * as prettierTypescriptPlugin from "prettier/plugins/typescript";
|
|
17
|
+
import * as prettierYamlPlugin from "prettier/plugins/yaml";
|
|
18
|
+
export const DEFAULT_CODE_BLOCK_LANGUAGE = "plaintext";
|
|
19
|
+
export const CODE_BLOCK_LANGUAGES = [
|
|
20
|
+
{ label: "Plain Text", value: DEFAULT_CODE_BLOCK_LANGUAGE },
|
|
21
|
+
{ label: "JavaScript", value: "javascript" },
|
|
22
|
+
{ label: "TypeScript", value: "typescript" },
|
|
23
|
+
{ label: "JSX", value: "jsx" },
|
|
24
|
+
{ label: "TSX", value: "tsx" },
|
|
25
|
+
{ label: "HTML", value: "html" },
|
|
26
|
+
{ label: "CSS", value: "css" },
|
|
27
|
+
{ label: "JSON", value: "json" },
|
|
28
|
+
{ label: "Markdown", value: "markdown" },
|
|
29
|
+
{ label: "Bash", value: "bash" },
|
|
30
|
+
{ label: "Python", value: "python" },
|
|
31
|
+
{ label: "SQL", value: "sql" },
|
|
32
|
+
{ label: "YAML", value: "yaml" },
|
|
33
|
+
{ label: "XML", value: "xml" },
|
|
34
|
+
];
|
|
35
|
+
const PRETTIER_PARSERS = {
|
|
36
|
+
javascript: "babel",
|
|
37
|
+
jsx: "babel",
|
|
38
|
+
typescript: "typescript",
|
|
39
|
+
tsx: "typescript",
|
|
40
|
+
html: "html",
|
|
41
|
+
css: "css",
|
|
42
|
+
json: "json",
|
|
43
|
+
markdown: "markdown",
|
|
44
|
+
yaml: "yaml",
|
|
45
|
+
};
|
|
46
|
+
const PRETTIER_PLUGINS = [
|
|
47
|
+
prettierBabelPlugin,
|
|
48
|
+
prettierEstreePlugin,
|
|
49
|
+
prettierHtmlPlugin,
|
|
50
|
+
prettierMarkdownPlugin,
|
|
51
|
+
prettierPostcssPlugin,
|
|
52
|
+
prettierTypescriptPlugin,
|
|
53
|
+
prettierYamlPlugin,
|
|
54
|
+
];
|
|
55
|
+
export const getCodeBlockLanguage = (editor) => {
|
|
56
|
+
var _a;
|
|
57
|
+
return (((_a = editor === null || editor === void 0 ? void 0 : editor.getAttributes("codeBlock")) === null || _a === void 0 ? void 0 : _a.language) ||
|
|
58
|
+
DEFAULT_CODE_BLOCK_LANGUAGE);
|
|
59
|
+
};
|
|
60
|
+
export const getCodeBlockLanguageOption = (language) => {
|
|
61
|
+
return (CODE_BLOCK_LANGUAGES.find((item) => item.value === language) ||
|
|
62
|
+
CODE_BLOCK_LANGUAGES[0]);
|
|
63
|
+
};
|
|
64
|
+
export const canFormatCodeBlockLanguage = (language) => {
|
|
65
|
+
return Boolean(language && PRETTIER_PARSERS[language]);
|
|
66
|
+
};
|
|
67
|
+
export const formatCodeBlockText = (text, language) => __awaiter(void 0, void 0, void 0, function* () {
|
|
68
|
+
const parser = language ? PRETTIER_PARSERS[language] : undefined;
|
|
69
|
+
if (!parser) {
|
|
70
|
+
throw new Error("Code formatting is not supported for this language.");
|
|
71
|
+
}
|
|
72
|
+
const formatted = yield prettier.format(text, {
|
|
73
|
+
parser,
|
|
74
|
+
plugins: PRETTIER_PLUGINS,
|
|
75
|
+
});
|
|
76
|
+
return formatted.replace(/\n$/, "");
|
|
77
|
+
});
|
|
78
|
+
export const hasSyntaxHighlightedCodeBlock = (editor) => {
|
|
79
|
+
return Boolean(editor === null || editor === void 0 ? void 0 : editor.extensionManager.extensions.find((extension) => { var _a; return extension.name === "codeBlock" && ((_a = extension.options) === null || _a === void 0 ? void 0 : _a.lowlight); }));
|
|
80
|
+
};
|
|
81
|
+
export const setCodeBlockLanguage = (editor, language) => {
|
|
82
|
+
if (!(editor === null || editor === void 0 ? void 0 : editor.isActive("codeBlock")))
|
|
83
|
+
return;
|
|
84
|
+
editor.chain().focus().updateAttributes("codeBlock", { language }).run();
|
|
85
|
+
};
|
|
86
|
+
export const getCodeBlockWrap = (editor) => {
|
|
87
|
+
var _a;
|
|
88
|
+
return Boolean((_a = editor === null || editor === void 0 ? void 0 : editor.getAttributes("codeBlock")) === null || _a === void 0 ? void 0 : _a.wrap);
|
|
89
|
+
};
|
|
90
|
+
export const toggleCodeBlockWrap = (editor) => {
|
|
91
|
+
if (!(editor === null || editor === void 0 ? void 0 : editor.isActive("codeBlock")))
|
|
92
|
+
return;
|
|
93
|
+
editor
|
|
94
|
+
.chain()
|
|
95
|
+
.focus()
|
|
96
|
+
.updateAttributes("codeBlock", { wrap: !getCodeBlockWrap(editor) })
|
|
97
|
+
.run();
|
|
98
|
+
};
|
|
99
|
+
export const toggleCodeBlock = (editor) => {
|
|
100
|
+
if (!editor)
|
|
101
|
+
return;
|
|
102
|
+
editor
|
|
103
|
+
.chain()
|
|
104
|
+
.focus()
|
|
105
|
+
.toggleCodeBlock({ language: DEFAULT_CODE_BLOCK_LANGUAGE })
|
|
106
|
+
.run();
|
|
107
|
+
};
|
|
108
|
+
export const getActiveCodeBlockText = (editor) => {
|
|
109
|
+
if (!(editor === null || editor === void 0 ? void 0 : editor.isActive("codeBlock")))
|
|
110
|
+
return "";
|
|
111
|
+
return editor.state.selection.$from.parent.textContent;
|
|
112
|
+
};
|
|
113
|
+
export const replaceCodeBlockContent = (editor, from, to, text) => {
|
|
114
|
+
return editor.commands.command(({ state, tr }) => {
|
|
115
|
+
if (text.length) {
|
|
116
|
+
tr.replaceWith(from, to, state.schema.text(text));
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
tr.delete(from, to);
|
|
120
|
+
}
|
|
121
|
+
return true;
|
|
122
|
+
});
|
|
123
|
+
};
|
|
124
|
+
export const formatActiveCodeBlock = (editor) => __awaiter(void 0, void 0, void 0, function* () {
|
|
125
|
+
if (!(editor === null || editor === void 0 ? void 0 : editor.isActive("codeBlock")))
|
|
126
|
+
return;
|
|
127
|
+
const language = getCodeBlockLanguage(editor);
|
|
128
|
+
const formatted = yield formatCodeBlockText(getActiveCodeBlockText(editor), language);
|
|
129
|
+
replaceCodeBlockContent(editor, editor.state.selection.$from.start(), editor.state.selection.$from.end(), formatted);
|
|
130
|
+
});
|
|
131
|
+
export const copyCodeBlockText = (text) => __awaiter(void 0, void 0, void 0, function* () {
|
|
132
|
+
var _a;
|
|
133
|
+
if (!((_a = navigator.clipboard) === null || _a === void 0 ? void 0 : _a.writeText)) {
|
|
134
|
+
throw new Error("Clipboard copying is not supported by this browser.");
|
|
135
|
+
}
|
|
136
|
+
yield navigator.clipboard.writeText(text);
|
|
137
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const hasInlineCode = (editor) => {
|
|
2
|
+
return Boolean(editor === null || editor === void 0 ? void 0 : editor.extensionManager.extensions.find((extension) => extension.name === "code"));
|
|
3
|
+
};
|
|
4
|
+
export const toggleInlineCode = (editor) => {
|
|
5
|
+
if (!editor || !hasInlineCode(editor))
|
|
6
|
+
return;
|
|
7
|
+
if (editor.isActive("code")) {
|
|
8
|
+
editor.chain().focus().unsetCode().run();
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
editor.chain().focus().unsetAllMarks().setCode().run();
|
|
12
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { EditorState } from "@tiptap/pm/state";
|
|
2
|
+
export declare const LINK_TARGET = "_blank";
|
|
3
|
+
export declare const LINK_REL = "noopener noreferrer nofollow";
|
|
4
|
+
export type NormalizedLink = {
|
|
5
|
+
href: string;
|
|
6
|
+
isValid: boolean;
|
|
7
|
+
};
|
|
8
|
+
export declare const normalizeLinkUrl: (value?: string | null) => NormalizedLink;
|
|
9
|
+
export declare const getLinkAttributes: (href: string) => {
|
|
10
|
+
href: string;
|
|
11
|
+
target: string;
|
|
12
|
+
rel: string;
|
|
13
|
+
class: string;
|
|
14
|
+
};
|
|
15
|
+
export declare const openLink: (href?: string | null) => void;
|
|
16
|
+
export declare const getLinkRangeAtPosition: (state: EditorState, pos: number) => void | import("@tiptap/core").Range;
|
|
17
|
+
export declare const getLinkAttributesAtPosition: (state: EditorState, pos: number) => {
|
|
18
|
+
href?: string;
|
|
19
|
+
} | undefined;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { getMarkRange } from "@tiptap/core";
|
|
2
|
+
export const LINK_TARGET = "_blank";
|
|
3
|
+
export const LINK_REL = "noopener noreferrer nofollow";
|
|
4
|
+
export const normalizeLinkUrl = (value) => {
|
|
5
|
+
const trimmedValue = (value === null || value === void 0 ? void 0 : value.trim()) || "";
|
|
6
|
+
if (!trimmedValue) {
|
|
7
|
+
return { href: "", isValid: false };
|
|
8
|
+
}
|
|
9
|
+
const href = /^[a-z][a-z0-9+.-]*:/i.test(trimmedValue)
|
|
10
|
+
? trimmedValue
|
|
11
|
+
: `https://${trimmedValue}`;
|
|
12
|
+
try {
|
|
13
|
+
const url = new URL(href);
|
|
14
|
+
const isValid = url.protocol === "http:" || url.protocol === "https:";
|
|
15
|
+
return {
|
|
16
|
+
href,
|
|
17
|
+
isValid,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
catch (_a) {
|
|
21
|
+
return {
|
|
22
|
+
href,
|
|
23
|
+
isValid: false,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
export const getLinkAttributes = (href) => ({
|
|
28
|
+
href,
|
|
29
|
+
target: LINK_TARGET,
|
|
30
|
+
rel: LINK_REL,
|
|
31
|
+
class: "editor-link",
|
|
32
|
+
});
|
|
33
|
+
export const openLink = (href) => {
|
|
34
|
+
if (!href)
|
|
35
|
+
return;
|
|
36
|
+
const normalizedLink = normalizeLinkUrl(href);
|
|
37
|
+
if (!normalizedLink.isValid)
|
|
38
|
+
return;
|
|
39
|
+
window.open(normalizedLink.href, "_blank", "noopener,noreferrer");
|
|
40
|
+
};
|
|
41
|
+
export const getLinkRangeAtPosition = (state, pos) => {
|
|
42
|
+
const linkMark = state.schema.marks.link;
|
|
43
|
+
if (!linkMark)
|
|
44
|
+
return;
|
|
45
|
+
return getMarkRange(state.doc.resolve(pos), linkMark);
|
|
46
|
+
};
|
|
47
|
+
export const getLinkAttributesAtPosition = (state, pos) => {
|
|
48
|
+
const linkMark = state.schema.marks.link;
|
|
49
|
+
if (!linkMark)
|
|
50
|
+
return;
|
|
51
|
+
const $pos = state.doc.resolve(pos);
|
|
52
|
+
const nextNode = $pos.parent.childAfter($pos.parentOffset).node;
|
|
53
|
+
const previousNode = $pos.parent.childBefore($pos.parentOffset).node;
|
|
54
|
+
const mark = (nextNode === null || nextNode === void 0 ? void 0 : nextNode.marks.find((mark) => mark.type === linkMark)) ||
|
|
55
|
+
(previousNode === null || previousNode === void 0 ? void 0 : previousNode.marks.find((mark) => mark.type === linkMark));
|
|
56
|
+
return mark === null || mark === void 0 ? void 0 : mark.attrs;
|
|
57
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const TABLE_CELL_MIN_WIDTH = 120;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const TABLE_CELL_MIN_WIDTH = 120;
|
|
@@ -55,7 +55,7 @@ export const SegmentedControl = (_a) => {
|
|
|
55
55
|
});
|
|
56
56
|
const columnCount = Math.max(normalizedData.length, 1);
|
|
57
57
|
const firstEnabledIndex = getFirstEnabledIndex(normalizedData);
|
|
58
|
-
return (_jsxs(StyledRoot, Object.assign({ role: "radiogroup", "aria-disabled": disabled, className: className, style: Object.assign({ gridTemplateColumns: `repeat(${columnCount}, minmax(0, 1fr))` }, style), "$fullWidth": fullWidth, "$disabled": disabled, onKeyDown: handleKeyDown }, other, { children: [name && _jsx("input", { type: "hidden", name: name, value: _value || "" }), activeIndex >= 0 && !(selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.disabled) && (_jsx(StyledIndicator, { "$index": activeIndex, "$count": columnCount, "$variant": variant, "$activeColor": activeColor })), normalizedData.map((item, index) => {
|
|
58
|
+
return (_jsxs(StyledRoot, Object.assign({ role: "radiogroup", "aria-disabled": disabled, className: className, style: Object.assign({ gridTemplateColumns: `repeat(${columnCount}, minmax(0, 1fr))` }, style), "$fullWidth": fullWidth, "$disabled": disabled, "$size": size, onKeyDown: handleKeyDown }, other, { children: [name && _jsx("input", { type: "hidden", name: name, value: _value || "" }), activeIndex >= 0 && !(selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.disabled) && (_jsx(StyledIndicator, { "$index": activeIndex, "$count": columnCount, "$variant": variant, "$activeColor": activeColor })), normalizedData.map((item, index) => {
|
|
59
59
|
const isActive = item.value === _value && !item.disabled;
|
|
60
60
|
const isSegmentDisabled = disabled || item.disabled;
|
|
61
61
|
return (_jsx(StyledSegmentButton, { ref: (node) => {
|
|
@@ -3,6 +3,7 @@ import { SegmentedControlVariant } from "./SegmentedControl.types";
|
|
|
3
3
|
export declare const StyledRoot: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
|
|
4
4
|
$fullWidth: boolean;
|
|
5
5
|
$disabled: boolean;
|
|
6
|
+
$size?: Size;
|
|
6
7
|
}>> & string;
|
|
7
8
|
export declare const StyledIndicator: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
|
|
8
9
|
$index: number;
|
|
@@ -1,27 +1,33 @@
|
|
|
1
1
|
import styled from "styled-components";
|
|
2
|
-
import { getSegmentFontSize, getSegmentHeight, resolveActiveColor, } from "./SegmentedControl.utils";
|
|
2
|
+
import { getSegmentFontSize, getSegmentHeight, getSegmentPaddingX, resolveActiveColor, } from "./SegmentedControl.utils";
|
|
3
|
+
const SEGMENT_GAP = 2;
|
|
3
4
|
export const StyledRoot = styled.div `
|
|
4
5
|
user-select: none;
|
|
5
6
|
position: relative;
|
|
6
7
|
display: grid;
|
|
7
8
|
align-items: center;
|
|
9
|
+
grid-auto-rows: minmax(0, 1fr);
|
|
10
|
+
column-gap: ${SEGMENT_GAP}px;
|
|
11
|
+
box-sizing: border-box;
|
|
8
12
|
width: ${({ $fullWidth }) => ($fullWidth ? "100%" : "fit-content")};
|
|
9
|
-
min-width:
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
border:
|
|
13
|
+
min-width: 0;
|
|
14
|
+
height: ${({ $size }) => `${getSegmentHeight($size)}px`};
|
|
15
|
+
padding: 2px;
|
|
16
|
+
border-radius: 5px;
|
|
17
|
+
border: 1px solid ${({ theme }) => theme.palette.input.border};
|
|
13
18
|
background: ${({ theme }) => theme.palette.background.secondary};
|
|
14
19
|
opacity: ${({ $disabled }) => ($disabled ? 0.6 : 1)};
|
|
15
20
|
pointer-events: ${({ $disabled }) => ($disabled ? "none" : "auto")};
|
|
16
21
|
`;
|
|
17
22
|
export const StyledIndicator = styled.div `
|
|
18
23
|
position: absolute;
|
|
19
|
-
top:
|
|
20
|
-
left:
|
|
24
|
+
top: 2px;
|
|
25
|
+
left: 2px;
|
|
21
26
|
z-index: 1;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
27
|
+
box-sizing: border-box;
|
|
28
|
+
height: calc(100% - 4px);
|
|
29
|
+
width: ${({ $count }) => `calc((100% - 4px - ${($count - 1) * SEGMENT_GAP}px) / ${$count})`};
|
|
30
|
+
border-radius: 4px;
|
|
25
31
|
border: 1px solid
|
|
26
32
|
${({ theme, $variant, $activeColor }) => {
|
|
27
33
|
const resolved = resolveActiveColor(theme, $activeColor);
|
|
@@ -33,17 +39,26 @@ export const StyledIndicator = styled.div `
|
|
|
33
39
|
? resolved.main
|
|
34
40
|
: theme.palette.background.paper;
|
|
35
41
|
}};
|
|
36
|
-
transform: translateX(
|
|
42
|
+
transform: translateX(
|
|
43
|
+
${({ $index }) => `calc(${$index * 100}% + ${$index * SEGMENT_GAP}px)`}
|
|
44
|
+
);
|
|
37
45
|
transition: transform 160ms ease;
|
|
38
46
|
`;
|
|
39
47
|
export const StyledSegmentButton = styled.button `
|
|
40
48
|
position: relative;
|
|
41
49
|
z-index: 2;
|
|
50
|
+
display: flex;
|
|
51
|
+
align-items: center;
|
|
52
|
+
justify-content: center;
|
|
53
|
+
box-sizing: border-box;
|
|
42
54
|
border: none;
|
|
43
55
|
outline: none;
|
|
44
|
-
padding: 0
|
|
56
|
+
padding: ${({ $size }) => `0 ${getSegmentPaddingX($size)}px`};
|
|
45
57
|
margin: 0;
|
|
46
|
-
|
|
58
|
+
min-width: 0;
|
|
59
|
+
overflow: hidden;
|
|
60
|
+
text-overflow: ellipsis;
|
|
61
|
+
border-radius: 4px;
|
|
47
62
|
background: transparent;
|
|
48
63
|
color: ${({ theme, $active, $variant, $activeColor }) => {
|
|
49
64
|
const resolved = resolveActiveColor(theme, $activeColor);
|
|
@@ -54,7 +69,8 @@ export const StyledSegmentButton = styled.button `
|
|
|
54
69
|
font-size: ${({ $size }) => getSegmentFontSize($size)};
|
|
55
70
|
font-weight: 500;
|
|
56
71
|
line-height: 1;
|
|
57
|
-
height:
|
|
72
|
+
height: 100%;
|
|
73
|
+
min-height: 0;
|
|
58
74
|
white-space: nowrap;
|
|
59
75
|
cursor: pointer;
|
|
60
76
|
transition:
|
|
@@ -6,6 +6,7 @@ export declare const resolveActiveColor: (theme: any, activeColor?: string) => {
|
|
|
6
6
|
};
|
|
7
7
|
export declare const getSegmentHeight: (size?: Size) => number;
|
|
8
8
|
export declare const getSegmentFontSize: (size?: Size) => string;
|
|
9
|
+
export declare const getSegmentPaddingX: (size?: Size) => number;
|
|
9
10
|
export declare const normalizeSegmentedData: (data: SegmentedControlDataItem[]) => NormalizedSegmentedItem[];
|
|
10
11
|
export declare const getFirstEnabledIndex: (data: NormalizedSegmentedItem[]) => number;
|
|
11
12
|
export declare const getNextEnabledIndex: (data: NormalizedSegmentedItem[], startIndex: number, direction: 1 | -1) => number;
|
|
@@ -22,10 +22,13 @@ export const resolveActiveColor = (theme, activeColor) => {
|
|
|
22
22
|
};
|
|
23
23
|
};
|
|
24
24
|
export const getSegmentHeight = (size) => {
|
|
25
|
-
return getControlSizeTokens(size).
|
|
25
|
+
return getControlSizeTokens(size).height;
|
|
26
26
|
};
|
|
27
27
|
export const getSegmentFontSize = (size) => {
|
|
28
|
-
return `${getControlSizeTokens(size).
|
|
28
|
+
return `${getControlSizeTokens(size).fontSize}px`;
|
|
29
|
+
};
|
|
30
|
+
export const getSegmentPaddingX = (size) => {
|
|
31
|
+
return getControlSizeTokens(size).buttonPaddingX;
|
|
29
32
|
};
|
|
30
33
|
export const normalizeSegmentedData = (data) => data.map((item) => {
|
|
31
34
|
var _a;
|
package/dist/Table/Table.js
CHANGED
|
@@ -12,7 +12,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
13
|
import { useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
14
14
|
import { useOverlayScrollbars } from "overlayscrollbars-react";
|
|
15
|
-
import { StyledTable } from "./TableComponents";
|
|
15
|
+
import { StyledTable, TableEmptyState, TableEmptyStateDescription, TableEmptyStateTitle, } from "./TableComponents";
|
|
16
16
|
import TableHeader from "./TableHeader";
|
|
17
17
|
import TableProvider from "./TableProvider";
|
|
18
18
|
import shortUUID from "short-uuid";
|
|
@@ -33,12 +33,13 @@ const StyledTableContainer = styled.div `
|
|
|
33
33
|
`;
|
|
34
34
|
const TableContent = ({ children, }) => {
|
|
35
35
|
const { columnState, tableElement, tableHeight, tableMaxHeight, tableMinHeight, headerRowElm, tableDimensions, targetElm, listElm, rowHeight, headerRowHeight, compactState, virtualized, loading, } = useTable();
|
|
36
|
-
const visibleColumnCount = columnState.filter((column) => column.visible
|
|
36
|
+
const visibleColumnCount = columnState.filter((column) => column.visible !== false).length;
|
|
37
|
+
const allColumnsHidden = columnState.length > 0 && visibleColumnCount === 0;
|
|
37
38
|
return (_jsxs(StyledTableContainer, { children: [_jsx(TableMenu, {}), children, _jsxs(StyledTable, { className: "mfui-table", style: {
|
|
38
39
|
height: tableHeight || "100%",
|
|
39
40
|
maxHeight: tableMaxHeight,
|
|
40
41
|
minHeight: tableMinHeight,
|
|
41
|
-
}, ref: tableElement, "data-compact": compactState, children: [_jsx(LoadingIndicator, { visible: loading }), _jsx(TableHeader, { headerRowElm: headerRowElm }),
|
|
42
|
+
}, ref: tableElement, "data-compact": compactState, "data-all-columns-hidden": allColumnsHidden, children: [_jsx(LoadingIndicator, { visible: loading }), _jsx(TableHeader, { headerRowElm: headerRowElm }), allColumnsHidden ? (_jsxs(TableEmptyState, { className: "mfui-table-empty-state", role: "status", children: [_jsx(TableEmptyStateTitle, { children: "All columns are hidden" }), _jsx(TableEmptyStateDescription, { children: "No data is currently displaying because every table column is hidden." })] })) : null, virtualized === true ? (_jsx(VirtualizedRows, { tableDimensions: tableDimensions, targetElm: targetElm, listElm: listElm, rowHeight: rowHeight, headerRowHeight: headerRowHeight })) : (_jsx(StaticRows, { targetElm: targetElm, listElm: listElm }))] })] }));
|
|
42
43
|
};
|
|
43
44
|
export const Table = (_a) => {
|
|
44
45
|
var { data, columnProps, children, treeOptions } = _a, props = __rest(_a, ["data", "columnProps", "children", "treeOptions"]) // pass through props straight to table context
|
|
@@ -18,5 +18,8 @@ export declare const TreeChevronPlaceholder: import("styled-components/dist/type
|
|
|
18
18
|
export declare const TreeCellContent: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
19
19
|
export declare const TableViewPort: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
20
20
|
export declare const TableListElement: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
21
|
+
export declare const TableEmptyState: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
22
|
+
export declare const TableEmptyStateTitle: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
23
|
+
export declare const TableEmptyStateDescription: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
21
24
|
export declare const TableWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
22
25
|
export declare const StyledTable: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|