@dxos/react-ui 0.3.3-main.3ce60d4 → 0.3.3-main.55fdeb1
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/lib/browser/index.mjs +181 -163
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/types/src/components/Card/Card.d.ts +9 -1
- package/dist/types/src/components/Card/Card.d.ts.map +1 -1
- package/dist/types/src/components/Card/Card.stories.d.ts +10 -2
- package/dist/types/src/components/Card/Card.stories.d.ts.map +1 -1
- package/dist/types/src/components/Main/Main.d.ts +4 -4
- package/dist/types/src/components/Main/Main.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/components/Card/Card.tsx +40 -7
- package/src/components/Main/Main.tsx +1 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/react-ui",
|
|
3
|
-
"version": "0.3.3-main.
|
|
3
|
+
"version": "0.3.3-main.55fdeb1",
|
|
4
4
|
"description": "Opinionated, styled, low-level React components for DXOS.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -40,10 +40,10 @@
|
|
|
40
40
|
"jdenticon": "^3.2.0",
|
|
41
41
|
"keyborg": "^2.0.0",
|
|
42
42
|
"react-i18next": "^11.18.6",
|
|
43
|
-
"@dxos/react-hooks": "0.3.3-main.
|
|
44
|
-
"@dxos/react-input": "0.3.3-main.
|
|
45
|
-
"@dxos/react-list": "0.3.3-main.
|
|
46
|
-
"@dxos/react-ui-types": "0.3.3-main.
|
|
43
|
+
"@dxos/react-hooks": "0.3.3-main.55fdeb1",
|
|
44
|
+
"@dxos/react-input": "0.3.3-main.55fdeb1",
|
|
45
|
+
"@dxos/react-list": "0.3.3-main.55fdeb1",
|
|
46
|
+
"@dxos/react-ui-types": "0.3.3-main.55fdeb1"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@dnd-kit/core": "^6.0.5",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"react-dom": "^18.2.0",
|
|
59
59
|
"vite": "^4.3.9",
|
|
60
60
|
"vite-plugin-turbosnap": "^1.0.2",
|
|
61
|
-
"@dxos/react-ui-theme": "0.3.3-main.
|
|
61
|
+
"@dxos/react-ui-theme": "0.3.3-main.55fdeb1"
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
64
64
|
"@phosphor-icons/react": "^2.0.5",
|
|
@@ -2,12 +2,19 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { DotsSixVertical, DotsThreeVertical } from '@phosphor-icons/react';
|
|
5
|
+
import { DotsSixVertical, DotsThreeVertical, type Icon } from '@phosphor-icons/react';
|
|
6
6
|
import { type Primitive } from '@radix-ui/react-primitive';
|
|
7
|
-
import React, {
|
|
7
|
+
import React, {
|
|
8
|
+
type ComponentPropsWithoutRef,
|
|
9
|
+
type ComponentPropsWithRef,
|
|
10
|
+
type FC,
|
|
11
|
+
forwardRef,
|
|
12
|
+
type PropsWithChildren,
|
|
13
|
+
} from 'react';
|
|
8
14
|
|
|
9
15
|
import { useDensityContext, useThemeContext } from '../../hooks';
|
|
10
16
|
import { type ThemedClassName } from '../../util';
|
|
17
|
+
import { DropdownMenu } from '../DropdownMenu';
|
|
11
18
|
|
|
12
19
|
type CardRootProps = ThemedClassName<ComponentPropsWithRef<typeof Primitive.div>> & {
|
|
13
20
|
grow?: boolean;
|
|
@@ -65,17 +72,42 @@ const CardDragHandle: FC<CardDragHandleProps> = ({ position, classNames, ...prop
|
|
|
65
72
|
);
|
|
66
73
|
};
|
|
67
74
|
|
|
68
|
-
type
|
|
75
|
+
type CardEndcapProps = ThemedClassName<ComponentPropsWithoutRef<'div'>> & { Icon: Icon; position?: 'left' | 'right' };
|
|
69
76
|
|
|
70
|
-
const
|
|
77
|
+
const CardEndcap: FC<CardEndcapProps> = ({ Icon, position, classNames, ...props }) => {
|
|
71
78
|
const { tx } = useThemeContext();
|
|
72
79
|
const density = useDensityContext();
|
|
73
80
|
return (
|
|
74
|
-
<div {...props} className={tx('card.menu', 'card', { density, position }, classNames)}
|
|
75
|
-
<
|
|
81
|
+
<div {...props} className={tx('card.menu', 'card', { density, position }, classNames)}>
|
|
82
|
+
<Icon className={tx('card.menuIcon', 'card')} />
|
|
76
83
|
</div>
|
|
77
84
|
);
|
|
78
|
-
}
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
type CardMenuProps = PropsWithChildren<
|
|
88
|
+
ThemedClassName<ComponentPropsWithoutRef<'div'>> & { position?: 'left' | 'right' }
|
|
89
|
+
>;
|
|
90
|
+
|
|
91
|
+
// TODO(burdon): Reconcile with Endcap (remove dropdown from here). See ListItem.Endcap (style icon/size?)
|
|
92
|
+
const CardMenu = forwardRef<HTMLDivElement, CardMenuProps>(
|
|
93
|
+
({ children, position, classNames, ...props }, forwardRef) => {
|
|
94
|
+
const { tx } = useThemeContext();
|
|
95
|
+
const density = useDensityContext();
|
|
96
|
+
return (
|
|
97
|
+
<div {...props} className={tx('card.menu', 'card', { density, position }, classNames)} ref={forwardRef}>
|
|
98
|
+
<DropdownMenu.Root>
|
|
99
|
+
<DropdownMenu.Trigger asChild>
|
|
100
|
+
<DotsThreeVertical className={tx('card.menuIcon', 'card', {})} />
|
|
101
|
+
</DropdownMenu.Trigger>
|
|
102
|
+
{/* TODO(burdon): Position to the left of the menu button. */}
|
|
103
|
+
<DropdownMenu.Content>
|
|
104
|
+
<DropdownMenu.Viewport>{children}</DropdownMenu.Viewport>
|
|
105
|
+
</DropdownMenu.Content>
|
|
106
|
+
</DropdownMenu.Root>
|
|
107
|
+
</div>
|
|
108
|
+
);
|
|
109
|
+
},
|
|
110
|
+
);
|
|
79
111
|
|
|
80
112
|
type CardBodyProps = ThemedClassName<ComponentPropsWithoutRef<'div'>> & { gutter?: boolean };
|
|
81
113
|
|
|
@@ -105,6 +137,7 @@ export const Card = {
|
|
|
105
137
|
Root: CardRoot,
|
|
106
138
|
Header: CardHeader,
|
|
107
139
|
DragHandle: CardDragHandle,
|
|
140
|
+
Endcap: CardEndcap,
|
|
108
141
|
Menu: CardMenu,
|
|
109
142
|
Title: CardTitle,
|
|
110
143
|
Body: CardBody,
|
|
@@ -131,8 +131,6 @@ type MainSidebarProps = ThemedClassName<ComponentPropsWithRef<typeof DialogConte
|
|
|
131
131
|
side: 'inline-start' | 'inline-end';
|
|
132
132
|
};
|
|
133
133
|
|
|
134
|
-
// TODO(burdon): Factor out Sidebar?
|
|
135
|
-
// TODO(burdon): Style left/right sidebar differently.
|
|
136
134
|
const MainSidebar = forwardRef<HTMLDivElement, MainSidebarProps>(
|
|
137
135
|
({ classNames, children, swipeToDismiss, onOpenAutoFocus, open, setOpen, side, ...props }, forwardedRef) => {
|
|
138
136
|
const [isLg] = useMediaQuery('lg', { ssr: false });
|
|
@@ -259,9 +257,9 @@ const MainOverlay = forwardRef<HTMLDivElement, MainOverlayProps>(({ classNames,
|
|
|
259
257
|
});
|
|
260
258
|
|
|
261
259
|
export const Main = {
|
|
260
|
+
Root: MainRoot,
|
|
262
261
|
Content: MainContent,
|
|
263
262
|
Overlay: MainOverlay,
|
|
264
|
-
Root: MainRoot,
|
|
265
263
|
NavigationSidebar: MainNavigationSidebar,
|
|
266
264
|
ComplementarySidebar: MainComplementarySidebar,
|
|
267
265
|
};
|