Skip to content

Commit e969e3d

Browse files
committed
2.0.3
1 parent 7490ff0 commit e969e3d

File tree

3 files changed

+338
-1
lines changed

3 files changed

+338
-1
lines changed

dist/amd/can-react-component.js

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
/*can-react-component@2.0.2#can-react-component*/
2+
define('can-react-component', [
3+
'require',
4+
'exports',
5+
'module',
6+
'react',
7+
'can-namespace',
8+
'can-assign',
9+
'can-reflect',
10+
'can-symbol',
11+
'can-view-callbacks'
12+
], function (require, exports, module) {
13+
var React = require('react');
14+
var namespace = require('can-namespace');
15+
var assign = require('can-assign');
16+
var reflect = require('can-reflect');
17+
var canSymbol = require('can-symbol');
18+
var viewCallbacks = require('can-view-callbacks');
19+
var viewModelSymbol = canSymbol.for('can.viewModel');
20+
module.exports = namespace.reactComponent = function canReactComponent(displayName, CanComponent) {
21+
if (arguments.length === 1) {
22+
CanComponent = arguments[0];
23+
displayName = (CanComponent.shortName || 'CanComponent') + 'Wrapper';
24+
}
25+
const __renderComponent = viewCallbacks._tags[CanComponent.prototype.tag];
26+
viewCallbacks._tags[CanComponent.prototype.tag] = function renderComponent(el) {
27+
if (el.getAttribute('auto-mount') !== 'false') {
28+
__renderComponent.apply(this, arguments);
29+
}
30+
};
31+
function Wrapper() {
32+
React.Component.call(this);
33+
this.canComponent = null;
34+
this.createComponent = this.createComponent.bind(this);
35+
}
36+
Wrapper.displayName = displayName;
37+
Wrapper.prototype = Object.create(React.Component.prototype);
38+
assign(Wrapper.prototype, {
39+
constructor: Wrapper,
40+
createComponent: function (el) {
41+
if (this.canComponent) {
42+
this.canComponent = null;
43+
}
44+
if (el) {
45+
this.vm = el[viewModelSymbol];
46+
if (this.vm) {
47+
reflect.assign(this.vm, this.props);
48+
} else {
49+
this.canComponent = new CanComponent(el, { viewModel: this.props });
50+
this.vm = this.canComponent.viewModel;
51+
}
52+
}
53+
},
54+
componentDidUpdate: function () {
55+
this.vm && reflect.assign(this.vm, this.props);
56+
},
57+
render: function () {
58+
return React.createElement(CanComponent.prototype.tag, {
59+
ref: this.createComponent,
60+
'auto-mount': 'false'
61+
});
62+
}
63+
});
64+
Object.defineProperty(Wrapper.prototype, 'viewModel', {
65+
enumerable: false,
66+
configurable: true,
67+
get: function () {
68+
return this.vm;
69+
}
70+
});
71+
try {
72+
Object.defineProperty(Wrapper, 'name', {
73+
writable: false,
74+
enumerable: false,
75+
configurable: true,
76+
value: displayName
77+
});
78+
} catch (e) {
79+
}
80+
return Wrapper;
81+
};
82+
});

dist/global/can-react-component.js

