@yuneta/gobj-ui 7.23.82 → 7.23.83

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
@@ -1364,10 +1364,13 @@ screen every card is a smudge. Since `7.23.82` a record has **three views**
1364
1364
  popover's own scope: this node, the topic, every node), remembered as the
1365
1365
  topic's default and saved per node in `__graphs__` as `node_shape`.
1366
1366
 
1367
- In the view's toolbar (`C_YUI_TREEDB_GRAPH`), next to the fold pair: a
1368
- `nodes` select (`full` / `compact` / `shape`, persisted as `node_mode`; a
1369
- change lays the graph out again, because a figure and a card do not take the
1370
- same room) and a labels toggle (`node_labels`, the name under each figure,
1367
+ In the view's toolbar (`C_YUI_TREEDB_GRAPH`), next to the fold pair: three
1368
+ push buttons in one group — a card, a line, a figure — the pressed one being
1369
+ the view that is on (`full` / `compact` / `shape`, persisted as `node_mode`;
1370
+ a change lays the graph out again, because a figure and a card do not take
1371
+ the same room; buttons and not a select since `7.23.83`, because a view is
1372
+ picked at a glance and a closed list says nothing until it is opened) and a
1373
+ labels toggle (`node_labels`, the name under each figure,
1371
1374
  enabled in the `shape` view only — nothing moves, the label hangs outside the
1372
1375
  figure and the layout measures the figure).
1373
1376
 
@@ -61911,68 +61911,64 @@ function option_label(name) {
61911
61911
  * its context menu (the child's business).
61912
61912
  ************************************************************/
61913
61913
  function node_shape_items(gobj, wide) {
61914
- let options = NODE_MODES.map((mode) => [
61915
- "option",
61914
+ return [[
61915
+ "div",
61916
61916
  {
61917
- value: mode,
61918
- "data-i18n": NODE_MODE_LABELS[mode]
61917
+ class: "GRAPH_NODE_MODE buttons has-addons",
61918
+ style: "margin:0 0 0 .5rem; flex:0 0 auto; flex-wrap:nowrap;"
61919
61919
  },
61920
- (0, i18next.t)(NODE_MODE_LABELS[mode])
61921
- ]);
61922
- return [
61923
- [
61924
- "span",
61925
- {
61926
- class: "GRAPH_NODE_MODE_LABEL is-hidden-mobile",
61927
- style: "padding-left:10px; padding-right:5px;",
61928
- i18n: "nodes"
61929
- },
61930
- "nodes"
61931
- ],
61932
- [
61933
- "div",
61934
- { class: "select" },
61935
- [[
61936
- "select",
61920
+ NODE_MODES.map((mode) => {
61921
+ let key = NODE_MODE_LABELS[mode];
61922
+ return [
61923
+ "button",
61937
61924
  {
61938
- class: "GRAPH_NODE_MODE_SELECT",
61939
- title: (0, i18next.t)("nodes"),
61940
- "data-i18n-title": "nodes",
61941
- "aria-label": (0, i18next.t)("nodes"),
61942
- "data-i18n-aria-label": "nodes"
61943
- },
61944
- options
61945
- ]],
61946
- { change: (evt) => {
61947
- evt.stopPropagation();
61948
- (0, _yuneta_gobj_js.gobj_send_event)(gobj, "EV_SET_NODE_MODE", { node_mode: evt.target.value }, gobj);
61949
- } }
61950
- ],
61951
- [
61952
- "button",
61953
- {
61954
- class: "GRAPH_NODE_LABELS button",
61955
- type: "button",
61956
- style: {
61957
- height: wide,
61958
- width: "2.5em"
61925
+ class: "GRAPH_NODE_MODE_BTN button",
61926
+ type: "button",
61927
+ "data-mode": mode,
61928
+ style: {
61929
+ height: wide,
61930
+ width: "2.5em"
61931
+ },
61932
+ title: (0, i18next.t)(key),
61933
+ "data-i18n-title": key,
61934
+ "aria-label": (0, i18next.t)(key),
61935
+ "data-i18n-aria-label": key,
61936
+ "aria-pressed": "false"
61959
61937
  },
61960
- title: (0, i18next.t)("node labels"),
61961
- "data-i18n-title": "node labels",
61962
- "aria-label": (0, i18next.t)("node labels"),
61963
- "data-i18n-aria-label": "node labels",
61964
- "aria-pressed": "false"
61938
+ ["i", {
61939
+ style: "font-size:1.5em; color:inherit;",
61940
+ class: NODE_MODE_ICONS[mode]
61941
+ }],
61942
+ { click: (evt) => {
61943
+ evt.stopPropagation();
61944
+ (0, _yuneta_gobj_js.gobj_send_event)(gobj, "EV_SET_NODE_MODE", { node_mode: mode }, gobj);
61945
+ } }
61946
+ ];
61947
+ })
61948
+ ], [
61949
+ "button",
61950
+ {
61951
+ class: "GRAPH_NODE_LABELS button",
61952
+ type: "button",
61953
+ style: {
61954
+ height: wide,
61955
+ width: "2.5em"
61965
61956
  },
61966
- ["i", {
61967
- style: "font-size:1.5em; color:inherit;",
61968
- class: "yi-font"
61969
- }],
61970
- { click: (evt) => {
61971
- evt.stopPropagation();
61972
- (0, _yuneta_gobj_js.gobj_send_event)(gobj, "EV_TOGGLE_NODE_LABELS", {}, gobj);
61973
- } }
61974
- ]
61975
- ];
61957
+ title: (0, i18next.t)("node labels"),
61958
+ "data-i18n-title": "node labels",
61959
+ "aria-label": (0, i18next.t)("node labels"),
61960
+ "data-i18n-aria-label": "node labels",
61961
+ "aria-pressed": "false"
61962
+ },
61963
+ ["i", {
61964
+ style: "font-size:1.5em; color:inherit;",
61965
+ class: "yi-font"
61966
+ }],
61967
+ { click: (evt) => {
61968
+ evt.stopPropagation();
61969
+ (0, _yuneta_gobj_js.gobj_send_event)(gobj, "EV_TOGGLE_NODE_LABELS", {}, gobj);
61970
+ } }
61971
+ ]];
61976
61972
  }
61977
61973
  var NODE_MODES = [
61978
61974
  "expanded",
@@ -61984,13 +61980,21 @@ var NODE_MODE_LABELS = {
61984
61980
  compact: "compact",
61985
61981
  shape: "shape"
61986
61982
  };
61983
+ var NODE_MODE_ICONS = {
61984
+ expanded: "yi-square",
61985
+ compact: "yi-bars",
61986
+ shape: "yi-hexagon-nodes"
61987
+ };
61987
61988
  function refresh_node_shape_buttons(gobj, $root) {
61988
61989
  if (!$root) return;
61989
61990
  let mode = (0, _yuneta_gobj_js.gobj_read_str_attr)(gobj, "node_mode");
61990
61991
  if (!NODE_MODES.includes(mode)) mode = "expanded";
61991
61992
  let labels = (0, _yuneta_gobj_js.gobj_read_bool_attr)(gobj, "node_labels");
61992
- let $mode = $root.querySelector(".GRAPH_NODE_MODE_SELECT");
61993
- if ($mode) $mode.value = mode;
61993
+ for (let $btn of $root.querySelectorAll(".GRAPH_NODE_MODE_BTN")) {
61994
+ let on = $btn.getAttribute("data-mode") === mode;
61995
+ $btn.classList.toggle("pressed_state", on);
61996
+ $btn.setAttribute("aria-pressed", on ? "true" : "false");
61997
+ }
61994
61998
  set_pressed_state($root, ".GRAPH_NODE_LABELS", labels);
61995
61999
  let $labels = $root.querySelector(".GRAPH_NODE_LABELS");
61996
62000
  if ($labels) {
@@ -61906,68 +61906,64 @@ function option_label(name) {
61906
61906
  * its context menu (the child's business).
61907
61907
  ************************************************************/
61908
61908
  function node_shape_items(gobj, wide) {
61909
- let options = NODE_MODES.map((mode) => [
61910
- "option",
61909
+ return [[
61910
+ "div",
61911
61911
  {
61912
- value: mode,
61913
- "data-i18n": NODE_MODE_LABELS[mode]
61912
+ class: "GRAPH_NODE_MODE buttons has-addons",
61913
+ style: "margin:0 0 0 .5rem; flex:0 0 auto; flex-wrap:nowrap;"
61914
61914
  },
61915
- t(NODE_MODE_LABELS[mode])
61916
- ]);
61917
- return [
61918
- [
61919
- "span",
61920
- {
61921
- class: "GRAPH_NODE_MODE_LABEL is-hidden-mobile",
61922
- style: "padding-left:10px; padding-right:5px;",
61923
- i18n: "nodes"
61924
- },
61925
- "nodes"
61926
- ],
61927
- [
61928
- "div",
61929
- { class: "select" },
61930
- [[
61931
- "select",
61915
+ NODE_MODES.map((mode) => {
61916
+ let key = NODE_MODE_LABELS[mode];
61917
+ return [
61918
+ "button",
61932
61919
  {
61933
- class: "GRAPH_NODE_MODE_SELECT",
61934
- title: t("nodes"),
61935
- "data-i18n-title": "nodes",
61936
- "aria-label": t("nodes"),
61937
- "data-i18n-aria-label": "nodes"
61938
- },
61939
- options
61940
- ]],
61941
- { change: (evt) => {
61942
- evt.stopPropagation();
61943
- gobj_send_event(gobj, "EV_SET_NODE_MODE", { node_mode: evt.target.value }, gobj);
61944
- } }
61945
- ],
61946
- [
61947
- "button",
61948
- {
61949
- class: "GRAPH_NODE_LABELS button",
61950
- type: "button",
61951
- style: {
61952
- height: wide,
61953
- width: "2.5em"
61920
+ class: "GRAPH_NODE_MODE_BTN button",
61921
+ type: "button",
61922
+ "data-mode": mode,
61923
+ style: {
61924
+ height: wide,
61925
+ width: "2.5em"
61926
+ },
61927
+ title: t(key),
61928
+ "data-i18n-title": key,
61929
+ "aria-label": t(key),
61930
+ "data-i18n-aria-label": key,
61931
+ "aria-pressed": "false"
61954
61932
  },
61955
- title: t("node labels"),
61956
- "data-i18n-title": "node labels",
61957
- "aria-label": t("node labels"),
61958
- "data-i18n-aria-label": "node labels",
61959
- "aria-pressed": "false"
61933
+ ["i", {
61934
+ style: "font-size:1.5em; color:inherit;",
61935
+ class: NODE_MODE_ICONS[mode]
61936
+ }],
61937
+ { click: (evt) => {
61938
+ evt.stopPropagation();
61939
+ gobj_send_event(gobj, "EV_SET_NODE_MODE", { node_mode: mode }, gobj);
61940
+ } }
61941
+ ];
61942
+ })
61943
+ ], [
61944
+ "button",
61945
+ {
61946
+ class: "GRAPH_NODE_LABELS button",
61947
+ type: "button",
61948
+ style: {
61949
+ height: wide,
61950
+ width: "2.5em"
61960
61951
  },
61961
- ["i", {
61962
- style: "font-size:1.5em; color:inherit;",
61963
- class: "yi-font"
61964
- }],
61965
- { click: (evt) => {
61966
- evt.stopPropagation();
61967
- gobj_send_event(gobj, "EV_TOGGLE_NODE_LABELS", {}, gobj);
61968
- } }
61969
- ]
61970
- ];
61952
+ title: t("node labels"),
61953
+ "data-i18n-title": "node labels",
61954
+ "aria-label": t("node labels"),
61955
+ "data-i18n-aria-label": "node labels",
61956
+ "aria-pressed": "false"
61957
+ },
61958
+ ["i", {
61959
+ style: "font-size:1.5em; color:inherit;",
61960
+ class: "yi-font"
61961
+ }],
61962
+ { click: (evt) => {
61963
+ evt.stopPropagation();
61964
+ gobj_send_event(gobj, "EV_TOGGLE_NODE_LABELS", {}, gobj);
61965
+ } }
61966
+ ]];
61971
61967
  }
61972
61968
  var NODE_MODES = [
61973
61969
  "expanded",
@@ -61979,13 +61975,21 @@ var NODE_MODE_LABELS = {
61979
61975
  compact: "compact",
61980
61976
  shape: "shape"
61981
61977
  };
61978
+ var NODE_MODE_ICONS = {
61979
+ expanded: "yi-square",
61980
+ compact: "yi-bars",
61981
+ shape: "yi-hexagon-nodes"
61982
+ };
61982
61983
  function refresh_node_shape_buttons(gobj, $root) {
61983
61984
  if (!$root) return;
61984
61985
  let mode = gobj_read_str_attr(gobj, "node_mode");
61985
61986
  if (!NODE_MODES.includes(mode)) mode = "expanded";
61986
61987
  let labels = gobj_read_bool_attr(gobj, "node_labels");
61987
- let $mode = $root.querySelector(".GRAPH_NODE_MODE_SELECT");
61988
- if ($mode) $mode.value = mode;
61988
+ for (let $btn of $root.querySelectorAll(".GRAPH_NODE_MODE_BTN")) {
61989
+ let on = $btn.getAttribute("data-mode") === mode;
61990
+ $btn.classList.toggle("pressed_state", on);
61991
+ $btn.setAttribute("aria-pressed", on ? "true" : "false");
61992
+ }
61989
61993
  set_pressed_state($root, ".GRAPH_NODE_LABELS", labels);
61990
61994
  let $labels = $root.querySelector(".GRAPH_NODE_LABELS");
61991
61995
  if ($labels) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuneta/gobj-ui",
3
- "version": "7.23.82",
3
+ "version": "7.23.83",
4
4
  "type": "module",
5
5
  "main": "dist/gobj-ui.cjs.js",
6
6
  "module": "dist/gobj-ui.es.js",
@@ -547,26 +547,31 @@ function option_label(name)
547
547
  ************************************************************/
548
548
  function node_shape_items(gobj, wide)
549
549
  {
550
- /* `value` explicit on every option, as on the two selects
551
- * above: a translated <option> without one answers with its
552
- * TEXT, and the mode the child is told is a word it does not
553
- * know. */
554
- let options = NODE_MODES.map((mode) =>
555
- ['option', {value: mode, 'data-i18n': NODE_MODE_LABELS[mode]}, t(NODE_MODE_LABELS[mode])]
556
- );
557
- return [
558
- ['span', {class: 'GRAPH_NODE_MODE_LABEL is-hidden-mobile',
559
- style: 'padding-left:10px; padding-right:5px;', i18n: 'nodes'}, 'nodes'],
560
- ['div', {class: 'select'}, [
561
- ['select', {class: 'GRAPH_NODE_MODE_SELECT',
562
- title: t('nodes'), 'data-i18n-title': 'nodes',
563
- 'aria-label': t('nodes'), 'data-i18n-aria-label': 'nodes'}, options]
564
- ], {
565
- change: (evt) => {
566
- evt.stopPropagation();
567
- gobj_send_event(gobj, "EV_SET_NODE_MODE", {node_mode: evt.target.value}, gobj);
550
+ /* Three push buttons in one group, not a select: a view is
551
+ * picked at a glance and in one press, and the pressed one
552
+ * SAYS which view is on -- a closed list says nothing until it
553
+ * is opened. Icons, because a card, a line and a figure draw
554
+ * themselves better than three words. */
555
+ let mode_buttons = NODE_MODES.map((mode) => {
556
+ let key = NODE_MODE_LABELS[mode];
557
+ return ['button', {class: 'GRAPH_NODE_MODE_BTN button', type: 'button',
558
+ 'data-mode': mode,
559
+ style: {height: wide, width: '2.5em'},
560
+ title: t(key), 'data-i18n-title': key,
561
+ 'aria-label': t(key), 'data-i18n-aria-label': key,
562
+ 'aria-pressed': 'false'},
563
+ ['i', {style: 'font-size:1.5em; color:inherit;', class: NODE_MODE_ICONS[mode]}],
564
+ {
565
+ click: (evt) => {
566
+ evt.stopPropagation();
567
+ gobj_send_event(gobj, "EV_SET_NODE_MODE", {node_mode: mode}, gobj);
568
+ }
568
569
  }
569
- }],
570
+ ];
571
+ });
572
+ return [
573
+ ['div', {class: 'GRAPH_NODE_MODE buttons has-addons',
574
+ style: 'margin:0 0 0 .5rem; flex:0 0 auto; flex-wrap:nowrap;'}, mode_buttons],
570
575
  ['button', {class: 'GRAPH_NODE_LABELS button', type: 'button',
571
576
  style: {height: wide, width: '2.5em'},
572
577
  title: t('node labels'), 'data-i18n-title': 'node labels',
@@ -583,17 +588,23 @@ function node_shape_items(gobj, wide)
583
588
  ];
584
589
  }
585
590
 
586
- /* The three views of a record, and the label of each in the
587
- * select. The values are the child's `node_mode`. */
591
+ /* The three views of a record: the child's `node_mode`, the i18n
592
+ * key of each, and the glyph -- a card, a line, a figure. */
588
593
  const NODE_MODES = ['expanded', 'compact', 'shape'];
589
594
  const NODE_MODE_LABELS = {
590
595
  expanded: 'full',
591
596
  compact: 'compact',
592
597
  shape: 'shape',
593
598
  };
599
+ const NODE_MODE_ICONS = {
600
+ expanded: 'yi-square',
601
+ compact: 'yi-bars',
602
+ shape: 'yi-hexagon-nodes',
603
+ };
594
604
 
595
- /* The select and the labels toggle, from the attrs. The toggle
596
- * only means something on figures, so it is disabled elsewhere.
605
+ /* The pressed view and the labels toggle, from the attrs. The
606
+ * toggle only means something on figures, so it is disabled
607
+ * elsewhere.
597
608
  * `$root` is whatever holds the toolbar: the toolbar itself before
598
609
  * the view is mounted, the view's container after. */
599
610
  function refresh_node_shape_buttons(gobj, $root)
@@ -606,9 +617,10 @@ function refresh_node_shape_buttons(gobj, $root)
606
617
  mode = 'expanded';
607
618
  }
608
619
  let labels = gobj_read_bool_attr(gobj, "node_labels");
609
- let $mode = $root.querySelector('.GRAPH_NODE_MODE_SELECT');
610
- if($mode) {
611
- $mode.value = mode;
620
+ for(let $btn of $root.querySelectorAll('.GRAPH_NODE_MODE_BTN')) {
621
+ let on = ($btn.getAttribute('data-mode') === mode);
622
+ $btn.classList.toggle('pressed_state', on);
623
+ $btn.setAttribute('aria-pressed', on? 'true' : 'false');
612
624
  }
613
625
  set_pressed_state($root, '.GRAPH_NODE_LABELS', labels);
614
626
  let $labels = $root.querySelector('.GRAPH_NODE_LABELS');