@dxos/react-ui-stack 0.8.4-main.bc674ce → 0.8.4-main.bcb3aa67d6

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 (51) hide show
  1. package/dist/lib/browser/index.mjs +201 -411
  2. package/dist/lib/browser/index.mjs.map +4 -4
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/node-esm/index.mjs +201 -411
  5. package/dist/lib/node-esm/index.mjs.map +4 -4
  6. package/dist/lib/node-esm/meta.json +1 -1
  7. package/dist/types/src/components/Stack/Stack.d.ts +4 -9
  8. package/dist/types/src/components/Stack/Stack.d.ts.map +1 -1
  9. package/dist/types/src/components/Stack/Stack.stories.d.ts.map +1 -1
  10. package/dist/types/src/components/StackItem/MenuSignifier.d.ts.map +1 -1
  11. package/dist/types/src/components/StackItem/StackItem.d.ts +2 -2
  12. package/dist/types/src/components/StackItem/StackItemContent.d.ts.map +1 -1
  13. package/dist/types/src/components/StackItem/StackItemDragHandle.d.ts.map +1 -1
  14. package/dist/types/src/components/StackItem/StackItemHeading.d.ts +1 -1
  15. package/dist/types/src/components/StackItem/StackItemHeading.d.ts.map +1 -1
  16. package/dist/types/src/components/StackItem/StackItemResizeHandle.d.ts +1 -1
  17. package/dist/types/src/components/StackItem/StackItemResizeHandle.d.ts.map +1 -1
  18. package/dist/types/src/components/StackItem/StackItemSigil.d.ts.map +1 -1
  19. package/dist/types/src/components/index.d.ts +0 -1
  20. package/dist/types/src/components/index.d.ts.map +1 -1
  21. package/dist/types/src/translations.d.ts +8 -8
  22. package/dist/types/tsconfig.tsbuildinfo +1 -1
  23. package/package.json +25 -25
  24. package/src/components/Stack/Stack.stories.tsx +2 -3
  25. package/src/components/Stack/Stack.tsx +197 -210
  26. package/src/components/StackItem/MenuSignifier.tsx +2 -9
  27. package/src/components/StackItem/StackItem.stories.tsx +5 -5
  28. package/src/components/StackItem/StackItem.tsx +1 -1
  29. package/src/components/StackItem/StackItemContent.tsx +11 -9
  30. package/src/components/StackItem/StackItemDragHandle.tsx +4 -3
  31. package/src/components/StackItem/StackItemHeading.tsx +13 -12
  32. package/src/components/StackItem/StackItemResizeHandle.tsx +1 -1
  33. package/src/components/StackItem/StackItemSigil.tsx +7 -4
  34. package/src/components/index.ts +1 -1
  35. package/src/playwright/playwright.config.ts +1 -1
  36. package/src/translations.ts +8 -8
  37. package/dist/types/src/components/CardStack/CardStack.d.ts +0 -47
  38. package/dist/types/src/components/CardStack/CardStack.d.ts.map +0 -1
  39. package/dist/types/src/components/CardStack/CardStack.stories.d.ts +0 -15
  40. package/dist/types/src/components/CardStack/CardStack.stories.d.ts.map +0 -1
  41. package/dist/types/src/components/CardStack/CardStackDragPreview.d.ts +0 -9
  42. package/dist/types/src/components/CardStack/CardStackDragPreview.d.ts.map +0 -1
  43. package/dist/types/src/components/CardStack/index.d.ts +0 -3
  44. package/dist/types/src/components/CardStack/index.d.ts.map +0 -1
  45. package/dist/types/src/components/deprecated/LayoutControls.d.ts +0 -22
  46. package/dist/types/src/components/deprecated/LayoutControls.d.ts.map +0 -1
  47. package/src/components/CardStack/CardStack.stories.tsx +0 -173
  48. package/src/components/CardStack/CardStack.tsx +0 -196
  49. package/src/components/CardStack/CardStackDragPreview.tsx +0 -61
  50. package/src/components/CardStack/index.ts +0 -6
  51. package/src/components/deprecated/LayoutControls.tsx +0 -112
