@yuneta/gobj-ui 7.23.145 → 7.23.146

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1664,6 +1664,15 @@ forwards them as `EV_SET_HIDDEN_TOPICS`, `EV_SET_MAIN_TOPIC`,
1664
1664
  `main topic`, `highlight topic`, `loose records`, `hidden topics`; `legend`
1665
1665
  is no longer used.
1666
1666
 
1667
+ **The layout select has a stepper beside it** (`7.23.146`): ▲ and ▼ step to
1668
+ the layout before or after the current one, in the order the engine offers
1669
+ them (`layout_names`), without opening the list. Layouts are picked by trying
1670
+ them one after another, and a list closes on every pick. The stepper reads the
1671
+ layout the engine is USING (its `layout` attr, which `auto_layout` can set),
1672
+ not the persisted choice, and disables the button at each end of the list. A
1673
+ press is `EV_STEP_LAYOUT {step}` (internal), which sends `EV_SET_LAYOUT` with
1674
+ the neighbour. Consumer i18n keys: `previous layout`, `next layout`.
1675
+
1667
1676
  **The main topic's chip is not a disabled button** (`7.23.88`): it cannot be
1668
1677
  hidden, so its body is a `div` wearing the `.button` skin — bold, at full
1669
1678
  strength, with a gold star — and not a toggle painted at Bulma's half
@@ -64485,6 +64485,40 @@ function refresh_fold_level(gobj) {
64485
64485
  if ($collapse) $collapse.disabled = !(levels && level > 1);
64486
64486
  if ($expand) $expand.disabled = !(levels && level < levels);
64487
64487
  }
64488
+ function layout_step_button(gobj, cls, icon, key, step) {
64489
+ return [
64490
+ "button",
64491
+ {
64492
+ class: `${cls} button`,
64493
+ type: "button",
64494
+ style: {
64495
+ height: (0, _yuneta_gobj_js.gobj_read_str_attr)(gobj, "wide"),
64496
+ width: "2.5em"
64497
+ },
64498
+ disabled: true,
64499
+ title: (0, i18next.t)(key),
64500
+ "data-i18n-title": key,
64501
+ "aria-label": (0, i18next.t)(key),
64502
+ "data-i18n-aria-label": key
64503
+ },
64504
+ yui_toolbar_icon(icon),
64505
+ { click: (evt) => {
64506
+ evt.stopPropagation();
64507
+ (0, _yuneta_gobj_js.gobj_send_event)(gobj, "EV_STEP_LAYOUT", { step }, gobj);
64508
+ } }
64509
+ ];
64510
+ }
64511
+ function refresh_layout_stepper(gobj) {
64512
+ let priv = gobj.priv;
64513
+ let $container = priv.$container;
64514
+ if (!$container || !priv.gobj_nodes_tree) return;
64515
+ let names = (0, _yuneta_gobj_js.gobj_read_attr)(priv.gobj_nodes_tree, "layout_names") || [];
64516
+ let index = names.indexOf((0, _yuneta_gobj_js.gobj_read_str_attr)(priv.gobj_nodes_tree, "layout"));
64517
+ let $prev = $container.querySelector(".GRAPH_LAYOUT_PREV");
64518
+ let $next = $container.querySelector(".GRAPH_LAYOUT_NEXT");
64519
+ if ($prev) $prev.disabled = !(index > 0);
64520
+ if ($next) $next.disabled = !(index >= 0 && index < names.length - 1);
64521
+ }
64488
64522
  function make_toolbar(gobj) {
64489
64523
  let priv = gobj.priv;
64490
64524
  let modes = (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "operation_modes");
@@ -64522,6 +64556,14 @@ function make_toolbar(gobj) {
64522
64556
  (0, _yuneta_gobj_js.gobj_send_event)(gobj, "EV_SET_LAYOUT", { layout: evt.target.value }, gobj);
64523
64557
  } }
64524
64558
  ],
