@dxos/react-ui-mosaic 0.9.0 → 0.9.1-staging.ee54ba693a

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.
Files changed (64) hide show
  1. package/dist/lib/browser/{chunk-I3M5WM6C.mjs → chunk-OBVIYZLR.mjs} +182 -43
  2. package/dist/lib/browser/chunk-OBVIYZLR.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +20 -17
  4. package/dist/lib/browser/index.mjs.map +3 -3
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/testing/index.mjs +13 -9
  7. package/dist/lib/browser/testing/index.mjs.map +3 -3
  8. package/dist/lib/node-esm/{chunk-DVJLDZLE.mjs → chunk-4IEMCMIV.mjs} +182 -43
  9. package/dist/lib/node-esm/chunk-4IEMCMIV.mjs.map +7 -0
  10. package/dist/lib/node-esm/index.mjs +20 -17
  11. package/dist/lib/node-esm/index.mjs.map +3 -3
  12. package/dist/lib/node-esm/meta.json +1 -1
  13. package/dist/lib/node-esm/testing/index.mjs +13 -9
  14. package/dist/lib/node-esm/testing/index.mjs.map +3 -3
  15. package/dist/types/src/components/Board/Board.d.ts +1 -1
  16. package/dist/types/src/components/Board/Board.d.ts.map +1 -1
  17. package/dist/types/src/components/Board/Board.stories.d.ts +2 -2
  18. package/dist/types/src/components/Board/Board.stories.d.ts.map +1 -1
  19. package/dist/types/src/components/Board/Item.d.ts.map +1 -1
  20. package/dist/types/src/components/Focus/Focus.d.ts +1 -1
  21. package/dist/types/src/components/Focus/Focus.d.ts.map +1 -1
  22. package/dist/types/src/components/Mosaic/Container.d.ts +10 -1
  23. package/dist/types/src/components/Mosaic/Container.d.ts.map +1 -1
  24. package/dist/types/src/components/Mosaic/DragHandle.d.ts +28 -0
  25. package/dist/types/src/components/Mosaic/DragHandle.d.ts.map +1 -0
  26. package/dist/types/src/components/Mosaic/Mosaic.d.ts +18 -2
  27. package/dist/types/src/components/Mosaic/Mosaic.d.ts.map +1 -1
  28. package/dist/types/src/components/Mosaic/Placeholder.d.ts +2 -2
  29. package/dist/types/src/components/Mosaic/Placeholder.d.ts.map +1 -1
  30. package/dist/types/src/components/Mosaic/ResizeHandle.d.ts +14 -0
  31. package/dist/types/src/components/Mosaic/ResizeHandle.d.ts.map +1 -0
  32. package/dist/types/src/components/Mosaic/ResizeHandle.stories.d.ts +12 -0
  33. package/dist/types/src/components/Mosaic/ResizeHandle.stories.d.ts.map +1 -0
  34. package/dist/types/src/components/Mosaic/Root.d.ts +1 -1
  35. package/dist/types/src/components/Mosaic/Root.d.ts.map +1 -1
  36. package/dist/types/src/components/Mosaic/Stack.d.ts +1 -1
  37. package/dist/types/src/components/Mosaic/Stack.d.ts.map +1 -1
  38. package/dist/types/src/components/Mosaic/Tile.d.ts +34 -0
  39. package/dist/types/src/components/Mosaic/Tile.d.ts.map +1 -1
  40. package/dist/types/src/components/Mosaic/styles.d.ts.map +1 -1
  41. package/dist/types/src/testing/DefaultStackTile.d.ts.map +1 -1
  42. package/dist/types/src/testing/types.d.ts +10 -12
  43. package/dist/types/src/testing/types.d.ts.map +1 -1
  44. package/dist/types/tsconfig.tsbuildinfo +1 -1
  45. package/package.json +33 -33
  46. package/src/components/Board/Board.stories.tsx +3 -3
  47. package/src/components/Board/Board.tsx +1 -1
  48. package/src/components/Board/Item.tsx +20 -12
  49. package/src/components/Focus/Focus.tsx +1 -1
  50. package/src/components/Mosaic/Container.tsx +21 -7
  51. package/src/components/Mosaic/DragHandle.tsx +75 -0
  52. package/src/components/Mosaic/Mosaic.tsx +12 -4
  53. package/src/components/Mosaic/Placeholder.tsx +4 -2
  54. package/src/components/Mosaic/ResizeHandle.stories.tsx +119 -0
  55. package/src/components/Mosaic/ResizeHandle.tsx +56 -0
  56. package/src/components/Mosaic/Root.tsx +3 -1
  57. package/src/components/Mosaic/Stack.tsx +23 -2
  58. package/src/components/Mosaic/Tile.tsx +82 -4
  59. package/src/components/Mosaic/styles.ts +4 -3
  60. package/src/components/SearchStack/SearchStack.tsx +1 -1
  61. package/src/testing/DefaultStackTile.tsx +6 -4
  62. package/src/testing/types.ts +14 -14
  63. package/dist/lib/browser/chunk-I3M5WM6C.mjs.map +0 -7
  64. package/dist/lib/node-esm/chunk-DVJLDZLE.mjs.map +0 -7
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/testing/decorator.tsx", "../../../../src/testing/types.ts", "../../../../src/testing/CardContainer.tsx", "../../../../src/testing/DefaultStackTile.tsx"],
4
- "sourcesContent": ["//\n// Copyright 2026 DXOS.org\n//\n\nimport { type Decorator } from '@storybook/react-vite';\nimport React from 'react';\n\nimport { Mosaic } from '../components';\n\nexport const withMosaic = (): Decorator => {\n return (Story) => (\n <Mosaic.Root>\n <Story />\n </Mosaic.Root>\n );\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { DXN, Ref, Type } from '@dxos/echo';\nimport { EntityId } from '@dxos/keys';\n\n//\n// Test Data\n//\n\nexport const TestItem = Schema.Struct({\n name: Schema.String,\n description: Schema.optional(Schema.String),\n label: Schema.optional(Schema.String),\n}).pipe(Type.makeObject(DXN.make('com.example.type.item', '0.1.0')));\n\nexport type TestItem = Type.InstanceType<typeof TestItem>;\n\nexport const TestColumn = Schema.Struct({\n id: EntityId,\n name: Schema.String,\n items: Schema.mutable(Schema.Array(Ref.Ref(TestItem))),\n}).pipe(Type.makeObject(DXN.make('com.example.type.column', '0.1.0')));\n\nexport type TestColumn = Type.InstanceType<typeof TestColumn>;\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport React, { type PropsWithChildren } from 'react';\n\nimport { Icon, Popover } from '@dxos/react-ui';\nimport { ResizeHandle, type Size, resizeAttributes, sizeStyle } from '@dxos/react-ui-dnd';\n\nconst DEFAULT_BLOCK_SIZE = 22;\nconst MIN_BLOCK_SIZE = 8;\n\n//\n// Card container.\n//\n\nexport type CardContainerProps = PropsWithChildren<{ role?: 'popover' | 'intrinsic'; icon?: string }>;\n\nexport const CardContainer = ({ children, role, icon = 'ph--arrow-line-down--regular' }: CardContainerProps) => {\n switch (role) {\n case 'popover':\n return (\n <div className='flex justify-center'>\n <PopoverCardContainer icon={icon}>{children}</PopoverCardContainer>\n </div>\n );\n case 'intrinsic':\n default:\n return <IntrinsicCardContainer>{children}</IntrinsicCardContainer>;\n }\n};\n\n//\n// Popover\n//\n\nexport type PopoverCardContainerProps = PropsWithChildren<{ icon?: string }>;\n\nexport const PopoverCardContainer = ({\n children,\n icon = 'ph--arrow-line-down--regular',\n}: PopoverCardContainerProps) => {\n return (\n <Popover.Root open>\n <Popover.Trigger asChild>\n <Icon icon={icon} />\n </Popover.Trigger>\n <Popover.Portal>\n <Popover.Content onOpenAutoFocus={(event: Event) => event.preventDefault()}>\n <Popover.Viewport classNames='dx-card-popover'>{children}</Popover.Viewport>\n <Popover.Arrow />\n </Popover.Content>\n </Popover.Portal>\n </Popover.Root>\n );\n};\n\n//\n// Intrinsic card container (size constrained by card itself).\n//\n\nexport type IntrinsicCardContainerProps = PropsWithChildren<{\n defaultSize?: Size;\n size?: Size;\n onSizeChange?: (size: Size, commit?: boolean) => void;\n}>;\n\nexport const IntrinsicCardContainer = ({\n children,\n defaultSize,\n size: propSize,\n onSizeChange,\n}: IntrinsicCardContainerProps) => {\n const [size = DEFAULT_BLOCK_SIZE, setSize] = useControllableState<Size>({\n prop: propSize,\n defaultProp: defaultSize,\n onChange: onSizeChange,\n });\n\n return (\n <div\n className='relative p-2 grid overflow-hidden border-2 border-dashed border-green-500 rounded-lg'\n style={sizeStyle(size, 'horizontal')}\n {...resizeAttributes}\n >\n <div className='dx-container flex flex-col'>{children}</div>\n <ResizeHandle\n side='inline-end'\n fallbackSize={DEFAULT_BLOCK_SIZE}\n minSize={MIN_BLOCK_SIZE}\n size={size}\n onSizeChange={setSize}\n />\n </div>\n );\n};\n", "//\n// Copyright 2026 DXOS.org\n//\n\nimport React, { useMemo, useRef, useState } from 'react';\n\nimport { Obj } from '@dxos/echo';\nimport { Card, Toolbar } from '@dxos/react-ui';\nimport { Menu, createMenuAction } from '@dxos/react-ui-menu';\nimport { JsonHighlighter } from '@dxos/react-ui-syntax-highlighter';\n\nimport { Focus, Mosaic, type MosaicStackTileComponent } from '../components';\n\nexport const DefaultStackTile: MosaicStackTileComponent<Obj.Any> = (props) => {\n const dragHandleRef = useRef<HTMLButtonElement>(null);\n const [open, setOpen] = useState(false);\n const menuItems = useMemo(\n () => [\n createMenuAction('toggle-details', () => setOpen((prev) => !prev), {\n label: open ? 'Hide details' : 'Show details',\n icon: 'ph--circle-dashed--regular',\n }),\n ],\n [open],\n );\n\n return (\n <Menu.Root>\n {/*\n * `Mosaic.Tile` sets `aria-current` from `props.current`, which the\n * Slot composition propagates down to `Card.Root`'s div. That's what\n * makes `dx-current` (an `aria-[current=true]:` utility) actually\n * fire here. See `ui-theme/src/css/components/selected.md`.\n */}\n <Mosaic.Tile {...props} asChild>\n <Focus.Item asChild>\n <Card.Root className='dx-current dx-hover'>\n <Card.Header>\n <Card.DragHandle ref={dragHandleRef} />\n <Card.Title>{Obj.getLabel(props.data) ?? props.data.id}</Card.Title>\n <Menu.Trigger asChild disabled={!menuItems?.length}>\n <Toolbar.IconButton iconOnly variant='ghost' icon='ph--dots-three-vertical--regular' label='Menu' />\n </Menu.Trigger>\n <Menu.Content items={menuItems} />\n </Card.Header>\n {open && (\n <Card.Row>\n <JsonHighlighter data={props.data} classNames='text-xs' />\n </Card.Row>\n )}\n </Card.Root>\n </Focus.Item>\n </Mosaic.Tile>\n </Menu.Root>\n );\n};\n\nDefaultStackTile.displayName = 'DefaultStackTile';\n"],
5
- "mappings": ";;;;;;AAKA,OAAOA,WAAW;AAIX,IAAMC,aAAa,MAAA;AACxB,SAAO,CAACC,UACN,sBAAA,cAACC,OAAOC,MAAI,MACV,sBAAA,cAACF,OAAAA,IAAAA,CAAAA;AAGP;;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AACF,SAAAA;KACV,gBAAAL,OAAA,cAACQ,KAAKN,MAAI;IAACO,WAAU;KACnB,gBAAAT,OAAA,cAACQ,KAAKE,QAAM,MACV,gBAAAV,OAAA,cAACQ,KAAKG,YAAU;IAACC,KAAKvB;MACtB,gBAAAW,OAAA,cAACQ,KAAKK,OAAK,MAAEC,IAAIC,SAAS3B,MAAM4B,IAAI,KAAK5B,MAAM4B,KAAKC,EAAE,GACtD,gBAAAjB,OAAA,cAACC,KAAKiB,SAAO;IAACb,SAAAA;IAAQc,UAAU,CAACzB,WAAW0B;KAC1C,gBAAApB,OAAA,cAACqB,QAAQC,YAAU;IAACC,UAAAA;IAASC,SAAQ;IAAQzB,MAAK;IAAmCD,OAAM;OAE7F,gBAAAE,OAAA,cAACC,KAAKwB,SAAO;IAACC,OAAOhC;OAEtBH,QACC,gBAAAS,OAAA,cAACQ,KAAKmB,KAAG,MACP,gBAAA3B,OAAA,cAAC4B,iBAAAA;IAAgBZ,MAAM5B,MAAM4B;IAAMa,YAAW;;AAQ9D;AAEA1C,iBAAiB2C,cAAc;",
6
- "names": ["React", "withMosaic", "Story", "Mosaic", "Root", "Schema", "DXN", "Ref", "Type", "EntityId", "TestItem", "Struct", "name", "String", "description", "optional", "label", "pipe", "makeObject", "make", "TestColumn", "id", "items", "mutable", "Array", "useControllableState", "React", "Icon", "Popover", "ResizeHandle", "resizeAttributes", "sizeStyle", "DEFAULT_BLOCK_SIZE", "MIN_BLOCK_SIZE", "CardContainer", "children", "role", "icon", "div", "className", "PopoverCardContainer", "IntrinsicCardContainer", "Root", "open", "Trigger", "asChild", "Portal", "Content", "onOpenAutoFocus", "event", "preventDefault", "Viewport", "classNames", "Arrow", "defaultSize", "size", "propSize", "onSizeChange", "setSize", "prop", "defaultProp", "onChange", "style", "side", "fallbackSize", "minSize", "React", "useMemo", "useRef", "useState", "Obj", "Card", "Toolbar", "Menu", "createMenuAction", "JsonHighlighter", "DefaultStackTile", "props", "dragHandleRef", "useRef", "open", "setOpen", "useState", "menuItems", "useMemo", "createMenuAction", "prev", "label", "icon", "React", "Menu", "Root", "Mosaic", "Tile", "asChild", "Focus", "Item", "Card", "className", "Header", "DragHandle", "ref", "Title", "Obj", "getLabel", "data", "id", "Trigger", "disabled", "length", "Toolbar", "IconButton", "iconOnly", "variant", "Content", "items", "Row", "JsonHighlighter", "classNames", "displayName"]
4
+ "sourcesContent": ["//\n// Copyright 2026 DXOS.org\n//\n\nimport { type Decorator } from '@storybook/react-vite';\nimport React from 'react';\n\nimport { Mosaic } from '../components';\n\nexport const withMosaic = (): Decorator => {\n return (Story) => (\n <Mosaic.Root>\n <Story />\n </Mosaic.Root>\n );\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { DXN, Ref, Type } from '@dxos/echo';\nimport { EntityId } from '@dxos/keys';\n\n//\n// Test Data\n//\n\nexport class TestItem extends Type.makeObject<TestItem>(DXN.make('com.example.type.item', '0.1.0'))(\n Schema.Struct({\n name: Schema.String,\n description: Schema.optional(Schema.String),\n label: Schema.optional(Schema.String),\n }),\n) {}\n\nexport class TestColumn extends Type.makeObject<TestColumn>(DXN.make('com.example.type.column', '0.1.0'))(\n Schema.Struct({\n id: EntityId,\n name: Schema.String,\n items: Schema.mutable(Schema.Array(Ref.Ref(TestItem))),\n }),\n) {}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport React, { type PropsWithChildren } from 'react';\n\nimport { Icon, Popover } from '@dxos/react-ui';\nimport { ResizeHandle, type Size, resizeAttributes, sizeStyle } from '@dxos/react-ui-dnd';\n\nconst DEFAULT_BLOCK_SIZE = 22;\nconst MIN_BLOCK_SIZE = 8;\n\n//\n// Card container.\n//\n\nexport type CardContainerProps = PropsWithChildren<{ role?: 'popover' | 'intrinsic'; icon?: string }>;\n\nexport const CardContainer = ({ children, role, icon = 'ph--arrow-line-down--regular' }: CardContainerProps) => {\n switch (role) {\n case 'popover':\n return (\n <div className='flex justify-center'>\n <PopoverCardContainer icon={icon}>{children}</PopoverCardContainer>\n </div>\n );\n case 'intrinsic':\n default:\n return <IntrinsicCardContainer>{children}</IntrinsicCardContainer>;\n }\n};\n\n//\n// Popover\n//\n\nexport type PopoverCardContainerProps = PropsWithChildren<{ icon?: string }>;\n\nexport const PopoverCardContainer = ({\n children,\n icon = 'ph--arrow-line-down--regular',\n}: PopoverCardContainerProps) => {\n return (\n <Popover.Root open>\n <Popover.Trigger asChild>\n <Icon icon={icon} />\n </Popover.Trigger>\n <Popover.Portal>\n <Popover.Content onOpenAutoFocus={(event: Event) => event.preventDefault()}>\n <Popover.Viewport classNames='dx-card-popover'>{children}</Popover.Viewport>\n <Popover.Arrow />\n </Popover.Content>\n </Popover.Portal>\n </Popover.Root>\n );\n};\n\n//\n// Intrinsic card container (size constrained by card itself).\n//\n\nexport type IntrinsicCardContainerProps = PropsWithChildren<{\n defaultSize?: Size;\n size?: Size;\n onSizeChange?: (size: Size, commit?: boolean) => void;\n}>;\n\nexport const IntrinsicCardContainer = ({\n children,\n defaultSize,\n size: propSize,\n onSizeChange,\n}: IntrinsicCardContainerProps) => {\n const [size = DEFAULT_BLOCK_SIZE, setSize] = useControllableState<Size>({\n prop: propSize,\n defaultProp: defaultSize,\n onChange: onSizeChange,\n });\n\n return (\n <div\n className='relative p-2 grid overflow-hidden border-2 border-dashed border-green-500 rounded-lg'\n style={sizeStyle(size, 'horizontal')}\n {...resizeAttributes}\n >\n <div className='dx-container flex flex-col'>{children}</div>\n <ResizeHandle\n side='inline-end'\n fallbackSize={DEFAULT_BLOCK_SIZE}\n minSize={MIN_BLOCK_SIZE}\n size={size}\n onSizeChange={setSize}\n />\n </div>\n );\n};\n", "//\n// Copyright 2026 DXOS.org\n//\n\nimport React, { useMemo, useRef, useState } from 'react';\n\nimport { Obj } from '@dxos/echo';\nimport { Card, IconButton } from '@dxos/react-ui';\nimport { Menu, createMenuAction } from '@dxos/react-ui-menu';\nimport { JsonHighlighter } from '@dxos/react-ui-syntax-highlighter';\n\nimport { Focus, Mosaic, type MosaicStackTileComponent } from '../components';\n\nexport const DefaultStackTile: MosaicStackTileComponent<Obj.Any> = (props) => {\n const dragHandleRef = useRef<HTMLButtonElement>(null);\n const [open, setOpen] = useState(false);\n const menuItems = useMemo(\n () => [\n createMenuAction('toggle-details', () => setOpen((prev) => !prev), {\n label: open ? 'Hide details' : 'Show details',\n icon: 'ph--circle-dashed--regular',\n }),\n ],\n [open],\n );\n\n return (\n <Menu.Root>\n {/*\n * `Mosaic.Tile` sets `aria-current` from `props.current`, which the\n * Slot composition propagates down to `Card.Root`'s div. That's what\n * makes `dx-current` (an `aria-[current=true]:` utility) actually\n * fire here. See `ui-theme/src/css/components/selected.md`.\n */}\n <Mosaic.Tile {...props} asChild>\n <Focus.Item asChild>\n <Card.Root className='dx-current dx-hover'>\n <Card.Header>\n <Card.DragHandle ref={dragHandleRef} />\n <Card.Title>{Obj.getLabel(props.data) ?? props.data.id}</Card.Title>\n <Card.Block end>\n <Menu.Trigger asChild disabled={!menuItems?.length}>\n <IconButton iconOnly variant='ghost' icon='ph--dots-three-vertical--regular' label='Menu' />\n </Menu.Trigger>\n </Card.Block>\n <Menu.Content items={menuItems} />\n </Card.Header>\n {open && (\n <Card.Row>\n <JsonHighlighter data={props.data} classNames='text-xs' />\n </Card.Row>\n )}\n </Card.Root>\n </Focus.Item>\n </Mosaic.Tile>\n </Menu.Root>\n );\n};\n\nDefaultStackTile.displayName = 'DefaultStackTile';\n"],
5
+ "mappings": ";;;;;;AAKA,OAAOA,WAAW;AAIX,IAAMC,aAAa,MAAA;AACxB,SAAO,CAACC,UACN,sBAAA,cAACC,OAAOC,MAAI,MACV,sBAAA,cAACF,OAAAA,IAAAA,CAAAA;AAGP;;;ACXA,YAAYG,YAAY;AAExB,SAASC,KAAKC,KAAKC,YAAY;AAC/B,SAASC,gBAAgB;AAMlB,IAAMC,WAAN,cAAuBF,KAAKG,WAAqBL,IAAIM,KAA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AV,OAAA,cAACQ,KAAKG,YAAU;IAACC,KAAKvB;MACtB,gBAAAW,OAAA,cAACQ,KAAKK,OAAK,MAAEC,IAAIC,SAAS3B,MAAM4B,IAAI,KAAK5B,MAAM4B,KAAKC,EAAE,GACtD,gBAAAjB,OAAA,cAACQ,KAAKU,OAAK;IAACC,KAAAA;KACV,gBAAAnB,OAAA,cAACC,KAAKmB,SAAO;IAACf,SAAAA;IAAQgB,UAAU,CAAC3B,WAAW4B;KAC1C,gBAAAtB,OAAA,cAACuB,YAAAA;IAAWC,UAAAA;IAASC,SAAQ;IAAQ1B,MAAK;IAAmCD,OAAM;QAGvF,gBAAAE,OAAA,cAACC,KAAKyB,SAAO;IAACC,OAAOjC;OAEtBH,QACC,gBAAAS,OAAA,cAACQ,KAAKoB,KAAG,MACP,gBAAA5B,OAAA,cAAC6B,iBAAAA;IAAgBb,MAAM5B,MAAM4B;IAAMc,YAAW;;AAQ9D;AAEA3C,iBAAiB4C,cAAc;",
6
+ "names": ["React", "withMosaic", "Story", "Mosaic", "Root", "Schema", "DXN", "Ref", "Type", "EntityId", "TestItem", "makeObject", "make", "Struct", "name", "String", "description", "optional", "label", "TestColumn", "id", "items", "mutable", "Array", "useControllableState", "React", "Icon", "Popover", "ResizeHandle", "resizeAttributes", "sizeStyle", "DEFAULT_BLOCK_SIZE", "MIN_BLOCK_SIZE", "CardContainer", "children", "role", "icon", "div", "className", "PopoverCardContainer", "IntrinsicCardContainer", "Root", "open", "Trigger", "asChild", "Portal", "Content", "onOpenAutoFocus", "event", "preventDefault", "Viewport", "classNames", "Arrow", "defaultSize", "size", "propSize", "onSizeChange", "setSize", "prop", "defaultProp", "onChange", "style", "side", "fallbackSize", "minSize", "React", "useMemo", "useRef", "useState", "Obj", "Card", "IconButton", "Menu", "createMenuAction", "JsonHighlighter", "DefaultStackTile", "props", "dragHandleRef", "useRef", "open", "setOpen", "useState", "menuItems", "useMemo", "createMenuAction", "prev", "label", "icon", "React", "Menu", "Root", "Mosaic", "Tile", "asChild", "Focus", "Item", "Card", "className", "Header", "DragHandle", "ref", "Title", "Obj", "getLabel", "data", "id", "Block", "end", "Trigger", "disabled", "length", "IconButton", "iconOnly", "variant", "Content", "items", "Row", "JsonHighlighter", "classNames", "displayName"]
7
7
  }
