react-rails 2.7.0.rc.0 → 2.7.0.rc.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -1
- data/lib/assets/javascripts/react_ujs.js +1 -568
- data/lib/assets/react-source/development/react-server.js +170 -9222
- data/lib/assets/react-source/development/react.js +181 -32465
- data/lib/assets/react-source/production/react-server.js +2 -22
- data/lib/assets/react-source/production/react.js +2 -33
- data/lib/react/rails/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 62aac1b130be2ccd36d0412fb3078560c38daccdb08dcb88fb85a55f0abe4e45
|
4
|
+
data.tar.gz: a047ab347feba6ed50cebab0b08e0b2f2e717f87e05ca9041eb8a47f8671fa06
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a581433841efb1b1fc11d11c928eb87c5d86e52837ce0076fe75fbdae37f5bf5943b4cdd935a94a1207f463cad7ab36edaa98dc6b6e5ee7897359da1fba07664
|
7
|
+
data.tar.gz: ae92fb8ae8d1a84204ef0cc6b61141032479bd6562f3658fdf44efbfda91dea8eac09528a7f3d58af4814050172a831abb87c101175774b1073dadc006933116
|
data/README.md
CHANGED
@@ -2,9 +2,12 @@
|
|
2
2
|
|
3
3
|
[![Gem](https://img.shields.io/gem/v/react-rails.svg?style=flat-square)](http://rubygems.org/gems/react-rails)
|
4
4
|
[![npm](https://img.shields.io/npm/v/react_ujs.svg?style=flat-square)](https://www.npmjs.com/package/react_ujs)
|
5
|
-
[![Ruby](https://github.com/reactjs/react-rails/actions/workflows/ruby.yml/badge.svg)](https://github.com/reactjs/react-rails/actions/workflows/ruby.yml)
|
5
|
+
[![Ruby](https://github.com/reactjs/react-rails/actions/workflows/ruby.yml/badge.svg)](https://github.com/reactjs/react-rails/actions/workflows/ruby.yml)
|
6
6
|
|
7
|
+
## News
|
8
|
+
v2.7.0.rc.0 is out on [Ruby Gems](https://rubygems.org/gems/react-rails/versions/2.7.0.rc.0) and [NPM](https://www.npmjs.com/package/react_ujs/v/2.7.0-rc.0). Please try it out!
|
7
9
|
|
10
|
+
## Summary
|
8
11
|
React-Rails is a flexible tool to use [React](http://facebook.github.io/react/) with Rails. The benefits:
|
9
12
|
* Automatically renders React server-side and client-side
|
10
13
|
* Supports Webpacker 4.x, 3.x, 2.x, 1.1+ or Shakapacker v6+
|
@@ -1,568 +1 @@
|
|
1
|
-
(function
|
2
|
-
if(typeof exports === 'object' && typeof module === 'object')
|
3
|
-
module.exports = factory(require("react-dom"), require("react"), require("react-dom/server"));
|
4
|
-
else if(typeof define === 'function' && define.amd)
|
5
|
-
define(["react-dom", "react", "react-dom/server"], factory);
|
6
|
-
else if(typeof exports === 'object')
|
7
|
-
exports["ReactRailsUJS"] = factory(require("react-dom"), require("react"), require("react-dom/server"));
|
8
|
-
else
|
9
|
-
root["ReactRailsUJS"] = factory(root["ReactDOM"], root["React"], root["ReactDOMServer"]);
|
10
|
-
})(this, function(__WEBPACK_EXTERNAL_MODULE_2__, __WEBPACK_EXTERNAL_MODULE_6__, __WEBPACK_EXTERNAL_MODULE_7__) {
|
11
|
-
return /******/ (function(modules) { // webpackBootstrap
|
12
|
-
/******/ // The module cache
|
13
|
-
/******/ var installedModules = {};
|
14
|
-
/******/
|
15
|
-
/******/ // The require function
|
16
|
-
/******/ function __webpack_require__(moduleId) {
|
17
|
-
/******/
|
18
|
-
/******/ // Check if module is in cache
|
19
|
-
/******/ if(installedModules[moduleId]) {
|
20
|
-
/******/ return installedModules[moduleId].exports;
|
21
|
-
/******/ }
|
22
|
-
/******/ // Create a new module (and put it into the cache)
|
23
|
-
/******/ var module = installedModules[moduleId] = {
|
24
|
-
/******/ i: moduleId,
|
25
|
-
/******/ l: false,
|
26
|
-
/******/ exports: {}
|
27
|
-
/******/ };
|
28
|
-
/******/
|
29
|
-
/******/ // Execute the module function
|
30
|
-
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
31
|
-
/******/
|
32
|
-
/******/ // Flag the module as loaded
|
33
|
-
/******/ module.l = true;
|
34
|
-
/******/
|
35
|
-
/******/ // Return the exports of the module
|
36
|
-
/******/ return module.exports;
|
37
|
-
/******/ }
|
38
|
-
/******/
|
39
|
-
/******/
|
40
|
-
/******/ // expose the modules object (__webpack_modules__)
|
41
|
-
/******/ __webpack_require__.m = modules;
|
42
|
-
/******/
|
43
|
-
/******/ // expose the module cache
|
44
|
-
/******/ __webpack_require__.c = installedModules;
|
45
|
-
/******/
|
46
|
-
/******/ // identity function for calling harmony imports with the correct context
|
47
|
-
/******/ __webpack_require__.i = function(value) { return value; };
|
48
|
-
/******/
|
49
|
-
/******/ // define getter function for harmony exports
|
50
|
-
/******/ __webpack_require__.d = function(exports, name, getter) {
|
51
|
-
/******/ if(!__webpack_require__.o(exports, name)) {
|
52
|
-
/******/ Object.defineProperty(exports, name, {
|
53
|
-
/******/ configurable: false,
|
54
|
-
/******/ enumerable: true,
|
55
|
-
/******/ get: getter
|
56
|
-
/******/ });
|
57
|
-
/******/ }
|
58
|
-
/******/ };
|
59
|
-
/******/
|
60
|
-
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
61
|
-
/******/ __webpack_require__.n = function(module) {
|
62
|
-
/******/ var getter = module && module.__esModule ?
|
63
|
-
/******/ function getDefault() { return module['default']; } :
|
64
|
-
/******/ function getModuleExports() { return module; };
|
65
|
-
/******/ __webpack_require__.d(getter, 'a', getter);
|
66
|
-
/******/ return getter;
|
67
|
-
/******/ };
|
68
|
-
/******/
|
69
|
-
/******/ // Object.prototype.hasOwnProperty.call
|
70
|
-
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
71
|
-
/******/
|
72
|
-
/******/ // __webpack_public_path__
|
73
|
-
/******/ __webpack_require__.p = "";
|
74
|
-
/******/
|
75
|
-
/******/ // Load entry module and return exports
|
76
|
-
/******/ return __webpack_require__(__webpack_require__.s = 8);
|
77
|
-
/******/ })
|
78
|
-
/************************************************************************/
|
79
|
-
/******/ ([
|
80
|
-
/* 0 */
|
81
|
-
/***/ (function(module, exports) {
|
82
|
-
|
83
|
-
// Assume className is simple and can be found at top-level (window).
|
84
|
-
// Fallback to eval to handle cases like 'My.React.ComponentName'.
|
85
|
-
// Also, try to gracefully import Babel 6 style default exports
|
86
|
-
var topLevel = typeof window === "undefined" ? this : window;
|
87
|
-
|
88
|
-
module.exports = function(className) {
|
89
|
-
var constructor;
|
90
|
-
// Try to access the class globally first
|
91
|
-
constructor = topLevel[className];
|
92
|
-
|
93
|
-
// If that didn't work, try eval
|
94
|
-
if (!constructor) {
|
95
|
-
constructor = eval(className);
|
96
|
-
}
|
97
|
-
|
98
|
-
// Lastly, if there is a default attribute try that
|
99
|
-
if (constructor && constructor['default']) {
|
100
|
-
constructor = constructor['default'];
|
101
|
-
}
|
102
|
-
|
103
|
-
return constructor;
|
104
|
-
}
|
105
|
-
|
106
|
-
|
107
|
-
/***/ }),
|
108
|
-
/* 1 */
|
109
|
-
/***/ (function(module, exports) {
|
110
|
-
|
111
|
-
// Load React components by requiring them from "components/", for example:
|
112
|
-
//
|
113
|
-
// - "pages/index" -> `require("components/pages/index")`
|
114
|
-
// - "pages/show.Header" -> `require("components/pages/show").Header`
|
115
|
-
// - "pages/show.Body.Content" -> `require("components/pages/show").Body.Content`
|
116
|
-
//
|
117
|
-
module.exports = function(reqctx) {
|
118
|
-
return function(className) {
|
119
|
-
var parts = className.split(".")
|
120
|
-
var filename = parts.shift()
|
121
|
-
var keys = parts
|
122
|
-
// Load the module:
|
123
|
-
var component = reqctx("./" + filename)
|
124
|
-
// Then access each key:
|
125
|
-
keys.forEach(function(k) {
|
126
|
-
component = component[k]
|
127
|
-
})
|
128
|
-
// support `export default`
|
129
|
-
if (component.__esModule) {
|
130
|
-
component = component["default"]
|
131
|
-
}
|
132
|
-
return component
|
133
|
-
}
|
134
|
-
}
|
135
|
-
|
136
|
-
|
137
|
-
/***/ }),
|
138
|
-
/* 2 */
|
139
|
-
/***/ (function(module, exports) {
|
140
|
-
|
141
|
-
module.exports = __WEBPACK_EXTERNAL_MODULE_2__;
|
142
|
-
|
143
|
-
/***/ }),
|
144
|
-
/* 3 */
|
145
|
-
/***/ (function(module, exports, __webpack_require__) {
|
146
|
-
|
147
|
-
var nativeEvents = __webpack_require__(9)
|
148
|
-
var pjaxEvents = __webpack_require__(10)
|
149
|
-
var turbolinksEvents = __webpack_require__(11)
|
150
|
-
var turbolinksClassicDeprecatedEvents = __webpack_require__(13)
|
151
|
-
var turbolinksClassicEvents = __webpack_require__(12)
|
152
|
-
|
153
|
-
// see what things are globally available
|
154
|
-
// and setup event handlers to those things
|
155
|
-
module.exports = function(ujs) {
|
156
|
-
if (ujs.handleEvent) {
|
157
|
-
// We're calling this a second time -- remove previous handlers
|
158
|
-
if (typeof Turbolinks !== "undefined" && typeof Turbolinks.EVENTS !== "undefined") {
|
159
|
-
turbolinksClassicEvents.teardown(ujs);
|
160
|
-
}
|
161
|
-
turbolinksEvents.teardown(ujs);
|
162
|
-
turbolinksClassicDeprecatedEvents.teardown(ujs);
|
163
|
-
pjaxEvents.teardown(ujs);
|
164
|
-
nativeEvents.teardown(ujs);
|
165
|
-
}
|
166
|
-
|
167
|
-
if ('addEventListener' in window) {
|
168
|
-
ujs.handleEvent = function(eventName, callback) {
|
169
|
-
document.addEventListener(eventName, callback);
|
170
|
-
};
|
171
|
-
ujs.removeEvent = function(eventName, callback) {
|
172
|
-
document.removeEventListener(eventName, callback);
|
173
|
-
};
|
174
|
-
} else {
|
175
|
-
ujs.handleEvent = function(eventName, callback) {
|
176
|
-
window.attachEvent(eventName, callback);
|
177
|
-
};
|
178
|
-
ujs.removeEvent = function(eventName, callback) {
|
179
|
-
window.detachEvent(eventName, callback);
|
180
|
-
};
|
181
|
-
}
|
182
|
-
|
183
|
-
// Detect which kind of events to set up:
|
184
|
-
if (typeof Turbolinks !== 'undefined' && Turbolinks.supported) {
|
185
|
-
if (typeof Turbolinks.EVENTS !== 'undefined') {
|
186
|
-
// Turbolinks.EVENTS is in classic version 2.4.0+
|
187
|
-
turbolinksClassicEvents.setup(ujs)
|
188
|
-
} else if (typeof Turbolinks.controller !== "undefined") {
|
189
|
-
// Turbolinks.controller is in version 5+
|
190
|
-
turbolinksEvents.setup(ujs);
|
191
|
-
} else {
|
192
|
-
turbolinksClassicDeprecatedEvents.setup(ujs);
|
193
|
-
}
|
194
|
-
} else if (typeof $ !== "undefined" && typeof $.pjax === 'function') {
|
195
|
-
pjaxEvents.setup(ujs);
|
196
|
-
} else {
|
197
|
-
nativeEvents.setup(ujs);
|
198
|
-
}
|
199
|
-
}
|
200
|
-
|
201
|
-
|
202
|
-
/***/ }),
|
203
|
-
/* 4 */
|
204
|
-
/***/ (function(module, exports, __webpack_require__) {
|
205
|
-
|
206
|
-
// Make a function which:
|
207
|
-
// - First tries to require the name
|
208
|
-
// - Then falls back to global lookup
|
209
|
-
var fromGlobal = __webpack_require__(0)
|
210
|
-
var fromRequireContext = __webpack_require__(1)
|
211
|
-
|
212
|
-
module.exports = function(reqctx) {
|
213
|
-
var fromCtx = fromRequireContext(reqctx)
|
214
|
-
return function(className) {
|
215
|
-
var component;
|
216
|
-
try {
|
217
|
-
// `require` will raise an error if this className isn't found:
|
218
|
-
component = fromCtx(className)
|
219
|
-
} catch (firstErr) {
|
220
|
-
// fallback to global:
|
221
|
-
try {
|
222
|
-
component = fromGlobal(className)
|
223
|
-
} catch (secondErr) {
|
224
|
-
console.error(firstErr)
|
225
|
-
console.error(secondErr)
|
226
|
-
}
|
227
|
-
}
|
228
|
-
return component
|
229
|
-
}
|
230
|
-
}
|
231
|
-
|
232
|
-
|
233
|
-
/***/ }),
|
234
|
-
/* 5 */
|
235
|
-
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
236
|
-
|
237
|
-
"use strict";
|
238
|
-
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
|
239
|
-
/* harmony export (immutable) */ __webpack_exports__["supportsHydration"] = supportsHydration;
|
240
|
-
/* harmony export (immutable) */ __webpack_exports__["reactHydrate"] = reactHydrate;
|
241
|
-
/* harmony export (immutable) */ __webpack_exports__["createReactRootLike"] = createReactRootLike;
|
242
|
-
const ReactDOM = __webpack_require__(2)
|
243
|
-
|
244
|
-
function supportsHydration() {
|
245
|
-
return typeof ReactDOM.hydrate === "function" || typeof ReactDOM.hydrateRoot === "function"
|
246
|
-
}
|
247
|
-
|
248
|
-
function reactHydrate(node, component) {
|
249
|
-
if (typeof ReactDOM.hydrateRoot === "function") {
|
250
|
-
return ReactDOM.hydrateRoot(node, component)
|
251
|
-
} else {
|
252
|
-
return ReactDOM.hydrate(component, node)
|
253
|
-
}
|
254
|
-
}
|
255
|
-
|
256
|
-
function createReactRootLike(node) {
|
257
|
-
return ReactDOM.createRoot ? ReactDOM.createRoot(node) : legacyReactRootLike(node)
|
258
|
-
}
|
259
|
-
|
260
|
-
function legacyReactRootLike(node) {
|
261
|
-
const root = {
|
262
|
-
render(component) {
|
263
|
-
return ReactDOM.render(component, node)
|
264
|
-
}
|
265
|
-
}
|
266
|
-
return root
|
267
|
-
}
|
268
|
-
|
269
|
-
|
270
|
-
/***/ }),
|
271
|
-
/* 6 */
|
272
|
-
/***/ (function(module, exports) {
|
273
|
-
|
274
|
-
module.exports = __WEBPACK_EXTERNAL_MODULE_6__;
|
275
|
-
|
276
|
-
/***/ }),
|
277
|
-
/* 7 */
|
278
|
-
/***/ (function(module, exports) {
|
279
|
-
|
280
|
-
module.exports = __WEBPACK_EXTERNAL_MODULE_7__;
|
281
|
-
|
282
|
-
/***/ }),
|
283
|
-
/* 8 */
|
284
|
-
/***/ (function(module, exports, __webpack_require__) {
|
285
|
-
|
286
|
-
var React = __webpack_require__(6)
|
287
|
-
var ReactDOM = __webpack_require__(2)
|
288
|
-
var ReactDOMServer = __webpack_require__(7)
|
289
|
-
|
290
|
-
var detectEvents = __webpack_require__(3)
|
291
|
-
var constructorFromGlobal = __webpack_require__(0)
|
292
|
-
var constructorFromRequireContext = __webpack_require__(1)
|
293
|
-
var constructorFromRequireContextWithGlobalFallback = __webpack_require__(4)
|
294
|
-
const { supportsHydration, reactHydrate, createReactRootLike } = __webpack_require__(5)
|
295
|
-
|
296
|
-
var ReactRailsUJS = {
|
297
|
-
// This attribute holds the name of component which should be mounted
|
298
|
-
// example: `data-react-class="MyApp.Items.EditForm"`
|
299
|
-
CLASS_NAME_ATTR: 'data-react-class',
|
300
|
-
|
301
|
-
// This attribute holds JSON stringified props for initializing the component
|
302
|
-
// example: `data-react-props="{\"item\": { \"id\": 1, \"name\": \"My Item\"} }"`
|
303
|
-
PROPS_ATTR: 'data-react-props',
|
304
|
-
|
305
|
-
// This attribute holds which method to use between: ReactDOM.hydrate, ReactDOM.render
|
306
|
-
RENDER_ATTR: 'data-hydrate',
|
307
|
-
|
308
|
-
// A unique identifier to identify a node
|
309
|
-
CACHE_ID_ATTR: "data-react-cache-id",
|
310
|
-
|
311
|
-
TURBOLINKS_PERMANENT_ATTR: "data-turbolinks-permanent",
|
312
|
-
|
313
|
-
// If jQuery is detected, save a reference to it for event handlers
|
314
|
-
jQuery: (typeof window !== 'undefined') && (typeof window.jQuery !== 'undefined') && window.jQuery,
|
315
|
-
|
316
|
-
components: {},
|
317
|
-
|
318
|
-
// helper method for the mount and unmount methods to find the
|
319
|
-
// `data-react-class` DOM elements
|
320
|
-
findDOMNodes: function(searchSelector) {
|
321
|
-
var classNameAttr = ReactRailsUJS.CLASS_NAME_ATTR
|
322
|
-
// we will use fully qualified paths as we do not bind the callbacks
|
323
|
-
var selector, parent;
|
324
|
-
|
325
|
-
switch (typeof searchSelector) {
|
326
|
-
case 'undefined':
|
327
|
-
selector = '[' + classNameAttr + ']';
|
328
|
-
parent = document;
|
329
|
-
break;
|
330
|
-
case 'object':
|
331
|
-
selector = '[' + classNameAttr + ']';
|
332
|
-
parent = searchSelector;
|
333
|
-
break;
|
334
|
-
case 'string':
|
335
|
-
selector = searchSelector + '[' + classNameAttr + '], ' +
|
336
|
-
searchSelector + ' [' + classNameAttr + ']';
|
337
|
-
parent = document;
|
338
|
-
break
|
339
|
-
default:
|
340
|
-
break;
|
341
|
-
}
|
342
|
-
|
343
|
-
if (ReactRailsUJS.jQuery) {
|
344
|
-
return ReactRailsUJS.jQuery(selector, parent);
|
345
|
-
} else {
|
346
|
-
return parent.querySelectorAll(selector);
|
347
|
-
}
|
348
|
-
},
|
349
|
-
|
350
|
-
// Get the constructor for a className (returns a React class)
|
351
|
-
// Override this function to lookup classes in a custom way,
|
352
|
-
// the default is ReactRailsUJS.ComponentGlobal
|
353
|
-
getConstructor: constructorFromGlobal,
|
354
|
-
|
355
|
-
// Available for customizing `getConstructor`
|
356
|
-
constructorFromGlobal: constructorFromGlobal,
|
357
|
-
constructorFromRequireContext: constructorFromRequireContext,
|
358
|
-
constructorFromRequireContextWithGlobalFallback: constructorFromRequireContextWithGlobalFallback,
|
359
|
-
|
360
|
-
// Given a Webpack `require.context`,
|
361
|
-
// try finding components with `require`,
|
362
|
-
// then falling back to global lookup.
|
363
|
-
useContext: function(requireContext) {
|
364
|
-
this.getConstructor = constructorFromRequireContextWithGlobalFallback(requireContext)
|
365
|
-
},
|
366
|
-
|
367
|
-
// Render `componentName` with `props` to a string,
|
368
|
-
// using the specified `renderFunction` from `react-dom/server`.
|
369
|
-
serverRender: function(renderFunction, componentName, props) {
|
370
|
-
var componentClass = this.getConstructor(componentName)
|
371
|
-
var element = React.createElement(componentClass, props)
|
372
|
-
return ReactDOMServer[renderFunction](element)
|
373
|
-
},
|
374
|
-
|
375
|
-
// Within `searchSelector`, find nodes which should have React components
|
376
|
-
// inside them, and mount them with their props.
|
377
|
-
mountComponents: function(searchSelector) {
|
378
|
-
var ujs = ReactRailsUJS
|
379
|
-
var nodes = ujs.findDOMNodes(searchSelector);
|
380
|
-
|
381
|
-
for (var i = 0; i < nodes.length; ++i) {
|
382
|
-
var node = nodes[i];
|
383
|
-
var className = node.getAttribute(ujs.CLASS_NAME_ATTR);
|
384
|
-
var constructor = ujs.getConstructor(className);
|
385
|
-
var propsJson = node.getAttribute(ujs.PROPS_ATTR);
|
386
|
-
var props = propsJson && JSON.parse(propsJson);
|
387
|
-
var hydrate = node.getAttribute(ujs.RENDER_ATTR);
|
388
|
-
var cacheId = node.getAttribute(ujs.CACHE_ID_ATTR);
|
389
|
-
var turbolinksPermanent = node.hasAttribute(ujs.TURBOLINKS_PERMANENT_ATTR);
|
390
|
-
|
391
|
-
if (!constructor) {
|
392
|
-
var message = "Cannot find component: '" + className + "'"
|
393
|
-
if (console && console.log) {
|
394
|
-
console.log("%c[react-rails] %c" + message + " for element", "font-weight: bold", "", node)
|
395
|
-
}
|
396
|
-
throw new Error(message + ". Make sure your component is available to render.")
|
397
|
-
} else {
|
398
|
-
var component = this.components[cacheId];
|
399
|
-
if(component === undefined) {
|
400
|
-
component = React.createElement(constructor, props);
|
401
|
-
if(turbolinksPermanent) {
|
402
|
-
this.components[cacheId] = component;
|
403
|
-
}
|
404
|
-
}
|
405
|
-
|
406
|
-
if (hydrate && supportsHydration()) {
|
407
|
-
component = reactHydrate(node, component);
|
408
|
-
} else {
|
409
|
-
const root = createReactRootLike(node)
|
410
|
-
component = root.render(component);
|
411
|
-
}
|
412
|
-
}
|
413
|
-
}
|
414
|
-
},
|
415
|
-
|
416
|
-
// Within `searchSelector`, find nodes which have React components
|
417
|
-
// inside them, and unmount those components.
|
418
|
-
unmountComponents: function(searchSelector) {
|
419
|
-
var nodes = ReactRailsUJS.findDOMNodes(searchSelector);
|
420
|
-
|
421
|
-
for (var i = 0; i < nodes.length; ++i) {
|
422
|
-
var node = nodes[i];
|
423
|
-
ReactDOM.unmountComponentAtNode(node);
|
424
|
-
}
|
425
|
-
},
|
426
|
-
|
427
|
-
// Check the global context for installed libraries
|
428
|
-
// and figure out which library to hook up to (pjax, Turbolinks, jQuery)
|
429
|
-
// This is called on load, but you can call it again if needed
|
430
|
-
// (It will unmount itself)
|
431
|
-
detectEvents: function() {
|
432
|
-
detectEvents(this)
|
433
|
-
},
|
434
|
-
|
435
|
-
}
|
436
|
-
|
437
|
-
// These stable references are so that handlers can be added and removed:
|
438
|
-
ReactRailsUJS.handleMount = function(e) {
|
439
|
-
var target = undefined;
|
440
|
-
if (e && e.target) {
|
441
|
-
target = e.target;
|
442
|
-
}
|
443
|
-
ReactRailsUJS.mountComponents(target);
|
444
|
-
}
|
445
|
-
ReactRailsUJS.handleUnmount = function(e) {
|
446
|
-
var target = undefined;
|
447
|
-
if (e && e.target) {
|
448
|
-
target = e.target;
|
449
|
-
}
|
450
|
-
ReactRailsUJS.unmountComponents(target);
|
451
|
-
}
|
452
|
-
|
453
|
-
|
454
|
-
if (typeof window !== "undefined") {
|
455
|
-
// Only setup events for browser (not server-rendering)
|
456
|
-
ReactRailsUJS.detectEvents()
|
457
|
-
}
|
458
|
-
|
459
|
-
// It's a bit of a no-no to populate the global namespace,
|
460
|
-
// but we really need it!
|
461
|
-
// We need access to this object for server rendering, and
|
462
|
-
// we can't do a dynamic `require`, so we'll grab it from here:
|
463
|
-
self.ReactRailsUJS = ReactRailsUJS
|
464
|
-
|
465
|
-
module.exports = ReactRailsUJS
|
466
|
-
|
467
|
-
|
468
|
-
/***/ }),
|
469
|
-
/* 9 */
|
470
|
-
/***/ (function(module, exports) {
|
471
|
-
|
472
|
-
module.exports = {
|
473
|
-
// Attach handlers to browser events to mount
|
474
|
-
// (There are no unmount handlers since the page is destroyed on navigation)
|
475
|
-
setup: function(ujs) {
|
476
|
-
if ('addEventListener' in window) {
|
477
|
-
ujs.handleEvent('DOMContentLoaded', ujs.handleMount);
|
478
|
-
} else {
|
479
|
-
// add support to IE8 without jQuery
|
480
|
-
ujs.handleEvent('onload', ujs.handleMount);
|
481
|
-
}
|
482
|
-
},
|
483
|
-
|
484
|
-
teardown: function(ujs) {
|
485
|
-
ujs.removeEvent('DOMContentLoaded', ujs.handleMount);
|
486
|
-
ujs.removeEvent('onload', ujs.handleMount);
|
487
|
-
}
|
488
|
-
}
|
489
|
-
|
490
|
-
|
491
|
-
/***/ }),
|
492
|
-
/* 10 */
|
493
|
-
/***/ (function(module, exports) {
|
494
|
-
|
495
|
-
module.exports = {
|
496
|
-
// pjax support
|
497
|
-
setup: function(ujs) {
|
498
|
-
ujs.handleEvent('ready', ujs.handleMount);
|
499
|
-
ujs.handleEvent('pjax:end', ujs.handleMount);
|
500
|
-
ujs.handleEvent('pjax:beforeReplace', ujs.handleUnmount);
|
501
|
-
},
|
502
|
-
|
503
|
-
teardown: function(ujs) {
|
504
|
-
ujs.removeEvent('ready', ujs.handleMount);
|
505
|
-
ujs.removeEvent('pjax:end', ujs.handleMount);
|
506
|
-
ujs.removeEvent('pjax:beforeReplace', ujs.handleUnmount);
|
507
|
-
},
|
508
|
-
}
|
509
|
-
|
510
|
-
|
511
|
-
/***/ }),
|
512
|
-
/* 11 */
|
513
|
-
/***/ (function(module, exports) {
|
514
|
-
|
515
|
-
module.exports = {
|
516
|
-
// Turbolinks 5+ got rid of named events (?!)
|
517
|
-
setup: function(ujs) {
|
518
|
-
ujs.handleEvent('turbolinks:load', ujs.handleMount);
|
519
|
-
},
|
520
|
-
|
521
|
-
teardown: function(ujs) {
|
522
|
-
ujs.removeEvent('turbolinks:load', ujs.handleMount);
|
523
|
-
},
|
524
|
-
}
|
525
|
-
|
526
|
-
|
527
|
-
/***/ }),
|
528
|
-
/* 12 */
|
529
|
-
/***/ (function(module, exports) {
|
530
|
-
|
531
|
-
module.exports = {
|
532
|
-
// Attach handlers to Turbolinks-Classic events
|
533
|
-
// for mounting and unmounting components
|
534
|
-
setup: function(ujs) {
|
535
|
-
ujs.handleEvent(Turbolinks.EVENTS.CHANGE, ujs.handleMount);
|
536
|
-
ujs.handleEvent(Turbolinks.EVENTS.BEFORE_UNLOAD, ujs.handleUnmount);
|
537
|
-
},
|
538
|
-
teardown: function(ujs) {
|
539
|
-
ujs.removeEvent(Turbolinks.EVENTS.CHANGE, ujs.handleMount);
|
540
|
-
ujs.removeEvent(Turbolinks.EVENTS.BEFORE_UNLOAD, ujs.handleUnmount);
|
541
|
-
}
|
542
|
-
}
|
543
|
-
|
544
|
-
|
545
|
-
/***/ }),
|
546
|
-
/* 13 */
|
547
|
-
/***/ (function(module, exports) {
|
548
|
-
|
549
|
-
module.exports = {
|
550
|
-
// Before Turbolinks 2.4.0, Turbolinks didn't
|
551
|
-
// have named events and didn't have a before-unload event.
|
552
|
-
// Also, it didn't work with the Turbolinks cache, see
|
553
|
-
// https://github.com/reactjs/react-rails/issues/87
|
554
|
-
setup: function(ujs) {
|
555
|
-
Turbolinks.pagesCached(0)
|
556
|
-
ujs.handleEvent('page:change', ujs.handleMount);
|
557
|
-
ujs.handleEvent('page:receive', ujs.handleUnmount);
|
558
|
-
},
|
559
|
-
teardown: function(ujs) {
|
560
|
-
ujs.removeEvent('page:change', ujs.handleMount);
|
561
|
-
ujs.removeEvent('page:receive', ujs.handleUnmount);
|
562
|
-
}
|
563
|
-
}
|
564
|
-
|
565
|
-
|
566
|
-
/***/ })
|
567
|
-
/******/ ]);
|
568
|
-
});
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("react-dom"),require("react-dom/server")):"function"==typeof define&&define.amd?define(["react","react-dom","react-dom/server"],t):"object"==typeof exports?exports.ReactRailsUJS=t(require("react"),require("react-dom"),require("react-dom/server")):e.ReactRailsUJS=t(e.React,e.ReactDOM,e.ReactDOMServer)}(self,((__WEBPACK_EXTERNAL_MODULE__787__,__WEBPACK_EXTERNAL_MODULE__156__,__WEBPACK_EXTERNAL_MODULE__997__)=>(()=>{var __webpack_modules__={10:(e,t,n)=>{var o=n(787),r=n(156),a=n(997),u=n(230),c=n(121),d=n(831),_=n(37),i=n(39);const{supportsHydration:s,reactHydrate:l,createReactRootLike:p}=n(244);var v={CLASS_NAME_ATTR:"data-react-class",PROPS_ATTR:"data-react-props",RENDER_ATTR:"data-hydrate",CACHE_ID_ATTR:"data-react-cache-id",TURBOLINKS_PERMANENT_ATTR:"data-turbolinks-permanent",jQuery:"undefined"!=typeof window&&void 0!==window.jQuery&&window.jQuery,components:{},findDOMNodes:function(e){var t,n,o=v.CLASS_NAME_ATTR;switch(typeof e){case"undefined":t="["+o+"]",n=document;break;case"object":t="["+o+"]",n=e;break;case"string":t=e+"["+o+"], "+e+" ["+o+"]",n=document}return v.jQuery?v.jQuery(t,n):n.querySelectorAll(t)},getConstructor:c,constructorFromGlobal:c,constructorFromRequireContext:d,constructorFromRequireContextWithGlobalFallback:_,useContext:function(e){this.getConstructor=_(e)},useContexts:function(e){this.getConstructor=i(e)},serverRender:function(e,t,n){var r=this.getConstructor(t),u=o.createElement(r,n);return a[e](u)},mountComponents:function(e){for(var t=v,n=t.findDOMNodes(e),r=0;r<n.length;++r){var a=n[r],u=a.getAttribute(t.CLASS_NAME_ATTR),c=t.getConstructor(u),d=a.getAttribute(t.PROPS_ATTR),_=d&&JSON.parse(d),i=a.getAttribute(t.RENDER_ATTR),f=a.getAttribute(t.CACHE_ID_ATTR),E=a.hasAttribute(t.TURBOLINKS_PERMANENT_ATTR);if(!c){var h="Cannot find component: '"+u+"'";throw console&&console.log&&console.log("%c[react-rails] %c"+h+" for element","font-weight: bold","",a),new Error(h+". Make sure your component is available to render.")}var m=this.components[f];void 0===m&&(m=o.createElement(c,_),E&&(this.components[f]=m)),m=i&&s()?l(a,m):p(a).render(m)}},unmountComponents:function(e){for(var t=v.findDOMNodes(e),n=0;n<t.length;++n){var o=t[n];r.unmountComponentAtNode(o)}},detectEvents:function(){u(this)},handleMount:function(e){var t=void 0;e&&e.target&&(t=e.target),v.mountComponents(t)},handleUnmount:function(e){var t=void 0;e&&e.target&&(t=e.target),v.unmountComponents(t)}};"undefined"!=typeof window&&v.detectEvents(),self.ReactRailsUJS=v,e.exports=v},230:(e,t,n)=>{var o=n(528),r=n(921),a=n(228),u=n(724),c=n(968);e.exports=function(e){e.handleEvent&&("undefined"!=typeof Turbolinks&&void 0!==Turbolinks.EVENTS&&c.teardown(e),a.teardown(e),u.teardown(e),r.teardown(e),o.teardown(e)),"addEventListener"in window?(e.handleEvent=function(e,t){document.addEventListener(e,t)},e.removeEvent=function(e,t){document.removeEventListener(e,t)}):(e.handleEvent=function(e,t){window.attachEvent(e,t)},e.removeEvent=function(e,t){window.detachEvent(e,t)}),"undefined"!=typeof Turbolinks&&Turbolinks.supported?void 0!==Turbolinks.EVENTS?c.setup(e):void 0!==Turbolinks.controller?a.setup(e):u.setup(e):"undefined"!=typeof $&&"function"==typeof $.pjax?r.setup(e):o.setup(e)}},528:e=>{e.exports={setup:function(e){"addEventListener"in window?e.handleEvent("DOMContentLoaded",e.handleMount):e.handleEvent("onload",e.handleMount)},teardown:function(e){e.removeEvent("DOMContentLoaded",e.handleMount),e.removeEvent("onload",e.handleMount)}}},921:e=>{e.exports={setup:function(e){e.handleEvent("ready",e.handleMount),e.handleEvent("pjax:end",e.handleMount),e.handleEvent("pjax:beforeReplace",e.handleUnmount)},teardown:function(e){e.removeEvent("ready",e.handleMount),e.removeEvent("pjax:end",e.handleMount),e.removeEvent("pjax:beforeReplace",e.handleUnmount)}}},228:e=>{e.exports={setup:function(e){e.handleEvent("turbolinks:load",e.handleMount)},teardown:function(e){e.removeEvent("turbolinks:load",e.handleMount)}}},968:e=>{e.exports={setup:function(e){e.handleEvent(Turbolinks.EVENTS.CHANGE,e.handleMount),e.handleEvent(Turbolinks.EVENTS.BEFORE_UNLOAD,e.handleUnmount)},teardown:function(e){e.removeEvent(Turbolinks.EVENTS.CHANGE,e.handleMount),e.removeEvent(Turbolinks.EVENTS.BEFORE_UNLOAD,e.handleUnmount)}}},724:e=>{e.exports={setup:function(e){Turbolinks.pagesCached(0),e.handleEvent("page:change",e.handleMount),e.handleEvent("page:receive",e.handleUnmount)},teardown:function(e){e.removeEvent("page:change",e.handleMount),e.removeEvent("page:receive",e.handleUnmount)}}},121:function(module){var topLevel="undefined"==typeof window?this:window;module.exports=function(className){var constructor;return constructor=topLevel[className],constructor||(constructor=eval(className)),constructor&&constructor.default&&(constructor=constructor.default),constructor}},831:e=>{e.exports=function(e){return function(t){var n=t.split("."),o=n.shift(),r=n,a=e("./"+o);return r.forEach((function(e){a=a[e]})),a.__esModule&&(a=a.default),a}}},37:(e,t,n)=>{var o=n(121),r=n(831);e.exports=function(e){var t=r(e);return function(e){var n;try{n=t(e)}catch(t){try{n=o(e)}catch(e){console.error(t),console.error(e)}}return n}}},39:(e,t,n)=>{var o=n(121),r=n(831);e.exports=function(e){var t=e.map((e=>r(e)));return function(e){var n;try{var r,a,u=0;do{r=t[u];try{n=r(e)}catch(e){a||(a=e)}u+=1}while(u<t.length);if(!n)throw a}catch(a){try{n=o(e)}catch(e){console.error(a),console.error(e)}}return n}}},244:(e,t,n)=>{"use strict";n.r(t),n.d(t,{createReactRootLike:()=>c,reactHydrate:()=>u,supportsHydration:()=>a});var o=n(156),r=n.n(o);function a(){return"function"==typeof r().hydrate||"function"==typeof r().hydrateRoot}function u(e,t){return"function"==typeof r().hydrateRoot?r().hydrateRoot(e,t):r().hydrate(t,e)}function c(e){return r().createRoot?r().createRoot(e):function(e){return{render:t=>r().render(t,e)}}(e)}},787:e=>{"use strict";e.exports=__WEBPACK_EXTERNAL_MODULE__787__},156:e=>{"use strict";e.exports=__WEBPACK_EXTERNAL_MODULE__156__},997:e=>{"use strict";e.exports=__WEBPACK_EXTERNAL_MODULE__997__}},__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var n=__webpack_module_cache__[e]={exports:{}};return __webpack_modules__[e].call(n.exports,n,n.exports,__webpack_require__),n.exports}__webpack_require__.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return __webpack_require__.d(t,{a:t}),t},__webpack_require__.d=(e,t)=>{for(var n in t)__webpack_require__.o(t,n)&&!__webpack_require__.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),__webpack_require__.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__=__webpack_require__(10);return __webpack_exports__})()));
|