Skip to content

Commit 37faf41

Browse files
author
Vlad Balin
committed
updated react-mvx
1 parent 8768769 commit 37faf41

17 files changed

Lines changed: 108 additions & 22 deletions

File tree

dist/index.js

Lines changed: 50 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -746,8 +746,19 @@ var Component = (function (_super) {
746746
};
747747
Component.prototype.linkAll = function () {
748748
// Quick and dirty hack to suppres type error - refactor later.
749-
return this.state.linkAll.apply(this, arguments);
749+
var state = this.state;
750+
return state.linkAll.apply(state, arguments);
751+
};
752+
Component.prototype.linkPath = function (path) {
753+
return this.state.linkPath(path);
750754
};
755+
Object.defineProperty(Component.prototype, "links", {
756+
get: function () {
757+
return this.state._links;
758+
},
759+
enumerable: true,
760+
configurable: true
761+
});
751762
Component.define = function (protoProps, staticProps) {
752763
var BaseClass = __WEBPACK_IMPORTED_MODULE_1_type_r__["tools"].getBaseClass(this), staticsDefinition = __WEBPACK_IMPORTED_MODULE_1_type_r__["tools"].getChangedStatics(this, 'state', 'store', 'props', 'context', 'childContext', 'pureRender'), combinedDefinition = __WEBPACK_IMPORTED_MODULE_1_type_r__["tools"].assign(staticsDefinition, protoProps || {});
753764
var definition = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2__define__["c" /* default */])(combinedDefinition, this.prototype);
@@ -829,7 +840,8 @@ var CommonMixin = __WEBPACK_IMPORTED_MODULE_0_type_r__["tools"].assign({
829840
if (isRoot) {
830841
this.shouldComponentUpdate = returnFalse;
831842
}
832-
fun(this.props, this.state);
843+
var _a = this, state = _a.state, store = _a.store, withStore = store ? function (state) { return store.transaction(function () { return fun(state); }); } : fun;
844+
state ? state.transaction(withStore) : withStore(state);
833845
if (isRoot) {
834846
this.shouldComponentUpdate = shouldComponentUpdate;
835847
this.asyncUpdate();
@@ -1362,7 +1374,13 @@ var Link = (function () {
13621374
// <input { ...link.props } />
13631375
get: function () {
13641376
var _this = this;
1365-
return { value: this.value, onChange: function (e) { return _this.set(e.target.value); } };
1377+
return typeof this.value === 'boolean' ? {
1378+
checked: this.value,
1379+
onChange: function (e) { return _this.set(Boolean(e.target.checked)); }
1380+
} : {
1381+
value: this.value,
1382+
onChange: function (e) { return _this.set(e.target.value); }
1383+
};
13661384
},
13671385
enumerable: true,
13681386
configurable: true
@@ -1675,11 +1693,14 @@ module.exports = invariant;
16751693

16761694
var emptyFunction = __webpack_require__(21);
16771695
var invariant = __webpack_require__(22);
1696+
var ReactPropTypesSecret = __webpack_require__(24);
16781697

16791698
module.exports = function() {
1680-
// Important!
1681-
// Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.
1682-
function shim() {
1699+
function shim(props, propName, componentName, location, propFullName, secret) {
1700+
if (secret === ReactPropTypesSecret) {
1701+
// It is still safe when called from React.
1702+
return;
1703+
}
16831704
invariant(
16841705
false,
16851706
'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
@@ -1691,6 +1712,8 @@ module.exports = function() {
16911712
function getShim() {
16921713
return shim;
16931714
};
1715+
// Important!
1716+
// Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.
16941717
var ReactPropTypes = {
16951718
array: shim,
16961719
bool: shim,
@@ -1718,6 +1741,27 @@ module.exports = function() {
17181741
};
17191742

17201743

1744+
/***/ }),
1745+
/* 24 */
1746+
/***/ (function(module, exports, __webpack_require__) {
1747+
1748+
"use strict";
1749+
/**
1750+
* Copyright 2013-present, Facebook, Inc.
1751+
* All rights reserved.
1752+
*
1753+
* This source code is licensed under the BSD-style license found in the
1754+
* LICENSE file in the root directory of this source tree. An additional grant
1755+
* of patent rights can be found in the PATENTS file in the same directory.
1756+
*/
1757+
1758+
1759+
1760+
var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
1761+
1762+
module.exports = ReactPropTypesSecret;
1763+
1764+
17211765
/***/ })
17221766
/******/ ]);
17231767
});

dist/index.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"title": "NestedReact",
3-
"tagline": "React. Playing well with traditional MVC.",
3+
"tagline": "BackboneJS compatibility layer for the React-MVx",
44
"author": "Vlad Balin",
55
"image": "",
66
"ignore": {

lib/react-mvx/component.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ export declare class Component<P> extends React.Component<P, Record> {
2323
linkAll(...keys: string[]): {
2424
[key: string]: Link<any>;
2525
};
26+
linkPath(path: string): Link<any>;
27+
readonly links: any;
2628
static define(protoProps: any, staticProps: any): typeof Component;
2729
readonly state: Record;
2830
readonly store?: Store;

lib/react-mvx/component.js

Lines changed: 12 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/react-mvx/component.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/react-mvx/define/common.js

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/react-mvx/define/common.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/react-mvx/valuelink/link.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ export declare abstract class Link<T> {
1919
abstract set(x: T): void;
2020
onChange(handler: (x: T) => void): Link<T>;
2121
readonly props: {
22+
checked: (T & true) | (T & false);
23+
onChange: (e: any) => void;
24+
} | {
2225
value: T;
2326
onChange: (e: any) => void;
2427
};

0 commit comments

Comments
 (0)