@fle-ui/next 2.0.0-alpha.6 → 2.0.0-alpha.7

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 (59) hide show
  1. package/es/affix/index.d.ts +54 -0
  2. package/es/affix/index.js +330 -0
  3. package/es/affix/style/css.js +2 -0
  4. package/es/affix/style/index-pure.less +6 -0
  5. package/es/affix/style/index.css +8 -0
  6. package/es/affix/style/index.d.ts +2 -0
  7. package/es/affix/style/index.js +2 -0
  8. package/es/affix/style/index.less +3 -0
  9. package/es/affix/utils.d.ts +15 -0
  10. package/es/affix/utils.js +86 -0
  11. package/package.json +1 -2
  12. package/es/affix/ActionButton.d.ts +0 -15
  13. package/es/affix/ActionButton.js +0 -118
  14. package/es/affix/colors.d.ts +0 -5
  15. package/es/affix/colors.js +0 -4
  16. package/es/affix/easings.d.ts +0 -1
  17. package/es/affix/easings.js +0 -12
  18. package/es/affix/getDataOrAriaProps.d.ts +0 -1
  19. package/es/affix/getDataOrAriaProps.js +0 -9
  20. package/es/affix/getRenderPropValue.d.ts +0 -3
  21. package/es/affix/getRenderPropValue.js +0 -11
  22. package/es/affix/getScroll.d.ts +0 -2
  23. package/es/affix/getScroll.js +0 -34
  24. package/es/affix/hooks/useFlexGapSupport.d.ts +0 -2
  25. package/es/affix/hooks/useFlexGapSupport.js +0 -14
  26. package/es/affix/hooks/useForceUpdate.d.ts +0 -2
  27. package/es/affix/hooks/useForceUpdate.js +0 -11
  28. package/es/affix/hooks/usePatchElement.d.ts +0 -5
  29. package/es/affix/hooks/usePatchElement.js +0 -26
  30. package/es/affix/hooks/useSyncState.d.ts +0 -3
  31. package/es/affix/hooks/useSyncState.js +0 -13
  32. package/es/affix/isNumeric.d.ts +0 -2
  33. package/es/affix/isNumeric.js +0 -5
  34. package/es/affix/motion.d.ts +0 -8
  35. package/es/affix/motion.js +0 -60
  36. package/es/affix/placements.d.ts +0 -17
  37. package/es/affix/placements.js +0 -88
  38. package/es/affix/raf.d.ts +0 -9
  39. package/es/affix/raf.js +0 -31
  40. package/es/affix/reactNode.d.ts +0 -8
  41. package/es/affix/reactNode.js +0 -16
  42. package/es/affix/responsiveObserve.d.ts +0 -21
  43. package/es/affix/responsiveObserve.js +0 -67
  44. package/es/affix/scrollTo.d.ts +0 -10
  45. package/es/affix/scrollTo.js +0 -38
  46. package/es/affix/statusUtils.d.ts +0 -6
  47. package/es/affix/statusUtils.js +0 -12
  48. package/es/affix/styleChecker.d.ts +0 -4
  49. package/es/affix/styleChecker.js +0 -31
  50. package/es/affix/throttleByAnimationFrame.d.ts +0 -8
  51. package/es/affix/throttleByAnimationFrame.js +0 -58
  52. package/es/affix/transButton.d.ts +0 -9
  53. package/es/affix/transButton.js +0 -75
  54. package/es/affix/type.d.ts +0 -9
  55. package/es/affix/type.js +0 -15
  56. package/es/affix/warning.d.ts +0 -6
  57. package/es/affix/warning.js +0 -17
  58. package/es/affix/wave.d.ts +0 -32
  59. package/es/affix/wave.js +0 -247
