@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
package/es/button/index.d.ts
CHANGED
|
@@ -1 +1,23 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @component 按钮
|
|
3
|
+
* @en Button
|
|
4
|
+
* @type 通用 - General
|
|
5
|
+
* @remarks 同 Next Button,按钮用于开始一个即时操作。- Same as Next.Button, Button used to trigger an action.
|
|
6
|
+
* @when 标记一个(或封装一组)操作命令,响应用户点击行为,触发相应的业务逻辑。- Buttons are used for emphasizing important functions on your page.
|
|
7
|
+
* @others
|
|
8
|
+
* ## 无障碍键盘操作指南
|
|
9
|
+
* | 按键 | 说明 |
|
|
10
|
+
* | :---- | :---------- |
|
|
11
|
+
* | Enter | 触发 onClick 事件 |
|
|
12
|
+
* | SPACE | 触发 onClick 事件 |
|
|
13
|
+
* @othersEn
|
|
14
|
+
* ## ARIA and KeyBoard
|
|
15
|
+
* | KeyBoard | Description |
|
|
16
|
+
* | :---------- | :------------------------------ |
|
|
17
|
+
* | Enter | Trigger the onClick event |
|
|
18
|
+
* | SPACE | Trigger the onClick event |
|
|
19
|
+
*/
|
|
20
|
+
import React from 'react';
|
|
21
|
+
import type { ButtonProps } from './types';
|
|
22
|
+
declare const Button: React.ForwardRefExoticComponent<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>>>;
|
|
23
|
+
export default Button;
|
package/es/button/index.js
CHANGED
|
@@ -1 +1,30 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @component 按钮
|
|
3
|
+
* @en Button
|
|
4
|
+
* @type 通用 - General
|
|
5
|
+
* @remarks 同 Next Button,按钮用于开始一个即时操作。- Same as Next.Button, Button used to trigger an action.
|
|
6
|
+
* @when 标记一个(或封装一组)操作命令,响应用户点击行为,触发相应的业务逻辑。- Buttons are used for emphasizing important functions on your page.
|
|
7
|
+
* @others
|
|
8
|
+
* ## 无障碍键盘操作指南
|
|
9
|
+
* | 按键 | 说明 |
|
|
10
|
+
* | :---- | :---------- |
|
|
11
|
+
* | Enter | 触发 onClick 事件 |
|
|
12
|
+
* | SPACE | 触发 onClick 事件 |
|
|
13
|
+
* @othersEn
|
|
14
|
+
* ## ARIA and KeyBoard
|
|
15
|
+
* | KeyBoard | Description |
|
|
16
|
+
* | :---------- | :------------------------------ |
|
|
17
|
+
* | Enter | Trigger the onClick event |
|
|
18
|
+
* | SPACE | Trigger the onClick event |
|
|
19
|
+
*/
|
|
20
|
+
import { __rest } from "tslib";
|
|
21
|
+
import React, { forwardRef } from 'react';
|
|
22
|
+
import { Button as NextButton } from '@alifd/next';
|
|
23
|
+
import cs from 'classnames';
|
|
24
|
+
import { PREFIX_DEFAULT } from '../utils';
|
|
25
|
+
const Button = forwardRef((_a, ref) => {
|
|
26
|
+
var { className, size = 'small' } = _a, props = __rest(_a, ["className", "size"]);
|
|
27
|
+
return React.createElement(NextButton, Object.assign({}, props, { className: cs(`${PREFIX_DEFAULT}button`, className), size: size, ref: ref }));
|
|
28
|
+
});
|
|
29
|
+
Button.displayName = 'Button';
|
|
30
|
+
export default Button;
|
package/es/button/main.scss
CHANGED
package/es/button/style.d.ts
CHANGED
package/es/button/style.js
CHANGED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
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
|
+
Collapsable: typeof Collapsable;
|
|
4
|
+
};
|
|
5
|
+
export default CardWithSub;
|
package/es/card/index.js
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
@import '../core/variables.scss';
|
|
2
|
+
|
|
3
|
+
@mixin size($shadow, $corner, $padding, $fontSize, $headFontSize) {
|
|
4
|
+
$verPadding: $padding * 0.5;
|
|
5
|
+
box-shadow: $shadow;
|
|
6
|
+
border-radius: $corner;
|
|
7
|
+
font-size: $fontSize;
|
|
8
|
+
overflow: hidden;
|
|
9
|
+
|
|
10
|
+
.#{$prefix}card {
|
|
11
|
+
&-header {
|
|
12
|
+
font-size: $headFontSize;
|
|
13
|
+
&-title {
|
|
14
|
+
padding: $verPadding $padding;
|
|
15
|
+
}
|
|
16
|
+
&-extras {
|
|
17
|
+
padding: $verPadding $padding $verPadding 0;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
&-content {
|
|
21
|
+
padding: 0 $padding;
|
|
22
|
+
|
|
23
|
+
&--gap-top {
|
|
24
|
+
margin-top: $verPadding;
|
|
25
|
+
}
|
|
26
|
+
&--gap-bottom {
|
|
27
|
+
margin-bottom: $verPadding;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
&-footer {
|
|
31
|
+
padding: $verPadding $padding;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.#{$prefix}card {
|
|
37
|
+
color: $color-text1-3;
|
|
38
|
+
|
|
39
|
+
&-inner {
|
|
40
|
+
display: flex;
|
|
41
|
+
flex-direction: column;
|
|
42
|
+
background-color: #fff;
|
|
43
|
+
@include size(
|
|
44
|
+
$shadow-2,
|
|
45
|
+
$size-base * 3,
|
|
46
|
+
$size-base * 4,
|
|
47
|
+
$font-size-body-1,
|
|
48
|
+
$font-size-subhead
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
&-header {
|
|
52
|
+
flex: none;
|
|
53
|
+
display: flex;
|
|
54
|
+
|
|
55
|
+
&-title {
|
|
56
|
+
font-weight: 500;
|
|
57
|
+
flex: 1;
|
|
58
|
+
overflow: hidden;
|
|
59
|
+
text-overflow: ellipsis;
|
|
60
|
+
white-space: nowrap;
|
|
61
|
+
word-break: break-all;
|
|
62
|
+
}
|
|
63
|
+
&-extras {
|
|
64
|
+
flex: none;
|
|
65
|
+
}
|
|
66
|
+
&--line {
|
|
67
|
+
border-bottom: 1px solid $color-line1-0;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
&-footer {
|
|
71
|
+
flex: none;
|
|
72
|
+
|
|
73
|
+
&--line {
|
|
74
|
+
border-top: 1px solid $color-line1-0;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
&--medium {
|
|
79
|
+
.#{$prefix}card-inner {
|
|
80
|
+
@include size(
|
|
81
|
+
$shadow-2,
|
|
82
|
+
$size-base * 3,
|
|
83
|
+
$size-base * 4,
|
|
84
|
+
$font-size-body-1,
|
|
85
|
+
$font-size-subhead
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
&.#{$prefix}card--no-padding {
|
|
90
|
+
.#{$prefix}card {
|
|
91
|
+
&-header,
|
|
92
|
+
&-content,
|
|
93
|
+
&-footer {
|
|
94
|
+
padding: 0;
|
|
95
|
+
margin: 0;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
@keyframes fade-in {
|
|
101
|
+
0% {
|
|
102
|
+
opacity: 0;
|
|
103
|
+
}
|
|
104
|
+
100% {
|
|
105
|
+
opacity: 1;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
&-collapsable {
|
|
110
|
+
&-inner {
|
|
111
|
+
}
|
|
112
|
+
&-inner--popup {
|
|
113
|
+
position: absolute;
|
|
114
|
+
left: 0;
|
|
115
|
+
top: 0;
|
|
116
|
+
width: 100%;
|
|
117
|
+
height: auto;
|
|
118
|
+
z-index: 999;
|
|
119
|
+
opacity: 0;
|
|
120
|
+
animation-timing-function: ease-out;
|
|
121
|
+
animation-duration: 0.3s;
|
|
122
|
+
animation-name: fade-in;
|
|
123
|
+
animation-iteration-count: 1;
|
|
124
|
+
animation-fill-mode: forwards;
|
|
125
|
+
}
|
|
126
|
+
&--visible {
|
|
127
|
+
position: relative;
|
|
128
|
+
.#{$prefix}card-collapsable-inner {
|
|
129
|
+
transition: opacity 0.5s ease-in;
|
|
130
|
+
opacity: 0;
|
|
131
|
+
pointer-events: none;
|
|
132
|
+
|
|
133
|
+
&--popup {
|
|
134
|
+
transition: none;
|
|
135
|
+
opacity: 1;
|
|
136
|
+
pointer-events: all;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
package/es/card/style.js
ADDED
|
@@ -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
|
+
}
|
package/es/card/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -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,52 @@
|
|
|
1
|
+
import { __rest } from "tslib";
|
|
2
|
+
import { ConfigProvider } from '@alifd/next';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import cs from 'classnames';
|
|
5
|
+
import { PREFIX_DEFAULT } from '../../utils';
|
|
6
|
+
function DefaultHeader({ prefix, className, align, extras, children }) {
|
|
7
|
+
return (React.createElement("div", { className: cs(className) },
|
|
8
|
+
React.createElement("div", { className: `${prefix}-title`, style: { textAlign: align } }, children),
|
|
9
|
+
!!extras && React.createElement("div", { className: `${prefix}-extras` }, extras)));
|
|
10
|
+
}
|
|
11
|
+
function DefaultContent({ className, children }) {
|
|
12
|
+
return React.createElement("div", { className: cs(className) }, children);
|
|
13
|
+
}
|
|
14
|
+
function DefaultFooter({ className, align, children }) {
|
|
15
|
+
return (React.createElement("div", { className: cs(className), style: { textAlign: align } }, children));
|
|
16
|
+
}
|
|
17
|
+
export function useCardInner({ prefix, innerClassName, title, titleAlign, titleLine, footer, footerAlign = 'end', footerLine, components, children, }) {
|
|
18
|
+
const cls = prefix;
|
|
19
|
+
const { Header = DefaultHeader, Content = DefaultContent, Footer = DefaultFooter, } = components || {};
|
|
20
|
+
return (React.createElement("div", { className: cs(`${cls}-inner`, innerClassName) },
|
|
21
|
+
!!title && (React.createElement(Header, { prefix: `${cls}-header`, className: cs(`${cls}-header`, { [`${cls}-header--line`]: titleLine }), align: titleAlign }, title)),
|
|
22
|
+
React.createElement(Content, { prefix: `${cls}-content`, className: cs(`${cls}-content`, {
|
|
23
|
+
[`${cls}-content--gap-top`]: !title || titleLine,
|
|
24
|
+
[`${cls}-content--gap-bottom`]: !footer || footerLine,
|
|
25
|
+
}) }, children),
|
|
26
|
+
!!footer && (React.createElement(Footer, { prefix: `${cls}-footer`, className: cs(`${cls}-footer`, { [`${cls}-footer--line`]: footerLine }), align: footerAlign }, footer))));
|
|
27
|
+
}
|
|
28
|
+
export function useCardOuter(props) {
|
|
29
|
+
const { prefix, className, title, titleAlign, titleLine, footer, footerAlign, footerLine, size = 'medium', noPadding, components, children, innerClassName } = props, rests = __rest(props, ["prefix", "className", "title", "titleAlign", "titleLine", "footer", "footerAlign", "footerLine", "size", "noPadding", "components", "children", "innerClassName"]);
|
|
30
|
+
const cls = prefix;
|
|
31
|
+
const rootCls = cs(cls, `${cls}--${size}`, { [`${cls}--no-padding`]: noPadding }, className);
|
|
32
|
+
return (React.createElement("div", Object.assign({ className: rootCls }, rests), children));
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* @component 卡片
|
|
36
|
+
* @en Card
|
|
37
|
+
* @type 通用 - General
|
|
38
|
+
* @remarks
|
|
39
|
+
* 一个通用的卡片组件。
|
|
40
|
+
* - A card is a piece of paper with unique related data taht servers as an entry point to more detailed information.
|
|
41
|
+
* @when
|
|
42
|
+
* 当一个模块的同类信息不能自然形成区块感,可借助 Card 组件将信息整合,帮助界面信息模块感更强。
|
|
43
|
+
* -
|
|
44
|
+
* A card could contain a photo, text, and a link about a single subject.
|
|
45
|
+
*/
|
|
46
|
+
function Card(props) {
|
|
47
|
+
const cls = `${PREFIX_DEFAULT}card`;
|
|
48
|
+
const inner = useCardInner(Object.assign(Object.assign({}, props), { prefix: cls }));
|
|
49
|
+
const outer = useCardOuter(Object.assign(Object.assign({}, props), { prefix: cls, children: inner }));
|
|
50
|
+
return outer;
|
|
51
|
+
}
|
|
52
|
+
export default 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,62 @@
|
|
|
1
|
+
import { __rest } from "tslib";
|
|
2
|
+
import React, { useMemo, useRef } from 'react';
|
|
3
|
+
import cs from 'classnames';
|
|
4
|
+
import { useCardOuter, useCardInner } from './card';
|
|
5
|
+
import { PREFIX_DEFAULT, useControlable, useDebounce } from '../../utils';
|
|
6
|
+
function useContent(props) {
|
|
7
|
+
const propsRef = useRef(props);
|
|
8
|
+
propsRef.current = props;
|
|
9
|
+
return useMemo(() => {
|
|
10
|
+
return function Content({ className, children }) {
|
|
11
|
+
const { visible, onVisibleChange, renderContent } = propsRef.current;
|
|
12
|
+
return (React.createElement("div", { className: cs(className) }, renderContent({ visible, onVisibleChange, children })));
|
|
13
|
+
};
|
|
14
|
+
}, []);
|
|
15
|
+
}
|
|
16
|
+
function CollapsableCard(_a) {
|
|
17
|
+
var { components, visible: _v, defaultVisible: _dv, onVisibleChange: _onVC, triggerType = 'hover', mode, renderContent } = _a, props = __rest(_a, ["components", "visible", "defaultVisible", "onVisibleChange", "triggerType", "mode", "renderContent"]);
|
|
18
|
+
const cls = `${PREFIX_DEFAULT}card`;
|
|
19
|
+
const [value, setValue] = useControlable(props, {
|
|
20
|
+
valueName: 'visible',
|
|
21
|
+
changeName: 'onVisibleChange',
|
|
22
|
+
});
|
|
23
|
+
const hoverToTrigger = triggerType === 'hover';
|
|
24
|
+
const setValueForContent = (visible) => {
|
|
25
|
+
if (hoverToTrigger) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
setValue(visible);
|
|
29
|
+
};
|
|
30
|
+
const { Header, Footer } = components || {};
|
|
31
|
+
const Content = useContent({
|
|
32
|
+
visible: false,
|
|
33
|
+
onVisibleChange: setValueForContent,
|
|
34
|
+
renderContent,
|
|
35
|
+
});
|
|
36
|
+
const PopupContent = useContent({
|
|
37
|
+
visible: true,
|
|
38
|
+
onVisibleChange: setValueForContent,
|
|
39
|
+
renderContent,
|
|
40
|
+
});
|
|
41
|
+
const newProps = Object.assign(Object.assign({}, props), { innerClassName: cs(props.innerClassName, `${cls}-collapsable-inner`), prefix: cls, components: { Header, Footer, Content } });
|
|
42
|
+
const inner = useCardInner(newProps);
|
|
43
|
+
const popupInnerProps = Object.assign(Object.assign({}, newProps), { innerClassName: cs(props.innerClassName, `${cls}-collapsable-inner`, `${cls}-collapsable-inner--popup`), components: { Header, Footer, Content: PopupContent } });
|
|
44
|
+
const popupInner = useCardInner(popupInnerProps);
|
|
45
|
+
const classNames = cs(`${cls}-collapsable`, { [`${cls}-collapsable--visible`]: value }, newProps.className);
|
|
46
|
+
const debounceSetValue = useDebounce(setValue, 150);
|
|
47
|
+
const outer = useCardOuter(Object.assign(Object.assign(Object.assign({}, newProps), (hoverToTrigger
|
|
48
|
+
? {
|
|
49
|
+
onMouseEnter: () => {
|
|
50
|
+
debounceSetValue(true);
|
|
51
|
+
},
|
|
52
|
+
onMouseLeave: () => {
|
|
53
|
+
debounceSetValue(false);
|
|
54
|
+
},
|
|
55
|
+
}
|
|
56
|
+
: {})), { className: classNames, children: (React.createElement(React.Fragment, null,
|
|
57
|
+
inner,
|
|
58
|
+
value ? popupInner : null)) }));
|
|
59
|
+
return outer;
|
|
60
|
+
}
|
|
61
|
+
CollapsableCard.displayName = 'CollapsableCard';
|
|
62
|
+
export 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,46 @@
|
|
|
1
|
+
import { __rest } from "tslib";
|
|
2
|
+
import React, { useCallback } from 'react';
|
|
3
|
+
import { ConfigProvider } from '@alifd/next';
|
|
4
|
+
import cs from 'classnames';
|
|
5
|
+
import { PREFIX_DEFAULT, useControlable, assignSubComponent } from '../utils';
|
|
6
|
+
import Good from './view/good';
|
|
7
|
+
/**
|
|
8
|
+
* @component 反馈
|
|
9
|
+
* @en Feedback
|
|
10
|
+
* @type 通用 - General
|
|
11
|
+
* @remarks 反馈组件给用户提供点赞、踩的交互按钮。
|
|
12
|
+
* @when 需要获取用户针对显示内容的赞同或否定意见时
|
|
13
|
+
*/
|
|
14
|
+
function Feedback(props) {
|
|
15
|
+
const { className, order = ['good', 'bad'], size, direction = 'hoz', defaultValue, value: _value, onChange: _onChange, renderItem } = props, rests = __rest(props, ["className", "order", "size", "direction", "defaultValue", "value", "onChange", "renderItem"]);
|
|
16
|
+
const cls = `${PREFIX_DEFAULT}feedback`;
|
|
17
|
+
const [value, onChange] = useControlable(props);
|
|
18
|
+
const defaultRenderItem = useCallback((status) => {
|
|
19
|
+
switch (status) {
|
|
20
|
+
case 'good': {
|
|
21
|
+
return (React.createElement(Good, { className: cs(`${cls}-item-icon`, `${cls}-item-icon--good`), height: "1em" }));
|
|
22
|
+
}
|
|
23
|
+
case 'bad': {
|
|
24
|
+
return (React.createElement(Good, { className: cs(`${cls}-item-icon`, `${cls}-item-icon--bad`), height: "1em" }));
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}, [cls]);
|
|
28
|
+
const render = renderItem || defaultRenderItem;
|
|
29
|
+
const padding = size && `0px ${Math.round((size * 3) / 10)}px`;
|
|
30
|
+
const fontSize = size;
|
|
31
|
+
return (React.createElement("div", Object.assign({ className: cs(cls, className) }, rests),
|
|
32
|
+
React.createElement("div", { className: `${cls}-inner`, style: {
|
|
33
|
+
flexDirection: direction === 'hoz' ? 'row' : 'column',
|
|
34
|
+
padding,
|
|
35
|
+
fontSize,
|
|
36
|
+
} }, order.map(status => {
|
|
37
|
+
return (React.createElement("button", { className: cs(`${cls}-item`, {
|
|
38
|
+
[`${cls}-item--active`]: status === value,
|
|
39
|
+
}), style: { padding }, key: status, onClick: () => {
|
|
40
|
+
onChange(value === status ? 'stale' : status);
|
|
41
|
+
} }, render(status)));
|
|
42
|
+
}))));
|
|
43
|
+
}
|
|
44
|
+
Feedback.displayName = 'Feedback';
|
|
45
|
+
const FeedbackWithSub = assignSubComponent(Feedback, { Good });
|
|
46
|
+
export default 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 @@
|
|
|
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 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
function Good(props) {
|
|
3
|
+
return (React.createElement("svg", Object.assign({ xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 1024 1024" }, props),
|
|
4
|
+
React.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" })));
|
|
5
|
+
}
|
|
6
|
+
Good.displayName = 'FeedbackGood';
|
|
7
|
+
export 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
|
};
|