@quintype/components 3.4.7-test-version.0 → 3.5.1-csv-table.1
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/cjs/index.js
CHANGED
|
@@ -1055,6 +1055,21 @@ function _isNativeReflectConstruct$l() { if (typeof Reflect === "undefined" || !
|
|
|
1055
1055
|
* onItemFocus={(item) => console.log(`Story In View: ${item.story.headline}`)}
|
|
1056
1056
|
* doNotChangeUrl={true} />
|
|
1057
1057
|
* ```
|
|
1058
|
+
*
|
|
1059
|
+
* #### Configuring the the url to change
|
|
1060
|
+
* When a story is focussed, the url is changed to the original slug of the story by default. To configure this, pass a prop called changeUrlTo as a function which returns the desired url.
|
|
1061
|
+
* This is typically used when you want to change the url but not to the original slug.
|
|
1062
|
+
*
|
|
1063
|
+
* Example:
|
|
1064
|
+
* ```javascript
|
|
1065
|
+
* <InfiniteStoryBase {...props}
|
|
1066
|
+
* render={StoryPageBase}
|
|
1067
|
+
* loadItems={storyPageLoadItems}
|
|
1068
|
+
* onItemFocus={(item) => console.log(`Story In View: ${item.story.headline}`)}
|
|
1069
|
+
changeUrlTo={(item) => item.currentPath || props.currentPath}
|
|
1070
|
+
* doNotChangeUrl={true} />
|
|
1071
|
+
* ```
|
|
1072
|
+
*
|
|
1058
1073
|
* @component
|
|
1059
1074
|
* @category Story Page
|
|
1060
1075
|
*/
|
|
@@ -1095,7 +1110,8 @@ var InfiniteStoryBase = /*#__PURE__*/function (_React$Component) {
|
|
|
1095
1110
|
var storyPath = item.story.url ? new URL(item.story.url).pathname : "/" + item.story.slug;
|
|
1096
1111
|
var metaTitle = get__default["default"](item, ['story', 'seo', 'meta-title'], item.story.headline);
|
|
1097
1112
|
var title = get__default["default"](item, ["customSeo", "title"], metaTitle);
|
|
1098
|
-
|
|
1113
|
+
var path = this.props.changeUrlTo ? this.props.changeUrlTo(item) : storyPath;
|
|
1114
|
+
global.app.maybeSetUrl(path, title);
|
|
1099
1115
|
}
|
|
1100
1116
|
|
|
1101
1117
|
this.props.onItemFocus && this.props.onItemFocus(item, index);
|
|
@@ -3102,9 +3118,10 @@ function _createSuper$8(Derived) { var hasNativeReflectConstruct = _isNativeRefl
|
|
|
3102
3118
|
|
|
3103
3119
|
function _isNativeReflectConstruct$8() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
3104
3120
|
|
|
3105
|
-
function TableHeader(
|
|
3121
|
+
function TableHeader() {
|
|
3122
|
+
var columns = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
3106
3123
|
return /*#__PURE__*/React__default["default"].createElement("thead", null, /*#__PURE__*/React__default["default"].createElement("tr", null, columns.map(function (col) {
|
|
3107
|
-
return /*#__PURE__*/React__default["default"].createElement("th", null, col
|
|
3124
|
+
return /*#__PURE__*/React__default["default"].createElement("th", null, col);
|
|
3108
3125
|
})));
|
|
3109
3126
|
}
|
|
3110
3127
|
|
|
@@ -3116,8 +3133,8 @@ function TableView(_ref) {
|
|
|
3116
3133
|
return /*#__PURE__*/React__default["default"].createElement("table", {
|
|
3117
3134
|
className: className
|
|
3118
3135
|
}, hasHeader && TableHeader(columns), /*#__PURE__*/React__default["default"].createElement("tbody", null, data.map(function (row) {
|
|
3119
|
-
return /*#__PURE__*/React__default["default"].createElement("tr", null,
|
|
3120
|
-
return /*#__PURE__*/React__default["default"].createElement("td", null,
|
|
3136
|
+
return /*#__PURE__*/React__default["default"].createElement("tr", null, row.map(function (item) {
|
|
3137
|
+
return /*#__PURE__*/React__default["default"].createElement("td", null, item);
|
|
3121
3138
|
}));
|
|
3122
3139
|
})));
|
|
3123
3140
|
}
|
|
@@ -3148,7 +3165,8 @@ var Table = /*#__PURE__*/function (_React$Component) {
|
|
|
3148
3165
|
'papaparse')); }).then(function (_ref2) {
|
|
3149
3166
|
var parse = _ref2.parse;
|
|
3150
3167
|
parse(content, {
|
|
3151
|
-
header:
|
|
3168
|
+
header: false,
|
|
3169
|
+
// with header true, the order of columns in table is not guaranteed, so we will handle the case
|
|
3152
3170
|
complete: function complete(results) {
|
|
3153
3171
|
return _this2._isMounted && _this2.setState({
|
|
3154
3172
|
tableData: results.data
|
|
@@ -3178,25 +3196,19 @@ var Table = /*#__PURE__*/function (_React$Component) {
|
|
|
3178
3196
|
}, {
|
|
3179
3197
|
key: "render",
|
|
3180
3198
|
value: function render() {
|
|
3181
|
-
var _this3 = this;
|
|
3182
|
-
|
|
3183
3199
|
if (!this.state.tableData.length > 0) {
|
|
3184
3200
|
return null;
|
|
3185
3201
|
}
|
|
3186
3202
|
|
|
3187
|
-
var
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
display: "none"
|
|
3193
|
-
} : {}
|
|
3194
|
-
};
|
|
3195
|
-
});
|
|
3203
|
+
var _ref3 = this.props.hasHeader ? [this.state.tableData[0], this.state.tableData.slice(1)] : [[], this.state.tableData],
|
|
3204
|
+
_ref4 = _slicedToArray__default["default"](_ref3, 2),
|
|
3205
|
+
columns = _ref4[0],
|
|
3206
|
+
tableData = _ref4[1];
|
|
3207
|
+
|
|
3196
3208
|
var className = "story-element-table-".concat(this.props.id);
|
|
3197
3209
|
return /*#__PURE__*/React__default["default"].createElement(this.props.tableComponent || TableView, {
|
|
3198
3210
|
hasHeader: this.props.hasHeader,
|
|
3199
|
-
data:
|
|
3211
|
+
data: tableData,
|
|
3200
3212
|
columns: columns,
|
|
3201
3213
|
showPageSizeOptions: false,
|
|
3202
3214
|
showPageJump: false,
|
|
@@ -56,6 +56,21 @@ import { removeDuplicateStories } from '../utils';
|
|
|
56
56
|
* onItemFocus={(item) => console.log(`Story In View: ${item.story.headline}`)}
|
|
57
57
|
* doNotChangeUrl={true} />
|
|
58
58
|
* ```
|
|
59
|
+
*
|
|
60
|
+
* #### Configuring the the url to change
|
|
61
|
+
* When a story is focussed, the url is changed to the original slug of the story by default. To configure this, pass a prop called changeUrlTo as a function which returns the desired url.
|
|
62
|
+
* This is typically used when you want to change the url but not to the original slug.
|
|
63
|
+
*
|
|
64
|
+
* Example:
|
|
65
|
+
* ```javascript
|
|
66
|
+
* <InfiniteStoryBase {...props}
|
|
67
|
+
* render={StoryPageBase}
|
|
68
|
+
* loadItems={storyPageLoadItems}
|
|
69
|
+
* onItemFocus={(item) => console.log(`Story In View: ${item.story.headline}`)}
|
|
70
|
+
changeUrlTo={(item) => item.currentPath || props.currentPath}
|
|
71
|
+
* doNotChangeUrl={true} />
|
|
72
|
+
* ```
|
|
73
|
+
*
|
|
59
74
|
* @component
|
|
60
75
|
* @category Story Page
|
|
61
76
|
*/
|
|
@@ -96,7 +111,8 @@ export var InfiniteStoryBase = /*#__PURE__*/function (_React$Component) {
|
|
|
96
111
|
var storyPath = item.story.url ? new URL(item.story.url).pathname : "/" + item.story.slug;
|
|
97
112
|
var metaTitle = get(item, ['story', 'seo', 'meta-title'], item.story.headline);
|
|
98
113
|
var title = get(item, ["customSeo", "title"], metaTitle);
|
|
99
|
-
|
|
114
|
+
var path = this.props.changeUrlTo ? this.props.changeUrlTo(item) : storyPath;
|
|
115
|
+
global.app.maybeSetUrl(path, title);
|
|
100
116
|
}
|
|
101
117
|
|
|
102
118
|
this.props.onItemFocus && this.props.onItemFocus(item, index);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
1
2
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
3
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
4
|
import _inherits from "@babel/runtime/helpers/inherits";
|
|
@@ -10,9 +11,10 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
10
11
|
|
|
11
12
|
import React from "react";
|
|
12
13
|
|
|
13
|
-
function TableHeader(
|
|
14
|
+
function TableHeader() {
|
|
15
|
+
var columns = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
14
16
|
return /*#__PURE__*/React.createElement("thead", null, /*#__PURE__*/React.createElement("tr", null, columns.map(function (col) {
|
|
15
|
-
return /*#__PURE__*/React.createElement("th", null, col
|
|
17
|
+
return /*#__PURE__*/React.createElement("th", null, col);
|
|
16
18
|
})));
|
|
17
19
|
}
|
|
18
20
|
|
|
@@ -24,8 +26,8 @@ export function TableView(_ref) {
|
|
|
24
26
|
return /*#__PURE__*/React.createElement("table", {
|
|
25
27
|
className: className
|
|
26
28
|
}, hasHeader && TableHeader(columns), /*#__PURE__*/React.createElement("tbody", null, data.map(function (row) {
|
|
27
|
-
return /*#__PURE__*/React.createElement("tr", null,
|
|
28
|
-
return /*#__PURE__*/React.createElement("td", null,
|
|
29
|
+
return /*#__PURE__*/React.createElement("tr", null, row.map(function (item) {
|
|
30
|
+
return /*#__PURE__*/React.createElement("td", null, item);
|
|
29
31
|
}));
|
|
30
32
|
})));
|
|
31
33
|
}
|
|
@@ -56,7 +58,8 @@ export var Table = /*#__PURE__*/function (_React$Component) {
|
|
|
56
58
|
"papaparse").then(function (_ref2) {
|
|
57
59
|
var parse = _ref2.parse;
|
|
58
60
|
parse(content, {
|
|
59
|
-
header:
|
|
61
|
+
header: false,
|
|
62
|
+
// with header true, the order of columns in table is not guaranteed, so we will handle the case
|
|
60
63
|
complete: function complete(results) {
|
|
61
64
|
return _this2._isMounted && _this2.setState({
|
|
62
65
|
tableData: results.data
|
|
@@ -86,25 +89,19 @@ export var Table = /*#__PURE__*/function (_React$Component) {
|
|
|
86
89
|
}, {
|
|
87
90
|
key: "render",
|
|
88
91
|
value: function render() {
|
|
89
|
-
var _this3 = this;
|
|
90
|
-
|
|
91
92
|
if (!this.state.tableData.length > 0) {
|
|
92
93
|
return null;
|
|
93
94
|
}
|
|
94
95
|
|
|
95
|
-
var
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
display: "none"
|
|
101
|
-
} : {}
|
|
102
|
-
};
|
|
103
|
-
});
|
|
96
|
+
var _ref3 = this.props.hasHeader ? [this.state.tableData[0], this.state.tableData.slice(1)] : [[], this.state.tableData],
|
|
97
|
+
_ref4 = _slicedToArray(_ref3, 2),
|
|
98
|
+
columns = _ref4[0],
|
|
99
|
+
tableData = _ref4[1];
|
|
100
|
+
|
|
104
101
|
var className = "story-element-table-".concat(this.props.id);
|
|
105
102
|
return /*#__PURE__*/React.createElement(this.props.tableComponent || TableView, {
|
|
106
103
|
hasHeader: this.props.hasHeader,
|
|
107
|
-
data:
|
|
104
|
+
data: tableData,
|
|
108
105
|
columns: columns,
|
|
109
106
|
showPageSizeOptions: false,
|
|
110
107
|
showPageJump: false,
|