@dtjoy/dt-design 1.0.1 → 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.
Files changed (141) 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 +8 -7
  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 +9 -0
  36. package/esm/index.js +7 -5
  37. package/esm/resize/index.d.ts +8 -0
  38. package/esm/resize/index.js +29 -0
  39. package/esm/splitter/Panel.d.ts +7 -0
  40. package/esm/splitter/Panel.js +38 -0
  41. package/esm/splitter/SplitBar.d.ts +24 -0
  42. package/esm/splitter/SplitBar.js +185 -0
  43. package/esm/splitter/Splitter.d.ts +5 -0
  44. package/esm/splitter/Splitter.js +215 -0
  45. package/esm/splitter/hooks/sizeUtil.d.ts +3 -0
  46. package/esm/splitter/hooks/sizeUtil.js +63 -0
  47. package/esm/splitter/hooks/useItems.d.ts +14 -0
  48. package/esm/splitter/hooks/useItems.js +44 -0
  49. package/esm/splitter/hooks/useResizable.d.ts +10 -0
  50. package/esm/splitter/hooks/useResizable.js +73 -0
  51. package/esm/splitter/hooks/useResize.d.ts +6 -0
  52. package/esm/splitter/hooks/useResize.js +158 -0
  53. package/esm/splitter/hooks/useSizes.d.ts +4 -0
  54. package/esm/splitter/hooks/useSizes.js +80 -0
  55. package/esm/splitter/index.d.ts +8 -0
  56. package/esm/splitter/index.js +5 -0
  57. package/esm/splitter/interface.d.ts +68 -0
  58. package/esm/splitter/interface.js +1 -0
  59. package/esm/splitter/style/index.d.ts +2 -0
  60. package/esm/splitter/style/index.js +2 -0
  61. package/esm/splitter/style/index.less +312 -0
  62. package/esm/statusTag/index.d.ts +28 -0
  63. package/esm/statusTag/index.js +122 -0
  64. package/esm/statusTag/style/index.d.ts +2 -0
  65. package/esm/statusTag/style/index.js +2 -0
  66. package/esm/statusTag/style/index.less +70 -0
  67. package/esm/statusTag/style/mixin.less +39 -0
  68. package/esm/style/mixins/index.less +0 -0
  69. package/esm/style/themes/index.less +2 -1
  70. package/esm/style/themes/variable.less +1 -0
  71. package/lib/_util/gapSize.d.ts +3 -0
  72. package/lib/_util/gapSize.js +17 -0
  73. package/lib/_util/hooks/index.d.ts +1 -0
  74. package/lib/_util/hooks/index.js +16 -0
  75. package/lib/_util/hooks/useOrientation.d.ts +2 -0
  76. package/lib/_util/hooks/useOrientation.js +26 -0
  77. package/lib/_util/isNonNullable.d.ts +2 -0
  78. package/lib/_util/isNonNullable.js +10 -0
  79. package/lib/_util/type.d.ts +2 -1
  80. package/lib/blockHeader/index.js +12 -12
  81. package/lib/blockHeader/style/index.d.ts +1 -1
  82. package/lib/blockHeader/style/index.js +1 -1
  83. package/lib/blockHeader/style/index.less +8 -7
  84. package/lib/button/style/index.less +60 -46
  85. package/lib/button/style/mixin.less +47 -0
  86. package/lib/collapsible/index.d.ts +97 -0
  87. package/lib/collapsible/index.js +199 -0
  88. package/lib/collapsible/style/index.d.ts +1 -0
  89. package/lib/collapsible/style/index.js +3 -0
  90. package/lib/collapsible/style/index.less +24 -0
  91. package/lib/collapsibleActionItems/index.d.ts +24 -0
  92. package/lib/collapsibleActionItems/index.js +68 -0
  93. package/lib/collapsibleActionItems/style/index.d.ts +2 -0
  94. package/lib/collapsibleActionItems/style/index.js +4 -0
  95. package/lib/collapsibleActionItems/style/index.less +7 -0
  96. package/lib/flex/index.d.ts +7 -0
  97. package/lib/flex/index.js +60 -0
  98. package/lib/flex/interface.d.ts +16 -0
  99. package/lib/flex/interface.js +5 -0
  100. package/lib/flex/style/index.d.ts +2 -0
  101. package/lib/flex/style/index.js +4 -0
  102. package/lib/flex/style/index.less +77 -0
  103. package/lib/flex/utils.d.ts +7 -0
  104. package/lib/flex/utils.js +39 -0
  105. package/lib/index.d.ts +9 -0
  106. package/lib/index.js +65 -0
  107. package/lib/resize/index.d.ts +8 -0
  108. package/lib/resize/index.js +38 -0
  109. package/lib/splitter/Panel.d.ts +7 -0
  110. package/lib/splitter/Panel.js +44 -0
  111. package/lib/splitter/SplitBar.d.ts +24 -0
  112. package/lib/splitter/SplitBar.js +179 -0
  113. package/lib/splitter/Splitter.d.ts +5 -0
  114. package/lib/splitter/Splitter.js +202 -0
  115. package/lib/splitter/hooks/sizeUtil.d.ts +3 -0
  116. package/lib/splitter/hooks/sizeUtil.js +56 -0
  117. package/lib/splitter/hooks/useItems.d.ts +14 -0
  118. package/lib/splitter/hooks/useItems.js +46 -0
  119. package/lib/splitter/hooks/useResizable.d.ts +10 -0
  120. package/lib/splitter/hooks/useResizable.js +83 -0
  121. package/lib/splitter/hooks/useResize.d.ts +6 -0
  122. package/lib/splitter/hooks/useResize.js +142 -0
  123. package/lib/splitter/hooks/useSizes.d.ts +4 -0
  124. package/lib/splitter/hooks/useSizes.js +62 -0
  125. package/lib/splitter/index.d.ts +8 -0
  126. package/lib/splitter/index.js +12 -0
  127. package/lib/splitter/interface.d.ts +68 -0
  128. package/lib/splitter/interface.js +5 -0
  129. package/lib/splitter/style/index.d.ts +2 -0
  130. package/lib/splitter/style/index.js +4 -0
  131. package/lib/splitter/style/index.less +312 -0
  132. package/lib/statusTag/index.d.ts +28 -0
  133. package/lib/statusTag/index.js +125 -0
  134. package/lib/statusTag/style/index.d.ts +2 -0
  135. package/lib/statusTag/style/index.js +4 -0
  136. package/lib/statusTag/style/index.less +70 -0
  137. package/lib/statusTag/style/mixin.less +39 -0
  138. package/lib/style/mixins/index.less +0 -0
  139. package/lib/style/themes/index.less +2 -1
  140. package/lib/style/themes/variable.less +1 -0
  141. package/package.json +142 -141
