native-document 1.0.287 → 1.0.289
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "native-document",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.289",
|
|
4
4
|
"description": "A reactive JavaScript framework that preserves native DOM simplicity without sacrificing modern features",
|
|
5
5
|
"author": "AfroCodeur <https://github.com/afrocodeur>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -13,6 +13,7 @@ import ObservableResource from './ObservableResource';
|
|
|
13
13
|
import {Formatters} from '../utils/formatters';
|
|
14
14
|
import Ref from './Ref';
|
|
15
15
|
import ObservableQuery from './ObservableQuery';
|
|
16
|
+
import Slot from '../elements/anchor/Slot';
|
|
16
17
|
|
|
17
18
|
/**
|
|
18
19
|
*
|
|
@@ -274,6 +275,15 @@ ObservableItem.prototype.match = function(cases, fallback = null) {
|
|
|
274
275
|
});
|
|
275
276
|
};
|
|
276
277
|
|
|
278
|
+
/**
|
|
279
|
+
* Wraps the current observable into a reactive UI Slot for element/node rendering.
|
|
280
|
+
*
|
|
281
|
+
* @returns {Slot}
|
|
282
|
+
*/
|
|
283
|
+
ObservableItem.prototype.asSlot = function() {
|
|
284
|
+
return Slot(this);
|
|
285
|
+
};
|
|
286
|
+
|
|
277
287
|
Observable.object = Observable.init;
|
|
278
288
|
Observable.json = Observable.init;
|
|
279
289
|
|
|
@@ -10,9 +10,9 @@ export default function Slot(content) {
|
|
|
10
10
|
|
|
11
11
|
if(content) {
|
|
12
12
|
if(content.__$Observable) {
|
|
13
|
-
this.$anchor.
|
|
13
|
+
this.$anchor.setContent(content.val());
|
|
14
14
|
content.subscribe((value) => {
|
|
15
|
-
this.$anchor.
|
|
15
|
+
this.$anchor.setContent(value);
|
|
16
16
|
});
|
|
17
17
|
return;
|
|
18
18
|
}
|
package/types/observable.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { FilterResult, PredicateMap } from './filters';
|
|
2
2
|
import Ref, {RefItem} from './ref';
|
|
3
3
|
import {ObservableQueryInstance} from "./observable-query";
|
|
4
|
+
import {ValidChild} from "./elements";
|
|
5
|
+
import {SlotInterface} from "./slot";
|
|
4
6
|
|
|
5
7
|
export type Unsubscribe = () => void;
|
|
6
8
|
|
|
@@ -98,6 +100,15 @@ export interface ObservableItem<T = any> {
|
|
|
98
100
|
set?: (value: T) => any;
|
|
99
101
|
}): this;
|
|
100
102
|
|
|
103
|
+
pick<A, B = null>(whenTrue: A, whenFalse?: B): ObservableChecker<A | B>;
|
|
104
|
+
|
|
105
|
+
match<R, F = null>(
|
|
106
|
+
cases: Record<string | number | symbol, R>,
|
|
107
|
+
fallback?: F
|
|
108
|
+
): ObservableChecker<R | F>;
|
|
109
|
+
|
|
110
|
+
asSlot(initial?: ValidChild): SlotInterface;
|
|
111
|
+
|
|
101
112
|
// -- comparison helpers (is*) -------------------------------------------------------------------------------------
|
|
102
113
|
|
|
103
114
|
isEqualTo(value: T | ObservableItem<T>): ObservableChecker<boolean>;
|