@dtjoy/dt-design 1.0.1 → 1.0.3

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.
Files changed (155) hide show
  1. package/esm/_util/gapSize.d.ts +3 -0
  2. package/esm/_util/gapSize.js +10 -0
  3. package/esm/_util/hooks/index.d.ts +1 -0
  4. package/esm/_util/hooks/index.js +1 -0
  5. package/esm/_util/hooks/useOrientation.d.ts +2 -0
  6. package/esm/_util/hooks/useOrientation.js +19 -0
  7. package/esm/_util/isNonNullable.d.ts +2 -0
  8. package/esm/_util/isNonNullable.js +4 -0
  9. package/esm/_util/type.d.ts +2 -1
  10. package/esm/blockHeader/index.js +12 -11
  11. package/esm/blockHeader/style/index.d.ts +1 -1
  12. package/esm/blockHeader/style/index.js +1 -1
  13. package/esm/blockHeader/style/index.less +9 -8
  14. package/esm/button/style/index.less +60 -46
  15. package/esm/button/style/mixin.less +47 -0
  16. package/esm/collapsible/index.d.ts +97 -0
  17. package/esm/collapsible/index.js +234 -0
  18. package/esm/collapsible/style/index.d.ts +1 -0
  19. package/esm/collapsible/style/index.js +1 -0
  20. package/esm/collapsible/style/index.less +24 -0
  21. package/esm/collapsibleActionItems/index.d.ts +24 -0
  22. package/esm/collapsibleActionItems/index.js +74 -0
  23. package/esm/collapsibleActionItems/style/index.d.ts +2 -0
  24. package/esm/collapsibleActionItems/style/index.js +2 -0
  25. package/esm/collapsibleActionItems/style/index.less +7 -0
  26. package/esm/flex/index.d.ts +7 -0
  27. package/esm/flex/index.js +62 -0
  28. package/esm/flex/interface.d.ts +16 -0
  29. package/esm/flex/interface.js +1 -0
  30. package/esm/flex/style/index.d.ts +2 -0
  31. package/esm/flex/style/index.js +2 -0
  32. package/esm/flex/style/index.less +77 -0
  33. package/esm/flex/utils.d.ts +7 -0
  34. package/esm/flex/utils.js +33 -0
  35. package/esm/index.d.ts +10 -1
  36. package/esm/index.js +8 -6
  37. package/esm/overflowList/index.d.ts +39 -0
  38. package/esm/overflowList/index.js +165 -0
  39. package/esm/overflowList/style/index.d.ts +2 -0
  40. package/esm/overflowList/style/index.js +2 -0
  41. package/esm/overflowList/style/index.less +9 -0
  42. package/esm/resize/index.d.ts +8 -0
  43. package/esm/resize/index.js +29 -0
  44. package/esm/resizeObserver/index.d.ts +45 -0
  45. package/esm/resizeObserver/index.js +175 -0
  46. package/esm/splitter/Panel.d.ts +7 -0
  47. package/esm/splitter/Panel.js +38 -0
  48. package/esm/splitter/SplitBar.d.ts +24 -0
  49. package/esm/splitter/SplitBar.js +185 -0
  50. package/esm/splitter/Splitter.d.ts +5 -0
  51. package/esm/splitter/Splitter.js +197 -0
  52. package/esm/splitter/hooks/sizeUtil.d.ts +3 -0
  53. package/esm/splitter/hooks/sizeUtil.js +63 -0
  54. package/esm/splitter/hooks/useItems.d.ts +14 -0
  55. package/esm/splitter/hooks/useItems.js +44 -0
  56. package/esm/splitter/hooks/useResizable.d.ts +10 -0
  57. package/esm/splitter/hooks/useResizable.js +73 -0
  58. package/esm/splitter/hooks/useResize.d.ts +6 -0
  59. package/esm/splitter/hooks/useResize.js +158 -0
  60. package/esm/splitter/hooks/useSizes.d.ts +4 -0
  61. package/esm/splitter/hooks/useSizes.js +80 -0
  62. package/esm/splitter/index.d.ts +8 -0
  63. package/esm/splitter/index.js +5 -0
  64. package/esm/splitter/interface.d.ts +68 -0
  65. package/esm/splitter/interface.js +1 -0
  66. package/esm/splitter/style/index.d.ts +2 -0
  67. package/esm/splitter/style/index.js +2 -0
  68. package/esm/splitter/style/index.less +312 -0
  69. package/esm/statusTag/index.d.ts +28 -0
  70. package/esm/statusTag/index.js +122 -0
  71. package/esm/statusTag/style/index.d.ts +2 -0
  72. package/esm/statusTag/style/index.js +2 -0
  73. package/esm/statusTag/style/index.less +70 -0
  74. package/esm/statusTag/style/mixin.less +39 -0
  75. package/esm/style/mixins/index.less +0 -0
  76. package/esm/style/themes/index.less +2 -1
  77. package/esm/style/themes/variable.less +1 -0
  78. package/lib/_util/gapSize.d.ts +3 -0
  79. package/lib/_util/gapSize.js +17 -0
  80. package/lib/_util/hooks/index.d.ts +1 -0
  81. package/lib/_util/hooks/index.js +16 -0
  82. package/lib/_util/hooks/useOrientation.d.ts +2 -0
  83. package/lib/_util/hooks/useOrientation.js +26 -0
  84. package/lib/_util/isNonNullable.d.ts +2 -0
  85. package/lib/_util/isNonNullable.js +10 -0
  86. package/lib/_util/type.d.ts +2 -1
  87. package/lib/blockHeader/index.js +12 -12
  88. package/lib/blockHeader/style/index.d.ts +1 -1
  89. package/lib/blockHeader/style/index.js +1 -1
  90. package/lib/blockHeader/style/index.less +9 -8
  91. package/lib/button/style/index.less +60 -46
  92. package/lib/button/style/mixin.less +47 -0
  93. package/lib/collapsible/index.d.ts +97 -0
  94. package/lib/collapsible/index.js +199 -0
  95. package/lib/collapsible/style/index.d.ts +1 -0
  96. package/lib/collapsible/style/index.js +3 -0
  97. package/lib/collapsible/style/index.less +24 -0
  98. package/lib/collapsibleActionItems/index.d.ts +24 -0
  99. package/lib/collapsibleActionItems/index.js +68 -0
  100. package/lib/collapsibleActionItems/style/index.d.ts +2 -0
  101. package/lib/collapsibleActionItems/style/index.js +4 -0
  102. package/lib/collapsibleActionItems/style/index.less +7 -0
  103. package/lib/flex/index.d.ts +7 -0
  104. package/lib/flex/index.js +60 -0
  105. package/lib/flex/interface.d.ts +16 -0
  106. package/lib/flex/interface.js +5 -0
  107. package/lib/flex/style/index.d.ts +2 -0
  108. package/lib/flex/style/index.js +4 -0
  109. package/lib/flex/style/index.less +77 -0
  110. package/lib/flex/utils.d.ts +7 -0
  111. package/lib/flex/utils.js +40 -0
  112. package/lib/index.d.ts +10 -1
  113. package/lib/index.js +73 -1
  114. package/lib/overflowList/index.d.ts +39 -0
  115. package/lib/overflowList/index.js +143 -0
  116. package/lib/overflowList/style/index.d.ts +2 -0
  117. package/lib/overflowList/style/index.js +4 -0
  118. package/lib/overflowList/style/index.less +9 -0
  119. package/lib/resize/index.d.ts +8 -0
  120. package/lib/resize/index.js +38 -0
  121. package/lib/resizeObserver/index.d.ts +45 -0
  122. package/lib/resizeObserver/index.js +136 -0
  123. package/lib/splitter/Panel.d.ts +7 -0
  124. package/lib/splitter/Panel.js +44 -0
  125. package/lib/splitter/SplitBar.d.ts +24 -0
  126. package/lib/splitter/SplitBar.js +179 -0
  127. package/lib/splitter/Splitter.d.ts +5 -0
  128. package/lib/splitter/Splitter.js +186 -0
  129. package/lib/splitter/hooks/sizeUtil.d.ts +3 -0
  130. package/lib/splitter/hooks/sizeUtil.js +56 -0
  131. package/lib/splitter/hooks/useItems.d.ts +14 -0
  132. package/lib/splitter/hooks/useItems.js +46 -0
  133. package/lib/splitter/hooks/useResizable.d.ts +10 -0
  134. package/lib/splitter/hooks/useResizable.js +83 -0
  135. package/lib/splitter/hooks/useResize.d.ts +6 -0
  136. package/lib/splitter/hooks/useResize.js +142 -0
  137. package/lib/splitter/hooks/useSizes.d.ts +4 -0
  138. package/lib/splitter/hooks/useSizes.js +62 -0
  139. package/lib/splitter/index.d.ts +8 -0
  140. package/lib/splitter/index.js +12 -0
  141. package/lib/splitter/interface.d.ts +68 -0
  142. package/lib/splitter/interface.js +5 -0
  143. package/lib/splitter/style/index.d.ts +2 -0
  144. package/lib/splitter/style/index.js +4 -0
  145. package/lib/splitter/style/index.less +312 -0
  146. package/lib/statusTag/index.d.ts +28 -0
  147. package/lib/statusTag/index.js +125 -0
  148. package/lib/statusTag/style/index.d.ts +2 -0
  149. package/lib/statusTag/style/index.js +4 -0
  150. package/lib/statusTag/style/index.less +70 -0
  151. package/lib/statusTag/style/mixin.less +39 -0
  152. package/lib/style/mixins/index.less +0 -0
  153. package/lib/style/themes/index.less +2 -1
  154. package/lib/style/themes/variable.less +1 -0
  155. package/package.json +11 -19
