@react-fabric/core 1.0.0-beta.4 → 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/chip/Chip.js +2 -2
- package/dist/cjs/components/chip/Chip.module.css +1 -1
- 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/chip/Chip.js +2 -2
- package/dist/esm/components/chip/Chip.module.css +1 -1
- 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/overlays/modal/Modal.d.ts +1 -1
- 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/chip/Chip.module.css +1 -1
- package/src/components/chip/Chip.tsx +2 -4
- 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/overlays/modal/Modal.tsx +1 -1
- package/src/types/index.ts +5 -0
- package/src/typography/Typography.module.css +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import { type Placement } from "@floating-ui/react";
|
|
2
3
|
import { type CallbackReturn, type PolymorphicProps, type RefProp } from "../../types";
|
|
3
4
|
import { type BaseProps, type ButtonProps } from "./Button";
|
|
4
5
|
interface ExtendedProps extends Omit<BaseProps, "onClick">, RefProp {
|
|
@@ -14,6 +15,10 @@ interface ExtendedProps extends Omit<BaseProps, "onClick">, RefProp {
|
|
|
14
15
|
* ok label
|
|
15
16
|
*/
|
|
16
17
|
cancelLabel?: string;
|
|
18
|
+
/**
|
|
19
|
+
* dropdown placement
|
|
20
|
+
*/
|
|
21
|
+
placement?: Placement;
|
|
17
22
|
/**
|
|
18
23
|
* click handler, return Promise to autoset loading state
|
|
19
24
|
*/
|
|
@@ -23,5 +28,5 @@ export type ConfirmButtonProps = ExtendedProps & ButtonProps;
|
|
|
23
28
|
/**
|
|
24
29
|
* Button with confirmation dropdown
|
|
25
30
|
*/
|
|
26
|
-
export declare const ConfirmButton: <Tag extends import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> = "button">({ ref, message, color, okLabel, cancelLabel, onClick, loading, actionMessage, showActionDone, showActionDoneEvent, ...props }: ConfirmButtonProps & PolymorphicProps<Tag>) => import("react/jsx-runtime").JSX.Element;
|
|
31
|
+
export declare const ConfirmButton: <Tag extends import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> = "button">({ ref, message, color, okLabel, cancelLabel, onClick, loading, placement, actionMessage, showActionDone, showActionDoneEvent, ...props }: ConfirmButtonProps & PolymorphicProps<Tag>) => import("react/jsx-runtime").JSX.Element;
|
|
27
32
|
export {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type MouseEventHandler } from "react";
|
|
2
2
|
import { type ContentProps } from "../../core/content/Content";
|
|
3
3
|
import { type HeadFootProps } from "../../core/headfoot/HeadFoot";
|
|
4
|
-
import { type AriaProps, type ChildrenProp, type CssProp, type TestProps } from "../../types";
|
|
5
|
-
export interface CardProps extends CssProp, AriaProps, TestProps, ChildrenProp<React.ReactElement<HeadFootProps | ContentProps>> {
|
|
4
|
+
import { type AriaProps, type ChildrenProp, type CssProp, type RefProp, type TestProps } from "../../types";
|
|
5
|
+
export interface CardProps extends CssProp, AriaProps, TestProps, RefProp<HTMLDivElement>, ChildrenProp<React.ReactElement<HeadFootProps | ContentProps>> {
|
|
6
6
|
/**
|
|
7
7
|
* apply flex fill styling
|
|
8
8
|
*/
|
|
@@ -36,4 +36,4 @@ export interface CardProps extends CssProp, AriaProps, TestProps, ChildrenProp<R
|
|
|
36
36
|
*/
|
|
37
37
|
dragData?: KeyValue;
|
|
38
38
|
}
|
|
39
|
-
export declare const Card: ({ children, className, bodyClassName, selected, selectedRibbon, onClick, flex, draggable, dragKey, dragData, ...aria }: CardProps) => import("react/jsx-runtime").JSX.Element;
|
|
39
|
+
export declare const Card: ({ children, className, bodyClassName, selected, selectedRibbon, onClick, flex, draggable, dragKey, dragData, ref, ...aria }: CardProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -18,6 +18,10 @@ export interface CollapsableProps extends CssProp, AriaProps, TestProps, RefProp
|
|
|
18
18
|
* header button className
|
|
19
19
|
*/
|
|
20
20
|
headerClassName?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Header position sticky
|
|
23
|
+
*/
|
|
24
|
+
stickyHeader?: boolean;
|
|
21
25
|
/**
|
|
22
26
|
* open state icon
|
|
23
27
|
*/
|
|
@@ -43,5 +47,5 @@ export interface CollapsableProps extends CssProp, AriaProps, TestProps, RefProp
|
|
|
43
47
|
*/
|
|
44
48
|
onClose?: () => void;
|
|
45
49
|
}
|
|
46
|
-
export declare const Collapsable: ({ ref, disabled, className, bodyClassName, headerClassName, children, iconAlign, iconClosed, iconOpen, open, onClose, onOpen, ...aria }: CollapsableProps) => import("react/jsx-runtime").JSX.Element;
|
|
50
|
+
export declare const Collapsable: ({ ref, disabled, className, bodyClassName, headerClassName, children, iconAlign, stickyHeader, iconClosed, iconOpen, open, onClose, onOpen, ...aria }: CollapsableProps) => import("react/jsx-runtime").JSX.Element;
|
|
47
51
|
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type ChildProp, type CssProp } from "../../types";
|
|
2
2
|
import { type DropdownProps } from "./Dropdown";
|
|
3
|
-
export declare const DropdownTool: ({ children, className, groupHover, ...props }: ChildProp & CssProp & Omit<DropdownProps, "children"> & {
|
|
3
|
+
export declare const DropdownTool: ({ children, className, groupHover, icon, ...props }: ChildProp & CssProp & Omit<DropdownProps, "children"> & {
|
|
4
|
+
icon?: string;
|
|
4
5
|
/**
|
|
5
6
|
* hide until group hovered
|
|
6
7
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type AriaProps, type CssProp } from "../../types";
|
|
2
|
-
export interface BaseProps extends CssProp, AriaProps {
|
|
1
|
+
import { type AriaProps, type CssProp, type TestProps } from "../../types";
|
|
2
|
+
export interface BaseProps extends CssProp, TestProps, AriaProps {
|
|
3
3
|
/**
|
|
4
4
|
* media source
|
|
5
5
|
*/
|
|
@@ -3,5 +3,6 @@ import { type ChildrenProp } from "../../types";
|
|
|
3
3
|
import { type Menu } from "./Menu";
|
|
4
4
|
export interface ContextMenuProps extends ChildrenProp {
|
|
5
5
|
menu: React.ReactElement<typeof Menu>;
|
|
6
|
+
disabled?: boolean;
|
|
6
7
|
}
|
|
7
|
-
export declare const ContextMenu: ({ children, menu }: ContextMenuProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export declare const ContextMenu: ({ children, menu, disabled }: ContextMenuProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ReactElement } from "react";
|
|
2
|
-
import { type AriaProps, type BadgeType, type CallbackReturn, type ChildrenProp, type ColorType, type CssProp, type IconProps, type PolymorphicProps, type RefProp, type TestProps } from "../../types";
|
|
3
|
-
export interface TabProps extends Partial<ChildrenProp>, CssProp, RefProp, AriaProps, TestProps, IconProps {
|
|
2
|
+
import { type AriaProps, type BadgeType, type CallbackReturn, type ChildrenProp, type ColorType, type CssProp, type IconProps, type PolymorphicProps, type RefProp, type TestProps, type TooltipProp } from "../../types";
|
|
3
|
+
export interface TabProps extends Partial<ChildrenProp>, CssProp, RefProp, AriaProps, TestProps, IconProps, TooltipProp {
|
|
4
4
|
/**
|
|
5
5
|
* tab id
|
|
6
6
|
*/
|
|
@@ -16,7 +16,7 @@ export interface TabProps extends Partial<ChildrenProp>, CssProp, RefProp, AriaP
|
|
|
16
16
|
/**
|
|
17
17
|
* tab badge
|
|
18
18
|
*/
|
|
19
|
-
badge?: BadgeType;
|
|
19
|
+
badge?: string | number | BadgeType;
|
|
20
20
|
/**
|
|
21
21
|
* disabled
|
|
22
22
|
*/
|
|
@@ -42,4 +42,4 @@ export interface TabProps extends Partial<ChildrenProp>, CssProp, RefProp, AriaP
|
|
|
42
42
|
*/
|
|
43
43
|
onClick?: (id: string) => CallbackReturn;
|
|
44
44
|
}
|
|
45
|
-
export declare const Tab: <Tag extends import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> = "button">({ ref, as, id, className, label, icon, iconBg, iconColor, rtlFlip, badge, disabled, onClose, active, minimal, onClick, tabFlex, color, actions, activeClassName, ...aria }: TabProps & PolymorphicProps<Tag>) => import("react/jsx-runtime").JSX.Element;
|
|
45
|
+
export declare const Tab: <Tag extends import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> = "button">({ ref, as, id, className, label, icon, iconBg, iconColor, rtlFlip, badge, disabled, onClose, active, minimal, onClick, tabFlex, color, actions, tooltip, activeClassName, ...aria }: TabProps & PolymorphicProps<Tag>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type MouseEvent } from "react";
|
|
2
|
+
import { type ChildrenProp, type CssProp, type RefProp, type ScrollObject, type SizeObject, type TestProps } from "../../types";
|
|
2
3
|
export interface ContentProps extends ChildrenProp, CssProp, RefProp, TestProps {
|
|
3
4
|
/**
|
|
4
5
|
* scroll vevent handler
|
|
5
6
|
*/
|
|
6
|
-
onScroll?: (event:
|
|
7
|
+
onScroll?: (scroll: ScrollObject, event: MouseEvent<HTMLDivElement>) => void;
|
|
7
8
|
/**
|
|
8
9
|
* scroll vevent handler
|
|
9
10
|
*/
|
|
@@ -44,7 +44,7 @@ export interface ModalProps extends AriaProps, TestProps, IconProps, ChildrenPro
|
|
|
44
44
|
/**
|
|
45
45
|
* close handler
|
|
46
46
|
*/
|
|
47
|
-
onClose
|
|
47
|
+
onClose?: (...args: AnyObject) => void;
|
|
48
48
|
/**
|
|
49
49
|
* before close handler, return false to prevent close
|
|
50
50
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-fabric/core",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.6",
|
|
4
4
|
"description": "RUF: Core package",
|
|
5
5
|
"author": "Adarsh Pastakia <adarshpastakia@outlook.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@floating-ui/react": "^0.26.24",
|
|
39
|
-
"@react-fabric/utilities": "^1.0.0-beta.
|
|
39
|
+
"@react-fabric/utilities": "^1.0.0-beta.6",
|
|
40
40
|
"@tailwindcss/container-queries": "^0.1.1",
|
|
41
41
|
"@tailwindcss/forms": "^0.5.7",
|
|
42
42
|
"@tailwindcss/typography": "^0.5.13",
|
|
@@ -56,5 +56,5 @@
|
|
|
56
56
|
"node": ">=18.12.0",
|
|
57
57
|
"npm": ">=8.19.0"
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "21167df13cedeae8b365e87b9bab6d7401298cb6"
|
|
60
60
|
}
|
|
@@ -22,12 +22,21 @@
|
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
24
|
import classNames from "classnames";
|
|
25
|
-
import { type ReactElement
|
|
26
|
-
import {
|
|
25
|
+
import { useCallback, type ReactElement } from "react";
|
|
26
|
+
import {
|
|
27
|
+
type AriaProps,
|
|
28
|
+
type ChildProp,
|
|
29
|
+
type CssProp,
|
|
30
|
+
type TestProps,
|
|
31
|
+
} from "../../types";
|
|
27
32
|
import { ButtonGroup } from "../button/ButtonGroup";
|
|
28
33
|
import classes from "./ActionLabel.module.css";
|
|
29
34
|
|
|
30
|
-
export interface ActionLabelProps
|
|
35
|
+
export interface ActionLabelProps
|
|
36
|
+
extends AriaProps,
|
|
37
|
+
CssProp,
|
|
38
|
+
ChildProp,
|
|
39
|
+
TestProps {
|
|
31
40
|
/**
|
|
32
41
|
* action buttons aligment
|
|
33
42
|
*/
|
|
@@ -142,6 +142,7 @@ export const AnimationSpinner = ({
|
|
|
142
142
|
className={classNames(
|
|
143
143
|
"absolute inset-0 z-10 flex justify-center items-center cursor-wait",
|
|
144
144
|
)}
|
|
145
|
+
data-testid="spinner"
|
|
145
146
|
>
|
|
146
147
|
<div
|
|
147
148
|
className={classNames(
|
|
@@ -164,15 +165,20 @@ export const Loading = () => {
|
|
|
164
165
|
classes.loader,
|
|
165
166
|
"area-[loader] relative overflow-x-clip",
|
|
166
167
|
)}
|
|
168
|
+
data-testid="loading"
|
|
167
169
|
>
|
|
168
170
|
<div className="absolute z-10 py-px inset-x-0 top-0 after:h-0.5 after:block after:bg-primary-500" />
|
|
169
171
|
</div>
|
|
170
172
|
);
|
|
171
173
|
};
|
|
172
174
|
|
|
173
|
-
export const Skeleton = () => {
|
|
175
|
+
export const Skeleton = ({ className, ...rest }: CssProp) => {
|
|
174
176
|
return (
|
|
175
|
-
<div
|
|
177
|
+
<div
|
|
178
|
+
className={classNames(className, "p-2 animate-pulse flex gap-2 max-w-lg")}
|
|
179
|
+
data-testid="skeleton"
|
|
180
|
+
{...rest}
|
|
181
|
+
>
|
|
176
182
|
<div className="bg-tint-100 rounded aspect-square h-12" />
|
|
177
183
|
<div className="flex-1 flex flex-col gap-2">
|
|
178
184
|
<div className="bg-tint-100 h-3 rounded-full" />
|
|
@@ -24,8 +24,7 @@
|
|
|
24
24
|
import { isSvgPath } from "@react-fabric/utilities";
|
|
25
25
|
import BoringAvatar from "boring-avatars";
|
|
26
26
|
import classNames from "classnames";
|
|
27
|
-
import { useState } from "react";
|
|
28
|
-
import { useMemoDebugger } from "../../hooks/useEffectDebugger";
|
|
27
|
+
import { useMemo, useState } from "react";
|
|
29
28
|
import {
|
|
30
29
|
type AriaProps,
|
|
31
30
|
type ColorType,
|
|
@@ -109,89 +108,77 @@ export const Avatar = ({
|
|
|
109
108
|
const [fallback, setFallback] = useState(true);
|
|
110
109
|
|
|
111
110
|
/** ***************** style map *******************/
|
|
112
|
-
const styles =
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
},
|
|
129
|
-
[bg, color, size],
|
|
130
|
-
"Avatar styles",
|
|
131
|
-
);
|
|
111
|
+
const styles = useMemo(() => {
|
|
112
|
+
const s: KeyValue = {};
|
|
113
|
+
if (bg) {
|
|
114
|
+
s.backgroundColor = getColor(bg);
|
|
115
|
+
}
|
|
116
|
+
if (color) {
|
|
117
|
+
s.color = getColor(color);
|
|
118
|
+
}
|
|
119
|
+
if (size && !(size in SizeMap)) {
|
|
120
|
+
s.fontSize = size;
|
|
121
|
+
}
|
|
122
|
+
if (size && size in SizeMap) {
|
|
123
|
+
s.fontSize = SizeMap[size];
|
|
124
|
+
}
|
|
125
|
+
return s;
|
|
126
|
+
}, [bg, color, size]);
|
|
132
127
|
|
|
133
128
|
/** ***************** render icon *******************/
|
|
134
|
-
const avatarImage =
|
|
135
|
-
()
|
|
136
|
-
|
|
129
|
+
const avatarImage = useMemo(() => {
|
|
130
|
+
setFallback(!avatar);
|
|
131
|
+
return (
|
|
132
|
+
avatar && (
|
|
133
|
+
<div className="contents">
|
|
134
|
+
<div
|
|
135
|
+
className={classNames(
|
|
136
|
+
classes.imgPlaceholder,
|
|
137
|
+
"absolute inset-0 bg-gray animate-pulse",
|
|
138
|
+
)}
|
|
139
|
+
/>
|
|
140
|
+
<img
|
|
141
|
+
src={avatar}
|
|
142
|
+
alt={avatar}
|
|
143
|
+
className="align-baseline"
|
|
144
|
+
onError={() => setFallback(true)}
|
|
145
|
+
onLoad={(e) => e.currentTarget.previousElementSibling?.remove()}
|
|
146
|
+
/>
|
|
147
|
+
</div>
|
|
148
|
+
)
|
|
149
|
+
);
|
|
150
|
+
}, [avatar]);
|
|
151
|
+
|
|
152
|
+
const fallbackAvatar = useMemo(() => {
|
|
153
|
+
if (fallbackIcon) {
|
|
154
|
+
return isSvgPath(fallbackIcon) ? (
|
|
155
|
+
<svg viewBox={viewBox}>
|
|
156
|
+
<path fill="currentColor" d={fallbackIcon.toString()} />
|
|
157
|
+
</svg>
|
|
158
|
+
) : (
|
|
159
|
+
<i className={fallbackIcon} />
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
if (variant === "text") {
|
|
163
|
+
const [, first, second, group] =
|
|
164
|
+
name.match(/(?=(\w).* (\w).*)|(?=(\w\w).*)/) ?? [];
|
|
137
165
|
return (
|
|
138
|
-
|
|
139
|
-
<
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
onError={() => setFallback(true)}
|
|
151
|
-
onLoad={(e) => e.currentTarget.previousElementSibling?.remove()}
|
|
152
|
-
/>
|
|
153
|
-
</div>
|
|
154
|
-
)
|
|
166
|
+
<svg role="img">
|
|
167
|
+
<text
|
|
168
|
+
x="50%"
|
|
169
|
+
y="50%"
|
|
170
|
+
dy=".1em"
|
|
171
|
+
dominantBaseline="middle"
|
|
172
|
+
textAnchor="middle"
|
|
173
|
+
style={{ fontSize: ".5em", fontWeight: 500 }}
|
|
174
|
+
>
|
|
175
|
+
{group ?? `${first}${second}`}
|
|
176
|
+
</text>
|
|
177
|
+
</svg>
|
|
155
178
|
);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
);
|
|
160
|
-
|
|
161
|
-
const fallbackAvatar = useMemoDebugger(
|
|
162
|
-
() => {
|
|
163
|
-
if (fallbackIcon) {
|
|
164
|
-
return isSvgPath(fallbackIcon) ? (
|
|
165
|
-
<svg viewBox={viewBox}>
|
|
166
|
-
<path fill="currentColor" d={fallbackIcon.toString()} />
|
|
167
|
-
</svg>
|
|
168
|
-
) : (
|
|
169
|
-
<i className={fallbackIcon} />
|
|
170
|
-
);
|
|
171
|
-
}
|
|
172
|
-
if (variant === "text") {
|
|
173
|
-
const [, first, second, group] =
|
|
174
|
-
name.match(/(?=(\w).* (\w).*)|(?=(\w\w).*)/) ?? [];
|
|
175
|
-
return (
|
|
176
|
-
<svg role="img">
|
|
177
|
-
<text
|
|
178
|
-
x="50%"
|
|
179
|
-
y="50%"
|
|
180
|
-
dy=".1em"
|
|
181
|
-
dominantBaseline="middle"
|
|
182
|
-
textAnchor="middle"
|
|
183
|
-
style={{ fontSize: ".5em", fontWeight: 500 }}
|
|
184
|
-
>
|
|
185
|
-
{group ?? `${first}${second}`}
|
|
186
|
-
</text>
|
|
187
|
-
</svg>
|
|
188
|
-
);
|
|
189
|
-
}
|
|
190
|
-
return <BoringAvatar square size={64} variant={variant} name={name} />;
|
|
191
|
-
},
|
|
192
|
-
[name, variant, fallbackIcon],
|
|
193
|
-
"Avatar fallback",
|
|
194
|
-
);
|
|
179
|
+
}
|
|
180
|
+
return <BoringAvatar square size={64} variant={variant} name={name} />;
|
|
181
|
+
}, [name, variant, fallbackIcon]);
|
|
195
182
|
|
|
196
183
|
return (
|
|
197
184
|
<dfn
|
|
@@ -22,18 +22,19 @@
|
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
24
|
import {
|
|
25
|
-
FloatingArrow,
|
|
26
|
-
FloatingFocusManager,
|
|
27
|
-
FloatingPortal,
|
|
28
25
|
arrow,
|
|
29
26
|
autoUpdate,
|
|
30
27
|
flip,
|
|
28
|
+
FloatingArrow,
|
|
29
|
+
FloatingFocusManager,
|
|
30
|
+
FloatingPortal,
|
|
31
31
|
offset,
|
|
32
32
|
shift,
|
|
33
33
|
useClick,
|
|
34
34
|
useDismiss,
|
|
35
35
|
useFloating,
|
|
36
36
|
useInteractions,
|
|
37
|
+
type Placement,
|
|
37
38
|
} from "@floating-ui/react";
|
|
38
39
|
import { mergeRefs } from "@react-fabric/utilities";
|
|
39
40
|
import classNames from "classnames";
|
|
@@ -66,6 +67,10 @@ interface ExtendedProps extends Omit<BaseProps, "onClick">, RefProp {
|
|
|
66
67
|
* ok label
|
|
67
68
|
*/
|
|
68
69
|
cancelLabel?: string;
|
|
70
|
+
/**
|
|
71
|
+
* dropdown placement
|
|
72
|
+
*/
|
|
73
|
+
placement?: Placement;
|
|
69
74
|
/**
|
|
70
75
|
* click handler, return Promise to autoset loading state
|
|
71
76
|
*/
|
|
@@ -85,6 +90,7 @@ export const ConfirmButton = <Tag extends React.ElementType = "button">({
|
|
|
85
90
|
cancelLabel,
|
|
86
91
|
onClick,
|
|
87
92
|
loading,
|
|
93
|
+
placement = "bottom",
|
|
88
94
|
actionMessage,
|
|
89
95
|
showActionDone,
|
|
90
96
|
showActionDoneEvent = "click",
|
|
@@ -127,7 +133,7 @@ export const ConfirmButton = <Tag extends React.ElementType = "button">({
|
|
|
127
133
|
}
|
|
128
134
|
},
|
|
129
135
|
strategy: "fixed",
|
|
130
|
-
placement
|
|
136
|
+
placement,
|
|
131
137
|
whileElementsMounted: autoUpdate,
|
|
132
138
|
middleware: [
|
|
133
139
|
shift({ padding: 8 }),
|
|
@@ -39,6 +39,7 @@ import {
|
|
|
39
39
|
type AriaProps,
|
|
40
40
|
type ChildrenProp,
|
|
41
41
|
type CssProp,
|
|
42
|
+
type RefProp,
|
|
42
43
|
type TestProps,
|
|
43
44
|
} from "../../types";
|
|
44
45
|
import { nodeCheck } from "../../utils";
|
|
@@ -48,6 +49,7 @@ export interface CardProps
|
|
|
48
49
|
extends CssProp,
|
|
49
50
|
AriaProps,
|
|
50
51
|
TestProps,
|
|
52
|
+
RefProp<HTMLDivElement>,
|
|
51
53
|
ChildrenProp<React.ReactElement<HeadFootProps | ContentProps>> {
|
|
52
54
|
/**
|
|
53
55
|
* apply flex fill styling
|
|
@@ -94,6 +96,7 @@ export const Card = ({
|
|
|
94
96
|
draggable,
|
|
95
97
|
dragKey,
|
|
96
98
|
dragData,
|
|
99
|
+
ref,
|
|
97
100
|
...aria
|
|
98
101
|
}: CardProps) => {
|
|
99
102
|
const [header, body, footer] = useMemo(() => {
|
|
@@ -136,6 +139,7 @@ export const Card = ({
|
|
|
136
139
|
dragKey &&
|
|
137
140
|
e.dataTransfer?.setData(dragKey, JSON.stringify(dragData))
|
|
138
141
|
}
|
|
142
|
+
ref={ref}
|
|
139
143
|
{...aria}
|
|
140
144
|
>
|
|
141
145
|
{header}
|
|
@@ -156,7 +156,7 @@ export const Chip = <Tag extends React.ElementType = "div">({
|
|
|
156
156
|
classes.chip,
|
|
157
157
|
className,
|
|
158
158
|
color && getColorClass(color),
|
|
159
|
-
"select-none inline-flex flex-nowrap items-center max-w-72 text-sm
|
|
159
|
+
"select-none inline-flex flex-nowrap items-center max-w-72 text-sm rounded",
|
|
160
160
|
rounded && "rounded-full",
|
|
161
161
|
!!onClick && classes.clickable,
|
|
162
162
|
disabled && classes.disabled,
|
|
@@ -178,9 +178,7 @@ export const Chip = <Tag extends React.ElementType = "div">({
|
|
|
178
178
|
/>
|
|
179
179
|
)}
|
|
180
180
|
{children && (
|
|
181
|
-
<label
|
|
182
|
-
className={classNames(classes.chipLabel, "leading-none truncate")}
|
|
183
|
-
>
|
|
181
|
+
<label className={classNames(classes.chipLabel, "truncate")}>
|
|
184
182
|
{children}
|
|
185
183
|
</label>
|
|
186
184
|
)}
|
|
@@ -66,6 +66,10 @@ export interface CollapsableProps
|
|
|
66
66
|
* header button className
|
|
67
67
|
*/
|
|
68
68
|
headerClassName?: string;
|
|
69
|
+
/**
|
|
70
|
+
* Header position sticky
|
|
71
|
+
*/
|
|
72
|
+
stickyHeader?: boolean;
|
|
69
73
|
/**
|
|
70
74
|
* open state icon
|
|
71
75
|
*/
|
|
@@ -100,6 +104,7 @@ export const Collapsable = ({
|
|
|
100
104
|
headerClassName,
|
|
101
105
|
children,
|
|
102
106
|
iconAlign,
|
|
107
|
+
stickyHeader,
|
|
103
108
|
iconClosed = CoreIcons.chevronRight,
|
|
104
109
|
iconOpen = CoreIcons.chevronDown,
|
|
105
110
|
open,
|
|
@@ -138,6 +143,7 @@ export const Collapsable = ({
|
|
|
138
143
|
classes.collapsableHead,
|
|
139
144
|
"flex gap-1 flex-nowrap py-2 font-medium cursor-pointer items-center select-none hover:opacity-70",
|
|
140
145
|
headerClassName,
|
|
146
|
+
stickyHeader && "bg-base sticky top-0 px-2 py-1 z-10",
|
|
141
147
|
iconAlign === "end" ? "flex-row-reverse" : "flex-row",
|
|
142
148
|
)}
|
|
143
149
|
onClick={() => !disabled && setOpenState(!openState)}
|
|
@@ -31,10 +31,12 @@ export const DropdownTool = ({
|
|
|
31
31
|
children,
|
|
32
32
|
className,
|
|
33
33
|
groupHover,
|
|
34
|
+
icon,
|
|
34
35
|
...props
|
|
35
36
|
}: ChildProp &
|
|
36
37
|
CssProp &
|
|
37
38
|
Omit<DropdownProps, "children"> & {
|
|
39
|
+
icon?: string;
|
|
38
40
|
/**
|
|
39
41
|
* hide until group hovered
|
|
40
42
|
*/
|
|
@@ -43,7 +45,7 @@ export const DropdownTool = ({
|
|
|
43
45
|
return (
|
|
44
46
|
<Dropdown {...props}>
|
|
45
47
|
<Icon
|
|
46
|
-
icon={CoreIcons.caretDown}
|
|
48
|
+
icon={icon ?? CoreIcons.caretDown}
|
|
47
49
|
className={classNames(
|
|
48
50
|
className,
|
|
49
51
|
"outline bg-base flex-content pointer-events-auto cursor-pointer",
|