@alifd/chat 0.0.1 → 0.1.0
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.
- package/es/button/index.d.ts +23 -1
- package/es/button/index.js +30 -1
- package/es/button/main.scss +5 -0
- package/es/button/style.d.ts +1 -0
- package/es/button/style.js +1 -0
- package/es/card/index.d.ts +5 -0
- package/es/card/index.js +5 -0
- package/es/card/main.scss +141 -0
- package/es/card/style.d.ts +2 -0
- package/es/card/style.js +2 -0
- package/es/card/types.d.ts +56 -0
- package/es/card/types.js +1 -0
- package/es/card/view/card.d.ts +6 -0
- package/es/card/view/card.js +52 -0
- package/es/card/view/collapsable.d.ts +7 -0
- package/es/card/view/collapsable.js +62 -0
- package/es/core/variables.scss +33 -0
- package/es/feedback/index.d.ts +6 -0
- package/es/feedback/index.js +46 -0
- package/es/feedback/main.scss +42 -0
- package/es/feedback/style.d.ts +1 -0
- package/es/feedback/style.js +1 -0
- package/es/feedback/types.d.ts +54 -0
- package/es/feedback/types.js +1 -0
- package/es/feedback/view/good.d.ts +7 -0
- package/es/feedback/view/good.js +7 -0
- package/es/float-button/hooks/useAutoAlign.d.ts +2 -2
- package/es/float-button/hooks/useAutoAlign.js +2 -2
- package/es/float-button/hooks/useTriggerType.d.ts +3 -0
- package/es/float-button/hooks/useTriggerType.js +31 -0
- package/es/float-button/main.scss +69 -11
- package/es/float-button/style.d.ts +1 -0
- package/es/float-button/style.js +1 -0
- package/es/float-button/types.d.ts +7 -2
- package/es/float-button/view/backtop.js +3 -3
- package/es/float-button/view/drawer.d.ts +7 -1
- package/es/float-button/view/drawer.js +11 -2
- package/es/float-button/view/float-button.js +43 -7
- package/es/float-button/view/inner-drawer.d.ts +16 -2
- package/es/float-button/view/inner-drawer.js +103 -3
- package/es/index.d.ts +6 -0
- package/es/index.js +7 -1
- package/es/tab/index.d.ts +8 -0
- package/es/tab/index.js +14 -0
- package/es/tab/main.scss +10 -0
- package/es/tab/style.d.ts +2 -0
- package/es/tab/style.js +2 -0
- package/es/tag/index.d.ts +12 -0
- package/es/tag/index.js +18 -0
- package/es/tag/main.scss +9 -0
- package/es/tag/style.d.ts +2 -0
- package/es/tag/style.js +2 -0
- package/es/tag/types.d.ts +0 -0
- package/es/tag/types.js +1 -0
- package/es/text/index.d.ts +3 -0
- package/es/text/index.js +301 -0
- package/es/text/main.scss +19 -0
- package/es/text/style.d.ts +1 -0
- package/es/text/style.js +1 -0
- package/es/text/types.d.ts +16 -0
- package/es/text/types.js +1 -0
- package/es/utils/consts.d.ts +1 -0
- package/es/utils/consts.js +1 -0
- package/es/utils/hooks/useControlable.d.ts +1 -1
- package/es/utils/hooks/useControlable.js +4 -3
- package/es/utils/index.d.ts +1 -0
- package/es/utils/index.js +1 -0
- package/lib/button/index.d.ts +23 -1
- package/lib/button/index.js +30 -6
- package/lib/button/main.scss +5 -0
- package/lib/button/style.d.ts +1 -0
- package/lib/button/style.js +1 -0
- package/lib/card/index.d.ts +5 -0
- package/lib/card/index.js +8 -0
- package/lib/card/main.scss +141 -0
- package/lib/card/style.d.ts +2 -0
- package/lib/card/style.js +4 -0
- package/lib/card/types.d.ts +56 -0
- package/lib/card/types.js +2 -0
- package/lib/card/view/card.d.ts +6 -0
- package/lib/card/view/card.js +57 -0
- package/lib/card/view/collapsable.d.ts +7 -0
- package/lib/card/view/collapsable.js +64 -0
- package/lib/core/variables.scss +33 -0
- package/lib/feedback/index.d.ts +6 -0
- package/lib/feedback/index.js +48 -0
- package/lib/feedback/main.scss +42 -0
- package/lib/feedback/style.d.ts +1 -0
- package/lib/feedback/style.js +3 -0
- package/lib/feedback/types.d.ts +54 -0
- package/lib/feedback/types.js +2 -0
- package/lib/feedback/view/good.d.ts +7 -0
- package/lib/feedback/view/good.js +10 -0
- package/lib/float-button/hooks/useAutoAlign.d.ts +2 -2
- package/lib/float-button/hooks/useAutoAlign.js +2 -2
- package/lib/float-button/hooks/useTriggerType.d.ts +3 -0
- package/lib/float-button/hooks/useTriggerType.js +35 -0
- package/lib/float-button/main.scss +69 -11
- package/lib/float-button/style.d.ts +1 -0
- package/lib/float-button/style.js +1 -0
- package/lib/float-button/types.d.ts +7 -2
- package/lib/float-button/view/backtop.js +2 -2
- package/lib/float-button/view/drawer.d.ts +7 -1
- package/lib/float-button/view/drawer.js +10 -2
- package/lib/float-button/view/float-button.js +41 -5
- package/lib/float-button/view/inner-drawer.d.ts +16 -2
- package/lib/float-button/view/inner-drawer.js +103 -3
- package/lib/index.d.ts +6 -0
- package/lib/index.js +14 -2
- package/lib/tab/index.d.ts +8 -0
- package/lib/tab/index.js +16 -0
- package/lib/tab/main.scss +10 -0
- package/lib/tab/style.d.ts +2 -0
- package/lib/tab/style.js +4 -0
- package/lib/tag/index.d.ts +12 -0
- package/lib/tag/index.js +20 -0
- package/lib/tag/main.scss +9 -0
- package/lib/tag/style.d.ts +2 -0
- package/lib/tag/style.js +4 -0
- package/lib/tag/types.d.ts +0 -0
- package/lib/tag/types.js +1 -0
- package/lib/text/index.d.ts +3 -0
- package/lib/text/index.js +304 -0
- package/lib/text/main.scss +19 -0
- package/lib/text/style.d.ts +1 -0
- package/lib/text/style.js +3 -0
- package/lib/text/types.d.ts +16 -0
- package/lib/text/types.js +2 -0
- package/lib/utils/consts.d.ts +1 -0
- package/lib/utils/consts.js +4 -0
- package/lib/utils/hooks/useControlable.d.ts +1 -1
- package/lib/utils/hooks/useControlable.js +4 -3
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.js +1 -0
- package/package.json +81 -1
- package/es/button/view/button.d.ts +0 -23
- package/es/button/view/button.js +0 -26
- package/lib/button/view/button.d.ts +0 -23
- package/lib/button/view/button.js +0 -29
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { HTMLAttributes, JSXElementConstructor, ReactElement, ReactNode } from 'react';
|
|
2
|
+
export type HTMLAttributesWeak = Omit<HTMLAttributes<HTMLDivElement>, 'title'>;
|
|
3
|
+
export interface CardSubCommonProps {
|
|
4
|
+
prefix: string;
|
|
5
|
+
className?: string;
|
|
6
|
+
children?: ReactNode;
|
|
7
|
+
}
|
|
8
|
+
export type Align = 'start' | 'center' | 'end';
|
|
9
|
+
export interface CardHeaderProps extends CardSubCommonProps {
|
|
10
|
+
extras?: ReactNode;
|
|
11
|
+
align?: Align;
|
|
12
|
+
}
|
|
13
|
+
export interface CardContentProps extends CardSubCommonProps {
|
|
14
|
+
}
|
|
15
|
+
export interface CardFooterProps extends CardSubCommonProps {
|
|
16
|
+
align?: Align;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* @api
|
|
20
|
+
*/
|
|
21
|
+
export interface CardProps extends HTMLAttributesWeak {
|
|
22
|
+
innerClassName?: string;
|
|
23
|
+
/**
|
|
24
|
+
* 尺寸
|
|
25
|
+
* @defaultValue 'medium'
|
|
26
|
+
*/
|
|
27
|
+
size?: 'small' | 'medium' | 'large';
|
|
28
|
+
title?: ReactNode;
|
|
29
|
+
titleAlign?: Align;
|
|
30
|
+
titleLine?: boolean;
|
|
31
|
+
footer?: ReactNode;
|
|
32
|
+
/**
|
|
33
|
+
* @defaultValue 'end'
|
|
34
|
+
*/
|
|
35
|
+
footerAlign?: Align;
|
|
36
|
+
footerLine?: boolean;
|
|
37
|
+
noPadding?: boolean;
|
|
38
|
+
components?: {
|
|
39
|
+
Header?: JSXElementConstructor<CardHeaderProps>;
|
|
40
|
+
Content?: JSXElementConstructor<CardContentProps>;
|
|
41
|
+
Footer?: JSXElementConstructor<CardFooterProps>;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
export interface CollapsableCardProps extends CardProps {
|
|
45
|
+
visible?: boolean;
|
|
46
|
+
defaultVisible?: boolean;
|
|
47
|
+
triggerType?: 'hover' | 'click';
|
|
48
|
+
onVisibleChange?: (visible: boolean) => void;
|
|
49
|
+
mode?: 'inner' | 'popup';
|
|
50
|
+
leaveToUnVisibleOnCard?: boolean;
|
|
51
|
+
renderContent: (info: {
|
|
52
|
+
visible: boolean;
|
|
53
|
+
onVisibleChange: (visible: boolean) => void;
|
|
54
|
+
children?: ReactNode;
|
|
55
|
+
}) => ReactElement<CardContentProps>;
|
|
56
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { CardProps } from '../types';
|
|
3
|
+
export declare function useCardInner({ prefix, innerClassName, title, titleAlign, titleLine, footer, footerAlign, footerLine, components, children, }: CardProps): React.JSX.Element;
|
|
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, {}>;
|
|
6
|
+
export default _default;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useCardOuter = exports.useCardInner = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const next_1 = require("@alifd/next");
|
|
6
|
+
const react_1 = tslib_1.__importDefault(require("react"));
|
|
7
|
+
const classnames_1 = tslib_1.__importDefault(require("classnames"));
|
|
8
|
+
const utils_1 = require("../../utils");
|
|
9
|
+
function DefaultHeader({ prefix, className, align, extras, children }) {
|
|
10
|
+
return (react_1.default.createElement("div", { className: (0, classnames_1.default)(className) },
|
|
11
|
+
react_1.default.createElement("div", { className: `${prefix}-title`, style: { textAlign: align } }, children),
|
|
12
|
+
!!extras && react_1.default.createElement("div", { className: `${prefix}-extras` }, extras)));
|
|
13
|
+
}
|
|
14
|
+
function DefaultContent({ className, children }) {
|
|
15
|
+
return react_1.default.createElement("div", { className: (0, classnames_1.default)(className) }, children);
|
|
16
|
+
}
|
|
17
|
+
function DefaultFooter({ className, align, children }) {
|
|
18
|
+
return (react_1.default.createElement("div", { className: (0, classnames_1.default)(className), style: { textAlign: align } }, children));
|
|
19
|
+
}
|
|
20
|
+
function useCardInner({ prefix, innerClassName, title, titleAlign, titleLine, footer, footerAlign = 'end', footerLine, components, children, }) {
|
|
21
|
+
const cls = prefix;
|
|
22
|
+
const { Header = DefaultHeader, Content = DefaultContent, Footer = DefaultFooter, } = components || {};
|
|
23
|
+
return (react_1.default.createElement("div", { className: (0, classnames_1.default)(`${cls}-inner`, innerClassName) },
|
|
24
|
+
!!title && (react_1.default.createElement(Header, { prefix: `${cls}-header`, className: (0, classnames_1.default)(`${cls}-header`, { [`${cls}-header--line`]: titleLine }), align: titleAlign }, title)),
|
|
25
|
+
react_1.default.createElement(Content, { prefix: `${cls}-content`, className: (0, classnames_1.default)(`${cls}-content`, {
|
|
26
|
+
[`${cls}-content--gap-top`]: !title || titleLine,
|
|
27
|
+
[`${cls}-content--gap-bottom`]: !footer || footerLine,
|
|
28
|
+
}) }, children),
|
|
29
|
+
!!footer && (react_1.default.createElement(Footer, { prefix: `${cls}-footer`, className: (0, classnames_1.default)(`${cls}-footer`, { [`${cls}-footer--line`]: footerLine }), align: footerAlign }, footer))));
|
|
30
|
+
}
|
|
31
|
+
exports.useCardInner = useCardInner;
|
|
32
|
+
function useCardOuter(props) {
|
|
33
|
+
const { prefix, className, title, titleAlign, titleLine, footer, footerAlign, footerLine, size = 'medium', noPadding, components, children, innerClassName } = props, rests = tslib_1.__rest(props, ["prefix", "className", "title", "titleAlign", "titleLine", "footer", "footerAlign", "footerLine", "size", "noPadding", "components", "children", "innerClassName"]);
|
|
34
|
+
const cls = prefix;
|
|
35
|
+
const rootCls = (0, classnames_1.default)(cls, `${cls}--${size}`, { [`${cls}--no-padding`]: noPadding }, className);
|
|
36
|
+
return (react_1.default.createElement("div", Object.assign({ className: rootCls }, rests), children));
|
|
37
|
+
}
|
|
38
|
+
exports.useCardOuter = useCardOuter;
|
|
39
|
+
/**
|
|
40
|
+
* @component 卡片
|
|
41
|
+
* @en Card
|
|
42
|
+
* @type 通用 - General
|
|
43
|
+
* @remarks
|
|
44
|
+
* 一个通用的卡片组件。
|
|
45
|
+
* - A card is a piece of paper with unique related data taht servers as an entry point to more detailed information.
|
|
46
|
+
* @when
|
|
47
|
+
* 当一个模块的同类信息不能自然形成区块感,可借助 Card 组件将信息整合,帮助界面信息模块感更强。
|
|
48
|
+
* -
|
|
49
|
+
* A card could contain a photo, text, and a link about a single subject.
|
|
50
|
+
*/
|
|
51
|
+
function Card(props) {
|
|
52
|
+
const cls = `${utils_1.PREFIX_DEFAULT}card`;
|
|
53
|
+
const inner = useCardInner(Object.assign(Object.assign({}, props), { prefix: cls }));
|
|
54
|
+
const outer = useCardOuter(Object.assign(Object.assign({}, props), { prefix: cls, children: inner }));
|
|
55
|
+
return outer;
|
|
56
|
+
}
|
|
57
|
+
exports.default = next_1.ConfigProvider.config(Card);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { CollapsableCardProps } from '../types';
|
|
3
|
+
declare function CollapsableCard({ components, visible, defaultVisible, onVisibleChange, triggerType, mode, renderContent, ...props }: CollapsableCardProps): React.JSX.Element;
|
|
4
|
+
declare namespace CollapsableCard {
|
|
5
|
+
var displayName: string;
|
|
6
|
+
}
|
|
7
|
+
export default CollapsableCard;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const react_1 = tslib_1.__importStar(require("react"));
|
|
5
|
+
const classnames_1 = tslib_1.__importDefault(require("classnames"));
|
|
6
|
+
const card_1 = require("./card");
|
|
7
|
+
const utils_1 = require("../../utils");
|
|
8
|
+
function useContent(props) {
|
|
9
|
+
const propsRef = (0, react_1.useRef)(props);
|
|
10
|
+
propsRef.current = props;
|
|
11
|
+
return (0, react_1.useMemo)(() => {
|
|
12
|
+
return function Content({ className, children }) {
|
|
13
|
+
const { visible, onVisibleChange, renderContent } = propsRef.current;
|
|
14
|
+
return (react_1.default.createElement("div", { className: (0, classnames_1.default)(className) }, renderContent({ visible, onVisibleChange, children })));
|
|
15
|
+
};
|
|
16
|
+
}, []);
|
|
17
|
+
}
|
|
18
|
+
function CollapsableCard(_a) {
|
|
19
|
+
var { components, visible: _v, defaultVisible: _dv, onVisibleChange: _onVC, triggerType = 'hover', mode, renderContent } = _a, props = tslib_1.__rest(_a, ["components", "visible", "defaultVisible", "onVisibleChange", "triggerType", "mode", "renderContent"]);
|
|
20
|
+
const cls = `${utils_1.PREFIX_DEFAULT}card`;
|
|
21
|
+
const [value, setValue] = (0, utils_1.useControlable)(props, {
|
|
22
|
+
valueName: 'visible',
|
|
23
|
+
changeName: 'onVisibleChange',
|
|
24
|
+
});
|
|
25
|
+
const hoverToTrigger = triggerType === 'hover';
|
|
26
|
+
const setValueForContent = (visible) => {
|
|
27
|
+
if (hoverToTrigger) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
setValue(visible);
|
|
31
|
+
};
|
|
32
|
+
const { Header, Footer } = components || {};
|
|
33
|
+
const Content = useContent({
|
|
34
|
+
visible: false,
|
|
35
|
+
onVisibleChange: setValueForContent,
|
|
36
|
+
renderContent,
|
|
37
|
+
});
|
|
38
|
+
const PopupContent = useContent({
|
|
39
|
+
visible: true,
|
|
40
|
+
onVisibleChange: setValueForContent,
|
|
41
|
+
renderContent,
|
|
42
|
+
});
|
|
43
|
+
const newProps = Object.assign(Object.assign({}, props), { innerClassName: (0, classnames_1.default)(props.innerClassName, `${cls}-collapsable-inner`), prefix: cls, components: { Header, Footer, Content } });
|
|
44
|
+
const inner = (0, card_1.useCardInner)(newProps);
|
|
45
|
+
const popupInnerProps = Object.assign(Object.assign({}, newProps), { innerClassName: (0, classnames_1.default)(props.innerClassName, `${cls}-collapsable-inner`, `${cls}-collapsable-inner--popup`), components: { Header, Footer, Content: PopupContent } });
|
|
46
|
+
const popupInner = (0, card_1.useCardInner)(popupInnerProps);
|
|
47
|
+
const classNames = (0, classnames_1.default)(`${cls}-collapsable`, { [`${cls}-collapsable--visible`]: value }, newProps.className);
|
|
48
|
+
const debounceSetValue = (0, utils_1.useDebounce)(setValue, 150);
|
|
49
|
+
const outer = (0, card_1.useCardOuter)(Object.assign(Object.assign(Object.assign({}, newProps), (hoverToTrigger
|
|
50
|
+
? {
|
|
51
|
+
onMouseEnter: () => {
|
|
52
|
+
debounceSetValue(true);
|
|
53
|
+
},
|
|
54
|
+
onMouseLeave: () => {
|
|
55
|
+
debounceSetValue(false);
|
|
56
|
+
},
|
|
57
|
+
}
|
|
58
|
+
: {})), { className: classNames, children: (react_1.default.createElement(react_1.default.Fragment, null,
|
|
59
|
+
inner,
|
|
60
|
+
value ? popupInner : null)) }));
|
|
61
|
+
return outer;
|
|
62
|
+
}
|
|
63
|
+
CollapsableCard.displayName = 'CollapsableCard';
|
|
64
|
+
exports.default = CollapsableCard;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
$prefix: 'ct-' !default;
|
|
2
|
+
|
|
3
|
+
$color-brand1-6: var(--color-brand1-6, #5584ff) !default;
|
|
4
|
+
$size-base: 4px !default;
|
|
5
|
+
$shadow-1: 1px 1px 4px 0px rgba(0, 0, 0, 0.16) !default;
|
|
6
|
+
$shadow-2: 2px 4px 16px 0px rgba(0, 0, 0, 0.12) !default;
|
|
7
|
+
|
|
8
|
+
$font-size-headline: var(--font-size-headline, 24px) !default;
|
|
9
|
+
$font-size-title: var(--font-size-title, 20px) !default;
|
|
10
|
+
$font-size-subhead: var(--font-size-subhead, 16px) !default;
|
|
11
|
+
$font-size-body-2: var(--font-size-body-2, 14px) !default;
|
|
12
|
+
$font-size-body-1: var(--font-size-body-1, 14px) !default;
|
|
13
|
+
$font-size-caption: var(--font-size-caption, 12px) !default;
|
|
14
|
+
|
|
15
|
+
/// 禁用
|
|
16
|
+
$color-text1-1: var(--color-text1-1, #cccccc) !default;
|
|
17
|
+
/// 水印/提示
|
|
18
|
+
$color-text1-2: var(--color-text1-2, #999999) !default;
|
|
19
|
+
/// 正文/标题
|
|
20
|
+
$color-text1-3: var(--color-text1-3, #666666) !default;
|
|
21
|
+
/// 正文/标题
|
|
22
|
+
$color-text1-4: var(--color-text1-4, #333333) !default;
|
|
23
|
+
|
|
24
|
+
/// 很浅
|
|
25
|
+
$color-line1-0: var(--color-line1-0, #f1f3f6) !default;
|
|
26
|
+
/// 浅
|
|
27
|
+
$color-line1-1: var(--color-line1-1, #e6e7eb) !default;
|
|
28
|
+
/// 常规
|
|
29
|
+
$color-line1-2: var(--color-line1-2, #dcdee3) !default;
|
|
30
|
+
/// 深
|
|
31
|
+
$color-line1-3: var(--color-line1-3, #c4c6cf) !default;
|
|
32
|
+
/// 重
|
|
33
|
+
$color-line1-4: var(--color-line1-4, #a0a2ad) !default;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { FeedbackProps } from './types';
|
|
2
|
+
import Good from './view/good';
|
|
3
|
+
declare const _default: import("@alifd/next/types/config-provider/types").ConfiguredComponentClass<FeedbackProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, undefined, {}> & {
|
|
4
|
+
Good: typeof Good;
|
|
5
|
+
};
|
|
6
|
+
export default _default;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const react_1 = tslib_1.__importStar(require("react"));
|
|
5
|
+
const next_1 = require("@alifd/next");
|
|
6
|
+
const classnames_1 = tslib_1.__importDefault(require("classnames"));
|
|
7
|
+
const utils_1 = require("../utils");
|
|
8
|
+
const good_1 = tslib_1.__importDefault(require("./view/good"));
|
|
9
|
+
/**
|
|
10
|
+
* @component 反馈
|
|
11
|
+
* @en Feedback
|
|
12
|
+
* @type 通用 - General
|
|
13
|
+
* @remarks 反馈组件给用户提供点赞、踩的交互按钮。
|
|
14
|
+
* @when 需要获取用户针对显示内容的赞同或否定意见时
|
|
15
|
+
*/
|
|
16
|
+
function Feedback(props) {
|
|
17
|
+
const { className, order = ['good', 'bad'], size, direction = 'hoz', defaultValue, value: _value, onChange: _onChange, renderItem } = props, rests = tslib_1.__rest(props, ["className", "order", "size", "direction", "defaultValue", "value", "onChange", "renderItem"]);
|
|
18
|
+
const cls = `${utils_1.PREFIX_DEFAULT}feedback`;
|
|
19
|
+
const [value, onChange] = (0, utils_1.useControlable)(props);
|
|
20
|
+
const defaultRenderItem = (0, react_1.useCallback)((status) => {
|
|
21
|
+
switch (status) {
|
|
22
|
+
case 'good': {
|
|
23
|
+
return (react_1.default.createElement(good_1.default, { className: (0, classnames_1.default)(`${cls}-item-icon`, `${cls}-item-icon--good`), height: "1em" }));
|
|
24
|
+
}
|
|
25
|
+
case 'bad': {
|
|
26
|
+
return (react_1.default.createElement(good_1.default, { className: (0, classnames_1.default)(`${cls}-item-icon`, `${cls}-item-icon--bad`), height: "1em" }));
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}, [cls]);
|
|
30
|
+
const render = renderItem || defaultRenderItem;
|
|
31
|
+
const padding = size && `0px ${Math.round((size * 3) / 10)}px`;
|
|
32
|
+
const fontSize = size;
|
|
33
|
+
return (react_1.default.createElement("div", Object.assign({ className: (0, classnames_1.default)(cls, className) }, rests),
|
|
34
|
+
react_1.default.createElement("div", { className: `${cls}-inner`, style: {
|
|
35
|
+
flexDirection: direction === 'hoz' ? 'row' : 'column',
|
|
36
|
+
padding,
|
|
37
|
+
fontSize,
|
|
38
|
+
} }, order.map(status => {
|
|
39
|
+
return (react_1.default.createElement("button", { className: (0, classnames_1.default)(`${cls}-item`, {
|
|
40
|
+
[`${cls}-item--active`]: status === value,
|
|
41
|
+
}), style: { padding }, key: status, onClick: () => {
|
|
42
|
+
onChange(value === status ? 'stale' : status);
|
|
43
|
+
} }, render(status)));
|
|
44
|
+
}))));
|
|
45
|
+
}
|
|
46
|
+
Feedback.displayName = 'Feedback';
|
|
47
|
+
const FeedbackWithSub = (0, utils_1.assignSubComponent)(Feedback, { Good: good_1.default });
|
|
48
|
+
exports.default = next_1.ConfigProvider.config(FeedbackWithSub);
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
@import '../core/variables.scss';
|
|
2
|
+
|
|
3
|
+
.#{$prefix}feedback {
|
|
4
|
+
display: inline-block;
|
|
5
|
+
|
|
6
|
+
&-inner {
|
|
7
|
+
padding: 0 4px;
|
|
8
|
+
display: flex;
|
|
9
|
+
flex-direction: row;
|
|
10
|
+
}
|
|
11
|
+
&-item {
|
|
12
|
+
background-color: transparent;
|
|
13
|
+
outline: 0;
|
|
14
|
+
border: 0;
|
|
15
|
+
display: inline-flex;
|
|
16
|
+
justify-content: center;
|
|
17
|
+
align-items: center;
|
|
18
|
+
padding: 0 4px;
|
|
19
|
+
cursor: pointer;
|
|
20
|
+
color: inherit;
|
|
21
|
+
font-size: inherit;
|
|
22
|
+
transition:
|
|
23
|
+
color 0.15s,
|
|
24
|
+
opacity 0.15s;
|
|
25
|
+
|
|
26
|
+
&--active {
|
|
27
|
+
color: $color-brand1-6;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
&:hover {
|
|
31
|
+
opacity: 0.8;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
&-icon {
|
|
35
|
+
line-height: 1;
|
|
36
|
+
|
|
37
|
+
&--bad {
|
|
38
|
+
transform: rotate(180deg);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './main.scss';
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { HTMLAttributes, ReactNode, SVGProps } from 'react';
|
|
2
|
+
export type HTMLAttributesWeek = Omit<HTMLAttributes<HTMLDivElement>, 'onChange' | 'direction'>;
|
|
3
|
+
/**
|
|
4
|
+
* @api
|
|
5
|
+
*/
|
|
6
|
+
export type FeedbackStatus = 'good' | 'stale' | 'bad';
|
|
7
|
+
/**
|
|
8
|
+
* @api
|
|
9
|
+
*/
|
|
10
|
+
export type FeedbackActiveStatus = 'good' | 'bad';
|
|
11
|
+
/**
|
|
12
|
+
* @api Feedback
|
|
13
|
+
*/
|
|
14
|
+
export interface FeedbackProps extends HTMLAttributesWeek {
|
|
15
|
+
/**
|
|
16
|
+
* 当前状态(受控)
|
|
17
|
+
* @defaultValue 'stale'
|
|
18
|
+
*/
|
|
19
|
+
value?: FeedbackStatus;
|
|
20
|
+
/**
|
|
21
|
+
* 默认状态(非受控)
|
|
22
|
+
* @defaultValue 'stale'
|
|
23
|
+
*/
|
|
24
|
+
defaultValue?: FeedbackStatus;
|
|
25
|
+
/**
|
|
26
|
+
* 顺序
|
|
27
|
+
* @defaultValue ['good', 'bad']
|
|
28
|
+
*/
|
|
29
|
+
order?: ['good', 'bad'] | ['bad', 'good'];
|
|
30
|
+
/**
|
|
31
|
+
* 当用户点击状态发生变化时
|
|
32
|
+
* @param status - 用户点击的状态
|
|
33
|
+
*/
|
|
34
|
+
onChange?: (status: FeedbackStatus) => void;
|
|
35
|
+
/**
|
|
36
|
+
* 自定义节点渲染
|
|
37
|
+
* @param status - 节点状态
|
|
38
|
+
* @returns 节点内容
|
|
39
|
+
*/
|
|
40
|
+
renderItem?: (status: 'good' | 'bad') => ReactNode;
|
|
41
|
+
/**
|
|
42
|
+
* 指定尺寸
|
|
43
|
+
*/
|
|
44
|
+
size?: number;
|
|
45
|
+
/**
|
|
46
|
+
* 方向
|
|
47
|
+
* @defaultValue 'hoz'
|
|
48
|
+
*/
|
|
49
|
+
direction?: 'ver' | 'hoz';
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* @api Feedback.Good
|
|
53
|
+
*/
|
|
54
|
+
export type FeedbackGoodProps = SVGProps<SVGSVGElement>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const react_1 = tslib_1.__importDefault(require("react"));
|
|
5
|
+
function Good(props) {
|
|
6
|
+
return (react_1.default.createElement("svg", Object.assign({ xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 1024 1024" }, props),
|
|
7
|
+
react_1.default.createElement("path", { fill: "currentColor", d: "M832 364.8H684.8s19.2-64 32-179.2C723.2 128 678.4 70.4 614.4 64h-12.8c-51.2 0-83.2 32-102.4 76.8l-38.4 96c-32 64-57.6 102.4-76.8 115.2-25.6 12.8-121.6 12.8-128 12.8H128c-38.4 0-64 25.6-64 57.6v480c0 32 25.6 57.6 64 57.6h646.4c96 0 121.6-64 134.4-153.6L960 499.2c6.4-70.4-6.4-134.4-128-134.4zM256 902.4H128v-480h128v480zm640-409.6L844.8 800C832 857.6 832 902.4 768 902.4H320v-480c44.8 0 70.4-6.4 89.6-19.2 32-12.8 64-64 108.8-147.2 25.6-64 38.4-96 44.8-102.4 6.4-19.2 19.2-32 44.8-32h6.4c32 0 44.8 32 44.8 51.2-12.8 102.4-32 166.4-32 166.4l-25.6 83.2h243.2c19.2 0 32 0 44.8 12.8 12.8 12.8 6.4 38.4 6.4 57.6z" })));
|
|
8
|
+
}
|
|
9
|
+
Good.displayName = 'FeedbackGood';
|
|
10
|
+
exports.default = Good;
|
|
@@ -2,10 +2,10 @@ import type { BalloonProps } from '../types';
|
|
|
2
2
|
/**
|
|
3
3
|
* 自动调整弹层 align 位置逻辑
|
|
4
4
|
*/
|
|
5
|
-
export declare function useAutoAlign(
|
|
5
|
+
export declare function useAutoAlign(_dom: HTMLElement | null | undefined, trigger: HTMLElement | null, { enable, defaultAlign, }: {
|
|
6
6
|
enable?: boolean;
|
|
7
7
|
defaultAlign: BalloonProps['align'];
|
|
8
8
|
}): {
|
|
9
9
|
align: "b" | "br" | "rt" | "tr" | "t" | "r" | "l" | "tl" | "bl" | "lt" | "lb" | "rb" | undefined;
|
|
10
|
-
update: () => void;
|
|
10
|
+
update: (dom?: HTMLElement | null | undefined) => void;
|
|
11
11
|
};
|
|
@@ -7,9 +7,9 @@ const utils_1 = require("../../utils");
|
|
|
7
7
|
/**
|
|
8
8
|
* 自动调整弹层 align 位置逻辑
|
|
9
9
|
*/
|
|
10
|
-
function useAutoAlign(
|
|
10
|
+
function useAutoAlign(_dom, trigger, { enable, defaultAlign, }) {
|
|
11
11
|
const [align, setAlign] = (0, react_1.useState)(defaultAlign);
|
|
12
|
-
const update = () => {
|
|
12
|
+
const update = (dom = _dom) => {
|
|
13
13
|
if (!enable || !dom || !trigger) {
|
|
14
14
|
return;
|
|
15
15
|
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { HTMLAttributes } from 'react';
|
|
2
|
+
import type { FloatButtonProps } from '../types';
|
|
3
|
+
export declare function useTriggerType({ triggerType, visible, onVisibleChange, }: Pick<FloatButtonProps, 'triggerType' | 'visible' | 'onVisibleChange'>): Pick<HTMLAttributes<HTMLElement>, "onClick" | "onMouseEnter" | "onMouseLeave">;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useTriggerType = void 0;
|
|
4
|
+
const utils_1 = require("../../utils");
|
|
5
|
+
function normalizeTriggerType(triggerType, defaultTriggerType) {
|
|
6
|
+
if (!triggerType) {
|
|
7
|
+
return defaultTriggerType;
|
|
8
|
+
}
|
|
9
|
+
const arr = Array.isArray(triggerType) ? triggerType : [triggerType];
|
|
10
|
+
return Array.from(new Set(arr));
|
|
11
|
+
}
|
|
12
|
+
function useTriggerType({ triggerType, visible, onVisibleChange, }) {
|
|
13
|
+
const normalTriggerTypes = normalizeTriggerType(triggerType, ['click']);
|
|
14
|
+
const allowClick = normalTriggerTypes.includes('click');
|
|
15
|
+
const allowHover = normalTriggerTypes.includes('hover');
|
|
16
|
+
const triggerHandlerProps = {};
|
|
17
|
+
const debounceOnVisibleChange = (0, utils_1.useDebounce)((v, type) => {
|
|
18
|
+
onVisibleChange === null || onVisibleChange === void 0 ? void 0 : onVisibleChange(v, type);
|
|
19
|
+
}, 150);
|
|
20
|
+
if (allowClick) {
|
|
21
|
+
triggerHandlerProps.onClick = () => {
|
|
22
|
+
onVisibleChange === null || onVisibleChange === void 0 ? void 0 : onVisibleChange(!visible, 'fromeTrigger');
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
if (allowHover) {
|
|
26
|
+
triggerHandlerProps.onMouseEnter = () => {
|
|
27
|
+
debounceOnVisibleChange(true, 'fromTrigger');
|
|
28
|
+
};
|
|
29
|
+
triggerHandlerProps.onMouseLeave = () => {
|
|
30
|
+
debounceOnVisibleChange(false, 'fromTrigger');
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
return triggerHandlerProps;
|
|
34
|
+
}
|
|
35
|
+
exports.useTriggerType = useTriggerType;
|
|
@@ -1,16 +1,74 @@
|
|
|
1
|
-
@import '
|
|
1
|
+
@import '../core/variables.scss';
|
|
2
2
|
|
|
3
|
-
.#{$
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
.#{$prefix}float-button {
|
|
4
|
+
position: fixed;
|
|
5
|
+
z-index: 1001;
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
&-backtop {
|
|
8
|
+
transition:
|
|
9
|
+
opacity 0.2s,
|
|
10
|
+
transform 0.2s;
|
|
11
|
+
cursor: pointer;
|
|
10
12
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
&--hidden {
|
|
14
|
+
opacity: 0;
|
|
15
|
+
transform: scale(0);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
&-inner-drawer {
|
|
20
|
+
flex: 1;
|
|
21
|
+
display: flex;
|
|
22
|
+
padding: $size-base * 2 $size-base * 3;
|
|
23
|
+
overflow: hidden;
|
|
24
|
+
display: flex;
|
|
25
|
+
box-shadow: $shadow-2;
|
|
26
|
+
border-radius: $size-base * 2;
|
|
27
|
+
|
|
28
|
+
&-outer {
|
|
29
|
+
display: flex;
|
|
30
|
+
}
|
|
31
|
+
&-inner-start {
|
|
32
|
+
flex: 1;
|
|
33
|
+
}
|
|
34
|
+
&-inner-end {
|
|
35
|
+
flex: none;
|
|
36
|
+
transition:
|
|
37
|
+
width 0.3s,
|
|
38
|
+
opacity 0.3s;
|
|
39
|
+
display: flex;
|
|
40
|
+
}
|
|
41
|
+
&-inner {
|
|
42
|
+
flex: 1;
|
|
43
|
+
display: flex;
|
|
44
|
+
flex-direction: column;
|
|
45
|
+
}
|
|
46
|
+
&-header {
|
|
47
|
+
flex: none;
|
|
48
|
+
display: flex;
|
|
49
|
+
justify-content: end;
|
|
50
|
+
&-title {
|
|
51
|
+
flex: 1;
|
|
52
|
+
}
|
|
53
|
+
&-close {
|
|
54
|
+
flex: none;
|
|
55
|
+
color: $color-text1-2;
|
|
56
|
+
cursor: pointer;
|
|
57
|
+
transition: color .15s;
|
|
58
|
+
outline: 0;
|
|
59
|
+
border: 0;
|
|
60
|
+
background-color: transparent;
|
|
61
|
+
|
|
62
|
+
&:hover {
|
|
63
|
+
color: $color-brand1-6;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
&-body {
|
|
68
|
+
flex: 1;
|
|
69
|
+
}
|
|
70
|
+
&-footer {
|
|
71
|
+
flex: none;
|
|
72
|
+
}
|
|
14
73
|
}
|
|
15
|
-
}
|
|
16
74
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import React, { type ReactNode } from 'react';
|
|
2
2
|
import { type CommonProps } from '@alifd/next';
|
|
3
3
|
import { type BalloonProps } from '@alifd/next/lib/balloon';
|
|
4
4
|
export type { BalloonProps };
|
|
@@ -100,6 +100,7 @@ export interface FloatButtonRef {
|
|
|
100
100
|
*/
|
|
101
101
|
updateNestleEdge(animation?: boolean): void;
|
|
102
102
|
}
|
|
103
|
+
export type TriggerType = 'hover' | 'click';
|
|
103
104
|
/**
|
|
104
105
|
* @api FloatButton
|
|
105
106
|
* @order 1
|
|
@@ -116,6 +117,10 @@ export interface FloatButtonProps extends CommonProps {
|
|
|
116
117
|
* - `inner-drawer`: 文档内部抽屉
|
|
117
118
|
*/
|
|
118
119
|
type?: 'balloon' | 'drawer' | 'inner-drawer';
|
|
120
|
+
drawerProps?: {
|
|
121
|
+
title?: ReactNode;
|
|
122
|
+
width?: number | string;
|
|
123
|
+
};
|
|
119
124
|
/**
|
|
120
125
|
* 弹层位置,适用 `type`: 'balloon'
|
|
121
126
|
*/
|
|
@@ -196,7 +201,7 @@ export interface FloatButtonProps extends CommonProps {
|
|
|
196
201
|
* 触发方式
|
|
197
202
|
* @defaultValue 'click'
|
|
198
203
|
*/
|
|
199
|
-
triggerType?:
|
|
204
|
+
triggerType?: TriggerType | TriggerType[];
|
|
200
205
|
/**
|
|
201
206
|
* 展示关闭按钮
|
|
202
207
|
* @defaultValue false
|
|
@@ -14,9 +14,9 @@ function getScroller(scroller) {
|
|
|
14
14
|
}
|
|
15
15
|
return scroller;
|
|
16
16
|
}
|
|
17
|
-
const Backtop = (0, react_1.forwardRef)(({
|
|
17
|
+
const Backtop = (0, react_1.forwardRef)(({ autoHide = true, scroller, offset = 10, smooth = true, children }, ref) => {
|
|
18
18
|
const [visible, setVisible] = (0, react_1.useState)(true);
|
|
19
|
-
const cls = `${
|
|
19
|
+
const cls = `${utils_1.PREFIX_DEFAULT}float-button-backtop`;
|
|
20
20
|
const visibleRef = (0, react_1.useRef)(visible);
|
|
21
21
|
visibleRef.current = visible;
|
|
22
22
|
const handleBackToTop = () => {
|
|
@@ -1,2 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
2
|
+
import type { DrawerProps as NextDrawerProps } from '@alifd/next/types/drawer';
|
|
3
|
+
import type { TriggerType } from '../types';
|
|
4
|
+
export interface DrawerProps extends Omit<NextDrawerProps, 'triggerType' | 'container' | 'onVisibleChange'> {
|
|
5
|
+
onVisibleChange?: (visible: boolean, reason: string) => void;
|
|
6
|
+
triggerType?: TriggerType | TriggerType[];
|
|
7
|
+
}
|
|
8
|
+
export declare function Drawer({ prefix, target, children, trigger, triggerType, visible, onVisibleChange, ...rests }: DrawerProps): React.JSX.Element;
|