@ditojs/admin 2.1.3 → 2.2.1

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.
Files changed (38) hide show
  1. package/dist/dito-admin.es.js +1549 -1451
  2. package/dist/dito-admin.umd.js +4 -4
  3. package/dist/style.css +1 -1
  4. package/package.json +5 -5
  5. package/src/DitoContext.js +10 -10
  6. package/src/DitoTypeComponent.js +1 -0
  7. package/src/components/DitoContainer.vue +22 -10
  8. package/src/components/DitoCreateButton.vue +11 -8
  9. package/src/components/DitoDraggable.vue +45 -0
  10. package/src/components/DitoPane.vue +1 -1
  11. package/src/components/DitoPanel.vue +1 -1
  12. package/src/components/DitoSchema.vue +11 -6
  13. package/src/components/DitoSchemaInlined.vue +1 -0
  14. package/src/components/DitoTreeItem.vue +3 -2
  15. package/src/components/index.js +1 -0
  16. package/src/mixins/DataMixin.js +3 -3
  17. package/src/mixins/DitoMixin.js +23 -10
  18. package/src/mixins/RouteMixin.js +1 -1
  19. package/src/mixins/SortableMixin.js +2 -6
  20. package/src/mixins/SourceMixin.js +0 -5
  21. package/src/mixins/TypeMixin.js +40 -17
  22. package/src/styles/_pulldown.scss +9 -12
  23. package/src/types/DitoTypeButton.vue +12 -9
  24. package/src/types/DitoTypeCode.vue +1 -0
  25. package/src/types/DitoTypeComponent.vue +1 -0
  26. package/src/types/DitoTypeLabel.vue +2 -1
  27. package/src/types/DitoTypeList.vue +4 -2
  28. package/src/types/DitoTypeMarkup.vue +2 -0
  29. package/src/types/DitoTypeObject.vue +2 -0
  30. package/src/types/DitoTypePanel.vue +1 -0
  31. package/src/types/DitoTypeSection.vue +1 -1
  32. package/src/types/DitoTypeTextarea.vue +1 -0
  33. package/src/types/DitoTypeTreeList.vue +2 -0
  34. package/src/types/DitoTypeUpload.vue +5 -2
  35. package/src/utils/accessor.js +1 -1
  36. package/src/utils/options.js +1 -0
  37. package/src/utils/schema.js +5 -15
  38. package/types/index.d.ts +3 -24
@@ -4,7 +4,7 @@ button.dito-button(
4
4
  ref="element"
5
5
  :type="type"
6
6
  :title="text"
7
- :class="`dito-button-${verb}`"
7
+ :class="buttonClass"
8
8
  v-bind="attributes"
9
9
  ) {{ text }}
10
10
  </template>
