@dxos/react-ui-stack 0.8.4-main.67995b8 → 0.8.4-main.72ec0f3

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 (77) hide show
  1. package/dist/lib/browser/{chunk-P3TQV4BA.mjs → chunk-3F2KBXLP.mjs} +479 -195
  2. package/dist/lib/browser/chunk-3F2KBXLP.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +9 -1
  4. package/dist/lib/browser/meta.json +1 -1
  5. package/dist/lib/browser/playwright/index.mjs +4 -0
  6. package/dist/lib/browser/playwright/index.mjs.map +2 -2
  7. package/dist/lib/browser/testing/index.mjs +3 -3
  8. package/dist/lib/browser/testing/index.mjs.map +3 -3
  9. package/dist/lib/node-esm/{chunk-3WVEPAJ4.mjs → chunk-SYKFLQGK.mjs} +479 -195
  10. package/dist/lib/node-esm/chunk-SYKFLQGK.mjs.map +7 -0
  11. package/dist/lib/node-esm/index.mjs +9 -1
  12. package/dist/lib/node-esm/meta.json +1 -1
  13. package/dist/lib/node-esm/playwright/index.mjs +4 -0
  14. package/dist/lib/node-esm/playwright/index.mjs.map +2 -2
  15. package/dist/lib/node-esm/testing/index.mjs +3 -3
  16. package/dist/lib/node-esm/testing/index.mjs.map +3 -3
  17. package/dist/types/src/components/Image/Image.d.ts +14 -0
  18. package/dist/types/src/components/Image/Image.d.ts.map +1 -0
  19. package/dist/types/src/components/Image/Image.stories.d.ts +33 -0
  20. package/dist/types/src/components/Image/Image.stories.d.ts.map +1 -0
  21. package/dist/types/src/components/Image/index.d.ts +2 -0
  22. package/dist/types/src/components/Image/index.d.ts.map +1 -0
  23. package/dist/types/src/components/Stack/Stack.d.ts +15 -7
  24. package/dist/types/src/components/Stack/Stack.d.ts.map +1 -1
  25. package/dist/types/src/components/Stack/Stack.stories.d.ts +12 -3
  26. package/dist/types/src/components/Stack/Stack.stories.d.ts.map +1 -1
  27. package/dist/types/src/components/StackContext.d.ts +2 -1
  28. package/dist/types/src/components/StackContext.d.ts.map +1 -1
  29. package/dist/types/src/components/StackItem/StackItem.d.ts +7 -6
  30. package/dist/types/src/components/StackItem/StackItem.d.ts.map +1 -1
  31. package/dist/types/src/components/StackItem/StackItem.stories.d.ts +13 -5
  32. package/dist/types/src/components/StackItem/StackItem.stories.d.ts.map +1 -1
  33. package/dist/types/src/components/StackItem/StackItemContent.d.ts +20 -10
  34. package/dist/types/src/components/StackItem/StackItemContent.d.ts.map +1 -1
  35. package/dist/types/src/components/StackItem/StackItemHeading.d.ts +1 -1
  36. package/dist/types/src/components/StackItem/StackItemHeading.d.ts.map +1 -1
  37. package/dist/types/src/components/StackItem/StackItemResizeHandle.d.ts.map +1 -1
  38. package/dist/types/src/components/StackItem/StackItemSigil.d.ts.map +1 -1
  39. package/dist/types/src/components/index.d.ts +1 -0
  40. package/dist/types/src/components/index.d.ts.map +1 -1
  41. package/dist/types/src/exemplars/Card/Card.d.ts +23 -12
  42. package/dist/types/src/exemplars/Card/Card.d.ts.map +1 -1
  43. package/dist/types/src/exemplars/Card/Card.stories.d.ts +12 -4
  44. package/dist/types/src/exemplars/Card/Card.stories.d.ts.map +1 -1
  45. package/dist/types/src/exemplars/Card/fragments.d.ts +3 -2
  46. package/dist/types/src/exemplars/Card/fragments.d.ts.map +1 -1
  47. package/dist/types/src/exemplars/CardStack/CardStack.d.ts +3 -1
  48. package/dist/types/src/exemplars/CardStack/CardStack.d.ts.map +1 -1
  49. package/dist/types/src/exemplars/CardStack/CardStack.stories.d.ts +9 -3
  50. package/dist/types/src/exemplars/CardStack/CardStack.stories.d.ts.map +1 -1
  51. package/dist/types/src/hooks/useStackDropForElements.d.ts +3 -3
  52. package/dist/types/src/hooks/useStackDropForElements.d.ts.map +1 -1
  53. package/dist/types/src/testing/CardContainer.d.ts.map +1 -1
  54. package/dist/types/tsconfig.tsbuildinfo +1 -1
  55. package/package.json +27 -27
  56. package/src/components/Image/Image.stories.tsx +84 -0
  57. package/src/components/Image/Image.tsx +222 -0
  58. package/src/components/Image/index.ts +5 -0
  59. package/src/components/Stack/Stack.stories.tsx +8 -9
  60. package/src/components/Stack/Stack.tsx +222 -25
  61. package/src/components/StackContext.tsx +2 -1
  62. package/src/components/StackItem/StackItem.stories.tsx +16 -14
  63. package/src/components/StackItem/StackItem.tsx +26 -18
  64. package/src/components/StackItem/StackItemContent.tsx +20 -8
  65. package/src/components/StackItem/StackItemHeading.tsx +4 -8
  66. package/src/components/StackItem/StackItemResizeHandle.tsx +2 -1
  67. package/src/components/StackItem/StackItemSigil.tsx +2 -1
  68. package/src/components/index.ts +1 -0
  69. package/src/exemplars/Card/Card.stories.tsx +29 -43
  70. package/src/exemplars/Card/Card.tsx +46 -22
  71. package/src/exemplars/Card/fragments.ts +3 -2
  72. package/src/exemplars/CardStack/CardStack.stories.tsx +11 -10
  73. package/src/exemplars/CardStack/CardStack.tsx +12 -9
  74. package/src/hooks/useStackDropForElements.ts +43 -36
  75. package/src/testing/CardContainer.tsx +9 -6
  76. package/dist/lib/browser/chunk-P3TQV4BA.mjs.map +0 -7
  77. package/dist/lib/node-esm/chunk-3WVEPAJ4.mjs.map +0 -7
