From 7296341d76a236f2db898be54f65ca451945fdc3 Mon Sep 17 00:00:00 2001 From: Stefan Zerkalica Date: Sun, 3 Dec 2023 20:16:19 +0300 Subject: [PATCH] $mol_view_tree2 right bind mixed args --- perf/jsfb/jsfb.view.tree | 4 +-- view/tree2/class/props.test.ts | 6 ++-- view/tree2/to/dts/dts.ts | 56 ++++++++++++++++++++++++---------- view/tree2/to/js/js.ts | 2 +- 4 files changed, 46 insertions(+), 22 deletions(-) diff --git a/perf/jsfb/jsfb.view.tree b/perf/jsfb/jsfb.view.tree index b88510723e0..211c0162adc 100644 --- a/perf/jsfb/jsfb.view.tree +++ b/perf/jsfb/jsfb.view.tree @@ -28,7 +28,7 @@ $mol_perf_jsfb $mol_scroll dom_id \swaprows title \Swap Rows click? <=> swap? null - <= Rows $mol_list rows <= rows / + <= Rows $mol_list rows <= rows /$mol_view <= Row*0 $mol_perf_jsfb_row title? => row_title*? selected? <=> row_selected*? false @@ -45,7 +45,7 @@ $mol_perf_jsfb_row $mol_view <= Id $mol_view sub / <= id \ <= Title $mol_check checked? <=> selected? false - sub / <= title + sub / <= title? \ <= Drop $mol_button_minor sub / <= Drop_icon $mol_icon_cross click? <=> drop? null diff --git a/view/tree2/class/props.test.ts b/view/tree2/class/props.test.ts index 418d7fa3f42..c0c2198bc15 100644 --- a/view/tree2/class/props.test.ts +++ b/view/tree2/class/props.test.ts @@ -12,7 +12,7 @@ namespace $.$$ { <= Close ${d}mol_button title \close click?event <=> close?event null - Some ${d}mol_speech + Some* ${d}mol_speech Text => f g => h plugins / @@ -38,7 +38,7 @@ namespace $.$$ { sub / <= Title <= Close - Some ${d}mol_speech + Some* ${d}mol_speech Text => f g => h plugins / <= Speech @@ -49,7 +49,7 @@ namespace $.$$ { title \close click?event <=> close?event f = - Some ${d}mol_speech Text => f g => h + Some* ${d}mol_speech Text => f g => h Text h = f diff --git a/view/tree2/to/dts/dts.ts b/view/tree2/to/dts/dts.ts index 56f20a00b82..2eceb6871e9 100644 --- a/view/tree2/to/dts/dts.ts +++ b/view/tree2/to/dts/dts.ts @@ -55,7 +55,7 @@ namespace $ { klass, input.data( '[\'' ), name_of.call(this, input ), - input.data( '\'] >' ), + input.data( `'] >`), ] } @@ -148,26 +148,50 @@ namespace $ { const [ left, right ] = input.kids const left_parts = this.$mol_view_tree2_prop_parts(left) const right_parts = this.$mol_view_tree2_prop_parts(right) - const left_arg = left_parts.next || left_parts.key - const right_arg = right_parts.next || right_parts.key - const main = klass.data(klass.type) - if (left_arg && right_arg) { - this.$mol_fail(err`Parameters allowed only in ${left.span} or ${right.span}`) + + let conflict: 'next' | 'key' | undefined + + if (left_parts.next && right_parts.next) conflict = 'next' + if (left_parts.key && right_parts.key) conflict = 'key' + + if (conflict) { + this.$mol_fail(err`Only one "${conflict}" allowed: ${ + left_parts[conflict]} at ${left.span} or ${right_parts[conflict]} at ${right.span}`) } - if (left_arg || right_arg) { - const host = ! left_arg && left.kids.length > 0 + const main = klass.data(klass.type) + const prop_parts = this.$mol_view_tree2_prop_parts(prop) + const method = prop.data(`${ klass.type }_${prop_parts.name}`) + + if (prop_parts.key || prop_parts.next) { + const prop_params = parameters.call(this, main, prop) + + const host = left.kids.length > 0 ? left.kids[0].data(left.kids[0].type) - : main + : undefined - types.push( - type_enforce.call( + if (prop_parts.key) { + const second_key = left_parts.key ? left : right + types.push( type_enforce.call( this, - prop.data(`${ klass.type }_${prop.type.replace(/[\?\*]*/g, '')}`), - parameters.call(this, main, prop), - parameters.call(this, host, left_arg ? left : right), - ) - ) + method, + [ ...prop_params, prop.data('[0]') ], + [ ...parameters.call(this, right_parts.key && host ? host : main, second_key), second_key.data('[0]') ], + ) ) + } + + if (prop_parts.next) { + const second_next = left_parts.next ? left : right + const second_parts = left_parts.next ? left_parts : right_parts + + types.push( type_enforce.call( + this, + method, + [ ...prop_params, prop.data(`[${prop_parts.key ? '1' : '0'}]`) ], + [ ...parameters.call(this, right_parts.next && host ? host : main, second_next), + second_next.data(`[${second_parts.key ? '1' : '0'}]`) ], + ) ) + } } return return_type.call( diff --git a/view/tree2/to/js/js.ts b/view/tree2/to/js/js.ts index d7c92994551..1ddf4fd0137 100644 --- a/view/tree2/to/js/js.ts +++ b/view/tree2/to/js/js.ts @@ -113,7 +113,7 @@ namespace $ { ] ), ], - '=': bind => [ call_of.call(this, bind, false) ], + '=': bind => [ call_of.call(this, bind, true) ], '': ( input, belt, context )=> {