@proyecto-viviana/solidaria-components 0.2.5 → 0.2.9
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.
- package/LICENSE +21 -0
- package/dist/ActionBar.d.ts +71 -0
- package/dist/ActionBar.d.ts.map +1 -0
- package/dist/ActionGroup.d.ts +74 -0
- package/dist/ActionGroup.d.ts.map +1 -0
- package/dist/Alert.d.ts +70 -0
- package/dist/Alert.d.ts.map +1 -0
- package/dist/Breadcrumbs.d.ts +10 -2
- package/dist/Breadcrumbs.d.ts.map +1 -1
- package/dist/Button.d.ts +4 -0
- package/dist/Button.d.ts.map +1 -1
- package/dist/Calendar.d.ts +13 -0
- package/dist/Calendar.d.ts.map +1 -1
- package/dist/Checkbox.d.ts +2 -2
- package/dist/Checkbox.d.ts.map +1 -1
- package/dist/Collection.d.ts +125 -0
- package/dist/Collection.d.ts.map +1 -0
- package/dist/Color.d.ts +114 -2
- package/dist/Color.d.ts.map +1 -1
- package/dist/ColorEditor.d.ts +42 -0
- package/dist/ColorEditor.d.ts.map +1 -0
- package/dist/ComboBox.d.ts +64 -0
- package/dist/ComboBox.d.ts.map +1 -1
- package/dist/ContextualHelpTrigger.d.ts +40 -0
- package/dist/ContextualHelpTrigger.d.ts.map +1 -0
- package/dist/DateField.d.ts +27 -2
- package/dist/DateField.d.ts.map +1 -1
- package/dist/DatePicker.d.ts +67 -2
- package/dist/DatePicker.d.ts.map +1 -1
- package/dist/Dialog.d.ts.map +1 -1
- package/dist/Disclosure.d.ts +2 -0
- package/dist/Disclosure.d.ts.map +1 -1
- package/dist/DragAndDrop.d.ts +80 -0
- package/dist/DragAndDrop.d.ts.map +1 -0
- package/dist/DragPreview.d.ts +14 -0
- package/dist/DragPreview.d.ts.map +1 -0
- package/dist/DropZone.d.ts +27 -0
- package/dist/DropZone.d.ts.map +1 -0
- package/dist/FieldError.d.ts +23 -0
- package/dist/FieldError.d.ts.map +1 -0
- package/dist/FileTrigger.d.ts +26 -0
- package/dist/FileTrigger.d.ts.map +1 -0
- package/dist/Focusable.d.ts +27 -0
- package/dist/Focusable.d.ts.map +1 -0
- package/dist/Form.d.ts +27 -0
- package/dist/Form.d.ts.map +1 -0
- package/dist/GridList.d.ts +40 -1
- package/dist/GridList.d.ts.map +1 -1
- package/dist/Icon.d.ts +57 -0
- package/dist/Icon.d.ts.map +1 -0
- package/dist/Keyboard.d.ts +13 -0
- package/dist/Keyboard.d.ts.map +1 -0
- package/dist/Link.d.ts.map +1 -1
- package/dist/ListBox.d.ts +43 -1
- package/dist/ListBox.d.ts.map +1 -1
- package/dist/ListDropTargetDelegate.d.ts +38 -0
- package/dist/ListDropTargetDelegate.d.ts.map +1 -0
- package/dist/Menu.d.ts +20 -2
- package/dist/Menu.d.ts.map +1 -1
- package/dist/Meter.d.ts +2 -2
- package/dist/Meter.d.ts.map +1 -1
- package/dist/Modal.d.ts +2 -0
- package/dist/Modal.d.ts.map +1 -1
- package/dist/NumberField.d.ts +2 -0
- package/dist/NumberField.d.ts.map +1 -1
- package/dist/Popover.d.ts +4 -2
- package/dist/Popover.d.ts.map +1 -1
- package/dist/Pressable.d.ts +27 -0
- package/dist/Pressable.d.ts.map +1 -0
- package/dist/ProgressBar.d.ts +2 -2
- package/dist/ProgressBar.d.ts.map +1 -1
- package/dist/RadioGroup.d.ts.map +1 -1
- package/dist/RangeCalendar.d.ts +5 -0
- package/dist/RangeCalendar.d.ts.map +1 -1
- package/dist/RouterProvider.d.ts +75 -0
- package/dist/RouterProvider.d.ts.map +1 -0
- package/dist/SearchField.d.ts +2 -3
- package/dist/SearchField.d.ts.map +1 -1
- package/dist/Select.d.ts +11 -0
- package/dist/Select.d.ts.map +1 -1
- package/dist/SelectionIndicator.d.ts +30 -0
- package/dist/SelectionIndicator.d.ts.map +1 -0
- package/dist/SharedElementTransition.d.ts +39 -0
- package/dist/SharedElementTransition.d.ts.map +1 -0
- package/dist/Slider.d.ts +6 -3
- package/dist/Slider.d.ts.map +1 -1
- package/dist/Table.d.ts +39 -0
- package/dist/Table.d.ts.map +1 -1
- package/dist/Tabs.d.ts +4 -3
- package/dist/Tabs.d.ts.map +1 -1
- package/dist/TagGroup.d.ts +12 -2
- package/dist/TagGroup.d.ts.map +1 -1
- package/dist/Text.d.ts +10 -0
- package/dist/Text.d.ts.map +1 -0
- package/dist/TextField.d.ts +4 -0
- package/dist/TextField.d.ts.map +1 -1
- package/dist/TimeField.d.ts +26 -1
- package/dist/TimeField.d.ts.map +1 -1
- package/dist/Toast.d.ts.map +1 -1
- package/dist/ToggleButton.d.ts +30 -0
- package/dist/ToggleButton.d.ts.map +1 -0
- package/dist/ToggleButtonGroup.d.ts +33 -0
- package/dist/ToggleButtonGroup.d.ts.map +1 -0
- package/dist/Toolbar.d.ts.map +1 -1
- package/dist/Tooltip.d.ts +9 -0
- package/dist/Tooltip.d.ts.map +1 -1
- package/dist/Tree.d.ts +44 -2
- package/dist/Tree.d.ts.map +1 -1
- package/dist/Virtualizer.d.ts +61 -0
- package/dist/Virtualizer.d.ts.map +1 -0
- package/dist/VirtualizerLayouts.d.ts +82 -0
- package/dist/VirtualizerLayouts.d.ts.map +1 -0
- package/dist/VisuallyHidden.d.ts +3 -1
- package/dist/VisuallyHidden.d.ts.map +1 -1
- package/dist/contexts.d.ts +1 -0
- package/dist/contexts.d.ts.map +1 -1
- package/dist/index.d.ts +57 -25
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13961 -5946
- package/dist/index.js.map +1 -7
- package/dist/index.ssr.js +9612 -2401
- package/dist/index.ssr.js.map +1 -7
- package/dist/useDragAndDrop.d.ts +93 -0
- package/dist/useDragAndDrop.d.ts.map +1 -0
- package/dist/utils.d.ts +7 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/virtualizer/Layout.d.ts +79 -0
- package/dist/virtualizer/Layout.d.ts.map +1 -0
- package/package.json +8 -6
- package/src/ActionBar.tsx +248 -0
- package/src/ActionGroup.tsx +285 -0
- package/src/Alert.tsx +177 -0
- package/src/Autocomplete.tsx +1 -1
- package/src/Breadcrumbs.tsx +103 -17
- package/src/Button.tsx +65 -21
- package/src/Calendar.tsx +179 -53
- package/src/Checkbox.tsx +1 -2
- package/src/Collection.tsx +341 -0
- package/src/Color.tsx +652 -34
- package/src/ColorEditor.tsx +231 -0
- package/src/ComboBox.tsx +315 -81
- package/src/ContextualHelpTrigger.tsx +183 -0
- package/src/DateField.tsx +93 -19
- package/src/DatePicker.tsx +495 -25
- package/src/Dialog.tsx +40 -9
- package/src/Disclosure.tsx +33 -27
- package/src/DragAndDrop.tsx +334 -0
- package/src/DragPreview.tsx +45 -0
- package/src/DropZone.tsx +213 -0
- package/src/FieldError.tsx +67 -0
- package/src/FileTrigger.tsx +83 -0
- package/src/Focusable.tsx +106 -0
- package/src/Form.tsx +85 -0
- package/src/GridList.tsx +379 -41
- package/src/Icon.tsx +154 -0
- package/src/Keyboard.tsx +26 -0
- package/src/Link.tsx +14 -1
- package/src/ListBox.tsx +484 -33
- package/src/ListDropTargetDelegate.ts +282 -0
- package/src/Menu.tsx +388 -35
- package/src/Meter.tsx +7 -3
- package/src/Modal.tsx +32 -4
- package/src/NumberField.tsx +163 -43
- package/src/Popover.tsx +136 -180
- package/src/Pressable.tsx +108 -0
- package/src/ProgressBar.tsx +7 -3
- package/src/RadioGroup.tsx +35 -25
- package/src/RangeCalendar.tsx +100 -68
- package/src/RouterProvider.tsx +240 -0
- package/src/SearchField.tsx +142 -34
- package/src/Select.tsx +221 -73
- package/src/SelectionIndicator.tsx +105 -0
- package/src/SharedElementTransition.tsx +258 -0
- package/src/Slider.tsx +16 -6
- package/src/Table.tsx +417 -57
- package/src/Tabs.tsx +68 -35
- package/src/TagGroup.tsx +121 -36
- package/src/Text.tsx +18 -0
- package/src/TextField.tsx +25 -8
- package/src/TimeField.tsx +101 -151
- package/src/Toast.tsx +108 -14
- package/src/ToggleButton.tsx +159 -0
- package/src/ToggleButtonGroup.tsx +136 -0
- package/src/Toolbar.tsx +14 -8
- package/src/Tooltip.tsx +108 -19
- package/src/Tree.tsx +1143 -87
- package/src/Virtualizer.tsx +702 -0
- package/src/VirtualizerLayouts.ts +265 -0
- package/src/VisuallyHidden.tsx +15 -21
- package/src/contexts.ts +1 -0
- package/src/index.ts +1057 -620
- package/src/useDragAndDrop.ts +351 -0
- package/src/utils.tsx +37 -3
- package/src/virtualizer/Layout.ts +200 -0
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import type { Accessor } from 'solid-js';
|
|
2
|
+
import type { DropTarget } from '@proyecto-viviana/solid-stately';
|
|
3
|
+
|
|
4
|
+
type Direction = 'ltr' | 'rtl';
|
|
5
|
+
type Orientation = 'horizontal' | 'vertical';
|
|
6
|
+
type Layout = 'stack' | 'grid';
|
|
7
|
+
|
|
8
|
+
interface CollectionNodeLike {
|
|
9
|
+
key: string | number;
|
|
10
|
+
type?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface ListDropTargetDelegateOptions {
|
|
14
|
+
layout?: Layout;
|
|
15
|
+
orientation?: Orientation;
|
|
16
|
+
direction?: Direction;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const cssEscape = (value: string): string => {
|
|
20
|
+
const css = (globalThis as { CSS?: { escape?: (input: string) => string } }).CSS;
|
|
21
|
+
return css?.escape ? css.escape(value) : value.replace(/[^a-zA-Z0-9_-]/g, '\\$&');
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export class ListDropTargetDelegate {
|
|
25
|
+
private collection: Iterable<CollectionNodeLike> | (() => Iterable<CollectionNodeLike>);
|
|
26
|
+
private ref: Accessor<HTMLElement | null>;
|
|
27
|
+
private layout: Layout;
|
|
28
|
+
private orientation: Orientation;
|
|
29
|
+
private direction: Direction;
|
|
30
|
+
|
|
31
|
+
constructor(
|
|
32
|
+
collection: Iterable<CollectionNodeLike> | (() => Iterable<CollectionNodeLike>),
|
|
33
|
+
ref: Accessor<HTMLElement | null>,
|
|
34
|
+
options?: ListDropTargetDelegateOptions
|
|
35
|
+
) {
|
|
36
|
+
this.collection = collection;
|
|
37
|
+
this.ref = ref;
|
|
38
|
+
this.layout = options?.layout ?? 'stack';
|
|
39
|
+
this.orientation = options?.orientation ?? 'vertical';
|
|
40
|
+
this.direction = options?.direction ?? 'ltr';
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
private getCollection(): Iterable<CollectionNodeLike> {
|
|
44
|
+
return typeof this.collection === 'function'
|
|
45
|
+
? (this.collection as () => Iterable<CollectionNodeLike>)()
|
|
46
|
+
: this.collection;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
private getPrimaryStart(rect: DOMRect): number {
|
|
50
|
+
return this.orientation === 'horizontal' ? rect.left : rect.top;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
private getPrimaryEnd(rect: DOMRect): number {
|
|
54
|
+
return this.orientation === 'horizontal' ? rect.right : rect.bottom;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
private getSecondaryStart(rect: DOMRect): number {
|
|
58
|
+
return this.orientation === 'horizontal' ? rect.top : rect.left;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
private getSecondaryEnd(rect: DOMRect): number {
|
|
62
|
+
return this.orientation === 'horizontal' ? rect.bottom : rect.right;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
private getFlowStart(rect: DOMRect): number {
|
|
66
|
+
return this.layout === 'stack' ? this.getPrimaryStart(rect) : this.getSecondaryStart(rect);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
private getFlowEnd(rect: DOMRect): number {
|
|
70
|
+
return this.layout === 'stack' ? this.getPrimaryEnd(rect) : this.getSecondaryEnd(rect);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
private getFlowSize(rect: DOMRect): number {
|
|
74
|
+
return this.getFlowEnd(rect) - this.getFlowStart(rect);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
private getItemKeys(): Array<string | number> {
|
|
78
|
+
return [...this.getCollection()]
|
|
79
|
+
.filter((item) => item.type === 'item')
|
|
80
|
+
.map((item) => item.key);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
private resolveBoundaryTarget(
|
|
84
|
+
direction: 'next' | 'previous',
|
|
85
|
+
isValidDropTarget: (target: DropTarget) => boolean
|
|
86
|
+
): DropTarget | null {
|
|
87
|
+
const keys = this.getItemKeys();
|
|
88
|
+
if (keys.length === 0) return null;
|
|
89
|
+
const key = direction === 'next' ? keys[0] : keys[keys.length - 1];
|
|
90
|
+
const order: Array<'before' | 'on' | 'after'> = direction === 'next'
|
|
91
|
+
? ['before', 'on', 'after']
|
|
92
|
+
: ['after', 'on', 'before'];
|
|
93
|
+
for (const dropPosition of order) {
|
|
94
|
+
const target: DropTarget = { type: 'item', key, dropPosition };
|
|
95
|
+
if (isValidDropTarget(target)) return target;
|
|
96
|
+
}
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
private resolveTransitionTarget(
|
|
101
|
+
target: DropTarget,
|
|
102
|
+
direction: 'next' | 'previous',
|
|
103
|
+
isValidDropTarget: (target: DropTarget) => boolean
|
|
104
|
+
): DropTarget | null {
|
|
105
|
+
if (target.type !== 'item') return null;
|
|
106
|
+
const tryPosition = (dropPosition: 'before' | 'on' | 'after'): DropTarget | null => {
|
|
107
|
+
if (target.dropPosition === dropPosition) return null;
|
|
108
|
+
const nextTarget: DropTarget = {
|
|
109
|
+
type: 'item',
|
|
110
|
+
key: target.key,
|
|
111
|
+
dropPosition,
|
|
112
|
+
};
|
|
113
|
+
return isValidDropTarget(nextTarget) ? nextTarget : null;
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
if (direction === 'next') {
|
|
117
|
+
if (target.dropPosition === 'before') {
|
|
118
|
+
return tryPosition('on') ?? tryPosition('after');
|
|
119
|
+
}
|
|
120
|
+
if (target.dropPosition === 'on') {
|
|
121
|
+
return tryPosition('after');
|
|
122
|
+
}
|
|
123
|
+
} else {
|
|
124
|
+
if (target.dropPosition === 'after') {
|
|
125
|
+
return tryPosition('on') ?? tryPosition('before');
|
|
126
|
+
}
|
|
127
|
+
if (target.dropPosition === 'on') {
|
|
128
|
+
return tryPosition('before');
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
private resolveNeighborTarget(
|
|
136
|
+
target: DropTarget,
|
|
137
|
+
direction: 'next' | 'previous',
|
|
138
|
+
isValidDropTarget: (target: DropTarget) => boolean
|
|
139
|
+
): DropTarget | null {
|
|
140
|
+
if (target.type !== 'item') return null;
|
|
141
|
+
const keys = this.getItemKeys();
|
|
142
|
+
const index = keys.findIndex((key) => key === target.key);
|
|
143
|
+
if (index < 0) return this.resolveBoundaryTarget(direction, isValidDropTarget);
|
|
144
|
+
const nextIndex = direction === 'next' ? index + 1 : index - 1;
|
|
145
|
+
if (nextIndex < 0 || nextIndex >= keys.length) {
|
|
146
|
+
const rootTarget: DropTarget = { type: 'root' };
|
|
147
|
+
return isValidDropTarget(rootTarget) ? rootTarget : null;
|
|
148
|
+
}
|
|
149
|
+
const key = keys[nextIndex];
|
|
150
|
+
const order: Array<'on' | 'before' | 'after'> = direction === 'next'
|
|
151
|
+
? ['on', 'before', 'after']
|
|
152
|
+
: ['on', 'after', 'before'];
|
|
153
|
+
for (const dropPosition of order) {
|
|
154
|
+
const nextTarget: DropTarget = { type: 'item', key, dropPosition };
|
|
155
|
+
if (isValidDropTarget(nextTarget)) return nextTarget;
|
|
156
|
+
}
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
getKeyboardNavigationTarget(
|
|
161
|
+
target: DropTarget | null,
|
|
162
|
+
direction: 'next' | 'previous',
|
|
163
|
+
isValidDropTarget: (target: DropTarget) => boolean
|
|
164
|
+
): DropTarget | null {
|
|
165
|
+
if (!target || target.type === 'root') {
|
|
166
|
+
return this.resolveBoundaryTarget(direction, isValidDropTarget);
|
|
167
|
+
}
|
|
168
|
+
const transition = this.resolveTransitionTarget(target, direction, isValidDropTarget);
|
|
169
|
+
if (transition) return transition;
|
|
170
|
+
return this.resolveNeighborTarget(target, direction, isValidDropTarget);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
getDropTargetFromPoint(
|
|
174
|
+
x: number,
|
|
175
|
+
y: number,
|
|
176
|
+
isValidDropTarget: (target: DropTarget) => boolean
|
|
177
|
+
): DropTarget {
|
|
178
|
+
const root = this.ref();
|
|
179
|
+
if (!root) {
|
|
180
|
+
return { type: 'root' };
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const allItems = [...this.getCollection()].filter((item) => item.type === 'item');
|
|
184
|
+
if (allItems.length === 0) {
|
|
185
|
+
return { type: 'root' };
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const collectionId = root.dataset.collection;
|
|
189
|
+
const selector = collectionId
|
|
190
|
+
? `[data-collection="${cssEscape(collectionId)}"]`
|
|
191
|
+
: '[data-key]';
|
|
192
|
+
const elements = root.querySelectorAll(selector);
|
|
193
|
+
const elementMap = new Map<string, HTMLElement>();
|
|
194
|
+
for (const node of elements) {
|
|
195
|
+
if (node instanceof HTMLElement && node.dataset.key != null) {
|
|
196
|
+
elementMap.set(node.dataset.key, node);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
let low = 0;
|
|
201
|
+
let high = allItems.length;
|
|
202
|
+
const rootRect = root.getBoundingClientRect();
|
|
203
|
+
let primary = this.orientation === 'horizontal' ? x : y;
|
|
204
|
+
let secondary = this.orientation === 'horizontal' ? y : x;
|
|
205
|
+
primary += this.getPrimaryStart(rootRect);
|
|
206
|
+
secondary += this.getSecondaryStart(rootRect);
|
|
207
|
+
|
|
208
|
+
const flow = this.layout === 'stack' ? primary : secondary;
|
|
209
|
+
const isPrimaryRtl = this.orientation === 'horizontal' && this.direction === 'rtl';
|
|
210
|
+
const isSecondaryRtl = this.layout === 'grid' && this.orientation === 'vertical' && this.direction === 'rtl';
|
|
211
|
+
const isFlowRtl = this.layout === 'stack' ? isPrimaryRtl : isSecondaryRtl;
|
|
212
|
+
|
|
213
|
+
while (low < high) {
|
|
214
|
+
const mid = Math.floor((low + high) / 2);
|
|
215
|
+
const item = allItems[mid];
|
|
216
|
+
const element = elementMap.get(String(item.key));
|
|
217
|
+
if (!element) break;
|
|
218
|
+
const rect = element.getBoundingClientRect();
|
|
219
|
+
const update = (isGreater: boolean) => {
|
|
220
|
+
if (isGreater) {
|
|
221
|
+
low = mid + 1;
|
|
222
|
+
} else {
|
|
223
|
+
high = mid;
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
if (primary < this.getPrimaryStart(rect)) {
|
|
228
|
+
update(isPrimaryRtl);
|
|
229
|
+
} else if (primary > this.getPrimaryEnd(rect)) {
|
|
230
|
+
update(!isPrimaryRtl);
|
|
231
|
+
} else if (secondary < this.getSecondaryStart(rect)) {
|
|
232
|
+
update(isSecondaryRtl);
|
|
233
|
+
} else if (secondary > this.getSecondaryEnd(rect)) {
|
|
234
|
+
update(!isSecondaryRtl);
|
|
235
|
+
} else {
|
|
236
|
+
const target: DropTarget = {
|
|
237
|
+
type: 'item',
|
|
238
|
+
key: item.key,
|
|
239
|
+
dropPosition: 'on',
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
if (isValidDropTarget(target)) {
|
|
243
|
+
if (flow <= this.getFlowStart(rect) + 5 && isValidDropTarget({ ...target, dropPosition: 'before' })) {
|
|
244
|
+
target.dropPosition = isFlowRtl ? 'after' : 'before';
|
|
245
|
+
} else if (flow >= this.getFlowEnd(rect) - 5 && isValidDropTarget({ ...target, dropPosition: 'after' })) {
|
|
246
|
+
target.dropPosition = isFlowRtl ? 'before' : 'after';
|
|
247
|
+
}
|
|
248
|
+
} else {
|
|
249
|
+
const midpoint = this.getFlowStart(rect) + this.getFlowSize(rect) / 2;
|
|
250
|
+
if (flow <= midpoint && isValidDropTarget({ ...target, dropPosition: 'before' })) {
|
|
251
|
+
target.dropPosition = isFlowRtl ? 'after' : 'before';
|
|
252
|
+
} else if (flow >= midpoint && isValidDropTarget({ ...target, dropPosition: 'after' })) {
|
|
253
|
+
target.dropPosition = isFlowRtl ? 'before' : 'after';
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
return target;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
const item = allItems[Math.min(low, allItems.length - 1)];
|
|
262
|
+
const element = elementMap.get(String(item.key));
|
|
263
|
+
const rect = element?.getBoundingClientRect();
|
|
264
|
+
if (
|
|
265
|
+
rect &&
|
|
266
|
+
(primary < this.getPrimaryStart(rect) ||
|
|
267
|
+
Math.abs(flow - this.getFlowStart(rect)) < Math.abs(flow - this.getFlowEnd(rect)))
|
|
268
|
+
) {
|
|
269
|
+
return {
|
|
270
|
+
type: 'item',
|
|
271
|
+
key: item.key,
|
|
272
|
+
dropPosition: isFlowRtl ? 'after' : 'before',
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
return {
|
|
277
|
+
type: 'item',
|
|
278
|
+
key: item.key,
|
|
279
|
+
dropPosition: isFlowRtl ? 'before' : 'after',
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
}
|