@ditojs/admin 2.0.5 → 2.1.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 (116) hide show
  1. package/dist/dito-admin.es.js +1511 -1435
  2. package/dist/dito-admin.umd.js +4 -4
  3. package/dist/style.css +1 -1
  4. package/package.json +31 -31
  5. package/src/DitoAdmin.js +66 -31
  6. package/src/DitoComponent.js +4 -1
  7. package/src/DitoContext.js +13 -5
  8. package/src/{TypeComponent.js → DitoTypeComponent.js} +8 -5
  9. package/src/components/DitoAccount.vue +20 -19
  10. package/src/components/DitoButtons.vue +14 -12
  11. package/src/components/DitoClipboard.vue +16 -8
  12. package/src/components/DitoContainer.vue +56 -43
  13. package/src/components/DitoCreateButton.vue +20 -15
  14. package/src/components/DitoDialog.vue +69 -48
  15. package/src/components/DitoEditButtons.vue +16 -14
  16. package/src/components/DitoElement.vue +2 -3
  17. package/src/components/DitoErrors.vue +18 -13
  18. package/src/components/DitoForm.vue +41 -24
  19. package/src/components/DitoFormNested.vue +12 -10
  20. package/src/components/DitoHeader.vue +103 -69
  21. package/src/components/DitoLabel.vue +108 -81
  22. package/src/components/DitoMenu.vue +52 -36
  23. package/src/components/DitoPagination.vue +9 -7
  24. package/src/components/DitoPane.vue +53 -45
  25. package/src/components/DitoPanel.vue +62 -42
  26. package/src/components/DitoPanels.vue +11 -10
  27. package/src/components/DitoRoot.vue +57 -46
  28. package/src/components/DitoSchema.vue +179 -131
  29. package/src/components/DitoSchemaInlined.vue +39 -28
  30. package/src/components/DitoScopes.vue +41 -31
  31. package/src/components/DitoSpinner.vue +31 -40
  32. package/src/components/DitoTableCell.vue +9 -9
  33. package/src/components/DitoTableHead.vue +52 -37
  34. package/src/components/DitoTabs.vue +39 -29
  35. package/src/components/DitoTreeItem.vue +140 -86
  36. package/src/components/DitoVNode.vue +1 -1
  37. package/src/components/DitoView.vue +13 -11
  38. package/src/mixins/DataMixin.js +11 -9
  39. package/src/mixins/DitoMixin.js +47 -25
  40. package/src/mixins/EmitterMixin.js +2 -1
  41. package/src/mixins/ItemMixin.js +15 -10
  42. package/src/mixins/LoadingMixin.js +2 -1
  43. package/src/mixins/NumberMixin.js +15 -10
  44. package/src/mixins/OptionsMixin.js +24 -12
  45. package/src/mixins/ResourceMixin.js +42 -34
  46. package/src/mixins/RouteMixin.js +8 -8
  47. package/src/mixins/SortableMixin.js +1 -1
  48. package/src/mixins/SourceMixin.js +68 -34
  49. package/src/mixins/TypeMixin.js +5 -4
  50. package/src/mixins/ValidationMixin.js +3 -0
  51. package/src/styles/_base.scss +17 -0
  52. package/src/styles/_button.scss +212 -0
  53. package/src/styles/_imports.scss +2 -0
  54. package/src/styles/_layout.scss +22 -0
  55. package/src/styles/_notifications.scss +54 -0
  56. package/src/styles/_pulldown.scss +39 -0
  57. package/src/styles/_scroll.scss +15 -0
  58. package/src/styles/_settings.scss +68 -0
  59. package/src/styles/_sortable.scss +13 -0
  60. package/src/styles/_table.scss +224 -0
  61. package/src/styles/style.scss +9 -0
  62. package/src/types/DitoTypeButton.vue +72 -0
  63. package/src/types/{TypeCheckbox.vue → DitoTypeCheckbox.vue} +12 -11
  64. package/src/types/{TypeCheckboxes.vue → DitoTypeCheckboxes.vue} +21 -15
  65. package/src/types/{TypeCode.vue → DitoTypeCode.vue} +46 -34
  66. package/src/types/{TypeColor.vue → DitoTypeColor.vue} +71 -52
  67. package/src/types/{TypeComponent.vue → DitoTypeComponent.vue} +2 -2
  68. package/src/types/DitoTypeComputed.vue +54 -0
  69. package/src/types/DitoTypeDate.vue +64 -0
  70. package/src/types/DitoTypeLabel.vue +23 -0
  71. package/src/types/{TypeList.vue → DitoTypeList.vue} +83 -61
  72. package/src/types/{TypeMarkup.vue → DitoTypeMarkup.vue} +172 -122
  73. package/src/types/DitoTypeMultiselect.vue +434 -0
  74. package/src/types/DitoTypeNumber.vue +46 -0
  75. package/src/types/{TypeObject.vue → DitoTypeObject.vue} +41 -26
  76. package/src/types/{TypePanel.vue → DitoTypePanel.vue} +2 -2
  77. package/src/types/{TypeProgress.vue → DitoTypeProgress.vue} +4 -6
  78. package/src/types/{TypeRadio.vue → DitoTypeRadio.vue} +17 -13
  79. package/src/types/{TypeSection.vue → DitoTypeSection.vue} +17 -17
  80. package/src/types/{TypeSelect.vue → DitoTypeSelect.vue} +39 -35
  81. package/src/types/{TypeSlider.vue → DitoTypeSlider.vue} +29 -23
  82. package/src/types/{TypeSwitch.vue → DitoTypeSwitch.vue} +15 -13
  83. package/src/types/DitoTypeText.vue +77 -0
  84. package/src/types/{TypeTextarea.vue → DitoTypeTextarea.vue} +17 -14
  85. package/src/types/DitoTypeTreeList.vue +191 -0
  86. package/src/types/{TypeUpload.vue → DitoTypeUpload.vue} +92 -65
  87. package/src/types/index.js +26 -26
  88. package/src/utils/SchemaGraph.js +21 -13
  89. package/src/utils/accessor.js +17 -9
  90. package/src/utils/data.js +4 -1
  91. package/src/utils/filter.js +8 -10
  92. package/src/utils/options.js +3 -3
  93. package/src/utils/resource.js +12 -10
  94. package/src/utils/schema.js +190 -125
  95. package/src/utils/type.js +31 -20
  96. package/src/validations/_decimals.js +1 -2
  97. package/types/index.d.ts +27 -23
  98. package/src/styles/_base.sass +0 -15
  99. package/src/styles/_button.sass +0 -127
  100. package/src/styles/_imports.sass +0 -2
  101. package/src/styles/_layout.sass +0 -13
  102. package/src/styles/_notifications.sass +0 -33
  103. package/src/styles/_pulldown.sass +0 -26
  104. package/src/styles/_scroll.sass +0 -13
  105. package/src/styles/_settings.sass +0 -55
  106. package/src/styles/_sortable.sass +0 -9
  107. package/src/styles/_table.sass +0 -153
  108. package/src/styles/style.sass +0 -10
  109. package/src/types/TypeButton.vue +0 -73
  110. package/src/types/TypeComputed.vue +0 -53
  111. package/src/types/TypeDate.vue +0 -64
  112. package/src/types/TypeLabel.vue +0 -19
  113. package/src/types/TypeMultiselect.vue +0 -376
  114. package/src/types/TypeNumber.vue +0 -44
  115. package/src/types/TypeText.vue +0 -67
  116. package/src/types/TypeTreeList.vue +0 -164
