@ditojs/admin 2.2.10 → 2.2.11

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ditojs/admin",
3
- "version": "2.2.10",
3
+ "version": "2.2.11",
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",
@@ -82,7 +82,7 @@
82
82
  "vite": "^4.3.1"
83
83
  },
84
84
  "types": "types",
85
- "gitHead": "8c6fffbc52edec642c72859dc280f3bb442b3bf1",
85
+ "gitHead": "52aada1f67b13f9b30b745777c64649c6c7b171f",
86
86
  "scripts": {
87
87
  "build": "vite build",
88
88
  "watch": "yarn build --mode 'development' --watch",
@@ -21,6 +21,7 @@ export default {
21
21
  generateLabel: true,
22
22
  excludeValue: false,
23
23
  ignoreMissingValue: null,
24
+ keepAligned: true,
24
25
  omitPadding: false,
25
26
 
26
27
  component: DitoComponent.component,
@@ -31,7 +31,7 @@ import { isString, isNumber } from '@ditojs/utils'
31
31
  import DitoComponent from '../DitoComponent.js'
32
32
  import DitoContext from '../DitoContext.js'
33
33
  import { getSchemaAccessor } from '../utils/accessor.js'
34
- import { getTypeComponent, omitPadding } from '../utils/schema.js'
34
+ import { getTypeComponent, keepAligned, omitPadding } from '../utils/schema.js'
35
35
  import { parseFraction } from '../utils/math.js'
36
36
 
37
37
  // @vue/component
@@ -68,25 +68,13 @@ export default DitoComponent.component('DitoContainer', {
68
68
  return (
69
69
  label !== false && (
70
70
  !!label ||
71
- this.generateLabels && (
72
- this.typeComponent?.generateLabel ||
73
- // If the component has no label but isn't full width, render an
74
- // empty label for alignment with other components:
75
- !this.isFullWidth
76
- )
71
+ this.generateLabels && this.typeComponent?.generateLabel
77
72
  )
78
73
  )
79
74
  },
80
75
 
81
76
  label() {
82
- return this.hasLabel
83
- ? this.getLabel(
84
- this.schema,
85
- // Pass an empty string in case we need an empty label, see
86
- // `hasLabel()`:
87
- this.typeComponent?.generateLabel ? this.schema.name : ''
88
- ) || ''
89
- : null
77
+ return this.hasLabel ? this.getLabel(this.schema) : null
90
78
  },
91
79
 
92
80
  labelDataPath() {
@@ -94,13 +82,6 @@ export default DitoComponent.component('DitoContainer', {
94
82
  return this.nested ? this.dataPath : null
95
83
  },
96
84
 
97
- isFullWidth() {
98
- return (
99
- !this.componentBasis.endsWith('%') ||
100
- parseFloat(this.componentBasis) === 100
101
- )
102
- },
103
-
104
85
  componentWidth: getSchemaAccessor('width', {
105
86
  type: [String, Number],
106
87
  default() {
@@ -146,6 +127,7 @@ export default DitoComponent.component('DitoContainer', {
146
127
  return {
147
128
  [`${prefix}--single`]: this.single,
148
129
  [`${prefix}--has-label`]: this.hasLabel,
130
+ [`${prefix}--aligned`]: keepAligned(this.schema),
149
131
  [`${prefix}--omit-padding`]: omitPadding(this.schema),
150
132
  ...(
151
133
  isString(containerClass)
@@ -205,6 +187,8 @@ export default DitoComponent.component('DitoContainer', {
205
187
  @import '../styles/_imports';
206
188
 
207
189
  .dito-container {
190
+ $self: &;
191
+
208
192
  display: flex;
209
193
  flex-flow: column;
210
194
  align-items: flex-start;
@@ -227,6 +211,23 @@ export default DitoComponent.component('DitoContainer', {
227
211
  padding: 0;
228
212
  }
229
213
 
214
+ &--aligned {
215
+ // To align components with and without labels.
216
+ justify-content: space-between;
217
+
218
+ &:has(> :only-child) {
219
+ justify-content: flex-end;
220
+ }
221
+
222
+ // Don't align if neighbouring components aren't aligned either.
223
+ // Look ahead:
224
+ #{$self}:not(#{&}) + &,
225
+ // Look behind:
226
+ &:has(+ #{$self}:not(#{&})) {
227
+ justify-content: flex-start;
228
+ }
229
+ }
230
+
230
231
  &--omit-padding {
231
232
  padding: 0;
232
233
 
@@ -1,5 +1,6 @@
1
1
  <template lang="pug">
2
2
  component.dito-label(
3
+ v-if="text || collapsible"
3
4
  :is="tag"
4
5
  v-bind="attributes"
5
6
  :class="{ 'dito-active': isActive }"
@@ -243,7 +243,7 @@ export default {
243
243
  getLabel(schema, name) {
244
244
  return schema
245
245
  ? this.getSchemaValue('label', { type: String, schema }) ||
246
- labelize(name ?? schema.name)
246
+ labelize(name || schema.name)
247
247
  : labelize(name) || ''
248
248
  },
249
249
 
@@ -14,6 +14,7 @@ import CodeFlask from 'codeflask'
14
14
  // @vue/component
15
15
  export default DitoTypeComponent.register('code', {
16
16
  mixins: [DomMixin],
17
+ keepAligned: false,
17
18
 
18
19
  computed: {
19
20
  lines() {
@@ -22,6 +22,7 @@ export default DitoTypeComponent.register('component', {
22
22
  // Override the standard `defaultValue: null` to not set any data for custom
23
23
  // components, unless they provide a default value.
24
24
  defaultValue: () => undefined, // Callback to override `defaultValue: null`
25
+ keepAligned: false,
25
26
  ignoreMissingValue: schema => !('default' in schema),
26
27
 
27
28
  async processSchema(api, schema) {
@@ -11,7 +11,8 @@ import DitoTypeComponent from '../DitoTypeComponent.js'
11
11
  // @vue/component
12
12
  export default DitoTypeComponent.register('label', {
13
13
  excludeValue: true,
14
- generateLabel: false
14
+ generateLabel: false,
15
+ keepAligned: false
15
16
  })
16
17
  </script>
17
18
 
@@ -167,6 +167,7 @@ import { pickBy, equals, hyphenate } from '@ditojs/utils'
167
167
  // @vue/component
168
168
  export default DitoTypeComponent.register('list', {
169
169
  mixins: [SourceMixin, SortableMixin],
170
+ keepAligned: false,
170
171
 
171
172
  getSourceType(type) {
172
173
  // No need for transformation here. See TypeTreeList for details.
@@ -83,6 +83,8 @@ export default DitoTypeComponent.register('markup', {
83
83
  Icon
84
84
  },
85
85
 
86
+ keepAligned: false,
87
+
86
88
  data() {
87
89
  return {
88
90
  editor: null,
@@ -63,6 +63,8 @@ import { resolveSchemaComponent } from '../utils/schema.js'
63
63
  export default DitoTypeComponent.register('object', {
64
64
  mixins: [SourceMixin],
65
65
 
66
+ keepAligned: false,
67
+
66
68
  getSourceType(type) {
67
69
  // No need for transformation here. See TypeTreeList for details.
68
70
  return type
@@ -6,6 +6,7 @@ export default DitoTypeComponent.register('panel', {
6
6
  defaultValue: () => undefined, // Callback to override `defaultValue: null`
7
7
  excludeValue: true,
8
8
  generateLabel: false,
9
+ keepAligned: false,
9
10
  omitPadding: true,
10
11
 
11
12
  getPanelSchema(api, schema) {
@@ -20,6 +20,7 @@ export default DitoTypeComponent.register('section', {
20
20
  ignoreMissingValue: schema => !schema.nested && !('default' in schema),
21
21
  defaultNested: false,
22
22
  generateLabel: false,
23
+ keepAligned: false,
23
24
 
24
25
  computed: {
25
26
  item() {
@@ -19,6 +19,7 @@ export default DitoTypeComponent.register('textarea', {
19
19
  mixins: [TextMixin],
20
20
  nativeField: true,
21
21
  textField: true,
22
+ keepAligned: false,
22
23
 
23
24
  computed: {
24
25
  lines() {
@@ -35,6 +35,8 @@ export default DitoTypeComponent.register(
35
35
  {
36
36
  mixins: [SourceMixin],
37
37
 
38
+ keepAligned: false,
39
+
38
40
  provide() {
39
41
  return { container: this }
40
42
  },
@@ -112,6 +112,8 @@ export default DitoTypeComponent.register('upload', {
112
112
  mixins: [SortableMixin],
113
113
  components: { VueUpload },
114
114
 
115
+ keepAligned: false,
116
+
115
117
  data() {
116
118
  return {
117
119
  uploads: []
@@ -36,6 +36,7 @@ const ditoOptionKeys = [
36
36
  'generateLabel',
37
37
  'excludeValue',
38
38
  'ignoreMissingValue',
39
+ 'keepAligned',
39
40
  'omitPadding',
40
41
  'processValue',
41
42
  'processSchema',
@@ -474,6 +474,10 @@ export function omitPadding(schema) {
474
474
  return !!getTypeOptions(schema)?.omitPadding
475
475
  }
476
476
 
477
+ export function keepAligned(schema) {
478
+ return !!getTypeOptions(schema)?.keepAligned
479
+ }
480
+
477
481
  export function getDefaultValue(schema) {
478
482
  // Support default values both on schema and on component level.
479
483
  // NOTE: At the time of creation, components may not be instantiated, (e.g. if