@yuneta/gobj-ui 1.0.1 → 2.2.0

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.
Files changed (46) hide show
  1. package/README.md +40 -363
  2. package/dist/gobj-ui.cjs.js +11154 -5506
  3. package/dist/gobj-ui.es.js +11131 -5508
  4. package/index.js +41 -14
  5. package/package.json +11 -9
  6. package/src/c_g6_nodes_tree.js +6 -1
  7. package/src/c_yui_form.js +1 -1
  8. package/src/c_yui_gobj_tree_js.js +1 -1
  9. package/src/c_yui_json_graph.js +1 -1
  10. package/src/c_yui_main.js +3 -3
  11. package/src/c_yui_map.js +6 -1
  12. package/src/c_yui_nav.js +881 -0
  13. package/src/c_yui_pager.js +545 -0
  14. package/src/c_yui_routing.css +1 -1
  15. package/src/c_yui_routing.js +1 -1
  16. package/src/c_yui_shell.css +571 -0
  17. package/src/c_yui_shell.js +2474 -0
  18. package/src/c_yui_tabs.js +1 -1
  19. package/src/c_yui_treedb_graph.js +35 -9
  20. package/src/c_yui_treedb_topic_with_form.js +1 -1
  21. package/src/c_yui_treedb_topics.js +36 -8
  22. package/src/c_yui_uplot.js +1 -1
  23. package/src/c_yui_window.js +242 -21
  24. package/src/c_yui_window_manager.js +602 -0
  25. package/src/c_yui_wizard.js +612 -0
  26. package/src/pager_helpers.js +138 -0
  27. package/src/pager_helpers.test.js +140 -0
  28. package/src/route_resolver.js +53 -0
  29. package/src/route_resolver.test.js +82 -0
  30. package/src/shell_focus_trap.js +123 -0
  31. package/src/shell_focus_trap.test.js +299 -0
  32. package/src/shell_modals.js +445 -0
  33. package/src/shell_show_on.js +91 -0
  34. package/src/shell_show_on.test.js +86 -0
  35. package/src/shell_toolbar_helpers.js +221 -0
  36. package/src/shell_toolbar_helpers.test.js +207 -0
  37. package/src/tabulator.css +53 -0
  38. package/src/wizard_helpers.js +117 -0
  39. package/src/wizard_helpers.test.js +122 -0
  40. package/src/yui_dev.js +1257 -362
  41. package/src/yui_icons.css +5 -0
  42. package/src/yui_inputs.css +32 -0
  43. package/src/yui_inputs.js +71 -0
  44. package/vite-plugin-yuneta-html.js +2 -2
  45. package/skeleton/config.json +0 -20
  46. package/skeleton/index.html +0 -37
package/README.md CHANGED
@@ -1,382 +1,59 @@
1
1
  # gobj-ui — Yuneta UI Library
2
2
 
3
- > **This is the `v1` (frozen) branch.** Active development is on `main` (v2).
4
- > See the branch table in the `main` README.
3
+ Reusable GUI components for Yuneta GClass front-ends: a declarative shell
4
+ (`C_YUI_SHELL`/`NAV`/`PAGER`/`WIZARD`), the legacy GClass GUI stack
5
+ (`C_YUI_MAIN`/`WINDOW`/`TABS`/`ROUTING`), TreeDB editors, charts and maps.
5
6
 