@@ -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,2 @@
1
+ import '../../style/index.less';
2
+ import './index.less';
@@ -0,0 +1,2 @@
1
+ import "../../style/index.less";
2
+ import "./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,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 {};
@@ -0,0 +1,2 @@
1
+ import '../../style/index.less';
2
+ import './index.less';
@@ -0,0 +1,2 @@
1
+ import "../../style/index.less";
2
+ import "./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;
@@ -0,0 +1,33 @@
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
+ import { clsx } from 'clsx';
8
+ export var flexWrapValues = ['wrap', 'nowrap', 'wrap-reverse'];
9
+ export var justifyContentValues = ['flex-start', 'flex-end', 'start', 'end', 'center', 'space-between', 'space-around', 'space-evenly', 'stretch', 'normal', 'left', 'right'];
10
+ export var alignItemsValues = ['center', 'start', 'end', 'flex-start', 'flex-end', 'self-start', 'self-end', 'baseline', 'normal', 'stretch'];
11
+ var genClsWrap = function genClsWrap(prefixCls, props) {
12
+ var wrap = props.wrap === true ? 'wrap' : props.wrap;
13
+ return _defineProperty({}, "".concat(prefixCls, "-wrap-").concat(wrap), wrap && flexWrapValues.includes(wrap));
14
+ };
15
+ var genClsAlign = function genClsAlign(prefixCls, props) {
16
+ var alignCls = {};
17
+ alignItemsValues.forEach(function (cssKey) {
18
+ alignCls["".concat(prefixCls, "-align-").concat(cssKey)] = props.align === cssKey;
19
+ });
20
+ alignCls["".concat(prefixCls, "-align-stretch")] = !props.align && !!props.vertical;
21
+ return alignCls;
22
+ };
23
+ var genClsJustify = function genClsJustify(prefixCls, props) {
24
+ var justifyCls = {};
25
+ justifyContentValues.forEach(function (cssKey) {
26
+ justifyCls["".concat(prefixCls, "-justify-").concat(cssKey)] = props.justify === cssKey;
27
+ });
28
+ return justifyCls;
29
+ };
30
+ var createFlexClassNames = function createFlexClassNames(prefixCls, props) {
31
+ return clsx(_objectSpread(_objectSpread(_objectSpread({}, genClsWrap(prefixCls, props)), genClsAlign(prefixCls, props)), genClsJustify(prefixCls, props)));
32
+ };
33
+ export default createFlexClassNames;
package/esm/index.d.ts CHANGED
@@ -1,3 +1,12 @@
1
1
  import '@dtinsight/react-icons/dist/index.css';