@@ -0,0 +1,54 @@
1
+ import * as React from 'react';
2
+ import type { ConfigConsumerProps } from '../config-provider';
3
+ export interface AffixProps {
4
+ /** 距离窗口顶部达到指定偏移量后触发 */
5
+ offsetTop?: number;
6
+ /** 距离窗口底部达到指定偏移量后触发 */
7
+ offsetBottom?: number;
8
+ style?: React.CSSProperties;
9
+ /** 固定状态改变时触发的回调函数 */
10
+ onChange?: (affixed?: boolean) => void;
11
+ /** 设置 Affix 需要监听其滚动事件的元素,值为一个返回对应 DOM 元素的函数 */
12
+ target?: () => Window | HTMLElement | null;
13
+ prefixCls?: string;
14
+ className?: string;
15
+ children: React.ReactNode;
16
+ }
17
+ interface InternalAffixProps extends AffixProps {
18
+ affixPrefixCls: string;
19
+ }
20
+ declare enum AffixStatus {
21
+ None = 0,
22
+ Prepare = 1
23
+ }
24
+ export interface AffixState {
25
+ affixStyle?: React.CSSProperties;
26
+ placeholderStyle?: React.CSSProperties;
27
+ status: AffixStatus;
28
+ lastAffix: boolean;
29
+ prevTarget: Window | HTMLElement | null;
30
+ }
31
+ declare class Affix extends React.Component<InternalAffixProps, AffixState> {
32
+ static contextType: React.Context<ConfigConsumerProps>;
33
+ state: AffixState;
34
+ placeholderNode: HTMLDivElement;
35
+ fixedNode: HTMLDivElement;
36
+ private timeout;
37
+ context: ConfigConsumerProps;
38
+ private getTargetFunc;
39
+ componentDidMount(): void;
40
+ componentDidUpdate(prevProps: AffixProps): void;
41
+ componentWillUnmount(): void;
42
+ getOffsetTop: () => number | undefined;
43
+ getOffsetBottom: () => number | undefined;
44
+ savePlaceholderNode: (node: HTMLDivElement) => void;
45
+ saveFixedNode: (node: HTMLDivElement) => void;
46
+ measure: () => void;
47
+ prepareMeasure: () => void;
48
+ updatePosition(): void;
49
+ lazyUpdatePosition(): void;
50
+ render(): JSX.Element;
51
+ }
52
+ export type InternalAffixClass = Affix;
53
+ declare const AffixFC: React.ForwardRefExoticComponent<AffixProps & React.RefAttributes<Affix>>;
54
+ export default AffixFC;
@@ -0,0 +1,330 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
3
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
4
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
5
+ import _inherits from "@babel/runtime/helpers/esm/inherits";
6
+ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
7
+ import _typeof from "@babel/runtime/helpers/esm/typeof";
8
+
9
+ var __decorate = this && this.__decorate || function (decorators, target, key, desc) {
10
+ var c = arguments.length,
11
+ r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
12
+ d;
13
+ if ((typeof Reflect === "undefined" ? "undefined" : _typeof(Reflect)) === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) {
14
+ if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
15
+ }
16
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
17
+ };
18
+
19
+ import classNames from 'classnames';
20
+ import ResizeObserver from 'rc-resize-observer';
21
+ import omit from "rc-util/es/omit";
22
+ import * as React from 'react';
23
+ import { ConfigContext } from "../config-provider";
24
+ import { throttleByAnimationFrameDecorator } from "../_util/throttleByAnimationFrame";
25
+ import { addObserveTarget, getFixedBottom, getFixedTop, getTargetRect, removeObserveTarget } from "./utils";
26
+
27
+ function getDefaultTarget() {
28
+ return typeof window !== 'undefined' ? window : null;
29
+ }
30
+
31
+ var AffixStatus;
32
+
33
+ (function (AffixStatus) {
34
+ AffixStatus[AffixStatus["None"] = 0] = "None";
35
+ AffixStatus[AffixStatus["Prepare"] = 1] = "Prepare";
36
+ })(AffixStatus || (AffixStatus = {}));
37
+
38
+ var Affix = /*#__PURE__*/function (_React$Component) {
39
+ _inherits(Affix, _React$Component);
40
+
41
+ var _super = _createSuper(Affix);
42
+
43
+ function Affix() {
44
+ var _this;
45
+
46
+ _classCallCheck(this, Affix);
47
+
48
+ _this = _super.apply(this, arguments);
49
+ _this.state = {
50
+ status: AffixStatus.None,
51
+ lastAffix: false,
52
+ prevTarget: null
53
+ };
54
+
55
+ _this.getOffsetTop = function () {
56
+ var _this$props = _this.props,
57
+ offsetBottom = _this$props.offsetBottom,
58
+ offsetTop = _this$props.offsetTop;
59
+ return offsetBottom === undefined && offsetTop === undefined ? 0 : offsetTop;
60
+ };
61
+
62
+ _this.getOffsetBottom = function () {
63
+ return _this.props.offsetBottom;
64
+ };
65
+
66
+ _this.savePlaceholderNode = function (node) {
67
+ _this.placeholderNode = node;
68
+ };
69
+
70
+ _this.saveFixedNode = function (node) {
71
+ _this.fixedNode = node;
72
+ }; // =================== Measure ===================
73
+
74
+
75
+ _this.measure = function () {
76
+ var _this$state = _this.state,
77
+ status = _this$state.status,
78
+ lastAffix = _this$state.lastAffix;
79
+ var onChange = _this.props.onChange;
80
+
81
+ var targetFunc = _this.getTargetFunc();
82
+
83
+ if (status !== AffixStatus.Prepare || !_this.fixedNode || !_this.placeholderNode || !targetFunc) {
84
+ return;
85
+ }
86
+
87
+ var offsetTop = _this.getOffsetTop();
88
+
89
+ var offsetBottom = _this.getOffsetBottom();
90
+
91
+ var targetNode = targetFunc();
92
+
93
+ if (!targetNode) {
94
+ return;
95
+ }
96
+
97
+ var newState = {
98
+ status: AffixStatus.None
99
+ };
100
+ var targetRect = getTargetRect(targetNode);
101
+ var placeholderReact = getTargetRect(_this.placeholderNode);
102
+ var fixedTop = getFixedTop(placeholderReact, targetRect, offsetTop);
103
+ var fixedBottom = getFixedBottom(placeholderReact, targetRect, offsetBottom);
104
+
105
+ if (placeholderReact.top === 0 && placeholderReact.left === 0 && placeholderReact.width === 0 && placeholderReact.height === 0) {
106
+ return;
107
+ }
108
+
109
+ if (fixedTop !== undefined) {
110
+ newState.affixStyle = {
111
+ position: 'fixed',
112
+ top: fixedTop,
113
+ width: placeholderReact.width,
114
+ height: placeholderReact.height
115
+ };
116
+ newState.placeholderStyle = {
117
+ width: placeholderReact.width,
118
+ height: placeholderReact.height
119
+ };
120
+ } else if (fixedBottom !== undefined) {
121
+ newState.affixStyle = {
122
+ position: 'fixed',
123
+ bottom: fixedBottom,
124
+ width: placeholderReact.width,
125
+ height: placeholderReact.height
126
+ };
127
+ newState.placeholderStyle = {
128
+ width: placeholderReact.width,
129
+ height: placeholderReact.height
130
+ };
131
+ }
132
+
133
+ newState.lastAffix = !!newState.affixStyle;
134
+
135
+ if (onChange && lastAffix !== newState.lastAffix) {
136
+ onChange(newState.lastAffix);
137
+ }
138
+
139
+ _this.setState(newState);
140
+ }; // @ts-ignore TS6133
141
+
142
+
143
+ _this.prepareMeasure = function () {
144
+ // event param is used before. Keep compatible ts define here.
145
+ _this.setState({
146
+ status: AffixStatus.Prepare,
147
+ affixStyle: undefined,
148
+ placeholderStyle: undefined
149
+ }); // Test if `updatePosition` called
150
+
151
+
152
+ if (process.env.NODE_ENV === 'test') {
153
+ var onTestUpdatePosition = _this.props.onTestUpdatePosition;
154
+ onTestUpdatePosition === null || onTestUpdatePosition === void 0 ? void 0 : onTestUpdatePosition();
155
+ }
156
+ };
157
+
158
+ return _this;
159
+ }
160
+
161
+ _createClass(Affix, [{
162
+ key: "getTargetFunc",
163
+ value: function getTargetFunc() {
164
+ var getTargetContainer = this.context.getTargetContainer;
165
+ var target = this.props.target;
166
+
167
+ if (target !== undefined) {
168
+ return target;
169
+ }
170
+
171
+ return getTargetContainer !== null && getTargetContainer !== void 0 ? getTargetContainer : getDefaultTarget;
172
+ } // Event handler
173
+
174
+ }, {
175
+ key: "componentDidMount",
176
+ value: function componentDidMount() {
177
+ var _this2 = this;
178
+
179
+ var targetFunc = this.getTargetFunc();
180
+
181
+ if (targetFunc) {
182
+ // [Legacy] Wait for parent component ref has its value.
183
+ // We should use target as directly element instead of function which makes element check hard.
184
+ this.timeout = setTimeout(function () {
185
+ addObserveTarget(targetFunc(), _this2); // Mock Event object.
186
+
187
+ _this2.updatePosition();
188
+ });
189
+ }
190
+ }
191
+ }, {
192
+ key: "componentDidUpdate",
193
+ value: function componentDidUpdate(prevProps) {
194
+ var prevTarget = this.state.prevTarget;
195
+ var targetFunc = this.getTargetFunc();
196
+ var newTarget = (targetFunc === null || targetFunc === void 0 ? void 0 : targetFunc()) || null;
197
+
198
+ if (prevTarget !== newTarget) {
199
+ removeObserveTarget(this);
200
+
201
+ if (newTarget) {
202
+ addObserveTarget(newTarget, this); // Mock Event object.
203
+
204
+ this.updatePosition();
205
+ } // eslint-disable-next-line react/no-did-update-set-state
206
+
207
+
208
+ this.setState({
209
+ prevTarget: newTarget
210
+ });
211
+ }
212
+
213
+ if (prevProps.offsetTop !== this.props.offsetTop || prevProps.offsetBottom !== this.props.offsetBottom) {
214
+ this.updatePosition();
215
+ }
216
+
217
+ this.measure();
218
+ }
219
+ }, {
220
+ key: "componentWillUnmount",
221
+ value: function componentWillUnmount() {
222
+ clearTimeout(this.timeout);
223
+ removeObserveTarget(this);
224
+ this.updatePosition.cancel(); // https://github.com/ant-design/ant-design/issues/22683
225
+
226
+ this.lazyUpdatePosition.cancel();
227
+ } // Handle realign logic
228
+
229
+ }, {
230
+ key: "updatePosition",
231
+ value: function updatePosition() {
232
+ this.prepareMeasure();
233
+ }
234
+ }, {
235
+ key: "lazyUpdatePosition",
236
+ value: function lazyUpdatePosition() {
237
+ var targetFunc = this.getTargetFunc();
238
+ var affixStyle = this.state.affixStyle; // Check position change before measure to make Safari smooth
239
+
240
+ if (targetFunc && affixStyle) {
241
+ var offsetTop = this.getOffsetTop();
242
+ var offsetBottom = this.getOffsetBottom();
243
+ var targetNode = targetFunc();
244
+
245
+ if (targetNode && this.placeholderNode) {
246
+ var targetRect = getTargetRect(targetNode);
247
+ var placeholderReact = getTargetRect(this.placeholderNode);
248
+ var fixedTop = getFixedTop(placeholderReact, targetRect, offsetTop);
249
+ var fixedBottom = getFixedBottom(placeholderReact, targetRect, offsetBottom);
250
+
251
+ if (fixedTop !== undefined && affixStyle.top === fixedTop || fixedBottom !== undefined && affixStyle.bottom === fixedBottom) {
252
+ return;
253
+ }
254
+ }
255
+ } // Directly call prepare measure since it's already throttled.
256
+
257
+
258
+ this.prepareMeasure();
259
+ } // =================== Render ===================
260
+
261
+ }, {
262
+ key: "render",
263
+ value: function render() {
264
+ var _this3 = this;
265
+
266
+ var _this$state2 = this.state,
267
+ affixStyle = _this$state2.affixStyle,
268
+ placeholderStyle = _this$state2.placeholderStyle;
269
+ var _this$props2 = this.props,
270
+ affixPrefixCls = _this$props2.affixPrefixCls,
271
+ children = _this$props2.children;
272
+ var className = classNames(_defineProperty({}, affixPrefixCls, !!affixStyle));
273
+ var props = omit(this.props, ['prefixCls', 'offsetTop', 'offsetBottom', 'target', 'onChange', 'affixPrefixCls']); // Omit this since `onTestUpdatePosition` only works on test.
274
+
275
+ if (process.env.NODE_ENV === 'test') {
276
+ props = omit(props, ['onTestUpdatePosition']);
277
+ }
278
+
279
+ return /*#__PURE__*/React.createElement(ResizeObserver, {
280
+ onResize: function onResize() {
281
+ _this3.updatePosition();
282
+ }
283
+ }, /*#__PURE__*/React.createElement("div", _extends({}, props, {
284
+ ref: this.savePlaceholderNode
285
+ }), affixStyle && /*#__PURE__*/React.createElement("div", {
286
+ style: placeholderStyle,
287
+ "aria-hidden": "true"
288
+ }), /*#__PURE__*/React.createElement("div", {
289
+ className: className,
290
+ ref: this.saveFixedNode,
291
+ style: affixStyle
292
+ }, /*#__PURE__*/React.createElement(ResizeObserver, {
293
+ onResize: function onResize() {
294
+ _this3.updatePosition();
295
+ }
296
+ }, children))));
297
+ }
298
+ }]);
299
+
300
+ return Affix;
301
+ }(React.Component);
302
+
303
+ Affix.contextType = ConfigContext;
304
+
305
+ __decorate([throttleByAnimationFrameDecorator()], Affix.prototype, "updatePosition", null);
306
+
307
+ __decorate([throttleByAnimationFrameDecorator()], Affix.prototype, "lazyUpdatePosition", null);
308
+
309
+ var AffixFC = /*#__PURE__*/React.forwardRef(function (props, ref) {
310
+ var customizePrefixCls = props.prefixCls;
311
+
312
+ var _React$useContext = React.useContext(ConfigContext),
313
+ getPrefixCls = _React$useContext.getPrefixCls;
314
+
315
+ var affixPrefixCls = getPrefixCls('affix', customizePrefixCls);
316
+
317
+ var affixProps = _extends(_extends({}, props), {
318
+ affixPrefixCls: affixPrefixCls
319
+ });
320
+
321
+ return /*#__PURE__*/React.createElement(Affix, _extends({}, affixProps, {
322
+ ref: ref
323
+ }));
324
+ });
325
+
326
+ if (process.env.NODE_ENV !== 'production') {
327
+ AffixFC.displayName = 'Affix';
328
+ }
329
+
330
+ export default AffixFC;
@@ -0,0 +1,2 @@
1
+ import "../../style/default.css";
2
+ import "./index.css";
@@ -0,0 +1,6 @@
1
+ @import '../../style/themes/index';
2
+
3
+ .@{ant-prefix}-affix {
4
+ position: fixed;
5
+ z-index: @zindex-affix;
6
+ }
@@ -0,0 +1,8 @@
1
+ /* stylelint-disable at-rule-empty-line-before,at-rule-name-space-after,at-rule-no-unknown */
2
+ /* stylelint-disable no-duplicate-selectors */
3
+ /* stylelint-disable */
4
+ /* stylelint-disable declaration-bang-space-before,no-duplicate-selectors,string-no-newline */
5
+ .ant-affix {
6
+ position: fixed;
7
+ z-index: 10;
8
+ }
@@ -0,0 +1,2 @@
1
+ import '../../style/default.less';
2
+ import './index.less';
@@ -0,0 +1,2 @@
1
+ import "../../style/default.less";
2
+ import "./index.less";
@@ -0,0 +1,3 @@
1
+ @root-entry-name: default;
2
+
3
+ @import './index-pure.less';
@@ -0,0 +1,15 @@
1
+ export type BindElement = HTMLElement | Window | null | undefined;
2
+ export declare function getTargetRect(target: BindElement): DOMRect;
3
+ export declare function getFixedTop(placeholderReact: DOMRect, targetRect: DOMRect, offsetTop?: number): number | undefined;
4
+ export declare function getFixedBottom(placeholderReact: DOMRect, targetRect: DOMRect, offsetBottom?: number): number | undefined;
5
+ interface ObserverEntity {
6
+ target: HTMLElement | Window;
7
+ affixList: any[];
8
+ eventHandlers: {
9
+ [eventName: string]: any;
10
+ };
11
+ }
12
+ export declare function getObserverEntities(): ObserverEntity[];
13
+ export declare function addObserveTarget<T>(target: HTMLElement | Window | null, affix?: T): void;
14
+ export declare function removeObserveTarget<T>(affix: T): void;
15
+ export {};
@@ -0,0 +1,86 @@
1
+ import addEventListener from "rc-util/es/Dom/addEventListener";
2
+ export function getTargetRect(target) {
3
+ return target !== window ? target.getBoundingClientRect() : {
4
+ top: 0,
5
+ bottom: window.innerHeight
6
+ };
7
+ }
8
+ export function getFixedTop(placeholderReact, targetRect, offsetTop) {
9
+ if (offsetTop !== undefined && targetRect.top > placeholderReact.top - offsetTop) {
10
+ return offsetTop + targetRect.top;
11
+ }
12
+
13
+ return undefined;
14
+ }
15
+ export function getFixedBottom(placeholderReact, targetRect, offsetBottom) {
16
+ if (offsetBottom !== undefined && targetRect.bottom < placeholderReact.bottom + offsetBottom) {
17
+ var targetBottomOffset = window.innerHeight - targetRect.bottom;
18
+ return offsetBottom + targetBottomOffset;
19
+ }
20
+
21
+ return undefined;
22
+ } // ======================== Observer ========================
23
+
24
+ var TRIGGER_EVENTS = ['resize', 'scroll', 'touchstart', 'touchmove', 'touchend', 'pageshow', 'load'];
25
+ var observerEntities = [];
26
+ export function getObserverEntities() {
27
+ // Only used in test env. Can be removed if refactor.
28
+ return observerEntities;
29
+ }
30
+ export function addObserveTarget(target, affix) {
31
+ if (!target) {
32
+ return;
33
+ }
34
+
35
+ var entity = observerEntities.find(function (item) {
36
+ return item.target === target;
37
+ });
38
+
39
+ if (entity) {
40
+ entity.affixList.push(affix);
41
+ } else {
42
+ entity = {
43
+ target: target,
44
+ affixList: [affix],
45
+ eventHandlers: {}
46
+ };
47
+ observerEntities.push(entity); // Add listener
48
+
49
+ TRIGGER_EVENTS.forEach(function (eventName) {
50
+ entity.eventHandlers[eventName] = addEventListener(target, eventName, function () {
51
+ entity.affixList.forEach(function (targetAffix) {
52
+ targetAffix.lazyUpdatePosition();
53
+ });
54
+ });
55
+ });
56
+ }
57
+ }
58
+ export function removeObserveTarget(affix) {
59
+ var observerEntity = observerEntities.find(function (oriObserverEntity) {
60
+ var hasAffix = oriObserverEntity.affixList.some(function (item) {
61
+ return item === affix;
62
+ });
63
+
64
+ if (hasAffix) {
65
+ oriObserverEntity.affixList = oriObserverEntity.affixList.filter(function (item) {
66
+ return item !== affix;
67
+ });
68
+ }
69
+
70
+ return hasAffix;
71
+ });
72
+
73
+ if (observerEntity && observerEntity.affixList.length === 0) {
74
+ observerEntities = observerEntities.filter(function (item) {
75
+ return item !== observerEntity;
76
+ }); // Remove listener
77
+
78
+ TRIGGER_EVENTS.forEach(function (eventName) {
79
+ var handler = observerEntity.eventHandlers[eventName];
80
+
81
+ if (handler && handler.remove) {
82
+ handler.remove();
83
+ }
84
+ });
85
+ }
86
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fle-ui/next",
3
- "version": "2.0.0-alpha.6",
3
+ "version": "2.0.0-alpha.7",
4
4
  "description": "fle-ui组件库",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -87,7 +87,6 @@
87
87
  "stylelint": "^14.9.1"
88
88
  },
