Skip to content

Commit

Permalink
adding rootContainerName property
Browse files Browse the repository at this point in the history
  • Loading branch information
maliknajjar committed Jan 21, 2024
1 parent 28ce5d3 commit 12adaf3
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/guifier/classes/Data.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import clone from 'clone'

import type { Property, Parameters } from '../types'
import type { Property, ParametersInternal } from '../types'

import { XMLParser, XMLBuilder } from 'fast-xml-parser'
import * as toml from 'toml'
Expand All @@ -18,18 +18,18 @@ import xmlFormat from 'xml-formatter'
export class Data {
public rawData: any
public parsedData: Property = defaultProperty
public params: Parameters
public params: ParametersInternal
private readonly path: Array<number | string> = []

constructor (data: string, dataType: DataType, params: Parameters) {
constructor (data: string, dataType: DataType, params: ParametersInternal) {
// add guifier params
this.params = params

// converting data types string into a js object
this.rawData = this.deserializeData(data, dataType)

// adding meta data (private properties) to the properties that dont have them
this.parsedData = this.addMetaDataRecursively(this.rawData, 'root')
this.parsedData = this.addMetaDataRecursively(this.rawData, this.params.rootContainerName)

// normalizing _rules array in the property meta data
this.normalizingRules()
Expand Down
4 changes: 2 additions & 2 deletions src/guifier/dialogue/dialog.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import './dialog.css'

import type { ParametersInternal } from '../types'
import type { Parameters } from '../types'
import type { DialogParameters } from './dialogTypes'

import { drawOutlineIcon } from '../utils'
Expand Down Expand Up @@ -208,7 +208,7 @@ export class Dialog {
* This function is responsible for drawing a grid element
*/
private drawGuifierGeneratedContent (data: any): HTMLElement {
const params: ParametersInternal = {
const params: Parameters = {
elementSelector: this.params.elementSelector,
data,
dataType: DataType.Js,
Expand Down
1 change: 1 addition & 0 deletions src/guifier/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const ParameterSchema = z.object({
elementSelector: z.string(),
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),
Expand Down
1 change: 1 addition & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ async function init (): Promise<void> {
elementSelector: '#app',
data: exampleData,
dataType: DataType.Json,
rootContainerName: 'Example Object',
onChange: () => {
console.log('guifier has changed')
console.log(guifier.getData(DataType.Json))
Expand Down

0 comments on commit 12adaf3

Please sign in to comment.