diff --git a/src/guifier/classes/Data.ts b/src/guifier/classes/Data.ts index d5c406b..7b912aa 100644 --- a/src/guifier/classes/Data.ts +++ b/src/guifier/classes/Data.ts @@ -1,6 +1,6 @@ import clone from 'clone' -import type { Property, ParametersInternal } from '../types' +import type { Property, Parameters } from '../types' import { XMLParser, XMLBuilder } from 'fast-xml-parser' import * as toml from 'toml' @@ -18,10 +18,10 @@ import xmlFormat from 'xml-formatter' export class Data { public rawData: any public parsedData: Property = defaultProperty - public params: ParametersInternal + public params: Parameters private readonly path: Array = [] - constructor (data: string, dataType: DataType, params: ParametersInternal) { + constructor (data: string, dataType: DataType, params: Parameters) { // add guifier params this.params = params @@ -29,7 +29,7 @@ export class Data { this.rawData = this.deserializeData(data, dataType) // adding meta data (private properties) to the properties that dont have them - this.parsedData = this.addMetaDataRecursively(this.rawData, this.params.rootContainerName) + this.parsedData = this.addMetaDataRecursively(this.rawData, 'root') // normalizing _rules array in the property meta data this.normalizingRules() diff --git a/src/guifier/fields/containers/Container/Container.ts b/src/guifier/fields/containers/Container/Container.ts index 80eb6a4..f88295f 100644 --- a/src/guifier/fields/containers/Container/Container.ts +++ b/src/guifier/fields/containers/Container/Container.ts @@ -150,7 +150,7 @@ export abstract class Container extends Field { const objectName = this.property._key const guifierContainerHeaderKeyName = document.createElement('div') guifierContainerHeaderKeyName.classList.add('guifierContainerHeaderKeyName') - guifierContainerHeaderKeyName.innerHTML = `${objectName}` + guifierContainerHeaderKeyName.innerHTML = this.property._path.length === 1 ? this.params.rootContainerName : `${objectName}` guifierContainerHeader.append(guifierContainerHeaderKeyName) // todo: add this part to a function diff --git a/src/guifier/types.ts b/src/guifier/types.ts index d267f4c..5f9f947 100644 --- a/src/guifier/types.ts +++ b/src/guifier/types.ts @@ -14,10 +14,10 @@ export const ParameterSchema = z.object({ data: z.any(), dataType: z.string(), rootContainerName: z.string().default('root'), - withoutContainer: z.boolean().optional().default(false), - flipBackgroundColors: z.boolean().optional().default(false), - expandFieldsToFullWidth: z.boolean().optional().default(false), - readOnlyMode: z.boolean().optional().default(false), + withoutContainer: z.boolean().default(false), + flipBackgroundColors: z.boolean().default(false), + expandFieldsToFullWidth: z.boolean().default(false), + readOnlyMode: z.boolean().default(false), onChange: z.function().optional(), xmlRootName: z.any() })