89
89
  "dependencies": {
90
- "@alifd/theme-22858": "2.0.0",
91
90
  "antd": "4.24.4"
92
91
  }
93
92
  }
@@ -1,15 +0,0 @@
1
- import * as React from 'react';
2
- import type { ButtonProps, LegacyButtonType } from '../button/button';
3
- export interface ActionButtonProps {
4
- type?: LegacyButtonType;
5
- actionFn?: (...args: any[]) => any | PromiseLike<any>;
6
- close?: Function;
7
- autoFocus?: boolean;
8
- prefixCls: string;
9
- buttonProps?: ButtonProps;
10
- emitEvent?: boolean;
11
- quitOnNullishReturnValue?: boolean;
12
- children?: React.ReactNode;
13
- }
14
- declare const ActionButton: React.FC<ActionButtonProps>;
15
- export default ActionButton;
@@ -1,118 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/esm/extends";
2
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
- import useState from "rc-util/es/hooks/useState";
4
- import * as React from 'react';
5
- import Button from "../button";
6
- import { convertLegacyProps } from "../button/button";
7
-
8
- function isThenable(thing) {
9
- return !!(thing && !!thing.then);
10
- }
11
-
12
- var ActionButton = function ActionButton(props) {
13
- var clickedRef = React.useRef(false);
14
- var ref = React.useRef(null);
15
-
16
- var _useState = useState(false),
17
- _useState2 = _slicedToArray(_useState, 2),
18
- loading = _useState2[0],
19
- setLoading = _useState2[1];
20
-
21
- var close = props.close;
22
-
23
- var onInternalClose = function onInternalClose() {
24
- close === null || close === void 0 ? void 0 : close.apply(void 0, arguments);
25
- };
26
-
27
- React.useEffect(function () {
28
- var timeoutId = null;
29
-
30
- if (props.autoFocus) {
31
- timeoutId = setTimeout(function () {
32
- var _a;
33
-
34
- (_a = ref.current) === null || _a === void 0 ? void 0 : _a.focus();
35
- });
36
- }
37
-
38
- return function () {
39
- if (timeoutId) {
40
- clearTimeout(timeoutId);
41
- }
42
- };
43
- }, []);
44
-
45
- var handlePromiseOnOk = function handlePromiseOnOk(returnValueOfOnOk) {
46
- if (!isThenable(returnValueOfOnOk)) {
47
- return;
48
- }
49
-
50
- setLoading(true);
51
- returnValueOfOnOk.then(function () {
52
- setLoading(false, true);
53
- onInternalClose.apply(void 0, arguments);
54
- clickedRef.current = false;
55
- }, function (e) {
56
- // Emit error when catch promise reject
57
- // eslint-disable-next-line no-console
58
- console.error(e); // See: https://github.com/ant-design/ant-design/issues/6183
59
-
60
- setLoading(false, true);
61
- clickedRef.current = false;
62
- });
63
- };
64
-
65
- var onClick = function onClick(e) {
66
- var actionFn = props.actionFn;
67
-
68
- if (clickedRef.current) {
69
- return;
70
- }
71
-
72
- clickedRef.current = true;
73
-
74
- if (!actionFn) {
75
- onInternalClose();
76
- return;
77
- }
78
-
79
- var returnValueOfOnOk;
80
-
81
- if (props.emitEvent) {
82
- returnValueOfOnOk = actionFn(e);
83
-
84
- if (props.quitOnNullishReturnValue && !isThenable(returnValueOfOnOk)) {
85
- clickedRef.current = false;
86
- onInternalClose(e);
87
- return;
88
- }
89
- } else if (actionFn.length) {
90
- returnValueOfOnOk = actionFn(close); // https://github.com/ant-design/ant-design/issues/23358
91
-
92
- clickedRef.current = false;
93
- } else {
94
- returnValueOfOnOk = actionFn();
95
-
96
- if (!returnValueOfOnOk) {
97
- onInternalClose();
98
- return;
99
- }
100
- }
101
-
102
- handlePromiseOnOk(returnValueOfOnOk);
103
- };
104
-
105
- var type = props.type,
106
- children = props.children,
107
- prefixCls = props.prefixCls,
108
- buttonProps = props.buttonProps;
109
- return /*#__PURE__*/React.createElement(Button, _extends({}, convertLegacyProps(type), {
110
- onClick: onClick,
111
- loading: loading,
112
- prefixCls: prefixCls
113
- }, buttonProps, {
114
- ref: ref
115
- }), children);
116
- };
117
-
118
- export default ActionButton;
@@ -1,5 +0,0 @@
1
- import type { ElementOf } from './type';
2
- export declare const PresetStatusColorTypes: ["success", "processing", "error", "default", "warning"];
3
- export declare const PresetColorTypes: ["pink", "red", "yellow", "orange", "cyan", "green", "blue", "purple", "geekblue", "magenta", "volcano", "gold", "lime"];
4
- export type PresetColorType = ElementOf<typeof PresetColorTypes>;
5
- export type PresetStatusColorType = ElementOf<typeof PresetStatusColorTypes>;
@@ -1,4 +0,0 @@
1
- import { tuple } from "./type";
2
- export var PresetStatusColorTypes = tuple('success', 'processing', 'error', 'default', 'warning'); // eslint-disable-next-line import/prefer-default-export
3
-
4
- export var PresetColorTypes = tuple('pink', 'red', 'yellow', 'orange', 'cyan', 'green', 'blue', 'purple', 'geekblue', 'magenta', 'volcano', 'gold', 'lime');
@@ -1 +0,0 @@
1
- export declare function easeInOutCubic(t: number, b: number, c: number, d: number): number;