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