@@ -247,7 +247,7 @@ const StackItemRoot = forwardRef<HTMLDivElement, StackItemRootProps>(
247
247
  : 'dx-focus-ring-group-y',
248
248
  orientation === 'horizontal' ? 'grid-rows-subgrid' : 'grid-cols-subgrid',
249
249
  rail && (orientation === 'horizontal' ? 'row-span-2' : 'col-span-2'),
250
- role === 'section' && orientation !== 'horizontal' && 'border-be border-subduedSeparator',
250
+ role === 'section' && orientation !== 'horizontal' && 'border-b border-subdued-separator',
251
251
  classNames,
252
252
  )}
253
253
  data-dx-stack-item={stackId}
@@ -24,10 +24,12 @@ export const StackItemContent = forwardRef<HTMLDivElement, StackItemContentProps
24
24
  const style = useMemo(
25
25
  () => ({
26
26
  gridTemplateRows: [
27
- ...(toolbar ? [role === 'section' ? 'calc(var(--toolbar-size) - 1px)' : 'var(--toolbar-size)'] : []),
27
+ toolbar && role === 'section' ? 'calc(var(--dx-toolbar-size) - 1px)' : 'var(--dx-toolbar-size)',
28
28
  '1fr',
29
- ...(statusbar ? ['var(--statusbar-size)'] : []),
30
- ].join(' '),
29
+ statusbar && 'var(--dx-statusbar-size)',
30
+ ]
31
+ .filter(Boolean)
32
+ .join(' '),
31
33
  }),
32
34
  [toolbar, statusbar],
33
35
  );
@@ -38,12 +40,12 @@ export const StackItemContent = forwardRef<HTMLDivElement, StackItemContentProps
38
40
  role='none'
39
41
  style={style}
40
42
  className={mx(
41
- 'group grid grid-cols-[100%] density-coarse',
42
- stackItemSize === 'contain' && 'min-bs-0 overflow-hidden',
43
- role === 'section' &&
44
- toolbar &&
45
- '[&_.dx-toolbar]:sticky [&_.dx-toolbar]:z-[1] [&_.dx-toolbar]:block-start-0 [&_.dx-toolbar]:-mbe-px [&_.dx-toolbar]:min-is-0',
46
- toolbar && '[&>.dx-toolbar]:relative [&>.dx-toolbar]:border-be [&>.dx-toolbar]:border-subduedSeparator',
43
+ 'group grid grid-cols-[100%] dx-density-coarse',
44
+ stackItemSize === 'contain' && 'min-h-0 overflow-hidden',
45
+ toolbar &&
46
+ role === 'section' &&
47
+ '[&_.dx-toolbar]:sticky [&_.dx-toolbar]:z-[1] [&_.dx-toolbar]:top-0 [&_.dx-toolbar]:-mb-px [&_.dx-toolbar]:min-w-0',
48
+ toolbar && '[&>.dx-toolbar]:relative [&>.dx-toolbar]:border-b [&>.dx-toolbar]:border-subdued-separator',
47
49
  classNames,
48
50
  )}
49
51
  data-popover-collision-boundary={true}
@@ -2,6 +2,7 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
+ import { Primitive } from '@radix-ui/react-primitive';
5
6
  import { Slot } from '@radix-ui/react-slot';
6
7
  import React, { type ComponentPropsWithoutRef } from 'react';
7
8
 
