@alifd/chat 0.3.7 → 0.3.8-beta.1

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.
@@ -43,12 +43,26 @@ export function useDragable(dom, options) {
43
43
  const optionsRef = useRef(options);
44
44
  optionsRef.current = options;
45
45
  const [position, setPosition] = useState();
46
+ const cancelIframePointerEvents = () => {
47
+ const iframes = document.querySelectorAll('iframe');
48
+ iframes.forEach(iframe => {
49
+ iframe.style.pointerEvents = 'none';
50
+ // iframe.style.userSelect = 'none';
51
+ });
52
+ };
53
+ const revertIframePointerEvents = () => {
54
+ const iframes = document.querySelectorAll('iframe');
55
+ iframes.forEach(iframe => {
56
+ iframe.style.pointerEvents = 'auto';
57
+ // iframe.style.userSelect = 'auto';
58
+ });
59
+ };
46
60
  useEffect(() => {
47
61
  if (!dom || !options.enable) {
48
62
  return;
49
63
  }
50
- let isDown = false;
51
- let isMoving = false;
64
+ let isDown = false; // mousedown 标记为down
65
+ let isMoving = false; // mousemove 标记为moving
52
66
  let leftOffset = 0;
53
67
  let topOffset = 0;
54
68
  let domSize;
@@ -58,40 +72,45 @@ export function useDragable(dom, options) {
58
72
  var _a, _b;
59
73
  isDown = true;
60
74
  lastPosition = undefined;
61
- const rect = dom.getBoundingClientRect();
75
+ const rect = dom.getBoundingClientRect(); // 当前dom的范围
62
76
  leftOffset = rect.left - e.clientX;
63
77
  topOffset = rect.top - e.clientY;
64
78
  domSize = { width: rect.width, height: rect.height };
65
79
  (_b = (_a = optionsRef.current).onDragBefore) === null || _b === void 0 ? void 0 : _b.call(_a, dom);
66
80
  domRect = dom.getBoundingClientRect();
81
+ cancelIframePointerEvents();
67
82
  };
68
83
  const move = (e) => {
69
- var _a, _b, _c, _d;
70
84
  if (!isDown) {
71
85
  return;
72
86
  }
73
87
  e.preventDefault();
74
88
  isMoving = true;
75
89
  // do update dom position
76
- const position = Object.assign({ left: e.clientX + leftOffset, top: e.clientY + topOffset }, domSize);
77
- const adjustPosition = adjustBySafeAreaMargin(position, domRect, optionsRef.current.safeAreaMargin);
78
- const { left, top } = adjustPosition || position;
79
- if (lastPosition && lastPosition.left === left && lastPosition.top === top) {
80
- (_b = (_a = optionsRef.current).onDraging) === null || _b === void 0 ? void 0 : _b.call(_a, dom, e);
81
- return;
82
- }
83
- lastPosition = { left, top };
84
- const res = (_d = (_c = optionsRef.current).onDraging) === null || _d === void 0 ? void 0 : _d.call(_c, dom, e);
85
- if (res === false) {
86
- return;
87
- }
88
- dom.style.transition = 'unset';
89
- dom.style.transform = `translate(${left}px, ${top}px)`;
90
- dom.style.left = `0px`;
91
- dom.style.top = `0px`;
90
+ // 尝试修复1
91
+ requestAnimationFrame(() => {
92
+ var _a, _b, _c, _d;
93
+ const position = Object.assign({ left: e.clientX + leftOffset, top: e.clientY + topOffset }, domSize);
94
+ const adjustPosition = adjustBySafeAreaMargin(position, domRect, optionsRef.current.safeAreaMargin);
95
+ const { left, top } = adjustPosition || position;
96
+ if (lastPosition && lastPosition.left === left && lastPosition.top === top) {
97
+ (_b = (_a = optionsRef.current).onDraging) === null || _b === void 0 ? void 0 : _b.call(_a, dom, e);
98
+ return;
99
+ }
100
+ lastPosition = { left, top };
101
+ const res = (_d = (_c = optionsRef.current).onDraging) === null || _d === void 0 ? void 0 : _d.call(_c, dom, e);
102
+ if (res === false) {
103
+ return;
104
+ }
105
+ dom.style.transition = 'unset';
106
+ dom.style.transform = `translate(${left}px, ${top}px)`;
107
+ dom.style.left = `0px`;
108
+ dom.style.top = `0px`;
109
+ });
92
110
  };
93
111
  const up = (e) => {
94
112
  var _a, _b;
113
+ revertIframePointerEvents();
95
114
  if (!isDown) {
96
115
  return;
97
116
  }
@@ -115,10 +134,12 @@ export function useDragable(dom, options) {
115
134
  dom.addEventListener('mousedown', down);
116
135
  window.addEventListener('mousemove', move);
117
136
  window.addEventListener('mouseup', up);
137
+ window.addEventListener('contextmenu', up);
118
138
  return () => {
119
139
  dom.removeEventListener('mousedown', down);
120
- window.removeEventListener('move', move);
121
- window.removeEventListener('up', up);
140
+ window.removeEventListener('mousemove', move);
141
+ window.removeEventListener('mouseup', up);
142
+ window.removeEventListener('contextmenu', up);
122
143
  };
123
144
  }, [dom, options.enable]);
124
145
  return {
@@ -101,6 +101,7 @@ const FloatButton = forwardRef((props, ref) => {
101
101
  handleMove(e);
102
102
  // 隐藏的时候不处理
103
103
  if (isHideRef.current) {
104
+ console.log('useDragable isHideRef.current');
104
105
  return false;
105
106
  }
106
107
  },
@@ -120,8 +121,17 @@ const FloatButton = forwardRef((props, ref) => {
120
121
  onVisibleChange(v, type);
121
122
  };
122
123
  const renderBalloon = () => {
124
+ var _a, _b;
123
125
  const popupClassName = cs(`${cls}-popup`, (balloonProps === null || balloonProps === void 0 ? void 0 : balloonProps.popupClassName) || '');
124
- const popupStyle = Object.assign({ maxHeight: `${currentMaxHeight}px`, overflow: 'auto' }, ((balloonProps === null || balloonProps === void 0 ? void 0 : balloonProps.popupStyle) || {}));
126
+ const popupStyle = Object.assign({}, ((balloonProps === null || balloonProps === void 0 ? void 0 : balloonProps.popupStyle) || {}));
127
+ //判读下最大高度有没有超过当前高度,超过的话覆盖height
128
+ const currentHeight = parseInt(((_a = balloonProps === null || balloonProps === void 0 ? void 0 : balloonProps.popupStyle) === null || _a === void 0 ? void 0 : _a.height) ? ((_b = balloonProps === null || balloonProps === void 0 ? void 0 : balloonProps.popupStyle) === null || _b === void 0 ? void 0 : _b.height) + '' : currentMaxHeight + '');
129
+ if (currentMaxHeight < currentHeight) {
130
+ popupStyle.height = `${currentMaxHeight}px`;
131
+ }
132
+ else {
133
+ popupStyle.height = `${currentHeight}px`;
134
+ }
125
135
  return (React.createElement(Balloon, Object.assign({ visible: visible, onVisibleChange: handleVisibleChange, popupProps: {
126
136
  afterOpen() {
127
137
  var _a, _b;
@@ -138,6 +148,7 @@ const FloatButton = forwardRef((props, ref) => {
138
148
  }
139
149
  return renderBalloon();
140
150
  };
151
+ console.log('useDragable dragStyle:', dragStyle);
141
152
  return (React.createElement("div", { className: classNames, style: Object.assign(Object.assign({}, style), dragStyle), ref: elRef },
142
153
  !!addonBefore && (React.createElement("div", { className: cs(`${cls}-addon`, `${cls}-addon--before`) }, addonBefore)),
143
154
  React.createElement("div", { className: cs(`${cls}-trigger`), ref: triggerRef }, renderView()),
package/es/index.js CHANGED
@@ -20,4 +20,4 @@ export { default as CardLoading } from './card-loading';
20
20
  export { default as Origin } from './origin';
21
21
  export { default as Loading } from './loading';
22
22
  export { default as Drawer } from './drawer';
23
- export const version = '0.3.7';
23
+ export const version = '0.3.8-beta.1';
package/es/tag/index.d.ts CHANGED
@@ -892,7 +892,7 @@ declare const _default: import("@alifd/next/types/config-provider/types").Config
892
892
  UNSAFE_componentWillUpdate?(nextProps: Readonly<TagProps>, nextState: Readonly<{
893
893
  visible: boolean;
894
894
  }>, nextContext: any): void;
895
- }>>>, "size" | "type" | "onClick" | "disabled" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "autoFocus" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "nonce" | "placeholder" | "slot" | "spellCheck" | "style" | "tabIndex" | "title" | "translate" | "radioGroup" | "role" | "about" | "content" | "datatype" | "inlist" | "prefix" | "property" | "rel" | "resource" | "rev" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "warning" | "key" | "locale" | "pure" | "device" | "rtl" | "errorBoundary" | "closable" | "onClose" | "afterClose" | "animation" | "afterAppear" | "_shape" | "closeArea"> & import("@alifd/next/types/config-provider/types").ComponentCommonProps, import("@alifd/next/types/config-provider/types").ConfiguredComponent<(TagProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps) & import("@alifd/next/types/config-provider/types").ComponentCommonProps, import("@alifd/next/types/config-provider/types").ConfiguredComponent<TagProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, {
895
+ }>>>, "size" | "type" | "onClick" | "disabled" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "autoCapitalize" | "autoFocus" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "nonce" | "placeholder" | "slot" | "spellCheck" | "style" | "tabIndex" | "title" | "translate" | "radioGroup" | "role" | "about" | "content" | "datatype" | "inlist" | "prefix" | "property" | "rel" | "resource" | "rev" | "typeof" | "vocab" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "warning" | "key" | "locale" | "pure" | "device" | "rtl" | "errorBoundary" | "closable" | "onClose" | "afterClose" | "animation" | "afterAppear" | "_shape" | "closeArea"> & import("@alifd/next/types/config-provider/types").ComponentCommonProps, import("@alifd/next/types/config-provider/types").ConfiguredComponent<(TagProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps) & import("@alifd/next/types/config-provider/types").ComponentCommonProps, import("@alifd/next/types/config-provider/types").ConfiguredComponent<TagProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, {
896
896
  __destroyed: boolean;
897
897
  tagNode: HTMLDivElement | null;
898
898
  componentWillUnmount(): void;
@@ -46,12 +46,26 @@ function useDragable(dom, options) {
46
46
  const optionsRef = (0, react_1.useRef)(options);
47
47
  optionsRef.current = options;
48
48
  const [position, setPosition] = (0, react_1.useState)();
49
+ const cancelIframePointerEvents = () => {
50
+ const iframes = document.querySelectorAll('iframe');
51
+ iframes.forEach(iframe => {
52
+ iframe.style.pointerEvents = 'none';
53
+ // iframe.style.userSelect = 'none';
54
+ });
55
+ };
56
+ const revertIframePointerEvents = () => {
57
+ const iframes = document.querySelectorAll('iframe');
58
+ iframes.forEach(iframe => {
59
+ iframe.style.pointerEvents = 'auto';
60
+ // iframe.style.userSelect = 'auto';
61
+ });
62
+ };
49
63
  (0, react_1.useEffect)(() => {
50
64
  if (!dom || !options.enable) {
51
65
  return;
52
66
  }
53
- let isDown = false;
54
- let isMoving = false;
67
+ let isDown = false; // mousedown 标记为down
68
+ let isMoving = false; // mousemove 标记为moving
55
69
  let leftOffset = 0;
56
70
  let topOffset = 0;
57
71
  let domSize;
@@ -61,40 +75,45 @@ function useDragable(dom, options) {
61
75
  var _a, _b;
62
76
  isDown = true;
63
77
  lastPosition = undefined;
64
- const rect = dom.getBoundingClientRect();
78
+ const rect = dom.getBoundingClientRect(); // 当前dom的范围
65
79
  leftOffset = rect.left - e.clientX;
66
80
  topOffset = rect.top - e.clientY;
67
81
  domSize = { width: rect.width, height: rect.height };
68
82
  (_b = (_a = optionsRef.current).onDragBefore) === null || _b === void 0 ? void 0 : _b.call(_a, dom);
69
83
  domRect = dom.getBoundingClientRect();
84
+ cancelIframePointerEvents();
70
85
  };
71
86
  const move = (e) => {
72
- var _a, _b, _c, _d;
73
87
  if (!isDown) {
74
88
  return;
75
89
  }
76
90
  e.preventDefault();
77
91
  isMoving = true;
78
92
  // do update dom position
79
- const position = Object.assign({ left: e.clientX + leftOffset, top: e.clientY + topOffset }, domSize);
80
- const adjustPosition = (0, util_1.adjustBySafeAreaMargin)(position, domRect, optionsRef.current.safeAreaMargin);
81
- const { left, top } = adjustPosition || position;
82
- if (lastPosition && lastPosition.left === left && lastPosition.top === top) {
83
- (_b = (_a = optionsRef.current).onDraging) === null || _b === void 0 ? void 0 : _b.call(_a, dom, e);
84
- return;
85
- }
86
- lastPosition = { left, top };
87
- const res = (_d = (_c = optionsRef.current).onDraging) === null || _d === void 0 ? void 0 : _d.call(_c, dom, e);
88
- if (res === false) {
89
- return;
90
- }
91
- dom.style.transition = 'unset';
92
- dom.style.transform = `translate(${left}px, ${top}px)`;
93
- dom.style.left = `0px`;
94
- dom.style.top = `0px`;
93
+ // 尝试修复1
94
+ requestAnimationFrame(() => {
95
+ var _a, _b, _c, _d;
96
+ const position = Object.assign({ left: e.clientX + leftOffset, top: e.clientY + topOffset }, domSize);
97
+ const adjustPosition = (0, util_1.adjustBySafeAreaMargin)(position, domRect, optionsRef.current.safeAreaMargin);
98
+ const { left, top } = adjustPosition || position;
99
+ if (lastPosition && lastPosition.left === left && lastPosition.top === top) {
100
+ (_b = (_a = optionsRef.current).onDraging) === null || _b === void 0 ? void 0 : _b.call(_a, dom, e);
101
+ return;
102
+ }
103
+ lastPosition = { left, top };
104
+ const res = (_d = (_c = optionsRef.current).onDraging) === null || _d === void 0 ? void 0 : _d.call(_c, dom, e);
105
+ if (res === false) {
106
+ return;
107
+ }
108
+ dom.style.transition = 'unset';
109
+ dom.style.transform = `translate(${left}px, ${top}px)`;
110
+ dom.style.left = `0px`;
111
+ dom.style.top = `0px`;
112
+ });
95
113
  };
96
114
  const up = (e) => {
97
115
  var _a, _b;
116
+ revertIframePointerEvents();
98
117
  if (!isDown) {
99
118
  return;
100
119
  }
@@ -118,10 +137,12 @@ function useDragable(dom, options) {
118
137
  dom.addEventListener('mousedown', down);
119
138
  window.addEventListener('mousemove', move);
120
139
  window.addEventListener('mouseup', up);
140
+ window.addEventListener('contextmenu', up);
121
141
  return () => {
122
142
  dom.removeEventListener('mousedown', down);
123
- window.removeEventListener('move', move);
124
- window.removeEventListener('up', up);
143
+ window.removeEventListener('mousemove', move);
144
+ window.removeEventListener('mouseup', up);
145
+ window.removeEventListener('contextmenu', up);
125
146
  };
126
147
  }, [dom, options.enable]);
127
148
  return {
@@ -103,6 +103,7 @@ const FloatButton = (0, react_1.forwardRef)((props, ref) => {
103
103
  handleMove(e);
104
104
  // 隐藏的时候不处理
105
105
  if (isHideRef.current) {
106
+ console.log('useDragable isHideRef.current');
106
107
  return false;
107
108
  }
108
109
  },
@@ -122,8 +123,17 @@ const FloatButton = (0, react_1.forwardRef)((props, ref) => {
122
123
  onVisibleChange(v, type);
123
124
  };
124
125
  const renderBalloon = () => {
126
+ var _a, _b;
125
127
  const popupClassName = (0, classnames_1.default)(`${cls}-popup`, (balloonProps === null || balloonProps === void 0 ? void 0 : balloonProps.popupClassName) || '');
126
- const popupStyle = Object.assign({ maxHeight: `${currentMaxHeight}px`, overflow: 'auto' }, ((balloonProps === null || balloonProps === void 0 ? void 0 : balloonProps.popupStyle) || {}));
128
+ const popupStyle = Object.assign({}, ((balloonProps === null || balloonProps === void 0 ? void 0 : balloonProps.popupStyle) || {}));
129
+ //判读下最大高度有没有超过当前高度,超过的话覆盖height
130
+ const currentHeight = parseInt(((_a = balloonProps === null || balloonProps === void 0 ? void 0 : balloonProps.popupStyle) === null || _a === void 0 ? void 0 : _a.height) ? ((_b = balloonProps === null || balloonProps === void 0 ? void 0 : balloonProps.popupStyle) === null || _b === void 0 ? void 0 : _b.height) + '' : currentMaxHeight + '');
131
+ if (currentMaxHeight < currentHeight) {
132
+ popupStyle.height = `${currentMaxHeight}px`;
133
+ }
134
+ else {
135
+ popupStyle.height = `${currentHeight}px`;
136
+ }
127
137
  return (react_1.default.createElement(next_1.Balloon, Object.assign({ visible: visible, onVisibleChange: handleVisibleChange, popupProps: {
128
138
  afterOpen() {
129
139
  var _a, _b;
@@ -140,6 +150,7 @@ const FloatButton = (0, react_1.forwardRef)((props, ref) => {
140
150
  }
141
151
  return renderBalloon();
142
152
  };
153
+ console.log('useDragable dragStyle:', dragStyle);
143
154
  return (react_1.default.createElement("div", { className: classNames, style: Object.assign(Object.assign({}, style), dragStyle), ref: elRef },
144
155
  !!addonBefore && (react_1.default.createElement("div", { className: (0, classnames_1.default)(`${cls}-addon`, `${cls}-addon--before`) }, addonBefore)),
145
156
  react_1.default.createElement("div", { className: (0, classnames_1.default)(`${cls}-trigger`), ref: triggerRef }, renderView()),
package/lib/index.js CHANGED
@@ -46,4 +46,4 @@ var loading_1 = require("./loading");
46
46
  Object.defineProperty(exports, "Loading", { enumerable: true, get: function () { return tslib_1.__importDefault(loading_1).default; } });
47
47
  var drawer_1 = require("./drawer");
48
48
  Object.defineProperty(exports, "Drawer", { enumerable: true, get: function () { return tslib_1.__importDefault(drawer_1).default; } });
49
- exports.version = '0.3.7';
49
+ exports.version = '0.3.8-beta.1';
@@ -892,7 +892,7 @@ declare const _default: import("@alifd/next/types/config-provider/types").Config
892
892
  UNSAFE_componentWillUpdate?(nextProps: Readonly<TagProps>, nextState: Readonly<{
893
893
  visible: boolean;
894
894
  }>, nextContext: any): void;
895
- }>>>, "size" | "type" | "onClick" | "disabled" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "autoFocus" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "nonce" | "placeholder" | "slot" | "spellCheck" | "style" | "tabIndex" | "title" | "translate" | "radioGroup" | "role" | "about" | "content" | "datatype" | "inlist" | "prefix" | "property" | "rel" | "resource" | "rev" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "warning" | "key" | "locale" | "pure" | "device" | "rtl" | "errorBoundary" | "closable" | "onClose" | "afterClose" | "animation" | "afterAppear" | "_shape" | "closeArea"> & import("@alifd/next/types/config-provider/types").ComponentCommonProps, import("@alifd/next/types/config-provider/types").ConfiguredComponent<(TagProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps) & import("@alifd/next/types/config-provider/types").ComponentCommonProps, import("@alifd/next/types/config-provider/types").ConfiguredComponent<TagProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, {
895
+ }>>>, "size" | "type" | "onClick" | "disabled" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "autoCapitalize" | "autoFocus" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "nonce" | "placeholder" | "slot" | "spellCheck" | "style" | "tabIndex" | "title" | "translate" | "radioGroup" | "role" | "about" | "content" | "datatype" | "inlist" | "prefix" | "property" | "rel" | "resource" | "rev" | "typeof" | "vocab" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "warning" | "key" | "locale" | "pure" | "device" | "rtl" | "errorBoundary" | "closable" | "onClose" | "afterClose" | "animation" | "afterAppear" | "_shape" | "closeArea"> & import("@alifd/next/types/config-provider/types").ComponentCommonProps, import("@alifd/next/types/config-provider/types").ConfiguredComponent<(TagProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps) & import("@alifd/next/types/config-provider/types").ComponentCommonProps, import("@alifd/next/types/config-provider/types").ConfiguredComponent<TagProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, {
896
896
  __destroyed: boolean;
897
897
  tagNode: HTMLDivElement | null;
898
898
  componentWillUnmount(): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alifd/chat",
3
- "version": "0.3.7",
3
+ "version": "0.3.8-beta.1",
4
4
  "description": "A configurable component library for chat built on React.",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -435,6 +435,9 @@
435
435
  "type": "git"
436
436
  },
437
437
  "license": "MIT",
438
+ "overrides": {
439
+ "uc.micro": "1.0.6"
440
+ },
438
441
  "publishConfig": {
439
442
  "access": "public",
440
443
  "registry": "https://registry.npmjs.org"