mirror of
https://github.com/misode/misode.github.io.git
synced 2026-05-04 22:51:47 +00:00
Merge style changes
This commit is contained in:
+1
-1
@@ -7,7 +7,7 @@ export class Path implements Iterable<PathElement> {
|
||||
model?: DataModel
|
||||
|
||||
constructor(arr?: PathElement[], model?: DataModel) {
|
||||
this.arr = arr || []
|
||||
this.arr = arr ?? []
|
||||
this.model = model
|
||||
}
|
||||
|
||||
|
||||
@@ -44,10 +44,10 @@ export abstract class AbstractNode<T> implements INode<T> {
|
||||
forceMod: IForce
|
||||
|
||||
constructor(mods?: NodeMods<T>) {
|
||||
this.defaultMod = mods?.default ? mods.default : (v) => v
|
||||
this.transformMod = mods?.transform ? mods.transform : (v) => v
|
||||
this.enableMod = mods?.enable ? mods.enable : () => true
|
||||
this.forceMod = mods?.force ? mods.force : () => false
|
||||
this.defaultMod = mods?.default ?? ((v) => v)
|
||||
this.transformMod = mods?.transform ?? ((v) => v)
|
||||
this.enableMod = mods?.enable ?? (() => true)
|
||||
this.forceMod = mods?.force ?? (() => false)
|
||||
}
|
||||
|
||||
setParent(parent: INode<any>) {
|
||||
|
||||
@@ -20,7 +20,7 @@ export class MapNode extends AbstractNode<IMap> {
|
||||
}
|
||||
|
||||
renderRaw(path: Path, value: IMap, view: TreeView) {
|
||||
value = value || []
|
||||
value = value ?? []
|
||||
const button = view.registerClick(el => {
|
||||
const key = this.keys.getState(el.parentElement!)
|
||||
view.model.set(path.push(key), this.values.default())
|
||||
|
||||
@@ -18,9 +18,9 @@ export class NumberNode extends AbstractNode<number> implements StateNode<number
|
||||
super({
|
||||
default: () => 0,
|
||||
...mods})
|
||||
this.integer = mods?.integer ? mods.integer : false
|
||||
this.min = mods?.min !== undefined ? mods.min : -Infinity
|
||||
this.max = mods?.max !== undefined ? mods.max : Infinity
|
||||
this.integer = mods?.integer ?? false
|
||||
this.min = mods?.min ?? -Infinity
|
||||
this.max = mods?.max ?? Infinity
|
||||
}
|
||||
|
||||
getState(el: Element) {
|
||||
@@ -37,6 +37,6 @@ export class NumberNode extends AbstractNode<number> implements StateNode<number
|
||||
|
||||
renderRaw(path: Path, value: number, view: TreeView, options?: RenderOptions) {
|
||||
return `${options?.hideLabel ? `` : `<label>${path.last()}</label>`}
|
||||
<input value="${value === undefined ? '' : value}"></input>`
|
||||
<input value="${value ?? ''}"></input>`
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ export class ObjectNode extends AbstractNode<IObject> {
|
||||
|
||||
transform(path: Path, value: IObject) {
|
||||
if (value === undefined) return undefined
|
||||
value = value || {}
|
||||
value = value ?? {}
|
||||
let res: any = {}
|
||||
Object.keys(this.fields).forEach(f =>
|
||||
res[f] = this.fields[f].transform(path.push(f), value[f])
|
||||
|
||||
@@ -12,7 +12,7 @@ export class RootNode extends ObjectNode {
|
||||
}
|
||||
|
||||
render(path: Path, value: IObject, view: TreeView) {
|
||||
value = value || {}
|
||||
value = value ?? {}
|
||||
return `<div>
|
||||
${Object.keys(this.fields).map(f => {
|
||||
return this.fields[f].render(path.push(f), value[f], view)
|
||||
|
||||
@@ -12,7 +12,7 @@ export class StringNode extends AbstractNode<string> implements StateNode<string
|
||||
|
||||
constructor(mods?: StringNodeMods) {
|
||||
super(mods)
|
||||
this.allowEmpty = (mods?.allowEmpty === true)
|
||||
this.allowEmpty = mods?.allowEmpty ?? false
|
||||
}
|
||||
|
||||
getState(el: Element) {
|
||||
@@ -26,6 +26,6 @@ export class StringNode extends AbstractNode<string> implements StateNode<string
|
||||
|
||||
renderRaw(path: Path, value: string, view: TreeView, options?: RenderOptions) {
|
||||
return `${options?.hideLabel ? `` : `<label>${path.last()}</label>`}
|
||||
<input value="${value || ''}"></input>`
|
||||
<input value="${value ?? ''}"></input>`
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user