@lemon-fe/components 0.1.140 → 0.1.145

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.
@@ -14,18 +14,48 @@ import React, { useState } from 'react';
14
14
  import classNames from 'classnames';
15
15
  import { Spin, Tabs } from 'antd';
16
16
  import { get } from 'lodash';
17
+ import { Resizable } from 'react-resizable';
17
18
  import { PREFIX_CLS } from '../constants';
18
19
  import { mapChildren } from '../utils';
19
20
  var prefixCls = "".concat(PREFIX_CLS, "-layout");
20
21
  function Sider(props) {
22
+ var _classNames;
21
23
  var children = props.children,
22
24
  onCollapse = props.onCollapse;
23
- var _useState = useState(false),
25
+ var _useState = useState(242),
24
26
  _useState2 = _slicedToArray(_useState, 2),
25
- collapsed = _useState2[0],
26
- setCollapsed = _useState2[1];
27
- return /*#__PURE__*/React.createElement("div", {
28
- className: classNames("".concat(prefixCls, "-left"), _defineProperty({}, "".concat(prefixCls, "-left-collapsed"), collapsed))
27
+ width = _useState2[0],
28
+ setWidth = _useState2[1];
29
+ var _useState3 = useState(false),
30
+ _useState4 = _slicedToArray(_useState3, 2),
31
+ collapsed = _useState4[0],
32
+ setCollapsed = _useState4[1];
33
+ var _useState5 = useState(false),
34
+ _useState6 = _slicedToArray(_useState5, 2),
35
+ dragging = _useState6[0],
36
+ setDragging = _useState6[1];
37
+ var viewWidth = collapsed ? 0 : width;
38
+ return /*#__PURE__*/React.createElement(Resizable, {
39
+ axis: "x",
40
+ width: width,
41
+ height: 0,
42
+ onResizeStart: function onResizeStart() {
43
+ setDragging(true);
44
+ },
45
+ onResizeStop: function onResizeStop() {
46
+ setDragging(false);
47
+ },
48
+ onResize: function onResize(_, data) {
49
+ setWidth(data.size.width);
50
+ },
51
+ handle: /*#__PURE__*/React.createElement("div", {
52
+ className: "".concat(prefixCls, "-left-resizable")
53
+ })
54
+ }, /*#__PURE__*/React.createElement("div", {
55
+ className: classNames("".concat(prefixCls, "-left"), (_classNames = {}, _defineProperty(_classNames, "".concat(prefixCls, "-left-collapsed"), collapsed), _defineProperty(_classNames, "".concat(prefixCls, "-left-resizing"), dragging), _classNames)),
56
+ style: {
57
+ width: viewWidth
58
+ }
29
59
  }, /*#__PURE__*/React.createElement("div", {
30
60
  className: "".concat(prefixCls, "-left-body")
31
61
  }, /*#__PURE__*/React.createElement("div", {
@@ -78,7 +108,7 @@ function Sider(props) {
78
108
  strokeLinejoin: "round",
79
109
  strokeDasharray: "0,0",
80
110
  transform: "translate(2.828427, 2.121320) rotate(-45.000000) translate(-2.828427, -2.121320) "
81
- }))))))));
111
+ })))))))));
82
112
  }