@@ -2,17 +2,14 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import '@dxos-theme';
6
-
7
5
  import { type Meta, type StoryObj } from '@storybook/react-vite';
8
6
  import React from 'react';
9
7
 
10
8
  import { faker } from '@dxos/random';
11
- import { withTheme } from '@dxos/storybook-utils';
9
+ import { withTheme } from '@dxos/react-ui/testing';
12
10
 
13
11
  import { Card } from './Card';
14
12
 
15
- // Set a seed for reproducible random values
16
13
  faker.seed(0);
17
14
 
18
15
  type CardStoryProps = {
@@ -23,44 +20,8 @@ type CardStoryProps = {
23
20
  showIcon: boolean;
24
21
  };
25
22
 
26
- const meta: Meta<CardStoryProps> = {
27
- title: 'ui/react-ui-stack/Card',
28
- decorators: [withTheme],
29
- argTypes: {
30
- title: {
31
- control: 'text',
32
- description: 'Card title',
33
- },
34
- description: {
35
- control: 'text',
36
- description: 'Card description',
37
- },
38
- image: {
39
- control: 'text',
40
- description: 'URL for the poster image',
41
- },
42
- showImage: {
43
- control: 'boolean',
44
- description: 'Whether to show the image',
45
- },
46
- showIcon: {
47
- control: 'boolean',
48
- description: 'Whether to show an icon (when image is not shown)',
49
- },
50
- },
51
- args: {
52
- title: faker.commerce.productName(),
53
- description: faker.lorem.paragraph(),
54
- image: faker.image.url(),
55
- showImage: true,
56
- showIcon: true,
57
- },
58
- };
59
-
60
- export default meta;
61
-
62
- export const Default: StoryObj<CardStoryProps> = {
63
- render: ({ title, description, image, showImage, showIcon }: CardStoryProps) => (
23
+ const DefaultStory = ({ title, description, image, showImage, showIcon }: CardStoryProps) => {
24
+ return (
64
25
  <div className='max-is-md'>
65
26
  <Card.StaticRoot>
66
27
  <Card.Toolbar>
@@ -74,5 +35,30 @@ export const Default: StoryObj<CardStoryProps> = {
74
35
  {description && <Card.Text classNames='line-clamp-2'>{description}</Card.Text>}
75
36
  </Card.StaticRoot>
76
37
  </div>
77
- ),
38
+ );
39
+ };
40
+
41
+ const meta = {
42
+ title: 'ui/react-ui-stack/Card',
43
+ render: DefaultStory,
44
+ decorators: [withTheme],
45
+ parameters: {
46
+ layout: 'centered',
47
+ },
48
+ } satisfies Meta<typeof DefaultStory>;
49
+
50
+ export default meta;
51
+
52
+ type Story = StoryObj<typeof meta>;
53
+
54
+ const image = faker.image.url();
55
+
56
+ export const Default: Story = {
57
+ args: {
58
+ title: faker.commerce.productName(),
59
+ description: faker.lorem.paragraph(),
60
+ image,
61
+ showImage: true,
62
+ showIcon: true,
63
+ },
78
64
  };
@@ -5,28 +5,39 @@
5
5
  import { Primitive } from '@radix-ui/react-primitive';
6
6
  import { Slot } from '@radix-ui/react-slot';
7
7
  import React, {
8
- type ComponentPropsWithoutRef,
9
8
  type ComponentPropsWithRef,
9
+ type ComponentPropsWithoutRef,
10
10
  type FC,
11
- forwardRef,
12
11
  type PropsWithChildren,
12
+ forwardRef,
13
13
  } from 'react';
14
14
 
15
15
  import { Icon, IconButton, type ThemedClassName, Toolbar, type ToolbarRootProps, useTranslation } from '@dxos/react-ui';
16
- import { hoverableControls, mx } from '@dxos/react-ui-theme';
16
+ import { cardMinInlineSize, hoverableControls, mx } from '@dxos/react-ui-theme';
17
17
 
18
- import { cardChrome, cardRoot, cardHeading, cardText, cardSpacing } from './fragments';
19
- import { StackItem } from '../../components';
18
+ import { Image, StackItem } from '../../components';
20
19
  import { translationKey } from '../../translations';
21
20
 
21
+ import { cardChrome, cardHeading, cardRoot, cardSpacing, cardText } from './fragments';
22
+
23
+ /**
24
+ * The default width of cards. It should be no larger than 320px per WCAG 2.1 SC 1.4.10.
25
+ */
26
+ const cardDefaultInlineSize = cardMinInlineSize;
27
+
28
+ /**
29
+ * This is `cardDefaultInlineSize` plus 2 times the sum of the inner and outer spacing applied by CardStack on the inline axis.
30
+ */
31
+ const cardStackDefaultInlineSizeRem = cardDefaultInlineSize + 2.125;
32
+
22
33
  type SharedCardProps = ThemedClassName<ComponentPropsWithoutRef<'div'>> & { asChild?: boolean };
23
34
 
24
- const CardStaticRoot = forwardRef<HTMLDivElement, SharedCardProps>(
25
- ({ children, classNames, asChild, role = 'group', ...props }, forwardedRef) => {
35
+ const CardStaticRoot = forwardRef<HTMLDivElement, SharedCardProps & { id?: string }>(
36
+ ({ children, classNames, id, asChild, role = 'group', ...props }, forwardedRef) => {
26
37
  const Root = asChild ? Slot : 'div';
27
38
  const rootProps = asChild ? { classNames: [cardRoot, classNames] } : { className: mx(cardRoot, classNames), role };
28
39
  return (
29
- <Root {...props} {...rootProps} ref={forwardedRef}>
40
+ <Root {...(id && { 'data-object-id': id })} {...props} {...rootProps} ref={forwardedRef}>
30
41
  {children}
31
42
  </Root>
32
43
  );
@@ -34,18 +45,19 @@ const CardStaticRoot = forwardRef<HTMLDivElement, SharedCardProps>(
34
45
  );
35
46
 
36
47
  /**
37
- * This should be used by Surface fulfillments in cases where the content may or may not already be encapsulated (e.g.
38
- * in a Popover) and knows this based on the `role` it receives. This will render a `Card.StaticRoot` by default, otherwise
39
- * it will render a `div` primitive with the appropriate styling for specific handled situations.
48
+ * This should be used by Surface fulfillments in cases where the content may or may not already be encapsulated (e.g., in a Popover) and knows this based on the `role` it receives.
49
+ * This will render a `Card.StaticRoot` by default, otherwise it will render a `div` primitive with the appropriate styling for specific handled situations.
40
50
  */
41
51
  const CardSurfaceRoot = ({
52
+ id,
42
53
  role = 'never',
43
54
  children,
44
55
  classNames,
45
- }: ThemedClassName<PropsWithChildren<{ role?: string }>>) => {
56
+ }: ThemedClassName<PropsWithChildren<{ id?: string; role?: string }>>) => {
46
57
  if (['card--popover', 'card--intrinsic', 'card--extrinsic'].includes(role)) {
47
58
  return (
48
59
  <div
60
+ {...(id && { 'data-object-id': id })}
49
61
  className={mx(
50
62
  role === 'card--popover'
51
63
  ? 'popover-card-width'
@@ -61,8 +73,9 @@ const CardSurfaceRoot = ({
61
73
  } else {
62
74
  return (
63
75
  <CardStaticRoot
76
+ id={id}
64
77
  classNames={[
65
- role === 'card--transclusion' && 'mlb-[1em]',
78
+ role === 'card--transclusion' && 'mlb-1',
66
79
  role === 'card--transclusion' && hoverableControls,
67
80
  classNames,
68
81
  ]}
@@ -117,23 +130,26 @@ const CardDragPreview = StackItem.DragPreview;
117
130
 
118
131
  const CardMenu = Primitive.div as FC<ComponentPropsWithRef<'div'>>;
119
132
 
120
- type CardPosterProps = {
121
- alt: string;
122
- aspect?: 'video' | 'auto';
123
- } & Partial<{ image: string; icon: string }>;
133
+ type CardPosterProps = ThemedClassName<
134
+ {
135
+ alt: string;
136
+ aspect?: 'video' | 'auto';
137
+ } & Partial<{ image: string; icon: string }>
138
+ >;
124
139
 
125
140
  const CardPoster = (props: CardPosterProps) => {
126
141
  const aspect = props.aspect === 'auto' ? 'aspect-auto' : 'aspect-video';
127
142
  if (props.image) {
128
143
  return (
129
- <img className={`dx-card__poster ${aspect} object-cover is-full bs-auto`} src={props.image} alt={props.alt} />
144
+ <Image classNames={[`dx-card__poster is-full`, aspect, props.classNames]} src={props.image} alt={props.alt} />
130
145
  );
131
146
  }
147
+
132
148
  if (props.icon) {
133
149
  return (
134
150
  <div
135
151
  role='image'
136
- className={`dx-card__poster grid ${aspect} place-items-center bg-inputSurface text-subdued`}
152
+ className={mx(`dx-card__poster grid place-items-center bg-inputSurface text-subdued`, aspect, props.classNames)}
137
153
  aria-label={props.alt}
138
154
  >
139
155
  <Icon icon={props.icon} size={10} />
@@ -156,9 +172,9 @@ const CardChrome = forwardRef<HTMLDivElement, SharedCardProps>(
156
172
  },
157
173
  );
158
174
 
159
- const CardText = forwardRef<HTMLParagraphElement, SharedCardProps>(
175
+ const CardText = forwardRef<HTMLDivElement, SharedCardProps>(
160
176
  ({ children, classNames, asChild, role = 'none', ...props }, forwardedRef) => {
161
- const Root = asChild ? Slot : 'p';
177
+ const Root = asChild ? Slot : 'div';
162
178
  const rootProps = asChild ? { classNames: [cardText, classNames] } : { className: mx(cardText, classNames), role };
163
179
  return (
164
180
  <Root {...props} {...rootProps} ref={forwardedRef}>
@@ -183,4 +199,12 @@ export const Card = {
183
199
  Text: CardText,
184
200
  };
185
201
 
186
- export { cardRoot, cardHeading, cardText, cardChrome, cardSpacing };
202
+ export {
203
+ cardRoot,
204
+ cardHeading,
205
+ cardText,
206
+ cardChrome,
207
+ cardSpacing,
208
+ cardStackDefaultInlineSizeRem,
209
+ cardDefaultInlineSize,
210
+ };
@@ -6,6 +6,7 @@ export const cardRoot =
6
6
  'rounded overflow-hidden bg-cardSurface border border-separator dark:border-subduedSeparator dx-focus-ring-group-y-indicator relative min-bs-[--rail-item] group/card';
7
7
 
8
8
  export const cardSpacing = 'pli-cardSpacingInline mlb-cardSpacingBlock';
9
+ export const cardNoSpacing = 'pli-0 mlb-0';
9
10
  export const labelSpacing = 'mbs-inputSpacingBlock mbe-labelSpacingBlock';
10
11
 
11
12
  export const cardDialogContent = 'p-0 bs-content min-bs-[8rem] max-bs-full md:max-is-[32rem] overflow-hidden';
@@ -17,7 +18,7 @@ export const cardDialogSearchListRoot =
17
18
 
18
19
  export const cardText = cardSpacing;
19
20
 
20
- export const cardHeading = 'text-lg font-medium line-clamp-2';
21
+ export const cardHeading = 'text-lg font-medium line-clamp-2 grow';
21
22
 
22
23
  export const cardChrome =
23
- 'pli-[--dx-cardSpacingChrome] mlb-[--dx-cardSpacingChrome] [&_.dx-button]:text-start [&_.dx-button]:is-full';
24
+ 'pli-[--dx-cardSpacingChrome] mlb-[--dx-cardSpacingChrome] [&_.dx-button]:text-start [&_.dx-button]:is-full [&_.dx-button]:pis-[calc(var(--dx-cardSpacingInline)-var(--dx-cardSpacingChrome))]';
@@ -2,21 +2,19 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import '@dxos-theme';
6
-
7
5
  import { type Edge } from '@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge';
8
6
  import { type Meta, type StoryObj } from '@storybook/react-vite';
9
- import React, { useState, useCallback } from 'react';
7
+ import React, { useCallback, useState } from 'react';
10
8
 
11
9
  import { faker } from '@dxos/random';
12
10
  import { IconButton } from '@dxos/react-ui';
13
- import { withLayout, withTheme } from '@dxos/storybook-utils';
11
+ import { withTheme } from '@dxos/react-ui/testing';
14
12
 
15
- import { CardStack } from './CardStack';
16
13
  import { StackItem } from '../../components';
17
14
  import { Card, CardDragPreview } from '../Card';
18
15
 
19
- // Set a seed for reproducible random values
16
+ import { CardStack } from './CardStack';
17
+
20
18
  faker.seed(0);
21
19
 
22
20
  type CardItem = {
@@ -130,7 +128,7 @@ const CardStackStory = () => {
130
128
  <Card.Text classNames='line-clamp-2'>{card.description}</Card.Text>
131
129
  </Card.StaticRoot>
132
130
  <StackItem.DragPreview>
133
- {({ item }) => (
131
+ {() => (
134
132
  <CardDragPreview.Root>
135
133
  <CardDragPreview.Content>
136
134
  <Card.Toolbar>
@@ -159,11 +157,14 @@ const CardStackStory = () => {
159
157
  );
160
158
  };
161
159
 
162
- const meta: Meta<typeof CardStackStory> = {
160
+ const meta = {
163
161
  title: 'ui/react-ui-stack/CardStack',
164
162
  component: CardStackStory,
165
- decorators: [withTheme, withLayout({ fullscreen: true })],
166
- };
163
+ decorators: [withTheme],
164
+ parameters: {
165
+ layout: 'fullscreen',
166
+ },
167
+ } satisfies Meta<typeof CardStackStory>;
167
168
 
168
169
  export default meta;
169
170
 
@@ -8,7 +8,7 @@ import React, { type ComponentPropsWithoutRef, forwardRef } from 'react';
8
8
  import type { ThemedClassName } from '@dxos/react-ui';
9
9
  import { mx } from '@dxos/react-ui-theme';
10
10
 
11
- import { railGridHorizontalContainFitContent, Stack, type StackProps } from '../../components';
11
+ import { Stack, type StackProps, railGridHorizontalContainFitContent } from '../../components';
12
12
  import { Card } from '../Card';
13
13
 
14
14
  type SharedCardStackProps = ThemedClassName<ComponentPropsWithoutRef<'div'>> & { asChild?: boolean };
@@ -72,17 +72,20 @@ const CardStackFooter = forwardRef<HTMLDivElement, SharedCardStackProps>(
72
72
  },
73
73
  );
74
74
 
75
- const cardStackContent = [
76
- 'shrink min-bs-0 bg-baseSurface border border-separator rounded-md grid dx-focus-ring-group-x-indicator kanban-drop',
77
- railGridHorizontalContainFitContent,
78
- ];
75
+ const cardStackContent =
76
+ 'shrink min-bs-0 bg-baseSurface border border-separator rounded-md grid dx-focus-ring-group-x-indicator kanban-drop';
79
77
 
80
- const CardStackContent = forwardRef<HTMLDivElement, SharedCardStackProps>(
81
- ({ children, classNames, asChild, role = 'none', ...props }, forwardedRef) => {
78
+ type CardStackContentProps = SharedCardStackProps & {
79
+ footer?: boolean;
80
+ };
81
+
82
+ const CardStackContent = forwardRef<HTMLDivElement, CardStackContentProps>(
83
+ ({ children, classNames, asChild, role = 'none', footer = true, ...props }, forwardedRef) => {
82
84
  const Root = asChild ? Slot : 'div';
85
+ const baseClassNames = footer ? [cardStackContent, railGridHorizontalContainFitContent] : [cardStackContent];
83
86
  const rootProps = asChild
84
- ? { classNames: [...cardStackContent, classNames] }
85
- : { className: mx(...cardStackContent, classNames), role };
87
+ ? { classNames: [...baseClassNames, classNames] }
88
+ : { className: mx(...baseClassNames, classNames), role };
86
89
  return (
87
90
  <Root {...props} {...rootProps} data-scroll-separator='false' ref={forwardedRef}>
88
91
  {children}
@@ -8,7 +8,9 @@ import { autoScrollForElements } from '@atlaskit/pragmatic-drag-and-drop-auto-sc
8
8
  import { attachClosestEdge, extractClosestEdge } from '@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge';
9
9
  import { useLayoutEffect, useState } from 'react';
10
10
 
11
- import { type StackItemRearrangeHandler, type StackItemData, type Orientation } from '../components';
11
+ import { type Orientation, type StackItemData, type StackItemRearrangeHandler } from '../components';
12
+
13
+ const noop = () => {};
12
14
 
13
15
  /**
14
16
  * Hook to handle drag and drop functionality for Stack components.
@@ -17,59 +19,64 @@ export const useStackDropForElements = ({
17
19
  id,
18
20
  element,
19
21
  scrollElement = element,
20
- selfDroppable,
21
22
  orientation,
23
+ selfDroppable,
22
24
  onRearrange,
23
25
  }: {
24
26
  id?: string;
25
27
  element: HTMLDivElement | null;
26
28
  scrollElement?: HTMLDivElement | null;
27
- selfDroppable: boolean;
28
29
  orientation: Orientation;
30
+ selfDroppable: boolean;
29
31
  onRearrange?: StackItemRearrangeHandler;
30
32
  }) => {
31
33
  const [dropping, setDropping] = useState(false);
32
34
 
33
35
  useLayoutEffect(() => {
34
- if (!element || !selfDroppable) {
36
+ if (!element) {
35
37
  return;
36
38
  }
37
39
 
38
40
  const acceptSourceType = orientation === 'horizontal' ? 'column' : 'card';
39
41
 
40
42
  return combine(
41
- dropTargetForElements({
42
- element,
43
- getData: ({ input, element }) => {
44
- return attachClosestEdge(
45
- { id, type: orientation === 'horizontal' ? 'card' : 'column' },
46
- { input, element, allowedEdges: [orientation === 'horizontal' ? 'left' : 'top'] },
47
- );
48
- },
49
- onDragEnter: ({ source }) => {
50
- if (source.data.type === acceptSourceType) {
51
- setDropping(true);
52
- }
53
- },
54
- onDrag: ({ source }) => {
55
- if (source.data.type === acceptSourceType) {
56
- setDropping(true);
57
- }
58
- },
59
- onDragLeave: () => {
60
- return setDropping(false);
61
- },
62
- onDrop: ({ self, source }) => {
63
- setDropping(false);
64
- if (source.data.type === acceptSourceType && selfDroppable && onRearrange) {
65
- onRearrange(source.data as StackItemData, self.data as StackItemData, extractClosestEdge(self.data));
66
- }
67
- },
68
- }),
69
- autoScrollForElements({
70
- element: scrollElement as Element,
71
- getAllowedAxis: () => orientation,
72
- }),
43
+ selfDroppable
44
+ ? dropTargetForElements({
45
+ element,
46
+ getData: ({ input, element }) => {
47
+ return attachClosestEdge(
48
+ { id, type: orientation === 'horizontal' ? 'card' : 'column' },
49
+ { input, element, allowedEdges: [orientation === 'horizontal' ? 'left' : 'top'] },
50
+ );
51
+ },
52
+ onDragEnter: ({ source }) => {
53
+ if (source.data.type === acceptSourceType) {
54
+ setDropping(true);
55
+ }
56
+ },
57
+ onDrag: ({ source }) => {
58
+ if (source.data.type === acceptSourceType) {
59
+ setDropping(true);
60
+ }
61
+ },
62
+ onDragLeave: () => {
63
+ return setDropping(false);
64
+ },
65
+ onDrop: ({ self, source }) => {
66
+ setDropping(false);
67
+ if (source.data.type === acceptSourceType && selfDroppable && onRearrange) {
68
+ onRearrange(source.data as StackItemData, self.data as StackItemData, extractClosestEdge(self.data));
69
+ }
70
+ },
71
+ })
72
+ : noop,
73
+
74
+ scrollElement
75
+ ? autoScrollForElements({
76
+ element: scrollElement,
77
+ getAllowedAxis: () => orientation,
78
+ })
79
+ : noop,
73
80
  );
74
81
  }, [element, scrollElement, selfDroppable, orientation, id, onRearrange]);
75
82
 
@@ -16,18 +16,21 @@ export const CardContainer = ({
16
16
  switch (role) {
17
17
  case 'card--popover':
18
18
  return <PopoverCardContainer icon={icon}>{children}</PopoverCardContainer>;
19
- case 'card--intrinsic':
20
- return (
21
- <IntrinsicCardContainer>
22
- <Card.StaticRoot>{children}</Card.StaticRoot>
23
- </IntrinsicCardContainer>
24
- );
19
+
25
20
  case 'card--extrinsic':
26
21
  return (
27
22
  <ExtrinsicCardContainer>
28
23
  <Card.StaticRoot>{children}</Card.StaticRoot>
29
24
  </ExtrinsicCardContainer>
30
25
  );
26
+
27
+ case 'card--intrinsic':
28
+ return (
29
+ <IntrinsicCardContainer>
30
+ <Card.StaticRoot>{children}</Card.StaticRoot>
31
+ </IntrinsicCardContainer>
32
+ );
33
+
31
34
  default:
32
35
  return <Card.StaticRoot>{children}</Card.StaticRoot>;
33
36
  }