@yuneta/gobj-ui 7.23.141 → 7.23.143

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
@@ -663,6 +663,11 @@ url is what gives way, cut with an ellipsis, and the whole value stays in the
663
663
  > only paginating the FETCH is not. `page_size` sets the display page for both
664
664
  > paths.
665
665
 
666
+ **A topic table opens sorted by `id`** (since `7.23.143`): the pkey, ascending
667
+ and natural (`alphanum`, so `d2` comes before `d10`) — normalized records are
668
+ read by their key. Not when the app passes its own `initialSort`, and not with
669
+ `with_remote_paging`, where a sort in the browser would reorder one page.
670
+
666
671
  `C_YUI_TREEDB_TOPICS` takes **`with_remote_paging`** (off by default) and
667
672
  forwards it to every topic table: the table pulls the page it is showing
668
673
  instead of the host pushing the whole topic down. It needs the SDK's `nodes`
@@ -1294,8 +1299,8 @@ a level or two, with a count on every cut.
1294
1299
  parent shows it or it is a shown root — the **union**, so a device that hangs
1295
1300
  from its place AND its controller is drawn once, under whichever opened
1296
1301
  first, and folding one of the two leaves it where the other shows it.
1297
- - **`expand_depth`** (default `2`) is how much opens on load: the roots and
1298
- their children. **`fold_page_size`** (default `24`) is how many children of
1302
+ - **`expand_depth`** (default `1` since `7.23.142`, `2` before) is how much
1303
+ opens on load until the reader steps: the roots alone. **`fold_page_size`** (default `24`) is how many children of
1299
1304
  one hook are shown at a time; the rest is a **`+N` chip** at the end of the
1300
1305
  page that opens the next one. Both are attrs of `C_YUI_TREEDB_GRAPH`,
1301
1306
  forwarded to the engine — and since `7.23.93` so are the seven the engine
@@ -1596,18 +1601,31 @@ them:
1596
1601
  | control | what it does |
1597
1602
  |---|---|
1598
1603
  | the chip body | **show / hide** the topic. A hidden topic leaves the MODEL, not just the drawing: no card, no pill counts it, no edge reaches it, and whatever hung from it alone has no parent any more. The name is struck through and the count is the total. |
1599
- | `★` / `☆` | the **main topic**: the trunk the tree hangs from. Filled on the main one (a mark, not a button — the main topic cannot be hidden, because hiding the trunk turns everything into roots, which is the pile); hollow on the others, where it moves the star. |
1604
+ | `★` / `☆` | the **main topic**: the trunk the tree hangs from, always a **hierarchical** topic (hooked to itself); the hollow star appears only on the other hierarchical topics, and only when there are two or more (`7.23.142`). Filled on the main one (a mark, not a button — the main topic cannot be hidden, because hiding the trunk turns everything into roots, which is the pile); hollow on the others, where it moves the star. |
1600
1605
  | `+N` | the topic's **loose records**: the ones that should hang from the main tree and do not (a device with no place). Counted here, shown only on request. |
1601
1606
  | `⌖` | **highlight** the topic — the focus, with `reveal: "all"`. |
1602
1607
 
1603
- The **main topic is deduced** when none is chosen: the topic whose hooks reach
1604
- the most OTHER topics, a self-referent hook breaking a tie (a tree of places
1605
- over a flat list of groups). On the yunovatios central that is `places` (it
1606
- reaches places, devices, users and controllers); `device_types` reaches one.
1607
- An `extended` topic (hooks, no fkeys) never wins: the engine draws no edge
1608
- from one, so its records hang nothing. A treedb where no topic reaches
1609
- another has no trunk, and every topic is a tree of its own — the behaviour
1610
- before this existed.
1608
+ **Only a HIERARCHICAL topic can be the main one** (since `7.23.142`): a topic
1609
+ hooked to ITSELF — places inside places, groups inside groups, roles inside
1610
+ roles (`fold_is_hierarchical()`). A topic that only reaches OTHER topics is a
1611
+ list with children, and the old rule (*the topic whose hooks reach the most
1612
+ others*) drew the agent's treedb from `yunos` instead of `realms`. In order:
1613
+
1614
+ 1. the reader's pick (the star), if it is hierarchical — a saved pick the rule
1615
+ refuses is ignored;
1616
+ 2. the topic the schema **marks**, `main_topic: true` on the topic, sent in the
1617
+ desc by SDK 7.19+ (`tranger2_topic_desc()`); the schema allows one, and only
1618
+ on a topic hooked to itself;
1619
+ 3. the hierarchical topic that reaches the most other topics, schema order
1620
+ breaking a tie.
1621
+
1622
+ In every treedb of the SDK and the apps there is exactly one hierarchical
1623
+ topic (`places`, `device_groups`, `systems`, `roles`, `realms`), so the mark
1624
+ only has something to decide once a schema grows a second one. A treedb with
1625
+ no topic hooked to itself has no trunk, and every topic is a tree of its own.
1626
+
1627
+ (Not the engine's card tier: a topic with hooks AND fkeys is an `entity` card
1628
+ — it was called `hierarchical` until `7.23.142` — and that only sizes a card.)
1611
1629
 
1612
1630
  What the main topic governs, in `treedb_fold_model.js`:
1613
1631
 
@@ -1889,6 +1907,27 @@ if(id) {
1889
1907
  $box.appendChild(yui_asset_element(answer, {detail: device.foto_name}));
1890
1908
  ```
1891
1909
 
1910
+ ### JSON viewer — `setup_json_pad`
1911
+
1912
+ `setup_json_pad(self)` opens a **blank JSON pad** (`C_YUI_JSON_PAD`) in a
1913
+ floating `C_YUI_WINDOW`: paste JSON from outside — a log line, a config file, an
1914
+ answer copied from a terminal — and read it with the library's own viewer
1915
+ (`C_YUI_JSON`: tree, text, graph). Wire it to an account-menu entry, next to the
1916
+ frontend view (`EV_OPEN_JSON_VIEWER` in every SPA of the ecosystem). Like the
1917
+ frontend view it returns `null` when the window is already open, so the host
1918
+ toggles with it, and it registers `C_YUI_JSON_PAD` (and the `C_YUI_JSON` it
1919
+ hosts) itself when the app did not.
1920
+
1921
+ - A **paste anywhere in the pad** replaces the document and shows it at once;
1922
+ **view** (or Ctrl+Enter) reads the text area as typed; **clear** empties it.
1923
+ - Text that is not JSON leaves the last document on screen and says so under
1924
+ the text area, with the parser's reason.
1925
+ - A `__collapsed__` sentinel in a pasted dump is answered with
1926
+ `EV_SUBTREE_ERROR`: the source truncated it, and a pad has no backend to ask.
1927
+
1928
+ Consumer i18n keys: `json viewer`, `paste json here`, `invalid json`,
1929
+ `collapsed in the source` (plus `view` and `clear`, which every app has).
1930
+
1892
1931
  ### Frontend view — `setup_frontend_view`
1893
1932
 
1894
1933
  `setup_frontend_view(self)` opens the **gobj tree of the app's own yuno** in a