@yuneta/gobj-ui 7.26.5 → 7.26.6
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 +67 -0
- package/dist/gobj-ui.cjs.js +723 -187
- package/dist/gobj-ui.es.js +714 -188
- package/index.js +13 -1
- package/package.json +1 -1
- package/src/c_yui_form.js +147 -8
- package/src/c_yui_shell.js +28 -0
- package/src/c_yui_treedb_topic_with_form.js +78 -2
- package/src/c_yui_treedb_topics.js +77 -7
- package/src/lib_icons.js +395 -0
- package/src/lib_icons.test.js +214 -0
- package/src/yui_icons.css +20 -0
package/README.md
CHANGED
|
@@ -2716,6 +2716,73 @@ The user needs the `read` permission of that service. The service is not the
|
|
|
2716
2716
|
one the connection was opened for, so a user who is not root must also hold a
|
|
2717
2717
|
role in it, or the ievent gate refuses to route the command there.
|
|
2718
2718
|
|
|
2719
|
+
### Icons a user adds — `__icons__` and `yui_icons_*`
|
|
2720
|
+
|
|
2721
|
+
The icon set of the library (`yui_icons.css`) is fixed: a CSS mask per glyph,
|
|
2722
|
+
shipped with the package. A user adds icons of their own as DATA. Every treedb
|
|
2723
|
+
has the system topic **`__icons__`** (SDK 7.26.7+): one node per icon, its `id`
|
|
2724
|
+
the name and `svg` the drawing. A column flagged `icon` then names it as
|
|
2725
|
+
**`yi-u-<id>`**:
|
|
2726
|
+
|
|
2727
|
+
```c
|
|
2728
|
+
/* In the schema of the topic that shows an icon */
|
|
2729
|
+
'icon': {
|
|
2730
|
+
'header': 'Icon',
|
|
2731
|
+
'type': 'string',
|
|
2732
|
+
'flag': ['icon', 'writable', 'persistent']
|
|
2733
|
+
}
|
|
2734
|
+
```
|
|
2735
|
+
|
|
2736
|
+
```json
|
|
2737
|
+
{"id": "transformer", "svg": "<svg viewBox='0 0 24 24'><path d='M4 4h16v16H4z'/></svg>"}
|
|
2738
|
+
```
|
|
2739
|
+
|
|
2740
|
+
A row of that topic with `"icon": "yi-u-transformer"` shows that drawing.
|
|
2741
|
+
|
|
2742
|
+
- **`yi-u-` is the user's namespace.** No icon of the library uses it, so a
|
|
2743
|
+
user icon can never replace one -- not today, and not when the library adds
|
|
2744
|
+
an icon of the same name. The name is `[a-z0-9]` words joined by `-`.
|
|
2745
|
+
- **The drawing is a MASK**, like the library's: painted with `currentColor`,
|
|
2746
|
+
one colour, the shapes' alpha only. A multicolour svg comes out as a
|
|
2747
|
+
silhouette.
|
|
2748
|
+
- **The svg is rebuilt, never inserted.** `yui_svg_sanitize()` parses it and
|
|
2749
|
+
writes a new one from the shapes alone (`path`, `circle`, `rect`, `ellipse`,
|
|
2750
|
+
`line`, `polyline`, `polygon`, `g`) and their geometric and stroke
|
|
2751
|
+
attributes. Script, `foreignObject`, `image`, `use`, styles, handlers and any
|
|
2752
|
+
`url(...)` value are left out. It is done where the svg is DRAWN, because any
|
|
2753
|
+
writer with the right to write a node can write one. Up to 32 KB.
|
|
2754
|
+
|
|
2755
|
+
**Who loads them.** `C_YUI_TREEDB_TOPICS` does it for you: it shows
|
|
2756
|
+
`__icons__` as a tab even when `system` is false (the only `__` topic it
|
|
2757
|
+
shows), reads it whole (never by pages), and hands every load and write to the
|
|
2758
|
+
registry. An app that does not mount that view feeds the registry itself, from
|
|
2759
|
+
its own `nodes` answer and `EV_TREEDB_NODE_*` subscription:
|
|
2760
|
+
|
|
2761
|
+
```js
|
|
2762
|
+
import {yui_icons_set_user, yui_icons_put_user, yui_icons_remove_user}
|
|
2763
|
+
from "@yuneta/gobj-ui/src/lib_icons.js";
|
|
2764
|
+
import {yui_shell_icons_changed} from "@yuneta/gobj-ui/src/c_yui_shell.js";
|
|
2765
|
+
|
|
2766
|
+
yui_icons_set_user(nodes); // the whole of __icons__
|
|
2767
|
+
yui_shell_icons_changed(shell); // EV_ICONS_CHANGED: views redraw
|
|
2768
|
+
```
|
|
2769
|
+
|
|
2770
|
+
**Redraw.** A class name picks its icon up by itself once the rule exists. The
|
|
2771
|
+
icon cell of a table does not: it decides when it is drawn whether a name is an
|
|
2772
|
+
icon at all (an unknown name is shown in grey). So the shell publishes
|
|
2773
|
+
**`EV_ICONS_CHANGED`**, and `C_YUI_TREEDB_TOPIC_WITH_FORM` redraws its `icon`
|
|
2774
|
+
cells on it.
|
|
2775
|
+
|
|
2776
|
+
**Editing.** In the form, an `icon` column is a picker that draws every icon
|
|
2777
|
+
beside its name: the library's, then the user's (`yui_icons_list()`). The
|
|
2778
|
+
`svg` of `__icons__` is a text area with the icon it makes below it, redrawn
|
|
2779
|
+
as it is typed, naming what the sanitizer left out. In the table, the `svg`
|
|
2780
|
+
cell shows the icon, not its source, and is never edited in place.
|
|
2781
|
+
|
|
2782
|
+
**i18n keys** the app's locales must carry: `__icons__` (the tab), `left
|
|
2783
|
+
out`, and the five causes of `svg_error_text()` -- `empty svg`, `svg too big`,
|
|
2784
|
+
`not an svg document`, `svg without size`, `svg without shapes`.
|
|
2785
|
+
|
|
2719
2786
|
### JSON viewer — `setup_json_pad`
|
|
2720
2787
|
|
|
2721
2788
|
`setup_json_pad(self)` opens a **blank JSON pad** (`C_YUI_JSON_PAD`) in a
|