@stokr/components-library 2.3.44-beta.3 → 2.3.44-beta.4

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.
@@ -37,8 +37,15 @@ function ReactTable(props) {
37
37
  customTdStyles = props.customTdStyles,
38
38
  customThStyles = props.customThStyles,
39
39
  customRowHoverStyles = props.customRowHoverStyles,
40
+ customRowHoverContent = props.customRowHoverContent,
40
41
  calculateSubData = props.calculateSubData;
41
42
 
43
+ // State to track which row is being hovered
44
+ var _useState = (0, _react.useState)(null),
45
+ _useState2 = _slicedToArray(_useState, 2),
46
+ hoveredRowIndex = _useState2[0],
47
+ setHoveredRowIndex = _useState2[1];
48
+
42
49
  // Use the state and functions returned from useTable to build UI
43
50
  var _useTable = (0, _reactTable.useTable)({
44
51
  columns: columns,
@@ -59,13 +66,24 @@ function ReactTable(props) {
59
66
  _useTable$state = _useTable.state,
60
67
  pageIndex = _useTable$state.pageIndex,
61
68
  pageSize = _useTable$state.pageSize;
62
- var _useState = (0, _react.useState)(isSubTable ? 10000 : 10),
63
- _useState2 = _slicedToArray(_useState, 2),
64
- inputPageSize = _useState2[0],
65
- setInputPageSize = _useState2[1];
69
+ var _useState3 = (0, _react.useState)(isSubTable ? 10000 : 10),
70
+ _useState4 = _slicedToArray(_useState3, 2),
71
+ inputPageSize = _useState4[0],
72
+ setInputPageSize = _useState4[1];
66
73
  _react.default.useEffect(function () {
67
74
  setInputPageSize(pageSize);
68
75
  }, [pageSize]);
76
+
77
+ // Function to render cell content with hover support
78
+ var renderCellContent = function renderCellContent(cell, rowIndex, rowData) {
79
+ if (customRowHoverContent && hoveredRowIndex === rowIndex) {
80
+ var hoverContent = customRowHoverContent(cell.column.id, rowIndex, rowData);
81
+ if (hoverContent !== undefined) {
82
+ return hoverContent;
83
+ }
84
+ }
85
+ return cell.render('Cell');
86
+ };
69
87
  return /*#__PURE__*/_react.default.createElement(_Table.Styles, null, /*#__PURE__*/_react.default.createElement(_Table.TableWrap, null, /*#__PURE__*/_react.default.createElement(_Table.StyledReactTable, getTableProps(), /*#__PURE__*/_react.default.createElement("thead", null, headerGroups.map(function (headerGroup) {
70
88
  return /*#__PURE__*/_react.default.createElement(_Table.StyledReactTable.Tr, headerGroup.getHeaderGroupProps(), headerGroup.headers.map(function (column) {
71
89
  var cellStyles = customThStyles ? customThStyles(column) : {};
@@ -73,7 +91,10 @@ function ReactTable(props) {
73
91
  className: column.collapse ? 'collapse' : '',
74
92
  style: _objectSpread({}, cellStyles)
75
93
  }), {
76
- blue: blue
94
+ blue: blue,
95
+ width: column.width,
96
+ minWidth: column.minWidth,
97
+ maxWidth: column.maxWidth
77
98
  }), column.render('Header'));
78
99
  }));
79
100
  })), /*#__PURE__*/_react.default.createElement("tbody", getTableBodyProps(), page.map(function (row, i) {
@@ -81,17 +102,26 @@ function ReactTable(props) {
81
102
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, {
82
103
  key: row.id
83
104
  }, /*#__PURE__*/_react.default.createElement(_Table.StyledReactTable.Tr, _extends({}, row.getRowProps(), {
84
- customRowHoverStyles: customRowHoverStyles
85
- // rowIndex={i}
86
- // rowData={row.original}
105
+ customRowHoverStyles: customRowHoverStyles,
106
+ rowIndex: i,
107
+ rowData: row.original,
108
+ onMouseEnter: function onMouseEnter() {
109
+ return setHoveredRowIndex(i);
110
+ },
111
+ onMouseLeave: function onMouseLeave() {
112
+ return setHoveredRowIndex(null);
113
+ }
87
114
  }), row.cells.map(function (cell) {
88
115
  var cellStyles = customTdStyles ? customTdStyles(i, row.original) : {};
89
116
  return /*#__PURE__*/_react.default.createElement(_Table.StyledReactTable.Td, _extends({}, cell.row.getToggleRowExpandedProps(), cell.getCellProps({
90
117
  className: cell.column.collapse ? 'collapse' : '',
91
118
  style: _objectSpread({}, cellStyles)
92
119
  }), {
93
- blue: blue
94
- }), cell.render('Cell'));
120
+ blue: blue,
121
+ width: cell.column.width,
122
+ minWidth: cell.column.minWidth,
123
+ maxWidth: cell.column.maxWidth
124
+ }), renderCellContent(cell, i, row.original));
95
125
  })), withSubTable && row.isExpanded && /*#__PURE__*/_react.default.createElement(_Table.StyledReactTable.Tr, {
96
126
  key: "".concat(row.id, "-").concat(i)
97
127
  }, /*#__PURE__*/_react.default.createElement(_Table.StyledReactTable.Td, {
@@ -124,7 +154,8 @@ ReactTable.propTypes = {
124
154
  noPagination: _propTypes.default.bool,
125
155
  withSubTable: _propTypes.default.bool,
126
156
  isSubTable: _propTypes.default.bool,
127
- customRowHoverStyles: _propTypes.default.func
157
+ customRowHoverStyles: _propTypes.default.func,
158
+ customRowHoverContent: _propTypes.default.func
128
159
  };
129
160
  ReactTable.defaultProps = {
130
161
  blue: false,
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = exports.WrapperWithSubTable = exports.WithoutPagination = exports.WithSubTable = exports.WithStatusBasedHover = exports.WithRowHover = exports.WithCustomStyling = exports.DefaultWrapper = exports.Default = exports.BlueWrapper = exports.BlueTable = void 0;
6
+ exports.default = exports.WrapperWithSubTable = exports.WithoutPagination = exports.WithSubTable = exports.WithStatusBasedHover = exports.WithRowSpecificHover = exports.WithRowHover = exports.WithHoverStylesAndContent = exports.WithHoverContent = exports.WithFixedColumnWidths = exports.WithCustomStyling = exports.DefaultWrapper = exports.Default = exports.BlueWrapper = exports.BlueTable = void 0;
7
7
  var _react = _interopRequireDefault(require("react"));
8
8
  var _ReactTable = require("./ReactTable");
9
9
  var _ReactTableWrapper = require("./ReactTableWrapper");
@@ -49,35 +49,54 @@ var _default = {
49
49
  },
50
50
  customRowHoverStyles: {
51
51
  control: 'function'
52
+ },
53
+ customRowHoverContent: {
54
+ control: 'function'
52
55
  }
53
56
  }
54
57
  }; // Sample columns and data for demonstration
55
58
  exports.default = _default;
56
59
  var columns = [{
57
60
  Header: 'ID',
58
- accessor: 'id'
61
+ accessor: 'id',
62
+ width: '10%',
63
+ minWidth: '80px'
59
64
  }, {
60
65
  Header: 'Name',
61
- accessor: 'name'
66
+ accessor: 'name',
67
+ width: '30%',
68
+ minWidth: '150px'
62
69
  }, {
63
70
  Header: 'Status',
64
- accessor: 'status'
71
+ accessor: 'status',
72
+ width: '20%',
73
+ minWidth: '100px'
65
74
  }, {
66
75
  Header: '',
67
- accessor: 'dropdown'
76
+ accessor: 'dropdown',
77
+ width: '40%',
78
+ minWidth: '120px'
68
79
  }];
69
80
  var columnsWrapper = [{
70
81
  label: 'ID',
71
- key: 'id'
82
+ key: 'id',
83
+ width: '10%',
84
+ minWidth: '80px'
72
85
  }, {
73
86
  label: 'Name',
74
- key: 'name'
87
+ key: 'name',
88
+ width: '30%',
89
+ minWidth: '150px'
75
90
  }, {
76
91
  label: 'Status',
77
- key: 'status'
92
+ key: 'status',
93
+ width: '20%',
94
+ minWidth: '100px'
78
95
  }, {
79
96
  label: '',
80
- key: 'dropdown'
97
+ key: 'dropdown',
98
+ width: '40%',
99
+ minWidth: '120px'
81
100
  }];
82
101
  var subColumns = [{
83
102
  Header: 'Detail ID',
@@ -160,6 +179,80 @@ var customRowHoverStyles = function customRowHoverStyles(rowIndex, rowData) {
160
179
  return "\n background-color: #f0f8ff !important;\n transform: scale(1.01);\n transition: all 0.2s ease-in-out;\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);\n \n td {\n background-color: #f0f8ff !important;\n border-bottom-color: #0050ca !important;\n }\n ";
161
180
  };
162
181
 
182
+ // Custom row hover content function
183
+ var customRowHoverContent = function customRowHoverContent(columnId, rowIndex, rowData) {
184
+ switch (columnId) {
185
+ case 'name':
186
+ // Show underlined link on hover
187
+ return /*#__PURE__*/_react.default.createElement("a", {
188
+ href: "/user/".concat(rowData.id),
189
+ style: {
190
+ textDecoration: 'underline',
191
+ color: '#0050ca',
192
+ fontWeight: 'bold'
193
+ }
194
+ }, rowData.name);
195
+ case 'dropdown':
196
+ // Show action buttons on hover
197
+ return /*#__PURE__*/_react.default.createElement("div", {
198
+ style: {
199
+ display: 'flex',
200
+ gap: '8px'
201
+ }
202
+ }, /*#__PURE__*/_react.default.createElement("button", {
203
+ style: {
204
+ padding: '4px 8px',
205
+ fontSize: '12px',
206
+ backgroundColor: '#0050ca',
207
+ color: 'white',
208
+ border: 'none',
209
+ borderRadius: '4px',
210
+ cursor: 'pointer'
211
+ },
212
+ onClick: function onClick() {
213
+ return alert("Edit ".concat(rowData.name));
214
+ }
215
+ }, "Edit"), /*#__PURE__*/_react.default.createElement("button", {
216
+ style: {
217
+ padding: '4px 8px',
218
+ fontSize: '12px',
219
+ backgroundColor: '#dc3545',
220
+ color: 'white',
221
+ border: 'none',
222
+ borderRadius: '4px',
223
+ cursor: 'pointer'
224
+ },
225
+ onClick: function onClick() {
226
+ return alert("Delete ".concat(rowData.name));
227
+ }
228
+ }, "Delete"));
229
+ case 'status':
230
+ // Show status with icon on hover
231
+ var statusColors = {
232
+ Active: '#28a745',
233
+ Inactive: '#dc3545',
234
+ Pending: '#ffc107'
235
+ };
236
+ return /*#__PURE__*/_react.default.createElement("div", {
237
+ style: {
238
+ display: 'flex',
239
+ alignItems: 'center',
240
+ gap: '4px'
241
+ }
242
+ }, /*#__PURE__*/_react.default.createElement("span", {
243
+ style: {
244
+ width: '8px',
245
+ height: '8px',
246
+ borderRadius: '50%',
247
+ backgroundColor: statusColors[rowData.status] || '#6c757d'
248
+ }
249
+ }), rowData.status);
250
+ default:
251
+ return undefined;
252
+ // Return undefined to use default content
253
+ }
254
+ };
255
+
163
256
  // Status-based hover styles
164
257
  var statusBasedHoverStyles = function statusBasedHoverStyles(rowIndex, rowData) {
165
258
  switch (rowData.status) {
@@ -174,6 +267,22 @@ var statusBasedHoverStyles = function statusBasedHoverStyles(rowIndex, rowData)
174
267
  }
175
268
  };
176
269
 
270
+ // Row-specific hover styles (example: different styles for first and last rows)
271
+ var rowSpecificHoverStyles = function rowSpecificHoverStyles(rowIndex, rowData) {
272
+ // Special styling for first row
273
+ if (rowIndex === 0) {
274
+ return "\n background-color: #e3f2fd !important;\n transform: scale(1.02);\n box-shadow: 0 4px 12px rgba(33, 150, 243, 0.3);\n td {\n background-color: #e3f2fd !important;\n border-bottom-color: #2196f3 !important;\n font-weight: bold;\n }\n ";
275
+ }
276
+
277
+ // Special styling for last row
278
+ if (rowIndex === data.length - 1) {
279
+ return "\n background-color: #f3e5f5 !important;\n transform: scale(1.02);\n box-shadow: 0 4px 12px rgba(156, 39, 176, 0.3);\n td {\n background-color: #f3e5f5 !important;\n border-bottom-color: #9c27b0 !important;\n font-weight: bold;\n }\n ";
280
+ }
281
+
282
+ // Default styling for other rows
283
+ return "\n background-color: #f0f8ff !important;\n transform: scale(1.01);\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);\n td {\n background-color: #f0f8ff !important;\n border-bottom-color: #0050ca !important;\n }\n ";
284
+ };
285
+
177
286
  // Function to calculate sub data
178
287
  var calculateSubData = function calculateSubData(row) {
179
288
  return row.original.subData || [];
@@ -207,11 +316,33 @@ exports.WithRowHover = WithRowHover;
207
316
  WithRowHover.args = _objectSpread(_objectSpread({}, Default.args), {}, {
208
317
  customRowHoverStyles: customRowHoverStyles
209
318
  });
319
+ var WithHoverContent = Template.bind({});
320
+ exports.WithHoverContent = WithHoverContent;
321
+ WithHoverContent.args = _objectSpread(_objectSpread({}, Default.args), {}, {
322
+ customRowHoverContent: customRowHoverContent
323
+ });
324
+ var WithHoverStylesAndContent = Template.bind({});
325
+ exports.WithHoverStylesAndContent = WithHoverStylesAndContent;
326
+ WithHoverStylesAndContent.args = _objectSpread(_objectSpread({}, Default.args), {}, {
327
+ customRowHoverStyles: customRowHoverStyles,
328
+ customRowHoverContent: customRowHoverContent
329
+ });
210
330
  var WithStatusBasedHover = Template.bind({});
211
331
  exports.WithStatusBasedHover = WithStatusBasedHover;
212
332
  WithStatusBasedHover.args = _objectSpread(_objectSpread({}, Default.args), {}, {
213
333
  customRowHoverStyles: statusBasedHoverStyles
214
334
  });
335
+ var WithRowSpecificHover = Template.bind({});
336
+ exports.WithRowSpecificHover = WithRowSpecificHover;
337
+ WithRowSpecificHover.args = _objectSpread(_objectSpread({}, Default.args), {}, {
338
+ customRowHoverStyles: rowSpecificHoverStyles
339
+ });
340
+ var WithFixedColumnWidths = Template.bind({});
341
+ exports.WithFixedColumnWidths = WithFixedColumnWidths;
342
+ WithFixedColumnWidths.args = _objectSpread(_objectSpread({}, Default.args), {}, {
343
+ customRowHoverContent: customRowHoverContent,
344
+ customRowHoverStyles: customRowHoverStyles
345
+ });
215
346
  var WithSubTable = Template.bind({});
216
347
  exports.WithSubTable = WithSubTable;
217
348
  WithSubTable.args = _objectSpread(_objectSpread({}, Default.args), {}, {
@@ -99,17 +99,29 @@ exports.TableWrap = TableWrap;
99
99
  var StyledTh = _styledComponents.default.th.withConfig({
100
100
  displayName: "Tablestyles__StyledTh",
101
101
  componentId: "sc-pdcd6r-12"
102
- })(["text-transform:uppercase;padding:10px;font-size:11px;letter-spacing:1.6px;font-weight:600;background-color:white;color:#000000de;border-bottom:1px solid #e1e1e1;line-height:20px;", ""], function (props) {
102
+ })(["text-transform:uppercase;padding:10px;font-size:11px;letter-spacing:1.6px;font-weight:600;background-color:white;color:#000000de;border-bottom:1px solid #e1e1e1;line-height:20px;", " ", " ", " ", ""], function (props) {
103
103
  return props.blue && "\n background-color: #0050ca;\n color: #ffffff;\n border:none;\n ";
104
+ }, function (props) {
105
+ return props.width && "\n width: ".concat(props.width, ";\n min-width: ").concat(props.width, ";\n max-width: ").concat(props.width, ";\n ");
106
+ }, function (props) {
107
+ return props.minWidth && "\n min-width: ".concat(props.minWidth, ";\n ");
108
+ }, function (props) {
109
+ return props.maxWidth && "\n max-width: ".concat(props.maxWidth, ";\n ");
104
110
  });
105
111
  exports.StyledTh = StyledTh;
106
112
  var StyledTd = _styledComponents.default.td.withConfig({
107
113
  displayName: "Tablestyles__StyledTd",
108
114
  componentId: "sc-pdcd6r-13"
109
- })(["padding:26px 15px;border-bottom:1px solid #e1e1e1;font-size:14px;", " ", ""], function (props) {
115
+ })(["padding:26px 15px;border-bottom:1px solid #e1e1e1;font-size:14px;", " ", " ", " ", " ", ""], function (props) {
110
116
  return props.blue && "\n background-color: #004bb7;\n color: #ffffff;\n ";
111
117
  }, function (props) {
112
118
  return props.subTable && "\n padding: 0;\n &:last-child {\n border-bottom: 0;\n }\n ";
119
+ }, function (props) {
120
+ return props.width && "\n width: ".concat(props.width, ";\n min-width: ").concat(props.width, ";\n max-width: ").concat(props.width, ";\n ");
121
+ }, function (props) {
122
+ return props.minWidth && "\n min-width: ".concat(props.minWidth, ";\n ");
123
+ }, function (props) {
124
+ return props.maxWidth && "\n max-width: ".concat(props.maxWidth, ";\n ");
113
125
  });
114
126
  exports.StyledTd = StyledTd;
115
127
  var StyledTr = _styledComponents.default.tr.withConfig({
@@ -8,7 +8,7 @@ var _react = _interopRequireDefault(require("react"));
8
8
  var _propTypes = _interopRequireDefault(require("prop-types"));
9
9
  var _reactTippy = require("react-tippy");
10
10
  var _InfoIcon = require("./InfoIcon.styles");
11
- var _excluded = ["title", "html", "position", "noMargin", "noMarginLeft", "noMarginRight", "noIcon", "disabled"];
11
+ var _excluded = ["title", "html", "position", "noMargin", "noMarginLeft", "noMarginRight", "noIcon", "disabled", "fullWidth"];
12
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
13
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
14
14
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
@@ -21,11 +21,13 @@ var InfoIcon = function InfoIcon(_ref) {
21
21
  noMarginRight = _ref.noMarginRight,
22
22
  noIcon = _ref.noIcon,
23
23
  disabled = _ref.disabled,
24
+ fullWidth = _ref.fullWidth,
24
25
  props = _objectWithoutProperties(_ref, _excluded);
25
26
  return /*#__PURE__*/_react.default.createElement(_InfoIcon.Container, {
26
27
  noMargin: noMargin,
27
28
  noMarginLeft: noMarginLeft,
28
- noMarginRight: noMarginRight
29
+ noMarginRight: noMarginRight,
30
+ fullWidth: fullWidth
29
31
  }, /*#__PURE__*/_react.default.createElement(_reactTippy.Tooltip, {
30
32
  position: position,
31
33
  title: title,
@@ -10,12 +10,16 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
10
10
  var Container = _styledComponents.default.div.withConfig({
11
11
  displayName: "InfoIconstyles__Container",
12
12
  componentId: "sc-d3sdn3-0"
13
- })(["display:inline-block;vertical-align:middle;margin:0 12px;font-size:0;line-height:0;", " ", " ", " & > div{position:relative;display:inline-block!important;}"], function (props) {
13
+ })(["display:inline-block;vertical-align:middle;margin:0 12px;font-size:0;line-height:0;", " ", " ", " ", " & > div{position:relative;display:inline-block !important;", "}"], function (props) {
14
14
  return props.noMargin && "\n margin: 0;\n ";
15
15
  }, function (props) {
16
16
  return props.noMarginLeft && "\n margin-left: 0;\n ";
17
17
  }, function (props) {
18
18
  return props.noMarginRight && "\n margin-right: 0;\n ";
19
+ }, function (props) {
20
+ return props.fullWidth && "\n width: 100%;\n height: 100%;\n ";
21
+ }, function (props) {
22
+ return props.fullWidth && "\n width: 100%;\n height: 100%;\n display: flex !important;\n align-content: center;\n flex-wrap: wrap;\n justify-content: center;\n ";
19
23
  });
20
24
  exports.Container = Container;
21
25
  var Icon = _styledComponents.default.i.attrs({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stokr/components-library",
3
- "version": "2.3.44-beta.3",
3
+ "version": "2.3.44-beta.4",
4
4
  "description": "STOKR - Components Library",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",