@thoughtbot/superglue 0.40.0 → 0.50.0-beta1
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/README.md +3 -3
- package/components/Nav.js +0 -10
- package/index.js +1 -9
- package/package.json +4 -5
- package/utils/ujs.js +1 -2
- package/components/RailsTag.js +0 -71
package/README.md
CHANGED
|
@@ -60,7 +60,7 @@ A popular ask of SPAs is page-to-page navigation without reloading. This is
|
|
|
60
60
|
easily done with Superglue's own UJS attributes inspired by Turbolinks:
|
|
61
61
|
|
|
62
62
|
```jsx
|
|
63
|
-
<a href='/posts' data-
|
|
63
|
+
<a href='/posts' data-sg-visit={true} />
|
|
64
64
|
```
|
|
65
65
|
|
|
66
66
|
The above will request for `/posts` with an `accept` of `application/json`, and
|
|
@@ -70,8 +70,8 @@ component the response asks for, and `pushState` on history.
|
|
|
70
70
|
|
|
71
71
|
#### Partial updates
|
|
72
72
|
Some features rely on updating some parts of the existing page. In
|
|
73
|
-
addition to `data-
|
|
74
|
-
also provides `data-
|
|
73
|
+
addition to `data-sg-visit` and it's equivalent `this.props.visit`, Superglue
|
|
74
|
+
also provides `data-sg-remote` or `this.props.remote`, which you can use to
|
|
75
75
|
update parts of your page in async fashion without changing `window.history`.
|
|
76
76
|
|
|
77
77
|
Imagine having to implement search, where you enter some text, hit enter, and
|
package/components/Nav.js
CHANGED
|
@@ -9,8 +9,6 @@ var _utils = require("../utils");
|
|
|
9
9
|
|
|
10
10
|
var _actions = require("../actions");
|
|
11
11
|
|
|
12
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
-
|
|
14
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
15
13
|
|
|
16
14
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
@@ -257,13 +255,5 @@ var Nav = /*#__PURE__*/function (_React$Component) {
|
|
|
257
255
|
return Nav;
|
|
258
256
|
}(_react["default"].Component);
|
|
259
257
|
|
|
260
|
-
Nav.propTypes = {
|
|
261
|
-
store: _propTypes["default"].object,
|
|
262
|
-
history: _propTypes["default"].object,
|
|
263
|
-
mapping: _propTypes["default"].object,
|
|
264
|
-
visit: _propTypes["default"].func,
|
|
265
|
-
remote: _propTypes["default"].func,
|
|
266
|
-
initialPageKey: _propTypes["default"].string
|
|
267
|
-
};
|
|
268
258
|
var _default = Nav;
|
|
269
259
|
exports["default"] = _default;
|
package/index.js
CHANGED
|
@@ -34,8 +34,6 @@ var _history = require("history");
|
|
|
34
34
|
|
|
35
35
|
var _Nav = _interopRequireDefault(require("./components/Nav"));
|
|
36
36
|
|
|
37
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
38
|
-
|
|
39
37
|
var _react2 = require("./utils/react");
|
|
40
38
|
|
|
41
39
|
exports.mapStateToProps = _react2.mapStateToProps;
|
|
@@ -254,10 +252,4 @@ var ApplicationBase = /*#__PURE__*/function (_React$Component) {
|
|
|
254
252
|
return ApplicationBase;
|
|
255
253
|
}(_react["default"].Component);
|
|
256
254
|
|
|
257
|
-
exports.ApplicationBase = ApplicationBase;
|
|
258
|
-
ApplicationBase.propTypes = {
|
|
259
|
-
initialPage: _propTypes["default"].object,
|
|
260
|
-
baseUrl: _propTypes["default"].string,
|
|
261
|
-
path: _propTypes["default"].string,
|
|
262
|
-
appEl: _propTypes["default"].object
|
|
263
|
-
};
|
|
255
|
+
exports.ApplicationBase = ApplicationBase;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thoughtbot/superglue",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.50.0-beta1",
|
|
4
4
|
"description": "Use a vanilla Rails with React and Redux",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -27,7 +27,6 @@
|
|
|
27
27
|
"fetch-headers": "^2.0.0",
|
|
28
28
|
"fetch-mock": "^9.11.0",
|
|
29
29
|
"history": "^5.3.0",
|
|
30
|
-
"html-react-parser": "^1.2.6",
|
|
31
30
|
"jest": "^27.0.4",
|
|
32
31
|
"node-fetch": "^2.6.1",
|
|
33
32
|
"prettier": "^2.3.1",
|
|
@@ -40,15 +39,15 @@
|
|
|
40
39
|
"redux-thunk": "^2.3.0"
|
|
41
40
|
},
|
|
42
41
|
"peerDependencies": {
|
|
43
|
-
"html-react-parser": ">=1.2.6",
|
|
44
|
-
"react": ">=16",
|
|
45
|
-
"redux": ">=4.1",
|
|
46
42
|
"history": "^5.3.0",
|
|
43
|
+
"react": ">=16",
|
|
47
44
|
"react-redux": ">=7.2",
|
|
45
|
+
"redux": ">=4.1",
|
|
48
46
|
"redux-thunk": ">=2.3"
|
|
49
47
|
},
|
|
50
48
|
"dependencies": {
|
|
51
49
|
"abortcontroller-polyfill": "^1.7.3",
|
|
50
|
+
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
|
|
52
51
|
"url-parse": "^1.5.1"
|
|
53
52
|
}
|
|
54
53
|
}
|
package/utils/ujs.js
CHANGED
|
@@ -74,9 +74,8 @@ var HandlerBuilder = /*#__PURE__*/function () {
|
|
|
74
74
|
event.preventDefault();
|
|
75
75
|
var url = link.getAttribute('href');
|
|
76
76
|
url = (0, _url.withoutBusters)(url);
|
|
77
|
-
var method = link.getAttribute(this.attributePrefix + '-method') || 'GET';
|
|
78
77
|
this.visitOrRemote(link, url, {
|
|
79
|
-
method:
|
|
78
|
+
method: 'GET'
|
|
80
79
|
});
|
|
81
80
|
};
|
|
82
81
|
|
package/components/RailsTag.js
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
exports.__esModule = true;
|
|
4
|
-
exports["default"] = void 0;
|
|
5
|
-
|
|
6
|
-
var _react = _interopRequireDefault(require("react"));
|
|
7
|
-
|
|
8
|
-
var _htmlReactParser = _interopRequireWildcard(require("html-react-parser"));
|
|
9
|
-
|
|
10
|
-
var _attributesToProps = _interopRequireDefault(require("html-react-parser/lib/attributes-to-props"));
|
|
11
|
-
|
|
12
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
-
|
|
14
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
15
|
-
|
|
16
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
17
|
-
|
|
18
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
19
|
-
|
|
20
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
21
|
-
|
|
22
|
-
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
|
|
23
|
-
|
|
24
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
25
|
-
|
|
26
|
-
var RailsTag = /*#__PURE__*/function (_React$Component) {
|
|
27
|
-
_inheritsLoose(RailsTag, _React$Component);
|
|
28
|
-
|
|
29
|
-
function RailsTag(props) {
|
|
30
|
-
var _this;
|
|
31
|
-
|
|
32
|
-
_this = _React$Component.call(this, props) || this;
|
|
33
|
-
_this.replace = _this.replace.bind(_assertThisInitialized(_this));
|
|
34
|
-
return _this;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
var _proto = RailsTag.prototype;
|
|
38
|
-
|
|
39
|
-
_proto.shouldComponentUpdate = function shouldComponentUpdate(nextProps) {
|
|
40
|
-
return this.props.html !== nextProps.html;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
_proto.replace = function replace(domNode) {
|
|
44
|
-
var parent = domNode.parent,
|
|
45
|
-
type = domNode.type,
|
|
46
|
-
name = domNode.name,
|
|
47
|
-
attribs = domNode.attribs,
|
|
48
|
-
children = domNode.children;
|
|
49
|
-
|
|
50
|
-
if (!parent && type === 'tag') {
|
|
51
|
-
var nextProps = Object.assign({}, this.props, (0, _attributesToProps["default"])(attribs), {
|
|
52
|
-
children: (0, _htmlReactParser.domToReact)(children)
|
|
53
|
-
});
|
|
54
|
-
delete nextProps.html;
|
|
55
|
-
return /*#__PURE__*/_react["default"].createElement(name, nextProps);
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
_proto.render = function render() {
|
|
60
|
-
return (0, _htmlReactParser["default"])(this.props.html, {
|
|
61
|
-
replace: this.replace
|
|
62
|
-
});
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
return RailsTag;
|
|
66
|
-
}(_react["default"].Component);
|
|
67
|
-
|
|
68
|
-
exports["default"] = RailsTag;
|
|
69
|
-
RailsTag.propTypes = {
|
|
70
|
-
html: _propTypes["default"].string
|
|
71
|
-
};
|