@@ -21,13 +21,16 @@ export default DitoTypeComponent.register(
21
21
  {
22
22
  defaultValue: () => undefined, // Callback to override `defaultValue: null`
23
23
  excludeValue: true,
24
+ generateLabel: false,
24
25
  defaultWidth: 'auto',
25
- // TODO: Consider making this work nicely:
26
- // omitFlexGrow: true,
27
26
 
28
27
  computed: {
29
28
  verb() {
30
- return this.verbs[this.name] || this.name
29
+ return this.verbs[this.name]
30
+ },
31
+
32
+ buttonClass() {
33
+ return this.verb ? `dito-button-${this.verb}` : null
31
34
  },
32
35
 
33
36
  text: getSchemaAccessor('text', {
@@ -40,16 +43,16 @@ export default DitoTypeComponent.register(
40
43
  closeForm: getSchemaAccessor('closeForm', {
41
44
  type: Boolean,
42
45
  default: false
43
- }),
46
+ })
47
+ },
44
48
 
49
+ methods: {
45
50
  // @override
46
- events() {
51
+ getEvents() {
47
52
  const { onFocus, onBlur, onClick } = this
48
53
  return { onFocus, onBlur, onClick }
49
- }
50
- },
54
+ },
51
55
 
52
- methods: {
53
56
  async submit(options) {
54
57
  return this.resourceComponent?.submit(this, options)
55
58
  },
@@ -14,6 +14,7 @@ import CodeFlask from 'codeflask'
14
14
  // @vue/component
15
15
  export default DitoTypeComponent.register('code', {
16
16
  mixins: [DomMixin],
17
+ alignBottom: 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
+ alignBottom: 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
+ alignBottom: false
15
16
  })
16
17
  </script>
17
18
 
@@ -38,10 +38,11 @@
38
38
  :columns="columns"
39
39
  :hasEditButtons="hasEditButtons"
40
40
  )
41
- UseSortable(
41
+ DitoDraggable(
42
42
  tag="tbody"
43
43
  :modelValue="updateOrder(sourceSchema, listData, paginationRange)"
44
- :options="getSortableOptions(draggable)"
44
+ :options="getSortableOptions(false)"
45
+ :draggable="draggable"
45
46
  @update:modelValue="value => (listData = value)"
46
47
  )
47
48
  tr(
@@ -167,6 +168,7 @@ import { pickBy, equals, hyphenate } from '@ditojs/utils'
167
168
  // @vue/component
168
169
  export default DitoTypeComponent.register('list', {
169
170
  mixins: [SourceMixin, SortableMixin],
171
+ alignBottom: false,
170
172
 
171
173
  getSourceType(type) {
172
174
  // 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
+ alignBottom: 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
+ alignBottom: 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
+ alignBottom: false,
9
10
  omitPadding: true,
10
11
 
11
12
  getPanelSchema(schema) {
@@ -20,7 +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
- omitFlexGrow: true,
23
+ alignBottom: false,
24
24
 
25
25
  computed: {
26
26
  item() {
@@ -17,6 +17,7 @@ import { getSchemaAccessor } from '../utils/accessor.js'
17
17
  export default DitoTypeComponent.register('textarea', {
18
18
  nativeField: true,
19
19
  textField: true,
20
+ alignBottom: false,
20
21
 
21
22
  computed: {
22
23
  lines() {
@@ -35,6 +35,8 @@ export default DitoTypeComponent.register(
35
35
  {
36
36
  mixins: [SourceMixin],
37
37
 
38
+ alignBottom: false,
39
+
38
40
  provide() {
39
41
  return { container: this }
40
42
  },
@@ -12,10 +12,11 @@
12
12
  span Status
13
13
  th
14
14
  span
15
- UseSortable(
15
+ DitoDraggable(
16
16
  v-model="files"
17
17
  tag="tbody"
18
- :options="getSortableOptions(draggable)"
18
+ :options="getSortableOptions(false)"
19
+ :draggable="draggable"
19
20
  )
20
21
  tr(
21
22
  v-for="(file, index) in files"
@@ -111,6 +112,8 @@ export default DitoTypeComponent.register('upload', {
111
112
  mixins: [SortableMixin],
112
113
  components: { VueUpload },
113
114
 
115
+ alignBottom: false,
116
+
114
117
  data() {
115
118
  return {
116
119
  uploads: []
@@ -53,7 +53,7 @@ export function getStoreAccessor(name, { default: def, get, set } = {}) {
53
53
  let value = this.getStore(name)
54
54
  if (value === undefined && def !== undefined) {
55
55
  // Support `default()` functions:
56
- value = isFunction(def) ? def.call(this, this.context) : def
56
+ value = isFunction(def) ? def.call(this) : def
57
57
  // Trigger setter by setting value and accessor to default:
58
58
  this[name] = value
59
59
  // Now access store again, for reactivity tracking
@@ -36,6 +36,7 @@ const ditoOptionKeys = [
36
36
  'generateLabel',
37
37
  'excludeValue',
38
38
  'ignoreMissingValue',
39
+ 'alignBottom',
39
40
  'omitPadding',
40
41
  'processValue',
41
42
  'processSchema',
@@ -432,10 +432,6 @@ export function getItemFormSchema(schema, item, context) {
432
432
  return getItemFormSchemaFromForms(getFormSchemas(schema, context), item)
433
433
  }
434
434
 
435
- export function hasLabel(schema) {
436
- return schema.label !== false
437
- }
438
-
439
435
  export function isCompact(schema) {
440
436
  return !!schema.compact
441
437
  }
@@ -448,10 +444,14 @@ export function isNested(schema) {
448
444
  return !!(schema.nested || getTypeOptions(schema)?.defaultNested === true)
449
445
  }
450
446
 
451
- export function shouldOmitPadding(schema) {
447
+ export function omitPadding(schema) {
452
448
  return !!getTypeOptions(schema)?.omitPadding
453
449
  }
454
450
 
451
+ export function alignBottom(schema) {
452
+ return !!getTypeOptions(schema)?.alignBottom
453
+ }
454
+
455
455
  export function getDefaultValue(schema) {
456
456
  // Support default values both on schema and on component level.
457
457
  // NOTE: At the time of creation, components may not be instantiated, (e.g. if
@@ -475,16 +475,6 @@ export function ignoreMissingValue(schema) {
475
475
  )
476
476
  }
477
477
 
478
- export function hasLabels(schema) {
479
- const checkComponents = components =>
480
- Object.values(components || {}).some(hasLabel)
481
-
482
- return (
483
- checkComponents(schema.components) ||
484
- Object.values(schema.tabs || {}).some(checkComponents)
485
- )
486
- }
487
-
488
478
  export function setDefaultValues(schema, data = {}, component) {
489
479
  const options = { component, rootData: data }
490
480
 
package/types/index.d.ts CHANGED
@@ -319,40 +319,19 @@ export interface SchemaSourceMixin<$Item> {
319
319
  *
320
320
  * @defaultValue `false`
321
321
  */
322
- creatable?: OrItemAccessor<
323
- $Item,
324
- {},
325
- | boolean
326
- | {
327
- label: string
328
- }
329
- >
322
+ creatable?: OrItemAccessor<$Item, {}, boolean | { label: string }>
330
323
  /**
331
324
  * Whether to add edit buttons next to the list items.
332
325
  *
333
326
  * @defaultValue `false`
334
327
  */
335
- editable?: OrItemAccessor<
336
- $Item,
337
- {},
338
- | boolean
339
- | {
340
- label: string
341
- }
342
- >
328
+ editable?: OrItemAccessor<$Item, {}, boolean | { label: string }>
343
329
  /**
344
330
  * Whether to add delete buttons next to the list items.
345
331
  *
346
332
  * @defaultValue `false`
347
333
  */
348
- deletable?: OrItemAccessor<
349
- $Item,
350
- {},
351
- | boolean
352
- | {
353
- label: string
354
- }
355
- >
334
+ deletable?: OrItemAccessor<$Item, {}, boolean | { label: string }>
356
335
  /**
357
336
  * The column used for the order resulting from dragging around list entries
358
337
  * when the `draggable` property of the list schema is set to `true`.