Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.
TypeScript ai-artartificial-intelligencegenerative-artimage-generationimg2imginpaintinglatent-diffusionlinuxmacosoutpaintingstable-diffusiontxt2imgwindows
feat(ui): let list rows carry detail content under the row
Josh Corbettdb275d2ba336
diff --git a/invokeai/frontend/webv2/src/platform/ui/list/ListItem.browser.test.tsx b/invokeai/frontend/webv2/src/platform/ui/list/ListItem.browser.test.tsxindex 80c9e11dbd..3829562db6 100644--- a/invokeai/frontend/webv2/src/platform/ui/list/ListItem.browser.test.tsx+++ b/invokeai/frontend/webv2/src/platform/ui/list/ListItem.browser.test.tsx@@ -65,6 +65,34 @@ describe('ListItem', () => {await userEvent.hover(primary());});+ it('keeps detail on the row surface outside the primary button, deferring to a menu it handles itself', async () => {+ const onContextMenu = vi.fn();++ await render(+ <ListItem+ detail={+ <div>+ <input aria-label="Weight" onContextMenu={(event) => event.preventDefault()} />+ <span>Plain detail</span>+ </div>+ }+ title="A concept"+ onContextMenu={onContextMenu}+ />+ );++ const input = host.querySelector('input')!;++ expect(input.closest('[role="listitem"]')).not.toBeNull();+ expect(primary().contains(input)).toBe(false);++ input.dispatchEvent(new MouseEvent('contextmenu', { bubbles: true, cancelable: true }));+ expect(onContextMenu).not.toHaveBeenCalled();++ host.querySelector('span')!.dispatchEvent(new MouseEvent('contextmenu', { bubbles: true, cancelable: true }));+ expect(onContextMenu).toHaveBeenCalledTimes(1);+ });+it('renders a static row without a press handler as plain content, not a button', async () => {await render(<ListItem title="Read only" />);diff --git a/invokeai/frontend/webv2/src/platform/ui/list/ListItem.tsx b/invokeai/frontend/webv2/src/platform/ui/list/ListItem.tsxindex 052694da66..483772261b 100644--- a/invokeai/frontend/webv2/src/platform/ui/list/ListItem.tsx+++ b/invokeai/frontend/webv2/src/platform/ui/list/ListItem.tsx@@ -34,6 +34,11 @@ export interface ListItemProps {trailing?: ReactNode;/** Controls that act on the row, rendered beside the primary button so they never nest inside it. */actions?: ReactNode;+ /**+ * Content under the row that belongs to it, such as a control tuning the item; it shares the row's surface but sits+ * outside the primary button, so it may hold controls. A context menu it handles itself takes precedence.+ */+ detail?: ReactNode;density?: ListDensity;/** The one row whose detail is open; announced with aria-current and filled with the accent tone. */isActive?: boolean;@@ -75,6 +80,7 @@ export const ListItem = ({checkLabel,density = 'regular',description,+ detail,isActive = false,isBusy = false,isChecked = false,@@ -102,7 +108,8 @@ export const ListItem = ({const handleContextMenu = useCallback((event: MouseEvent<HTMLDivElement>) => {- if (!onContextMenu) {+ // A nested control (e.g. a field in `detail`) that opened its own menu already claimed the gesture.+ if (!onContextMenu || event.defaultPrevented) {return;}@@ -231,6 +238,7 @@ export const ListItem = ({</chakra.div>)}{actions !== undefined && actions !== null ? <chakra.div css={styles.actions}>{actions}</chakra.div> : null}+ {detail !== undefined && detail !== null ? <chakra.div css={styles.detail}>{detail}</chakra.div> : null}</chakra.div>);};diff --git a/invokeai/frontend/webv2/src/platform/ui/theme/recipes.ts b/invokeai/frontend/webv2/src/platform/ui/theme/recipes.tsindex 32fe51c41e..db039fa223 100644--- a/invokeai/frontend/webv2/src/platform/ui/theme/recipes.ts+++ b/invokeai/frontend/webv2/src/platform/ui/theme/recipes.ts@@ -948,12 +948,26 @@ export const rowRecipe = defineRecipe({* the button has focus; the accent tone recolors muted text so it stays legible on the solid fill.*/export const listItemSlotRecipe = defineSlotRecipe({- slots: ['root', 'check', 'primary', 'body', 'titleLine', 'title', 'badges', 'description', 'trailing', 'actions'],+ slots: [+ 'root',+ 'check',+ 'primary',+ 'body',+ 'titleLine',+ 'title',+ 'badges',+ 'description',+ 'trailing',+ 'actions',+ 'detail',+ ],base: {root: {...rowSurface,alignItems: 'stretch',display: 'flex',+ // Lets `detail` take its own line under the row.+ flexWrap: 'wrap',minW: 0,position: 'relative','&:has([data-list-primary]:focus-visible)': rowFocusRing,@@ -1028,6 +1042,13 @@ export const listItemSlotRecipe = defineSlotRecipe({gap: '0.5',pe: '1',},+ // Row-owned content on its own line, inset to the primary button's text.+ detail: {+ flexBasis: '100%',+ minW: 0,+ pb: '2',+ px: '2',+ },},variants: {active: {