@@ -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,199 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _configProvider = require("antd/es/config-provider");
9
+ var _classnames = _interopRequireDefault(require("classnames"));
10
+ var _lodashEs = require("lodash-es");
11
+ require("./style");
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+ 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); }
14
+ class Collapsible extends _react.default.Component {
15
+ static defaultProps = {
16
+ isOpen: false,
17
+ duration: 250,
18
+ motion: true,
19
+ keepDOM: false,
20
+ lazyRender: false,
21
+ collapseHeight: 0,
22
+ fade: false
23
+ };
24
+ prefixCls = 'collapsible';
25
+ foundation;
26
+ domRef = /*#__PURE__*/_react.default.createRef();
27
+ resizeObserver = null;
28
+ hasBeenRendered = false;
29
+ static displayName;
30
+ // public cssClasses = {
31
+ // PREFIX: 'ant-collapsible',
32
+ // TRANSITION: 'ant-collapsible-transition',
33
+ // WRAPPER: 'ant-collapsible-wrapper',
34
+ // };
35
+
36
+ constructor(props) {
37
+ super(props);
38
+ this.state = {
39
+ domInRenderTree: false,
40
+ domHeight: 0,
41
+ visible: this.props.isOpen || false,
42
+ isTransitioning: false,
43
+ cacheIsOpen: this.props.isOpen || false
44
+ };
45
+ this.prefixCls = `${(0, _configProvider.globalConfig)().getPrefixCls(this.prefixCls)}`;
46
+ this.foundation = {
47
+ updateDOMInRenderTree: val => this.setState({
48
+ domInRenderTree: val
49
+ }),
50
+ updateDOMHeight: val => this.setState({
51
+ domHeight: val
52
+ }),
53
+ updateVisible: val => this.setState({
54
+ visible: val
55
+ }),
56
+ updateIsTransitioning: val => this.setState({
57
+ isTransitioning: val
58
+ })
59
+ };
60
+ }
61
+ handleResize = entryList => {
62
+ const entry = entryList[0];
63
+ if (entry) {
64
+ const entryInfo = Collapsible.getEntryInfo(entry);
65
+ this.foundation.updateDOMHeight(entryInfo.height);
66
+ this.foundation.updateDOMInRenderTree(entryInfo.isShown);
67
+ }
68
+ };
69
+ isChildrenInRenderTree = () => {
70
+ if (this.domRef.current) {
71
+ return this.domRef.current.offsetHeight > 0;
72
+ }
73
+ return false;
74
+ };
75
+ static getEntryInfo = entry => {
76
+ let inRenderTree;
77
+ if (entry.borderBoxSize) {
78
+ inRenderTree = !(entry.borderBoxSize[0].blockSize === 0 && entry.borderBoxSize[0].inlineSize === 0);
79
+ } else {
80
+ inRenderTree = !(entry.contentRect.height === 0 && entry.contentRect.width === 0);
81
+ }
82
+ let height = 0;
83
+ if (entry.borderBoxSize) {
84
+ height = Math.ceil(entry.borderBoxSize[0].blockSize);
85
+ } else {
86
+ const target = entry.target;
87
+ height = target.clientHeight;
88
+ }
89
+ return {
90
+ isShown: inRenderTree,
91
+ height
92
+ };
93
+ };
94
+ getDataAttr = props => {
95
+ const dataAttrs = {};
96
+ Object.keys(props).forEach(key => {
97
+ if (key.startsWith('data-')) {
98
+ dataAttrs[key] = String(props[key]);
99
+ }
100
+ });
101
+ return dataAttrs;
102
+ };
103
+ componentDidMount() {
104
+ this.resizeObserver = new ResizeObserver(this.handleResize);
105
+ if (this.domRef.current) {
106
+ this.resizeObserver.observe(this.domRef.current);
107
+ }
108
+ const domInRenderTree = this.isChildrenInRenderTree();
109
+ this.foundation.updateDOMInRenderTree(domInRenderTree);
110
+ if (domInRenderTree && this.domRef.current) {
111
+ this.foundation.updateDOMHeight(this.domRef.current.scrollHeight);
112
+ }
113
+ }
114
+ static getDerivedStateFromProps(props, prevState) {
115
+ const newState = {};
116
+ const isOpenChanged = props.isOpen !== prevState.cacheIsOpen;
117
+ if (isOpenChanged) {
118
+ if (props.isOpen || !props.motion) {
119
+ newState.visible = props.isOpen;
120
+ }
121
+ }
122
+ if (props.motion && isOpenChanged) {
123
+ newState.isTransitioning = true;
124
+ }
125
+ newState.cacheIsOpen = props.isOpen;
126
+ return newState;
127
+ }
128
+ componentDidUpdate(prevProps, prevState) {
129
+ const changedPropKeys = Object.keys((0, _lodashEs.pick)(this.props, ['reCalcKey'])).filter(key => !(0, _lodashEs.isEqual)(this.props[key], prevProps[key]));
130
+ const changedStateKeys = Object.keys((0, _lodashEs.pick)(this.state, ['domInRenderTree'])).filter(key => !(0, _lodashEs.isEqual)(this.state[key], prevState[key]));
131
+ if (changedPropKeys.includes('reCalcKey') && this.domRef.current) {
132
+ this.foundation.updateDOMHeight(this.domRef.current.scrollHeight);
133
+ }
134
+ if (changedStateKeys.includes('domInRenderTree') && this.state.domInRenderTree && this.domRef.current) {
135
+ this.foundation.updateDOMHeight(this.domRef.current.scrollHeight);
136
+ }
137
+ }
138
+ componentWillUnmount() {
139
+ if (this.resizeObserver) {
140
+ this.resizeObserver.disconnect();
141
+ this.resizeObserver = null;
142
+ }
143
+ }
144
+ render() {
145
+ const {
146
+ isOpen,
147
+ collapseHeight,
148
+ fade,
149
+ motion,
150
+ duration,
151
+ style,
152
+ className,
153
+ id,
154
+ keepDOM,
155
+ lazyRender,
156
+ onMotionEnd
157
+ } = this.props;
158
+ const {
159
+ domHeight,
160
+ isTransitioning,
161
+ visible
162
+ } = this.state;
163
+ const wrapperStyle = {
164
+ overflow: 'hidden',
165
+ height: isOpen ? domHeight : collapseHeight,
166
+ opacity: isOpen || !fade || collapseHeight !== 0 ? 1 : 0,
167
+ transitionDuration: `${motion && isTransitioning ? duration : 0}ms`,
168
+ ...style
169
+ };
170
+ const wrapperCls = (0, _classnames.default)(`${this.prefixCls}-wrapper`, {
171
+ [`${this.prefixCls}-transition`]: motion && isTransitioning
172
+ }, className);
173
+ const shouldRender = keepDOM && (lazyRender ? this.hasBeenRendered : true) || collapseHeight !== 0 || visible || isOpen;
174
+ if (shouldRender && !this.hasBeenRendered) {
175
+ this.hasBeenRendered = true;
176
+ }
177
+ return /*#__PURE__*/_react.default.createElement("div", _extends({
178
+ className: wrapperCls,
179
+ style: wrapperStyle,
180
+ onTransitionEnd: () => {
181
+ if (!isOpen) {
182
+ this.foundation.updateVisible(false);
183
+ }
184
+ this.foundation.updateIsTransitioning(false);
185
+ onMotionEnd?.();
186
+ }
187
+ }, this.getDataAttr(this.props)), /*#__PURE__*/_react.default.createElement("div", {
188
+ ref: this.domRef,
189
+ style: {
190
+ overflow: 'hidden'
191
+ },
192
+ id: id
193
+ }, shouldRender && this.props.children));
194
+ }
195
+ }
196
+ if (process.env.NODE_ENV !== 'production') {
197
+ Collapsible.displayName = 'Collapsible';
198
+ }
199
+ var _default = exports.default = Collapsible;
@@ -0,0 +1 @@
1
+ import './index.less';
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+
3
+ require("./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,68 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _icons = require("@ant-design/icons");
9
+ var _ = require("./..");
10
+ var _antd = require("antd");
11
+ var _configProvider = require("antd/es/config-provider");
12
+ var _classnames = _interopRequireDefault(require("classnames"));
13
+ require("./style");
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+ 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); }
16
+ const CollapsibleActionItems = props => {
17
+ const {
18
+ actionItems,
19
+ maxCount = 3,
20
+ className,
21
+ divider = /*#__PURE__*/_react.default.createElement(_antd.Divider, {
22
+ type: "vertical"
23
+ }),
24
+ collapseIcon = /*#__PURE__*/_react.default.createElement(_icons.EllipsisOutlined, null),
25
+ dropdownProps,
26
+ buttonProps,
27
+ style,
28
+ onItemClick
29
+ } = props;
30
+ const isOverMaxCount = actionItems.length > maxCount;
31
+ const prefixCls = (0, _configProvider.globalConfig)().getPrefixCls('collapsible-action-items');
32
+ const getActionItemNode = (item, isCollapse = false) => {
33
+ const customRender = item.render ? item.render() : null;
34
+ if (!isCollapse) return /*#__PURE__*/_react.default.createElement("span", {
35
+ className: `${prefixCls}__btn`,
36
+ key: item.key,
37
+ onClick: () => !item.disabled && onItemClick?.(item.key)
38
+ }, customRender || /*#__PURE__*/_react.default.createElement(_.Button, _extends({
39
+ type: "link",
40
+ disabled: item.disabled
41
+ }, buttonProps), item.name));
42
+ return /*#__PURE__*/_react.default.createElement(_antd.Menu.Item, {
43
+ key: item.key,
44
+ disabled: item.disabled
45
+ }, customRender || item.name);
46
+ };
47
+ const displayAction = actionItems.slice(0, isOverMaxCount ? maxCount - 1 : maxCount).map(item => getActionItemNode(item, false));
48
+ const dropdownMenu = isOverMaxCount ? /*#__PURE__*/_react.default.createElement(_antd.Menu, {
49
+ "data-testid": "action-dropdown-menu",
50
+ onClick: info => onItemClick?.(info.key)
51
+ }, actionItems.slice(maxCount - 1).map(item => getActionItemNode(item, true))) : null;
52
+ return /*#__PURE__*/_react.default.createElement("div", {
53
+ className: (0, _classnames.default)(prefixCls, className),
54
+ style: style
55
+ }, displayAction.map((actionItem, index) => {
56
+ const showDivider = index < actionItems.length - 1;
57
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, {
58
+ key: actionItem.key
59
+ }, actionItem, showDivider && divider);
60
+ }), dropdownMenu && /*#__PURE__*/_react.default.createElement(_antd.Dropdown, _extends({
61
+ placement: 'bottomRight',
62
+ overlay: dropdownMenu,
63
+ getPopupContainer: triggerNode => triggerNode.parentElement ?? document.body
64
+ }, dropdownProps), /*#__PURE__*/_react.default.createElement("a", {
65
+ className: `${prefixCls}__icon`
66
+ }, collapseIcon)));
67
+ };
68
+ var _default = exports.default = CollapsibleActionItems;
@@ -0,0 +1,2 @@
1
+ import '../../style/index.less';
2
+ import './index.less';
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+
3
+ require("../../style/index.less");
4
+ require("./index.less");
@@ -0,0 +1,7 @@
1
+ @import '../../style/themes/index.less';
2
+
3
+ @collapsible-action-items-prefix-cls: ~'@{ant-prefix}-collapsible-action-items';
4
+
5
+ .@{collapsible-action-items-prefix-cls}__icon {
6
+ font-size: 16px;
7
+ }
@@ -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,60 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _configProvider = require("antd/es/config-provider");
9
+ var _classnames = _interopRequireDefault(require("classnames"));
10
+ var _lodashEs = require("lodash-es");
11
+ require("./style");
12
+ var _gapSize = require("../_util/gapSize");
13
+ var _hooks = require("../_util/hooks");
14
+ var _isNonNullable = _interopRequireDefault(require("../_util/isNonNullable"));
15
+ var _utils = _interopRequireDefault(require("./utils"));
16
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
+ 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); }
18
+ const Flex = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
19
+ const {
20
+ prefixCls: customizePrefixCls,
21
+ rootClassName,
22
+ className,
23
+ style,
24
+ flex,
25
+ gap,
26
+ vertical,
27
+ orientation,
28
+ component: Component = 'div',
29
+ children,
30
+ ...othersProps
31
+ } = props;
32
+ const {
33
+ direction: ctxDirection
34
+ } = _react.default.useContext(_configProvider.ConfigContext);
35
+ const prefixCls = customizePrefixCls || (0, _configProvider.globalConfig)().getPrefixCls('flex');
36
+ const [mergedVertical] = (0, _hooks.useOrientation)(orientation, vertical);
37
+ const mergedCls = (0, _classnames.default)(className, rootClassName, prefixCls, (0, _utils.default)(prefixCls, props), {
38
+ [`${prefixCls}-rtl`]: ctxDirection === 'rtl',
39
+ [`${prefixCls}-gap-${gap}`]: (0, _gapSize.isPresetSize)(gap),
40
+ [`${prefixCls}-vertical`]: mergedVertical === 'vertical'
41
+ });
42
+ const mergedStyle = {
43
+ ...style
44
+ };
45
+ if ((0, _isNonNullable.default)(flex)) {
46
+ mergedStyle.flex = flex;
47
+ }
48
+ if ((0, _isNonNullable.default)(gap) && !(0, _gapSize.isPresetSize)(gap)) {
49
+ mergedStyle.gap = gap;
50
+ }
51
+ return /*#__PURE__*/_react.default.createElement(Component, _extends({
52
+ ref: ref,
53
+ className: mergedCls,
54
+ style: mergedStyle
55
+ }, (0, _lodashEs.omit)(othersProps, ['justify', 'wrap', 'align'])), children);
56
+ });
57
+ if (process.env.NODE_ENV !== 'production') {
58
+ Flex.displayName = 'Flex';
59
+ }
60
+ var _default = exports.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,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -0,0 +1,2 @@
1
+ import '../../style/index.less';
2
+ import './index.less';
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+
3
+ require("../../style/index.less");
4
+ require("./index.less");
@@ -0,0 +1,77 @@
1
+ @import '../../style/themes/index.less';
2
+
3
+ @flex-prefix-cls: ~'@{ant-prefix}-flex';
4
+
5
+ // 属性与值的映射
6
+ @align-items-values: {
7
+ stretch: stretch;
8
+ flex-start: flex-start;
9
+ center: center;
10
+ flex-end: flex-end;
11
+ baseline: baseline;
12
+ };
13
+
14
+ @justify-content-values: {
15
+ flex-start: flex-start;
16
+ center: center;
17
+ flex-end: flex-end;
18
+ space-between: space-between;
19
+ space-around: space-around;
20
+ space-evenly: space-evenly;
21
+ };
22
+
23
+ @flex-wrap-values: {
24
+ nowrap: nowrap;
25
+ wrap: wrap;
26
+ wrap-reverse: wrap-reverse;
27
+ };
28
+
29
+ .@{flex-prefix-cls} {
30
+ display: flex;
31
+ margin: 0;
32
+ padding: 0;
33
+
34
+ // 方向
35
+ &-vertical {
36
+ flex-direction: column;
37
+ }
38
+ &-rtl {
39
+ direction: rtl;
40
+ }
41
+ &:empty {
42
+ display: none;
43
+ }
44
+
45
+ // 间距 (Gap)
46
+ &-gap-small {
47
+ gap: @padding-xs;
48
+ }
49
+ &-gap-middle {
50
+ gap: @padding-md;
51
+ }
52
+ &-gap-large {
53
+ gap: @padding-lg;
54
+ }
55
+
56
+ // 使用 Loops/Each 抽象重复代码
57
+ // flex-wrap
58
+ each(@flex-wrap-values, .(@value, @key) {
59
+ &-wrap-@{key} {
60
+ flex-wrap: @value;
61
+ }
62
+ });
63
+
64
+ // align-items
65
+ each(@align-items-values, .(@value, @key) {
66
+ &-align-@{key} {
67
+ align-items: @value;
68
+ }
69
+ });
70
+
71
+ // justify-content
72
+ each(@justify-content-values, .(@value, @key) {
73
+ &-justify-@{key} {
74
+ justify-content: @value;
75
+ }
76
+ });
77
+ }
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import type { FlexProps } from './interface';
3
+ export declare const flexWrapValues: React.CSSProperties['flexWrap'][];
4
+ export declare const justifyContentValues: React.CSSProperties['justifyContent'][];
5
+ export declare const alignItemsValues: React.CSSProperties['alignItems'][];
6
+ declare const createFlexClassNames: (prefixCls: string, props: FlexProps) => string;
7
+ export default createFlexClassNames;