@cloud-app-dev/vidc 2.0.0-alpha.7 → 2.1.0-alpha.2

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 (197) hide show
  1. package/.fatherrc.js +11 -4
  2. package/.umirc.ts +1 -1
  3. package/es/Api/index.js +7 -7
  4. package/es/AppRedirect/index.d.ts +1 -1
  5. package/es/AppRedirect/index.js +7 -12
  6. package/es/Auth/index.js +1 -1
  7. package/es/AutoExit/index.js +12 -10
  8. package/es/{ContentBox → Box}/BetweenBox/index.css +0 -0
  9. package/es/{ContentBox → Box}/BetweenBox/index.d.ts +0 -0
  10. package/es/{ContentBox → Box}/BetweenBox/index.js +0 -0
  11. package/es/{ContentBox → Box}/InfoBox/index.css +0 -0
  12. package/es/{ContentBox → Box}/InfoBox/index.d.ts +0 -0
  13. package/es/{ContentBox → Box}/InfoBox/index.js +0 -0
  14. package/es/{ContentBox → Box}/TwoColumnBox/index.css +0 -0
  15. package/es/{ContentBox → Box}/TwoColumnBox/index.d.ts +0 -0
  16. package/es/{ContentBox → Box}/TwoColumnBox/index.js +0 -0
  17. package/es/{ContentBox → Box}/deps/content-grid.d.ts +0 -0
  18. package/es/{ContentBox → Box}/deps/content-grid.js +0 -0
  19. package/es/{ContentBox → Box}/deps/grid-factory.d.ts +0 -0
  20. package/es/{ContentBox → Box}/deps/grid-factory.js +0 -0
  21. package/es/{ContentBox → Box}/deps/simple-grid.d.ts +0 -0
  22. package/es/{ContentBox → Box}/deps/simple-grid.js +0 -0
  23. package/es/{ContentBox → Box}/index.css +0 -0
  24. package/es/{ContentBox → Box}/index.d.ts +3 -3
  25. package/es/{ContentBox → Box}/index.js +5 -5
  26. package/es/CheckGroupFixed/index.js +4 -2
  27. package/es/Config/index.js +44 -14
  28. package/es/Config/interface.d.ts +12 -5
  29. package/es/Config/utils.d.ts +1 -1
  30. package/es/Config/utils.js +1 -3
  31. package/es/ConfigContext/index.d.ts +15 -2
  32. package/es/ConfigContext/index.js +25 -3
  33. package/es/DeviceSelect/TreeType.d.ts +6 -0
  34. package/es/DeviceSelect/TreeType.js +36 -0
  35. package/es/DeviceSelect/demo.js +2 -2
  36. package/es/DeviceSelect/index.css +6 -1
  37. package/es/DeviceSelect/index.d.ts +5 -0
  38. package/es/DeviceSelect/index.js +21 -52
  39. package/es/Dict/desc.js +3 -3
  40. package/es/Dict/utils.js +3 -3
  41. package/es/IconFont/index.d.ts +0 -1
  42. package/es/IconFont/index.js +12 -13
  43. package/es/InitialConfig/index.js +7 -4
  44. package/es/InitialConfig/utils.d.ts +5 -0
  45. package/es/InitialConfig/utils.js +33 -6
  46. package/es/InitialRequest/index.d.ts +3 -1
  47. package/es/InitialRequest/index.js +20 -16
  48. package/es/InitialRequest/utils.d.ts +6 -4
  49. package/es/InitialRequest/utils.js +52 -70
  50. package/es/Input/index.js +3 -2
  51. package/es/InstanceHistory/index.d.ts +3 -0
  52. package/es/InstanceHistory/index.js +9 -0
  53. package/es/List/CheckExt.d.ts +3 -5
  54. package/es/List/CheckExt.js +21 -13
  55. package/es/{AppRoute → List/DeviceList}/index.css +0 -0
  56. package/es/List/DeviceList/index.d.ts +11 -0
  57. package/es/{DeviceList → List/DeviceList}/index.js +6 -18
  58. package/es/{DynamicDeviceList → List/DynamicDeviceList}/Demo.d.ts +0 -0
  59. package/es/{DynamicList/demo.js → List/DynamicDeviceList/Demo.js} +25 -42
  60. package/es/{DynamicDeviceList → List/DynamicDeviceList}/index.css +5 -17
  61. package/es/List/DynamicDeviceList/index.d.ts +11 -0
  62. package/es/List/DynamicDeviceList/index.js +205 -0
  63. package/es/List/DynamicDeviceList/interface.d.ts +37 -0
  64. package/es/List/DynamicDeviceList/utils.d.ts +16 -0
  65. package/es/List/DynamicDeviceList/utils.js +61 -0
  66. package/es/{DynamicList/demo.d.ts → List/DynamicGridList/Demo.d.ts} +0 -0
  67. package/es/List/DynamicGridList/Demo.js +70 -0
  68. package/es/List/DynamicGridList/index.d.ts +26 -0
  69. package/es/List/DynamicGridList/index.js +73 -0
  70. package/es/List/GridList/Demo.d.ts +2 -0
  71. package/es/List/GridList/Demo.js +91 -0
  72. package/es/List/GridList/hook.d.ts +13 -0
  73. package/es/List/GridList/hook.js +301 -0
  74. package/es/List/GridList/index.css +7 -0
  75. package/es/List/GridList/index.d.ts +15 -0
  76. package/es/List/GridList/index.js +47 -0
  77. package/es/List/GridList/interface.d.ts +59 -0
  78. package/es/List/GridList/utils.d.ts +9 -0
  79. package/es/List/GridList/utils.js +43 -0
  80. package/es/List/ListExt/index.css +3 -0
  81. package/es/{ListExt → List/ListExt}/index.d.ts +1 -1
  82. package/es/{ListExt → List/ListExt}/index.js +3 -3
  83. package/es/List/VList/index.css +6 -0
  84. package/es/List/VList/index.d.ts +18 -0
  85. package/es/List/VList/index.js +51 -0
  86. package/es/List/VList/utils.d.ts +14 -0
  87. package/es/{VList → List/VList}/utils.js +0 -0
  88. package/es/List/index.css +11 -12
  89. package/es/List/index.d.ts +5 -70
  90. package/es/List/index.js +32 -24
  91. package/es/List/interface.d.ts +87 -0
  92. package/es/List/renderItem.d.ts +1 -1
  93. package/es/List/renderItem.js +13 -10
  94. package/es/LoaderApp/index.d.ts +1 -1
  95. package/es/LoaderApp/index.js +18 -18
  96. package/es/LoaderApp/utils.d.ts +2 -1
  97. package/es/LoaderApp/utils.js +6 -3
  98. package/es/LoaderScript/index.js +7 -89
  99. package/es/LoaderScript/utils.d.ts +2 -0
  100. package/es/LoaderScript/utils.js +170 -33
  101. package/es/Picture/component/MoveContent/index.js +3 -3
  102. package/es/RefDrawer/index.js +1 -1
  103. package/es/RefModal/index.js +1 -1
  104. package/es/Service/http.d.ts +6 -4
  105. package/es/Service/http.js +20 -22
  106. package/es/Service/index.d.ts +3 -3
  107. package/es/Service/index.js +7 -11
  108. package/es/Service/interface.d.ts +5 -11
  109. package/es/Service/middleware.d.ts +1 -1
  110. package/es/Service/middleware.js +1 -1
  111. package/es/TableLayout/index.d.ts +3 -0
  112. package/es/TableLayout/index.js +14 -45
  113. package/es/{TreeTitle → Title}/index.css +5 -5
  114. package/es/{TreeTitle → Title}/index.d.ts +2 -2
  115. package/es/{TreeTitle → Title}/index.js +7 -4
  116. package/es/{TreeMode → Tree/BaseTree}/demo.d.ts +0 -0
  117. package/es/Tree/BaseTree/demo.js +69 -0
  118. package/es/Tree/BaseTree/index.css +64 -0
  119. package/es/Tree/BaseTree/index.d.ts +24 -0
  120. package/es/Tree/BaseTree/index.js +83 -0
  121. package/es/Tree/demo.js +19 -56
  122. package/es/Tree/index.css +29 -55
  123. package/es/Tree/index.d.ts +19 -20
  124. package/es/Tree/index.js +185 -70
  125. package/es/UserSelect/index.js +6 -4
  126. package/es/WorkerFlow/Form/Condition.js +2 -4
  127. package/es/WorkerFlow/Form/EmptyUserSet.js +2 -4
  128. package/es/WorkerFlow/Form/FormAuth.js +2 -2
  129. package/es/WorkerFlow/Form/GroupList.js +2 -2
  130. package/es/WorkerFlow/Form/GroupSelect.js +2 -4
  131. package/es/WorkerFlow/Form/GroupSelectModalContent.js +1 -1
  132. package/es/WorkerFlow/Form/LevelGroupSelect.js +3 -5
  133. package/es/WorkerFlow/Form/UserAndGroupSelect.js +2 -4
  134. package/es/WorkerFlow/Form/UserSelect.js +2 -4
  135. package/es/WorkerFlow/Form/UserSelectModalContent.js +3 -3
  136. package/es/WorkerFlow/Form/UserSet.js +2 -2
  137. package/es/WorkerFlow/Nodes/TitleElement.js +71 -34
  138. package/es/WorkerFlow/index.css +9 -3
  139. package/es/WorkerFlow/index.js +13 -8
  140. package/es/WorkerFlow/utils.js +2 -2
  141. package/es/index.d.ts +3 -11
  142. package/es/index.js +3 -11
  143. package/es/useDrawer/index.d.ts +1 -1
  144. package/es/useDrawer/index.js +3 -2
  145. package/es/useHistory/index.d.ts +2 -2
  146. package/es/useHistory/index.js +3 -6
  147. package/es/useHttp/index.js +1 -1
  148. package/es/useModal/index.d.ts +1 -1
  149. package/es/useModal/index.js +3 -2
  150. package/es/utils.d.ts +9 -0
  151. package/es/utils.js +36 -1
  152. package/package.json +10 -11
  153. package/tsconfig.json +1 -1
  154. package/es/AppRoute/Render.d.ts +0 -23
  155. package/es/AppRoute/Render.js +0 -111
  156. package/es/AppRoute/Rendered.d.ts +0 -4
  157. package/es/AppRoute/Rendered.js +0 -11
  158. package/es/AppRoute/index.d.ts +0 -14
  159. package/es/AppRoute/index.js +0 -106
  160. package/es/AppRoute/interface.d.ts +0 -18
  161. package/es/AppRoute/utils.d.ts +0 -1
  162. package/es/AppRoute/utils.js +0 -28
  163. package/es/DeviceList/index.css +0 -32
  164. package/es/DeviceList/index.d.ts +0 -14
  165. package/es/DynamicDeviceList/CheckExt.d.ts +0 -8
  166. package/es/DynamicDeviceList/CheckExt.js +0 -36
  167. package/es/DynamicDeviceList/Demo.js +0 -17
  168. package/es/DynamicDeviceList/index.d.ts +0 -35
  169. package/es/DynamicDeviceList/index.js +0 -224
  170. package/es/DynamicDeviceList/utils.d.ts +0 -2
  171. package/es/DynamicDeviceList/utils.js +0 -15
  172. package/es/DynamicList/index.css +0 -7
  173. package/es/DynamicList/index.d.ts +0 -31
  174. package/es/DynamicList/index.js +0 -132
  175. package/es/IconFont/index.css +0 -0
  176. package/es/List/utils.d.ts +0 -5
  177. package/es/List/utils.js +0 -18
  178. package/es/ListExt/index.css +0 -9
  179. package/es/ScrollList/index.css +0 -73
  180. package/es/ScrollList/index.d.ts +0 -24
  181. package/es/ScrollList/index.js +0 -261
  182. package/es/ScrollList/utils.js +0 -84
  183. package/es/Service/logger.d.ts +0 -3
  184. package/es/Service/logger.js +0 -13
  185. package/es/Service/utils.d.ts +0 -3
  186. package/es/Service/utils.js +0 -11
  187. package/es/TreeMode/demo.js +0 -32
  188. package/es/TreeMode/index.css +0 -38
  189. package/es/TreeMode/index.d.ts +0 -23
  190. package/es/TreeMode/index.js +0 -201
  191. package/es/VList/index.css +0 -4
  192. package/es/VList/index.d.ts +0 -16
  193. package/es/VList/index.js +0 -56
  194. package/es/VList/utils.d.ts +0 -10
  195. package/es/useChangeEffect/index.d.ts +0 -3
  196. package/es/useChangeEffect/index.js +0 -32
  197. package/es/useHistory/index.css +0 -0
