@adminforth/text-complete 1.4.4 → 1.6.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.
package/build.log CHANGED
@@ -9,5 +9,5 @@ custom/package-lock.json
9
9
  custom/package.json
10
10
  custom/tsconfig.json
11
11
 
12
- sent 19,663 bytes received 96 bytes 39,518.00 bytes/sec
13
- total size is 19,305 speedup is 0.98
12
+ sent 22,089 bytes received 96 bytes 44,370.00 bytes/sec
13
+ total size is 21,731 speedup is 0.98
@@ -4,11 +4,12 @@
4
4
  dark:focus:ring-blue-500 dark:focus:border-blue-500 relative max-w-full">
5
5
  <SuggestionInput
6
6
  ref="suggestionInputRef"
7
- class="w-full !border-none text-gray-900 text-sm dark:placeholder-gray-400 dark:text-white whitespace-normal mr-14"
7
+ class="w-full !border-none text-gray-900 text-sm dark:placeholder-gray-400 dark:text-white whitespace-normal mr-28"
8
8
  v-model="currentValue"
9
9
  :type="column.type"
10
10
  :completionRequest="complete"
11
11
  :debounceTime="meta.debounceTime"
12
+ @completion-approved="handleCompletionApproved"
12
13
  />
13
14
  <div class="absolute right-2 bottom-1">
14
15
  <Tooltip v-if="isUntouched || (!currentValue.trim() && !isFocused)">
@@ -29,13 +30,36 @@
29
30
  <button
30
31
  @click.stop="approveCompletion"
31
32
  @mousedown.prevent
32
- class="text-white bg-gradient-to-r from-purple-500 via-purple-600 to-purple-700 hover:bg-gradient-to-br focus:ring-4 focus:outline-none focus:ring-purple-300 dark:focus:ring-purple-800
33
- font-medium rounded-lg text-xs w-14 h-6 flex items-center justify-center">
34
- <IconArrowRightThin class="w-5 h-5"/>
35
- <span class="scale-75 border border-white rounded-sm px-0.5 bg-white/25">TAB</span>
33
+ :class="[
34
+ 'text-white bg-gradient-to-r from-purple-500 via-purple-600 to-purple-700 hover:bg-gradient-to-br focus:ring-4 focus:outline-none focus:ring-purple-300 dark:focus:ring-purple-800',
35
+ 'font-medium rounded-lg text-xs flex items-center justify-center py-1 px-1 ',
36
+ buttonText === approveCompletionValue ? 'w-16' : 'w-18'
37
+ ]">
38
+ <div
39
+ class="flex items-center justify-center"
40
+ v-if="buttonText === approveCompletionValue"
41
+ >
42
+ <IconArrowRightThin class="mt-0.5 w-5 h-5 text-white"/>
43
+ <span class="ml-1 px-1 h-4 flex items-center justify-center rounded border bg-white text-black text-[10px] font-mono shadow-inner shadow-sm border-gray-300 dark:bg-gray-700 dark:text-white dark:border-gray-500">
44
+ <p class="mt-0.5">Tab</p>
45
+ </span>
46
+ </div>
47
+ <div
48
+ class="flex items-center justify-center"
49
+ v-else-if="buttonText === approveNextWordValue"
50
+ >
51
+ <IconArrowRightThin class="mt-0.5 w-5 h-5 text-white" />
52
+ <span class="ml-1 px-1 h-4 flex items-center justify-center rounded border bg-white text-black text-[10px] font-mono shadow-inner shadow-sm border-gray-300 dark:bg-gray-700 dark:text-white dark:border-gray-500">
53
+ <p class="mt-0.5">Ctrl</p>
54
+ </span>
55
+ <span class="ml-1 text-white">+</span>
56
+ <span class="ml-1 px-1 h-4 flex items-center justify-center rounded border bg-white text-black text-[10px] font-mono shadow-inner shadow-sm border-gray-300 dark:bg-gray-700 dark:text-white dark:border-gray-500">
57
+ <IconArrowRightThin class="w-3.5 h-3.5" />
58
+ </span>
59
+ </div>
36
60
  </button>
37
61
  <template #tooltip>
38
- {{ $t('Approve completion') }}
62
+ {{ $t(tooltipText) }}
39
63
  </template>
40
64
  </Tooltip>
41
65
 
@@ -44,7 +68,7 @@
44
68
  </template>
45
69
 
46
70
  <script setup lang="ts">
47
- import { ref, onMounted, watch, Ref } from 'vue';
71
+ import { ref, onMounted, watch, Ref, computed } from 'vue';
48
72
  import { callAdminForthApi } from '@/utils';
49
73
  import { AdminForthColumnCommon } from '@/types/Common';
50
74
  import { Spinner, Tooltip } from '@/afcl';
