brew-js-react 0.4.6 → 0.4.8
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 +140 -112
- package/dist/brew-js-react.js.map +1 -1
- package/dist/brew-js-react.min.js +2 -2
- package/dist/brew-js-react.min.js.map +1 -1
- package/hooks.js +53 -40
- package/i18n.d.ts +6 -3
- package/i18n.js +18 -16
- package/mixin.d.ts +1 -1
- package/mixins/AnimateSequenceMixin.js +9 -2
- package/package.json +5 -5
- package/view.js +33 -20
package/dist/brew-js-react.js
CHANGED
|
@@ -1,27 +1,17 @@
|
|
|
1
|
-
/*! brew-js-react v0.4.
|
|
1
|
+
/*! brew-js-react v0.4.8 | (c) misonou | https://hackmd.io/@misonou/brew-js-react */
|
|
2
2
|
(function webpackUniversalModuleDefinition(root, factory) {
|
|
3
3
|
if(typeof exports === 'object' && typeof module === 'object')
|
|
4
|
-
module.exports = factory(require("brew-js"), require("react"), require("react-dom"),
|
|
4
|
+
module.exports = factory(require("brew-js"), require("react"), require("react-dom"), require("zeta-dom"), require("zeta-dom-react"), require("waterpipe"));
|
|
5
5
|
else if(typeof define === 'function' && define.amd)
|
|
6
|
-
define("brew-js-react", ["brew-js", "react", "react-dom", "
|
|
6
|
+
define("brew-js-react", ["brew-js", "react", "react-dom", "zeta-dom", "zeta-dom-react", "waterpipe"], factory);
|
|
7
7
|
else if(typeof exports === 'object')
|
|
8
|
-
exports["brew-js-react"] = factory(require("brew-js"), require("react"), require("react-dom"),
|
|
8
|
+
exports["brew-js-react"] = factory(require("brew-js"), require("react"), require("react-dom"), require("zeta-dom"), require("zeta-dom-react"), require("waterpipe"));
|
|
9
9
|
else
|
|
10
|
-
root["brew-js-react"] = factory(root["brew"], root["React"], root["ReactDOM"], root["
|
|
11
|
-
})(self, function(__WEBPACK_EXTERNAL_MODULE__80__, __WEBPACK_EXTERNAL_MODULE__359__, __WEBPACK_EXTERNAL_MODULE__318__,
|
|
10
|
+
root["brew-js-react"] = factory(root["brew"], root["React"], root["ReactDOM"], root["zeta"], root["zeta-dom-react"], root["waterpipe"]);
|
|
11
|
+
})(self, function(__WEBPACK_EXTERNAL_MODULE__80__, __WEBPACK_EXTERNAL_MODULE__359__, __WEBPACK_EXTERNAL_MODULE__318__, __WEBPACK_EXTERNAL_MODULE__654__, __WEBPACK_EXTERNAL_MODULE__103__, __WEBPACK_EXTERNAL_MODULE__28__) {
|
|
12
12
|
return /******/ (() => { // webpackBootstrap
|
|
13
13
|
/******/ var __webpack_modules__ = ({
|
|
14
14
|
|
|
15
|
-
/***/ 715:
|
|
16
|
-
/***/ ((module) => {
|
|
17
|
-
|
|
18
|
-
"use strict";
|
|
19
|
-
if(typeof __WEBPACK_EXTERNAL_MODULE__715__ === 'undefined') { var e = new Error("Cannot find module 'react-dom/client'"); e.code = 'MODULE_NOT_FOUND'; throw e; }
|
|
20
|
-
|
|
21
|
-
module.exports = __WEBPACK_EXTERNAL_MODULE__715__;
|
|
22
|
-
|
|
23
|
-
/***/ }),
|
|
24
|
-
|
|
25
15
|
/***/ 28:
|
|
26
16
|
/***/ ((module) => {
|
|
27
17
|
|
|
@@ -70,38 +60,33 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__654__;
|
|
|
70
60
|
|
|
71
61
|
/***/ }),
|
|
72
62
|
|
|
73
|
-
/***/
|
|
63
|
+
/***/ 862:
|
|
74
64
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
75
65
|
|
|
76
|
-
var
|
|
66
|
+
var ReactDOM = __webpack_require__(318);
|
|
77
67
|
var ReactDOMClient;
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
68
|
+
|
|
69
|
+
if (ReactDOM.createRoot) {
|
|
70
|
+
ReactDOMClient = ReactDOM;
|
|
71
|
+
} else {
|
|
81
72
|
ReactDOMClient = {
|
|
82
73
|
createRoot(container, options) {
|
|
83
74
|
return {
|
|
84
75
|
render(children) {
|
|
85
|
-
|
|
76
|
+
ReactDOM.render(children, container);
|
|
86
77
|
},
|
|
87
78
|
unmount() {
|
|
88
|
-
|
|
79
|
+
ReactDOM.unmountComponentAtNode(container);
|
|
89
80
|
}
|
|
90
81
|
};
|
|
91
82
|
},
|
|
92
83
|
hydrateRoot(container, initialChildren, options) {
|
|
93
|
-
|
|
94
|
-
return
|
|
95
|
-
render(children) {
|
|
96
|
-
React.render(children, container);
|
|
97
|
-
},
|
|
98
|
-
unmount() {
|
|
99
|
-
React.unmountComponentAtNode(container);
|
|
100
|
-
}
|
|
101
|
-
};
|
|
84
|
+
ReactDOM.hydrate(initialChildren, container);
|
|
85
|
+
return ReactDOMClient.createRoot(container, options);
|
|
102
86
|
},
|
|
103
87
|
};
|
|
104
88
|
}
|
|
89
|
+
|
|
105
90
|
/** @type {import("react-dom/client")} */
|
|
106
91
|
module.exports = ReactDOMClient;
|
|
107
92
|
|
|
@@ -241,14 +226,14 @@ var install = external_commonjs_brew_js_commonjs2_brew_js_amd_brew_js_root_brew_
|
|
|
241
226
|
var external_commonjs_react_commonjs2_react_amd_react_root_React_ = __webpack_require__(359);
|
|
242
227
|
// EXTERNAL MODULE: external {"commonjs":"react-dom","commonjs2":"react-dom","amd":"react-dom","root":"ReactDOM"}
|
|
243
228
|
var external_commonjs_react_dom_commonjs2_react_dom_amd_react_dom_root_ReactDOM_ = __webpack_require__(318);
|
|
244
|
-
// EXTERNAL MODULE: ./node_modules/@misonou/react-dom-client/
|
|
245
|
-
var
|
|
229
|
+
// EXTERNAL MODULE: ./node_modules/@misonou/react-dom-client/fallback.js
|
|
230
|
+
var fallback = __webpack_require__(862);
|
|
246
231
|
;// CONCATENATED MODULE: ./src/include/external/react-dom-client.js
|
|
247
232
|
// @ts-nocheck
|
|
248
233
|
|
|
249
234
|
/** @type {import("react-dom/client")} */
|
|
250
235
|
|
|
251
|
-
/* harmony default export */ const
|
|
236
|
+
/* harmony default export */ const react_dom_client = (fallback);
|
|
252
237
|
// EXTERNAL MODULE: external {"commonjs":"zeta-dom","commonjs2":"zeta-dom","amd":"zeta-dom","root":"zeta"}
|
|
253
238
|
var external_commonjs_zeta_dom_commonjs2_zeta_dom_amd_zeta_dom_root_zeta_ = __webpack_require__(654);
|
|
254
239
|
;// CONCATENATED MODULE: ./tmp/zeta-dom/util.js
|
|
@@ -257,6 +242,7 @@ var _lib$util = external_commonjs_zeta_dom_commonjs2_zeta_dom_amd_zeta_dom_root_
|
|
|
257
242
|
noop = _lib$util.noop,
|
|
258
243
|
pipe = _lib$util.pipe,
|
|
259
244
|
either = _lib$util.either,
|
|
245
|
+
sameValueZero = _lib$util.sameValueZero,
|
|
260
246
|
is = _lib$util.is,
|
|
261
247
|
isUndefinedOrNull = _lib$util.isUndefinedOrNull,
|
|
262
248
|
isArray = _lib$util.isArray,
|
|
@@ -321,6 +307,7 @@ var _lib$util = external_commonjs_zeta_dom_commonjs2_zeta_dom_amd_zeta_dom_root_
|
|
|
321
307
|
lcfirst = _lib$util.lcfirst,
|
|
322
308
|
trim = _lib$util.trim,
|
|
323
309
|
matchWord = _lib$util.matchWord,
|
|
310
|
+
matchWordMulti = _lib$util.matchWordMulti,
|
|
324
311
|
htmlDecode = _lib$util.htmlDecode,
|
|
325
312
|
resolve = _lib$util.resolve,
|
|
326
313
|
reject = _lib$util.reject,
|
|
@@ -436,7 +423,7 @@ var addAsyncAction = external_commonjs_brew_js_commonjs2_brew_js_amd_brew_js_roo
|
|
|
436
423
|
|
|
437
424
|
function createDialog(props) {
|
|
438
425
|
var root = document.createElement('div');
|
|
439
|
-
var reactRoot =
|
|
426
|
+
var reactRoot = react_dom_client.createRoot(root);
|
|
440
427
|
|
|
441
428
|
var _closeDialog = closeFlyout.bind(0, root);
|
|
442
429
|
|
|
@@ -609,6 +596,9 @@ var emitter = new ZetaEventContainer();
|
|
|
609
596
|
var rootContext = freeze(extend(new ViewContext(null, null), {
|
|
610
597
|
container: root
|
|
611
598
|
}));
|
|
599
|
+
|
|
600
|
+
var rootState = _(rootContext);
|
|
601
|
+
|
|
612
602
|
var StateContext = /*#__PURE__*/external_commonjs_react_commonjs2_react_amd_react_root_React_.createContext(rootContext);
|
|
613
603
|
var errorView;
|
|
614
604
|
/** @type {Partial<Zeta.ZetaEventType<"beforepageload", Brew.RouterEventMap, Element>>} */
|
|
@@ -616,19 +606,39 @@ var errorView;
|
|
|
616
606
|
var view_event = {};
|
|
617
607
|
onAppInit(function () {
|
|
618
608
|
app_app.on('beforepageload', function (e) {
|
|
609
|
+
rootState.setPage(app_app.page);
|
|
610
|
+
rootState.setActive(true);
|
|
619
611
|
view_event = e;
|
|
612
|
+
e.waitFor(new Promise(function (resolve) {
|
|
613
|
+
(function updateViewRecursive(next) {
|
|
614
|
+
if (!next[0]) {
|
|
615
|
+
return resolve();
|
|
616
|
+
}
|
|
620
617
|
|
|
621
|
-
|
|
618
|
+
resolveAll(map(next, function (v) {
|
|
619
|
+
return new Promise(function (resolve) {
|
|
620
|
+
v.onRender = resolve;
|
|
621
|
+
v.forceUpdate();
|
|
622
|
+
});
|
|
623
|
+
})).then(function () {
|
|
624
|
+
updateViewRecursive(map(next, function (v) {
|
|
625
|
+
return v.children;
|
|
626
|
+
}));
|
|
627
|
+
});
|
|
628
|
+
})(rootState.children);
|
|
629
|
+
}));
|
|
622
630
|
});
|
|
623
631
|
});
|
|
624
632
|
|
|
625
633
|
function ViewContext(view, page) {
|
|
626
634
|
var self = this;
|
|
635
|
+
watch(self, true);
|
|
627
636
|
defineOwnProperty(self, 'view', view, true);
|
|
628
637
|
|
|
629
638
|
_(self, {
|
|
639
|
+
children: [],
|
|
630
640
|
setPage: defineObservableProperty(self, 'page', page, true),
|
|
631
|
-
setActive: defineObservableProperty(self, 'active',
|
|
641
|
+
setActive: defineObservableProperty(self, 'active', !!page, true)
|
|
632
642
|
});
|
|
633
643
|
|
|
634
644
|
watch(self, 'page', function (page, previousPage) {
|
|
@@ -698,33 +708,27 @@ definePrototype(ErrorBoundary, external_commonjs_react_commonjs2_react_amd_react
|
|
|
698
708
|
|
|
699
709
|
function ViewContainer() {
|
|
700
710
|
external_commonjs_react_commonjs2_react_amd_react_root_React_.Component.apply(this, arguments);
|
|
701
|
-
this.stateId = history.state;
|
|
702
711
|
}
|
|
703
712
|
|
|
704
713
|
ViewContainer.contextType = StateContext;
|
|
705
714
|
definePrototype(ViewContainer, external_commonjs_react_commonjs2_react_amd_react_root_React_.Component, {
|
|
706
715
|
componentDidMount: function componentDidMount() {
|
|
707
|
-
/** @type {any} */
|
|
708
716
|
var self = this;
|
|
717
|
+
|
|
718
|
+
var parent = _(self.context).children;
|
|
719
|
+
|
|
720
|
+
parent.push(self);
|
|
709
721
|
self.componentWillUnmount = combineFn(watch(app_app.route, function () {
|
|
710
722
|
(self.setActive || noop)(self.getViewComponent() === self.currentViewComponent);
|
|
711
|
-
}),
|
|
712
|
-
self
|
|
713
|
-
|
|
714
|
-
if (self.context === rootContext || self.updateOnNext) {
|
|
715
|
-
view_event.waitFor(new Promise(function (resolve) {
|
|
716
|
-
self.onRender = resolve;
|
|
717
|
-
}));
|
|
718
|
-
self.updateView();
|
|
719
|
-
self.forceUpdate();
|
|
720
|
-
}
|
|
721
|
-
}));
|
|
723
|
+
}), function () {
|
|
724
|
+
arrRemove(parent, self);
|
|
725
|
+
});
|
|
722
726
|
},
|
|
723
727
|
render: function render() {
|
|
724
728
|
/** @type {any} */
|
|
725
729
|
var self = this;
|
|
726
730
|
|
|
727
|
-
if (
|
|
731
|
+
if (self.context.active) {
|
|
728
732
|
self.updateView();
|
|
729
733
|
}
|
|
730
734
|
|
|
@@ -734,21 +738,20 @@ definePrototype(ViewContainer, external_commonjs_react_commonjs2_react_amd_react
|
|
|
734
738
|
updateView: function updateView() {
|
|
735
739
|
var self = this;
|
|
736
740
|
var V = self.getViewComponent();
|
|
737
|
-
|
|
741
|
+
var viewChanged = V !== self.currentViewComponent;
|
|
738
742
|
|
|
739
|
-
if (V) {
|
|
743
|
+
if (V && (viewChanged || !(self.children || '')[0])) {
|
|
740
744
|
// ensure the current path actually corresponds to the matched view
|
|
741
745
|
// when some views are not included in the list of allowed views
|
|
742
746
|
var targetPath = resolvePath(V, getCurrentParams(V, true));
|
|
743
747
|
|
|
744
748
|
if (targetPath !== removeQueryAndHash(app_app.path)) {
|
|
745
749
|
app_app.navigate(targetPath, true);
|
|
746
|
-
self.updateOnNext = true;
|
|
747
750
|
return;
|
|
748
751
|
}
|
|
749
752
|
}
|
|
750
753
|
|
|
751
|
-
if (V &&
|
|
754
|
+
if (V && viewChanged) {
|
|
752
755
|
var prevElement = self.currentElement;
|
|
753
756
|
|
|
754
757
|
if (prevElement) {
|
|
@@ -986,26 +989,24 @@ function redirectTo(view, params, data) {
|
|
|
986
989
|
|
|
987
990
|
|
|
988
991
|
|
|
989
|
-
|
|
990
992
|
var hooks_emitter = new ZetaEventContainer();
|
|
991
993
|
|
|
992
994
|
function getCurrentStates() {
|
|
993
995
|
return app_app.historyStorage.current;
|
|
994
996
|
}
|
|
995
997
|
|
|
996
|
-
function ViewState(key,
|
|
998
|
+
function ViewState(key, dispose) {
|
|
997
999
|
this.key = key;
|
|
998
|
-
this.
|
|
1000
|
+
this.store = getCurrentStates();
|
|
1001
|
+
this.dispose = dispose;
|
|
999
1002
|
}
|
|
1000
1003
|
|
|
1001
1004
|
definePrototype(ViewState, {
|
|
1002
1005
|
get: function get() {
|
|
1003
|
-
return this.
|
|
1006
|
+
return this.store.get(this.key);
|
|
1004
1007
|
},
|
|
1005
1008
|
set: function set(value) {
|
|
1006
|
-
|
|
1007
|
-
self.value = value;
|
|
1008
|
-
self.store.set(self.key, value);
|
|
1009
|
+
this.store.set(this.key, value);
|
|
1009
1010
|
},
|
|
1010
1011
|
onPopState: function onPopState(callback) {
|
|
1011
1012
|
throwNotFunction(callback);
|
|
@@ -1014,6 +1015,34 @@ definePrototype(ViewState, {
|
|
|
1014
1015
|
});
|
|
1015
1016
|
}
|
|
1016
1017
|
});
|
|
1018
|
+
|
|
1019
|
+
function updateViewState(state, key, store) {
|
|
1020
|
+
var newValue = state.get();
|
|
1021
|
+
|
|
1022
|
+
if (key !== state.key || store !== state.store && store.has(key)) {
|
|
1023
|
+
newValue = store.get(key);
|
|
1024
|
+
hooks_emitter.emit('popstate', state, {
|
|
1025
|
+
newValue: newValue
|
|
1026
|
+
});
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
state.key = key;
|
|
1030
|
+
state.store = store;
|
|
1031
|
+
store.set(key, newValue);
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
function useViewContextWithEffect(callback, deps) {
|
|
1035
|
+
var container = useViewContext();
|
|
1036
|
+
(0,external_commonjs_react_commonjs2_react_amd_react_root_React_.useEffect)(function () {
|
|
1037
|
+
return app_app.on('beforepageload popstate', function () {
|
|
1038
|
+
if (container.active) {
|
|
1039
|
+
callback(getCurrentStates());
|
|
1040
|
+
}
|
|
1041
|
+
});
|
|
1042
|
+
}, deps);
|
|
1043
|
+
return container;
|
|
1044
|
+
}
|
|
1045
|
+
|
|
1017
1046
|
function useAppReady() {
|
|
1018
1047
|
return useAppReadyState().ready;
|
|
1019
1048
|
}
|
|
@@ -1065,11 +1094,18 @@ function useRouteParam(name, defaultValue) {
|
|
|
1065
1094
|
return value;
|
|
1066
1095
|
}
|
|
1067
1096
|
function useRouteState(key, defaultValue, snapshotOnUpdate) {
|
|
1068
|
-
var container = useViewContext();
|
|
1069
1097
|
var cur = getCurrentStates();
|
|
1070
|
-
var state = (0,external_commonjs_react_commonjs2_react_amd_react_root_React_.useState)(cur.has(key) ? cur.get(key) : defaultValue);
|
|
1098
|
+
var state = (0,external_commonjs_react_commonjs2_react_amd_react_root_React_.useState)(cur && cur.has(key) ? cur.get(key) : defaultValue);
|
|
1099
|
+
var container = useViewContextWithEffect(function (cur) {
|
|
1100
|
+
state[1](function (oldValue) {
|
|
1101
|
+
return cur.has(key) ? cur.get(key) : (cur.set(key, oldValue), oldValue);
|
|
1102
|
+
});
|
|
1103
|
+
}, [key]);
|
|
1071
1104
|
|
|
1072
|
-
if (
|
|
1105
|
+
if (!cur) {
|
|
1106
|
+
// delay app ready to ensure that beforepageload event can be caught
|
|
1107
|
+
app_app.beforeInit(delay(1));
|
|
1108
|
+
} else if (container.active && cur.get(key) !== state[0]) {
|
|
1073
1109
|
if (snapshotOnUpdate && cur.has(key)) {
|
|
1074
1110
|
app_app.snapshot();
|
|
1075
1111
|
cur = getCurrentStates();
|
|
@@ -1078,44 +1114,27 @@ function useRouteState(key, defaultValue, snapshotOnUpdate) {
|
|
|
1078
1114
|
cur.set(key, state[0]);
|
|
1079
1115
|
}
|
|
1080
1116
|
|
|
1081
|
-
(0,external_commonjs_react_commonjs2_react_amd_react_root_React_.useEffect)(function () {
|
|
1082
|
-
if (snapshotOnUpdate) {
|
|
1083
|
-
return bind(window, 'popstate', function () {
|
|
1084
|
-
if (container.active) {
|
|
1085
|
-
var cur = getCurrentStates();
|
|
1086
|
-
state[1](cur.has(key) ? cur.get(key) : defaultValue);
|
|
1087
|
-
}
|
|
1088
|
-
});
|
|
1089
|
-
}
|
|
1090
|
-
}, [container, snapshotOnUpdate]);
|
|
1091
1117
|
return state;
|
|
1092
1118
|
}
|
|
1093
1119
|
function ViewStateContainer(props) {
|
|
1094
|
-
var
|
|
1120
|
+
var cache = (0,external_commonjs_react_commonjs2_react_amd_react_root_React_.useState)({})[0];
|
|
1121
|
+
var container = useViewContextWithEffect(function (cur) {
|
|
1122
|
+
each(cache, function (i, v) {
|
|
1123
|
+
updateViewState(v, v.key, cur);
|
|
1124
|
+
});
|
|
1125
|
+
}, []);
|
|
1095
1126
|
var provider = (0,external_commonjs_react_commonjs2_react_amd_react_root_React_.useState)(function () {
|
|
1096
|
-
var cache = {};
|
|
1097
1127
|
return {
|
|
1098
1128
|
getState: function getState(uniqueId, key) {
|
|
1099
|
-
var
|
|
1100
|
-
var value = cur.get(key);
|
|
1101
|
-
var state = cache[uniqueId] || (cache[uniqueId] = new ViewState(key, value));
|
|
1102
|
-
|
|
1103
|
-
if (container.active) {
|
|
1104
|
-
var store = state.store;
|
|
1105
|
-
|
|
1106
|
-
if (store && (store !== cur && cur.has(key) || key !== state.key)) {
|
|
1107
|
-
hooks_emitter.emit('popstate', state, {
|
|
1108
|
-
newValue: value
|
|
1109
|
-
});
|
|
1110
|
-
state.value = value;
|
|
1111
|
-
state.key = key;
|
|
1112
|
-
}
|
|
1129
|
+
var state = cache[uniqueId];
|
|
1113
1130
|
|
|
1114
|
-
|
|
1115
|
-
|
|
1131
|
+
if (state && container.active) {
|
|
1132
|
+
updateViewState(state, key, getCurrentStates());
|
|
1116
1133
|
}
|
|
1117
1134
|
|
|
1118
|
-
return state
|
|
1135
|
+
return state || (cache[uniqueId] = new ViewState(key, function () {
|
|
1136
|
+
delete cache[uniqueId];
|
|
1137
|
+
}));
|
|
1119
1138
|
}
|
|
1120
1139
|
};
|
|
1121
1140
|
})[0];
|
|
@@ -1148,19 +1167,19 @@ if (toPrimitive) {
|
|
|
1148
1167
|
}
|
|
1149
1168
|
|
|
1150
1169
|
function createCallback(translate) {
|
|
1151
|
-
var callback = function callback(key, data) {
|
|
1152
|
-
var result = translate(key, data, true);
|
|
1170
|
+
var callback = function callback(key, data, lang) {
|
|
1171
|
+
var result = translate(key, data, lang, true);
|
|
1153
1172
|
return result !== undefined ? result : key;
|
|
1154
1173
|
};
|
|
1155
1174
|
|
|
1156
1175
|
return extend(callback, {
|
|
1157
|
-
html: function html(id, data) {
|
|
1176
|
+
html: function html(id, data, lang) {
|
|
1158
1177
|
return {
|
|
1159
|
-
__html: translate(id, data)
|
|
1178
|
+
__html: translate(id, data, lang)
|
|
1160
1179
|
};
|
|
1161
1180
|
},
|
|
1162
|
-
lazy: function lazy(id, data) {
|
|
1163
|
-
return new TString(translate.bind(0, id, data, true));
|
|
1181
|
+
lazy: function lazy(id, data, lang) {
|
|
1182
|
+
return new TString(translate.bind(0, id, data, lang, true));
|
|
1164
1183
|
}
|
|
1165
1184
|
});
|
|
1166
1185
|
}
|
|
@@ -1190,36 +1209,38 @@ function makeTranslation(resources, defaultLang) {
|
|
|
1190
1209
|
}
|
|
1191
1210
|
}
|
|
1192
1211
|
|
|
1193
|
-
function translate(key, data, noEncode) {
|
|
1212
|
+
function translate(key, data, lang, noEncode) {
|
|
1194
1213
|
var prefix = re.test(key) ? RegExp.$1 : '';
|
|
1195
1214
|
var name = prefix ? key.slice(RegExp.lastMatch.length) : key;
|
|
1196
|
-
return getTranslation(prefix, name, data, noEncode, app_app.language);
|
|
1215
|
+
return getTranslation(prefix, name, data, noEncode, lang || app_app.language);
|
|
1197
1216
|
}
|
|
1198
1217
|
|
|
1199
1218
|
function getTranslationCallback() {
|
|
1219
|
+
var currentLang = String(this);
|
|
1200
1220
|
var prefix = makeArray(arguments);
|
|
1201
|
-
var key = prefix.join(' ');
|
|
1202
|
-
return cache[key] || (cache[key] = createCallback(function (key, data, noEncode) {
|
|
1203
|
-
|
|
1221
|
+
var key = currentLang + ' ' + prefix.join(' ');
|
|
1222
|
+
return cache[key] || (cache[key] = prefix[0] ? createCallback(function (key, data, lang, noEncode) {
|
|
1223
|
+
lang = lang || currentLang || app_app.language;
|
|
1204
1224
|
return single(prefix, function (v) {
|
|
1205
1225
|
return getTranslation(v, key, data, noEncode, lang);
|
|
1206
1226
|
});
|
|
1227
|
+
}) : createCallback(function (key, data, lang, noEncode) {
|
|
1228
|
+
return translate(key, data, lang || currentLang, noEncode);
|
|
1207
1229
|
}));
|
|
1208
1230
|
}
|
|
1209
1231
|
|
|
1210
1232
|
function useTranslation() {
|
|
1211
1233
|
var language = useLanguage();
|
|
1212
|
-
var t = getTranslationCallback.apply(
|
|
1234
|
+
var t = getTranslationCallback.apply(language, arguments);
|
|
1213
1235
|
return {
|
|
1214
1236
|
language: language,
|
|
1215
1237
|
t: t
|
|
1216
1238
|
};
|
|
1217
1239
|
}
|
|
1218
1240
|
|
|
1219
|
-
cache[''] = createCallback(translate);
|
|
1220
1241
|
return {
|
|
1221
|
-
translate:
|
|
1222
|
-
getTranslation: getTranslationCallback,
|
|
1242
|
+
translate: createCallback(translate),
|
|
1243
|
+
getTranslation: getTranslationCallback.bind(''),
|
|
1223
1244
|
useTranslation: useTranslation,
|
|
1224
1245
|
keys: function keys(prefix) {
|
|
1225
1246
|
return util_keys(resources[defaultLang][prefix] || empty);
|
|
@@ -1529,13 +1550,20 @@ function AnimateSequenceMixin() {
|
|
|
1529
1550
|
self.item = new AnimateSequenceItemMixin(self.className);
|
|
1530
1551
|
}
|
|
1531
1552
|
definePrototype(AnimateSequenceMixin, AnimateMixin, {
|
|
1553
|
+
withOptions: function withOptions(options) {
|
|
1554
|
+
this.selector = options;
|
|
1555
|
+
return this;
|
|
1556
|
+
},
|
|
1532
1557
|
reset: function reset() {
|
|
1533
1558
|
this.item.reset();
|
|
1534
1559
|
return AnimateSequenceMixinSuper.reset.call(this);
|
|
1535
1560
|
},
|
|
1536
1561
|
getCustomAttributes: function getCustomAttributes() {
|
|
1537
|
-
|
|
1538
|
-
|
|
1562
|
+
var self = this;
|
|
1563
|
+
return extend({}, AnimateSequenceMixinSuper.getCustomAttributes.call(self), {
|
|
1564
|
+
'animate-in': null,
|
|
1565
|
+
'animate-sequence-type': (self.effects || []).join(' '),
|
|
1566
|
+
'animate-sequence': self.selector || '.' + self.className
|
|
1539
1567
|
});
|
|
1540
1568
|
},
|
|
1541
1569
|
clone: function clone() {
|