From b8507caecda08b995b04cee1d0faff00f6abd933 Mon Sep 17 00:00:00 2001 From: Stefan Zerkalica Date: Mon, 4 Dec 2023 02:16:12 +0300 Subject: [PATCH] $mol_view_tree2 refactor, https://github.com/hyoo-ru/mam_mol/pull/646 --- editor/editor.view.tree | 2 +- editor/editor.view.ts | 4 ++++ element/nav/action.ts | 9 +++++++++ element/nav/nav.view.tree | 2 ++ element/nav/nav.view.ts | 14 +++----------- element/options/options.view.tree | 1 + 6 files changed, 20 insertions(+), 12 deletions(-) create mode 100644 element/nav/action.ts diff --git a/editor/editor.view.tree b/editor/editor.view.tree index 6efa746..b49b59f 100644 --- a/editor/editor.view.tree +++ b/editor/editor.view.tree @@ -38,7 +38,7 @@ $hyoo_sketch_editor $mol_page <= Page_grid $hyoo_sketch_option name @ \Grid Control <= Grid $mol_switch - value? <=> grid? + value? <=> grid_str? \ options * 4 \4 8 \8 diff --git a/editor/editor.view.ts b/editor/editor.view.ts index ab41f12..805172b 100644 --- a/editor/editor.view.ts +++ b/editor/editor.view.ts @@ -6,6 +6,10 @@ namespace $.$$ { return this.domain().element(id) } + grid_str(next?: string) { + return String(this.grid(next === undefined ? next : Number(next))) + } + @ $mol_mem_key Element(id: $mol_int62_string) { const type = this.element(id).type() diff --git a/element/nav/action.ts b/element/nav/action.ts new file mode 100644 index 0000000..05e5606 --- /dev/null +++ b/element/nav/action.ts @@ -0,0 +1,9 @@ +namespace $ { + export type $hyoo_sketch_element_nav_action_type = 'open' | 'close' | 'replace' | 'external' + export type $hyoo_sketch_element_nav_action_data = { + type: $hyoo_sketch_element_nav_action_type + source_page: string + target_page: string + target_link: string + } +} diff --git a/element/nav/nav.view.tree b/element/nav/nav.view.tree index a43fd3c..df80955 100644 --- a/element/nav/nav.view.tree +++ b/element/nav/nav.view.tree @@ -2,6 +2,8 @@ $hyoo_sketch_element_nav $hyoo_sketch_element_base Element $mol_view sub / \nav nav_pages_param \demo + nav_click_handler null + nav_actions /$hyoo_sketch_element_nav_action_data Options * ^ nav <= nav_options / diff --git a/element/nav/nav.view.ts b/element/nav/nav.view.ts index 3d3c719..6b4ca37 100644 --- a/element/nav/nav.view.ts +++ b/element/nav/nav.view.ts @@ -1,13 +1,5 @@ namespace $.$$ { - type Action_type = 'open' | 'close' | 'replace' | 'external' - type Action = { - type: Action_type, - source_page: string, - target_page: string, - target_link: string, - } - export class $hyoo_sketch_element_nav extends $.$hyoo_sketch_element_nav { @ $mol_mem @@ -36,7 +28,7 @@ namespace $.$$ { } @ $mol_mem - nav_actions(next?: Action[]) { + nav_actions(next?: $hyoo_sketch_element_nav_action_data[]) { return this.nav_actions_node().list(next) as Exclude } @@ -51,7 +43,7 @@ namespace $.$$ { } @ $mol_mem_key - nav_action_value({ id, key } : { id: number, key: Key }, next?: string) { + nav_action_value({ id, key } : { id: number, key: Key }, next?: string) { const list = this.nav_actions() const item = list[id] ?? {} @@ -65,7 +57,7 @@ namespace $.$$ { ... list.slice( id + 1 ), ]) - return next as Action[Key] + return next as $hyoo_sketch_element_nav_action_data[Key] } nav_action_type(id: number, next?: string) { diff --git a/element/options/options.view.tree b/element/options/options.view.tree index 1380ebe..52c7fa3 100644 --- a/element/options/options.view.tree +++ b/element/options/options.view.tree @@ -4,6 +4,7 @@ $hyoo_sketch_element_options $hyoo_sketch_element_base \two \three option_current? \ + option_list /string Options * ^ options <= options /