@kep-platform/basic-component 0.0.2 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. package/dist/@types/index.d.ts +61 -0
  2. package/dist/@types/styled-components.d.ts +9 -0
  3. package/dist/@types/theme.d.ts +38 -0
  4. package/dist/BoxShadowBox/BoxShadowBox.d.ts +8 -0
  5. package/dist/BoxShadowBox/BoxShadowBox.js +14 -0
  6. package/dist/BoxShadowBox/index.d.ts +1 -0
  7. package/dist/BoxShadowBox/index.js +1 -0
  8. package/dist/Button/Button.d.ts +12 -0
  9. package/dist/Button/Button.js +86 -0
  10. package/dist/Button/index.d.ts +1 -0
  11. package/dist/Button/index.js +1 -0
  12. package/dist/Columns/Columns.d.ts +24 -0
  13. package/dist/Columns/Columns.js +126 -0
  14. package/dist/Columns/index.d.ts +1 -0
  15. package/dist/Columns/index.js +1 -0
  16. package/dist/Flex/flex.d.ts +14 -0
  17. package/dist/Flex/flex.js +29 -0
  18. package/dist/Flex/index.d.ts +1 -0
  19. package/dist/Flex/index.js +1 -0
  20. package/dist/Grid/Col.d.ts +8 -0
  21. package/dist/Grid/Col.js +12 -0
  22. package/dist/Grid/Row.d.ts +6 -0
  23. package/dist/Grid/Row.js +55 -0
  24. package/dist/Grid/index.d.ts +2 -0
  25. package/dist/Grid/index.js +2 -0
  26. package/dist/Indent/Indent.d.ts +7 -0
  27. package/dist/Indent/Indent.js +25 -0
  28. package/dist/Indent/index.d.ts +1 -0
  29. package/dist/Indent/index.js +1 -0
  30. package/dist/List/List.d.ts +19 -0
  31. package/dist/List/List.js +41 -0
  32. package/dist/List/index.d.ts +1 -0
  33. package/dist/List/index.js +1 -0
  34. package/dist/Menu/Menu.d.ts +14 -0
  35. package/dist/Menu/Menu.js +107 -0
  36. package/dist/Menu/index.d.ts +3 -0
  37. package/dist/Menu/index.js +2 -0
  38. package/dist/Pagination/Pagination.d.ts +7 -0
  39. package/dist/Pagination/Pagination.js +44 -0
  40. package/dist/Pagination/index.d.ts +1 -0
  41. package/dist/Pagination/index.js +1 -0
  42. package/dist/PopupBox/PopupBox.d.ts +12 -0
  43. package/dist/PopupBox/PopupBox.js +12 -0
  44. package/dist/PopupBox/index.d.ts +1 -0
  45. package/dist/PopupBox/index.js +1 -0
  46. package/dist/Select/Select.d.ts +13 -0
  47. package/dist/Select/Select.js +121 -0
  48. package/dist/Select/index.d.ts +1 -0
  49. package/dist/Select/index.js +1 -0
  50. package/dist/Space/Space.d.ts +11 -0
  51. package/dist/Space/Space.js +39 -0
  52. package/dist/Space/index.d.ts +1 -0
  53. package/dist/Space/index.js +1 -0
  54. package/dist/Spin/Spin.d.ts +6 -0
  55. package/dist/Spin/Spin.js +16 -0
  56. package/dist/Spin/index.d.ts +1 -0
  57. package/dist/Spin/index.js +1 -0
  58. package/dist/Table/Table.d.ts +17 -0
  59. package/dist/Table/Table.js +243 -0
  60. package/dist/Table/index.d.ts +1 -0
  61. package/dist/Table/index.js +1 -0
  62. package/dist/Tag/Tag.d.ts +7 -0
  63. package/dist/Tag/Tag.js +16 -0
  64. package/dist/Tree/BOMTree.d.ts +3 -0
  65. package/dist/Tree/BOMTree.js +111 -0
  66. package/dist/Tree/MainProperties.d.ts +12 -0
  67. package/dist/Tree/MainProperties.js +23 -0
  68. package/dist/Tree/Tree.d.ts +20 -0
  69. package/dist/Tree/Tree.js +253 -0
  70. package/dist/Tree/TreeNode.d.ts +20 -0
  71. package/dist/Tree/TreeNode.js +147 -0
  72. package/dist/Tree/index.d.ts +3 -0
  73. package/dist/Tree/index.js +3 -0
  74. package/dist/__consts/theme.d.ts +81 -0
  75. package/dist/__consts/theme.js +88 -0
  76. package/dist/__consts/unit.d.ts +1 -0
  77. package/dist/__consts/unit.js +1 -0
  78. package/dist/__styles/GlobalStyles.d.ts +6 -0
  79. package/dist/__styles/GlobalStyles.js +6 -0
  80. package/dist/__styles/index.d.ts +1 -0
  81. package/dist/__styles/index.js +1 -0
  82. package/dist/index.d.ts +14 -1
  83. package/dist/index.js +14 -1
  84. package/package.json +11 -2
  85. package/dist/Foo/index.d.ts +0 -5
  86. package/dist/Foo/index.js +0 -5
