@jackens/nnn 2024.3.3 → 2024.3.5
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/nnn.d.ts +6 -1
- package/nnn.js +2 -0
- package/package.json +1 -1
- package/readme.md +12 -3
package/nnn.d.ts
CHANGED
|
@@ -107,6 +107,11 @@ export declare const s: {
|
|
|
107
107
|
(tagOrNode: string | Node, ...args1: HArgs1[]): Node;
|
|
108
108
|
};
|
|
109
109
|
|
|
110
|
+
/**
|
|
111
|
+
* A convenient shortcut for `s('svg', ['use', { 'xlink:href': '#' + id }], ...args)`.
|
|
112
|
+
*/
|
|
113
|
+
export declare const svgUse: (id: string, ...args: HArgs1[]) => SVGSVGElement;
|
|
114
|
+
|
|
110
115
|
/**
|
|
111
116
|
* A replacement for the `in` operator (not to be confused with the `for-in` loop) that works properly.
|
|
112
117
|
*/
|
|
@@ -139,7 +144,7 @@ export type JcNode = {
|
|
|
139
144
|
export type JcRoot = Partial<Record<PropertyKey, JcNode>>;
|
|
140
145
|
|
|
141
146
|
/**
|
|
142
|
-
* A simple CSS-in-JS helper.
|
|
147
|
+
* A simple JS-to-CSS (aka CSS-in-JS) helper.
|
|
143
148
|
*
|
|
144
149
|
* The `root` parameter provides a hierarchical description of CSS rules.
|
|
145
150
|
*
|
package/nnn.js
CHANGED
|
@@ -64,6 +64,7 @@ var _h = (namespaceURI) => {
|
|
|
64
64
|
};
|
|
65
65
|
var h = _h();
|
|
66
66
|
var s = _h("http://www.w3.org/2000/svg");
|
|
67
|
+
var svgUse = (id, ...args) => s("svg", ["use", { "xlink:href": "#" + id }], ...args);
|
|
67
68
|
|
|
68
69
|
// src/nnn/chartable.ts
|
|
69
70
|
var COLORS = ["#e22", "#e73", "#fc3", "#ad4", "#4d9", "#3be", "#45d", "#c3e"];
|
|
@@ -398,6 +399,7 @@ var uuid1 = ({
|
|
|
398
399
|
};
|
|
399
400
|
export {
|
|
400
401
|
uuid1,
|
|
402
|
+
svgUse,
|
|
401
403
|
s,
|
|
402
404
|
refsInfo,
|
|
403
405
|
pro,
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Jackens’ JavaScript helpers.
|
|
4
4
|
|
|
5
|
-
<sub>Version: <code class="version">2024.3.
|
|
5
|
+
<sub>Version: <code class="version">2024.3.5</code></sub>
|
|
6
6
|
|
|
7
7
|
## Examples
|
|
8
8
|
|
|
@@ -53,7 +53,7 @@ import { «something» } from './node_modules/@jackens/nnn/nnn.js'
|
|
|
53
53
|
- `h`: A lightweight [HyperScript](https://github.com/hyperhype/hyperscript)-style helper for creating and modifying `HTMLElement`s (see also `s`).
|
|
54
54
|
- `has`: A replacement for the `in` operator (not to be confused with the `for-in` loop) that works properly.
|
|
55
55
|
- `is`: A helper that checks if the given argument is of a certain type.
|
|
56
|
-
- `jc`: A simple CSS-in-JS helper.
|
|
56
|
+
- `jc`: A simple JS-to-CSS (aka CSS-in-JS) helper.
|
|
57
57
|
- `jsOnParse`: `JSON.parse` with “JavaScript turned on”.
|
|
58
58
|
- `locale`: Language translations helper.
|
|
59
59
|
- `nanolight`: A generic helper for syntax highlighting (see also `nanolightJs`).
|
|
@@ -64,6 +64,7 @@ import { «something» } from './node_modules/@jackens/nnn/nnn.js'
|
|
|
64
64
|
- `pro`: A helper that protects calls to nested properties by a `Proxy` that initializes non-existent values with an empty object.
|
|
65
65
|
- `refsInfo`: A helper that provides information about the given `refs`.
|
|
66
66
|
- `s`: A lightweight [HyperScript](https://github.com/hyperhype/hyperscript)-style helper for creating and modifying `SVGElement`s (see also `h`).
|
|
67
|
+
- `svgUse`: A convenient shortcut for `s('svg', ['use', { 'xlink:href': '#' + id }], ...args)`.
|
|
67
68
|
- `uuid1`: A helper that generates a UUID v1 identifier (with a creation timestamp).
|
|
68
69
|
|
|
69
70
|
### EscapeMap
|
|
@@ -459,7 +460,7 @@ expect(is(Number, num)).toBeTrue()
|
|
|
459
460
|
const jc: (root: JcRoot, splitter?: string) => string;
|
|
460
461
|
```
|
|
461
462
|
|
|
462
|
-
A simple CSS-in-JS helper.
|
|
463
|
+
A simple JS-to-CSS (aka CSS-in-JS) helper.
|
|
463
464
|
|
|
464
465
|
The `root` parameter provides a hierarchical description of CSS rules.
|
|
465
466
|
|
|
@@ -957,6 +958,14 @@ A lightweight [HyperScript](https://github.com/hyperhype/hyperscript)-style help
|
|
|
957
958
|
- All other arguments of type `string`/`number` are converted to `Text` nodes and appended to the element being created or modified.
|
|
958
959
|
- All other arguments of type `HArgs` are passed to `s` and the results are appended to the element being created or modified.
|
|
959
960
|
|
|
961
|
+
### svgUse
|
|
962
|
+
|
|
963
|
+
```ts
|
|
964
|
+
const svgUse: (id: string, ...args: HArgs1[]) => SVGSVGElement;
|
|
965
|
+
```
|
|
966
|
+
|
|
967
|
+
A convenient shortcut for `s('svg', ['use', { 'xlink:href': '#' + id }], ...args)`.
|
|
968
|
+
|
|
960
969
|
### uuid1
|
|
961
970
|
|
|
962
971
|
```ts
|