Skip to content

Commit

Permalink
Remove uuid dependency, add generateUiConfig return type
Browse files Browse the repository at this point in the history
  • Loading branch information
repalash committed Jan 1, 2024
1 parent e2ca5bc commit ee01cdf
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 19 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "uiconfig.js",
"version": "0.0.9",
"version": "0.0.10",
"description": "A framework for building user interface layouts with JSON configuration.",
"main": "src/index.ts",
"module": "dist/index.mjs",
Expand Down Expand Up @@ -65,7 +65,6 @@
"@rollup/plugin-node-resolve": "^15.0.1",
"@rollup/plugin-terser": "^0.4.0",
"@rollup/plugin-typescript": "^11.0.0",
"@types/uuid": "^9.0.0",
"@typescript-eslint/eslint-plugin": "^5.53.0",
"eslint": "^8.34.0",
"eslint-plugin-deprecation": "^1.3.3",
Expand All @@ -77,10 +76,9 @@
"rollup-plugin-delete": "^2.0.0",
"rollup-plugin-license": "^3.0.1",
"rollup-plugin-multi-input": "^1.3.3",
"ts-browser-helpers": "^0.5.0",
"ts-browser-helpers": "^0.11.0",
"tslib": "^2.5.0",
"typescript": "^4.9.5",
"uuid": "^9.0.0",
"typedoc": "^0.23.26",
"rimraf": "^5.0.1"
},
Expand Down
5 changes: 2 additions & 3 deletions src/UiConfigMethods.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {ChangeArgs, ChangeEvent, UiObjectConfig} from './types'
import {Fof, getOrCall, safeSetProperty} from 'ts-browser-helpers'
import {Fof, getOrCall, safeSetProperty, uuidV4} from 'ts-browser-helpers'
import {UiConfigRendererBase} from './UiConfigRendererBase'
import {v4} from 'uuid'

export class UiConfigMethods {
constructor(protected _renderer: UiConfigRendererBase) {
Expand Down Expand Up @@ -122,7 +121,7 @@ export class UiConfigMethods {
console.warn('No type for config', config)
config.type = 'input'
}
if (!config.uuid) config.uuid = v4()
if (!config.uuid) config.uuid = uuidV4()

if (config.property === undefined) {
if (config.binding) config.property = config.binding
Expand Down
9 changes: 4 additions & 5 deletions src/decorator_utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {UiObjectConfig} from './types'
import {v4} from 'uuid'
import {Fof} from 'ts-browser-helpers'
import {Fof, uuidV4} from 'ts-browser-helpers'

export class UiConfigTypeMap {
static Map = new Map<ObjectConstructor, any[]>()
Expand Down Expand Up @@ -28,12 +27,12 @@ export function generateValueConfig(obj: any, key: string | number, label?: stri
return result
}

export function generateUiConfig(obj: any): UiObjectConfig[] {
export function generateUiConfig(obj: any): UiObjectConfig['children'] {
if (!obj) return []
let type = obj.constructor || Object
if (type === Array) type = Object

const result: UiObjectConfig[] = []
const result: UiObjectConfig['children'] = []
const types: any[] = []
while (type && type !== Object) {
types.push(type)
Expand Down Expand Up @@ -94,7 +93,7 @@ export function generateUiFolder(label: string, obj: any, params: any = {}, type
return {
type, label,
children: generateUiConfig(obj),
uuid: v4(),
uuid: uuidV4(),
...params,
}
}
Expand Down

0 comments on commit ee01cdf

Please sign in to comment.