@ditojs/admin 2.29.0 → 2.30.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ditojs/admin",
3
- "version": "2.29.0",
3
+ "version": "2.30.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.29.0",
37
- "@ditojs/utils": "^2.29.0",
36
+ "@ditojs/ui": "^2.30.0",
37
+ "@ditojs/utils": "^2.30.0",
38
38
  "@kyvg/vue3-notification": "^3.2.1",
39
39
  "@lk77/vue3-color": "^3.0.6",
40
40
  "@tiptap/core": "^2.3.0",
@@ -67,23 +67,23 @@
67
67
  "sortablejs": "^1.15.2",
68
68
  "tinycolor2": "^1.6.0",
69
69
  "tippy.js": "^6.3.7",
70
- "type-fest": "^4.15.0",
70
+ "type-fest": "^4.17.0",
71
71
  "vue": "3.4.10",
72
72
  "vue-multiselect": "^3.0.0",
73
73
  "vue-router": "^4.3.2",
74
74
  "vue-upload-component": "^3.1.15"
75
75
  },
76
76
  "devDependencies": {
77
- "@ditojs/build": "^2.29.0",
77
+ "@ditojs/build": "^2.30.0",
78
78
  "@vitejs/plugin-vue": "^5.0.4",
79
- "@vue/compiler-sfc": "3.4.23",
79
+ "@vue/compiler-sfc": "3.4.25",
80
80
  "pug": "^3.0.2",
81
81
  "sass": "1.75.0",
82
82
  "typescript": "^5.4.5",
83
83
  "vite": "^5.2.10"
84
84
  },
85
85
  "types": "types",