@@ -1,20 +1,28 @@
1
- import "antd/lib/checkbox/style";
2
- import _Checkbox from "antd/lib/checkbox";
1
+ import "antd/lib/tooltip/style";
2
+ import _Tooltip from "antd/lib/tooltip";
3
3
  import React from 'react';
4
+ import IconFont from '../IconFont';
4
5
 
5
6
  function CheckExt(_ref) {
6
- var checkHalfStatus = _ref.checkHalfStatus,
7
- checkAllStatus = _ref.checkAllStatus,
8
- selectCount = _ref.selectCount,
9
- onChange = _ref.onChange,
10
- count = _ref.count;
7
+ var selectCount = _ref.selectCount,
8
+ onCheck = _ref.onCheck,
9
+ count = _ref.count,
10
+ onCancel = _ref.onCancel;
11
11
  return /*#__PURE__*/React.createElement("div", {
12
- className: "c-check-list-checkext"
13
- }, /*#__PURE__*/React.createElement(_Checkbox, {
14
- indeterminate: checkHalfStatus,
15
- checked: checkAllStatus,
16
- onChange: onChange
17
- }, "\u5168\u9009"), /*#__PURE__*/React.createElement("span", null, "\u5DF2\u9009 ", /*#__PURE__*/React.createElement("span", {
12
+ className: "cloudapp-c-check-list-checkext"
13
+ }, /*#__PURE__*/React.createElement("span", {
14
+ className: "select-group"
15
+ }, /*#__PURE__*/React.createElement(_Tooltip, {
16
+ title: "\u9009\u4E2D\u6240\u6709\u5DF2\u52A0\u8F7D"
17
+ }, /*#__PURE__*/React.createElement(IconFont, {
18
+ type: "icon-S_Photo_MarkYes",
19
+ onClick: onCheck
20
+ })), /*#__PURE__*/React.createElement(_Tooltip, {
21
+ title: "\u53D6\u6D88\u9009\u4E2D\u6240\u6709\u5DF2\u52A0\u8F7D\u9879"
22
+ }, /*#__PURE__*/React.createElement(IconFont, {
23
+ type: "icon-MarkNo",
24
+ onClick: onCancel
25
+ }))), /*#__PURE__*/React.createElement("span", null, "\u5DF2\u9009 ", /*#__PURE__*/React.createElement("span", {
18
26
  style: {
19
27
  color: 'var(--success)'
20
28
  }
File without changes
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import { IListProps } from '../ListExt';
3
+ import { DeviceItemType } from '../../core';
4
+ import './index.less';
5
+ interface DeviceListProps extends Exclude<IListProps<DeviceItemType>, 'list' | 'itemKey' | 'itemNameKey' | 'whatIcon' | 'inputPlaceholder' | 'rowHeight'> {
6
+ deviceList?: Array<DeviceItemType>;
7
+ deleteItem?: (item: DeviceItemType) => void;
8
+ getIconStyle?: (item: DeviceItemType) => React.CSSProperties;
9
+ }
10
+ declare function DeviceList({ getIconStyle, className, deleteItem, deviceList, renderItemExt, ...props }: DeviceListProps): JSX.Element;
11
+ export default DeviceList;
@@ -1,9 +1,8 @@
1
1
  import { __rest } from "tslib";
2
2
  import React, { useCallback } from 'react';
3
- import List from '../List';
4
- import IconFont from '../IconFont';
5
- import DeviceIcon from '../DeviceIcon';
6
- import TreeTitle from '../TreeTitle';
3
+ import List from '../ListExt';
4
+ import IconFont from '../../IconFont';
5
+ import DeviceIcon from '../../DeviceIcon';
7
6
  import "./index.css";
8
7
 
9
8
  function DeviceList(_a) {
@@ -11,12 +10,8 @@ function DeviceList(_a) {
11
10
  className = _a.className,
12
11
  deleteItem = _a.deleteItem,
13
12
  deviceList = _a.deviceList,
14
- onMouseOverItem = _a.onMouseOverItem,
15
13
  _renderItemExt = _a.renderItemExt,
16
- title = _a.title,
17
- onKeywordChange = _a.onKeywordChange,
18
- itemKey = _a.itemKey,
19
- props = __rest(_a, ["getIconStyle", "className", "deleteItem", "deviceList", "onMouseOverItem", "renderItemExt", "title", "onKeywordChange", "itemKey"]);
14
+ props = __rest(_a, ["getIconStyle", "className", "deleteItem", "deviceList", "renderItemExt"]);
20
15
 
21
16
  var whatIcon = useCallback(function (item) {
22
17
  return /*#__PURE__*/React.createElement(DeviceIcon, {
@@ -34,17 +29,10 @@ function DeviceList(_a) {
34
29
  className: "lm-c-device-list-wrapper ".concat(className),
35
30
  list: deviceList,
36
31
  itemNameKey: "deviceName",
37
- itemKey: itemKey,
32
+ itemKey: "cid",
38
33
  rowHeight: 30,
39
- renderHeader: function renderHeader() {
40
- return /*#__PURE__*/React.createElement(TreeTitle, {
41
- title: title,
42
- onChange: onKeywordChange,
43
- inputPlaceholder: "\u8BF7\u8F93\u5165\u8BBE\u5907\u540D\u79F0"
44
- });
45
- },
34
+ inputPlaceholder: "\u8BF7\u8F93\u5165\u8BBE\u5907\u540D\u79F0",
46
35
  whatIcon: whatIcon,
47
- onMouseOverItem: onMouseOverItem,
48
36
  renderItemExt: function renderItemExt(item) {
49
37
  return _renderItemExt ? _renderItemExt(item) : deleteItem ? /*#__PURE__*/React.createElement("span", {
50
38
  className: "clear-item",
@@ -1,10 +1,5 @@
1
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
2
-
3
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
-
5
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
6
-
7
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
1
+ import "antd/lib/config-provider/style";
2
+ import _ConfigProvider from "antd/lib/config-provider";
8
3
 
9
4
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
10
5
 
@@ -18,33 +13,20 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
18
13
 
19
14
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
20
15
 
21
- import React, { useCallback, useState } from 'react';
22
- import DynamicList from './index';
23
- var defaultList = Array.from(new Array(20)).map(function (_, i) {
24
- return {
25
- name: "\u6211\u662F\u5217\u8868".concat(i),
26
- id: i
27
- };
28
- });
16
+ import React, { useState } from 'react';
17
+ import DynamicDeviceList from './index';
29
18
 
30
- var App = function App() {
31
- var _useState = useState(defaultList),
19
+ function App() {
20
+ var _useState = useState({
21
+ keyword: ''
22
+ }),
32
23
  _useState2 = _slicedToArray(_useState, 2),
33
24
  state = _useState2[0],
34
25
  setState = _useState2[1];
35
26
 
36
- var loadMore = useCallback(function () {
37
- console.log(11111);
38
- return new Promise(function (resolve) {
39
- setTimeout(function () {
40
- setState(function (old) {
41
- return [].concat(_toConsumableArray(old), _toConsumableArray(defaultList));
42
- });
43
- resolve(true);
44
- }, 500);
45
- });
46
- }, [state]);
47
- return /*#__PURE__*/React.createElement("div", {
27
+ return /*#__PURE__*/React.createElement(_ConfigProvider, {
28
+ prefixCls: "cloudapp"
29
+ }, /*#__PURE__*/React.createElement("div", {
48
30
  style: {
49
31
  display: 'flex'
50
32
  }
@@ -53,19 +35,20 @@ var App = function App() {
53
35
  height: 400,
54
36
  width: 300
55
37
  }
56
- }, /*#__PURE__*/React.createElement(DynamicList, {
57
- list: state,
58
- rowCount: 300,
59
- renderItem: function renderItem(item, index) {
60
- return /*#__PURE__*/React.createElement("span", {
61
- style: {
62
- padding: '0 20px',
63
- lineHeight: '40px'
64
- }
65
- }, item.name, "-", index);
38
+ }, /*#__PURE__*/React.createElement(DynamicDeviceList, {
39
+ onChecked: console.log,
40
+ params: {
41
+ keywords: state.keyword
66
42
  },
67
- loadMore: loadMore
68
- })));
69
- };
43
+ title: "\u5217\u8868",
44
+ onKeywordChange: function onKeywordChange(e) {
45
+ return setState(function (old) {
46
+ return Object.assign(Object.assign({}, old), {
47
+ keyword: e
48
+ });
49
+ });
50
+ }
51
+ }))));
52
+ }
70
53
 
71
54
  export default App;
@@ -3,17 +3,21 @@
3
3
  flex-direction: column;
4
4
  width: 100%;
5
5
  height: 100%;
6
+ border: 1px solid var(--bd-color);
6
7
  }
7
8
  .zenview-c-dynamic-device-list-layout .dynamic-list-item {
8
9
  padding: 0 10px;
9
10
  }
10
- .zenview-c-dynamic-device-list-layout .lm-c-dynamiclist {
11
+ .zenview-c-dynamic-device-list-layout .zenview-c-dynamic-device-box {
11
12
  flex: 1;
13
+ overflow: auto;
14
+ contain: strict;
12
15
  }
13
16
  .zenview-c-dynamic-device-list-layout .device-item-box {
14
17
  height: 40px;
15
18
  line-height: 40px;
16
19
  display: flex;
20
+ padding: 0 10px;
17
21
  }
18
22
  .zenview-c-dynamic-device-list-layout .device-item-box .device-name {
19
23
  flex: 1;
@@ -33,19 +37,3 @@
33
37
  text-overflow: ellipsis;
34
38
  white-space: nowrap;
35
39
  }
36
- .zenview-c-dynamic-device-list-layout .c-check-list-checkext {
37
- font-size: var(--fs-small);
38
- padding: 5px 12px;
39
- display: flex;
40
- justify-content: space-between;
41
- border-bottom: 1px solid var(--bd-color);
42
- }
43
- .zenview-c-dynamic-device-list-layout .c-check-list-checkext .select-group .anticon {
44
- font-size: 16px;
45
- cursor: pointer;
46
- padding-right: 8px;
47
- color: var(--icon);
48
- }
49
- .zenview-c-dynamic-device-list-layout .c-check-list-checkext .select-group .anticon:hover {
50
- color: var(--primary);
51
- }
@@ -0,0 +1,11 @@
1
+ import { IDynamicDeviceListProps } from './interface';
2
+ import './index.less';
3
+ declare function DynamicDeviceList({ onClick, checkedKeys, defaultCheckedIds, onChecked, params, title, onKeywordChange, limit, itemHeight }: IDynamicDeviceListProps): JSX.Element;
4
+ declare namespace DynamicDeviceList {
5
+ var defaultProps: {
6
+ limit: number;
7
+ itemHeight: number;
8
+ params: {};
9
+ };
10
+ }
11
+ export default DynamicDeviceList;
@@ -0,0 +1,205 @@
1
+ import "antd/lib/skeleton/style";
2
+ import _Skeleton from "antd/lib/skeleton";
3
+ import "antd/lib/checkbox/style";
4
+ import _Checkbox from "antd/lib/checkbox";
5
+ import _useMemoizedFn from "ahooks/es/useMemoizedFn";
6
+ import _useUpdateEffect from "ahooks/es/useUpdateEffect";
7
+ import _useVirtualList3 from "ahooks/es/useVirtualList";
8
+ import _useInfiniteScroll2 from "ahooks/es/useInfiniteScroll";
9
+
10
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
11
+
12
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
13
+
14
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
15
+
16
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
17
+
18
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
19
+
20
+ 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."); }
21
+
22
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
23
+
24
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
25
+
26
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
27
+
28
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
29
+
30
+ import React, { useCallback, useMemo, useRef, useState } from 'react';
31
+ import DeviceIcon from '../../DeviceIcon';
32
+ import Title from '../../Title';
33
+ import CheckExt from '../CheckExt';
34
+ import { loadNextPage, LIMIT, skeletonList } from './utils';
35
+ import "./index.css";
36
+
37
+ function DynamicDeviceList(_ref) {
38
+ var onClick = _ref.onClick,
39
+ checkedKeys = _ref.checkedKeys,
40
+ defaultCheckedIds = _ref.defaultCheckedIds,
41
+ onChecked = _ref.onChecked,
42
+ params = _ref.params,
43
+ title = _ref.title,
44
+ onKeywordChange = _ref.onKeywordChange,
45
+ limit = _ref.limit,
46
+ itemHeight = _ref.itemHeight;
47
+
48
+ var _useState = useState({
49
+ checkedKeys: defaultCheckedIds || checkedKeys || []
50
+ }),
51
+ _useState2 = _slicedToArray(_useState, 2),
52
+ state = _useState2[0],
53
+ setState = _useState2[1];
54
+
55
+ var containerRef = useRef();
56
+ var wrapperRef = useRef();
57
+
58
+ var _useInfiniteScroll = _useInfiniteScroll2(function (d) {
59
+ return loadNextPage(d, limit, params);
60
+ }, {
61
+ target: containerRef,
62
+ threshold: 50,
63
+ isNoMore: function isNoMore(d) {
64
+ var _a;
65
+
66
+ return ((_a = d === null || d === void 0 ? void 0 : d.list) === null || _a === void 0 ? void 0 : _a.length) >= (d === null || d === void 0 ? void 0 : d.count);
67
+ },
68
+ reloadDeps: [params.placeIds, params.buzGroupId]
69
+ }),
70
+ data = _useInfiniteScroll.data,
71
+ loadingMore = _useInfiniteScroll.loadingMore,
72
+ noMore = _useInfiniteScroll.noMore;
73
+
74
+ var isSkeleton = useMemo(function () {
75
+ return !noMore && loadingMore;
76
+ }, [noMore, loadingMore]);
77
+ var dataList = useMemo(function () {
78
+ return data ? (data === null || data === void 0 ? void 0 : data.list) || [] : [];
79
+ }, [data]);
80
+
81
+ var _useVirtualList = _useVirtualList3(dataList, {
82
+ containerTarget: containerRef,
83
+ wrapperTarget: wrapperRef,
84
+ itemHeight: itemHeight,
85
+ overscan: 10
86
+ }),
87
+ _useVirtualList2 = _slicedToArray(_useVirtualList, 2),
88
+ list = _useVirtualList2[0],
89
+ scrollTo = _useVirtualList2[1];
90
+ /**
91
+ * 列表选中处理
92
+ */
93
+
94
+
95
+ var onCheckedAction = useCallback(function (item) {
96
+ var ids = state.checkedKeys || [];
97
+ var id = item.cid;
98
+ var checked = !ids.includes(item.cid);
99
+
100
+ if (checked) {
101
+ ids.push(id);
102
+ } else {
103
+ ids = ids.filter(function (v) {
104
+ return v !== id;
105
+ });
106
+ }
107
+
108
+ setState(function (old) {
109
+ return Object.assign(Object.assign({}, old), {
110
+ checkedKeys: _toConsumableArray(ids)
111
+ });
112
+ });
113
+ onChecked && onChecked(ids, [item], checked);
114
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps
115
+ [state.checkedKeys]);
116
+
117
+ _useUpdateEffect(function () {
118
+ return scrollTo(0);
119
+ }, [params.placeIds, params.buzGroupId]);
120
+
121
+ var onSelectAll = _useMemoizedFn(function () {
122
+ var ids = dataList.map(function (v) {
123
+ return v.cid;
124
+ });
125
+ setState(function (old) {
126
+ return Object.assign(Object.assign({}, old), {
127
+ checkedKeys: ids
128
+ });
129
+ });
130
+ onChecked && onChecked(ids, dataList, true);
131
+ });
132
+
133
+ var onCancelAll = function onCancelAll() {
134
+ setState(function (old) {
135
+ return Object.assign(Object.assign({}, old), {
136
+ checkedKeys: []
137
+ });
138
+ });
139
+ onChecked && onChecked([], [], false);
140
+ };
141
+
142
+ return /*#__PURE__*/React.createElement("div", {
143
+ className: "zenview-c-dynamic-device-list-layout"
144
+ }, /*#__PURE__*/React.createElement(Title, {
145
+ title: title,
146
+ onChange: onKeywordChange,
147
+ inputPlaceholder: "\u8BF7\u8F93\u5165\u8BBE\u5907\u540D\u79F0"
148
+ }), onChecked && /*#__PURE__*/React.createElement(CheckExt, {
149
+ count: data === null || data === void 0 ? void 0 : data.count,
150
+ selectCount: state.checkedKeys.length,
151
+ onCancel: onCancelAll,
152
+ onCheck: onSelectAll
153
+ }), /*#__PURE__*/React.createElement("div", {
154
+ className: "zenview-c-dynamic-device-box",
155
+ ref: containerRef
156
+ }, /*#__PURE__*/React.createElement("div", {
157
+ ref: wrapperRef
158
+ }, list.map(function (item) {
159
+ return /*#__PURE__*/React.createElement("div", {
160
+ key: item.index,
161
+ className: "device-item-box ".concat(state.checkedKeys.includes(item.data.cid) ? 'device-item-selected' : '')
162
+ }, onChecked ? /*#__PURE__*/React.createElement(_Checkbox, {
163
+ className: "device-name device-checkbox-name",
164
+ checked: state.checkedKeys.includes(item.data.cid),
165
+ value: item.data.cid,
166
+ onClick: function onClick() {
167
+ return onCheckedAction(item.data);
168
+ }
169
+ }, /*#__PURE__*/React.createElement(DeviceIcon, {
170
+ type: item.data.deviceType,
171
+ status: item.data.deviceStatus
172
+ }), /*#__PURE__*/React.createElement("span", {
173
+ title: item.data.deviceName
174
+ }, item.data.deviceName)) : /*#__PURE__*/React.createElement("span", {
175
+ className: "device-name",
176
+ onClick: onClick ? function () {
177
+ return onClick(item);
178
+ } : undefined
179
+ }, /*#__PURE__*/React.createElement(DeviceIcon, {
180
+ type: item.data.deviceType,
181
+ status: item.data.deviceStatus
182
+ }), /*#__PURE__*/React.createElement("span", {
183
+ title: item.data.deviceName
184
+ }, item.data.deviceName)));
185
+ })), isSkeleton && skeletonList.map(function (_, index) {
186
+ return /*#__PURE__*/React.createElement("div", {
187
+ key: index,
188
+ style: {
189
+ padding: '0 10px'
190
+ },
191
+ className: "dynamic-list-item"
192
+ }, /*#__PURE__*/React.createElement(_Skeleton, {
193
+ paragraph: false,
194
+ loading: true,
195
+ active: true
196
+ }));
197
+ })));
198
+ }
199
+
200
+ DynamicDeviceList.defaultProps = {
201
+ limit: LIMIT,
202
+ itemHeight: 40,
203
+ params: {}
204
+ };
205
+ export default DynamicDeviceList;
@@ -0,0 +1,37 @@
1
+ export interface IDynamicDeviceListProps {
2
+ /**
3
+ * @description 列表点击事件
4
+ */
5
+ onClick?: (item: DeviceItemType) => void;
6
+
7
+ /**
8
+ * @description 选中设备cid集合
9
+ */
10
+ checkedKeys?: string[];
11
+
12
+ /**
13
+ * @description 传入onSelect列表默认渲染为checkbox模式
14
+ */
15
+ onChecked?: (ids: string[], list: DeviceItemType[], checked: boolean) => void;
16
+
17
+ /**
18
+ * @description 传入queryList需要的参数,例如业务树ID,场所id等,分页参数除外
19
+ */
20
+ params?: { [key: string]: any };
21
+
22
+ title?: string;
23
+
24
+ onKeywordChange?: (v: string) => void;
25
+
26
+ defaultCheckedIds?: string[];
27
+
28
+ limit?: number;
29
+
30
+ itemHeight?: number;
31
+ }
32
+
33
+ export interface IDynamicDeviceListResult<T> {
34
+ list: T[];
35
+ offset: number;
36
+ [key: string]: any;
37
+ }
@@ -0,0 +1,16 @@
1
+ import { DeviceItemType, HttpPageResult2 } from '../../core';
2
+ import { IDynamicDeviceListResult } from './interface';
3
+ export declare function queryDeviceList(params?: any): Promise<HttpPageResult2<DeviceItemType>>;
4
+ export declare const LIMIT = 30;
5
+ /**
6
+ * @desc 懒加载方法
7
+ */
8
+ export declare const loadNextPage: (d?: IDynamicDeviceListResult<DeviceItemType>, defaultLimit?: number, params?: any) => Promise<{
9
+ list: DeviceItemType[];
10
+ count: number;
11
+ offset: number;
12
+ limit: number;
13
+ }>;
14
+ export declare const skeletonList: {
15
+ skeleton: boolean;
16
+ }[];
@@ -0,0 +1,61 @@
1
+ import { __awaiter } from "tslib";
2
+ import Service from '../../Service';
3
+ import { getHeader } from '../../utils';
4
+ export function queryDeviceList() {
5
+ var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
6
+ return Service.http({
7
+ method: 'post',
8
+ url: '/api/udm-api/device/queryList',
9
+ requestId: 'queryDeviceList',
10
+ headers: getHeader(),
11
+ data: Object.assign(Object.assign({}, params), {
12
+ includeSubOrganizations: 1,
13
+ isPagination: true
14
+ })
15
+ });
16
+ }
17
+ export var LIMIT = 30;
18
+ /**
19
+ * @desc 懒加载方法
20
+ */
21
+
22
+ export var loadNextPage = function loadNextPage(d, defaultLimit) {
23
+ var params = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
24
+ return __awaiter(this, void 0, void 0, /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
25
+ var _ref, offset, limit, pageLimit, pageOffset, res;
26
+
27
+ return regeneratorRuntime.wrap(function _callee$(_context) {
28
+ while (1) {
29
+ switch (_context.prev = _context.next) {
30
+ case 0:
31
+ _ref = d || {}, offset = _ref.offset, limit = _ref.limit;
32
+ pageLimit = typeof limit === 'number' ? limit : defaultLimit || LIMIT;
33
+ pageOffset = typeof offset === 'number' ? offset + pageLimit : 0;
34
+ _context.next = 5;
35
+ return queryDeviceList(Object.assign({
36
+ offset: pageOffset,
37
+ limit: pageLimit
38
+ }, params));
39
+
40
+ case 5:
41
+ res = _context.sent;
42
+ return _context.abrupt("return", {
43
+ list: res.data || [],
44
+ count: res.totalCount,
45
+ offset: pageOffset,
46
+ limit: pageLimit
47
+ });
48
+
49
+ case 7:
50
+ case "end":
51
+ return _context.stop();
52
+ }
53
+ }
54
+ }, _callee);
55
+ }));
56
+ };
57
+ export var skeletonList = Array.from(new Array(LIMIT)).map(function () {
58
+ return {
59
+ skeleton: true
60
+ };
61
+ });
@@ -0,0 +1,70 @@
1
+ import React from 'react';
2
+ import GridList from './index';
3
+
4
+ function random(low, high) {
5
+ return Math.floor(Math.random() * high) + low;
6
+ }
7
+
8
+ var IMAGES = Array.from({
9
+ length: 60
10
+ }, function (_, index) {
11
+ var width = 300;
12
+ var height = random(200, 300);
13
+ return {
14
+ url: "https://picsum.photos/id/".concat(index + 1, "/").concat(width, "/").concat(height, ".jpg"),
15
+ width: width,
16
+ height: height
17
+ };
18
+ });
19
+
20
+ var App = function App() {
21
+ function loadNextPage(d) {
22
+ return new Promise(function (resolve) {
23
+ setTimeout(function () {
24
+ resolve({
25
+ list: IMAGES
26
+ });
27
+ });
28
+ });
29
+ }
30
+
31
+ return /*#__PURE__*/React.createElement("div", {
32
+ style: {
33
+ height: 800,
34
+ overflow: 'auto'
35
+ }
36
+ }, /*#__PURE__*/React.createElement(GridList, {
37
+ itemKey: "url",
38
+ itemHeight: 300,
39
+ itemWidth: 250,
40
+ renderItem: function renderItem(image) {
41
+ return /*#__PURE__*/React.createElement("div", {
42
+ style: {
43
+ border: '1px solid gray',
44
+ height: '100%',
45
+ display: 'flex',
46
+ flexDirection: 'column'
47
+ }
48
+ }, /*#__PURE__*/React.createElement("div", {
49
+ style: {
50
+ flex: 1,
51
+ overflow: 'hidden'
52
+ }
53
+ }, /*#__PURE__*/React.createElement("img", {
54
+ src: image.url,
55
+ style: {
56
+ objectFit: 'cover',
57
+ display: 'block',
58
+ width: '100%',
59
+ height: '100%'
60
+ }
61
+ })), /*#__PURE__*/React.createElement("p", null, "\u6807\u9898"), /*#__PURE__*/React.createElement("p", null, "\u63CF\u8FF0"));
62
+ },
63
+ loadNextPage: loadNextPage,
64
+ isNoMore: function isNoMore() {
65
+ return false;
66
+ }
67
+ }));
68
+ };
69
+
70
+ export default App;
@@ -0,0 +1,26 @@
1
+ import React from 'react';
2
+ export interface IDynamicGridListProps<T> {
3
+ itemKey: string;
4
+ itemHeight?: number;
5
+ itemWidth?: number;
6
+ loadNextPage: (d: IDynamicGridListResult<T>) => Promise<IDynamicGridListResult<T>>;
7
+ reloadDep?: any;
8
+ isNoMore: (d: any) => boolean;
9
+ renderItem: (item: T) => React.ReactNode;
10
+ className?: string;
11
+ getGridGap?: (elementWidth: number, windowHeight: number) => number;
12
+ }
13
+ export interface IDynamicGridListResult<T> {
14
+ list: T[];
15
+ [key: string]: any;
16
+ }
17
+ declare function DynamicGridList<T>({ itemKey, itemHeight, itemWidth, loadNextPage, reloadDep, isNoMore, renderItem, className, getGridGap }: IDynamicGridListProps<T>): JSX.Element;
18
+ declare namespace DynamicGridList {
19
+ var defaultProps: {
20
+ itemWidth: number;
21
+ itemHeight: number;
22
+ className: string;
23
+ getGridGap: () => number;
24
+ };
25
+ }
26
+ export default DynamicGridList;