From 68c01111fd842e544767ef4320569f59f2c416f5 Mon Sep 17 00:00:00 2001 From: tiye Date: Fri, 23 May 2025 01:12:00 +0800 Subject: [PATCH] update respo 0.0.33 --- moon.mod.json | 2 +- src/container.mbt | 40 ++++++++++++++++------------------------ src/main.mbt | 2 +- src/store.mbt | 12 +----------- 4 files changed, 19 insertions(+), 37 deletions(-) diff --git a/moon.mod.json b/moon.mod.json index 15b8c98..bd02197 100644 --- a/moon.mod.json +++ b/moon.mod.json @@ -2,7 +2,7 @@ "name": "respo/app", "version": "0.1.0", "deps": { - "tiye/respo": "0.0.32", + "tiye/respo": "0.0.33", "tiye/dom-ffi": "0.0.9" }, "readme": "README.md", diff --git a/src/container.mbt b/src/container.mbt index f930e6b..087d817 100644 --- a/src/container.mbt +++ b/src/container.mbt @@ -1,8 +1,8 @@ ///| -typealias @respo_node.(RespoEvent, RespoNode, DispatchFn, RespoCommonError) +typealias @respo_node.RespoNode ///| -fnalias @respo_node.(text_node, textarea, declare_static_style) +fnalias @respo_node.(textarea, static_style) ///| fnalias @respo.ui_textarea @@ -22,38 +22,30 @@ fn comp_container(states : @respo.RespoStatesTree) -> RespoNode[ActionOp] { class_list=[ui_textarea, style_textbox], placeholder="Question", value=state.draft, - event=Map::of([ - ( - Input, - fn(e, dispatch) { - if e is Input(value~, ..) { - dispatch.set_state!(cursor, ContainerState::{ draft: value }) - } - }, - ), - ( - Keydown, - fn(e, dispatch) { - if e is Keyboard(key_code~, meta_key~, ..) { - if key_code == 13 && meta_key { - ask_gemini(state.draft) - } - } - }, - ), - ]), + on_input=fn(e, dispatch) { + if e is Input(value~, ..) { + dispatch.set_state!(cursor, ContainerState::{ draft: value }) + } + }, + on_keydown=fn(e, _dispatch) { + if e is Keyboard(key_code~, meta_key~, ..) { + if key_code == 13 && meta_key { + ask_gemini(state.draft) + } + } + }, ), button( inner_text="Ask", class_name=ui_button, style=respo_style(margin=4 |> Px), - event={}..set(Click, fn(e, dispatch) { ask_gemini(state.draft) }), + on_click=fn(_e, _dispatch) { ask_gemini(state.draft) }, ), ]), ]) } ///| -let style_textbox : String = declare_static_style([ +let style_textbox : String = static_style([ ("&", respo_style(width=600 |> Px, height=160 |> Px)), ]) diff --git a/src/main.mbt b/src/main.mbt index b2d101d..220ee48 100644 --- a/src/main.mbt +++ b/src/main.mbt @@ -2,7 +2,7 @@ fnalias @respo.(ui_global, ui_button) ///| -fnalias @respo_node.(div, span, button, respo_style) +fnalias @respo_node.(div, button, respo_style) ///| let app_store_key : String = "mbt-workflow" diff --git a/src/store.mbt b/src/store.mbt index 21f926f..36bf4d6 100644 --- a/src/store.mbt +++ b/src/store.mbt @@ -1,6 +1,6 @@ ///| struct Store { - mut counted : Int + counted : Int tasks : Array[Task] states : @respo.RespoStatesTree } derive(ToJson, @json.FromJson) @@ -21,9 +21,6 @@ struct Task { ///| enum ActionOp { StatesChange(@respo.RespoUpdateState) - Increment - Decrement - IncTwice } ///| @@ -36,10 +33,6 @@ impl Show for ActionOp with output(self, logger) -> Unit { let s = match self { StatesChange(states) => "StatesChange(\{states.cursor} \{states.data.to_json()})" - // Intent(_intent) => "Intent(...)" - Increment => "Increment" - Decrement => "Decrement" - IncTwice => "IncTwice" } logger.write_string(s) } @@ -52,10 +45,7 @@ fn get_states(self : Store) -> @respo.RespoStatesTree { ///| TODO mutation might break memoization in future fn update(self : Store, op : ActionOp) -> Unit { match op { - Increment => self.counted += 1 StatesChange(states) => self.states.set_in_mut(states) - Decrement => self.counted -= 1 - _ => () } }