64559
+ [
64560
+ "div",
64561
+ {
64562
+ class: "GRAPH_LAYOUT_STEPPER buttons has-addons",
64563
+ style: "margin:0 0 0 .25rem; flex:0 0 auto; flex-wrap:nowrap; align-items:stretch;"
64564
+ },
64565
+ [layout_step_button(gobj, "GRAPH_LAYOUT_PREV", "yi-chevron-up", "previous layout", -1), layout_step_button(gobj, "GRAPH_LAYOUT_NEXT", "yi-chevron-down", "next layout", 1)]
64566
+ ],
64525
64567
  [
64526
64568
  "span",
64527
64569
  {
@@ -64868,6 +64910,7 @@ function populate_nodes_tree_options(gobj) {
64868
64910
  }
64869
64911
  let current_layout = (0, _yuneta_gobj_js.gobj_read_str_attr)(priv.gobj_nodes_tree, "layout");
64870
64912
  if (current_layout) $layout_select.value = current_layout;
64913
+ refresh_layout_stepper(gobj);
64871
64914
  }
64872
64915
  let $operation_mode_select = $container.querySelector(".GRAPH_MODE_SELECT");
64873
64916
  $operation_mode_select.value = priv.operation_mode;
@@ -65560,6 +65603,25 @@ function ac_set_layout(gobj, event, kw, src) {
65560
65603
  let $layout_select = priv.$container.querySelector(".GRAPH_LAYOUT_SELECT");
65561
65604
  $layout_select.value = priv.layout;
65562
65605
  (0, _yuneta_gobj_js.gobj_send_event)(priv.gobj_nodes_tree, "EV_SET_LAYOUT", { layout }, gobj);
65606
+ refresh_layout_stepper(gobj);
65607
+ return 0;
65608
+ }
65609
+ /************************************************************
65610
+ * One press of the layout stepper (EV_STEP_LAYOUT {step}): the
65611
+ * layout before or after the one the engine is using, in the order
65612
+ * it offers them. The buttons are disabled at the ends, so a step
65613
+ * out of the list is a sender that did not read them.
65614
+ ************************************************************/
65615
+ function ac_step_layout(gobj, event, kw, src) {
65616
+ let priv = gobj.priv;
65617
+ let step = kw && kw.step || 0;
65618
+ let names = (0, _yuneta_gobj_js.gobj_read_attr)(priv.gobj_nodes_tree, "layout_names") || [];
65619
+ let index = names.indexOf((0, _yuneta_gobj_js.gobj_read_str_attr)(priv.gobj_nodes_tree, "layout")) + step;
65620
+ if (step === 0 || index < 0 || index >= names.length) {
65621
+ (0, _yuneta_gobj_js.log_error)(`${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}: layout step ${step} is out of the list`);
65622
+ return -1;
65623
+ }
65624
+ (0, _yuneta_gobj_js.gobj_send_event)(gobj, "EV_SET_LAYOUT", { layout: names[index] }, gobj);
65563
65625
  return 0;
65564
65626
  }
65565
65627
  /************************************************************
@@ -65892,6 +65954,7 @@ function ac_layout_autoset(gobj, event, kw, src) {
65892
65954
  let layout = kw && kw.layout || "";
65893
65955
  if (!$select || !layout) return 0;
65894
65956
  $select.value = layout;
65957
+ refresh_layout_stepper(gobj);
65895
65958
  return 0;
65896
65959
  }
65897
65960
  /************************************************************
@@ -66168,6 +66231,11 @@ function create_gclass$3(gclass_name) {
66168
66231
  ac_set_layout,
66169
66232
  null
66170
66233
  ],
66234
+ [
66235
+ "EV_STEP_LAYOUT",
66236
+ ac_step_layout,
66237
+ null
66238
+ ],
66171
66239
  [
66172
66240
  "EV_SET_OPERATION_MODE",
66173
66241
  ac_set_operation_mode,
@@ -66272,6 +66340,7 @@ function create_gclass$3(gclass_name) {
66272
66340
  ["EV_RUN_NODE", 0],
66273
66341
  ["EV_CLOSE_WINDOW", 0],
66274
66342
  ["EV_SET_LAYOUT", 0],
66343
+ ["EV_STEP_LAYOUT", 0],
66275
66344
  ["EV_SET_OPERATION_MODE", 0],
66276
66345
  ["EV_SET_FOCUS_TOPIC", 0],
66277
66346
  ["EV_FIND_NODES", 0],
@@ -64480,6 +64480,40 @@ function refresh_fold_level(gobj) {
64480
64480
  if ($collapse) $collapse.disabled = !(levels && level > 1);
64481
64481
  if ($expand) $expand.disabled = !(levels && level < levels);
64482
64482
  }
64483
+ function layout_step_button(gobj, cls, icon, key, step) {
64484
+ return [
64485
+ "button",
64486
+ {
64487
+ class: `${cls} button`,
64488
+ type: "button",
64489
+ style: {
64490
+ height: gobj_read_str_attr(gobj, "wide"),
64491
+ width: "2.5em"
64492
+ },
64493
+ disabled: true,
64494
+ title: t(key),
64495
+ "data-i18n-title": key,
64496
+ "aria-label": t(key),
64497
+ "data-i18n-aria-label": key
64498
+ },
64499
+ yui_toolbar_icon(icon),
64500
+ { click: (evt) => {
64501
+ evt.stopPropagation();
64502
+ gobj_send_event(gobj, "EV_STEP_LAYOUT", { step }, gobj);
64503
+ } }
64504
+ ];
64505
+ }
64506
+ function refresh_layout_stepper(gobj) {
64507
+ let priv = gobj.priv;
64508
+ let $container = priv.$container;
64509
+ if (!$container || !priv.gobj_nodes_tree) return;
64510
+ let names = gobj_read_attr(priv.gobj_nodes_tree, "layout_names") || [];
64511
+ let index = names.indexOf(gobj_read_str_attr(priv.gobj_nodes_tree, "layout"));
64512
+ let $prev = $container.querySelector(".GRAPH_LAYOUT_PREV");
64513
+ let $next = $container.querySelector(".GRAPH_LAYOUT_NEXT");
64514
+ if ($prev) $prev.disabled = !(index > 0);
64515
+ if ($next) $next.disabled = !(index >= 0 && index < names.length - 1);
64516
+ }
64483
64517
  function make_toolbar(gobj) {
64484
64518
  let priv = gobj.priv;
64485
64519
  let modes = gobj_read_attr(gobj, "operation_modes");
@@ -64517,6 +64551,14 @@ function make_toolbar(gobj) {
64517
64551
  gobj_send_event(gobj, "EV_SET_LAYOUT", { layout: evt.target.value }, gobj);
64518
64552
  } }
64519
64553
  ],
64554
+ [
64555
+ "div",
64556
+ {
64557
+ class: "GRAPH_LAYOUT_STEPPER buttons has-addons",
64558
+ style: "margin:0 0 0 .25rem; flex:0 0 auto; flex-wrap:nowrap; align-items:stretch;"
64559
+ },
64560
+ [layout_step_button(gobj, "GRAPH_LAYOUT_PREV", "yi-chevron-up", "previous layout", -1), layout_step_button(gobj, "GRAPH_LAYOUT_NEXT", "yi-chevron-down", "next layout", 1)]
64561
+ ],
64520
64562
  [
64521
64563
  "span",
64522
64564
  {
@@ -64863,6 +64905,7 @@ function populate_nodes_tree_options(gobj) {
64863
64905
  }
64864
64906
  let current_layout = gobj_read_str_attr(priv.gobj_nodes_tree, "layout");
64865
64907
  if (current_layout) $layout_select.value = current_layout;
64908
+ refresh_layout_stepper(gobj);
64866
64909
  }
64867
64910
  let $operation_mode_select = $container.querySelector(".GRAPH_MODE_SELECT");
64868
64911
  $operation_mode_select.value = priv.operation_mode;
@@ -65555,6 +65598,25 @@ function ac_set_layout(gobj, event, kw, src) {
65555
65598
  let $layout_select = priv.$container.querySelector(".GRAPH_LAYOUT_SELECT");
65556
65599
  $layout_select.value = priv.layout;
65557
65600
  gobj_send_event(priv.gobj_nodes_tree, "EV_SET_LAYOUT", { layout }, gobj);
65601
+ refresh_layout_stepper(gobj);
65602
+ return 0;
65603
+ }
65604
+ /************************************************************
65605
+ * One press of the layout stepper (EV_STEP_LAYOUT {step}): the
65606
+ * layout before or after the one the engine is using, in the order
65607
+ * it offers them. The buttons are disabled at the ends, so a step
65608
+ * out of the list is a sender that did not read them.
65609
+ ************************************************************/
65610
+ function ac_step_layout(gobj, event, kw, src) {
65611
+ let priv = gobj.priv;
65612
+ let step = kw && kw.step || 0;
65613
+ let names = gobj_read_attr(priv.gobj_nodes_tree, "layout_names") || [];
65614
+ let index = names.indexOf(gobj_read_str_attr(priv.gobj_nodes_tree, "layout")) + step;
65615
+ if (step === 0 || index < 0 || index >= names.length) {
65616
+ log_error(`${gobj_short_name(gobj)}: layout step ${step} is out of the list`);
65617
+ return -1;
65618
+ }
65619
+ gobj_send_event(gobj, "EV_SET_LAYOUT", { layout: names[index] }, gobj);
65558
65620
  return 0;
65559
65621
  }
65560
65622
  /************************************************************
@@ -65887,6 +65949,7 @@ function ac_layout_autoset(gobj, event, kw, src) {
65887
65949
  let layout = kw && kw.layout || "";
65888
65950
  if (!$select || !layout) return 0;
65889
65951
  $select.value = layout;
65952
+ refresh_layout_stepper(gobj);
65890
65953
  return 0;
65891
65954
  }
65892
65955
  /************************************************************
@@ -66163,6 +66226,11 @@ function create_gclass$3(gclass_name) {
66163
66226
  ac_set_layout,
66164
66227
  null
66165
66228
  ],
66229
+ [
66230
+ "EV_STEP_LAYOUT",
66231
+ ac_step_layout,
66232
+ null
66233
+ ],
66166
66234
  [
66167
66235
  "EV_SET_OPERATION_MODE",
66168
66236
  ac_set_operation_mode,
@@ -66267,6 +66335,7 @@ function create_gclass$3(gclass_name) {
66267
66335
  ["EV_RUN_NODE", 0],
66268
66336
  ["EV_CLOSE_WINDOW", 0],
66269
66337
  ["EV_SET_LAYOUT", 0],
66338
+ ["EV_STEP_LAYOUT", 0],
66270
66339
  ["EV_SET_OPERATION_MODE", 0],
66271
66340
  ["EV_SET_FOCUS_TOPIC", 0],
66272
66341
  ["EV_FIND_NODES", 0],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuneta/gobj-ui",
3
- "version": "7.23.145",
3
+ "version": "7.23.146",
4
4
  "type": "module",
5
5
  "main": "dist/gobj-ui.cjs.js",
6
6
  "module": "dist/gobj-ui.es.js",
@@ -783,6 +783,48 @@ function refresh_fold_level(gobj)
783
783
  }
784
784
  }
785
785
 
786
+ /* A button of the layout stepper: the layout before (`step` -1) or
787
+ * after (+1) the current one, in the order the engine offers them. */
788
+ function layout_step_button(gobj, cls, icon, key, step)
789
+ {
790
+ return ['button', {class: `${cls} button`, type: 'button',
791
+ style: {height: gobj_read_str_attr(gobj, "wide"), width: '2.5em'},
792
+ disabled: true,
793
+ title: t(key), 'data-i18n-title': key,
794
+ 'aria-label': t(key), 'data-i18n-aria-label': key},
795
+ yui_toolbar_icon(icon),
796
+ {
797
+ click: (evt) => {
798
+ evt.stopPropagation();
799
+ gobj_send_event(gobj, "EV_STEP_LAYOUT", {step: step}, gobj);
800
+ }
801
+ }
802
+ ];
803
+ }
804
+
805
+ /* Paint the layout stepper from the layout the engine is USING: it can
806
+ * differ from the persisted choice (auto_layout picks one for a treedb
807
+ * nobody arranged). The ends of the list disable their button. */
808
+ function refresh_layout_stepper(gobj)
809
+ {
810
+ let priv = gobj.priv;
811
+ let $container = priv.$container;
812
+ if(!$container || !priv.gobj_nodes_tree) {
813
+ return;
814
+ }
815
+ let names = gobj_read_attr(priv.gobj_nodes_tree, "layout_names") || [];
816
+ let index = names.indexOf(gobj_read_str_attr(priv.gobj_nodes_tree, "layout"));
817
+
818
+ let $prev = $container.querySelector('.GRAPH_LAYOUT_PREV');
819
+ let $next = $container.querySelector('.GRAPH_LAYOUT_NEXT');
820
+ if($prev) {
821
+ $prev.disabled = !(index > 0);
822
+ }
823
+ if($next) {
824
+ $next.disabled = !(index >= 0 && index < names.length - 1);
825
+ }
826
+ }
827
+
786
828
  function make_toolbar(gobj)
787
829
  {
788
830
  let priv = gobj.priv;
@@ -833,6 +875,15 @@ function make_toolbar(gobj)
833
875
  gobj_send_event(gobj, "EV_SET_LAYOUT", {layout: evt.target.value}, gobj);
834
876
  }
835
877
  }],
