@dxos/react-ui-list 0.7.4 → 0.7.5-main.9cb18ac

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.
@@ -1,69 +0,0 @@
1
- //
2
- // Copyright 2024 DXOS.org
3
- //
4
-
5
- import { type Edge } from '@atlaskit/pragmatic-drag-and-drop-hitbox/types';
6
- import React, { type CSSProperties, type HTMLAttributes } from 'react';
7
-
8
- import { mx } from '@dxos/react-ui-theme';
9
-
10
- type Orientation = 'horizontal' | 'vertical';
11
-
12
- const edgeToOrientationMap: Record<Edge, Orientation> = {
13
- top: 'horizontal',
14
- bottom: 'horizontal',
15
- left: 'vertical',
16
- right: 'vertical',
17
- };
18
-
19
- const orientationStyles: Record<Orientation, HTMLAttributes<HTMLElement>['className']> = {
20
- horizontal: 'h-[--line-thickness] left-[--terminal-radius] right-0 before:left-[--negative-terminal-size]',
21
- vertical: 'w-[--line-thickness] top-[--terminal-radius] bottom-0 before:top-[--negative-terminal-size]',
22
- };
23
-
24
- const edgeStyles: Record<Edge, HTMLAttributes<HTMLElement>['className']> = {
25
- top: 'top-[--line-offset] before:top-[--offset-terminal]',
26
- right: 'right-[--line-offset] before:right-[--offset-terminal]',
27
- bottom: 'bottom-[--line-offset] before:bottom-[--offset-terminal]',
28
- left: 'left-[--line-offset] before:left-[--offset-terminal]',
29
- };
30
-
31
- const strokeSize = 2;
32
- const terminalSize = 8;
33
- const offsetToAlignTerminalWithLine = (strokeSize - terminalSize) / 2;
34
-
35
- export type DropIndicatorProps = {
36
- edge: Edge;
37
- gap?: number;
38
- };
39
-
40
- /**
41
- * This is a tailwind port of `@atlaskit/pragmatic-drag-and-drop-react-drop-indicator/box`
42
- */
43
- export const DropIndicator = ({ edge, gap = 0 }: DropIndicatorProps) => {
44
- const lineOffset = `calc(-0.5 * (${gap}px + ${strokeSize}px))`;
45
-
46
- const orientation = edgeToOrientationMap[edge];
47
-
48
- return (
49
- <div
50
- style={
51
- {
52
- '--line-thickness': `${strokeSize}px`,
53
- '--line-offset': `${lineOffset}`,
54
- '--terminal-size': `${terminalSize}px`,
55
- '--terminal-radius': `${terminalSize / 2}px`,
56
- '--negative-terminal-size': `-${terminalSize}px`,
57
- '--offset-terminal': `${offsetToAlignTerminalWithLine}px`,
58
- } as CSSProperties
59
- }
60
- className={mx(
61
- 'absolute z-10 pointer-events-none bg-blue-700',
62
- "before:content-[''] before:w-[--terminal-size] before:h-[--terminal-size] box-border before:absolute",
63
- 'before:border-[length:--line-thickness] before:border-solid before:border-blue-700 before:rounded-full',
64
- orientationStyles[orientation],
65
- edgeStyles[edge],
66
- )}
67
- ></div>
68
- );
69
- };
@@ -1,78 +0,0 @@
1
- //
2
- // Copyright 2024 DXOS.org
3
- //
4
-
5
- import { type Instruction } from '@atlaskit/pragmatic-drag-and-drop-hitbox/tree-item';
6
- import React, { type HTMLAttributes, type CSSProperties } from 'react';
7
-
8
- import { mx } from '@dxos/react-ui-theme';
9
-
10
- // Tree item hitbox
11
- // https://github.com/atlassian/pragmatic-drag-and-drop/blob/main/packages/hitbox/constellation/index/about.mdx#tree-item
12
-
13
- type InstructionType = Exclude<Instruction, { type: 'instruction-blocked' }>['type'];
14
- type Orientation = 'sibling' | 'child';
15
-
16
- const edgeToOrientationMap: Record<InstructionType, Orientation> = {
17
- 'reorder-above': 'sibling',
18
- 'reorder-below': 'sibling',
19
- 'make-child': 'child',
20
- reparent: 'child',
21
- };
22
-
23
- const orientationStyles: Record<Orientation, HTMLAttributes<HTMLElement>['className']> = {
24
- // TODO(wittjosiah): Stop using left/right here.
25
- sibling:
26
- 'bs-[--line-thickness] left-[--horizontal-indent] right-0 bg-accentSurface before:left-[--negative-terminal-size]',
27
- child: 'is-full block-start-0 block-end-0 border-[length:--line-thickness] before:invisible',
28
- };
29
-
30
- const instructionStyles: Record<InstructionType, HTMLAttributes<HTMLElement>['className']> = {
31
- 'reorder-above': 'block-start-[--line-offset] before:block-start-[--offset-terminal]',
32
- 'reorder-below': 'block-end-[--line-offset] before:block-end-[--offset-terminal]',
33
- 'make-child': 'border-accentSurface',
34
- // TODO(wittjosiah): This is not occurring in the current implementation.
35
- reparent: '',
36
- };
37
-
38
- const strokeSize = 2;
39
- const terminalSize = 8;
40
- const offsetToAlignTerminalWithLine = (strokeSize - terminalSize) / 2;
41
-
42
- export type DropIndicatorProps = {
43
- instruction: Instruction;
44
- gap?: number;
45
- };
46
-
47
- export const DropIndicator = ({ instruction, gap = 0 }: DropIndicatorProps) => {
48
- const lineOffset = `calc(-0.5 * (${gap}px + ${strokeSize}px))`;
49
- const isBlocked = instruction.type === 'instruction-blocked';
50
- const desiredInstruction = isBlocked ? instruction.desired : instruction;
51
- const orientation = edgeToOrientationMap[desiredInstruction.type];
52
- if (isBlocked) {
53
- return null;
54
- }
55
-
56
- return (
57
- <div
58
- style={
59
- {
60
- '--line-thickness': `${strokeSize}px`,
61
- '--line-offset': `${lineOffset}`,
62
- '--terminal-size': `${terminalSize}px`,
63
- '--terminal-radius': `${terminalSize / 2}px`,
64
- '--negative-terminal-size': `-${terminalSize}px`,
65
- '--offset-terminal': `${offsetToAlignTerminalWithLine}px`,
66
- '--horizontal-indent': `${desiredInstruction.currentLevel * desiredInstruction.indentPerLevel + 4}px`,
67
- } as CSSProperties
68
- }
69
- className={mx(
70
- 'absolute z-10 pointer-events-none',
71
- 'before:is-[--terminal-size] before:bs-[--terminal-size] box-border before:absolute',
72
- 'before:border-[length:--line-thickness] before:border-solid before:border-accentSurface before:rounded-full',
73
- orientationStyles[orientation],
74
- instructionStyles[desiredInstruction.type],
75
- )}
76
- ></div>
77
- );
78
- };