quasar-ui-danx 0.2.15 → 0.2.17
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/danx.es.js +2 -2
- package/dist/danx.es.js.map +1 -1
- package/dist/danx.umd.js +1 -1
- package/dist/danx.umd.js.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/src/components/ActionTable/ActionMenu.vue +4 -4
- package/src/components/ActionTable/ActionTable.vue +12 -12
- package/src/components/ActionTable/ActionTableColumn.vue +11 -11
- package/src/components/ActionTable/Columns/ColumnListItem.vue +2 -2
- package/src/components/ActionTable/Columns/ColumnSettingsDialog.vue +8 -8
- package/src/components/ActionTable/Columns/TitleColumnFormat.vue +1 -1
- package/src/components/ActionTable/Columns/VisibleColumnsToggleButtons.vue +7 -7
- package/src/components/ActionTable/EmptyTableState.vue +4 -4
- package/src/components/ActionTable/Filters/CollapsableFiltersSidebar.vue +3 -3
- package/src/components/ActionTable/Filters/FilterFieldList.vue +6 -6
- package/src/components/ActionTable/Filters/FilterListToggle.vue +3 -3
- package/src/components/ActionTable/Filters/FilterToolbarLayout.vue +3 -3
- package/src/components/ActionTable/Filters/FilterableField.vue +6 -6
- package/src/components/ActionTable/Form/Fields/BooleanField.vue +4 -4
- package/src/components/ActionTable/Form/Fields/ConfirmPasswordField.vue +7 -7
- package/src/components/ActionTable/Form/Fields/DateField.vue +6 -6
- package/src/components/ActionTable/Form/Fields/DateRangeField.vue +13 -13
- package/src/components/ActionTable/Form/Fields/DateTimeField.vue +6 -6
- package/src/components/ActionTable/Form/Fields/DateTimePicker.vue +6 -6
- package/src/components/ActionTable/Form/Fields/EditableDiv.vue +3 -3
- package/src/components/ActionTable/Form/Fields/FieldLabel.vue +2 -2
- package/src/components/ActionTable/Form/Fields/FileUploadButton.vue +15 -15
- package/src/components/ActionTable/Form/Fields/InlineDateTimeField.vue +7 -7
- package/src/components/ActionTable/Form/Fields/IntegerField.vue +2 -2
- package/src/components/ActionTable/Form/Fields/LabeledInput.vue +2 -2
- package/src/components/ActionTable/Form/Fields/MultiFileField.vue +6 -6
- package/src/components/ActionTable/Form/Fields/MultiKeywordField.vue +8 -8
- package/src/components/ActionTable/Form/Fields/NewPasswordField.vue +6 -6
- package/src/components/ActionTable/Form/Fields/NumberField.vue +20 -20
- package/src/components/ActionTable/Form/Fields/NumberRangeField.vue +20 -20
- package/src/components/ActionTable/Form/Fields/SelectDrawer.vue +8 -8
- package/src/components/ActionTable/Form/Fields/SelectField.vue +36 -36
- package/src/components/ActionTable/Form/Fields/SelectWithChildrenField.vue +9 -9
- package/src/components/ActionTable/Form/Fields/SingleFileField.vue +6 -6
- package/src/components/ActionTable/Form/Fields/TextField.vue +15 -15
- package/src/components/ActionTable/Form/Fields/WysiwygField.vue +4 -4
- package/src/components/ActionTable/Form/RenderedForm.vue +5 -5
- package/src/components/ActionTable/TableSummaryRow.vue +8 -8
- package/src/components/ActionTable/listControls.ts +5 -5
- package/src/components/ActionTable/listHelpers.ts +1 -1
- package/src/components/ActionTable/tableColumns.ts +24 -1
- package/src/components/AuditHistory/AuditHistoryItem.vue +4 -4
- package/src/components/AuditHistory/AuditHistoryItemValue.vue +10 -10
- package/src/components/DragAndDrop/HandleDraggable.vue +8 -8
- package/src/components/DragAndDrop/ListItemDraggable.vue +8 -8
- package/src/components/DragAndDrop/dragAndDrop.ts +219 -219
- package/src/components/DragAndDrop/listDragAndDrop.ts +4 -4
- package/src/components/PanelsDrawer/PanelsDrawer.vue +8 -8
- package/src/components/PanelsDrawer/PanelsDrawerPanels.vue +1 -1
- package/src/components/PanelsDrawer/PanelsDrawerTabs.vue +4 -4
- package/src/components/Utility/Buttons/ExportButton.vue +4 -4
- package/src/components/Utility/Buttons/RefreshButton.vue +2 -2
- package/src/components/Utility/Controls/PreviousNextControls.vue +2 -2
- package/src/components/Utility/Dialogs/ConfirmDialog.vue +14 -14
- package/src/components/Utility/Dialogs/FullScreenDialog.vue +8 -8
- package/src/components/Utility/Dialogs/FullscreenCarouselDialog.vue +11 -11
- package/src/components/Utility/Dialogs/InfoDialog.vue +12 -12
- package/src/components/Utility/Dialogs/InputDialog.vue +5 -5
- package/src/components/Utility/Files/FilePreview.vue +10 -10
- package/src/components/Utility/Formats/GpsCoordinatesFormat.vue +4 -4
- package/src/components/Utility/Formats/IconWithTextFormat.vue +2 -2
- package/src/components/Utility/Formats/LabelValueFormat.vue +2 -2
- package/src/components/Utility/Layouts/CollapsableSidebar.vue +15 -15
- package/src/components/Utility/Layouts/ContentDrawer.vue +6 -6
- package/src/components/Utility/Popovers/InteractiveTooltip.vue +4 -4
- package/src/components/Utility/Popovers/PopoverMenu.vue +49 -49
- package/src/components/Utility/Tabs/BadgeTab.vue +1 -1
- package/src/components/Utility/Tabs/IndicatorTab.vue +3 -3
- package/src/components/Utility/Tools/ActionVnode.vue +3 -3
- package/src/components/Utility/Tools/RenderComponent.vue +3 -3
- package/src/components/Utility/Transitions/StaggeredListTransition.vue +3 -3
- package/src/helpers/array.ts +16 -16
- package/src/helpers/storage.ts +5 -5
- package/src/helpers/utils.ts +1 -1
- package/src/index.common.js +1 -2
- package/src/index.esm.js +1 -1
- package/src/index.umd.js +2 -2
- package/src/svg/CaretDownIcon.svg +1 -1
- package/src/svg/DragHandleDotsIcon.svg +3 -3
- package/src/svg/DragHandleIcon.svg +3 -3
- package/src/svg/FilterIcon.svg +5 -5
- package/src/svg/ImageIcon.svg +27 -27
- package/src/svg/PdfIcon.svg +5 -5
- package/src/svg/SkipNextIcon.svg +3 -3
- package/src/svg/SkipPreviousIcon.svg +3 -3
- package/src/svg/TrashIcon.svg +12 -12
- package/src/svg/WarningIcon.svg +3 -3
- package/src/svg/XIcon.svg +15 -15
- package/src/vue-plugin.js +5 -5
- package/vite.config.js +7 -0
@@ -1,7 +1,30 @@
|
|
1
1
|
import { computed, ref, watch } from "vue";
|
2
2
|
import { getItem, setItem } from "../../helpers";
|
3
3
|
|
4
|
-
export
|
4
|
+
export interface TableColumn {
|
5
|
+
actionMenu?: object,
|
6
|
+
align?: string,
|
7
|
+
category?: string,
|
8
|
+
class?: string | object,
|
9
|
+
field: string,
|
10
|
+
format?: Function,
|
11
|
+
innerClass?: string | object,
|
12
|
+
isSaving?: boolean,
|
13
|
+
label: string,
|
14
|
+
maxWidth?: number,
|
15
|
+
minWidth?: number,
|
16
|
+
name: string,
|
17
|
+
onClick?: Function,
|
18
|
+
required?: boolean,
|
19
|
+
resizeable?: boolean,
|
20
|
+
sortable?: boolean,
|
21
|
+
sortBy?: string,
|
22
|
+
sortByExpression?: string,
|
23
|
+
titleColumns?: string[]
|
24
|
+
vnode?: Function,
|
25
|
+
}
|
26
|
+
|
27
|
+
export function useTableColumns(name: string, columns: TableColumn[]) {
|
5
28
|
const COLUMN_ORDER_KEY = `${name}-column-order`;
|
6
29
|
const VISIBLE_COLUMNS_KEY = `${name}-visible-columns`;
|
7
30
|
const TITLE_COLUMNS_KEY = `${name}-title-columns`;
|
@@ -31,9 +31,9 @@
|
|
31
31
|
</div>
|
32
32
|
</template>
|
33
33
|
<script setup>
|
34
|
-
import { computed } from
|
35
|
-
import { fLocalizedDateTime } from
|
36
|
-
import AuditHistoryItemValue from
|
34
|
+
import { computed } from "vue";
|
35
|
+
import { fLocalizedDateTime } from "../../helpers";
|
36
|
+
import AuditHistoryItemValue from "./AuditHistoryItemValue";
|
37
37
|
|
38
38
|
const props = defineProps({
|
39
39
|
item: {
|
@@ -46,7 +46,7 @@ const props = defineProps({
|
|
46
46
|
},
|
47
47
|
novaUrl: {
|
48
48
|
type: String,
|
49
|
-
default:
|
49
|
+
default: "/nova"
|
50
50
|
}
|
51
51
|
});
|
52
52
|
|
@@ -23,8 +23,8 @@
|
|
23
23
|
</div>
|
24
24
|
</template>
|
25
25
|
<script setup>
|
26
|
-
import { fCurrency, fDate, fLocalizedDateTime, fNumber } from
|
27
|
-
import { FilePreview } from
|
26
|
+
import { fCurrency, fDate, fLocalizedDateTime, fNumber } from "../../helpers";
|
27
|
+
import { FilePreview } from "../Utility";
|
28
28
|
|
29
29
|
const props = defineProps({
|
30
30
|
type: {
|
@@ -38,21 +38,21 @@ const props = defineProps({
|
|
38
38
|
});
|
39
39
|
|
40
40
|
function format(value) {
|
41
|
-
if (value === null || value ===
|
42
|
-
return
|
41
|
+
if (value === null || value === "" || value === undefined) {
|
42
|
+
return "";
|
43
43
|
}
|
44
44
|
|
45
45
|
switch (props.type) {
|
46
|
-
case
|
46
|
+
case "NUMBER":
|
47
47
|
return fNumber(value);
|
48
|
-
case
|
48
|
+
case "CURRENCY":
|
49
49
|
return fCurrency(value);
|
50
|
-
case
|
50
|
+
case "DATE":
|
51
51
|
return fDate(value);
|
52
|
-
case
|
52
|
+
case "DATETIME":
|
53
53
|
return fLocalizedDateTime(value);
|
54
|
-
case
|
55
|
-
return value ?
|
54
|
+
case "BOOLEAN":
|
55
|
+
return value ? "Yes" : "No";
|
56
56
|
}
|
57
57
|
|
58
58
|
return value;
|
@@ -13,10 +13,10 @@
|
|
13
13
|
</div>
|
14
14
|
</template>
|
15
15
|
<script setup>
|
16
|
-
import { useDebounceFn } from
|
17
|
-
import { DragAndDrop } from
|
16
|
+
import { useDebounceFn } from "@vueuse/core";
|
17
|
+
import { DragAndDrop } from "./dragAndDrop";
|
18
18
|
|
19
|
-
const emit = defineEmits([
|
19
|
+
const emit = defineEmits(["start", "end", "resize"]);
|
20
20
|
const props = defineProps({
|
21
21
|
initialValue: {
|
22
22
|
type: Number,
|
@@ -28,8 +28,8 @@ const props = defineProps({
|
|
28
28
|
},
|
29
29
|
direction: {
|
30
30
|
type: String,
|
31
|
-
default:
|
32
|
-
validator: (value) => [
|
31
|
+
default: "horizontal",
|
32
|
+
validator: (value) => ["vertical", "horizontal"].includes(value)
|
33
33
|
}
|
34
34
|
});
|
35
35
|
|
@@ -41,13 +41,13 @@ const dragAndDrop = new DragAndDrop()
|
|
41
41
|
hideDragImage: true
|
42
42
|
})
|
43
43
|
.onDragging(useDebounceFn(() => {
|
44
|
-
emit(
|
44
|
+
emit("resize", {
|
45
45
|
distance: dragAndDrop.getDistance(),
|
46
46
|
percent: dragAndDrop.getPercentChange(),
|
47
47
|
startDropZoneSize: dragAndDrop.startSize,
|
48
48
|
dropZoneSize: dragAndDrop.getDropZoneSize()
|
49
49
|
});
|
50
50
|
}, 20, { maxWait: 30 }))
|
51
|
-
.onStart(() => emit(
|
52
|
-
.onEnd(() => emit(
|
51
|
+
.onStart(() => emit("start"))
|
52
|
+
.onEnd(() => emit("end"));
|
53
53
|
</script>
|
@@ -16,11 +16,11 @@
|
|
16
16
|
</div>
|
17
17
|
</template>
|
18
18
|
<script setup>
|
19
|
-
import { DragHandleDotsIcon as DragHandleIcon } from
|
20
|
-
import { SvgImg } from
|
21
|
-
import { ListDragAndDrop } from
|
19
|
+
import { DragHandleDotsIcon as DragHandleIcon } from "../../svg";
|
20
|
+
import { SvgImg } from "../Utility";
|
21
|
+
import { ListDragAndDrop } from "./listDragAndDrop";
|
22
22
|
|
23
|
-
const emit = defineEmits([
|
23
|
+
const emit = defineEmits(["position", "update:list-items"]);
|
24
24
|
const props = defineProps({
|
25
25
|
dropZone: {
|
26
26
|
type: [Function, String],
|
@@ -28,8 +28,8 @@ const props = defineProps({
|
|
28
28
|
},
|
29
29
|
direction: {
|
30
30
|
type: String,
|
31
|
-
default:
|
32
|
-
validator: (value) => [
|
31
|
+
default: "vertical",
|
32
|
+
validator: (value) => ["vertical", "horizontal"].includes(value)
|
33
33
|
},
|
34
34
|
showHandle: Boolean,
|
35
35
|
listItems: {
|
@@ -42,12 +42,12 @@ const dragAndDrop = new ListDragAndDrop()
|
|
42
42
|
.setDropZone(props.dropZone)
|
43
43
|
.setOptions({ showPlaceholder: true, direction: props.direction })
|
44
44
|
.onPositionChange((newPosition, oldPosition) => {
|
45
|
-
emit(
|
45
|
+
emit("position", newPosition);
|
46
46
|
|
47
47
|
if (props.listItems) {
|
48
48
|
const items = [...props.listItems];
|
49
49
|
items.splice(newPosition, 0, items.splice(oldPosition, 1)[0]);
|
50
|
-
emit(
|
50
|
+
emit("update:list-items", items);
|
51
51
|
}
|
52
52
|
});
|
53
53
|
</script>
|
@@ -2,224 +2,224 @@
|
|
2
2
|
* Drag and Drop basic functionality for dragging elements and firing events on drag start, drag over and drag end
|
3
3
|
*/
|
4
4
|
export class DragAndDrop {
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
5
|
+
options: {
|
6
|
+
direction?: string,
|
7
|
+
hideDragImage?: boolean,
|
8
|
+
showPlaceholder?: boolean,
|
9
|
+
} = { direction: "vertical", hideDragImage: false };
|
10
|
+
|
11
|
+
// State
|
12
|
+
startY = 0;
|
13
|
+
startX = 0;
|
14
|
+
startSize = 0;
|
15
|
+
cursorY = 0;
|
16
|
+
cursorX = 0;
|
17
|
+
onStartCb = null;
|
18
|
+
onEndCb = null;
|
19
|
+
onDropCb = null;
|
20
|
+
onDraggingCb = null;
|
21
|
+
dropZoneResolver = null;
|
22
|
+
currentDropZone = null;
|
23
|
+
draggableData = null;
|
24
|
+
// Used to abort dragging event listeners on the element
|
25
|
+
abortController = null;
|
26
|
+
|
27
|
+
constructor(options = {}) {
|
28
|
+
// Options
|
29
|
+
options = {
|
30
|
+
direction: "vertical",
|
31
|
+
hideDragImage: false,
|
32
|
+
...options
|
33
|
+
};
|
34
|
+
|
35
|
+
this.setOptions(options);
|
36
|
+
}
|
37
|
+
|
38
|
+
/**
|
39
|
+
* Set the options for the drag and drop instance
|
40
|
+
* @param options
|
41
|
+
* @returns {DragAndDrop}
|
42
|
+
*/
|
43
|
+
setOptions(options = {}) {
|
44
|
+
this.options = { ...this.options, ...options };
|
45
|
+
return this;
|
46
|
+
}
|
47
|
+
|
48
|
+
/**
|
49
|
+
* Returns if the list is stacked vertically or horizontally
|
50
|
+
* @returns {boolean}
|
51
|
+
*/
|
52
|
+
isVertical() {
|
53
|
+
return this.options.direction === "vertical";
|
54
|
+
}
|
55
|
+
|
56
|
+
/**
|
57
|
+
* Set the target drop zone for draggable elements
|
58
|
+
* @param dropZone
|
59
|
+
* @returns {DragAndDrop}
|
60
|
+
*/
|
61
|
+
setDropZone(dropZone) {
|
62
|
+
this.dropZoneResolver = dropZone;
|
63
|
+
return this;
|
64
|
+
}
|
65
|
+
|
66
|
+
/**
|
67
|
+
* Callback that fires when an element has started dragging
|
68
|
+
* @param cb
|
69
|
+
* @returns {DragAndDrop}
|
70
|
+
*/
|
71
|
+
onStart(cb) {
|
72
|
+
this.onStartCb = cb;
|
73
|
+
return this;
|
74
|
+
}
|
75
|
+
|
76
|
+
/**
|
77
|
+
* Callback that fires when an element has stopped dragging
|
78
|
+
* @param cb
|
79
|
+
* @returns {DragAndDrop}
|
80
|
+
*/
|
81
|
+
onEnd(cb) {
|
82
|
+
this.onEndCb = cb;
|
83
|
+
return this;
|
84
|
+
}
|
85
|
+
|
86
|
+
/**
|
87
|
+
* Callback that fires when the dragging element is moved
|
88
|
+
* @param cb
|
89
|
+
* @returns {DragAndDrop}
|
90
|
+
*/
|
91
|
+
onDragging(cb) {
|
92
|
+
this.onDraggingCb = cb;
|
93
|
+
return this;
|
94
|
+
}
|
95
|
+
|
96
|
+
/**
|
97
|
+
* Callback that fires when the dragging element has been dropped
|
98
|
+
* @param cb
|
99
|
+
* @returns {DragAndDrop}
|
100
|
+
*/
|
101
|
+
onDrop(cb) {
|
102
|
+
this.onDropCb = cb;
|
103
|
+
return this;
|
104
|
+
}
|
105
|
+
|
106
|
+
/**
|
107
|
+
* Start listening for drag events and prepare an element for drag/drop
|
108
|
+
* @param e
|
109
|
+
* @param data
|
110
|
+
*/
|
111
|
+
dragStart(e, data) {
|
112
|
+
this.currentDropZone = this.getDropZone(e);
|
113
|
+
|
114
|
+
if (this.currentDropZone) {
|
115
|
+
this.startY = e.clientY;
|
116
|
+
this.startX = e.clientX;
|
117
|
+
this.startSize = this.getDropZoneSize();
|
118
|
+
e.dataTransfer.effectAllowed = "move";
|
119
|
+
e.dataTransfer.dropEffect = "move";
|
120
|
+
this.draggableData = data;
|
121
|
+
this.abortController = new AbortController();
|
122
|
+
const options = { signal: this.abortController.signal };
|
123
|
+
document.addEventListener("dragenter", (e) => this.dragEnter(e), options);
|
124
|
+
document.addEventListener("dragover", (e) => this.dragOver(e), options);
|
125
|
+
document.addEventListener("drop", (e) => this.drop(e), options);
|
126
|
+
this.onStartCb && this.onStartCb(e);
|
127
|
+
|
128
|
+
if (this.options.hideDragImage) {
|
129
|
+
e.dataTransfer.setDragImage(new Image(), 0, 0);
|
130
|
+
}
|
131
|
+
} else {
|
132
|
+
console.error("Drop zone was not found", e, data);
|
133
|
+
}
|
134
|
+
}
|
135
|
+
|
136
|
+
/**
|
137
|
+
* Clean up event listeners after dragging is done
|
138
|
+
*/
|
139
|
+
dragEnd(e) {
|
140
|
+
this.currentDropZone = null;
|
141
|
+
this.abortController.abort();
|
142
|
+
this.draggableData = null;
|
143
|
+
this.onEndCb && this.onEndCb(e);
|
144
|
+
}
|
145
|
+
|
146
|
+
/**
|
147
|
+
* The dragging element has entered a new target
|
148
|
+
* @param e
|
149
|
+
*/
|
150
|
+
dragEnter(e) {
|
151
|
+
e.preventDefault();
|
152
|
+
}
|
153
|
+
|
154
|
+
/**
|
155
|
+
* The dragging element is moving
|
156
|
+
* @param e
|
157
|
+
*/
|
158
|
+
dragOver(e) {
|
159
|
+
e.preventDefault();
|
160
|
+
this.cursorY = e.clientY;
|
161
|
+
this.cursorX = e.clientX;
|
162
|
+
this.onDraggingCb && this.onDraggingCb(e);
|
163
|
+
}
|
164
|
+
|
165
|
+
/**
|
166
|
+
* Handle dropping the element into its correct position
|
167
|
+
* @param e
|
168
|
+
*/
|
169
|
+
drop(e) {
|
170
|
+
e.dataTransfer.dropEffect = "move";
|
171
|
+
e.preventDefault();
|
172
|
+
this.onDropCb && this.onDropCb(e, this.draggableData);
|
173
|
+
}
|
174
|
+
|
175
|
+
/**
|
176
|
+
* Returns the drop zone if the current target element is or is inside the drop zone
|
177
|
+
* @param e
|
178
|
+
* @returns {HTMLElement|null}
|
179
|
+
*/
|
180
|
+
getDropZone(e) {
|
181
|
+
if (typeof this.dropZoneResolver === "string") {
|
182
|
+
let target = e.target;
|
183
|
+
while (target) {
|
184
|
+
if (target.dataset?.dropZone === this.dropZoneResolver) {
|
185
|
+
return target;
|
186
|
+
}
|
187
|
+
target = target.parentNode;
|
188
|
+
}
|
189
|
+
return null;
|
190
|
+
} else if (typeof this.dropZoneResolver === "function") {
|
191
|
+
return this.dropZoneResolver(e);
|
192
|
+
} else {
|
193
|
+
return document.body;
|
186
194
|
}
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
* Returns the percent change between the start and current cursor position relative to the drop zone size
|
218
|
-
*
|
219
|
-
* @returns {number}
|
220
|
-
*/
|
221
|
-
getPercentChange() {
|
222
|
-
const distance = this.getDistance();
|
223
|
-
return (distance / this.startSize) * 100;
|
224
|
-
}
|
195
|
+
}
|
196
|
+
|
197
|
+
/**
|
198
|
+
* Returns the distance between the start and current cursor position
|
199
|
+
* @returns {number}
|
200
|
+
*/
|
201
|
+
getDistance() {
|
202
|
+
return this.isVertical()
|
203
|
+
? this.cursorY - this.startY
|
204
|
+
: this.cursorX - this.startX;
|
205
|
+
}
|
206
|
+
|
207
|
+
/**
|
208
|
+
* Returns the size of the drop zone
|
209
|
+
*/
|
210
|
+
getDropZoneSize() {
|
211
|
+
return this.isVertical()
|
212
|
+
? this.currentDropZone?.offsetHeight
|
213
|
+
: this.currentDropZone?.offsetWidth;
|
214
|
+
}
|
215
|
+
|
216
|
+
/**
|
217
|
+
* Returns the percent change between the start and current cursor position relative to the drop zone size
|
218
|
+
*
|
219
|
+
* @returns {number}
|
220
|
+
*/
|
221
|
+
getPercentChange() {
|
222
|
+
const distance = this.getDistance();
|
223
|
+
return (distance / this.startSize) * 100;
|
224
|
+
}
|
225
225
|
}
|
@@ -17,7 +17,7 @@ export class ListDragAndDrop extends DragAndDrop {
|
|
17
17
|
constructor(options = {}) {
|
18
18
|
super({
|
19
19
|
showPlaceholder: true,
|
20
|
-
...options
|
20
|
+
...options
|
21
21
|
});
|
22
22
|
}
|
23
23
|
|
@@ -88,7 +88,7 @@ export class ListDragAndDrop extends DragAndDrop {
|
|
88
88
|
const prevPosition = this.listPosition;
|
89
89
|
const newPosition = this.getListPositionOfPoint({
|
90
90
|
x: e.clientX,
|
91
|
-
y: e.clientY
|
91
|
+
y: e.clientY
|
92
92
|
});
|
93
93
|
|
94
94
|
// If the cursor position has changed, we should update the rendering and see if our actual list position has
|
@@ -189,12 +189,12 @@ export class ListDragAndDrop extends DragAndDrop {
|
|
189
189
|
if (this.isVertical()) {
|
190
190
|
this.currentDropZone.scrollTo({
|
191
191
|
top: this.currentDropZone.scrollTop + velocity,
|
192
|
-
behavior: "smooth"
|
192
|
+
behavior: "smooth"
|
193
193
|
});
|
194
194
|
} else {
|
195
195
|
this.currentDropZone.scrollTo({
|
196
196
|
left: this.currentDropZone.scrollLeft + velocity,
|
197
|
-
behavior: "smooth"
|
197
|
+
behavior: "smooth"
|
198
198
|
});
|
199
199
|
}
|
200
200
|
}
|