@@ -0,0 +1,9 @@
1
+ @import '_imports';
2
+ @import '_base';
3
+ @import '_button';
4
+ @import '_pulldown';
5
+ @import '_layout';
6
+ @import '_scroll';
7
+ @import '_sortable';
8
+ @import '_table';
9
+ @import '_notifications';
@@ -0,0 +1,72 @@
1
+ <template lang="pug">
2
+ button.dito-button(
3
+ :id="dataPath"
4
+ ref="element"
5
+ :type="type"
6
+ :title="text"
7
+ :class="`dito-button-${verb}`"
8
+ v-bind="attributes"
9
+ ) {{ text }}
10
+ </template>
11
+
12
+ <script>
13
+ import DitoTypeComponent from '../DitoTypeComponent.js'
14
+ import { getSchemaAccessor } from '../utils/accessor.js'
15
+ import { hasResource } from '../utils/resource.js'
16
+ import { labelize } from '@ditojs/utils'
17
+
18
+ export default DitoTypeComponent.register(
19
+ ['button', 'submit'],
20
+ // @vue/component
21
+ {
22
+ defaultValue: () => undefined, // Callback to override `defaultValue: null`
23
+ excludeValue: true,
24
+ defaultWidth: 'auto',
25
+ // TODO: Consider making this work nicely:
26
+ // omitFlexGrow: true,
27
+
28
+ computed: {
29
+ verb() {
30
+ return this.verbs[this.name] || this.name
31
+ },
32
+
33
+ text: getSchemaAccessor('text', {
34
+ type: String,
35
+ get(text) {
36
+ return text || labelize(this.verb)
37
+ }
38
+ }),
39
+
40
+ closeForm: getSchemaAccessor('closeForm', {
41
+ type: Boolean,
42
+ default: false
43
+ }),
44
+
45
+ // @override
46
+ events() {
47
+ const { onFocus, onBlur, onClick } = this
48
+ return { onFocus, onBlur, onClick }
49
+ }
50
+ },
51
+
52
+ methods: {
53
+ async submit(options) {
54
+ return this.resourceComponent?.submit(this, options)
55
+ },
56
+
57
+ async onClick() {
58
+ const res = await this.emitEvent('click', {
59
+ parent: this.schemaComponent
60
+ })
61
+ // Have buttons that define resources call `this.submit()` by default:
62
+ if (
63
+ res === undefined && // Meaning: don't prevent default.
64
+ hasResource(this.schema)
65
+ ) {
66
+ await this.submit()
67
+ }
68
+ }
69
+ }
70
+ }
71
+ )
72
+ </script>
@@ -1,25 +1,26 @@
1
1
  <template lang="pug">
