@stokr/components-library 2.1.4 → 2.1.6
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/components/AdminDashboard/Table/ReactTable.js +10 -1
- package/dist/components/AdminDashboard/Table/ReactTable.stories.js +74 -0
- package/dist/components/ChartLegend/ChartLegend.js +10 -2
- package/dist/components/ChartLegend/ChartLegend.stories.js +3 -0
- package/dist/components/ChartLegend/ChartLegend.styles.js +18 -4
- package/package.json +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
@@ -15,6 +16,11 @@ var _Card = require("../../Card/Card.styles");
|
|
|
15
16
|
var _InputWithButton = _interopRequireDefault(require("../../Input/InputWithButton"));
|
|
16
17
|
var _Button = _interopRequireDefault(require("../../Button/Button.styles"));
|
|
17
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
20
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
21
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
22
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
23
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
18
24
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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); }
|
|
19
25
|
//This components is used only to memoize the values before we sent them to the react-table
|
|
20
26
|
var ReactTableWrapper = function ReactTableWrapper(props) {
|
|
@@ -76,6 +82,7 @@ function ReactTable(props) {
|
|
|
76
82
|
noPagination = props.noPagination,
|
|
77
83
|
withSubTable = props.withSubTable,
|
|
78
84
|
isSubTable = props.isSubTable,
|
|
85
|
+
customTdStyles = props.customTdStyles,
|
|
79
86
|
calculateSubData = props.calculateSubData;
|
|
80
87
|
|
|
81
88
|
// Use the state and functions returned from useTable to build UI
|
|
@@ -109,8 +116,10 @@ function ReactTable(props) {
|
|
|
109
116
|
})), /*#__PURE__*/_react.default.createElement("tbody", getTableBodyProps(), page.map(function (row, i) {
|
|
110
117
|
prepareRow(row);
|
|
111
118
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_Table.StyledReactTable.Tr, row.getRowProps(), row.cells.map(function (cell) {
|
|
119
|
+
var cellStyles = customTdStyles ? customTdStyles(i, row.original) : {};
|
|
112
120
|
return /*#__PURE__*/_react.default.createElement(_Table.StyledReactTable.Td, _extends({}, cell.row.getToggleRowExpandedProps(), cell.getCellProps({
|
|
113
|
-
className: cell.column.collapse ? 'collapse' : ''
|
|
121
|
+
className: cell.column.collapse ? 'collapse' : '',
|
|
122
|
+
style: _objectSpread({}, cellStyles)
|
|
114
123
|
}), {
|
|
115
124
|
blue: blue
|
|
116
125
|
}), cell.render('Cell'));
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.WithCustomStyling = exports.Default = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _ReactTable = require("./ReactTable");
|
|
9
|
+
var _global = _interopRequireDefault(require("../../../styles/global"));
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
var _default = {
|
|
12
|
+
title: 'Components Library/React table',
|
|
13
|
+
component: _ReactTable.ReactTable
|
|
14
|
+
}; // Sample columns and data for demonstration
|
|
15
|
+
exports.default = _default;
|
|
16
|
+
var columns = [{
|
|
17
|
+
Header: 'ID',
|
|
18
|
+
accessor: 'id' // accessor is the "key" in the data
|
|
19
|
+
}, {
|
|
20
|
+
Header: 'Name',
|
|
21
|
+
accessor: 'name'
|
|
22
|
+
}, {
|
|
23
|
+
Header: 'Status',
|
|
24
|
+
accessor: 'status'
|
|
25
|
+
}];
|
|
26
|
+
var data = [{
|
|
27
|
+
id: 1,
|
|
28
|
+
name: 'Alice',
|
|
29
|
+
status: 'Active'
|
|
30
|
+
}, {
|
|
31
|
+
id: 2,
|
|
32
|
+
name: 'Bob',
|
|
33
|
+
status: 'Inactive'
|
|
34
|
+
}, {
|
|
35
|
+
id: 3,
|
|
36
|
+
name: 'Carol',
|
|
37
|
+
status: 'Active'
|
|
38
|
+
}];
|
|
39
|
+
|
|
40
|
+
// Custom styling function
|
|
41
|
+
var customTdStyles = function customTdStyles(index, row) {
|
|
42
|
+
if (index === 0) {
|
|
43
|
+
return {
|
|
44
|
+
backgroundColor: 'lightblue',
|
|
45
|
+
fontWeight: 'bold',
|
|
46
|
+
paddingBottom: 0
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
if (row.status === 'Inactive') {
|
|
50
|
+
return {
|
|
51
|
+
backgroundColor: 'lightgray'
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
return {}; // default style
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
var Template = function Template(args) {
|
|
58
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_global.default, null), /*#__PURE__*/_react.default.createElement(_ReactTable.ReactTable, args));
|
|
59
|
+
};
|
|
60
|
+
var Default = function Default() {
|
|
61
|
+
return /*#__PURE__*/_react.default.createElement(Template, {
|
|
62
|
+
columns: columns,
|
|
63
|
+
data: data
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
exports.Default = Default;
|
|
67
|
+
var WithCustomStyling = function WithCustomStyling() {
|
|
68
|
+
return /*#__PURE__*/_react.default.createElement(Template, {
|
|
69
|
+
columns: columns,
|
|
70
|
+
data: data,
|
|
71
|
+
customTdStyles: customTdStyles
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
exports.WithCustomStyling = WithCustomStyling;
|
|
@@ -41,7 +41,11 @@ var ChartLegend = function ChartLegend(props) {
|
|
|
41
41
|
}
|
|
42
42
|
}, /*#__PURE__*/_react.default.createElement(_ChartLegend.ColorLabel, {
|
|
43
43
|
itemColor: item.color
|
|
44
|
-
}), /*#__PURE__*/_react.default.createElement(_ChartLegend.NameCol, null, /*#__PURE__*/_react.default.createElement(_ChartLegend.LargeText, null, item.name), /*#__PURE__*/_react.default.createElement(_ChartLegend.SmallText, null, item.subname)), /*#__PURE__*/_react.default.createElement(_ChartLegend.
|
|
44
|
+
}), /*#__PURE__*/_react.default.createElement(_ChartLegend.NameCol, null, /*#__PURE__*/_react.default.createElement(_ChartLegend.LargeText, null, item.name), /*#__PURE__*/_react.default.createElement(_ChartLegend.SmallText, null, item.subname)), /*#__PURE__*/_react.default.createElement(_ChartLegend.NameCol, null, /*#__PURE__*/_react.default.createElement(_ChartLegend.LargeText, null, item.value), /*#__PURE__*/_react.default.createElement(_ChartLegend.SmallText, null, item.info)), /*#__PURE__*/_react.default.createElement(_ChartLegend.MarketDataCol, {
|
|
45
|
+
isPositive: item.isPositive
|
|
46
|
+
}, /*#__PURE__*/_react.default.createElement(_ChartLegend.LargeText, {
|
|
47
|
+
isPositive: item.isPositive
|
|
48
|
+
}, item.marketValue), /*#__PURE__*/_react.default.createElement(_ChartLegend.SmallText, null, item.marketInfo)), item.details && /*#__PURE__*/_react.default.createElement(_ChartLegend.Arrow, {
|
|
45
49
|
isOpened: activeItems[itemKey]
|
|
46
50
|
})), item.details && /*#__PURE__*/_react.default.createElement(_reactCollapse.Collapse, {
|
|
47
51
|
isOpened: activeItems[itemKey]
|
|
@@ -55,7 +59,11 @@ ChartLegend.propTypes = {
|
|
|
55
59
|
name: _propTypes.default.string,
|
|
56
60
|
color: _propTypes.default.string,
|
|
57
61
|
subname: _propTypes.default.string,
|
|
58
|
-
info: _propTypes.default.string
|
|
62
|
+
info: _propTypes.default.string,
|
|
63
|
+
details: _propTypes.default.any,
|
|
64
|
+
isPositive: _propTypes.default.bool,
|
|
65
|
+
marketValue: _propTypes.default.string,
|
|
66
|
+
marketInfo: _propTypes.default.string
|
|
59
67
|
})).isRequired
|
|
60
68
|
};
|
|
61
69
|
var _default = ChartLegend;
|
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.ValueCol = exports.SmallText = exports.NameCol = exports.LargeText = exports.Items = exports.Item = exports.Head = exports.ColorLabel = exports.Body = exports.Arrow = void 0;
|
|
6
|
+
exports.ValueCol = exports.SmallText = exports.NameCol = exports.MarketDataCol = exports.LargeText = exports.Items = exports.Item = exports.Head = exports.ColorLabel = exports.Body = exports.Arrow = void 0;
|
|
7
7
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
8
|
+
var _theme = _interopRequireDefault(require("../../styles/theme"));
|
|
8
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
10
|
var Items = _styledComponents.default.div.withConfig({
|
|
10
11
|
displayName: "ChartLegendstyles__Items",
|
|
@@ -36,7 +37,7 @@ exports.ColorLabel = ColorLabel;
|
|
|
36
37
|
var NameCol = _styledComponents.default.div.withConfig({
|
|
37
38
|
displayName: "ChartLegendstyles__NameCol",
|
|
38
39
|
componentId: "sc-gh1vwu-5"
|
|
39
|
-
})(["width:
|
|
40
|
+
})(["width:40%;display:inline-block;vertical-align:top;"]);
|
|
40
41
|
exports.NameCol = NameCol;
|
|
41
42
|
var ValueCol = _styledComponents.default.div.withConfig({
|
|
42
43
|
displayName: "ChartLegendstyles__ValueCol",
|
|
@@ -46,18 +47,31 @@ exports.ValueCol = ValueCol;
|
|
|
46
47
|
var LargeText = _styledComponents.default.div.withConfig({
|
|
47
48
|
displayName: "ChartLegendstyles__LargeText",
|
|
48
49
|
componentId: "sc-gh1vwu-7"
|
|
49
|
-
})(["font-weight:300;font-size:22px;line-height:28px;"])
|
|
50
|
+
})(["font-weight:300;font-size:22px;line-height:28px;", " ", ""], function (props) {
|
|
51
|
+
return props.isPositive && "\n color: ".concat(_theme.default.cProgressDone, ";\n ");
|
|
52
|
+
}, function (props) {
|
|
53
|
+
return props.isPositive === false && "\n color: ".concat(_theme.default.cWarning, ";\n ");
|
|
54
|
+
});
|
|
50
55
|
exports.LargeText = LargeText;
|
|
51
56
|
var SmallText = _styledComponents.default.div.withConfig({
|
|
52
57
|
displayName: "ChartLegendstyles__SmallText",
|
|
53
58
|
componentId: "sc-gh1vwu-8"
|
|
54
59
|
})(["font-size:11px;line-height:12px;margin-top:4px;font-style:italic;"]);
|
|
55
60
|
exports.SmallText = SmallText;
|
|
61
|
+
var MarketDataCol = _styledComponents.default.div.withConfig({
|
|
62
|
+
displayName: "ChartLegendstyles__MarketDataCol",
|
|
63
|
+
componentId: "sc-gh1vwu-9"
|
|
64
|
+
})(["width:20%;display:inline-block;vertical-align:top;position:relative;", "{position:relative;left:-20px;}&::before{display:block;position:absolute;content:'';top:30%;left:-20px;width:0;height:0;border-left:5px solid transparent;border-right:5px solid transparent;", " ", "}"], SmallText, function (props) {
|
|
65
|
+
return props.isPositive && "\n border-bottom: 7px solid\n ".concat(_theme.default.cProgressDone, ";\n ");
|
|
66
|
+
}, function (props) {
|
|
67
|
+
return props.isPositive === false && "\n border-top: 7px solid\n ".concat(_theme.default.cWarning, ";\n ");
|
|
68
|
+
});
|
|
69
|
+
exports.MarketDataCol = MarketDataCol;
|
|
56
70
|
var Arrow = _styledComponents.default.i.attrs({
|
|
57
71
|
className: 'ion ion-ios-arrow-down'
|
|
58
72
|
}).withConfig({
|
|
59
73
|
displayName: "ChartLegendstyles__Arrow",
|
|
60
|
-
componentId: "sc-gh1vwu-
|
|
74
|
+
componentId: "sc-gh1vwu-10"
|
|
61
75
|
})(["&&&{position:absolute;top:14px;right:24px;transition:0.3s transform;transform:rotate(0);text-align:center;font-size:16px;line-height:16px;height:16px;margin-top:-8px;", "}"], function (props) {
|
|
62
76
|
return props.isOpened && "\n transform: rotate(180deg);\n ";
|
|
63
77
|
});
|