86
- "gitHead": "bdf4f66c3d6232f2322dacb088a0611f1e07dc7b",
86
+ "gitHead": "59a02102ca6fd2340fcc51961b2879198b396410",
87
87
  "scripts": {
88
88
  "build": "vite build",
89
89
  "watch": "yarn build --mode 'development' --watch",
@@ -261,6 +261,10 @@ export default DitoComponent.component('DitoContainer', {
261
261
  display: none;
262
262
  }
263
263
 
264
+ &:empty {
265
+ padding: 0;
266
+ }
267
+
264
268
  .dito-pane > & {
265
269
  .dito-page--width-80 & {
266
270
  flex-grow: 1;
@@ -284,11 +288,7 @@ export default DitoComponent.component('DitoContainer', {
284
288
  }
285
289
  }
286
290
 
287
- &:empty {
288
- padding: 0;
289
- }
290
-
291
- &--single {
291
+ :not(.dito-pane) > &--single {
292
292
  height: 100%; // So that list buttons can be sticky at the bottom;
293
293
  // Just like on DitoPane, clear settings from above.
294
294
  padding: 0;
@@ -185,7 +185,7 @@ export default {
185
185
  }
186
186
 
187
187
  if (nativeField) {
188
- attributes.name = this.name
188
+ attributes.name = this.dataPath
189
189
  if (this.label) {
190
190
  attributes.title = this.label
191
191
  }
@@ -34,8 +34,9 @@ Trigger.dito-color(
34
34
  <script>
35
35
  import tinycolor from 'tinycolor2'
36
36
  import { Sketch as SketchPicker } from '@lk77/vue3-color'
37
- import DitoTypeComponent from '../DitoTypeComponent.js'
37
+ import { isObject } from '@ditojs/utils'
38
38
  import { Trigger } from '@ditojs/ui/src'
39
+ import DitoTypeComponent from '../DitoTypeComponent.js'
39
40
  import { getSchemaAccessor } from '../utils/accessor.js'
40
41
 
41
42
  // @vue/component
@@ -45,61 +46,53 @@ export default DitoTypeComponent.register('color', {
45
46
  data() {
46
47
  return {
47
48
  showPopup: false,
48
- convertedHexValue: null
49
+ convertedValue: null
49
50
  }
50
51
  },
51
52
 
52
53
  computed: {
54
+ canUpdateValue() {
55
+ return !this.focused || this.readonly
56
+ },
57
+
53
58
  colorValue: {
54
59
  get() {
55
- return this.value || {}
60
+ return (
61
+ this.convertedValue ||
62
+ this.value ||
63
+ (this.colorFormat === 'hex' ? '' : {})
64
+ )
56
65
  },
57
66
 
58
67
  set(value) {
59
- const format = this.colorFormat
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
- )
68
- if (key) {
69
- this.value = value[key]
70
- } else {
71
- this.value = tinycolor(value).toString(format)
72
- }
68
+ this.value = convertColor(value, this.colorFormat)
73
69
  this.onChange()
74
70
  }
75
71
  },
76
72
 
77
73
  hexValue: {
78
74
  get() {
79
- if (this.value == null) {
80
- // TODO: Fix side-effects
81
- // eslint-disable-next-line vue/no-side-effects-in-computed-properties
82
- this.convertedHexValue = null
83
- } else if (
84
- !this.focused ||
85
- this.$refs.element.hasAttribute('readonly')
86
- ) {
87
- const color = tinycolor(this.value)
88
- if (color.isValid()) {
89
- // TODO: Fix side-effects
90
- // eslint-disable-next-line max-len
91
- // eslint-disable-next-line vue/no-side-effects-in-computed-properties
92
- this.convertedHexValue = color
75
+ const color = tinycolor(this.value)
76
+ return color.isValid()
77
+ ? color
93
78
  .toString(color.getAlpha() < 1 ? 'hex8' : 'hex6')
94
79
  .slice(1)
95
80
  .toUpperCase()
96
- }
97
- }
98
- return this.convertedHexValue
81
+ : null
99
82
  },
100
83
 
101
84
  set(value) {
102
- this.convertedHexValue = value
85
+ const color = tinycolor(value)
86
+ if (color.isValid()) {
87
+ const convertedValue = convertColor(value, this.colorFormat)
88
+ if (this.canUpdateValue) {
89
+ this.value = convertedValue
90
+ } else {
91
+ // Store to change later, once `canUpdateValue` is true again.
92
+ // See `watch` below.
93
+ this.convertedValue = convertedValue
94
+ }
95
+ }
103
96
  }
104
97
  },
105
98
 
@@ -144,8 +137,59 @@ export default DitoTypeComponent.register('color', {
144
137
  '#00000000'
145
138
  ]
146
139
  })
147
- }
140
+ },
141
+
142
+ watch: {
143
+ canUpdateValue(canUpdateValue) {
144
+ if (canUpdateValue && this.convertedValue !== null) {
145
+ this.value = this.convertedValue
146
+ this.convertedValue = null
147
+ }
148
+ }
149
+ },
150
+
151
+ methods: {}
148
152
  })
153
+
154
+ function convertColor(color, format) {
155
+ return isObject(color) // a vue3-color color object
156
+ ? color[
157
+ {
158
+ hex: color?.a < 1 ? 'hex8' : 'hex',
159
+ rgb: 'rgba'
160
+ }[format] ||
161
+ format
162
+ ]
163
+ : toColorFormat(tinycolor(color), format)
164
+ }
165
+
166
+ // This should really be in tinycolor, but it only has the string equivalent
167
+ // of it.
168
+ function toColorFormat(color, format) {
169
+ switch (format) {
170
+ case 'rgb':
171
+ return color.toRgb()
172
+ case 'prgb':
173
+ return color.toPercentageRgb()
174
+ case 'hex':
175
+ case 'hex6':
176
+ return color.toHex()
177
+ case 'hex3':
178
+ return color.toHex(true)
179
+ case 'hex4':
180
+ return color.toHex8(true)
181
+ case 'hex8':
182
+ return color.toHex8()
183
+ case 'name':
184
+ return color.toName()
185
+ case 'hsl':
186
+ return color.toHsl()
187
+ case 'hsv':
188
+ return color.toHsv()
189
+ default:
190
+ return color.toHex()
191
+ }
192
+ }
149
193
  </script>
150
194
 
151
195
  <style lang="scss">