@dxos/react-ui-stack 0.7.5-main.9cb18ac → 0.7.5-main.9d2a38b
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 +18 -17
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +8 -7
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +18 -17
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/components/StackItem.d.ts +7 -1
- package/dist/types/src/components/StackItem.d.ts.map +1 -1
- package/dist/types/src/components/StackItemContent.d.ts +35 -2
- package/dist/types/src/components/StackItemContent.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +20 -20
- package/src/components/StackItemContent.tsx +45 -27
- package/src/components/StackItemHeading.tsx +1 -1
- package/src/components/StackItemSigil.tsx +1 -1
- package/dist/types/src/testing/EditorContent.d.ts +0 -8
- package/dist/types/src/testing/EditorContent.d.ts.map +0 -1
- package/src/testing/EditorContent.tsx +0 -60
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import React, { type ComponentPropsWithoutRef } from 'react';
|
|
5
|
+
import React, { type ComponentPropsWithoutRef, forwardRef } from 'react';
|
|
6
6
|
|
|
7
7
|
import { type ThemedClassName } from '@dxos/react-ui';
|
|
8
8
|
import { mx } from '@dxos/react-ui-theme';
|
|
@@ -10,33 +10,51 @@ import { mx } from '@dxos/react-ui-theme';
|
|
|
10
10
|
import { useStack } from './StackContext';
|
|
11
11
|
|
|
12
12
|
export type StackItemContentProps = ThemedClassName<ComponentPropsWithoutRef<'div'>> & {
|
|
13
|
-
|
|
13
|
+
/**
|
|
14
|
+
* This flag is required in order to clarify a developer experience that seemed like it needed extra boilerplate
|
|
15
|
+
* (`row-span-2`) or was buggy. See the description of the StackItem.Content component itself for more information.
|
|
16
|
+
*/
|
|
17
|
+
toolbar: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Whether to provide for the layout of a statusbar after the content.
|
|
20
|
+
*/
|
|
14
21
|
statusbar?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Whether to set a certain aspect ratio on the content, including the toolbar and statusbar. This is provided for
|
|
24
|
+
* convenience and consistency; it can instead be specified by the `classNames` or `style` props as needed.
|
|
25
|
+
*/
|
|
26
|
+
size?: 'intrinsic' | 'video' | 'square';
|
|
15
27
|
};
|
|
16
28
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
...props
|
|
23
|
-
|
|
24
|
-
const { size } = useStack();
|
|
29
|
+
/**
|
|
30
|
+
* This component should be used by plugins for rendering content within a stack item, a.k.a. a “plank” or “section”.
|
|
31
|
+
* The `toolbar` flag must be provided since this component provides for the layout of content with the toolbar.
|
|
32
|
+
*/
|
|
33
|
+
export const StackItemContent = forwardRef<HTMLDivElement, StackItemContentProps>(
|
|
34
|
+
({ children, toolbar, statusbar, classNames, size = 'intrinsic', ...props }, forwardedRef) => {
|
|
35
|
+
const { size: stackItemSize } = useStack();
|
|
25
36
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
37
|
+
return (
|
|
38
|
+
<div
|
|
39
|
+
role='none'
|
|
40
|
+
{...props}
|
|
41
|
+
className={mx(
|
|
42
|
+
'group grid grid-cols-[100%]',
|
|
43
|
+
stackItemSize === 'contain' && 'min-bs-0 overflow-hidden',
|
|
44
|
+
size === 'video' ? 'aspect-video' : size === 'square' && 'aspect-square',
|
|
45
|
+
classNames,
|
|
46
|
+
)}
|
|
47
|
+
style={{
|
|
48
|
+
gridTemplateRows: [
|
|
49
|
+
...(toolbar ? ['var(--rail-action)'] : []),
|
|
50
|
+
'1fr',
|
|
51
|
+
...(statusbar ? ['var(--statusbar-size)'] : []),
|
|
52
|
+
].join(' '),
|
|
53
|
+
}}
|
|
54
|
+
ref={forwardedRef}
|
|
55
|
+
>
|
|
56
|
+
{children}
|
|
57
|
+
</div>
|
|
58
|
+
);
|
|
59
|
+
},
|
|
60
|
+
);
|
|
@@ -43,7 +43,7 @@ export const StackItemHeadingLabel = forwardRef<HTMLHeadingElement, StackItemHea
|
|
|
43
43
|
{...props}
|
|
44
44
|
data-attention={((related && isRelated) || hasAttention || isAncestor).toString()}
|
|
45
45
|
className={mx(
|
|
46
|
-
'pli-1 min-is-0 is-0 grow truncate font-medium text-baseText data-[attention=true]:text-accentText',
|
|
46
|
+
'pli-1 min-is-0 is-0 grow truncate font-medium text-baseText data-[attention=true]:text-accentText self-center',
|
|
47
47
|
classNames,
|
|
48
48
|
)}
|
|
49
49
|
ref={forwardedRef}
|
|
@@ -42,7 +42,7 @@ export const StackItemSigilButton = forwardRef<HTMLButtonElement, StackItemSigil
|
|
|
42
42
|
<Button
|
|
43
43
|
{...props}
|
|
44
44
|
variant={variant}
|
|
45
|
-
classNames={['
|
|
45
|
+
classNames={['shrink-0 pli-0 min-bs-0 is-[--rail-action] bs-[--rail-action] relative', classNames]}
|
|
46
46
|
ref={forwardedRef}
|
|
47
47
|
>
|
|
48
48
|
<MenuSignifierHorizontal />
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { type StackItemContentProps } from '../components';
|
|
3
|
-
export declare const EditorContent: ({ data: { content } }: {
|
|
4
|
-
data: StackItemContentProps & {
|
|
5
|
-
content?: string;
|
|
6
|
-
};
|
|
7
|
-
}) => React.JSX.Element;
|
|
8
|
-
//# sourceMappingURL=EditorContent.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EditorContent.d.ts","sourceRoot":"","sources":["../../../../src/testing/EditorContent.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAkBxC,OAAO,EAAa,KAAK,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAEtE,eAAO,MAAM,aAAa,0BAAgC;IAAE,IAAI,EAAE,qBAAqB,GAAG;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,sBAmC/G,CAAC"}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import React, { useState } from 'react';
|
|
6
|
-
|
|
7
|
-
import { Expando } from '@dxos/echo-schema';
|
|
8
|
-
import { create } from '@dxos/live-object';
|
|
9
|
-
import { useThemeContext } from '@dxos/react-ui';
|
|
10
|
-
import {
|
|
11
|
-
createBasicExtensions,
|
|
12
|
-
createMarkdownExtensions,
|
|
13
|
-
createThemeExtensions,
|
|
14
|
-
decorateMarkdown,
|
|
15
|
-
formattingKeymap,
|
|
16
|
-
Toolbar,
|
|
17
|
-
useActionHandler,
|
|
18
|
-
useFormattingState,
|
|
19
|
-
useTextEditor,
|
|
20
|
-
} from '@dxos/react-ui-editor';
|
|
21
|
-
import { focusRing, mx, textBlockWidth } from '@dxos/react-ui-theme';
|
|
22
|
-
|
|
23
|
-
import { StackItem, type StackItemContentProps } from '../components';
|
|
24
|
-
|
|
25
|
-
export const EditorContent = ({ data: { content = '' } }: { data: StackItemContentProps & { content?: string } }) => {
|
|
26
|
-
const { themeMode } = useThemeContext();
|
|
27
|
-
const [text] = useState(create(Expando, { content }));
|
|
28
|
-
const id = text.id;
|
|
29
|
-
const [formattingState, formattingObserver] = useFormattingState();
|
|
30
|
-
const { parentRef, view, focusAttributes } = useTextEditor(() => {
|
|
31
|
-
return {
|
|
32
|
-
id,
|
|
33
|
-
initialValue: text.content,
|
|
34
|
-
extensions: [
|
|
35
|
-
formattingObserver,
|
|
36
|
-
createBasicExtensions(),
|
|
37
|
-
createMarkdownExtensions({ themeMode }),
|
|
38
|
-
createThemeExtensions({ themeMode, syntaxHighlighting: true, slots: { editor: { className: 'p-2' } } }),
|
|
39
|
-
decorateMarkdown(),
|
|
40
|
-
formattingKeymap(),
|
|
41
|
-
],
|
|
42
|
-
};
|
|
43
|
-
}, [id, formattingObserver, themeMode]);
|
|
44
|
-
|
|
45
|
-
const handleAction = useActionHandler(view);
|
|
46
|
-
|
|
47
|
-
return (
|
|
48
|
-
<StackItem.Content>
|
|
49
|
-
<div {...focusAttributes} className={mx(textBlockWidth, focusRing, 'rounded-sm order-last')} ref={parentRef} />
|
|
50
|
-
<Toolbar.Root
|
|
51
|
-
onAction={handleAction}
|
|
52
|
-
state={formattingState}
|
|
53
|
-
classNames='sticky block-start-0 bg-[--sticky-bg] z-10'
|
|
54
|
-
>
|
|
55
|
-
<Toolbar.Markdown />
|
|
56
|
-
<Toolbar.Separator />
|
|
57
|
-
</Toolbar.Root>
|
|
58
|
-
</StackItem.Content>
|
|
59
|
-
);
|
|
60
|
-
};
|