@ditojs/admin 2.71.1 → 2.73.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.css +1 -1
- package/dist/dito-admin.es.js +2647 -2495
- package/dist/dito-admin.umd.js +5 -5
- package/package.json +33 -33
- package/src/DitoContext.js +8 -0
- package/src/components/DitoAccount.vue +1 -1
- package/src/components/DitoAffix.vue +56 -0
- package/src/components/DitoAffixes.vue +82 -0
- package/src/components/DitoClipboard.vue +3 -3
- package/src/components/DitoContainer.vue +24 -16
- package/src/components/DitoCreateButton.vue +7 -12
- package/src/components/DitoDialog.vue +1 -1
- package/src/components/DitoEditButtons.vue +3 -3
- package/src/components/DitoForm.vue +3 -6
- package/src/components/DitoHeader.vue +0 -13
- package/src/components/DitoLabel.vue +24 -42
- package/src/components/DitoMenu.vue +30 -34
- package/src/components/DitoPagination.vue +1 -1
- package/src/components/DitoPane.vue +10 -8
- package/src/components/DitoPanel.vue +2 -2
- package/src/components/DitoSchema.vue +5 -2
- package/src/components/DitoSchemaInlined.vue +1 -1
- package/src/components/DitoScopes.vue +1 -1
- package/src/components/DitoTableHead.vue +3 -3
- package/src/components/DitoTabs.vue +5 -5
- package/src/components/DitoTrail.vue +23 -18
- package/src/components/DitoTreeItem.vue +8 -8
- package/src/components/index.js +2 -1
- package/src/mixins/DitoMixin.js +1 -1
- package/src/mixins/EmitterMixin.js +13 -7
- package/src/mixins/SortableMixin.js +1 -1
- package/src/styles/_button.scss +99 -98
- package/src/styles/_layout.scss +14 -12
- package/src/styles/_pulldown.scss +17 -15
- package/src/styles/_table.scss +23 -22
- package/src/types/DitoTypeButton.vue +62 -19
- package/src/types/DitoTypeCheckboxes.vue +1 -1
- package/src/types/DitoTypeColor.vue +16 -10
- package/src/types/DitoTypeDate.vue +21 -7
- package/src/types/DitoTypeList.vue +9 -9
- package/src/types/DitoTypeMarkup.vue +8 -7
- package/src/types/DitoTypeMultiselect.vue +2 -2
- package/src/types/DitoTypeNumber.vue +15 -5
- package/src/types/DitoTypeRadio.vue +1 -1
- package/src/types/DitoTypeSelect.vue +7 -7
- package/src/types/DitoTypeSlider.vue +3 -3
- package/src/types/DitoTypeSwitch.vue +3 -3
- package/src/types/DitoTypeText.vue +15 -5
- package/src/types/DitoTypeTextarea.vue +2 -2
- package/src/types/DitoTypeUpload.vue +7 -7
- package/src/utils/schema.js +4 -1
- package/src/components/DitoElement.vue +0 -68
|
@@ -9,8 +9,17 @@
|
|
|
9
9
|
:format="formats"
|
|
10
10
|
v-bind="attributes"
|
|
11
11
|
)
|
|
12
|
-
template(#
|
|
13
|
-
|
|
12
|
+
template(#prefix)
|
|
13
|
+
DitoAffixes(
|
|
14
|
+
:items="schema.prefix"
|
|
15
|
+
:parentContext="context"
|
|
16
|
+
)
|
|
17
|
+
template(#suffix)
|
|
18
|
+
DitoAffixes(
|
|
19
|
+
:items="schema.suffix"
|
|
20
|
+
:parentContext="context"
|
|
21
|
+
)
|
|
22
|
+
button.dito-button--clear.dito-button--overlay(
|
|
14
23
|
v-if="showClearButton"
|
|
15
24
|
:disabled="disabled"
|
|
16
25
|
@click.stop="clear"
|
|
@@ -21,14 +30,19 @@
|
|
|
21
30
|
<script>
|
|
22
31
|
import DitoTypeComponent from '../DitoTypeComponent.js'
|
|
23
32
|
import { getSchemaAccessor } from '../utils/accessor.js'
|
|
24
|
-
import
|
|
33
|
+
import DitoAffixes from '../components/DitoAffixes.vue'
|
|
34
|
+
import {
|
|
35
|
+
DitoDatePicker,
|
|
36
|
+
DitoTimePicker,
|
|
37
|
+
DitoDateTimePicker
|
|
38
|
+
} from '@ditojs/ui/src'
|
|
25
39
|
import { isDate, assignDeeply } from '@ditojs/utils'
|
|
26
40
|
|
|
27
41
|
export default DitoTypeComponent.register(
|
|
28
42
|
['date', 'datetime', 'time'],
|
|
29
43
|
// @vue/component
|
|
30
44
|
{
|
|
31
|
-
components: {
|
|
45
|
+
components: { DitoAffixes },
|
|
32
46
|
// TODO: This is only here so we get placeholder added. Come up with a
|
|
33
47
|
// better way to support attributes per component (a list of actually
|
|
34
48
|
// supported attributes)
|
|
@@ -65,9 +79,9 @@ export default DitoTypeComponent.register(
|
|
|
65
79
|
methods: {
|
|
66
80
|
getComponent(type) {
|
|
67
81
|
return {
|
|
68
|
-
date:
|
|
69
|
-
time:
|
|
70
|
-
datetime:
|
|
82
|
+
date: DitoDatePicker,
|
|
83
|
+
time: DitoTimePicker,
|
|
84
|
+
datetime: DitoDateTimePicker
|
|
71
85
|
}[type]
|
|
72
86
|
}
|
|
73
87
|
},
|
|
@@ -24,10 +24,10 @@
|
|
|
24
24
|
)
|
|
25
25
|
table.dito-table(
|
|
26
26
|
:class=`{
|
|
27
|
-
'dito-table
|
|
28
|
-
'dito-table
|
|
29
|
-
'dito-table
|
|
30
|
-
'dito-table
|
|
27
|
+
'dito-table--separators': isInlined,
|
|
28
|
+
'dito-table--larger-padding': hasEditButtons && !isInlined,
|
|
29
|
+
'dito-table--alternate-colors': !isInlined,
|
|
30
|
+
'dito-table--even-count': hasEvenCount
|
|
31
31
|
}`
|
|
32
32
|
)
|
|
33
33
|
DitoTableHead(
|
|
@@ -103,7 +103,7 @@
|
|
|
103
103
|
v-else
|
|
104
104
|
v-html="getItemLabel(schema, item, { index })"
|
|
105
105
|
)
|
|
106
|
-
td.dito-
|
|
106
|
+
td.dito-table__buttons(
|
|
107
107
|
v-if="hasCellEditButtons"
|
|
108
108
|
)
|
|
109
109
|
DitoEditButtons(
|
|
@@ -124,7 +124,7 @@
|
|
|
124
124
|
v-if="hasListButtons && !single"
|
|
125
125
|
)
|
|
126
126
|
tr
|
|
127
|
-
td.dito-
|
|
127
|
+
td.dito-table__buttons(:colspan="numColumns")
|
|
128
128
|
DitoEditButtons(
|
|
129
129
|
:buttons="buttonSchemas"
|
|
130
130
|
:schema="schema"
|
|
@@ -138,7 +138,7 @@
|
|
|
138
138
|
:createPath="path"
|
|
139
139
|
)
|
|
140
140
|
//- Render create buttons outside table when in a single component view:
|
|
141
|
-
DitoEditButtons.dito-buttons
|
|
141
|
+
DitoEditButtons.dito-buttons--large.dito-buttons--main.dito-buttons--sticky(
|
|
142
142
|
v-if="hasListButtons && single"
|
|
143
143
|
:buttons="buttonSchemas"
|
|
144
144
|
:schema="schema"
|
|
@@ -257,7 +257,7 @@ export default DitoTypeComponent.register('list', {
|
|
|
257
257
|
},
|
|
258
258
|
|
|
259
259
|
getCellClass(column) {
|
|
260
|
-
return `dito-cell
|
|
260
|
+
return `dito-cell--${hyphenate(column.name)}`
|
|
261
261
|
},
|
|
262
262
|
|
|
263
263
|
getContext(item, index) {
|
|
@@ -333,7 +333,7 @@ export default DitoTypeComponent.register('list', {
|
|
|
333
333
|
}
|
|
334
334
|
}
|
|
335
335
|
|
|
336
|
-
&.dito-single {
|
|
336
|
+
&.dito-component--single {
|
|
337
337
|
// So that list buttons can be sticky to the bottom:
|
|
338
338
|
display: grid;
|
|
339
339
|
grid-template-rows: min-content;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
<template lang="pug">
|
|
2
2
|
.dito-markup(:id="dataPath")
|
|
3
|
-
.dito-buttons.dito-buttons
|
|
3
|
+
.dito-buttons.dito-buttons--toolbar(
|
|
4
4
|
v-if="groupedButtons.length > 0"
|
|
5
5
|
)
|
|
6
|
-
.dito-
|
|
6
|
+
.dito-buttons__group(
|
|
7
7
|
v-for="buttons in groupedButtons"
|
|
8
8
|
)
|
|
9
9
|
button.dito-button(
|
|
10
10
|
v-for="{ name, icon, isActive, onClick } in buttons"
|
|
11
11
|
:key="name"
|
|
12
|
-
:class="{ 'dito-active': isActive }"
|
|
12
|
+
:class="{ 'dito-button--active': isActive }"
|
|
13
13
|
@click="onClick"
|
|
14
14
|
)
|
|
15
|
-
|
|
15
|
+
DitoIcon(:name="icon")
|
|
16
16
|
EditorContent.dito-markup-editor(
|
|
17
17
|
ref="editor"
|
|
18
18
|
:editor="editor"
|
|
@@ -66,7 +66,7 @@ import { Footnotes, FootnoteReference, Footnote } from 'tiptap-footnotes'
|
|
|
66
66
|
// Tools:
|
|
67
67
|
import { History } from '@tiptap/extension-history'
|
|
68
68
|
|
|
69
|
-
import {
|
|
69
|
+
import { DitoIcon } from '@ditojs/ui/src'
|
|
70
70
|
import { isArray, isObject, hyphenate, debounce, camelize } from '@ditojs/utils'
|
|
71
71
|
|
|
72
72
|
// @vue/component
|
|
@@ -74,7 +74,7 @@ export default DitoTypeComponent.register('markup', {
|
|
|
74
74
|
mixins: [DomMixin],
|
|
75
75
|
components: {
|
|
76
76
|
EditorContent,
|
|
77
|
-
|
|
77
|
+
DitoIcon
|
|
78
78
|
},
|
|
79
79
|
|
|
80
80
|
data() {
|
|
@@ -298,6 +298,7 @@ export default DitoTypeComponent.register('markup', {
|
|
|
298
298
|
async onClickLink(editor) {
|
|
299
299
|
const attributes = await this.rootComponent.showDialog({
|
|
300
300
|
components: {
|
|
301
|
+
DitoIcon,
|
|
301
302
|
href: {
|
|
302
303
|
type: 'url',
|
|
303
304
|
label: 'Link',
|
|
@@ -552,7 +553,7 @@ const LinkWithTitle = Link.extend({
|
|
|
552
553
|
padding-right: $input-padding-hor;
|
|
553
554
|
}
|
|
554
555
|
|
|
555
|
-
.dito-buttons
|
|
556
|
+
.dito-buttons--toolbar {
|
|
556
557
|
margin: 0;
|
|
557
558
|
}
|
|
558
559
|
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
@tag="onAddTag"
|
|
32
32
|
@search-change="onSearchChange"
|
|
33
33
|
)
|
|
34
|
-
button.dito-button
|
|
34
|
+
button.dito-button--clear.dito-button--overlay(
|
|
35
35
|
v-if="showClearButton"
|
|
36
36
|
type="button"
|
|
37
37
|
:disabled="disabled"
|
|
@@ -267,7 +267,7 @@ $tag-line-height: 1em;
|
|
|
267
267
|
// So tags can float on multiple lines and have proper margins:
|
|
268
268
|
padding-bottom: $tag-margin;
|
|
269
269
|
|
|
270
|
-
.dito-has-errors & {
|
|
270
|
+
.dito-container--has-errors & {
|
|
271
271
|
border-color: $color-error;
|
|
272
272
|
}
|
|
273
273
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template lang="pug">
|
|
2
|
-
|
|
2
|
+
DitoInput.dito-number(
|
|
3
3
|
:id="dataPath"
|
|
4
4
|
ref="element"
|
|
5
5
|
v-model="inputValue"
|
|
@@ -9,8 +9,17 @@ InputField.dito-number(
|
|
|
9
9
|
:max="max"
|
|
10
10
|
:step="stepValue"
|
|
11
11
|
)
|
|
12
|
-
template(#
|
|
13
|
-
|
|
12
|
+
template(#prefix)
|
|
13
|
+
DitoAffixes(
|
|
14
|
+
:items="schema.prefix"
|
|
15
|
+
:parentContext="context"
|
|
16
|
+
)
|
|
17
|
+
template(#suffix)
|
|
18
|
+
DitoAffixes(
|
|
19
|
+
:items="schema.suffix"
|
|
20
|
+
:parentContext="context"
|
|
21
|
+
)
|
|
22
|
+
button.dito-button--clear.dito-button--overlay(
|
|
14
23
|
v-if="showClearButton"
|
|
15
24
|
:disabled="disabled"
|
|
16
25
|
@click.stop="clear"
|
|
@@ -20,14 +29,15 @@ InputField.dito-number(
|
|
|
20
29
|
<script>
|
|
21
30
|
import DitoTypeComponent from '../DitoTypeComponent.js'
|
|
22
31
|
import NumberMixin from '../mixins/NumberMixin.js'
|
|
23
|
-
import
|
|
32
|
+
import DitoAffixes from '../components/DitoAffixes.vue'
|
|
33
|
+
import { DitoInput } from '@ditojs/ui/src'
|
|
24
34
|
|
|
25
35
|
export default DitoTypeComponent.register(
|
|
26
36
|
['number', 'integer'],
|
|
27
37
|
// @vue/component
|
|
28
38
|
{
|
|
29
39
|
mixins: [NumberMixin],
|
|
30
|
-
components: {
|
|
40
|
+
components: { DitoInput, DitoAffixes },
|
|
31
41
|
nativeField: true,
|
|
32
42
|
textField: true,
|
|
33
43
|
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
v-else-if="selectedOption"
|
|
33
33
|
)
|
|
34
34
|
option(:value="selectedValue") {{ getLabelForOption(selectedOption) }}
|
|
35
|
-
button.dito-button
|
|
35
|
+
button.dito-button--clear.dito-button--overlay(
|
|
36
36
|
v-if="showClearButton"
|
|
37
37
|
:disabled="disabled"
|
|
38
38
|
@click="clear"
|
|
@@ -96,6 +96,10 @@ export default DitoTypeComponent.register('select', {
|
|
|
96
96
|
position: absolute;
|
|
97
97
|
bottom: $select-arrow-bottom;
|
|
98
98
|
right: $select-arrow-right;
|
|
99
|
+
|
|
100
|
+
.dito-container--disabled & {
|
|
101
|
+
border-color: $color-disabled;
|
|
102
|
+
}
|
|
99
103
|
}
|
|
100
104
|
}
|
|
101
105
|
|
|
@@ -103,15 +107,11 @@ export default DitoTypeComponent.register('select', {
|
|
|
103
107
|
margin-left: $form-spacing-half;
|
|
104
108
|
}
|
|
105
109
|
|
|
106
|
-
// Handle
|
|
107
|
-
&.dito-
|
|
110
|
+
// Handle width fill separately due to required nesting of select:
|
|
111
|
+
&.dito-component--fill {
|
|
108
112
|
select {
|
|
109
113
|
width: 100%;
|
|
110
114
|
}
|
|
111
115
|
}
|
|
112
|
-
|
|
113
|
-
&.dito-disabled::after {
|
|
114
|
-
border-color: $border-color;
|
|
115
|
-
}
|
|
116
116
|
}
|
|
117
117
|
</style>
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
:max="max"
|
|
11
11
|
:step="stepValue"
|
|
12
12
|
)
|
|
13
|
-
|
|
13
|
+
DitoInput.dito-number(
|
|
14
14
|
v-if="input"
|
|
15
15
|
v-model="inputValue"
|
|
16
16
|
type="number"
|
|
@@ -25,12 +25,12 @@
|
|
|
25
25
|
import DitoTypeComponent from '../DitoTypeComponent.js'
|
|
26
26
|
import NumberMixin from '../mixins/NumberMixin.js'
|
|
27
27
|
import { getSchemaAccessor } from '../utils/accessor.js'
|
|
28
|
-
import {
|
|
28
|
+
import { DitoInput } from '@ditojs/ui/src'
|
|
29
29
|
|
|
30
30
|
// @vue/component
|
|
31
31
|
export default DitoTypeComponent.register('slider', {
|
|
32
32
|
mixins: [NumberMixin],
|
|
33
|
-
components: {
|
|
33
|
+
components: { DitoInput },
|
|
34
34
|
nativeField: true,
|
|
35
35
|
|
|
36
36
|
computed: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template lang="pug">
|
|
2
|
-
|
|
2
|
+
DitoSwitch.dito-switch(
|
|
3
3
|
:id="dataPath"
|
|
4
4
|
ref="element"
|
|
5
5
|
v-model="value"
|
|
@@ -10,7 +10,7 @@ SwitchButton.dito-switch(
|
|
|
10
10
|
|
|
11
11
|
<script>
|
|
12
12
|
import DitoTypeComponent from '../DitoTypeComponent.js'
|
|
13
|
-
import {
|
|
13
|
+
import { DitoSwitch } from '@ditojs/ui/src'
|
|
14
14
|
|
|
15
15
|
// @vue/component
|
|
16
16
|
export default DitoTypeComponent.register('switch', {
|
|
@@ -18,7 +18,7 @@ export default DitoTypeComponent.register('switch', {
|
|
|
18
18
|
defaultWidth: 'auto',
|
|
19
19
|
|
|
20
20
|
components: {
|
|
21
|
-
|
|
21
|
+
DitoSwitch
|
|
22
22
|
},
|
|
23
23
|
|
|
24
24
|
computed: {
|
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
<template lang="pug">
|
|
2
|
-
|
|
2
|
+
DitoInput.dito-text(
|
|
3
3
|
:id="dataPath"
|
|
4
4
|
ref="element"
|
|
5
5
|
v-model="inputValue"
|
|
6
6
|
:type="inputType"
|
|
7
7
|
v-bind="attributes"
|
|
8
8
|
)
|
|
9
|
-
template(#
|
|
10
|
-
|
|
9
|
+
template(#prefix)
|
|
10
|
+
DitoAffixes(
|
|
11
|
+
:items="schema.prefix"
|
|
12
|
+
:parentContext="context"
|
|
13
|
+
)
|
|
14
|
+
template(#suffix)
|
|
15
|
+
DitoAffixes(
|
|
16
|
+
:items="schema.suffix"
|
|
17
|
+
:parentContext="context"
|
|
18
|
+
)
|
|
19
|
+
button.dito-button--clear.dito-button--overlay(
|
|
11
20
|
v-if="showClearButton"
|
|
12
21
|
:disabled="disabled"
|
|
13
22
|
@click.stop="clear"
|
|
@@ -17,7 +26,8 @@ InputField.dito-text(
|
|
|
17
26
|
<script>
|
|
18
27
|
import DitoTypeComponent from '../DitoTypeComponent.js'
|
|
19
28
|
import TextMixin from '../mixins/TextMixin'
|
|
20
|
-
import
|
|
29
|
+
import DitoAffixes from '../components/DitoAffixes.vue'
|
|
30
|
+
import { DitoInput } from '@ditojs/ui/src'
|
|
21
31
|
|
|
22
32
|
const maskedPassword = '****************'
|
|
23
33
|
|
|
@@ -35,7 +45,7 @@ export default DitoTypeComponent.register(
|
|
|
35
45
|
// @vue/component
|
|
36
46
|
{
|
|
37
47
|
mixins: [TextMixin],
|
|
38
|
-
components: {
|
|
48
|
+
components: { DitoInput, DitoAffixes },
|
|
39
49
|
nativeField: true,
|
|
40
50
|
textField: true,
|
|
41
51
|
ignoreMissingValue: ({ schema }) => schema.type === 'password',
|
|
@@ -5,7 +5,7 @@ textarea.dito-textarea.dito-input(
|
|
|
5
5
|
v-model="value"
|
|
6
6
|
v-bind="attributes"
|
|
7
7
|
:rows="lines"
|
|
8
|
-
:class="{ 'dito-resizable': resizable }"
|
|
8
|
+
:class="{ 'dito-textarea--resizable': resizable }"
|
|
9
9
|
)
|
|
10
10
|
</template>
|
|
11
11
|
|
|
@@ -41,7 +41,7 @@ export default DitoTypeComponent.register('textarea', {
|
|
|
41
41
|
resize: none;
|
|
42
42
|
min-height: calc(1em * var(--line-height) + #{2 * $input-padding-ver});
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
&--resizable {
|
|
45
45
|
resize: vertical;
|
|
46
46
|
}
|
|
47
47
|
}
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
@input-filter="onInputFilter"
|
|
21
21
|
@input-file="onInputFile"
|
|
22
22
|
)
|
|
23
|
-
table.dito-table.dito-table
|
|
23
|
+
table.dito-table.dito-table--separators.dito-table--background
|
|
24
24
|
//- Styling comes from `DitoTableHead`
|
|
25
25
|
thead.dito-table-head
|
|
26
26
|
tr
|
|
@@ -92,9 +92,9 @@
|
|
|
92
92
|
v-else
|
|
93
93
|
)
|
|
94
94
|
| Stored
|
|
95
|
-
td.dito-
|
|
96
|
-
.dito-buttons.dito-buttons
|
|
97
|
-
button.dito-button.dito-button
|
|
95
|
+
td.dito-table__buttons
|
|
96
|
+
.dito-buttons.dito-buttons--round
|
|
97
|
+
button.dito-button.dito-button--upload(
|
|
98
98
|
v-if="!multiple"
|
|
99
99
|
:title="uploadTitle"
|
|
100
100
|
@click="onClickUpload"
|
|
@@ -121,13 +121,13 @@
|
|
|
121
121
|
:value="uploadProgress"
|
|
122
122
|
max="100"
|
|
123
123
|
)
|
|
124
|
-
.dito-buttons.dito-buttons
|
|
124
|
+
.dito-buttons.dito-buttons--round
|
|
125
125
|
button.dito-button(
|
|
126
126
|
v-if="isUploadActive"
|
|
127
127
|
type="button"
|
|
128
128
|
@click.prevent="upload.active = false"
|
|
129
129
|
) Cancel
|
|
130
|
-
button.dito-button.dito-button
|
|
130
|
+
button.dito-button.dito-button--upload(
|
|
131
131
|
v-if="multiple || !hasFiles"
|
|
132
132
|
:title="uploadTitle"
|
|
133
133
|
@click="onClickUpload"
|
|
@@ -473,7 +473,7 @@ function asFiles(value) {
|
|
|
473
473
|
.dito-upload {
|
|
474
474
|
.dito-table {
|
|
475
475
|
tr,
|
|
476
|
-
.dito-
|
|
476
|
+
.dito-table__buttons {
|
|
477
477
|
vertical-align: middle;
|
|
478
478
|
}
|
|
479
479
|
}
|
package/src/utils/schema.js
CHANGED
|
@@ -332,7 +332,10 @@ export async function processView(component, api, schema, name, fullPath = '') {
|
|
|
332
332
|
}
|
|
333
333
|
|
|
334
334
|
export function processSchemaDefaults(api, schema) {
|
|
335
|
-
let defaults =
|
|
335
|
+
let defaults = (
|
|
336
|
+
api.defaults[schema.type] ||
|
|
337
|
+
api.defaults[camelize(schema.type)]
|
|
338
|
+
)
|
|
336
339
|
if (defaults) {
|
|
337
340
|
if (isFunction(defaults)) {
|
|
338
341
|
defaults = defaults(schema)
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
<template lang="pug">
|
|
2
|
-
component(
|
|
3
|
-
v-if="options?.text != null"
|
|
4
|
-
:is="tagName"
|
|
5
|
-
:class="classes"
|
|
6
|
-
:style="styles"
|
|
7
|
-
) {{ options.text }}
|
|
8
|
-
component(
|
|
9
|
-
v-else-if="options?.html != null"
|
|
10
|
-
:is="tagName"
|
|
11
|
-
:class="classes"
|
|
12
|
-
:style="styles"
|
|
13
|
-
v-html="options.html"
|
|
14
|
-
)
|
|
15
|
-
</template>
|
|
16
|
-
|
|
17
|
-
<script>
|
|
18
|
-
import DitoComponent from '../DitoComponent.js'
|
|
19
|
-
import { isObject, isString, asArray } from '@ditojs/utils'
|
|
20
|
-
|
|
21
|
-
// @vue/component
|
|
22
|
-
export default DitoComponent.component('DitoElement', {
|
|
23
|
-
props: {
|
|
24
|
-
as: { type: String, default: 'span' },
|
|
25
|
-
content: { type: [String, Object], default: null }
|
|
26
|
-
},
|
|
27
|
-
|
|
28
|
-
computed: {
|
|
29
|
-
options() {
|
|
30
|
-
const { content } = this
|
|
31
|
-
return content != null
|
|
32
|
-
? isObject(content)
|
|
33
|
-
? content
|
|
34
|
-
: { text: content }
|
|
35
|
-
: null
|
|
36
|
-
},
|
|
37
|
-
|
|
38
|
-
tagName() {
|
|
39
|
-
return this.options.as || this.as
|
|
40
|
-
},
|
|
41
|
-
|
|
42
|
-
classes() {
|
|
43
|
-
return {
|
|
44
|
-
...asObject(this.$attrs.class),
|
|
45
|
-
...asObject(this.options.class)
|
|
46
|
-
}
|
|
47
|
-
},
|
|
48
|
-
|
|
49
|
-
styles() {
|
|
50
|
-
return {
|
|
51
|
-
...asObject(this.$attrs.style),
|
|
52
|
-
...asObject(this.options.style)
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
})
|
|
57
|
-
|
|
58
|
-
function asObject(value) {
|
|
59
|
-
return asArray(value).reduce((object, entry) => {
|
|
60
|
-
if (isString(entry)) {
|
|
61
|
-
object[entry] = true
|
|
62
|
-
} else if (isObject(entry)) {
|
|
63
|
-
Object.assign(object, entry)
|
|
64
|
-
}
|
|
65
|
-
return object
|
|
66
|
-
}, {})
|
|
67
|
-
}
|
|
68
|
-
</script>
|