@react-fabric/core 1.0.0-beta.5 → 1.0.0-beta.6
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/dist/cjs/components/animations/Animations.js +12 -5
- package/dist/cjs/components/avatar/Avatar.js +6 -7
- package/dist/cjs/components/button/ConfirmButton.js +4 -2
- package/dist/cjs/components/card/Card.js +4 -2
- package/dist/cjs/components/collapsable/Collapsable.js +3 -2
- package/dist/cjs/components/dropdown/Dropdown.js +2 -1
- package/dist/cjs/components/dropdown/DropdownTool.js +3 -2
- package/dist/cjs/components/icon/Icon.js +7 -7
- package/dist/cjs/components/menu/ContextMenu.js +30 -10
- package/dist/cjs/components/menu/Menu.js +1 -1
- package/dist/cjs/components/navigator/Navigator.js +2 -0
- package/dist/cjs/components/panel/Panel.js +2 -0
- package/dist/cjs/components/tabpanel/Tab.js +54 -36
- package/dist/cjs/core/aside/Aside.js +3 -0
- package/dist/cjs/core/content/Content.js +8 -5
- package/dist/cjs/core/page/Page.js +1 -0
- package/dist/cjs/typography/Typography.module.css +1 -1
- package/dist/esm/components/animations/Animations.js +12 -5
- package/dist/esm/components/avatar/Avatar.js +7 -8
- package/dist/esm/components/button/ConfirmButton.js +4 -2
- package/dist/esm/components/card/Card.js +4 -2
- package/dist/esm/components/collapsable/Collapsable.js +3 -2
- package/dist/esm/components/dropdown/Dropdown.js +2 -1
- package/dist/esm/components/dropdown/DropdownTool.js +3 -2
- package/dist/esm/components/icon/Icon.js +7 -7
- package/dist/esm/components/menu/ContextMenu.js +32 -12
- package/dist/esm/components/menu/Menu.js +1 -1
- package/dist/esm/components/navigator/Navigator.js +2 -0
- package/dist/esm/components/panel/Panel.js +2 -0
- package/dist/esm/components/tabpanel/Tab.js +55 -37
- package/dist/esm/core/aside/Aside.js +3 -0
- package/dist/esm/core/content/Content.js +8 -5
- package/dist/esm/core/page/Page.js +1 -0
- package/dist/esm/typography/Typography.module.css +1 -1
- package/dist/types/components/actionLabel/ActionLabel.d.ts +2 -2
- package/dist/types/components/animations/Animations.d.ts +1 -1
- package/dist/types/components/button/ConfirmButton.d.ts +6 -1
- package/dist/types/components/card/Card.d.ts +3 -3
- package/dist/types/components/collapsable/Collapsable.d.ts +5 -1
- package/dist/types/components/dropdown/DropdownTool.d.ts +2 -1
- package/dist/types/components/media/Media.d.ts +2 -2
- package/dist/types/components/menu/ContextMenu.d.ts +2 -1
- package/dist/types/components/tabpanel/Tab.d.ts +4 -4
- package/dist/types/core/content/Content.d.ts +3 -2
- package/dist/types/types/index.d.ts +4 -0
- package/package.json +3 -3
- package/src/components/actionLabel/ActionLabel.tsx +12 -3
- package/src/components/animations/Animations.tsx +8 -2
- package/src/components/avatar/Avatar.tsx +68 -81
- package/src/components/button/ConfirmButton.tsx +10 -4
- package/src/components/card/Card.tsx +4 -0
- package/src/components/collapsable/Collapsable.tsx +6 -0
- package/src/components/dropdown/Dropdown.tsx +1 -0
- package/src/components/dropdown/DropdownTool.tsx +3 -1
- package/src/components/icon/Icon.tsx +45 -57
- package/src/components/media/Media.tsx +2 -2
- package/src/components/menu/ContextMenu.tsx +36 -11
- package/src/components/menu/Menu.tsx +1 -1
- package/src/components/navigator/Navigator.tsx +2 -0
- package/src/components/panel/Panel.tsx +2 -0
- package/src/components/tabpanel/Tab.tsx +73 -59
- package/src/core/aside/Aside.tsx +3 -0
- package/src/core/content/Content.tsx +16 -10
- package/src/core/page/Page.tsx +1 -0
- package/src/types/index.ts +5 -0
- package/src/typography/Typography.module.css +1 -1
|
@@ -61,6 +61,7 @@ export const Navigator = ({
|
|
|
61
61
|
color={color}
|
|
62
62
|
className="text-[1em] p-1"
|
|
63
63
|
aria-label="previous"
|
|
64
|
+
data-testid="previous"
|
|
64
65
|
icon={CoreIcons.chevronLeft}
|
|
65
66
|
onClick={(e) => [e.stopPropagation(), onNavigate(-1)]}
|
|
66
67
|
/>
|
|
@@ -69,6 +70,7 @@ export const Navigator = ({
|
|
|
69
70
|
className="text-[1em] p-1"
|
|
70
71
|
color={color}
|
|
71
72
|
aria-label="next"
|
|
73
|
+
data-testid="next"
|
|
72
74
|
icon={CoreIcons.chevronRight}
|
|
73
75
|
onClick={(e) => [e.stopPropagation(), onNavigate(1)]}
|
|
74
76
|
/>
|
|
@@ -176,6 +176,7 @@ export const Panel = ({
|
|
|
176
176
|
headerClassName,
|
|
177
177
|
"flex flex-nowrap items-center area-head",
|
|
178
178
|
)}
|
|
179
|
+
data-testid="panel-header"
|
|
179
180
|
onClick={collapsable ? toggleCollapse : undefined}
|
|
180
181
|
>
|
|
181
182
|
{onBack && (
|
|
@@ -240,6 +241,7 @@ export const Panel = ({
|
|
|
240
241
|
</header>
|
|
241
242
|
{(!collapsed || expanded) && (
|
|
242
243
|
<div
|
|
244
|
+
data-testid="panel-body"
|
|
243
245
|
className={classNames(
|
|
244
246
|
classes.panelBody,
|
|
245
247
|
"area-content grid overflow-hidden",
|
|
@@ -21,8 +21,10 @@
|
|
|
21
21
|
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
+
import { isString } from "@react-fabric/utilities";
|
|
24
25
|
import classNames from "classnames";
|
|
25
|
-
import { type ReactElement, useMemo } from "react";
|
|
26
|
+
import { Fragment, type ReactElement, useMemo } from "react";
|
|
27
|
+
import { Tooltip } from "../../overlays";
|
|
26
28
|
import {
|
|
27
29
|
type AriaProps,
|
|
28
30
|
type BadgeType,
|
|
@@ -34,6 +36,7 @@ import {
|
|
|
34
36
|
type PolymorphicProps,
|
|
35
37
|
type RefProp,
|
|
36
38
|
type TestProps,
|
|
39
|
+
type TooltipProp,
|
|
37
40
|
} from "../../types";
|
|
38
41
|
import { Badge, getBadgeProps } from "../badge/Badge";
|
|
39
42
|
import { DropdownTool } from "../dropdown/DropdownTool";
|
|
@@ -46,7 +49,8 @@ export interface TabProps
|
|
|
46
49
|
RefProp,
|
|
47
50
|
AriaProps,
|
|
48
51
|
TestProps,
|
|
49
|
-
IconProps
|
|
52
|
+
IconProps,
|
|
53
|
+
TooltipProp {
|
|
50
54
|
/**
|
|
51
55
|
* tab id
|
|
52
56
|
*/
|
|
@@ -62,7 +66,7 @@ export interface TabProps
|
|
|
62
66
|
/**
|
|
63
67
|
* tab badge
|
|
64
68
|
*/
|
|
65
|
-
badge?: BadgeType;
|
|
69
|
+
badge?: string | number | BadgeType;
|
|
66
70
|
/**
|
|
67
71
|
* disabled
|
|
68
72
|
*/
|
|
@@ -110,6 +114,7 @@ export const Tab = <Tag extends React.ElementType = "button">({
|
|
|
110
114
|
tabFlex,
|
|
111
115
|
color,
|
|
112
116
|
actions,
|
|
117
|
+
tooltip,
|
|
113
118
|
activeClassName,
|
|
114
119
|
...aria
|
|
115
120
|
}: TabProps & PolymorphicProps<Tag>) => {
|
|
@@ -117,63 +122,72 @@ export const Tab = <Tag extends React.ElementType = "button">({
|
|
|
117
122
|
return getBadgeProps(badge);
|
|
118
123
|
}, [badge]);
|
|
119
124
|
|
|
125
|
+
const tooltipProps = useMemo(() => {
|
|
126
|
+
if (isString(tooltip)) return { content: tooltip };
|
|
127
|
+
|
|
128
|
+
return tooltip ?? {};
|
|
129
|
+
}, [tooltip]);
|
|
130
|
+
|
|
120
131
|
const E = as ?? "button";
|
|
132
|
+
const W = tooltip ? Tooltip : Fragment;
|
|
121
133
|
return (
|
|
122
|
-
<
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
134
|
+
<W {...tooltipProps}>
|
|
135
|
+
<E
|
|
136
|
+
data-id={id}
|
|
137
|
+
disabled={disabled}
|
|
138
|
+
data-color={color}
|
|
139
|
+
className={classNames(
|
|
140
|
+
classes.tabButton,
|
|
141
|
+
className,
|
|
142
|
+
active && "active pointer-events-none",
|
|
143
|
+
active && activeClassName,
|
|
144
|
+
disabled && "text-tint-500 pointer-events-none",
|
|
145
|
+
tabFlex ? "flex-1" : "flex-initial max-w-36 min-w-24",
|
|
146
|
+
"flex items-center justify-center px-1 rounded overflow-hidden",
|
|
147
|
+
)}
|
|
148
|
+
onClick={() => !active && onClick?.(id)}
|
|
149
|
+
ref={ref as AnyObject}
|
|
150
|
+
{...aria}
|
|
151
|
+
>
|
|
152
|
+
{icon && (
|
|
153
|
+
<Icon
|
|
154
|
+
icon={icon}
|
|
155
|
+
bg={iconBg}
|
|
156
|
+
color={iconColor}
|
|
157
|
+
rtlFlip={rtlFlip}
|
|
158
|
+
className="flex-content"
|
|
159
|
+
/>
|
|
160
|
+
)}
|
|
161
|
+
{!minimal && (
|
|
162
|
+
<label className="flex-initial truncate text-center px-1 py-1">
|
|
163
|
+
{label}
|
|
164
|
+
</label>
|
|
165
|
+
)}
|
|
166
|
+
{badge && (
|
|
167
|
+
<Badge
|
|
168
|
+
{...badgeProps}
|
|
169
|
+
placement={minimal ? "end" : ""}
|
|
170
|
+
className={classNames("me-1", badgeProps.className)}
|
|
171
|
+
/>
|
|
172
|
+
)}
|
|
173
|
+
{actions && active && (
|
|
174
|
+
<DropdownTool className="bg-base/20 me-1 z-5">{actions}</DropdownTool>
|
|
175
|
+
)}
|
|
176
|
+
{onClose && (
|
|
177
|
+
<span
|
|
178
|
+
role="none"
|
|
179
|
+
className={classNames(
|
|
180
|
+
"cursor-pointer me-1 opacity-65 hover:opacity-90 pointer-events-auto",
|
|
181
|
+
)}
|
|
182
|
+
onClick={(e) => {
|
|
183
|
+
onClose?.();
|
|
184
|
+
e.stopPropagation();
|
|
185
|
+
}}
|
|
186
|
+
>
|
|
187
|
+
×
|
|
188
|
+
</span>
|
|
189
|
+
)}
|
|
190
|
+
</E>
|
|
191
|
+
</W>
|
|
178
192
|
);
|
|
179
193
|
};
|
package/src/core/aside/Aside.tsx
CHANGED
|
@@ -200,6 +200,7 @@ export const Aside = ({
|
|
|
200
200
|
className={classNames(classes.aside, className, "overflow-hidden grid")}
|
|
201
201
|
data-align={align}
|
|
202
202
|
data-flyout={peek}
|
|
203
|
+
data-loading={loading}
|
|
203
204
|
data-collapsed={isCollapsed}
|
|
204
205
|
style={isCollapsed ? undefined : widthStyles}
|
|
205
206
|
data-testid={testId}
|
|
@@ -211,6 +212,7 @@ export const Aside = ({
|
|
|
211
212
|
headerClassName,
|
|
212
213
|
"grid area-head items-center",
|
|
213
214
|
)}
|
|
215
|
+
data-testid="aside-header"
|
|
214
216
|
>
|
|
215
217
|
{title && (
|
|
216
218
|
<div
|
|
@@ -264,6 +266,7 @@ export const Aside = ({
|
|
|
264
266
|
"overflow-hidden grid",
|
|
265
267
|
)}
|
|
266
268
|
style={isCollapsed ? widthStyles : undefined}
|
|
269
|
+
data-testid="aside-body"
|
|
267
270
|
>
|
|
268
271
|
<ErrorBoundary>{children}</ErrorBoundary>
|
|
269
272
|
</section>
|
|
@@ -22,14 +22,14 @@
|
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
24
|
import classNames from "classnames";
|
|
25
|
-
import { useImperativeHandle } from "react";
|
|
25
|
+
import { type MouseEvent, useImperativeHandle } from "react";
|
|
26
26
|
import { useDebounce } from "../../hooks/useDebounce";
|
|
27
27
|
import { useResizeObserver } from "../../hooks/useResizeObserver";
|
|
28
28
|
import {
|
|
29
29
|
type ChildrenProp,
|
|
30
30
|
type CssProp,
|
|
31
|
-
type PositionObject,
|
|
32
31
|
type RefProp,
|
|
32
|
+
type ScrollObject,
|
|
33
33
|
type SizeObject,
|
|
34
34
|
type TestProps,
|
|
35
35
|
} from "../../types";
|
|
@@ -44,7 +44,7 @@ export interface ContentProps
|
|
|
44
44
|
/**
|
|
45
45
|
* scroll vevent handler
|
|
46
46
|
*/
|
|
47
|
-
onScroll?: (event:
|
|
47
|
+
onScroll?: (scroll: ScrollObject, event: MouseEvent<HTMLDivElement>) => void;
|
|
48
48
|
/**
|
|
49
49
|
* scroll vevent handler
|
|
50
50
|
*/
|
|
@@ -65,13 +65,19 @@ export const Content = ({
|
|
|
65
65
|
}: ContentProps) => {
|
|
66
66
|
const resizeHandle = useResizeObserver(onResize);
|
|
67
67
|
const scrollHandler = useDebounce(
|
|
68
|
-
(e:
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
68
|
+
(e: MouseEvent<HTMLDivElement>) => {
|
|
69
|
+
const el = e.target as HTMLElement;
|
|
70
|
+
onScroll?.(
|
|
71
|
+
{
|
|
72
|
+
left: el.scrollLeft,
|
|
73
|
+
top: el.scrollTop,
|
|
74
|
+
scrollHeight: el.scrollHeight,
|
|
75
|
+
scrollWidth: el.scrollWidth,
|
|
76
|
+
width: el.offsetWidth,
|
|
77
|
+
height: el.offsetHeight,
|
|
78
|
+
},
|
|
79
|
+
e,
|
|
80
|
+
);
|
|
75
81
|
},
|
|
76
82
|
[onScroll],
|
|
77
83
|
);
|
package/src/core/page/Page.tsx
CHANGED
package/src/types/index.ts
CHANGED