@chaoswise/business 1.0.5 → 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.
Files changed (82) hide show
  1. package/lib/I18nInput/index.d.ts +31 -0
  2. package/lib/I18nInput/index.js +379 -0
  3. package/lib/I18nInput/index.less +7 -0
  4. package/lib/index.d.ts +1 -0
  5. package/lib/index.js +1 -4
  6. package/lib/locales/en_US.json +1 -1
  7. package/lib/locales/index.d.ts +7 -0
  8. package/lib/locales/index.js +28 -13
  9. package/lib/locales/intl.d.ts +11 -0
  10. package/lib/locales/intl.js +39 -24
  11. package/lib/locales/ja_JP.json +1 -0
  12. package/lib/locales/normalizeLocale.d.ts +2 -0
  13. package/lib/locales/normalizeLocale.js +27 -0
  14. package/lib/locales/withLocale.d.ts +28 -0
  15. package/lib/locales/withLocale.js +2 -2
  16. package/lib/locales/zh_CN.json +1 -1
  17. package/lib/locales/zh_HK.json +1 -0
  18. package/lib/locales/zh_TW.json +1 -1
  19. package/package.json +10 -5
  20. package/lib/AggregateSearch/CLSPL/CLQLLexer.js +0 -78
  21. package/lib/AggregateSearch/CLSPL/CLQLParser.js +0 -2724
  22. package/lib/AggregateSearch/CLSPL/CLQLParserListener.js +0 -347
  23. package/lib/AggregateSearch/CLSPL/CLQLParserVisitor.js +0 -251
  24. package/lib/AggregateSearch/CLSPL/SPLStagy.js +0 -197
  25. package/lib/AggregateSearch/CLSPL/index.js +0 -196
  26. package/lib/AggregateSearch/CLSPL/makeTokenizeFn.js +0 -18
  27. package/lib/AggregateSearch/CLSPL/token.js +0 -7
  28. package/lib/AggregateSearch/components/CloseAllIcon/index.js +0 -13
  29. package/lib/AggregateSearch/components/CloseAllIcon/index.less +0 -11
  30. package/lib/AggregateSearch/components/DropDown/assets/combined.svg +0 -22
  31. package/lib/AggregateSearch/components/DropDown/assets/copy.svg +0 -22
  32. package/lib/AggregateSearch/components/DropDown/assets/delete.svg +0 -24
  33. package/lib/AggregateSearch/components/DropDown/assets/home.svg +0 -20
  34. package/lib/AggregateSearch/components/DropDown/assets/key.svg +0 -21
  35. package/lib/AggregateSearch/components/DropDown/assets/star.svg +0 -22
  36. package/lib/AggregateSearch/components/DropDown/assets/time-circle.svg +0 -20
  37. package/lib/AggregateSearch/components/DropDown/assets/value.svg +0 -23
  38. package/lib/AggregateSearch/components/DropDown/config.js +0 -54
  39. package/lib/AggregateSearch/components/DropDown/index.js +0 -584
  40. package/lib/AggregateSearch/components/DropDown/index.less +0 -118
  41. package/lib/AggregateSearch/components/SwitchBtn/assets/tag-icon.svg +0 -17
  42. package/lib/AggregateSearch/components/SwitchBtn/assets/text-icon.svg +0 -18
  43. package/lib/AggregateSearch/components/SwitchBtn/index.js +0 -27
  44. package/lib/AggregateSearch/components/SwitchBtn/index.less +0 -31
  45. package/lib/AggregateSearch/hooks/useDropDown.js +0 -428
  46. package/lib/AggregateSearch/index.js +0 -520
  47. package/lib/AggregateSearch/index.less +0 -225
  48. package/lib/AggregateSearch/utils/index.js +0 -391
  49. package/lib/ContentEditableSearch/components/CloseAllIcon/index.js +0 -13
  50. package/lib/ContentEditableSearch/components/CloseAllIcon/index.less +0 -11
  51. package/lib/ContentEditableSearch/index.js +0 -157
  52. package/lib/ContentEditableSearch/index.less +0 -65
  53. package/lib/ContentEditableSearch/utils/index.js +0 -98
  54. package/lib/PropertyControlViewer/assets/doCommon.less +0 -75
  55. package/lib/PropertyControlViewer/assets/doSelect.less +0 -74
  56. package/lib/PropertyControlViewer/assets/index.less +0 -189
  57. package/lib/PropertyControlViewer/components/DoAppIcon/CustomIcon/iconfont.js +0 -1
  58. package/lib/PropertyControlViewer/components/DoAppIcon/CustomIcon/index.js +0 -29
  59. package/lib/PropertyControlViewer/components/DoAppIcon/iconData/IconJson.js +0 -0
  60. package/lib/PropertyControlViewer/components/DoAppIcon/index.js +0 -41
  61. package/lib/PropertyControlViewer/components/DoCiUnitBitmap.js +0 -50
  62. package/lib/PropertyControlViewer/components/DoCommon.js +0 -36
  63. package/lib/PropertyControlViewer/components/DoDefaultPlaceholder.js +0 -9
  64. package/lib/PropertyControlViewer/components/DoImage.js +0 -107
  65. package/lib/PropertyControlViewer/components/DoQuote/components/QuoteView.js +0 -63
  66. package/lib/PropertyControlViewer/components/DoQuote/components/TableQuoteView.js +0 -18
  67. package/lib/PropertyControlViewer/components/DoQuote/index.js +0 -16
  68. package/lib/PropertyControlViewer/components/DoSelect.js +0 -80
  69. package/lib/PropertyControlViewer/components/DoTable.js +0 -44
  70. package/lib/PropertyControlViewer/components/DoUser.js +0 -61
  71. package/lib/PropertyControlViewer/components/TagShowMoreList/index.js +0 -132
  72. package/lib/PropertyControlViewer/components/TagShowMoreList/index.less +0 -106
  73. package/lib/PropertyControlViewer/config/constants.js +0 -84
  74. package/lib/PropertyControlViewer/config/utils.js +0 -353
  75. package/lib/PropertyControlViewer/index.js +0 -195
  76. package/lib/PropertyControlViewer/index.less +0 -107
  77. package/lib/Watermark/index.js +0 -187
  78. package/lib/Watermark/index.less +0 -17
  79. package/lib/demo.js +0 -0
  80. package/lib/locale/en_US.js +0 -9
  81. package/lib/locale/index.js +0 -12
  82. package/lib/locale/zh_CN.js +0 -9
