@ditojs/admin 2.7.4 → 2.8.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/dist/dito-admin.es.js +1769 -1705
- package/dist/dito-admin.umd.js +5 -5
- package/dist/style.css +1 -1
- package/package.json +5 -5
- package/src/DitoContext.js +4 -0
- package/src/DitoTypeComponent.js +1 -1
- package/src/components/DitoClipboard.vue +22 -0
- package/src/components/DitoContainer.vue +7 -12
- package/src/components/DitoCreateButton.vue +26 -11
- package/src/components/DitoDialog.vue +14 -3
- package/src/components/DitoEditButtons.vue +20 -9
- package/src/components/DitoForm.vue +17 -12
- package/src/components/DitoHeader.vue +22 -6
- package/src/components/DitoLabel.vue +39 -22
- package/src/components/DitoPane.vue +43 -35
- package/src/components/DitoRoot.vue +1 -2
- package/src/components/DitoSchema.vue +137 -165
- package/src/components/DitoSchemaInlined.vue +17 -13
- package/src/components/DitoTabs.vue +65 -23
- package/src/components/DitoTreeItem.vue +1 -1
- package/src/components/DitoView.vue +0 -1
- package/src/mixins/DitoMixin.js +8 -7
- package/src/mixins/ItemMixin.js +5 -1
- package/src/mixins/TypeMixin.js +5 -0
- package/src/styles/_button.scss +13 -12
- package/src/styles/_settings.scss +2 -2
- package/src/types/DitoTypeList.vue +12 -9
- package/src/types/DitoTypeMultiselect.vue +3 -4
- package/src/types/DitoTypeObject.vue +9 -6
- package/src/types/DitoTypePanel.vue +1 -1
- package/src/types/DitoTypeSection.vue +38 -10
- package/src/types/DitoTypeSelect.vue +3 -2
- package/src/types/DitoTypeUpload.vue +2 -2
- package/src/utils/options.js +1 -1
- package/src/utils/schema.js +8 -6
- package/types/index.d.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ditojs/admin",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.8.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Dito.js Admin is a schema based admin interface for Dito.js Server, featuring auto-generated views and forms and built with Vue.js",
|
|
6
6
|
"repository": "https://github.com/ditojs/dito/tree/master/packages/admin",
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"not ie_mob > 0"
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@ditojs/ui": "^2.
|
|
37
|
-
"@ditojs/utils": "^2.
|
|
36
|
+
"@ditojs/ui": "^2.8.0",
|
|
37
|
+
"@ditojs/utils": "^2.8.0",
|
|
38
38
|
"@kyvg/vue3-notification": "^2.9.0",
|
|
39
39
|
"@lk77/vue3-color": "^3.0.6",
|
|
40
40
|
"@tiptap/core": "^2.0.3",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"vue-upload-component": "^3.1.8"
|
|
75
75
|
},
|
|
76
76
|
"devDependencies": {
|
|
77
|
-
"@ditojs/build": "^2.
|
|
77
|
+
"@ditojs/build": "^2.8.0",
|
|
78
78
|
"@vitejs/plugin-vue": "^4.2.1",
|
|
79
79
|
"@vue/compiler-sfc": "^3.2.47",
|
|
80
80
|
"pug": "^3.0.2",
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
"vite": "^4.3.5"
|
|
84
84
|
},
|
|
85
85
|
"types": "types",
|
|
86
|
-
"gitHead": "
|
|
86
|
+
"gitHead": "6f589b645e8841b1875330d9918a7d952af49b31",
|
|
87
87
|
"scripts": {
|
|
88
88
|
"build": "vite build",
|
|
89
89
|
"watch": "yarn build --mode 'development' --watch",
|
package/src/DitoContext.js
CHANGED
|
@@ -216,6 +216,10 @@ export default class DitoContext {
|
|
|
216
216
|
return get(this, 'options', undefined)
|
|
217
217
|
}
|
|
218
218
|
|
|
219
|
+
get open() {
|
|
220
|
+
return get(this, 'open', undefined)
|
|
221
|
+
}
|
|
222
|
+
|
|
219
223
|
// TODO: Rename this to `searchTerm` or `searchQuery`, to perhaps free `query`
|
|
220
224
|
// for the actual `resourceComponent.query` object?
|
|
221
225
|
get query() {
|
package/src/DitoTypeComponent.js
CHANGED
|
@@ -165,3 +165,25 @@ export default DitoComponent.component('DitoClipboard', {
|
|
|
165
165
|
}
|
|
166
166
|
})
|
|
167
167
|
</script>
|
|
168
|
+
|
|
169
|
+
<style lang="scss">
|
|
170
|
+
@import '../styles/_imports';
|
|
171
|
+
|
|
172
|
+
.dito-clipboard {
|
|
173
|
+
display: flex;
|
|
174
|
+
|
|
175
|
+
.dito-schema & {
|
|
176
|
+
// Push clipboard to the right in the flex layout, see:
|
|
177
|
+
// https://codepen.io/tholex/pen/hveBx/
|
|
178
|
+
margin-left: auto;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
.dito-header & {
|
|
182
|
+
margin-left: 0;
|
|
183
|
+
|
|
184
|
+
.dito-button {
|
|
185
|
+
margin: 0 0 $tab-margin $tab-margin;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
</style>
|
|
@@ -51,7 +51,7 @@ import {
|
|
|
51
51
|
getAllPanelEntries,
|
|
52
52
|
getTypeComponent,
|
|
53
53
|
hasLabel,
|
|
54
|
-
|
|
54
|
+
omitSpacing
|
|
55
55
|
} from '../utils/schema.js'
|
|
56
56
|
import { parseFraction } from '../utils/math.js'
|
|
57
57
|
|
|
@@ -73,8 +73,7 @@ export default DitoComponent.component('DitoContainer', {
|
|
|
73
73
|
|
|
74
74
|
data() {
|
|
75
75
|
return {
|
|
76
|
-
errors: null
|
|
77
|
-
isMounted: false
|
|
76
|
+
errors: null
|
|
78
77
|
}
|
|
79
78
|
},
|
|
80
79
|
|
|
@@ -184,7 +183,7 @@ export default DitoComponent.component('DitoContainer', {
|
|
|
184
183
|
'dito-disabled': this.componentDisabled,
|
|
185
184
|
'dito-has-errors': !!this.errors,
|
|
186
185
|
[`${prefix}--label-vertical`]: this.verticalLabels,
|
|
187
|
-
[`${prefix}--omit-
|
|
186
|
+
[`${prefix}--omit-spacing`]: omitSpacing(this.schema),
|
|
188
187
|
...(isString(classes) ? { [classes]: true } : classes)
|
|
189
188
|
}
|
|
190
189
|
},
|
|
@@ -228,10 +227,6 @@ export default DitoComponent.component('DitoContainer', {
|
|
|
228
227
|
}
|
|
229
228
|
},
|
|
230
229
|
|
|
231
|
-
mounted() {
|
|
232
|
-
this.isMounted = true
|
|
233
|
-
},
|
|
234
|
-
|
|
235
230
|
methods: {
|
|
236
231
|
onErrors(errors) {
|
|
237
232
|
this.errors = errors
|
|
@@ -258,7 +253,7 @@ export default DitoComponent.component('DitoContainer', {
|
|
|
258
253
|
max-width: 100%;
|
|
259
254
|
// Cannot use margin here as it needs to be part of box-sizing for
|
|
260
255
|
// percentages in flex-basis to work.
|
|
261
|
-
padding: $form-spacing
|
|
256
|
+
padding: $form-spacing-half;
|
|
262
257
|
|
|
263
258
|
.dito-page .dito-pane > & {
|
|
264
259
|
@container (width < #{calc($content-width * 0.8)}) {
|
|
@@ -300,15 +295,15 @@ export default DitoComponent.component('DitoContainer', {
|
|
|
300
295
|
// have labels, add some spacing to the top to align with the other
|
|
301
296
|
// components (e.g. buttons):
|
|
302
297
|
> .dito-component:first-child:not(.dito-section, .dito-list, .dito-object) {
|
|
303
|
-
margin-top: $
|
|
298
|
+
margin-top: $input-height;
|
|
304
299
|
}
|
|
305
300
|
}
|
|
306
301
|
|
|
307
|
-
&--omit-
|
|
302
|
+
&--omit-spacing {
|
|
308
303
|
padding: 0;
|
|
309
304
|
|
|
310
305
|
> .dito-label {
|
|
311
|
-
margin: $form-spacing $form-spacing-half 0;
|
|
306
|
+
margin: $form-spacing-half $form-spacing-half 0;
|
|
312
307
|
}
|
|
313
308
|
}
|
|
314
309
|
}
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
)
|
|
6
6
|
button.dito-button(
|
|
7
7
|
type="button"
|
|
8
|
-
:
|
|
9
|
-
|
|
8
|
+
:disabled="disabled"
|
|
9
|
+
v-bind="getButtonAttributes(verb)"
|
|
10
10
|
@mousedown.stop="onPulldownMouseDown()"
|
|
11
11
|
) {{ text }}
|
|
12
12
|
ul.dito-pulldown(:class="{ 'dito-open': pulldown.open }")
|
|
@@ -14,17 +14,17 @@
|
|
|
14
14
|
v-for="(form, type) in forms"
|
|
15
15
|
)
|
|
16
16
|
a(
|
|
17
|
-
v-if="
|
|
18
|
-
v-show="
|
|
17
|
+
v-if="isFormCreatable(form)"
|
|
18
|
+
v-show="shouldShowSchema(form)"
|
|
19
19
|
:class="getFormClass(form, type)"
|
|
20
20
|
@mousedown.stop="onPulldownMouseDown(type)"
|
|
21
21
|
@mouseup="onPulldownMouseUp(type)"
|
|
22
22
|
) {{ getLabel(form) }}
|
|
23
23
|
button.dito-button(
|
|
24
|
-
v-else
|
|
24
|
+
v-else-if="isFormCreatable(forms.default)"
|
|
25
25
|
:type="isInlined ? 'button' : 'submit'"
|
|
26
|
-
:
|
|
27
|
-
|
|
26
|
+
:disabled="disabled"
|
|
27
|
+
v-bind="getButtonAttributes(verb)"
|
|
28
28
|
@click="createItem(forms.default)"
|
|
29
29
|
) {{ text }}
|
|
30
30
|
</template>
|
|
@@ -40,9 +40,14 @@ export default DitoComponent.component('DitoCreateButton', {
|
|
|
40
40
|
|
|
41
41
|
props: {
|
|
42
42
|
schema: { type: Object, required: true },
|
|
43
|
+
dataPath: { type: String, required: true },
|
|
44
|
+
data: { type: [Object, Array], default: null },
|
|
45
|
+
meta: { type: Object, required: true },
|
|
46
|
+
store: { type: Object, required: true },
|
|
43
47
|
path: { type: String, required: true },
|
|
44
48
|
verb: { type: String, required: true },
|
|
45
|
-
text: { type: String, default: null }
|
|
49
|
+
text: { type: String, default: null },
|
|
50
|
+
disabled: { type: Boolean, required: true }
|
|
46
51
|
},
|
|
47
52
|
|
|
48
53
|
computed: {
|
|
@@ -55,13 +60,23 @@ export default DitoComponent.component('DitoCreateButton', {
|
|
|
55
60
|
},
|
|
56
61
|
|
|
57
62
|
showPulldown() {
|
|
58
|
-
|
|
63
|
+
const forms = Object.values(this.forms)
|
|
64
|
+
return (
|
|
65
|
+
(forms.length > 1 || !this.forms.default) &&
|
|
66
|
+
forms.some(this.isFormCreatable)
|
|
67
|
+
)
|
|
59
68
|
}
|
|
60
69
|
},
|
|
61
70
|
|
|
62
71
|
methods: {
|
|
72
|
+
isFormCreatable(form) {
|
|
73
|
+
// Forms can be excluded from the list by providing `if: false` or
|
|
74
|
+
// `creatable: false`.
|
|
75
|
+
return form.creatable !== false && this.shouldRenderSchema(form)
|
|
76
|
+
},
|
|
77
|
+
|
|
63
78
|
createItem(form, type = null) {
|
|
64
|
-
if (this.
|
|
79
|
+
if (this.isFormCreatable(form) && !this.shouldDisableSchema(form)) {
|
|
65
80
|
if (this.isInlined) {
|
|
66
81
|
this.sourceComponent.createItem(form, type)
|
|
67
82
|
} else {
|
|
@@ -78,7 +93,7 @@ export default DitoComponent.component('DitoCreateButton', {
|
|
|
78
93
|
getFormClass(form, type) {
|
|
79
94
|
return {
|
|
80
95
|
[`dito-type-${type}`]: true,
|
|
81
|
-
'dito-disabled': this.
|
|
96
|
+
'dito-disabled': this.shouldDisableSchema(form)
|
|
82
97
|
}
|
|
83
98
|
},
|
|
84
99
|
|
|
@@ -7,12 +7,15 @@
|
|
|
7
7
|
:style="{ '--width': `${settings.width}px` }"
|
|
8
8
|
@mouseup="onMouseUp"
|
|
9
9
|
)
|
|
10
|
-
UseFocusTrap.dito-dialog__focus-trap(
|
|
11
|
-
:options="{ immediate: true, fallbackFocus: () => $refs.dialog }"
|
|
12
|
-
)
|
|
10
|
+
UseFocusTrap.dito-dialog__focus-trap(:options="focusTrapOptions")
|
|
13
11
|
form.dito-scroll-parent(
|
|
14
12
|
@submit.prevent="submit"
|
|
15
13
|
)
|
|
14
|
+
// Add an invisible button that prevents the clearable buttons from being
|
|
15
|
+
// pressed when the user presses the Enter key:
|
|
16
|
+
button(
|
|
17
|
+
v-show="false"
|
|
18
|
+
)
|
|
16
19
|
DitoSchema(
|
|
17
20
|
:schema="schema"
|
|
18
21
|
:data="dialogData"
|
|
@@ -104,6 +107,14 @@ export default DitoComponent.component('DitoDialog', {
|
|
|
104
107
|
)
|
|
105
108
|
},
|
|
106
109
|
|
|
110
|
+
focusTrapOptions() {
|
|
111
|
+
return {
|
|
112
|
+
immediate: true,
|
|
113
|
+
fallbackFocus: () => this.$refs.dialog,
|
|
114
|
+
onDeactivate: this.cancel
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
|
|
107
118
|
hasButtons() {
|
|
108
119
|
return Object.keys(this.buttonSchemas).length > 0
|
|
109
120
|
},
|
|
@@ -11,25 +11,31 @@ DitoButtons.dito-edit-buttons.dito-buttons-round(
|
|
|
11
11
|
//- Firefox doesn't like <button> here, so use <a> instead:
|
|
12
12
|
a.dito-button(
|
|
13
13
|
v-if="hasDraggable"
|
|
14
|
+
:class="{ 'dito-disabled': disabled }"
|
|
14
15
|
v-bind="getButtonAttributes(verbs.drag)"
|
|
15
16
|
)
|
|
16
17
|
RouterLink.dito-button(
|
|
17
18
|
v-if="hasEditable"
|
|
18
|
-
:class="{ 'dito-disabled': !editPath }"
|
|
19
|
+
:class="{ 'dito-disabled': disabled || !editPath }"
|
|
19
20
|
:to="editPath ? { path: editPath } : {}"
|
|
20
21
|
v-bind="getButtonAttributes(verbs.edit)"
|
|
21
22
|
)
|
|
22
23
|
DitoCreateButton(
|
|
23
24
|
v-if="hasCreatable"
|
|
24
|
-
:class="{ 'dito-disabled': !createPath }"
|
|
25
25
|
:schema="schema"
|
|
26
|
+
:dataPath="dataPath"
|
|
27
|
+
:data="data"
|
|
28
|
+
:meta="meta"
|
|
29
|
+
:store="store"
|
|
26
30
|
:path="createPath"
|
|
27
31
|
:verb="verbs.create"
|
|
28
32
|
:text="createButtonText"
|
|
33
|
+
:disabled="disabled || !createPath"
|
|
29
34
|
)
|
|
30
35
|
button.dito-button(
|
|
31
36
|
v-if="hasDeletable"
|
|
32
37
|
type="button"
|
|
38
|
+
:disabled="disabled || !isFormDeletable"
|
|
33
39
|
v-bind="getButtonAttributes(verbs.delete)"
|
|
34
40
|
@click="$emit('delete')"
|
|
35
41
|
)
|
|
@@ -44,18 +50,19 @@ export default DitoComponent.component('DitoEditButtons', {
|
|
|
44
50
|
emits: ['delete'],
|
|
45
51
|
|
|
46
52
|
props: {
|
|
47
|
-
draggable: { type: Boolean, default: false },
|
|
48
|
-
editable: { type: Boolean, default: false },
|
|
49
|
-
creatable: { type: Boolean, default: false },
|
|
50
|
-
deletable: { type: Boolean, default: false },
|
|
51
|
-
editPath: { type: String, default: null },
|
|
52
|
-
createPath: { type: String, default: null },
|
|
53
53
|
buttons: { type: Object, default: null },
|
|
54
54
|
schema: { type: Object, required: true },
|
|
55
55
|
dataPath: { type: String, required: true },
|
|
56
56
|
data: { type: [Object, Array], default: null },
|
|
57
57
|
meta: { type: Object, required: true },
|
|
58
|
-
store: { type: Object, required: true }
|
|
58
|
+
store: { type: Object, required: true },
|
|
59
|
+
disabled: { type: Boolean, required: true },
|
|
60
|
+
draggable: { type: Boolean, default: false },
|
|
61
|
+
editable: { type: Boolean, default: false },
|
|
62
|
+
creatable: { type: Boolean, default: false },
|
|
63
|
+
deletable: { type: Boolean, default: false },
|
|
64
|
+
editPath: { type: String, default: null },
|
|
65
|
+
createPath: { type: String, default: null }
|
|
59
66
|
},
|
|
60
67
|
|
|
61
68
|
computed: {
|
|
@@ -79,6 +86,10 @@ export default DitoComponent.component('DitoEditButtons', {
|
|
|
79
86
|
return this.hasOption('deletable')
|
|
80
87
|
},
|
|
81
88
|
|
|
89
|
+
isFormDeletable() {
|
|
90
|
+
return this.schema.deletable !== false
|
|
91
|
+
},
|
|
92
|
+
|
|
82
93
|
createButtonText() {
|
|
83
94
|
return (
|
|
84
95
|
// Allow schema to override create button through creatable object:
|
|
@@ -12,11 +12,20 @@
|
|
|
12
12
|
v-show="!isActive"
|
|
13
13
|
)
|
|
14
14
|
//- Use a <div> for inlined forms, as we shouldn't nest actual <form> tags.
|
|
15
|
-
component
|
|
15
|
+
component(
|
|
16
16
|
v-show="isActive"
|
|
17
17
|
:is="isNestedRoute ? 'div' : 'form'"
|
|
18
|
+
:class="{ 'dito-scroll-parent': isRootForm }"
|
|
18
19
|
@submit.prevent
|
|
19
20
|
)
|
|
21
|
+
//- Prevent implicit submission of the form, for example when typing enter
|
|
22
|
+
//- in an input field.
|
|
23
|
+
//- https://stackoverflow.com/a/51507806
|
|
24
|
+
button(
|
|
25
|
+
v-show="false"
|
|
26
|
+
type="submit"
|
|
27
|
+
disabled
|
|
28
|
+
)
|
|
20
29
|
DitoSchema(
|
|
21
30
|
:schema="schema"
|
|
22
31
|
:dataPath="dataPath"
|
|
@@ -24,12 +33,12 @@
|
|
|
24
33
|
:meta="meta"
|
|
25
34
|
:store="store"
|
|
26
35
|
:disabled="isLoading"
|
|
27
|
-
:scrollable="
|
|
28
|
-
headerInMenu
|
|
36
|
+
:scrollable="isRootForm"
|
|
29
37
|
generateLabels
|
|
30
38
|
)
|
|
31
39
|
template(#buttons)
|
|
32
|
-
DitoButtons.dito-buttons-round.dito-buttons-
|
|
40
|
+
DitoButtons.dito-buttons-round.dito-buttons-large.dito-buttons-main(
|
|
41
|
+
:class="{ 'dito-buttons-sticky': isRootForm }"
|
|
33
42
|
:buttons="buttonSchemas"
|
|
34
43
|
:dataPath="dataPath"
|
|
35
44
|
:data="data"
|
|
@@ -37,14 +46,6 @@
|
|
|
37
46
|
:store="store"
|
|
38
47
|
:disabled="isLoading"
|
|
39
48
|
)
|
|
40
|
-
//- Prevent implicit submission of the form, for example when typing enter
|
|
41
|
-
//- in an input field.
|
|
42
|
-
//- https://stackoverflow.com/a/51507806
|
|
43
|
-
button(
|
|
44
|
-
v-show="false"
|
|
45
|
-
type="submit"
|
|
46
|
-
disabled
|
|
47
|
-
)
|
|
48
49
|
</template>
|
|
49
50
|
|
|
50
51
|
<script>
|
|
@@ -122,6 +123,10 @@ export default DitoComponent.component('DitoForm', {
|
|
|
122
123
|
)
|
|
123
124
|
},
|
|
124
125
|
|
|
126
|
+
isRootForm() {
|
|
127
|
+
return this.dataPath === '' && !this.isNestedRoute
|
|
128
|
+
},
|
|
129
|
+
|
|
125
130
|
isActive() {
|
|
126
131
|
return this.isLastRoute || this.isLastUnnestedRoute
|
|
127
132
|
},
|
|
@@ -85,13 +85,10 @@ export default DitoComponent.component('DitoHeader', {
|
|
|
85
85
|
@include user-select(none);
|
|
86
86
|
|
|
87
87
|
&::after {
|
|
88
|
-
//
|
|
89
|
-
// layout rounding imprecisions.
|
|
88
|
+
// Set the full-width header background to the header color.
|
|
90
89
|
content: '';
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
left: calc(100% - 1px);
|
|
94
|
-
width: 2px;
|
|
90
|
+
inset: 0;
|
|
91
|
+
width: 100vw;
|
|
95
92
|
position: absolute;
|
|
96
93
|
background: inherit;
|
|
97
94
|
z-index: -1;
|
|
@@ -175,5 +172,24 @@ export default DitoComponent.component('DitoHeader', {
|
|
|
175
172
|
border-radius: 100%;
|
|
176
173
|
}
|
|
177
174
|
}
|
|
175
|
+
|
|
176
|
+
&__teleport {
|
|
177
|
+
// Align the teleported schema headers on top of to the header menu.
|
|
178
|
+
position: absolute;
|
|
179
|
+
inset: 0;
|
|
180
|
+
display: flex;
|
|
181
|
+
justify-content: flex-end;
|
|
182
|
+
padding: 0 $header-padding-hor;
|
|
183
|
+
// Turn off pointer events so that DitoTrail keeps receiving events...
|
|
184
|
+
pointer-events: none;
|
|
185
|
+
// ...but move them to the children.
|
|
186
|
+
> * {
|
|
187
|
+
pointer-events: auto;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
.dito-button {
|
|
191
|
+
margin: 0 0 $tab-margin $tab-margin;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
178
194
|
}
|
|
179
195
|
</style>
|
|
@@ -7,20 +7,23 @@ component.dito-label(
|
|
|
7
7
|
)
|
|
8
8
|
.dito-chevron(
|
|
9
9
|
v-if="collapsible"
|
|
10
|
-
:class="{ 'dito-
|
|
10
|
+
:class="{ 'dito-open': !collapsed }"
|
|
11
11
|
)
|
|
12
|
-
.dito-label__inner
|
|
13
|
-
|
|
12
|
+
.dito-label__inner(
|
|
13
|
+
v-if="text || prefixes.length > 0 || suffixes.length > 0"
|
|
14
|
+
)
|
|
15
|
+
DitoElement.dito-label__prefix(
|
|
14
16
|
v-for="(prefix, index) of prefixes"
|
|
15
17
|
:key="`prefix-${index}`"
|
|
16
18
|
tag="span"
|
|
17
19
|
:content="prefix"
|
|
18
20
|
)
|
|
19
21
|
label(
|
|
22
|
+
v-if="text"
|
|
20
23
|
:for="dataPath"
|
|
21
24
|
v-html="text"
|
|
22
25
|
)
|
|
23
|
-
DitoElement.dito-
|
|
26
|
+
DitoElement.dito-label__suffix(
|
|
24
27
|
v-for="(suffix, index) of suffixes"
|
|
25
28
|
:key="`suffix-${index}`"
|
|
26
29
|
tag="span"
|
|
@@ -30,7 +33,6 @@ component.dito-label(
|
|
|
30
33
|
v-if="info"
|
|
31
34
|
:data-info="info"
|
|
32
35
|
)
|
|
33
|
-
slot(name="edit-buttons")
|
|
34
36
|
</template>
|
|
35
37
|
|
|
36
38
|
<script>
|
|
@@ -39,7 +41,7 @@ import { isObject, asArray } from '@ditojs/utils'
|
|
|
39
41
|
|
|
40
42
|
// @vue/component
|
|
41
43
|
export default DitoComponent.component('DitoLabel', {
|
|
42
|
-
emits: ['
|
|
44
|
+
emits: ['open'],
|
|
43
45
|
|
|
44
46
|
props: {
|
|
45
47
|
label: { type: [String, Object], default: null },
|
|
@@ -79,7 +81,7 @@ export default DitoComponent.component('DitoLabel', {
|
|
|
79
81
|
methods: {
|
|
80
82
|
onClick() {
|
|
81
83
|
this.appState.activeLabel = this
|
|
82
|
-
this.$emit('
|
|
84
|
+
this.$emit('open', this.collapsed)
|
|
83
85
|
}
|
|
84
86
|
}
|
|
85
87
|
})
|
|
@@ -96,35 +98,44 @@ export default DitoComponent.component('DitoLabel', {
|
|
|
96
98
|
position: relative;
|
|
97
99
|
// Vertically center all items in the label, e.g. chevron, edit-buttons.
|
|
98
100
|
align-items: center;
|
|
99
|
-
|
|
101
|
+
min-height: $input-height;
|
|
102
|
+
margin-right: $form-spacing-half; // When inlined.
|
|
103
|
+
|
|
104
|
+
&:has(.dito-schema-header) {
|
|
105
|
+
// The container's label is used as teleport for a nested section or object
|
|
106
|
+
// label. Hide `&__inner`, as it is be duplicated inside the nested label.
|
|
107
|
+
> #{$self}__inner {
|
|
108
|
+
display: none;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
100
111
|
|
|
101
|
-
|
|
102
|
-
//
|
|
103
|
-
|
|
104
|
-
margin-bottom: 0;
|
|
112
|
+
&:not(:has(+ .dito-tabs)) {
|
|
113
|
+
// Take full width but only if there aren't also tabs to be centered.
|
|
114
|
+
flex: 1;
|
|
105
115
|
}
|
|
106
116
|
|
|
107
117
|
&__inner {
|
|
108
118
|
display: flex;
|
|
109
|
-
|
|
110
|
-
|
|
119
|
+
flex: 1 0 0%;
|
|
120
|
+
overflow: hidden;
|
|
111
121
|
}
|
|
112
122
|
|
|
113
123
|
label {
|
|
114
124
|
cursor: inherit;
|
|
115
125
|
font-weight: bold;
|
|
116
126
|
white-space: nowrap;
|
|
127
|
+
line-height: $input-height;
|
|
117
128
|
}
|
|
118
129
|
|
|
119
130
|
label,
|
|
120
|
-
|
|
121
|
-
|
|
131
|
+
&__prefix,
|
|
132
|
+
&__suffix {
|
|
122
133
|
@include user-select(none);
|
|
123
134
|
@include ellipsis;
|
|
124
135
|
}
|
|
125
136
|
|
|
126
|
-
|
|
127
|
-
label +
|
|
137
|
+
&__prefix + label,
|
|
138
|
+
label + &__suffix {
|
|
128
139
|
&::before {
|
|
129
140
|
content: '\a0'; //
|
|
130
141
|
}
|
|
@@ -140,11 +151,17 @@ export default DitoComponent.component('DitoLabel', {
|
|
|
140
151
|
|
|
141
152
|
&.dito-width-fill {
|
|
142
153
|
width: 100%;
|
|
154
|
+
|
|
143
155
|
// In order for ellipsis to work on labels without affecting other layout,
|
|
144
|
-
// we need to position it absolutely inside its container.
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
156
|
+
// we need to position it absolutely inside its container. But we can only
|
|
157
|
+
// do so if there is't also a chevron or other UX elements besides it.
|
|
158
|
+
&:has(> #{$self}__inner:only-child) {
|
|
159
|
+
flex: 1; // When in `.dito-schema-header`.
|
|
160
|
+
|
|
161
|
+
> #{$self}__inner {
|
|
162
|
+
position: absolute;
|
|
163
|
+
inset: 0;
|
|
164
|
+
}
|
|
148
165
|
}
|
|
149
166
|
|
|
150
167
|
&::after {
|