@appscode/design-system 1.0.43-alpha.151 → 1.0.43-alpha.152
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
|
@@ -3,69 +3,76 @@
|
|
|
3
3
|
</template>
|
|
4
4
|
|
|
5
5
|
<script>
|
|
6
|
-
import { defineComponent, computed, toRefs } from
|
|
7
|
-
import * as monaco from
|
|
6
|
+
import { defineComponent, computed, toRefs } from "vue";
|
|
7
|
+
import * as monaco from "monaco-editor";
|
|
8
8
|
|
|
9
9
|
export default defineComponent({
|
|
10
10
|
name: "MonacoEditor",
|
|
11
11
|
props: {
|
|
12
12
|
diffEditor: { type: Boolean, default: false },
|
|
13
|
-
width: {type: [String, Number], default:
|
|
14
|
-
height: {type: [String, Number], default:
|
|
15
|
-
original: String,
|
|
13
|
+
width: { type: [String, Number], default: "100%" },
|
|
14
|
+
height: { type: [String, Number], default: "100%" },
|
|
15
|
+
original: String,
|
|
16
16
|
value: String,
|
|
17
|
-
language: {type: String, default:
|
|
18
|
-
theme: {type: String, default:
|
|
19
|
-
options: {
|
|
17
|
+
language: { type: String, default: "javascript" },
|
|
18
|
+
theme: { type: String, default: "vs" },
|
|
19
|
+
options: {
|
|
20
|
+
type: Object,
|
|
21
|
+
default() {
|
|
22
|
+
return {};
|
|
23
|
+
},
|
|
24
|
+
},
|
|
20
25
|
},
|
|
21
|
-
emits: [
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
emits: ["editorWillMount", "editorDidMount", "change"],
|
|
27
|
+
setup(props) {
|
|
28
|
+
const { width, height } = toRefs(props);
|
|
29
|
+
const style = computed(() => {
|
|
30
|
+
const fixedWidth = width.value.toString().includes("%")
|
|
31
|
+
? width.value
|
|
32
|
+
: `${width.value}px`;
|
|
33
|
+
const fixedHeight = height.value.toString().includes("%")
|
|
34
|
+
? height.value
|
|
35
|
+
: `${height.value}px`;
|
|
31
36
|
return {
|
|
32
37
|
width: fixedWidth,
|
|
33
38
|
height: fixedHeight,
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
})
|
|
39
|
+
"text-align": "left",
|
|
40
|
+
};
|
|
41
|
+
});
|
|
37
42
|
return {
|
|
38
|
-
style
|
|
39
|
-
}
|
|
43
|
+
style,
|
|
44
|
+
};
|
|
40
45
|
},
|
|
41
46
|
mounted() {
|
|
42
|
-
this.initMonaco()
|
|
47
|
+
this.initMonaco();
|
|
43
48
|
},
|
|
44
|
-
|
|
49
|
+
beforeUnmount() {
|
|
45
50
|
this.editor && this.editor.dispose();
|
|
46
51
|
},
|
|
47
52
|
methods: {
|
|
48
|
-
initMonaco(){
|
|
49
|
-
this.$emit(
|
|
53
|
+
initMonaco() {
|
|
54
|
+
this.$emit("editorWillMount", this.monaco);
|
|
50
55
|
const { value, language, theme, options } = this;
|
|
51
|
-
this.editor = monaco.editor[
|
|
56
|
+
this.editor = monaco.editor[
|
|
57
|
+
this.diffEditor ? "createDiffEditor" : "create"
|
|
58
|
+
](this.$el, {
|
|
52
59
|
value: value,
|
|
53
60
|
language: language,
|
|
54
61
|
theme: theme,
|
|
55
|
-
...options
|
|
62
|
+
...options,
|
|
56
63
|
});
|
|
57
64
|
this.diffEditor && this._setModel(this.value, this.original);
|
|
58
65
|
|
|
59
66
|
// @event `change`
|
|
60
|
-
const editor = this._getEditor()
|
|
61
|
-
editor.onDidChangeModelContent(event => {
|
|
62
|
-
const value = editor.getValue()
|
|
67
|
+
const editor = this._getEditor();
|
|
68
|
+
editor.onDidChangeModelContent((event) => {
|
|
69
|
+
const value = editor.getValue();
|
|
63
70
|
if (this.value !== value) {
|
|
64
|
-
this.$emit(
|
|
71
|
+
this.$emit("change", value, event);
|
|
65
72
|
}
|
|
66
|
-
})
|
|
73
|
+
});
|
|
67
74
|
|
|
68
|
-
this.$emit(
|
|
75
|
+
this.$emit("editorDidMount", this.editor);
|
|
69
76
|
},
|
|
70
77
|
_setModel(value, original) {
|
|
71
78
|
const { language } = this;
|
|
@@ -73,52 +80,52 @@ export default defineComponent({
|
|
|
73
80
|
const modifiedModel = monaco.editor.createModel(value, language);
|
|
74
81
|
this.editor.setModel({
|
|
75
82
|
original: originalModel,
|
|
76
|
-
modified: modifiedModel
|
|
83
|
+
modified: modifiedModel,
|
|
77
84
|
});
|
|
78
85
|
},
|
|
79
86
|
_setValue(value) {
|
|
80
87
|
let editor = this._getEditor();
|
|
81
|
-
if(editor) return editor.setValue(value);
|
|
88
|
+
if (editor) return editor.setValue(value);
|
|
82
89
|
},
|
|
83
90
|
_getValue() {
|
|
84
91
|
let editor = this._getEditor();
|
|
85
|
-
if(!editor) return
|
|
92
|
+
if (!editor) return "";
|
|
86
93
|
return editor.getValue();
|
|
87
94
|
},
|
|
88
95
|
_getEditor() {
|
|
89
|
-
if(!this.editor) return null;
|
|
96
|
+
if (!this.editor) return null;
|
|
90
97
|
return this.diffEditor ? this.editor.getModifiedEditor() : this.editor;
|
|
91
98
|
},
|
|
92
|
-
_setOriginal(){
|
|
93
|
-
const { original } = this.editor.getModel()
|
|
94
|
-
original.setValue(this.original)
|
|
95
|
-
}
|
|
99
|
+
_setOriginal() {
|
|
100
|
+
const { original } = this.editor.getModel();
|
|
101
|
+
original.setValue(this.original);
|
|
102
|
+
},
|
|
96
103
|
},
|
|
97
104
|
watch: {
|
|
98
105
|
options: {
|
|
99
106
|
deep: true,
|
|
100
107
|
handler(options) {
|
|
101
108
|
this.editor.updateOptions(options);
|
|
102
|
-
}
|
|
109
|
+
},
|
|
103
110
|
},
|
|
104
111
|
value() {
|
|
105
112
|
this.value !== this._getValue() && this._setValue(this.value);
|
|
106
113
|
},
|
|
107
114
|
original() {
|
|
108
|
-
this._setOriginal()
|
|
115
|
+
this._setOriginal();
|
|
109
116
|
},
|
|
110
117
|
language() {
|
|
111
|
-
if(!this.editor) return;
|
|
112
|
-
if(this.diffEditor){
|
|
118
|
+
if (!this.editor) return;
|
|
119
|
+
if (this.diffEditor) {
|
|
113
120
|
const { original, modified } = this.editor.getModel();
|
|
114
121
|
monaco.editor.setModelLanguage(original, this.language);
|
|
115
122
|
monaco.editor.setModelLanguage(modified, this.language);
|
|
116
|
-
}else
|
|
123
|
+
} else
|
|
117
124
|
monaco.editor.setModelLanguage(this.editor.getModel(), this.language);
|
|
118
125
|
},
|
|
119
126
|
theme() {
|
|
120
127
|
monaco.editor.setTheme(this.theme);
|
|
121
128
|
},
|
|
122
|
-
}
|
|
129
|
+
},
|
|
123
130
|
});
|
|
124
131
|
</script>
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="form-wrapper">
|
|
3
|
+
<div
|
|
4
|
+
:class="{
|
|
5
|
+
'pt-20': !reducePaddingTop,
|
|
6
|
+
'pt-10': reducePaddingTop,
|
|
7
|
+
'pl-20': !isContainer,
|
|
8
|
+
'form-content': !isContainer,
|
|
9
|
+
container: isContainer,
|
|
10
|
+
}"
|
|
11
|
+
>
|
|
12
|
+
<slot />
|
|
13
|
+
</div>
|
|
14
|
+
<div
|
|
15
|
+
class="form-footer b-t-1 pt-10 pb-10 pl-20 pr-20 mt-15"
|
|
16
|
+
v-if="hasFooter"
|
|
17
|
+
>
|
|
18
|
+
<div
|
|
19
|
+
class="ac-vcentered"
|
|
20
|
+
:class="{
|
|
21
|
+
'form-content': !isContainer,
|
|
22
|
+
container: isContainer,
|
|
23
|
+
}"
|
|
24
|
+
>
|
|
25
|
+
<form-footer-controls>
|
|
26
|
+
<slot name="form-left-controls" />
|
|
27
|
+
</form-footer-controls>
|
|
28
|
+
<form-footer-controls>
|
|
29
|
+
<slot name="form-right-controls" />
|
|
30
|
+
</form-footer-controls>
|
|
31
|
+
</div>
|
|
32
|
+
</div>
|
|
33
|
+
</div>
|
|
34
|
+
</template>
|
|
35
|
+
|
|
36
|
+
<script>
|
|
37
|
+
import { defineComponent, defineAsyncComponent, h } from "vue";
|
|
38
|
+
|
|
39
|
+
export default defineComponent({
|
|
40
|
+
props: {
|
|
41
|
+
isContainer: {
|
|
42
|
+
type: Boolean,
|
|
43
|
+
default: false,
|
|
44
|
+
},
|
|
45
|
+
hasFooter: {
|
|
46
|
+
type: Boolean,
|
|
47
|
+
default: true,
|
|
48
|
+
},
|
|
49
|
+
reducePaddingTop: {
|
|
50
|
+
type: Boolean,
|
|
51
|
+
default: false,
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
components: {
|
|
56
|
+
FormFooterControls: defineAsyncComponent(() =>
|
|
57
|
+
import("../../v2/form/FormFooterControl.vue").then(
|
|
58
|
+
(module) => module.default
|
|
59
|
+
)
|
|
60
|
+
),
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
</script>
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<input
|
|
2
|
+
<input
|
|
3
|
+
class="ac-input"
|
|
4
|
+
:value="modelValue"
|
|
5
|
+
@input="$emit('update:modelValue', $event.target.value)"
|
|
6
|
+
/>
|
|
3
7
|
</template>
|
|
4
8
|
|
|
5
9
|
<script>
|
|
6
10
|
import { defineComponent } from "vue";
|
|
7
11
|
|
|
8
12
|
export default defineComponent({
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return Object.assign({}, this.$attrs, {
|
|
14
|
-
onInput: (event) => {
|
|
15
|
-
this.$emit("update:modelValue", event.target.value);
|
|
16
|
-
},
|
|
17
|
-
});
|
|
13
|
+
props: {
|
|
14
|
+
modelValue: {
|
|
15
|
+
type: null,
|
|
16
|
+
default: "",
|
|
18
17
|
},
|
|
19
18
|
},
|
|
19
|
+
emits: ["update:modelValue"],
|
|
20
20
|
});
|
|
21
21
|
</script>
|