@dataloop-ai/components 0.20.258 → 0.20.259-new-json.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dataloop-ai/components",
|
|
3
|
-
"version": "0.20.
|
|
3
|
+
"version": "0.20.259-new-json.1",
|
|
4
4
|
"exports": {
|
|
5
5
|
".": "./index.ts",
|
|
6
6
|
"./models": "./models.ts",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"tokenizr": "^1.7.0",
|
|
43
43
|
"uuid": "^8.3.2",
|
|
44
44
|
"v-wave": "^1.5.0",
|
|
45
|
-
"vanilla-jsoneditor": "^0.10.
|
|
45
|
+
"vanilla-jsoneditor": "^0.10.4",
|
|
46
46
|
"vue-demi": "^0.14.5",
|
|
47
47
|
"vue-sortable": "^0.1.3",
|
|
48
48
|
"vue2-teleport": "^1.0.1"
|
|
@@ -53,6 +53,11 @@ export default defineComponent({
|
|
|
53
53
|
required: false,
|
|
54
54
|
type: String as PropType<Mode>,
|
|
55
55
|
default: Mode.text
|
|
56
|
+
},
|
|
57
|
+
autoFocus: {
|
|
58
|
+
required: false,
|
|
59
|
+
type: Boolean,
|
|
60
|
+
default: true
|
|
56
61
|
}
|
|
57
62
|
},
|
|
58
63
|
emits: [
|
|
@@ -64,11 +69,34 @@ export default defineComponent({
|
|
|
64
69
|
'blur'
|
|
65
70
|
],
|
|
66
71
|
setup(props, { emit }) {
|
|
67
|
-
const { modelValue, indentation, readonly, mode } =
|
|
72
|
+
const { modelValue, indentation, readonly, mode, autoFocus } =
|
|
73
|
+
toRefs(props)
|
|
68
74
|
|
|
69
75
|
const jsonEditorRef = ref(null)
|
|
70
76
|
const jsonEditor = ref<JSONEditor>(null as any)
|
|
71
77
|
const innerUpdate = ref(false)
|
|
78
|
+
const suppressProgrammaticFocus = ref(false)
|
|
79
|
+
|
|
80
|
+
const blurEditorIfFocused = () => {
|
|
81
|
+
const target = jsonEditorRef.value as HTMLElement | null
|
|
82
|
+
if (target?.contains(document.activeElement)) {
|
|
83
|
+
;(document.activeElement as HTMLElement)?.blur()
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const runWithoutAutoFocus = (fn: () => void) => {
|
|
88
|
+
if (autoFocus.value) {
|
|
89
|
+
fn()
|
|
90
|
+
return
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
suppressProgrammaticFocus.value = true
|
|
94
|
+
fn()
|
|
95
|
+
nextTick(() => {
|
|
96
|
+
blurEditorIfFocused()
|
|
97
|
+
suppressProgrammaticFocus.value = false
|
|
98
|
+
})
|
|
99
|
+
}
|
|
72
100
|
|
|
73
101
|
watch(modelValue, (val) => {
|
|
74
102
|
if (innerUpdate.value) {
|
|
@@ -76,15 +104,19 @@ export default defineComponent({
|
|
|
76
104
|
return
|
|
77
105
|
}
|
|
78
106
|
|
|
79
|
-
|
|
80
|
-
|
|
107
|
+
runWithoutAutoFocus(() => {
|
|
108
|
+
jsonEditor.value?.set({
|
|
109
|
+
text: val
|
|
110
|
+
})
|
|
81
111
|
})
|
|
82
112
|
})
|
|
83
113
|
|
|
84
114
|
watch(mode, (val) => {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
115
|
+
runWithoutAutoFocus(() => {
|
|
116
|
+
jsonEditor.value?.updateProps({
|
|
117
|
+
mode: val,
|
|
118
|
+
readOnly: val === Mode.tree
|
|
119
|
+
})
|
|
88
120
|
})
|
|
89
121
|
})
|
|
90
122
|
|
|
@@ -136,6 +168,10 @@ export default defineComponent({
|
|
|
136
168
|
navigationBar: false,
|
|
137
169
|
statusBar: false,
|
|
138
170
|
onFocus: () => {
|
|
171
|
+
if (suppressProgrammaticFocus.value) {
|
|
172
|
+
blurEditorIfFocused()
|
|
173
|
+
return
|
|
174
|
+
}
|
|
139
175
|
emit('focus')
|
|
140
176
|
},
|
|
141
177
|
onBlur: () => {
|
|
@@ -153,18 +189,22 @@ export default defineComponent({
|
|
|
153
189
|
props: initialAttrs
|
|
154
190
|
})
|
|
155
191
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
192
|
+
runWithoutAutoFocus(() => {
|
|
193
|
+
jsonEditor.value?.set({
|
|
194
|
+
text: modelValue.value
|
|
195
|
+
})
|
|
159
196
|
|
|
160
|
-
|
|
161
|
-
|
|
197
|
+
nextTick(() => {
|
|
198
|
+
jsonEditor.value?.refresh()
|
|
199
|
+
})
|
|
162
200
|
})
|
|
163
201
|
}
|
|
164
202
|
|
|
165
203
|
watch(readonly, (val) => {
|
|
166
|
-
|
|
167
|
-
|
|
204
|
+
runWithoutAutoFocus(() => {
|
|
205
|
+
jsonEditor.value?.updateProps({
|
|
206
|
+
readOnly: val || mode.value === Mode.tree
|
|
207
|
+
})
|
|
168
208
|
})
|
|
169
209
|
})
|
|
170
210
|
|