@sfxcode/formkit-primevue 2.9.7 → 2.9.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.
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
<script setup lang='ts'>
|
|
2
2
|
import type { FormKitFrameworkContext } from '@formkit/core'
|
|
3
3
|
import type { AutoCompleteCompleteEvent, AutoCompleteProps } from 'primevue/autocomplete'
|
|
4
|
-
|
|
5
4
|
import type { PropType } from 'vue'
|
|
6
|
-
import { ref } from 'vue'
|
|
5
|
+
import { ref, watch } from 'vue'
|
|
7
6
|
import { useFormKitInput } from '../composables'
|
|
8
7
|
|
|
9
8
|
export interface FormKitPrimeAutoCompleteProps {
|
|
@@ -19,6 +18,7 @@ export interface FormKitPrimeAutoCompleteProps {
|
|
|
19
18
|
minLength?: AutoCompleteProps['minLength']
|
|
20
19
|
placeholder?: AutoCompleteProps['placeholder']
|
|
21
20
|
fluid?: AutoCompleteProps['fluid']
|
|
21
|
+
separators?: string[] | []
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
const props = defineProps({
|
|
@@ -34,6 +34,31 @@ const suggestions = ref(['', {}])
|
|
|
34
34
|
suggestions.value = []
|
|
35
35
|
const loading = ref(false)
|
|
36
36
|
|
|
37
|
+
// Local value for v-model
|
|
38
|
+
const localValue = ref(props.context._value)
|
|
39
|
+
|
|
40
|
+
// Sync localValue with context._value
|
|
41
|
+
watch(
|
|
42
|
+
() => props.context._value,
|
|
43
|
+
(newVal) => {
|
|
44
|
+
localValue.value = newVal
|
|
45
|
+
},
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
// Emit changes from localValue to context
|
|
49
|
+
watch(
|
|
50
|
+
localValue,
|
|
51
|
+
(newVal) => {
|
|
52
|
+
if (newVal !== props.context._value) {
|
|
53
|
+
props.context._value = newVal
|
|
54
|
+
props.context?.node?.input?.(newVal)
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Searches for suggestions based on the input query.
|
|
61
|
+
*/
|
|
37
62
|
async function search(event: AutoCompleteCompleteEvent) {
|
|
38
63
|
if (props.context?.options && props.context?.optionLabel) {
|
|
39
64
|
suggestions.value = props.context.options.filter((option) => {
|
|
@@ -54,13 +79,55 @@ async function search(event: AutoCompleteCompleteEvent) {
|
|
|
54
79
|
}
|
|
55
80
|
}
|
|
56
81
|
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Handles paste event to transform a string separated by any of the provided separators into multiple items.
|
|
85
|
+
*/
|
|
86
|
+
function handlePaste(event: ClipboardEvent) {
|
|
87
|
+
if (!props.context?.multiple)
|
|
88
|
+
return
|
|
89
|
+
const clipboardData = event.clipboardData
|
|
90
|
+
if (!clipboardData)
|
|
91
|
+
return
|
|
92
|
+
const pastedText = clipboardData.getData('text')
|
|
93
|
+
const separators = Array.isArray(props.context?.separators) && props.context.separators.length > 0
|
|
94
|
+
? props.context.separators
|
|
95
|
+
: [',']
|
|
96
|
+
const regex = new RegExp(`[${separators.map(s => s.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&')).join('')}]`)
|
|
97
|
+
// If separators are provided, split the pasted text by them
|
|
98
|
+
if (pastedText && regex.test(pastedText)) {
|
|
99
|
+
event.preventDefault()
|
|
100
|
+
const items = pastedText
|
|
101
|
+
.split(regex)
|
|
102
|
+
.map(item => item.trim())
|
|
103
|
+
.filter(item => item.length > 0)
|
|
104
|
+
// Use a local ref, never mutate context._value directly
|
|
105
|
+
if (Array.isArray(localValue.value)) {
|
|
106
|
+
localValue.value = [...localValue.value, ...items]
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
localValue.value = items
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
// If no separators, just set the value directly
|
|
113
|
+
else if (pastedText) {
|
|
114
|
+
event.preventDefault()
|
|
115
|
+
// If no separators, just set the value directly
|
|
116
|
+
if (Array.isArray(localValue.value)) {
|
|
117
|
+
localValue.value = [...localValue.value, pastedText.trim()]
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
localValue.value = [pastedText.trim()]
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
57
124
|
</script>
|
|
58
125
|
|
|
59
126
|
<template>
|
|
60
127
|
<div class="p-formkit">
|
|
61
128
|
<AutoComplete
|
|
62
129
|
:id="context.id"
|
|
63
|
-
v-model="
|
|
130
|
+
v-model="localValue"
|
|
64
131
|
v-bind="context?.attrs"
|
|
65
132
|
:disabled="!!context?.disabled"
|
|
66
133
|
:class="context?.attrs?.class"
|
|
@@ -85,6 +152,7 @@ async function search(event: AutoCompleteCompleteEvent) {
|
|
|
85
152
|
@complete="search"
|
|
86
153
|
@change="handleInput"
|
|
87
154
|
@blur="handleBlur"
|
|
155
|
+
@paste="handlePaste"
|
|
88
156
|
>
|
|
89
157
|
<template v-for="slotName in validSlotNames" :key="slotName" #[slotName]="slotProps">
|
|
90
158
|
<component :is="context?.slots[slotName]" v-bind="{ ...context, ...slotProps }" />
|
|
@@ -21,8 +21,11 @@ function useFormKitRepeater() {
|
|
|
21
21
|
}
|
|
22
22
|
function addListGroupFunctions(data, addNodeDefaultObject = {}) {
|
|
23
23
|
const swapElements = (array, index1, index2) => {
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
const newArray = [...array];
|
|
25
|
+
const temp = newArray[index1];
|
|
26
|
+
newArray[index1] = newArray[index2];
|
|
27
|
+
newArray[index2] = temp;
|
|
28
|
+
return newArray;
|
|
26
29
|
};
|
|
27
30
|
data.addNode = parentNode => () => {
|
|
28
31
|
const newArray = [...parentNode.value, addNodeDefaultObject];
|
|
@@ -8,8 +8,11 @@ export function useFormKitRepeater() {
|
|
|
8
8
|
}
|
|
9
9
|
function addListGroupFunctions(data, addNodeDefaultObject = {}) {
|
|
10
10
|
const swapElements = (array, index1, index2) => {
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
const newArray = [...array];
|
|
12
|
+
const temp = newArray[index1];
|
|
13
|
+
newArray[index1] = newArray[index2];
|
|
14
|
+
newArray[index2] = temp;
|
|
15
|
+
return newArray;
|
|
13
16
|
};
|
|
14
17
|
data.addNode = (parentNode) => () => {
|
|
15
18
|
const newArray = [...parentNode.value, addNodeDefaultObject];
|
|
@@ -30,7 +30,7 @@ var _PrimeToggleSwitch = _interopRequireDefault(require("../components/PrimeTogg
|
|
|
30
30
|
var _PrimeTreeSelect = _interopRequireDefault(require("../components/PrimeTreeSelect.vue"));
|
|
31
31
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
32
32
|
const primeAutoCompleteDefinition = exports.primeAutoCompleteDefinition = (0, _vue.createInput)(_PrimeAutoComplete.default, {
|
|
33
|
-
props: ["pt", "ptOptions", "unstyled", "Select", "multiple", "typeahead", "optionLabel", "options", "size", "minLength", "placeholder", "fluid"]
|
|
33
|
+
props: ["pt", "ptOptions", "unstyled", "Select", "multiple", "typeahead", "optionLabel", "options", "size", "minLength", "placeholder", "fluid", "separators"]
|
|
34
34
|
});
|
|
35
35
|
const primeInputTextDefinition = exports.primeInputTextDefinition = (0, _vue.createInput)(_PrimeInputText.default, {
|
|
36
36
|
props: ["pt", "ptOptions", "unstyled", "placeholder", "iconPrefix", "iconSuffix", "size", "inputType"]
|
|
@@ -23,7 +23,7 @@ import PrimeToggleButton from "../components/PrimeToggleButton.vue";
|
|
|
23
23
|
import PrimeToggleSwitch from "../components/PrimeToggleSwitch.vue";
|
|
24
24
|
import PrimeTreeSelect from "../components/PrimeTreeSelect.vue";
|
|
25
25
|
export const primeAutoCompleteDefinition = createInput(PrimeAutoComplete, {
|
|
26
|
-
props: ["pt", "ptOptions", "unstyled", "Select", "multiple", "typeahead", "optionLabel", "options", "size", "minLength", "placeholder", "fluid"]
|
|
26
|
+
props: ["pt", "ptOptions", "unstyled", "Select", "multiple", "typeahead", "optionLabel", "options", "size", "minLength", "placeholder", "fluid", "separators"]
|
|
27
27
|
});
|
|
28
28
|
export const primeInputTextDefinition = createInput(PrimeInputText, {
|
|
29
29
|
props: ["pt", "ptOptions", "unstyled", "placeholder", "iconPrefix", "iconSuffix", "size", "inputType"]
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sfxcode/formkit-primevue",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.9.
|
|
5
|
-
"packageManager": "pnpm@10.
|
|
4
|
+
"version": "2.9.9",
|
|
5
|
+
"packageManager": "pnpm@10.13.1+sha512.37ebf1a5c7a30d5fabe0c5df44ee8da4c965ca0c5af3dbab28c3a1681b70a256218d05c81c9c0dcf767ef6b8551eb5b960042b9ed4300c59242336377e01cfad",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Tom",
|
|
8
8
|
"email": "tom@sfxcode.com"
|
|
@@ -91,56 +91,56 @@
|
|
|
91
91
|
"@formkit/i18n": "^1.6.9",
|
|
92
92
|
"@formkit/inputs": "^1.6.9",
|
|
93
93
|
"@formkit/vue": "^1.6.9",
|
|
94
|
-
"@intlify/core": "^11.1.
|
|
94
|
+
"@intlify/core": "^11.1.9",
|
|
95
95
|
"primeicons": "^7.0.0",
|
|
96
|
-
"primevue": "^4.3.
|
|
97
|
-
"vue-i18n": "^11.1.
|
|
96
|
+
"primevue": "^4.3.6",
|
|
97
|
+
"vue-i18n": "^11.1.9"
|
|
98
98
|
},
|
|
99
99
|
"devDependencies": {
|
|
100
|
-
"@antfu/eslint-config": "^4.
|
|
100
|
+
"@antfu/eslint-config": "^4.16.2",
|
|
101
101
|
"@formkit/core": "^1.6.9",
|
|
102
102
|
"@formkit/drag-and-drop": "^0.5.3",
|
|
103
|
-
"@primeuix/themes": "^1.1
|
|
104
|
-
"@types/node": "^24.0.
|
|
103
|
+
"@primeuix/themes": "^1.2.1",
|
|
104
|
+
"@types/node": "^24.0.13",
|
|
105
105
|
"@types/uuid": "^10.0.0",
|
|
106
|
-
"@unocss/preset-icons": "66.
|
|
107
|
-
"@unocss/preset-uno": "66.
|
|
108
|
-
"@vitejs/plugin-vue": "^
|
|
106
|
+
"@unocss/preset-icons": "66.3.3",
|
|
107
|
+
"@unocss/preset-uno": "66.3.3",
|
|
108
|
+
"@vitejs/plugin-vue": "^6.0.0",
|
|
109
109
|
"@vitest/coverage-v8": "^3.2.4",
|
|
110
110
|
"@vitest/ui": "^3.2.4",
|
|
111
111
|
"@vue/compiler-sfc": "^3.5.17",
|
|
112
112
|
"@vue/server-renderer": "^3.5.17",
|
|
113
113
|
"@vue/test-utils": "^2.4.6",
|
|
114
114
|
"@vue/tsconfig": "^0.7.0",
|
|
115
|
-
"@vueuse/core": "^13.
|
|
115
|
+
"@vueuse/core": "^13.5.0",
|
|
116
116
|
"@vueuse/head": "^2.0.0",
|
|
117
|
-
"changelogen": "^0.6.
|
|
117
|
+
"changelogen": "^0.6.2",
|
|
118
118
|
"chart.js": "^4.5.0",
|
|
119
119
|
"consola": "^3.4.2",
|
|
120
120
|
"cookie": "^1.0.2",
|
|
121
|
-
"esbuild": "^0.25.
|
|
122
|
-
"eslint": "^9.
|
|
121
|
+
"esbuild": "^0.25.6",
|
|
122
|
+
"eslint": "^9.31.0",
|
|
123
123
|
"happy-dom": "^18.0.1",
|
|
124
124
|
"json-editor-vue": "^0.18.1",
|
|
125
125
|
"mkdist": "^2.3.0",
|
|
126
|
-
"quill": "
|
|
126
|
+
"quill": "1.3.7",
|
|
127
127
|
"sass": "^1.89.2",
|
|
128
128
|
"tslib": "^2.8.1",
|
|
129
129
|
"typescript": "^5.8.3",
|
|
130
130
|
"unbuild": "^3.5.0",
|
|
131
|
-
"unocss": "66.
|
|
131
|
+
"unocss": "66.3.3",
|
|
132
132
|
"unplugin-auto-import": "^19.3.0",
|
|
133
|
-
"unplugin-vue-components": "^28.
|
|
134
|
-
"vite": "^
|
|
133
|
+
"unplugin-vue-components": "^28.8.0",
|
|
134
|
+
"vite": "^7.0.4",
|
|
135
135
|
"vite-plugin-dts": "^4.5.4",
|
|
136
136
|
"vite-plugin-eslint": "^1.8.1",
|
|
137
|
-
"vite-plugin-pages": "^0.33.
|
|
138
|
-
"vite-ssg": "^
|
|
137
|
+
"vite-plugin-pages": "^0.33.1",
|
|
138
|
+
"vite-ssg": "^28.0.0",
|
|
139
139
|
"vitepress": "^1.6.3",
|
|
140
140
|
"vitest": "^3.2.4",
|
|
141
141
|
"vue": "^3.5.17",
|
|
142
142
|
"vue-demi": "^0.14.10",
|
|
143
143
|
"vue-router": "^4.5.1",
|
|
144
|
-
"vue-tsc": "^
|
|
144
|
+
"vue-tsc": "^3.0.1"
|
|
145
145
|
}
|
|
146
146
|
}
|