878
+ /* One step up or down the list without opening it: layouts are
879
+ * picked by trying them one after another, and a list closes on
880
+ * every pick. Born disabled, like the fold stepper: the options
881
+ * arrive with the child (populate_nodes_tree_options). */
882
+ ['div', {class: 'GRAPH_LAYOUT_STEPPER buttons has-addons',
883
+ style: 'margin:0 0 0 .25rem; flex:0 0 auto; flex-wrap:nowrap; align-items:stretch;'}, [
884
+ layout_step_button(gobj, 'GRAPH_LAYOUT_PREV', 'yi-chevron-up', 'previous layout', -1),
885
+ layout_step_button(gobj, 'GRAPH_LAYOUT_NEXT', 'yi-chevron-down', 'next layout', 1),
886
+ ]],
836
887
 
837
888
  ['span', {class: 'GRAPH_MODE_LABEL is-hidden-mobile', style: 'padding-left:10px; padding-right:5px;', i18n: 'operation mode'}, 'operation mode'],
838
889
  ['div', {class: 'select'}, [
@@ -1264,6 +1315,7 @@ function populate_nodes_tree_options(gobj)
1264
1315
  if(current_layout) {
1265
1316
  $layout_select.value = current_layout;
1266
1317
  }
1318
+ refresh_layout_stepper(gobj);
1267
1319
  }
1268
1320
 
1269
1321
  // Restore persisted operation_mode selection
@@ -2558,7 +2610,30 @@ function ac_set_layout(gobj, event, kw, src)
2558
2610
  },
