Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

add preview project block from soup and project block (#536)

Caleb Taylor2d0615efff58
diff --git a/js/app/packages/app/component/PreviewPanel.tsx b/js/app/packages/app/component/PreviewPanel.tsx
new file mode 100644
index 0000000000..d242c8102b
--- /dev/null
+++ b/js/app/packages/app/component/PreviewPanel.tsx
@@ -0,0 +1,175 @@
+import type { BlockAliasContext } from '@core/block';
+import { fileTypeToResolvedBlockName } from '@core/constant/allBlocks';
+import { useHotkeyDOMScope } from '@core/hotkey/hotkeys';
+import type { BlockOrchestrator } from '@core/orchestrator';
+import type { NonNullableFields } from '@core/util/withRequired';
+import { type EntityData, isTaskEntity } from '@macro-entity';
+import {
+ type Component,
+ createMemo,
+ createRenderEffect,
+ createSignal,
+ onCleanup,
+ onMount,
+ Show,
+} from 'solid-js';
+import { Dynamic } from 'solid-js/web';
+import {
+ createNavigationEntityListShortcut,
+ createSoupContext,
+} from './SoupContext';
+import {
+ SplitPanelContext,
+ type SplitPanelContextType,
+} from './split-layout/context';
+import { useSplitLayout } from './split-layout/layout';
+import { useSplitPanelOrThrow } from './split-layout/layoutUtils';
+
+type PreviewPanel = {
+ selectedEntity: EntityData | undefined;
+ orchestrator: BlockOrchestrator;
+ splitPanelContext: SplitPanelContextType;
+};
+
+const PreviewPanelContent: Component<NonNullableFields<PreviewPanel>> = (
+ props
+) => {
+ const [containerRef, setContainerRef] = createSignal<HTMLDivElement | null>(
+ null
+ );
+ let scopedSplitPanelContextType: SplitPanelContextType = {} as any;
+ const splitPanelContext = useSplitPanelOrThrow();
+
+ if (props.selectedEntity.type === 'project') {
+ const { getSplitCount } = useSplitLayout();
+ const soupContext = createSoupContext({
+ isRenderedFromPreview: true,
+ parentContext: splitPanelContext.soupContext,
+ domRef: containerRef,
+ });
+
+ const [attachHotKeys, splitHotkeyScope] = useHotkeyDOMScope(
+ `split=${splitPanelContext.splitHotkeyScope}`
+ );
+
+ const [previewState, setPreviewState] = createSignal(false);
+ const splitName = createMemo(() => {
+ const { type, id } = splitPanelContext.handle.content();
+ if (type === 'component') return id;
+
+ return type;
+ });
+
+ createNavigationEntityListShortcut({
+ splitName,
+ splitHandle: splitPanelContext.handle,
+ splitHotkeyScope,
+ soupContext,
+ previewState: [previewState, setPreviewState],
+ getSplitCount: getSplitCount,
+ });
+ scopedSplitPanelContextType.soupContext = soupContext;
+ scopedSplitPanelContextType.previewState = [previewState, setPreviewState];
+
+ onMount(() => {
+ attachHotKeys(containerRef()!);
+ });
+ }
+
+ const blockInstance = () => {
+ const aliasContext = isTaskEntity(props.selectedEntity)
+ ? ({
+ alias: 'task',
+ baseType: 'md',
+ } as BlockAliasContext)
+ : undefined;
+ return props.orchestrator.createBlockInstance(
+ props.selectedEntity.type === 'document'
+ ? fileTypeToResolvedBlockName(props.selectedEntity.fileType)
+ : props.selectedEntity.type,
+ props.selectedEntity.id,
+ { aliasContext }
+ );
+ };
+ const [interactedWith, setInteractedWith] = createSignal(false);
+
+ createRenderEffect((prevId: string) => {
+ const id = props.selectedEntity.id;
+ if (id !== prevId) {
+ setInteractedWith(false);
+ }
+ return id;
+ }, props.selectedEntity.id);
+
+ createRenderEffect(() => {
+ // Temporary fix to prevent toolbarLeft overlapping right content
+ if (!splitPanelContext.layoutRefs.toolbarLeft) return;
+ splitPanelContext.layoutRefs.toolbarLeft.style.maxWidth = `${splitPanelContext.halfSplitState?.()?.percentage ?? 30}%`;
+ onCleanup(() => {
+ if (!splitPanelContext.layoutRefs.toolbarLeft) return;
+ splitPanelContext.layoutRefs.toolbarLeft.style.maxWidth = '';
+ });
+ });
+
+ return (
+ <div
+ class="size-full"
+ onFocusIn={(event) => {
+ if (interactedWith()) return;
+ const relatedTarget = event.relatedTarget;
+ const currentTarget = event.currentTarget;
+
+ // TODO: use state instead to determine when preview block can recieve focus
+ if (event.target.hasAttribute('data-allow-focus-in-preview')) {
+ setInteractedWith(true);
+ return;
+ }
+
+ if (relatedTarget instanceof HTMLElement) {
+ if (!currentTarget.contains(relatedTarget)) {
+ relatedTarget.focus();
+ }
+ }
+ }}
+ onPointerDown={() => {
+ setInteractedWith(true);
+ }}
+ tabIndex={-1}
+ ref={setContainerRef}
+ >
+ <SplitPanelContext.Provider
+ value={{
+ ...props.splitPanelContext,
+ ...scopedSplitPanelContextType,
+ layoutRefs: {
+ ...props.splitPanelContext.layoutRefs,
+ headerLeft: undefined,
+ headerRight: undefined,
+ },
+ halfSplitState: () => ({
+ side: 'right',
+ percentage: 30,
+ }),
+ }}
+ >
+ <Dynamic component={blockInstance().element} />
+ </SplitPanelContext.Provider>
+ </div>
+ );
+};
+
+export const PreviewPanel: Component<PreviewPanel> = (props) => {
+ return (
+ <div class="flex flex-row size-full sm:w-[70%] max-sm:h-[50%] max-sm:border-t border-edge-muted shrink-0">
+ <Show when={props.selectedEntity}>
+ {(selectedEntity) => (
+ <PreviewPanelContent
+ selectedEntity={selectedEntity()}
+ orchestrator={props.orchestrator}
+ splitPanelContext={props.splitPanelContext}
+ />
+ )}
+ </Show>
+ </div>
+ );
+};
diff --git a/js/app/packages/app/component/Soup.tsx b/js/app/packages/app/component/Soup.tsx
index e911bd6959..55490a460c 100644
--- a/js/app/packages/app/component/Soup.tsx
+++ b/js/app/packages/app/component/Soup.tsx
@@ -5,18 +5,15 @@ import {
import { useHandleFileUpload } from '@app/util/handleFileUpload';
import { playSound } from '@app/util/sound';
import { useIsAuthenticated } from '@core/auth';
-import type { BlockAliasContext } from '@core/block';
import { FileDropOverlay } from '@core/component/FileDropOverlay';
import { DeprecatedButton } from '@core/component/FormControls/DeprecatedButton';
import { SegmentedControl } from '@core/component/FormControls/SegmentControls';
import { ContextMenuContent, MenuItem } from '@core/component/Menu';
-import { fileTypeToResolvedBlockName } from '@core/constant/allBlocks';
import { fileFolderDrop } from '@core/directive/fileFolderDrop';
import { TOKENS } from '@core/hotkey/tokens';
import type { RegisterHotkeyReturn } from '@core/hotkey/types';
import { isTouchDevice } from '@core/mobile/isTouchDevice';
import { isMobileWidth } from '@core/mobile/mobileWidth';
-import type { BlockOrchestrator } from '@core/orchestrator';
import {
DEFAULT_VIEWS,
type DefaultView,
@@ -26,9 +23,7 @@ import {
import { handleFileFolderDrop } from '@core/util/upload';
import { ContextMenu } from '@kobalte/core/context-menu';
import { Tabs } from '@kobalte/core/tabs';
-import type { EntityData } from '@macro-entity';
import {
- isTaskEntity,
queryKeys,
useQueryClient as useEntityQueryClient,
} from '@macro-entity';
@@ -43,7 +38,6 @@ import {
type Component,
createEffect,
createMemo,
- createRenderEffect,
createSignal,
For,
Match,
@@ -52,14 +46,13 @@ import {
Show,
Switch,
} from 'solid-js';
-import { Dynamic } from 'solid-js/web';
import { EntityModal } from './EntityModal/EntityModal';
import { HelpDrawer } from './HelpDrawer';
+import { PreviewPanel } from './PreviewPanel';
import { SuspenseContextComp } from './SuspenseContext';
import { SplitHeaderLeft } from './split-layout/components/SplitHeader';
import { SplitTabs } from './split-layout/components/SplitTabs';
import { SplitToolbarRight } from './split-layout/components/SplitToolbar';
-import type { SplitPanelContextType } from './split-layout/context';
import { SplitPanelContext } from './split-layout/context';
import { useSplitPanelOrThrow } from './split-layout/layoutUtils';
import { UnifiedListView } from './UnifiedListView';
@@ -129,102 +122,6 @@ const ViewWithSearch: Component<{
);
};
-const PreviewPanelContent: Component<{
- selectedEntity: EntityData;
- orchestrator: BlockOrchestrator;
- splitPanelContext: SplitPanelContextType;
-}> = (props) => {
- const blockInstance = () => {
- const aliasContext = isTaskEntity(props.selectedEntity)
- ? ({
- alias: 'task',
- baseType: 'md',
- } as BlockAliasContext)
- : undefined;
- return props.orchestrator.createBlockInstance(
- props.selectedEntity.type === 'document'
- ? fileTypeToResolvedBlockName(props.selectedEntity.fileType)
- : props.selectedEntity.type,
- props.selectedEntity.id,
- { aliasContext }
- );
- };
- const [interactedWith, setInteractedWith] = createSignal(false);
-
- createRenderEffect((prevId: string) => {
- const id = props.selectedEntity.id;
- if (id !== prevId) {
- setInteractedWith(false);
- }
- return id;
- }, props.selectedEntity.id);
-
- return (
- <div
- class="size-full"
- onFocusIn={(event) => {
- if (interactedWith()) return;
- const relatedTarget = event.relatedTarget;
- const currentTarget = event.currentTarget;
-
- // TODO: use state instead to determine when preview block can recieve focus
- if (event.target.hasAttribute('data-allow-focus-in-preview')) {
- setInteractedWith(true);
- return;
- }
-
- if (relatedTarget instanceof HTMLElement) {
- if (!currentTarget.contains(relatedTarget)) {
- relatedTarget.focus();
- }
- }
- }}
- onPointerDown={() => {
- setInteractedWith(true);
- }}
- >
- <SplitPanelContext.Provider
- value={{
- ...props.splitPanelContext,
- layoutRefs: {
- ...props.splitPanelContext.layoutRefs,
- headerLeft: undefined,
- headerRight: undefined,
- },
- halfSplitState: () => ({
- side: 'right',
- percentage: 30,
- }),
- }}
- >
- <Dynamic component={blockInstance().element} />
- </SplitPanelContext.Provider>
- </div>
- );
-};
-
-const PreviewPanel: Component<{
- selectedEntity: EntityData | undefined;
- orchestrator: BlockOrchestrator;
- splitPanelContext: SplitPanelContextType;
-}> = (props) => {
- return (
- <div class="flex flex-row size-full sm:w-[70%] max-sm:h-[50%] max-sm:border-t border-edge-muted shrink-0">
- <Show
- when={props.selectedEntity?.type !== 'project' && props.selectedEntity}
- >
- {(selectedEntity) => (
- <PreviewPanelContent
- selectedEntity={selectedEntity()}
- orchestrator={props.orchestrator}
- splitPanelContext={props.splitPanelContext}
- />
- )}
- </Show>
- </div>
- );
-};
-
export function Soup() {
const authenticated = useIsAuthenticated();
if (!authenticated()) return <Navigate href="/" />;
diff --git a/js/app/packages/app/component/SoupContext.tsx b/js/app/packages/app/component/SoupContext.tsx
index 091bd5cae1..44bf757265 100644
--- a/js/app/packages/app/component/SoupContext.tsx
+++ b/js/app/packages/app/component/SoupContext.tsx
@@ -5,7 +5,7 @@ import { HotkeyTags } from '@core/hotkey/constants';
import { activeScope, hotkeyScopeTree } from '@core/hotkey/state';
import { TOKENS } from '@core/hotkey/tokens';
import type { ValidHotkey } from '@core/hotkey/types';
-import { runCommand } from '@core/hotkey/utils';
+import { getActiveCommandByToken, runCommand } from '@core/hotkey/utils';
import { isModality } from '@core/mobile/inputModality';
import { DEFAULT_VIEWS, type DefaultView, type ViewId } from '@core/types/view';
import { getActualTarget } from '@core/util/getActualTarget';
@@ -97,6 +97,7 @@ export type SoupContext = {
showHelpDrawer: Accessor<Set<DefaultView>>;
setShowHelpDrawer: Setter<Set<DefaultView>>;
actionRegistry: EntityActionRegistry;
+ isRenderedFromPreview: boolean;
navigateThroughList: NavigateListFn;
// this is a private method that should be registered once by createNavigationEntityListShortcut
_setNavigateThroughList: (fn: NavigateListFn) => void;
@@ -104,6 +105,10 @@ export type SoupContext = {
* Optional hook to animate an entity row collapsing before the entity disappears from the list. This gets set by the EntityRowProvider.
*/
collapseEntitySignal: Signal<CollapseEntityFn | undefined>;
+ parentContextSignal: Signal<SoupContext | undefined>;
+ childContextSignal: Signal<SoupContext | undefined>;
+ activeContextSignal: Signal<SoupContext | undefined>;
+ domRef: Accessor<HTMLDivElement | null>;
};
export function createStubSoupContext(): SoupContext {
@@ -126,6 +131,12 @@ export function createStubSoupContext(): SoupContext {
}),
_setNavigateThroughList: () => {},
collapseEntitySignal: createSignal<CollapseEntityFn | undefined>(undefined),
+
+ isRenderedFromPreview: false,
+ parentContextSignal: createSignal<SoupContext | undefined>(undefined),
+ childContextSignal: createSignal<SoupContext | undefined>(undefined),
+ activeContextSignal: createSignal<SoupContext | undefined>(undefined),
+ domRef: () => null,
};
}
@@ -133,7 +144,16 @@ const DEFAULT_VIEW_ID: DefaultView = 'signal';
const DEFAULT_VIEW_IDS_SET = new Set(VIEWCONFIG_DEFAULTS_IDS);
-export function createSoupContext(): SoupContext {
+type CreateSoupContextProps = {
+ splitId?: string;
+ domRef: Accessor<HTMLDivElement | null>;
+ isRenderedFromPreview?: boolean;
+ parentContext?: SoupContext;
+};
+
+const splitIdSoupContextMapper = new Map<string, SoupContext>();
+
+export function createSoupContext(props: CreateSoupContextProps): SoupContext {
const [selectedView, setSelectedView] = createSignal<ViewId>(DEFAULT_VIEW_ID);
const [viewsDataStore, setViewDataStore] = useAllViews({
selectedViewSignal: [selectedView, setSelectedView],
@@ -151,7 +171,15 @@ export function createSoupContext(): SoupContext {
);
let navigateThroughListFn: NavigateListFn | undefined;
- return {
+ const parentContextSignal = createSignal<SoupContext | undefined>(
+ props?.parentContext
+ );
+ const childContextSignal = createSignal<SoupContext | undefined>(undefined);
+ const activeContextSignal =
+ props?.parentContext?.activeContextSignal ??
+ createSignal<SoupContext | undefined>(undefined);
+
+ const context: SoupContext = {
viewsDataStore,
setViewDataStore,
selectedView,
@@ -164,6 +192,10 @@ export function createSoupContext(): SoupContext {
showHelpDrawer,
setShowHelpDrawer,
actionRegistry: createEntityActionRegistry(),
+ isRenderedFromPreview: props?.isRenderedFromPreview ?? false,
+ parentContextSignal,
+ childContextSignal,
+ activeContextSignal,
navigateThroughList: (input) => {
if (!navigateThroughListFn) {
throw new Error('navigateThroughList not initialized');
@@ -176,7 +208,33 @@ export function createSoupContext(): SoupContext {
}
navigateThroughListFn = fn;
},
+ domRef: props?.domRef!,
};
+
+ if (props.splitId) {
+ splitIdSoupContextMapper.set(props.splitId, context);
+ }
+
+ onCleanup(() => {
+ const [parentContext] = parentContextSignal;
+ parentContext()?.childContextSignal[1](undefined);
+ if (activeContextSignal[0]() === context) {
+ activeContextSignal[1](parentContext);
+ }
+ if (props.splitId) {
+ splitIdSoupContextMapper.delete(props.splitId);
+ }
+ });
+
+ if (!activeContextSignal[0]()) {
+ activeContextSignal[1](context);
+ }
+
+ if (props?.parentContext) {
+ props.parentContext.childContextSignal[1](context);
+ }
+
+ return context;
}
function createViewData(
@@ -255,6 +313,7 @@ export function createNavigationEntityListShortcut({
previewState,
getSplitCount,
}: {
+ splitName: Accessor<string>;
splitHandle: SplitHandle;
splitHotkeyScope: string;
soupContext: SoupContext;
@@ -270,6 +329,9 @@ export function createNavigationEntityListShortcut({
setSelectedView,
entitiesSignal: [entities],
actionRegistry,
+ parentContextSignal: [getParentContext],
+ childContextSignal: [getChildContext],
+ activeContextSignal: [, setActiveContext],
} = soupContext;
const viewData = createMemo(() => viewsData[selectedView()]);
const viewIds = createMemo<ViewId[]>(() => Object.keys(viewsData));
@@ -291,7 +353,10 @@ export function createNavigationEntityListShortcut({
const userId = useUserId();
const isViewingList = createMemo(() => {
- return splitHandle.content().id === 'unified-list';
+ return (
+ splitHandle.content().id === 'unified-list' ||
+ splitHandle.content().type === 'project'
+ );
});
const canAccessEntityList = () => {
if (isViewingList()) return true;
@@ -1251,6 +1316,66 @@ export function createNavigationEntityListShortcut({
hide: true,
});
+ registerEntityHotkey({
+ hotkey: ['h', 'arrowleft'],
+ scopeId: splitHotkeyScope,
+ description: 'Navigate to parent context',
+ hotkeyToken: TOKENS.unifiedList.navigation.parent,
+ keyDownHandler: () => {
+ const parentContext = getParentContext();
+
+ if (!parentContext) {
+ const [preview] = previewState;
+ if (!preview()) {
+ const command = getActiveCommandByToken(TOKENS.split.goHome);
+ if (command) {
+ runCommand(command);
+ }
+ }
+ return true;
+ }
+ setActiveContext(parentContext);
+
+ const parentDomRef = parentContext.domRef();
+
+ if (parentDomRef) {
+ parentDomRef.focus();
+ return true;
+ }
+
+ return false;
+ },
+ canExecuteKeyDownHandler: () => {
+ return isViewingList();
+ },
+ hide: true,
+ });
+
+ registerEntityHotkey({
+ hotkey: ['l', 'arrowright'],
+ scopeId: splitHotkeyScope,
+ description: 'Navigate to child context',
+ hotkeyToken: TOKENS.unifiedList.navigation.child,
+ keyDownHandler: () => {
+ const childContext = getChildContext();
+ if (!childContext) return false;
+ setActiveContext(childContext);
+
+ const childDomRef = childContext.domRef();
+
+ if (childDomRef) {
+ childDomRef.setAttribute('data-allow-focus-in-preview', '');
+ childDomRef.focus();
+ return true;
+ }
+ return false;
+ },
+ canExecuteKeyDownHandler: () => {
+ return isViewingList() && getChildContext() !== undefined;
+ },
+ hide: true,
+ });
+
const navigateThroughViews = ({
axis,
}: {
@@ -1625,9 +1750,9 @@ function registerEntityHotkey(
const currentActiveSplitId = globalSplitManager()?.activeSplitId();
const getCommand = () => {
- const splitScope = document.querySelector(
- `[data-split-id="${currentActiveSplitId}"]`
- );
+ const soupContext = splitIdSoupContextMapper.get(currentActiveSplitId!);
+ const activeSoupContext = soupContext?.activeContextSignal[0]?.();
+ const splitScope = activeSoupContext?.domRef();
if (!splitScope || !(splitScope instanceof HTMLElement)) return;
const scopeId = splitScope.dataset.hotkeyScope;
if (!scopeId) return undefined;
diff --git a/js/app/packages/app/component/UnifiedListView.tsx b/js/app/packages/app/component/UnifiedListView.tsx
index b892056e3e..b387d77d1c 100644
--- a/js/app/packages/app/component/UnifiedListView.tsx
+++ b/js/app/packages/app/component/UnifiedListView.tsx
@@ -50,7 +50,6 @@ import {
createUnifiedInfiniteList,
createUnifiedSearchInfiniteQuery,
Entity,
- type EntityClickHandler,
type EntityData,
type EntityFilter,
type ExpandedEntityType,
@@ -115,9 +114,10 @@ import {
type SetStoreFunction,
unwrap,
} from 'solid-js/store';
-import type { EntityPointerDownHandler } from '../../macro-entity/src/components/Entity';
import {
ENTITY_HEIGHT,
+ type EntityClickHandler,
+ type EntityPointerDownHandler,
EntityWithEverything,
} from '../../macro-entity/src/components/EntityWithEverything';
import {
@@ -206,7 +206,7 @@ export type UnifiedListViewProps = {
defaultFilterOptions?: Partial<FilterOptions>;
defaultSortOptions?: Partial<SortOptions>;
defaultDisplayOptions?: Partial<DisplayOptions>;
- hideToolbar?: true;
+ hideToolbar?: boolean;
};
export function UnifiedListView(props: UnifiedListViewProps) {
const [contextAndModalState, setContextAndModalState] = createStore<{
@@ -251,6 +251,7 @@ export function UnifiedListView(props: UnifiedListViewProps) {
entityListRefSignal: [, setEntityListRef],
entitiesSignal: [entities_, setEntities],
emailViewSignal: [emailView],
+ activeContextSignal: [activeSoupContext, setActiveSoupContext],
} = soupContext;
// Properties for task entities
@@ -1217,23 +1218,24 @@ export function UnifiedListView(props: UnifiedListViewProps) {
window.open(entityUrl.toString(), '_blank', 'noopener');
};
- const entityClickHandler: EntityClickHandler<EntityData> = async (
- entity,
- event,
- location,
- options
- ) => {
- if (preview() && !options?.ignorePreview) {
- setSelectedEntity(entity);
+ const entityClickHandler: EntityClickHandler<EntityData> = async (args) => {
+ const { type, event, location } = args;
- return;
- }
+ const entity = (
+ type === 'entity' ? args.entity : args.projectEntity
+ ) as EntityData;
if (event.metaKey || event.ctrlKey) {
openEntityInNewTab({ entity, location });
return;
}
+ if (preview() && type === 'entity') {
+ setSelectedEntity(entity);
+
+ return;
+ }
+
await openEntityInSplitFromUnifiedList(entity, {
openInNewSplit: event.altKey,
location,
@@ -1241,16 +1243,30 @@ export function UnifiedListView(props: UnifiedListViewProps) {
});
};
- const entityPointerDownHandler: EntityPointerDownHandler<EntityData> = async (
+ const entityDblClickHandler: EntityClickHandler<EntityData> = async ({
entity,
- event,
location,
- options
- ) => {
- if (preview() && !options?.ignorePreview) {
+ event,
+ }) => {
+ if (!preview()) {
return;
}
+ await openEntityInSplitFromUnifiedList(entity, {
+ openInNewSplit: event.altKey,
+ location,
+ splitHandle: splitContext.handle,
+ });
+ };
+
+ const entityPointerDownHandler: EntityPointerDownHandler<EntityData> = async (
+ args
+ ) => {
+ const { type, location, event } = args;
+ const entity = (
+ type === 'entity' ? args.entity : args.projectEntity
+ ) as EntityData;
+
// middle mouse button pressed
if (event.button === 1 && event.pointerType === 'mouse') {
// TODO: current page should remain focused after opening new tab
@@ -1734,7 +1750,15 @@ export function UnifiedListView(props: UnifiedListViewProps) {
});
}}
>
- <ContextMenu.Trigger class="size-full unified-list-root">
+ <ContextMenu.Trigger
+ class="@container/uList size-full unified-list-root"
+ onPointerDown={() => {
+ setActiveSoupContext(soupContext);
+ }}
+ onKeyUp={() => {
+ setActiveSoupContext(soupContext);
+ }}
+ >
<EntityRowProvider
container={localEntityListRef}
canSwipeLeft={(entityId) => {
@@ -1812,6 +1836,7 @@ export function UnifiedListView(props: UnifiedListViewProps) {
properties={properties()}
timestamp={timestamp()}
onClick={entityClickHandler}
+ onDblClick={entityDblClickHandler}
onPointerDown={entityPointerDownHandler}
onClickRowAction={
soupContext.actionRegistry.isActionEnabled(
@@ -1825,7 +1850,7 @@ export function UnifiedListView(props: UnifiedListViewProps) {
}
: undefined
}
- onClickNotification={(notifiedEntity) => {
+ onClickNotification={({ entity: notifiedEntity }) => {
const notification = tryToTypedNotification(
notifiedEntity.notification
);
@@ -1860,11 +1885,15 @@ export function UnifiedListView(props: UnifiedListViewProps) {
highlighted={
isPanelActive() && focusedSelector(innerProps.entity.id)
}
- selected={
- focusedSelector(innerProps.entity.id) ||
- contextAndModalState.selectedEntity?.id ===
- innerProps.entity.id
- }
+ selected={{
+ active:
+ focusedSelector(innerProps.entity.id) ||
+ contextAndModalState.selectedEntity?.id ===
+ innerProps.entity.id,
+ muted:
+ focusedSelector(innerProps.entity.id) &&
+ activeSoupContext() !== soupContext,
+ }}
checked={multiSelectSelector(innerProps.entity.id)}
onChecked={(next, shiftKey) =>
handleMultiSelectChecked({
@@ -2137,7 +2166,7 @@ function SearchBar(props: {
});
return (
- <SplitToolbarLeft>
+ <SplitToolbarLeft class="min-w-0">
<div class="flex ml-2 h-full items-center gap-1">
<Show
when={props.isLoading() && searchText()}
@@ -2206,7 +2235,7 @@ function SearchBar(props: {
focusNextEntity();
}
}}
- class="p-1 pr-0 border-0 outline-none! focus:outline-none ring-0! focus:ring-0 flex-1 text-ink text-sm truncate"
+ class="p-1 pr-0 border-0 outline-none! focus:outline-none ring-0! focus:ring-0 flex-1 text-ink text-sm truncate min-w-0"
/>
</div>
</SplitToolbarLeft>
diff --git a/js/app/packages/app/component/split-layout/SplitLayout.tsx b/js/app/packages/app/component/split-layout/SplitLayout.tsx
index 1e9c28cd41..4357269683 100644
--- a/js/app/packages/app/component/split-layout/SplitLayout.tsx
+++ b/js/app/packages/app/component/split-layout/SplitLayout.tsx
@@ -356,7 +356,10 @@ function SplitPanel(props: SplitPanelProps) {
const panelSize = createElementSize(panelRef);
const [contentOffsetTop, setContentOffsetTop] = createSignal(0);
- const soupContext = createSoupContext();
+ const soupContext = createSoupContext({
+ splitId: props.split.id,
+ domRef: panelRef,
+ });
const [previewState, setPreviewState] = createSignal(false);
@@ -380,13 +383,22 @@ function SplitPanel(props: SplitPanelProps) {
},
});
+ const splitName = createMemo(() => {
+ const { type, id } = props.split.content;
+ if (type === 'component') return id;
+
+ return type;
+ });
+
createNavigationEntityListShortcut({
+ splitName,
splitHandle: props.handle,
splitHotkeyScope,
soupContext,
previewState: [previewState, setPreviewState],
getSplitCount: () => splitLayoutHelpers.getSplitCount(),
});
+
return (
<SplitPanelContext.Provider
value={{
diff --git a/js/app/packages/app/component/split-layout/components/SplitHeader.tsx b/js/app/packages/app/component/split-layout/components/SplitHeader.tsx
index 6e5dd99521..f772d8e302 100644
--- a/js/app/packages/app/component/split-layout/components/SplitHeader.tsx
+++ b/js/app/packages/app/component/split-layout/components/SplitHeader.tsx
@@ -1,6 +1,9 @@
import EntityNavigationIndicator from '@app/component/EntityNavigationIndicator';
import { LabelAndHotKey } from '@core/component/Tooltip';
-import { ENABLE_PREVIEW } from '@core/constant/featureFlags';
+import {
+ ENABLE_PREVIEW,
+ ENABLE_PROJECT_VIEW_PREVIEW,
+} from '@core/constant/featureFlags';
import { TOKENS } from '@core/hotkey/tokens';
import { isTouchDevice } from '@core/mobile/isTouchDevice';
import { isMobileWidth } from '@core/mobile/mobileWidth';
@@ -111,9 +114,10 @@ function SplitPreviewToggle() {
const context = useContext(SplitPanelContext);
if (!ENABLE_PREVIEW || !context || !context.previewState) return null;
- // Only show toggle for unified-list component, not for blocks
+ // Only show toggle for unified-list component and project block
const isUnifiedList = createMemo(() => {
const content = context.handle.content();
+ if (ENABLE_PROJECT_VIEW_PREVIEW && content.type === 'project') return true;
return content.type === 'component' && content.id === 'unified-list';
});
diff --git a/js/app/packages/block-project/component/Block.tsx b/js/app/packages/block-project/component/Block.tsx
index e70f7156f9..59f065e66a 100644
--- a/js/app/packages/block-project/component/Block.tsx
+++ b/js/app/packages/block-project/component/Block.tsx
@@ -1,11 +1,18 @@
+import { useGlobalBlockOrchestrator } from '@app/component/GlobalAppState';
+import { PreviewPanel } from '@app/component/PreviewPanel';
+import { SplitPanelContext } from '@app/component/split-layout/context';
import { useSplitPanelOrThrow } from '@app/component/split-layout/layoutUtils';
import { UnifiedListView } from '@app/component/UnifiedListView';
import { PROJECT_VIEWCONFIG_BASE } from '@app/component/ViewConfig';
+import { playSound } from '@app/util/sound';
import { getIsSpecialProject } from '@block-project/isSpecial';
import { useBlockId } from '@core/block';
import { DocumentBlockContainer } from '@core/component/DocumentBlockContainer';
+import { ENABLE_PROJECT_VIEW_PREVIEW } from '@core/constant/featureFlags';
import { fileFolderDrop } from '@core/directive/fileFolderDrop';
import { fileSelector } from '@core/directive/fileSelector';
+import { registerHotkey } from '@core/hotkey/hotkeys';
+import { TOKENS } from '@core/hotkey/tokens';
import {
handleFileFolderDrop,
type UploadInput,
@@ -20,6 +27,7 @@ import { refetchResources } from '@service-storage/util/refetchResources';
import { toast } from 'core/component/Toast/Toast';
import {
type Component,
+ createMemo,
createRenderEffect,
createSignal,
onCleanup,
@@ -83,9 +91,33 @@ const Block: Component = () => {
}
};
- const splitContext = useSplitPanelOrThrow();
- const { selectedView, setSelectedView, setViewDataStore } =
- splitContext.soupContext;
+ const orchestrator = useGlobalBlockOrchestrator();
+ const splitPanelContext = useSplitPanelOrThrow();
+ const {
+ selectedView,
+ setSelectedView,
+ setViewDataStore,
+ isRenderedFromPreview,
+ viewsDataStore: viewsData,
+ } = splitPanelContext.soupContext;
+ const [preview, setPreview] = splitPanelContext.previewState;
+ const view = createMemo(() => viewsData[selectedView()]);
+ const selectedEntity = () => view().selectedEntity;
+
+ if (!isRenderedFromPreview) {
+ registerHotkey({
+ hotkey: ['p'],
+ scopeId: splitPanelContext.splitHotkeyScope,
+ description: 'Toggle Preview',
+ hotkeyToken: TOKENS.unifiedList.togglePreview,
+ keyDownHandler: () => {
+ playSound('open');
+ setPreview((prev) => !prev);
+ return true;
+ },
+ hide: true,
+ });
+ }
createRenderEffect(() => {
const previousView = untrack(selectedView);
@@ -134,7 +166,26 @@ const Block: Component = () => {
</div>
</Show>
<TopBar />
- <UnifiedListView />
+ <Show when={ENABLE_PROJECT_VIEW_PREVIEW} fallback={<UnifiedListView />}>
+ <div class="flex size-full">
+ <SplitPanelContext.Provider
+ value={{
+ ...splitPanelContext,
+ halfSplitState: () =>
+ preview() ? { side: 'left', percentage: 30 } : undefined,
+ }}
+ >
+ <UnifiedListView hideToolbar={isRenderedFromPreview} />
+ </SplitPanelContext.Provider>
+ <Show when={preview()}>
+ <PreviewPanel
+ selectedEntity={selectedEntity()}
+ orchestrator={orchestrator}
+ splitPanelContext={splitPanelContext}
+ />
+ </Show>
+ </div>
+ </Show>
</div>
</DocumentBlockContainer>
);
diff --git a/js/app/packages/block-project/component/TopBar.tsx b/js/app/packages/block-project/component/TopBar.tsx
index 06a13fb1b7..e70ef99878 100644
--- a/js/app/packages/block-project/component/TopBar.tsx
+++ b/js/app/packages/block-project/component/TopBar.tsx
@@ -11,11 +11,15 @@ import {
SplitToolbarLeft,
SplitToolbarRight,
} from '@app/component/split-layout/components/SplitToolbar';
+import { useSplitPanelOrThrow } from '@app/component/split-layout/layoutUtils';
import { getIsSpecialProject } from '@block-project/isSpecial';
import { projectBlockDataSignal } from '@block-project/signal/projectBlockData';
import { useBlockId } from '@core/block';
import { ShareButton } from '@core/component/TopBar/ShareButton';
-import { ENABLE_PROJECT_SHARING } from '@core/constant/featureFlags';
+import {
+ ENABLE_PROJECT_SHARING,
+ ENABLE_PROJECT_VIEW_PREVIEW,
+} from '@core/constant/featureFlags';
import {
useCanEdit,
useGetPermissions,
@@ -31,6 +35,8 @@ import { ProjectPropertiesModal } from './ProjectPropertiesModal';
// with folder block.
export function TopBar() {
+ const splitPanelContext = useSplitPanelOrThrow();
+ const [preview] = splitPanelContext.previewState;
const id = useBlockId();
const isSpecialProject = getIsSpecialProject(id);
const permissions = useGetPermissions();
@@ -62,6 +68,11 @@ export function TopBar() {
: []),
]);
+ const showToolbarRight = () => {
+ if (!ENABLE_PROJECT_VIEW_PREVIEW) return true;
+ return !preview();
+ };
+
return (
<>
<SplitHeaderLeft>
@@ -82,26 +93,28 @@ export function TopBar() {
</Show>
</div>
</SplitToolbarLeft>
- <SplitToolbarRight>
- <div class="flex items-center p-1">
- <div class="flex items-center">
- <Show when={!isSpecialProject}>
- <ProjectPropertiesModal buttonSize="sm" name={name()} />
- </Show>
- <SplitPermissionsBadge />
- <Show when={ENABLE_PROJECT_SHARING && !isSpecialProject}>
- <ShareButton
- id={id}
- name={name()}
- userPermissions={permissions()}
- copyLink={handleCopyLink}
- itemType="project"
- owner={owner()}
- />
- </Show>
+ <Show when={showToolbarRight()}>
+ <SplitToolbarRight>
+ <div class="flex items-center p-1">
+ <div class="flex items-center">
+ <Show when={!isSpecialProject}>
+ <ProjectPropertiesModal buttonSize="sm" name={name()} />
+ </Show>
+ <SplitPermissionsBadge />
+ <Show when={ENABLE_PROJECT_SHARING && !isSpecialProject}>
+ <ShareButton
+ id={id}
+ name={name()}
+ userPermissions={permissions()}
+ copyLink={handleCopyLink}
+ itemType="project"
+ owner={owner()}
+ />
+ </Show>
+ </div>
</div>
- </div>
- </SplitToolbarRight>
+ </SplitToolbarRight>
+ </Show>
</>
);
}
diff --git a/js/app/packages/core/constant/featureFlags.ts b/js/app/packages/core/constant/featureFlags.ts
index ecb3d57386..15889ec2ad 100644
--- a/js/app/packages/core/constant/featureFlags.ts
+++ b/js/app/packages/core/constant/featureFlags.ts
@@ -118,6 +118,7 @@ export const ENABLE_PROPERTY_FILTER = DEV_MODE_ENV;
export const ENABLE_SOUP_FROM_FILTER = false;
export const ENABLE_PREVIEW = true;
+export const ENABLE_PROJECT_VIEW_PREVIEW = true;
export const ENABLE_DOCK_NOTITIFCATIONS = DEV_MODE_ENV;
export const ENABLE_TTFT = DEV_MODE_ENV;
diff --git a/js/app/packages/core/hotkey/tokens.ts b/js/app/packages/core/hotkey/tokens.ts
index 93cf37546e..01aa19321a 100644
--- a/js/app/packages/core/hotkey/tokens.ts
+++ b/js/app/packages/core/hotkey/tokens.ts
@@ -19,6 +19,10 @@ export const TOKENS = {
// unified list
unifiedList: {
togglePreview: 'unifiedList.togglePreview',
+ navigation: {
+ parent: 'unifiedList.navigation.parent',
+ child: 'unifiedList.navigation.child',
+ },
},
// entity navigation
diff --git a/js/app/packages/core/util/withRequired.ts b/js/app/packages/core/util/withRequired.ts
index 3cfdb7a1ac..8d62064a90 100644
--- a/js/app/packages/core/util/withRequired.ts
+++ b/js/app/packages/core/util/withRequired.ts
@@ -9,3 +9,7 @@ export type DeepPartial<T> =
: T extends object
? { [P in keyof T]?: DeepPartial<T[P]> }
: T;
+
+export type NonNullableFields<T> = {
+ [K in keyof T]: NonNullable<T[K]>;
+};
diff --git a/js/app/packages/macro-entity/src/components/Entity.tsx b/js/app/packages/macro-entity/src/components/Entity.tsx
index 7a4de324e1..7cfd220ba9 100644
--- a/js/app/packages/macro-entity/src/components/Entity.tsx
+++ b/js/app/packages/macro-entity/src/components/Entity.tsx
@@ -6,26 +6,8 @@ import { children, createMemo, Show, Suspense } from 'solid-js';
import { Dynamic } from 'solid-js/web';
import { createProfilePictureQuery } from '../queries/auth';
import type { EntityData } from '../types/entity';
-import type { SearchLocation } from '../types/search';
-
-export type EntityClickEvent = Parameters<
- JSX.EventHandler<HTMLDivElement, MouseEvent>
->[0];
-type EntityPointerDownEvent = Parameters<
- JSX.EventHandler<HTMLDivElement, PointerEvent>
->[0];
-export type EntityClickHandler<T extends EntityData> = (
- entity: T,
- event: EntityClickEvent,
- location?: SearchLocation,
- options?: { ignorePreview?: boolean }
-) => void;
-export type EntityPointerDownHandler<T extends EntityData> = (
- entity: T,
- event: EntityPointerDownEvent,
- location?: SearchLocation,
- options?: { ignorePreview?: boolean }
-) => void;
+import type { EntityClickHandler } from './EntityWithEverything';
+
interface EntityProps<T extends EntityData> extends ParentProps {
entity: T;
timestamp?: number;
diff --git a/js/app/packages/macro-entity/src/components/EntityWithEverything.tsx b/js/app/packages/macro-entity/src/components/EntityWithEverything.tsx
index e4e97e1ec7..d1a4424f26 100644
--- a/js/app/packages/macro-entity/src/components/EntityWithEverything.tsx
+++ b/js/app/packages/macro-entity/src/components/EntityWithEverything.tsx
@@ -15,10 +15,9 @@ import { StaticMarkdown } from 'core/component/LexicalMarkdown/component/core/St
import { unifiedListMarkdownTheme } from 'core/component/LexicalMarkdown/theme';
import { UserIcon } from 'core/component/UserIcon';
import { emailToMacroId, tryMacroId, useDisplayName } from 'core/user';
-import type { ParentProps, Ref } from 'solid-js';
+import type { JSX, ParentProps, Ref } from 'solid-js';
import {
createDeferred,
- createEffect,
createMemo,
createSignal,
For,
@@ -49,9 +48,28 @@ import type {
SearchLocation,
WithSearch,
} from '../types/search';
-import type { EntityClickEvent, EntityClickHandler } from './Entity';
import { KeyPropertiesGrid, PropertyPills } from './PropertyPills';
+export type EntityClickEvent = Parameters<
+ JSX.EventHandler<HTMLDivElement, MouseEvent>
+>[0];
+type EntityPointerDownEvent = Parameters<
+ JSX.EventHandler<HTMLDivElement, PointerEvent>
+>[0];
+type EntityClickProps<T extends EntityData, E> = {
+ type: 'entity' | 'entity-project-path';
+ entity: T;
+ projectEntity?: T;
+ event: E;
+ location?: SearchLocation;
+};
+export type EntityClickHandler<T extends EntityData> = (
+ args: EntityClickProps<T, EntityClickEvent>
+) => void;
+export type EntityPointerDownHandler<T extends EntityData> = (
+ args: EntityClickProps<T, EntityPointerDownEvent>
+) => void;
+
export const ENTITY_HEIGHT = 40;
function UnreadIndicator(props: { active?: boolean }) {
@@ -331,13 +349,14 @@ function NotificationRow(props: {
onClick={
props.onClick
? (e) => {
- props.onClick?.(
- {
+ props.onClick?.({
+ type: 'entity',
+ entity: {
...props.entity,
notification: props.notification,
},
- e
- );
+ event: e,
+ });
}
: undefined
}
@@ -437,6 +456,7 @@ interface EntityProps<T extends WithNotification<EntityData>>
focused?: boolean;
timestamp?: number;
onClick?: EntityClickHandler<T>;
+ onDblClick?: EntityClickHandler<T>;
onPointerDown?: EntityClickHandler<T>;
onClickRowAction?: (entity: T, type: 'done') => void;
onClickNotification?: NotificationClickHandler<T>;
@@ -453,7 +473,7 @@ interface EntityProps<T extends WithNotification<EntityData>>
showUnrollNotifications?: boolean;
showDoneButton?: boolean;
highlighted?: boolean;
- selected?: boolean;
+ selected: { active: boolean; muted?: boolean };
ref?: Ref<HTMLDivElement>;
onChecked?: (checked: boolean, shiftKey?: boolean) => void;
checked?: boolean;
@@ -577,16 +597,16 @@ export function EntityWithEverything(
};
return (
- <div class="flex gap-1 items-center text-sm min-w-0 w-full truncate overflow-hidden @max-md/split:flex-col @max-md/split:items-start @max-md/split:gap-1 @max-md/split:truncate-none">
+ <div class="flex gap-1 items-center text-sm min-w-0 w-full truncate overflow-hidden @max-md/uList:flex-col @max-md/uList:items-start @max-md/uList:gap-1 @max-md/uList:truncate-none">
{/* sometimes senderName and senderEmail are the same */}
<div
- class="flex gap-2 items-center font-semibold shrink-0 @max-md/split:w-full @max-md/split:truncate"
+ class="flex gap-2 items-center font-semibold shrink-0 @max-md/uList:w-full @max-md/uList:truncate"
classList={{
'w-[20cqw]': !isSearch(),
}}
>
{/* Icon inline with sender in narrow mode */}
- <div class="hidden @max-md/split:flex size-[1em] shrink-0 items-center justify-center relative group/icon-checkbox">
+ <div class="hidden @max-md/uList:flex size-[1em] shrink-0 items-center justify-center relative group/icon-checkbox">
{/* Checkbox for narrow mode - shown on hover or when checked */}
<button
type="button"
@@ -625,7 +645,7 @@ export function EntityWithEverything(
</div>
</div>
{/* Sender Name */}
- <div class="truncate @max-md/split:min-w-0">
+ <div class="truncate @max-md/uList:min-w-0">
{displayedNames() ??
props.entity.senderName ??
props.entity.senderEmail?.split('@')[0]}
@@ -643,17 +663,17 @@ export function EntityWithEverything(
</div>
{/* Subject */}
{/*<ImportantBadge active={props.importantIndicatorActive} />*/}
- <div class="flex items-center w-full gap-2 flex-1 min-w-0 @max-md/split:flex-col @max-md/split:items-start @max-md/split:w-full @max-md/split:gap-1">
- <div class="flex items-center gap-2 flex-1 min-w-0 @max-md/split:w-full @max-md/split:justify-between @max-md/split:min-w-0">
+ <div class="flex items-center w-full gap-2 flex-1 min-w-0 @max-md/uList:flex-col @max-md/uList:items-start @max-md/uList:w-full @max-md/uList:gap-1">
+ <div class="flex items-center gap-2 flex-1 min-w-0 @max-md/uList:w-full @max-md/uList:justify-between @max-md/uList:min-w-0">
<div
- class="shrink-0 truncate @max-md/split:min-w-0 @max-md/split:flex-1"
+ class="shrink-0 truncate @max-md/uList:min-w-0 @max-md/uList:flex-1"
classList={{
'font-regular text-ink-disabled': isSearch(),
'font-medium': !isSearch(),
}}
>
<Show when={isSearch()}>
- <span class="@max-md/split:hidden"> – </span>
+ <span class="@max-md/uList:hidden"> – </span>
</Show>
<Show
when={isSearch() && searchHighlightName()}
@@ -669,20 +689,20 @@ export function EntityWithEverything(
</Show>
</div>
{/* Body snippet - inline in wide mode */}
- <div class="truncate shrink grow opacity-60 @max-md/split:hidden">
+ <div class="truncate shrink grow opacity-60 @max-md/uList:hidden">
{props.entity.snippet}
</div>
{/* Timestamp inline with subject in narrow mode */}
<Show when={props.timestamp ?? props.entity.updatedAt}>
{(date) => (
- <span class="hidden @max-md/split:inline shrink-0 whitespace-nowrap text-xs font-mono uppercase text-ink-extra-muted">
+ <span class="hidden @max-md/uList:inline shrink-0 whitespace-nowrap text-xs font-mono uppercase text-ink-extra-muted">
{createFormattedDate(date())}
</span>
)}
</Show>
</div>
{/* Body snippet - below subject in narrow mode */}
- <div class="hidden @max-md/split:block truncate w-full text-xs opacity-60">
+ <div class="hidden @max-md/uList:block truncate w-full text-xs opacity-60">
{props.entity.snippet}
</div>
</div>
@@ -712,11 +732,11 @@ export function EntityWithEverything(
};
return (
- <div class="flex gap-2 items-center min-w-0 w-fit max-w-full overflow-hidden @max-md/split:flex-col @max-md/split:items-start @max-md/split:w-full @max-md/split:gap-1">
- <span class="flex gap-1 truncate font-medium text-sm shrink-0 items-center @max-md/split:w-full @max-md/split:flex-col @max-md/split:items-start @max-md/split:gap-1">
- <div class="flex items-center gap-2 w-full @max-md/split:justify-between @max-md/split:min-w-0">
+ <div class="flex gap-2 items-center min-w-0 w-fit max-w-full overflow-hidden @max-md/uList:flex-col @max-md/uList:items-start @max-md/uList:w-full @max-md/uList:gap-1">
+ <span class="flex gap-1 truncate font-medium text-sm shrink-0 items-center @max-md/uList:w-full @max-md/uList:flex-col @max-md/uList:items-start @max-md/uList:gap-1">
+ <div class="flex items-center gap-2 w-full @max-md/uList:justify-between @max-md/uList:min-w-0">
{/* Icon inline with title in narrow mode */}
- <div class="hidden @max-md/split:flex size-[1em] shrink-0 items-center justify-center relative group/icon-checkbox-nonemail">
+ <div class="hidden @max-md/uList:flex size-[1em] shrink-0 items-center justify-center relative group/icon-checkbox-nonemail">
{/* Checkbox for narrow mode - shown on hover or when checked */}
<button
type="button"
@@ -765,7 +785,7 @@ export function EntityWithEverything(
</div>
</div>
<span
- class="font-semibold truncate @max-md/split:min-w-0 @max-md/split:flex-1"
+ class="font-semibold truncate @max-md/uList:min-w-0 @max-md/uList:flex-1"
classList={{
'w-[20cqw]': !props.showUnrollNotifications,
}}
@@ -786,7 +806,7 @@ export function EntityWithEverything(
{/* Timestamp inline with title in narrow mode */}
<Show when={props.timestamp ?? props.entity.updatedAt}>
{(date) => (
- <span class="hidden @max-md/split:inline shrink-0 whitespace-nowrap text-xs font-mono uppercase text-ink-extra-muted">
+ <span class="hidden @max-md/uList:inline shrink-0 whitespace-nowrap text-xs font-mono uppercase text-ink-extra-muted">
{createFormattedDate(date())}
</span>
)}
@@ -794,14 +814,14 @@ export function EntityWithEverything(
</div>
<Show when={showLatestMessageInfo()}>
- <div class="flex items-center gap-1 @max-md/split:w-full @max-md/split:flex-col @max-md/split:items-start @max-md/split:gap-1">
+ <div class="flex items-center gap-1 @max-md/uList:w-full @max-md/uList:flex-col @max-md/uList:items-start @max-md/uList:gap-1">
{/*<ImportantBadge active={props.importantIndicatorActive} />*/}
- <span class="font-medium shrink-0 truncate @max-md/split:w-full">
+ <span class="font-medium shrink-0 truncate @max-md/uList:w-full">
{userNameFromSender()}
</span>
<Show when={latestMessage()}>
{(lastMessage) => (
- <div class="truncate shrink grow opacity-60 flex items-center @max-md/split:w-full @max-md/split:text-xs">
+ <div class="truncate shrink grow opacity-60 flex items-center @max-md/uList:w-full @max-md/uList:text-xs">
{/* TODO (seamus): Channels endpoint does not return any information about attachments. If we have an empty message, assume it's attachments.*/}
<Show
when={lastMessage().content.trim()}
@@ -882,11 +902,13 @@ export function EntityWithEverything(
}}
classList={{
'outline outline-accent/20 outline-offset-[-1px]':
- !isTouchDevice() && props.selected && !props.checked,
+ !isTouchDevice() && props.selected.active && !props.checked,
'!bg-accent/5 outline outline-accent/20 outline-offset-[-1px]':
props.checked,
'bracket outline outline-accent/20 outline-offset-[-1px]':
- !isTouchDevice() && props.selected,
+ !isTouchDevice() && props.selected.active,
+ 'after:opacity-20 !outline-accent/10':
+ !isTouchDevice() && props.selected.active && props.selected.muted,
'active:bracket active:outline active:outline-accent/20 active:outline-offset-[-1px]':
isTouchDevice() && !props.checked,
}}
@@ -903,10 +925,18 @@ export function EntityWithEverything(
<div
data-entity
data-entity-id={props.entity.id}
- class="w-full min-w-0 grid flex-1 items-center suppress-css-bracket grid-cols-[2rem_1fr_auto] @max-md/split:flex @max-md/split:flex-col pr-2 @max-md/split:px-2 @max-md/split:py-2"
+ class="w-full min-w-0 grid flex-1 items-center suppress-css-bracket grid-cols-[2rem_1fr_auto] @max-md/uList:flex @max-md/uList:flex-col pr-2 @max-md/uList:px-2 @max-md/uList:py-2"
onClick={(e) => {
if (blocksNavigation(e)) return;
- props.onClick?.(props.entity, e);
+ props.onClick?.({ type: 'entity', entity: props.entity, event: e });
+ }}
+ onDblClick={(e) => {
+ if (blocksNavigation(e)) return;
+ props.onDblClick?.({
+ type: 'entity',
+ entity: props.entity,
+ event: e,
+ });
}}
onMouseDown={(e) => {
if (blocksNavigation(e)) return;
@@ -914,7 +944,11 @@ export function EntityWithEverything(
}}
onPointerDown={(e) => {
if (blocksNavigation(e)) return;
- props.onPointerDown?.(props.entity, e);
+ props.onPointerDown?.({
+ type: 'entity',
+ entity: props.entity,
+ event: e,
+ });
}}
// Action List is also rendered based on focus, but when focused via Shift+Tab, parent is focused due to Action List dom not present. Here we check if current browser task has captured Shift+Tab focus on Action List
onFocusIn={(e) => {
@@ -935,7 +969,7 @@ export function EntityWithEverything(
>
<button
type="button"
- class="col-1 size-full relative group/button flex items-center justify-center bracket-never @max-md/split:hidden"
+ class="col-1 size-full relative group/button flex items-center justify-center bracket-never @max-md/uList:hidden"
onMouseDown={(e) => {
e.stopPropagation();
}}
@@ -964,7 +998,7 @@ export function EntityWithEverything(
!props.highlighted
}
>
- <div class="absolute inset-0 flex items-center justify-center group-hover/button:opacity-0 @max-md/split:hidden">
+ <div class="absolute inset-0 flex items-center justify-center group-hover/button:opacity-0 @max-md/uList:hidden">
<UnreadIndicator active={props.unreadIndicatorActive} />
</div>
</Show>
@@ -972,7 +1006,7 @@ export function EntityWithEverything(
{/* Left Column Indicator(s) */}
{/* Icon and name - top left on mobile, first item on desktop */}
<div
- class="min-h-10 min-w-[50px] flex flex-row items-center gap-2 col-2 @max-md/split:col-auto @max-md/split:w-full @max-md/split:min-h-0 @max-md/split:items-start"
+ class="min-h-10 min-w-[50px] flex flex-row items-center gap-2 col-2 @max-md/uList:col-auto @max-md/uList:w-full @max-md/uList:min-h-0 @max-md/uList:items-start"
classList={{
grow: props.contentPlacement === 'bottom-row',
'opacity-70': props.fadeIfRead && !props.unreadIndicatorActive,
@@ -980,11 +1014,11 @@ export function EntityWithEverything(
>
{/* Icon/Checkbox container - in narrow mode, shows icon by default, checkbox on hover */}
{/* For emails, icon is inline with sender, so hide this container in narrow mode */}
- <div class="flex size-5 shrink-0 items-center justify-center relative group/icon-checkbox @max-md/split:hidden">
+ <div class="flex size-5 shrink-0 items-center justify-center relative group/icon-checkbox @max-md/uList:hidden">
{/* Checkbox for narrow mode - shown on hover or when checked, hidden at larger widths */}
<button
type="button"
- class="hidden @max-md/split:flex @min-md/split:hidden absolute inset-0 items-center justify-center opacity-0 group-hover/icon-checkbox:opacity-100 transition-opacity"
+ class="hidden @max-md/uList:flex @min-md/uList:hidden absolute inset-0 items-center justify-center opacity-0 group-hover/icon-checkbox:opacity-100 transition-opacity"
classList={{
'opacity-100': props.checked,
}}
@@ -1007,9 +1041,9 @@ export function EntityWithEverything(
</button>
{/* Icon - hidden on hover in narrow mode when not checked */}
<div
- class="flex items-center justify-center @max-md/split:group-hover/icon-checkbox:opacity-0 @max-md/split:transition-opacity"
+ class="flex items-center justify-center @max-md/uList:group-hover/icon-checkbox:opacity-0 @max-md/uList:transition-opacity"
classList={{
- '@max-md/split:opacity-0': props.checked,
+ '@max-md/uList:opacity-0': props.checked,
}}
>
<Show
@@ -1035,12 +1069,12 @@ export function EntityWithEverything(
</div>
{/* Date and user - top right on mobile, end on desktop */}
<div
- class="row-1 ml-2 @md:ml-4 self-center min-w-0 col-3 @max-md/split:col-auto @max-md/split:row-auto @max-md/split:ml-0 @max-md/split:mt-1 @max-md/split:self-start @max-md/split:w-full"
+ class="row-1 ml-2 @md:ml-4 self-center min-w-0 col-3 @max-md/uList:col-auto @max-md/uList:row-auto @max-md/uList:ml-0 @max-md/uList:mt-1 @max-md/uList:self-start @max-md/uList:w-full"
classList={{
'opacity-50': props.fadeIfRead && !props.unreadIndicatorActive,
}}
>
- <div class="flex flex-row items-center justify-end gap-2 min-w-0 @max-md/split:justify-start @max-md/split:flex-wrap">
+ <div class="flex flex-row items-center justify-end gap-2 min-w-0 @max-md/uList:justify-start @max-md/uList:flex-wrap">
<Show when={properties().length > 0}>
<div class="pr-2 overflow-hidden shrink min-w-0">
<PropertyPills
@@ -1060,23 +1094,28 @@ export function EntityWithEverything(
</Show>
<Show when={matches(props.entity, isProjectContainedEntity)}>
{(entity) => (
- <EntityProject entity={entity()} onClick={props.onClick} />
+ <EntityProject
+ entity={entity()}
+ onClick={props.onClick}
+ onPointerdown={props.onPointerDown}
+ />
)}
</Show>
<Show when={props.timestamp ?? props.entity.updatedAt}>
{(date) => (
- <span class="shrink-0 whitespace-nowrap text-xs font-mono uppercase text-ink-extra-muted @max-md/split:hidden">
+ <span class="shrink-0 whitespace-nowrap text-xs font-mono uppercase text-ink-extra-muted @max-md/uList:hidden">
{createFormattedDate(date())}
</span>
)}
</Show>
<Show
when={
- (props.selected || hoveredEntityId() === props.entity.id) &&
+ (props.selected.active ||
+ hoveredEntityId() === props.entity.id) &&
props.onClickRowAction
}
>
- <div class="absolute top-1 right-1 items-center flex @max-sm/split:hidden">
+ <div class="absolute top-1 right-1 items-center flex @max-sm/uList:hidden">
<Tooltip
tooltip={
<LabelAndHotKey
@@ -1114,7 +1153,12 @@ export function EntityWithEverything(
allData={contentHitData()}
data={data}
onClick={(e, location) => {
- props.onClick?.(props.entity, e, location);
+ props.onClick?.({
+ type: 'entity',
+ entity: props.entity,
+ event: e,
+ location,
+ });
}}
index={index}
count={count}
@@ -1131,7 +1175,7 @@ export function EntityWithEverything(
contentHitData().length === 0
}
>
- <div class="relative col-2 col-end-4 pb-2 @max-md/split:col-auto @max-md/split:w-full @max-md/split:mt-1">
+ <div class="relative col-2 col-end-4 pb-2 @max-md/uList:col-auto @max-md/uList:w-full @max-md/uList:mt-1">
<CollapsibleList items={notDoneNotifications()} threadBorder>
{(notification) => (
<NotificationRow
@@ -1225,39 +1269,44 @@ function EntityProjectPathDisplay(props: { name: string; path: string[] }) {
function EntityProject(props: {
entity: ProjectContainedEntity;
onClick?: EntityClickHandler<ProjectEntity>;
+ onPointerdown?: EntityPointerDownHandler<ProjectEntity>;
}) {
const projectQuery = createProjectQuery(props.entity.projectId);
- let projectIconRef!: HTMLDivElement;
-
- createEffect(() => {
- const click = props.onClick;
- if (!click) return;
+ const openProjectEntity: (args: {
+ event: Parameters<JSX.EventHandler<HTMLDivElement, MouseEvent>>[number];
+ eventHandler?: EntityClickHandler<ProjectEntity>;
+ }) => void = ({ event, eventHandler }) => {
if (!projectQuery.isSuccess) return;
const data = projectQuery.data;
- const handleClick = (e: EntityClickEvent) => {
- const projectEntity: ProjectEntity = {
- type: 'project',
- id: data.id,
- name: data.name,
- ownerId: data.owner,
- updatedAt: data.updatedAt,
- };
- click(projectEntity, e, undefined, { ignorePreview: true });
+ const projectEntity: ProjectEntity = {
+ type: 'project',
+ id: data.id,
+ name: data.name,
+ ownerId: data.owner,
+ updatedAt: data.updatedAt,
};
-
- projectIconRef.classList.add('hover:text-accent');
- projectIconRef.dataset.blocksNavigation = 'true';
- projectIconRef.addEventListener('click', handleClick);
- onCleanup(() => {
- projectIconRef.removeEventListener('click', handleClick);
+ eventHandler?.({
+ type: 'entity-project-path',
+ entity: props.entity as unknown as ProjectEntity,
+ projectEntity,
+ event,
});
- });
+ };
return (
<div
- ref={projectIconRef}
+ data-blocks-navigation={projectQuery.isSuccess ? 'true' : undefined}
+ onClick={(e) =>
+ openProjectEntity({ event: e, eventHandler: props.onClick })
+ }
+ onPointerDown={(e) =>
+ openProjectEntity({ event: e, eventHandler: props.onPointerdown })
+ }
class="flex gap-1 items-center text-xs text-ink-extra-muted min-w-0"
+ classList={{
+ 'hover:text-accent': projectQuery.isSuccess,
+ }}
>
<svg
class="shrink-0"
diff --git a/js/app/packages/macro-entity/src/index.tsx b/js/app/packages/macro-entity/src/index.tsx
index de40001e7f..dcbd905a32 100644
--- a/js/app/packages/macro-entity/src/index.tsx
+++ b/js/app/packages/macro-entity/src/index.tsx
@@ -1,4 +1,4 @@
-export { Entity, type EntityClickHandler } from './components/Entity';
+export { Entity } from './components/Entity';
export { EntityWrapper } from './components/EntityWrapper';
export { createFilter } from './components/Filter';
export { Provider } from './components/Provider';