yootd 0.2.19 → 0.2.21

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.
@@ -34,7 +34,11 @@ var SortableItem = function SortableItem(_ref) {
34
34
  subId = _ref.subId,
35
35
  isSubNode = _ref.isSubNode,
36
36
  subNode = _ref.subNode,
37
- onSubClick = _ref.onSubClick;
37
+ onSubClick = _ref.onSubClick,
38
+ _ref$showEditBtn = _ref.showEditBtn,
39
+ showEditBtn = _ref$showEditBtn === void 0 ? true : _ref$showEditBtn,
40
+ _ref$showDelBtn = _ref.showDelBtn,
41
+ showDelBtn = _ref$showDelBtn === void 0 ? true : _ref$showDelBtn;
38
42
  var _useSortable = useSortable({
39
43
  id: id
40
44
  }),
@@ -44,7 +48,6 @@ var SortableItem = function SortableItem(_ref) {
44
48
  transform = _useSortable.transform,
45
49
  transition = _useSortable.transition,
46
50
  isDragging = _useSortable.isDragging;
47
- console.log(statusColor[status !== null && status !== void 0 ? status : '']);
48
51
  var style = _objectSpread({
49
52
  transform: CSS.Transform.toString(transform),
50
53
  transition: transition
@@ -92,11 +95,13 @@ var SortableItem = function SortableItem(_ref) {
92
95
  marginLeft: dragBtnIcon ? '6px' : '0'
93
96
  }
94
97
  }, title))), /*#__PURE__*/React.createElement("div", {
98
+ className: "".concat(top.b('top-right'))
99
+ }, /*#__PURE__*/React.createElement("div", {
95
100
  className: "".concat(top.b('top-middle')),
96
101
  style: {
97
102
  marginLeft: editBtnIcon || delBtnIcon ? '12px' : 0
98
103
  }
99
- }, /*#__PURE__*/React.createElement("div", {
104
+ }, showEditBtn ? /*#__PURE__*/React.createElement("div", {
100
105
  className: "".concat(top.b('top-middle').b('top-edit-btn-icon')),
101
106
  style: {
102
107
  opacity: id === activeKey ? 1 : 0,
@@ -117,7 +122,7 @@ var SortableItem = function SortableItem(_ref) {
117
122
  }
118
123
  }, /*#__PURE__*/React.createElement(EditBtnIcon, {
119
124
  className: "".concat(top.b('top-middle').b('top-edit-btn-icon').e('edit-btn-icon-svg'))
120
- })), /*#__PURE__*/React.createElement("div", {
125
+ })) : null, showDelBtn ? /*#__PURE__*/React.createElement("div", {
121
126
  className: "".concat(top.b('top-middle').b('top-del-btn-icon')),
122
127
  style: {
123
128
  opacity: id === activeKey ? 1 : 0,
@@ -138,7 +143,7 @@ var SortableItem = function SortableItem(_ref) {
138
143
  }
139
144
  }, /*#__PURE__*/React.createElement(DelBtnIcon, {
140
145
  className: "".concat(top.b('top-middle').b('top-del-btn-icon').e('del-btn-icon-svg'))
141
- }))), /*#__PURE__*/React.createElement("div", {
146
+ })) : null), /*#__PURE__*/React.createElement("div", {
142
147
  style: {
143
148
  display: switchBtnIcon ? 'block' : 'none',
144
149
  marginLeft: switchBtnIcon ? '12px' : '0'
@@ -152,7 +157,7 @@ var SortableItem = function SortableItem(_ref) {
152
157
  onChange: function onChange(e) {
153
158
  onSwitch === null || onSwitch === void 0 || onSwitch(id, e);
154
159
  }
155
- }))), /*#__PURE__*/React.createElement("div", {
160
+ })))), /*#__PURE__*/React.createElement("div", {
156
161
  className: "".concat(mb.b('content').b('bottom')),
157
162
  style: {
158
163
  marginLeft: dragBtnIcon ? '22px' : '0'
@@ -54,6 +54,9 @@
54
54
  }
55
55
  }
56
56
  }