2559
2611
  gobj
2560
2612
  );
2613
+ refresh_layout_stepper(gobj);
2614
+
2615
+ return 0;
2616
+ }
2617
+
2618
+ /************************************************************
2619
+ * One press of the layout stepper (EV_STEP_LAYOUT {step}): the
2620
+ * layout before or after the one the engine is using, in the order
2621
+ * it offers them. The buttons are disabled at the ends, so a step
2622
+ * out of the list is a sender that did not read them.
2623
+ ************************************************************/
2624
+ function ac_step_layout(gobj, event, kw, src)
2625
+ {
2626
+ let priv = gobj.priv;
2627
+
2628
+ let step = (kw && kw.step) || 0;
2629
+ let names = gobj_read_attr(priv.gobj_nodes_tree, "layout_names") || [];
2630
+ let index = names.indexOf(gobj_read_str_attr(priv.gobj_nodes_tree, "layout")) + step;
2631
+ if(step === 0 || index < 0 || index >= names.length) {
2632
+ log_error(`${gobj_short_name(gobj)}: layout step ${step} is out of the list`);
2633
+ return -1;
2634
+ }
2561
2635
 
2636
+ gobj_send_event(gobj, "EV_SET_LAYOUT", {layout: names[index]}, gobj);
2562
2637
  return 0;
2563
2638
  }
