diff --git a/component/component.ts b/component/component.ts index 80eb5e0..f2c199d 100644 --- a/component/component.ts +++ b/component/component.ts @@ -47,7 +47,7 @@ namespace $ { @ $mol_mem prop_names() { - return this.$.$mol_view_tree2_class_props( this.tree() ).map( tree => this.$.$mol_view_tree2_prop_split( tree ).name.text() ) + return this.$.$mol_view_tree2_class_props( this.tree() ).map( tree => this.$.$mol_view_tree2_prop_parts( tree ).name ) } @ $mol_mem diff --git a/studio.view.ts b/studio.view.ts index 99a3300..b1d3278 100644 --- a/studio.view.ts +++ b/studio.view.ts @@ -214,7 +214,7 @@ namespace $.$$ { const all = new Map< string, $mol_tree2 >() const add = ( prop: $mol_tree2 )=> { - const name = this.$.$mol_view_tree2_prop_split( prop ).name.text() + const name = this.$.$mol_view_tree2_prop_parts( prop ).name all.set( name, prop ) } @@ -262,7 +262,7 @@ namespace $.$$ { @ $mol_mem props() { const props = this.prop_filtered().map( prop => { - const name = this.$.$mol_view_tree2_prop_split( prop ).name.text() + const name = this.$.$mol_view_tree2_prop_parts( prop ).name return this.Prop( name ) } ) return props diff --git a/type/type.view.tree b/type/type.view.tree index 6c811ee..f8044c2 100644 --- a/type/type.view.tree +++ b/type/type.view.tree @@ -1,6 +1,7 @@ $hyoo_studio_type $mol_pick - tree?val $mol_tree2_empty + tree?val null $mol_tree2_empty belong_to \ + type? \ trigger_content / <= Value $mol_paragraph title <= type_display \ <= Take_put_hack_icon $mol_icon_arrow_left_right_bold_outline diff --git a/type/type.view.ts b/type/type.view.ts index 45e30b9..9bc561f 100644 --- a/type/type.view.ts +++ b/type/type.view.ts @@ -103,32 +103,36 @@ namespace $.$$ { @ $mol_mem type( next? : string ) { - - if( next !== undefined ) { - - switch( next ) { - case '' : this.tree(null); break - case 'null' : this.tree( this.tree().struct('null') ); break - case 'boolean_true' : this.tree( this.tree().struct('true') ); break - case 'boolean_false' : this.tree( this.tree().struct('false') ); break - case 'number': this.tree( this.tree().struct('0') ); break - case 'number_nan': this.tree( this.tree().struct('+NaN') ); break - case 'number_infinity_negative': this.tree( this.tree().struct('-Infinity') ); break - case 'number_infinity_positive': this.tree( this.tree().struct('+Infinity') ); break - case 'text': this.tree( this.tree().data('') ); break - case 'list': this.tree( this.tree().struct( '/' ) ); break - case 'dict': this.tree( this.tree().struct( '*' ) ); break - case 'object': this.tree( this.tree().struct( '$mol_view', [ this.tree().kids[0] ?? this.tree().data( '' ) ] ) ); break - case 'bind': this.tree( this.tree().struct( '<=>', [ this.tree().kids[0] ?? this.tree().data( '' ) ] ) ); break - case 'get': this.tree( this.tree().struct( '<=', [ this.tree().kids[0] ?? this.tree().data( '' ) ] ) ); break - case 'put': this.tree( this.tree().struct( '=>', [ this.tree().kids[0] ?? this.tree().data( '' ) ] ) ); break - default : $mol_fail( new TypeError( `Unsupported type: ${ next }` ) ) - } - - this.showed(false) + const tree = this.tree() + if (! tree) throw new Error(`tree prop not provided`) + if (next === undefined) return $hyoo_studio_type_value(tree) + + let val + + switch( next ) { + case '' : val = null; break + case 'null' : val = tree.struct('null'); break + case 'boolean_true' : val = tree.struct('true'); break + case 'boolean_false' : val = tree.struct('false'); break + case 'number': val = tree.struct('0'); break + case 'number_nan': val = tree.struct('+NaN'); break + case 'number_infinity_negative': val = tree.struct('-Infinity'); break + case 'number_infinity_positive': val = tree.struct('+Infinity'); break + case 'text': val = tree.data(''); break + case 'list': val = tree.struct( '/' ); break + case 'dict': val = tree.struct( '*' ); break + case 'object': val = tree.struct( '$mol_view', [ tree.kids[0] ?? tree.data( '' ) ] ); break + case 'bind': val = tree.struct( '<=>', [ tree.kids[0] ?? tree.data( '' ) ] ); break + case 'get': val = tree.struct( '<=', [ tree.kids[0] ?? tree.data( '' ) ] ); break + case 'put': val = tree.struct( '=>', [ tree.kids[0] ?? tree.data( '' ) ] ); break } - return $hyoo_studio_type_value(this.tree()) + if (val === undefined) $mol_fail( new TypeError( `Unsupported type: ${ next }` ) ) + + const next_tree = this.tree(val)! + this.showed(false) + + return $hyoo_studio_type_value(next_tree) } show_obj_select() { @@ -140,10 +144,10 @@ namespace $.$$ { if ( next !== undefined ) { this.showed(false) - return this.tree(this.tree().struct( next )).type + return this.tree(this.tree()?.struct( next ))?.type ?? super.selected_class() } - return this.tree()?.type + return this.tree()?.type ?? super.selected_class() } @ $mol_mem @@ -156,8 +160,8 @@ namespace $.$$ { const from_tree = this.tree( next === undefined ? undefined - : this.tree().struct( '/' + next, this.tree().kids ) - ).type.slice( 1 ) + : this.tree()?.struct( '/' + next, this.tree()?.kids ?? []) ?? null + )?.type.slice( 1 ) const focused = this.List_items_type().focused() diff --git a/value/bound/bound.view.ts b/value/bound/bound.view.ts index a34b354..168815c 100644 --- a/value/bound/bound.view.ts +++ b/value/bound/bound.view.ts @@ -42,7 +42,7 @@ namespace $.$$ { const val = this.tree() if( next === undefined ) { - return this.$.$mol_view_tree2_prop_split( val.kids[ 0 ] ).name.text() || '...' + return this.$.$mol_view_tree2_prop_parts( val.kids[ 0 ] ).name || '...' } this.tree(