57
+ &-top-right {
58
+ display: flex;
59
+ }
57
60
  }
58
61
  &-bottom {
59
62
  text-overflow: ellipsis;
@@ -100,11 +103,12 @@
100
103
  -webkit-line-clamp: 2; //超出2行隐藏,并显示省略号
101
104
  line-clamp: 2;
102
105
  }
103
- &__top-title-active{
106
+ &__top-title-active {
104
107
  font-weight: bold;
105
108
  }
106
109
  }
107
110
  }
111
+
108
112
  &-top-middle {
109
113
  display: flex;
110
114
  align-items: center;
@@ -150,7 +154,7 @@
150
154
  background-color: #e5e5e5;
151
155
  z-index: 100;
152
156
  }
153
- &-content-no-bg::before{
157
+ &-content-no-bg::before {
154
158
  content: '';
155
159
  position: absolute;
156
160
  bottom: -0.5px;
@@ -194,7 +198,7 @@
194
198
  box-sizing: border-box;
195
199
  cursor: pointer;
196
200
  background-color: #fff;
197
- border-bottom:1 px solid ;
201
+ border-bottom: 1 px solid;
198
202
  &-top {
199
203
  display: flex;
200
204
  justify-content: space-between;
@@ -231,7 +231,9 @@ export var Aside = function Aside(_ref) {
231
231
  status: item.status,
232
232
  subId: subKey !== null && subKey !== void 0 ? subKey : (_item$children = item.children) === null || _item$children === void 0 || (_item$children = _item$children[0]) === null || _item$children === void 0 ? void 0 : _item$children.key,
233
233
  isSubNode: isSubNode,
234
- subNode: item.children
234
+ subNode: item.children,
235
+ showDelBtn: item.showDelBtn,
236
+ showEditBtn: item.showEditBtn
235
237
  });
236
238
  })))));
237
239
  };
