@thi.ng/rdom 1.1.10 → 1.1.12

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/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2024-03-01T15:22:50Z
3
+ - **Last updated**: 2024-03-07T20:40:47Z
4
4
  - **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
5
5
 
6
6
  All notable changes to this project will be documented in this file.
package/compile.d.ts CHANGED
@@ -20,6 +20,15 @@ import type { IComponent } from "./api.js";
20
20
  * target attribute. If used as element body, the reactive value will be wrapped
21
21
  * using a {@link $sub} `<span>` with the value as its reactive body.
22
22
  *
23
+ * **Important:** Use {@link $replace}, {@link $refresh} or {@link $switch} to
24
+ * wrap any reactive values/subscriptions which produce actual HTML
25
+ * elements/components/subtrees (in hiccup format). See docs for these functions
26
+ * for details & examples. Not using any of these wrappers will result in
27
+ * unexpected outcomes.
28
+ *
29
+ * Also see {@link $wrapText}, {@link $wrapHtml} or {@link $wrapEl} for DOM
30
+ * element related component wrappers.
31
+ *
23
32
  * @param tree -
24
33
  */
25
34
  export declare const $compile: (tree: any) => IComponent;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/rdom",
3
- "version": "1.1.10",
3
+ "version": "1.1.12",
4
4
  "description": "Lightweight, reactive, VDOM-less UI/DOM components with async lifecycle and @thi.ng/hiccup compatible",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -33,17 +33,18 @@
33
33
  "doc:readme": "bun ../../tools/src/module-stats.ts && bun ../../tools/src/readme.ts",
34
34
  "pub": "yarn npm publish --access public",
35
35
  "pub:wip": "yarn npm publish --access public --no-git-tag-version",
36
- "test": "bun test"
36
+ "test": "bun test",
37
+ "tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
37
38
  },
38
39
  "dependencies": {
39
- "@thi.ng/api": "^8.9.27",
40
- "@thi.ng/checks": "^3.5.1",
41
- "@thi.ng/errors": "^2.4.19",
42
- "@thi.ng/hiccup": "^5.1.18",
43
- "@thi.ng/paths": "^5.1.70",
44
- "@thi.ng/prefixes": "^2.3.11",
45
- "@thi.ng/rstream": "^8.3.10",
46
- "@thi.ng/strings": "^3.7.20"
40
+ "@thi.ng/api": "^8.9.28",
41
+ "@thi.ng/checks": "^3.5.2",
42
+ "@thi.ng/errors": "^2.4.20",
43
+ "@thi.ng/hiccup": "^5.1.19",
44
+ "@thi.ng/paths": "^5.1.71",
45
+ "@thi.ng/prefixes": "^2.3.12",
46
+ "@thi.ng/rstream": "^8.3.11",
47
+ "@thi.ng/strings": "^3.7.21"
47
48
  },
48
49
  "devDependencies": {
49
50
  "@microsoft/api-extractor": "^7.40.1",
@@ -142,5 +143,5 @@
142
143
  ],
143
144
  "year": 2020
144
145
  },
145
- "gitHead": "df9e312af741d87e6b450afcfea6a6e381662b1e\n"
146
+ "gitHead": "a421058a65ba76608d94129ac29451bfedaf201c\n"
146
147
  }
package/wrap.d.ts CHANGED
@@ -12,6 +12,25 @@ export declare const $wrapText: (tag: string, attribs?: any, body?: any) => IMou
12
12
  * Returns a component wrapper for a single DOM element whose HTML body can be
13
13
  * later updated/replaced via `.update()`, similarly to setting `.innerHTML`.
14
14
  *
15
+ * @remarks
16
+ * Setting `.innerHtml` considered dangerous — please use with caution or use
17
+ * {@link $wrapText} if the source of the HTML body given to `.update()` cannot
18
+ * be trusted!
19
+ *
20
+ * @example
21
+ * ```ts
22
+ * import { $compile, $wrapHtml } from "@thi.ng/rdom";
23
+ *
24
+ * // create pre-configured updatable element
25
+ * const title = $wrapHtml("h1", { style: { color: "red" } });
26
+ *
27
+ * // embed inside rdom tree
28
+ * $compile(["div", {}, title, "world..."]).mount(document.body);
29
+ *
30
+ * // update element body (only after element has been mounted!)
31
+ * title.update("<em>hello</em>");
32
+ * ```
33
+ *
15
34
  * @param tag - element name
16
35
  * @param attribs - element attribs
17
36
  * @param body - optional initial body
@@ -21,6 +40,17 @@ export declare const $wrapHtml: (tag: string, attribs?: any, body?: import("@thi
21
40
  * {@link IComponent} wrapper for an existing DOM element. When mounted, the
22
41
  * given element will be (re)attached to the parent node provided at that time.
23
42
  *
43
+ * @example
44
+ * ```ts
45
+ * import { $compile, $wrapEl } from "@thi.ng/rdom";
46
+ *
47
+ * const title = document.createElement("h1");
48
+ * title.innerText = "hello";
49
+ *
50
+ * // embed existing DOM element inside an rdom tree
51
+ * $compile(["div", {}, $wrapEl(title), "world..."]).mount(document.body);
52
+ * ```
53
+ *
24
54
  * @param el
25
55
  */
26
56
  export declare const $wrapEl: (el: Element) => IComponent;