2
2
  input.dito-checkbox(
3
- ref="element"
4
3
  :id="dataPath"
5
- type="checkbox"
4
+ ref="element"
6
5
  v-model="value"
6
+ type="checkbox"
7
7
  v-bind="attributes"
8
8
  )
9
9
  </template>
10
10
 
11
- <style lang="sass">
12
- @import '../styles/_imports'
13
-
14
- .dito-checkbox
15
- @extend %input-borderless
16
- </style>
17
-
18
11
  <script>
19
- import TypeComponent from '../TypeComponent.js'
12
+ import DitoTypeComponent from '../DitoTypeComponent.js'
20
13
 
21
14
  // @vue/component
22
- export default TypeComponent.register('checkbox', {
15
+ export default DitoTypeComponent.register('checkbox', {
23
16
  nativeField: true
24
17
  })
25
18
  </script>
19
+
20
+ <style lang="scss">
21
+ @import '../styles/_imports';
22
+
23
+ .dito-checkbox {
24
+ @extend %input-borderless;
25
+ }
26
+ </style>
@@ -3,34 +3,26 @@ ul.dito-checkboxes(
3
3
  :id="dataPath"
4
4
  :class="`dito-layout-${schema.layout || 'vertical'}`"
5
5
  )
6
- li(v-for="option in options")
6
+ li(
7
+ v-for="option in options"
8
+ )
7
9
  label
8
10
  input.dito-checkbox(
9
11
  ref="element"
12
+ v-model="selectedOptions"
10
13
  type="checkbox"
11
14
  :value="getValueForOption(option)"
12
- v-model="selectedOptions"
13
15
  v-bind="attributes"
14
16
  )
15
17
  | {{ getLabelForOption(option) }}
16
18
  </template>
17
19
 
18
- <style lang="sass">
19
- @import '../styles/_imports'
20
-
21
- .dito-checkboxes
22
- label
23
- @extend %input-borderless
24
- .dito-checkbox
25
- margin-right: $form-spacing
26
- </style>
27
-
28
20
  <script>
29
- import TypeComponent from '../TypeComponent.js'
21
+ import DitoTypeComponent from '../DitoTypeComponent.js'
30
22
  import OptionsMixin from '../mixins/OptionsMixin.js'
31
23
 
32
24
  // @vue/component
33
- export default TypeComponent.register('checkboxes', {
25
+ export default DitoTypeComponent.register('checkboxes', {
34
26
  mixins: [OptionsMixin],
35
27
 
36
28
  nativeField: true,
@@ -43,9 +35,23 @@ export default TypeComponent.register('checkboxes', {
43
35
  },
44
36
 
45
37
  set(option) {
46
- this.selectedValue = (option || [])
38
+ this.selectedValue = option || []
47
39
  }
48
40
  }
49
41
  }
50
42
  })
51
43
  </script>
44
+
45
+ <style lang="scss">
46
+ @import '../styles/_imports';
47
+
48
+ .dito-checkboxes {
49
+ label {
50
+ @extend %input-borderless;
51
+ }
52
+
53
+ .dito-checkbox {
54
+ margin-right: $form-spacing;
55
+ }
56
+ }
57
+ </style>
@@ -1,49 +1,18 @@
1
1
  <template lang="pug">
2
2
  .dito-code(
3
- ref="code"
4
3
  :id="dataPath"
4
+ ref="code"
5
5
  :style="style"
6
6
  )
7
7
  </template>
8
8
 
9
- <style lang="sass">
10
- @import '../styles/_imports'
11
-
12
- .dito-code
13
- @extend %input
14
- position: relative
15
- // For proper sizing of content along with :style="style" setting above,
16
- // for proper line-height calculation.
17
- padding: $input-padding
18
- &.dito-width-fill
19
- width: auto
20
- .codeflask
21
- background: none
22
- // Ignore the parent padding defined above which is only needed to set
23
- // the desired height with :style="style".
24
- top: 0
25
- left: 0
26
- .codeflask__textarea,
27
- .codeflask__pre
28
- // Use same padding as .dito-code
29
- padding: $input-padding
30
- .codeflask__textarea,
31
- .codeflask__code,
32
- .codeflask__lines
33
- font-family: $font-family-mono
34
- font-size: var(--font-size)
35
- line-height: var(--line-height)
36
- .codeflask__lines
37
- padding: $input-padding
38
- </style>
39
-
40
9
  <script>
41
- import TypeComponent from '../TypeComponent.js'
10
+ import DitoTypeComponent from '../DitoTypeComponent.js'
42
11
  import DomMixin from '../mixins/DomMixin.js'
43
12
  import CodeFlask from 'codeflask'
44
13
 
45
14
  // @vue/component
46
- export default TypeComponent.register('code', {
15
+ export default DitoTypeComponent.register('code', {
47
16
  mixins: [DomMixin],
48
17
 
49
18
  computed: {
@@ -128,3 +97,46 @@ export default TypeComponent.register('code', {
128
97
  }
129
98
  })
130
99
  </script>
100
+
101
+ <style lang="scss">
102
+ @import '../styles/_imports';
103
+
104
+ .dito-code {
105
+ @extend %input;
106
+
107
+ position: relative;
108
+ // For proper sizing of content along with :style="style" setting above,
109
+ // for proper line-height calculation.
110
+ padding: $input-padding;
111
+
112
+ &.dito-width-fill {
113
+ width: auto;
114
+ }
115
+
116
+ .codeflask {
117
+ background: none;
118
+ // Ignore the parent padding defined above which is only needed to set
119
+ // the desired height with :style="style".
120
+ top: 0;
121
+ left: 0;
122
+ }
123
+
124
+ .codeflask__textarea,
125
+ .codeflask__pre {
126
+ // Use same padding as .dito-code
127
+ padding: $input-padding;
128
+ }
129
+
130
+ .codeflask__textarea,
131
+ .codeflask__code,
132
+ .codeflask__lines {
133
+ font-family: $font-family-mono;
134
+ font-size: var(--font-size);
135
+ line-height: var(--line-height);
136
+ }
137
+
138
+ .codeflask__lines {
139
+ padding: $input-padding;
140
+ }
141
+ }
142
+ </style>
@@ -1,16 +1,16 @@
1
1
  <template lang="pug">
2
- trigger.dito-color(
3
- trigger="click"
2
+ Trigger.dito-color(
4
3
  v-model:show="showPopup"
4
+ trigger="click"
5
5
  )
6
6
  template(#trigger)
7
7
  .dito-input(:class="{ 'dito-focus': showPopup }")
8
8
  input(
9
- ref="element"
10
9
  :id="dataPath"
10
+ ref="element"
11
+ v-model="hexValue"
11
12
  type="input"
12
13
  size="8"
13
- v-model="hexValue"
14
14
  v-bind="attributes"
15
15
  )
16
16
  .dito-color-preview.dito-inherit-focus(
@@ -19,62 +19,27 @@ trigger.dito-color(
19
19
  div(:style="{ background: `#${hexValue || '00000000'}` }")
20
20
  button.dito-button-clear.dito-button-overlay(
21
21
  v-if="showClearButton"
22
- @click.stop="clear"
23
22
  :disabled="disabled"
23
+ @click.stop="clear"
24
24
  )
25
25
  template(#popup)
26
- sketch-picker.dito-color-picker(
26
+ SketchPicker.dito-color-picker(
27
27
  v-model="colorValue"
28
- :disable-alpha="!alpha"
29
- :disable-fields="!inputs"
30
- :preset-colors="presets"
28
+ :disableAlpha="!alpha"
29
+ :disableFields="!inputs"
30
+ :presetColors="presets"
31
31
  )
32
32
  </template>
33
33
 
34
- <style lang="sass">
35
- @import '../styles/_imports'
36
-
37
- $color-swatch-width: $pattern-transparency-size
38
- $color-swatch-radius: $border-radius - $border-width
39
- .dito-color
40
- .dito-input
41
- display: block
42
- position: relative
43
- input
44
- box-sizing: border-box
45
- font-variant-numeric: tabular-nums
46
- padding-right: $color-swatch-width
47
- .dito-button-clear
48
- margin-right: $color-swatch-width
49
- .dito-color-picker
50
- margin: $popup-margin
51
- border: $border-style
52
- border-radius: $border-radius
53
- background: $color-white
54
- box-shadow: $shadow-window
55
- .dito-color-preview
56
- background: $pattern-transparency
57
- border-left: $border-style
58
- &,
59
- div
60
- position: absolute
61
- width: $color-swatch-width
62
- top: 0
63
- right: 0
64
- bottom: 0
65
- border-top-right-radius: $color-swatch-radius
66
- border-bottom-right-radius: $color-swatch-radius
67
- </style>
68
-
69
34
  <script>
70
35
  import tinycolor from 'tinycolor2'
71
36
  import { Sketch as SketchPicker } from '@lk77/vue3-color'
72
- import TypeComponent from '../TypeComponent.js'
37
+ import DitoTypeComponent from '../DitoTypeComponent.js'
73
38
  import { Trigger } from '@ditojs/ui/src'
74
39
  import { getSchemaAccessor } from '../utils/accessor.js'
75
40
 
76
41
  // @vue/component
77
- export default TypeComponent.register('color', {
42
+ export default DitoTypeComponent.register('color', {
78
43
  components: { Trigger, SketchPicker },
79
44
 
80
45
  data() {
@@ -92,11 +57,14 @@ export default TypeComponent.register('color', {
92
57
 
93
58
  set(value) {
94
59
  const format = this.colorFormat
95
- const key = {
96
- // NOTE: vue3-color calls it 'hex', while tinycolor calls it 'hex6'
97
- hex: value?.a < 1 ? 'hex8' : 'hex',
98
- rgb: 'rgba'
99
- }[format] || format
60
+ const key = (
61
+ {
62
+ // NOTE: vue3-color calls it 'hex', while tinycolor calls it 'hex6'
63
+ hex: value?.a < 1 ? 'hex8' : 'hex',
64
+ rgb: 'rgba'
65
+ }[format] ||
66
+ format
67
+ )
100
68
  if (key) {
101
69
  this.value = value[key]
102
70
  } else {
@@ -109,10 +77,14 @@ export default TypeComponent.register('color', {
109
77
  hexValue: {
110
78
  get() {
111
79
  if (this.value == null) {
80
+ // TODO: Fix side-effects
81
+ // eslint-disable-next-line vue/no-side-effects-in-computed-properties
112
82
  this.convertedHexValue = null
113
83
  } else if (!this.focused) {
114
84
  const color = tinycolor(this.value)
115
85
  if (color.isValid()) {
86
+ // TODO: Fix side-effects
87
+ // eslint-disable-next-line
116
88
  this.convertedHexValue = color
117
89
  .toString(color.getAlpha() < 1 ? 'hex8' : 'hex6')
118
90
  .slice(1)
@@ -183,5 +155,52 @@ export default TypeComponent.register('color', {
183
155
  }
184
156
  }
185
157
  })
186
-
187
158
  </script>
159
+
160
+ <style lang="scss">
161
+ @import '../styles/_imports';
162
+
163
+ $color-swatch-width: $pattern-transparency-size;
164
+ $color-swatch-radius: $border-radius - $border-width;
165
+
166
+ .dito-color {
167
+ .dito-input {
168
+ display: block;
169
+ position: relative;
170
+
171
+ input {
172
+ box-sizing: border-box;
173
+ font-variant-numeric: tabular-nums;
174
+ padding-right: $color-swatch-width;
175
+ }
176
+ }
177
+
178
+ .dito-button-clear {
179
+ margin-right: $color-swatch-width;
180
+ }
181
+
182
+ .dito-color-picker {
183
+ margin: $popup-margin;
184
+ border: $border-style;
185
+ border-radius: $border-radius;
186
+ background: $color-white;
187
+ box-shadow: $shadow-window;
188
+ }
189
+
190
+ .dito-color-preview {
191
+ background: $pattern-transparency;
192
+ border-left: $border-style;
193
+
194
+ &,
195
+ div {
196
+ position: absolute;
197
+ width: $color-swatch-width;
198
+ top: 0;
199
+ right: 0;
200
+ bottom: 0;
201
+ border-top-right-radius: $color-swatch-radius;
202
+ border-bottom-right-radius: $color-swatch-radius;
203
+ }
204
+ }
205
+ }
206
+ </style>
@@ -14,11 +14,11 @@ component(
14
14
  // component: import('./component')
15
15
  // }
16
16
 
17
- import TypeComponent from '../TypeComponent.js'
17
+ import DitoTypeComponent from '../DitoTypeComponent.js'
18
18
  import { resolveSchemaComponent } from '../utils/schema.js'
19
19
 
20
20
  // @vue/component
21
- export default TypeComponent.register('component', {
21
+ 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`
@@ -0,0 +1,54 @@
1
+ <template lang="pug">
2
+ //- TODO: Find a better way to trigger evaluation of `value` that dose not
3
+ //- involve actually rendering it when the component is not visible.
4
+ input.dito-text.dito-input(
5
+ :id="dataPath"
6
+ ref="element"
7
+ :name="name"
8
+ type="text"
9
+ :value="value"
10
+ :disabled="disabled"
11
+ :readonly="true"
12
+ )
13
+ </template>
14
+
15
+ <script>
16
+ import DitoTypeComponent from '../DitoTypeComponent.js'
17
+ import TypeMixin from '../mixins/TypeMixin.js'
18
+ import DataMixin from '../mixins/DataMixin.js'
19
+
20
+ export default DitoTypeComponent.register(
21
+ ['computed', 'data', 'hidden'],
22
+ // @vue/component
23
+ {
24
+ mixins: [DataMixin],
25
+
26
+ defaultValue: () => undefined, // Callback to override `defaultValue: null`
27
+ defaultVisible: false,
28
+
29
+ computed: {
30
+ value: {
31
+ get() {
32
+ const { schema } = this
33
+ if (schema.data || schema.dataPath) {
34
+ const value = this.handleDataSchema(schema, 'schema', {
35
+ // Modifying `this.data` below triggers another call of the
36
+ // `value` getter, so use a value of 2 for `resolveCounter` to
37
+ // return the resolved data twice.
38
+ resolveCounter: 2
39
+ })
40
+ // TODO: Fix side-effects
41
+ // eslint-disable-next-line
42
+ this.data[this.name] = value
43
+ }
44
+ return TypeMixin.computed.value.get.call(this)
45
+ },
46
+
47
+ set(value) {
48
+ TypeMixin.computed.value.set.call(this, value)
49
+ }
50
+ }
51
+ }
52
+ }
53
+ )
54
+ </script>
@@ -0,0 +1,64 @@
1
+ <template lang="pug">
2
+ .dito-date
3
+ component(
4
+ :is="getComponent(type)"
5
+ :id="dataPath"
6
+ ref="element"
7
+ v-model="dateValue"
8
+ :locale="locale"
9
+ :dateFormat="{ ...api.formats.date, ...dateFormat }"
10
+ v-bind="attributes"
11
+ )
12
+ </template>
13
+
14
+ <script>
15
+ import DitoTypeComponent from '../DitoTypeComponent.js'
16
+ import { getSchemaAccessor } from '../utils/accessor.js'
17
+ import { DatePicker, TimePicker, DateTimePicker } from '@ditojs/ui/src'
18
+ import { isDate } from '@ditojs/utils'
19
+
20
+ export default DitoTypeComponent.register(
21
+ ['date', 'datetime', 'time'],
22
+ // @vue/component
23
+ {
24
+ components: { DatePicker, TimePicker, DateTimePicker },
25
+ // TODO: This is only here so we get placeholder added. Come up with a
26
+ // better way to support attributes per component (a list of actually
27
+ // supported attributes)
28
+ nativeField: true,
29
+ textField: true,
30
+
31
+ computed: {
32
+ dateValue: {
33
+ get() {
34
+ const { value } = this
35
+ return value ? new Date(value) : value
36
+ },
37
+
38
+ set(value) {
39
+ this.value = value
40
+ }
41
+ },
42
+
43
+ dateFormat: getSchemaAccessor('dateFormat', {
44
+ type: Object,
45
+ default: null
46
+ })
47
+ },
48
+
49
+ methods: {
50
+ getComponent(type) {
51
+ return {
52
+ date: 'date-picker',
53
+ time: 'time-picker',
54
+ datetime: 'date-time-picker'
55
+ }[type]
56
+ }
57
+ },
58
+
59
+ processValue(schema, value) {
60
+ return isDate(value) ? value.toISOString() : value
61
+ }
62
+ }
63
+ )
64
+ </script>
@@ -0,0 +1,23 @@
1
+ <template lang="pug">
2
+ DitoLabel.dito-label-component(
3
+ :label="value"
4
+ :dataPath="dataPath"
5
+ )
6
+ </template>
7
+
8
+ <script>
9
+ import DitoTypeComponent from '../DitoTypeComponent.js'
10
+
11
+ // @vue/component
12
+ export default DitoTypeComponent.register('label', {
13
+ excludeValue: true,
14
+ generateLabel: false
15
+ })
16
+ </script>
17
+
18
+ <style lang="scss">
19
+ .dito-label-component {
20
+ display: flex;
21
+ height: 2em;
22
+ }
23
+ </style>