@@ -6,6 +6,8 @@ type IdataItem = {
6
6
  checked?: boolean;
7
7
  status?: string;
8
8
  data?: any;
9
+ showEditBtn?: boolean;
10
+ showDelBtn?: boolean;
9
11
  children?: Array<{
10
12
  key: string;
11
13
  title: string;
@@ -13,6 +15,8 @@ type IdataItem = {
13
15
  checked?: boolean;
14
16
  status?: string;
15
17
  data?: any;
18
+ showEditBtn?: boolean;
19
+ showDelBtn?: boolean;
16
20
  }>;
17
21
  };
18
22
  export type AsideProps = {
@@ -56,6 +60,8 @@ export type AsideItemProps = {
56
60
  extra?: string;
57
61
  status?: string;
58
62
  data?: any;
63
+ showEditBtn?: boolean;
64
+ showDelBtn?: boolean;
59
65
  onClick?: (key: string | undefined, e: IdataItem) => void;
60
66
  onEdit?: (key: string, e: IdataItem) => void;
61
67
  onDel?: (key: string, e: IdataItem) => void;
@@ -69,6 +75,8 @@ export type AsideItemProps = {
69
75
  checked?: boolean;
70
76
  status?: string;
71
77
  data?: any;
78
+ showEditBtn?: boolean;
79
+ showDelBtn?: boolean;
72
80
  }>;
73
81
  onSubClick?: (key, subKey: string | undefined, e: IdataItem) => void;
74
82
  };
@@ -1,4 +1,14 @@
1
1
  import React from 'react';
2
- import { TreeProps } from "../..";
3
- declare const App: React.FC<TreeProps>;
4
- export default App;
2
+ import { TreeRefProps } from "../..";
3
+ declare const DeptTree: React.ForwardRefExoticComponent<import("antd").TreeProps<import("antd").TreeDataNode> & {
4
+ showChildNumbers?: boolean | undefined;
5
+ placeholder?: string | undefined;
6
+ showSearch?: boolean | undefined;
7
+ type?: string | undefined;
8
+ depth?: number | undefined;
9
+ notRequireSchool?: boolean | undefined;
10
+ areaType?: number | undefined;
11
+ areaSubType?: number | undefined;
12
+ requireLastLevel?: boolean | undefined;
13
+ } & React.RefAttributes<TreeRefProps>>;
14
+ export default DeptTree;
@@ -1,10 +1,10 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectDestructuringEmpty from "@babel/runtime/helpers/esm/objectDestructuringEmpty";
3
3
  import { useQuery } from '@tanstack/react-query';
4
- import React, { useMemo } from 'react';
4
+ import React, { forwardRef, useImperativeHandle, useMemo } from 'react';
5
5
  import { Tree } from "../..";
6
6
  import { useRequest } from "../../hooks/useRequest";
7
- var App = function App(_ref) {
7
+ var DeptTree = /*#__PURE__*/forwardRef(function (_ref, ref) {
8
8
  var props = Object.assign({}, (_objectDestructuringEmpty(_ref), _ref));
9
9
  var request = useRequest();
10
10
  var _useQuery = useQuery({
@@ -19,7 +19,8 @@ var App = function App(_ref) {
19
19
  });
20
20
  }
21
21
  }),
22
- queryDepts = _useQuery.data;
22
+ queryDepts = _useQuery.data,
23
+ refetch = _useQuery.refetch;
23
24
  var treeData = useMemo(function () {
24
25
  if (queryDepts !== null && queryDepts !== void 0 && queryDepts.content) {
25
26
  var jsonStr = JSON.stringify(queryDepts.content);
@@ -27,9 +28,16 @@ var App = function App(_ref) {
27
28
  return JSON.parse(formatted);
28
29
  }
29
30
  }, [queryDepts]);
31
+ useImperativeHandle(ref, function () {
32
+ return {
33
+ refetchData: function refetchData() {
34
+ refetch();
35
+ }
36
+ };
37
+ });
30
38
  return /*#__PURE__*/React.createElement(Tree, _extends({
31
39
  treeData: treeData,
32
40
  showIcon: true
33
41
  }, props));
34
- };
35
- export default App;
42
+ });
43
+ export default DeptTree;
@@ -1,4 +1,14 @@
1
1
  import React from 'react';
2
- import { TreeProps } from "../..";
3
- declare const App: React.FC<TreeProps>;
4
- export default App;
2
+ import { TreeRefProps } from "../..";
3
+ declare const SpaceTree: React.ForwardRefExoticComponent<import("antd").TreeProps<import("antd").TreeDataNode> & {
4
+ showChildNumbers?: boolean | undefined;
5
+ placeholder?: string | undefined;
6
+ showSearch?: boolean | undefined;
7
+ type?: string | undefined;
8
+ depth?: number | undefined;
9
+ notRequireSchool?: boolean | undefined;
10
+ areaType?: number | undefined;
11
+ areaSubType?: number | undefined;
12
+ requireLastLevel?: boolean | undefined;
13
+ } & React.RefAttributes<TreeRefProps>>;
14
+ export default SpaceTree;
@@ -2,10 +2,10 @@ import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
3
  var _excluded = ["depth", "notRequireSchool", "areaType", "areaSubType", "requireLastLevel"];
4
4
  import { useQuery } from '@tanstack/react-query';
5
- import React, { useMemo } from 'react';
5
+ import React, { forwardRef, useImperativeHandle, useMemo } from 'react';
6
6
  import { Tree } from "../..";
7
7
  import { useRequest } from "../../hooks/useRequest";
8
- var App = function App(_ref) {
8
+ var SpaceTree = /*#__PURE__*/forwardRef(function (_ref, ref) {
9
9
  var depth = _ref.depth,
10
10
  notRequireSchool = _ref.notRequireSchool,
11
11
  areaType = _ref.areaType,
@@ -31,7 +31,8 @@ var App = function App(_ref) {
31
31
  });
32
32
  }
33
33
  }),
