@ditojs/admin 2.0.5 → 2.1.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.
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
@@ -5,7 +5,15 @@ import { getUid } from './uid.js'
5
5
  import { SchemaGraph } from './SchemaGraph.js'
6
6
  import { appendDataPath, isTemporaryId } from './data.js'
7
7
  import {
8
- isObject, isString, isArray, isFunction, isPromise, clone, camelize, isModule,
8
+ isObject,
9
+ isString,
10
+ isArray,
11
+ isFunction,
12
+ isPromise,
13
+ isModule,
14
+ clone,
15
+ merge,
16
+ camelize,
9
17
  mapConcurrently
10
18
  } from '@ditojs/utils'
11
19
  import { markRaw } from 'vue'
@@ -27,16 +35,17 @@ export function getTypeComponent(type, allowNull = false) {
27
35
  return component
28
36
  }
29
37
 
30
- export function forEachSchemaComponent(schema, callback) {
38
+ function getSchemas(schema) {
39
+ return schema
40
+ ? [...Object.values(schema.tabs || {}), schema]
41
+ : []
42
+ }
43
+
44
+ export function iterateSchemaComponents(schema, callback) {
31
45
  if (isSingleComponentView(schema)) {
32
- const res = callback(schema.component, schema.name)
33
- if (res !== undefined) {
34
- return res
35
- }
46
+ return callback(schema.component, schema.name)
36
47
  } else {
37
- const schemas = schema
38
- ? [...Object.values(schema.tabs || {}), schema]
39
- : []
48
+ const schemas = getSchemas(schema)
40
49
  for (const schema of schemas) {
41
50
  for (const [name, component] of Object.entries(schema.components || {})) {
42
51
  const res = callback(component, name)
@@ -49,24 +58,32 @@ export function forEachSchemaComponent(schema, callback) {
49
58
  }
50
59
 
51
60
  export function findSchemaComponent(schema, callback) {
52
- return forEachSchemaComponent(
53
- schema,
54
- (component, name) => callback(component, name) ? component : undefined
55
- ) || null
61
+ return (
62
+ iterateSchemaComponents(
63
+ schema,
64
+ (component, name) => (callback(component, name) ? component : undefined)
65
+ ) || null
66
+ )
56
67
  }
57
68
 
58
69
  export function someSchemaComponent(schema, callback) {
59
- return forEachSchemaComponent(
60
- schema,
61
- (component, name) => callback(component, name) ? true : undefined
62
- ) === true
70
+ return (
71
+ iterateSchemaComponents(
72
+ schema,
73
+ (component, name) => (callback(component, name) ? true : undefined)
74
+ ) ===
75
+ true
76
+ )
63
77
  }
64
78
 
65
79
  export function everySchemaComponent(schema, callback) {
66
- return forEachSchemaComponent(
67
- schema,
68
- (component, name) => !callback(component, name) ? false : undefined
69
- ) !== false
80
+ return (
81
+ iterateSchemaComponents(
82
+ schema,
83
+ (component, name) => (!callback(component, name) ? false : undefined)
84
+ ) !==
85
+ false
86
+ )
70
87
  }
71
88
 
72
89
  export function isSchema(schema) {
@@ -174,18 +191,17 @@ export async function resolveSchemaComponents(schemas) {
174
191
  }
175
192
 
176
193
  export async function processView(component, api, schema, name) {
177
- const children = []
178
194
  processRouteSchema(api, schema, name)
195
+ processDefaults(api, schema)
179
196
  await resolvePanels(schema)
197
+ const children = []
180
198
  if (isView(schema)) {
181
- let level = 0
182
199
  if (isSingleComponentView(schema)) {
183
- await processComponent(api, schema.component, name, children, level)
200
+ await processComponent(api, schema.component, name, children, 0)
184
201
  } else {
185
202
  // A multi-component view, start at level 1
186
- await processSchemaComponents(api, schema, children, ++level)
203
+ await processSchemaComponents(api, schema, children, 1)
187
204
  }
188
- schema.level = level
189
205
  } else {
190
206
  throw new Error(`Invalid view schema: '${getSchemaIdentifier(schema)}'`)
191
207
  }
@@ -201,34 +217,62 @@ export async function processView(component, api, schema, name) {
201
217
  }
202
218
 
203
219
  export async function processComponent(api, schema, name, routes, level) {
204
- schema.level = level
220
+ processDefaults(api, schema)
205
221
  // Delegate schema processing to the actual type components.
206
222
  await getTypeOptions(schema)?.processSchema?.(
207
- api, schema, name, routes, level
223
+ api,
224
+ schema,
225
+ name,
226
+ routes,
227
+ level
208
228
  )
209
229
  }
210
230
 
231
+ export function processDefaults(api, schema) {
232
+ let defaults = api.defaults[schema.type]
233
+ if (defaults) {
234
+ if (isFunction(defaults)) {
235
+ defaults = defaults(schema)
236
+ }
237
+ if (isObject(defaults)) {
238
+ for (const [key, value] of Object.entries(defaults)) {
239
+ if (schema[key] === undefined) {
240
+ schema[key] = value
241
+ } else {
242
+ schema[key] = merge(value, schema[key])
243
+ }
244
+ }
245
+ }
246
+ }
247
+ }
248
+
211
249
  export function processRouteSchema(api, schema, name) {
212
- // Used for view and source schemas, see SourceMixin
250
+ // Used for view and source schemas, see SourceMixin.
213
251
  schema.name = name
214
252
  schema.path ||= api.normalizePath(name)
215
253
  }
216
254
 
217
255
  export async function processSchemaComponents(api, schema, routes, level) {
218
256
  const promises = []
219
- forEachSchemaComponent(schema, (component, name) => {
257
+ iterateSchemaComponents(schema, (component, name) => {
220
258
  promises.push(processComponent(api, component, name, routes, level))
221
259
  })
222
260
  await Promise.all(promises)
223
261
  }
224
262
 
225
263
  export async function processForms(api, schema, level) {
264
+ const processForm = async form => {
265
+ form = await resolveForm(form)
266
+ processDefaults(api, schema)
267
+ return form
268
+ }
269
+
226
270
  // First resolve the forms and store the results back on the schema.
227
271
  let { form, forms, components } = schema
228
272
  if (forms) {
229
- forms = schema.forms = await resolveSchemas(forms, resolveForm)
273
+ forms = schema.forms = await resolveSchemas(forms, processForm)
230
274
  } else if (form) {
231
- form = schema.form = await resolveForm(form)
275
+ form = schema.form = await processForm(form)
232
276
  } else if (components) {
233
277
  // NOTE: Processing forms in computed components is not supported, since it
234
278
  // only can be computed in conjunction with actual data.
@@ -236,6 +280,7 @@ export async function processForms(api, schema, level) {
236
280
  form = { components }
237
281
  }
238
282
  }
283
+
239
284
  forms ||= { default: form } // Only used for process loop below.
240
285
  const children = []
241
286
  for (const form of Object.values(forms)) {
@@ -249,9 +294,7 @@ export async function resolveForm(schema) {
249
294
  if (!isForm(schema)) {
250
295
  throw new Error(`Invalid form schema: '${getSchemaIdentifier(schema)}'`)
251
296
  }
252
- if (schema) {
253
- await resolvePanels(schema)
254
- }
297
+ await resolvePanels(schema)
255
298
  return schema
256
299
  }
257
300
 
@@ -282,13 +325,13 @@ export function getViewFormSchema(schema, context) {
282
325
  const { view } = schema
283
326
  const viewSchema = view && context.views[view]
284
327
  return viewSchema
285
- // NOTE: Views can have tabs, in which case the view component is nested
286
- // in one of the tabs, go find it.
287
- ? forEachSchemaComponent(viewSchema, schema => {
288
- if (hasFormSchema(schema)) {
289
- return schema
290
- }
291
- }) || null
328
+ ? // NOTE: Views can have tabs, in which case the view component is nested
329
+ // in one of the tabs, go find it.
330
+ iterateSchemaComponents(viewSchema, schema => {
331
+ if (hasFormSchema(schema)) {
332
+ return schema
333
+ }
334
+ }) || null
292
335
  : null
293
336
  }
294
337
 
@@ -301,9 +344,9 @@ export function getViewSchema(schema, context) {
301
344
  export function getViewEditPath(schema, context) {
302
345
  const view = getViewSchema(schema, context)
303
346
  return view
304
- ? view.level === 0
305
- ? `/${view.path}` // A single-component view
306
- : `/${view.path}/${view.path}` // A multi-component view
347
+ ? isSingleComponentView(view)
348
+ ? `/${view.path}`
349
+ : `/${view.path}/${view.path}`
307
350
  : null
308
351
  }
309
352
 
@@ -361,10 +404,7 @@ export function isInlined(schema) {
361
404
  }
362
405
 
363
406
  export function isNested(schema) {
364
- return !!(
365
- schema.nested ||
366
- getTypeOptions(schema)?.defaultNested === true
367
- )
407
+ return !!(schema.nested || getTypeOptions(schema)?.defaultNested === true)
368
408
  }
369
409
 
370
410
  export function shouldOmitPadding(schema) {
@@ -378,9 +418,10 @@ export function getDefaultValue(schema) {
378
418
  // we can't use `dataPath` to get to components, and the `defaultValue` from
379
419
  // there. That's why `defaultValue` is defined statically in the components:
380
420
  const defaultValue = schema.default
381
- const value = defaultValue !== undefined
382
- ? defaultValue
383
- : getTypeOptions(schema)?.defaultValue
421
+ const value =
422
+ defaultValue !== undefined
423
+ ? defaultValue
424
+ : getTypeOptions(schema)?.defaultValue
384
425
  return isFunction(value)
385
426
  ? value(schema)
386
427
  : clone(value)
@@ -389,8 +430,7 @@ export function getDefaultValue(schema) {
389
430
  export function ignoreMissingValue(schema) {
390
431
  const typeOptions = getTypeOptions(schema)
391
432
  return !!(
392
- typeOptions?.excludeValue ||
393
- typeOptions?.ignoreMissingValue?.(schema)
433
+ typeOptions?.excludeValue || typeOptions?.ignoreMissingValue?.(schema)
394
434
  )
395
435
  }
396
436
 
@@ -404,7 +444,7 @@ export function hasLabels(schema) {
404
444
  )
405
445
  }
406
446
 
407
- export function setDefaults(schema, data = {}, component) {
447
+ export function setDefaultValues(schema, data = {}, component) {
408
448
  const options = { component, rootData: data }
409
449
 
410
450
  const processBefore = (schema, data, name) => {
@@ -416,7 +456,13 @@ export function setDefaults(schema, data = {}, component) {
416
456
  // Sets up a data object that has keys with default values for all
417
457
  // form fields, so they can be correctly watched for changes.
418
458
  return processSchemaData(
419
- schema, data, null, null, processBefore, null, options
459
+ schema,
460
+ data,
461
+ null,
462
+ null,
463
+ processBefore,
464
+ null,
465
+ options
420
466
  )
421
467
  }
422
468
 
@@ -426,15 +472,17 @@ export function computeValue(schema, data, name, dataPath, {
426
472
  } = {}) {
427
473
  const { compute } = schema
428
474
  if (compute) {
429
- const value = compute(DitoContext.get(component, {
430
- // Override value to prevent endless recursion through calling the
431
- // getter for `this.value` in `DitoContext`:
432
- value: data[name],
433
- name,
434
- data,
435
- dataPath,
436
- rootData
437
- }))
475
+ const value = compute(
476
+ DitoContext.get(component, {
477
+ // Override value to prevent endless recursion through calling the
478
+ // getter for `this.value` in `DitoContext`:
479
+ value: data[name],
480
+ name,
481
+ data,
482
+ dataPath,
483
+ rootData
484
+ })
485
+ )
438
486
  if (value !== undefined) {
439
487
  // Access `data[name]` directly instead of `this.value = …` to update the
440
488
  // value without calling parse():
@@ -501,11 +549,11 @@ export function processData(schema, sourceSchema, data, dataPath, {
501
549
  value.sort((a, b) => {
502
550
  const id1 = a?.[idKey]
503
551
  const id2 = b?.[idKey]
504
- return (
505
- id1 == null || isTemporaryId(id1) ? 1
506
- : id2 == null || isTemporaryId(id2) ? -1
507
- : id1 - id2
508
- )
552
+ return id1 == null || isTemporaryId(id1)
553
+ ? 1
554
+ : id2 == null || isTemporaryId(id2)
555
+ ? -1
556
+ : id1 - id2
509
557
  })
510
558
  }
511
559
  }
@@ -519,16 +567,17 @@ export function processData(schema, sourceSchema, data, dataPath, {
519
567
  const typeOptions = getTypeOptions(schema)
520
568
 
521
569
  // NOTE: We don't cache this context, since `value` is changing.
522
- const getContext = () => DitoContext.get(component, {
523
- value,
524
- name,
525
- data,
526
- dataPath,
527
- rootData: options.rootData,
528
- // Pass the already processed data to `process()`, so it can be modified
529
- // through `processedItem` from there.
530
- processedData
531
- })
570
+ const getContext = () =>
571
+ DitoContext.get(component, {
572
+ value,
573
+ name,
574
+ data,
575
+ dataPath,
576
+ rootData: options.rootData,
577
+ // Pass the already processed data to `process()`, so it can be modified
578
+ // through `processedItem` from there.
579
+ processedData
580
+ })
532
581
 
533
582
  // First unwrap the wrapped primitives again, to bring the data back into
534
583
  // its native form. Se `processBefore()` for more details.
@@ -583,9 +632,10 @@ export function processSchemaData(
583
632
  options
584
633
  ) {
585
634
  const processComponents = components => {
586
- const getDataPath = (dataPath, token) => dataPath != null
587
- ? appendDataPath(dataPath, token)
588
- : null
635
+ const getDataPath = (dataPath, token) =>
636
+ dataPath != null
637
+ ? appendDataPath(dataPath, token)
638
+ : null
589
639
 
590
640
  if (components) {
591
641
  for (const [name, componentSchema] of Object.entries(components)) {
@@ -604,9 +654,10 @@ export function processSchemaData(
604
654
  const componentDataPath = getDataPath(dataPath, name)
605
655
 
606
656
  const processItem = (item, index = null) => {
607
- const dataPath = index !== null
608
- ? getDataPath(componentDataPath, index)
609
- : componentDataPath
657
+ const dataPath =
658
+ index !== null
659
+ ? getDataPath(componentDataPath, index)
660
+ : componentDataPath
610
661
  const context = DitoContext.get(options.component, {
611
662
  data,
612
663
  value: item,
@@ -616,7 +667,7 @@ export function processSchemaData(
616
667
  })
617
668
  const getForms = (
618
669
  getTypeOptions(componentSchema)?.getFormSchemasForProcessing ||
619
- getFormSchemas
670
+ getFormSchemas
620
671
  )
621
672
  const forms = getForms(componentSchema, context)
622
673
  const form = getItemFormSchemaFromForms(forms, item)
@@ -641,7 +692,11 @@ export function processSchemaData(
641
692
  }
642
693
 
643
694
  processBefore?.(
644
- componentSchema, data, name, componentDataPath, processedData
695
+ componentSchema,
696
+ data,
697
+ name,
698
+ componentDataPath,
699
+ processedData
645
700
  )
646
701
  let value = processedData ? processedData[name] : data[name]
647
702
  if (value != null && hasFormSchema(componentSchema)) {
@@ -659,7 +714,11 @@ export function processSchemaData(
659
714
  }
660
715
  }
661
716
  processAfter?.(
662
- componentSchema, data, name, componentDataPath, processedData
717
+ componentSchema,
718
+ data,
719
+ name,
720
+ componentDataPath,
721
+ processedData
663
722
  )
664
723
  }
665
724
  }
@@ -683,37 +742,42 @@ export function getNamedSchemas(schemas, defaults) {
683
742
  const toObject = (array, toSchema) => {
684
743
  return array.length > 0
685
744
  ? array.reduce((object, value) => {
686
- const schema = toSchema(value)
687
- if (schema) {
688
- object[schema.name] = schema && defaults
689
- ? { ...defaults, ...schema }
690
- : schema
691
- }
692
- return object
693
- }, {})
745
+ const schema = toSchema(value)
746
+ if (schema) {
747
+ object[schema.name] =
748
+ schema && defaults
749
+ ? { ...defaults, ...schema }
750
+ : schema
751
+ }
752
+ return object
753
+ }, {})
694
754
  : null
695
755
  }
696
756
 
697
757
  return isArray(schemas)
698
- ? toObject(schemas, value => (
699
- isObject(value) ? value : {
700
- name: camelize(value, false)
701
- }
702
- ))
758
+ ? toObject(schemas, value =>
759
+ isObject(value)
760
+ ? value
761
+ : {
762
+ name: camelize(value, false)
763
+ }
764
+ )
703
765
  : isObject(schemas)
704
766
  ? toObject(
705
- Object.entries(schemas),
706
- ([name, value]) =>
707
- isObject(value) ? {
708
- name,
709
- ...value
710
- }
711
- : isString(value) ? {
712
- name,
713
- label: value
714
- }
715
- : null
716
- )
767
+ Object.entries(schemas),
768
+ ([name, value]) =>
769
+ isObject(value)
770
+ ? {
771
+ name,
772
+ ...value
773
+ }
774
+ : isString(value)
775
+ ? {
776
+ name,
777
+ label: value
778
+ }
779
+ : null
780
+ )
717
781
  : null
718
782
  }
719
783
 
@@ -733,22 +797,23 @@ export function getTypeOptions(schemaOrType) {
733
797
  }
734
798
 
735
799
  export function getSourceType(schemaOrType) {
736
- return getTypeOptions(schemaOrType)?.getSourceType?.(
737
- getType(schemaOrType)
738
- ) ?? null
800
+ return (
801
+ getTypeOptions(schemaOrType)?.getSourceType?.(getType(schemaOrType)) ??
802
+ null
803
+ )
739
804
  }
740
805
 
741
806
  export function getPanelSchema(schema, dataPath, tabComponent) {
742
807
  return schema
743
808
  ? {
744
- schema,
745
- // If the panel provides its own name, append it to the dataPath.
746
- // This is used e.g. for $filters panels.
747
- dataPath: schema.name
748
- ? appendDataPath(dataPath, schema.name)
749
- : dataPath,
750
- tabComponent
751
- }
809
+ schema,
810
+ // If the panel provides its own name, append it to the dataPath.
811
+ // This is used e.g. for $filters panels.
812
+ dataPath: schema.name
813
+ ? appendDataPath(dataPath, schema.name)
814
+ : dataPath,
815
+ tabComponent
816
+ }
752
817
  : null
753
818
  }
754
819
 
package/src/utils/type.js CHANGED
@@ -1,6 +1,13 @@
1
1
  import {
2
- isArray, isObject, isString, isBoolean, isNumber, isFunction, isDate,
3
- isRegExp, asArray
2
+ isArray,
3
+ isObject,
4
+ isString,
5
+ isBoolean,
6
+ isNumber,
7
+ isFunction,
8
+ isDate,
9
+ isRegExp,
10
+ asArray
4
11
  } from '@ditojs/utils'
5
12
 
6
13
  const typeCheckers = {
@@ -20,27 +27,31 @@ const toBoolean = value => !!value
20
27
  const toNumber = value => +value
21
28
  const toString = value => String(value)
22
29
 
23
- const toDate = value => isDate(value)
24
- ? value
25
- : new Date(value)
30
+ const toDate = value =>
31
+ isDate(value)
32
+ ? value
33
+ : new Date(value)
26
34
 
27
- const toArray = value => isArray(value)
28
- ? value
29
- : isString(value)
30
- ? value.split(',')
31
- : asArray(value)
35
+ const toArray = value =>
36
+ isArray(value)
37
+ ? value
38
+ : isString(value)
39
+ ? value.split(',')
40
+ : asArray(value)
32
41
 
33
- const toObject = value => isObject(value)
34
- ? value
35
- // If a Object is expected but a Boolean provide, convert to an empty
36
- // object. Used by `creatable` & co, that can be both.
37
- : value === true
38
- ? {}
39
- : null
42
+ const toObject = value =>
43
+ isObject(value)
44
+ ? value
45
+ : // If a Object is expected but a Boolean provide, convert to an empty
46
+ // object. Used by `creatable` & co, that can be both.
47
+ value === true
48
+ ? {}
49
+ : null
40
50
 
41
- const toRegExp = value => isRegExp(value)
42
- ? value
43
- : new RegExp(value)
51
+ const toRegExp = value =>
52
+ isRegExp(value)
53
+ ? value
54
+ : new RegExp(value)
44
55
 
45
56
  const typeConverters = {
46
57
  Boolean: toBoolean,
@@ -4,9 +4,8 @@ export const decimals = {
4
4
  return new RegExp(`^[-+]?\\d*(\\.\\d${match})?$`).test(value)
5
5
  },
6
6
 
7
- message: (value, decimals) => (
7
+ message: (value, decimals) =>
8
8
  `must be numeric and may contain ${
9
9
  !decimals || decimals === '*' ? '' : decimals
10
10
  } decimal points`
11
- )
12
11
  }