@ditojs/admin 2.25.0 → 2.26.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.
- package/dist/dito-admin.es.js +1445 -1394
- package/dist/dito-admin.umd.js +5 -5
- package/dist/style.css +1 -1
- package/package.json +38 -38
- package/src/DitoContext.js +6 -0
- package/src/components/DitoForm.vue +76 -56
- package/src/components/{DitoFormNested.vue → DitoFormInlined.vue} +3 -3
- package/src/components/DitoPane.vue +2 -2
- package/src/components/DitoSchema.vue +24 -5
- package/src/components/index.js +1 -1
- package/src/mixins/DitoMixin.js +24 -18
- package/src/mixins/EmitterMixin.js +2 -0
- package/src/mixins/OptionsMixin.js +4 -1
- package/src/mixins/RouteMixin.js +0 -4
- package/src/mixins/SourceMixin.js +1 -1
- package/src/styles/_table.scss +1 -1
- package/src/types/DitoTypeColor.vue +2 -1
- package/src/types/DitoTypeComputed.vue +2 -1
- package/src/utils/schema.js +41 -17
package/src/utils/schema.js
CHANGED
|
@@ -23,6 +23,7 @@ import { markRaw } from 'vue'
|
|
|
23
23
|
|
|
24
24
|
const typeComponents = {}
|
|
25
25
|
const unknownTypeReported = {}
|
|
26
|
+
const emptySchema = {}
|
|
26
27
|
|
|
27
28
|
export function registerTypeComponent(type, component) {
|
|
28
29
|
typeComponents[type] = component
|
|
@@ -121,7 +122,12 @@ export function getSchemaIdentifier(schema) {
|
|
|
121
122
|
return JSON.stringify(schema)
|
|
122
123
|
}
|
|
123
124
|
|
|
124
|
-
|
|
125
|
+
const resolvedSchemas = new WeakMap()
|
|
126
|
+
export async function resolveSchema(value, unwrapModule = false) {
|
|
127
|
+
if (resolvedSchemas.has(value)) {
|
|
128
|
+
return resolvedSchemas.get(value)
|
|
129
|
+
}
|
|
130
|
+
let schema = value
|
|
125
131
|
if (isFunction(schema)) {
|
|
126
132
|
schema = schema()
|
|
127
133
|
}
|
|
@@ -146,6 +152,7 @@ export async function resolveSchema(schema, unwrapModule = false) {
|
|
|
146
152
|
}
|
|
147
153
|
}
|
|
148
154
|
}
|
|
155
|
+
resolvedSchemas.set(value, schema)
|
|
149
156
|
return schema
|
|
150
157
|
}
|
|
151
158
|
|
|
@@ -235,29 +242,34 @@ export async function resolveSchemaComponents(schemas) {
|
|
|
235
242
|
await mapConcurrently(Object.values(schemas || {}), resolveSchemaComponent)
|
|
236
243
|
}
|
|
237
244
|
|
|
245
|
+
const processedSchemas = new WeakSet()
|
|
238
246
|
export async function processSchemaComponents(
|
|
239
247
|
api,
|
|
240
248
|
schema,
|
|
241
249
|
routes = null,
|
|
242
250
|
level = 0
|
|
243
251
|
) {
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
252
|
+
if (schema && !processedSchemas.has(schema)) {
|
|
253
|
+
processedSchemas.add(schema)
|
|
254
|
+
|
|
255
|
+
const promises = []
|
|
256
|
+
const process = (component, name, relativeLevel) => {
|
|
257
|
+
promises.push(
|
|
258
|
+
processSchemaComponent(
|
|
259
|
+
api,
|
|
260
|
+
component,
|
|
261
|
+
name,
|
|
262
|
+
routes,
|
|
263
|
+
level + relativeLevel
|
|
264
|
+
)
|
|
253
265
|
)
|
|
254
|
-
|
|
255
|
-
}
|
|
266
|
+
}
|
|
256
267
|
|
|
257
|
-
|
|
258
|
-
|
|
268
|
+
iterateNestedSchemaComponents(schema, process)
|
|
269
|
+
iterateSchemaComponents(getPanelSchemas(schema), process)
|
|
259
270
|
|
|
260
|
-
|
|
271
|
+
await Promise.all(promises)
|
|
272
|
+
}
|
|
261
273
|
}
|
|
262
274
|
|
|
263
275
|
export async function processSchemaComponent(
|
|
@@ -324,7 +336,7 @@ export function processSchemaDefaults(api, schema) {
|
|
|
324
336
|
if (schema[key] === undefined) {
|
|
325
337
|
schema[key] = value
|
|
326
338
|
} else {
|
|
327
|
-
schema[key] = assignDeeply(
|
|
339
|
+
schema[key] = assignDeeply(schema[key], value)
|
|
328
340
|
}
|
|
329
341
|
}
|
|
330
342
|
}
|
|
@@ -518,7 +530,15 @@ export function getItemFormSchemaFromForms(forms, item) {
|
|
|
518
530
|
}
|
|
519
531
|
|
|
520
532
|
export function getItemFormSchema(schema, item, context) {
|
|
521
|
-
return
|
|
533
|
+
return (
|
|
534
|
+
getItemFormSchemaFromForms(getFormSchemas(schema, context), item) ||
|
|
535
|
+
// Always return a schema object so we don't need to check for it.
|
|
536
|
+
emptySchema
|
|
537
|
+
)
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
export function isEmptySchema(schema) {
|
|
541
|
+
return schema === emptySchema
|
|
522
542
|
}
|
|
523
543
|
|
|
524
544
|
export function isCompact(schema) {
|
|
@@ -672,11 +692,15 @@ export function computeValue(schema, data, name, dataPath, {
|
|
|
672
692
|
if (value !== undefined) {
|
|
673
693
|
// Access `data[name]` directly to update the value without calling
|
|
674
694
|
// parse():
|
|
695
|
+
// TODO: Fix side-effects
|
|
696
|
+
// eslint-disable-next-line vue/no-side-effects-in-computed-properties
|
|
675
697
|
data[name] = value
|
|
676
698
|
}
|
|
677
699
|
}
|
|
678
700
|
// If the value is still missing after compute, set the default for it:
|
|
679
701
|
if (!(name in data) && !ignoreMissingValue(schema)) {
|
|
702
|
+
// TODO: Fix side-effects
|
|
703
|
+
// eslint-disable-next-line vue/no-side-effects-in-computed-properties
|
|
680
704
|
data[name] = getDefaultValue(schema)
|
|
681
705
|
}
|
|
682
706
|
// Now access the value. This is important for reactivity and needs to
|