@sfxcode/formkit-primevue 4.2.3 → 4.3.0
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.
|
@@ -123,6 +123,7 @@ type TransferList = 'source' | 'target'
|
|
|
123
123
|
const dragSource = ref<TransferList | null>(null)
|
|
124
124
|
const draggedItems = ref<any[]>([])
|
|
125
125
|
const activeDropzone = ref<TransferList | null>(null)
|
|
126
|
+
const dragOverIndex = ref<number | null>(null)
|
|
126
127
|
|
|
127
128
|
function getComparableValue(item: any): any {
|
|
128
129
|
const valueKey = optionValueKey.value
|
|
@@ -154,14 +155,17 @@ function clearDragState() {
|
|
|
154
155
|
dragSource.value = null
|
|
155
156
|
draggedItems.value = []
|
|
156
157
|
activeDropzone.value = null
|
|
158
|
+
dragOverIndex.value = null
|
|
157
159
|
}
|
|
158
160
|
|
|
159
161
|
function canDropInto(target: TransferList): boolean {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
162
|
+
if (!transferDragDrop.value || props.context.disabled || !dragSource.value || draggedItems.value.length === 0)
|
|
163
|
+
return false
|
|
164
|
+
// The target list accepts cross-list moves as well as same-list reordering.
|
|
165
|
+
if (target === 'target')
|
|
166
|
+
return true
|
|
167
|
+
// The source list only accepts items coming from the target (i.e. removal).
|
|
168
|
+
return dragSource.value !== target
|
|
165
169
|
}
|
|
166
170
|
|
|
167
171
|
function handleOptionDragStart(origin: TransferList, option: any, event: DragEvent) {
|
|
@@ -186,6 +190,8 @@ function handleDropzoneDragOver(target: TransferList, event: DragEvent) {
|
|
|
186
190
|
|
|
187
191
|
event.preventDefault()
|
|
188
192
|
activeDropzone.value = target
|
|
193
|
+
// Hovering empty space (not over a specific item) clears the per-item highlight.
|
|
194
|
+
dragOverIndex.value = null
|
|
189
195
|
if (event.dataTransfer)
|
|
190
196
|
event.dataTransfer.dropEffect = 'move'
|
|
191
197
|
}
|
|
@@ -214,6 +220,57 @@ function handleDropzoneDrop(target: TransferList, event: DragEvent) {
|
|
|
214
220
|
clearDragState()
|
|
215
221
|
}
|
|
216
222
|
|
|
223
|
+
function handleTargetItemDragOver(index: number, event: DragEvent) {
|
|
224
|
+
if (!canDropInto('target'))
|
|
225
|
+
return
|
|
226
|
+
|
|
227
|
+
// Handle the drop at the item level so it lands at a precise position.
|
|
228
|
+
event.preventDefault()
|
|
229
|
+
event.stopPropagation()
|
|
230
|
+
activeDropzone.value = 'target'
|
|
231
|
+
dragOverIndex.value = index
|
|
232
|
+
if (event.dataTransfer)
|
|
233
|
+
event.dataTransfer.dropEffect = 'move'
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
function handleTargetItemDrop(index: number, event: DragEvent) {
|
|
237
|
+
if (!canDropInto('target')) {
|
|
238
|
+
clearDragState()
|
|
239
|
+
return
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
event.preventDefault()
|
|
243
|
+
event.stopPropagation()
|
|
244
|
+
|
|
245
|
+
const referenceItem = targetItems.value[index]
|
|
246
|
+
const itemsToInsert = getUniqueItems(draggedItems.value)
|
|
247
|
+
|
|
248
|
+
if (dragSource.value === 'target') {
|
|
249
|
+
// Reorder within the target list: move the dragged items to the drop position.
|
|
250
|
+
if (itemsToInsert.some(dragged => isSameOption(dragged, referenceItem))) {
|
|
251
|
+
clearDragState()
|
|
252
|
+
return
|
|
253
|
+
}
|
|
254
|
+
const remaining = targetItems.value.filter(item => !itemsToInsert.some(dragged => isSameOption(dragged, item)))
|
|
255
|
+
let insertAt = remaining.findIndex(item => isSameOption(item, referenceItem))
|
|
256
|
+
if (insertAt === -1)
|
|
257
|
+
insertAt = remaining.length
|
|
258
|
+
remaining.splice(insertAt, 0, ...itemsToInsert)
|
|
259
|
+
targetItems.value = remaining
|
|
260
|
+
targetSelection.value = []
|
|
261
|
+
}
|
|
262
|
+
else {
|
|
263
|
+
// Cross-list move: insert the dragged source items at the drop position.
|
|
264
|
+
const additions = itemsToInsert.filter(item => !targetItems.value.some(candidate => isSameOption(candidate, item)))
|
|
265
|
+
const updated = [...targetItems.value]
|
|
266
|
+
updated.splice(index, 0, ...additions)
|
|
267
|
+
targetItems.value = updated
|
|
268
|
+
sourceSelection.value = []
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
clearDragState()
|
|
272
|
+
}
|
|
273
|
+
|
|
217
274
|
function resolveOptionDisabled(option: any): boolean {
|
|
218
275
|
const optionDisabled = props.context.optionDisabled
|
|
219
276
|
if (!optionDisabled)
|
|
@@ -495,9 +552,14 @@ watch(() => modelValue.value, (newVal) => {
|
|
|
495
552
|
<div
|
|
496
553
|
:draggable="transferDragDrop && !context.disabled && !resolveOptionDisabled(slotProps.option)"
|
|
497
554
|
class="p-formkit-transfer-option"
|
|
498
|
-
:class="{
|
|
555
|
+
:class="{
|
|
556
|
+
'p-formkit-transfer-option-draggable': transferDragDrop && !context.disabled && !resolveOptionDisabled(slotProps.option),
|
|
557
|
+
'p-formkit-transfer-option-dragover': dragOverIndex === slotProps.index,
|
|
558
|
+
}"
|
|
499
559
|
@dragstart="handleOptionDragStart('target', slotProps.option, $event)"
|
|
500
560
|
@dragend="handleOptionDragEnd"
|
|
561
|
+
@dragover="handleTargetItemDragOver(slotProps.index, $event)"
|
|
562
|
+
@drop="handleTargetItemDrop(slotProps.index, $event)"
|
|
501
563
|
>
|
|
502
564
|
<component
|
|
503
565
|
:is="context?.slots.option"
|
|
@@ -529,4 +591,8 @@ watch(() => modelValue.value, (newVal) => {
|
|
|
529
591
|
outline: 2px dashed var(--p-primary-color);
|
|
530
592
|
outline-offset: 2px;
|
|
531
593
|
}
|
|
594
|
+
|
|
595
|
+
.p-formkit-transfer-option-dragover {
|
|
596
|
+
box-shadow: inset 0 2px 0 0 var(--p-primary-color);
|
|
597
|
+
}
|
|
532
598
|
</style>
|
|
@@ -23,9 +23,10 @@ const props = defineProps({
|
|
|
23
23
|
},
|
|
24
24
|
})
|
|
25
25
|
|
|
26
|
+
const { t } = useI18n()
|
|
27
|
+
|
|
26
28
|
const textValue = computed(() => {
|
|
27
29
|
const value = props.context?._value
|
|
28
|
-
const { t } = useI18n()
|
|
29
30
|
let result = ''
|
|
30
31
|
if (value) {
|
|
31
32
|
if (props.context?.isTranslationKey) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sfxcode/formkit-primevue",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.3.0",
|
|
5
5
|
"packageManager": "pnpm@11.0.9+sha512.34ce82e6780233cf9cad8685029a8f81d2e06196c5a9bad98879f7424940c6817c4e4524fb7d38b8553ceed48b9758b8ebaf1abd3600c232c4c8cf7366086f38",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Tom",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"dev": "vite serve dev",
|
|
80
80
|
"dev:build": "vite build dev",
|
|
81
81
|
"dev:preview": "vite preview dev",
|
|
82
|
-
"release": "npm run lint && npm run build && changelogen --
|
|
82
|
+
"release": "npm run lint && npm run build && changelogen --minor --release && npm publish --access public && git push --follow-tags",
|
|
83
83
|
"lint": "eslint .",
|
|
84
84
|
"lint:fix": "eslint . --fix",
|
|
85
85
|
"prepublishOnly": "pnpm build",
|
|
@@ -94,28 +94,28 @@
|
|
|
94
94
|
"vue": "^3.4.0"
|
|
95
95
|
},
|
|
96
96
|
"dependencies": {
|
|
97
|
-
"@formkit/addons": "^2.
|
|
97
|
+
"@formkit/addons": "^2.1.0",
|
|
98
98
|
"@formkit/auto-animate": "^0.9.0",
|
|
99
|
-
"@formkit/core": "^2.
|
|
100
|
-
"@formkit/i18n": "^2.
|
|
101
|
-
"@formkit/inputs": "^2.
|
|
102
|
-
"@formkit/vue": "^2.
|
|
103
|
-
"@intlify/core": "^11.4.
|
|
99
|
+
"@formkit/core": "^2.1.0",
|
|
100
|
+
"@formkit/i18n": "^2.1.0",
|
|
101
|
+
"@formkit/inputs": "^2.1.0",
|
|
102
|
+
"@formkit/vue": "^2.1.0",
|
|
103
|
+
"@intlify/core": "^11.4.5",
|
|
104
104
|
"primeicons": "^7.0.0",
|
|
105
105
|
"primevue": "^4.5.5",
|
|
106
|
-
"vue-i18n": "^11.4.
|
|
106
|
+
"vue-i18n": "^11.4.5"
|
|
107
107
|
},
|
|
108
108
|
"devDependencies": {
|
|
109
109
|
"@antfu/eslint-config": "^9.0.0",
|
|
110
110
|
"@primeuix/themes": "^2.0.3",
|
|
111
|
-
"@types/node": "^25.9.
|
|
111
|
+
"@types/node": "^25.9.3",
|
|
112
112
|
"@unocss/preset-icons": "66.7.0",
|
|
113
113
|
"@unocss/preset-uno": "66.7.0",
|
|
114
114
|
"@vitejs/plugin-vue": "^6.0.7",
|
|
115
|
-
"@vitest/coverage-v8": "^4.1.
|
|
116
|
-
"@vitest/ui": "^4.1.
|
|
117
|
-
"@vue/compiler-sfc": "^3.5.
|
|
118
|
-
"@vue/server-renderer": "^3.5.
|
|
115
|
+
"@vitest/coverage-v8": "^4.1.9",
|
|
116
|
+
"@vitest/ui": "^4.1.9",
|
|
117
|
+
"@vue/compiler-sfc": "^3.5.38",
|
|
118
|
+
"@vue/server-renderer": "^3.5.38",
|
|
119
119
|
"@vue/test-utils": "^2.4.11",
|
|
120
120
|
"@vue/tsconfig": "^0.9.1",
|
|
121
121
|
"@vueuse/core": "^14.3.0",
|
|
@@ -124,12 +124,12 @@
|
|
|
124
124
|
"chart.js": "^4.5.1",
|
|
125
125
|
"consola": "^3.4.2",
|
|
126
126
|
"cookie": "^1.1.1",
|
|
127
|
-
"esbuild": "^0.28.
|
|
128
|
-
"eslint": "^10.
|
|
129
|
-
"happy-dom": "^20.10.
|
|
127
|
+
"esbuild": "^0.28.1",
|
|
128
|
+
"eslint": "^10.5.0",
|
|
129
|
+
"happy-dom": "^20.10.5",
|
|
130
130
|
"json-editor-vue": "^0.18.1",
|
|
131
131
|
"mkdist": "^2.4.1",
|
|
132
|
-
"sass": "^1.
|
|
132
|
+
"sass": "^1.101.0",
|
|
133
133
|
"tslib": "^2.8.1",
|
|
134
134
|
"typescript": "^6.0.3",
|
|
135
135
|
"unbuild": "^3.6.1",
|
|
@@ -141,10 +141,10 @@
|
|
|
141
141
|
"vite-plugin-pages": "^0.33.3",
|
|
142
142
|
"vite-ssg": "^28.3.0",
|
|
143
143
|
"vitepress": "2.0.0-alpha.16",
|
|
144
|
-
"vitest": "^4.1.
|
|
145
|
-
"vue": "^3.5.
|
|
144
|
+
"vitest": "^4.1.9",
|
|
145
|
+
"vue": "^3.5.38",
|
|
146
146
|
"vue-demi": "^0.14.10",
|
|
147
147
|
"vue-router": "^5.1.0",
|
|
148
|
-
"vue-tsc": "^3.3.
|
|
148
|
+
"vue-tsc": "^3.3.5"
|
|
149
149
|
}
|
|
150
150
|
}
|