xh-lab-rc 0.0.1

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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,40 @@
1
+ # xh-lab-rc
2
+
3
+ [![NPM version](https://img.shields.io/npm/v/xh-lab-rc.svg?style=flat)](https://npmjs.org/package/xh-lab-rc)
4
+ [![NPM downloads](http://img.shields.io/npm/dm/xh-lab-rc.svg?style=flat)](https://npmjs.org/package/xh-lab-rc)
5
+
6
+ 杏和-实验室管理通用方法库-广州团队(WEB)
7
+
8
+ ## Usage
9
+
10
+ TODO
11
+
12
+ ## Options
13
+
14
+ TODO
15
+
16
+ ## Development
17
+
18
+ ```bash
19
+ # install dependencies
20
+ $ pnpm install
21
+
22
+ # develop library by docs demo
23
+ $ pnpm start
24
+
25
+ # build library source code
26
+ $ pnpm run build
27
+
28
+ # build library source code in watch mode
29
+ $ pnpm run build:watch
30
+
31
+ # build docs
32
+ $ pnpm run docs:build
33
+
34
+ # check your project for potential problems
35
+ $ pnpm run doctor
36
+ ```
37
+
38
+ ## LICENSE
39
+
40
+ MIT
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import './style.less';
3
+ interface indexProps {
4
+ /**值发生变化时触发的事件 */
5
+ onSelect?: (value: any, node: any) => void;
6
+ defaultValue?: string;
7
+ treeData?: any;
8
+ placeholder?: string;
9
+ fieldNames?: object;
10
+ treeNodeFilterProp?: string;
11
+ treeDefaultExpandAll?: boolean;
12
+ style?: object;
13
+ }
14
+ declare const GTreeSelect: ({ defaultValue, treeData, onSelect, style, placeholder, ...restProps }: indexProps) => React.JSX.Element;
15
+ export default GTreeSelect;
@@ -0,0 +1,75 @@
1
+ var _excluded = ["defaultValue", "treeData", "onSelect", "style", "placeholder"];
2
+ 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); }
3
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
4
+ 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."); }
5
+ 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); }
6
+ 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; }
7
+ 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; } }
8
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
9
+ 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; }
10
+ 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; }
11
+ /*
12
+ * @Author: xqy
13
+ * @Date: 2024-03-19 14:07:55
14
+ * @LastEditors: xqy
15
+ * @LastEditTime: 2024-03-25 17:21:49
16
+ * @Description:
17
+ */
18
+ import React, { useEffect, useState } from 'react';
19
+ import { TreeSelect } from 'antd';
20
+ import "./style.less";
21
+ var GTreeSelect = function GTreeSelect(_ref) {
22
+ var defaultValue = _ref.defaultValue,
23
+ _ref$treeData = _ref.treeData,
24
+ treeData = _ref$treeData === void 0 ? [] : _ref$treeData,
25
+ onSelect = _ref.onSelect,
26
+ _ref$style = _ref.style,
27
+ style = _ref$style === void 0 ? {
28
+ width: '100%'
29
+ } : _ref$style,
30
+ _ref$placeholder = _ref.placeholder,
31
+ placeholder = _ref$placeholder === void 0 ? '院区/检验专业组' : _ref$placeholder,
32
+ restProps = _objectWithoutProperties(_ref, _excluded);
33
+ var _useState = useState(defaultValue || undefined),
34
+ _useState2 = _slicedToArray(_useState, 2),
35
+ value = _useState2[0],
36
+ setValue = _useState2[1];
37
+ var handleSelect = function handleSelect(value, node) {
38
+ setValue(value);
39
+ onSelect === null || onSelect === void 0 || onSelect(value, node);
40
+ };
41
+ var handClear = function handClear(val) {
42
+ if (!val) {
43
+ setValue(val);
44
+ onSelect === null || onSelect === void 0 || onSelect(val, '');
45
+ }
46
+ };
47
+ useEffect(function () {
48
+ if (defaultValue) {
49
+ setValue(defaultValue);
50
+ }
51
+ }, [defaultValue]);
52
+ return /*#__PURE__*/React.createElement(TreeSelect, _extends({
53
+ showSearch: true,
54
+ style: style,
55
+ dropdownStyle: {
56
+ maxHeight: 400,
57
+ overflow: 'auto'
58
+ },
59
+ allowClear: true,
60
+ treeData: treeData,
61
+ onChange: handClear,
62
+ value: value,
63
+ onSelect: handleSelect,
64
+ placeholder: placeholder,
65
+ fieldNames: {
66
+ label: 'NAME',
67
+ value: 'SOURCE_ID',
68
+ children: 'CHILDREN'
69
+ },
70
+ treeNodeFilterProp: "NAME",
71
+ popupClassName: "group-treeSelect",
72
+ treeDefaultExpandAll: true
73
+ }, restProps));
74
+ };
75
+ export default GTreeSelect;
@@ -0,0 +1,16 @@
1
+ .group-treeSelect {
2
+ :global {
3
+ .ant-select-tree-list-holder-inner
4
+ .ant-select-tree-treenode
5
+ .ant-select-tree-node-content-wrapper {
6
+ width: 80% !important;
7
+ white-space: nowrap !important;
8
+ overflow: hidden !important;
9
+ text-overflow: ellipsis;
10
+ font-size: 12px;
11
+ }
12
+ .ant-select-tree-indent-unit {
13
+ width: 13px;
14
+ }
15
+ }
16
+ }
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import type { IGtreeProps } from './typing';
3
+ import './style.less';
4
+ declare const LabGroupTree: ({ treeData, onSelect, childTitleNode, GBeforeIcon, showLine, showIcon, treeProperties, ...restProps }: IGtreeProps) => React.JSX.Element;
5
+ export default LabGroupTree;
@@ -0,0 +1,76 @@
1
+ var _excluded = ["treeData", "onSelect", "childTitleNode", "GBeforeIcon", "showLine", "showIcon", "treeProperties"];
2
+ 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); }
3
+ 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; }
4
+ 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; }
5
+ /*
6
+ * @Author: xqy
7
+ * @Date: 2024-03-18 16:23:10
8
+ * @LastEditors: xqy
9
+ * @LastEditTime: 2024-03-26 16:57:55
10
+ * @Description:专业组树形
11
+ */
12
+ import React from 'react';
13
+ import { Tree } from 'antd';
14
+ import { Iconfont } from "../components";
15
+ import "./style.less";
16
+ var LabGroupTree = function LabGroupTree(_ref) {
17
+ var _ref$treeData = _ref.treeData,
18
+ treeData = _ref$treeData === void 0 ? [] : _ref$treeData,
19
+ _onSelect = _ref.onSelect,
20
+ childTitleNode = _ref.childTitleNode,
21
+ _ref$GBeforeIcon = _ref.GBeforeIcon,
22
+ GBeforeIcon = _ref$GBeforeIcon === void 0 ? function (type) {
23
+ return /*#__PURE__*/React.createElement(Iconfont, {
24
+ type: type === '1' ? 'icon-jian' : 'icon-guan',
25
+ style: {
26
+ fontSize: '16px',
27
+ marginRight: '4px'
28
+ }
29
+ });
30
+ } : _ref$GBeforeIcon,
31
+ _ref$showLine = _ref.showLine,
32
+ showLine = _ref$showLine === void 0 ? {
33
+ showLeafIcon: function showLeafIcon() {
34
+ return false;
35
+ }
36
+ } : _ref$showLine,
37
+ _ref$showIcon = _ref.showIcon,
38
+ showIcon = _ref$showIcon === void 0 ? true : _ref$showIcon,
39
+ treeProperties = _ref.treeProperties,
40
+ restProps = _objectWithoutProperties(_ref, _excluded);
41
+ //构造标题的结构
42
+ var customTitle = function customTitle(nodeData) {
43
+ var NAME = nodeData.NAME,
44
+ NODE_TYPE = nodeData.NODE_TYPE,
45
+ NUM = nodeData.NUM;
46
+ //NODE_TYPE(1-检验专业组,2-管理专业组,)
47
+ if (NODE_TYPE === '1' || NODE_TYPE === '2') {
48
+ return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
49
+ className: "tree-item-text tree-first"
50
+ }, GBeforeIcon === null || GBeforeIcon === void 0 ? void 0 : GBeforeIcon(NODE_TYPE), NAME, /*#__PURE__*/React.createElement("span", {
51
+ className: "num"
52
+ }, NUM)));
53
+ } else {
54
+ return childTitleNode === null || childTitleNode === void 0 ? void 0 : childTitleNode(nodeData);
55
+ }
56
+ };
57
+ return /*#__PURE__*/React.createElement(Tree, _extends({
58
+ rootClassName: "lab-group-tree",
59
+ treeData: treeData,
60
+ onSelect: function onSelect(keys, node) {
61
+ return _onSelect === null || _onSelect === void 0 ? void 0 : _onSelect(keys, node);
62
+ },
63
+ rootStyle: {
64
+ width: '100%'
65
+ },
66
+ showIcon: true,
67
+ showLine: showLine,
68
+ titleRender: customTitle,
69
+ fieldNames: {
70
+ title: 'NAME',
71
+ key: 'NODE_NO',
72
+ children: 'CHILDREN'
73
+ }
74
+ }, treeProperties, restProps));
75
+ };
76
+ export default LabGroupTree;
@@ -0,0 +1,50 @@
1
+ .lab-group-tree {
2
+ width: 100%;
3
+ height: 100%;
4
+ background-color: #fff;
5
+ overflow-y: auto;
6
+ .tree-first {
7
+ width: calc(100% - 1rem);
8
+ position: relative;
9
+ min-width: 100%;
10
+ overflow: hidden;
11
+ white-space: nowrap;
12
+ text-overflow: ellipsis;
13
+ line-height: 25px;
14
+ .num {
15
+ position: absolute;
16
+ right: 2px;
17
+ color: #185ddc;
18
+ }
19
+ }
20
+ .ant-tree-treenode {
21
+ width: 100%;
22
+ }
23
+ .ant-tree-title {
24
+ width: 100%;
25
+ }
26
+ .ant-tree-switcher {
27
+ height: 24px;
28
+ width: 24px;
29
+ display: flex;
30
+ align-items: center;
31
+ justify-content: center;
32
+ }
33
+ .ant-tree-switcher-line-icon > svg {
34
+ height: 16px;
35
+ width: 16px;
36
+ }
37
+ .ant-tree-title {
38
+ width: 100% !important;
39
+ }
40
+ .ant-tree-node-content-wrapper {
41
+ width: 100%;
42
+ display: flex;
43
+ align-items: center;
44
+ min-height: 26px !important;
45
+ white-space: nowrap;
46
+ overflow: hidden;
47
+ text-overflow: ellipsis;
48
+ padding: 0 4px 0 2px;
49
+ }
50
+ }
@@ -0,0 +1,30 @@
1
+ /// <reference types="react" />
2
+ import type { TreeProps } from 'antd';
3
+ export interface IGtreeProps {
4
+ /**点击树节点触发 */
5
+ onSelect?: (keys: any, node: any) => void;
6
+ /** treeNodes 数据,如果设置则不需要手动构造 TreeNode 节点*/
7
+ treeData?: any;
8
+ /**默认展开所有树节点 */
9
+ defaultExpandAll?: boolean;
10
+ /** 自定义节点 title、key、children 的字段*/
11
+ fieldNames?: object;
12
+ /**是否展示连接线,用法同ant-desgin tree */
13
+ showLine?: any;
14
+ /**是否展示title前的图标,需要自行定义图标相关样式 */
15
+ showIcon?: boolean;
16
+ /**异步加载数据 */
17
+ loadData?: (node: any) => Promise<any>;
18
+ /**构造除检/管专业组的标题样式 */
19
+ childTitleNode: (node: any) => React.ReactNode;
20
+ /**专业组前的图标*/
21
+ GBeforeIcon?: (type: string) => React.ReactNode;
22
+ /**设置选中的节点 */
23
+ selectedKeys?: string[];
24
+ /**指定展开节点 */
25
+ expandedKeys?: string[];
26
+ /**展开树节点触发 */
27
+ onExpand?: (keys: any, node: any) => void;
28
+ /**透传ant tree 属性 */
29
+ treeProperties?: TreeProps;
30
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ declare const Iconfont: import("react").FC<import("@ant-design/icons/lib/components/IconFont").IconFontProps<string>>;
3
+ export default Iconfont;
@@ -0,0 +1,7 @@
1
+ import { createFromIconfontCN } from '@ant-design/icons';
2
+ var ICONFONT_URL = '//at.alicdn.com/t/c/font_4487114_ujnjcn872z.js';
3
+ // 生产环境使用public中的文件,开发环境使用线上环境以方便开发
4
+ var Iconfont = createFromIconfontCN({
5
+ scriptUrl: process.env.NODE_ENV === 'development' ? ICONFONT_URL : '/statics/iconfont/iconfont.js' // 在 iconfont.cn 上生成
6
+ });
7
+ export default Iconfont;
@@ -0,0 +1,2 @@
1
+ import Iconfont from './Iconfont';
2
+ export { Iconfont, };
@@ -0,0 +1,2 @@
1
+ import Iconfont from "./Iconfont";
2
+ export { Iconfont };
@@ -0,0 +1,2 @@
1
+ export { default as LabGroupTree } from './LabGroupTree';
2
+ export { default as LabGTreeSelect } from './LabGTreeSelect';
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { default as LabGroupTree } from "./LabGroupTree";
2
+ export { default as LabGTreeSelect } from "./LabGTreeSelect";
package/package.json ADDED
@@ -0,0 +1,77 @@
1
+ {
2
+ "name": "xh-lab-rc",
3
+ "version": "0.0.1",
4
+ "description": " A react library for xinhelab",
5
+ "license": "MIT",
6
+ "module": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "files": [
9
+ "dist"
10
+ ],
11
+ "scripts": {
12
+ "build": "father build",
13
+ "build:watch": "father dev",
14
+ "dev": "dumi dev",
15
+ "docs:build": "dumi build",
16
+ "doctor": "father doctor",
17
+ "lint": "npm run lint:es && npm run lint:css",
18
+ "lint:css": "stylelint \"{src,test}/**/*.{css,less}\"",
19
+ "lint:es": "eslint \"{src,test}/**/*.{js,jsx,ts,tsx}\"",
20
+ "prepare": "husky install && dumi setup",
21
+ "prepublishOnly": "father doctor && npm run build",
22
+ "start": "npm run dev"
23
+ },
24
+ "commitlint": {
25
+ "extends": [
26
+ "@commitlint/config-conventional"
27
+ ]
28
+ },
29
+ "lint-staged": {
30
+ "*.{md,json}": [
31
+ "prettier --write --no-error-on-unmatched-pattern"
32
+ ],
33
+ "*.{css,less}": [
34
+ "stylelint --fix",
35
+ "prettier --write"
36
+ ],
37
+ "*.{js,jsx}": [
38
+ "eslint --fix",
39
+ "prettier --write"
40
+ ],
41
+ "*.{ts,tsx}": [
42
+ "eslint --fix",
43
+ "prettier --parser=typescript --write"
44
+ ]
45
+ },
46
+ "dependencies": {
47
+ "@ant-design/icons": "^5.3.5",
48
+ "antd": "^5.15.3",
49
+ "classnames": "^2.5.1"
50
+ },
51
+ "devDependencies": {
52
+ "@commitlint/cli": "^17.1.2",
53
+ "@commitlint/config-conventional": "^17.1.0",
54
+ "@types/react": "^18.0.0",
55
+ "@types/react-dom": "^18.0.0",
56
+ "@umijs/lint": "^4.0.0",
57
+ "dumi": "^2.2.13",
58
+ "eslint": "^8.23.0",
59
+ "father": "^4.1.0",
60
+ "husky": "^8.0.1",
61
+ "lint-staged": "^13.0.3",
62
+ "prettier": "^2.7.1",
63
+ "prettier-plugin-organize-imports": "^3.0.0",
64
+ "prettier-plugin-packagejson": "^2.2.18",
65
+ "react": "^18.0.0",
66
+ "react-dom": "^18.0.0",
67
+ "stylelint": "^14.9.1"
68
+ },
69
+ "peerDependencies": {
70
+ "react": ">=16.9.0",
71
+ "react-dom": ">=16.9.0"
72
+ },
73
+ "publishConfig": {
74
+ "access": "public"
75
+ },
76
+ "authors": []
77
+ }