@chaoswise/business 1.1.0 → 2.1.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/lib/I18nInput/index.d.ts +31 -0
- package/lib/I18nInput/index.js +159 -58
- package/lib/index.d.ts +1 -0
- package/lib/index.js +0 -4
- package/lib/locales/en_US.json +1 -1
- package/lib/locales/index.d.ts +7 -0
- package/lib/locales/index.js +15 -19
- package/lib/locales/intl.d.ts +11 -0
- package/lib/locales/intl.js +18 -58
- package/lib/locales/ja_JP.json +1 -1
- package/lib/locales/normalizeLocale.d.ts +2 -0
- package/lib/locales/normalizeLocale.js +27 -0
- package/lib/locales/withLocale.d.ts +28 -0
- package/lib/locales/withLocale.js +1 -1
- package/lib/locales/zh_CN.json +1 -1
- package/lib/locales/zh_HK.json +1 -1
- package/lib/locales/zh_TW.json +1 -1
- package/package.json +8 -6
- package/lib/AggregateSearch/CLSPL/CLQLLexer.js +0 -78
- package/lib/AggregateSearch/CLSPL/CLQLParser.js +0 -2724
- package/lib/AggregateSearch/CLSPL/CLQLParserListener.js +0 -347
- package/lib/AggregateSearch/CLSPL/CLQLParserVisitor.js +0 -251
- package/lib/AggregateSearch/CLSPL/SPLStagy.js +0 -197
- package/lib/AggregateSearch/CLSPL/index.js +0 -196
- package/lib/AggregateSearch/CLSPL/makeTokenizeFn.js +0 -18
- package/lib/AggregateSearch/CLSPL/token.js +0 -7
- package/lib/AggregateSearch/components/CloseAllIcon/index.js +0 -13
- package/lib/AggregateSearch/components/CloseAllIcon/index.less +0 -11
- package/lib/AggregateSearch/components/DropDown/assets/combined.svg +0 -22
- package/lib/AggregateSearch/components/DropDown/assets/copy.svg +0 -22
- package/lib/AggregateSearch/components/DropDown/assets/delete.svg +0 -24
- package/lib/AggregateSearch/components/DropDown/assets/home.svg +0 -20
- package/lib/AggregateSearch/components/DropDown/assets/key.svg +0 -21
- package/lib/AggregateSearch/components/DropDown/assets/star.svg +0 -22
- package/lib/AggregateSearch/components/DropDown/assets/time-circle.svg +0 -20
- package/lib/AggregateSearch/components/DropDown/assets/value.svg +0 -23
- package/lib/AggregateSearch/components/DropDown/config.js +0 -54
- package/lib/AggregateSearch/components/DropDown/index.js +0 -576
- package/lib/AggregateSearch/components/DropDown/index.less +0 -118
- package/lib/AggregateSearch/components/SwitchBtn/assets/tag-icon.svg +0 -17
- package/lib/AggregateSearch/components/SwitchBtn/assets/text-icon.svg +0 -18
- package/lib/AggregateSearch/components/SwitchBtn/index.js +0 -27
- package/lib/AggregateSearch/components/SwitchBtn/index.less +0 -31
- package/lib/AggregateSearch/hooks/useDropDown.js +0 -428
- package/lib/AggregateSearch/index.js +0 -503
- package/lib/AggregateSearch/index.less +0 -225
- package/lib/AggregateSearch/utils/index.js +0 -391
- package/lib/ContentEditableSearch/components/CloseAllIcon/index.js +0 -13
- package/lib/ContentEditableSearch/components/CloseAllIcon/index.less +0 -11
- package/lib/ContentEditableSearch/index.js +0 -155
- package/lib/ContentEditableSearch/index.less +0 -65
- package/lib/ContentEditableSearch/utils/index.js +0 -98
- package/lib/PropertyControlViewer/assets/doCommon.less +0 -75
- package/lib/PropertyControlViewer/assets/doSelect.less +0 -74
- package/lib/PropertyControlViewer/assets/index.less +0 -189
- package/lib/PropertyControlViewer/components/DoAppIcon/CustomIcon/iconfont.js +0 -1
- package/lib/PropertyControlViewer/components/DoAppIcon/CustomIcon/index.js +0 -29
- package/lib/PropertyControlViewer/components/DoAppIcon/iconData/IconJson.js +0 -0
- package/lib/PropertyControlViewer/components/DoAppIcon/index.js +0 -41
- package/lib/PropertyControlViewer/components/DoCiUnitBitmap.js +0 -50
- package/lib/PropertyControlViewer/components/DoCommon.js +0 -36
- package/lib/PropertyControlViewer/components/DoDefaultPlaceholder.js +0 -9
- package/lib/PropertyControlViewer/components/DoImage.js +0 -107
- package/lib/PropertyControlViewer/components/DoQuote/components/QuoteView.js +0 -63
- package/lib/PropertyControlViewer/components/DoQuote/components/TableQuoteView.js +0 -18
- package/lib/PropertyControlViewer/components/DoQuote/index.js +0 -16
- package/lib/PropertyControlViewer/components/DoSelect.js +0 -80
- package/lib/PropertyControlViewer/components/DoTable.js +0 -44
- package/lib/PropertyControlViewer/components/DoUser.js +0 -61
- package/lib/PropertyControlViewer/components/TagShowMoreList/index.js +0 -132
- package/lib/PropertyControlViewer/components/TagShowMoreList/index.less +0 -106
- package/lib/PropertyControlViewer/config/constants.js +0 -84
- package/lib/PropertyControlViewer/config/utils.js +0 -353
- package/lib/PropertyControlViewer/index.js +0 -195
- package/lib/PropertyControlViewer/index.less +0 -107
- package/lib/Watermark/index.js +0 -184
- package/lib/Watermark/index.less +0 -17
- package/lib/demo.js +0 -0
- package/lib/locale/en_US.js +0 -9
- package/lib/locale/index.js +0 -12
- package/lib/locale/zh_CN.js +0 -9
- package/lib/locales/localeCode.js +0 -13
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
-
import _Tooltip from "@chaoswise/ui/lib/Tooltip";
|
|
3
|
-
import _Form from "@chaoswise/ui/lib/Form";
|
|
4
|
-
import _Collapse from "@chaoswise/ui/lib/Collapse";
|
|
5
|
-
var _excluded = ["schemaData", "detailContent", "filterAttrs"],
|
|
6
|
-
_excluded2 = ["properties", "attrID"],
|
|
7
|
-
_excluded3 = ["item", "detailContent"];
|
|
8
|
-
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
9
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
10
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
11
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
12
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
13
|
-
function _toPrimitive(t, e) { if ("object" != _typeof(t) || !t) return t; var r; if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) { var i = r.call(t, e || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === e ? String : Number)(t); }
|
|
14
|
-
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
15
|
-
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
16
|
-
import React, { useState, useEffect, useMemo, memo } from 'react';
|
|
17
|
-
import { getDescriptionComp, getDataFunc, judgmentTypeFunc } from './config/utils';
|
|
18
|
-
import { useIntl } from '../locales';
|
|
19
|
-
import './index.less';
|
|
20
|
-
import PropTypes from "prop-types";
|
|
21
|
-
var Panel = _Collapse.Panel;
|
|
22
|
-
var compositeAttr = {
|
|
23
|
-
UNIT_RANGE: 1,
|
|
24
|
-
UNIT_SELECT: 1
|
|
25
|
-
};
|
|
26
|
-
var setWidthClassName = {
|
|
27
|
-
TABLE: 1
|
|
28
|
-
};
|
|
29
|
-
var PropertyControlViewer = function PropertyControlViewer(_ref) {
|
|
30
|
-
var schemaData = _ref.schemaData,
|
|
31
|
-
detailContent = _ref.detailContent,
|
|
32
|
-
filterAttrs = _ref.filterAttrs,
|
|
33
|
-
rest = _objectWithoutProperties(_ref, _excluded);
|
|
34
|
-
var intl = useIntl();
|
|
35
|
-
var _schemaData = useMemo(function () {
|
|
36
|
-
if (!filterAttrs || filterAttrs.length == 0) {
|
|
37
|
-
return schemaData;
|
|
38
|
-
}
|
|
39
|
-
var filteredData = schemaData.map(function (_ref2) {
|
|
40
|
-
var properties = _ref2.properties,
|
|
41
|
-
attrID = _ref2.attrID,
|
|
42
|
-
rest = _objectWithoutProperties(_ref2, _excluded2);
|
|
43
|
-
return _objectSpread(_objectSpread({}, rest), {}, {
|
|
44
|
-
attrID: attrID,
|
|
45
|
-
properties: properties.filter(function (property) {
|
|
46
|
-
return !filterAttrs.some(function (_ref3) {
|
|
47
|
-
var attrGroupId = _ref3.attrGroupId,
|
|
48
|
-
conditionAttrID = _ref3.attrID;
|
|
49
|
-
return attrID === attrGroupId && property.attrID === conditionAttrID;
|
|
50
|
-
});
|
|
51
|
-
})
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
return filteredData;
|
|
55
|
-
}, [schemaData]);
|
|
56
|
-
var comList = useMemo(function () {
|
|
57
|
-
if (_schemaData && _schemaData.length > 0) {
|
|
58
|
-
return _schemaData.map(function (i, index) {
|
|
59
|
-
if (i.componentType === 'ATTRIBUTE_GROUP') {
|
|
60
|
-
return /*#__PURE__*/React.createElement(_Collapse, {
|
|
61
|
-
key: i.attrID,
|
|
62
|
-
style: {
|
|
63
|
-
width: '100%'
|
|
64
|
-
},
|
|
65
|
-
openAnimation: false,
|
|
66
|
-
defaultActiveKey: index === 0 ? [i.attrID] : undefined
|
|
67
|
-
}, /*#__PURE__*/React.createElement(Panel, {
|
|
68
|
-
header: i.attrName || intl.get('324f8bc5-e6dc-46b5-a18b-8c4e55c7352e').d('分组'),
|
|
69
|
-
key: i.attrID,
|
|
70
|
-
style: {
|
|
71
|
-
border: 0,
|
|
72
|
-
display: i.hidden == true && 'none'
|
|
73
|
-
}
|
|
74
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
75
|
-
className: 'form-properties-box'
|
|
76
|
-
}, i.properties.map(function (item) {
|
|
77
|
-
var componentType = item.componentType,
|
|
78
|
-
properties = item.properties;
|
|
79
|
-
if (compositeAttr[componentType]) {
|
|
80
|
-
return properties.map(function (item) {
|
|
81
|
-
return /*#__PURE__*/React.createElement(AttrFormItem, _extends({
|
|
82
|
-
key: item.attrID,
|
|
83
|
-
item: item,
|
|
84
|
-
detailContent: detailContent
|
|
85
|
-
}, rest));
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
return /*#__PURE__*/React.createElement(AttrFormItem, _extends({
|
|
89
|
-
key: item.attrID,
|
|
90
|
-
item: item,
|
|
91
|
-
detailContent: detailContent
|
|
92
|
-
}, rest));
|
|
93
|
-
}))));
|
|
94
|
-
}
|
|
95
|
-
return /*#__PURE__*/React.createElement(AttrFormItem, _extends({
|
|
96
|
-
key: i.attrID,
|
|
97
|
-
item: i,
|
|
98
|
-
detailContent: detailContent
|
|
99
|
-
}, rest));
|
|
100
|
-
});
|
|
101
|
-
} else {
|
|
102
|
-
return null;
|
|
103
|
-
}
|
|
104
|
-
}, [_schemaData]);
|
|
105
|
-
return /*#__PURE__*/React.createElement(_Form, {
|
|
106
|
-
style: {
|
|
107
|
-
minHeight: '100%'
|
|
108
|
-
},
|
|
109
|
-
layout: 'horizontal'
|
|
110
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
111
|
-
className: "form-properties-box form-properties-view-box"
|
|
112
|
-
}, comList));
|
|
113
|
-
};
|
|
114
|
-
var AttrFormItem = /*#__PURE__*/memo(function (_ref4) {
|
|
115
|
-
var _detailContent$conten;
|
|
116
|
-
var item = _ref4.item,
|
|
117
|
-
detailContent = _ref4.detailContent,
|
|
118
|
-
rest = _objectWithoutProperties(_ref4, _excluded3);
|
|
119
|
-
var attrID = item.attrID,
|
|
120
|
-
attrName = item.attrName,
|
|
121
|
-
componentType = item.componentType,
|
|
122
|
-
attrInfo = item.attrInfo;
|
|
123
|
-
var fieldWidth = attrInfo.fieldWidth;
|
|
124
|
-
var _value = detailContent === null || detailContent === void 0 || (_detailContent$conten = detailContent.content) === null || _detailContent$conten === void 0 ? void 0 : _detailContent$conten[attrID];
|
|
125
|
-
var judgmentType = judgmentTypeFunc(componentType, _value); // 判断值类型是否规范
|
|
126
|
-
var data = {};
|
|
127
|
-
if (judgmentType) {
|
|
128
|
-
data = getDataFunc(_value, item, rest);
|
|
129
|
-
}
|
|
130
|
-
var comType = judgmentType ? componentType : 'default_placeholder';
|
|
131
|
-
var DescriptionComp = useMemo(function () {
|
|
132
|
-
return getDescriptionComp(comType);
|
|
133
|
-
}, [comType]);
|
|
134
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
135
|
-
key: attrID,
|
|
136
|
-
className: 'CM-DB-form-item-box',
|
|
137
|
-
style: {
|
|
138
|
-
width: fieldWidth == 'WHOLE_LINE' ? '100%' : '50%'
|
|
139
|
-
}
|
|
140
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
141
|
-
className: 'form_box'
|
|
142
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
143
|
-
className: setWidthClassName[componentType] ? 'view_table' : 'attrDetailLabel'
|
|
144
|
-
}, /*#__PURE__*/React.createElement("span", {
|
|
145
|
-
className: 'name'
|
|
146
|
-
}, /*#__PURE__*/React.createElement(_Tooltip, {
|
|
147
|
-
title: attrName
|
|
148
|
-
}, /*#__PURE__*/React.createElement("span", {
|
|
149
|
-
className: 'label'
|
|
150
|
-
}, attrName)), /*#__PURE__*/React.createElement("span", {
|
|
151
|
-
className: 'symbol'
|
|
152
|
-
}, ":")), /*#__PURE__*/React.createElement("span", {
|
|
153
|
-
className: 'content'
|
|
154
|
-
}, /*#__PURE__*/React.createElement(DescriptionComp, {
|
|
155
|
-
data: data
|
|
156
|
-
})))));
|
|
157
|
-
});
|
|
158
|
-
PropertyControlViewer.propTypes = {
|
|
159
|
-
/**
|
|
160
|
-
* 模型属性数据
|
|
161
|
-
*/
|
|
162
|
-
schemaData: PropTypes.array.isRequired,
|
|
163
|
-
/**
|
|
164
|
-
* 配置项数据
|
|
165
|
-
*/
|
|
166
|
-
detailContent: PropTypes.object.isRequired,
|
|
167
|
-
/**
|
|
168
|
-
* 需要过滤隐藏的属性
|
|
169
|
-
*/
|
|
170
|
-
filterAttrs: PropTypes.arrayOf(PropTypes.shape({
|
|
171
|
-
"attrGroupId": PropTypes.string,
|
|
172
|
-
"attrID": PropTypes.string
|
|
173
|
-
})),
|
|
174
|
-
/**
|
|
175
|
-
* 属性类型为input和textarea自动溢出省略,为对象时可设置省略行数与是否可展开等
|
|
176
|
-
*/
|
|
177
|
-
paragraphEllipsis: PropTypes.oneOf([PropTypes["boolean"], PropTypes.object]),
|
|
178
|
-
/**
|
|
179
|
-
* 属性类型为select和checkbox, 可设置显示的数量
|
|
180
|
-
*/
|
|
181
|
-
tagCount: PropTypes.number,
|
|
182
|
-
/**
|
|
183
|
-
* 属性类型为quote的点击事件
|
|
184
|
-
*/
|
|
185
|
-
handleClickChange: PropTypes.func,
|
|
186
|
-
/**
|
|
187
|
-
* 属性类型为user,鼠标悬浮显示的tooltip字段
|
|
188
|
-
*/
|
|
189
|
-
userTooltipContent: PropTypes.object,
|
|
190
|
-
/**
|
|
191
|
-
* 属性类型为userGroup, 鼠标悬浮显示的tooltip字段
|
|
192
|
-
*/
|
|
193
|
-
userGroupTooltipContent: PropTypes.object
|
|
194
|
-
};
|
|
195
|
-
export default PropertyControlViewer;
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
.form-properties-box {
|
|
2
|
-
display: flex;
|
|
3
|
-
flex-wrap: wrap;
|
|
4
|
-
justify-content: space-between;
|
|
5
|
-
|
|
6
|
-
.@{ant-prefix}-form-item {
|
|
7
|
-
padding-bottom: 0px !important;
|
|
8
|
-
margin-bottom: 16px !important;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
.@{ant-prefix}-collapse {
|
|
12
|
-
width: 100%;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
.CM-DB-form-item-box:last-child {
|
|
16
|
-
.@{ant-prefix}-form-item {
|
|
17
|
-
margin-bottom: 0 !important;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
.@{ant-prefix}-typography {
|
|
22
|
-
margin-bottom: 0 !important;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
.view_table {
|
|
26
|
-
margin-bottom: 24px;
|
|
27
|
-
.@{ant-prefix}-form-item-control-wrapper {
|
|
28
|
-
width: calc(100% - 110px);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
.form_box {
|
|
33
|
-
.cw-form-item-label-horizontal {
|
|
34
|
-
>label {
|
|
35
|
-
width: 100%;
|
|
36
|
-
|
|
37
|
-
.cw-form-item-typography-label {
|
|
38
|
-
word-break: break-all !important;
|
|
39
|
-
flex: 1;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
.@{ant-prefix}-checkbox-wrapper+.@{ant-prefix}-checkbox-wrapper {
|
|
45
|
-
margin-right: 8px;
|
|
46
|
-
margin-left: 0px;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
.attrDetailLabel {
|
|
51
|
-
display: flex;
|
|
52
|
-
width: 100%;
|
|
53
|
-
margin-bottom: 24px;
|
|
54
|
-
|
|
55
|
-
.name {
|
|
56
|
-
width: 85px;
|
|
57
|
-
margin-right: 6px;
|
|
58
|
-
display: flex;
|
|
59
|
-
justify-content: space-between;
|
|
60
|
-
|
|
61
|
-
// align-items: center;
|
|
62
|
-
.label {
|
|
63
|
-
display: -webkit-box;
|
|
64
|
-
-webkit-line-clamp: 2;
|
|
65
|
-
-webkit-box-orient: vertical;
|
|
66
|
-
overflow: hidden;
|
|
67
|
-
word-wrap: break-word;
|
|
68
|
-
word-break: break-all;
|
|
69
|
-
width: 95%;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
.symbol {
|
|
73
|
-
flex: 1;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
.content {
|
|
78
|
-
flex: 1;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
.ciunitbitmap-content-box {
|
|
83
|
-
max-width: 320px;
|
|
84
|
-
display: flex;
|
|
85
|
-
|
|
86
|
-
.ciunitbitmap-modal-icon-box {
|
|
87
|
-
width: 24px;
|
|
88
|
-
height: 24px;
|
|
89
|
-
background-color: rgb(230, 247, 255);
|
|
90
|
-
border-radius: 50%;
|
|
91
|
-
display: flex;
|
|
92
|
-
justify-content: center;
|
|
93
|
-
align-items: center;
|
|
94
|
-
|
|
95
|
-
.ciunitbitmap-modal-icon {
|
|
96
|
-
font-size: 12px;
|
|
97
|
-
color: rgb(25, 133, 255);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
.ciunitbitmap-content-text {
|
|
102
|
-
margin-left: 6px;
|
|
103
|
-
display: flex;
|
|
104
|
-
align-items: center;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
package/lib/Watermark/index.js
DELETED
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
import _Watermark from "@chaoswise/ui/lib/Watermark";
|
|
2
|
-
var _excluded = ["type", "fetchWatermark", "densityConfig", "children", "renderWatermarkDateFormat"];
|
|
3
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
-
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
5
|
-
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
6
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
7
|
-
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
8
|
-
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
9
|
-
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
10
|
-
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
11
|
-
function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
|
|
12
|
-
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
|
|
13
|
-
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
14
|
-
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
15
|
-
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
16
|
-
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
17
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
18
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
19
|
-
function _toPrimitive(t, e) { if ("object" != _typeof(t) || !t) return t; var r; if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) { var i = r.call(t, e || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === e ? String : Number)(t); }
|
|
20
|
-
import React, { useEffect, useState, useRef, useCallback } from "react";
|
|
21
|
-
import PropTypes from "prop-types";
|
|
22
|
-
import moment from "moment";
|
|
23
|
-
import "./index.less";
|
|
24
|
-
|
|
25
|
-
// 疏密类型
|
|
26
|
-
var DENSITY = {
|
|
27
|
-
// 稀疏
|
|
28
|
-
sparse: 1,
|
|
29
|
-
// 标准
|
|
30
|
-
standard: 2,
|
|
31
|
-
// 密集
|
|
32
|
-
dense: 3
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
// 疏密值-web端
|
|
36
|
-
var DENSITY_CONFIG_DESKTOP = _defineProperty(_defineProperty(_defineProperty({}, DENSITY.sparse, [100, 200]), DENSITY.standard, [80, 160]), DENSITY.dense, [60, 120]);
|
|
37
|
-
|
|
38
|
-
// 疏密值-mobile端
|
|
39
|
-
var DENSITY_CONFIG_MOBILE = _defineProperty(_defineProperty(_defineProperty({}, DENSITY.sparse, [200, 400]), DENSITY.standard, [160, 320]), DENSITY.dense, [120, 240]);
|
|
40
|
-
var WatermarkCom = function WatermarkCom(_ref) {
|
|
41
|
-
var _ref$type = _ref.type,
|
|
42
|
-
type = _ref$type === void 0 ? "desktop" : _ref$type,
|
|
43
|
-
_ref$fetchWatermark = _ref.fetchWatermark,
|
|
44
|
-
fetchWatermark = _ref$fetchWatermark === void 0 ? /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
45
|
-
return _regenerator().w(function (_context) {
|
|
46
|
-
while (1) switch (_context.n) {
|
|
47
|
-
case 0:
|
|
48
|
-
return _context.a(2, fetch("/docp/gateway/douc/api/v1/watermark/query").then(function (res) {
|
|
49
|
-
return res.json();
|
|
50
|
-
}).then(function (res) {
|
|
51
|
-
if (res && res.code === 100000) {
|
|
52
|
-
return res.data;
|
|
53
|
-
} else {
|
|
54
|
-
console.error(res);
|
|
55
|
-
}
|
|
56
|
-
})["catch"](function (error) {
|
|
57
|
-
console.error(error);
|
|
58
|
-
}));
|
|
59
|
-
}
|
|
60
|
-
}, _callee);
|
|
61
|
-
})) : _ref$fetchWatermark,
|
|
62
|
-
_ref$densityConfig = _ref.densityConfig,
|
|
63
|
-
densityConfig = _ref$densityConfig === void 0 ? {} : _ref$densityConfig,
|
|
64
|
-
children = _ref.children,
|
|
65
|
-
renderWatermarkDateFormat = _ref.renderWatermarkDateFormat,
|
|
66
|
-
rest = _objectWithoutProperties(_ref, _excluded);
|
|
67
|
-
var watermarkRef = useRef();
|
|
68
|
-
|
|
69
|
-
// 默认为 false 的话,刷新页面会有bug
|
|
70
|
-
var _useState = useState(true),
|
|
71
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
72
|
-
visible = _useState2[0],
|
|
73
|
-
setVisible = _useState2[1];
|
|
74
|
-
var _useState3 = useState({}),
|
|
75
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
76
|
-
watermarkProps = _useState4[0],
|
|
77
|
-
setWatermarkProps = _useState4[1];
|
|
78
|
-
var getGapValue = useCallback(function (density) {
|
|
79
|
-
if (Object.keys(densityConfig).length > 0) {
|
|
80
|
-
return densityConfig[density];
|
|
81
|
-
} else {
|
|
82
|
-
if (type === "desktop") {
|
|
83
|
-
return DENSITY_CONFIG_DESKTOP[density];
|
|
84
|
-
} else {
|
|
85
|
-
return DENSITY_CONFIG_MOBILE[density];
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}, [densityConfig, type]);
|
|
89
|
-
useEffect(function () {
|
|
90
|
-
var fetchWatermarkFn = /*#__PURE__*/function () {
|
|
91
|
-
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
|
|
92
|
-
var watermarkInfo, status, params, density, size, transparency, rotation, timeStrField, props;
|
|
93
|
-
return _regenerator().w(function (_context2) {
|
|
94
|
-
while (1) switch (_context2.n) {
|
|
95
|
-
case 0:
|
|
96
|
-
_context2.n = 1;
|
|
97
|
-
return fetchWatermark();
|
|
98
|
-
case 1:
|
|
99
|
-
watermarkInfo = _context2.v;
|
|
100
|
-
if (watermarkInfo) {
|
|
101
|
-
_context2.n = 2;
|
|
102
|
-
break;
|
|
103
|
-
}
|
|
104
|
-
return _context2.a(2);
|
|
105
|
-
case 2:
|
|
106
|
-
status = watermarkInfo.status, params = watermarkInfo.params, density = watermarkInfo.density, size = watermarkInfo.size, transparency = watermarkInfo.transparency, rotation = watermarkInfo.rotation; // 处理时间戳
|
|
107
|
-
timeStrField = params === null || params === void 0 ? void 0 : params.find(function (filed) {
|
|
108
|
-
return filed.key === "timeStr";
|
|
109
|
-
});
|
|
110
|
-
if (timeStrField) {
|
|
111
|
-
timeStrField.value = renderWatermarkDateFormat ? renderWatermarkDateFormat(moment()) : moment().format("YYYY-MM-DD");
|
|
112
|
-
}
|
|
113
|
-
props = {
|
|
114
|
-
content: params === null || params === void 0 ? void 0 : params.filter(function (field) {
|
|
115
|
-
return !!field.value;
|
|
116
|
-
}).map(function (field) {
|
|
117
|
-
return field.value;
|
|
118
|
-
}).join(" "),
|
|
119
|
-
font: {
|
|
120
|
-
color: "rgba(0,0,0,".concat(transparency, ")"),
|
|
121
|
-
fontSize: size
|
|
122
|
-
},
|
|
123
|
-
rotate: rotation,
|
|
124
|
-
gap: getGapValue(density)
|
|
125
|
-
};
|
|
126
|
-
setVisible(!!status);
|
|
127
|
-
setWatermarkProps(props);
|
|
128
|
-
case 3:
|
|
129
|
-
return _context2.a(2);
|
|
130
|
-
}
|
|
131
|
-
}, _callee2);
|
|
132
|
-
}));
|
|
133
|
-
return function fetchWatermarkFn() {
|
|
134
|
-
return _ref3.apply(this, arguments);
|
|
135
|
-
};
|
|
136
|
-
}();
|
|
137
|
-
fetchWatermarkFn();
|
|
138
|
-
}, []);
|
|
139
|
-
var targetRef = useCallback(function (ref) {
|
|
140
|
-
if (ref) {
|
|
141
|
-
watermarkRef.current = ref;
|
|
142
|
-
}
|
|
143
|
-
}, []);
|
|
144
|
-
useEffect(function () {
|
|
145
|
-
if (!visible || children) {
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
watermarkRef.current && document.body.append(watermarkRef.current);
|
|
149
|
-
|
|
150
|
-
// 退出当前页面删除水印
|
|
151
|
-
return function () {
|
|
152
|
-
watermarkRef.current && watermarkRef.current.remove();
|
|
153
|
-
};
|
|
154
|
-
}, [visible, children]);
|
|
155
|
-
function renderWatermark() {
|
|
156
|
-
if (children) {
|
|
157
|
-
return visible ? /*#__PURE__*/React.createElement(_Watermark, _extends({}, watermarkProps, rest, {
|
|
158
|
-
zIndex: 10000
|
|
159
|
-
}), children) : children;
|
|
160
|
-
} else {
|
|
161
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
162
|
-
ref: targetRef,
|
|
163
|
-
className: visible ? "portal-watermark" : "portal-watermark-hidden"
|
|
164
|
-
}, visible && /*#__PURE__*/React.createElement(_Watermark, _extends({}, watermarkProps, rest)));
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
return renderWatermark();
|
|
168
|
-
};
|
|
169
|
-
WatermarkCom.propTypes = {
|
|
170
|
-
/**
|
|
171
|
-
* 水印类型,可选值为 desktop、mobile 或者不设
|
|
172
|
-
*/
|
|
173
|
-
type: PropTypes.string,
|
|
174
|
-
/**
|
|
175
|
-
* 获取水印的信息,需要返回promise,async(value)=>({}),默认地址:/douc/api/v1/watermark/query
|
|
176
|
-
*/
|
|
177
|
-
fetchWatermark: PropTypes.func
|
|
178
|
-
/**
|
|
179
|
-
* 水印展示密度配置,默认支持三种模式,1: 稀疏,2: 标准 3: 密集,具体相关配置可以通过{1: [xx, yy]} 进行改写,其中xx为x方向间距,yy为y方向间距,单位为px,
|
|
180
|
-
* 可按需进行配置,此配置会覆盖 type 配置
|
|
181
|
-
*/
|
|
182
|
-
// densityConfig: PropTypes.object,
|
|
183
|
-
};
|
|
184
|
-
export default WatermarkCom;
|
package/lib/Watermark/index.less
DELETED
package/lib/demo.js
DELETED
|
File without changes
|
package/lib/locale/en_US.js
DELETED
package/lib/locale/index.js
DELETED
package/lib/locale/zh_CN.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
// 只规范格式;是否支持某种语言由资源注册表和宿主配置决定。
|
|
2
|
-
export var normalizeLocale = function normalizeLocale(locale) {
|
|
3
|
-
if (typeof locale !== 'string') return locale;
|
|
4
|
-
var value = locale.trim();
|
|
5
|
-
var legacy = {
|
|
6
|
-
zh: 'zh_CN',
|
|
7
|
-
en: 'en_US',
|
|
8
|
-
ja: 'ja_JP'
|
|
9
|
-
};
|
|
10
|
-
if (legacy[value]) return legacy[value];
|
|
11
|
-
var match = /^([a-z]{2,3})[-_]([a-z]{2}|\d{3})$/i.exec(value);
|
|
12
|
-
return match ? "".concat(match[1].toLowerCase(), "_").concat(match[2].toUpperCase()) : value;
|
|
13
|
-
};
|