83
113
  function Content(props) {
84
114
  var left = props.left,
@@ -40,29 +40,33 @@
40
40
  &-left {
41
41
  position: relative;
42
42
 
43
+ &:not(&-resizing) {
44
+ transition: width 0.2s;
45
+ }
46
+
43
47
  &-body {
44
- width: 242px;
45
48
  height: 100%;
46
49
  overflow-x: hidden;
47
- transition: width 0.2s;
48
50
  }
49
51
 
50
52
  &-content {
51
53
  position: relative;
52
54
  display: flex;
53
55
  flex-direction: column;
54
- width: 242px;
55
56
  height: 100%;
57
+ }
56
58
 
57
- &::after {
58
- position: absolute;
59
- top: 0;
60
- right: 0;
61
- width: 1px;
62
- height: 100%;
63
- background-color: #e6e6e6;
64
- content: '';
65
- }
59
+ &-resizable {
60
+ position: absolute;
61
+ top: 0;
62
+ right: -8px;
63
+ box-sizing: border-box;
64
+ width: 17px;
65
+ height: 100%;
66
+ padding: 0 8px;
67
+ background-color: #e6e6e6;
68
+ background-clip: content-box;
69
+ cursor: col-resize;
66
70
  }
67
71
 
68
72
  &-collapse {
@@ -45,5 +45,10 @@ interface Props<RecordType, ParamsType extends Record<string, any>> {
45
45
  } & FilterProps<ParamsType>;
46
46
  rowSelection?: TableRowSelection<RecordType>;
47
47
  }
48
- export default function SelectView<RecordType extends Record<string | number, any>, ParamsType extends Record<string, any>>(props: Props<RecordType, ParamsType>): JSX.Element;
49
- export {};
48
+ export interface SelectViewRef {
49
+ fetch: (page?: number) => void;
50
+ }
51
+ declare const _default: <RecordType extends Record<string | number, any>, ParamsType extends Record<string, any>>(props: Props<RecordType, ParamsType> & {
52
+ ref?: SelectViewRef | undefined;
53
+ }) => JSX.Element;
54
+ export default _default;
@@ -11,13 +11,13 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
11
11
  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; }
12
12
  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; }
13
13
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
14
- import React, { useEffect, useMemo, useRef, useState } from 'react';
14
+ import React, { forwardRef, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
15
15
  import { Tabs, Button } from 'antd';
16
16
  import { get } from 'lodash';
17
17
  import Filter from '../Filter';
18
18
  import Table from '../Table';
19
19
  import { PREFIX_CLS } from '../constants';
20
- export default function SelectView(props) {
20
+ function SelectView(props, ref) {
21
21
  var value = props.value,
22
22
  onChange = props.onChange,
23
23
  columns = props.columns,
@@ -44,13 +44,23 @@ export default function SelectView(props) {
44
44
  _useState6 = _slicedToArray(_useState5, 2),
45
45
  tabFlag = _useState6[0],
46
46
  setTabFlag = _useState6[1];
47
- useEffect(function () {
47
+ var refreshList = function refreshList(page) {
48
48
  var _list$current;
49
- (_list$current = list.current) === null || _list$current === void 0 ? void 0 : _list$current.fetch();
49
+ (_list$current = list.current) === null || _list$current === void 0 ? void 0 : _list$current.fetch(page);
50
+ };
51
+ useEffect(function () {
52
+ refreshList();
50
53
  }, [params]);
51
54
  useEffect(function () {
52
55
  setData(value || []);
53
56
  }, [value]);
57
+ useImperativeHandle(ref, function () {
58
+ return {
59
+ fetch: function fetch(page) {
60
+ return refreshList(page);
61
+ }
62
+ };
63
+ }, []);
54
64
  var getRowKey = function getRowKey(item) {
55
65
  if (typeof rowKey === 'function') {
56
66
  return rowKey(item);
@@ -211,4 +221,5 @@ export default function SelectView(props) {
211
221
  return /*#__PURE__*/React.createElement("div", {
212
222
  className: prefixCls
213
223
  }, content);
214
- }
224
+ }
225
+ export default /*#__PURE__*/forwardRef(SelectView);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lemon-fe/components",
3
- "version": "0.1.140",
3
+ "version": "0.1.145",
4
4
  "description": "> TODO: description",
5
5
  "author": "鲁盛杰 <lusj@cnlemon.net>",
6
6
  "homepage": "",
@@ -16,7 +16,7 @@
16
16
  "registry": "https://registry.npmjs.org"
17
17
  },
18
18
  "dependencies": {
19
- "@lemon-fe/hooks": "^0.1.140",
19
+ "@lemon-fe/hooks": "^0.1.142",
20
20
  "classnames": "^2.2.6",
21
21
  "color-string": "^1.9.0",
22
22
  "lodash": "^4.17.0",
@@ -39,5 +39,5 @@
39
39
  "react": "^17.0.2",
40
40
  "react-dom": "^17.0.2"
41
41
  },
42
- "gitHead": "99cc7a85d28b2380ee970ff1f616fe1f77b44259"
42
+ "gitHead": "aa14d0c951acdc5db1bd2246dfb4bf6200bf845d"
43
43
  }