@dataloop-ai/components 0.20.258 → 0.20.259-wip-json.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/package.json
CHANGED
|
@@ -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,7 +69,8 @@ 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)
|
|
@@ -126,6 +132,13 @@ export default defineComponent({
|
|
|
126
132
|
return debounce(handleJSONChange, 100)
|
|
127
133
|
})
|
|
128
134
|
|
|
135
|
+
const blurEditorIfFocused = () => {
|
|
136
|
+
const target = jsonEditorRef.value as HTMLElement | null
|
|
137
|
+
if (target?.contains(document.activeElement)) {
|
|
138
|
+
;(document.activeElement as HTMLElement)?.blur()
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
129
142
|
const initJsonEditor = () => {
|
|
130
143
|
const initialAttrs: JSONEditorPropsOptional = {
|
|
131
144
|
onChange: debouncedHandleJSONChange.value,
|
|
@@ -159,6 +172,9 @@ export default defineComponent({
|
|
|
159
172
|
|
|
160
173
|
nextTick(() => {
|
|
161
174
|
jsonEditor.value?.refresh()
|
|
175
|
+
if (!autoFocus.value) {
|
|
176
|
+
blurEditorIfFocused()
|
|
177
|
+
}
|
|
162
178
|
})
|
|
163
179
|
}
|
|
164
180
|
|