@alifd/chat 0.1.8 → 0.1.10

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.
@@ -20,5 +20,13 @@
20
20
  import React from 'react';
21
21
  import type { ButtonProps } from './types';
22
22
  export * from './types';
23
- declare const _default: import("@alifd/next/types/config-provider/types").ConfiguredComponentClass<Pick<ButtonProps & React.RefAttributes<import("@alifd/next/types/config-provider/types").ConfiguredComponent<import("@alifd/next/types/button").ButtonProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, import("@alifd/next/types/button/view/button").default>>, keyof ButtonProps | "key"> & import("@alifd/next/types/config-provider/types").ComponentCommonProps, import("@alifd/next/types/config-provider/types").ConfiguredComponent<import("@alifd/next/types/button").ButtonProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, import("@alifd/next/types/button/view/button").default>, {}>;
23
+ declare const _default: {
24
+ new (props: ButtonProps & React.RefAttributes<import("@alifd/next/types/config-provider/types").ConfiguredComponent<import("@alifd/next/types/button").ButtonProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, import("@alifd/next/types/button/view/button").default>> & import("@alifd/next/types/config-provider/types").ComponentCommonProps, context?: unknown): import("@alifd/next/types/config-provider/types").ConfiguredComponent<ButtonProps & React.RefAttributes<import("@alifd/next/types/config-provider/types").ConfiguredComponent<import("@alifd/next/types/button").ButtonProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, import("@alifd/next/types/button/view/button").default>> & import("@alifd/next/types/config-provider/types").ComponentCommonProps, import("@alifd/next/types/config-provider/types").ConfiguredComponent<import("@alifd/next/types/button").ButtonProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, import("@alifd/next/types/button/view/button").default>>;
25
+ contextType?: React.Context<any> | undefined;
26
+ } & {
27
+ displayName: string;
28
+ defaultProps: Partial<ButtonProps & React.RefAttributes<import("@alifd/next/types/config-provider/types").ConfiguredComponent<import("@alifd/next/types/button").ButtonProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, import("@alifd/next/types/button/view/button").default>>> | undefined;
29
+ propTypes: React.WeakValidationMap<ButtonProps & React.RefAttributes<import("@alifd/next/types/config-provider/types").ConfiguredComponent<import("@alifd/next/types/button").ButtonProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, import("@alifd/next/types/button/view/button").default>>> | undefined;
30
+ $$typeof: symbol;
31
+ };
24
32
  export default _default;
@@ -1,5 +1,9 @@
1
+ /// <reference types="react" />
1
2
  import Collapsable from './view/collapsable';
