@abi-software/map-utilities 0.0.0-beta.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.
@@ -0,0 +1,345 @@
1
+ <template>
2
+ <div>
3
+ <el-row v-if="title">
4
+ <el-col :span="12">
5
+ <div class="title-text">
6
+ {{ title }}
7
+ </div>
8
+ </el-col>
9
+ </el-row>
10
+ <div class="tree-container">
11
+ <el-tree
12
+ ref="regionTree"
13
+ v-loading="!isReady"
14
+ element-loading-background="rgba(0, 0, 0, 0.3)"
15
+ show-checkbox
16
+ :node-key="nodeKey"
17
+ :data="treeData"
18
+ :check-strictly="false"
19
+ :expand-on-click-node="false"
20
+ :render-after-expand="false"
21
+ :default-expanded-keys="expandedKeys"
22
+ @check="checkChanged"
23
+ >
24
+ <template #default="{ node, data }">
25
+ <span
26
+ v-if="mapType === 'flatmap'"
27
+ class="region-tree-node"
28
+ :class="{
29
+ activeItem: nodeIsActive(data),
30
+ hoverItem: nodeIsHover(data),
31
+ }"
32
+ @click="changeActiveByNode(data)"
33
+ @mouseover="changeHoverByNode(data)"
34
+ >
35
+ <div :style="getBackgroundStyles(data)">
36
+ {{ node.label }}
37
+ </div>
38
+ </span>
39
+ <span
40
+ v-else-if="mapType === 'scaffold'"
41
+ class="region-tree-node"
42
+ :class="{
43
+ activeItem: active.includes(data.id),
44
+ hoverItem: hover.includes(data.id),
45
+ }"
46
+ @click="changeActiveByNode(data, true)"
47
+ @mouseover="changeHoverByNode(data, true)"
48
+ >
49
+ <el-color-picker
50
+ v-if="data.isPrimitives"
51
+ :class="{ 'show-picker': showColourPicker }"
52
+ v-model="data.activeColour"
53
+ size="small"
54
+ :popper-class="myPopperClass"
55
+ @change="setColour(data, $event)"
56
+ />
57
+ <span>{{ node.label }}</span>
58
+ <span v-if="data.isTextureSlides" class="node-options">
59
+ (Texture)
60
+ </span>
61
+ </span>
62
+ </template>
63
+ </el-tree>
64
+ </div>
65
+ </div>
66
+ </template>
67
+
68
+ <script>
69
+ export default {
70
+ name: "TreeControls",
71
+ props: {
72
+ /**
73
+ * The type of map that the TreeControls is used. Either "flatmap" or "scaffold".
74
+ */
75
+ mapType: {
76
+ type: String,
77
+ required: true,
78
+ },
79
+ isReady: {
80
+ type: Boolean,
81
+ default: true,
82
+ },
83
+ /**
84
+ * The title of the TreeControls.
85
+ */
86
+ title: {
87
+ type: String,
88
+ },
89
+ /**
90
+ * The data of the tree.
91
+ */
92
+ treeData: {
93
+ type: Array,
94
+ default: function () {
95
+ return [];
96
+ },
97
+ },
98
+ showColourPicker: {
99
+ type: Boolean,
100
+ default: false,
101
+ },
102
+ /**
103
+ * The active node of the tree.
104
+ */
105
+ active: {
106
+ type: [String, Array],
107
+ required: true,
108
+ },
109
+ /**
110
+ * The hover node of the tree.
111
+ */
112
+ hover: {
113
+ type: [String, Array],
114
+ required: true,
115
+ },
116
+ },
117
+ data: function () {
118
+ return {
119
+ defaultExpandedKeys: ["All"],
120
+ myPopperClass: "hide-scaffold-colour-popup",
121
+ };
122
+ },
123
+ computed: {
124
+ isFlatmap: function () {
125
+ return this.mapType === "flatmap";
126
+ },
127
+ isScaffold: function () {
128
+ return this.mapType === "scaffold";
129
+ },
130
+ nodeKey: function () {
131
+ if (this.isFlatmap) {
132
+ return "key";
133
+ } else if (this.isScaffold) {
134
+ return "id";
135
+ }
136
+ },
137
+ expandedKeys: function () {
138
+ if (this.isFlatmap) {
139
+ return this.defaultExpandedKeys;
140
+ } else if (this.isScaffold) {
141
+ return [];
142
+ }
143
+ },
144
+ },
145
+ watch: {
146
+ showColourPicker: {
147
+ immediate: true,
148
+ handler: function () {
149
+ if (this.showColourPicker) this.myPopperClass = "showPicker";
150
+ else this.myPopperClass = "hide-scaffold-colour-popup";
151
+ },
152
+ },
153
+ },
154
+ methods: {
155
+ setColour: function (nodeData, value) {
156
+ this.$emit("setColour", nodeData, value);
157
+ },
158
+ getBackgroundStyles: function (node) {
159
+ if ("colour" in node) {
160
+ return { background: node.colour };
161
+ }
162
+ return {};
163
+ },
164
+ nodeIsActive: function (data) {
165
+ return this.active === data.models;
166
+ },
167
+ nodeIsHover: function (data) {
168
+ return this.hover === data.models;
169
+ },
170
+ changeActiveByNode: function (data, propagate = false) {
171
+ if (this.isFlatmap) {
172
+ if (data.models) {
173
+ this.$emit("changeActive", data.models);
174
+ }
175
+ } else if (this.isScaffold) {
176
+ if (data.isPrimitives || data.isRegion) {
177
+ this.$emit("changeActive", data, propagate);
178
+ }
179
+ }
180
+ },
181
+ changeHoverByNode: function (data, propagate = false) {
182
+ if (this.isFlatmap) {
183
+ if (data.models) {
184
+ this.$emit("changeHover", data.models);
185
+ }
186
+ } else if (this.isScaffold) {
187
+ if (data.isPrimitives) {
188
+ this.$emit("changeHover", data, propagate);
189
+ }
190
+ }
191
+ },
192
+ checkChanged: function (node, data) {
193
+ if (this.isFlatmap) {
194
+ const isChecked = data.checkedKeys.includes(node.key);
195
+ if (node.key === "All") {
196
+ this.$emit("checkAll", isChecked);
197
+ } else {
198
+ this.$emit("checkChanged", { key: node.key, value: isChecked });
199
+ }
200
+ } else if (this.isScaffold) {
201
+ this.$emit("checkChanged", node, data);
202
+ }
203
+ },
204
+ },
205
+ unmounted: function () {
206
+ this.sortedPrimitiveGroups = undefined;
207
+ },
208
+ };
209
+ </script>
210
+
211
+ <style lang="scss" scoped>
212
+ :deep(.el-loading-spinner) {
213
+ .path {
214
+ stroke: $app-primary-color;
215
+ }
216
+
217
+ .el-loading-text {
218
+ color: $app-primary-color;
219
+ }
220
+ }
221
+
222
+ .title-text {
223
+ width: 59px;
224
+ height: 20px;
225
+ color: rgb(48, 49, 51);
226
+ font-size: 14px;
227
+ font-weight: normal;
228
+ line-height: 20px;
229
+ margin-left: 8px;
230
+ }
231
+
232
+ .tree-container {
233
+ width: 260px;
234
+ border: 1px solid rgb(144, 147, 153);
235
+ border-radius: 4px;
236
+ background: #ffffff;
237
+ margin-top: 6px;
238
+ scrollbar-width: thin;
239
+
240
+ :deep(.el-tree) {
241
+ max-height: 240px;
242
+ min-height: 130px;
243
+ overflow: auto;
244
+
245
+ &::-webkit-scrollbar {
246
+ width: 4px;
247
+ }
248
+
249
+ &::-webkit-scrollbar-thumb {
250
+ border-radius: 10px;
251
+ box-shadow: inset 0 0 6px #c0c4cc;
252
+ }
253
+ }
254
+
255
+ :deep(.el-tree-node__content) {
256
+ height: 22px;
257
+ }
258
+ }
259
+
260
+ :deep(.el-checkbox__input) {
261
+ &.is-indeterminate,
262
+ &.is-checked {
263
+ .el-checkbox__inner {
264
+ background-color: $app-primary-color;
265
+ border-color: $app-primary-color;
266
+ }
267
+ }
268
+ }
269
+
270
+ :deep(
271
+ .el-tree-node__children
272
+ .el-tree-node__children
273
+ .el-tree-node__content
274
+ > label.el-checkbox
275
+ ) {
276
+ display: none;
277
+ }
278
+
279
+ :deep(.el-checkbox__label) {
280
+ padding-left: 5px;
281
+ color: $app-primary-color !important;
282
+ font-size: 12px;
283
+ font-weight: 500;
284
+ letter-spacing: 0px;
285
+ line-height: 14px;
286
+ }
287
+
288
+ .activeItem {
289
+ background-color: #bbb !important;
290
+ }
291
+
292
+ .hoverItem {
293
+ background-color: #eee !important;
294
+ }
295
+
296
+ .region-tree-node {
297
+ flex: 1;
298
+ color: $app-primary-color !important;
299
+ display: flex;
300
+ font-size: 12px;
301
+ line-height: 14px;
302
+ padding-left: 0px;
303
+ background-color: #fff;
304
+ width: 100%;
305
+
306
+ :deep(.el-color-picker) {
307
+ height: 14px !important;
308
+ }
309
+
310
+ :deep(.el-color-picker__trigger) {
311
+ margin-left: 8px;
312
+ margin-right: 8px;
313
+ padding: 0px;
314
+ height: 14px;
315
+ width: 14px;
316
+ border: 0px;
317
+ }
318
+ }
319
+
320
+ :deep(.el-color-picker__color) {
321
+ border: 1px solid $app-primary-color;
322
+ }
323
+
324
+ :deep(.el-color-picker__icon) {
325
+ &.el-icon-arrow-down {
326
+ display: none;
327
+ }
328
+ }
329
+
330
+ :deep(.show-picker) {
331
+ .el-color-picker__icon {
332
+ &.el-icon-arrow-down {
333
+ display: block;
334
+ }
335
+ }
336
+ }
337
+
338
+ .hide-scaffold-colour-popup {
339
+ display: none;
340
+ }
341
+
342
+ .node-options {
343
+ text-align: right;
344
+ }
345
+ </style>
@@ -0,0 +1,6 @@
1
+ import DrawToolbar from "./DrawToolbar/DrawToolbar.vue";
2
+ import HelpModeDialog from "./HelpModeDialog/HelpModeDialog.vue";
3
+ import Tooltip from "./Tooltip/Tooltip.vue";
4
+ import TreeControls from "./TreeControls/TreeControls.vue";
5
+
6
+ export { DrawToolbar, HelpModeDialog, Tooltip, TreeControls };
@@ -0,0 +1,42 @@
1
+ /* eslint-disable */
2
+ // @ts-nocheck
3
+ // Generated by unplugin-vue-components
4
+ // Read more: https://github.com/vuejs/core/pull/3399
5
+ export {}
6
+
7
+ /* prettier-ignore */
8
+ declare module 'vue' {
9
+ export interface GlobalComponents {
10
+ AnnotationPopup: typeof import('./components/Tooltip/AnnotationPopup.vue')['default']
11
+ ConnectionDialog: typeof import('./components/DrawToolbar/ConnectionDialog.vue')['default']
12
+ DrawToolbar: typeof import('./components/DrawToolbar/DrawToolbar.vue')['default']
13
+ ElButton: typeof import('element-plus/es')['ElButton']
14
+ ElButtonGroup: typeof import('element-plus/es')['ElButtonGroup']
15
+ ElCard: typeof import('element-plus/es')['ElCard']
16
+ ElCol: typeof import('element-plus/es')['ElCol']
17
+ ElColorPicker: typeof import('element-plus/es')['ElColorPicker']
18
+ ElIcon: typeof import('element-plus/es')['ElIcon']
19
+ ElIconArrowDown: typeof import('@element-plus/icons-vue')['ArrowDown']
20
+ ElIconArrowUp: typeof import('@element-plus/icons-vue')['ArrowUp']
21
+ ElIconClose: typeof import('@element-plus/icons-vue')['Close']
22
+ ElIconDelete: typeof import('@element-plus/icons-vue')['Delete']
23
+ ElIconEdit: typeof import('@element-plus/icons-vue')['Edit']
24
+ ElIconFinished: typeof import('@element-plus/icons-vue')['Finished']
25
+ ElIconWarning: typeof import('@element-plus/icons-vue')['Warning']
26
+ ElInput: typeof import('element-plus/es')['ElInput']
27
+ ElMain: typeof import('element-plus/es')['ElMain']
28
+ ElOption: typeof import('element-plus/es')['ElOption']
29
+ ElPopover: typeof import('element-plus/es')['ElPopover']
30
+ ElRow: typeof import('element-plus/es')['ElRow']
31
+ ElSelect: typeof import('element-plus/es')['ElSelect']
32
+ ElTree: typeof import('element-plus/es')['ElTree']
33
+ ExternalResourceCard: typeof import('./components/Tooltip/ExternalResourceCard.vue')['default']
34
+ HelpModeDialog: typeof import('./components/HelpModeDialog/HelpModeDialog.vue')['default']
35
+ ProvenancePopup: typeof import('./components/Tooltip/ProvenancePopup.vue')['default']
36
+ Tooltip: typeof import('./components/Tooltip/Tooltip.vue')['default']
37
+ TreeControls: typeof import('./components/TreeControls/TreeControls.vue')['default']
38
+ }
39
+ export interface ComponentCustomProperties {
40
+ vLoading: typeof import('element-plus/es')['ElLoadingDirective']
41
+ }
42
+ }
package/src/main.js ADDED
@@ -0,0 +1,5 @@
1
+ import { createApp } from "vue";
2
+ import App from "./App.vue";
3
+
4
+ const app = createApp(App);
5
+ app.mount("#app");