@monolith-forensics/monolith-ui 1.8.1-dev.4 → 1.9.1-dev.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Calendar/Calendar.js +2 -2
- package/dist/DropDownMenu/DropDownMenu.js +2 -2
- package/dist/DropDownMenu/components/MenuItemList.d.ts +1 -0
- package/dist/DropDownMenu/components/MenuItemList.js +5 -2
- package/dist/DropDownMenu/types.d.ts +1 -0
- package/dist/RichTextEditor/Components/BubbleMenu.js +3 -1
- package/dist/RichTextEditor/Plugins/ImageActionsPlugin.js +73 -3
- package/package.json +1 -1
|
@@ -144,13 +144,13 @@ const Calendar = ({ defaultValue = new Date(), value, onChange = () => { }, hour
|
|
|
144
144
|
const yearOptions = getYearOptions();
|
|
145
145
|
const selectedMonthOption = MONTH_OPTIONS.find((option) => option.value === month);
|
|
146
146
|
const selectedYearOption = yearOptions.find((option) => option.value === year);
|
|
147
|
-
return (_jsxs(CalendarHeader, { children: [_jsx(CalendarNavButton, { type: "button", onClick: handlePrevious, onMouseUp: clearPressureTimer, "aria-label": "Go to previous month", title: "Previous month. Hold Shift to jump by year.", children: _jsx(ChevronLeftIcon, { "aria-hidden": "true" }) }), _jsxs(CalendarHeaderControls, { children: [_jsx(CalendarHeaderSelect, { children: _jsx(DropDownMenu, { data: MONTH_OPTIONS, value: selectedMonthOption ? [selectedMonthOption] : [], variant: "outlined", size: "xs", arrow: true, onItemSelect: (item) => commitMonthOrYearSelection(Number(item.value), year, "month"), dropDownProps: {
|
|
147
|
+
return (_jsxs(CalendarHeader, { children: [_jsx(CalendarNavButton, { type: "button", onClick: handlePrevious, onMouseUp: clearPressureTimer, "aria-label": "Go to previous month", title: "Previous month. Hold Shift to jump by year.", children: _jsx(ChevronLeftIcon, { "aria-hidden": "true" }) }), _jsxs(CalendarHeaderControls, { children: [_jsx(CalendarHeaderSelect, { children: _jsx(DropDownMenu, { data: MONTH_OPTIONS, value: selectedMonthOption ? [selectedMonthOption] : [], enableSelectedOptionStyling: true, variant: "outlined", size: "xs", arrow: true, onItemSelect: (item) => commitMonthOrYearSelection(Number(item.value), year, "month"), dropDownProps: {
|
|
148
148
|
style: { maxHeight: 260, width: 125 },
|
|
149
149
|
}, buttonProps: {
|
|
150
150
|
title: "Select month",
|
|
151
151
|
size: "xxs",
|
|
152
152
|
style: { minWidth: 95 },
|
|
153
|
-
}, children: _jsx(CalendarMonth, { children: monthName }) }) }), _jsx(CalendarHeaderSelect, { children: _jsx(DropDownMenu, { data: yearOptions, value: selectedYearOption ? [selectedYearOption] : [], variant: "outlined", size: "xs", arrow: true, searchable: true, onItemSelect: (item) => commitMonthOrYearSelection(month, Number(item.value), "year"), dropDownProps: {
|
|
153
|
+
}, children: _jsx(CalendarMonth, { children: monthName }) }) }), _jsx(CalendarHeaderSelect, { children: _jsx(DropDownMenu, { data: yearOptions, value: selectedYearOption ? [selectedYearOption] : [], enableSelectedOptionStyling: true, variant: "outlined", size: "xs", arrow: true, searchable: true, onItemSelect: (item) => commitMonthOrYearSelection(month, Number(item.value), "year"), dropDownProps: {
|
|
154
154
|
style: { width: 120, maxHeight: 260 },
|
|
155
155
|
}, buttonProps: {
|
|
156
156
|
title: "Select year",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useState } from "react";
|
|
3
3
|
import { Menu, MenuItemList, StyledInnerItemContainer } from "./components";
|
|
4
|
-
export const DropDownMenu = ({ data, children, defaultValue, value, variant, arrow, size, searchable, grouped, onAddNew, loading, onScroll, onScrollToTop, onScrollToBottom, onSearch, manualSearch, multiselect, enableSelectAll, renderOption, dynamicOptionHeight, onItemSelect, onChange, buttonProps, TooltipContent, dropDownProps, query, disabled, }) => {
|
|
4
|
+
export const DropDownMenu = ({ data, children, defaultValue, value, variant, arrow, size, searchable, grouped, onAddNew, loading, onScroll, onScrollToTop, onScrollToBottom, onSearch, manualSearch, multiselect, enableSelectAll, enableSelectedOptionStyling, renderOption, dynamicOptionHeight, onItemSelect, onChange, buttonProps, TooltipContent, dropDownProps, query, disabled, }) => {
|
|
5
5
|
var _a;
|
|
6
6
|
const isObjectArray = (_a = Object.keys((data === null || data === void 0 ? void 0 : data[0]) || {})) === null || _a === void 0 ? void 0 : _a.includes("label");
|
|
7
7
|
const [internalSelected, setInternalSelected] = useState(defaultValue || []);
|
|
@@ -35,5 +35,5 @@ export const DropDownMenu = ({ data, children, defaultValue, value, variant, arr
|
|
|
35
35
|
const handleScrollToBottom = (e) => {
|
|
36
36
|
onScrollToBottom === null || onScrollToBottom === void 0 ? void 0 : onScrollToBottom(e);
|
|
37
37
|
};
|
|
38
|
-
return (_jsx(Menu, { label: children, disabled: disabled, arrow: arrow, buttonSize: size, variant: variant, multiselect: multiselect, buttonProps: buttonProps, onMenuClose: handleMenuClose, dropDownProps: dropDownProps, children: _jsxs(StyledInnerItemContainer, { children: [loading && _jsx("div", { children: "Loading..." }), !loading && (_jsx(MenuItemList, { menuItems: data, searchable: searchable, grouped: grouped, onAddNew: onAddNew, onSearch: onSearch, manualSearch: manualSearch, dynamicOptionHeight: dynamicOptionHeight, selected: selected, TooltipContent: TooltipContent, multiselect: multiselect, enableSelectAll: enableSelectAll, size: size, handleAddItem: handleAddItem, handleRemoveItem: handleRemoveItem, handleSetSelected: handleSetSelected, onItemSelect: onItemSelect, renderOption: renderOption, onScroll: onScroll, onScrollToTop: onScrollToTop, onScrollToBottom: handleScrollToBottom, query: query }))] }) }));
|
|
38
|
+
return (_jsx(Menu, { label: children, disabled: disabled, arrow: arrow, buttonSize: size, variant: variant, multiselect: multiselect, buttonProps: buttonProps, onMenuClose: handleMenuClose, dropDownProps: dropDownProps, children: _jsxs(StyledInnerItemContainer, { children: [loading && _jsx("div", { children: "Loading..." }), !loading && (_jsx(MenuItemList, { menuItems: data, searchable: searchable, grouped: grouped, onAddNew: onAddNew, onSearch: onSearch, manualSearch: manualSearch, dynamicOptionHeight: dynamicOptionHeight, selected: selected, TooltipContent: TooltipContent, multiselect: multiselect, enableSelectAll: enableSelectAll, enableSelectedOptionStyling: enableSelectedOptionStyling, size: size, handleAddItem: handleAddItem, handleRemoveItem: handleRemoveItem, handleSetSelected: handleSetSelected, onItemSelect: onItemSelect, renderOption: renderOption, onScroll: onScroll, onScrollToTop: onScrollToTop, onScrollToBottom: handleScrollToBottom, query: query }))] }) }));
|
|
39
39
|
};
|
|
@@ -121,7 +121,7 @@ const MeasuredRow = ({ children, index, setItemSize, style }) => {
|
|
|
121
121
|
}, [children, index, setItemSize]);
|
|
122
122
|
return (_jsx("div", { style: Object.assign(Object.assign({}, style), { overflow: "visible" }), children: _jsx("div", { ref: rowRef, children: children }) }));
|
|
123
123
|
};
|
|
124
|
-
export const MenuItemList = ({ menuItems, searchable, onSearch, manualSearch, dynamicOptionHeight, selected, TooltipContent, multiselect, enableSelectAll, grouped, onAddNew, size, handleAddItem, handleRemoveItem, handleSetSelected, onItemSelect, renderOption, onScroll, onScrollToTop, onScrollToBottom, query, }) => {
|
|
124
|
+
export const MenuItemList = ({ menuItems, searchable, onSearch, manualSearch, dynamicOptionHeight, selected, TooltipContent, multiselect, enableSelectAll, enableSelectedOptionStyling, grouped, onAddNew, size, handleAddItem, handleRemoveItem, handleSetSelected, onItemSelect, renderOption, onScroll, onScrollToTop, onScrollToBottom, query, }) => {
|
|
125
125
|
const [searchValue, setSearchValue] = useState("");
|
|
126
126
|
const _a = query !== null && query !== void 0 ? query : {}, { queryKey, queryFn, getNextPageParam, initialPageParam } = _a, rest = __rest(_a, ["queryKey", "queryFn", "getNextPageParam", "initialPageParam"]);
|
|
127
127
|
const targetElm = useRef(null);
|
|
@@ -294,12 +294,15 @@ export const MenuItemList = ({ menuItems, searchable, onSearch, manualSearch, dy
|
|
|
294
294
|
(_b = variableListRef.current) === null || _b === void 0 ? void 0 : _b.scrollToItem(selectedDisplayIndex, "smart");
|
|
295
295
|
return;
|
|
296
296
|
}
|
|
297
|
+
if (!enableSelectedOptionStyling)
|
|
298
|
+
return;
|
|
297
299
|
if (selectedDisplayIndex < 0)
|
|
298
300
|
return;
|
|
299
301
|
(_c = fixedListRef.current) === null || _c === void 0 ? void 0 : _c.scrollToItem(selectedDisplayIndex, "smart");
|
|
300
302
|
(_d = variableListRef.current) === null || _d === void 0 ? void 0 : _d.scrollToItem(selectedDisplayIndex, "smart");
|
|
301
303
|
}, [
|
|
302
304
|
displayItemsKey,
|
|
305
|
+
enableSelectedOptionStyling,
|
|
303
306
|
itemCount,
|
|
304
307
|
multiselect,
|
|
305
308
|
selectedDisplayIndex,
|
|
@@ -320,7 +323,7 @@ export const MenuItemList = ({ menuItems, searchable, onSearch, manualSearch, dy
|
|
|
320
323
|
if (item.items) {
|
|
321
324
|
return (_jsx(DropDownMenu, { data: item.items, size: size, buttonProps: style ? Object.assign({ style }, item) : Object.assign({}, item), disabled: item.disabled, dynamicOptionHeight: dynamicListEnabled, children: item.label }));
|
|
322
325
|
}
|
|
323
|
-
return (_jsx(MenuItem, { className: "MenuItem", itemData: item, TooltipContent: TooltipContent, "data-selected": !multiselect && isSelected, "data-disabled": item.disabled, disabled: item.disabled, leftSection: multiselect ? (_jsxs(_Fragment, { children: [_jsx(CheckBox, { value: isSelected, size: size, onChange: (newValue) => {
|
|
326
|
+
return (_jsx(MenuItem, { className: "MenuItem", itemData: item, TooltipContent: TooltipContent, "data-selected": enableSelectedOptionStyling && !multiselect && isSelected, "data-disabled": item.disabled, disabled: item.disabled, leftSection: multiselect ? (_jsxs(_Fragment, { children: [_jsx(CheckBox, { value: isSelected, size: size, onChange: (newValue) => {
|
|
324
327
|
var _a;
|
|
325
328
|
newValue ? handleAddItem(item) : handleRemoveItem(item);
|
|
326
329
|
(_a = item === null || item === void 0 ? void 0 : item.onClick) === null || _a === void 0 ? void 0 : _a.call(item, item);
|
|
@@ -311,7 +311,9 @@ const BubbleMenu = ({ editor, rect, open, onOpen, customMenuItems = [], }) => {
|
|
|
311
311
|
return (_jsx(BubbleItemButton, { variant: "subtle", onClick: () => { var _a; return (_a = item === null || item === void 0 ? void 0 : item.onClick) === null || _a === void 0 ? void 0 : _a.call(item, editor); }, color: isActive ? "primary" : undefined, selected: isActive, children: item.icon && _jsx(item.icon, { size: 14 }) }, item.name));
|
|
312
312
|
}
|
|
313
313
|
if (item.type === "menu") {
|
|
314
|
-
return (_jsx(DropDownMenu, Object.assign({ data: item.items, size: "xs", arrow: item.arrow, buttonProps: item.buttonProps, variant: "subtle", buttonRender: item.buttonRender, onItemSelect: (item) => { var _a, _b; return (_b = (_a = item === null || item === void 0 ? void 0 : item.data) === null || _a === void 0 ? void 0 : _a.command) === null || _b === void 0 ? void 0 : _b.call(_a, editor, selectedText); }
|
|
314
|
+
return (_jsx(DropDownMenu, Object.assign({ data: item.items, size: "xs", arrow: item.arrow, buttonProps: item.buttonProps, variant: "subtle", buttonRender: item.buttonRender, onItemSelect: (item) => { var _a, _b; return (_b = (_a = item === null || item === void 0 ? void 0 : item.data) === null || _a === void 0 ? void 0 : _a.command) === null || _b === void 0 ? void 0 : _b.call(_a, editor, selectedText); }, dropDownProps: {
|
|
315
|
+
style: { width: 135 },
|
|
316
|
+
} }, item.dropDownProps, { children: item.icon
|
|
315
317
|
? (_jsx(item.icon, { size: 14 }))
|
|
316
318
|
: (item.label || item.name) }), item.name));
|
|
317
319
|
}
|
|
@@ -66,14 +66,84 @@ const getImageBlob = (src) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
66
66
|
}
|
|
67
67
|
return response.blob();
|
|
68
68
|
});
|
|
69
|
+
const clipboardPngType = "image/png";
|
|
70
|
+
const canWriteClipboardType = (ClipboardItemCtor, type) => {
|
|
71
|
+
if (!type)
|
|
72
|
+
return false;
|
|
73
|
+
if (typeof ClipboardItemCtor.supports === "function") {
|
|
74
|
+
return ClipboardItemCtor.supports(type);
|
|
75
|
+
}
|
|
76
|
+
return type === clipboardPngType;
|
|
77
|
+
};
|
|
78
|
+
const loadImageSource = (src) => new Promise((resolve, reject) => {
|
|
79
|
+
const image = new Image();
|
|
80
|
+
image.crossOrigin = "anonymous";
|
|
81
|
+
image.onload = () => resolve(image);
|
|
82
|
+
image.onerror = () => {
|
|
83
|
+
reject(new Error("Unable to prepare image for clipboard."));
|
|
84
|
+
};
|
|
85
|
+
image.src = src;
|
|
86
|
+
});
|
|
87
|
+
const renderImageSourceToPngBlob = (src) => __awaiter(void 0, void 0, void 0, function* () {
|
|
88
|
+
const image = yield loadImageSource(src);
|
|
89
|
+
const width = image.naturalWidth || image.width;
|
|
90
|
+
const height = image.naturalHeight || image.height;
|
|
91
|
+
if (!width || !height) {
|
|
92
|
+
throw new Error("Unable to prepare image for clipboard.");
|
|
93
|
+
}
|
|
94
|
+
const canvas = document.createElement("canvas");
|
|
95
|
+
canvas.width = width;
|
|
96
|
+
canvas.height = height;
|
|
97
|
+
const context = canvas.getContext("2d");
|
|
98
|
+
if (!context) {
|
|
99
|
+
throw new Error("Unable to prepare image for clipboard.");
|
|
100
|
+
}
|
|
101
|
+
context.drawImage(image, 0, 0, width, height);
|
|
102
|
+
return new Promise((resolve, reject) => {
|
|
103
|
+
canvas.toBlob((blob) => {
|
|
104
|
+
if (blob) {
|
|
105
|
+
resolve(blob);
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
reject(new Error("Unable to prepare image for clipboard."));
|
|
109
|
+
}
|
|
110
|
+
}, clipboardPngType);
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
const convertBlobToClipboardPng = (blob, fallbackSrc) => __awaiter(void 0, void 0, void 0, function* () {
|
|
114
|
+
const objectUrl = URL.createObjectURL(blob);
|
|
115
|
+
try {
|
|
116
|
+
return yield renderImageSourceToPngBlob(objectUrl);
|
|
117
|
+
}
|
|
118
|
+
catch (error) {
|
|
119
|
+
if (!fallbackSrc || fallbackSrc === objectUrl)
|
|
120
|
+
throw error;
|
|
121
|
+
return renderImageSourceToPngBlob(fallbackSrc);
|
|
122
|
+
}
|
|
123
|
+
finally {
|
|
124
|
+
URL.revokeObjectURL(objectUrl);
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
const getClipboardImageBlob = (image, ClipboardItemCtor) => __awaiter(void 0, void 0, void 0, function* () {
|
|
128
|
+
const src = image.currentSrc || image.src;
|
|
129
|
+
const blob = yield getImageBlob(src);
|
|
130
|
+
const type = blob.type || "";
|
|
131
|
+
if (canWriteClipboardType(ClipboardItemCtor, type)) {
|
|
132
|
+
return { blob, type };
|
|
133
|
+
}
|
|
134
|
+
return {
|
|
135
|
+
blob: yield convertBlobToClipboardPng(blob, src),
|
|
136
|
+
type: clipboardPngType,
|
|
137
|
+
};
|
|
138
|
+
});
|
|
69
139
|
const copyImage = (image) => __awaiter(void 0, void 0, void 0, function* () {
|
|
70
140
|
var _a;
|
|
71
|
-
const ClipboardItemCtor = window
|
|
141
|
+
const ClipboardItemCtor = window
|
|
142
|
+
.ClipboardItem;
|
|
72
143
|
if (!((_a = navigator.clipboard) === null || _a === void 0 ? void 0 : _a.write) || !ClipboardItemCtor) {
|
|
73
144
|
throw new Error("Image copying is not supported by this browser.");
|
|
74
145
|
}
|
|
75
|
-
const blob = yield
|
|
76
|
-
const type = blob.type || "image/png";
|
|
146
|
+
const { blob, type } = yield getClipboardImageBlob(image, ClipboardItemCtor);
|
|
77
147
|
yield navigator.clipboard.write([
|
|
78
148
|
new ClipboardItemCtor({
|
|
79
149
|
[type]: blob,
|