@appscode/design-system 1.0.3-alpha.7 → 1.0.43-alpha.12
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/base/utilities/_default.scss +24 -4
- package/base/utilities/_derived-variables.scss +2 -2
- package/base/utilities/_initial-variables.scss +35 -22
- package/base/utilities/_mixin.scss +96 -9
- package/components/_ac-alert-box.scss +30 -2
- package/components/_ac-input.scss +70 -3
- package/components/_ac-multi-select.scss +25 -5
- package/components/_ac-table.scss +52 -17
- package/components/_ac-tags.scss +1 -1
- package/components/_breadcumb.scss +2 -2
- package/components/_buttons.scss +26 -6
- package/components/_left-sidebar-menu.scss +8 -2
- package/components/_navbar.scss +1 -1
- package/components/_pagination.scss +36 -6
- package/components/_preloader.scss +1 -1
- package/components/_wizard.scss +1 -1
- package/components/ac-toaster/_ac-toasted.scss +36 -4
- package/components/bbum/_information-center.scss +2 -2
- package/components/bbum/_user-profile.scss +1 -1
- package/components/ui-builder/_ui-builder.scss +2 -2
- package/layouts/_404.scss +158 -0
- package/layouts/_code-preview.scss +1 -0
- package/package.json +1 -1
- package/plugins/vue-toaster.js +7 -6
- package/vue-components/v2/card/CardContent.vue +5 -0
- package/vue-components/v2/card/CardHeader.vue +12 -0
- package/vue-components/v2/card/OverviewCard.vue +10 -0
- package/vue-components/v2/card/OverviewCards.vue +5 -0
- package/vue-components/v2/card/PaymentCards.vue +6 -9
- package/vue-components/v2/content/ContentHeader.vue +1 -1
- package/vue-components/v2/header/Header.vue +0 -1
- package/vue-components/v2/modal/Modal.vue +2 -3
- package/vue-components/v2/modals/JsonShowModal.vue +0 -1
- package/vue-components/v2/navbar/Appdrawer.vue +8 -6
- package/vue-components/v2/pagination/Pagination.vue +8 -1
- package/vue-components/v2/sidebar/SidebarItem.vue +1 -1
- package/vue-components/v2/table/InfoTable.vue +13 -3
- package/vue-components/v2/table/Table.vue +75 -5
- package/vue-components/v3/button/Button.vue +73 -0
- package/vue-components/v3/content/ContentHeader.vue +54 -0
- package/vue-components/v3/content/ContentTable.vue +65 -0
- package/vue-components/v3/dropdown/DropdownDivider.vue +3 -0
- package/vue-components/v3/dropdown/DropdownItem.vue +5 -0
- package/vue-components/v3/dropdown/DropdownMenu.vue +111 -0
- package/vue-components/v3/editor/Editor.vue +137 -0
- package/vue-components/v3/form-fields/Input.vue +21 -0
- package/vue-components/v3/header/Header.vue +45 -0
- package/vue-components/v3/modal/Modal.vue +126 -0
- package/vue-components/v3/modals/JsonShowModal.vue +87 -0
- package/vue-components/v3/navbar/Appdrawer.vue +58 -0
- package/vue-components/v3/navbar/User.vue +64 -0
- package/vue-components/v3/pagination/Pagination.vue +159 -0
- package/vue-components/v3/searchbars/SearchBar.vue +47 -0
- package/vue-components/v3/tab/TabItem.vue +17 -0
- package/vue-components/v3/table/FakeTableCell.vue +39 -0
- package/vue-components/v3/table/InfoTable.vue +105 -0
- package/vue-components/v3/table/Table.vue +238 -0
- package/vue-components/v3/table/TableCell.vue +28 -0
- package/vue-components/v3/table/TableRow.vue +60 -0
- package/vue-components/v3/table/table-cell/ArrayCell.vue +111 -0
- package/vue-components/v3/table/table-cell/CellValue.vue +108 -0
- package/vue-components/v3/table/table-cell/ObjectCell.vue +105 -0
- package/vue-components/v3/table/table-cell/ValueWithModal.vue +43 -0
- package/vue-components/v3/tabs/EditorTabs.vue +36 -0
- package/vue-components/v3/tag/Tag.vue +17 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div class="app-drawer-wrapper">
|
|
2
|
+
<div class="app-drawer-wrapper d-table-cell">
|
|
3
3
|
<div class="drawer-icon">
|
|
4
4
|
<svg
|
|
5
5
|
class="gb_We"
|
|
@@ -20,14 +20,16 @@
|
|
|
20
20
|
<article class="media">
|
|
21
21
|
<figure class="media-left">
|
|
22
22
|
<p class="image">
|
|
23
|
-
<img
|
|
23
|
+
<img
|
|
24
|
+
:src="app.icon_url"
|
|
25
|
+
/>
|
|
24
26
|
</p>
|
|
25
27
|
</figure>
|
|
26
28
|
<div class="media-content">
|
|
27
29
|
<div class="content">
|
|
28
30
|
<p>
|
|
29
|
-
<strong>{{
|
|
30
|
-
<span>{{
|
|
31
|
+
<strong>{{app.title}}</strong>
|
|
32
|
+
<span>{{app.sub_title}}</span>
|
|
31
33
|
</p>
|
|
32
34
|
</div>
|
|
33
35
|
</div>
|
|
@@ -44,8 +46,8 @@ export default {
|
|
|
44
46
|
props: {
|
|
45
47
|
apps: {
|
|
46
48
|
type: Array,
|
|
47
|
-
default: () => []
|
|
48
|
-
}
|
|
49
|
+
default: () => []
|
|
50
|
+
}
|
|
49
51
|
},
|
|
50
52
|
components: {
|
|
51
53
|
NavbarItemContent: () => import("./NavbarItemContent.vue"),
|
|
@@ -3,7 +3,10 @@
|
|
|
3
3
|
<div class="pagination-filter level-left">
|
|
4
4
|
<div
|
|
5
5
|
class="level-item"
|
|
6
|
-
v-show="
|
|
6
|
+
v-show="
|
|
7
|
+
!hideRowsPerPageSelection &&
|
|
8
|
+
totalNoOfItems > preSelectedItemsCountPerPage
|
|
9
|
+
"
|
|
7
10
|
>
|
|
8
11
|
<label>Rows per page</label>
|
|
9
12
|
<select v-model="selectedItemCountPerPage" name="page">
|
|
@@ -52,6 +55,10 @@
|
|
|
52
55
|
<script>
|
|
53
56
|
export default {
|
|
54
57
|
props: {
|
|
58
|
+
hideRowsPerPageSelection: {
|
|
59
|
+
type: Boolean,
|
|
60
|
+
default: false,
|
|
61
|
+
},
|
|
55
62
|
totalNoOfItems: {
|
|
56
63
|
type: Number,
|
|
57
64
|
default: 0,
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<table-container>
|
|
3
|
-
<table
|
|
3
|
+
<table
|
|
4
|
+
class="table ac-info-table is-fullwidth"
|
|
5
|
+
:class="{ 'pl-0 pr-0': removeContentPadding }"
|
|
6
|
+
>
|
|
4
7
|
<tbody v-if="isFullTableLoaderActive">
|
|
5
8
|
<!-- table loader -->
|
|
6
9
|
<table-row v-for="i in loaderCols" :key="i">
|
|
@@ -15,7 +18,10 @@
|
|
|
15
18
|
</tbody>
|
|
16
19
|
<tbody
|
|
17
20
|
v-else
|
|
18
|
-
:class="
|
|
21
|
+
:class="{
|
|
22
|
+
'no-data-available has-text-centered p-10': isTableEmpty,
|
|
23
|
+
'pl-0 pr-0': removeContentPadding
|
|
24
|
+
}"
|
|
19
25
|
>
|
|
20
26
|
<template v-if="!isTableEmpty">
|
|
21
27
|
<!-- table rows -->
|
|
@@ -60,7 +66,11 @@ export default {
|
|
|
60
66
|
},
|
|
61
67
|
tableHeaders: {
|
|
62
68
|
type: Array,
|
|
63
|
-
default: () => []
|
|
69
|
+
default: () => []
|
|
70
|
+
},
|
|
71
|
+
removeContentPadding: {
|
|
72
|
+
type: Boolean,
|
|
73
|
+
default: false,
|
|
64
74
|
},
|
|
65
75
|
},
|
|
66
76
|
|
|
@@ -18,8 +18,17 @@
|
|
|
18
18
|
</th>
|
|
19
19
|
</table-row>
|
|
20
20
|
<table-row v-else>
|
|
21
|
-
<th
|
|
22
|
-
|
|
21
|
+
<th
|
|
22
|
+
v-for="(tableHeader, idx) in tableHeaders"
|
|
23
|
+
:key="idx"
|
|
24
|
+
:class="{
|
|
25
|
+
sorting: headerSortables[idx] && headerSortables[idx].enabled,
|
|
26
|
+
'sorting-desc': headerSortables[idx] && headerSortables[idx].mode === 'desc',
|
|
27
|
+
'sorting-asc': headerSortables[idx] && headerSortables[idx].mode === 'asc',
|
|
28
|
+
}"
|
|
29
|
+
@click.prevent="headerSortables[idx] && headerSortables[idx].enabled && emitSortEvent(idx)"
|
|
30
|
+
>
|
|
31
|
+
{{ headerLabels[idx] }}
|
|
23
32
|
</th>
|
|
24
33
|
<th
|
|
25
34
|
ref="action-section"
|
|
@@ -41,8 +50,14 @@
|
|
|
41
50
|
</th>
|
|
42
51
|
</table-row>
|
|
43
52
|
<table-row v-else>
|
|
44
|
-
<table-cell
|
|
45
|
-
|
|
53
|
+
<table-cell
|
|
54
|
+
v-for="(tableHeader, idx) in tableHeaders"
|
|
55
|
+
:key="headerLabels[idx]"
|
|
56
|
+
>
|
|
57
|
+
<cell-value
|
|
58
|
+
:is-loader-active="true"
|
|
59
|
+
:cell-title="headerLabels[idx]"
|
|
60
|
+
/>
|
|
46
61
|
</table-cell>
|
|
47
62
|
</table-row>
|
|
48
63
|
</tbody>
|
|
@@ -112,12 +127,13 @@ export default {
|
|
|
112
127
|
data() {
|
|
113
128
|
return {
|
|
114
129
|
fakeCellWidth: 0,
|
|
130
|
+
headerSortables: [],
|
|
115
131
|
};
|
|
116
132
|
},
|
|
117
133
|
|
|
118
134
|
computed: {
|
|
119
135
|
loaderCols() {
|
|
120
|
-
if (this.
|
|
136
|
+
if (this.isFullTableLoaderActive) {
|
|
121
137
|
return 5;
|
|
122
138
|
} else if (this.isLoaderActive) {
|
|
123
139
|
return Math.max(this.tableHeaders.length + 1, 5);
|
|
@@ -128,6 +144,41 @@ export default {
|
|
|
128
144
|
isFullTableLoaderActive() {
|
|
129
145
|
return !this.tableHeaders.length;
|
|
130
146
|
},
|
|
147
|
+
headerLabels() {
|
|
148
|
+
return this.tableHeaders.map((th) =>
|
|
149
|
+
typeof th === "string" ? th : th.label || "Label"
|
|
150
|
+
);
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
|
|
154
|
+
watch: {
|
|
155
|
+
tableHeaders: {
|
|
156
|
+
immediate: true,
|
|
157
|
+
handler(n) {
|
|
158
|
+
if (this.headerSortables.length === n.length) {
|
|
159
|
+
n.forEach((th, idx) => {
|
|
160
|
+
if (this.headerSortables[idx].enabled !== !!th.sortable) {
|
|
161
|
+
this.headerSortables[idx].enabled = !!th.sortable;
|
|
162
|
+
this.headerSortables[idx].mode = "";
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
} else {
|
|
166
|
+
this.headerSortables = n.map((th) => {
|
|
167
|
+
if (typeof th === "string") {
|
|
168
|
+
return {
|
|
169
|
+
enabled: false,
|
|
170
|
+
mode: "",
|
|
171
|
+
};
|
|
172
|
+
} else {
|
|
173
|
+
return {
|
|
174
|
+
enabled: !!th.sortable,
|
|
175
|
+
mode: "",
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
},
|
|
131
182
|
},
|
|
132
183
|
|
|
133
184
|
updated() {
|
|
@@ -144,6 +195,25 @@ export default {
|
|
|
144
195
|
this.fakeCellWidth = d;
|
|
145
196
|
}
|
|
146
197
|
},
|
|
198
|
+
emitSortEvent(index) {
|
|
199
|
+
const emitValue = {
|
|
200
|
+
index,
|
|
201
|
+
label: this.tableHeaders[index].label,
|
|
202
|
+
mode: "",
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
this.headerSortables.forEach((hs, idx) => {
|
|
206
|
+
if (idx !== index) hs.mode = "";
|
|
207
|
+
else {
|
|
208
|
+
if (hs.mode === "asc") hs.mode = "desc";
|
|
209
|
+
else hs.mode = "asc";
|
|
210
|
+
|
|
211
|
+
emitValue.mode = hs.mode;
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
this.$emit("sort", emitValue);
|
|
216
|
+
},
|
|
147
217
|
},
|
|
148
218
|
};
|
|
149
219
|
</script>
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<button
|
|
3
|
+
class="button ac-button is-extra-small"
|
|
4
|
+
:class="`${modifierClasses}${isLoaderActive ? ' is-loading' : ''}`"
|
|
5
|
+
:disabled="disabled ? true : null"
|
|
6
|
+
@click="handleClick"
|
|
7
|
+
>
|
|
8
|
+
<span v-if="iconClass || iconImage" class="icon is-small">
|
|
9
|
+
<img
|
|
10
|
+
v-if="iconImage"
|
|
11
|
+
:src="iconImage"
|
|
12
|
+
alt="close-icon"
|
|
13
|
+
:width="iconImageWidth"
|
|
14
|
+
/>
|
|
15
|
+
<i v-else :class="`fa fa-${iconClass}`" aria-hidden="true" />
|
|
16
|
+
</span>
|
|
17
|
+
<span v-if="title" :class="titleModifierClass">{{ title }}</span>
|
|
18
|
+
<slot />
|
|
19
|
+
</button>
|
|
20
|
+
</template>
|
|
21
|
+
|
|
22
|
+
<script>
|
|
23
|
+
import { defineComponent } from "vue";
|
|
24
|
+
export default defineComponent({
|
|
25
|
+
props: {
|
|
26
|
+
// button title
|
|
27
|
+
title: {
|
|
28
|
+
type: String,
|
|
29
|
+
default: "",
|
|
30
|
+
},
|
|
31
|
+
// for loader
|
|
32
|
+
isLoaderActive: {
|
|
33
|
+
type: Boolean,
|
|
34
|
+
default: false,
|
|
35
|
+
},
|
|
36
|
+
// for disability
|
|
37
|
+
disabled: {
|
|
38
|
+
type: Boolean,
|
|
39
|
+
default: false,
|
|
40
|
+
},
|
|
41
|
+
// for icon
|
|
42
|
+
iconClass: {
|
|
43
|
+
type: String,
|
|
44
|
+
default: "",
|
|
45
|
+
},
|
|
46
|
+
iconImage: {
|
|
47
|
+
type: String,
|
|
48
|
+
default: "",
|
|
49
|
+
},
|
|
50
|
+
iconImageWidth: {
|
|
51
|
+
type: Number,
|
|
52
|
+
default: undefined,
|
|
53
|
+
},
|
|
54
|
+
// modifier class
|
|
55
|
+
modifierClasses: {
|
|
56
|
+
type: String,
|
|
57
|
+
default: "is-primary",
|
|
58
|
+
},
|
|
59
|
+
titleModifierClass: {
|
|
60
|
+
type: String,
|
|
61
|
+
default: "",
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
emits: ["click"],
|
|
66
|
+
|
|
67
|
+
methods: {
|
|
68
|
+
handleClick(e) {
|
|
69
|
+
if (!this.disabled) this.$emit("click", e);
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
</script>
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="ac-content-header" :class="{ 'b-b-1': !removeBorderBottom }">
|
|
3
|
+
<!-- header left start -->
|
|
4
|
+
<div class="ac-cheader-left">
|
|
5
|
+
<!-- title -->
|
|
6
|
+
<div class="ac-content-title">
|
|
7
|
+
<h6>
|
|
8
|
+
<slot name="header-icon" />
|
|
9
|
+
{{ headerTitle }}
|
|
10
|
+
</h6>
|
|
11
|
+
<p v-if="headerSubTitle">{{ headerSubTitle }}</p>
|
|
12
|
+
</div>
|
|
13
|
+
<!-- title -->
|
|
14
|
+
</div>
|
|
15
|
+
<!-- header left end -->
|
|
16
|
+
|
|
17
|
+
<!-- header right start -->
|
|
18
|
+
<div class="ac-cheader-right">
|
|
19
|
+
<!-- your feedom content start here -->
|
|
20
|
+
<header-items>
|
|
21
|
+
<slot />
|
|
22
|
+
</header-items>
|
|
23
|
+
<!-- your feedom content end here -->
|
|
24
|
+
</div>
|
|
25
|
+
<!-- header right end -->
|
|
26
|
+
</div>
|
|
27
|
+
</template>
|
|
28
|
+
|
|
29
|
+
<script>
|
|
30
|
+
import { defineComponent, defineAsyncComponent } from "vue";
|
|
31
|
+
|
|
32
|
+
export default defineComponent({
|
|
33
|
+
props: {
|
|
34
|
+
headerTitle: {
|
|
35
|
+
type: String,
|
|
36
|
+
default: "Content Header",
|
|
37
|
+
},
|
|
38
|
+
headerSubTitle: {
|
|
39
|
+
type: String,
|
|
40
|
+
default: "",
|
|
41
|
+
},
|
|
42
|
+
removeBorderBottom: {
|
|
43
|
+
type: Boolean,
|
|
44
|
+
default: false,
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
components: {
|
|
49
|
+
HeaderItems: defineAsyncComponent(() =>
|
|
50
|
+
import("../../v2/header/HeaderItems.vue").then((module) => module.default)
|
|
51
|
+
),
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
</script>
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<content-layout>
|
|
3
|
+
<template #content-header>
|
|
4
|
+
<content-header
|
|
5
|
+
:header-title="tableTitle"
|
|
6
|
+
:header-sub-title="tableSubTitle"
|
|
7
|
+
:class="{ 'pl-0 pr-0': removeTableHeaderPadding }"
|
|
8
|
+
>
|
|
9
|
+
<slot name="content-left-controls" />
|
|
10
|
+
<header-item>
|
|
11
|
+
<search-bar v-if="searchable" @search="searchText = $event" />
|
|
12
|
+
</header-item>
|
|
13
|
+
<slot name="content-right-controls" />
|
|
14
|
+
</content-header>
|
|
15
|
+
</template>
|
|
16
|
+
<slot name="content" :search-text="searchText" />
|
|
17
|
+
</content-layout>
|
|
18
|
+
</template>
|
|
19
|
+
|
|
20
|
+
<script>
|
|
21
|
+
import { defineComponent, defineAsyncComponent } from "vue";
|
|
22
|
+
|
|
23
|
+
export default defineComponent({
|
|
24
|
+
props: {
|
|
25
|
+
removeTableHeaderPadding: {
|
|
26
|
+
type: Boolean,
|
|
27
|
+
default: false,
|
|
28
|
+
},
|
|
29
|
+
tableTitle: {
|
|
30
|
+
type: String,
|
|
31
|
+
default: "Table",
|
|
32
|
+
},
|
|
33
|
+
tableSubTitle: {
|
|
34
|
+
type: String,
|
|
35
|
+
default: "",
|
|
36
|
+
},
|
|
37
|
+
searchable: {
|
|
38
|
+
type: Boolean,
|
|
39
|
+
default: true,
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
components: {
|
|
43
|
+
ContentLayout: defineAsyncComponent(() =>
|
|
44
|
+
import("../../v2/content/ContentLayout.vue").then(
|
|
45
|
+
(module) => module.default
|
|
46
|
+
)
|
|
47
|
+
),
|
|
48
|
+
ContentHeader: defineAsyncComponent(() =>
|
|
49
|
+
import("./ContentHeader.vue").then((module) => module.default)
|
|
50
|
+
),
|
|
51
|
+
HeaderItem: defineAsyncComponent(() =>
|
|
52
|
+
import("../../v2/header/HeaderItem.vue").then((module) => module.default)
|
|
53
|
+
),
|
|
54
|
+
SearchBar: defineAsyncComponent(() =>
|
|
55
|
+
import("../searchbars/SearchBar.vue").then((module) => module.default)
|
|
56
|
+
),
|
|
57
|
+
},
|
|
58
|
+
|
|
59
|
+
data() {
|
|
60
|
+
return {
|
|
61
|
+
searchText: "",
|
|
62
|
+
};
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
</script>
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
ref="dropdown"
|
|
4
|
+
class="dropdown"
|
|
5
|
+
:class="{
|
|
6
|
+
'is-active': isDropdownActive,
|
|
7
|
+
'dropdown-show-animation': dropdownShowAnimation,
|
|
8
|
+
'dropdown-hide-animation': dropdownHideAnimation,
|
|
9
|
+
}"
|
|
10
|
+
>
|
|
11
|
+
<div class="dropdown-trigger">
|
|
12
|
+
<slot name="dropdown-trigger" />
|
|
13
|
+
</div>
|
|
14
|
+
<div id="dropdown-menu" class="dropdown-menu" role="menu">
|
|
15
|
+
<div class="dropdown-content">
|
|
16
|
+
<slot />
|
|
17
|
+
</div>
|
|
18
|
+
</div>
|
|
19
|
+
</div>
|
|
20
|
+
</template>
|
|
21
|
+
|
|
22
|
+
<script lang="ts">
|
|
23
|
+
//@ts-ignore
|
|
24
|
+
import { defineComponent, onUnmounted, Ref, ref, toRefs, watch } from "vue";
|
|
25
|
+
|
|
26
|
+
export default defineComponent({
|
|
27
|
+
props: {
|
|
28
|
+
isActive: {
|
|
29
|
+
type: Boolean,
|
|
30
|
+
default: false,
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
emits: ["update:is-active"],
|
|
34
|
+
|
|
35
|
+
setup(props, { emit }) {
|
|
36
|
+
const { isActive } = toRefs(props);
|
|
37
|
+
watch(isActive, (n) => {
|
|
38
|
+
if (ignoreClick.value) {
|
|
39
|
+
// ignore new value
|
|
40
|
+
// emit old value
|
|
41
|
+
emit("update:is-active", isDropdownActive.value);
|
|
42
|
+
} else {
|
|
43
|
+
if (n) {
|
|
44
|
+
animateDropdown("show");
|
|
45
|
+
isDropdownActive.value = true;
|
|
46
|
+
} else {
|
|
47
|
+
animateDropdown("hide");
|
|
48
|
+
setTimeout(() => {
|
|
49
|
+
isDropdownActive.value = false;
|
|
50
|
+
}, 200);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const dropdown: Ref<HTMLElement | null> = ref(null);
|
|
56
|
+
const isDropdownActive = ref(isActive.value);
|
|
57
|
+
|
|
58
|
+
// attach click event listener on window, and close the dropdown
|
|
59
|
+
function deactivateDropdown(e: Event) {
|
|
60
|
+
e.preventDefault();
|
|
61
|
+
const { target } = e;
|
|
62
|
+
if (
|
|
63
|
+
dropdown.value &&
|
|
64
|
+
dropdown.value !== target &&
|
|
65
|
+
!dropdown.value.contains(target as Node)
|
|
66
|
+
) {
|
|
67
|
+
if (!ignoreClick.value) {
|
|
68
|
+
animateDropdown("hide");
|
|
69
|
+
setTimeout(() => {
|
|
70
|
+
isDropdownActive.value = false;
|
|
71
|
+
emit("update:is-active", false);
|
|
72
|
+
}, 200);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
window.addEventListener("click", deactivateDropdown);
|
|
77
|
+
onUnmounted(() => {
|
|
78
|
+
window.removeEventListener("click", deactivateDropdown);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
// for animation
|
|
82
|
+
const dropdownShowAnimation = ref(false);
|
|
83
|
+
const dropdownHideAnimation = ref(false);
|
|
84
|
+
const ignoreClick = ref(false);
|
|
85
|
+
function animateDropdown(type: string) {
|
|
86
|
+
ignoreClick.value = true;
|
|
87
|
+
if (type === "show") {
|
|
88
|
+
dropdownShowAnimation.value = true;
|
|
89
|
+
// remove class after 200 miliseconds
|
|
90
|
+
setTimeout(() => {
|
|
91
|
+
dropdownShowAnimation.value = false;
|
|
92
|
+
ignoreClick.value = false;
|
|
93
|
+
}, 200);
|
|
94
|
+
} else {
|
|
95
|
+
dropdownHideAnimation.value = true;
|
|
96
|
+
setTimeout(() => {
|
|
97
|
+
dropdownHideAnimation.value = false;
|
|
98
|
+
ignoreClick.value = false;
|
|
99
|
+
}, 200);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return {
|
|
104
|
+
dropdown,
|
|
105
|
+
isDropdownActive,
|
|
106
|
+
dropdownShowAnimation,
|
|
107
|
+
dropdownHideAnimation,
|
|
108
|
+
};
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
</script>
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<editor-tabs
|
|
4
|
+
v-if="!readOnly"
|
|
5
|
+
@tabchange="activeTab = $event"
|
|
6
|
+
:active-tab="activeTab"
|
|
7
|
+
/>
|
|
8
|
+
<monaco-editor
|
|
9
|
+
v-if="activeTab === 'edit'"
|
|
10
|
+
ref="monacoEditor"
|
|
11
|
+
@editorDidMount="onEditorMount"
|
|
12
|
+
key="edit"
|
|
13
|
+
:class="`vh-${editorHeight} is-clipped`"
|
|
14
|
+
:value="editorContent"
|
|
15
|
+
@change="onChange"
|
|
16
|
+
:language="language"
|
|
17
|
+
:options="{
|
|
18
|
+
minimap: {
|
|
19
|
+
enabled: calcShowMinimap,
|
|
20
|
+
},
|
|
21
|
+
readOnly: readOnly,
|
|
22
|
+
scrollBeyondLastLine: false,
|
|
23
|
+
}"
|
|
24
|
+
/>
|
|
25
|
+
<monaco-editor
|
|
26
|
+
v-if="activeTab === 'preview'"
|
|
27
|
+
key="preview"
|
|
28
|
+
:class="`vh-${editorHeight} is-clipped`"
|
|
29
|
+
:value="editorContent"
|
|
30
|
+
:language="language"
|
|
31
|
+
:options="{
|
|
32
|
+
minimap: {
|
|
33
|
+
enabled: calcShowMinimap,
|
|
34
|
+
},
|
|
35
|
+
readOnly: true,
|
|
36
|
+
scrollBeyondLastLine: false,
|
|
37
|
+
}"
|
|
38
|
+
:original="originalEditorContent"
|
|
39
|
+
:diff-editor="true"
|
|
40
|
+
/>
|
|
41
|
+
</div>
|
|
42
|
+
</template>
|
|
43
|
+
|
|
44
|
+
<script>
|
|
45
|
+
import { defineComponent, defineAsyncComponent, h } from "vue";
|
|
46
|
+
export default defineComponent({
|
|
47
|
+
props: {
|
|
48
|
+
value: {
|
|
49
|
+
type: String,
|
|
50
|
+
default: "",
|
|
51
|
+
},
|
|
52
|
+
originalValue: {
|
|
53
|
+
type: String,
|
|
54
|
+
default: "",
|
|
55
|
+
},
|
|
56
|
+
readOnly: {
|
|
57
|
+
type: Boolean,
|
|
58
|
+
default: false,
|
|
59
|
+
},
|
|
60
|
+
language: {
|
|
61
|
+
type: String,
|
|
62
|
+
default: "yaml",
|
|
63
|
+
},
|
|
64
|
+
showMinimap: {
|
|
65
|
+
type: Boolean,
|
|
66
|
+
default: true,
|
|
67
|
+
},
|
|
68
|
+
editorHeight: {
|
|
69
|
+
type: Number,
|
|
70
|
+
default: 40,
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
|
|
74
|
+
emits: ["update:modelValue"],
|
|
75
|
+
|
|
76
|
+
components: {
|
|
77
|
+
EditorTabs: defineAsyncComponent(() =>
|
|
78
|
+
import("../tabs/EditorTabs.vue").then((module) => module.default)
|
|
79
|
+
),
|
|
80
|
+
MonacoEditor: defineAsyncComponent(() =>
|
|
81
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
82
|
+
// @ts-ignore
|
|
83
|
+
import("vue-monaco").then((module) => {
|
|
84
|
+
module.default.render = () => h("div");
|
|
85
|
+
return module.default;
|
|
86
|
+
})
|
|
87
|
+
),
|
|
88
|
+
},
|
|
89
|
+
|
|
90
|
+
data() {
|
|
91
|
+
return {
|
|
92
|
+
activeTab: "edit",
|
|
93
|
+
editorContent: "",
|
|
94
|
+
originalEditorContent: "",
|
|
95
|
+
};
|
|
96
|
+
},
|
|
97
|
+
|
|
98
|
+
computed: {
|
|
99
|
+
calcShowMinimap() {
|
|
100
|
+
const noOfLines = this.editorContent.split("\n").length;
|
|
101
|
+
return this.showMinimap && noOfLines * 2 > this.editorHeight;
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
|
|
105
|
+
watch: {
|
|
106
|
+
value: {
|
|
107
|
+
immediate: true,
|
|
108
|
+
handler(n) {
|
|
109
|
+
if (this.editorContent !== n) {
|
|
110
|
+
this.editorContent = n;
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
originalValue: {
|
|
115
|
+
immediate: true,
|
|
116
|
+
handler(n) {
|
|
117
|
+
if (this.originalEditorContent !== n) {
|
|
118
|
+
this.originalEditorContent = n;
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
|
|
124
|
+
methods: {
|
|
125
|
+
onChange(e) {
|
|
126
|
+
if (typeof e === "string") this.editorContent = e;
|
|
127
|
+
},
|
|
128
|
+
onEditorMount() {
|
|
129
|
+
const editor = this.$refs.monacoEditor.getEditor();
|
|
130
|
+
// add event listeners
|
|
131
|
+
editor.onDidBlurEditorText(() => {
|
|
132
|
+
this.$emit("update:modelValue", this.editorContent);
|
|
133
|
+
});
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
});
|
|
137
|
+
</script>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<input class="ac-input" v-bind="inputListeners" />
|
|
3
|
+
</template>
|
|
4
|
+
|
|
5
|
+
<script>
|
|
6
|
+
import { defineComponent } from "vue";
|
|
7
|
+
|
|
8
|
+
export default defineComponent({
|
|
9
|
+
inheritAttrs: false,
|
|
10
|
+
emits: ["update:modelValue"],
|
|
11
|
+
computed: {
|
|
12
|
+
inputListeners() {
|
|
13
|
+
return Object.assign({}, this.$attrs, {
|
|
14
|
+
onInput: (event) => {
|
|
15
|
+
this.$emit("update:modelValue", event.target.value);
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
</script>
|