@yuneta/gobj-ui 7.26.6 → 7.26.7
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 +74 -25
- package/dist/gobj-ui.cjs.js +635 -242
- package/dist/gobj-ui.es.js +635 -242
- package/index.js +5 -1
- package/package.json +2 -2
- package/src/c_g6_nodes_tree.js +41 -0
- package/src/c_yui_form.js +140 -83
- package/src/c_yui_gclass.js +6 -2
- package/src/c_yui_gobj_tree_js.js +15 -4
- package/src/c_yui_json_graph.js +40 -13
- package/src/c_yui_map.js +115 -75
- package/src/c_yui_nav.js +53 -14
- package/src/c_yui_pager.js +14 -9
- package/src/c_yui_period.js +16 -6
- package/src/c_yui_shell.js +89 -31
- package/src/c_yui_treedb_topic_with_form.js +33 -44
- package/src/c_yui_uplot.js +1 -1
- package/src/c_yui_window.js +70 -24
- package/src/c_yui_window_manager.js +7 -3
- package/src/c_yui_wizard.js +23 -8
- package/src/delete_impact.js +5 -3
- package/src/form_json_field.js +116 -0
- package/src/form_json_field.test.js +43 -0
- package/src/form_json_field.wiring.test.js +137 -0
- package/src/schema_to_c.js +17 -1
- package/src/schema_to_c.test.js +7 -0
- package/src/shell_route_map.js +6 -0
- package/src/treedb_topics_transport.wiring.test.js +9 -1
- package/src/window_veto_back.wiring.test.js +101 -0
- package/src/wizard_chrome.wiring.test.js +87 -0
- package/src/yui_dev.js +10 -3
- package/src/yui_table_filter_clear.js +44 -44
- package/vite-plugin-yuneta-html.js +28 -6
package/index.js
CHANGED
|
@@ -5,7 +5,11 @@
|
|
|
5
5
|
*
|
|
6
6
|
* Barrel re-exports for the v2 source, which lives in src/.
|
|
7
7
|
* This is the canonical line, embedded as the yunetas submodule
|
|
8
|
-
* kernel/js/gobj-ui and
|
|
8
|
+
* kernel/js/gobj-ui and published to npm; every app takes it
|
|
9
|
+
* from the registry. The barrel is a SUBSET: most apps import
|
|
10
|
+
* by specifier (`@yuneta/gobj-ui/src/<module>.js`), which is
|
|
11
|
+
* how C_YUI_NODE, yui_shell_of() and the rest of the deep
|
|
12
|
+
* surface are reached.
|
|
9
13
|
*
|
|
10
14
|
* Copyright (c) 2024-2026, ArtGins.
|
|
11
15
|
* All Rights Reserved.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yuneta/gobj-ui",
|
|
3
|
-
"version": "7.26.
|
|
3
|
+
"version": "7.26.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/gobj-ui.cjs.js",
|
|
6
6
|
"module": "dist/gobj-ui.es.js",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"src/",
|
|
21
21
|
"vite-plugin-yuneta-html.js"
|
|
22
22
|
],
|
|
23
|
-
"description": "Yuneta UI Library — the active line: declarative shell (C_YUI_SHELL+NAV+PAGER+WIZARD) + windows, TreeDB views, forms, charts and maps. Consumed
|
|
23
|
+
"description": "Yuneta UI Library — the active line: declarative shell (C_YUI_SHELL+NAV+PAGER+WIZARD) + windows, TreeDB views, forms, charts and maps. Consumed from the npm registry by the Yuneta SPAs (gui_agent, gui_treedb, wattyzer, yunovatios). The frozen legacy GClass GUI stack (C_YUI_MAIN/TABS/ROUTING) lives on the v1 branch, npm dist-tag 'legacy' (consumed by estadodelaire and hidraulia).",
|
|
24
24
|
"scripts": {
|
|
25
25
|
"build": "vite build",
|
|
26
26
|
"test": "vitest run",
|
package/src/c_g6_nodes_tree.js
CHANGED
|
@@ -5579,6 +5579,7 @@ function start_node_resize(gobj, e, mx, my)
|
|
|
5579
5579
|
function onPointerUp(ev) {
|
|
5580
5580
|
document.removeEventListener('pointermove', onPointerMove);
|
|
5581
5581
|
document.removeEventListener('pointerup', onPointerUp);
|
|
5582
|
+
document.removeEventListener('pointercancel', onPointerCancel);
|
|
5582
5583
|
|
|
5583
5584
|
// Calculate final size in world coordinates from the viewport rect deltas
|
|
5584
5585
|
const dLeft = (currentRect.left - origVpRect.left) / zoom;
|
|
@@ -5631,8 +5632,19 @@ function start_node_resize(gobj, e, mx, my)
|
|
|
5631
5632
|
});
|
|
5632
5633
|
}
|
|
5633
5634
|
|
|
5635
|
+
/* A cancelled pointer (the browser took the touch) is no drop: the
|
|
5636
|
+
* listeners go, and what was there stays. Without it they stayed
|
|
5637
|
+
* on `document` until some later pointerup, which then dropped. */
|
|
5638
|
+
function onPointerCancel(ev) {
|
|
5639
|
+
document.removeEventListener('pointermove', onPointerMove);
|
|
5640
|
+
document.removeEventListener('pointerup', onPointerUp);
|
|
5641
|
+
document.removeEventListener('pointercancel', onPointerCancel);
|
|
5642
|
+
update_resize_handles_position(gobj);
|
|
5643
|
+
}
|
|
5644
|
+
|
|
5634
5645
|
document.addEventListener('pointermove', onPointerMove);
|
|
5635
5646
|
document.addEventListener('pointerup', onPointerUp);
|
|
5647
|
+
document.addEventListener('pointercancel', onPointerCancel);
|
|
5636
5648
|
}
|
|
5637
5649
|
|
|
5638
5650
|
/************************************************************
|
|
@@ -6477,6 +6489,7 @@ function start_link_drag(gobj, e)
|
|
|
6477
6489
|
function onPointerUp(ev) {
|
|
6478
6490
|
document.removeEventListener('pointermove', onPointerMove);
|
|
6479
6491
|
document.removeEventListener('pointerup', onPointerUp);
|
|
6492
|
+
document.removeEventListener('pointercancel', onPointerCancel);
|
|
6480
6493
|
priv.$container.style.cursor = '';
|
|
6481
6494
|
|
|
6482
6495
|
// Remove drag line
|
|
@@ -6503,8 +6516,24 @@ function start_link_drag(gobj, e)
|
|
|
6503
6516
|
}
|
|
6504
6517
|
}
|
|
6505
6518
|
|
|
6519
|
+
/* A cancelled pointer (the browser took the touch) is no drop: the
|
|
6520
|
+
* listeners go, and what was there stays. Without it they stayed
|
|
6521
|
+
* on `document` until some later pointerup, which then dropped. */
|
|
6522
|
+
function onPointerCancel(ev) {
|
|
6523
|
+
document.removeEventListener('pointermove', onPointerMove);
|
|
6524
|
+
document.removeEventListener('pointerup', onPointerUp);
|
|
6525
|
+
document.removeEventListener('pointercancel', onPointerCancel);
|
|
6526
|
+
priv.$container.style.cursor = '';
|
|
6527
|
+
if(priv._link_drag_svg) {
|
|
6528
|
+
priv._link_drag_svg.remove();
|
|
6529
|
+
priv._link_drag_svg = null;
|
|
6530
|
+
}
|
|
6531
|
+
exit_linking_mode(gobj);
|
|
6532
|
+
}
|
|
6533
|
+
|
|
6506
6534
|
document.addEventListener('pointermove', onPointerMove);
|
|
6507
6535
|
document.addEventListener('pointerup', onPointerUp);
|
|
6536
|
+
document.addEventListener('pointercancel', onPointerCancel);
|
|
6508
6537
|
}
|
|
6509
6538
|
|
|
6510
6539
|
/************************************************************
|
|
@@ -6744,6 +6773,7 @@ function start_port_resize(gobj, e)
|
|
|
6744
6773
|
function onPointerUp(ev) {
|
|
6745
6774
|
document.removeEventListener('pointermove', onPointerMove);
|
|
6746
6775
|
document.removeEventListener('pointerup', onPointerUp);
|
|
6776
|
+
document.removeEventListener('pointercancel', onPointerCancel);
|
|
6747
6777
|
|
|
6748
6778
|
// Calculate new radius in world coordinates
|
|
6749
6779
|
const dx = ev.clientX - clientCx;
|
|
@@ -6769,8 +6799,19 @@ function start_port_resize(gobj, e)
|
|
|
6769
6799
|
});
|
|
6770
6800
|
}
|
|
6771
6801
|
|
|
6802
|
+
/* A cancelled pointer (the browser took the touch) is no drop: the
|
|
6803
|
+
* listeners go, and what was there stays. Without it they stayed
|
|
6804
|
+
* on `document` until some later pointerup, which then dropped. */
|
|
6805
|
+
function onPointerCancel(ev) {
|
|
6806
|
+
document.removeEventListener('pointermove', onPointerMove);
|
|
6807
|
+
document.removeEventListener('pointerup', onPointerUp);
|
|
6808
|
+
document.removeEventListener('pointercancel', onPointerCancel);
|
|
6809
|
+
update_port_resize_handles_position(gobj);
|
|
6810
|
+
}
|
|
6811
|
+
|
|
6772
6812
|
document.addEventListener('pointermove', onPointerMove);
|
|
6773
6813
|
document.addEventListener('pointerup', onPointerUp);
|
|
6814
|
+
document.addEventListener('pointercancel', onPointerCancel);
|
|
6774
6815
|
}
|
|
6775
6816
|
|
|
6776
6817
|
/************************************************************
|
package/src/c_yui_form.js
CHANGED
|
@@ -89,6 +89,7 @@ import "tabulator-tables/dist/css/tabulator_bulma.css";
|
|
|
89
89
|
import "./tabulator.css";
|
|
90
90
|
import {is_time_field} from "./json_view_helpers.js";
|
|
91
91
|
import {date_to_datetime_local, datetime_local_to_epoch} from "./form_time_value.js";
|
|
92
|
+
import {parse_json_field, json_editor_value} from "./form_json_field.js";
|
|
92
93
|
import { TabulatorFull as Tabulator } from "tabulator-tables"; // Import Full Tabulator JS
|
|
93
94
|
// import { Tabulator } from "tabulator-tables"; // Import light Tabulator JS
|
|
94
95
|
|
|
@@ -492,6 +493,7 @@ function destroy_ui(gobj)
|
|
|
492
493
|
{
|
|
493
494
|
let $container = gobj_read_attr(gobj, "$container");
|
|
494
495
|
if($container) {
|
|
496
|
+
destroy_widgets(gobj, $container);
|
|
495
497
|
if($container.parentNode) {
|
|
496
498
|
$container.parentNode.removeChild($container);
|
|
497
499
|
}
|
|
@@ -499,6 +501,60 @@ function destroy_ui(gobj)
|
|
|
499
501
|
}
|
|
500
502
|
}
|
|
501
503
|
|
|
504
|
+
/************************************************************
|
|
505
|
+
* The icon a table cell draws as its control (delete the row,
|
|
506
|
+
* add a nested row): an element, so it carries its name. Drawn
|
|
507
|
+
* by Tabulator on every render, so t() at render time is
|
|
508
|
+
* current.
|
|
509
|
+
************************************************************/
|
|
510
|
+
function cell_icon(icon_class, key)
|
|
511
|
+
{
|
|
512
|
+
let $i = document.createElement('i');
|
|
513
|
+
$i.className = icon_class;
|
|
514
|
+
$i.setAttribute('title', t(key));
|
|
515
|
+
$i.setAttribute('aria-label', t(key));
|
|
516
|
+
return $i;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
/************************************************************
|
|
520
|
+
* Destroy the third-party widgets the form built. Removing
|
|
521
|
+
* their DOM is not enough: Tom Select keeps listeners on
|
|
522
|
+
* `document` and `window`, the jsoneditor is a live Svelte app
|
|
523
|
+
* and a Tabulator keeps its observers -- each one a closure over
|
|
524
|
+
* this form, alive for the life of the page. Nested tables go
|
|
525
|
+
* first: their parent's destroy drops the rows they hang from.
|
|
526
|
+
************************************************************/
|
|
527
|
+
function destroy_widgets(gobj, $container)
|
|
528
|
+
{
|
|
529
|
+
let destroy = (what, widget) => {
|
|
530
|
+
try {
|
|
531
|
+
widget.destroy();
|
|
532
|
+
} catch(e) {
|
|
533
|
+
log_warning(`${gobj_short_name(gobj)}: cannot destroy ${what}: ${e}`);
|
|
534
|
+
}
|
|
535
|
+
};
|
|
536
|
+
$container.querySelectorAll('.yui-tabulator-table-nested').forEach(($el) => {
|
|
537
|
+
if($el.tabulator) {
|
|
538
|
+
destroy("nested table", $el.tabulator);
|
|
539
|
+
$el.tabulator = null;
|
|
540
|
+
}
|
|
541
|
+
});
|
|
542
|
+
$container.querySelectorAll('.yui-form-data-input').forEach(($el) => {
|
|
543
|
+
if($el.tom_select) {
|
|
544
|
+
destroy("select", $el.tom_select);
|
|
545
|
+
$el.tom_select = null;
|
|
546
|
+
}
|
|
547
|
+
if($el.jsoneditor) {
|
|
548
|
+
destroy("json editor", $el.jsoneditor);
|
|
549
|
+
$el.jsoneditor = null;
|
|
550
|
+
}
|
|
551
|
+
if($el.tabulator) {
|
|
552
|
+
destroy("table", $el.tabulator);
|
|
553
|
+
$el.tabulator = null;
|
|
554
|
+
}
|
|
555
|
+
});
|
|
556
|
+
}
|
|
557
|
+
|
|
502
558
|
/******************************************************************
|
|
503
559
|
* Build form with bulma and createElement2
|
|
504
560
|
******************************************************************/
|
|
@@ -1200,7 +1256,9 @@ function create_form_field(
|
|
|
1200
1256
|
['div', {class: 'field-body'}, [
|
|
1201
1257
|
['div', {class: 'field'}, [
|
|
1202
1258
|
['div', {class: '' }, [
|
|
1203
|
-
['button', {class: 'button p-1'
|
|
1259
|
+
['button', {class: 'button p-1',
|
|
1260
|
+
title: t('add'), 'data-i18n-title': 'add',
|
|
1261
|
+
'aria-label': t('add'), 'data-i18n-aria-label': 'add'}, [
|
|
1204
1262
|
['span', {class: 'icon m-0'}, '<i class="yi-plus"></i>'],
|
|
1205
1263
|
['span', {class: 'p-1 pr-2 is-hidden-mobile', i18n: 'add'}, 'add'],
|
|
1206
1264
|
], {
|
|
@@ -1356,7 +1414,8 @@ function create_form_field(
|
|
|
1356
1414
|
name: name
|
|
1357
1415
|
},
|
|
1358
1416
|
opts.map(option =>
|
|
1359
|
-
['option', {value:option, i18n:option},
|
|
1417
|
+
['option', {value:option, i18n:option},
|
|
1418
|
+
document.createTextNode(String(option))] // data, not markup
|
|
1360
1419
|
),
|
|
1361
1420
|
{
|
|
1362
1421
|
'change': function (evt) {
|
|
@@ -1450,19 +1509,18 @@ function create_form_field(
|
|
|
1450
1509
|
|
|
1451
1510
|
case 'radio':
|
|
1452
1511
|
{
|
|
1453
|
-
// TODO review, not tested
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
// }
|
|
1512
|
+
// TODO review, not tested: one radio, labelled by `options`
|
|
1513
|
+
/* Built as nodes: the name and the label are data, and the
|
|
1514
|
+
* label keeps its key so it re-translates. The <label> WRAPS
|
|
1515
|
+
* its control, which is what names it. */
|
|
1516
|
+
let label_key = String(options === undefined || options === null ? "" : options);
|
|
1517
|
+
$extend = createElement2(
|
|
1518
|
+
['label', {class: 'radio'}, [
|
|
1519
|
+
['input', {type: 'radio', name: name}],
|
|
1520
|
+
['span', {i18n: label_key}, label_key]
|
|
1521
|
+
]]
|
|
1522
|
+
);
|
|
1523
|
+
$control.appendChild($extend);
|
|
1466
1524
|
break;
|
|
1467
1525
|
}
|
|
1468
1526
|
|
|
@@ -1488,12 +1546,18 @@ function create_form_field(
|
|
|
1488
1546
|
props: {
|
|
1489
1547
|
readOnly: !!readonly,
|
|
1490
1548
|
onChange: function() {
|
|
1549
|
+
/* A field marked wrong clears its mark as soon as
|
|
1550
|
+
* it holds good json again. */
|
|
1551
|
+
if($extend.yui_json_error) {
|
|
1552
|
+
check_json_editor($extend);
|
|
1553
|
+
mark_field_validity($extend);
|
|
1554
|
+
}
|
|
1491
1555
|
gobj_send_event(gobj, "EV_RECORD_CHANGED", {}, gobj);
|
|
1492
1556
|
},
|
|
1493
|
-
/*
|
|
1494
|
-
*
|
|
1495
|
-
*
|
|
1496
|
-
*
|
|
1557
|
+
/* The list lives in json_view_helpers.js: the JSON
|
|
1558
|
+
* viewer and this editor must recognise the SAME
|
|
1559
|
+
* fields, and a copy each is how they stopped
|
|
1560
|
+
* doing so. */
|
|
1497
1561
|
timestampTag: function({field, value, path}) {
|
|
1498
1562
|
return is_time_field(field);
|
|
1499
1563
|
},
|
|
@@ -1951,7 +2015,7 @@ function create_tabulator(gobj, $extend, name, template)
|
|
|
1951
2015
|
columns.push(
|
|
1952
2016
|
{
|
|
1953
2017
|
formatter: function(cell, formatterParams) {
|
|
1954
|
-
return '
|
|
2018
|
+
return cell_icon('yi-trash has-text-danger', 'delete');
|
|
1955
2019
|
},
|
|
1956
2020
|
width:40,
|
|
1957
2021
|
hozAlign:"center",
|
|
@@ -2062,7 +2126,7 @@ function template2columns(gobj, columns, template, sub_elements)
|
|
|
2062
2126
|
validator.push("required");
|
|
2063
2127
|
}
|
|
2064
2128
|
|
|
2065
|
-
// TODO
|
|
2129
|
+
// TODO add the validators needed, like validator.push("integer");
|
|
2066
2130
|
|
|
2067
2131
|
switch(field_desc.type) {
|
|
2068
2132
|
case "object":
|
|
@@ -2075,7 +2139,7 @@ function template2columns(gobj, columns, template, sub_elements)
|
|
|
2075
2139
|
|
|
2076
2140
|
case "template":
|
|
2077
2141
|
// field_conf.tag = "fieldset";
|
|
2078
|
-
// TODO
|
|
2142
|
+
// TODO when editing, it must be field_conf.tag = "jsoneditor";
|
|
2079
2143
|
break;
|
|
2080
2144
|
|
|
2081
2145
|
case "blob":
|
|
@@ -2091,8 +2155,8 @@ function template2columns(gobj, columns, template, sub_elements)
|
|
|
2091
2155
|
// field_conf.tag = "table";
|
|
2092
2156
|
// field_conf.options = enum_list;
|
|
2093
2157
|
// column.editor = "false";
|
|
2094
|
-
// TODO
|
|
2095
|
-
// TODO -
|
|
2158
|
+
// TODO it is another table: give it buttons
|
|
2159
|
+
// TODO - to show/hide the second table
|
|
2096
2160
|
|
|
2097
2161
|
let template = field_desc.enum_list;
|
|
2098
2162
|
sub_elements.push({
|
|
@@ -2102,7 +2166,7 @@ function template2columns(gobj, columns, template, sub_elements)
|
|
|
2102
2166
|
|
|
2103
2167
|
Object.assign(column, {
|
|
2104
2168
|
formatter: function(cell, formatterParams) {
|
|
2105
|
-
return '
|
|
2169
|
+
return cell_icon('yi-plus has-text-link', 'add');
|
|
2106
2170
|
},
|
|
2107
2171
|
hozAlign:"center",
|
|
2108
2172
|
cellClick: function(evt, cell) {
|
|
@@ -2345,6 +2409,9 @@ function template2columns(gobj, columns, template, sub_elements)
|
|
|
2345
2409
|
************************************************************/
|
|
2346
2410
|
function field_validation_message($input)
|
|
2347
2411
|
{
|
|
2412
|
+
if($input.yui_json_error) {
|
|
2413
|
+
return t($input.yui_json_error);
|
|
2414
|
+
}
|
|
2348
2415
|
let v = $input.validity;
|
|
2349
2416
|
if(v && v.valueMissing) {
|
|
2350
2417
|
return t("this field is required");
|
|
@@ -2369,7 +2436,7 @@ function mark_field_validity($input)
|
|
|
2369
2436
|
* field. Reading `validity` asks the same question and fires nothing.
|
|
2370
2437
|
* A control with no `validity` (a wrapper div) is not invalid. */
|
|
2371
2438
|
let v = $input.validity;
|
|
2372
|
-
let ok = !v || v.valid;
|
|
2439
|
+
let ok = (!v || v.valid) && !$input.yui_json_error;
|
|
2373
2440
|
|
|
2374
2441
|
if(ok) {
|
|
2375
2442
|
$input.classList.remove('is-danger');
|
|
@@ -2399,6 +2466,16 @@ function validate_form(gobj, $form)
|
|
|
2399
2466
|
validated = false;
|
|
2400
2467
|
}
|
|
2401
2468
|
|
|
2469
|
+
/* checkValidity() does not see a jsoneditor: it is no form control.
|
|
2470
|
+
* A text that is not json -- or not the column's shape -- used to be
|
|
2471
|
+
* saved as {} or []. */
|
|
2472
|
+
$form.querySelectorAll('.jsoneditor.yui-form-data-input').forEach($editor => {
|
|
2473
|
+
if(!check_json_editor($editor)) {
|
|
2474
|
+
validated = false;
|
|
2475
|
+
mark_field_validity($editor);
|
|
2476
|
+
}
|
|
2477
|
+
});
|
|
2478
|
+
|
|
2402
2479
|
$form.querySelectorAll('.yui-tabulator-table').forEach($table => {
|
|
2403
2480
|
if(!$table.tabulator.validate()) {
|
|
2404
2481
|
validated = false;
|
|
@@ -2414,6 +2491,24 @@ function validate_form(gobj, $form)
|
|
|
2414
2491
|
return validated;
|
|
2415
2492
|
}
|
|
2416
2493
|
|
|
2494
|
+
/************************************************************
|
|
2495
|
+
* Does the jsoneditor `$editor` hold json its column can store?
|
|
2496
|
+
* Leaves the answer on the element (`yui_json_error`, an i18n key
|
|
2497
|
+
* or ""), where mark_field_validity() reads it.
|
|
2498
|
+
************************************************************/
|
|
2499
|
+
function check_json_editor($editor)
|
|
2500
|
+
{
|
|
2501
|
+
let jsoneditor = $editor.jsoneditor;
|
|
2502
|
+
let field_desc = $editor.field_desc;
|
|
2503
|
+
if(!jsoneditor || !field_desc || $editor.hasAttribute('readonly')) {
|
|
2504
|
+
$editor.yui_json_error = "";
|
|
2505
|
+
return true;
|
|
2506
|
+
}
|
|
2507
|
+
let r = parse_json_field(json_editor_value(jsoneditor.get()), field_desc.type);
|
|
2508
|
+
$editor.yui_json_error = r.error;
|
|
2509
|
+
return !r.error;
|
|
2510
|
+
}
|
|
2511
|
+
|
|
2417
2512
|
/************************************************************
|
|
2418
2513
|
* Function to get input value based on its type
|
|
2419
2514
|
************************************************************/
|
|
@@ -3000,6 +3095,20 @@ function treedb_value_2_form_value(gobj, field_desc, value)
|
|
|
3000
3095
|
return value;
|
|
3001
3096
|
}
|
|
3002
3097
|
|
|
3098
|
+
/************************************************************
|
|
3099
|
+
* A json field's value, parsed. validate_form() refuses a field
|
|
3100
|
+
* that does not parse, so reaching the error here is a path that
|
|
3101
|
+
* skipped it: logged, never quiet.
|
|
3102
|
+
************************************************************/
|
|
3103
|
+
function parse_json_value(gobj, field_desc, value)
|
|
3104
|
+
{
|
|
3105
|
+
let r = parse_json_field(value, field_desc.type);
|
|
3106
|
+
if(r.error) {
|
|
3107
|
+
log_error(`${gobj_short_name(gobj)}: field '${field_desc.name}' (${field_desc.type}) holds no valid json, stored as empty`);
|
|
3108
|
+
}
|
|
3109
|
+
return r.value;
|
|
3110
|
+
}
|
|
3111
|
+
|
|
3003
3112
|
/************************************************************
|
|
3004
3113
|
* Convert from frontend to backend
|
|
3005
3114
|
* operation: "create" "update"
|
|
@@ -3014,21 +3123,7 @@ function form_value_2_treedb_value(gobj, field_desc, value)
|
|
|
3014
3123
|
* interpreted-widget conversions ('exec' mode) below. */
|
|
3015
3124
|
if(gobj_read_str_attr(gobj, "render_mode") === "edit" &&
|
|
3016
3125
|
(type === "template" || type === "table" || type === "coordinates")) {
|
|
3017
|
-
|
|
3018
|
-
try {
|
|
3019
|
-
value = JSON.parse(value);
|
|
3020
|
-
} catch (e) {
|
|
3021
|
-
value = (type === "table")? [] : {};
|
|
3022
|
-
}
|
|
3023
|
-
}
|
|
3024
|
-
if(type === "table") {
|
|
3025
|
-
if(!is_array(value)) {
|
|
3026
|
-
value = [];
|
|
3027
|
-
}
|
|
3028
|
-
} else if(!is_object(value) && !is_array(value)) {
|
|
3029
|
-
value = {};
|
|
3030
|
-
}
|
|
3031
|
-
return value;
|
|
3126
|
+
return parse_json_value(gobj, field_desc, value);
|
|
3032
3127
|
}
|
|
3033
3128
|
|
|
3034
3129
|
switch(type) {
|
|
@@ -3084,19 +3179,7 @@ function form_value_2_treedb_value(gobj, field_desc, value)
|
|
|
3084
3179
|
case "svg":
|
|
3085
3180
|
break;
|
|
3086
3181
|
case "template":
|
|
3087
|
-
|
|
3088
|
-
// Come from the form
|
|
3089
|
-
try {
|
|
3090
|
-
value = JSON.parse(value);
|
|
3091
|
-
} catch (e) {
|
|
3092
|
-
value = {};
|
|
3093
|
-
}
|
|
3094
|
-
} else if(is_object(value)) {
|
|
3095
|
-
// Come from the table
|
|
3096
|
-
}
|
|
3097
|
-
if(!is_object(value)) {
|
|
3098
|
-
value = {};
|
|
3099
|
-
}
|
|
3182
|
+
value = parse_json_value(gobj, field_desc, value);
|
|
3100
3183
|
break;
|
|
3101
3184
|
case "table":
|
|
3102
3185
|
case "id":
|
|
@@ -3117,19 +3200,7 @@ function form_value_2_treedb_value(gobj, field_desc, value)
|
|
|
3117
3200
|
break;
|
|
3118
3201
|
case "array":
|
|
3119
3202
|
case "list":
|
|
3120
|
-
|
|
3121
|
-
// Come from the form
|
|
3122
|
-
try {
|
|
3123
|
-
value = JSON.parse(value);
|
|
3124
|
-
} catch (e) {
|
|
3125
|
-
value = [];
|
|
3126
|
-
}
|
|
3127
|
-
} else if(is_array(value)) {
|
|
3128
|
-
// Come from the table
|
|
3129
|
-
}
|
|
3130
|
-
if(!is_array(value)) {
|
|
3131
|
-
value = [];
|
|
3132
|
-
}
|
|
3203
|
+
value = parse_json_value(gobj, field_desc, value);
|
|
3133
3204
|
break;
|
|
3134
3205
|
case "real":
|
|
3135
3206
|
value = parseFloat(value) || 0.0;
|
|
@@ -3138,21 +3209,7 @@ function form_value_2_treedb_value(gobj, field_desc, value)
|
|
|
3138
3209
|
value = parseBoolean(value);
|
|
3139
3210
|
break;
|
|
3140
3211
|
case "blob":
|
|
3141
|
-
|
|
3142
|
-
// Come from the form
|
|
3143
|
-
try {
|
|
3144
|
-
value = JSON.parse(value);
|
|
3145
|
-
} catch (e) {
|
|
3146
|
-
value = {};
|
|
3147
|
-
}
|
|
3148
|
-
|
|
3149
|
-
} else if(is_object(value)) {
|
|
3150
|
-
// Come from the table
|
|
3151
|
-
} else if(is_array(value)) {
|
|
3152
|
-
// Come from the table
|
|
3153
|
-
} else {
|
|
3154
|
-
value = {};
|
|
3155
|
-
}
|
|
3212
|
+
value = parse_json_value(gobj, field_desc, value);
|
|
3156
3213
|
break;
|
|
3157
3214
|
case "number":
|
|
3158
3215
|
break;
|
|
@@ -3370,7 +3427,7 @@ function ac_add_table_row(gobj, event, kw, src)
|
|
|
3370
3427
|
}
|
|
3371
3428
|
})
|
|
3372
3429
|
.catch(function(error){
|
|
3373
|
-
|
|
3430
|
+
log_error(`${gobj_short_name(gobj)}: cannot add a table row: ${error}`);
|
|
3374
3431
|
});
|
|
3375
3432
|
|
|
3376
3433
|
// TODO improve, to use only once the timeout?
|
package/src/c_yui_gclass.js
CHANGED
|
@@ -633,6 +633,8 @@ function build_zone(gobj, zone)
|
|
|
633
633
|
|
|
634
634
|
let $toggle = createElement2(
|
|
635
635
|
['button', {class: 'GCLASS_ZONE_TOGGLE', type: 'button',
|
|
636
|
+
title: t(zone.key), 'data-i18n-title': zone.key,
|
|
637
|
+
'aria-label': t(zone.key), 'data-i18n-aria-label': zone.key,
|
|
636
638
|
'aria-expanded': collapsed? 'false': 'true'}, [
|
|
637
639
|
['span', {class: 'icon GCLASS_ZONE_ARROW'}, [
|
|
638
640
|
['i', {class: collapsed? 'yi-chevron-right': 'yi-chevron-down'}]
|
|
@@ -726,8 +728,10 @@ function build_attrs(attrs)
|
|
|
726
728
|
['td', {class: 'GCLASS_CELL_KEY'}, a.id],
|
|
727
729
|
['td', {class: 'GCLASS_CELL_TYPE'}, a.type],
|
|
728
730
|
['td', {class: 'GCLASS_CELL_FLAGS'}, flag_chips(a.flags)],
|
|
729
|
-
|
|
730
|
-
|
|
731
|
+
/* What a remote yuno answers is data, not markup: Text nodes,
|
|
732
|
+
* or a default starting with '<' would be parsed as HTML. */
|
|
733
|
+
['td', {class: 'GCLASS_CELL_DEFAULT'}, document.createTextNode(String(a.default_value ?? ""))],
|
|
734
|
+
['td', {class: 'GCLASS_CELL_DESC'}, document.createTextNode(String(a.description ?? ""))]
|
|
731
735
|
]];
|
|
732
736
|
});
|
|
733
737
|
|
|
@@ -649,6 +649,10 @@ function mt_destroy(gobj)
|
|
|
649
649
|
cancelAnimationFrame(priv._resize_raf);
|
|
650
650
|
priv._resize_raf = 0;
|
|
651
651
|
}
|
|
652
|
+
if(priv.find_timer) {
|
|
653
|
+
clearTimeout(priv.find_timer);
|
|
654
|
+
priv.find_timer = null;
|
|
655
|
+
}
|
|
652
656
|
|
|
653
657
|
if(priv.graph) {
|
|
654
658
|
priv.graph.destroy();
|
|
@@ -1177,7 +1181,14 @@ function build_graph(gobj)
|
|
|
1177
1181
|
});
|
|
1178
1182
|
|
|
1179
1183
|
graph.on(NodeEvent.CLICK, (evt) => {
|
|
1180
|
-
|
|
1184
|
+
/* An identity, never the G6 event: a kw is plain json, and the
|
|
1185
|
+
* event is circular -- the machine trace dumps the kw. */
|
|
1186
|
+
let client = (evt && evt.client)? evt.client : null;
|
|
1187
|
+
gobj_send_event(gobj, "EV_NODE_CLICK", {
|
|
1188
|
+
id: (evt && evt.target && evt.target.id)? String(evt.target.id) : "",
|
|
1189
|
+
client_x: (client && typeof client.x === "number")? client.x : 0,
|
|
1190
|
+
client_y: (client && typeof client.y === "number")? client.y : 0
|
|
1191
|
+
}, gobj);
|
|
1181
1192
|
});
|
|
1182
1193
|
|
|
1183
1194
|
graph.on(CanvasEvent.CLICK, (evt) => {
|
|
@@ -2691,7 +2702,7 @@ function ac_node_click(gobj, event, kw, src)
|
|
|
2691
2702
|
{
|
|
2692
2703
|
let priv = gobj.priv;
|
|
2693
2704
|
let graph = priv.graph;
|
|
2694
|
-
let node_id = kw.
|
|
2705
|
+
let node_id = kw.id;
|
|
2695
2706
|
|
|
2696
2707
|
/*
|
|
2697
2708
|
* Prefer our own cached node_data (richer) and fall back to
|
|
@@ -2734,8 +2745,8 @@ function ac_node_click(gobj, event, kw, src)
|
|
|
2734
2745
|
/*
|
|
2735
2746
|
* Show popover at click position
|
|
2736
2747
|
*/
|
|
2737
|
-
let client_x =
|
|
2738
|
-
let client_y =
|
|
2748
|
+
let client_x = kw.client_x || 0;
|
|
2749
|
+
let client_y = kw.client_y || 0;
|
|
2739
2750
|
show_popover(gobj, node_data, client_x, client_y);
|
|
2740
2751
|
|
|
2741
2752
|
return 0;
|
package/src/c_yui_json_graph.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Displays JSON data as a hierarchical graph visualization
|
|
6
6
|
* Migrated from mx_json_viewer.js (mxGraph)
|
|
7
7
|
*
|
|
8
|
-
* Copyright (c) 2025, ArtGins.
|
|
8
|
+
* Copyright (c) 2025-2026, ArtGins.
|
|
9
9
|
* All Rights Reserved.
|
|
10
10
|
***********************************************************************/
|
|
11
11
|
import {
|
|
@@ -753,7 +753,14 @@ function build_graph(gobj)
|
|
|
753
753
|
}
|
|
754
754
|
|
|
755
755
|
graph.on(NodeEvent.CLICK, (evt) => {
|
|
756
|
-
|
|
756
|
+
/* An identity, never the G6 event: a kw is plain json, and the
|
|
757
|
+
* event is circular -- the machine trace dumps the kw. */
|
|
758
|
+
let client = (evt && evt.client)? evt.client : null;
|
|
759
|
+
gobj_send_event(gobj, "EV_NODE_CLICK", {
|
|
760
|
+
id: (evt && evt.target && evt.target.id)? String(evt.target.id) : "",
|
|
761
|
+
client_x: (client && typeof client.x === "number")? client.x : 0,
|
|
762
|
+
client_y: (client && typeof client.y === "number")? client.y : 0
|
|
763
|
+
}, gobj);
|
|
757
764
|
});
|
|
758
765
|
|
|
759
766
|
/* ONE hook for the readout, the same one the treedb graph uses:
|
|
@@ -1071,12 +1078,24 @@ function cell_matches(key, value, type, needle)
|
|
|
1071
1078
|
************************************************************/
|
|
1072
1079
|
function get_json_type(value)
|
|
1073
1080
|
{
|
|
1074
|
-
if(is_string(value))
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
if(
|
|
1078
|
-
|
|
1079
|
-
|
|
1081
|
+
if(is_string(value)) {
|
|
1082
|
+
return "string";
|
|
1083
|
+
}
|
|
1084
|
+
if(is_null(value)) {
|
|
1085
|
+
return "null";
|
|
1086
|
+
}
|
|
1087
|
+
if(is_number(value)) {
|
|
1088
|
+
return "number";
|
|
1089
|
+
}
|
|
1090
|
+
if(is_boolean(value)) {
|
|
1091
|
+
return "boolean";
|
|
1092
|
+
}
|
|
1093
|
+
if(is_object(value)) {
|
|
1094
|
+
return "dict";
|
|
1095
|
+
}
|
|
1096
|
+
if(is_array(value)) {
|
|
1097
|
+
return "list";
|
|
1098
|
+
}
|
|
1080
1099
|
return "unknown";
|
|
1081
1100
|
}
|
|
1082
1101
|
|
|
@@ -1787,7 +1806,9 @@ class JsonTreeLayout extends BaseLayout {
|
|
|
1787
1806
|
}
|
|
1788
1807
|
let total = 0;
|
|
1789
1808
|
for(let i = 0; i < kids.length; i++) {
|
|
1790
|
-
if(i > 0)
|
|
1809
|
+
if(i > 0) {
|
|
1810
|
+
total += H_GAP;
|
|
1811
|
+
}
|
|
1791
1812
|
total += calc_subtree_width(kids[i]);
|
|
1792
1813
|
}
|
|
1793
1814
|
subtree_widths[node_id] = Math.max(total, node_dims[node_id].w);
|
|
@@ -1818,11 +1839,15 @@ class JsonTreeLayout extends BaseLayout {
|
|
|
1818
1839
|
positions[node_id] = {x, y};
|
|
1819
1840
|
|
|
1820
1841
|
let kids = children_map[node_id] || [];
|
|
1821
|
-
if(kids.length === 0)
|
|
1842
|
+
if(kids.length === 0) {
|
|
1843
|
+
return;
|
|
1844
|
+
}
|
|
1822
1845
|
|
|
1823
1846
|
let total_width = 0;
|
|
1824
1847
|
for(let i = 0; i < kids.length; i++) {
|
|
1825
|
-
if(i > 0)
|
|
1848
|
+
if(i > 0) {
|
|
1849
|
+
total_width += H_GAP;
|
|
1850
|
+
}
|
|
1826
1851
|
total_width += subtree_widths[kids[i]];
|
|
1827
1852
|
}
|
|
1828
1853
|
|
|
@@ -1842,7 +1867,9 @@ class JsonTreeLayout extends BaseLayout {
|
|
|
1842
1867
|
*/
|
|
1843
1868
|
let total_root_width = 0;
|
|
1844
1869
|
for(let i = 0; i < roots.length; i++) {
|
|
1845
|
-
if(i > 0)
|
|
1870
|
+
if(i > 0) {
|
|
1871
|
+
total_root_width += H_GAP;
|
|
1872
|
+
}
|
|
1846
1873
|
total_root_width += subtree_widths[roots[i].id];
|
|
1847
1874
|
}
|
|
1848
1875
|
|
|
@@ -2323,7 +2350,7 @@ function ac_node_click(gobj, event, kw, src)
|
|
|
2323
2350
|
{
|
|
2324
2351
|
let priv = gobj.priv;
|
|
2325
2352
|
let graph = priv.graph;
|
|
2326
|
-
let node_id = kw.
|
|
2353
|
+
let node_id = kw.id;
|
|
2327
2354
|
|
|
2328
2355
|
let nodedata;
|
|
2329
2356
|
try {
|