@@ -42,9 +42,10 @@ var styles = {
42
42
  ],
43
43
  content: [
44
44
  "transition-all duration-0",
45
- // TODO(burdon): Don't animate open if placeholder is the source.
46
- // TODO(burdon): Flickers when start to drag since source is removed and then the placeholder shows up.
47
- // - Use absolute positioning?
45
+ // Placeholders open instantly (`duration-0`). The source slot is reserved on drag start by
46
+ // activating its placeholder (see Stack.tsx), so the stack no longer collapses/flickers when the
47
+ // dragged item is removed. NOTE: if the open animation below is ever enabled, exempt the source
48
+ // placeholder — animating its reserved gap from 0 would reintroduce the start-of-drag flicker.
48
49
  // 'group-data-[mosaic-placeholder-state=active]:duration-200',
49
50
  "group-data-[mosaic-placeholder-orientation=vertical]:h-0",
50
51
  "group-data-[mosaic-placeholder-orientation=vertical]:group-data-[mosaic-placeholder-state=active]:h-[var(--mosaic-placeholder-height)]",
@@ -145,6 +146,8 @@ var MosaicRoot = /* @__PURE__ */ forwardRef(({ children, asChild, debug }, forwa
145
146
  };
146
147
  let noTargetTimeout;
147
148
  return combine(monitorForElements({
149
+ // Only monitor Mosaic tile drags; other pragmatic-dnd sources under this root are not ours to handle.
150
+ canMonitor: ({ source }) => source.data.type === "tile",
148
151
  /**
149
152
  * Dragging started within any container.
150
153
  */
@@ -152,7 +155,7 @@ var MosaicRoot = /* @__PURE__ */ forwardRef(({ children, asChild, debug }, forwa
152
155
  log("Root.onDragStart", {
153
156
  source: source.data,
154
157
  location: location.current.dropTargets.map((target) => target.data)
155
- }, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 96, S: void 0 });
158
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 98, S: void 0 });
156
159
  handleChange({
157
160
  source,
158
161
  location
@@ -166,7 +169,7 @@ var MosaicRoot = /* @__PURE__ */ forwardRef(({ children, asChild, debug }, forwa
166
169
  log("Root.onDropTargetChange", {
167
170
  source: source.data,
168
171
  location: location.current.dropTargets.map((target) => target.data)
169
- }, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 109, S: void 0 });
172
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 111, S: void 0 });
170
173
  if (location.current.dropTargets.length === 0) {
171
174
  noTargetTimeout = setTimeout(() => setDragging(void 0), 1e3);
172
175
  } else {
@@ -200,18 +203,18 @@ var MosaicRoot = /* @__PURE__ */ forwardRef(({ children, asChild, debug }, forwa
200
203
  log.info("Root.onDrop", {
201
204
  source: source.data,
202
205
  location: location.current.dropTargets.map((target) => target.data)
203
- }, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 142, S: void 0 });
206
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 144, S: void 0 });
204
207
  const { data: sourceData, handler: sourceHandler } = getSourceHandler(source);
205
208
  if (!sourceHandler) {
206
209
  log.warn("invalid source", {
207
210
  source: sourceData,
208
211
  handlers: Object.keys(handlers)
209
- }, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 149, S: void 0 });
212
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 151, S: void 0 });
210
213
  return;
211
214
  }
212
215
  try {
213
216
  if (location.current.dropTargets.length === 0) {
214
- log.info("cancelled", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 163, S: void 0 });
217
+ log.info("cancelled", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 165, S: void 0 });
215
218
  } else {
216
219
  const { data: targetData, handler: targetHandler } = getTargetHandler(location);
217
220
  if (!targetHandler) {
@@ -219,7 +222,7 @@ var MosaicRoot = /* @__PURE__ */ forwardRef(({ children, asChild, debug }, forwa
219
222
  source: sourceData,
220
223
  location,
221
224
  handlers: Object.keys(handlers)
222
- }, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 168, S: void 0 });
225
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 170, S: void 0 });
223
226
  return;