Lines changed: 255 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,255 @@
1+
/*[process-shim]*/
2+
(function(global, env) {
3+
// jshint ignore:line
4+
if (typeof process === "undefined") {
5+
global.process = {
6+
argv: [],
7+
cwd: function() {
8+
return "";
9+
},
10+
browser: true,
11+
env: {
12+
NODE_ENV: env || "development"
13+
},
14+
version: "",
15+
platform:
16+
global.navigator &&
17+
global.navigator.userAgent &&
18+
/Windows/.test(global.navigator.userAgent)
19+
? "win"
20+
: ""
21+
};
22+
}
23+
})(
24+
typeof self == "object" && self.Object == Object
25+
? self
26+
: typeof process === "object" &&
27+
Object.prototype.toString.call(process) === "[object process]"
28+
? global
29+
: window,
30+
"development"
31+
);
32+
33+
/*[global-shim-start]*/
34+
(function(exports, global, doEval) {
35+
// jshint ignore:line
36+
var origDefine = global.define;
37+
38+
var get = function(name) {
39+
var parts = name.split("."),
40+
cur = global,
41+
i;
42+
for (i = 0; i < parts.length; i++) {
43+
if (!cur) {
44+
break;
45+
}
46+
cur = cur[parts[i]];
47+
}
48+
return cur;
49+
};
50+
var set = function(name, val) {
51+
var parts = name.split("."),
52+
cur = global,
53+
i,
54+
part,
55+
next;
56+
for (i = 0; i < parts.length - 1; i++) {
57+
part = parts[i];
58+
next = cur[part];
59+
if (!next) {
60+
next = cur[part] = {};
61+
}
62+
cur = next;
63+
}
64+
part = parts[parts.length - 1];
65+
cur[part] = val;
66+
};
67+
var useDefault = function(mod) {
68+
if (!mod || !mod.__esModule) return false;
69+
var esProps = { __esModule: true, default: true };
70+
for (var p in mod) {
71+
if (!esProps[p]) return false;
72+
}
73+
return true;
74+
};
75+
76+
var hasCjsDependencies = function(deps) {
77+
return (
78+
deps[0] === "require" && deps[1] === "exports" && deps[2] === "module"
79+
);
80+
};
81+
82+
var modules =
83+
(global.define && global.define.modules) ||
84+
(global._define && global._define.modules) ||
85+
{};
86+
var ourDefine = (global.define = function(moduleName, deps, callback) {
87+
var module;
88+
if (typeof deps === "function") {
89+
callback = deps;
90+
deps = [];
91+
}
92+
var args = [],
93+
i;
94+
for (i = 0; i < deps.length; i++) {
95+
args.push(
96+
exports[deps[i]]
97+
? get(exports[deps[i]])
98+
: modules[deps[i]] || get(deps[i])
99+
);
100+
}
101+
// CJS has no dependencies but 3 callback arguments
102+
if (hasCjsDependencies(deps) || (!deps.length && callback.length)) {
103+
module = { exports: {} };
104+
args[0] = function(name) {
105+
return exports[name] ? get(exports[name]) : modules[name];
106+
};
107+
args[1] = module.exports;
108+
args[2] = module;
109+
}
110+
// Babel uses the exports and module object.
111+
else if (!args[0] && deps[0] === "exports") {
112+
module = { exports: {} };
113+
args[0] = module.exports;
114+
if (deps[1] === "module") {
115+
args[1] = module;
116+
}
117+
} else if (!args[0] && deps[0] === "module") {
118+
args[0] = { id: moduleName };
119+
}
120+
121+
global.define = origDefine;
122+
var result = callback ? callback.apply(null, args) : undefined;
123+
global.define = ourDefine;
124+
125+
// Favor CJS module.exports over the return value
126+
result = module && module.exports ? module.exports : result;
127+
modules[moduleName] = result;
128+
129+
// Set global exports
130+
var globalExport = exports[moduleName];
131+
if (globalExport && !get(globalExport)) {
132+
if (useDefault(result)) {
133+
result = result["default"];
134+
}
135+
set(globalExport, result);
136+
}
137+
});
138+
global.define.orig = origDefine;
139+
global.define.modules = modules;
140+
global.define.amd = true;
141+
ourDefine("@loader", [], function() {
142+
// shim for @@global-helpers
143+
var noop = function() {};
144+
return {
145+
get: function() {
146+
return { prepareGlobal: noop, retrieveGlobal: noop };
147+
},
148+
global: global,
149+
__exec: function(__load) {
150+
doEval(__load.source, global);
151+
}
152+
};
153+
});
154+
})(
155+
{},
156+
typeof self == "object" && self.Object == Object
157+
? self
158+
: typeof process === "object" &&
159+
Object.prototype.toString.call(process) === "[object process]"
160+
? global
161+
: window,
162+
function(__$source__, __$global__) {
163+
// jshint ignore:line
164+
eval("(function() { " + __$source__ + " \n }).call(__$global__);");
165+
}
166+
);
167+
168+
/*can-react-component@2.0.2#can-react-component*/
169+
define('can-react-component', [
170+
'require',
171+
'exports',
172+
'module',
173+
'react',
174+
'can-namespace',
175+
'can-assign',
176+
'can-reflect',
177+
'can-symbol',
178+
'can-view-callbacks'
179+
], function (require, exports, module) {
180+
var React = require('react');
181+
var namespace = require('can-namespace');
182+
var assign = require('can-assign');
183+
var reflect = require('can-reflect');
184+
var canSymbol = require('can-symbol');
185+
var viewCallbacks = require('can-view-callbacks');
186+
var viewModelSymbol = canSymbol.for('can.viewModel');
187+
module.exports = namespace.reactComponent = function canReactComponent(displayName, CanComponent) {
188+
if (arguments.length === 1) {
189+
CanComponent = arguments[0];
190+
displayName = (CanComponent.shortName || 'CanComponent') + 'Wrapper';
191+
}
192+
const __renderComponent = viewCallbacks._tags[CanComponent.prototype.tag];
193+
viewCallbacks._tags[CanComponent.prototype.tag] = function renderComponent(el) {
194+
if (el.getAttribute('auto-mount') !== 'false') {
195+
__renderComponent.apply(this, arguments);
196+
}
197+
};
198+
function Wrapper() {
199+
React.Component.call(this);
200+
this.canComponent = null;
201+
this.createComponent = this.createComponent.bind(this);
202+
}
203+
Wrapper.displayName = displayName;
204+
Wrapper.prototype = Object.create(React.Component.prototype);
205+
assign(Wrapper.prototype, {
206+
constructor: Wrapper,
207+
createComponent: function (el) {
208+
if (this.canComponent) {
209+
this.canComponent = null;
210+
}
211+
if (el) {
212+
this.vm = el[viewModelSymbol];
213+
if (this.vm) {
214+
reflect.assign(this.vm, this.props);
215+
} else {
216+
this.canComponent = new CanComponent(el, { viewModel: this.props });
217+
this.vm = this.canComponent.viewModel;
218+
}
219+
}
220+
},
221+
componentDidUpdate: function () {
222+
this.vm && reflect.assign(this.vm, this.props);
223+
},
224+
render: function () {
225+
return React.createElement(CanComponent.prototype.tag, {
226+
ref: this.createComponent,
227+
'auto-mount': 'false'
228+
});
229+
}
230+
});
231+
Object.defineProperty(Wrapper.prototype, 'viewModel', {
232+
enumerable: false,
233+
configurable: true,
234+
get: function () {
235+
return this.vm;
236+
}
237+
});
238+
try {
239+
Object.defineProperty(Wrapper, 'name', {
240+
writable: false,
241+
enumerable: false,
242+
configurable: true,
243+
value: displayName
244+
});
245+
} catch (e) {
246+
}
247+
return Wrapper;
248+
};
249+
});
250+
/*[global-shim-end]*/
251+
(function(global) { // jshint ignore:line
252+
global._define = global.define;
253+
global.define = global.define.orig;
254+
}
255+
)(typeof self == "object" && self.Object == Object ? self : (typeof process === "object" && Object.prototype.toString.call(process) === "[object process]") ? global : window);

package-lock.json

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

0 commit comments

Comments
 (0)