@@ -0,0 +1,243 @@
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
+ var _excluded = ["render"];
3
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
4
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
5
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
6
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
7
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
8
+ 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); }
9
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
10
+ 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."); }
11
+ 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); }
12
+ 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; }
13
+ 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; } }
14
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
15
+ import CaretDownOutlined from '@ant-design/icons/CaretDownOutlined';
16
+ import CaretUpOutlined from '@ant-design/icons/CaretUpOutlined';
17
+ import React, { useCallback, useMemo, useRef, useState } from 'react';
18
+ import styled from 'styled-components';
19
+ import { BoxShadowBox } from "../BoxShadowBox";
20
+ import { Column, Columns } from "../Columns";
21
+ import { DefaultColumnWidth } from "../Columns/Columns";
22
+ import { Col, Row } from "../Grid";
23
+ import { List, ListItem } from "../List";
24
+ import { Pagination } from "../Pagination";
25
+ import { Space } from "../Space";
26
+ var TableContainer = styled.div.withConfig({
27
+ displayName: "TableContainer",
28
+ componentId: "basic-component-347b__sc-12r61fm-0"
29
+ })([""]);
30
+ var TableTitle = styled.h5.withConfig({
31
+ displayName: "TableTitle",
32
+ componentId: "basic-component-347b__sc-12r61fm-1"
33
+ })(["font-weight:600;padding:var(--kep-platform-padding-sm);"]);
34
+ var TableToolbar = styled.div.withConfig({
35
+ displayName: "TableToolbar",
36
+ componentId: "basic-component-347b__sc-12r61fm-2"
37
+ })(["text-align:right;padding:var(--kep-platform-padding-sm);"]);
38
+ var TableHeaderRow = styled(Columns).withConfig({
39
+ displayName: "TableHeaderRow",
40
+ componentId: "basic-component-347b__sc-12r61fm-3"
41
+ })(["border-bottom:var(--kep-platform-line-width) solid var(--kep-platform-color-table-border);& ", "{background-color:var(--kep-platform-header-bg);font-weight:600;position:sticky;&:not(:last-child):after{content:'';width:1px;height:calc(100% - 2 * var(--kep-platform-padding-xs));position:absolute;top:var(--kep-platform-padding-xs);right:0;background-color:var(--kep-platform-color-border-secondary);}}"], Column);
42
+ var TableBody = styled(List).withConfig({
43
+ displayName: "TableBody",
44
+ componentId: "basic-component-347b__sc-12r61fm-4"
45
+ })([""]);
46
+ var TableBodyRow = styled(ListItem).withConfig({
47
+ displayName: "TableBodyRow",
48
+ componentId: "basic-component-347b__sc-12r61fm-5"
49
+ })([""]);
50
+ var TableContent = styled.div.withConfig({
51
+ displayName: "TableContent",
52
+ componentId: "basic-component-347b__sc-12r61fm-6"
53
+ })(["position:relative;overflow:auto;border-radius:var(--kep-platform-border-radius);box-shadow:var(--kep-platform-box-shadow-tertiary);"]);
54
+ var SortIconList = styled(List).withConfig({
55
+ displayName: "SortIconList",
56
+ componentId: "basic-component-347b__sc-12r61fm-7"
57
+ })([""]);
58
+ var SortIconListItem = styled(ListItem).withConfig({
59
+ displayName: "SortIconListItem",
60
+ componentId: "basic-component-347b__sc-12r61fm-8"
61
+ })(["height:10px;line-height:10px;font-size:10px;cursor:pointer;user-select:none;color:", ";"], function (props) {
62
+ return props.active ? 'var(--kep-platform-color-primary)' : 'currentColor';
63
+ });
64
+ var SortIconGroup = function SortIconGroup(_ref) {
65
+ var sorter = _ref.sorter,
66
+ onSorterChange = _ref.onSorterChange,
67
+ hidden = _ref.hidden;
68
+ var onSortIconGroupClickHandler = useCallback(function () {
69
+ switch (sorter) {
70
+ case 'desc':
71
+ onSorterChange === null || onSorterChange === void 0 || onSorterChange();
72
+ break;
73
+ case 'asc':
74
+ onSorterChange === null || onSorterChange === void 0 || onSorterChange('desc');
75
+ break;
76
+ default:
77
+ onSorterChange === null || onSorterChange === void 0 || onSorterChange('asc');
78
+ }
79
+ }, [sorter, onSorterChange]);
80
+ return /*#__PURE__*/React.createElement(SortIconList, {
81
+ direction: "column",
82
+ onClick: onSortIconGroupClickHandler,
83
+ hidden: hidden
84
+ }, /*#__PURE__*/React.createElement(SortIconListItem, {
85
+ active: sorter === 'asc'
86
+ }, /*#__PURE__*/React.createElement(CaretUpOutlined, null)), /*#__PURE__*/React.createElement(SortIconListItem, {
87
+ active: sorter === 'desc'
88
+ }, /*#__PURE__*/React.createElement(CaretDownOutlined, null)));
89
+ };
90
+ var ColumnTitle = styled.div.withConfig({
91
+ displayName: "ColumnTitle",
92
+ componentId: "basic-component-347b__sc-12r61fm-9"
93
+ })([""]);
94
+ var ColumnTitleController = function ColumnTitleController(_ref2) {
95
+ var onSorterChange = _ref2.onSorterChange,
96
+ title = _ref2.title,
97
+ sorterType = _ref2.sorterType,
98
+ hasSorter = _ref2.hasSorter;
99
+ return /*#__PURE__*/React.createElement(ColumnTitle, null, /*#__PURE__*/React.createElement(Space, {
100
+ size: "small"
101
+ }, title, /*#__PURE__*/React.createElement(SortIconGroup, {
102
+ sorter: sorterType,
103
+ onSorterChange: onSorterChange,
104
+ hidden: !hasSorter
105
+ })));
106
+ };
107
+ function sortObjectsByProperty(objects, property, sorterType, func) {
108
+ var sorterOffset = sorterType === 'asc' ? 1 : sorterType === 'desc' ? -1 : 0;
109
+ if (sorterOffset === 0) return objects;
110
+ var sorterFunc = func || function (a, b) {
111
+ if (typeof a[property] === 'number' && typeof b[property] === 'number') {
112
+ return a[property] - b[property];
113
+ } else if (typeof a[property] === 'string' && typeof b[property] === 'string') {
114
+ return a[property].localeCompare(b[property]);
115
+ } else {
116
+ return 0;
117
+ }
118
+ };
119
+ switch (sorterOffset) {
120
+ case 1:
121
+ return objects.slice().sort(sorterFunc);
122
+ case -1:
123
+ return objects.slice().sort(sorterFunc).reverse();
124
+ }
125
+ }
126
+ export default function Table(_ref3) {
127
+ var columns = _ref3.columns,
128
+ dataSource = _ref3.dataSource,
129
+ rowKey = _ref3.rowKey,
130
+ actions = _ref3.actions,
131
+ title = _ref3.title,
132
+ scroll = _ref3.scroll,
133
+ _onChange2 = _ref3.onChange,
134
+ headerRender = _ref3.headerRender,
135
+ _ref3$pagination = _ref3.pagination,
136
+ pagination = _ref3$pagination === void 0 ? {
137
+ current: 1,
138
+ pageSize: 10
139
+ } : _ref3$pagination;
140
+ var _useState = useState(null),
141
+ _useState2 = _slicedToArray(_useState, 2),
142
+ sorterController = _useState2[0],
143
+ setSorterController = _useState2[1];
144
+ var titleRowData = useMemo(function () {
145
+ var data = {};
146
+ columns.forEach(function (column) {
147
+ var dataIndex = column.dataIndex;
148
+ data[dataIndex] = /*#__PURE__*/React.createElement(ColumnTitleController, {
149
+ column: column,
150
+ onSorterChange: function onSorterChange(sorter) {
151
+ var key = column.key;
152
+ _onChange2 === null || _onChange2 === void 0 || _onChange2(undefined, _defineProperty({}, key, sorter), undefined);
153
+ setSorterController({
154
+ columnKey: column.key,
155
+ sorterType: sorter
156
+ });
157
+ },
158
+ title: (headerRender === null || headerRender === void 0 ? void 0 : headerRender(column)) || column.title,
159
+ sorterType: (sorterController === null || sorterController === void 0 ? void 0 : sorterController.columnKey) === column.key ? sorterController === null || sorterController === void 0 ? void 0 : sorterController.sorterType : undefined,
160
+ hasSorter: !!column.sorter
161
+ });
162
+ });
163
+ return data;
164
+ }, [columns, _onChange2, sorterController, setSorterController]);
165
+ var boxShadowBox = useRef(null);
166
+ var headerColumns = useMemo(function () {
167
+ return columns.map(function (column) {
168
+ var render = column.render,
169
+ rest = _objectWithoutProperties(column, _excluded);
170
+ console.log('exclude render', render);
171
+ return rest;
172
+ });
173
+ }, [columns]);
174
+ var scrollLeftOffset = useMemo(function () {
175
+ return columns.reduce(function (pre, current) {
176
+ return pre + (current.hideInTable ? 0 : current.fixed === 'left' ? current.width || DefaultColumnWidth : 0);
177
+ }, 0);
178
+ }, [columns]);
179
+ var formatedDataSource = useMemo(function () {
180
+ if (sorterController && sorterController.sorterType !== undefined) {
181
+ var sortedColumn = columns.find(function (column) {
182
+ return column.key === sorterController.columnKey;
183
+ });
184
+ var sorterFunc = typeof (sortedColumn === null || sortedColumn === void 0 ? void 0 : sortedColumn.sorter) === 'function' ? sortedColumn.sorter : undefined;
185
+ return sortObjectsByProperty(dataSource, sorterController.columnKey, sorterController.sorterType, sorterFunc);
186
+ }
187
+ return dataSource;
188
+ }, [sorterController, dataSource, columns]);
189
+ return /*#__PURE__*/React.createElement(TableContainer, null, /*#__PURE__*/React.createElement(Row, null, /*#__PURE__*/React.createElement(Col, {
190
+ span: 8
191
+ }, /*#__PURE__*/React.createElement(TableTitle, null, title)), /*#__PURE__*/React.createElement(Col, {
192
+ span: 16
193
+ }, /*#__PURE__*/React.createElement(TableToolbar, null, /*#__PURE__*/React.createElement(Space, null, actions === null || actions === void 0 ? void 0 : actions.map(function (element) {
194
+ if ( /*#__PURE__*/React.isValidElement(element)) {
195
+ var action = element;
196
+ return /*#__PURE__*/React.cloneElement(action, {
197
+ size: 'default'
198
+ });
199
+ } else {
200
+ return element;
201
+ }
202
+ }))))), /*#__PURE__*/React.createElement(TableContent, {
203
+ onScroll: function onScroll(e) {
204
+ var tableContainer = e.target;
205
+ if (boxShadowBox.current) {
206
+ if (tableContainer.scrollLeft === 0) {
207
+ boxShadowBox.current.style.opacity = '0';
208
+ } else {
209
+ boxShadowBox.current.style.opacity = '1';
210
+ }
211
+ boxShadowBox.current.style.left = tableContainer.scrollLeft + scrollLeftOffset + 'px';
212
+ }
213
+ }
214
+ }, scroll && /*#__PURE__*/React.createElement(BoxShadowBox, {
215
+ ref: boxShadowBox,
216
+ width: "10px",
217
+ height: "100%",
218
+ offsetLeft: "-999px"
219
+ }), /*#__PURE__*/React.createElement(TableHeaderRow, {
220
+ columns: headerColumns,
221
+ rowData: titleRowData,
222
+ isFlex: !scroll
223
+ }), /*#__PURE__*/React.createElement(TableBody, {
224
+ direction: "column"
225
+ }, formatedDataSource.map(function (rowData) {
226
+ return /*#__PURE__*/React.createElement(TableBodyRow, {
227
+ key: rowData[rowKey]
228
+ }, /*#__PURE__*/React.createElement(Columns, {
229
+ rowData: rowData,
230
+ columns: columns,
231
+ isFlex: !scroll
232
+ }));
233
+ }))), /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement(Pagination, _extends({}, pagination, {
234
+ total: pagination.total || dataSource.length,
235
+ justifyContent: "right",
236
+ onChange: function onChange(current, pageSize) {
237
+ _onChange2 === null || _onChange2 === void 0 || _onChange2({
238
+ current: current,
239
+ pageSize: pageSize
240
+ });
241
+ }
242
+ })));
243
+ }
@@ -0,0 +1 @@
1
+ export { default as Table, type TableProps } from './Table';
@@ -0,0 +1 @@
1
+ export { default as Table } from "./Table";
@@ -0,0 +1,7 @@
1
+ import React, { ReactNode } from 'react';
2
+ export type TagProps = {
3
+ children: ReactNode;
4
+ color: string;
5
+ };
6
+ declare const Tag: React.FC<TagProps>;
7
+ export default Tag;
@@ -0,0 +1,16 @@
1
+ var _excluded = ["children"];
2
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
3
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
4
+ import React from 'react';
5
+ import styled from 'styled-components';
6
+ import theme from "../__consts/theme";
7
+ var StyledTag = styled.span.withConfig({
8
+ displayName: "StyledTag",
9
+ componentId: "basic-component-347b__sc-14fuyeq-0"
10
+ })(["background-color:", ";color:1px soild ", ";"], theme.defaultTagBackgroundColor, theme.defaultTagColor);
11
+ var Tag = function Tag(_ref) {
12
+ var children = _ref.children,
13
+ rest = _objectWithoutProperties(_ref, _excluded);
14
+ return /*#__PURE__*/React.createElement(StyledTag, rest, children);
15
+ };
16
+ export default Tag;
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ declare const _default: () => React.JSX.Element;
3
+ export default _default;
@@ -0,0 +1,111 @@
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+ 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."); }
3
+ 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); }
4
+ 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; }
5
+ 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; } }
6
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
+ import { GlobalStyles, Tree } from "./..";
8
+ import React, { useState } from 'react';
9
+ import styled from 'styled-components';
10
+ var Title = styled.div.withConfig({
11
+ displayName: "Title",
12
+ componentId: "basic-component-347b__sc-klaw2r-0"
13
+ })(["width:100%;text-align:center;"]);
14
+ export default (function () {
15
+ var _useState = useState([]),
16
+ _useState2 = _slicedToArray(_useState, 2),
17
+ selectedKeys = _useState2[0],
18
+ setSelectedKeys = _useState2[1];
19
+ var _useState3 = useState([]),
20
+ _useState4 = _slicedToArray(_useState3, 2),
21
+ expandedKeys = _useState4[0],
22
+ setExpandedKeys = _useState4[1];
23
+ var treeData = [{
24
+ key: '1',
25
+ title: 'jss',
26
+ count: 1,
27
+ children: [{
28
+ key: '4',
29
+ title: 'skjdfkljasklfjkljdsklajfkl就是要长一的点点滴滴的点点滴滴哒哒哒哒哒哒哒哒哒哒哒哒哒哒',
30
+ children: []
31
+ }, {
32
+ key: '5',
33
+ title: 567,
34
+ children: []
35
+ }, {
36
+ key: '6',
37
+ title: 789,
38
+ children: []
39
+ }]
40
+ }, {
41
+ key: '2121212121212',
42
+ title: '2',
43
+ count: 1,
44
+ children: []
45
+ }, {
46
+ key: '3',
47
+ title: 'jss',
48
+ name: 'jss',
49
+ children: [],
50
+ count: 2
51
+ }, {
52
+ key: '10',
53
+ title: 'jss',
54
+ name: 'jss',
55
+ children: [],
56
+ count: 2
57
+ }, {
58
+ key: '20',
59
+ title: '3',
60
+ children: [],
61
+ count: 2
62
+ }];
63
+ var columns = [{
64
+ key: 'key',
65
+ title: '键值',
66
+ dataIndex: 'key',
67
+ align: 'center',
68
+ width: 400,
69
+ fixed: 'left'
70
+ }, {
71
+ key: 'name',
72
+ title: '姓名',
73
+ dataIndex: 'name',
74
+ align: 'center'
75
+ }, {
76
+ key: 'count',
77
+ title: '数量',
78
+ dataIndex: 'count',
79
+ align: 'center'
80
+ }];
81
+ var contextMenuRender = function contextMenuRender(node) {
82
+ return [{
83
+ key: 'delete',
84
+ label: "\u5220\u9664 node".concat(node.key)
85
+ }, {
86
+ key: 'add',
87
+ label: '新增'
88
+ }, {
89
+ key: 'edit',
90
+ label: '编辑'
91
+ }];
92
+ };
93
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(GlobalStyles, {
94
+ $css: []
95
+ }), /*#__PURE__*/React.createElement(Tree, {
96
+ title: /*#__PURE__*/React.createElement(Title, null, "\u6807\u8BC6"),
97
+ titleWidth: 400,
98
+ contextMenuRender: contextMenuRender,
99
+ treeData: treeData,
100
+ columns: columns,
101
+ selectedKeys: selectedKeys,
102
+ expandedKeys: expandedKeys,
103
+ onSelect: function onSelect(selectedKeys) {
104
+ return setSelectedKeys(selectedKeys);
105
+ },
106
+ onExpand: function onExpand(expandedKeys) {
107
+ return setExpandedKeys(expandedKeys);
108
+ },
109
+ groupBy: "count"
110
+ }));
111
+ });
@@ -0,0 +1,12 @@
1
+ import React, { ReactNode } from 'react';
2
+ export declare const MainArea: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<Omit<import("styled-components").FastOmit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof React.HtmlHTMLAttributes<HTMLDivElement> | keyof import("../Flex").FlexItemProps> & import("../Flex").FlexItemProps & React.HtmlHTMLAttributes<HTMLDivElement>, "ref"> & {
3
+ ref?: ((instance: HTMLDivElement | null) => void) | React.RefObject<HTMLDivElement> | null | undefined;
4
+ }, never>> & string;
5
+ type MainPropertyProps = {
6
+ mainWidth?: number;
7
+ main: ReactNode;
8
+ property?: ReactNode;
9
+ isFlex: boolean;
10
+ };
11
+ export declare const MainProperty: React.FC<MainPropertyProps>;
12
+ export {};
@@ -0,0 +1,23 @@
1
+ import React from 'react';
2
+ import styled from 'styled-components';
3
+ import { Flex, FlexItem } from "../Flex";
4
+ export var MainArea = styled(FlexItem).withConfig({
5
+ displayName: "MainArea",
6
+ componentId: "basic-component-347b__sc-u1pspr-0"
7
+ })(["overflow:hidden;position:sticky;left:0;z-index:20;align-self:stretch;display:flex;align-items:center;border-right:var(--kep-platform-line-width) var(--kep-platform-line-type) var(--kep-platform-color-border-secondary);border-bottom:var(--kep-platform-line-width) var(--kep-platform-line-type) var(--kep-platform-color-border-secondary);"]);
8
+ var PropertiesArea = styled(FlexItem).withConfig({
9
+ displayName: "PropertiesArea",
10
+ componentId: "basic-component-347b__sc-u1pspr-1"
11
+ })([""]);
12
+ /* 有属性就渲染属性,没有属性就不处理 */
13
+ export var MainProperty = function MainProperty(_ref) {
14
+ var mainWidth = _ref.mainWidth,
15
+ main = _ref.main,
16
+ property = _ref.property,
17
+ isFlex = _ref.isFlex;
18
+ if (property) return /*#__PURE__*/React.createElement(Flex, null, /*#__PURE__*/React.createElement(MainArea, {
19
+ width: mainWidth
20
+ }, main), /*#__PURE__*/React.createElement(PropertiesArea, {
21
+ flex: isFlex ? 1 : undefined
22
+ }, property));else return main;
23
+ };
@@ -0,0 +1,20 @@
1
+ import React, { Key, ReactNode } from 'react';
2
+ export type TreeProps = {
3
+ treeData: TreeNodeType[];
4
+ expandedKeys?: Key[];
5
+ selectedKeys?: Key[];
6
+ fieldNames?: TreeFieldNames;
7
+ multiple?: boolean;
8
+ columns?: ColumnType[];
9
+ titleRender?: ((node: TreeNodeType) => ReactNode | null) | null | undefined;
10
+ onExpand?: onExpandHandler;
11
+ onSelect?: onSelectHandler;
12
+ contextMenuRender: (node: TreeNodeType) => MenuItem[];
13
+ titleWidth?: number;
14
+ title?: ReactNode;
15
+ isFlex?: boolean;
16
+ bordered?: boolean;
17
+ groupBy?: string | null;
18
+ };
19
+ declare const Tree: React.FC<TreeProps>;
20
+ export default Tree;