2
- declare const CardWithSub: import("@alifd/next/types/config-provider/types").ConfiguredComponentClass<import("./types").CardProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, undefined, {}> & {
3
+ declare const CardWithSub: {
4
+ new (props: import("./types").CardProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, context?: unknown): import("@alifd/next/types/config-provider/types").ConfiguredComponent<import("./types").CardProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, unknown>;
5
+ contextType?: import("react").Context<any> | undefined;
6
+ } & {} & {
3
7
  Collapsable: typeof Collapsable;
4
8
  };
5
9
  export * from './types';
@@ -2,5 +2,8 @@ import React from 'react';
2
2
  import type { CardProps } from '../types';
3
3
  export declare function useCardInner({ prefix, innerClassName, title, titleAlign, titleLine, footer, footerAlign, footerLine, components, children, }: CardProps): React.JSX.Element;
4
4
  export declare function useCardOuter(props: CardProps): React.JSX.Element;
5
- declare const _default: import("@alifd/next/types/config-provider/types").ConfiguredComponentClass<CardProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, undefined, {}>;
5
+ declare const _default: {
6
+ new (props: CardProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, context?: unknown): import("@alifd/next/types/config-provider/types").ConfiguredComponent<CardProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, unknown>;
7
+ contextType?: React.Context<any> | undefined;
8
+ } & {};
6
9
  export default _default;
@@ -1,7 +1,12 @@
1
+ import React from 'react';
1
2
  import type { FeedbackProps } from './types';
2
3
  import Good from './view/good';
3
4
  export * from './types';
4
- declare const _default: import("@alifd/next/types/config-provider/types").ConfiguredComponentClass<FeedbackProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, undefined, {}> & {
5
+ declare const _default: {
6
+ new (props: FeedbackProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, context?: unknown): import("@alifd/next/types/config-provider/types").ConfiguredComponent<FeedbackProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, unknown>;
7
+ contextType?: React.Context<any> | undefined;
8
+ } & {
9
+ displayName: string;
5
10
  Good: typeof Good;
6
11
  };
7
12
  export default _default;
@@ -1,8 +1,30 @@
1
1
  /// <reference types="react" />
2
- declare const FloatButtonWithSub: import("@alifd/next/types/config-provider/types").ConfiguredComponentClass<Pick<import("./types").FloatButtonProps & import("react").RefAttributes<import("./types").FloatButtonRef>, "key" | keyof import("./types").FloatButtonProps> & import("@alifd/next/types/config-provider/types").ComponentCommonProps, import("./types").FloatButtonRef, {}> & {
3
- Backtop: import("@alifd/next/types/config-provider/types").ConfiguredComponentClass<Pick<import("./types").BacktopProps & import("react").RefAttributes<import("./types").BacktopRef>, "key" | keyof import("./types").BacktopProps> & import("@alifd/next/types/config-provider/types").ComponentCommonProps, import("./types").BacktopRef, {}>;
4
- Drawer: import("@alifd/next/types/config-provider/types").ConfiguredComponentClass<import("./types").FloatButtonDrawerProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, undefined, {}>;
5
- InnerDrawer: import("@alifd/next/types/config-provider/types").ConfiguredComponentClass<import("./types").FloatButtonInnerDrawerProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, undefined, {}>;
2
+ declare const FloatButtonWithSub: {
3
+ new (props: import("./types").FloatButtonProps & import("react").RefAttributes<import("./types").FloatButtonRef> & import("@alifd/next/types/config-provider/types").ComponentCommonProps, context?: unknown): import("@alifd/next/types/config-provider/types").ConfiguredComponent<import("./types").FloatButtonProps & import("react").RefAttributes<import("./types").FloatButtonRef> & import("@alifd/next/types/config-provider/types").ComponentCommonProps, import("./types").FloatButtonRef>;
4
+ contextType?: import("react").Context<any> | undefined;
5
+ } & {
6
+ displayName: string | undefined;
7
+ defaultProps: Partial<import("./types").FloatButtonProps & import("react").RefAttributes<import("./types").FloatButtonRef>> | undefined;
8
+ propTypes: import("react").WeakValidationMap<import("./types").FloatButtonProps & import("react").RefAttributes<import("./types").FloatButtonRef>> | undefined;
9
+ $$typeof: symbol;
10
+ } & {
11
+ Backtop: {
12
+ new (props: import("./types").BacktopProps & import("react").RefAttributes<import("./types").BacktopRef> & import("@alifd/next/types/config-provider/types").ComponentCommonProps, context?: unknown): import("@alifd/next/types/config-provider/types").ConfiguredComponent<import("./types").BacktopProps & import("react").RefAttributes<import("./types").BacktopRef> & import("@alifd/next/types/config-provider/types").ComponentCommonProps, import("./types").BacktopRef>;
13
+ contextType?: import("react").Context<any> | undefined;
14
+ } & {
15
+ displayName: string | undefined;
16
+ defaultProps: Partial<import("./types").BacktopProps & import("react").RefAttributes<import("./types").BacktopRef>> | undefined;
17
+ propTypes: import("react").WeakValidationMap<import("./types").BacktopProps & import("react").RefAttributes<import("./types").BacktopRef>> | undefined;
18
+ $$typeof: symbol;
19
+ };
20
+ Drawer: {
21
+ new (props: import("./types").FloatButtonDrawerProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, context?: unknown): import("@alifd/next/types/config-provider/types").ConfiguredComponent<import("./types").FloatButtonDrawerProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, unknown>;
22
+ contextType?: import("react").Context<any> | undefined;
23
+ } & {};
24
+ InnerDrawer: {
25
+ new (props: import("./types").FloatButtonInnerDrawerProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, context?: unknown): import("@alifd/next/types/config-provider/types").ConfiguredComponent<import("./types").FloatButtonInnerDrawerProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, unknown>;
26
+ contextType?: import("react").Context<any> | undefined;
27
+ } & {};
6
28
  };
7
29
  export type { BacktopRef, BacktopProps, FloatButtonRef, FloatButtonProps, FloatButtonDrawerProps, FloatButtonInnerDrawerProps, Edge, Margin, Position, RequiredParts, ScreenRatioPosition, Size, TriggerType, } from './types';
8
30
  export default FloatButtonWithSub;
@@ -1,4 +1,12 @@
1
1
  import React from 'react';
2
2
  import type { BacktopProps, BacktopRef } from '../types';
3
- declare const _default: import("@alifd/next/types/config-provider/types").ConfiguredComponentClass<Pick<BacktopProps & React.RefAttributes<BacktopRef>, "key" | keyof BacktopProps> & import("@alifd/next/types/config-provider/types").ComponentCommonProps, BacktopRef, {}>;
3
+ declare const _default: {
4
+ new (props: BacktopProps & React.RefAttributes<BacktopRef> & import("@alifd/next/types/config-provider/types").ComponentCommonProps, context?: unknown): import("@alifd/next/types/config-provider/types").ConfiguredComponent<BacktopProps & React.RefAttributes<BacktopRef> & import("@alifd/next/types/config-provider/types").ComponentCommonProps, BacktopRef>;
5
+ contextType?: React.Context<any> | undefined;
6
+ } & {
7
+ displayName: string | undefined;
8
+ defaultProps: Partial<BacktopProps & React.RefAttributes<BacktopRef>> | undefined;
9
+ propTypes: React.WeakValidationMap<BacktopProps & React.RefAttributes<BacktopRef>> | undefined;
10
+ $$typeof: symbol;
11
+ };
4
12
  export default _default;
@@ -6,5 +6,8 @@ export interface DrawerProps extends Omit<NextDrawerProps, 'triggerType' | 'cont
6
6
  triggerType?: TriggerType | TriggerType[];
7
7
  }
8
8
  export declare function Drawer({ prefix, children, trigger, triggerType, visible, onVisibleChange, ...rests }: DrawerProps): React.JSX.Element;
9
- declare const _default: import("@alifd/next/types/config-provider/types").ConfiguredComponentClass<FloatButtonDrawerProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, undefined, {}>;
9
+ declare const _default: {
10
+ new (props: FloatButtonDrawerProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, context?: unknown): import("@alifd/next/types/config-provider/types").ConfiguredComponent<FloatButtonDrawerProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, unknown>;
11
+ contextType?: React.Context<any> | undefined;
12
+ } & {};
10
13
  export default _default;
@@ -1,4 +1,12 @@
1
1
  import React from 'react';
2
2
  import type { FloatButtonProps, FloatButtonRef } from '../types';
3
- declare const _default: import("@alifd/next/types/config-provider/types").ConfiguredComponentClass<Pick<FloatButtonProps & React.RefAttributes<FloatButtonRef>, "key" | keyof FloatButtonProps> & import("@alifd/next/types/config-provider/types").ComponentCommonProps, FloatButtonRef, {}>;
3
+ declare const _default: {
4
+ new (props: FloatButtonProps & React.RefAttributes<FloatButtonRef> & import("@alifd/next/types/config-provider/types").ComponentCommonProps, context?: unknown): import("@alifd/next/types/config-provider/types").ConfiguredComponent<FloatButtonProps & React.RefAttributes<FloatButtonRef> & import("@alifd/next/types/config-provider/types").ComponentCommonProps, FloatButtonRef>;
5
+ contextType?: React.Context<any> | undefined;
6
+ } & {
7
+ displayName: string | undefined;
8
+ defaultProps: Partial<FloatButtonProps & React.RefAttributes<FloatButtonRef>> | undefined;
9
+ propTypes: React.WeakValidationMap<FloatButtonProps & React.RefAttributes<FloatButtonRef>> | undefined;
10
+ $$typeof: symbol;
11
+ };
4
12
  export default _default;
@@ -19,5 +19,8 @@ export interface InnerDrawerProps {
19
19
  afterClose?: () => void;
20
20
  }
21
21
  export declare function InnerDrawer({ className, prefix, target, children, trigger, triggerType, visible, onVisibleChange, closable, title, cache, width, beforeOpen, beforeClose, afterOpen, afterClose, }: InnerDrawerProps): React.JSX.Element;
22
- declare const _default: import("@alifd/next/types/config-provider/types").ConfiguredComponentClass<FloatButtonInnerDrawerProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, undefined, {}>;
22
+ declare const _default: {
23
+ new (props: FloatButtonInnerDrawerProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, context?: unknown): import("@alifd/next/types/config-provider/types").ConfiguredComponent<FloatButtonInnerDrawerProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, unknown>;
24
+ contextType?: React.Context<any> | undefined;
25
+ } & {};
23
26
  export default _default;
@@ -101,34 +101,23 @@ export function InnerDrawer({ className, prefix, target, children, trigger, trig
101
101
  const handlers = useTriggerType({ visible, onVisibleChange: handleVisibleChange, triggerType });
102
102
  const domRef = useRef(null);
103
103
  const triggerRef = useRef(null);
104
- useEffect(() => {
105
- if (!mountTarget) {
106
- return;
107
- }
108
- if (visible) {
109
- beforeOpen === null || beforeOpen === void 0 ? void 0 : beforeOpen();
110
- const id = requestAnimationFrame(() => {
111
- mountTarget.style.width = `${typeof width === 'number' ? `${width}px` : width}`;
112
- mountTarget.style.opacity = '1';
113
- });
114
- return () => {
115
- cancelAnimationFrame(id);
116
- };
117
- }
118
- else {
119
- beforeClose === null || beforeClose === void 0 ? void 0 : beforeClose();
120
- mountTarget.style.width = `0px`;
121
- mountTarget.style.opacity = '0';
104
+ const timeoutRef = useRef(null);
105
+ const hasCallbackFired = useRef(false);
106
+ function handleAnimationEnd() {
107
+ if (!hasCallbackFired.current) {
108
+ const { visible, afterClose, afterOpen } = propsRef.current;
109
+ visible ? afterOpen === null || afterOpen === void 0 ? void 0 : afterOpen() : afterClose === null || afterClose === void 0 ? void 0 : afterClose();
110
+ hasCallbackFired.current = true;
122
111
  }
123
- }, [visible, mountTarget]);
112
+ }
124
113
  useEffect(() => {
125
114
  if (!mountTarget) {
126
115
  return;
127
116
  }
128
117
  const onEnd = (e) => {
129
118
  if (e.target === mountTarget && e.propertyName === 'width') {
130
- const { visible, afterClose, afterOpen } = propsRef.current;
131
- visible ? afterOpen === null || afterOpen === void 0 ? void 0 : afterOpen() : afterClose === null || afterClose === void 0 ? void 0 : afterClose();
119
+ clearTimeout(timeoutRef.current);
120
+ handleAnimationEnd();
132
121
  }
133
122
  };
134
123
  mountTarget.addEventListener('transitionend', onEnd);
@@ -136,6 +125,39 @@ export function InnerDrawer({ className, prefix, target, children, trigger, trig
136
125
  mountTarget.removeEventListener('transitionend', onEnd);
137
126
  };
138
127
  }, [mountTarget]);
128
+ useEffect(() => {
129
+ if (!mountTarget) {
130
+ return;
131
+ }
132
+ hasCallbackFired.current = false;
133
+ function applyAnimationStyles(target, width, opacity) {
134
+ target.style.transition = 'width 0.3s, opacity 0.3s';
135
+ target.style.width = `${typeof width === 'number' ? `${width}px` : width}`;
136
+ target.style.opacity = opacity;
137
+ }
138
+ const animationFrameId = requestAnimationFrame(() => {
139
+ if (visible) {
140
+ beforeOpen === null || beforeOpen === void 0 ? void 0 : beforeOpen();
141
+ clearTimeout(timeoutRef.current);
142
+ timeoutRef.current = setTimeout(() => {
143
+ handleAnimationEnd();
144
+ }, 300);
145
+ applyAnimationStyles(mountTarget, width, '1');
146
+ }
147
+ else {
148
+ beforeClose === null || beforeClose === void 0 ? void 0 : beforeClose();
149
+ clearTimeout(timeoutRef.current);
150
+ timeoutRef.current = setTimeout(() => {
151
+ handleAnimationEnd();
152
+ }, 300);
153
+ applyAnimationStyles(mountTarget, 0, '0');
154
+ }
155
+ });
156
+ return () => {
157
+ cancelAnimationFrame(animationFrameId);
158
+ clearTimeout(timeoutRef.current);
159
+ };
160
+ }, [visible, mountTarget]);
139
161
  useEffect(() => {
140
162
  if (!mountTarget || !className) {
141
163
  return;
package/es/index.js CHANGED
@@ -5,4 +5,4 @@ export { default as FloatButton } from './float-button';
5
5
  export { default as Text } from './text';
6
6
  export { default as Tag } from './tag';
7
7
  export { default as Tab } from './tab';
8
- export const version = '0.1.8';
8
+ export const version = '0.1.9';
package/es/tab/index.d.ts CHANGED
@@ -2,7 +2,14 @@ import React from 'react';
2
2
  import { Tab as NextTab } from '@alifd/next';
3
3
  import type { TabProps } from '@alifd/next/types/tab';
4
4
  export type { TabProps, ItemProps } from '@alifd/next/types/tab';
5
- declare const _default: import("@alifd/next/types/config-provider/types").ConfiguredComponentClass<Pick<TabProps & React.RefAttributes<NextTab>, "key" | keyof TabProps> & import("@alifd/next/types/config-provider/types").ComponentCommonProps, NextTab, {}> & {
5
+ declare const _default: {
6
+ new (props: TabProps & React.RefAttributes<NextTab> & import("@alifd/next/types/config-provider/types").ComponentCommonProps, context?: unknown): import("@alifd/next/types/config-provider/types").ConfiguredComponent<TabProps & React.RefAttributes<NextTab> & import("@alifd/next/types/config-provider/types").ComponentCommonProps, NextTab>;
7
+ contextType?: React.Context<any> | undefined;
8
+ } & {
9
+ displayName: string;
10
+ defaultProps: Partial<TabProps & React.RefAttributes<NextTab>> | undefined;
11
+ propTypes: React.WeakValidationMap<TabProps & React.RefAttributes<NextTab>> | undefined;
12
+ $$typeof: symbol;
6
13
  Item: typeof import("@alifd/next/types/tab").Item;
7
14
  };
8
15
  export default _default;
package/es/tag/index.d.ts CHANGED
@@ -9,5 +9,13 @@ import React from 'react';
9
9
  import { Tag as NextTag } from '@alifd/next';
10
10
  import type { TagProps } from '@alifd/next/types/tag';
11
11
  export type { TagProps } from '@alifd/next/types/tag';
12
- declare const _default: import("@alifd/next/types/config-provider/types").ConfiguredComponentClass<Pick<TagProps & React.RefAttributes<NextTag>, "key" | keyof TagProps> & import("@alifd/next/types/config-provider/types").ComponentCommonProps, NextTag, {}>;
12
+ declare const _default: {
13
+ new (props: TagProps & React.RefAttributes<NextTag> & import("@alifd/next/types/config-provider/types").ComponentCommonProps, context?: unknown): import("@alifd/next/types/config-provider/types").ConfiguredComponent<TagProps & React.RefAttributes<NextTag> & import("@alifd/next/types/config-provider/types").ComponentCommonProps, NextTag>;
14
+ contextType?: React.Context<any> | undefined;
15
+ } & {
16
+ displayName: string;
17
+ defaultProps: Partial<TagProps & React.RefAttributes<NextTag>> | undefined;
18
+ propTypes: React.WeakValidationMap<TagProps & React.RefAttributes<NextTag>> | undefined;
19
+ $$typeof: symbol;
20
+ };
13
21
  export default _default;
@@ -1,3 +1,9 @@
1
+ import React from 'react';
1
2
  import type { TextProps } from './types';
2
- declare const _default: import("@alifd/next/types/config-provider/types").ConfiguredComponentClass<TextProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, undefined, {}>;
3
+ declare const _default: {
4
+ new (props: TextProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, context?: unknown): import("@alifd/next/types/config-provider/types").ConfiguredComponent<TextProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, unknown>;
5
+ contextType?: React.Context<any> | undefined;
6
+ } & {
7
+ displayName: string;
8
+ };
3
9
  export default _default;
@@ -20,9 +20,9 @@ export function useControlable(props, { valueName = 'value', defaultValueName =
20
20
  }
21
21
  };
22
22
  useEffect(() => {
23
- if (value !== propValue) {
23
+ if (isControl && value !== propValue) {
24
24
  setValue(() => propValue);
25
25
  }
26
- }, [propValue]);
26
+ }, [propValue, isControl]);
27
27
  return [value, handleChange];
28
28
  }
@@ -20,5 +20,13 @@
20
20
  import React from 'react';
21
21
  import type { ButtonProps } from './types';
22
22
  export * from './types';
23
- declare const _default: import("@alifd/next/types/config-provider/types").ConfiguredComponentClass<Pick<ButtonProps & React.RefAttributes<import("@alifd/next/types/config-provider/types").ConfiguredComponent<import("@alifd/next/types/button").ButtonProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, import("@alifd/next/types/button/view/button").default>>, keyof ButtonProps | "key"> & import("@alifd/next/types/config-provider/types").ComponentCommonProps, import("@alifd/next/types/config-provider/types").ConfiguredComponent<import("@alifd/next/types/button").ButtonProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, import("@alifd/next/types/button/view/button").default>, {}>;
23
+ declare const _default: {
24
+ new (props: ButtonProps & React.RefAttributes<import("@alifd/next/types/config-provider/types").ConfiguredComponent<import("@alifd/next/types/button").ButtonProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, import("@alifd/next/types/button/view/button").default>> & import("@alifd/next/types/config-provider/types").ComponentCommonProps, context?: unknown): import("@alifd/next/types/config-provider/types").ConfiguredComponent<ButtonProps & React.RefAttributes<import("@alifd/next/types/config-provider/types").ConfiguredComponent<import("@alifd/next/types/button").ButtonProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, import("@alifd/next/types/button/view/button").default>> & import("@alifd/next/types/config-provider/types").ComponentCommonProps, import("@alifd/next/types/config-provider/types").ConfiguredComponent<import("@alifd/next/types/button").ButtonProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, import("@alifd/next/types/button/view/button").default>>;
25
+ contextType?: React.Context<any> | undefined;
26
+ } & {
27
+ displayName: string;
28
+ defaultProps: Partial<ButtonProps & React.RefAttributes<import("@alifd/next/types/config-provider/types").ConfiguredComponent<import("@alifd/next/types/button").ButtonProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, import("@alifd/next/types/button/view/button").default>>> | undefined;
29
+ propTypes: React.WeakValidationMap<ButtonProps & React.RefAttributes<import("@alifd/next/types/config-provider/types").ConfiguredComponent<import("@alifd/next/types/button").ButtonProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, import("@alifd/next/types/button/view/button").default>>> | undefined;
30
+ $$typeof: symbol;
31
+ };
24
32
  export default _default;
@@ -1,5 +1,9 @@
1
+ /// <reference types="react" />
1
2
  import Collapsable from './view/collapsable';
2
- declare const CardWithSub: import("@alifd/next/types/config-provider/types").ConfiguredComponentClass<import("./types").CardProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, undefined, {}> & {
3
+ declare const CardWithSub: {
4
+ new (props: import("./types").CardProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, context?: unknown): import("@alifd/next/types/config-provider/types").ConfiguredComponent<import("./types").CardProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, unknown>;
5
+ contextType?: import("react").Context<any> | undefined;
6
+ } & {} & {
3
7
  Collapsable: typeof Collapsable;
4
8
  };
5
9
  export * from './types';
@@ -2,5 +2,8 @@ import React from 'react';
2
2
  import type { CardProps } from '../types';
3
3
  export declare function useCardInner({ prefix, innerClassName, title, titleAlign, titleLine, footer, footerAlign, footerLine, components, children, }: CardProps): React.JSX.Element;
4
4
  export declare function useCardOuter(props: CardProps): React.JSX.Element;
5
- declare const _default: import("@alifd/next/types/config-provider/types").ConfiguredComponentClass<CardProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, undefined, {}>;
5
+ declare const _default: {
6
+ new (props: CardProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, context?: unknown): import("@alifd/next/types/config-provider/types").ConfiguredComponent<CardProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, unknown>;
7
+ contextType?: React.Context<any> | undefined;
8
+ } & {};
6
9
  export default _default;
@@ -1,7 +1,12 @@
1
+ import React from 'react';
1
2
  import type { FeedbackProps } from './types';
2
3
  import Good from './view/good';
3
4
  export * from './types';
4
- declare const _default: import("@alifd/next/types/config-provider/types").ConfiguredComponentClass<FeedbackProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, undefined, {}> & {
5
+ declare const _default: {
6
+ new (props: FeedbackProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, context?: unknown): import("@alifd/next/types/config-provider/types").ConfiguredComponent<FeedbackProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, unknown>;
7
+ contextType?: React.Context<any> | undefined;
8
+ } & {
9
+ displayName: string;
5
10
  Good: typeof Good;
6
11
  };
7
12
  export default _default;
@@ -1,8 +1,30 @@
1
1
  /// <reference types="react" />
2
- declare const FloatButtonWithSub: import("@alifd/next/types/config-provider/types").ConfiguredComponentClass<Pick<import("./types").FloatButtonProps & import("react").RefAttributes<import("./types").FloatButtonRef>, "key" | keyof import("./types").FloatButtonProps> & import("@alifd/next/types/config-provider/types").ComponentCommonProps, import("./types").FloatButtonRef, {}> & {
3
- Backtop: import("@alifd/next/types/config-provider/types").ConfiguredComponentClass<Pick<import("./types").BacktopProps & import("react").RefAttributes<import("./types").BacktopRef>, "key" | keyof import("./types").BacktopProps> & import("@alifd/next/types/config-provider/types").ComponentCommonProps, import("./types").BacktopRef, {}>;
4
- Drawer: import("@alifd/next/types/config-provider/types").ConfiguredComponentClass<import("./types").FloatButtonDrawerProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, undefined, {}>;
5
- InnerDrawer: import("@alifd/next/types/config-provider/types").ConfiguredComponentClass<import("./types").FloatButtonInnerDrawerProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, undefined, {}>;
2
+ declare const FloatButtonWithSub: {
3
+ new (props: import("./types").FloatButtonProps & import("react").RefAttributes<import("./types").FloatButtonRef> & import("@alifd/next/types/config-provider/types").ComponentCommonProps, context?: unknown): import("@alifd/next/types/config-provider/types").ConfiguredComponent<import("./types").FloatButtonProps & import("react").RefAttributes<import("./types").FloatButtonRef> & import("@alifd/next/types/config-provider/types").ComponentCommonProps, import("./types").FloatButtonRef>;
4
+ contextType?: import("react").Context<any> | undefined;
5
+ } & {
6
+ displayName: string | undefined;
7
+ defaultProps: Partial<import("./types").FloatButtonProps & import("react").RefAttributes<import("./types").FloatButtonRef>> | undefined;
8
+ propTypes: import("react").WeakValidationMap<import("./types").FloatButtonProps & import("react").RefAttributes<import("./types").FloatButtonRef>> | undefined;
9
+ $$typeof: symbol;
10
+ } & {
11
+ Backtop: {
12
+ new (props: import("./types").BacktopProps & import("react").RefAttributes<import("./types").BacktopRef> & import("@alifd/next/types/config-provider/types").ComponentCommonProps, context?: unknown): import("@alifd/next/types/config-provider/types").ConfiguredComponent<import("./types").BacktopProps & import("react").RefAttributes<import("./types").BacktopRef> & import("@alifd/next/types/config-provider/types").ComponentCommonProps, import("./types").BacktopRef>;
13
+ contextType?: import("react").Context<any> | undefined;
14
+ } & {
15
+ displayName: string | undefined;
16
+ defaultProps: Partial<import("./types").BacktopProps & import("react").RefAttributes<import("./types").BacktopRef>> | undefined;
17
+ propTypes: import("react").WeakValidationMap<import("./types").BacktopProps & import("react").RefAttributes<import("./types").BacktopRef>> | undefined;
18
+ $$typeof: symbol;
19
+ };
20
+ Drawer: {
21
+ new (props: import("./types").FloatButtonDrawerProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, context?: unknown): import("@alifd/next/types/config-provider/types").ConfiguredComponent<import("./types").FloatButtonDrawerProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, unknown>;
22
+ contextType?: import("react").Context<any> | undefined;
23
+ } & {};
24
+ InnerDrawer: {
25
+ new (props: import("./types").FloatButtonInnerDrawerProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, context?: unknown): import("@alifd/next/types/config-provider/types").ConfiguredComponent<import("./types").FloatButtonInnerDrawerProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, unknown>;
26
+ contextType?: import("react").Context<any> | undefined;
27
+ } & {};
6
28
  };
7
29
  export type { BacktopRef, BacktopProps, FloatButtonRef, FloatButtonProps, FloatButtonDrawerProps, FloatButtonInnerDrawerProps, Edge, Margin, Position, RequiredParts, ScreenRatioPosition, Size, TriggerType, } from './types';
8
30
  export default FloatButtonWithSub;
@@ -1,4 +1,12 @@
1
1
  import React from 'react';
2
2
  import type { BacktopProps, BacktopRef } from '../types';
3
- declare const _default: import("@alifd/next/types/config-provider/types").ConfiguredComponentClass<Pick<BacktopProps & React.RefAttributes<BacktopRef>, "key" | keyof BacktopProps> & import("@alifd/next/types/config-provider/types").ComponentCommonProps, BacktopRef, {}>;
3
+ declare const _default: {
4
+ new (props: BacktopProps & React.RefAttributes<BacktopRef> & import("@alifd/next/types/config-provider/types").ComponentCommonProps, context?: unknown): import("@alifd/next/types/config-provider/types").ConfiguredComponent<BacktopProps & React.RefAttributes<BacktopRef> & import("@alifd/next/types/config-provider/types").ComponentCommonProps, BacktopRef>;
5
+ contextType?: React.Context<any> | undefined;
6
+ } & {
7
+ displayName: string | undefined;
8
+ defaultProps: Partial<BacktopProps & React.RefAttributes<BacktopRef>> | undefined;
9
+ propTypes: React.WeakValidationMap<BacktopProps & React.RefAttributes<BacktopRef>> | undefined;
10
+ $$typeof: symbol;
11
+ };
4
12
  export default _default;
@@ -6,5 +6,8 @@ export interface DrawerProps extends Omit<NextDrawerProps, 'triggerType' | 'cont
6
6
  triggerType?: TriggerType | TriggerType[];
7
7
  }
8
8
  export declare function Drawer({ prefix, children, trigger, triggerType, visible, onVisibleChange, ...rests }: DrawerProps): React.JSX.Element;
9
- declare const _default: import("@alifd/next/types/config-provider/types").ConfiguredComponentClass<FloatButtonDrawerProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, undefined, {}>;
9
+ declare const _default: {
10
+ new (props: FloatButtonDrawerProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, context?: unknown): import("@alifd/next/types/config-provider/types").ConfiguredComponent<FloatButtonDrawerProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, unknown>;
11
+ contextType?: React.Context<any> | undefined;
12
+ } & {};
10
13
  export default _default;
@@ -1,4 +1,12 @@
1
1
  import React from 'react';
2
2
  import type { FloatButtonProps, FloatButtonRef } from '../types';
3
- declare const _default: import("@alifd/next/types/config-provider/types").ConfiguredComponentClass<Pick<FloatButtonProps & React.RefAttributes<FloatButtonRef>, "key" | keyof FloatButtonProps> & import("@alifd/next/types/config-provider/types").ComponentCommonProps, FloatButtonRef, {}>;
3
+ declare const _default: {
4
+ new (props: FloatButtonProps & React.RefAttributes<FloatButtonRef> & import("@alifd/next/types/config-provider/types").ComponentCommonProps, context?: unknown): import("@alifd/next/types/config-provider/types").ConfiguredComponent<FloatButtonProps & React.RefAttributes<FloatButtonRef> & import("@alifd/next/types/config-provider/types").ComponentCommonProps, FloatButtonRef>;
5
+ contextType?: React.Context<any> | undefined;
6
+ } & {
7
+ displayName: string | undefined;
8
+ defaultProps: Partial<FloatButtonProps & React.RefAttributes<FloatButtonRef>> | undefined;
9
+ propTypes: React.WeakValidationMap<FloatButtonProps & React.RefAttributes<FloatButtonRef>> | undefined;
10
+ $$typeof: symbol;
11
+ };
4
12
  export default _default;
@@ -19,5 +19,8 @@ export interface InnerDrawerProps {
19
19
  afterClose?: () => void;
20
20
  }
21
21
  export declare function InnerDrawer({ className, prefix, target, children, trigger, triggerType, visible, onVisibleChange, closable, title, cache, width, beforeOpen, beforeClose, afterOpen, afterClose, }: InnerDrawerProps): React.JSX.Element;
22
- declare const _default: import("@alifd/next/types/config-provider/types").ConfiguredComponentClass<FloatButtonInnerDrawerProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, undefined, {}>;
22
+ declare const _default: {
23
+ new (props: FloatButtonInnerDrawerProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, context?: unknown): import("@alifd/next/types/config-provider/types").ConfiguredComponent<FloatButtonInnerDrawerProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, unknown>;
24
+ contextType?: React.Context<any> | undefined;
25
+ } & {};
23
26
  export default _default;
@@ -104,34 +104,23 @@ function InnerDrawer({ className, prefix, target, children, trigger, triggerType
104
104
  const handlers = (0, useTriggerType_1.useTriggerType)({ visible, onVisibleChange: handleVisibleChange, triggerType });
105
105
  const domRef = (0, react_1.useRef)(null);
106
106
  const triggerRef = (0, react_1.useRef)(null);
107
- (0, react_1.useEffect)(() => {
108
- if (!mountTarget) {
109
- return;
110
- }
111
- if (visible) {
112
- beforeOpen === null || beforeOpen === void 0 ? void 0 : beforeOpen();
113
- const id = requestAnimationFrame(() => {
114
- mountTarget.style.width = `${typeof width === 'number' ? `${width}px` : width}`;
115
- mountTarget.style.opacity = '1';
116
- });
117
- return () => {
118
- cancelAnimationFrame(id);
119
- };
120
- }
121
- else {
122
- beforeClose === null || beforeClose === void 0 ? void 0 : beforeClose();
123
- mountTarget.style.width = `0px`;
124
- mountTarget.style.opacity = '0';
107
+ const timeoutRef = (0, react_1.useRef)(null);
108
+ const hasCallbackFired = (0, react_1.useRef)(false);
109
+ function handleAnimationEnd() {
110
+ if (!hasCallbackFired.current) {
111
+ const { visible, afterClose, afterOpen } = propsRef.current;
112
+ visible ? afterOpen === null || afterOpen === void 0 ? void 0 : afterOpen() : afterClose === null || afterClose === void 0 ? void 0 : afterClose();
113
+ hasCallbackFired.current = true;
125
114
  }
126
- }, [visible, mountTarget]);
115
+ }
127
116
  (0, react_1.useEffect)(() => {
128
117
  if (!mountTarget) {
129
118
  return;
130
119
  }
131
120
  const onEnd = (e) => {
132
121
  if (e.target === mountTarget && e.propertyName === 'width') {
133
- const { visible, afterClose, afterOpen } = propsRef.current;
134
- visible ? afterOpen === null || afterOpen === void 0 ? void 0 : afterOpen() : afterClose === null || afterClose === void 0 ? void 0 : afterClose();
122
+ clearTimeout(timeoutRef.current);
123
+ handleAnimationEnd();
135
124
  }
136
125
  };
137
126
  mountTarget.addEventListener('transitionend', onEnd);
@@ -139,6 +128,39 @@ function InnerDrawer({ className, prefix, target, children, trigger, triggerType
139
128
  mountTarget.removeEventListener('transitionend', onEnd);
140
129
  };
141
130
  }, [mountTarget]);
131
+ (0, react_1.useEffect)(() => {
132
+ if (!mountTarget) {
133
+ return;
134
+ }
135
+ hasCallbackFired.current = false;
136
+ function applyAnimationStyles(target, width, opacity) {
137
+ target.style.transition = 'width 0.3s, opacity 0.3s';
138
+ target.style.width = `${typeof width === 'number' ? `${width}px` : width}`;
139
+ target.style.opacity = opacity;
140
+ }
141
+ const animationFrameId = requestAnimationFrame(() => {
142
+ if (visible) {
143
+ beforeOpen === null || beforeOpen === void 0 ? void 0 : beforeOpen();
144
+ clearTimeout(timeoutRef.current);
145
+ timeoutRef.current = setTimeout(() => {
146
+ handleAnimationEnd();
147
+ }, 300);
148
+ applyAnimationStyles(mountTarget, width, '1');
149
+ }
150
+ else {
151
+ beforeClose === null || beforeClose === void 0 ? void 0 : beforeClose();
152
+ clearTimeout(timeoutRef.current);
153
+ timeoutRef.current = setTimeout(() => {
154
+ handleAnimationEnd();
155
+ }, 300);
156
+ applyAnimationStyles(mountTarget, 0, '0');
157
+ }
158
+ });
159
+ return () => {
160
+ cancelAnimationFrame(animationFrameId);
161
+ clearTimeout(timeoutRef.current);
162
+ };
163
+ }, [visible, mountTarget]);
142
164
  (0, react_1.useEffect)(() => {
143
165
  if (!mountTarget || !className) {
144
166
  return;
package/lib/index.js CHANGED
@@ -18,4 +18,4 @@ var tag_1 = require("./tag");
18
18
  Object.defineProperty(exports, "Tag", { enumerable: true, get: function () { return __importDefault(tag_1).default; } });
19
19
  var tab_1 = require("./tab");
20
20
  Object.defineProperty(exports, "Tab", { enumerable: true, get: function () { return __importDefault(tab_1).default; } });
21
- exports.version = '0.1.8';
21
+ exports.version = '0.1.9';
@@ -2,7 +2,14 @@ import React from 'react';
2
2
  import { Tab as NextTab } from '@alifd/next';
3
3
  import type { TabProps } from '@alifd/next/types/tab';
4
4
  export type { TabProps, ItemProps } from '@alifd/next/types/tab';
5
- declare const _default: import("@alifd/next/types/config-provider/types").ConfiguredComponentClass<Pick<TabProps & React.RefAttributes<NextTab>, "key" | keyof TabProps> & import("@alifd/next/types/config-provider/types").ComponentCommonProps, NextTab, {}> & {
5
+ declare const _default: {
6
+ new (props: TabProps & React.RefAttributes<NextTab> & import("@alifd/next/types/config-provider/types").ComponentCommonProps, context?: unknown): import("@alifd/next/types/config-provider/types").ConfiguredComponent<TabProps & React.RefAttributes<NextTab> & import("@alifd/next/types/config-provider/types").ComponentCommonProps, NextTab>;
7
+ contextType?: React.Context<any> | undefined;
8
+ } & {
9
+ displayName: string;
10
+ defaultProps: Partial<TabProps & React.RefAttributes<NextTab>> | undefined;
11
+ propTypes: React.WeakValidationMap<TabProps & React.RefAttributes<NextTab>> | undefined;
12
+ $$typeof: symbol;
6
13
  Item: typeof import("@alifd/next/types/tab").Item;
7
14
  };
8
15
  export default _default;
@@ -9,5 +9,13 @@ import React from 'react';
9
9
  import { Tag as NextTag } from '@alifd/next';
10
10
  import type { TagProps } from '@alifd/next/types/tag';
11
11
  export type { TagProps } from '@alifd/next/types/tag';
12
- declare const _default: import("@alifd/next/types/config-provider/types").ConfiguredComponentClass<Pick<TagProps & React.RefAttributes<NextTag>, "key" | keyof TagProps> & import("@alifd/next/types/config-provider/types").ComponentCommonProps, NextTag, {}>;
12
+ declare const _default: {
13
+ new (props: TagProps & React.RefAttributes<NextTag> & import("@alifd/next/types/config-provider/types").ComponentCommonProps, context?: unknown): import("@alifd/next/types/config-provider/types").ConfiguredComponent<TagProps & React.RefAttributes<NextTag> & import("@alifd/next/types/config-provider/types").ComponentCommonProps, NextTag>;
14
+ contextType?: React.Context<any> | undefined;
15
+ } & {
16
+ displayName: string;
17
+ defaultProps: Partial<TagProps & React.RefAttributes<NextTag>> | undefined;
18
+ propTypes: React.WeakValidationMap<TagProps & React.RefAttributes<NextTag>> | undefined;
19
+ $$typeof: symbol;
20
+ };
13
21
  export default _default;
@@ -1,3 +1,9 @@
1
+ import React from 'react';
1
2
  import type { TextProps } from './types';
2
- declare const _default: import("@alifd/next/types/config-provider/types").ConfiguredComponentClass<TextProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, undefined, {}>;
3
+ declare const _default: {
4
+ new (props: TextProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, context?: unknown): import("@alifd/next/types/config-provider/types").ConfiguredComponent<TextProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, unknown>;
5
+ contextType?: React.Context<any> | undefined;
6
+ } & {
7
+ displayName: string;
8
+ };
3
9
  export default _default;
@@ -23,10 +23,10 @@ function useControlable(props, { valueName = 'value', defaultValueName = getDefa
23
23
  }
24
24
  };
25
25
  (0, react_1.useEffect)(() => {
26
- if (value !== propValue) {
26
+ if (isControl && value !== propValue) {
27
27
  setValue(() => propValue);
28
28
  }
29
- }, [propValue]);
29
+ }, [propValue, isControl]);
30
30
  return [value, handleChange];
31
31
  }
32
32
  exports.useControlable = useControlable;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alifd/chat",
3
- "version": "0.1.8",
3
+ "version": "0.1.10",
4
4
  "description": "A configurable component library for chat built on React.",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",