yootd 0.2.20 → 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.
@@ -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.20",
3
+ "version": "0.2.21",
4
4
  "description": "基于 Antd 二次开发的组件库",
5
5
  "license": "MIT",
6
6
  "module": "dist/index.js",