zmdms-webui 0.0.180 → 0.0.181
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/es/print/components/PrintBtn.js +1 -1
- package/dist/es/sortable/index.d.ts +5 -0
- package/dist/es/sortable/index.js +5 -0
- package/dist/es/sortable/sortable-item.d.ts +14 -0
- package/dist/es/sortable/sortable-item.js +68 -0
- package/dist/es/sortable/sortable.d.ts +13 -0
- package/dist/es/sortable/sortable.js +16 -0
- package/dist/es/table/useInnerPagination.js +2 -2
- package/dist/es/watermark/index.css +1 -1
- package/dist/es/watermark/interface.d.ts +4 -0
- package/dist/es/watermark/utils.js +54 -0
- package/dist/es/watermark/watermark.js +12 -2
- package/dist/index.build.d.ts +1 -0
- package/dist/index.dark.css +1 -1
- package/dist/index.default.css +1 -1
- package/dist/index.es.js +1 -0
- package/package.json +1 -1
|
@@ -37,7 +37,7 @@ var PrintBtn = function (_a) {
|
|
|
37
37
|
_a.label = 2;
|
|
38
38
|
case 2:
|
|
39
39
|
style_1 = document.createElement("style");
|
|
40
|
-
style_1.innerHTML = "\n @media print {\n body * {\n visibility: hidden;\n }\n }\n ";
|
|
40
|
+
style_1.innerHTML = "\n @media print {\n body * {\n visibility: hidden;\n }\n #watermark-shadow-id-zmdms {\n visibility: visible;\n }\n }\n ";
|
|
41
41
|
document.head.appendChild(style_1);
|
|
42
42
|
window.print();
|
|
43
43
|
setTimeout(function () {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
|
|
3
|
+
interface ISortableProps {
|
|
4
|
+
type: string | symbol;
|
|
5
|
+
onMoveItem: (dragIndex: number, hoverIndex: number) => void;
|
|
6
|
+
index: number;
|
|
7
|
+
id?: string;
|
|
8
|
+
className?: string;
|
|
9
|
+
style?: any;
|
|
10
|
+
children?: any;
|
|
11
|
+
}
|
|
12
|
+
declare const Sortable: React__default.FC<ISortableProps>;
|
|
13
|
+
|
|
14
|
+
export { Sortable as default };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { __assign } from '../_virtual/_tslib.js';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { useRef } from 'react';
|
|
4
|
+
import classNames from '../node_modules/classnames/index.js';
|
|
5
|
+
import { useDrop } from '../node_modules/react-dnd/dist/hooks/useDrop/useDrop.js';
|
|
6
|
+
import { useDrag } from '../node_modules/react-dnd/dist/hooks/useDrag/useDrag.js';
|
|
7
|
+
|
|
8
|
+
var Sortable = function (_a) {
|
|
9
|
+
var type = _a.type, onMoveItem = _a.onMoveItem, index = _a.index, id = _a.id, children = _a.children, style = _a.style, className = _a.className;
|
|
10
|
+
var ref = useRef(null);
|
|
11
|
+
var classes = classNames("zt-sortable", className, {});
|
|
12
|
+
/**
|
|
13
|
+
* @description 定义可放置对象
|
|
14
|
+
*/
|
|
15
|
+
var _b = useDrop({
|
|
16
|
+
accept: type,
|
|
17
|
+
hover: function (item, monitor) {
|
|
18
|
+
var _a;
|
|
19
|
+
if (!ref.current) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
// 当前拖动项索引
|
|
23
|
+
var dragIndex = item.index;
|
|
24
|
+
// 当前放置位置索引
|
|
25
|
+
var hoverIndex = index;
|
|
26
|
+
// 不要将项目本身替换
|
|
27
|
+
if (dragIndex === hoverIndex) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
// 获取当前项的位置信息
|
|
31
|
+
var hoverBoundingRect = (_a = ref.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
|
|
32
|
+
// 元素高度的一半
|
|
33
|
+
var hoverMiddleY = (hoverBoundingRect.bottom - hoverBoundingRect.top) / 2;
|
|
34
|
+
// 确定鼠标位置
|
|
35
|
+
var clientOffset = monitor.getClientOffset();
|
|
36
|
+
// 鼠标位置纵坐标 与 当前hover元素顶部位置差
|
|
37
|
+
var hoverClientY = clientOffset.y - hoverBoundingRect.top;
|
|
38
|
+
// 临界值判断
|
|
39
|
+
// 如果当前拖拽元素本身在当前放置元素之上 并且 鼠标位置与当前放置元素之差 要小于中间位置
|
|
40
|
+
if (dragIndex < hoverIndex && hoverClientY < hoverMiddleY) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
// 如果当前拖拽元素本身在当前放置元素之下 并且鼠标位置与当前放置元素之差要 大于 中间位置
|
|
44
|
+
if (dragIndex > hoverIndex && hoverClientY > hoverMiddleY) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
onMoveItem(dragIndex, hoverIndex);
|
|
48
|
+
item.index = hoverIndex;
|
|
49
|
+
},
|
|
50
|
+
}), drop = _b[1];
|
|
51
|
+
/**
|
|
52
|
+
* @description 定义可拖动对象
|
|
53
|
+
*/
|
|
54
|
+
var _c = useDrag({
|
|
55
|
+
type: type,
|
|
56
|
+
item: function () {
|
|
57
|
+
return { id: id, index: index };
|
|
58
|
+
},
|
|
59
|
+
collect: function (monitor) { return ({
|
|
60
|
+
isDragging: monitor.isDragging(),
|
|
61
|
+
}); },
|
|
62
|
+
}), isDragging = _c[0].isDragging, drag = _c[1];
|
|
63
|
+
var opacity = isDragging ? 0 : 1;
|
|
64
|
+
drag(drop(ref));
|
|
65
|
+
return (jsx("div", __assign({ ref: ref, className: classes, style: __assign(__assign({}, style), { opacity: opacity }) }, { children: children })));
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export { Sortable as default };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
import Sortable$1 from './sortable-item.js';
|
|
3
|
+
|
|
4
|
+
interface ISortableProps {
|
|
5
|
+
children?: any;
|
|
6
|
+
}
|
|
7
|
+
interface SortableListComponent extends React__default.FC<ISortableProps> {
|
|
8
|
+
Item: typeof Sortable$1;
|
|
9
|
+
displayName: string;
|
|
10
|
+
}
|
|
11
|
+
declare const Sortable: SortableListComponent;
|
|
12
|
+
|
|
13
|
+
export { Sortable as default };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { __assign } from '../_virtual/_tslib.js';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { memo } from 'react';
|
|
4
|
+
import { HTML5Backend } from '../node_modules/react-dnd-html5-backend/dist/index.js';
|
|
5
|
+
import Sortable$1 from './sortable-item.js';
|
|
6
|
+
import { DndProvider } from '../node_modules/react-dnd/dist/core/DndProvider.js';
|
|
7
|
+
|
|
8
|
+
var SortableList = function (_a) {
|
|
9
|
+
var children = _a.children;
|
|
10
|
+
return (jsx(DndProvider, __assign({ backend: HTML5Backend, context: window }, { children: children })));
|
|
11
|
+
};
|
|
12
|
+
var Sortable = memo(SortableList);
|
|
13
|
+
Sortable.displayName = "ZTXK_WEBUI_Sortable";
|
|
14
|
+
Sortable.Item = Sortable$1;
|
|
15
|
+
|
|
16
|
+
export { Sortable as default };
|
|
@@ -55,9 +55,9 @@ function useInnerPagination(isInnerPagination, innerPaginationPageSize, options)
|
|
|
55
55
|
}
|
|
56
56
|
},
|
|
57
57
|
hideOnSinglePage: true,
|
|
58
|
-
position:
|
|
58
|
+
position: innerPaginationPosition,
|
|
59
59
|
defaultPageSize: pageSize,
|
|
60
|
-
pageSizeOptions:
|
|
60
|
+
pageSizeOptions: innerPaginationPageSizeOptions,
|
|
61
61
|
}); }, [
|
|
62
62
|
isInnerPagination,
|
|
63
63
|
current,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.ztxk-watermark.ztxk-watermark--hidden>.ztxk-watermark--div{display:none}
|
|
1
|
+
.ztxk-watermark.ztxk-watermark--hidden>.ztxk-watermark--div{display:none}#watermark-shadow-id-zmdms{display:block!important;pointer-events:none!important}
|
|
@@ -11,6 +11,10 @@ interface IWatermark extends IWaterConfig {
|
|
|
11
11
|
* 如果采取之前的模式 打印的时候需要勾选显示背景才能显示内容
|
|
12
12
|
*/
|
|
13
13
|
isAppendBody?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* 是否采用 shadow-root的模式创建水印
|
|
16
|
+
*/
|
|
17
|
+
isShadow?: boolean;
|
|
14
18
|
}
|
|
15
19
|
interface WatermarkComponent extends React__default.FC<IWatermark> {
|
|
16
20
|
displayName: string;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { __assign } from '../_virtual/_tslib.js';
|
|
2
|
+
|
|
3
|
+
var WRAP_DIV_ID = "watermark-shadow-id-zmdms";
|
|
4
|
+
function createWatermark(watermarkText, options) {
|
|
5
|
+
var preDiv = document.getElementById(WRAP_DIV_ID);
|
|
6
|
+
if (preDiv) {
|
|
7
|
+
preDiv.remove();
|
|
8
|
+
}
|
|
9
|
+
// 创建一个新的 div 作为水印容器
|
|
10
|
+
var watermarkDiv = document.createElement("div");
|
|
11
|
+
watermarkDiv.id = WRAP_DIV_ID;
|
|
12
|
+
// 使用 shadow DOM
|
|
13
|
+
var shadowRoot = watermarkDiv.attachShadow({ mode: "open" });
|
|
14
|
+
var width = options.width, height = options.height;
|
|
15
|
+
// 创建一个水印元素
|
|
16
|
+
var fragment = document.createDocumentFragment();
|
|
17
|
+
for (var i = 0; i < 3; i++) {
|
|
18
|
+
var watermark = createWatermarkItem(watermarkText, __assign(__assign({}, options), { top: 50 + height * i, left: 50 + width * i }));
|
|
19
|
+
fragment.appendChild(watermark);
|
|
20
|
+
}
|
|
21
|
+
// 将水印添加到 shadow DOM
|
|
22
|
+
shadowRoot.appendChild(fragment);
|
|
23
|
+
// 将水印容器添加到文档的 body 中
|
|
24
|
+
document.body.appendChild(watermarkDiv);
|
|
25
|
+
}
|
|
26
|
+
function createWatermarkItem(watermarkText, options) {
|
|
27
|
+
// 创建一个水印元素
|
|
28
|
+
var watermark = document.createElement("div");
|
|
29
|
+
watermark.className = "shadow-root--container";
|
|
30
|
+
var textContent = watermarkText;
|
|
31
|
+
if (Array.isArray(watermarkText)) {
|
|
32
|
+
textContent = watermarkText.join("\n");
|
|
33
|
+
}
|
|
34
|
+
watermark.innerHTML = "\n <span style=\"position: absolute; top: 20px; left: 20px\">".concat(textContent, "</span>\n <span style=\"position: absolute; bottom: 20px; right: 20px\">").concat(textContent, "</span>\n ");
|
|
35
|
+
var font = options.font, rotate = options.rotate, width = options.width, height = options.height, top = options.top, left = options.left;
|
|
36
|
+
// 设置水印样式
|
|
37
|
+
watermark.style.position = "absolute";
|
|
38
|
+
watermark.style.top = "".concat(top || 50, "px");
|
|
39
|
+
watermark.style.left = "".concat(left || 50, "px");
|
|
40
|
+
watermark.style.width = "".concat(width || 200, "px");
|
|
41
|
+
watermark.style.height = "".concat(height || 200, "px");
|
|
42
|
+
watermark.style.color = (font === null || font === void 0 ? void 0 : font.color) || "rgba(0, 0, 0, 0.2)";
|
|
43
|
+
watermark.style.fontFamily = (font === null || font === void 0 ? void 0 : font.fontFamily) || "微软雅黑";
|
|
44
|
+
watermark.style.fontSize = "".concat((font === null || font === void 0 ? void 0 : font.fontSize) || 14, "px");
|
|
45
|
+
watermark.style.fontStyle = (font === null || font === void 0 ? void 0 : font.fontStyle) || "normal";
|
|
46
|
+
watermark.style.fontWeight = (font === null || font === void 0 ? void 0 : font.fontWeight) || "normal";
|
|
47
|
+
watermark.style.textAlign = (font === null || font === void 0 ? void 0 : font.textAlign) || "center";
|
|
48
|
+
watermark.style.zIndex = "1000";
|
|
49
|
+
watermark.style.whiteSpace = "pre";
|
|
50
|
+
watermark.style.transform = "rotate(".concat(rotate || -20, "deg)");
|
|
51
|
+
return watermark;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export { createWatermark };
|
|
@@ -5,6 +5,7 @@ import classNames from '../node_modules/classnames/index.js';
|
|
|
5
5
|
import WatermarkDiv from './watermark-div.js';
|
|
6
6
|
import { mergeWaterConfig, createWater } from 'zmdms-utils';
|
|
7
7
|
import { useMutationObserver } from 'ahooks';
|
|
8
|
+
import { createWatermark } from './utils.js';
|
|
8
9
|
|
|
9
10
|
var reRendering = function (mutation, isWatermarkEle) {
|
|
10
11
|
var flag = false;
|
|
@@ -18,7 +19,7 @@ var reRendering = function (mutation, isWatermarkEle) {
|
|
|
18
19
|
};
|
|
19
20
|
// TODO: 通过方法设置水印隐藏 (有没有必要做)
|
|
20
21
|
var Watermark = function (props) {
|
|
21
|
-
var children = props.children, className = props.className, _a = props.visible, visible = _a === void 0 ? true : _a, _b = props.isMutationObserver, isMutationObserver = _b === void 0 ? true : _b, isAppendBody = props.isAppendBody, waterConfigProps = __rest(props, ["children", "className", "visible", "isMutationObserver", "isAppendBody"]);
|
|
22
|
+
var children = props.children, className = props.className, _a = props.visible, visible = _a === void 0 ? true : _a, _b = props.isMutationObserver, isMutationObserver = _b === void 0 ? true : _b, isAppendBody = props.isAppendBody, isShadow = props.isShadow, waterConfigProps = __rest(props, ["children", "className", "visible", "isMutationObserver", "isAppendBody", "isShadow"]);
|
|
22
23
|
// 主容器类名
|
|
23
24
|
var classes = classNames("ztxk-watermark", className, {
|
|
24
25
|
"ztxk-watermark--hidden": !visible,
|
|
@@ -51,7 +52,7 @@ var Watermark = function (props) {
|
|
|
51
52
|
};
|
|
52
53
|
}, [content, font, height, image, rotate, width, lineSpacing]);
|
|
53
54
|
useMutationObserver(function (mutationsList) {
|
|
54
|
-
if (!isMutationObserver || isAppendBody) {
|
|
55
|
+
if (!isMutationObserver || isAppendBody || isShadow) {
|
|
55
56
|
return;
|
|
56
57
|
}
|
|
57
58
|
console.log("触发父级", mutationsList);
|
|
@@ -76,6 +77,15 @@ var Watermark = function (props) {
|
|
|
76
77
|
document.body.style.background = "";
|
|
77
78
|
}
|
|
78
79
|
}, [isAppendBody, visible, config.image]);
|
|
80
|
+
useEffect(function () {
|
|
81
|
+
if (!isShadow) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
createWatermark(content, { font: font, rotate: rotate, width: width, height: height });
|
|
85
|
+
}, [content, font, height, isShadow, rotate, width]);
|
|
86
|
+
if (isShadow) {
|
|
87
|
+
return (jsx("div", __assign({ className: classes, style: { position: "relative" }, ref: waterDomRef }, { children: children })));
|
|
88
|
+
}
|
|
79
89
|
return isAppendBody ? (jsx("div", __assign({ className: classes, style: { position: "relative" }, ref: waterDomRef }, { children: children }))) : (jsxs("div", __assign({ className: classes, style: { position: "relative" }, ref: waterDomRef }, { children: [children, jsx(WatermarkDiv, { ref: waterDomChildHandleRef, isMutationObserver: isMutationObserver, isAppendBody: isAppendBody, zIndex: zIndex, image: config.image })] })));
|
|
80
90
|
};
|
|
81
91
|
var WatermarkCom = memo(Watermark);
|
package/dist/index.build.d.ts
CHANGED
|
@@ -43,6 +43,7 @@ export { default as NotRoutePage } from './es/notroutepage/notRoutePage.js';
|
|
|
43
43
|
export { default as Alert } from './es/alert/alert.js';
|
|
44
44
|
export { default as ZtTransfer } from './es/zttransfer/zt-transfer.js';
|
|
45
45
|
export { default as Watermark } from './es/watermark/watermark.js';
|
|
46
|
+
export { default as Sortable } from './es/sortable/sortable.js';
|
|
46
47
|
export { Affix, Anchor, AutoComplete, Avatar, BackTop, Badge, Breadcrumb, Card, Carousel, Cascader, Checkbox, Col, Comment, ConfigProvider, Divider, Drawer, Dropdown, Empty, Grid, Image, Layout, List, Mentions, Menu, PageHeader, Popconfirm, Popover, Progress, Radio, Rate, Result, Row, Segmented, Skeleton, Slider, Space, Spin, Statistic, Steps, Switch, Timeline, Tooltip, Transfer, Typography, Upload, message, notification } from 'antd';
|
|
47
48
|
export { IModalOpenOptions, IModalProps, IModalRef } from './es/modal/interface.js';
|
|
48
49
|
export { IFooterDom, IFooterProps } from './es/footer/interface.js';
|