@dooboostore/dom-render 1.0.114 → 1.0.116

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/LICENSE.md ADDED
@@ -0,0 +1,7 @@
1
+ Copyright (c) 2016-21 these people
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
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` now exposes modules from root entry:
67
-
68
- - `components`
69
- - `configs`
70
- - `decorators`
71
- - `events`
72
- - `lifecycle`
73
- - `messenger`
74
- - `operators`
75
- - `rawsets`
76
- - `types`
77
- - `DomRender`
78
- - `DomRenderProxy`
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-style directive.
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="@this@.items[i]">
136
- ${destIt.name}$
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 around operator execution
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 dr-attr="{ src: @this@.imageUrl, alt: @this@.alt }" />
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 fields and optional validator metadata.
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`, not from `dom-render` directly.
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
- ### `@appendChild` (extended)
435
+ ### `@insertBeforeEnd` (extended)
429
436
 
430
- `@appendChild` is from `simple-web-component`.
437
+ `simple-web-component` appends via `@insertBeforeEnd` (there is no `@appendChild` decorator).
431
438
 
432
439
  `dom-render` alternatives:
433
440