@dtjoy/dt-design 1.0.0
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 +21 -0
- package/README.md +141 -0
- package/esm/_util/index.d.ts +3 -0
- package/esm/_util/index.js +10 -0
- package/esm/_util/type.d.ts +51 -0
- package/esm/_util/type.js +1 -0
- package/esm/blockHeader/index.d.ts +47 -0
- package/esm/blockHeader/index.js +113 -0
- package/esm/blockHeader/style.less +141 -0
- package/esm/index.d.ts +3 -0
- package/esm/index.js +52 -0
- package/esm/styles/entry.less +6 -0
- package/esm/styles/variables.less +1 -0
- package/lib/_util/index.d.ts +3 -0
- package/lib/_util/index.js +16 -0
- package/lib/_util/type.d.ts +51 -0
- package/lib/_util/type.js +5 -0
- package/lib/blockHeader/index.d.ts +47 -0
- package/lib/blockHeader/index.js +106 -0
- package/lib/blockHeader/style.less +141 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.js +15 -0
- package/lib/styles/entry.less +6 -0
- package/lib/styles/variables.less +1 -0
- package/package.json +147 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) dtinsight UED
|
|
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,141 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
<div align="center">
|
|
5
|
+
|
|
6
|
+
# dt-design
|
|
7
|
+
|
|
8
|
+
English | [简体中文](./README-zh_CN.md)
|
|
9
|
+
|
|
10
|
+
An enterprise-class React component library built on [Ant Design](https://github.com/ant-design/ant-design), optimized for back-office business scenarios with high reusability and extensibility.
|
|
11
|
+
|
|
12
|
+
</div>
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## 📖 Introduction
|
|
17
|
+
|
|
18
|
+
dt-design is a React component library internally developed by the **Digital Business Department**, extending Ant Design 5.x. It abstracts and沉淀(consolidates)common business patterns into **out-of-the-box components**, boosting development velocity while reducing redundant code.
|
|
19
|
+
|
|
20
|
+
In addition, we provide several framework-agnostic utilities written in vanilla JavaScript:
|
|
21
|
+
|
|
22
|
+
* `ContextMenu` – right-click context menu
|
|
23
|
+
* `KeyEventListener` – global keyboard event binder
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## 🎯 When to Use
|
|
28
|
+
|
|
29
|
+
* ✅ Ant Design's basic components are insufficient for complex business requirements
|
|
30
|
+
* ✅ Multiple projects share similar modules and need a unified implementation
|
|
31
|
+
* ✅ You want to extract general business logic to avoid duplicate development
|
|
32
|
+
* ✅ You need consistent UI specification and interaction behavior across products
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## 📦 Installation
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
# npm
|
|
40
|
+
npm install dt-design
|
|
41
|
+
|
|
42
|
+
# yarn
|
|
43
|
+
yarn add dt-design
|
|
44
|
+
|
|
45
|
+
# pnpm
|
|
46
|
+
pnpm add dt-design
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## 🚀 Quick Start
|
|
52
|
+
|
|
53
|
+
```tsx
|
|
54
|
+
import React from 'react';
|
|
55
|
+
import { BlockHeader } from '@dtjoy/dt-design';
|
|
56
|
+
|
|
57
|
+
const App = () => <BlockHeader title="Category Title" background />;
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## 📌 Tree-Shaking & On-Demand
|
|
63
|
+
|
|
64
|
+
ES modules are fully supported; import only what you need and the bundler will drop the rest automatically:
|
|
65
|
+
|
|
66
|
+
```ts
|
|
67
|
+
import { BlockHeader, CustomTable } from '@dtjoy/dt-design';
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## 🧩 TypeScript First
|
|
73
|
+
|
|
74
|
+
Written entirely in TypeScript with complete type definitions for better IntelliSense and compile-time safety.
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## 🛠 Local Development
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
git clone https://github.com/ZhaoFxxkSky/dt-design
|
|
82
|
+
cd dt-design
|
|
83
|
+
pnpm install
|
|
84
|
+
pnpm dev
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Then open [http://127.0.0.1:8000](http://127.0.0.1:8000).
|
|
88
|
+
We use [dumi](https://d.umijs.org/) for docs & component management.
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## 📦 Build & Release
|
|
93
|
+
|
|
94
|
+
### Build the library
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
pnpm build
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Bump version (internal npm registry)
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
pnpm release -- -r x.x.x
|
|
104
|
+
npm publish --registry <internal-npm-registry>
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Deploy documentation site (optional)
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
pnpm deploy
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## 🤝 Contributing
|
|
116
|
+
|
|
117
|
+
We welcome Issues and Pull Requests. Workflow:
|
|
118
|
+
|
|
119
|
+
1. Fork the repository
|
|
120
|
+
2. Create your feature branch (`git checkout -b feature/xxx`)
|
|
121
|
+
3. Commit your changes (`git commit -m 'feat: add xxx'`)
|
|
122
|
+
4. Push to the branch (`git push origin feature/xxx`)
|
|
123
|
+
5. Open a Pull Request
|
|
124
|
+
|
|
125
|
+
Please read [CONTRIBUTING.md](./CONTRIBUTING.md) for coding standards and CI rules.
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## 👨💻 Core Team
|
|
130
|
+
|
|
131
|
+
Maintained by the **Digital Business Department**. Thanks to all contributors!
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## 📄 License
|
|
136
|
+
|
|
137
|
+
Internal use only. Redistribution or publication without explicit permission is strictly prohibited.
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
Need help? Contact us at `wx-zhaog@dtjoy.com`
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
import React from 'react';
|
|
3
|
+
export function toTooltipProps(tooltip) {
|
|
4
|
+
if (tooltip !== null && _typeof(tooltip) === 'object' && ! /*#__PURE__*/React.isValidElement(tooltip)) {
|
|
5
|
+
return tooltip;
|
|
6
|
+
}
|
|
7
|
+
return {
|
|
8
|
+
title: tooltip
|
|
9
|
+
};
|
|
10
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
/** https://github.com/Microsoft/TypeScript/issues/29729 */
|
|
3
|
+
export declare type LiteralUnion<T extends string> = T | (string & {});
|
|
4
|
+
export declare type AnyObject = Record<string, any>;
|
|
5
|
+
export declare type CustomComponent<P = AnyObject> = React.ComponentType<P> | string;
|
|
6
|
+
/**
|
|
7
|
+
* Get component props
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { Checkbox } from '@dtjoy/dt-design'
|
|
11
|
+
* import type { GetProps } from '@dtjoy/dt-design';
|
|
12
|
+
*
|
|
13
|
+
* type CheckboxGroupProps = GetProps<typeof Checkbox.Group>
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare type GetProps<T extends React.ComponentType<any> | object> = T extends React.ComponentType<infer P> ? P : T extends object ? T : never;
|
|
17
|
+
/**
|
|
18
|
+
* Get component props by component name
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* import { Select } from '@dtjoy/dt-design';
|
|
22
|
+
* import type { GetProp, SelectProps } from '@dtjoy/dt-design';
|
|
23
|
+
*
|
|
24
|
+
* type SelectOption1 = GetProp<SelectProps, 'options'>[number];
|
|
25
|
+
* // or
|
|
26
|
+
* type SelectOption2 = GetProp<typeof Select, 'options'>[number];
|
|
27
|
+
*
|
|
28
|
+
* const onChange: GetProp<typeof Select, 'onChange'> = (value, option) => {
|
|
29
|
+
* // Do something
|
|
30
|
+
* };
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export declare type GetProp<T extends React.ComponentType<any> | object, PropName extends keyof GetProps<T>> = NonNullable<GetProps<T>[PropName]>;
|
|
34
|
+
declare type ReactRefComponent<Props extends {
|
|
35
|
+
ref?: React.Ref<any> | string;
|
|
36
|
+
}> = (props: Props) => React.ReactNode;
|
|
37
|
+
declare type ExtractRefAttributesRef<T> = T extends React.RefAttributes<infer P> ? P : never;
|
|
38
|
+
/**
|
|
39
|
+
* Get component ref
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* import { Input } from '@dtjoy/dt-design';
|
|
43
|
+
* import type { GetRef } from '@dtjoy/dt-design';
|
|
44
|
+
*
|
|
45
|
+
* type InputRef = GetRef<typeof Input>;
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export declare type GetRef<T extends ReactRefComponent<any> | React.Component<any>> = T extends React.Component<any> ? T : T extends React.ComponentType<infer P> ? ExtractRefAttributesRef<P> : never;
|
|
49
|
+
export declare type GetContextProps<T> = T extends React.Context<infer P> ? P : never;
|
|
50
|
+
export declare type GetContextProp<T extends React.Context<any>, PropName extends keyof GetContextProps<T>> = NonNullable<GetContextProps<T>[PropName]>;
|
|
51
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import { LabelTooltipType } from '../_util';
|
|
3
|
+
import './style.less';
|
|
4
|
+
export declare type SizeType = 'small' | 'middle' | 'large';
|
|
5
|
+
export interface IBlockHeaderProps {
|
|
6
|
+
/** 标题 */
|
|
7
|
+
title: ReactNode;
|
|
8
|
+
/** 标题前的图标,默认是一个色块 */
|
|
9
|
+
addonBefore?: ReactNode;
|
|
10
|
+
/** 标题后的提示说明文字 */
|
|
11
|
+
description?: ReactNode;
|
|
12
|
+
/** 默认展示为问号的tooltip */
|
|
13
|
+
tooltip?: LabelTooltipType;
|
|
14
|
+
/** 后缀自定义内容块 */
|
|
15
|
+
addonAfter?: ReactNode;
|
|
16
|
+
/**
|
|
17
|
+
* 小标题 font-size: 12px; line-height: 32px
|
|
18
|
+
* 中标题 font-size: 14px; line-height: 40px
|
|
19
|
+
* 大标题 font-size: 16px; line-height: 40px
|
|
20
|
+
* 默认 中标题
|
|
21
|
+
*/
|
|
22
|
+
size?: SizeType;
|
|
23
|
+
/** 自定义 Bottom 值 */
|
|
24
|
+
spaceBottom?: number;
|
|
25
|
+
/** 标题一行的样式类名 */
|
|
26
|
+
className?: string;
|
|
27
|
+
/** 标题的样式类名 */
|
|
28
|
+
style?: React.CSSProperties;
|
|
29
|
+
/** 展示内容(children)的样式类名 */
|
|
30
|
+
contentClassName?: string;
|
|
31
|
+
/** 展示内容(children)的样式 */
|
|
32
|
+
contentStyle?: React.CSSProperties;
|
|
33
|
+
/** 是否显示背景, 默认 true */
|
|
34
|
+
background?: boolean;
|
|
35
|
+
/** 当前展开状态 */
|
|
36
|
+
expand?: boolean;
|
|
37
|
+
/** 是否默认展开内容, 默认为 undefined */
|
|
38
|
+
defaultExpand?: boolean;
|
|
39
|
+
/** 展开/收起的内容 */
|
|
40
|
+
children?: ReactNode;
|
|
41
|
+
/** 展开/收起时的回调 */
|
|
42
|
+
onExpand?: (expand: boolean) => void;
|
|
43
|
+
/** 标题的样式 */
|
|
44
|
+
titleStyle?: React.CSSProperties;
|
|
45
|
+
}
|
|
46
|
+
declare const BlockHeader: React.FC<IBlockHeaderProps>;
|
|
47
|
+
export default BlockHeader;
|
|
@@ -0,0 +1,113 @@
|
|
|
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
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
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; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
+
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); }
|
|
7
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
8
|
+
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."); }
|
|
9
|
+
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); }
|
|
10
|
+
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; }
|
|
11
|
+
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; } }
|
|
12
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
13
|
+
import React, { useState } from 'react';
|
|
14
|
+
import { QuestionOutlined, UpOutlined } from '@dtinsight/react-icons';
|
|
15
|
+
import { Tooltip } from 'antd';
|
|
16
|
+
import { globalConfig } from 'antd/es/config-provider';
|
|
17
|
+
import classNames from 'classnames';
|
|
18
|
+
import { toTooltipProps } from "../_util";
|
|
19
|
+
// import useLocale from '../locale/useLocale';
|
|
20
|
+
import "./style.less";
|
|
21
|
+
function isControlled(props) {
|
|
22
|
+
return props.expand !== undefined;
|
|
23
|
+
}
|
|
24
|
+
var prefixCls = globalConfig().getPrefixCls('block-header');
|
|
25
|
+
var preTitleRowCls = "".concat(prefixCls, "__title");
|
|
26
|
+
var BlockHeader = function BlockHeader(props) {
|
|
27
|
+
var title = props.title,
|
|
28
|
+
_props$description = props.description,
|
|
29
|
+
description = _props$description === void 0 ? '' : _props$description,
|
|
30
|
+
tooltip = props.tooltip,
|
|
31
|
+
_props$size = props.size,
|
|
32
|
+
size = _props$size === void 0 ? 'middle' : _props$size,
|
|
33
|
+
_props$spaceBottom = props.spaceBottom,
|
|
34
|
+
spaceBottom = _props$spaceBottom === void 0 ? 16 : _props$spaceBottom,
|
|
35
|
+
_props$className = props.className,
|
|
36
|
+
className = _props$className === void 0 ? '' : _props$className,
|
|
37
|
+
_props$contentClassNa = props.contentClassName,
|
|
38
|
+
contentClassName = _props$contentClassNa === void 0 ? '' : _props$contentClassNa,
|
|
39
|
+
_props$style = props.style,
|
|
40
|
+
style = _props$style === void 0 ? {} : _props$style,
|
|
41
|
+
_props$contentStyle = props.contentStyle,
|
|
42
|
+
contentStyle = _props$contentStyle === void 0 ? {} : _props$contentStyle,
|
|
43
|
+
_props$background = props.background,
|
|
44
|
+
background = _props$background === void 0 ? true : _props$background,
|
|
45
|
+
defaultExpand = props.defaultExpand,
|
|
46
|
+
addonAfter = props.addonAfter,
|
|
47
|
+
expand = props.expand,
|
|
48
|
+
_props$children = props.children,
|
|
49
|
+
children = _props$children === void 0 ? '' : _props$children,
|
|
50
|
+
_props$addonBefore = props.addonBefore,
|
|
51
|
+
addonBefore = _props$addonBefore === void 0 ? /*#__PURE__*/React.createElement("div", {
|
|
52
|
+
className: "addon-before--default"
|
|
53
|
+
}) : _props$addonBefore,
|
|
54
|
+
onExpand = props.onExpand,
|
|
55
|
+
titleStyle = props.titleStyle;
|
|
56
|
+
var _useState = useState(defaultExpand),
|
|
57
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
58
|
+
internalExpand = _useState2[0],
|
|
59
|
+
setInternalExpand = _useState2[1];
|
|
60
|
+
// const locale = useLocale('BlockHeader');
|
|
61
|
+
|
|
62
|
+
var currentExpand = isControlled(props) ? expand : internalExpand;
|
|
63
|
+
|
|
64
|
+
// 只有在有了 children 并且设置了 expand/defaultExpand 的时候才能够展开收起
|
|
65
|
+
var showCollapse = (typeof expand === 'boolean' || typeof defaultExpand === 'boolean') && children;
|
|
66
|
+
var tooltipProps = toTooltipProps(tooltip);
|
|
67
|
+
var bottomStyle;
|
|
68
|
+
if (spaceBottom) bottomStyle = showCollapse && currentExpand ? {
|
|
69
|
+
marginBottom: 0
|
|
70
|
+
} : {
|
|
71
|
+
marginBottom: spaceBottom
|
|
72
|
+
};
|
|
73
|
+
var handleExpand = function handleExpand(expand) {
|
|
74
|
+
if (!children) return;
|
|
75
|
+
!isControlled(props) && setInternalExpand(expand);
|
|
76
|
+
onExpand === null || onExpand === void 0 || onExpand(expand);
|
|
77
|
+
};
|
|
78
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
79
|
+
className: classNames("".concat(prefixCls), className),
|
|
80
|
+
style: _objectSpread(_objectSpread({}, bottomStyle), style)
|
|
81
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
82
|
+
className: classNames(preTitleRowCls, "".concat(preTitleRowCls, "--").concat(size), _defineProperty(_defineProperty({}, "".concat(preTitleRowCls, "--background"), background), "".concat(preTitleRowCls, "--pointer"), showCollapse)),
|
|
83
|
+
style: titleStyle,
|
|
84
|
+
onClick: function onClick() {
|
|
85
|
+
return showCollapse && handleExpand(!currentExpand);
|
|
86
|
+
}
|
|
87
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
88
|
+
className: "title__box"
|
|
89
|
+
}, addonBefore ? /*#__PURE__*/React.createElement("div", {
|
|
90
|
+
className: "title__addon-before title__addon-before--".concat(size)
|
|
91
|
+
}, addonBefore) : null, /*#__PURE__*/React.createElement("div", {
|
|
92
|
+
className: "title__text"
|
|
93
|
+
}, title), tooltipProps !== null && tooltipProps !== void 0 && tooltipProps.title ? /*#__PURE__*/React.createElement("div", {
|
|
94
|
+
className: "title__tooltip"
|
|
95
|
+
}, /*#__PURE__*/React.createElement(Tooltip, tooltipProps, /*#__PURE__*/React.createElement(QuestionOutlined, null))) : null, description ? /*#__PURE__*/React.createElement("div", {
|
|
96
|
+
className: "title__description"
|
|
97
|
+
}, description) : null), addonAfter && /*#__PURE__*/React.createElement("div", {
|
|
98
|
+
className: "title__addon-after"
|
|
99
|
+
}, addonAfter), showCollapse && /*#__PURE__*/React.createElement("div", {
|
|
100
|
+
className: "title__collapse"
|
|
101
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
102
|
+
className: "collapse__text"
|
|
103
|
+
}), /*#__PURE__*/React.createElement(UpOutlined, {
|
|
104
|
+
className: classNames('collapse__icon', {
|
|
105
|
+
'collapse__icon--up': currentExpand,
|
|
106
|
+
'collapse__icon--down': !currentExpand
|
|
107
|
+
})
|
|
108
|
+
}))), children && /*#__PURE__*/React.createElement("div", {
|
|
109
|
+
className: classNames("".concat(prefixCls, "__content"), contentClassName, _defineProperty({}, "".concat(prefixCls, "__content--active"), currentExpand || !showCollapse)),
|
|
110
|
+
style: contentStyle
|
|
111
|
+
}, children));
|
|
112
|
+
};
|
|
113
|
+
export default BlockHeader;
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
// @card_prefix: ~'dt-block-header';
|
|
2
|
+
@card_prefix: ~'@{ant-prefix}-block-header';
|
|
3
|
+
|
|
4
|
+
.@{card_prefix} {
|
|
5
|
+
&__title {
|
|
6
|
+
border-radius: 4px;
|
|
7
|
+
display: flex;
|
|
8
|
+
align-items: center;
|
|
9
|
+
justify-content: space-between;
|
|
10
|
+
&--large {
|
|
11
|
+
.title__box {
|
|
12
|
+
line-height: 24px;
|
|
13
|
+
.title__text {
|
|
14
|
+
font-size: 16px;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
&--middle {
|
|
19
|
+
.title__box {
|
|
20
|
+
line-height: 22px;
|
|
21
|
+
.title__text {
|
|
22
|
+
font-size: 14px;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
&--small {
|
|
27
|
+
.title__box {
|
|
28
|
+
line-height: 20px;
|
|
29
|
+
.title__text {
|
|
30
|
+
font-size: 12px;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
&--background {
|
|
35
|
+
padding: 0 12px;
|
|
36
|
+
background-color: #f9f9fa;
|
|
37
|
+
&.@{card_prefix}__title {
|
|
38
|
+
&--middle,
|
|
39
|
+
&--large {
|
|
40
|
+
height: 40px;
|
|
41
|
+
}
|
|
42
|
+
&--small {
|
|
43
|
+
height: 32px;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
&--pointer {
|
|
48
|
+
cursor: pointer;
|
|
49
|
+
}
|
|
50
|
+
.title {
|
|
51
|
+
&__box {
|
|
52
|
+
flex: 1;
|
|
53
|
+
display: flex;
|
|
54
|
+
align-items: center;
|
|
55
|
+
}
|
|
56
|
+
&__addon-before {
|
|
57
|
+
margin-right: 8px;
|
|
58
|
+
color: @primary-color;
|
|
59
|
+
&--middle {
|
|
60
|
+
.addon-before--default {
|
|
61
|
+
width: 4px;
|
|
62
|
+
height: 16px;
|
|
63
|
+
background-color: @primary-color;
|
|
64
|
+
}
|
|
65
|
+
font-size: 20px;
|
|
66
|
+
}
|
|
67
|
+
&--small {
|
|
68
|
+
.addon-before--default {
|
|
69
|
+
width: 4px;
|
|
70
|
+
height: 16px;
|
|
71
|
+
background-color: @primary-color;
|
|
72
|
+
}
|
|
73
|
+
font-size: 16px;
|
|
74
|
+
}
|
|
75
|
+
&--large {
|
|
76
|
+
.addon-before--default {
|
|
77
|
+
width: 4px;
|
|
78
|
+
height: 20px;
|
|
79
|
+
background-color: @primary-color;
|
|
80
|
+
}
|
|
81
|
+
font-size: 24px;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
&__tooltip {
|
|
85
|
+
display: flex;
|
|
86
|
+
margin-right: 4px;
|
|
87
|
+
font-size: 16px;
|
|
88
|
+
color: #b1b4c5;
|
|
89
|
+
cursor: pointer;
|
|
90
|
+
}
|
|
91
|
+
&__text {
|
|
92
|
+
color: @text-color;
|
|
93
|
+
font-weight: 500;
|
|
94
|
+
margin-right: 4px;
|
|
95
|
+
}
|
|
96
|
+
&__description {
|
|
97
|
+
display: flex;
|
|
98
|
+
align-items: center;
|
|
99
|
+
color: @label-color;
|
|
100
|
+
font-size: 12px;
|
|
101
|
+
}
|
|
102
|
+
&__addon-after {
|
|
103
|
+
color: @label-color;
|
|
104
|
+
}
|
|
105
|
+
&__collapse {
|
|
106
|
+
color: @label-color;
|
|
107
|
+
display: flex;
|
|
108
|
+
align-items: center;
|
|
109
|
+
cursor: pointer;
|
|
110
|
+
user-select: none;
|
|
111
|
+
.collapse {
|
|
112
|
+
&__text {
|
|
113
|
+
font-size: 12px;
|
|
114
|
+
margin: 0 4px;
|
|
115
|
+
}
|
|
116
|
+
&__icon {
|
|
117
|
+
font-size: 16px;
|
|
118
|
+
transition: transform 0.4s;
|
|
119
|
+
&--down {
|
|
120
|
+
transform: rotate(-180deg);
|
|
121
|
+
}
|
|
122
|
+
&--up {
|
|
123
|
+
transform: rotate(0deg);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
&__content {
|
|
131
|
+
opacity: 0;
|
|
132
|
+
height: 0;
|
|
133
|
+
overflow: hidden;
|
|
134
|
+
transition: opacity 0.5s ease, height 0.5s ease;
|
|
135
|
+
&--active {
|
|
136
|
+
opacity: 1;
|
|
137
|
+
padding: 16px 24px;
|
|
138
|
+
height: auto;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
package/esm/index.d.ts
ADDED
package/esm/index.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import '@dtinsight/react-icons/dist/index.css';
|
|
2
|
+
import "./styles/entry.less";
|
|
3
|
+
export { default as BlockHeader } from "./blockHeader";
|
|
4
|
+
// export { default as Button } from './button';
|
|
5
|
+
// export { default as Catalogue } from './catalogue';
|
|
6
|
+
// export { default as Chat } from './chat';
|
|
7
|
+
// export { default as CollapsibleActionItems } from './collapsibleActionItems';
|
|
8
|
+
// export { default as ConfigProvider } from './configProvider';
|
|
9
|
+
// export { default as ContentLayout } from './contentLayout';
|
|
10
|
+
// export { default as ContextMenu } from './contextMenu';
|
|
11
|
+
// export { default as Copy } from './copy';
|
|
12
|
+
// export { default as Descriptions } from './descriptions';
|
|
13
|
+
// export { default as Drawer } from './drawer';
|
|
14
|
+
// export { default as Dropdown } from './dropdown';
|
|
15
|
+
// export { default as EllipsisText } from './ellipsisText';
|
|
16
|
+
// export { default as Empty } from './empty';
|
|
17
|
+
// export { default as ErrorBoundary } from './errorBoundary';
|
|
18
|
+
// export { default as LoadError } from './errorBoundary/loadError';
|
|
19
|
+
// export { default as FilterRules } from './filterRules';
|
|
20
|
+
// export { default as Flex } from './flex';
|
|
21
|
+
// export type { FlexProps } from './flex/interface';
|
|
22
|
+
// export { default as Float } from './float';
|
|
23
|
+
// export { default as Form } from './form';
|
|
24
|
+
// export { default as Fullscreen } from './fullscreen';
|
|
25
|
+
// export { default as GlobalLoading } from './globalLoading';
|
|
26
|
+
// export { default as Image } from './image';
|
|
27
|
+
// export { default as Input } from './input';
|
|
28
|
+
// export { default as KeyEventListener } from './keyEventListener';
|
|
29
|
+
// export { default as enUS } from './locale/en-US';
|
|
30
|
+
// export { default as useLocale } from './locale/useLocale';
|
|
31
|
+
// export { default as zhCN } from './locale/zh-CN';
|
|
32
|
+
// export { default as MarkdownRender } from './markdownRender';
|
|
33
|
+
// export { default as Modal } from './modal/modal';
|
|
34
|
+
// export { default as NotFound } from './notFound';
|
|
35
|
+
// export { default as ProgressBar } from './progressBar';
|
|
36
|
+
// export { default as ProgressLine } from './progressLine';
|
|
37
|
+
// export { default as Resize } from './resize';
|
|
38
|
+
// export { default as Splitter } from './splitter';
|
|
39
|
+
// export * from './splitter';
|
|
40
|
+
// export { default as SpreadSheet } from './spreadSheet';
|
|
41
|
+
// export { default as StatusTag } from './statusTag';
|
|
42
|
+
// export { default as Table } from './table';
|
|
43
|
+
// export { default as TinyTag } from './tinyTag';
|
|
44
|
+
// export { default as useCookieListener } from './useCookieListener';
|
|
45
|
+
// export { default as useDebounce } from './useDebounce';
|
|
46
|
+
// export { default as useIntersectionObserver } from './useIntersectionObserver';
|
|
47
|
+
// export { default as useList } from './useList';
|
|
48
|
+
// export { default as useMeasure } from './useMeasure';
|
|
49
|
+
// export { default as useMergeOption } from './useMergeOption';
|
|
50
|
+
// export { default as useModal } from './useModal';
|
|
51
|
+
// export { default as useTyping } from './useTyping';
|
|
52
|
+
// export { default as useWindowSwitchListener } from './useWindowSwitchListener';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@primary-color: red;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.toTooltipProps = toTooltipProps;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
|
+
function toTooltipProps(tooltip) {
|
|
10
|
+
if (tooltip !== null && typeof tooltip === 'object' && ! /*#__PURE__*/_react.default.isValidElement(tooltip)) {
|
|
11
|
+
return tooltip;
|
|
12
|
+
}
|
|
13
|
+
return {
|
|
14
|
+
title: tooltip
|
|
15
|
+
};
|
|
16
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
/** https://github.com/Microsoft/TypeScript/issues/29729 */
|
|
3
|
+
export declare type LiteralUnion<T extends string> = T | (string & {});
|
|
4
|
+
export declare type AnyObject = Record<string, any>;
|
|
5
|
+
export declare type CustomComponent<P = AnyObject> = React.ComponentType<P> | string;
|
|
6
|
+
/**
|
|
7
|
+
* Get component props
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { Checkbox } from '@dtjoy/dt-design'
|
|
11
|
+
* import type { GetProps } from '@dtjoy/dt-design';
|
|
12
|
+
*
|
|
13
|
+
* type CheckboxGroupProps = GetProps<typeof Checkbox.Group>
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare type GetProps<T extends React.ComponentType<any> | object> = T extends React.ComponentType<infer P> ? P : T extends object ? T : never;
|
|
17
|
+
/**
|
|
18
|
+
* Get component props by component name
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* import { Select } from '@dtjoy/dt-design';
|
|
22
|
+
* import type { GetProp, SelectProps } from '@dtjoy/dt-design';
|
|
23
|
+
*
|
|
24
|
+
* type SelectOption1 = GetProp<SelectProps, 'options'>[number];
|
|
25
|
+
* // or
|
|
26
|
+
* type SelectOption2 = GetProp<typeof Select, 'options'>[number];
|
|
27
|
+
*
|
|
28
|
+
* const onChange: GetProp<typeof Select, 'onChange'> = (value, option) => {
|
|
29
|
+
* // Do something
|
|
30
|
+
* };
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export declare type GetProp<T extends React.ComponentType<any> | object, PropName extends keyof GetProps<T>> = NonNullable<GetProps<T>[PropName]>;
|
|
34
|
+
declare type ReactRefComponent<Props extends {
|
|
35
|
+
ref?: React.Ref<any> | string;
|
|
36
|
+
}> = (props: Props) => React.ReactNode;
|
|
37
|
+
declare type ExtractRefAttributesRef<T> = T extends React.RefAttributes<infer P> ? P : never;
|
|
38
|
+
/**
|
|
39
|
+
* Get component ref
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* import { Input } from '@dtjoy/dt-design';
|
|
43
|
+
* import type { GetRef } from '@dtjoy/dt-design';
|
|
44
|
+
*
|
|
45
|
+
* type InputRef = GetRef<typeof Input>;
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export declare type GetRef<T extends ReactRefComponent<any> | React.Component<any>> = T extends React.Component<any> ? T : T extends React.ComponentType<infer P> ? ExtractRefAttributesRef<P> : never;
|
|
49
|
+
export declare type GetContextProps<T> = T extends React.Context<infer P> ? P : never;
|
|
50
|
+
export declare type GetContextProp<T extends React.Context<any>, PropName extends keyof GetContextProps<T>> = NonNullable<GetContextProps<T>[PropName]>;
|
|
51
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import { LabelTooltipType } from '../_util';
|
|
3
|
+
import './style.less';
|
|
4
|
+
export declare type SizeType = 'small' | 'middle' | 'large';
|
|
5
|
+
export interface IBlockHeaderProps {
|
|
6
|
+
/** 标题 */
|
|
7
|
+
title: ReactNode;
|
|
8
|
+
/** 标题前的图标,默认是一个色块 */
|
|
9
|
+
addonBefore?: ReactNode;
|
|
10
|
+
/** 标题后的提示说明文字 */
|
|
11
|
+
description?: ReactNode;
|
|
12
|
+
/** 默认展示为问号的tooltip */
|
|
13
|
+
tooltip?: LabelTooltipType;
|
|
14
|
+
/** 后缀自定义内容块 */
|
|
15
|
+
addonAfter?: ReactNode;
|
|
16
|
+
/**
|
|
17
|
+
* 小标题 font-size: 12px; line-height: 32px
|
|
18
|
+
* 中标题 font-size: 14px; line-height: 40px
|
|
19
|
+
* 大标题 font-size: 16px; line-height: 40px
|
|
20
|
+
* 默认 中标题
|
|
21
|
+
*/
|
|
22
|
+
size?: SizeType;
|
|
23
|
+
/** 自定义 Bottom 值 */
|
|
24
|
+
spaceBottom?: number;
|
|
25
|
+
/** 标题一行的样式类名 */
|
|
26
|
+
className?: string;
|
|
27
|
+
/** 标题的样式类名 */
|
|
28
|
+
style?: React.CSSProperties;
|
|
29
|
+
/** 展示内容(children)的样式类名 */
|
|
30
|
+
contentClassName?: string;
|
|
31
|
+
/** 展示内容(children)的样式 */
|
|
32
|
+
contentStyle?: React.CSSProperties;
|
|
33
|
+
/** 是否显示背景, 默认 true */
|
|
34
|
+
background?: boolean;
|
|
35
|
+
/** 当前展开状态 */
|
|
36
|
+
expand?: boolean;
|
|
37
|
+
/** 是否默认展开内容, 默认为 undefined */
|
|
38
|
+
defaultExpand?: boolean;
|
|
39
|
+
/** 展开/收起的内容 */
|
|
40
|
+
children?: ReactNode;
|
|
41
|
+
/** 展开/收起时的回调 */
|
|
42
|
+
onExpand?: (expand: boolean) => void;
|
|
43
|
+
/** 标题的样式 */
|
|
44
|
+
titleStyle?: React.CSSProperties;
|
|
45
|
+
}
|
|
46
|
+
declare const BlockHeader: React.FC<IBlockHeaderProps>;
|
|
47
|
+
export default BlockHeader;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _reactIcons = require("@dtinsight/react-icons");
|
|
9
|
+
var _antd = require("antd");
|
|
10
|
+
var _configProvider = require("antd/es/config-provider");
|
|
11
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
12
|
+
var _util = require("../_util");
|
|
13
|
+
require("./style.less");
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
16
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
17
|
+
// import useLocale from '../locale/useLocale';
|
|
18
|
+
|
|
19
|
+
function isControlled(props) {
|
|
20
|
+
return props.expand !== undefined;
|
|
21
|
+
}
|
|
22
|
+
const prefixCls = (0, _configProvider.globalConfig)().getPrefixCls('block-header');
|
|
23
|
+
const preTitleRowCls = `${prefixCls}__title`;
|
|
24
|
+
const BlockHeader = function (props) {
|
|
25
|
+
const {
|
|
26
|
+
title,
|
|
27
|
+
description = '',
|
|
28
|
+
tooltip,
|
|
29
|
+
size = 'middle',
|
|
30
|
+
spaceBottom = 16,
|
|
31
|
+
className = '',
|
|
32
|
+
contentClassName = '',
|
|
33
|
+
style = {},
|
|
34
|
+
contentStyle = {},
|
|
35
|
+
background = true,
|
|
36
|
+
defaultExpand,
|
|
37
|
+
addonAfter,
|
|
38
|
+
expand,
|
|
39
|
+
children = '',
|
|
40
|
+
addonBefore = /*#__PURE__*/_react.default.createElement("div", {
|
|
41
|
+
className: "addon-before--default"
|
|
42
|
+
}),
|
|
43
|
+
onExpand,
|
|
44
|
+
titleStyle
|
|
45
|
+
} = props;
|
|
46
|
+
const [internalExpand, setInternalExpand] = (0, _react.useState)(defaultExpand);
|
|
47
|
+
// const locale = useLocale('BlockHeader');
|
|
48
|
+
|
|
49
|
+
const currentExpand = isControlled(props) ? expand : internalExpand;
|
|
50
|
+
|
|
51
|
+
// 只有在有了 children 并且设置了 expand/defaultExpand 的时候才能够展开收起
|
|
52
|
+
const showCollapse = (typeof expand === 'boolean' || typeof defaultExpand === 'boolean') && children;
|
|
53
|
+
const tooltipProps = (0, _util.toTooltipProps)(tooltip);
|
|
54
|
+
let bottomStyle;
|
|
55
|
+
if (spaceBottom) bottomStyle = showCollapse && currentExpand ? {
|
|
56
|
+
marginBottom: 0
|
|
57
|
+
} : {
|
|
58
|
+
marginBottom: spaceBottom
|
|
59
|
+
};
|
|
60
|
+
const handleExpand = expand => {
|
|
61
|
+
if (!children) return;
|
|
62
|
+
!isControlled(props) && setInternalExpand(expand);
|
|
63
|
+
onExpand?.(expand);
|
|
64
|
+
};
|
|
65
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
66
|
+
className: (0, _classnames.default)(`${prefixCls}`, className),
|
|
67
|
+
style: {
|
|
68
|
+
...bottomStyle,
|
|
69
|
+
...style
|
|
70
|
+
}
|
|
71
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
72
|
+
className: (0, _classnames.default)(preTitleRowCls, `${preTitleRowCls}--${size}`, {
|
|
73
|
+
[`${preTitleRowCls}--background`]: background,
|
|
74
|
+
[`${preTitleRowCls}--pointer`]: showCollapse
|
|
75
|
+
}),
|
|
76
|
+
style: titleStyle,
|
|
77
|
+
onClick: () => showCollapse && handleExpand(!currentExpand)
|
|
78
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
79
|
+
className: "title__box"
|
|
80
|
+
}, addonBefore ? /*#__PURE__*/_react.default.createElement("div", {
|
|
81
|
+
className: `title__addon-before title__addon-before--${size}`
|
|
82
|
+
}, addonBefore) : null, /*#__PURE__*/_react.default.createElement("div", {
|
|
83
|
+
className: "title__text"
|
|
84
|
+
}, title), tooltipProps?.title ? /*#__PURE__*/_react.default.createElement("div", {
|
|
85
|
+
className: `title__tooltip`
|
|
86
|
+
}, /*#__PURE__*/_react.default.createElement(_antd.Tooltip, tooltipProps, /*#__PURE__*/_react.default.createElement(_reactIcons.QuestionOutlined, null))) : null, description ? /*#__PURE__*/_react.default.createElement("div", {
|
|
87
|
+
className: `title__description`
|
|
88
|
+
}, description) : null), addonAfter && /*#__PURE__*/_react.default.createElement("div", {
|
|
89
|
+
className: `title__addon-after`
|
|
90
|
+
}, addonAfter), showCollapse && /*#__PURE__*/_react.default.createElement("div", {
|
|
91
|
+
className: `title__collapse`
|
|
92
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
93
|
+
className: "collapse__text"
|
|
94
|
+
}), /*#__PURE__*/_react.default.createElement(_reactIcons.UpOutlined, {
|
|
95
|
+
className: (0, _classnames.default)('collapse__icon', {
|
|
96
|
+
'collapse__icon--up': currentExpand,
|
|
97
|
+
'collapse__icon--down': !currentExpand
|
|
98
|
+
})
|
|
99
|
+
}))), children && /*#__PURE__*/_react.default.createElement("div", {
|
|
100
|
+
className: (0, _classnames.default)(`${prefixCls}__content`, contentClassName, {
|
|
101
|
+
[`${prefixCls}__content--active`]: currentExpand || !showCollapse
|
|
102
|
+
}),
|
|
103
|
+
style: contentStyle
|
|
104
|
+
}, children));
|
|
105
|
+
};
|
|
106
|
+
var _default = exports.default = BlockHeader;
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
// @card_prefix: ~'dt-block-header';
|
|
2
|
+
@card_prefix: ~'@{ant-prefix}-block-header';
|
|
3
|
+
|
|
4
|
+
.@{card_prefix} {
|
|
5
|
+
&__title {
|
|
6
|
+
border-radius: 4px;
|
|
7
|
+
display: flex;
|
|
8
|
+
align-items: center;
|
|
9
|
+
justify-content: space-between;
|
|
10
|
+
&--large {
|
|
11
|
+
.title__box {
|
|
12
|
+
line-height: 24px;
|
|
13
|
+
.title__text {
|
|
14
|
+
font-size: 16px;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
&--middle {
|
|
19
|
+
.title__box {
|
|
20
|
+
line-height: 22px;
|
|
21
|
+
.title__text {
|
|
22
|
+
font-size: 14px;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
&--small {
|
|
27
|
+
.title__box {
|
|
28
|
+
line-height: 20px;
|
|
29
|
+
.title__text {
|
|
30
|
+
font-size: 12px;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
&--background {
|
|
35
|
+
padding: 0 12px;
|
|
36
|
+
background-color: #f9f9fa;
|
|
37
|
+
&.@{card_prefix}__title {
|
|
38
|
+
&--middle,
|
|
39
|
+
&--large {
|
|
40
|
+
height: 40px;
|
|
41
|
+
}
|
|
42
|
+
&--small {
|
|
43
|
+
height: 32px;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
&--pointer {
|
|
48
|
+
cursor: pointer;
|
|
49
|
+
}
|
|
50
|
+
.title {
|
|
51
|
+
&__box {
|
|
52
|
+
flex: 1;
|
|
53
|
+
display: flex;
|
|
54
|
+
align-items: center;
|
|
55
|
+
}
|
|
56
|
+
&__addon-before {
|
|
57
|
+
margin-right: 8px;
|
|
58
|
+
color: @primary-color;
|
|
59
|
+
&--middle {
|
|
60
|
+
.addon-before--default {
|
|
61
|
+
width: 4px;
|
|
62
|
+
height: 16px;
|
|
63
|
+
background-color: @primary-color;
|
|
64
|
+
}
|
|
65
|
+
font-size: 20px;
|
|
66
|
+
}
|
|
67
|
+
&--small {
|
|
68
|
+
.addon-before--default {
|
|
69
|
+
width: 4px;
|
|
70
|
+
height: 16px;
|
|
71
|
+
background-color: @primary-color;
|
|
72
|
+
}
|
|
73
|
+
font-size: 16px;
|
|
74
|
+
}
|
|
75
|
+
&--large {
|
|
76
|
+
.addon-before--default {
|
|
77
|
+
width: 4px;
|
|
78
|
+
height: 20px;
|
|
79
|
+
background-color: @primary-color;
|
|
80
|
+
}
|
|
81
|
+
font-size: 24px;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
&__tooltip {
|
|
85
|
+
display: flex;
|
|
86
|
+
margin-right: 4px;
|
|
87
|
+
font-size: 16px;
|
|
88
|
+
color: #b1b4c5;
|
|
89
|
+
cursor: pointer;
|
|
90
|
+
}
|
|
91
|
+
&__text {
|
|
92
|
+
color: @text-color;
|
|
93
|
+
font-weight: 500;
|
|
94
|
+
margin-right: 4px;
|
|
95
|
+
}
|
|
96
|
+
&__description {
|
|
97
|
+
display: flex;
|
|
98
|
+
align-items: center;
|
|
99
|
+
color: @label-color;
|
|
100
|
+
font-size: 12px;
|
|
101
|
+
}
|
|
102
|
+
&__addon-after {
|
|
103
|
+
color: @label-color;
|
|
104
|
+
}
|
|
105
|
+
&__collapse {
|
|
106
|
+
color: @label-color;
|
|
107
|
+
display: flex;
|
|
108
|
+
align-items: center;
|
|
109
|
+
cursor: pointer;
|
|
110
|
+
user-select: none;
|
|
111
|
+
.collapse {
|
|
112
|
+
&__text {
|
|
113
|
+
font-size: 12px;
|
|
114
|
+
margin: 0 4px;
|
|
115
|
+
}
|
|
116
|
+
&__icon {
|
|
117
|
+
font-size: 16px;
|
|
118
|
+
transition: transform 0.4s;
|
|
119
|
+
&--down {
|
|
120
|
+
transform: rotate(-180deg);
|
|
121
|
+
}
|
|
122
|
+
&--up {
|
|
123
|
+
transform: rotate(0deg);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
&__content {
|
|
131
|
+
opacity: 0;
|
|
132
|
+
height: 0;
|
|
133
|
+
overflow: hidden;
|
|
134
|
+
transition: opacity 0.5s ease, height 0.5s ease;
|
|
135
|
+
&--active {
|
|
136
|
+
opacity: 1;
|
|
137
|
+
padding: 16px 24px;
|
|
138
|
+
height: auto;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
package/lib/index.d.ts
ADDED
package/lib/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "BlockHeader", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _blockHeader.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
require("@dtinsight/react-icons/dist/index.css");
|
|
13
|
+
require("./styles/entry.less");
|
|
14
|
+
var _blockHeader = _interopRequireDefault(require("./blockHeader"));
|
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@primary-color: red;
|
package/package.json
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dtjoy/dt-design",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "react-component",
|
|
5
|
+
"repository": "https://github.com/ZhaoFxxkSky/dt-design",
|
|
6
|
+
"main": "lib/index.js",
|
|
7
|
+
"module": "esm/index.js",
|
|
8
|
+
"types": "esm/index.d.ts",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"start": "npm run dev",
|
|
11
|
+
"dev": "dumi dev",
|
|
12
|
+
"build": "father build",
|
|
13
|
+
"build:watch": "father dev",
|
|
14
|
+
"test": "jest",
|
|
15
|
+
"docs:build": "dumi build",
|
|
16
|
+
"prepare": "husky install && dumi setup",
|
|
17
|
+
"doctor": "father doctor",
|
|
18
|
+
"lint": "npm run lint:es && npm run lint:css",
|
|
19
|
+
"lint:es-fix": "eslint \"src/**/*.{js,jsx,ts,tsx}\" \".dumi/**/*.{js,jsx,ts,tsx}\" --fix",
|
|
20
|
+
"lint:css-fix": "stylelint \"src/**/*.{css,less,scss}\" \".dumi/**/*.{css,less,scss}\" --fix",
|
|
21
|
+
"lint:css": "stylelint \"src/**/*.{css,less,scss}\" \".dumi/**/*.{css,less,scss}\"",
|
|
22
|
+
"lint:es": "eslint \"src/**/*.{js,jsx,ts,tsx}\" \".dumi/**/*.{js,jsx,ts,tsx}\"",
|
|
23
|
+
"prepublishOnly": "npm run build",
|
|
24
|
+
"deploy": "npm run docs:build && gh-pages -d docs-dist",
|
|
25
|
+
"release": "./scripts/release.sh"
|
|
26
|
+
},
|
|
27
|
+
"author": {
|
|
28
|
+
"name": "夕颜",
|
|
29
|
+
"email": "wx-zhaog@dtjoy.com",
|
|
30
|
+
"url": "https://github.com/ZhaoFxxkSky/dt-design"
|
|
31
|
+
},
|
|
32
|
+
"license": "MIT",
|
|
33
|
+
"files": [
|
|
34
|
+
"lib",
|
|
35
|
+
"esm"
|
|
36
|
+
],
|
|
37
|
+
"sideEffects": [
|
|
38
|
+
"lib/*",
|
|
39
|
+
"*.scss",
|
|
40
|
+
"*.less"
|
|
41
|
+
],
|
|
42
|
+
"keywords": [
|
|
43
|
+
"react",
|
|
44
|
+
"react-component",
|
|
45
|
+
"ui-library",
|
|
46
|
+
"typescript",
|
|
47
|
+
"ant-design"
|
|
48
|
+
],
|
|
49
|
+
"commitlint": {
|
|
50
|
+
"extends": [
|
|
51
|
+
"@commitlint/config-conventional"
|
|
52
|
+
]
|
|
53
|
+
},
|
|
54
|
+
"lint-staged": {
|
|
55
|
+
"*.{md,json}": [
|
|
56
|
+
"prettier --write --no-error-on-unmatched-pattern"
|
|
57
|
+
],
|
|
58
|
+
"*.{css,scss}": [
|
|
59
|
+
"stylelint --fix"
|
|
60
|
+
],
|
|
61
|
+
"*.{js,jsx}": [
|
|
62
|
+
"eslint --fix",
|
|
63
|
+
"prettier --write"
|
|
64
|
+
],
|
|
65
|
+
"*.{ts,tsx}": [
|
|
66
|
+
"eslint --fix",
|
|
67
|
+
"prettier --parser=typescript --write"
|
|
68
|
+
]
|
|
69
|
+
},
|
|
70
|
+
"publishConfig": {
|
|
71
|
+
"access": "public"
|
|
72
|
+
},
|
|
73
|
+
"peerDependencies": {
|
|
74
|
+
"react": ">=16.9.0",
|
|
75
|
+
"react-dom": ">=16.9.0"
|
|
76
|
+
},
|
|
77
|
+
"devDependencies": {
|
|
78
|
+
"@commitlint/cli": "^17.1.2",
|
|
79
|
+
"@commitlint/config-conventional": "^17.1.0",
|
|
80
|
+
"@faker-js/faker": "^7.6.0",
|
|
81
|
+
"@testing-library/jest-dom": "^5.16.5",
|
|
82
|
+
"@testing-library/react": "^13.4.0",
|
|
83
|
+
"@testing-library/react-hooks": "^8.0.1",
|
|
84
|
+
"@testing-library/user-event": "^14.4.3",
|
|
85
|
+
"@types/jest": "^29.2.3",
|
|
86
|
+
"@types/lodash-es": "^4.17.12",
|
|
87
|
+
"@types/node": "^24.3.1",
|
|
88
|
+
"@types/react": "^18.0.0",
|
|
89
|
+
"@types/react-resizable": "^3.0.8",
|
|
90
|
+
"@types/react-syntax-highlighter": "~15.5.13",
|
|
91
|
+
"@types/shortid": "^0.0.31",
|
|
92
|
+
"@types/showdown": "^1.9.0",
|
|
93
|
+
"@types/testing-library__jest-dom": "^5.14.5",
|
|
94
|
+
"ant-design-testing": "^1.1.0",
|
|
95
|
+
"babel-plugin-import": "^1.13.8",
|
|
96
|
+
"cz-conventional-changelog": "^3.3.0",
|
|
97
|
+
"dumi": "^2.2.12",
|
|
98
|
+
"eslint": "^8.23.0",
|
|
99
|
+
"father": "~4.1.0",
|
|
100
|
+
"gh-pages": "^4.0.0",
|
|
101
|
+
"husky": "^8.0.1",
|
|
102
|
+
"jest": "^29.3.1",
|
|
103
|
+
"jest-environment-jsdom": "^29.3.1",
|
|
104
|
+
"ko-lint-config": "2.2.21",
|
|
105
|
+
"lint-staged": "^13.0.3",
|
|
106
|
+
"prettier": "^2.7.1",
|
|
107
|
+
"rc-motion": "2.6.2",
|
|
108
|
+
"rc-util": "^5.44.4",
|
|
109
|
+
"react": "^18.0.0",
|
|
110
|
+
"react-dom": "^18.0.0",
|
|
111
|
+
"react-test-renderer": "^18.2.0",
|
|
112
|
+
"resize-observer-polyfill": "^1.5.1",
|
|
113
|
+
"standard-version": "^9.5.0",
|
|
114
|
+
"stylelint": "^14.9.1",
|
|
115
|
+
"ts-jest": "^29.0.3",
|
|
116
|
+
"typescript": "~4.5.2"
|
|
117
|
+
},
|
|
118
|
+
"dependencies": {
|
|
119
|
+
"@dtinsight/dt-utils": "^1.3.1",
|
|
120
|
+
"@dtinsight/react-icons": "^1.0.0",
|
|
121
|
+
"@handsontable/react": "2.1.0",
|
|
122
|
+
"antd": "4.24.16",
|
|
123
|
+
"classnames": "^2.2.6",
|
|
124
|
+
"handsontable": "6.2.2",
|
|
125
|
+
"highlight.js": "^10.5.0",
|
|
126
|
+
"immer": "~10.1.1",
|
|
127
|
+
"lodash-es": "^4.17.21",
|
|
128
|
+
"rc-drawer": "~5.1.0",
|
|
129
|
+
"rc-resize-observer": "^1.4.3",
|
|
130
|
+
"rc-virtual-list": "^3.4.13",
|
|
131
|
+
"react-draggable": "~4.4.6",
|
|
132
|
+
"react-markdown": "~8.0.6",
|
|
133
|
+
"react-resizable": "^3.0.5",
|
|
134
|
+
"react-syntax-highlighter": "~15.5.0",
|
|
135
|
+
"remark-gfm": "~3.0.1",
|
|
136
|
+
"shortid": "^2.2.16",
|
|
137
|
+
"showdown": "^1.9.0"
|
|
138
|
+
},
|
|
139
|
+
"config": {
|
|
140
|
+
"commitizen": {
|
|
141
|
+
"path": "./node_modules/cz-conventional-changelog"
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
"resolutions": {
|
|
145
|
+
"rc-motion": "2.6.2"
|
|
146
|
+
}
|
|
147
|
+
}
|