@@ -12,11 +13,11 @@ export type StackItemDragHandleProps = ComponentPropsWithoutRef<'button'> & { as
12
13
  export const StackItemDragHandle = ({ asChild, children }: StackItemDragHandleProps) => {
13
14
  const { selfDragHandleRef } = useStackItem();
14
15
 
15
- const Root = asChild ? Slot : 'div';
16
+ const Comp = asChild ? Slot : Primitive.div;
16
17
 
17
18
  return (
18
- <Root ref={selfDragHandleRef} role='button'>
19
+ <Comp ref={selfDragHandleRef} role='button'>
19
20
  {children}
20
- </Root>
21
+ </Comp>
21
22
  );
22
23
  };
@@ -2,6 +2,7 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
+ import { Primitive } from '@radix-ui/react-primitive';
5
6
  import { Slot } from '@radix-ui/react-slot';
6
7
  import React, {
7
8
  type ComponentPropsWithRef,
@@ -26,34 +27,34 @@ export const StackItemHeading = ({
26
27
  classNames,
27
28
  asChild,
28
29
  separateOnScroll,
30
+ role,
29
31
  ...props
30
32
  }: StackItemHeadingProps) => {
31
33
  const { orientation } = useStack();
32
-
33
- const Root = asChild ? Slot : 'div';
34
+ const Comp = asChild ? Slot : Primitive.div;
34
35
 
35
36
  return (
36
- <Root
37
- role='heading'
37
+ <Comp
38
38
  {...props}
39
+ role={role ?? 'heading'}
39
40
  className={mx(
40
- 'flex items-center !border-is-0 bg-headerSurface',
41
+ 'flex items-center border-x-0! bg-header-surface',
41
42
  separateOnScroll
42
- ? 'border-transparent [[data-scroll-separator="true"]_&]:border-subduedSeparator'
43
- : 'border-subduedSeparator',
44
- orientation === 'horizontal' ? 'bs-[--rail-size]' : 'is-[--rail-size] flex-col',
45
- orientation === 'horizontal' ? 'border-be' : 'border-ie',
43
+ ? 'border-transparent [[data-scroll-separator="true"]_&]:border-subdued-separator'
44
+ : 'border-subdued-separator',
45
+ orientation === 'horizontal' ? 'h-(--dx-rail-size)' : 'w-(--dx-rail-size) flex-col',
46
+ orientation === 'horizontal' ? 'border-b' : 'border-e',
46
47
  classNames,
47
48
  )}
48
49
  >
49
50
  {children}
50
- </Root>
51
+ </Comp>
51
52
  );
52
53
  };
53
54
 
54
55
  export const StackItemHeadingStickyContent = ({ children }: PropsWithChildren<{}>) => {
55
56
  return (
56
- <div role='none' className='sticky block-start-0 bg-[--sticky-bg] p-1 is-full'>
57
+ <div role='none' className='sticky top-0 bg-(--sticky-bg) p-1 w-full'>
57
58
  {children}
58
59
  </div>
59
60
  );
@@ -70,7 +71,7 @@ export const StackItemHeadingLabel = forwardRef<HTMLHeadingElement, StackItemHea
70
71
  {...props}
71
72
  data-attention={((related && isRelated) || hasAttention || isAncestor).toString()}
72
73
  className={mx(
73
- 'pli-1 min-is-0 is-0 grow truncate font-medium text-baseText data-[attention=true]:text-accentText self-center',
74
+ 'px-1 min-w-0 w-0 grow truncate font-medium text-base-surface-text data-[attention=true]:text-accent-text self-center',
74
75
  classNames,
75
76
  )}
76
77
  ref={forwardedRef}
@@ -15,7 +15,7 @@ const MIN_HEIGHT = 3;
15
15
 
16
16
  export type StackItemResizeHandleProps = {};
17
17
 
18
- export const StackItemResizeHandle = () => {
18
+ export const StackItemResizeHandle = (_: StackItemResizeHandleProps) => {
19
19
  const { orientation } = useStack();
20
20
  const { setSize, size } = useStackItem();
21
21
 
@@ -8,7 +8,7 @@ import { type Node } from '@dxos/app-graph';
8
8
  import { keySymbols } from '@dxos/keyboard';
9
9
  import { Button, type ButtonProps, DropdownMenu, Icon, toLocalizedString, useTranslation } from '@dxos/react-ui';
10
10
  import { type AttendableId, type Related, useAttention } from '@dxos/react-ui-attention';
11
- import { descriptionText, mx } from '@dxos/ui-theme';
11
+ import { mx } from '@dxos/ui-theme';
12
12
  import { getHostPlatform } from '@dxos/util';
13
13
 
14
14
  import { translationKey } from '../../translations';
@@ -40,7 +40,10 @@ export const StackItemSigilButton = forwardRef<HTMLButtonElement, StackItemSigil
40
40
  <Button
41
41
  {...props}
42
42
  variant={variant}
43
- classNames={['shrink-0 pli-0 min-bs-0 is-[--rail-action] bs-[--rail-action] relative app-no-drag', classNames]}
43
+ classNames={[
44
+ 'shrink-0 px-0 min-h-0 w-(--dx-rail-action) h-(--dx-rail-action) relative dx-app-no-drag',
45
+ classNames,
46
+ ]}
44
47
  ref={forwardedRef}
45
48
  >
46
49
  {isMenu && <MenuSignifierHorizontal />}
@@ -78,7 +81,7 @@ export const StackItemSigil = forwardRef<HTMLButtonElement, StackItemSigilProps>
78
81
  classNames={!hasActions && 'cursor-default'}
79
82
  >
80
83
  <span className='sr-only'>{triggerLabel}</span>
81
- <Icon icon={icon} size={5} />
84
+ <Icon icon={icon} />
82
85
  </StackItemSigilButton>
83
86
  );
84
87
 
@@ -133,7 +136,7 @@ export const StackItemSigil = forwardRef<HTMLButtonElement, StackItemSigilProps>
133
136
  </DropdownMenu.ItemIndicator>
134
137
  )}
135
138
  {shortcut && (
136
- <span className={mx('shrink-0', descriptionText)}>{keySymbols(shortcut).join('')}</span>
139
+ <span className={mx('shrink-0', 'text-description')}>{keySymbols(shortcut).join('')}</span>
137
140
  )}
138
141
  </Root>
139
142
  );
@@ -4,6 +4,6 @@
4
4
 
5
5
  export type * from './types';
6
6
 
7
- export * from './CardStack';
8
7
  export * from './Stack';
8
+
9
9
  export * from './StackItem';
@@ -10,7 +10,7 @@ export default defineConfig({
10
10
  ...e2ePreset(import.meta.dirname),
11
11
  // TODO(wittjosiah): Avoid hard-coding ports.
12
12
  webServer: {
13
- command: 'moon run storybook-react:serve-e2e -- --port=9003',
13
+ command: 'pnpm storybook dev --ci --quiet --port=9003 --config-dir=.storybook',
14
14
  port: 9003,
15
15
  reuseExistingServer: false,
16
16
  },
@@ -10,14 +10,14 @@ export const translations = [
10
10
  {
11
11
  'en-US': {
12
12
  [translationKey]: {
13
- 'resize label': 'Drag to resize',
14
- 'drag handle label': 'Drag to rearrange',
15
- 'pin start label': 'Pin to the left sidebar',
16
- 'pin end label': 'Pin to the right sidebar',
17
- 'increment start label': 'Move to the left',
18
- 'increment end label': 'Move to the right',
19
- 'close label': 'Close',
20
- 'minify label': 'Minify',
13
+ 'resize.label': 'Drag to resize',
14
+ 'drag-handle.label': 'Drag to rearrange',
15
+ 'pin-start.label': 'Pin to the left sidebar',
16
+ 'pin-end.label': 'Pin to the right sidebar',
17
+ 'increment-start.label': 'Move to the left',
18
+ 'increment-end.label': 'Move to the right',
19
+ 'close.label': 'Close',
20
+ 'minify.label': 'Minify',
21
21
  },
22
22
  },
23
23
  },
@@ -1,47 +0,0 @@
1
- import React from 'react';
2
- import { type StackProps } from '../Stack';
3
- /**
4
- * This is `cardDefaultInlineSize` plus 2 times the sum of the inner and outer spacing applied by CardStack on the inline axis.
5
- */
6
- declare const cardStackDefaultInlineSizeRem: number;
7
- declare const cardStackRoot = "flex flex-col";
8
- declare const cardStackContent = "shrink min-bs-0 grid dx-focus-ring-group-x-indicator bg-baseSurface";
9
- declare const cardStackItem = "contain-layout pli-2 plb-1 first-of-type:pbs-0 last-of-type:pbe-0";
10
- declare const cardStackHeading = "mli-2 order-first bg-transparent rounded-bs-md flex items-center";
11
- declare const cardStackFooter = "plb-2 mli-2 border-bs border-transparent [[data-scroll-separator-end=\"true\"]_&]:border-subduedSeparator";
12
- /**
13
- * @deprecated Replace with Mosaic.Stack.
14
- */
15
- export declare const CardStack: {
16
- Root: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "className"> & {
17
- classNames?: import("@dxos/ui-types").ClassNameValue;
18
- } & {
19
- asChild?: boolean;
20
- } & React.RefAttributes<HTMLDivElement>>;
21
- Content: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "className"> & {
22
- classNames?: import("@dxos/ui-types").ClassNameValue;
23
- } & {
24
- asChild?: boolean;
25
- } & {
26
- footer?: boolean;
27
- } & React.RefAttributes<HTMLDivElement>>;
28
- Stack: React.ForwardRefExoticComponent<Omit<Omit<StackProps, "orientation" | "rail" | "size" | "separatorOnScroll">, "ref"> & React.RefAttributes<HTMLDivElement>>;
29
- Heading: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "className"> & {
30
- classNames?: import("@dxos/ui-types").ClassNameValue;
31
- } & {
32
- asChild?: boolean;
33
- } & React.RefAttributes<HTMLDivElement>>;
34
- Footer: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "className"> & {
35
- classNames?: import("@dxos/ui-types").ClassNameValue;
36
- } & {
37
- asChild?: boolean;
38
- } & React.RefAttributes<HTMLDivElement>>;
39
- DragHandle: React.ForwardRefExoticComponent<React.RefAttributes<HTMLButtonElement>>;
40
- Item: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "className"> & {
41
- classNames?: import("@dxos/ui-types").ClassNameValue;
42
- } & {
43
- asChild?: boolean;
44
- } & React.RefAttributes<HTMLDivElement>>;
45
- };
46
- export { cardStackRoot, cardStackFooter, cardStackHeading, cardStackContent, cardStackItem, cardStackDefaultInlineSizeRem, };
47
- //# sourceMappingURL=CardStack.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CardStack.d.ts","sourceRoot":"","sources":["../../../../../src/components/CardStack/CardStack.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAoD,MAAM,OAAO,CAAC;AAMzE,OAAO,EAAS,KAAK,UAAU,EAAuC,MAAM,UAAU,CAAC;AAEvF;;GAEG;AACH,QAAA,MAAM,6BAA6B,QAAgC,CAAC;AAMpE,QAAA,MAAM,aAAa,kBAAkB,CAAC;AAuBtC,QAAA,MAAM,gBAAgB,wEAAwE,CAAC;AA4D/F,QAAA,MAAM,aAAa,sEAAsE,CAAC;AAqB1F,QAAA,MAAM,gBAAgB,qEAAqE,CAAC;AAqB5F,QAAA,MAAM,eAAe,8GACsF,CAAC;AA2B5G;;GAEG;AACH,eAAO,MAAM,SAAS;;;;kBAzGV,OAAO;;;;;kBAAP,OAAO;;iBAzBR,OAAO;;;;;;kBAyBN,OAAO;;;;;kBAAP,OAAO;;;;;;kBAAP,OAAO;;CAiHlB,CAAC;AAEF,OAAO,EACL,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EACb,6BAA6B,GAC9B,CAAC"}
@@ -1,15 +0,0 @@
1
- import { type StoryObj } from '@storybook/react-vite';
2
- import React from 'react';
3
- declare const CardStackStory: () => React.JSX.Element;
4
- declare const meta: {
5
- title: string;
6
- component: () => React.JSX.Element;
7
- decorators: import("@storybook/react").Decorator[];
8
- parameters: {
9
- layout: string;
10
- };
11
- };
12
- export default meta;
13
- type Story = StoryObj<typeof CardStackStory>;
14
- export declare const Default: Story;
15
- //# sourceMappingURL=CardStack.stories.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CardStack.stories.d.ts","sourceRoot":"","sources":["../../../../../src/components/CardStack/CardStack.stories.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAa,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,KAAgC,MAAM,OAAO,CAAC;AAyBrD,QAAA,MAAM,cAAc,yBA8HnB,CAAC;AAEF,QAAA,MAAM,IAAI;;;;;;;CAO6B,CAAC;AAExC,eAAe,IAAI,CAAC;AAEpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,cAAc,CAAC,CAAC;AAE7C,eAAO,MAAM,OAAO,EAAE,KAAU,CAAC"}
@@ -1,9 +0,0 @@
1
- import React, { type PropsWithChildren } from 'react';
2
- import { type StackProps } from '../Stack';
3
- export declare const CardStackDragPreview: {
4
- Root: ({ children }: PropsWithChildren<{}>) => React.JSX.Element;
5
- Heading: ({ children }: PropsWithChildren<{}>) => React.JSX.Element;
6
- Content: ({ children, itemsCount, }: PropsWithChildren<Pick<StackProps, "itemsCount">>) => React.JSX.Element;
7
- Footer: ({ children }: PropsWithChildren<{}>) => React.JSX.Element;
8
- };
9
- //# sourceMappingURL=CardStackDragPreview.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CardStackDragPreview.d.ts","sourceRoot":"","sources":["../../../../../src/components/CardStack/CardStackDragPreview.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,EAAE,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAMtD,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AA6C3C,eAAO,MAAM,oBAAoB;yBA3Ce,iBAAiB,CAAC,EAAE,CAAC;4BAUlB,iBAAiB,CAAC,EAAE,CAAC;yCAmBrE,iBAAiB,CAAC,IAAI,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;2BAUF,iBAAiB,CAAC,EAAE,CAAC;CAStE,CAAC"}
@@ -1,3 +0,0 @@
1
- export * from './CardStack';
2
- export * from './CardStackDragPreview';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/CardStack/index.ts"],"names":[],"mappings":"AAIA,cAAc,aAAa,CAAC;AAC5B,cAAc,wBAAwB,CAAC"}
@@ -1,22 +0,0 @@
1
- import React from 'react';
2
- import { type ButtonGroupProps } from '@dxos/react-ui';
3
- export type LayoutControlEvent = 'solo' | 'close' | `${'pin' | 'increment'}-${'start' | 'end'}`;
4
- export type LayoutControlHandler = (event: LayoutControlEvent) => void;
5
- export type LayoutCapabilities = {
6
- incrementStart?: boolean;
7
- incrementEnd?: boolean;
8
- solo?: boolean;
9
- };
10
- export type LayoutControlsProps = Omit<ButtonGroupProps, 'onClick'> & {
11
- onClick?: LayoutControlHandler;
12
- variant?: 'hide-disabled' | 'default';
13
- close?: boolean | 'minify-start' | 'minify-end';
14
- capabilities: LayoutCapabilities;
15
- isSolo?: boolean;
16
- pin?: 'start' | 'end' | 'both';
17
- };
18
- /**
19
- * @deprecated
20
- */
21
- export declare const LayoutControls: React.ForwardRefExoticComponent<Omit<LayoutControlsProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
22
- //# sourceMappingURL=LayoutControls.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"LayoutControls.d.ts","sourceRoot":"","sources":["../../../../../src/components/deprecated/LayoutControls.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAE1C,OAAO,EAAe,KAAK,gBAAgB,EAAgD,MAAM,gBAAgB,CAAC;AAIlH,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,OAAO,GAAG,GAAG,KAAK,GAAG,WAAW,IAAI,OAAO,GAAG,KAAK,EAAE,CAAC;AAChG,MAAM,MAAM,oBAAoB,GAAG,CAAC,KAAK,EAAE,kBAAkB,KAAK,IAAI,CAAC;AAEvE,MAAM,MAAM,kBAAkB,GAAG;IAC/B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,IAAI,CAAC,gBAAgB,EAAE,SAAS,CAAC,GAAG;IACpE,OAAO,CAAC,EAAE,oBAAoB,CAAC;IAC/B,OAAO,CAAC,EAAE,eAAe,GAAG,SAAS,CAAC;IACtC,KAAK,CAAC,EAAE,OAAO,GAAG,cAAc,GAAG,YAAY,CAAC;IAChD,YAAY,EAAE,kBAAkB,CAAC;IACjC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,GAAG,CAAC,EAAE,OAAO,GAAG,KAAK,GAAG,MAAM,CAAC;CAChC,CAAC;AAMF;;GAEG;AACH,eAAO,MAAM,cAAc,yGA4E1B,CAAC"}
@@ -1,173 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import { type Edge } from '@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge';
6
- import { type Meta, type StoryObj } from '@storybook/react-vite';
7
- import React, { useCallback, useState } from 'react';
8
-
9
- import { faker } from '@dxos/random';
10
- import { IconButton } from '@dxos/react-ui';
11
- import { withTheme } from '@dxos/react-ui/testing';
12
- import { Card, CardDragPreview } from '@dxos/react-ui-mosaic';
13
-
14
- import { StackItem } from '../StackItem';
15
-
16
- import { CardStack } from './CardStack';
17
-
18
- faker.seed(0);
19
-
20
- type CardItem = {
21
- id: string;
22
- title: string;
23
- description: string;
24
- image: string;
25
- };
26
-
27
- type StackItemData = {
28
- id: string;
29
- type?: 'column' | 'card';
30
- };
31
-
32
- const CardStackStory = () => {
33
- const [column, setColumn] = useState<CardItem[]>(
34
- faker.helpers.multiple(
35
- () => ({
36
- id: faker.string.uuid(),
37
- title: faker.commerce.productName(),
38
- description: faker.lorem.paragraph(),
39
- image: faker.image.url(),
40
- }),
41
- { count: 12 },
42
- ),
43
- );
44
-
45
- const handleRearrange = useCallback((source: StackItemData, target: StackItemData, closestEdge: Edge | null) => {
46
- setColumn((prevColumn) => {
47
- const newColumns = [...prevColumn];
48
- // Reordering cards within a column
49
- const sourceCardIndex = prevColumn.findIndex((card) => card.id === source.id);
50
- const targetCardIndex = prevColumn.findIndex((card) => card.id === target.id);
51
-
52
- if (typeof sourceCardIndex === 'number' && typeof targetCardIndex === 'number') {
53
- const [movedCard] = newColumns.splice(sourceCardIndex, 1);
54
-
55
- let insertIndex;
56
- if (sourceCardIndex < targetCardIndex) {
57
- insertIndex = closestEdge === 'bottom' ? targetCardIndex : targetCardIndex - 1;
58
- } else {
59
- insertIndex = closestEdge === 'bottom' ? targetCardIndex + 1 : targetCardIndex;
60
- }
61
- newColumns.splice(insertIndex, 0, movedCard);
62
- }
63
- return newColumns;
64
- });
65
- }, []);
66
-
67
- const handleAddCard = useCallback(() => {
68
- setColumn((prevColumn) => {
69
- const newColumn = [...prevColumn];
70
- const newCard = {
71
- id: faker.string.uuid(),
72
- title: faker.commerce.productName(),
73
- description: faker.lorem.paragraph(),
74
- image: faker.image.url(),
75
- } satisfies CardItem;
76
- newColumn.push(newCard);
77
- console.log('[add card]', prevColumn.length, newColumn.length);
78
- return newColumn;
79
- });
80
- }, []);
81
-
82
- const handleRemoveCard = useCallback((cardId: string) => {
83
- setColumn((prevColumn) => {
84
- const newColumn = [...prevColumn];
85
-
86
- const cardIndex = prevColumn.findIndex((card) => card.id === cardId);
87
- if (cardIndex !== -1) {
88
- newColumn.splice(cardIndex, 1);
89
- }
90
-
91
- return newColumn;
92
- });
93
- }, []);
94
-
95
- return (
96
- <CardStack.Root classNames='is-96'>
97
- <CardStack.Content footer>
98
- <CardStack.Stack id='story column' onRearrange={handleRearrange} itemsCount={column.length}>
99
- {column.map((card, cardIndex, cardsArray) => {
100
- const cardItem = { id: card.id, type: 'card' as const };
101
- const prevCardId = cardIndex > 0 ? cardsArray[cardIndex - 1].id : undefined;
102
- const nextCardId = cardIndex < cardsArray.length - 1 ? cardsArray[cardIndex + 1].id : undefined;
103
-
104
- return (
105
- <CardStack.Item asChild key={card.id}>
106
- <StackItem.Root
107
- item={cardItem}
108
- focusIndicatorVariant='group'
109
- prevSiblingId={prevCardId}
110
- nextSiblingId={nextCardId}
111
- >
112
- <Card.Root>
113
- <Card.Toolbar>
114
- <StackItem.DragHandle asChild>
115
- <Card.DragHandle />
116
- </StackItem.DragHandle>
117
- <Card.ToolbarSeparator variant='gap' />
118
- <Card.ToolbarIconButton
119
- iconOnly
120
- variant='ghost'
121
- icon='ph--x--regular'
122
- label='Remove card'
123
- onClick={() => handleRemoveCard(card.id)}
124
- />
125
- </Card.Toolbar>
126
- <Card.Poster alt={card.title} image={card.image} />
127
- <Card.Heading>{card.title}</Card.Heading>
128
- <Card.Text variant='description'>{card.description}</Card.Text>
129
- </Card.Root>
130
- <StackItem.DragPreview>
131
- {() => (
132
- <CardDragPreview.Root>
133
- <CardDragPreview.Content>
134
- <Card.Toolbar>
135
- <Card.DragHandle />
136
- </Card.Toolbar>
137
- <Card.Poster alt={card.title} image={card.image} />
138
- <Card.Heading>{card.title}</Card.Heading>
139
- <Card.Text variant='description'>{card.description}</Card.Text>
140
- </CardDragPreview.Content>
141
- </CardDragPreview.Root>
142
- )}
143
- </StackItem.DragPreview>
144
- </StackItem.Root>
145
- </CardStack.Item>
146
- );
147
- })}
148
- </CardStack.Stack>
149
-
150
- <CardStack.Footer>
151
- <IconButton icon='ph--plus--regular' label='Add card' onClick={handleAddCard} classNames='is-full' />
152
- </CardStack.Footer>
153
-
154
- <CardStack.Heading>{faker.company.name()}</CardStack.Heading>
155
- </CardStack.Content>
156
- </CardStack.Root>
157
- );
158
- };
159
-
160
- const meta = {
161
- title: 'ui/react-ui-stack/CardStack',
162
- component: CardStackStory,
163
- decorators: [withTheme],
164
- parameters: {
165
- layout: 'fullscreen',
166
- },
167
- } satisfies Meta<typeof CardStackStory>;
168
-
169
- export default meta;
170
-
171
- type Story = StoryObj<typeof CardStackStory>;
172
-
173
- export const Default: Story = {};