2
2
  export { default as BlockHeader } from './blockHeader';
3
+ export type { ButtonProps } from './button';
3
4
  export { default as Button } from './button';
5
+ export { default as Flex } from './flex';
6
+ export type { FlexProps } from './flex/interface';
7
+ export { default as CollapsibleActionItems } from './collapsibleActionItems';
8
+ export { default as Resize } from './resize';
9
+ export { default as Splitter } from './splitter';
10
+ export * from './splitter';
11
+ export { default as Collapsible } from './collapsible';
12
+ export { default as StatusTag } from './statusTag';
package/esm/index.js CHANGED
@@ -1,9 +1,10 @@
1
1
  import '@dtinsight/react-icons/dist/index.css';
2
2
  export { default as BlockHeader } from "./blockHeader";
3
3
  export { default as Button } from "./button";
4
+ export { default as Flex } from "./flex";
4
5
  // export { default as Catalogue } from './catalogue';
5
6
  // export { default as Chat } from './chat';
6
- // export { default as CollapsibleActionItems } from './collapsibleActionItems';
7
+ export { default as CollapsibleActionItems } from "./collapsibleActionItems";
7
8
  // export { default as ConfigProvider } from './configProvider';
8
9
  // export { default as ContentLayout } from './contentLayout';
9
10
  // export { default as ContextMenu } from './contextMenu';
@@ -33,11 +34,12 @@ export { default as Button } from "./button";
33
34
  // export { default as NotFound } from './notFound';
34
35
  // export { default as ProgressBar } from './progressBar';
35
36
  // export { default as ProgressLine } from './progressLine';
36
- // export { default as Resize } from './resize';
37
- // export { default as Splitter } from './splitter';
38
- // export * from './splitter';
37
+ export { default as Resize } from "./resize";
38
+ export { default as Splitter } from "./splitter";
39
+ export * from "./splitter";
39
40
  // export { default as SpreadSheet } from './spreadSheet';
40
- // export { default as StatusTag } from './statusTag';
41
+ export { default as Collapsible } from "./collapsible";
42
+ export { default as StatusTag } from "./statusTag";
41
43
  // export { default as Table } from './table';
42
44
  // export { default as TinyTag } from './tinyTag';
43
45
  // export { default as useCookieListener } from './useCookieListener';