Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
style(entity): update entity edit modal wrapper styles (#2316)
Seamus32d65f567ea3
diff --git a/js/app/packages/app/component/bulk-edit-entity/BulkDeleteView.tsx b/js/app/packages/app/component/bulk-edit-entity/BulkDeleteView.tsxindex f4c22cc4d2..e33e3588ca 100644--- a/js/app/packages/app/component/bulk-edit-entity/BulkDeleteView.tsx+++ b/js/app/packages/app/component/bulk-edit-entity/BulkDeleteView.tsx@@ -1,9 +1,10 @@-import type { EntityData } from '@entity';+import { type EntityData, InlineEntity } from '@entity';import { createBulkDeleteDssItemsMutation } from '@macro-entity';-import {- BulkEditEntityModalActionFooter,- BulkEditEntityModalTitle,-} from './BulkEditEntityModal';+import { Dialog } from '@kobalte/core/dialog';+import { Button } from '@ui/components/Button';+import { cn } from '@ui/utils/classname';+import { For, Show } from 'solid-js';+import CloseIcon from '@phosphor-icons/core/regular/x.svg?component-solid';export const BulkDeleteView = (props: {entities: EntityData[];@@ -26,23 +27,65 @@ export const BulkDeleteView = (props: {};return (- <div class="w-full">- <BulkEditEntityModalTitle title="Delete Items" />+ <>+ <div class="shrink-0 flex flex-row items-center px-2 gap-1 border-b-1 border-b-edge-muted h-[40px]">+ <Dialog.CloseButton as={Button} variant="ghost" size="icon-sm">+ <CloseIcon />+ </Dialog.CloseButton>+ <Dialog.Title as="span" class="text-sm font-medium p-0 m-0">+ Delete{' '}+ {props.entities.length === 1+ ? 'Item'+ : `${props.entities.length} Items`}+ </Dialog.Title>+ </div>++ <div class="p-2 border-b border-edge-muted">+ <div class="flex items-center gap-2">+ <For each={props.entities.slice(0, 2)}>+ {(entity) => (+ <div+ class={cn('bg-edge/20 px-2 py-1 truncate text-xs rounded-xs', {+ 'max-w-[50%]': props.entities.length === 2,+ })}+ >+ <InlineEntity entity={entity} />+ </div>+ )}+ </For>+ <Show when={props.entities.length > 2}>+ <div class="text-muted-foreground text-xs px-2 py-1">+ +{props.entities.length - 2} more+ </div>+ </Show>+ </div>+ </div>- <div class="mb-4">- <p class="text-ink-muted text-sm">+ <div class="p-3 flex flex-col gap-3">+ <p class="text-sm text-ink-muted">{props.entities.length === 1- ? `You are about to delete "${props.entities[0].name}".`- : `You are about to delete ${props.entities.length} items.`}+ ? 'You are about to delete this item. This action cannot be undone.'+ : `You are about to delete ${props.entities.length} items. This action cannot be undone.`}</p>- <p class="text-ink-muted text-sm mt-2">This action cannot be undone.</p>- </div>- <BulkEditEntityModalActionFooter- onCancel={handleCancel}- onConfirm={handleDelete}- confirmText="Delete"- />- </div>+ <div class="flex justify-end gap-2">+ <Button variant="ghost" onClick={handleCancel}>+ Cancel+ </Button>+ <Button+ ref={(el: HTMLButtonElement) => {+ requestAnimationFrame(() =>+ requestAnimationFrame(() => el.focus())+ );+ }}+ type="button"+ variant="destructive"+ onClick={handleDelete}+ >+ Delete+ </Button>+ </div>+ </div>+ </>);};diff --git a/js/app/packages/app/component/bulk-edit-entity/BulkEditEntityModal.tsx b/js/app/packages/app/component/bulk-edit-entity/BulkEditEntityModal.tsxindex 18fcd71e17..cb393ee35f 100644--- a/js/app/packages/app/component/bulk-edit-entity/BulkEditEntityModal.tsx+++ b/js/app/packages/app/component/bulk-edit-entity/BulkEditEntityModal.tsx@@ -1,4 +1,5 @@import { createControlledOpenSignal } from '@core/util/createControlledOpenSignal';+import { DialogWrapper } from '@core/component/DialogWrapper';import { Dialog } from '@kobalte/core/dialog';import type { EntityData } from '@entity';import {@@ -12,39 +13,6 @@ import { BulkDeleteView } from './BulkDeleteView';import { BulkMoveToProjectView } from './BulkMoveToProjectView';import { BulkRenameEntitiesView } from './BulkRenameEntitiesView';-export const BulkEditEntityModalTitle = (props: { title: string }) => {- return <h2 class="text-xl mb-4">{props.title}</h2>;-};--export const BulkEditEntityModalActionFooter = (props: {- onCancel: () => void;- onConfirm: () => void;- confirmText: string;- isDisabled?: boolean;-}) => {- return (- <div class="flex w-full justify-end items-stretch tex-sm gap-1">- <button- class="py-1 px-3 text-sm border-edge-muted border bg-panel"- onClick={props.onCancel}- >- Cancel- </button>- <button- class="uppercase py-1 px-3 text-sm font-semibold border"- classList={{- 'text-accent bg-accent/10 border-accent/20': !props.isDisabled,- 'text-ink-disabled bg-egde/10 border-edge-muted': props.isDisabled,- }}- onClick={props.onConfirm}- disabled={props.isDisabled}- >- {props.confirmText}- </button>- </div>- );-};-const BulkEditEntityModalContent = (props: {isOpen: Accessor<boolean>;setIsOpen: Setter<boolean>;@@ -74,36 +42,31 @@ const BulkEditEntityModalContent = (props: {modal={true}><Dialog.Portal>- <Dialog.Overlay class="fixed inset-0 z-modal bg-modal-overlay" />- <div class="fixed inset-0 z-modal">- <Dialog.Content>- <div class="pointer-events-auto max-w-[min(36rem,calc(100%-1rem))] bg-menu border border-edge-muted w-lg h-fit p-2 mt-[25vh] mx-auto">- <div class="w-full my-1">- <Show when={props.view === 'rename'}>- <BulkRenameEntitiesView- entities={props.entities}- onFinish={handleFinish}- onCancel={handleCancel}- />- </Show>- <Show when={props.view === 'moveToProject'}>- <BulkMoveToProjectView- entities={props.entities}- onFinish={handleFinish}- onCancel={handleCancel}- />- </Show>- <Show when={props.view === 'delete'}>- <BulkDeleteView- entities={props.entities}- onFinish={handleFinish}- onCancel={handleCancel}- />- </Show>- </div>- </div>- </Dialog.Content>- </div>+ <DialogWrapper>+ <div class="flex flex-col text-ink">+ <Show when={props.view === 'rename'}>+ <BulkRenameEntitiesView+ entities={props.entities}+ onFinish={handleFinish}+ onCancel={handleCancel}+ />+ </Show>+ <Show when={props.view === 'moveToProject'}>+ <BulkMoveToProjectView+ entities={props.entities}+ onFinish={handleFinish}+ onCancel={handleCancel}+ />+ </Show>+ <Show when={props.view === 'delete'}>+ <BulkDeleteView+ entities={props.entities}+ onFinish={handleFinish}+ onCancel={handleCancel}+ />+ </Show>+ </div>+ </DialogWrapper></Dialog.Portal></Dialog>);diff --git a/js/app/packages/app/component/bulk-edit-entity/BulkMoveToProjectView.tsx b/js/app/packages/app/component/bulk-edit-entity/BulkMoveToProjectView.tsxindex 70e44c10b9..b7dc8bb118 100644--- a/js/app/packages/app/component/bulk-edit-entity/BulkMoveToProjectView.tsx+++ b/js/app/packages/app/component/bulk-edit-entity/BulkMoveToProjectView.tsx@@ -3,13 +3,21 @@ import { scrollToKeepGap } from '@core/util/scrollToKeepGap';import { useProjectsQuery } from '@queries/storage/projects';import type { Project } from '@service-storage/generated/schemas';import { registerHotkey, useHotkeyDOMScope } from 'core/hotkey/hotkeys';-import { createMemo, createSignal, For, onMount, Show } from 'solid-js';-import { createBulkMoveToProjectDssEntityMutation } from '@macro-entity';-import type { EntityData } from '@entity';import {- BulkEditEntityModalActionFooter,- BulkEditEntityModalTitle,-} from './BulkEditEntityModal';+ createEffect,+ createMemo,+ createSignal,+ For,+ onMount,+ Show,+ untrack,+} from 'solid-js';+import { createBulkMoveToProjectDssEntityMutation } from '@macro-entity';+import { type EntityData, InlineEntity } from '@entity';+import { Dialog } from '@kobalte/core/dialog';+import { Button } from '@ui/components/Button';+import { cn } from '@ui/utils/classname';+import CloseIcon from '@phosphor-icons/core/regular/x.svg?component-solid';type ProjectWithDepth = Project & { depth?: number; path?: string };@@ -38,7 +46,7 @@ export const BulkMoveToProjectView = (props: {onMount(() => {attachHotkeys(rootScopeId);registerHotkey({- hotkey: ['arrowdown'],+ hotkey: ['arrowdown', 'ctrl+j'],scopeId: moveToProjectHotkeyScopeId,description: 'Down',keyDownHandler: () => {@@ -67,7 +75,7 @@ export const BulkMoveToProjectView = (props: {runWithInputFocused: true,});registerHotkey({- hotkey: ['arrowup'],+ hotkey: ['arrowup', 'ctrl+k'],scopeId: moveToProjectHotkeyScopeId,description: 'Up',keyDownHandler: () => {@@ -241,6 +249,7 @@ export const BulkMoveToProjectView = (props: {const updateFlattenedProjects = () => {const query = searchQuery().toLowerCase();+ let newItems: ProjectWithDepth[];if (query) {// Search mode: filter projects that match the query@@ -256,6 +265,7 @@ export const BulkMoveToProjectView = (props: {}));setFlattenedProjects({ items: searchResults });+ newItems = searchResults;} else {// Tree mode: flatten the hierarchy respecting expanded stateconst result: ProjectWithDepth[] = [];@@ -280,22 +290,23 @@ export const BulkMoveToProjectView = (props: {processItems(tree.rootItems);setFlattenedProjects({ items: result });+ newItems = result;}- // Reset focus when items change- const items = flattenedProjects().items;- if (items.length > 0 && focusedIndex() === -1) {+ // Reset focus when items change — use newItems directly to avoid re-tracking+ const fi = untrack(focusedIndex);+ if (newItems.length > 0 && fi === -1) {setFocusedIndex(0);- setSelectedProject(items[0]);- } else if (focusedIndex() >= items.length) {- const newIndex = Math.max(0, items.length - 1);+ setSelectedProject(newItems[0]);+ } else if (fi >= newItems.length) {+ const newIndex = Math.max(0, newItems.length - 1);setFocusedIndex(newIndex);- setSelectedProject(items[newIndex] || null);+ setSelectedProject(newItems[newIndex] || null);}};// Update flattened projects when dependencies change- createMemo(() => {+ createEffect(() => {updateFlattenedProjects();});@@ -309,26 +320,13 @@ export const BulkMoveToProjectView = (props: {};// Keep focused index in sync with current selection- createMemo(() => {+ createEffect(() => {const index = currentIndex();- if (index !== -1 && index !== focusedIndex()) {+ if (index !== -1 && index !== untrack(focusedIndex)) {setFocusedIndex(index);}});- const currentFocus = () => {- const index = focusedIndex();- return index >= 0 && index < items().length ? items()[index] : null;- };-- // Auto-select focused item- createMemo(() => {- const focused = currentFocus();- if (focused && focused.id !== currentSelected()?.id) {- setSelectedProject(focused);- }- });-const toggleExpanded = (projectId: string) => {setExpandedProjects((prev) => ({...prev,@@ -363,81 +361,152 @@ export const BulkMoveToProjectView = (props: {return (<div ref={rootScopeId}>- <BulkEditEntityModalTitle- title={`Move ${entityCount()} ${entityText()} to folder`}- />- <div class="mb-4">- <input- type="text"- placeholder="Search folders..."- value={searchQuery()}- onInput={(e) => setSearchQuery(e.target.value)}- class="w-full px-3 py-2 border border-edge bg-menu text-ink focus:outline-none focus:border-accent"- />+ <div class="shrink-0 flex flex-row items-center px-2 gap-1 border-b-1 border-b-edge-muted h-[40px]">+ <Dialog.CloseButton as={Button} variant="ghost" size="icon-sm">+ <CloseIcon />+ </Dialog.CloseButton>+ <Dialog.Title as="span" class="text-sm font-medium p-0 m-0">+ Move {entityCount()} {entityText()} to folder+ </Dialog.Title></div>- <div class="h-64 overflow-auto border border-edge" ref={listRef}>- <For each={items()}>- {(project, index) => {- const isSelected = () => currentSelected()?.id === project.id;- const isFocused = () => focusedIndex() === index();- const isExpanded = () => expandedProjects()[project.id];- const hasChildren = () => {- const tree = projectTree();- return (- tree.itemMap[project.id]?.children &&- tree.itemMap[project.id].children!.length > 0- );- };- return (+ <div class="p-2 border-b border-edge-muted">+ <div class="flex items-center gap-2">+ <For each={props.entities.slice(0, 2)}>+ {(entity) => (<div- class={`flex items-center px-2 py-1 cursor-pointer hover:bg-accent/10 ${- isFocused() ? 'focused bg-accent/20' : ''- } ${isSelected() ? 'bg-accent/10' : ''}`}- style={{- 'padding-left': `${(project.depth || 0) * 16 + 8}px`,- }}- onClick={() => {- setSelectedProject(project);- setFocusedIndex(index());- scrollToKeepGap({- container: listRef,- target: listRef.querySelector('.focused') as HTMLElement,- align: 'top',- });- }}+ class={cn('bg-edge/20 px-2 py-1 truncate text-xs rounded-xs', {+ 'max-w-[50%]': props.entities.length === 2,+ })}>- <div- class={`mr-2 w-4 h-4 flex items-center justify-center text-xs ${- hasChildren() ? 'cursor-pointer' : 'opacity-20'- }`}- onClick={(e) => {- e.stopPropagation();- if (hasChildren()) {- toggleExpanded(project.id);- }- }}- >- {hasChildren() ? (isExpanded() ? '▼' : '▶') : ''}- </div>- <div class="mr-2">{<EntityIcon targetType="project" />}</div>- <div class="flex-1 text-sm truncate">{project.name}</div>- <Show when={searchQuery()}>- <div class="text-xs text-ink-placeholder ml-2 truncate max-w-48">- {getProjectPath(project.id)}- </div>- </Show>+ <InlineEntity entity={entity} /></div>- );- }}- </For>+ )}+ </For>+ <Show when={props.entities.length > 2}>+ <div class="text-muted-foreground text-xs px-2 py-1">+ +{props.entities.length - 2} more+ </div>+ </Show>+ </div>+ </div>++ <div class="p-3 flex flex-col gap-3">+ <div class="border border-edge-muted rounded-sm overflow-hidden">+ <input+ ref={(el) => {+ requestAnimationFrame(() =>+ requestAnimationFrame(() => el.focus())+ );+ }}+ type="text"+ placeholder="Search folders..."+ value={searchQuery()}+ onInput={(e) => setSearchQuery(e.currentTarget.value)}+ onKeyDown={(e) => {+ const isDown =+ e.key === 'ArrowDown' || (e.ctrlKey && e.key === 'j');+ const isUp = e.key === 'ArrowUp' || (e.ctrlKey && e.key === 'k');+ if (isDown || isUp) {+ e.preventDefault();+ const itms = items();+ if (itms.length === 0) return;+ const fi = focusedIndex();+ const nextIndex = isDown+ ? Math.min(fi + 1, itms.length - 1)+ : Math.max(fi - 1, 0);+ setFocusedIndex(nextIndex);+ setSelectedProject(itms[nextIndex]);+ scrollToKeepGap({+ container: listRef,+ target: listRef.querySelector('.focused') as HTMLElement,+ align: isDown ? 'bottom' : 'top',+ });+ } else if (e.key === 'Enter') {+ e.preventDefault();+ finishEditing();+ }+ }}+ class="w-full px-3 py-2 text-sm bg-menu text-ink focus:outline-none border-b border-edge-muted"+ />+ <div class="h-64 overflow-auto" ref={listRef}>+ <For each={items()}>+ {(project, index) => {+ const isSelected = () => currentSelected()?.id === project.id;+ const isFocused = () => focusedIndex() === index();+ const isExpanded = () => expandedProjects()[project.id];+ const hasChildren = () => {+ const tree = projectTree();+ return (+ tree.itemMap[project.id]?.children &&+ tree.itemMap[project.id].children!.length > 0+ );+ };++ return (+ <div+ class={`flex items-center px-2 py-1 cursor-pointer hover:bg-accent/10 ${+ isFocused() ? 'focused bg-accent/20' : ''+ } ${isSelected() ? 'bg-accent/10' : ''}`}+ style={{+ 'padding-left': `${(project.depth || 0) * 16 + 8}px`,+ }}+ onClick={() => {+ setSelectedProject(project);+ setFocusedIndex(index());+ scrollToKeepGap({+ container: listRef,+ target: listRef.querySelector(+ '.focused'+ ) as HTMLElement,+ align: 'top',+ });+ }}+ >+ <div+ class={`mr-2 w-4 h-4 flex items-center justify-center text-xs ${+ hasChildren() ? 'cursor-pointer' : 'opacity-20'+ }`}+ onClick={(e) => {+ e.stopPropagation();+ if (hasChildren()) {+ toggleExpanded(project.id);+ }+ }}+ >+ {hasChildren() ? (isExpanded() ? '▼' : '▶') : ''}+ </div>+ <div class="mr-2">+ {<EntityIcon targetType="project" />}+ </div>+ <div class="flex-1 text-sm truncate">{project.name}</div>+ <Show when={searchQuery()}>+ <div class="text-xs text-ink-placeholder ml-2 truncate max-w-48">+ {getProjectPath(project.id)}+ </div>+ </Show>+ </div>+ );+ }}+ </For>+ </div>+ </div>++ <div class="flex justify-end gap-2">+ <Button variant="ghost" class="rounded-xs" onClick={props.onCancel}>+ Cancel+ </Button>+ <Button+ type="button"+ variant="secondary"+ class="rounded-xs"+ onClick={finishEditing}+ disabled={!selectedProject()}+ >+ Move+ </Button>+ </div></div>- <BulkEditEntityModalActionFooter- onCancel={props.onCancel}- onConfirm={finishEditing}- confirmText="Move"- isDisabled={!selectedProject()}- /></div>);};diff --git a/js/app/packages/app/component/bulk-edit-entity/BulkRenameEntitiesView.tsx b/js/app/packages/app/component/bulk-edit-entity/BulkRenameEntitiesView.tsxindex ee2c0ce6ff..bda49d8442 100644--- a/js/app/packages/app/component/bulk-edit-entity/BulkRenameEntitiesView.tsx+++ b/js/app/packages/app/component/bulk-edit-entity/BulkRenameEntitiesView.tsx@@ -1,11 +1,11 @@import { SegmentedControl } from '@core/component/FormControls/SegmentControls';-import { createMemo, createSignal, onMount, Show } from 'solid-js';+import { createMemo, createSignal, For, onMount, Show } from 'solid-js';import { createBulkRenameDssEntityMutation } from '@macro-entity';-import type { EntityData } from '@entity';-import {- BulkEditEntityModalActionFooter,- BulkEditEntityModalTitle,-} from './BulkEditEntityModal';+import { type EntityData, InlineEntity } from '@entity';+import { Dialog } from '@kobalte/core/dialog';+import { Button } from '@ui/components/Button';+import { cn } from '@ui/utils/classname';+import CloseIcon from '@phosphor-icons/core/regular/x.svg?component-solid';type RenameMode = 'total' | 'prepend' | 'append' | 'replace';@@ -96,11 +96,39 @@ export const BulkRenameEntitiesView = (props: {};return (- <div class="w-full">- <BulkEditEntityModalTitle title="Rename" />+ <>+ <div class="shrink-0 flex flex-row items-center px-2 gap-1 border-b-1 border-b-edge-muted h-[40px]">+ <Dialog.CloseButton as={Button} variant="ghost" size="icon-sm">+ <CloseIcon />+ </Dialog.CloseButton>+ <Dialog.Title as="span" class="text-sm font-medium p-0 m-0">+ Rename+ </Dialog.Title>+ </div>++ <div class="p-2 border-b border-edge-muted">+ <div class="flex items-center gap-2">+ <For each={props.entities.slice(0, 2)}>+ {(entity) => (+ <div+ class={cn('bg-edge/20 px-2 py-1 truncate text-xs rounded-xs', {+ 'max-w-[50%]': props.entities.length === 2,+ })}+ >+ <InlineEntity entity={entity} />+ </div>+ )}+ </For>+ <Show when={props.entities.length > 2}>+ <div class="text-muted-foreground text-xs px-2 py-1">+ +{props.entities.length - 2} more+ </div>+ </Show>+ </div>+ </div>- <Show when={multi()}>- <div class="mb-3">+ <div class="p-3 flex flex-col gap-3">+ <Show when={multi()}><SegmentedControllabel="Mode"value={mode()}@@ -108,63 +136,69 @@ export const BulkRenameEntitiesView = (props: {onChange={(value) => setMode(value as RenameMode)}size="SM"/>- </div>- </Show>-- <div class="w-full focus-within:bracket-offset-2 mb-3">- <input- ref={(el) => {- inputRef = el;- onMount(() => {- setTimeout(() => {- inputRef?.focus();- inputRef?.select();- });- });- }}- value={editValue()}- onInput={(e) => setEditValue(e.currentTarget.value)}- onKeyDown={handleKeyDown}- class="w-full p-2 text-sm border-1 border-edge/20 bg-menu text-ink- placeholder:text-ink-placeholder focus:outline-none- selection:bg-ink selection:text-panel"- placeholder="Enter new text..."- />- </div>+ </Show>- {/* Extra inputs for replace mode */}- <Show when={multi() && mode() === 'replace'}>- <div class="flex flex-col gap-2 mb-4">+ <div class="w-full focus-within:bracket-offset-2"><input- class="p-1 text-sm border border-edge/20 bg-menu"- placeholder="Find…"- value={replaceFind()}- onInput={(e) => setReplaceFind(e.currentTarget.value)}- />- <input- class="p-1 text-sm border border-edge/20 bg-menu"- placeholder="Replace with…"- value={replaceWith()}- onInput={(e) => setReplaceWith(e.currentTarget.value)}+ ref={(el) => {+ inputRef = el;+ onMount(() => {+ setTimeout(() => {+ inputRef?.focus();+ inputRef?.select();+ });+ });+ }}+ value={editValue()}+ onInput={(e) => setEditValue(e.currentTarget.value)}+ onKeyDown={handleKeyDown}+ class="w-full p-2 text-sm border-1 border-edge/20 bg-menu text-ink+ placeholder:text-ink-placeholder focus:outline-none+ selection:bg-ink selection:text-panel"+ placeholder="Enter new text..."/></div>- </Show>-- {/* Preview */}- <Show when={multi() && mode() !== 'total'}>- <div class="text-xs opacity-70 mb-3">- Preview (first item):- <div class="mt-1 p-2 bg-surface border border-edge/10 rounded">- {previewName()}++ <Show when={multi() && mode() === 'replace'}>+ <div class="flex flex-col gap-2">+ <input+ class="p-1 text-sm border border-edge/20 bg-menu"+ placeholder="Find…"+ value={replaceFind()}+ onInput={(e) => setReplaceFind(e.currentTarget.value)}+ />+ <input+ class="p-1 text-sm border border-edge/20 bg-menu"+ placeholder="Replace with…"+ value={replaceWith()}+ onInput={(e) => setReplaceWith(e.currentTarget.value)}+ />+ </div>+ </Show>++ <Show when={multi() && mode() !== 'total'}>+ <div class="text-xs opacity-70">+ Preview (first item):+ <div class="mt-1 p-2 bg-surface border border-edge/10 rounded">+ {previewName()}+ </div></div>+ </Show>++ <div class="flex justify-end gap-2">+ <Button variant="ghost" class="rounded-xs" onClick={props.onCancel}>+ Cancel+ </Button>+ <Button+ type="button"+ variant="secondary"+ class="rounded-xs"+ onClick={finishEditing}+ >+ Rename+ </Button></div>- </Show>-- <BulkEditEntityModalActionFooter- onCancel={props.onCancel}- onConfirm={finishEditing}- confirmText="Rename"- />- </div>+ </div>+ </>);};