@@ -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, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? 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
- }
@@ -1,187 +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 _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
12
- 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); }
13
- 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); }); }; }
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
- 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; }
17
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
18
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
19
- import React, { useEffect, useState, useRef, useCallback } from "react";
20
- import PropTypes from "prop-types";
21
- import moment from "moment";
22
- import "./index.less";
23
-
24
- // 疏密类型
25
- var DENSITY = {
26
- // 稀疏
27
- sparse: 1,
28
- // 标准
29
- standard: 2,
30
- // 密集
31
- dense: 3
32
- };
33
-
34
- // 疏密值-web端
35
- var DENSITY_CONFIG_DESKTOP = _defineProperty(_defineProperty(_defineProperty({}, DENSITY.sparse, [100, 200]), DENSITY.standard, [80, 160]), DENSITY.dense, [60, 120]);
36
-
37
- // 疏密值-mobile端
38
- var DENSITY_CONFIG_MOBILE = _defineProperty(_defineProperty(_defineProperty({}, DENSITY.sparse, [200, 400]), DENSITY.standard, [160, 320]), DENSITY.dense, [120, 240]);
39
- var WatermarkCom = function WatermarkCom(_ref) {
40
- var _ref$type = _ref.type,
41
- type = _ref$type === void 0 ? "desktop" : _ref$type,
42
- _ref$fetchWatermark = _ref.fetchWatermark,
43
- fetchWatermark = _ref$fetchWatermark === void 0 ? /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
44
- return _regeneratorRuntime().wrap(function _callee$(_context) {
45
- while (1) switch (_context.prev = _context.next) {
46
- case 0:
47
- return _context.abrupt("return", fetch("/docp/gateway/douc/api/v1/watermark/query").then(function (res) {
48
- return res.json();
49
- }).then(function (res) {
50
- if (res && res.code === 100000) {
51
- return res.data;
52
- } else {
53
- console.error(res);
54
- }
55
- })["catch"](function (error) {
56
- console.error(error);
57
- }));
58
- case 1:
59
- case "end":
60
- return _context.stop();
61
- }
62
- }, _callee);
63
- })) : _ref$fetchWatermark,
64
- _ref$densityConfig = _ref.densityConfig,
65
- densityConfig = _ref$densityConfig === void 0 ? {} : _ref$densityConfig,
66
- children = _ref.children,
67
- renderWatermarkDateFormat = _ref.renderWatermarkDateFormat,
68
- rest = _objectWithoutProperties(_ref, _excluded);
69
- var watermarkRef = useRef();
70
-
71
- // 默认为 false 的话,刷新页面会有bug
72
- var _useState = useState(true),
73
- _useState2 = _slicedToArray(_useState, 2),
74
- visible = _useState2[0],
75
- setVisible = _useState2[1];
76
- var _useState3 = useState({}),
77
- _useState4 = _slicedToArray(_useState3, 2),
78
- watermarkProps = _useState4[0],
79
- setWatermarkProps = _useState4[1];
80
- var getGapValue = useCallback(function (density) {
81
- if (Object.keys(densityConfig).length > 0) {
82
- return densityConfig[density];
83
- } else {
84
- if (type === "desktop") {
85
- return DENSITY_CONFIG_DESKTOP[density];
86
- } else {
87
- return DENSITY_CONFIG_MOBILE[density];
88
- }
89
- }
90
- }, [densityConfig, type]);
91
- useEffect(function () {
92
- var fetchWatermarkFn = /*#__PURE__*/function () {
93
- var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
94
- var watermarkInfo, status, params, density, size, transparency, rotation, timeStrField, props;
95
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
96
- while (1) switch (_context2.prev = _context2.next) {
97
- case 0:
98
- _context2.next = 2;
99
- return fetchWatermark();
100
- case 2:
101
- watermarkInfo = _context2.sent;
102
- if (watermarkInfo) {
103
- _context2.next = 5;
104
- break;
105
- }
106
- return _context2.abrupt("return");
107
- case 5:
108
- status = watermarkInfo.status, params = watermarkInfo.params, density = watermarkInfo.density, size = watermarkInfo.size, transparency = watermarkInfo.transparency, rotation = watermarkInfo.rotation; // 处理时间戳
109
- timeStrField = params === null || params === void 0 ? void 0 : params.find(function (filed) {
110
- return filed.key === "timeStr";
111
- });
112
- if (timeStrField) {
113
- timeStrField.value = renderWatermarkDateFormat ? renderWatermarkDateFormat(moment()) : moment().format("YYYY-MM-DD");
114
- }
115
- props = {
116
- content: params === null || params === void 0 ? void 0 : params.filter(function (field) {
117
- return !!field.value;
118
- }).map(function (field) {
119
- return field.value;
120
- }).join(" "),
121
- font: {
122
- color: "rgba(0,0,0,".concat(transparency, ")"),
123
- fontSize: size
124
- },
125
- rotate: rotation,
126
- gap: getGapValue(density)
127
- };
128
- setVisible(!!status);
129
- setWatermarkProps(props);
130
- case 11:
131
- case "end":
132
- return _context2.stop();
133
- }
134
- }, _callee2);
135
- }));
136
- return function fetchWatermarkFn() {
137
- return _ref3.apply(this, arguments);
138
- };
139
- }();
140
- fetchWatermarkFn();
141
- }, []);
142
- var targetRef = useCallback(function (ref) {
143
- if (ref) {
144
- watermarkRef.current = ref;
145
- }
146
- }, []);
147
- useEffect(function () {
148
- if (!visible || children) {
149
- return;
150
- }
151
- watermarkRef.current && document.body.append(watermarkRef.current);
152
-
153
- // 退出当前页面删除水印
154
- return function () {
155
- watermarkRef.current && watermarkRef.current.remove();
156
- };
157
- }, [visible, children]);
158
- function renderWatermark() {
159
- if (children) {
160
- return visible ? /*#__PURE__*/React.createElement(_Watermark, _extends({}, watermarkProps, rest, {
161
- zIndex: 10000
162
- }), children) : children;
163
- } else {
164
- return /*#__PURE__*/React.createElement("div", {
165
- ref: targetRef,
166
- className: visible ? "portal-watermark" : "portal-watermark-hidden"
167
- }, visible && /*#__PURE__*/React.createElement(_Watermark, _extends({}, watermarkProps, rest)));
168
- }
169
- }
170
- return renderWatermark();
171
- };
172
- WatermarkCom.propTypes = {
173
- /**
174
- * 水印类型,可选值为 desktop、mobile 或者不设
175
- */
176
- type: PropTypes.string,
177
- /**
178
- * 获取水印的信息,需要返回promise,async(value)=>({}),默认地址:/douc/api/v1/watermark/query
179
- */
180
- fetchWatermark: PropTypes.func
181
- /**
182
- * 水印展示密度配置,默认支持三种模式,1: 稀疏,2: 标准 3: 密集,具体相关配置可以通过{1: [xx, yy]} 进行改写,其中xx为x方向间距,yy为y方向间距,单位为px,
183
- * 可按需进行配置,此配置会覆盖 type 配置
184
- */
185
- // densityConfig: PropTypes.object,
186
- };
187
- export default WatermarkCom;
@@ -1,17 +0,0 @@
1
- .portal-watermark{
2
- position: absolute !important;
3
- top: 0;
4
- left: 0;
5
- z-index: 10000;
6
- width: 100%;
7
- height: 100%;
8
- pointer-events: none;
9
-
10
- div{
11
- height: 100%;
12
- }
13
- }
14
-
15
- .portal-watermark-hidden{
16
- display: none;
17
- }
package/lib/demo.js DELETED
File without changes
@@ -1,9 +0,0 @@
1
- export default {
2
- name: 'Name',
3
- userName: 'Username',
4
- department: 'Department',
5
- emil: 'Email',
6
- mobile: "Phone",
7
- groupName: 'User group',
8
- groupDetails: 'Description'
9
- };
@@ -1,12 +0,0 @@
1
- import zhCN from './zh_CN.js';
2
- import enUS from './en_US.js';
3
- export var getLocale = function getLocale(locale) {
4
- switch (locale) {
5
- case 'zh':
6
- return zhCN;
7
- case 'en':
8
- return enUS;
9
- default:
10
- return zhCN;
11
- }
12
- };
@@ -1,9 +0,0 @@
1
- export default {
2
- name: '姓名',
3
- userName: '用户名',
4
- department: '部门',
5
- emil: '邮箱',
6
- mobile: "手机",
7
- groupName: '用户组',
8
- groupDetails: '描述'
9
- };