2564
2639
 
@@ -3037,6 +3112,7 @@ function ac_layout_autoset(gobj, event, kw, src)
3037
3112
  return 0;
3038
3113
  }
3039
3114
  $select.value = layout;
3115
+ refresh_layout_stepper(gobj);
3040
3116
  return 0;
3041
3117
  }
3042
3118
 
@@ -3308,6 +3384,7 @@ function create_gclass(gclass_name)
3308
3384
  ["EV_RUN_NODE", ac_run_node, null],
3309
3385
  ["EV_CLOSE_WINDOW", ac_close_window, null],
3310
3386
  ["EV_SET_LAYOUT", ac_set_layout, null],
3387
+ ["EV_STEP_LAYOUT", ac_step_layout, null],
3311
3388
  ["EV_SET_OPERATION_MODE", ac_set_operation_mode, null],
3312
3389
  ["EV_SET_FOCUS_TOPIC", ac_set_focus_topic, null],
3313
3390
  ["EV_FIND_NODES", ac_find_nodes, null],
@@ -3353,6 +3430,7 @@ function create_gclass(gclass_name)
3353
3430
  ["EV_RUN_NODE", 0],
3354
3431
  ["EV_CLOSE_WINDOW", 0],
3355
3432
  ["EV_SET_LAYOUT", 0],
3433
+ ["EV_STEP_LAYOUT", 0],
3356
3434
  ["EV_SET_OPERATION_MODE", 0],
3357
3435
  ["EV_SET_FOCUS_TOPIC", 0],
3358
3436
  ["EV_FIND_NODES", 0],