6
- Reusable GUI components for building Yuneta-based web applications. Every
7
- component is a GClass (from [`@yuneta/gobj-js`](https://www.npmjs.com/package/@yuneta/gobj-js))
8
- that plugs into the GObject tree and communicates via events.
7
+ Published as `@yuneta/gobj-ui`. Built on top of [`@yuneta/gobj-js`](https://github.com/artgins/gobj-js.js).
9
8
 
10
- ## What this package ships
9
+ ## Two maintained lines
11
10
 
12
- `gobj-ui` is the **Yuneta UI library**. This `v1` line is the **frozen legacy
13
- GClass GUI stack only** `C_YUI_MAIN`, `C_YUI_WINDOW`, `C_YUI_TABS`,
14
- `C_YUI_FORM`, `C_YUI_ROUTING`, TreeDB editors, charts and maps. It is consumed
15
- by **estadodelaire** and **hidraulia**, which resolve `@yuneta/gobj-ui` to this
16
- checkout through an npm `file:` dependency.
11
+ This repository carries **two parallel lines** with different layouts and
12
+ consumers. They are independent snapshots (no shared git ancestry):
17
13
 
18
- The **declarative shell** (`C_YUI_SHELL`, `C_YUI_NAV`, `C_YUI_PAGER`,
19
- `C_YUI_WIZARD`) is **not** on this line — it lives on the **v2 / `main`** line,
20
- consumed by **wattyzer**.
14
+ | Line | Branch | Tag | Layout | Consumed by | How | Status |
15
+ |------|--------|-----|--------|-------------|-----|--------|
16
+ | **v2** | `main` | `2.0.0`+ | `src/` subdir | **wattyzer** | local `file:` dep on the yunetas submodule | active development |
17
+ | **v1** | `v1` | `1.0.0` | `src/` subdir | **estadodelaire**, **hidraulia** | published npm `@yuneta/gobj-ui@^1.0.0` | frozen, maintenance-only |
21
18
 
22
- > **Where development happens.** This repo (`github.com/artgins/gobj-ui.js`) is
23
- > the single source of truth, embedded as a git submodule in both yunetas
24
- > (`kernel/js/gobj-ui`, tracking `v1`) and wattyzer (`gui/src/gobj-ui`, tracking
25
- > `main`/v2). All new feature work lands on `main`/v2; `v1` is maintenance-only.
19
+ - **v2 / `main`** is the active development line: the declarative shell on top
20
+ of the legacy stack. It is embedded as a git submodule in **yunetas** at
21
+ `kernel/js/gobj-ui`, and **wattyzer** consumes that checkout as a `file:`
22
+ dependency (`@yuneta/gobj-ui` `../../../yunetas/kernel/js/gobj-ui`),
23
+ importing by package specifier (`@yuneta/gobj-ui/src/*.js`, exports map
24
+ `"./src/*"`; the `index.js` barrel and the vite plugin stay at the package root).
25
+ - **v1 / `v1`** is the frozen legacy-only stack (the declarative shell is not on
26
+ this line). It is **published to npm**; estadodelaire and hidraulia depend on
27
+ `@yuneta/gobj-ui@^1.0.0` from the registry. Land only maintenance fixes here,
28
+ then `npm publish` a new `1.x`.
26
29
 
27
- ## Components
30
+ All new feature work lands on `main`/v2.
28
31
 
29
- - **App shell** (`C_YUI_MAIN`) — layered layout with toolbar,
30
- modals, and notifications.
31
- - **Window manager** (`C_YUI_WINDOW`) — draggable/resizable floating windows.
32
- - **Tabs** (`C_YUI_TABS`) — tab container for sub-components.
33
- - **Form builder** (`C_YUI_FORM`) — dynamic forms backed by Tabulator and TomSelect.
34
- - **Routing** (`C_YUI_ROUTING`) — hash-based menu/content
35
- routing. Used by `C_YUI_MAIN`-based apps.
36
- - **Map** (`C_YUI_MAP`) — MapLibre GL map wrapper.
37
- - **Charts** (`C_YUI_UPLOT`) — uPlot chart wrapper.
38
- - **JSON viewer** (`C_YUI_JSON_GRAPH`) — JSON visualization with AntV/G6.
39
- - **TreeDB UI** — topic list, table+form editor, graph manager, and G6-based node graph editor for interacting with Yuneta TreeDB backends.
40
-
41
- Extracted from `gui_treedb` to be shared across projects (EstadoDelAire, TreeDB GUI, etc.).
42
-
43
- ## Install
44
-
45
- This project uses [`vite`](https://vite.dev/) as build tool.
46
-
47
- Install the latest `node`:
48
-
49
- nvm install --lts
50
-
51
- When writing this readme the LTS version was:
52
-
53
- node --version
54
- v22.17.0
55
-
56
- npm install -g vite
57
-
58
- Install dependencies:
59
-
60
- npm install
61
-
62
- To build:
63
-
64
- vite build
65
-
66
- To publish a new version of @yuneta/gobj-ui to [npmjs.com](https://www.npmjs.com/package/@yuneta/gobj-ui):
67
-
68
- # 1. Configure your npm token (only once)
69
- echo "//registry.npmjs.org/:_authToken=<your-token>" > ~/.npmrc
70
-
71
- # 2. Update the version in package.json
72
- npm version patch # or minor / major
73
-
74
- # 3. Publish (build runs automatically via prepublishOnly)
75
- npm publish --access public
76
-
77
- To create an npm token, go to [npmjs.com](https://www.npmjs.com) → Account → Access Tokens.
78
-
79
- ## Update
80
-
81
- ONLY one time: to update all js packages, install the module:
82
-
83
- npm install -g npm-check-updates
84
-
85
- To download new releases:
86
-
87
- ncu -u
88
-
89
- And to install the new versions:
90
-
91
- npm install
92
-
93
- ---
94
-
95
- ## Quick Start
96
-
97
- ### 1. Add dependency
98
-
99
- In your project's `package.json`:
100
-
101
- ```json
102
- {
103
- "dependencies": {
104
- "@yuneta/gobj-ui": "file:../../../yunetas/kernel/js/gobj-ui",
105
- "@yuneta/gobj-js": "file:../../../yunetas/kernel/js/gobj-js"
106
- }
107
- }
108
- ```
109
-
110
- Adjust the relative path to match your directory layout.
111
-
112
- ### 2. Register GClasses in `main.js`
113
-
114
- ```js
115
- import {
116
- register_c_yui_main,
117
- register_c_yui_window,
118
- register_c_yui_tabs,
119
- register_c_yui_form,
120
- register_c_yui_routing,
121
- register_c_yui_map,
122
- register_c_yui_uplot,
123
- register_c_yui_treedb_topics,
124
- register_c_yui_treedb_graph,
125
- inject_svg_icons,
126
- } from "@yuneta/gobj-ui";
127
-
128
- // Register in main():
129
- register_c_yui_main();
130
- register_c_yui_window();
131
- register_c_yui_tabs();
132
- // ... etc.
133
- ```
134
-
135
- ### 3. Import CSS
136
-
137
- ```js
138
- import "@yuneta/gobj-ui/src/c_yui_main.css";
139
- import "@yuneta/gobj-ui/src/c_yui_map.css";
140
- import "@yuneta/gobj-ui/src/c_yui_routing.css";
141
- import "@yuneta/gobj-ui/src/ytable.css";
142
- import "@yuneta/gobj-ui/src/yui_toolbar.css";
143
- import "@yuneta/gobj-ui/src/lib_graph.css";
144
- import "@yuneta/gobj-ui/src/yui_icons.css";
145
- ```
146
-
147
- ### 4. Configure `C_YUI_MAIN` with your app branding
148
-
149
- `c_yui_main.js` does **not** import logos or flags directly. Your app provides
150
- them as GClass attributes:
151
-
152
- ```js
153
- // In your c_yuneta_gui.js:
154
- import {logo_wide_svg} from "./logos_svg.js"; // your app logo
155
- import {flags_of_world} from "./locales/flags.js"; // your app flags
156
-
157
- __yuno__.__yui_main__ = gobj_create_service(
158
- "__yui_main__",
159
- "C_YUI_MAIN",
160
- {
161
- logo_wide_svg: logo_wide_svg,
162
- flags_of_world: flags_of_world,
163
- },
164
- gobj
165
- );
166
- ```
167
-
168
- ### 5. Vite configuration
169
-
170
- ```js
171
- import { defineConfig } from "vite";
172
- import { yunetaHtmlPlugin } from "@yuneta/gobj-ui/vite-plugin-yuneta-html.js";
173
-
174
- export default defineConfig({
175
- resolve: {
176
- preserveSymlinks: true,
177
- },
178
- plugins: [
179
- yunetaHtmlPlugin({ defaultTitle: "My App" })
180
- ]
181
- });
182
- ```
183
-
184
- > **Note**: `preserveSymlinks: true` is required so that Vite resolves
185
- > `import "@yuneta/gobj-js"` from within gobj-ui's source files using the host
186
- > app's `node_modules/`.
187
-
188
- ## Project Structure
189
-
190
- ```
191
- gobj-ui/
192
- ├── index.js # Barrel re-exports
193
- ├── package.json # Peer dependencies
194
- ├── vite-plugin-yuneta-html.js # Shared Vite plugin
195
- ├── skeleton/ # Template files for new projects
196
- │ ├── index.html # HTML template with placeholders
197
- │ └── config.json # Documented config schema
198
- └── src/
199
- ├── Components ─────────────────────────────────────────────
200
- │ c_yui_main.js Main app shell (layers, toolbar, modals)
201
- │ c_yui_window.js Draggable/resizable floating windows
202
- │ c_yui_tabs.js Tab container for sub-components
203
- │ c_yui_form.js Form builder (Tabulator + TomSelect)
204
- │ c_yui_routing.js Hash-based menu/content routing
205
- │ c_yui_map.js MapLibre GL map wrapper
206
- │ c_yui_uplot.js uPlot chart wrapper
207
- │ c_yui_json_graph.js JSON visualization with AntV/G6
208
-
209
- ├── TreeDB Components ──────────────────────────────────────
210
- │ c_yui_treedb_topics.js Topic list management
211
- │ c_yui_treedb_topic_with_form.js Table + form editor
212
- │ c_yui_treedb_graph.js Graph manager / backend bridge
213
- │ c_g6_nodes_tree.js G6-based node graph editor
214
-
215
- ├── Utilities ──────────────────────────────────────────────
216
- │ lib_graph.js DOM utilities (classes, enable/disable)
217
- │ lib_icons.js SVG icon injection
218
- │ lib_maplibre.js Custom MapLibre controls
219
- │ themes.js Light/dark theme management
220
- │ ytable.js Simple HTML table with selection
221
- │ yui_toolbar.js Horizontal scrollable toolbar
222
- │ yui_dev.js Developer tools (JSON editor, traffic)
223
-
224
- └── CSS ────────────────────────────────────────────────────
225
- c_yui_main.css Main layout and layers
226
- c_yui_map.css Map styles
227
- c_yui_routing.css Router layout
228
- lib_graph.css Graph utility styles
229
- ytable.css Table styles
230
- yui_toolbar.css Toolbar styles
231
- yui_icons.css Icon font styles
232
- ```
233
-
234
- ## Exports
235
-
236
- ### Components
237
-
238
- | Export | Source | Description |
239
- |--------|--------|-------------|
240
- | `register_c_yui_main` | `c_yui_main.js` | Main app shell with layers and toolbar |
241
- | `display_volatil_modal` | `c_yui_main.js` | Show a temporary modal |
242
- | `display_info_message` | `c_yui_main.js` | Show info notification |
243
- | `display_warning_message` | `c_yui_main.js` | Show warning notification |
244
- | `display_error_message` | `c_yui_main.js` | Show error notification |
245
- | `get_yesnocancel` | `c_yui_main.js` | Yes/No/Cancel dialog |
246
- | `get_yesno` | `c_yui_main.js` | Yes/No dialog |
247
- | `get_ok` | `c_yui_main.js` | OK dialog |
248
- | `register_c_yui_window` | `c_yui_window.js` | Floating window container |
249
- | `register_c_yui_tabs` | `c_yui_tabs.js` | Tab container |
250
- | `register_c_yui_form` | `c_yui_form.js` | Form builder |
251
- | `register_c_yui_routing` | `c_yui_routing.js` | Hash-based routing |
252
- | `register_c_yui_map` | `c_yui_map.js` | Map component |
253
- | `register_c_yui_uplot` | `c_yui_uplot.js` | Chart component |
254
- | `register_c_yui_json_graph` | `c_yui_json_graph.js` | JSON graph viewer |
255
-
256
- ### TreeDB Components
257
-
258
- | Export | Source | Description |
259
- |--------|--------|-------------|
260
- | `register_c_yui_treedb_topics` | `c_yui_treedb_topics.js` | Topic list UI |
261
- | `register_c_yui_treedb_topic_with_form` | `c_yui_treedb_topic_with_form.js` | Table + form editor |
262
- | `register_c_yui_treedb_graph` | `c_yui_treedb_graph.js` | Graph backend bridge |
263
- | `register_c_g6_nodes_tree` | `c_g6_nodes_tree.js` | G6 node graph editor |
264
-
265
- ### Utilities
266
-
267
- | Export | Source | Description |
268
- |--------|--------|-------------|
269
- | `addClasses`, `removeClasses`, `toggleClasses` | `lib_graph.js` | CSS class manipulation |
270
- | `removeChildElements` | `lib_graph.js` | Remove all children from element |
271
- | `disableElements`, `enableElements` | `lib_graph.js` | Enable/disable DOM elements |
272
- | `set_submit_state`, `set_cancel_state`, `set_active_state` | `lib_graph.js` | Visual state helpers |
273
- | `getStrokeColor` | `lib_graph.js` | Generate stroke from fill color |
274
- | `inject_svg_icons` | `lib_icons.js` | Inject SVG icon symbols into DOM |
275
- | `EditControl`, `MarkerControl` | `lib_maplibre.js` | Custom MapLibre GL controls |
276
- | `themes` | `themes.js` | Theme initialization and switching |
277
- | `YTable`, `createYTable` | `ytable.js` | HTML table with selection |
278
- | `yui_toolbar` | `yui_toolbar.js` | Scrollable toolbar builder |
279
- | `info_traffic`, `setup_dev` | `yui_dev.js` | Developer panel and traffic monitor |
280
-
281
- ## Icon set (`yui_icons.css`)
282
-
283
- The shipped icon set is **~40 CSS-mask glyphs** with class names
284
- `yi-<name>`. Anything outside that list renders as a **solid black
285
- square** (the default CSS mask with no image). Before using a new
286
- icon name, grep the file:
32
+ ## Usage
287
33
 
288
34
  ```bash
289
- grep '^\.yi-.*::before' kernel/js/gobj-ui/src/yui_icons.css
290
- ```
291
-
292
- If you need an icon that isn't there, add it to `yui_icons.css` first
293
- (SVG → CSS mask), then reference `yi-<name>` from your component. See
294
- memory `yui_icons_set`.
295
-
296
- ## Skeleton — Starting a New Project
297
-
298
- Copy the template files from `skeleton/` to bootstrap a new GUI:
299
-
300
- ```bash
301
- cp gobj-ui/skeleton/index.html my-gui/index.html
302
- cp gobj-ui/skeleton/config.json my-gui/config.json
303
- ```
304
-
305
- ### `index.html`
306
-
307
- A clean, invariant HTML file with three placeholders replaced at build time:
308
-
309
- | Placeholder | Replaced with | Source |
310
- |-------------|---------------|--------|
311
- | `<!-- CSP_PLACEHOLDER -->` | Full `<meta http-equiv="Content-Security-Policy">` tag | `config.json → csp_connect_src` |
312
- | `<title></title>` | `<title>My App</title>` | `config.json → title` |
313
- | `<!-- METADATA_PLACEHOLDER -->` | `<meta name="..." content="...">` tags | `config.json → metadata` |
35
+ # v2 (active): clone yunetas with submodules; wattyzer picks it up via file:
36
+ git clone --recurse-submodules <yunetas>
37
+ git submodule update --init kernel/js/gobj-ui # yunetas tracks main/v2
314
38
 
315
- **You should not edit `index.html` directly.** All variable parts go in `config.json`.
316
-
317
- ### `config.json`
318
-
319
- ```json
320
- {
321
- "title": "My Yuneta GUI",
322
-
323
- "metadata": {
324
- "application-name": "My Yuneta GUI",
325
- "description": "Yuneta-based GUI application",
326
- "keywords": "yuneta gui"
327
- },
328
-
329
- "csp_connect_src": [
330
- "wss://localhost:1800",
331
- "https://localhost:1801",
332
- "https://auth.artgins.com"
333
- ]
334
- }
39
+ # v1 (frozen): consumers just install the published package
40
+ npm install @yuneta/gobj-ui@^1.0.0
335
41
  ```
336
42
 
337
- **`csp_connect_src`** must list every origin from `backend_config.js`:
338
- - Each `backend_urls` value (`wss://...`)
339
- - Each BFF endpoint (`https://...:port`)
340
- - Each Keycloak `auth-server-url` (`https://...`)
341
-
342
- Entries starting with `_comment` are ignored (used for inline documentation).
43
+ Edit v2 from the yunetas `kernel/js/gobj-ui` checkout, commit on `main` in this
44
+ repo, then bump that submodule pointer in yunetas. For v1, work from a `v1`
45
+ checkout and publish.
343
46
 
344
- ## Vite Plugin — `yunetaHtmlPlugin`
47
+ ## Build & test
345
48
 
346
- Shared plugin that replaces the placeholders in `index.html` at build time.
347
-
348
- ```js
349
- import { yunetaHtmlPlugin } from "@yuneta/gobj-ui/vite-plugin-yuneta-html.js";
350
-
351
- // Options:
352
- yunetaHtmlPlugin({
353
- defaultTitle: "My App", // Fallback if config.json is missing
354
- configPath: "./config.json" // Custom path (default: ./config.json)
355
- })
49
+ ```bash
50
+ npm install
51
+ npm run build # vite -> dist/ (ES/CJS/UMD/IIFE, min + non-min)
52
+ npm test # vitest (v2/main only; v1 has no test target)
356
53
  ```
357
54
 
358
- The plugin generates a strict Content-Security-Policy with:
359
- - `default-src 'self'`
360
- - `script-src 'self'`
361
- - `style-src 'self' 'unsafe-inline'` (required by Bulma)
362
- - `connect-src 'self' <origins from csp_connect_src>`
363
- - `worker-src 'self' blob:`
364
- - `child-src 'self' blob:`
365
- - `img-src 'self' data: blob:`
366
- - `font-src 'self' data:`
367
-
368
- ## Peer Dependencies
369
-
370
- gobj-ui does **not** bundle these — your project must include them:
55
+ `dist/` is gitignored. v1 consumers get `dist/` from the **published** npm
56
+ tarball; v2 (wattyzer) imports source files by specifier. Rebuild `dist/` to
57
+ validate and before publishing a v1 release.
371
58
 
372
- | Package | Used by |
373
- |---------|---------|
374
- | `@yuneta/gobj-js` | All components (GClass framework) |
375
- | `@antv/g6` | `c_g6_nodes_tree`, `c_yui_json_graph` |
376
- | `bulma` | All components (CSS framework) |
377
- | `i18next` | `c_yui_main`, `c_yui_form` (i18n) |
378
- | `maplibre-gl` | `c_yui_map` |
379
- | `tabulator-tables` | `c_yui_form`, `c_yui_treedb_topic_with_form` |
380
- | `tom-select` | `c_yui_form`, `c_yui_treedb_topic_with_form` |
381
- | `uplot` | `c_yui_uplot` |
382
- | `vanilla-jsoneditor` | `c_yui_treedb_topic_with_form`, `yui_dev` |
59
+ Copyright (c) 2024-2026, ArtGins. All Rights Reserved.