34
- queryAreas = _useQuery.data;
34
+ queryAreas = _useQuery.data,
35
+ refetch = _useQuery.refetch;
35
36
  var treeData = useMemo(function () {
36
37
  if (queryAreas !== null && queryAreas !== void 0 && queryAreas.content) {
37
38
  var jsonStr = JSON.stringify(queryAreas.content);
@@ -39,11 +40,18 @@ var App = function App(_ref) {
39
40
  return JSON.parse(formatted);
40
41
  }
41
42
  }, [queryAreas]);
43
+ useImperativeHandle(ref, function () {
44
+ return {
45
+ refetchData: function refetchData() {
46
+ refetch();
47
+ }
48
+ };
49
+ });
42
50
  return /*#__PURE__*/React.createElement(Tree, _extends({
43
51
  treeData: treeData,
44
52
  showIcon: true
45
53
  }, props, {
46
54
  notRequireSchool: notRequireSchool
47
55
  }));
48
- };
49
- export default App;
56
+ });
57
+ export default SpaceTree;
@@ -1,3 +1,15 @@
1
- import { FC } from 'react';
2
- import { TreeProps } from "..";
3
- export declare const BusinessTree: FC<TreeProps>;
1
+ import React from 'react';
2
+ export interface TreeRefProps {
3
+ refetchData: () => void;
4
+ }
5
+ export declare const BusinessTree: React.ForwardRefExoticComponent<import("antd").TreeProps<import("antd").TreeDataNode> & {
6
+ showChildNumbers?: boolean | undefined;
7
+ placeholder?: string | undefined;
8
+ showSearch?: boolean | undefined;
9
+ type?: string | undefined;
10
+ depth?: number | undefined;
11
+ notRequireSchool?: boolean | undefined;
12
+ areaType?: number | undefined;
13
+ areaSubType?: number | undefined;
14
+ requireLastLevel?: boolean | undefined;
15
+ } & React.RefAttributes<TreeRefProps>>;
@@ -1,15 +1,19 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
3
  var _excluded = ["type"];
4
- import React from 'react';
4
+ import React, { forwardRef } from 'react';
5
5
  import Departments from "./components/dept";
6
6
  import Space from "./components/space";
7
- export var BusinessTree = function BusinessTree(_ref) {
7
+ export var BusinessTree = /*#__PURE__*/forwardRef(function (_ref, ref) {
8
8
  var type = _ref.type,
9
9
  props = _objectWithoutProperties(_ref, _excluded);
10
10
  return /*#__PURE__*/React.createElement(React.Fragment, null, type === 'dept' ? /*#__PURE__*/React.createElement(Departments, _extends({
11
11
  type: type
12
- }, props)) : null, type === 'area' ? /*#__PURE__*/React.createElement(Space, _extends({
12
+ }, props, {
13
+ ref: ref
14
+ })) : null, type === 'area' ? /*#__PURE__*/React.createElement(Space, _extends({
13
15
  type: type
14
- }, props)) : null);
15
- };
16
+ }, props, {
17
+ ref: ref
18
+ })) : null);
19
+ });
package/dist/index.d.ts CHANGED
@@ -70,6 +70,7 @@ export { ApprovalProcess } from './approval-process';
70
70
  export { State } from './state';
71
71
  export type { StateProps } from './state';
72
72
  export { BusinessTree } from './business-tree';
73
+ export type { TreeRefProps } from './business-tree';
73
74
  export { Table } from './table';
74
75
  export type { ColumnGroupProps, ColumnProps, TableProps } from './table';
75
76
  export { Typography } from './typography';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yootd",
3
- "version": "0.2.19",
3
+ "version": "0.2.21",
4
4
  "description": "基于 Antd 二次开发的组件库",
5
5
  "license": "MIT",
6
6
  "module": "dist/index.js",