@@ -61,15 +85,33 @@ const props = defineProps<{
61
85
  const emit = defineEmits([
62
86
  'update:value',
63
87
  ]);
64
-
88
+ const approveCompletionValue:string='TAB';
89
+ const approveNextWordValue:string='CTRL + ->'
65
90
  const isLoading = ref<boolean>(false);
66
91
  const isUntouched = ref<boolean>(true);
67
92
  const isFocused = ref<boolean>(false);
68
93
  const currentValue: Ref<string> = ref('');
69
94
  const suggestionInputRef = ref<InstanceType<typeof SuggestionInput> | null>(null);
95
+ const buttonText = ref<string>(approveCompletionValue);
96
+
97
+ const tooltipText = computed(() =>
98
+ buttonText.value === approveCompletionValue ? 'Approve completion' : 'Approve next word'
99
+ );
100
+
101
+ function handleCompletionApproved(type: 'all' | 'word') {
102
+ if(buttonText.value === approveCompletionValue && type === 'all') {
103
+ buttonText.value = approveNextWordValue;
104
+ } else if (buttonText.value === approveNextWordValue && type === 'word') {
105
+ buttonText.value = approveCompletionValue;
106
+ }
107
+ }
70
108
 
71
109
  onMounted(() => {
72
- currentValue.value = props.record[props.column.name] || '';
110
+ const value = props.record[props.column.name] || '';
111
+ currentValue.value = value;
112
+ if (value.trim()) {
113
+ isUntouched.value = false;
114
+ }
73
115
  if (suggestionInputRef.value) {
74
116
  const editor = suggestionInputRef.value.$el.querySelector('.ql-editor');
75
117
  if (editor) {
@@ -84,7 +126,11 @@ watch(() => currentValue.value, (value) => {
84
126
  });
85
127
 
86
128
  watch(() => props.record, (value) => {
87
- currentValue.value = value[props.column.name] || '';
129
+ const val = value[props.column.name] || '';
130
+ currentValue.value = val;
131
+ if (val.trim()) {
132
+ isUntouched.value = false;
133
+ }
88
134
  });
89
135
 
90
136
  async function complete(textBeforeCursor: string) {
@@ -105,8 +151,13 @@ async function complete(textBeforeCursor: string) {
105
151
 
106
152
  const approveCompletion = async () => {
107
153
  if (suggestionInputRef.value) {
108
- await suggestionInputRef.value.approveCompletion('all');
154
+ if( buttonText.value === approveCompletionValue) {
155
+ await suggestionInputRef.value.approveCompletion('all');
156
+ } else {
157
+ await suggestionInputRef.value.approveCompletion('word');
158
+ }
109
159
  }
160
+ buttonText.value === approveCompletionValue ? buttonText.value = approveNextWordValue : buttonText.value = approveCompletionValue;
110
161
  }
111
162
 
112
163
  function handleFocus() {
@@ -10,34 +10,34 @@
10
10
  "license": "ISC",
11
11
  "dependencies": {
12
12
  "@iconify-prerendered/vue-mdi": "^0.28.1737398331",
13
- "vue-suggestion-input": "^1.0.11"
13
+ "vue-suggestion-input": "^1.0.12"
14
14
  }
15
15
  },
16
16
  "node_modules/@babel/helper-string-parser": {
17
- "version": "7.25.9",
18
- "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.25.9.tgz",
19
- "integrity": "sha512-4A/SCr/2KLd5jrtOMFzaKjVtAei3+2r/NChoBNoZ3EyP/+GlhoaEGoWOZUmFmoITP7zOJyHIMm+DYRd8o3PvHA==",
17
+ "version": "7.27.1",
18
+ "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.27.1.tgz",
19
+ "integrity": "sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA==",
20
20
  "license": "MIT",
21
21
  "engines": {
22
22
  "node": ">=6.9.0"
23
23
  }
24
24
  },
25
25
  "node_modules/@babel/helper-validator-identifier": {
26
- "version": "7.25.9",
27
- "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.25.9.tgz",
28
- "integrity": "sha512-Ed61U6XJc3CVRfkERJWDz4dJwKe7iLmmJsbOGu9wSloNSFttHV0I8g6UAgb7qnK5ly5bGLPd4oXZlxCdANBOWQ==",
26
+ "version": "7.27.1",
27
+ "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.27.1.tgz",
28
+ "integrity": "sha512-D2hP9eA+Sqx1kBZgzxZh0y1trbuU+JoDkiEwqhQ36nodYqJwyEIhPSdMNd7lOm/4io72luTPWH20Yda0xOuUow==",
29
29
  "license": "MIT",
30
30
  "engines": {
31
31
  "node": ">=6.9.0"
32
32
  }
33
33
  },
34
34
  "node_modules/@babel/parser": {
35
- "version": "7.27.0",
36
- "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.27.0.tgz",
37
- "integrity": "sha512-iaepho73/2Pz7w2eMS0Q5f83+0RKI7i4xmiYeBmDzfRVbQtTOG7Ts0S4HzJVsTMGI9keU8rNfuZr8DKfSt7Yyg==",
35
+ "version": "7.28.0",
36
+ "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.28.0.tgz",
37
+ "integrity": "sha512-jVZGvOxOuNSsuQuLRTh13nU0AogFlw32w/MT+LV6D3sP5WdbW61E77RnkbaO2dUvmPAYrBDJXGn5gGS6tH4j8g==",
38
38
  "license": "MIT",
39
39
  "dependencies": {
40
- "@babel/types": "^7.27.0"
40
+ "@babel/types": "^7.28.0"
41
41
  },
42
42
  "bin": {
43
43
  "parser": "bin/babel-parser.js"
@@ -47,13 +47,13 @@
47
47
  }
48
48
  },
49
49
  "node_modules/@babel/types": {
50
- "version": "7.27.0",
51
- "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.27.0.tgz",
52
- "integrity": "sha512-H45s8fVLYjbhFH62dIJ3WtmJ6RSPt/3DRO0ZcT2SUiYiQyz3BLVb9ADEnLl91m74aQPS3AzzeajZHYOalWe3bg==",
50
+ "version": "7.28.2",
51
+ "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.28.2.tgz",
52
+ "integrity": "sha512-ruv7Ae4J5dUYULmeXw1gmb7rYRz57OWCPM57pHojnLq/3Z1CK2lNSLTCVjxVk1F/TZHwOZZrOWi0ur95BbLxNQ==",
53
53
  "license": "MIT",
54
54
  "dependencies": {
55
- "@babel/helper-string-parser": "^7.25.9",
56
- "@babel/helper-validator-identifier": "^7.25.9"
55
+ "@babel/helper-string-parser": "^7.27.1",
56
+ "@babel/helper-validator-identifier": "^7.27.1"
57
57
  },
58
58
  "engines": {
59
59
  "node": ">=6.9.0"
@@ -72,109 +72,109 @@
72
72
  }
73
73
  },
74
74
  "node_modules/@jridgewell/sourcemap-codec": {
75
- "version": "1.5.0",
76
- "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz",
77
- "integrity": "sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==",
75
+ "version": "1.5.4",
76
+ "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.4.tgz",
77
+ "integrity": "sha512-VT2+G1VQs/9oz078bLrYbecdZKs912zQlkelYpuf+SXF+QvZDYJlbx/LSx+meSAwdDFnF8FVXW92AVjjkVmgFw==",
78
78
  "license": "MIT"
79
79
  },
80
80
  "node_modules/@vue/compiler-core": {
81
- "version": "3.5.13",
82
- "resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.5.13.tgz",
83
- "integrity": "sha512-oOdAkwqUfW1WqpwSYJce06wvt6HljgY3fGeM9NcVA1HaYOij3mZG9Rkysn0OHuyUAGMbEbARIpsG+LPVlBJ5/Q==",
81
+ "version": "3.5.18",
82
+ "resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.5.18.tgz",
83
+ "integrity": "sha512-3slwjQrrV1TO8MoXgy3aynDQ7lslj5UqDxuHnrzHtpON5CBinhWjJETciPngpin/T3OuW3tXUf86tEurusnztw==",
84
84
  "license": "MIT",
85
85
  "dependencies": {
86
- "@babel/parser": "^7.25.3",
87
- "@vue/shared": "3.5.13",
86
+ "@babel/parser": "^7.28.0",
87
+ "@vue/shared": "3.5.18",
88
88
  "entities": "^4.5.0",
89
89
  "estree-walker": "^2.0.2",
90
- "source-map-js": "^1.2.0"
90
+ "source-map-js": "^1.2.1"
91
91
  }
92
92
  },
93
93
  "node_modules/@vue/compiler-dom": {
94
- "version": "3.5.13",
95
- "resolved": "https://registry.npmjs.org/@vue/compiler-dom/-/compiler-dom-3.5.13.tgz",
96
- "integrity": "sha512-ZOJ46sMOKUjO3e94wPdCzQ6P1Lx/vhp2RSvfaab88Ajexs0AHeV0uasYhi99WPaogmBlRHNRuly8xV75cNTMDA==",
94
+ "version": "3.5.18",
95
+ "resolved": "https://registry.npmjs.org/@vue/compiler-dom/-/compiler-dom-3.5.18.tgz",
96
+ "integrity": "sha512-RMbU6NTU70++B1JyVJbNbeFkK+A+Q7y9XKE2EM4NLGm2WFR8x9MbAtWxPPLdm0wUkuZv9trpwfSlL6tjdIa1+A==",
97
97
  "license": "MIT",
98
98
  "dependencies": {
99
- "@vue/compiler-core": "3.5.13",
100
- "@vue/shared": "3.5.13"
99
+ "@vue/compiler-core": "3.5.18",
100
+ "@vue/shared": "3.5.18"
101
101
  }
102
102
  },
103
103
  "node_modules/@vue/compiler-sfc": {
104
- "version": "3.5.13",
105
- "resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-3.5.13.tgz",
106
- "integrity": "sha512-6VdaljMpD82w6c2749Zhf5T9u5uLBWKnVue6XWxprDobftnletJ8+oel7sexFfM3qIxNmVE7LSFGTpv6obNyaQ==",
104
+ "version": "3.5.18",
105
+ "resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-3.5.18.tgz",
106
+ "integrity": "sha512-5aBjvGqsWs+MoxswZPoTB9nSDb3dhd1x30xrrltKujlCxo48j8HGDNj3QPhF4VIS0VQDUrA1xUfp2hEa+FNyXA==",
107
107
  "license": "MIT",
108
108
  "dependencies": {
109
- "@babel/parser": "^7.25.3",
110
- "@vue/compiler-core": "3.5.13",
111
- "@vue/compiler-dom": "3.5.13",
112
- "@vue/compiler-ssr": "3.5.13",
113
- "@vue/shared": "3.5.13",
109
+ "@babel/parser": "^7.28.0",
110
+ "@vue/compiler-core": "3.5.18",
111
+ "@vue/compiler-dom": "3.5.18",
112
+ "@vue/compiler-ssr": "3.5.18",
113
+ "@vue/shared": "3.5.18",
114
114
  "estree-walker": "^2.0.2",
115
- "magic-string": "^0.30.11",
116
- "postcss": "^8.4.48",
117
- "source-map-js": "^1.2.0"
115
+ "magic-string": "^0.30.17",
116
+ "postcss": "^8.5.6",
117
+ "source-map-js": "^1.2.1"
118
118
  }
119
119
  },
120
120
  "node_modules/@vue/compiler-ssr": {
121
- "version": "3.5.13",
122
- "resolved": "https://registry.npmjs.org/@vue/compiler-ssr/-/compiler-ssr-3.5.13.tgz",
123
- "integrity": "sha512-wMH6vrYHxQl/IybKJagqbquvxpWCuVYpoUJfCqFZwa/JY1GdATAQ+TgVtgrwwMZ0D07QhA99rs/EAAWfvG6KpA==",
121
+ "version": "3.5.18",
122
+ "resolved": "https://registry.npmjs.org/@vue/compiler-ssr/-/compiler-ssr-3.5.18.tgz",
123
+ "integrity": "sha512-xM16Ak7rSWHkM3m22NlmcdIM+K4BMyFARAfV9hYFl+SFuRzrZ3uGMNW05kA5pmeMa0X9X963Kgou7ufdbpOP9g==",
124
124
  "license": "MIT",
125
125
  "dependencies": {
126
- "@vue/compiler-dom": "3.5.13",
127
- "@vue/shared": "3.5.13"
126
+ "@vue/compiler-dom": "3.5.18",
127
+ "@vue/shared": "3.5.18"
128
128
  }
129
129
  },
130
130
  "node_modules/@vue/reactivity": {
131
- "version": "3.5.13",
132
- "resolved": "https://registry.npmjs.org/@vue/reactivity/-/reactivity-3.5.13.tgz",
133
- "integrity": "sha512-NaCwtw8o48B9I6L1zl2p41OHo/2Z4wqYGGIK1Khu5T7yxrn+ATOixn/Udn2m+6kZKB/J7cuT9DbWWhRxqixACg==",
131
+ "version": "3.5.18",
132
+ "resolved": "https://registry.npmjs.org/@vue/reactivity/-/reactivity-3.5.18.tgz",
133
+ "integrity": "sha512-x0vPO5Imw+3sChLM5Y+B6G1zPjwdOri9e8V21NnTnlEvkxatHEH5B5KEAJcjuzQ7BsjGrKtfzuQ5eQwXh8HXBg==",
134
134
  "license": "MIT",
135
135
  "dependencies": {
136
- "@vue/shared": "3.5.13"
136
+ "@vue/shared": "3.5.18"
137
137
  }
138
138
  },
139
139
  "node_modules/@vue/runtime-core": {
140
- "version": "3.5.13",
141
- "resolved": "https://registry.npmjs.org/@vue/runtime-core/-/runtime-core-3.5.13.tgz",
142
- "integrity": "sha512-Fj4YRQ3Az0WTZw1sFe+QDb0aXCerigEpw418pw1HBUKFtnQHWzwojaukAs2X/c9DQz4MQ4bsXTGlcpGxU/RCIw==",
140
+ "version": "3.5.18",
141
+ "resolved": "https://registry.npmjs.org/@vue/runtime-core/-/runtime-core-3.5.18.tgz",
142
+ "integrity": "sha512-DUpHa1HpeOQEt6+3nheUfqVXRog2kivkXHUhoqJiKR33SO4x+a5uNOMkV487WPerQkL0vUuRvq/7JhRgLW3S+w==",
143
143
  "license": "MIT",
144
144
  "dependencies": {
145
- "@vue/reactivity": "3.5.13",
146
- "@vue/shared": "3.5.13"
145
+ "@vue/reactivity": "3.5.18",
146
+ "@vue/shared": "3.5.18"
147
147
  }
148
148
  },
149
149
  "node_modules/@vue/runtime-dom": {
150
- "version": "3.5.13",
151
- "resolved": "https://registry.npmjs.org/@vue/runtime-dom/-/runtime-dom-3.5.13.tgz",
152
- "integrity": "sha512-dLaj94s93NYLqjLiyFzVs9X6dWhTdAlEAciC3Moq7gzAc13VJUdCnjjRurNM6uTLFATRHexHCTu/Xp3eW6yoog==",
150
+ "version": "3.5.18",
151
+ "resolved": "https://registry.npmjs.org/@vue/runtime-dom/-/runtime-dom-3.5.18.tgz",
152
+ "integrity": "sha512-YwDj71iV05j4RnzZnZtGaXwPoUWeRsqinblgVJwR8XTXYZ9D5PbahHQgsbmzUvCWNF6x7siQ89HgnX5eWkr3mw==",
153
153
  "license": "MIT",
154
154
  "dependencies": {
155
- "@vue/reactivity": "3.5.13",
156
- "@vue/runtime-core": "3.5.13",
157
- "@vue/shared": "3.5.13",
155
+ "@vue/reactivity": "3.5.18",
156
+ "@vue/runtime-core": "3.5.18",
157
+ "@vue/shared": "3.5.18",
158
158
  "csstype": "^3.1.3"
159
159
  }
160
160
  },
161
161
  "node_modules/@vue/server-renderer": {
162
- "version": "3.5.13",
163
- "resolved": "https://registry.npmjs.org/@vue/server-renderer/-/server-renderer-3.5.13.tgz",
164
- "integrity": "sha512-wAi4IRJV/2SAW3htkTlB+dHeRmpTiVIK1OGLWV1yeStVSebSQQOwGwIq0D3ZIoBj2C2qpgz5+vX9iEBkTdk5YA==",
162
+ "version": "3.5.18",
163
+ "resolved": "https://registry.npmjs.org/@vue/server-renderer/-/server-renderer-3.5.18.tgz",
164
+ "integrity": "sha512-PvIHLUoWgSbDG7zLHqSqaCoZvHi6NNmfVFOqO+OnwvqMz/tqQr3FuGWS8ufluNddk7ZLBJYMrjcw1c6XzR12mA==",
165
165
  "license": "MIT",
166
166
  "dependencies": {
167
- "@vue/compiler-ssr": "3.5.13",
168
- "@vue/shared": "3.5.13"
167
+ "@vue/compiler-ssr": "3.5.18",
168
+ "@vue/shared": "3.5.18"
169
169
  },
170
170
  "peerDependencies": {
171
- "vue": "3.5.13"
171
+ "vue": "3.5.18"
172
172
  }
173
173
  },
174
174
  "node_modules/@vue/shared": {
175
- "version": "3.5.13",
176
- "resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.5.13.tgz",
177
- "integrity": "sha512-/hnE/qP5ZoGpol0a5mDi45bOd7t3tjYJBjsgCsivow7D48cJeV5l05RD82lPqi7gRiphZM37rnhW1l6ZoCNNnQ==",
175
+ "version": "3.5.18",
176
+ "resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.5.18.tgz",
177
+ "integrity": "sha512-cZy8Dq+uuIXbxCZpuLd2GJdeSO/lIzIspC2WtkqIpje5QyFbvLaI5wZtdUjLHjGZrlVX6GilejatWwVYYRc8tA==",
178
178
  "license": "MIT"
179
179
  },
180
180
  "node_modules/csstype": {
@@ -272,9 +272,9 @@
272
272
  "license": "ISC"
273
273
  },
274
274
  "node_modules/postcss": {
275
- "version": "8.5.3",
276
- "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.3.tgz",
277
- "integrity": "sha512-dle9A3yYxlBSrt8Fu+IpjGT8SY8hN0mlaA6GY8t0P5PjIOZemULz/E2Bnm/2dcUOena75OTNkHI76uZBNUUq3A==",
275
+ "version": "8.5.6",
276
+ "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.6.tgz",
277
+ "integrity": "sha512-3Ybi1tAuwAP9s0r1UQ2J4n5Y0G05bJkpUIO0/bI9MhwmD70S5aTWbXGBwxHrelT+XM1k6dM0pk+SwNkpTRN7Pg==",
278
278
  "funding": [
279
279
  {
280
280
  "type": "opencollective",
@@ -291,7 +291,7 @@
291
291
  ],
292
292
  "license": "MIT",
293
293
  "dependencies": {
294
- "nanoid": "^3.3.8",
294
+ "nanoid": "^3.3.11",
295
295
  "picocolors": "^1.1.1",
296
296
  "source-map-js": "^1.2.1"
297
297
  },
@@ -338,16 +338,16 @@
338
338
  }
339
339
  },
340
340
  "node_modules/vue": {
341
- "version": "3.5.13",
342
- "resolved": "https://registry.npmjs.org/vue/-/vue-3.5.13.tgz",
343
- "integrity": "sha512-wmeiSMxkZCSc+PM2w2VRsOYAZC8GdipNFRTsLSfodVqI9mbejKeXEGr8SckuLnrQPGe3oJN5c3K0vpoU9q/wCQ==",
341
+ "version": "3.5.18",
342
+ "resolved": "https://registry.npmjs.org/vue/-/vue-3.5.18.tgz",
343
+ "integrity": "sha512-7W4Y4ZbMiQ3SEo+m9lnoNpV9xG7QVMLa+/0RFwwiAVkeYoyGXqWE85jabU4pllJNUzqfLShJ5YLptewhCWUgNA==",
344
344
  "license": "MIT",
345
345
  "dependencies": {
346
- "@vue/compiler-dom": "3.5.13",
347
- "@vue/compiler-sfc": "3.5.13",
348
- "@vue/runtime-dom": "3.5.13",
349
- "@vue/server-renderer": "3.5.13",
350
- "@vue/shared": "3.5.13"
346
+ "@vue/compiler-dom": "3.5.18",
347
+ "@vue/compiler-sfc": "3.5.18",
348
+ "@vue/runtime-dom": "3.5.18",
349
+ "@vue/server-renderer": "3.5.18",
350
+ "@vue/shared": "3.5.18"
351
351
  },
352
352
  "peerDependencies": {
353
353
  "typescript": "*"
@@ -359,9 +359,9 @@
359
359
  }
360
360
  },
361
361
  "node_modules/vue-suggestion-input": {
362
- "version": "1.0.11",
363
- "resolved": "https://registry.npmjs.org/vue-suggestion-input/-/vue-suggestion-input-1.0.11.tgz",
364
- "integrity": "sha512-biAo2PD5XTJl7Kp6bf9RFcqdiBcIgl73szfkNdqxVmngV+CltKf0UOLkfNIdijRX8s9JxIkPlpJYmYgYAjiXHw==",
362
+ "version": "1.0.12",
363
+ "resolved": "https://registry.npmjs.org/vue-suggestion-input/-/vue-suggestion-input-1.0.12.tgz",
364
+ "integrity": "sha512-Ik6uuvAonvHmgCRDbnSyqQ/iv91ne2uMv6rVowd8XzIDazzzAvdUQMFjqytl/NbhTAXdXZbKd5WsY/X+PtUvwQ==",
365
365
  "dependencies": {
366
366
  "quill": "^2.0.2",
367
367
  "vue": "^3.4.31"
@@ -11,6 +11,6 @@
11
11
  "license": "ISC",
12
12
  "dependencies": {
13
13
  "@iconify-prerendered/vue-mdi": "^0.28.1737398331",
14
- "vue-suggestion-input": "^1.0.11"
14
+ "vue-suggestion-input": "^1.0.12"
15
15
  }
16
16
  }
@@ -4,11 +4,12 @@
4
4
  dark:focus:ring-blue-500 dark:focus:border-blue-500 relative max-w-full">
5
5
  <SuggestionInput
6
6
  ref="suggestionInputRef"
7
- class="w-full !border-none text-gray-900 text-sm dark:placeholder-gray-400 dark:text-white whitespace-normal mr-14"
7
+ class="w-full !border-none text-gray-900 text-sm dark:placeholder-gray-400 dark:text-white whitespace-normal mr-28"
8
8
  v-model="currentValue"
9
9
  :type="column.type"
10
10
  :completionRequest="complete"
11
11
  :debounceTime="meta.debounceTime"
12
+ @completion-approved="handleCompletionApproved"
12
13
  />
13
14
  <div class="absolute right-2 bottom-1">
14
15
  <Tooltip v-if="isUntouched || (!currentValue.trim() && !isFocused)">
@@ -29,13 +30,36 @@
29
30
  <button
30
31
  @click.stop="approveCompletion"
31
32
  @mousedown.prevent
32
- class="text-white bg-gradient-to-r from-purple-500 via-purple-600 to-purple-700 hover:bg-gradient-to-br focus:ring-4 focus:outline-none focus:ring-purple-300 dark:focus:ring-purple-800
33
- font-medium rounded-lg text-xs w-14 h-6 flex items-center justify-center">
34
- <IconArrowRightThin class="w-5 h-5"/>
35
- <span class="scale-75 border border-white rounded-sm px-0.5 bg-white/25">TAB</span>
33
+ :class="[
34
+ 'text-white bg-gradient-to-r from-purple-500 via-purple-600 to-purple-700 hover:bg-gradient-to-br focus:ring-4 focus:outline-none focus:ring-purple-300 dark:focus:ring-purple-800',
35
+ 'font-medium rounded-lg text-xs flex items-center justify-center py-1 px-1 ',
36
+ buttonText === approveCompletionValue ? 'w-16' : 'w-18'
37
+ ]">
38
+ <div
39
+ class="flex items-center justify-center"
40
+ v-if="buttonText === approveCompletionValue"
41
+ >
42
+ <IconArrowRightThin class="mt-0.5 w-5 h-5 text-white"/>
43
+ <span class="ml-1 px-1 h-4 flex items-center justify-center rounded border bg-white text-black text-[10px] font-mono shadow-inner shadow-sm border-gray-300 dark:bg-gray-700 dark:text-white dark:border-gray-500">
44
+ <p class="mt-0.5">Tab</p>
45
+ </span>
46
+ </div>
47
+ <div
48
+ class="flex items-center justify-center"
49
+ v-else-if="buttonText === approveNextWordValue"
50
+ >
51
+ <IconArrowRightThin class="mt-0.5 w-5 h-5 text-white" />
52
+ <span class="ml-1 px-1 h-4 flex items-center justify-center rounded border bg-white text-black text-[10px] font-mono shadow-inner shadow-sm border-gray-300 dark:bg-gray-700 dark:text-white dark:border-gray-500">
53
+ <p class="mt-0.5">Ctrl</p>
54
+ </span>
55
+ <span class="ml-1 text-white">+</span>
56
+ <span class="ml-1 px-1 h-4 flex items-center justify-center rounded border bg-white text-black text-[10px] font-mono shadow-inner shadow-sm border-gray-300 dark:bg-gray-700 dark:text-white dark:border-gray-500">
57
+ <IconArrowRightThin class="w-3.5 h-3.5" />
58
+ </span>
59
+ </div>
36
60
  </button>
37
61
  <template #tooltip>
38
- {{ $t('Approve completion') }}
62
+ {{ $t(tooltipText) }}
39
63
  </template>
40
64
  </Tooltip>
41
65
 
@@ -44,7 +68,7 @@
44
68
  </template>
45
69
 
46
70
  <script setup lang="ts">
47
- import { ref, onMounted, watch, Ref } from 'vue';
71
+ import { ref, onMounted, watch, Ref, computed } from 'vue';
48
72
  import { callAdminForthApi } from '@/utils';
49
73
  import { AdminForthColumnCommon } from '@/types/Common';
50
74
  import { Spinner, Tooltip } from '@/afcl';
@@ -61,15 +85,33 @@ const props = defineProps<{
61
85
  const emit = defineEmits([
62
86
  'update:value',
63
87
  ]);
64
-
88
+ const approveCompletionValue:string='TAB';
89
+ const approveNextWordValue:string='CTRL + ->'
65
90
  const isLoading = ref<boolean>(false);
66
91
  const isUntouched = ref<boolean>(true);
67
92
  const isFocused = ref<boolean>(false);
68
93
  const currentValue: Ref<string> = ref('');
69
94
  const suggestionInputRef = ref<InstanceType<typeof SuggestionInput> | null>(null);
95
+ const buttonText = ref<string>(approveCompletionValue);
96
+
97
+ const tooltipText = computed(() =>
98
+ buttonText.value === approveCompletionValue ? 'Approve completion' : 'Approve next word'
99
+ );
100
+
101
+ function handleCompletionApproved(type: 'all' | 'word') {
102
+ if(buttonText.value === approveCompletionValue && type === 'all') {
103
+ buttonText.value = approveNextWordValue;
104
+ } else if (buttonText.value === approveNextWordValue && type === 'word') {
105
+ buttonText.value = approveCompletionValue;
106
+ }
107
+ }
70
108
 
71
109
  onMounted(() => {
72
- currentValue.value = props.record[props.column.name] || '';
110
+ const value = props.record[props.column.name] || '';
111
+ currentValue.value = value;
112
+ if (value.trim()) {
113
+ isUntouched.value = false;
114
+ }
73
115
  if (suggestionInputRef.value) {
74
116
  const editor = suggestionInputRef.value.$el.querySelector('.ql-editor');
75
117
  if (editor) {
@@ -84,7 +126,11 @@ watch(() => currentValue.value, (value) => {
84
126
  });
85
127
 
86
128
  watch(() => props.record, (value) => {
87
- currentValue.value = value[props.column.name] || '';
129
+ const val = value[props.column.name] || '';
130
+ currentValue.value = val;
131
+ if (val.trim()) {
132
+ isUntouched.value = false;
133
+ }
88
134
  });
89
135
 
90
136
  async function complete(textBeforeCursor: string) {
@@ -105,8 +151,13 @@ async function complete(textBeforeCursor: string) {
105
151
 
106
152
  const approveCompletion = async () => {
107
153
  if (suggestionInputRef.value) {
108
- await suggestionInputRef.value.approveCompletion('all');
154
+ if( buttonText.value === approveCompletionValue) {
155
+ await suggestionInputRef.value.approveCompletion('all');
156
+ } else {
157
+ await suggestionInputRef.value.approveCompletion('word');
158
+ }
109
159
  }
160
+ buttonText.value === approveCompletionValue ? buttonText.value = approveNextWordValue : buttonText.value = approveCompletionValue;
110
161
  }
111
162
 
112
163
  function handleFocus() {
@@ -10,34 +10,34 @@
10
10
  "license": "ISC",
11
11
  "dependencies": {
12
12
  "@iconify-prerendered/vue-mdi": "^0.28.1737398331",
13
- "vue-suggestion-input": "^1.0.11"
13
+ "vue-suggestion-input": "^1.0.12"
14
14
  }
15
15
  },
16
16
  "node_modules/@babel/helper-string-parser": {
17
- "version": "7.25.9",
18
- "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.25.9.tgz",
19
- "integrity": "sha512-4A/SCr/2KLd5jrtOMFzaKjVtAei3+2r/NChoBNoZ3EyP/+GlhoaEGoWOZUmFmoITP7zOJyHIMm+DYRd8o3PvHA==",
17
+ "version": "7.27.1",
18
+ "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.27.1.tgz",
19
+ "integrity": "sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA==",
20
20
  "license": "MIT",
21
21
  "engines": {
22
22
  "node": ">=6.9.0"
23
23
  }
24
24
  },
25
25
  "node_modules/@babel/helper-validator-identifier": {
26
- "version": "7.25.9",
27
- "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.25.9.tgz",
28
- "integrity": "sha512-Ed61U6XJc3CVRfkERJWDz4dJwKe7iLmmJsbOGu9wSloNSFttHV0I8g6UAgb7qnK5ly5bGLPd4oXZlxCdANBOWQ==",
26
+ "version": "7.27.1",
27
+ "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.27.1.tgz",
28
+ "integrity": "sha512-D2hP9eA+Sqx1kBZgzxZh0y1trbuU+JoDkiEwqhQ36nodYqJwyEIhPSdMNd7lOm/4io72luTPWH20Yda0xOuUow==",
29
29
  "license": "MIT",
30
30
  "engines": {
31
31
  "node": ">=6.9.0"
32
32
  }
33
33
  },
34
34
  "node_modules/@babel/parser": {
35
- "version": "7.27.0",
36
- "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.27.0.tgz",
37
- "integrity": "sha512-iaepho73/2Pz7w2eMS0Q5f83+0RKI7i4xmiYeBmDzfRVbQtTOG7Ts0S4HzJVsTMGI9keU8rNfuZr8DKfSt7Yyg==",
35
+ "version": "7.28.0",
36
+ "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.28.0.tgz",
37
+ "integrity": "sha512-jVZGvOxOuNSsuQuLRTh13nU0AogFlw32w/MT+LV6D3sP5WdbW61E77RnkbaO2dUvmPAYrBDJXGn5gGS6tH4j8g==",
38
38
  "license": "MIT",
39
39
  "dependencies": {
40
- "@babel/types": "^7.27.0"
40
+ "@babel/types": "^7.28.0"
41
41
  },
42
42
  "bin": {
43
43
  "parser": "bin/babel-parser.js"
@@ -47,13 +47,13 @@
47
47
  }
48
48
  },
49
49
  "node_modules/@babel/types": {
50
- "version": "7.27.0",
51
- "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.27.0.tgz",
52
- "integrity": "sha512-H45s8fVLYjbhFH62dIJ3WtmJ6RSPt/3DRO0ZcT2SUiYiQyz3BLVb9ADEnLl91m74aQPS3AzzeajZHYOalWe3bg==",
50
+ "version": "7.28.2",
51
+ "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.28.2.tgz",
52
+ "integrity": "sha512-ruv7Ae4J5dUYULmeXw1gmb7rYRz57OWCPM57pHojnLq/3Z1CK2lNSLTCVjxVk1F/TZHwOZZrOWi0ur95BbLxNQ==",
53
53
  "license": "MIT",
54
54
  "dependencies": {
55
- "@babel/helper-string-parser": "^7.25.9",
56
- "@babel/helper-validator-identifier": "^7.25.9"
55
+ "@babel/helper-string-parser": "^7.27.1",
56
+ "@babel/helper-validator-identifier": "^7.27.1"
57
57
  },
58
58
  "engines": {
59
59
  "node": ">=6.9.0"
@@ -72,109 +72,109 @@
72
72
  }
73
73
  },
74
74
  "node_modules/@jridgewell/sourcemap-codec": {
75
- "version": "1.5.0",
76
- "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz",
77
- "integrity": "sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==",
75
+ "version": "1.5.4",
76
+ "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.4.tgz",
77
+ "integrity": "sha512-VT2+G1VQs/9oz078bLrYbecdZKs912zQlkelYpuf+SXF+QvZDYJlbx/LSx+meSAwdDFnF8FVXW92AVjjkVmgFw==",
78
78
  "license": "MIT"
79
79
  },
80
80
  "node_modules/@vue/compiler-core": {
81
- "version": "3.5.13",
82
- "resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.5.13.tgz",
83
- "integrity": "sha512-oOdAkwqUfW1WqpwSYJce06wvt6HljgY3fGeM9NcVA1HaYOij3mZG9Rkysn0OHuyUAGMbEbARIpsG+LPVlBJ5/Q==",
81
+ "version": "3.5.18",
82
+ "resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.5.18.tgz",
83
+ "integrity": "sha512-3slwjQrrV1TO8MoXgy3aynDQ7lslj5UqDxuHnrzHtpON5CBinhWjJETciPngpin/T3OuW3tXUf86tEurusnztw==",
84
84
  "license": "MIT",
85
85
  "dependencies": {
86
- "@babel/parser": "^7.25.3",
87
- "@vue/shared": "3.5.13",
86
+ "@babel/parser": "^7.28.0",
87
+ "@vue/shared": "3.5.18",
88
88
  "entities": "^4.5.0",
89
89
  "estree-walker": "^2.0.2",
90
- "source-map-js": "^1.2.0"
90
+ "source-map-js": "^1.2.1"
91
91
  }
92
92
  },
93
93
  "node_modules/@vue/compiler-dom": {
94
- "version": "3.5.13",
95
- "resolved": "https://registry.npmjs.org/@vue/compiler-dom/-/compiler-dom-3.5.13.tgz",
96
- "integrity": "sha512-ZOJ46sMOKUjO3e94wPdCzQ6P1Lx/vhp2RSvfaab88Ajexs0AHeV0uasYhi99WPaogmBlRHNRuly8xV75cNTMDA==",
94
+ "version": "3.5.18",
95
+ "resolved": "https://registry.npmjs.org/@vue/compiler-dom/-/compiler-dom-3.5.18.tgz",
96
+ "integrity": "sha512-RMbU6NTU70++B1JyVJbNbeFkK+A+Q7y9XKE2EM4NLGm2WFR8x9MbAtWxPPLdm0wUkuZv9trpwfSlL6tjdIa1+A==",
97
97
  "license": "MIT",
98
98
  "dependencies": {
99
- "@vue/compiler-core": "3.5.13",
100
- "@vue/shared": "3.5.13"
99
+ "@vue/compiler-core": "3.5.18",
100
+ "@vue/shared": "3.5.18"
101
101
  }
102
102
  },
103
103
  "node_modules/@vue/compiler-sfc": {
104
- "version": "3.5.13",
105
- "resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-3.5.13.tgz",
106
- "integrity": "sha512-6VdaljMpD82w6c2749Zhf5T9u5uLBWKnVue6XWxprDobftnletJ8+oel7sexFfM3qIxNmVE7LSFGTpv6obNyaQ==",
104
+ "version": "3.5.18",
105
+ "resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-3.5.18.tgz",
106
+ "integrity": "sha512-5aBjvGqsWs+MoxswZPoTB9nSDb3dhd1x30xrrltKujlCxo48j8HGDNj3QPhF4VIS0VQDUrA1xUfp2hEa+FNyXA==",
107
107
  "license": "MIT",
108
108
  "dependencies": {
109
- "@babel/parser": "^7.25.3",
110
- "@vue/compiler-core": "3.5.13",
111
- "@vue/compiler-dom": "3.5.13",
112
- "@vue/compiler-ssr": "3.5.13",
113
- "@vue/shared": "3.5.13",
109
+ "@babel/parser": "^7.28.0",
110
+ "@vue/compiler-core": "3.5.18",
111
+ "@vue/compiler-dom": "3.5.18",
112
+ "@vue/compiler-ssr": "3.5.18",
113
+ "@vue/shared": "3.5.18",
114
114
  "estree-walker": "^2.0.2",
115
- "magic-string": "^0.30.11",
116
- "postcss": "^8.4.48",
117
- "source-map-js": "^1.2.0"
115
+ "magic-string": "^0.30.17",
116
+ "postcss": "^8.5.6",
117
+ "source-map-js": "^1.2.1"
118
118
  }
119
119
  },
120
120
  "node_modules/@vue/compiler-ssr": {
121
- "version": "3.5.13",
122
- "resolved": "https://registry.npmjs.org/@vue/compiler-ssr/-/compiler-ssr-3.5.13.tgz",
123
- "integrity": "sha512-wMH6vrYHxQl/IybKJagqbquvxpWCuVYpoUJfCqFZwa/JY1GdATAQ+TgVtgrwwMZ0D07QhA99rs/EAAWfvG6KpA==",
121
+ "version": "3.5.18",
122
+ "resolved": "https://registry.npmjs.org/@vue/compiler-ssr/-/compiler-ssr-3.5.18.tgz",
123
+ "integrity": "sha512-xM16Ak7rSWHkM3m22NlmcdIM+K4BMyFARAfV9hYFl+SFuRzrZ3uGMNW05kA5pmeMa0X9X963Kgou7ufdbpOP9g==",
124
124
  "license": "MIT",
125
125
  "dependencies": {
126
- "@vue/compiler-dom": "3.5.13",
127
- "@vue/shared": "3.5.13"
126
+ "@vue/compiler-dom": "3.5.18",
127
+ "@vue/shared": "3.5.18"
128
128
  }
129
129
  },
130
130
  "node_modules/@vue/reactivity": {
131
- "version": "3.5.13",
132
- "resolved": "https://registry.npmjs.org/@vue/reactivity/-/reactivity-3.5.13.tgz",
133
- "integrity": "sha512-NaCwtw8o48B9I6L1zl2p41OHo/2Z4wqYGGIK1Khu5T7yxrn+ATOixn/Udn2m+6kZKB/J7cuT9DbWWhRxqixACg==",
131
+ "version": "3.5.18",
132
+ "resolved": "https://registry.npmjs.org/@vue/reactivity/-/reactivity-3.5.18.tgz",
133
+ "integrity": "sha512-x0vPO5Imw+3sChLM5Y+B6G1zPjwdOri9e8V21NnTnlEvkxatHEH5B5KEAJcjuzQ7BsjGrKtfzuQ5eQwXh8HXBg==",
134
134
  "license": "MIT",
135
135
  "dependencies": {
136
- "@vue/shared": "3.5.13"
136
+ "@vue/shared": "3.5.18"
137
137
  }
138
138
  },
139
139
  "node_modules/@vue/runtime-core": {
140
- "version": "3.5.13",
141
- "resolved": "https://registry.npmjs.org/@vue/runtime-core/-/runtime-core-3.5.13.tgz",
142
- "integrity": "sha512-Fj4YRQ3Az0WTZw1sFe+QDb0aXCerigEpw418pw1HBUKFtnQHWzwojaukAs2X/c9DQz4MQ4bsXTGlcpGxU/RCIw==",
140
+ "version": "3.5.18",
141
+ "resolved": "https://registry.npmjs.org/@vue/runtime-core/-/runtime-core-3.5.18.tgz",
142
+ "integrity": "sha512-DUpHa1HpeOQEt6+3nheUfqVXRog2kivkXHUhoqJiKR33SO4x+a5uNOMkV487WPerQkL0vUuRvq/7JhRgLW3S+w==",
143
143
  "license": "MIT",
144
144
  "dependencies": {
145
- "@vue/reactivity": "3.5.13",
146
- "@vue/shared": "3.5.13"
145
+ "@vue/reactivity": "3.5.18",
146
+ "@vue/shared": "3.5.18"
147
147
  }
148
148
  },
149
149
  "node_modules/@vue/runtime-dom": {
150
- "version": "3.5.13",
151
- "resolved": "https://registry.npmjs.org/@vue/runtime-dom/-/runtime-dom-3.5.13.tgz",
152
- "integrity": "sha512-dLaj94s93NYLqjLiyFzVs9X6dWhTdAlEAciC3Moq7gzAc13VJUdCnjjRurNM6uTLFATRHexHCTu/Xp3eW6yoog==",
150
+ "version": "3.5.18",
151
+ "resolved": "https://registry.npmjs.org/@vue/runtime-dom/-/runtime-dom-3.5.18.tgz",
152
+ "integrity": "sha512-YwDj71iV05j4RnzZnZtGaXwPoUWeRsqinblgVJwR8XTXYZ9D5PbahHQgsbmzUvCWNF6x7siQ89HgnX5eWkr3mw==",
153
153
  "license": "MIT",
154
154
  "dependencies": {
155
- "@vue/reactivity": "3.5.13",
156
- "@vue/runtime-core": "3.5.13",
157
- "@vue/shared": "3.5.13",
155
+ "@vue/reactivity": "3.5.18",
156
+ "@vue/runtime-core": "3.5.18",
157
+ "@vue/shared": "3.5.18",
158
158
  "csstype": "^3.1.3"
159
159
  }
160
160
  },
161
161
  "node_modules/@vue/server-renderer": {
162
- "version": "3.5.13",
163
- "resolved": "https://registry.npmjs.org/@vue/server-renderer/-/server-renderer-3.5.13.tgz",
164
- "integrity": "sha512-wAi4IRJV/2SAW3htkTlB+dHeRmpTiVIK1OGLWV1yeStVSebSQQOwGwIq0D3ZIoBj2C2qpgz5+vX9iEBkTdk5YA==",
162
+ "version": "3.5.18",
163
+ "resolved": "https://registry.npmjs.org/@vue/server-renderer/-/server-renderer-3.5.18.tgz",
164
+ "integrity": "sha512-PvIHLUoWgSbDG7zLHqSqaCoZvHi6NNmfVFOqO+OnwvqMz/tqQr3FuGWS8ufluNddk7ZLBJYMrjcw1c6XzR12mA==",
165
165
  "license": "MIT",
166
166
  "dependencies": {
167
- "@vue/compiler-ssr": "3.5.13",
168
- "@vue/shared": "3.5.13"
167
+ "@vue/compiler-ssr": "3.5.18",
168
+ "@vue/shared": "3.5.18"
169
169
  },
170
170
  "peerDependencies": {
171
- "vue": "3.5.13"
171
+ "vue": "3.5.18"
172
172
  }
173
173
  },
174
174
  "node_modules/@vue/shared": {
175
- "version": "3.5.13",
176
- "resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.5.13.tgz",
177
- "integrity": "sha512-/hnE/qP5ZoGpol0a5mDi45bOd7t3tjYJBjsgCsivow7D48cJeV5l05RD82lPqi7gRiphZM37rnhW1l6ZoCNNnQ==",
175
+ "version": "3.5.18",
176
+ "resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.5.18.tgz",
177
+ "integrity": "sha512-cZy8Dq+uuIXbxCZpuLd2GJdeSO/lIzIspC2WtkqIpje5QyFbvLaI5wZtdUjLHjGZrlVX6GilejatWwVYYRc8tA==",
178
178
  "license": "MIT"
179
179
  },
180
180
  "node_modules/csstype": {
@@ -272,9 +272,9 @@
272
272
  "license": "ISC"
273
273
  },
274
274
  "node_modules/postcss": {
275
- "version": "8.5.3",
276
- "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.3.tgz",
277
- "integrity": "sha512-dle9A3yYxlBSrt8Fu+IpjGT8SY8hN0mlaA6GY8t0P5PjIOZemULz/E2Bnm/2dcUOena75OTNkHI76uZBNUUq3A==",
275
+ "version": "8.5.6",
276
+ "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.6.tgz",
277
+ "integrity": "sha512-3Ybi1tAuwAP9s0r1UQ2J4n5Y0G05bJkpUIO0/bI9MhwmD70S5aTWbXGBwxHrelT+XM1k6dM0pk+SwNkpTRN7Pg==",
278
278
  "funding": [
279
279
  {
280
280
  "type": "opencollective",
@@ -291,7 +291,7 @@
291
291
  ],
292
292
  "license": "MIT",
293
293
  "dependencies": {
294
- "nanoid": "^3.3.8",
294
+ "nanoid": "^3.3.11",
295
295
  "picocolors": "^1.1.1",
296
296
  "source-map-js": "^1.2.1"
297
297
  },
@@ -338,16 +338,16 @@
338
338
  }
339
339
  },
340
340
  "node_modules/vue": {
341
- "version": "3.5.13",
342
- "resolved": "https://registry.npmjs.org/vue/-/vue-3.5.13.tgz",
343
- "integrity": "sha512-wmeiSMxkZCSc+PM2w2VRsOYAZC8GdipNFRTsLSfodVqI9mbejKeXEGr8SckuLnrQPGe3oJN5c3K0vpoU9q/wCQ==",
341
+ "version": "3.5.18",
342
+ "resolved": "https://registry.npmjs.org/vue/-/vue-3.5.18.tgz",
343
+ "integrity": "sha512-7W4Y4ZbMiQ3SEo+m9lnoNpV9xG7QVMLa+/0RFwwiAVkeYoyGXqWE85jabU4pllJNUzqfLShJ5YLptewhCWUgNA==",
344
344
  "license": "MIT",
345
345
  "dependencies": {
346
- "@vue/compiler-dom": "3.5.13",
347
- "@vue/compiler-sfc": "3.5.13",
348
- "@vue/runtime-dom": "3.5.13",
349
- "@vue/server-renderer": "3.5.13",
350
- "@vue/shared": "3.5.13"
346
+ "@vue/compiler-dom": "3.5.18",
347
+ "@vue/compiler-sfc": "3.5.18",
348
+ "@vue/runtime-dom": "3.5.18",
349
+ "@vue/server-renderer": "3.5.18",
350
+ "@vue/shared": "3.5.18"
351
351
  },
352
352
  "peerDependencies": {
353
353
  "typescript": "*"
@@ -359,9 +359,9 @@
359
359
  }
360
360
  },
361
361
  "node_modules/vue-suggestion-input": {
362
- "version": "1.0.11",
363
- "resolved": "https://registry.npmjs.org/vue-suggestion-input/-/vue-suggestion-input-1.0.11.tgz",
364
- "integrity": "sha512-biAo2PD5XTJl7Kp6bf9RFcqdiBcIgl73szfkNdqxVmngV+CltKf0UOLkfNIdijRX8s9JxIkPlpJYmYgYAjiXHw==",
362
+ "version": "1.0.12",
363
+ "resolved": "https://registry.npmjs.org/vue-suggestion-input/-/vue-suggestion-input-1.0.12.tgz",
364
+ "integrity": "sha512-Ik6uuvAonvHmgCRDbnSyqQ/iv91ne2uMv6rVowd8XzIDazzzAvdUQMFjqytl/NbhTAXdXZbKd5WsY/X+PtUvwQ==",
365
365
  "dependencies": {
366
366
  "quill": "^2.0.2",
367
367
  "vue": "^3.4.31"
@@ -11,6 +11,6 @@
11
11
  "license": "ISC",
12
12
  "dependencies": {
13
13
  "@iconify-prerendered/vue-mdi": "^0.28.1737398331",
14
- "vue-suggestion-input": "^1.0.11"
14
+ "vue-suggestion-input": "^1.0.12"
15
15
  }
16
16
  }
package/dist/index.js CHANGED
@@ -63,7 +63,7 @@ export default class TextCompletePlugin extends AdminForthPlugin {
63
63
  method: 'POST',
64
64
  path: `/plugin/${this.pluginInstanceId}/doComplete`,
65
65
  handler: (_a) => __awaiter(this, [_a], void 0, function* ({ body, headers }) {
66
- var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
66
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
67
67
  if ((_b = this.options.rateLimit) === null || _b === void 0 ? void 0 : _b.limit) {
68
68
  // rate limit
69
69
  const { error } = RateLimiter.checkRateLimit(this.pluginInstanceId, (_c = this.options.rateLimit) === null || _c === void 0 ? void 0 : _c.limit, this.adminforth.auth.getClientIp(headers));
@@ -82,18 +82,17 @@ export default class TextCompletePlugin extends AdminForthPlugin {
82
82
  if (currentVal && currentVal.length > promptLimit) {
83
83
  currentVal = currentVal.slice(-promptLimit);
84
84
  }
85
+ const fieldLabel = ((_m = (_l = this.resourceConfig) === null || _l === void 0 ? void 0 : _l.columns.find(c => c.name === this.options.fieldName)) === null || _m === void 0 ? void 0 : _m.label) || this.options.fieldName;
85
86
  const resLabel = this.resourceConfig.label;
86
87
  let content;
87
88
  if (currentVal) {
88
- content = `Continue writing for text/string field "${this.options.fieldName}" in the table "${resLabel}"\n` +
89
+ content = `Continue writing for text/string field "${fieldLabel}" in the table "${resLabel}"\n` +
89
90
  (Object.keys(recordNoField).length > 0 ? `Record has values for the context: ${inputContext}\n` : '') +
90
91
  `Current field value: ${currentVal}\n` +
91
92
  "Don't talk to me. Just write text. No quotes. Don't repeat current field value, just write completion\n";
92
93
  }
93
94
  else {
94
95
  if (this.options.initialPrompt) {
95
- // initial prompt might have mustache syntax for current record value (several fields)
96
- // use regex to replace it with current record value
97
96
  const regex = /{{([^}]+)}}/g;
98
97
  const interpretedPrompt = this.options.initialPrompt.replace(regex, (match, p1) => {
99
98
  const fieldName = p1.trim();
@@ -107,14 +106,14 @@ export default class TextCompletePlugin extends AdminForthPlugin {
107
106
  "No quotes. Don't talk to me. Just write text\n";
108
107
  }
109
108
  else {
110
- content = `Fill text/string field "${this.options.fieldName}" in the table "${resLabel}"\n` +
109
+ content = `Fill text/string field "${fieldLabel}" in the table "${resLabel}"\n` +
111
110
  (Object.keys(recordNoField).length > 0 ? `Record has values for the context: ${inputContext}\n` : '') +
112
111
  "Be short, clear and precise. No quotes. Don't talk to me. Just write text\n";
113
112
  }
114
113
  }
115
114
  process.env.HEAVY_DEBUG && console.log('🪲 OpenAI Prompt 🧠', content);
116
- const { content: respContent, finishReason } = yield this.options.adapter.complete(content, (_l = this.options.expert) === null || _l === void 0 ? void 0 : _l.stop, (_m = this.options.expert) === null || _m === void 0 ? void 0 : _m.maxTokens);
117
- const stop = ((_o = this.options.expert) === null || _o === void 0 ? void 0 : _o.stop) || ['.'];
115
+ const { content: respContent, finishReason } = yield this.options.adapter.complete(content, (_o = this.options.expert) === null || _o === void 0 ? void 0 : _o.stop, (_p = this.options.expert) === null || _p === void 0 ? void 0 : _p.maxTokens);
116
+ const stop = ((_q = this.options.expert) === null || _q === void 0 ? void 0 : _q.stop) || ['.'];
118
117
  let suggestion = respContent + (finishReason === 'stop' ? (stop[0] === '.' && stop.length === 1 && this.columnType === AdminForthDataTypes.TEXT ? '. ' : '') : '');
119
118
  if (suggestion.startsWith(currentVal)) {
120
119
  suggestion = suggestion.slice(currentVal.length);
package/index.ts CHANGED
@@ -108,21 +108,18 @@ export default class TextCompletePlugin extends AdminForthPlugin {
108
108
  currentVal = currentVal.slice(-promptLimit);
109
109
  }
110
110
 
111
- const resLabel = this.resourceConfig.label;
112
-
111
+ const fieldLabel = this.resourceConfig?.columns.find(c => c.name === this.options.fieldName)?.label || this.options.fieldName;
112
+ const resLabel = this.resourceConfig!.label;
113
+
113
114
  let content;
114
-
115
+
115
116
  if (currentVal) {
116
- content = `Continue writing for text/string field "${this.options.fieldName}" in the table "${resLabel}"\n` +
117
+ content = `Continue writing for text/string field "${fieldLabel}" in the table "${resLabel}"\n` +
117
118
  (Object.keys(recordNoField).length > 0 ? `Record has values for the context: ${inputContext}\n` : '') +
118
119
  `Current field value: ${currentVal}\n` +
119
120
  "Don't talk to me. Just write text. No quotes. Don't repeat current field value, just write completion\n";
120
-
121
121
  } else {
122
-
123
122
  if (this.options.initialPrompt) {
124
- // initial prompt might have mustache syntax for current record value (several fields)
125
- // use regex to replace it with current record value
126
123
  const regex = /{{([^}]+)}}/g;
127
124
  const interpretedPrompt = this.options.initialPrompt.replace(regex, (match, p1) => {
128
125
  const fieldName = p1.trim();
@@ -133,11 +130,10 @@ export default class TextCompletePlugin extends AdminForthPlugin {
133
130
  return match;
134
131
  });
135
132
 
136
-
137
133
  content = `${interpretedPrompt}\n` +
138
134
  "No quotes. Don't talk to me. Just write text\n";
139
135
  } else {
140
- content = `Fill text/string field "${this.options.fieldName}" in the table "${resLabel}"\n` +
136
+ content = `Fill text/string field "${fieldLabel}" in the table "${resLabel}"\n` +
141
137
  (Object.keys(recordNoField).length > 0 ? `Record has values for the context: ${inputContext}\n` : '') +
142
138
  "Be short, clear and precise. No quotes. Don't talk to me. Just write text\n";
143
139
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/text-complete",
3
- "version": "1.4.4",
3
+ "version": "1.6.0",
4
4
  "description": "Text completion plugin for adminforth",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",