@dtjoy/dt-design 1.0.0 → 1.0.2
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/esm/_util/gapSize.d.ts +3 -0
- package/esm/_util/gapSize.js +10 -0
- package/esm/_util/hooks/index.d.ts +1 -0
- package/esm/_util/hooks/index.js +1 -0
- package/esm/_util/hooks/useOrientation.d.ts +2 -0
- package/esm/_util/hooks/useOrientation.js +19 -0
- package/esm/_util/isNonNullable.d.ts +2 -0
- package/esm/_util/isNonNullable.js +4 -0
- package/esm/_util/type.d.ts +2 -1
- package/esm/blockHeader/index.d.ts +1 -1
- package/esm/blockHeader/index.js +13 -10
- package/esm/blockHeader/style/index.d.ts +2 -0
- package/esm/blockHeader/style/index.js +2 -0
- package/esm/blockHeader/{style.less → style/index.less} +143 -141
- package/esm/button/index.d.ts +10 -0
- package/esm/button/index.js +29 -0
- package/esm/button/style/index.d.ts +2 -0
- package/esm/button/style/index.js +2 -0
- package/esm/button/style/index.less +134 -0
- package/esm/button/style/mixin.less +47 -0
- package/esm/collapsible/index.d.ts +97 -0
- package/esm/collapsible/index.js +234 -0
- package/esm/collapsible/style/index.d.ts +1 -0
- package/esm/collapsible/style/index.js +1 -0
- package/esm/collapsible/style/index.less +24 -0
- package/esm/collapsibleActionItems/index.d.ts +24 -0
- package/esm/collapsibleActionItems/index.js +74 -0
- package/esm/collapsibleActionItems/style/index.d.ts +2 -0
- package/esm/collapsibleActionItems/style/index.js +2 -0
- package/esm/collapsibleActionItems/style/index.less +7 -0
- package/esm/flex/index.d.ts +7 -0
- package/esm/flex/index.js +62 -0
- package/esm/flex/interface.d.ts +16 -0
- package/esm/flex/interface.js +1 -0
- package/esm/flex/style/index.d.ts +2 -0
- package/esm/flex/style/index.js +2 -0
- package/esm/flex/style/index.less +77 -0
- package/esm/flex/utils.d.ts +7 -0
- package/esm/flex/utils.js +33 -0
- package/esm/index.d.ts +10 -1
- package/esm/index.js +8 -7
- package/esm/resize/index.d.ts +8 -0
- package/esm/resize/index.js +29 -0
- package/esm/splitter/Panel.d.ts +7 -0
- package/esm/splitter/Panel.js +38 -0
- package/esm/splitter/SplitBar.d.ts +24 -0
- package/esm/splitter/SplitBar.js +185 -0
- package/esm/splitter/Splitter.d.ts +5 -0
- package/esm/splitter/Splitter.js +215 -0
- package/esm/splitter/hooks/sizeUtil.d.ts +3 -0
- package/esm/splitter/hooks/sizeUtil.js +63 -0
- package/esm/splitter/hooks/useItems.d.ts +14 -0
- package/esm/splitter/hooks/useItems.js +44 -0
- package/esm/splitter/hooks/useResizable.d.ts +10 -0
- package/esm/splitter/hooks/useResizable.js +73 -0
- package/esm/splitter/hooks/useResize.d.ts +6 -0
- package/esm/splitter/hooks/useResize.js +158 -0
- package/esm/splitter/hooks/useSizes.d.ts +4 -0
- package/esm/splitter/hooks/useSizes.js +80 -0
- package/esm/splitter/index.d.ts +8 -0
- package/esm/splitter/index.js +5 -0
- package/esm/splitter/interface.d.ts +68 -0
- package/esm/splitter/interface.js +1 -0
- package/esm/splitter/style/index.d.ts +2 -0
- package/esm/splitter/style/index.js +2 -0
- package/esm/splitter/style/index.less +312 -0
- package/esm/statusTag/index.d.ts +28 -0
- package/esm/statusTag/index.js +122 -0
- package/esm/statusTag/style/index.d.ts +2 -0
- package/esm/statusTag/style/index.js +2 -0
- package/esm/statusTag/style/index.less +70 -0
- package/esm/statusTag/style/mixin.less +39 -0
- package/esm/style/index.d.ts +1 -0
- package/esm/style/index.js +1 -0
- package/esm/style/index.less +1 -0
- package/esm/style/mixins/index.less +0 -0
- package/esm/style/themes/index.less +2 -0
- package/esm/style/themes/variable.less +1 -0
- package/lib/_util/gapSize.d.ts +3 -0
- package/lib/_util/gapSize.js +17 -0
- package/lib/_util/hooks/index.d.ts +1 -0
- package/lib/_util/hooks/index.js +16 -0
- package/lib/_util/hooks/useOrientation.d.ts +2 -0
- package/lib/_util/hooks/useOrientation.js +26 -0
- package/lib/_util/isNonNullable.d.ts +2 -0
- package/lib/_util/isNonNullable.js +10 -0
- package/lib/_util/type.d.ts +2 -1
- package/lib/blockHeader/index.d.ts +1 -1
- package/lib/blockHeader/index.js +13 -11
- package/lib/blockHeader/style/index.d.ts +2 -0
- package/lib/blockHeader/style/index.js +4 -0
- package/lib/blockHeader/{style.less → style/index.less} +143 -141
- package/lib/button/index.d.ts +10 -0
- package/lib/button/index.js +33 -0
- package/lib/button/style/index.d.ts +2 -0
- package/lib/button/style/index.js +4 -0
- package/lib/button/style/index.less +134 -0
- package/lib/button/style/mixin.less +47 -0
- package/lib/collapsible/index.d.ts +97 -0
- package/lib/collapsible/index.js +199 -0
- package/lib/collapsible/style/index.d.ts +1 -0
- package/lib/collapsible/style/index.js +3 -0
- package/lib/collapsible/style/index.less +24 -0
- package/lib/collapsibleActionItems/index.d.ts +24 -0
- package/lib/collapsibleActionItems/index.js +68 -0
- package/lib/collapsibleActionItems/style/index.d.ts +2 -0
- package/lib/collapsibleActionItems/style/index.js +4 -0
- package/lib/collapsibleActionItems/style/index.less +7 -0
- package/lib/flex/index.d.ts +7 -0
- package/lib/flex/index.js +60 -0
- package/lib/flex/interface.d.ts +16 -0
- package/lib/flex/interface.js +5 -0
- package/lib/flex/style/index.d.ts +2 -0
- package/lib/flex/style/index.js +4 -0
- package/lib/flex/style/index.less +77 -0
- package/lib/flex/utils.d.ts +7 -0
- package/lib/flex/utils.js +39 -0
- package/lib/index.d.ts +10 -1
- package/lib/index.js +72 -1
- package/lib/resize/index.d.ts +8 -0
- package/lib/resize/index.js +38 -0
- package/lib/splitter/Panel.d.ts +7 -0
- package/lib/splitter/Panel.js +44 -0
- package/lib/splitter/SplitBar.d.ts +24 -0
- package/lib/splitter/SplitBar.js +179 -0
- package/lib/splitter/Splitter.d.ts +5 -0
- package/lib/splitter/Splitter.js +202 -0
- package/lib/splitter/hooks/sizeUtil.d.ts +3 -0
- package/lib/splitter/hooks/sizeUtil.js +56 -0
- package/lib/splitter/hooks/useItems.d.ts +14 -0
- package/lib/splitter/hooks/useItems.js +46 -0
- package/lib/splitter/hooks/useResizable.d.ts +10 -0
- package/lib/splitter/hooks/useResizable.js +83 -0
- package/lib/splitter/hooks/useResize.d.ts +6 -0
- package/lib/splitter/hooks/useResize.js +142 -0
- package/lib/splitter/hooks/useSizes.d.ts +4 -0
- package/lib/splitter/hooks/useSizes.js +62 -0
- package/lib/splitter/index.d.ts +8 -0
- package/lib/splitter/index.js +12 -0
- package/lib/splitter/interface.d.ts +68 -0
- package/lib/splitter/interface.js +5 -0
- package/lib/splitter/style/index.d.ts +2 -0
- package/lib/splitter/style/index.js +4 -0
- package/lib/splitter/style/index.less +312 -0
- package/lib/statusTag/index.d.ts +28 -0
- package/lib/statusTag/index.js +125 -0
- package/lib/statusTag/style/index.d.ts +2 -0
- package/lib/statusTag/style/index.js +4 -0
- package/lib/statusTag/style/index.less +70 -0
- package/lib/statusTag/style/mixin.less +39 -0
- package/lib/style/index.d.ts +1 -0
- package/lib/style/index.js +3 -0
- package/lib/style/index.less +1 -0
- package/lib/style/mixins/index.less +0 -0
- package/lib/style/themes/index.less +2 -0
- package/lib/style/themes/variable.less +1 -0
- package/package.json +142 -141
- package/esm/styles/entry.less +0 -6
- package/esm/styles/variables.less +0 -1
- package/lib/styles/entry.less +0 -6
- package/lib/styles/variables.less +0 -1
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
.btn-size-small() {
|
|
2
|
+
@padding: 2px 12px;
|
|
3
|
+
@icon-font-size: 12px;
|
|
4
|
+
@text-font-size: 12px;
|
|
5
|
+
@icon-text-margin: 2px;
|
|
6
|
+
}
|
|
7
|
+
.btn-size-middle() {
|
|
8
|
+
@padding: 4px 16px;
|
|
9
|
+
@icon-font-size: 16px;
|
|
10
|
+
@text-font-size: 14px;
|
|
11
|
+
@icon-text-margin: 8px;
|
|
12
|
+
}
|
|
13
|
+
.btn-size-large() {
|
|
14
|
+
@padding: 3px 40px;
|
|
15
|
+
@icon-font-size: 18px;
|
|
16
|
+
@text-font-size: 14px;
|
|
17
|
+
@icon-text-margin: 8px;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// 禁用状态配置(同样用混入)
|
|
21
|
+
.btn-disabled-primary() {
|
|
22
|
+
@bg: @disabled-color;
|
|
23
|
+
@color: #F9F9F9;
|
|
24
|
+
@border: @disabled-color;
|
|
25
|
+
}
|
|
26
|
+
.btn-disabled-secondary-tertiary() {
|
|
27
|
+
@bg: @primary-color-disabled;
|
|
28
|
+
@color: @disabled-color;
|
|
29
|
+
@border: @border-color-base;
|
|
30
|
+
}
|
|
31
|
+
.btn-disabled-default() {
|
|
32
|
+
@bg: transparent;
|
|
33
|
+
@color: @disabled-color;
|
|
34
|
+
@border: @border-color-base;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// ===================== 工具混入 =====================
|
|
38
|
+
.generate-btn-disabled(@bg, @color, @border) {
|
|
39
|
+
&[disabled],
|
|
40
|
+
&[disabled]:hover {
|
|
41
|
+
background: @bg;
|
|
42
|
+
color: @color;
|
|
43
|
+
border-color: @border;
|
|
44
|
+
cursor: not-allowed;
|
|
45
|
+
opacity: 1;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import './style';
|
|
3
|
+
interface BaseComponentProps {
|
|
4
|
+
/**
|
|
5
|
+
* 类名
|
|
6
|
+
*/
|
|
7
|
+
className?: string;
|
|
8
|
+
/**
|
|
9
|
+
* 样式
|
|
10
|
+
*/
|
|
11
|
+
style?: React.CSSProperties;
|
|
12
|
+
/**
|
|
13
|
+
* id
|
|
14
|
+
*/
|
|
15
|
+
id?: string;
|
|
16
|
+
'data-*'?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface CollapsibleProps extends BaseComponentProps {
|
|
19
|
+
/**
|
|
20
|
+
* 是否开启动画
|
|
21
|
+
*/
|
|
22
|
+
motion?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* 子元素
|
|
25
|
+
*/
|
|
26
|
+
children?: React.ReactNode;
|
|
27
|
+
/**
|
|
28
|
+
* 是否展开内容区域
|
|
29
|
+
*/
|
|
30
|
+
isOpen?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* 动画执行的时间
|
|
33
|
+
*/
|
|
34
|
+
duration?: number;
|
|
35
|
+
/**
|
|
36
|
+
* 是否保留隐藏的面板 DOM 树,默认销毁
|
|
37
|
+
*/
|
|
38
|
+
keepDOM?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* 配合 keepDOM 使用,为 true 时挂载时不会渲染组件
|
|
41
|
+
*/
|
|
42
|
+
lazyRender?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* 折叠高度
|
|
45
|
+
*/
|
|
46
|
+
collapseHeight?: number;
|
|
47
|
+
/**
|
|
48
|
+
* 当 reCalcKey 改变时,将重新计算子节点的高度,用于优化动态渲染时的计算
|
|
49
|
+
*/
|
|
50
|
+
reCalcKey?: number | string;
|
|
51
|
+
/**
|
|
52
|
+
* 动画结束的回调
|
|
53
|
+
*/
|
|
54
|
+
onMotionEnd?: () => void;
|
|
55
|
+
/**
|
|
56
|
+
* 是否开启淡入淡出
|
|
57
|
+
*/
|
|
58
|
+
fade?: boolean;
|
|
59
|
+
}
|
|
60
|
+
interface CollapsibleState {
|
|
61
|
+
domInRenderTree: boolean;
|
|
62
|
+
domHeight: number;
|
|
63
|
+
visible: boolean;
|
|
64
|
+
isTransitioning: boolean;
|
|
65
|
+
cacheIsOpen: boolean;
|
|
66
|
+
}
|
|
67
|
+
declare class Collapsible extends React.Component<CollapsibleProps, CollapsibleState> {
|
|
68
|
+
static defaultProps: {
|
|
69
|
+
isOpen: boolean;
|
|
70
|
+
duration: number;
|
|
71
|
+
motion: boolean;
|
|
72
|
+
keepDOM: boolean;
|
|
73
|
+
lazyRender: boolean;
|
|
74
|
+
collapseHeight: number;
|
|
75
|
+
fade: boolean;
|
|
76
|
+
};
|
|
77
|
+
prefixCls: string;
|
|
78
|
+
foundation: any;
|
|
79
|
+
private domRef;
|
|
80
|
+
private resizeObserver;
|
|
81
|
+
private hasBeenRendered;
|
|
82
|
+
static displayName: string;
|
|
83
|
+
constructor(props: CollapsibleProps);
|
|
84
|
+
private handleResize;
|
|
85
|
+
private isChildrenInRenderTree;
|
|
86
|
+
static getEntryInfo: (entry: ResizeObserverEntry) => {
|
|
87
|
+
isShown: boolean;
|
|
88
|
+
height: number;
|
|
89
|
+
};
|
|
90
|
+
private getDataAttr;
|
|
91
|
+
componentDidMount(): void;
|
|
92
|
+
static getDerivedStateFromProps(props: CollapsibleProps, prevState: CollapsibleState): Partial<CollapsibleState>;
|
|
93
|
+
componentDidUpdate(prevProps: Readonly<CollapsibleProps>, prevState: Readonly<CollapsibleState>): void;
|
|
94
|
+
componentWillUnmount(): void;
|
|
95
|
+
render(): React.JSX.Element;
|
|
96
|
+
}
|
|
97
|
+
export default Collapsible;
|
|
@@ -0,0 +1,234 @@
|
|
|
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 _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 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; }
|
|
4
|
+
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; }
|
|
5
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
6
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
7
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
8
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
9
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
10
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
11
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
12
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
13
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
14
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
15
|
+
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; }
|
|
16
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
17
|
+
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); }
|
|
18
|
+
import React from 'react';
|
|
19
|
+
import { globalConfig } from 'antd/es/config-provider';
|
|
20
|
+
import classNames from 'classnames';
|
|
21
|
+
import { isEqual, pick } from 'lodash';
|
|
22
|
+
import "./style";
|
|
23
|
+
var Collapsible = /*#__PURE__*/function (_React$Component) {
|
|
24
|
+
_inherits(Collapsible, _React$Component);
|
|
25
|
+
var _super = _createSuper(Collapsible);
|
|
26
|
+
// public cssClasses = {
|
|
27
|
+
// PREFIX: 'ant-collapsible',
|
|
28
|
+
// TRANSITION: 'ant-collapsible-transition',
|
|
29
|
+
// WRAPPER: 'ant-collapsible-wrapper',
|
|
30
|
+
// };
|
|
31
|
+
|
|
32
|
+
function Collapsible(_props) {
|
|
33
|
+
var _this;
|
|
34
|
+
_classCallCheck(this, Collapsible);
|
|
35
|
+
_this = _super.call(this, _props);
|
|
36
|
+
_defineProperty(_assertThisInitialized(_this), "prefixCls", 'collapsible');
|
|
37
|
+
_defineProperty(_assertThisInitialized(_this), "foundation", void 0);
|
|
38
|
+
_defineProperty(_assertThisInitialized(_this), "domRef", /*#__PURE__*/React.createRef());
|
|
39
|
+
_defineProperty(_assertThisInitialized(_this), "resizeObserver", null);
|
|
40
|
+
_defineProperty(_assertThisInitialized(_this), "hasBeenRendered", false);
|
|
41
|
+
_defineProperty(_assertThisInitialized(_this), "handleResize", function (entryList) {
|
|
42
|
+
var entry = entryList[0];
|
|
43
|
+
if (entry) {
|
|
44
|
+
var entryInfo = Collapsible.getEntryInfo(entry);
|
|
45
|
+
_this.foundation.updateDOMHeight(entryInfo.height);
|
|
46
|
+
_this.foundation.updateDOMInRenderTree(entryInfo.isShown);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
_defineProperty(_assertThisInitialized(_this), "isChildrenInRenderTree", function () {
|
|
50
|
+
if (_this.domRef.current) {
|
|
51
|
+
return _this.domRef.current.offsetHeight > 0;
|
|
52
|
+
}
|
|
53
|
+
return false;
|
|
54
|
+
});
|
|
55
|
+
_defineProperty(_assertThisInitialized(_this), "getDataAttr", function (props) {
|
|
56
|
+
var dataAttrs = {};
|
|
57
|
+
Object.keys(props).forEach(function (key) {
|
|
58
|
+
if (key.startsWith('data-')) {
|
|
59
|
+
dataAttrs[key] = String(props[key]);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
return dataAttrs;
|
|
63
|
+
});
|
|
64
|
+
_this.state = {
|
|
65
|
+
domInRenderTree: false,
|
|
66
|
+
domHeight: 0,
|
|
67
|
+
visible: _this.props.isOpen || false,
|
|
68
|
+
isTransitioning: false,
|
|
69
|
+
cacheIsOpen: _this.props.isOpen || false
|
|
70
|
+
};
|
|
71
|
+
_this.prefixCls = "".concat(globalConfig().getPrefixCls(_this.prefixCls));
|
|
72
|
+
_this.foundation = {
|
|
73
|
+
updateDOMInRenderTree: function updateDOMInRenderTree(val) {
|
|
74
|
+
return _this.setState({
|
|
75
|
+
domInRenderTree: val
|
|
76
|
+
});
|
|
77
|
+
},
|
|
78
|
+
updateDOMHeight: function updateDOMHeight(val) {
|
|
79
|
+
return _this.setState({
|
|
80
|
+
domHeight: val
|
|
81
|
+
});
|
|
82
|
+
},
|
|
83
|
+
updateVisible: function updateVisible(val) {
|
|
84
|
+
return _this.setState({
|
|
85
|
+
visible: val
|
|
86
|
+
});
|
|
87
|
+
},
|
|
88
|
+
updateIsTransitioning: function updateIsTransitioning(val) {
|
|
89
|
+
return _this.setState({
|
|
90
|
+
isTransitioning: val
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
return _this;
|
|
95
|
+
}
|
|
96
|
+
_createClass(Collapsible, [{
|
|
97
|
+
key: "componentDidMount",
|
|
98
|
+
value: function componentDidMount() {
|
|
99
|
+
this.resizeObserver = new ResizeObserver(this.handleResize);
|
|
100
|
+
if (this.domRef.current) {
|
|
101
|
+
this.resizeObserver.observe(this.domRef.current);
|
|
102
|
+
}
|
|
103
|
+
var domInRenderTree = this.isChildrenInRenderTree();
|
|
104
|
+
this.foundation.updateDOMInRenderTree(domInRenderTree);
|
|
105
|
+
if (domInRenderTree && this.domRef.current) {
|
|
106
|
+
this.foundation.updateDOMHeight(this.domRef.current.scrollHeight);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}, {
|
|
110
|
+
key: "componentDidUpdate",
|
|
111
|
+
value: function componentDidUpdate(prevProps, prevState) {
|
|
112
|
+
var _this2 = this;
|
|
113
|
+
var changedPropKeys = Object.keys(pick(this.props, ['reCalcKey'])).filter(function (key) {
|
|
114
|
+
return !isEqual(_this2.props[key], prevProps[key]);
|
|
115
|
+
});
|
|
116
|
+
var changedStateKeys = Object.keys(pick(this.state, ['domInRenderTree'])).filter(function (key) {
|
|
117
|
+
return !isEqual(_this2.state[key], prevState[key]);
|
|
118
|
+
});
|
|
119
|
+
if (changedPropKeys.includes('reCalcKey') && this.domRef.current) {
|
|
120
|
+
this.foundation.updateDOMHeight(this.domRef.current.scrollHeight);
|
|
121
|
+
}
|
|
122
|
+
if (changedStateKeys.includes('domInRenderTree') && this.state.domInRenderTree && this.domRef.current) {
|
|
123
|
+
this.foundation.updateDOMHeight(this.domRef.current.scrollHeight);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}, {
|
|
127
|
+
key: "componentWillUnmount",
|
|
128
|
+
value: function componentWillUnmount() {
|
|
129
|
+
if (this.resizeObserver) {
|
|
130
|
+
this.resizeObserver.disconnect();
|
|
131
|
+
this.resizeObserver = null;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}, {
|
|
135
|
+
key: "render",
|
|
136
|
+
value: function render() {
|
|
137
|
+
var _this3 = this;
|
|
138
|
+
var _this$props = this.props,
|
|
139
|
+
isOpen = _this$props.isOpen,
|
|
140
|
+
collapseHeight = _this$props.collapseHeight,
|
|
141
|
+
fade = _this$props.fade,
|
|
142
|
+
motion = _this$props.motion,
|
|
143
|
+
duration = _this$props.duration,
|
|
144
|
+
style = _this$props.style,
|
|
145
|
+
className = _this$props.className,
|
|
146
|
+
id = _this$props.id,
|
|
147
|
+
keepDOM = _this$props.keepDOM,
|
|
148
|
+
lazyRender = _this$props.lazyRender,
|
|
149
|
+
onMotionEnd = _this$props.onMotionEnd;
|
|
150
|
+
var _this$state = this.state,
|
|
151
|
+
domHeight = _this$state.domHeight,
|
|
152
|
+
isTransitioning = _this$state.isTransitioning,
|
|
153
|
+
visible = _this$state.visible;
|
|
154
|
+
var wrapperStyle = _objectSpread({
|
|
155
|
+
overflow: 'hidden',
|
|
156
|
+
height: isOpen ? domHeight : collapseHeight,
|
|
157
|
+
opacity: isOpen || !fade || collapseHeight !== 0 ? 1 : 0,
|
|
158
|
+
transitionDuration: "".concat(motion && isTransitioning ? duration : 0, "ms")
|
|
159
|
+
}, style);
|
|
160
|
+
var wrapperCls = classNames("".concat(this.prefixCls, "-wrapper"), _defineProperty({}, "".concat(this.prefixCls, "-transition"), motion && isTransitioning), className);
|
|
161
|
+
var shouldRender = keepDOM && (lazyRender ? this.hasBeenRendered : true) || collapseHeight !== 0 || visible || isOpen;
|
|
162
|
+
if (shouldRender && !this.hasBeenRendered) {
|
|
163
|
+
this.hasBeenRendered = true;
|
|
164
|
+
}
|
|
165
|
+
return /*#__PURE__*/React.createElement("div", _extends({
|
|
166
|
+
className: wrapperCls,
|
|
167
|
+
style: wrapperStyle,
|
|
168
|
+
onTransitionEnd: function onTransitionEnd() {
|
|
169
|
+
if (!isOpen) {
|
|
170
|
+
_this3.foundation.updateVisible(false);
|
|
171
|
+
}
|
|
172
|
+
_this3.foundation.updateIsTransitioning(false);
|
|
173
|
+
onMotionEnd === null || onMotionEnd === void 0 || onMotionEnd();
|
|
174
|
+
}
|
|
175
|
+
}, this.getDataAttr(this.props)), /*#__PURE__*/React.createElement("div", {
|
|
176
|
+
ref: this.domRef,
|
|
177
|
+
style: {
|
|
178
|
+
overflow: 'hidden'
|
|
179
|
+
},
|
|
180
|
+
id: id
|
|
181
|
+
}, shouldRender && this.props.children));
|
|
182
|
+
}
|
|
183
|
+
}], [{
|
|
184
|
+
key: "getDerivedStateFromProps",
|
|
185
|
+
value: function getDerivedStateFromProps(props, prevState) {
|
|
186
|
+
var newState = {};
|
|
187
|
+
var isOpenChanged = props.isOpen !== prevState.cacheIsOpen;
|
|
188
|
+
if (isOpenChanged) {
|
|
189
|
+
if (props.isOpen || !props.motion) {
|
|
190
|
+
newState.visible = props.isOpen;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
if (props.motion && isOpenChanged) {
|
|
194
|
+
newState.isTransitioning = true;
|
|
195
|
+
}
|
|
196
|
+
newState.cacheIsOpen = props.isOpen;
|
|
197
|
+
return newState;
|
|
198
|
+
}
|
|
199
|
+
}]);
|
|
200
|
+
return Collapsible;
|
|
201
|
+
}(React.Component);
|
|
202
|
+
_defineProperty(Collapsible, "defaultProps", {
|
|
203
|
+
isOpen: false,
|
|
204
|
+
duration: 250,
|
|
205
|
+
motion: true,
|
|
206
|
+
keepDOM: false,
|
|
207
|
+
lazyRender: false,
|
|
208
|
+
collapseHeight: 0,
|
|
209
|
+
fade: false
|
|
210
|
+
});
|
|
211
|
+
_defineProperty(Collapsible, "displayName", void 0);
|
|
212
|
+
_defineProperty(Collapsible, "getEntryInfo", function (entry) {
|
|
213
|
+
var inRenderTree;
|
|
214
|
+
if (entry.borderBoxSize) {
|
|
215
|
+
inRenderTree = !(entry.borderBoxSize[0].blockSize === 0 && entry.borderBoxSize[0].inlineSize === 0);
|
|
216
|
+
} else {
|
|
217
|
+
inRenderTree = !(entry.contentRect.height === 0 && entry.contentRect.width === 0);
|
|
218
|
+
}
|
|
219
|
+
var height = 0;
|
|
220
|
+
if (entry.borderBoxSize) {
|
|
221
|
+
height = Math.ceil(entry.borderBoxSize[0].blockSize);
|
|
222
|
+
} else {
|
|
223
|
+
var target = entry.target;
|
|
224
|
+
height = target.clientHeight;
|
|
225
|
+
}
|
|
226
|
+
return {
|
|
227
|
+
isShown: inRenderTree,
|
|
228
|
+
height: height
|
|
229
|
+
};
|
|
230
|
+
});
|
|
231
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
232
|
+
Collapsible.displayName = 'Collapsible';
|
|
233
|
+
}
|
|
234
|
+
export default Collapsible;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './index.less';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./index.less";
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
@import '../../style/themes/index.less';
|
|
2
|
+
|
|
3
|
+
@collapsible-prefix-cls: ~'@{ant-prefix}-collapsible';
|
|
4
|
+
|
|
5
|
+
@transition-duration-collapsible-height: 250ms;
|
|
6
|
+
@transition-function-collapsible-height: cubic-bezier(0.25, 0.1, 0.25, 1);
|
|
7
|
+
@transition-delay-collapsible-height: 0ms;
|
|
8
|
+
|
|
9
|
+
@transition-duration-collapsible-opacity: 250ms;
|
|
10
|
+
@transition-function-collapsible-opacity: @ease-in;
|
|
11
|
+
@transition-delay-collapsible-opacity: 0ms;
|
|
12
|
+
|
|
13
|
+
// 容器基础样式
|
|
14
|
+
.@{collapsible-prefix-cls}-wrapper {
|
|
15
|
+
box-sizing: border-box;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// 过渡动画样式
|
|
19
|
+
.@{collapsible-prefix-cls}-transition {
|
|
20
|
+
transition: height @transition-duration-collapsible-height
|
|
21
|
+
@transition-function-collapsible-height @transition-delay-collapsible-height,
|
|
22
|
+
opacity @transition-duration-collapsible-opacity @transition-function-collapsible-opacity
|
|
23
|
+
@transition-delay-collapsible-opacity;
|
|
24
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import type { ButtonProps } from "..";
|
|
4
|
+
import type { DropDownProps } from 'antd';
|
|
5
|
+
import './style';
|
|
6
|
+
export declare type ActionItem = {
|
|
7
|
+
key: React.Key;
|
|
8
|
+
name: ReactNode;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
render?: () => ReactNode;
|
|
11
|
+
};
|
|
12
|
+
interface ICollapsibleActionItems {
|
|
13
|
+
maxCount?: number;
|
|
14
|
+
actionItems: ActionItem[];
|
|
15
|
+
className?: string;
|
|
16
|
+
divider?: ReactNode;
|
|
17
|
+
collapseIcon?: ReactNode;
|
|
18
|
+
dropdownProps?: Partial<DropDownProps>;
|
|
19
|
+
buttonProps?: Partial<ButtonProps>;
|
|
20
|
+
style?: React.CSSProperties;
|
|
21
|
+
onItemClick?: (key: React.Key) => void;
|
|
22
|
+
}
|
|
23
|
+
declare const CollapsibleActionItems: React.FC<ICollapsibleActionItems>;
|
|
24
|
+
export default CollapsibleActionItems;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
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); }
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { EllipsisOutlined } from '@ant-design/icons';
|
|
4
|
+
import { Button } from "./..";
|
|
5
|
+
import { Divider, Dropdown, Menu } from 'antd';
|
|
6
|
+
import { globalConfig } from 'antd/es/config-provider';
|
|
7
|
+
import classNames from 'classnames';
|
|
8
|
+
import "./style";
|
|
9
|
+
var CollapsibleActionItems = function CollapsibleActionItems(props) {
|
|
10
|
+
var actionItems = props.actionItems,
|
|
11
|
+
_props$maxCount = props.maxCount,
|
|
12
|
+
maxCount = _props$maxCount === void 0 ? 3 : _props$maxCount,
|
|
13
|
+
className = props.className,
|
|
14
|
+
_props$divider = props.divider,
|
|
15
|
+
divider = _props$divider === void 0 ? /*#__PURE__*/React.createElement(Divider, {
|
|
16
|
+
type: "vertical"
|
|
17
|
+
}) : _props$divider,
|
|
18
|
+
_props$collapseIcon = props.collapseIcon,
|
|
19
|
+
collapseIcon = _props$collapseIcon === void 0 ? /*#__PURE__*/React.createElement(EllipsisOutlined, null) : _props$collapseIcon,
|
|
20
|
+
dropdownProps = props.dropdownProps,
|
|
21
|
+
buttonProps = props.buttonProps,
|
|
22
|
+
style = props.style,
|
|
23
|
+
onItemClick = props.onItemClick;
|
|
24
|
+
var isOverMaxCount = actionItems.length > maxCount;
|
|
25
|
+
var prefixCls = globalConfig().getPrefixCls('collapsible-action-items');
|
|
26
|
+
var getActionItemNode = function getActionItemNode(item) {
|
|
27
|
+
var isCollapse = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
28
|
+
var customRender = item.render ? item.render() : null;
|
|
29
|
+
if (!isCollapse) return /*#__PURE__*/React.createElement("span", {
|
|
30
|
+
className: "".concat(prefixCls, "__btn"),
|
|
31
|
+
key: item.key,
|
|
32
|
+
onClick: function onClick() {
|
|
33
|
+
return !item.disabled && (onItemClick === null || onItemClick === void 0 ? void 0 : onItemClick(item.key));
|
|
34
|
+
}
|
|
35
|
+
}, customRender || /*#__PURE__*/React.createElement(Button, _extends({
|
|
36
|
+
type: "link",
|
|
37
|
+
disabled: item.disabled
|
|
38
|
+
}, buttonProps), item.name));
|
|
39
|
+
return /*#__PURE__*/React.createElement(Menu.Item, {
|
|
40
|
+
key: item.key,
|
|
41
|
+
disabled: item.disabled
|
|
42
|
+
}, customRender || item.name);
|
|
43
|
+
};
|
|
44
|
+
var displayAction = actionItems.slice(0, isOverMaxCount ? maxCount - 1 : maxCount).map(function (item) {
|
|
45
|
+
return getActionItemNode(item, false);
|
|
46
|
+
});
|
|
47
|
+
var dropdownMenu = isOverMaxCount ? /*#__PURE__*/React.createElement(Menu, {
|
|
48
|
+
"data-testid": "action-dropdown-menu",
|
|
49
|
+
onClick: function onClick(info) {
|
|
50
|
+
return onItemClick === null || onItemClick === void 0 ? void 0 : onItemClick(info.key);
|
|
51
|
+
}
|
|
52
|
+
}, actionItems.slice(maxCount - 1).map(function (item) {
|
|
53
|
+
return getActionItemNode(item, true);
|
|
54
|
+
})) : null;
|
|
55
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
56
|
+
className: classNames(prefixCls, className),
|
|
57
|
+
style: style
|
|
58
|
+
}, displayAction.map(function (actionItem, index) {
|
|
59
|
+
var showDivider = index < actionItems.length - 1;
|
|
60
|
+
return /*#__PURE__*/React.createElement(React.Fragment, {
|
|
61
|
+
key: actionItem.key
|
|
62
|
+
}, actionItem, showDivider && divider);
|
|
63
|
+
}), dropdownMenu && /*#__PURE__*/React.createElement(Dropdown, _extends({
|
|
64
|
+
placement: 'bottomRight',
|
|
65
|
+
overlay: dropdownMenu,
|
|
66
|
+
getPopupContainer: function getPopupContainer(triggerNode) {
|
|
67
|
+
var _triggerNode$parentEl;
|
|
68
|
+
return (_triggerNode$parentEl = triggerNode.parentElement) !== null && _triggerNode$parentEl !== void 0 ? _triggerNode$parentEl : document.body;
|
|
69
|
+
}
|
|
70
|
+
}, dropdownProps), /*#__PURE__*/React.createElement("a", {
|
|
71
|
+
className: "".concat(prefixCls, "__icon")
|
|
72
|
+
}, collapseIcon)));
|
|
73
|
+
};
|
|
74
|
+
export default CollapsibleActionItems;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import './style';
|
|
3
|
+
import type { FlexProps } from './interface';
|
|
4
|
+
declare const Flex: React.ForwardRefExoticComponent<FlexProps<import("../_util/type").AnyObject> & {
|
|
5
|
+
children?: React.ReactNode;
|
|
6
|
+
} & React.RefAttributes<HTMLElement>>;
|
|
7
|
+
export default Flex;
|
|
@@ -0,0 +1,62 @@
|
|
|
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
|
+
var _excluded = ["prefixCls", "rootClassName", "className", "style", "flex", "gap", "vertical", "orientation", "component", "children"];
|
|
3
|
+
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); }
|
|
4
|
+
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; }
|
|
5
|
+
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; }
|
|
6
|
+
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; }
|
|
7
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
8
|
+
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); }
|
|
9
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
10
|
+
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."); }
|
|
11
|
+
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); }
|
|
12
|
+
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; }
|
|
13
|
+
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; } }
|
|
14
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
15
|
+
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; }
|
|
16
|
+
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; }
|
|
17
|
+
import React from 'react';
|
|
18
|
+
import { ConfigContext, globalConfig } from 'antd/es/config-provider';
|
|
19
|
+
import { clsx } from 'clsx';
|
|
20
|
+
import { omit } from 'lodash-es';
|
|
21
|
+
import "./style";
|
|
22
|
+
import { isPresetSize } from "../_util/gapSize";
|
|
23
|
+
import { useOrientation } from "../_util/hooks";
|
|
24
|
+
import isNonNullable from "../_util/isNonNullable";
|
|
25
|
+
import createFlexClassNames from "./utils";
|
|
26
|
+
var Flex = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
27
|
+
var customizePrefixCls = props.prefixCls,
|
|
28
|
+
rootClassName = props.rootClassName,
|
|
29
|
+
className = props.className,
|
|
30
|
+
style = props.style,
|
|
31
|
+
flex = props.flex,
|
|
32
|
+
gap = props.gap,
|
|
33
|
+
vertical = props.vertical,
|
|
34
|
+
orientation = props.orientation,
|
|
35
|
+
_props$component = props.component,
|
|
36
|
+
Component = _props$component === void 0 ? 'div' : _props$component,
|
|
37
|
+
children = props.children,
|
|
38
|
+
othersProps = _objectWithoutProperties(props, _excluded);
|
|
39
|
+
var _React$useContext = React.useContext(ConfigContext),
|
|
40
|
+
ctxDirection = _React$useContext.direction;
|
|
41
|
+
var prefixCls = customizePrefixCls || globalConfig().getPrefixCls('flex');
|
|
42
|
+
var _useOrientation = useOrientation(orientation, vertical),
|
|
43
|
+
_useOrientation2 = _slicedToArray(_useOrientation, 1),
|
|
44
|
+
mergedVertical = _useOrientation2[0];
|
|
45
|
+
var mergedCls = clsx(className, rootClassName, prefixCls, createFlexClassNames(prefixCls, props), _defineProperty(_defineProperty(_defineProperty({}, "".concat(prefixCls, "-rtl"), ctxDirection === 'rtl'), "".concat(prefixCls, "-gap-").concat(gap), isPresetSize(gap)), "".concat(prefixCls, "-vertical"), mergedVertical === 'vertical'));
|
|
46
|
+
var mergedStyle = _objectSpread({}, style);
|
|
47
|
+
if (isNonNullable(flex)) {
|
|
48
|
+
mergedStyle.flex = flex;
|
|
49
|
+
}
|
|
50
|
+
if (isNonNullable(gap) && !isPresetSize(gap)) {
|
|
51
|
+
mergedStyle.gap = gap;
|
|
52
|
+
}
|
|
53
|
+
return /*#__PURE__*/React.createElement(Component, _extends({
|
|
54
|
+
ref: ref,
|
|
55
|
+
className: mergedCls,
|
|
56
|
+
style: mergedStyle
|
|
57
|
+
}, omit(othersProps, ['justify', 'wrap', 'align'])), children);
|
|
58
|
+
});
|
|
59
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
60
|
+
Flex.displayName = 'Flex';
|
|
61
|
+
}
|
|
62
|
+
export default Flex;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import { SizeType } from 'antd/es/config-provider/SizeContext';
|
|
3
|
+
import type { Orientation } from '../_util/hooks';
|
|
4
|
+
import type { AnyObject, CustomComponent, LiteralUnion } from '../_util/type';
|
|
5
|
+
export interface FlexProps<P = AnyObject> extends React.HTMLAttributes<HTMLElement> {
|
|
6
|
+
prefixCls?: string;
|
|
7
|
+
rootClassName?: string;
|
|
8
|
+
vertical?: boolean;
|
|
9
|
+
orientation?: Orientation;
|
|
10
|
+
wrap?: boolean | React.CSSProperties['flexWrap'];
|
|
11
|
+
justify?: React.CSSProperties['justifyContent'];
|
|
12
|
+
align?: React.CSSProperties['alignItems'];
|
|
13
|
+
flex?: React.CSSProperties['flex'];
|
|
14
|
+
gap?: LiteralUnion<SizeType, React.CSSProperties['gap']>;
|
|
15
|
+
component?: CustomComponent<P>;
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|