@dooboostore/dom-render 1.0.114 → 1.0.115
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 +35 -28
- package/dist/esm-bundle/dooboostore-dom-render.esm.js +406 -255
- package/dist/esm-bundle/dooboostore-dom-render.esm.js.map +4 -4
- package/dist/umd-bundle/dooboostore-dom-render.umd.js +406 -255
- package/dist/umd-bundle/dooboostore-dom-render.umd.js.map +4 -4
- package/package.json +13 -11
package/README.md
CHANGED
|
@@ -63,21 +63,19 @@ state = result.rootObject;
|
|
|
63
63
|
|
|
64
64
|
## Public API (Root Export)
|
|
65
65
|
|
|
66
|
-
`@dooboostore/dom-render`
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
- `lifecycle`
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
This enables single-entry usage without relying on package subpath exports.
|
|
66
|
+
`@dooboostore/dom-render`'s root entry (`src/index.ts`) re-exports as flat named exports — there is no `components`/`configs`/etc. namespace object to import:
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
import { DomRender, DomRenderProxy, ComponentBase, attribute, Appender, DomRenderConfig } from '@dooboostore/dom-render';
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
This covers: a selected set of built-in components/helpers (`If`, `This`, `AppenderComponent`, `PromiseSwitch`, `Choose`, `CheckBox`, `Radio`, `Select`, `Timer`, `Details`, `Input`, `Route`, `RouterOutlet`, `A`, `ComponentSet`, `ComponentRouterBase`, `ComponentBase`, `attribute`, and the combined `drComponent` map used to register them all at once), plus everything from `configs`, `decorators`, `events`, `lifecycle`, `messenger`, `operators` (including the `Appender` collection class), `rawsets`, `types`, `DomRender` and `DomRenderProxy`.
|
|
73
|
+
|
|
74
|
+
The `query` and `event` decorators are **not** re-exported from the root; import them via the `./*` subpath export:
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
import { query, event } from '@dooboostore/dom-render/components/ComponentBase';
|
|
78
|
+
```
|
|
81
79
|
|
|
82
80
|
---
|
|
83
81
|
|
|
@@ -129,11 +127,11 @@ Conditional rendering based on expression truthiness.
|
|
|
129
127
|
|
|
130
128
|
### `dr-for`
|
|
131
129
|
|
|
132
|
-
Classic loop-
|
|
130
|
+
Classic `for(...)` loop. `dr-option-it` is evaluated per iteration and its value is substituted for `#it#` in the cloned markup.
|
|
133
131
|
|
|
134
132
|
```html
|
|
135
|
-
<li dr-for="let i=0; i<@this@.items.length; i++" dr-option-it="
|
|
136
|
-
${
|
|
133
|
+
<li dr-for="let i=0; i<@this@.items.length; i++" dr-option-it="i">
|
|
134
|
+
${@this@.items[#it#].name}$
|
|
137
135
|
</li>
|
|
138
136
|
```
|
|
139
137
|
|
|
@@ -183,19 +181,24 @@ Strip wrapper element while preserving children.
|
|
|
183
181
|
|
|
184
182
|
- `dr-inner-html`: bind `innerHTML`
|
|
185
183
|
- `dr-inner-text`: bind `innerText`
|
|
186
|
-
- `dr-attr`: bind attribute object
|
|
187
184
|
- `dr-this`, `dr-this-property`: bind target context object
|
|
188
|
-
- `dr-before`, `dr-after`: pre/post scripts
|
|
185
|
+
- `dr-option-before`, `dr-option-after`: pre/post scripts attached alongside another directive on the same element
|
|
186
|
+
|
|
187
|
+
- `dr-value`, `dr-src`, `dr-checked`, `dr-selected`, `dr-readonly`, `dr-disabled`, `dr-hidden`, `dr-required`, `dr-open`, `dr-class`, `dr-style`: bind the corresponding property/attribute from an expression
|
|
188
|
+
- `dr-attr="{key: expr, ...}"`: shorthand that expands each pair into `key="${expr}$"`
|
|
189
|
+
|
|
190
|
+
Plain attributes can also be bound by putting a template expression inside the attribute value itself:
|
|
189
191
|
|
|
190
192
|
```html
|
|
191
193
|
<div dr-inner-text="@this@.plainText"></div>
|
|
192
194
|
<div dr-inner-html="@this@.trustedHtml"></div>
|
|
193
|
-
<img
|
|
195
|
+
<img src="${@this@.imageUrl}$" alt="${@this@.alt}$" />
|
|
196
|
+
<img dr-attr="{src: @this@.imageUrl, alt: @this@.alt}" />
|
|
194
197
|
```
|
|
195
198
|
|
|
196
199
|
### Form utility (`dr-form`)
|
|
197
200
|
|
|
198
|
-
`dr-form` wires
|
|
201
|
+
`dr-form` wires every `[name]` child to the target object (optionally with `Validator`/`ValidatorArray` from `@dooboostore/core`). Per-field options: `dr-form:name`, `dr-form:event` (default `change`), `dr-form:validator`.
|
|
199
202
|
|
|
200
203
|
```html
|
|
201
204
|
<form dr-form="@this@.formState">
|
|
@@ -317,6 +320,7 @@ const userCard = DomRender.createComponent({
|
|
|
317
320
|
template: `<div>${@this@.name}$</div>`
|
|
318
321
|
});
|
|
319
322
|
|
|
323
|
+
// DomRender.run({...}) is a shorthand that returns the proxied rootObject directly.
|
|
320
324
|
const app = new DomRender({
|
|
321
325
|
rootObject: { users: [] },
|
|
322
326
|
target: document.querySelector('#app')!,
|
|
@@ -331,13 +335,16 @@ const app = new DomRender({
|
|
|
331
335
|
Implement interfaces to receive lifecycle callbacks:
|
|
332
336
|
|
|
333
337
|
- `onProxyDomRender(config)`
|
|
334
|
-
- `onCreateRender(...args)`
|
|
338
|
+
- `onCreateRender(...args)` / `onCreateRendered(...args)`
|
|
335
339
|
- `onCreateRenderData(data)`
|
|
340
|
+
- `onCreatedThisChild(child, childData)`
|
|
336
341
|
- `onInitRender(param, rawSet)`
|
|
337
342
|
- `onRawSetRendered(rawSet, otherData)`
|
|
338
|
-
- `onChildRawSetRendered()`
|
|
343
|
+
- `onChildRawSetRendered()` (interface in `lifecycle/OnChildRawSetRendered`, not re-exported from `lifecycle/index`)
|
|
344
|
+
- `onChildRenderedByProperty(key, value)`
|
|
339
345
|
- `onDestroyRender(params)`
|
|
340
346
|
- `onChangeAttrRender(name, value, other)`
|
|
347
|
+
- `onBeforeReturnGet(name, value, fullPath)` / `onBeforeReturnSet(name, value, fullPath)`
|
|
341
348
|
|
|
342
349
|
```typescript
|
|
343
350
|
class ViewModel {
|
|
@@ -388,9 +395,9 @@ Use this when direct parent-child access is not suitable.
|
|
|
388
395
|
|
|
389
396
|
This section is added for teams using both `dom-render` and `simple-web-component`.
|
|
390
397
|
|
|
391
|
-
### `@addEventListener` (extended)
|
|
398
|
+
### `@event` / `@addEventListener` (extended)
|
|
392
399
|
|
|
393
|
-
`@addEventListener` is a decorator from `@dooboostore/simple-web-component
|
|
400
|
+
`@event` (alias of `@addEventListener`) is a decorator from `@dooboostore/simple-web-component`; it is unrelated to dom-render's own `@event({ query, name })`.
|
|
394
401
|
|
|
395
402
|
In `dom-render`, equivalent patterns are:
|
|
396
403
|
|
|
@@ -425,9 +432,9 @@ updateRows(container: HTMLElement, nodes: Node[]) {
|
|
|
425
432
|
|
|
426
433
|
For reactive templates, prefer declarative updates over manual replacement.
|
|
427
434
|
|
|
428
|
-
### `@
|
|
435
|
+
### `@insertBeforeEnd` (extended)
|
|
429
436
|
|
|
430
|
-
`@
|
|
437
|
+
`simple-web-component` appends via `@insertBeforeEnd` (there is no `@appendChild` decorator).
|
|
431
438
|
|
|
432
439
|
`dom-render` alternatives:
|
|
433
440
|
|