oolib 2.67.9 → 2.68.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.
@@ -1,4 +1,4 @@
1
- export function ActionMenu({ icon, invert, actions, align, iconSize, M, ButtonComp: _ButtonComp, setShowActions: setShowActionsInParent, popOutOfOverflowHiddenParent, storybookPreview }: {
1
+ export function ActionMenu({ icon, invert, actions, align, iconSize, M, ButtonComp: _ButtonComp, setShowActions: setShowActionsInParent, popOutOfOverflowHiddenParent, CustomSelectComp, storybookPreview }: {
2
2
  icon?: string;
3
3
  invert: any;
4
4
  actions: any;
@@ -8,6 +8,7 @@ export function ActionMenu({ icon, invert, actions, align, iconSize, M, ButtonCo
8
8
  ButtonComp?: string;
9
9
  setShowActions: any;
10
10
  popOutOfOverflowHiddenParent?: boolean;
11
+ CustomSelectComp: any;
11
12
  storybookPreview: any;
12
13
  }): React.JSX.Element;
13
14
  import React from "react";
@@ -46,7 +46,7 @@ var styled_1 = require("./styled");
46
46
  var ActionMenu = function (_a) {
47
47
  var _b, _c;
48
48
  var _d = _a.icon, icon = _d === void 0 ? 'DotsThree' : _d, //most likely will never change
49
- invert = _a.invert, actions = _a.actions, _e = _a.align, align = _e === void 0 ? 'right' : _e, _f = _a.iconSize, iconSize = _f === void 0 ? 'S' : _f, M = _a.M, _g = _a.ButtonComp, _ButtonComp = _g === void 0 ? 'ButtonGhost' : _g, setShowActionsInParent = _a.setShowActions, _h = _a.popOutOfOverflowHiddenParent, popOutOfOverflowHiddenParent = _h === void 0 ? false : _h, storybookPreview = _a.storybookPreview //for storybook purposes
49
+ invert = _a.invert, actions = _a.actions, _e = _a.align, align = _e === void 0 ? 'right' : _e, _f = _a.iconSize, iconSize = _f === void 0 ? 'S' : _f, M = _a.M, _g = _a.ButtonComp, _ButtonComp = _g === void 0 ? 'ButtonGhost' : _g, setShowActionsInParent = _a.setShowActions, _h = _a.popOutOfOverflowHiddenParent, popOutOfOverflowHiddenParent = _h === void 0 ? false : _h, CustomSelectComp = _a.CustomSelectComp, storybookPreview = _a.storybookPreview //for storybook purposes
50
50
  ;
51
51
  var actionMenuRef = (0, react_1.useRef)(null);
52
52
  var optionsWrapperRef = (0, react_1.useRef)(null);
@@ -78,10 +78,13 @@ var ActionMenu = function (_a) {
78
78
  }, []);
79
79
  var _k = (0, usePopOutOfOverflowHiddenParent_1.usePopOutOfOverflowHiddenParent)(popOutOfOverflowHiddenParent), fixPos = _k.fixPos, applyFixedPos = _k.applyFixedPos, removeFixedPos = _k.removeFixedPos, trackerRef = _k.trackerRef;
80
80
  return (react_1.default.createElement(styled_1.StyledActionMenu, { ref: actionMenuRef },
81
- react_1.default.createElement(ButtonComp, __assign({}, buttonSize, { icon: icon, iconSize: iconSize, invert: invert, stopPropagation: true, preventDefault: true, onClick: function (e) {
82
- console.log('detected');
83
- setShowActions(!showActions);
84
- }, active: showActions })),
81
+ CustomSelectComp
82
+ ? react_1.default.createElement(CustomSelectComp, { active: showActions, onClick: function (e) {
83
+ setShowActions(!showActions);
84
+ } })
85
+ : react_1.default.createElement(ButtonComp, __assign({}, buttonSize, { icon: icon, iconSize: iconSize, invert: invert, stopPropagation: true, preventDefault: true, onClick: function (e) {
86
+ setShowActions(!showActions);
87
+ }, active: showActions })),
85
88
  popOutOfOverflowHiddenParent &&
86
89
  react_1.default.createElement(styled_1.StyledActionMenuTracker, { storybookPreview: storybookPreview, align: align, ref: trackerRef }),
87
90
  react_1.default.createElement(styled_1.StyledActionsDropMenu, __assign({}, {
@@ -0,0 +1,8 @@
1
+ export function ColActionsMenu({ value, colIdx, onChange, id, defaultColWidth }: {
2
+ value: any;
3
+ colIdx: any;
4
+ onChange: any;
5
+ id: any;
6
+ defaultColWidth: any;
7
+ }): React.JSX.Element;
8
+ import React from "react";
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
3
+ if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
4
+ return cooked;
5
+ };
6
+ var __importDefault = (this && this.__importDefault) || function (mod) {
7
+ return (mod && mod.__esModule) ? mod : { "default": mod };
8
+ };
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.ColActionsMenu = void 0;
11
+ var react_1 = __importDefault(require("react"));
12
+ var ActionMenu_1 = require("../../../../ActionMenu");
13
+ var handleColActions_1 = require("../../../handlers/handleColActions");
14
+ var UIContent_1 = require("../../../../../UIContent");
15
+ var styled_1 = require("../styled");
16
+ var DisplayIcon_1 = require("../../../../../utils/comps/DisplayIcon");
17
+ var styled_components_1 = __importDefault(require("styled-components"));
18
+ var StyledCustomSelectCompWrapper = styled_components_1.default.button(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", "\n height: 1.5rem;\n width: 2.5rem;\n"], ["\n ", "\n height: 1.5rem;\n width: 2.5rem;\n"])), styled_1.commonRowColActionMenuStyles);
19
+ var ColActionsMenu = function (_a) {
20
+ var value = _a.value, colIdx = _a.colIdx, onChange = _a.onChange, id = _a.id, defaultColWidth = _a.defaultColWidth;
21
+ return (react_1.default.createElement("div", { style: { zIndex: 2, position: 'absolute', top: 0, left: '50%', transform: 'translate(-50%, -50%)' } },
22
+ react_1.default.createElement(ActionMenu_1.ActionMenu, { align: "left", CustomSelectComp: function (_a) {
23
+ var active = _a.active, onClick = _a.onClick;
24
+ return (react_1.default.createElement(StyledCustomSelectCompWrapper, { onClick: onClick, active: active },
25
+ react_1.default.createElement(DisplayIcon_1.DisplayIcon, { icon: "DotsThree", size: 16 })));
26
+ }, actions: [
27
+ {
28
+ display: UIContent_1.UIContent.SimpleTable.delete,
29
+ onClick: function () { return (0, handleColActions_1.handleDeleteCol)({ value: value, colIdx: colIdx, onChange: onChange, id: id }); },
30
+ },
31
+ {
32
+ display: UIContent_1.UIContent.SimpleTable.duplicate,
33
+ onClick: function () { return (0, handleColActions_1.handleDuplicateCol)({ value: value, colIdx: colIdx, onChange: onChange, id: id }); },
34
+ },
35
+ {
36
+ display: UIContent_1.UIContent.SimpleTable.insertColAfter,
37
+ onClick: function () { return (0, handleColActions_1.handleInsertColAfter)({ value: value, colIdx: colIdx, onChange: onChange, id: id, defaultColWidth: defaultColWidth }); },
38
+ },
39
+ {
40
+ display: UIContent_1.UIContent.SimpleTable.insertColBefore,
41
+ onClick: function () { return (0, handleColActions_1.handleInsertColBefore)({ value: value, colIdx: colIdx, onChange: onChange, id: id, defaultColWidth: defaultColWidth }); },
42
+ }
43
+ ] })));
44
+ };
45
+ exports.ColActionsMenu = ColActionsMenu;
46
+ var templateObject_1;
@@ -0,0 +1,8 @@
1
+ export function RowActionsMenu({ value, rowIdx, onChange, id, setActionsActiveOnRow }: {
2
+ value: any;
3
+ rowIdx: any;
4
+ onChange: any;
5
+ id: any;
6
+ setActionsActiveOnRow: any;
7
+ }): React.JSX.Element;
8
+ import React from "react";
@@ -1,23 +1,36 @@
1
1
  "use strict";
2
+ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
3
+ if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
4
+ return cooked;
5
+ };
2
6
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
7
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
8
  };
5
9
  Object.defineProperty(exports, "__esModule", { value: true });
6
10
  exports.RowActionsMenu = void 0;
7
11
  var react_1 = __importDefault(require("react"));
8
- var handleRowActions_1 = require("../../handlers/handleRowActions");
9
- var ActionMenu_1 = require("../../../ActionMenu");
10
- var UIContent_1 = require("../../../../UIContent");
12
+ var styled_components_1 = __importDefault(require("styled-components"));
13
+ var UIContent_1 = require("../../../../../UIContent");
14
+ var DisplayIcon_1 = require("../../../../../utils/comps/DisplayIcon");
15
+ var ActionMenu_1 = require("../../../../ActionMenu");
16
+ var handleRowActions_1 = require("../../../handlers/handleRowActions");
17
+ var styled_1 = require("../styled");
18
+ var StyledCustomSelectCompWrapper = styled_components_1.default.button(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", "\n width: 1.5rem;\n height: 2.5rem;\n"], ["\n ", "\n width: 1.5rem;\n height: 2.5rem;\n"])), styled_1.commonRowColActionMenuStyles);
19
+ var CustomSelectComp = function (_a) {
20
+ var active = _a.active, onClick = _a.onClick;
21
+ return (react_1.default.createElement(StyledCustomSelectCompWrapper, { onClick: onClick, active: active },
22
+ react_1.default.createElement(DisplayIcon_1.DisplayIcon, { icon: "DotsThreeVertical", size: 16 })));
23
+ };
11
24
  var RowActionsMenu = function (_a) {
12
- var value = _a.value, rowIdx = _a.rowIdx, onChange = _a.onChange, id = _a.id;
25
+ var value = _a.value, rowIdx = _a.rowIdx, onChange = _a.onChange, id = _a.id, setActionsActiveOnRow = _a.setActionsActiveOnRow;
13
26
  return (react_1.default.createElement("div", { style: {
14
- zIndex: 100,
27
+ zIndex: 1,
15
28
  position: "absolute",
16
29
  top: "50%",
17
30
  left: 0,
18
- transform: "translate(-100%, -50%)",
31
+ transform: "translate(-50%, -50%)",
19
32
  } },
20
- react_1.default.createElement(ActionMenu_1.ActionMenu, { actions: [
33
+ react_1.default.createElement(ActionMenu_1.ActionMenu, { align: "left", setShowActions: function (showActions) { return setActionsActiveOnRow(showActions ? rowIdx : undefined); }, CustomSelectComp: CustomSelectComp, actions: [
21
34
  {
22
35
  display: UIContent_1.UIContent.SimpleTable.delete,
23
36
  onClick: function () { return (0, handleRowActions_1.handleDeleteRow)({ value: value, rowIdx: rowIdx, onChange: onChange, id: id }); },
@@ -41,3 +54,4 @@ var RowActionsMenu = function (_a) {
41
54
  ] })));
42
55
  };
43
56
  exports.RowActionsMenu = RowActionsMenu;
57
+ var templateObject_1;
@@ -0,0 +1 @@
1
+ export const commonRowColActionMenuStyles: import("styled-components").FlattenInterpolation<import("styled-components").ThemeProps<any>>;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
3
+ if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
4
+ return cooked;
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.commonRowColActionMenuStyles = void 0;
8
+ var styled_components_1 = require("styled-components");
9
+ var utilsOolib_1 = require("../../../../utilsOolib");
10
+ var globalVariables_1 = require("../../../../globalStyles/globalVariables");
11
+ var mixins_1 = require("../../../../themes/mixins");
12
+ var themes_1 = require("../../../../themes");
13
+ exports.commonRowColActionMenuStyles = (0, styled_components_1.css)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n border: none;\n display: flex;\n align-items: center;\n justify-content: center;\n ", ";\n border-radius: 4px;\n ", "\n cursor: pointer;\n ", "\n"], ["\n border: none;\n display: flex;\n align-items: center;\n justify-content: center;\n ", ";\n border-radius: 4px;\n ", "\n cursor: pointer;\n ", "\n"])), (0, mixins_1.transition)("background-color", "border-color"), function (_a) {
14
+ var active = _a.active, theme = _a.theme;
15
+ return active
16
+ ? (0, styled_components_1.css)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n background-color: ", ";\n border: 1px solid;\n border-color: ", ";\n "], ["\n background-color: ", ";\n border: 1px solid;\n border-color: ", ";\n "])), (0, utilsOolib_1.getPrimaryColor40)(theme === null || theme === void 0 ? void 0 : theme.colors), (0, utilsOolib_1.getPrimaryColor100)(theme === null || theme === void 0 ? void 0 : theme.colors)) : (0, styled_components_1.css)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n background-color: ", ";\n border: 1px solid;\n border-color: ", ";\n ", ";\n "], ["\n background-color: ", ";\n border: 1px solid;\n border-color: ", ";\n ", ";\n "])), themes_1.colors.white, themes_1.colors.greyColor15, globalVariables_1.globalHoverOnWhiteBG);
17
+ }, mixins_1.boxShadow1);
18
+ var templateObject_1, templateObject_2, templateObject_3;
@@ -1 +1,32 @@
1
- export function handleAddCol(value: any, props: any): void;
1
+ export function handleAddCol({ value, onChange, id, defaultColWidth }: {
2
+ value: any;
3
+ onChange: any;
4
+ id: any;
5
+ defaultColWidth: any;
6
+ }): void;
7
+ export function handleDeleteCol({ value, colIdx, onChange, id }: {
8
+ value: any;
9
+ colIdx: any;
10
+ onChange: any;
11
+ id: any;
12
+ }): void;
13
+ export function handleDuplicateCol({ value, colIdx, onChange, id }: {
14
+ value: any;
15
+ colIdx: any;
16
+ onChange: any;
17
+ id: any;
18
+ }): void;
19
+ export function handleInsertColAfter({ value, colIdx, onChange, id, defaultColWidth }: {
20
+ value: any;
21
+ colIdx: any;
22
+ onChange: any;
23
+ id: any;
24
+ defaultColWidth: any;
25
+ }): void;
26
+ export function handleInsertColBefore({ value, colIdx, onChange, id, defaultColWidth }: {
27
+ value: any;
28
+ colIdx: any;
29
+ onChange: any;
30
+ id: any;
31
+ defaultColWidth: any;
32
+ }): void;
@@ -1,4 +1,15 @@
1
1
  "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
2
13
  var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
3
14
  if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4
15
  if (ar || !(i in from)) {
@@ -9,17 +20,110 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
9
20
  return to.concat(ar || Array.prototype.slice.call(from));
10
21
  };
11
22
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.handleAddCol = void 0;
23
+ exports.handleInsertColBefore = exports.handleInsertColAfter = exports.handleDuplicateCol = exports.handleDeleteCol = exports.handleAddCol = void 0;
13
24
  var genHash_1 = require("../utils/genHash");
14
- var handleAddCol = function (value, props) {
15
- var onChange = props.onChange, id = props.id;
25
+ var handleAddColAtIdx = function (_a) {
26
+ var value = _a.value, onChange = _a.onChange, id = _a.id, defaultColWidth = _a.defaultColWidth, colIdx = _a.colIdx;
16
27
  var data = value.data, colWidthConfig = value.colWidthConfig;
17
28
  var newData = __spreadArray([], data, true);
18
- newData.map(function (row) {
19
- row.cellData.push({
20
- id: "row_".concat((0, genHash_1.genHash)(8)),
21
- });
29
+ newData = newData.map(function (row) {
30
+ var newCellData = __spreadArray([], row.cellData, true);
31
+ newCellData.splice(colIdx, 0, { id: "cell_".concat((0, genHash_1.genHash)(8)) });
32
+ return __assign(__assign({}, row), { cellData: newCellData });
33
+ });
34
+ var newColWidthValue = defaultColWidth + "px";
35
+ var newColWidthConfigAsArray = Object.values(colWidthConfig);
36
+ newColWidthConfigAsArray.splice(colIdx, 0, newColWidthValue);
37
+ var newColWidthConfig = newColWidthConfigAsArray
38
+ .map(function (width, i) { return ({
39
+ colId: "col_".concat(i),
40
+ width: width,
41
+ }); })
42
+ .reduce(function (a, b) {
43
+ var _a;
44
+ return (__assign(__assign({}, a), (_a = {}, _a[b.colId] = b.width, _a)));
45
+ }, {});
46
+ onChange &&
47
+ onChange(id, { data: newData, colWidthConfig: newColWidthConfig });
48
+ };
49
+ var handleAddCol = function (_a) {
50
+ var value = _a.value, onChange = _a.onChange, id = _a.id, defaultColWidth = _a.defaultColWidth;
51
+ handleAddColAtIdx({
52
+ value: value,
53
+ onChange: onChange,
54
+ id: id,
55
+ defaultColWidth: defaultColWidth,
56
+ colIdx: value.data[0].cellData.length,
22
57
  });
23
- onChange && onChange(id, { data: newData, colWidthConfig: colWidthConfig });
24
58
  };
25
59
  exports.handleAddCol = handleAddCol;
60
+ var handleDeleteCol = function (_a) {
61
+ var value = _a.value, colIdx = _a.colIdx, onChange = _a.onChange, id = _a.id;
62
+ var data = value.data, colWidthConfig = value.colWidthConfig;
63
+ var newData = data.map(function (row) {
64
+ var newCellData = row.cellData.filter(function (cell, cellIdx) { return colIdx !== cellIdx; });
65
+ return __assign(__assign({}, row), { cellData: newCellData });
66
+ });
67
+ var newColWidthConfig = __assign({}, colWidthConfig);
68
+ delete newColWidthConfig["col_".concat(colIdx)];
69
+ // now that we deleted this colIdx from widthconfig. we need to reset all the keys from col_0 to col_<length-1>
70
+ newColWidthConfig = Object.values(newColWidthConfig)
71
+ .map(function (width, i) { return ({
72
+ colId: "col_".concat(i),
73
+ width: width,
74
+ }); })
75
+ .reduce(function (a, b) {
76
+ var _a;
77
+ return (__assign(__assign({}, a), (_a = {}, _a[b.colId] = b.width, _a)));
78
+ }, {});
79
+ onChange &&
80
+ onChange(id, { data: newData, colWidthConfig: newColWidthConfig });
81
+ };
82
+ exports.handleDeleteCol = handleDeleteCol;
83
+ var handleDuplicateCol = function (_a) {
84
+ var value = _a.value, colIdx = _a.colIdx, onChange = _a.onChange, id = _a.id;
85
+ var data = value.data, colWidthConfig = value.colWidthConfig;
86
+ var newData = data.map(function (row) {
87
+ var newCellData = __spreadArray([], row.cellData, true);
88
+ var dataToDuplicate = __assign(__assign({}, newCellData[colIdx]), { id: "cell_".concat((0, genHash_1.genHash)(8)) });
89
+ newCellData.splice(colIdx + 1, 0, dataToDuplicate);
90
+ return __assign(__assign({}, row), { cellData: newCellData });
91
+ });
92
+ var newColWidthValue = colWidthConfig["col_".concat(colIdx)];
93
+ var newColWidthConfigAsArray = Object.values(colWidthConfig);
94
+ newColWidthConfigAsArray.splice(colIdx + 1, 0, newColWidthValue);
95
+ var newColWidthConfig = newColWidthConfigAsArray
96
+ .map(function (width, i) { return ({
97
+ colId: "col_".concat(i),
98
+ width: width,
99
+ }); })
100
+ .reduce(function (a, b) {
101
+ var _a;
102
+ return (__assign(__assign({}, a), (_a = {}, _a[b.colId] = b.width, _a)));
103
+ }, {});
104
+ onChange &&
105
+ onChange(id, { data: newData, colWidthConfig: newColWidthConfig });
106
+ };
107
+ exports.handleDuplicateCol = handleDuplicateCol;
108
+ var handleInsertColAfter = function (_a) {
109
+ var value = _a.value, colIdx = _a.colIdx, onChange = _a.onChange, id = _a.id, defaultColWidth = _a.defaultColWidth;
110
+ handleAddColAtIdx({
111
+ value: value,
112
+ onChange: onChange,
113
+ id: id,
114
+ defaultColWidth: defaultColWidth,
115
+ colIdx: colIdx + 1,
116
+ });
117
+ };
118
+ exports.handleInsertColAfter = handleInsertColAfter;
119
+ var handleInsertColBefore = function (_a) {
120
+ var value = _a.value, colIdx = _a.colIdx, onChange = _a.onChange, id = _a.id, defaultColWidth = _a.defaultColWidth;
121
+ handleAddColAtIdx({
122
+ value: value,
123
+ onChange: onChange,
124
+ id: id,
125
+ defaultColWidth: defaultColWidth,
126
+ colIdx: colIdx,
127
+ });
128
+ };
129
+ exports.handleInsertColBefore = handleInsertColBefore;
@@ -1,4 +1,15 @@
1
1
  "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
2
13
  var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
3
14
  if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4
15
  if (ar || !(i in from)) {
@@ -44,7 +55,7 @@ var handleDuplicateRow = function (_a) {
44
55
  var value = _a.value, rowIdx = _a.rowIdx, onChange = _a.onChange, id = _a.id;
45
56
  var data = value.data, colWidthConfig = value.colWidthConfig;
46
57
  var newData = __spreadArray([], data, true);
47
- var dataToDuplicate = newData[rowIdx];
58
+ var dataToDuplicate = __assign(__assign({}, newData[rowIdx]), { id: "row_".concat((0, genHash_1.genHash)(8)), cellData: newData[rowIdx].cellData.map(function (cell) { return (__assign(__assign({}, cell), { id: "cell_".concat((0, genHash_1.genHash)(8)) })); }) });
48
59
  newData.splice(rowIdx + 1, 0, dataToDuplicate);
49
60
  onChange && onChange(id, { data: newData, colWidthConfig: colWidthConfig });
50
61
  };
@@ -52,8 +52,8 @@ var BlockLabel_1 = require("../BlockLabel");
52
52
  var styled_components_1 = require("styled-components");
53
53
  var utilsOolib_1 = require("../../utilsOolib");
54
54
  var AddRowColButtons_1 = require("./comps/AddRowColButtons");
55
- var ColActionsMenu_1 = require("./comps/ColActionsMenu");
56
- var RowActionsMenu_1 = require("./comps/RowActionsMenu");
55
+ var ColActionsMenu_1 = require("./comps/rowColActionMenus/ColActionsMenu");
56
+ var RowActionsMenu_1 = require("./comps/rowColActionMenus/RowActionsMenu");
57
57
  var handleColActions_1 = require("./handlers/handleColActions");
58
58
  var handleRowActions_1 = require("./handlers/handleRowActions");
59
59
  var styled_1 = require("./styled");
@@ -78,12 +78,21 @@ function SimpleTable(_a) {
78
78
  } : _b, _value = _a.value, onChange = _a.onChange, _c = _a.defaultColWidth, defaultColWidth = _c === void 0 ? 200 : _c;
79
79
  var props = arguments[0];
80
80
  var theme = (0, styled_components_1.useTheme)();
81
- var _d = theme || {}, RichTextEditor = _d.RichTextEditor, convertToRichText = _d.convertToRichText;
82
- var _e = (0, prepInitValueFromConfigIfNoValue_1.prepInitValueFromConfigIfNoValue)({
81
+ var _d = theme || {}, _RichTextEditor = _d.RichTextEditor, convertToRichText = _d.convertToRichText;
82
+ //memoizing cuz we dont want all cell rtes to render everytime one cell changes
83
+ var RichTextEditor = (0, react_1.useMemo)(function () {
84
+ var checkMemoFn = function (prevProps, currentProps) {
85
+ var prevVal = prevProps.value;
86
+ var currentVal = currentProps.value;
87
+ return isEqual(prevVal, currentVal);
88
+ };
89
+ return _RichTextEditor && react_1.default.memo(_RichTextEditor, checkMemoFn);
90
+ }, []);
91
+ var _e = (0, react_1.useMemo)(function () { return (0, prepInitValueFromConfigIfNoValue_1.prepInitValueFromConfigIfNoValue)({
83
92
  _value: _value,
84
93
  config: config,
85
94
  defaultColWidth: defaultColWidth,
86
- }), value = _e.value, enableColActions = _e.enableColActions, //returns all possible actions config if no config.colHeaderData is defined. else undefined\
95
+ }); }, [_value]), value = _e.value, enableColActions = _e.enableColActions, //returns all possible actions config if no config.colHeaderData is defined. else undefined\
87
96
  enableRowActions = _e.enableRowActions, canToggleColHeaderStyle = _e.canToggleColHeaderStyle;
88
97
  var _f = (0, useResizeTableColumns_1.useResizeTableColumns)({
89
98
  setColWidthConfig: function (setterFn) {
@@ -121,10 +130,11 @@ function SimpleTable(_a) {
121
130
  // size: 'small',
122
131
  // },
123
132
  };
124
- var _g = (0, react_1.useState)({
133
+ var _g = (0, react_1.useState)(undefined), actionsActiveOnRow = _g[0], setActionsActiveOnRow = _g[1];
134
+ var _h = (0, react_1.useState)({
125
135
  rowIdx: undefined,
126
136
  colIdx: undefined,
127
- }), hoveredRowAndCol = _g[0], setHoveredRowAndCol = _g[1];
137
+ }), hoveredRowAndCol = _h[0], setHoveredRowAndCol = _h[1];
128
138
  var CellValueGetters = {
129
139
  RichTextEditor: function (v) { return (convertToRichText ? convertToRichText(v) : v); },
130
140
  }; //prob dont need this..
@@ -141,11 +151,9 @@ function SimpleTable(_a) {
141
151
  var StyledWrapper = row.isColHeader
142
152
  ? styled_1.StyledSimpleTableHeader
143
153
  : styled_1.StyledSimpleTableRow;
144
- return (react_1.default.createElement(StyledWrapper
145
- // onClick={() => row.link && history.push(row.link)}
146
- , {
154
+ return (react_1.default.createElement(StyledWrapper, { actionsActiveOnRow: actionsActiveOnRow,
147
155
  // onClick={() => row.link && history.push(row.link)}
148
- style: { display: "flex" }, readOnly: readOnly, rowIdx: rowIdx, key: "row_" + rowIdx }, row.cellData.map(function (cell, cellIdx) {
156
+ style: { display: "flex" }, readOnly: readOnly, rowIdx: rowIdx, key: row.id }, row.cellData.map(function (cell, cellIdx) {
149
157
  var CellComp = RichTextEditor //cuz in oolib, richtexteditor will not be there for now
150
158
  ? CellContentBlocks["RichTextEditor"]
151
159
  : function () { return react_1.default.createElement("div", null, "RTE Doesnt Exist"); };
@@ -160,10 +168,9 @@ function SimpleTable(_a) {
160
168
  return (react_1.default.createElement(styled_1.StyledSimpleTableCell, { key: cell.id, id: "kp_table__cell__".concat(cell.id), readOnly: readOnly || cell.readOnly, style: {
161
169
  color: greyColor100,
162
170
  width: "".concat(cellWidth),
163
- minHeight: "4rem",
164
171
  borderRight: (colResizeState === null || colResizeState === void 0 ? void 0 : colResizeState.colId) === "col_".concat(cellIdx) &&
165
172
  "2px solid ".concat((0, utilsOolib_1.getPrimaryColor100)(theme === null || theme === void 0 ? void 0 : theme.colors)),
166
- }, onMouseEnter: function (e) {
173
+ }, actionsActiveOnRow: actionsActiveOnRow, onMouseEnter: function (e) {
167
174
  setHoveredRowAndCol({
168
175
  rowIdx: rowIdx,
169
176
  colIdx: cellIdx,
@@ -175,13 +182,21 @@ function SimpleTable(_a) {
175
182
  onMouseDown: function (e) {
176
183
  initColResizeState(e, { colId: "col_".concat(cellIdx) });
177
184
  }, onMouseOut: resetDragZoneIndicator, onMouseMove: hideShowDragZoneIndicator, tabIndex: 0 },
178
- !readOnly && enableColActions &&
185
+ !readOnly &&
186
+ enableColActions &&
179
187
  rowIdx === 0 &&
180
- hoveredRowAndCol.colIdx === cellIdx && react_1.default.createElement(ColActionsMenu_1.ColActionsMenu, null),
181
- !readOnly && enableRowActions &&
188
+ hoveredRowAndCol.colIdx === cellIdx && (react_1.default.createElement(ColActionsMenu_1.ColActionsMenu, __assign({}, {
189
+ value: value,
190
+ colIdx: cellIdx,
191
+ onChange: onChange,
192
+ id: id,
193
+ defaultColWidth: defaultColWidth,
194
+ }))),
195
+ !readOnly &&
196
+ enableRowActions &&
182
197
  cellIdx === 0 &&
183
198
  rowIdx !== undefined && //cuz for fixed col headers, rowIdx is undefined
184
- hoveredRowAndCol.rowIdx === rowIdx && (react_1.default.createElement(RowActionsMenu_1.RowActionsMenu, __assign({}, { value: value, rowIdx: rowIdx, onChange: onChange, id: id }))),
199
+ hoveredRowAndCol.rowIdx === rowIdx && (react_1.default.createElement(RowActionsMenu_1.RowActionsMenu, __assign({}, { value: value, rowIdx: rowIdx, onChange: onChange, id: id, setActionsActiveOnRow: setActionsActiveOnRow }))),
185
200
  react_1.default.createElement(CellComp, __assign({}, cellProps, { id: "kp_table_cell__".concat(cell.id, "__rich_input") /*dont mess with this id nomenclature. it needs to stay this way. check out the handleCellInputChange fn to understand */, value: cellValue, readOnly: readOnly || cell.readOnly, onChange: function (k, v) {
186
201
  return handleCellInputChange({ v: v, rowIdx: rowIdx, cellIdx: cellIdx });
187
202
  } }))));
@@ -206,6 +221,8 @@ function SimpleTable(_a) {
206
221
  }),
207
222
  value.data.map(function (row, rowIdx) { return genRow({ row: row, rowIdx: rowIdx }); })),
208
223
  !readOnly && enableRowActions && (react_1.default.createElement(AddRowColButtons_1.AddRowButton, { onClick: function () { return (0, handleRowActions_1.handleAddRow)(value, props); } }))),
209
- !readOnly && enableColActions && (react_1.default.createElement(AddRowColButtons_1.AddColButton, { onClick: function () { return (0, handleColActions_1.handleAddCol)(value, props); } })))));
224
+ !readOnly && enableColActions && (react_1.default.createElement(AddRowColButtons_1.AddColButton, { onClick: function () {
225
+ return (0, handleColActions_1.handleAddCol)({ value: value, onChange: onChange, id: id, defaultColWidth: defaultColWidth });
226
+ } })))));
210
227
  }
211
228
  exports.SimpleTable = SimpleTable;
@@ -32,14 +32,18 @@ var themes_1 = require("../../themes");
32
32
  var transitions_1 = require("../../themes/mixins/transitions");
33
33
  var styled_components_1 = __importStar(require("styled-components"));
34
34
  var utilsOolib_1 = require("../../utilsOolib");
35
- exports.StyledSimpleTable = styled_components_1.default.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n border-top: 1px solid ", ";\n border-bottom: 1px solid ", ";\n border-left: 1px solid ", ";\n"], ["\n border-top: 1px solid ", ";\n border-bottom: 1px solid ", ";\n border-left: 1px solid ", ";\n"])), themes_1.colors.greyColor10, themes_1.colors.greyColor10, themes_1.colors.greyColor10);
36
- exports.StyledSimpleTableRow = styled_components_1.default.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n display: flex;\n ", ";\n background-color: ", ";\n"], ["\n display: flex;\n ", ";\n background-color: ", ";\n"])), (0, transitions_1.transition)("background-color"), function (_a) {
35
+ var globalVariables_1 = require("../../globalStyles/globalVariables");
36
+ exports.StyledSimpleTable = styled_components_1.default.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n border-top: 1px solid ", ";\n \n border-left: 1px solid ", ";\n"], ["\n border-top: 1px solid ", ";\n \n border-left: 1px solid ", ";\n"])), themes_1.colors.greyColor10, themes_1.colors.greyColor10);
37
+ exports.StyledSimpleTableRow = styled_components_1.default.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n min-height: 4rem;\n position: relative;\n display: flex;\n ", ";\n /* background-color: ", "; */\n ", "\n"], ["\n min-height: 4rem;\n position: relative;\n display: flex;\n ", ";\n /* background-color: ", "; */\n ", "\n"])), (0, transitions_1.transition)("background-color"), function (_a) {
37
38
  var rowIdx = _a.rowIdx;
38
39
  return rowIdx % 2 === 1 ? themes_1.colors.white : themes_1.colors.greyColor3;
40
+ }, function (_a) {
41
+ var actionsActiveOnRow = _a.actionsActiveOnRow, rowIdx = _a.rowIdx, theme = _a.theme;
42
+ return actionsActiveOnRow === rowIdx && (0, styled_components_1.css)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n &::before{\n content: '';\n position: absolute;\n width: calc(100% - 1px);\n height: calc(100% - 1px);\n outline: 1px solid ", ";\n border: 1px solid ", ";\n z-index: 1;\n }\n "], ["\n &::before{\n content: '';\n position: absolute;\n width: calc(100% - 1px);\n height: calc(100% - 1px);\n outline: 1px solid ", ";\n border: 1px solid ", ";\n z-index: 1;\n }\n "])), (0, utilsOolib_1.getPrimaryColor100)(theme === null || theme === void 0 ? void 0 : theme.colors), (0, utilsOolib_1.getPrimaryColor100)(theme === null || theme === void 0 ? void 0 : theme.colors));
39
43
  });
40
- exports.StyledSimpleTableCell = styled_components_1.default.div(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n position: relative;\n border-right: 1px solid ", ";\n ", ";\n ", "\n"], ["\n position: relative;\n border-right: 1px solid ", ";\n ", ";\n ", "\n"])), themes_1.colors.greyColor10, (0, transitions_1.transition)("background-color"), function (_a) {
41
- var readOnly = _a.readOnly, theme = _a.theme;
42
- return !readOnly && (0, styled_components_1.css)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n :hover{\n background-color: ", ";\n }\n :focus-within{\n outline: 1px solid ", ";\n background-color: ", ";\n } \n "], ["\n :hover{\n background-color: ", ";\n }\n :focus-within{\n outline: 1px solid ", ";\n background-color: ", ";\n } \n "])), (0, utilsOolib_1.getPrimaryColor10)(theme === null || theme === void 0 ? void 0 : theme.colors), (0, utilsOolib_1.getPrimaryColor100)(theme === null || theme === void 0 ? void 0 : theme.colors), themes_1.colors.none);
44
+ exports.StyledSimpleTableCell = styled_components_1.default.div(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n min-height: 4rem;\n position: relative;\n border-right: 1px solid ", ";\n border-bottom: 1px solid ", ";\n ", ";\n \n ", "\n"], ["\n min-height: 4rem;\n position: relative;\n border-right: 1px solid ", ";\n border-bottom: 1px solid ", ";\n ", ";\n \n ", "\n"])), themes_1.colors.greyColor10, themes_1.colors.greyColor10, (0, transitions_1.transition)("background-color"), function (_a) {
45
+ var readOnly = _a.readOnly, theme = _a.theme, actionsActiveOnRow = _a.actionsActiveOnRow;
46
+ return !readOnly && (0, styled_components_1.css)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n ", ";\n \n ", "\n "], ["\n ", ";\n \n ", "\n "])), globalVariables_1.globalHoverOnWhiteBG, !actionsActiveOnRow && (0, styled_components_1.css)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n :focus-within{\n &::before{\n content: '';\n position: absolute;\n width: 100%;\n height: 100%;\n outline: 1px solid ", ";\n border: 1px solid ", ";\n }\n background-color: ", ";\n } \n "], ["\n :focus-within{\n &::before{\n content: '';\n position: absolute;\n width: 100%;\n height: 100%;\n outline: 1px solid ", ";\n border: 1px solid ", ";\n }\n background-color: ", ";\n } \n "])), (0, utilsOolib_1.getPrimaryColor100)(theme === null || theme === void 0 ? void 0 : theme.colors), (0, utilsOolib_1.getPrimaryColor100)(theme === null || theme === void 0 ? void 0 : theme.colors), themes_1.colors.none));
43
47
  });
44
- exports.StyledSimpleTableHeader = styled_components_1.default.div(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n .public-DraftEditor-content {\n font-weight: 600;\n }\n background-color: ", ";\n border-bottom: 2px solid ", ";\n"], ["\n .public-DraftEditor-content {\n font-weight: 600;\n }\n background-color: ", ";\n border-bottom: 2px solid ", ";\n"])), themes_1.colors.greyColor, themes_1.colors.greyColor10);
45
- var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5;
48
+ exports.StyledSimpleTableHeader = styled_components_1.default.div(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n .public-DraftEditor-content {\n font-weight: 600;\n }\n background-color: ", ";\n border-bottom: 2px solid ", ";\n"], ["\n .public-DraftEditor-content {\n font-weight: 600;\n }\n background-color: ", ";\n border-bottom: 2px solid ", ";\n"])), themes_1.colors.greyColor, themes_1.colors.greyColor10);
49
+ var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7;
@@ -22,18 +22,15 @@ exports.globalInputElemFocused = (0, styled_components_1.css)(templateObject_3 |
22
22
  return (invert ? themes_1.colors.greyColor70 : themes_1.colors.greyColor10);
23
23
  });
24
24
  // Lghtbox style used for DatePicker, Dropdowns, hints and ActionMenu
25
- exports.globalLightboxStyle = (0, styled_components_1.css)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n border: 1px solid ", ";\n background-color: ", ";\n border-radius: 2px;\n box-shadow: 2px 2px 10px ", ";\n"], ["\n border: 1px solid ", ";\n background-color: ", ";\n border-radius: 2px;\n box-shadow: 2px 2px 10px ", ";\n"])), function (_a) {
25
+ exports.globalLightboxStyle = (0, styled_components_1.css)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n border: 1px solid ", ";\n background-color: ", ";\n border-radius: 2px;\n ", ";\n"], ["\n border: 1px solid ", ";\n background-color: ", ";\n border-radius: 2px;\n ", ";\n"])), function (_a) {
26
26
  var invert = _a.invert;
27
27
  return (invert ? themes_1.colors.greyColor70 : themes_1.colors.greyColor5);
28
28
  }, function (_a) {
29
29
  var invert = _a.invert;
30
30
  return (invert ? themes_1.colors.greyColor80 : themes_1.colors.white);
31
- }, themes_1.colors.black_opacity05);
32
- exports.globalHoverOnWhiteBG = (0, styled_components_1.css)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n &:hover {\n color: ", ";\n background-color: ", ";\n }\n"], ["\n &:hover {\n color: ", ";\n background-color: ", ";\n }\n"])), function (_a) {
31
+ }, mixins_1.boxShadow1);
32
+ exports.globalHoverOnWhiteBG = (0, styled_components_1.css)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n &:hover {\n background-color: ", ";\n }\n"], ["\n &:hover {\n background-color: ", ";\n }\n"])), function (_a) {
33
33
  var invert = _a.invert;
34
- return invert ? themes_1.colors.white : themes_1.colors.greyColor100;
35
- }, function (_a) {
36
- var invert = _a.invert;
37
- return invert ? themes_1.colors.greyColor70 : themes_1.colors.greyColor10;
34
+ return invert ? themes_1.colors.greyColor80 : themes_1.colors.greyColor5;
38
35
  });
39
36
  var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5;
@@ -6,7 +6,8 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.innerShadow0 = exports.boxShadow1 = exports.boxShadow0 = void 0;
8
8
  var styled_components_1 = require("styled-components");
9
- exports.boxShadow0 = (0, styled_components_1.css)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n box-shadow: 1px 1px 5px rgba(0, 0, 0, 0.05);\n"], ["\n box-shadow: 1px 1px 5px rgba(0, 0, 0, 0.05);\n"])));
10
- exports.boxShadow1 = (0, styled_components_1.css)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.05);\n"], ["\n box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.05);\n"])));
11
- exports.innerShadow0 = (0, styled_components_1.css)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n box-shadow: inset 1px 1px 5px rgba(0, 0, 0, 0.05);\n"], ["\n box-shadow: inset 1px 1px 5px rgba(0, 0, 0, 0.05);\n"])));
9
+ var colors_1 = require("../colors");
10
+ exports.boxShadow0 = (0, styled_components_1.css)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n box-shadow: 1px 1px 5px ", ";\n"], ["\n box-shadow: 1px 1px 5px ", ";\n"])), colors_1.colors.black_opacity05);
11
+ exports.boxShadow1 = (0, styled_components_1.css)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n box-shadow: 2px 2px 10px ", ";\n"], ["\n box-shadow: 2px 2px 10px ", ";\n"])), colors_1.colors.black_opacity05);
12
+ exports.innerShadow0 = (0, styled_components_1.css)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n box-shadow: inset 1px 1px 5px ", ";\n"], ["\n box-shadow: inset 1px 1px 5px ", ";\n"])), colors_1.colors.black_opacity05);
12
13
  var templateObject_1, templateObject_2, templateObject_3;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oolib",
3
- "version": "2.67.9",
3
+ "version": "2.68.1",
4
4
  "description": " OKE Component Library",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -60,6 +60,7 @@
60
60
  "chromatic": "^6.1.0",
61
61
  "copyfiles": "^2.4.1",
62
62
  "cz-conventional-changelog": "^3.3.0",
63
+ "localtunnel": "^2.0.2",
63
64
  "mdx-embed": "^1.0.0",
64
65
  "react": "^17.0.2",
65
66
  "react-dom": "^17.0.2",
@@ -92,7 +93,6 @@
92
93
  "draft-js": "^0.11.7",
93
94
  "draftjs-conductor": "^2.2.0",
94
95
  "immutable": "^3.7.6",
95
- "localtunnel": "^2.0.2",
96
96
  "lodash": "^4.17.21",
97
97
  "modularscale-js": "^3.0.1",
98
98
  "moment": "^2.24.0",
@@ -1,2 +0,0 @@
1
- export function ColActionsMenu({}: {}): React.JSX.Element;
2
- import React from "react";
@@ -1,18 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.ColActionsMenu = void 0;
7
- var react_1 = __importDefault(require("react"));
8
- var ActionMenu_1 = require("../../../ActionMenu");
9
- var ColActionsMenu = function (_a) {
10
- return (react_1.default.createElement("div", { style: { position: 'absolute', top: 0, left: '50%', transform: 'translate(-50%, -100%)' } },
11
- react_1.default.createElement(ActionMenu_1.ActionMenu, { actions: [
12
- {
13
- display: 'Dummy',
14
- onClick: function () { return console.log('dummy'); },
15
- }
16
- ] })));
17
- };
18
- exports.ColActionsMenu = ColActionsMenu;
@@ -1,7 +0,0 @@
1
- export function RowActionsMenu({ value, rowIdx, onChange, id }: {
2
- value: any;
3
- rowIdx: any;
4
- onChange: any;
5
- id: any;
6
- }): React.JSX.Element;
7
- import React from "react";