brew-js-react 0.2.2 → 0.2.5
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/dist/brew-js-react.js +155 -50
- package/dist/brew-js-react.js.map +1 -1
- package/dist/brew-js-react.min.js +1 -1
- package/dist/brew-js-react.min.js.map +1 -1
- package/hooks.js +115 -113
- package/i18n.d.ts +9 -1
- package/i18n.js +5 -2
- package/include/brew-js/util/path.js +1 -0
- package/include/brew-js/var.js +1 -0
- package/mixins/ClassNameMixin.js +0 -3
- package/mixins/FlyoutMixin.d.ts +5 -3
- package/mixins/FlyoutMixin.js +13 -2
- package/mixins/FlyoutToggleMixin.d.ts +4 -1
- package/mixins/FlyoutToggleMixin.js +6 -3
- package/mixins/StatefulMixin.js +83 -82
- package/package.json +3 -2
- package/view.d.ts +27 -0
- package/view.js +84 -22
package/hooks.js
CHANGED
|
@@ -1,113 +1,115 @@
|
|
|
1
|
-
import { createElement, useEffect, useRef, useState } from "react";
|
|
2
|
-
import { ViewStateProvider } from "zeta-dom-react";
|
|
3
|
-
import { definePrototype, extend, kv, setImmediateOnce, throwNotFunction } from "./include/zeta-dom/util.js";
|
|
4
|
-
import { ZetaEventContainer } from "./include/zeta-dom/events.js";
|
|
5
|
-
import { app } from "./app.js";
|
|
6
|
-
import { useViewContainerState } from "./view.js";
|
|
7
|
-
|
|
8
|
-
const emitter = new ZetaEventContainer();
|
|
9
|
-
const states = {};
|
|
10
|
-
|
|
11
|
-
function getCurrentStates() {
|
|
12
|
-
return states[history.state] || (states[history.state] = {});
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
function ViewState(value) {
|
|
16
|
-
this.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
const
|
|
48
|
-
const
|
|
49
|
-
const
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
const
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
var
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}
|
|
1
|
+
import { createElement, useEffect, useRef, useState } from "react";
|
|
2
|
+
import { ViewStateProvider } from "zeta-dom-react";
|
|
3
|
+
import { definePrototype, extend, kv, setImmediateOnce, throwNotFunction } from "./include/zeta-dom/util.js";
|
|
4
|
+
import { ZetaEventContainer } from "./include/zeta-dom/events.js";
|
|
5
|
+
import { app } from "./app.js";
|
|
6
|
+
import { useViewContainerState } from "./view.js";
|
|
7
|
+
|
|
8
|
+
const emitter = new ZetaEventContainer();
|
|
9
|
+
const states = {};
|
|
10
|
+
|
|
11
|
+
function getCurrentStates() {
|
|
12
|
+
return states[history.state] || (states[history.state] = {});
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function ViewState(key, value) {
|
|
16
|
+
this.key = key;
|
|
17
|
+
this.value = value;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
definePrototype(ViewState, {
|
|
21
|
+
get: function () {
|
|
22
|
+
return this.value;
|
|
23
|
+
},
|
|
24
|
+
set: function (value) {
|
|
25
|
+
this.value = value;
|
|
26
|
+
},
|
|
27
|
+
onPopState: function (callback) {
|
|
28
|
+
throwNotFunction(callback);
|
|
29
|
+
return emitter.add(this, 'popstate', function (e) {
|
|
30
|
+
callback.call(this, e.newValue);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
export function useAppReady() {
|
|
36
|
+
const sReady = useState(false);
|
|
37
|
+
const ready = sReady[0], setReady = sReady[1];
|
|
38
|
+
useEffect(function () {
|
|
39
|
+
app.ready.then(function () {
|
|
40
|
+
setReady(true);
|
|
41
|
+
});
|
|
42
|
+
}, []);
|
|
43
|
+
return ready;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function useRouteParam(name, defaultValue) {
|
|
47
|
+
const container = useViewContainerState();
|
|
48
|
+
const route = app.route;
|
|
49
|
+
const value = route[name] || '';
|
|
50
|
+
const ref = useRef(value);
|
|
51
|
+
const forceUpdate = useState()[1];
|
|
52
|
+
useEffect(function () {
|
|
53
|
+
var setValue = function () {
|
|
54
|
+
var current = route[name] || '';
|
|
55
|
+
if (container.active && current !== ref.current) {
|
|
56
|
+
ref.current = current;
|
|
57
|
+
forceUpdate({});
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
// route parameter might be changed after state initialization and before useEffect hook is called
|
|
61
|
+
setValue();
|
|
62
|
+
if (name in route) {
|
|
63
|
+
return route.watch(name, function () {
|
|
64
|
+
setImmediateOnce(setValue);
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
console.error('Route parameter ' + name + ' does not exist');
|
|
68
|
+
}, [name, defaultValue]);
|
|
69
|
+
ref.current = value;
|
|
70
|
+
if (!value && defaultValue !== undefined) {
|
|
71
|
+
app.navigate(route.getPath(extend({}, route, kv(name, defaultValue))), true);
|
|
72
|
+
}
|
|
73
|
+
return value;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function useRouteState(key, defaultValue) {
|
|
77
|
+
const container = useViewContainerState();
|
|
78
|
+
const cur = getCurrentStates();
|
|
79
|
+
const state = useState(key in cur ? cur[key] : defaultValue);
|
|
80
|
+
if (container.active) {
|
|
81
|
+
cur[key] = state[0];
|
|
82
|
+
}
|
|
83
|
+
return state;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function ViewStateContainer(props) {
|
|
87
|
+
const container = useViewContainerState();
|
|
88
|
+
const provider = useState(function () {
|
|
89
|
+
const cache = {};
|
|
90
|
+
return {
|
|
91
|
+
getState: function (uniqueId, key) {
|
|
92
|
+
var cur = getCurrentStates();
|
|
93
|
+
var state = cache[uniqueId] || (cache[uniqueId] = new ViewState(key, cur[key] && cur[key].value));
|
|
94
|
+
if (container.active) {
|
|
95
|
+
var stateId = state.stateId;
|
|
96
|
+
if (stateId && (stateId !== history.state || key !== state.key)) {
|
|
97
|
+
var newValue = cur[key] && cur[key].value;
|
|
98
|
+
emitter.emit('popstate', state, {
|
|
99
|
+
newValue: newValue
|
|
100
|
+
});
|
|
101
|
+
// detach value in previous history state from current one
|
|
102
|
+
var previous = new ViewState(state.key, state.value);
|
|
103
|
+
states[stateId][previous.key] = previous;
|
|
104
|
+
state.value = newValue;
|
|
105
|
+
state.key = key;
|
|
106
|
+
}
|
|
107
|
+
state.stateId = history.state;
|
|
108
|
+
cur[key] = state;
|
|
109
|
+
}
|
|
110
|
+
return state;
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
})[0];
|
|
114
|
+
return createElement(ViewStateProvider, { value: provider }, props.children);
|
|
115
|
+
}
|
package/i18n.d.ts
CHANGED
|
@@ -63,6 +63,13 @@ export function makeTranslation<T extends Zeta.Dictionary<object>, K extends key
|
|
|
63
63
|
type ResourceKey<T> = { [P in ResourcePrefix]: StringKeysOf<ResourceObject[P]> }[T];
|
|
64
64
|
type ResourceGlobalKey = { [P in ResourcePrefix]: `${P}.${StringKeysOf<ResourceObject[P]>}` }[ResourcePrefix];
|
|
65
65
|
|
|
66
|
+
interface GetKeys {
|
|
67
|
+
/**
|
|
68
|
+
* Gets the list of translation key under the given prefix.
|
|
69
|
+
*/
|
|
70
|
+
<T extends ResourcePrefix>(prefix: T): ResourceKey<T>[];
|
|
71
|
+
}
|
|
72
|
+
|
|
66
73
|
interface GetTranslation {
|
|
67
74
|
/**
|
|
68
75
|
* Create translation callback which only looks up all prefixes.
|
|
@@ -89,8 +96,9 @@ export function makeTranslation<T extends Zeta.Dictionary<object>, K extends key
|
|
|
89
96
|
<T extends readonly ResourcePrefix[]>(...args: T): Translation<ResourceKey<ArrayMember<T>>>;
|
|
90
97
|
}
|
|
91
98
|
|
|
99
|
+
declare const keys: GetKeys;
|
|
92
100
|
declare const translate: Translate<ResourceGlobalKey>;
|
|
93
101
|
declare const getTranslation: GetTranslation;
|
|
94
102
|
declare const useTranslation: UseTranslationHook;
|
|
95
|
-
return { translate, getTranslation, useTranslation };
|
|
103
|
+
return { keys, translate, getTranslation, useTranslation };
|
|
96
104
|
}
|
package/i18n.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useObservableProperty } from "zeta-dom-react";
|
|
2
2
|
import waterpipe from "./include/external/waterpipe.js"
|
|
3
|
-
import { extend, makeArray, single } from "./include/zeta-dom/util.js";
|
|
3
|
+
import { extend, keys, makeArray, single } from "./include/zeta-dom/util.js";
|
|
4
4
|
import { app } from "./app.js";
|
|
5
5
|
|
|
6
6
|
const empty = Object.create(null);
|
|
@@ -79,6 +79,9 @@ export function makeTranslation(resources, defaultLang) {
|
|
|
79
79
|
return {
|
|
80
80
|
translate: cache[''],
|
|
81
81
|
getTranslation: getTranslationCallback,
|
|
82
|
-
useTranslation
|
|
82
|
+
useTranslation: useTranslation,
|
|
83
|
+
keys: function (prefix) {
|
|
84
|
+
return keys(resources[defaultLang][prefix] || empty);
|
|
85
|
+
}
|
|
83
86
|
};
|
|
84
87
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "brew-js/util/path";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "brew-js/var";
|
package/mixins/ClassNameMixin.js
CHANGED
|
@@ -52,9 +52,6 @@ definePrototype(ClassNameMixin, StatefulMixin, {
|
|
|
52
52
|
}
|
|
53
53
|
});
|
|
54
54
|
},
|
|
55
|
-
clone: function () {
|
|
56
|
-
return extend(ClassNameMixinSuper.clone.call(this), { classNames: this.classNames });
|
|
57
|
-
},
|
|
58
55
|
onClassNameUpdated: function (element, prevState, state) {
|
|
59
56
|
}
|
|
60
57
|
});
|
package/mixins/FlyoutMixin.d.ts
CHANGED
|
@@ -5,18 +5,20 @@ import { AnimationEffect } from "./AnimateMixin";
|
|
|
5
5
|
export interface FlyoutMixinOptions {
|
|
6
6
|
modal?: boolean;
|
|
7
7
|
tabThrough?: boolean;
|
|
8
|
-
swipeToDismiss?:
|
|
8
|
+
swipeToDismiss?: 'up' | 'down' | 'left' | 'right';
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
export default class FlyoutMixin extends ClassNameMixin {
|
|
12
12
|
readonly isFlyoutOpened: boolean;
|
|
13
13
|
readonly animating: boolean;
|
|
14
14
|
readonly visible: boolean;
|
|
15
|
-
readonly toggle:
|
|
15
|
+
readonly toggle: FlyoutToggleMixin;
|
|
16
16
|
modal: boolean;
|
|
17
17
|
|
|
18
18
|
withEffects(...effects: AnimationEffect[]): this;
|
|
19
|
-
onOpen(callback: () => void): Zeta.UnregisterCallback;
|
|
19
|
+
onOpen(callback: (state: any) => void): Zeta.UnregisterCallback;
|
|
20
20
|
onToggleState(callback: (state: boolean) => void): Zeta.UnregisterCallback;
|
|
21
21
|
onVisibilityChanged(callback: (state: boolean) => void): Zeta.UnregisterCallback;
|
|
22
|
+
open(state?: any): Promise<any>;
|
|
23
|
+
close(state?: any): Promise<void>;
|
|
22
24
|
}
|
package/mixins/FlyoutMixin.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { defineAliasProperty, definePrototype, each, extend, makeArray } from "../include/zeta-dom/util.js";
|
|
2
|
+
import { closeFlyout, openFlyout } from "../include/brew-js/domAction.js";
|
|
2
3
|
import { app } from "../app.js";
|
|
3
4
|
import ClassNameMixin from "./ClassNameMixin.js";
|
|
4
5
|
import FlyoutToggleMixin from "./FlyoutToggleMixin.js";
|
|
5
6
|
|
|
6
7
|
const FlyoutMixinSuper = ClassNameMixin.prototype;
|
|
8
|
+
const valueMap = new WeakMap();
|
|
7
9
|
var flyoutMixinCounter = 0;
|
|
8
10
|
|
|
9
11
|
export default function FlyoutMixin() {
|
|
10
12
|
var self = this;
|
|
11
|
-
ClassNameMixin.call(self, ['open', 'closing', 'tweening-in', 'tweening-out']);
|
|
13
|
+
ClassNameMixin.call(self, ['open', 'closing', 'visible', 'tweening-in', 'tweening-out']);
|
|
12
14
|
self.modal = false;
|
|
13
15
|
self.tabThrough = false;
|
|
14
16
|
self.isFlyoutOpened = false;
|
|
@@ -45,10 +47,19 @@ definePrototype(FlyoutMixin, ClassNameMixin, {
|
|
|
45
47
|
'animate-out': ''
|
|
46
48
|
});
|
|
47
49
|
},
|
|
50
|
+
open: function (value) {
|
|
51
|
+
var element = this.elements()[0];
|
|
52
|
+
valueMap.set(element, value);
|
|
53
|
+
return openFlyout(element);
|
|
54
|
+
},
|
|
55
|
+
close: function (value) {
|
|
56
|
+
return closeFlyout(this.elements()[0], value);
|
|
57
|
+
},
|
|
48
58
|
onOpen: function (callback) {
|
|
59
|
+
var element = this.elements()[0];
|
|
49
60
|
return this.onToggleState(function (opened) {
|
|
50
61
|
if (opened) {
|
|
51
|
-
return callback();
|
|
62
|
+
return callback(valueMap.get(element));
|
|
52
63
|
}
|
|
53
64
|
});
|
|
54
65
|
},
|
|
@@ -9,13 +9,16 @@ export default function FlyoutToggleMixin(mixin) {
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
definePrototype(FlyoutToggleMixin, ClassNameMixin, {
|
|
12
|
+
open: function (value) {
|
|
13
|
+
return this.flyoutMixin.open(value);
|
|
14
|
+
},
|
|
15
|
+
close: function (value) {
|
|
16
|
+
return this.flyoutMixin.close(value);
|
|
17
|
+
},
|
|
12
18
|
getCustomAttributes: function () {
|
|
13
19
|
var element = this.flyoutMixin.elements()[0];
|
|
14
20
|
return extend({}, FlyoutToggleMixinSuper.getCustomAttributes.call(this), {
|
|
15
21
|
'toggle': element && ('#' + element.id)
|
|
16
22
|
});
|
|
17
|
-
},
|
|
18
|
-
clone: function () {
|
|
19
|
-
return extend(FlyoutToggleMixinSuper.clone.call(this), { flyoutMixin: this.flyoutMixin });
|
|
20
23
|
}
|
|
21
24
|
});
|
package/mixins/StatefulMixin.js
CHANGED
|
@@ -1,82 +1,83 @@
|
|
|
1
|
-
import { createPrivateStore, definePrototype, each, inherit, randomId, values } from "../include/zeta-dom/util.js";
|
|
2
|
-
import Mixin from "./Mixin.js";
|
|
3
|
-
|
|
4
|
-
const _ = createPrivateStore();
|
|
5
|
-
|
|
6
|
-
function MixinRefImpl(mixin) {
|
|
7
|
-
this.mixin = mixin;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
definePrototype(MixinRefImpl, {
|
|
11
|
-
getMixin: function () {
|
|
12
|
-
return this.mixin;
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
export default function StatefulMixin() {
|
|
17
|
-
Mixin.call(this);
|
|
18
|
-
_(this, {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
self.
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
1
|
+
import { createPrivateStore, definePrototype, each, extend, inherit, randomId, setAdd, values } from "../include/zeta-dom/util.js";
|
|
2
|
+
import Mixin from "./Mixin.js";
|
|
3
|
+
|
|
4
|
+
const _ = createPrivateStore();
|
|
5
|
+
|
|
6
|
+
function MixinRefImpl(mixin) {
|
|
7
|
+
this.mixin = mixin;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
definePrototype(MixinRefImpl, {
|
|
11
|
+
getMixin: function () {
|
|
12
|
+
return this.mixin;
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export default function StatefulMixin() {
|
|
17
|
+
Mixin.call(this);
|
|
18
|
+
_(this, {
|
|
19
|
+
elements: new WeakSet(),
|
|
20
|
+
states: {},
|
|
21
|
+
prefix: '',
|
|
22
|
+
counter: 0
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
definePrototype(StatefulMixin, Mixin, {
|
|
27
|
+
get ref() {
|
|
28
|
+
const self = this;
|
|
29
|
+
const state = self.state;
|
|
30
|
+
self.next();
|
|
31
|
+
return state.ref || (state.ref = new MixinRefImpl(self.clone()));
|
|
32
|
+
},
|
|
33
|
+
get state() {
|
|
34
|
+
const obj = _(this);
|
|
35
|
+
const key = obj.prefix + obj.counter;
|
|
36
|
+
return obj.states[key] || (obj.states[key] = this.initState());
|
|
37
|
+
},
|
|
38
|
+
reset: function () {
|
|
39
|
+
_(this).counter = 0;
|
|
40
|
+
return this;
|
|
41
|
+
},
|
|
42
|
+
next: function () {
|
|
43
|
+
_(this).counter++;
|
|
44
|
+
return this;
|
|
45
|
+
},
|
|
46
|
+
getRef: function () {
|
|
47
|
+
const self = this;
|
|
48
|
+
const state = self.state;
|
|
49
|
+
return function (current) {
|
|
50
|
+
state.element = current;
|
|
51
|
+
if (current && setAdd(_(self).elements, current)) {
|
|
52
|
+
self.initElement(current, state);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
},
|
|
56
|
+
elements: function () {
|
|
57
|
+
return values(_(this).states).map(function (v) {
|
|
58
|
+
return v.element;
|
|
59
|
+
}).filter(function (v) {
|
|
60
|
+
return v;
|
|
61
|
+
});
|
|
62
|
+
},
|
|
63
|
+
initState: function () {
|
|
64
|
+
return { element: null };
|
|
65
|
+
},
|
|
66
|
+
initElement: function (element, state) {
|
|
67
|
+
},
|
|
68
|
+
clone: function () {
|
|
69
|
+
const self = this;
|
|
70
|
+
const clone = inherit(Object.getPrototypeOf(self), self);
|
|
71
|
+
_(clone, extend({}, _(self), {
|
|
72
|
+
prefix: randomId() + '.',
|
|
73
|
+
counter: 0
|
|
74
|
+
}));
|
|
75
|
+
return clone;
|
|
76
|
+
},
|
|
77
|
+
dispose: function () {
|
|
78
|
+
var states = _(this).states;
|
|
79
|
+
each(states, function (i, v) {
|
|
80
|
+
delete states[i];
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "brew-js-react",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"homepage": "https://hackmd.io/@misonou/brew-js-react",
|
|
18
18
|
"repository": "github:misonou/brew-js-react",
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"brew-js": ">=0.3.
|
|
20
|
+
"brew-js": ">=0.3.10",
|
|
21
21
|
"waterpipe": "^2.5.0",
|
|
22
22
|
"zeta-dom": ">=0.2.3",
|
|
23
23
|
"zeta-dom-react": ">=0.2.1"
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
"cross-env": "^7.0.2",
|
|
41
41
|
"glob": "^7.2.0",
|
|
42
42
|
"jest": "^27.0.6",
|
|
43
|
+
"jest-environment-jsdom": "^27.4.6",
|
|
43
44
|
"ncp": "^2.0.0",
|
|
44
45
|
"regenerator-runtime": "^0.13.9",
|
|
45
46
|
"webpack": "^5.3.0",
|
package/view.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export type ViewComponentRootProps = React.DetailedHTMLProps<React.HTMLAttribute
|
|
|
2
2
|
export type ViewComponent<P> = React.FC<P>;
|
|
3
3
|
|
|
4
4
|
export interface ViewContainerState {
|
|
5
|
+
readonly view: ViewComponent<any>;
|
|
5
6
|
readonly active: boolean;
|
|
6
7
|
}
|
|
7
8
|
|
|
@@ -22,6 +23,32 @@ export function registerView<P>(factory: () => Promise<{ default: React.Componen
|
|
|
22
23
|
*/
|
|
23
24
|
export function isViewMatched(view: ViewComponent<any>): boolean;
|
|
24
25
|
|
|
26
|
+
/**
|
|
27
|
+
* Gets the view component that matches the current path within all registered views.
|
|
28
|
+
* However it does not imply if the view is in fact being rendered.
|
|
29
|
+
*/
|
|
30
|
+
export function matchView(): ViewComponent<any> | undefined;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Gets the view component that matches the current path within the given set of views.
|
|
34
|
+
* However it does not imply if the view is in fact being rendered.
|
|
35
|
+
* @param views A list of view components.
|
|
36
|
+
*/
|
|
37
|
+
export function matchView(views: ViewComponent<any>[]): ViewComponent<any> | undefined;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Gets the view component that matches the specified path.
|
|
41
|
+
* @param path A valid path that could navigate to.
|
|
42
|
+
*/
|
|
43
|
+
export function matchView(path: string): ViewComponent<any> | undefined;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Gets the view component that matches the specified path, within the given set of views.
|
|
47
|
+
* @param path A valid path that could navigate to.
|
|
48
|
+
* @param views A list of view components.
|
|
49
|
+
*/
|
|
50
|
+
export function matchView(path: string, views: ViewComponent<any>[]): ViewComponent<any> | undefined;
|
|
51
|
+
|
|
25
52
|
/**
|
|
26
53
|
* Renders view by matching current route state against registered route parameters of each supplied views.
|
|
27
54
|
* @param args A list of view components created by {@link registerView}.
|