224
227
  }
225
228
  if (sourceHandler === targetHandler) {
@@ -231,7 +234,7 @@ var MosaicRoot = /* @__PURE__ */ forwardRef(({ children, asChild, debug }, forwa
231
234
  if (!sourceHandler.onTake) {
232
235
  log.warn("invalid source", {
233
236
  source: sourceData
234
- }, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 183, S: void 0 });
237
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 185, S: void 0 });
235
238
  return;
236
239
  }
237
240
  sourceHandler.onTake?.({
@@ -288,7 +291,7 @@ import { createContext as createContext2 } from "@radix-ui/react-context";
288
291
  import { Primitive as Primitive2 } from "@radix-ui/react-primitive";
289
292
  import { Slot as Slot2 } from "@radix-ui/react-slot";
290
293
  import { bind } from "bind-event-listener";
291
- import React2, { useCallback as useCallback2, useEffect as useEffect2, useMemo as useMemo2, useRef as useRef2, useState as useState2 } from "react";
294
+ import React2, { useCallback as useCallback2, useEffect as useEffect2, useImperativeHandle, useMemo as useMemo2, useRef as useRef2, useState as useState2 } from "react";
292
295
  import { composable, composableProps } from "@dxos/react-ui";
293
296
  import { isTruthy } from "@dxos/util";
294
297
  var MOSAIC_CONTAINER_NAME = "Mosaic.Container";
@@ -297,7 +300,7 @@ var MOSAIC_CONTAINER_STATE_ATTR = "mosaic-container-state";
297
300
  var MOSAIC_CONTAINER_PLACEHOLDER_WIDTH = "--mosaic-placeholder-width";
298
301
  var MOSAIC_CONTAINER_PLACEHOLDER_HEIGHT = "--mosaic-placeholder-height";
299
302
  var counter = 0;
300
- var MosaicContainer = composable(({ children, eventHandler: eventHandlerProp, orientation = "vertical", asChild, autoScroll: autoscrollElement, withFocus, currentId, onCurrentChange, selectedIds, onSelectionChange, debug, ...props }, forwardedRef) => {
303
+ var MosaicContainer = composable(({ children, eventHandler: eventHandlerProp, orientation = "vertical", asChild, autoScroll: autoscrollElement, withFocus, controllerRef, currentId, onCurrentChange, selectedIds, onSelectionChange, debug, ...props }, forwardedRef) => {
301
304
  const Comp = asChild ? Slot2 : Primitive2.div;
302
305
  const rootRef = useRef2(null);
303
306
  const composedRef = useComposedRefs2(rootRef, forwardedRef);
@@ -322,6 +325,9 @@ var MosaicContainer = composable(({ children, eventHandler: eventHandlerProp, or
322
325
  const registerScrollTo = useCallback2((fn) => {
323
326
  scrollToRef.current = fn;
324
327
  }, []);
328
+ useImperativeHandle(controllerRef, () => ({
329
+ scrollToItem: (id) => scrollToRef.current?.(id)
330
+ }), []);
325
331
  useEffect2(() => {
326
332
  if (currentId) {
327
333
  scrollToRef.current?.(currentId);
@@ -390,10 +396,8 @@ var MosaicContainer = composable(({ children, eventHandler: eventHandlerProp, or
390
396
  source: data2
391
397
  }) || false;
392
398
  },
393
- // TODO(burdon): Provide semantic intent to onDrop.
394
- // getDropEffect: () => {
395
- // return 'move';
396
- // },
399
+ // Reorder is a move, not a copy — otherwise the browser shows the green "+" copy cursor.
400
+ getDropEffect: () => "move",
397
401
  /**
398
402
  * Dragging started in this container.
399
403
  */
@@ -442,9 +446,9 @@ var MosaicContainer = composable(({ children, eventHandler: eventHandlerProp, or
442
446
  autoscrollElement && [
443
447
  autoScrollForElements({
444
448
  element: autoscrollElement,
445
- // canScroll: ({ element: _ }) => {
446
- // return true;
447
- // },
449
+ // Only autoscroll for tile (reorder) drags. Resize-handle drags carry no tile data, so
450
+ // resizing a tile near a viewport edge must not scroll the container.
451
+ canScroll: ({ source }) => getSourceData(source) != null,
448
452
  getAllowedAxis: () => orientation,
449
453
  getConfiguration: () => ({
450
454
  maxScrollSpeed: "fast"
@@ -501,13 +505,14 @@ import { composeRefs } from "@radix-ui/react-compose-refs";
501
505
  import { createContext as createContext3 } from "@radix-ui/react-context";
502
506
  import { Primitive as Primitive3 } from "@radix-ui/react-primitive";
503
507
  import { Slot as Slot3 } from "@radix-ui/react-slot";
504
- import React3, { useLayoutEffect, useMemo as useMemo3, useRef as useRef3, useState as useState3 } from "react";
508
+ import React3, { useCallback as useCallback3, useLayoutEffect, useMemo as useMemo3, useRef as useRef3, useState as useState3 } from "react";
505
509
  import { createPortal } from "react-dom";
506
510
  import { composableProps as composableProps2, slottable } from "@dxos/react-ui";
511
+ import { resizeAttributes, sizeStyle } from "@dxos/react-ui-dnd";
507
512
  var MOSAIC_TILE_NAME = "Mosaic.Tile";
508
513
  var [MosaicTileContextProvider, useMosaicTileContext] = createContext3("MosaicTile");
509
514
  var MOSAIC_TILE_STATE_ATTR = "mosaic-tile-state";
510
- var MosaicTile = slottable(({ children, asChild, dragHandle, allowedEdges: allowedEdgesProp, location, id, data: dataProp, draggable: draggableProp, current, selected, debug: _, ...props }, forwardedRef) => {
515
+ var MosaicTile = slottable(({ children, asChild, dragHandle: dragHandleProp, allowedEdges: allowedEdgesProp, location, id, data: dataProp, draggable: draggableProp, current, selected, size: sizeProp, onSizeChange, minSize, maxSize, debug: _, ...props }, forwardedRef) => {
511
516
  const Comp = asChild ? Slot3 : Primitive3.div;
512
517
  const rootRef = useRef3(null);
513
518
  const composedRef = composeRefs(rootRef, forwardedRef);
@@ -515,6 +520,17 @@ var MosaicTile = slottable(({ children, asChild, dragHandle, allowedEdges: allow
515
520
  const [state, setState] = useState3({
516
521
  type: "idle"
517
522
  });
523
+ const [registeredDragHandle, setRegisteredDragHandle] = useState3(null);
524
+ const dragHandle = dragHandleProp ?? registeredDragHandle;
525
+ const [size, setInternalSize] = useState3(sizeProp);
526
+ const setSize = useCallback3((nextSize, commit) => {
527
+ setInternalSize(nextSize);
528
+ if (commit) {
529
+ onSizeChange?.(nextSize);
530
+ }
531
+ }, [
532
+ onSizeChange
533
+ ]);
518
534
  const allowedEdges = useMemo3(() => allowedEdgesProp || (orientation === "vertical" ? [
519
535
  "top",
520
536
  "bottom"
@@ -552,7 +568,14 @@ var MosaicTile = slottable(({ children, asChild, dragHandle, allowedEdges: allow
552
568
  });
553
569
  }
554
570
  };
571
+ const handleNativeDragStart = (event) => {
572
+ if (event.dataTransfer) {
573
+ event.dataTransfer.effectAllowed = "move";
574
+ }
575
+ };
576
+ root.addEventListener("dragstart", handleNativeDragStart);
555
577
  return combine3(
578
+ () => root.removeEventListener("dragstart", handleNativeDragStart),
556
579
  // Source.
557
580
  draggable({
558
581
  element: root,
@@ -604,6 +627,8 @@ var MosaicTile = slottable(({ children, asChild, dragHandle, allowedEdges: allow
604
627
  source: data2
605
628
  }) || false;
606
629
  },
630
+ // Reorder is a move, not a copy — otherwise the browser shows the green "+" copy cursor.
631
+ getDropEffect: () => "move",
607
632
  onDragEnter: ({ self, source }) => {
608
633
  handleChange({
609
634
  self,
@@ -644,10 +669,34 @@ var MosaicTile = slottable(({ children, asChild, dragHandle, allowedEdges: allow
644
669
  const { className, ...rest } = composableProps2(props, {
645
670
  classNames: "relative outline-none"
646
671
  });
672
+ const vertical = orientation === "vertical";
673
+ const sized = size != null;
674
+ const bounded = sized || minSize != null || maxSize != null;
675
+ const sizeStyles = {
676
+ ...sized && sizeStyle(size, vertical ? "vertical" : "horizontal"),
677
+ ...minSize != null && {
678
+ [vertical ? "minBlockSize" : "minInlineSize"]: `${minSize}rem`
679
+ },
680
+ ...maxSize != null && {
681
+ [vertical ? "maxBlockSize" : "maxInlineSize"]: `${maxSize}rem`
682
+ }
683
+ };
647
684
  return /* @__PURE__ */ React3.createElement(MosaicTileContextProvider, {
648
- state
685
+ state,
686
+ setDragHandle: setRegisteredDragHandle,
687
+ size,
688
+ setSize,
689
+ minSize,
690
+ maxSize
649
691
  }, /* @__PURE__ */ React3.createElement(Comp, {
650
692
  ...rest,
693
+ ...bounded && resizeAttributes,
694
+ ...bounded && {
695
+ style: {
696
+ ...rest.style,
697
+ ...sizeStyles
698
+ }
699
+ },
651
700
  "data-object-id": id,
652
701
  [`data-${MOSAIC_TILE_STATE_ATTR}`]: state.type,
653
702
  role: "listitem",
@@ -671,12 +720,56 @@ var MosaicTile = slottable(({ children, asChild, dragHandle, allowedEdges: allow
671
720
  });
672
721
  MosaicTile.displayName = MOSAIC_TILE_NAME;
673
722
 
723
+ // src/components/Mosaic/DragHandle.tsx
724
+ import { composeRefs as composeRefs2 } from "@radix-ui/react-compose-refs";
725
+ import React4, { forwardRef as forwardRef2 } from "react";
726
+ import { Button, IconButton, useTranslation } from "@dxos/react-ui";
727
+ var MOSAIC_DRAG_HANDLE_NAME = "Mosaic.DragHandle";
728
+ var REACT_UI_TRANSLATION_KEY = "@dxos/react-ui";
729
+ var MosaicDragHandle = /* @__PURE__ */ forwardRef2(({ icon = "ph--dots-six-vertical--regular", label, variant = "ghost", classNames, testId, children }, forwardedRef) => {
730
+ const { t } = useTranslation(REACT_UI_TRANSLATION_KEY);
731
+ const { setDragHandle } = useMosaicTileContext(MOSAIC_DRAG_HANDLE_NAME);
732
+ const ref = composeRefs2(forwardedRef, setDragHandle);
733
+ const testIdProps = testId ? {
734
+ "data-testid": testId
735
+ } : {};
736
+ if (children) {
737
+ return /* @__PURE__ */ React4.createElement(Button, {
738
+ ref,
739
+ variant,
740
+ tabIndex: -1,
741
+ classNames: [
742
+ "grid place-items-center cursor-grab",
743
+ classNames
744
+ ],
745
+ ...testIdProps
746
+ }, children, /* @__PURE__ */ React4.createElement("span", {
747
+ className: "sr-only"
748
+ }, label ?? t("toolbar-drag-handle.label")));
749
+ }
750
+ return /* @__PURE__ */ React4.createElement(IconButton, {
751
+ ref,
752
+ iconOnly: true,
753
+ noTooltip: true,
754
+ tabIndex: -1,
755
+ variant,
756
+ icon,
757
+ label: label ?? t("toolbar-drag-handle.label"),
758
+ classNames: [
759
+ "cursor-grab",
760
+ classNames
761
+ ],
762
+ ...testIdProps
763
+ });
764
+ });
765
+ MosaicDragHandle.displayName = MOSAIC_DRAG_HANDLE_NAME;
766
+
674
767
  // src/components/Mosaic/Placeholder.tsx
675
768
  import { DropIndicator as NaturalDropIndicator } from "@atlaskit/pragmatic-drag-and-drop-react-drop-indicator/box";
676
769
  import { dropTargetForElements as dropTargetForElements3 } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
677
770
  import { Primitive as Primitive4 } from "@radix-ui/react-primitive";
678
771
  import { Slot as Slot4 } from "@radix-ui/react-slot";
679
- import React4, { useLayoutEffect as useLayoutEffect2, useMemo as useMemo4, useRef as useRef4 } from "react";
772
+ import React5, { useLayoutEffect as useLayoutEffect2, useMemo as useMemo4, useRef as useRef4 } from "react";
680
773
  import { mx } from "@dxos/ui-theme";
681
774
  var MOSAIC_PLACEHOLDER_NAME = "Mosaic.Placeholder";
682
775
  var MOSAIC_PLACEHOLDER_ORIENTATION_ATTR = "mosaic-placeholder-orientation";
@@ -708,6 +801,8 @@ var MosaicPlaceholder = ({ classNames, children, asChild, orientation = "vertica
708
801
  source: data2
709
802
  }) || false;
710
803
  },
804
+ // Reorder is a move, not a copy — otherwise the browser shows the green "+" copy cursor.
805
+ getDropEffect: () => "move",
711
806
  onDragEnter: () => {
712
807
  setActiveLocation(data.location);
713
808
  },
@@ -724,7 +819,7 @@ var MosaicPlaceholder = ({ classNames, children, asChild, orientation = "vertica
724
819
  scrolling,
725
820
  setActiveLocation
726
821
  ]);
727
- return /* @__PURE__ */ React4.createElement(Comp, {
822
+ return /* @__PURE__ */ React5.createElement(Comp, {
728
823
  [`data-${MOSAIC_PLACEHOLDER_ORIENTATION_ATTR}`]: orientation,
729
824
  [`data-${MOSAIC_PLACEHOLDER_STATE_ATTR}`]: data.location === activeLocation ? "active" : "idle",
730
825
  [`data-${MOSAIC_PLACEHOLDER_LOCATION_ATTR}`]: String(location),
@@ -737,24 +832,46 @@ MosaicPlaceholder.displayName = MOSAIC_PLACEHOLDER_NAME;
737
832
  var DROP_INDICATOR_NAME = "Mosaic.DropIndicator";
738
833
  var MosaicDropIndicator = (props) => {
739
834
  const { state } = useMosaicTileContext(DROP_INDICATOR_NAME);
740
- return state.type === "target" && state.closestEdge ? /* @__PURE__ */ React4.createElement(NaturalDropIndicator, {
835
+ return state.type === "target" && state.closestEdge ? /* @__PURE__ */ React5.createElement(NaturalDropIndicator, {
741
836
  ...props,
742
837
  edge: state.closestEdge
743
838
  }) : null;
744
839
  };
745
840
  MosaicDropIndicator.displayName = DROP_INDICATOR_NAME;
746
841
 
842
+ // src/components/Mosaic/ResizeHandle.tsx
843
+ import React6 from "react";
844
+ import { ResizeHandle } from "@dxos/react-ui-dnd";
845
+ var MOSAIC_RESIZE_HANDLE_NAME = "Mosaic.ResizeHandle";
846
+ var MIN_WIDTH = 20;
847
+ var MIN_HEIGHT = 3;
848
+ var DEFAULT_EXTRINSIC_SIZE = 50;
849
+ var MosaicResizeHandle = ({ minSize, maxSize, fallbackSize = DEFAULT_EXTRINSIC_SIZE }) => {
850
+ const { orientation = "vertical" } = useMosaicContainerContext(MOSAIC_RESIZE_HANDLE_NAME);
851
+ const { size, setSize, minSize: tileMinSize, maxSize: tileMaxSize } = useMosaicTileContext(MOSAIC_RESIZE_HANDLE_NAME);
852
+ const horizontal = orientation === "horizontal";
853
+ return /* @__PURE__ */ React6.createElement(ResizeHandle, {
854
+ side: horizontal ? "inline-end" : "block-end",
855
+ fallbackSize,
856
+ minSize: minSize ?? tileMinSize ?? (horizontal ? MIN_WIDTH : MIN_HEIGHT),
857
+ maxSize: maxSize ?? tileMaxSize,
858
+ size,
859
+ onSizeChange: setSize
860
+ });
861
+ };
862
+ MosaicResizeHandle.displayName = MOSAIC_RESIZE_HANDLE_NAME;
863
+
747
864
  // src/components/Mosaic/Stack.tsx
748
865
  import { useComposedRefs as useComposedRefs3 } from "@radix-ui/react-compose-refs";
749
866
  import { useVirtualizer } from "@tanstack/react-virtual";
750
- import React5, { forwardRef as forwardRef2, Fragment, useCallback as useCallback3, useEffect as useEffect3, useRef as useRef5 } from "react";
867
+ import React7, { Fragment, forwardRef as forwardRef3, useCallback as useCallback4, useEffect as useEffect3, useLayoutEffect as useLayoutEffect3, useMemo as useMemo5, useRef as useRef5 } from "react";
751
868
  import { invariant } from "@dxos/invariant";
752
869
  import { composable as composable2, composableProps as composableProps3 } from "@dxos/react-ui";
753
870
  import { mx as mx2 } from "@dxos/ui-theme";
754
871
  var __dxlog_file2 = "/__w/dxos/dxos/packages/ui/react-ui-mosaic/src/components/Mosaic/Stack.tsx";
755
872
  var MOSAIC_STACK_NAME = "MosaicStack";
756
873
  var MosaicStackInner = composable2(({ orientation: orientationProp = "vertical", getId, items, scrollIntoView = true, Tile, draggable: draggable2 = true, debug, ...props }, forwardedRef) => {
757
- const { id, orientation = orientationProp, dragging, currentId, selectedIds, registerScrollTo } = useMosaicContainerContext(MOSAIC_STACK_NAME);
874
+ const { id, orientation = orientationProp, dragging, currentId, selectedIds, registerScrollTo, setActiveLocation } = useMosaicContainerContext(MOSAIC_STACK_NAME);
758
875
  const visibleItems = useVisibleItems({
759
876
  id,
760
877
  items,
@@ -762,8 +879,28 @@ var MosaicStackInner = composable2(({ orientation: orientationProp = "vertical",
762
879
  getId
763
880
  });
764
881
  invariant(orientation === "vertical" || orientation === "horizontal", `Invalid orientation: ${orientation}`, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 46, S: void 0, A: ["orientation === 'vertical' || orientation === 'horizontal'", "`Invalid orientation: ${orientation}`"] });
882
+ const draggingSource = dragging?.source.data;
883
+ const sourceIndex = useMemo5(() => {
884
+ if (!items || !draggingSource || draggingSource.containerId !== id) {
885
+ return -1;
886
+ }
887
+ return items.findIndex((item) => getId(item) === draggingSource.id);
888
+ }, [
889
+ items,
890
+ draggingSource,
891
+ id,
892
+ getId
893
+ ]);
894
+ useLayoutEffect3(() => {
895
+ if (sourceIndex >= 0) {
896
+ setActiveLocation(sourceIndex + 0.5);
897
+ }
898
+ }, [
899
+ sourceIndex,
900
+ setActiveLocation
901
+ ]);
765
902
  const rootRef = useRef5(null);
766
- const scrollToId = useCallback3((targetId) => {
903
+ const scrollToId = useCallback4((targetId) => {
767
904
  if (!scrollIntoView) {
768
905
  return;
769
906
  }
@@ -783,7 +920,7 @@ var MosaicStackInner = composable2(({ orientation: orientationProp = "vertical",
783
920
  scrollToId
784
921
  ]);
785
922
  const composedRef = useComposedRefs3(rootRef, forwardedRef);
786
- return /* @__PURE__ */ React5.createElement("div", {
923
+ return /* @__PURE__ */ React7.createElement("div", {
787
924
  ...composableProps3(props, {
788
925
  role: "list",
789
926
  classNames: [
@@ -793,12 +930,12 @@ var MosaicStackInner = composable2(({ orientation: orientationProp = "vertical",
793
930
  ]
794
931
  }),
795
932
  ref: composedRef
796
- }, draggable2 && /* @__PURE__ */ React5.createElement(InternalPlaceholder, {
933
+ }, draggable2 && /* @__PURE__ */ React7.createElement(InternalPlaceholder, {
797
934
  orientation,
798
935
  location: 0.5
799
- }), visibleItems?.map((item, index) => /* @__PURE__ */ React5.createElement(Fragment, {
936
+ }), visibleItems?.map((item, index) => /* @__PURE__ */ React7.createElement(Fragment, {
800
937
  key: getId(item)
801
- }, /* @__PURE__ */ React5.createElement(Tile, {
938
+ }, /* @__PURE__ */ React7.createElement(Tile, {
802
939
  id: getId(item),
803
940
  data: item,
804
941
  location: index + 1,
@@ -806,7 +943,7 @@ var MosaicStackInner = composable2(({ orientation: orientationProp = "vertical",
806
943
  current: getId(item) === currentId,
807
944
  selected: selectedIds?.has(getId(item)),
808
945
  debug
809
- }), draggable2 && /* @__PURE__ */ React5.createElement(InternalPlaceholder, {
946
+ }), draggable2 && /* @__PURE__ */ React7.createElement(InternalPlaceholder, {
810
947
  orientation,
811
948
  location: index + 1.5
812
949
  }))));
@@ -814,8 +951,8 @@ var MosaicStackInner = composable2(({ orientation: orientationProp = "vertical",
814
951
  MosaicStackInner.displayName = MOSAIC_STACK_NAME;
815
952
  var MosaicStack = MosaicStackInner;
816
953
  var MOSAIC_VIRTUAL_STACK_NAME = "MosaicVirtualStack";
817
- var MosaicVirtualStackInner = /* @__PURE__ */ forwardRef2(({ orientation = "vertical", getId, items, scrollIntoView = true, Tile, estimateSize, getScrollElement, overscan = 8, gap, onChange, draggable: draggable2 = true, debug, ...props }, forwardedRef) => {
818
- invariant(Tile, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 103, S: void 0, A: ["Tile", ""] });
954
+ var MosaicVirtualStackInner = /* @__PURE__ */ forwardRef3(({ orientation = "vertical", getId, items, scrollIntoView = true, Tile, estimateSize, getScrollElement, overscan = 8, gap, onChange, draggable: draggable2 = true, debug, ...props }, forwardedRef) => {
955
+ invariant(Tile, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 128, S: void 0, A: ["Tile", ""] });
819
956
  const { id, dragging, currentId, selectedIds, registerScrollTo } = useMosaicContainerContext(MOSAIC_VIRTUAL_STACK_NAME);
820
957
  const visibleItems = useVisibleItems({
821
958
  id,
@@ -840,7 +977,7 @@ var MosaicVirtualStackInner = /* @__PURE__ */ forwardRef2(({ orientation = "vert
840
977
  overscan,
841
978
  onChange
842
979
  });
843
- const scrollToId = useCallback3((targetId) => {
980
+ const scrollToId = useCallback4((targetId) => {
844
981
  const itemIndex = visibleItems.findIndex((item) => getId(item) === targetId);
845
982
  if (itemIndex >= 0) {
846
983
  if (!scrollIntoView) {
@@ -889,7 +1026,7 @@ var MosaicVirtualStackInner = /* @__PURE__ */ forwardRef2(({ orientation = "vert
889
1026
  };
890
1027
  }
891
1028
  };
892
- return /* @__PURE__ */ React5.createElement("div", {
1029
+ return /* @__PURE__ */ React7.createElement("div", {
893
1030
  ...composableProps3(props, {
894
1031
  role: "list",
895
1032
  classNames: [
@@ -914,7 +1051,7 @@ var MosaicVirtualStackInner = /* @__PURE__ */ forwardRef2(({ orientation = "vert
914
1051
  ref: forwardedRef
915
1052
  }, virtualItems.map(({ key, index, start }) => {
916
1053
  const { data, location } = getData(index);
917
- return /* @__PURE__ */ React5.createElement("div", {
1054
+ return /* @__PURE__ */ React7.createElement("div", {
918
1055
  key,
919
1056
  "data-index": index,
920
1057
  style: {
@@ -930,7 +1067,7 @@ var MosaicVirtualStackInner = /* @__PURE__ */ forwardRef2(({ orientation = "vert
930
1067
  }
931
1068
  },
932
1069
  ref: virtualizer.measureElement
933
- }, data ? /* @__PURE__ */ React5.createElement(Tile, {
1070
+ }, data ? /* @__PURE__ */ React7.createElement(Tile, {
934
1071
  id: getId(data),
935
1072
  data,
936
1073
  location,
@@ -938,7 +1075,7 @@ var MosaicVirtualStackInner = /* @__PURE__ */ forwardRef2(({ orientation = "vert
938
1075
  current: getId(data) === currentId,
939
1076
  selected: selectedIds?.has(getId(data)),
940
1077
  debug
941
- }) : /* @__PURE__ */ React5.createElement(InternalPlaceholder, {
1078
+ }) : /* @__PURE__ */ React7.createElement(InternalPlaceholder, {
942
1079
  orientation,
943
1080
  location
944
1081
  }));
@@ -948,10 +1085,10 @@ MosaicVirtualStackInner.displayName = MOSAIC_VIRTUAL_STACK_NAME;
948
1085
  var MosaicVirtualStack = MosaicVirtualStackInner;
949
1086
  MosaicVirtualStack[/* @__PURE__ */ Symbol.for("dxos.composable")] = true;
950
1087
  var InternalPlaceholder = (props) => {
951
- return /* @__PURE__ */ React5.createElement(MosaicPlaceholder, {
1088
+ return /* @__PURE__ */ React7.createElement(MosaicPlaceholder, {
952
1089
  ...props,
953
1090
  classNames: styles.placeholder.root
954
- }, /* @__PURE__ */ React5.createElement("div", {
1091
+ }, /* @__PURE__ */ React7.createElement("div", {
955
1092
  className: mx2("flex h-full bg-base-surface border border-dashed border-separator rounded-xs", styles.placeholder.content)
956
1093
  }));
957
1094
  };
@@ -962,6 +1099,8 @@ var Mosaic = {
962
1099
  Root: MosaicRoot,
963
1100
  Container: MosaicContainer,
964
1101
  Tile: MosaicTile,
1102
+ DragHandle: MosaicDragHandle,
1103
+ ResizeHandle: MosaicResizeHandle,
965
1104
  Placeholder: MosaicPlaceholder,
966
1105
  DropIndicator: MosaicDropIndicator,
967
1106
  Stack: MosaicStack,
@@ -979,4 +1118,4 @@ export {
979
1118
  useMosaicTileContext,
980
1119
  Mosaic
981
1120
  };
982
- //# sourceMappingURL=chunk-DVJLDZLE.mjs.map
1121
+ //# sourceMappingURL=chunk-4IEMCMIV.mjs.map