native-document 1.0.286 → 1.0.288
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 +1 -1
- package/src/core/data/Observable.js +10 -0
- package/src/core/elements/anchor/Slot.js +10 -1
- package/src/core/wrappers/ElementCreator.js +2 -0
- package/src/ui/components/menu/helpers.js +4 -1
- package/src/ui/components/menu/menu.css +5 -0
- package/types/elements.d.ts +2 -0
- package/types/observable.d.ts +11 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "native-document",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.288",
|
|
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
|
|
|
@@ -8,7 +8,16 @@ export default function Slot(content) {
|
|
|
8
8
|
}
|
|
9
9
|
this.$anchor = Anchor();
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
if(content) {
|
|
12
|
+
if(content.__$Observable) {
|
|
13
|
+
this.$anchor.set(content.val());
|
|
14
|
+
content.subscribe((value) => {
|
|
15
|
+
this.$anchor.set(value);
|
|
16
|
+
});
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
this.$anchor.setContent(content);
|
|
20
|
+
}
|
|
12
21
|
}
|
|
13
22
|
|
|
14
23
|
|
|
@@ -125,7 +125,10 @@ export const setupInteraction = (listItem, el, submenuEl, orientation, interacti
|
|
|
125
125
|
export function applyIsActive(instance, $description, props) {
|
|
126
126
|
const root = instance.getRoot();
|
|
127
127
|
if(root && root.$description.active) {
|
|
128
|
-
|
|
128
|
+
if(!(typeof root.$description.active === 'function')) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
const isActive = root.$description.active($description);
|
|
129
132
|
props.class.add({ 'is-active': isActive });
|
|
130
133
|
}
|
|
131
134
|
}
|
package/types/elements.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { NDElement } from './nd-element';
|
|
|
5
5
|
import {AnchorAttributes,
|
|
6
6
|
AudioAttributes, CanvasAttributes, DetailsAttributes, DialogAttributes, GlobalAttributes, OlAttributes,
|
|
7
7
|
SourceAttributes, SvgAttributes, TrackAttributes, VideoAttributes, ThAttributes, ModAttributes, TdAttributes, TimeAttributes } from './globals';
|
|
8
|
+
import {SlotInterface} from "./slot";
|
|
8
9
|
|
|
9
10
|
// - Re-export all attribute types and utilities from globals
|
|
10
11
|
export type {
|
|
@@ -57,6 +58,7 @@ export type ValidChild =
|
|
|
57
58
|
| ObservableItem
|
|
58
59
|
| NDElement
|
|
59
60
|
| BindingHydrator
|
|
61
|
+
| SlotInterface
|
|
60
62
|
| ValidChild[]
|
|
61
63
|
| ((...args: any[]) => ValidChild);
|
|
62
64
|
|
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>;
|