oolib 2.227.6 → 2.227.7

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.
Files changed (39) hide show
  1. package/dist/UIContent/index.d.ts +0 -15
  2. package/dist/UIContent/index.js +0 -14
  3. package/dist/index.d.ts +0 -1
  4. package/dist/index.js +2 -4
  5. package/package.json +1 -1
  6. package/dist/components/SimpleTable/comps/AddRowColButtons/index.d.ts +0 -9
  7. package/dist/components/SimpleTable/comps/AddRowColButtons/index.js +0 -77
  8. package/dist/components/SimpleTable/comps/rowColActionMenus/ColActionsMenu/index.d.ts +0 -11
  9. package/dist/components/SimpleTable/comps/rowColActionMenus/ColActionsMenu/index.js +0 -95
  10. package/dist/components/SimpleTable/comps/rowColActionMenus/RowActionsMenu/index.d.ts +0 -12
  11. package/dist/components/SimpleTable/comps/rowColActionMenus/RowActionsMenu/index.js +0 -120
  12. package/dist/components/SimpleTable/comps/rowColActionMenus/styled.d.ts +0 -1
  13. package/dist/components/SimpleTable/comps/rowColActionMenus/styled.js +0 -18
  14. package/dist/components/SimpleTable/handlers/handleColActions.d.ts +0 -38
  15. package/dist/components/SimpleTable/handlers/handleColActions.js +0 -155
  16. package/dist/components/SimpleTable/handlers/handleRowActions.d.ts +0 -34
  17. package/dist/components/SimpleTable/handlers/handleRowActions.js +0 -96
  18. package/dist/components/SimpleTable/handlers/handleStretchToFullWidth.d.ts +0 -8
  19. package/dist/components/SimpleTable/handlers/handleStretchToFullWidth.js +0 -34
  20. package/dist/components/SimpleTable/handlers/handleToggleColHeader.d.ts +0 -5
  21. package/dist/components/SimpleTable/handlers/handleToggleColHeader.js +0 -21
  22. package/dist/components/SimpleTable/handlers/handleToggleRowHeader.d.ts +0 -5
  23. package/dist/components/SimpleTable/handlers/handleToggleRowHeader.js +0 -31
  24. package/dist/components/SimpleTable/index.d.ts +0 -31
  25. package/dist/components/SimpleTable/index.js +0 -366
  26. package/dist/components/SimpleTable/styled.d.ts +0 -5
  27. package/dist/components/SimpleTable/styled.js +0 -80
  28. package/dist/components/SimpleTable/useResizeTableColumns.d.ts +0 -21
  29. package/dist/components/SimpleTable/useResizeTableColumns.js +0 -88
  30. package/dist/components/SimpleTable/utils/convertColHeaderConfigToRowData.d.ts +0 -8
  31. package/dist/components/SimpleTable/utils/convertColHeaderConfigToRowData.js +0 -16
  32. package/dist/components/SimpleTable/utils/convertRowHeaderConfigToCellData.d.ts +0 -10
  33. package/dist/components/SimpleTable/utils/convertRowHeaderConfigToCellData.js +0 -13
  34. package/dist/components/SimpleTable/utils/genHash.d.ts +0 -1
  35. package/dist/components/SimpleTable/utils/genHash.js +0 -13
  36. package/dist/components/SimpleTable/utils/prepInitValueFromConfigIfNoValue.d.ts +0 -10
  37. package/dist/components/SimpleTable/utils/prepInitValueFromConfigIfNoValue.js +0 -79
  38. package/dist/stories/Oolib/components/SimpleTable.stories.d.ts +0 -67
  39. package/dist/stories/Oolib/components/SimpleTable.stories.js +0 -128
@@ -1,34 +0,0 @@
1
- export function handleAddRow(value: any, props: any): void;
2
- export function handleDeleteRow({ value, rowIdx, onChange, id }: {
3
- value: any;
4
- rowIdx: any;
5
- onChange: any;
6
- id: any;
7
- }): void;
8
- export function handleDuplicateRow({ value, rowIdx, onChange, id }: {
9
- value: any;
10
- rowIdx: any;
11
- onChange: any;
12
- id: any;
13
- }): void;
14
- export function handleInsertRowAfter({ value, rowIdx, onChange, id, blockConfig }: {
15
- value: any;
16
- rowIdx: any;
17
- onChange: any;
18
- id: any;
19
- blockConfig: any;
20
- }): void;
21
- export function handleInsertRowBefore({ value, rowIdx, onChange, id, blockConfig }: {
22
- value: any;
23
- rowIdx: any;
24
- onChange: any;
25
- id: any;
26
- blockConfig: any;
27
- }): void;
28
- export function handleClearRowContent({ value, rowIdx, onChange, id, blockConfig }: {
29
- value: any;
30
- rowIdx: any;
31
- onChange: any;
32
- id: any;
33
- blockConfig: any;
34
- }): void;
@@ -1,96 +0,0 @@
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
- };
13
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
14
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
15
- if (ar || !(i in from)) {
16
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
17
- ar[i] = from[i];
18
- }
19
- }
20
- return to.concat(ar || Array.prototype.slice.call(from));
21
- };
22
- Object.defineProperty(exports, "__esModule", { value: true });
23
- exports.handleClearRowContent = exports.handleInsertRowBefore = exports.handleInsertRowAfter = exports.handleDuplicateRow = exports.handleDeleteRow = exports.handleAddRow = void 0;
24
- var makeArrayFromLength_1 = require("../../../utils/makeArrayFromLength");
25
- var genHash_1 = require("../utils/genHash");
26
- var genNewRow = function (_a) {
27
- var data = _a.data, rowIdx = _a.rowIdx, blockConfig = _a.blockConfig;
28
- var totCells = data[rowIdx].cellData.length;
29
- return ({
30
- id: "row_".concat((0, genHash_1.genHash)(8)),
31
- cellData: (0, makeArrayFromLength_1.makeArrayFromLength)(totCells).map(function (d, i) {
32
- var _a, _b;
33
- return (__assign(__assign({ id: "cell_".concat((0, genHash_1.genHash)(8)) }, (((_a = blockConfig === null || blockConfig === void 0 ? void 0 : blockConfig[i]) === null || _a === void 0 ? void 0 : _a.comp) ? { comp: blockConfig[i].comp } : {})), (((_b = blockConfig === null || blockConfig === void 0 ? void 0 : blockConfig[i]) === null || _b === void 0 ? void 0 : _b.props) ? { props: blockConfig[i].props } : {})));
34
- })
35
- });
36
- };
37
- var handleAddRow = function (value, props) {
38
- var onChange = props.onChange, id = props.id, config = props.config;
39
- var data = value.data, colWidthConfig = value.colWidthConfig;
40
- var newData = __spreadArray([], data, true);
41
- var lastRowIdx = newData.length - 1;
42
- var newRow = genNewRow({ data: newData, rowIdx: lastRowIdx, blockConfig: config === null || config === void 0 ? void 0 : config.blockConfig });
43
- newData.push(newRow);
44
- onChange && onChange(id, { data: newData, colWidthConfig: colWidthConfig });
45
- };
46
- exports.handleAddRow = handleAddRow;
47
- var handleDeleteRow = function (_a) {
48
- var value = _a.value, rowIdx = _a.rowIdx, onChange = _a.onChange, id = _a.id;
49
- var data = value.data, colWidthConfig = value.colWidthConfig;
50
- var newData = __spreadArray([], data, true);
51
- newData.splice(rowIdx, 1);
52
- onChange && onChange(id, { data: newData, colWidthConfig: colWidthConfig });
53
- };
54
- exports.handleDeleteRow = handleDeleteRow;
55
- var handleDuplicateRow = function (_a) {
56
- var value = _a.value, rowIdx = _a.rowIdx, onChange = _a.onChange, id = _a.id;
57
- var data = value.data, colWidthConfig = value.colWidthConfig;
58
- var newData = __spreadArray([], data, true);
59
- 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)) })); }) });
60
- newData.splice(rowIdx + 1, 0, dataToDuplicate);
61
- onChange && onChange(id, { data: newData, colWidthConfig: colWidthConfig });
62
- };
63
- exports.handleDuplicateRow = handleDuplicateRow;
64
- var handleInsertRowAfter = function (_a) {
65
- var value = _a.value, rowIdx = _a.rowIdx, onChange = _a.onChange, id = _a.id, blockConfig = _a.blockConfig;
66
- var data = value.data, colWidthConfig = value.colWidthConfig;
67
- var newData = __spreadArray([], data, true);
68
- var newRow = genNewRow({ data: newData, rowIdx: rowIdx, blockConfig: blockConfig });
69
- newData.splice(rowIdx + 1, 0, newRow);
70
- onChange && onChange(id, { data: newData, colWidthConfig: colWidthConfig });
71
- };
72
- exports.handleInsertRowAfter = handleInsertRowAfter;
73
- var handleInsertRowBefore = function (_a) {
74
- var value = _a.value, rowIdx = _a.rowIdx, onChange = _a.onChange, id = _a.id, blockConfig = _a.blockConfig;
75
- var data = value.data, colWidthConfig = value.colWidthConfig;
76
- var newData = __spreadArray([], data, true);
77
- var newRow = genNewRow({ data: newData, rowIdx: rowIdx, blockConfig: blockConfig });
78
- newData.splice(rowIdx, 0, newRow);
79
- onChange && onChange(id, { data: newData, colWidthConfig: colWidthConfig });
80
- };
81
- exports.handleInsertRowBefore = handleInsertRowBefore;
82
- var handleClearRowContent = function (_a) {
83
- var value = _a.value, rowIdx = _a.rowIdx, onChange = _a.onChange, id = _a.id, blockConfig = _a.blockConfig;
84
- var data = value.data, colWidthConfig = value.colWidthConfig;
85
- var newData = __spreadArray([], data, true);
86
- /**
87
- * this genNewRow does one very important thing apart from the obvious of clearing the value:
88
- * it creates a fresh new row id, which changes the 'react key' of the row being rendered, which
89
- * ensures the the RTE used within the cell is reinitiated and the previous value in it is cleared.
90
- * (since RTEs are not controlled components)
91
- */
92
- var newRow = genNewRow({ data: newData, rowIdx: rowIdx, blockConfig: blockConfig });
93
- newData.splice(rowIdx, 1, newRow);
94
- onChange && onChange(id, { data: newData, colWidthConfig: colWidthConfig });
95
- };
96
- exports.handleClearRowContent = handleClearRowContent;
@@ -1,8 +0,0 @@
1
- export function handleStretchToFullWidth({ value, onChange, id, enableColActions, addColButtonWidth, fullWidthCompWrapper, }: {
2
- value: any;
3
- onChange: any;
4
- id: any;
5
- enableColActions: any;
6
- addColButtonWidth: any;
7
- fullWidthCompWrapper: any;
8
- }): void;
@@ -1,34 +0,0 @@
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
- };
13
- Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.handleStretchToFullWidth = void 0;
15
- var handleStretchToFullWidth = function (_a) {
16
- var _b;
17
- var value = _a.value, onChange = _a.onChange, id = _a.id, enableColActions = _a.enableColActions, addColButtonWidth = _a.addColButtonWidth, fullWidthCompWrapper = _a.fullWidthCompWrapper;
18
- var data = value.data, colWidthConfig = value.colWidthConfig;
19
- var totalAvailableWidth = ((_b = fullWidthCompWrapper.current) === null || _b === void 0 ? void 0 : _b.getBoundingClientRect().width) -
20
- (enableColActions ? addColButtonWidth : 0);
21
- var noOfCols = data[0].cellData.length;
22
- var widthPerCol = totalAvailableWidth / noOfCols + "px";
23
- var newColWidthConfig = Object.keys(colWidthConfig)
24
- .map(function (k) { return ({
25
- colId: k,
26
- width: widthPerCol,
27
- }); })
28
- .reduce(function (a, b) {
29
- var _a;
30
- return (__assign(__assign({}, a), (_a = {}, _a[b.colId] = b.width, _a)));
31
- }, {});
32
- onChange && onChange(id, { data: data, colWidthConfig: newColWidthConfig });
33
- };
34
- exports.handleStretchToFullWidth = handleStretchToFullWidth;
@@ -1,5 +0,0 @@
1
- export function handleToggleColHeader({ value, onChange, id }: {
2
- value: any;
3
- onChange: any;
4
- id: any;
5
- }): void;
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.handleToggleColHeader = void 0;
4
- var lodash_1 = require("lodash");
5
- var handleToggleColHeader = function (_a) {
6
- var value = _a.value, onChange = _a.onChange, id = _a.id;
7
- var data = value.data, colWidthConfig = value.colWidthConfig;
8
- var newData = data.map(function (row) {
9
- var newRowData = (0, lodash_1.cloneDeep)(row);
10
- if (newRowData.cellData[0].isRowHeader) { //then remove
11
- delete newRowData.cellData[0].isRowHeader;
12
- }
13
- else {
14
- newRowData.cellData[0].isRowHeader = true;
15
- }
16
- return newRowData;
17
- });
18
- onChange &&
19
- onChange(id, { data: newData, colWidthConfig: colWidthConfig });
20
- };
21
- exports.handleToggleColHeader = handleToggleColHeader;
@@ -1,5 +0,0 @@
1
- export function handleToggleRowHeader({ value, onChange, id }: {
2
- value: any;
3
- onChange: any;
4
- id: any;
5
- }): void;
@@ -1,31 +0,0 @@
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
- };
13
- Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.handleToggleRowHeader = void 0;
15
- var handleToggleRowHeader = function (_a) {
16
- var value = _a.value, onChange = _a.onChange, id = _a.id;
17
- var data = value.data, colWidthConfig = value.colWidthConfig;
18
- var newData = data.map(function (row, rowIdx) {
19
- if (row.isColHeader) { //then remove
20
- var newRow = __assign({}, row);
21
- delete newRow.isColHeader;
22
- return newRow;
23
- }
24
- else { //else add
25
- return __assign(__assign({}, row), (rowIdx === 0 ? { isColHeader: true } : {}));
26
- }
27
- });
28
- onChange &&
29
- onChange(id, { data: newData, colWidthConfig: colWidthConfig });
30
- };
31
- exports.handleToggleRowHeader = handleToggleRowHeader;
@@ -1,31 +0,0 @@
1
- /**
2
- * PENDINGS
3
- * - Ideally should migrate RichTextEditor to Lexical
4
- * - Should run a function that converts rich text to plain text and sends that out in onChange. (like how we do for TitleInput)
5
- * - for backwards compatibility, in the initValueSetting function, we should convert all plain text values to lexical shape & all draftjs shaped values also to lexical shape
6
- * - memoization of cell comps maybe? there is some commented code for the same below..
7
- * - KNOWN ISSUE: when the number input block is used, the component is lagging like mad. might have something to
8
- * do with the memoization issue
9
- */
10
- export function SimpleTable({ id, readOnly, config, value: _value, onChange, defaultColWidth, }: {
11
- id: any;
12
- readOnly: any;
13
- config?: {
14
- noOfCols: number;
15
- noOfRows: number;
16
- headerForRowHeadersColumn: any;
17
- colHeaderData: any;
18
- rowHeaderData: any;
19
- disableAddRow: boolean;
20
- disableRowActionsMenu: boolean;
21
- disablePrimaryActionsMenu: boolean;
22
- blockConfig: {
23
- comp: string;
24
- props: {};
25
- }[];
26
- };
27
- value: any;
28
- onChange: any;
29
- defaultColWidth?: number;
30
- }, ...args: any[]): React.JSX.Element;
31
- import React from "react";
@@ -1,366 +0,0 @@
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
- };
13
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
- if (k2 === undefined) k2 = k;
15
- var desc = Object.getOwnPropertyDescriptor(m, k);
16
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17
- desc = { enumerable: true, get: function() { return m[k]; } };
18
- }
19
- Object.defineProperty(o, k2, desc);
20
- }) : (function(o, m, k, k2) {
21
- if (k2 === undefined) k2 = k;
22
- o[k2] = m[k];
23
- }));
24
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
25
- Object.defineProperty(o, "default", { enumerable: true, value: v });
26
- }) : function(o, v) {
27
- o["default"] = v;
28
- });
29
- var __importStar = (this && this.__importStar) || (function () {
30
- var ownKeys = function(o) {
31
- ownKeys = Object.getOwnPropertyNames || function (o) {
32
- var ar = [];
33
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
34
- return ar;
35
- };
36
- return ownKeys(o);
37
- };
38
- return function (mod) {
39
- if (mod && mod.__esModule) return mod;
40
- var result = {};
41
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
42
- __setModuleDefault(result, mod);
43
- return result;
44
- };
45
- })();
46
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
47
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
48
- if (ar || !(i in from)) {
49
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
50
- ar[i] = from[i];
51
- }
52
- }
53
- return to.concat(ar || Array.prototype.slice.call(from));
54
- };
55
- Object.defineProperty(exports, "__esModule", { value: true });
56
- exports.SimpleTable = SimpleTable;
57
- var react_1 = __importStar(require("react"));
58
- var themes_1 = require("../../themes");
59
- var getBlockLabelProps_1 = require("../../utils/getBlockLabelProps");
60
- var BlockLabel_1 = require("../../v2/components/BlockLabel");
61
- //local utils
62
- var styled_components_1 = require("styled-components");
63
- var utilsOolib_1 = require("../../utilsOolib");
64
- var AddRowColButtons_1 = require("./comps/AddRowColButtons");
65
- var UIContent_1 = require("../../UIContent");
66
- var ActionMenu_1 = require("../ActionMenu");
67
- var ColActionsMenu_1 = require("./comps/rowColActionMenus/ColActionsMenu");
68
- var RowActionsMenu_1 = require("./comps/rowColActionMenus/RowActionsMenu");
69
- var handleColActions_1 = require("./handlers/handleColActions");
70
- var handleRowActions_1 = require("./handlers/handleRowActions");
71
- var handleStretchToFullWidth_1 = require("./handlers/handleStretchToFullWidth");
72
- var handleToggleRowHeader_1 = require("./handlers/handleToggleRowHeader");
73
- var handleToggleColHeader_1 = require("./handlers/handleToggleColHeader");
74
- var styled_1 = require("./styled");
75
- var useResizeTableColumns_1 = require("./useResizeTableColumns");
76
- var convertColHeaderConfigToRowData_1 = require("./utils/convertColHeaderConfigToRowData");
77
- var convertRowHeaderConfigToCellData_1 = require("./utils/convertRowHeaderConfigToCellData");
78
- var prepInitValueFromConfigIfNoValue_1 = require("./utils/prepInitValueFromConfigIfNoValue");
79
- var icons_1 = require("../../icons");
80
- var Typo2_1 = require("../../v2/components/Typo2");
81
- var DropdownSingle_1 = require("../../v2/components/Dropdowns/DropdownSingle");
82
- var TextInputs_1 = require("../../v2/components/TextInputs");
83
- var ArrowDown = icons_1.icons.ArrowDown;
84
- var greyColor100 = themes_1.colors.greyColor100;
85
- /**
86
- * PENDINGS
87
- * - Ideally should migrate RichTextEditor to Lexical
88
- * - Should run a function that converts rich text to plain text and sends that out in onChange. (like how we do for TitleInput)
89
- * - for backwards compatibility, in the initValueSetting function, we should convert all plain text values to lexical shape & all draftjs shaped values also to lexical shape
90
- * - memoization of cell comps maybe? there is some commented code for the same below..
91
- * - KNOWN ISSUE: when the number input block is used, the component is lagging like mad. might have something to
92
- * do with the memoization issue
93
- */
94
- function SimpleTable(_a) {
95
- var id = _a.id, readOnly = _a.readOnly, _b = _a.config, config = _b === void 0 ? {
96
- noOfCols: 3,
97
- noOfRows: 3,
98
- headerForRowHeadersColumn: undefined,
99
- colHeaderData: undefined,
100
- rowHeaderData: undefined,
101
- disableAddRow: false,
102
- disableRowActionsMenu: false,
103
- disablePrimaryActionsMenu: false,
104
- blockConfig: [undefined, { comp: 'DropdownSingle', props: {} }, { comp: 'DropdownSingle', props: {} }]
105
- } : _b, _value = _a.value, onChange = _a.onChange, _c = _a.defaultColWidth, defaultColWidth = _c === void 0 ? 200 : _c;
106
- var props = arguments[0];
107
- var localize = (0, utilsOolib_1.useLocale)();
108
- var theme = (0, styled_components_1.useTheme)();
109
- var _d = theme || {}, RichTextEditor = _d.RichTextEditor /*: _RichTextEditor*/, convertToRichText = _d.convertToRichText;
110
- //memoizing cuz we dont want all cell rtes to render everytime one cell changes
111
- // const RichTextEditor = useMemo(() => {
112
- // const checkMemoFn = (prevProps, currentProps) => {
113
- // const {
114
- // value: prevVal,
115
- // } = prevProps
116
- // const {
117
- // value: currentVal
118
- // } = currentProps
119
- // return isEqual(prevVal, currentVal)
120
- // }
121
- // return _RichTextEditor && React.memo(_RichTextEditor, checkMemoFn)
122
- // },[])
123
- var _e = (0, react_1.useMemo)(function () {
124
- return (0, prepInitValueFromConfigIfNoValue_1.prepInitValueFromConfigIfNoValue)({
125
- //memo v.imp cuz otherwise cell and row id keep changing on rerender if value doesnt exist, and this messes with their react keys, this leads to bugs
126
- _value: _value,
127
- config: config,
128
- defaultColWidth: defaultColWidth,
129
- });
130
- }, [_value]), value = _e.value, enableColActions = _e.enableColActions, //returns all possible actions config if no config.colHeaderData is defined. else undefined\
131
- enableRowActions = _e.enableRowActions;
132
- var _f = (0, useResizeTableColumns_1.useResizeTableColumns)({
133
- setColWidthConfig: function (setterFn) {
134
- var newColWidthConfig = setterFn(value.colWidthConfig);
135
- onChange(id, __assign(__assign({}, value), { colWidthConfig: newColWidthConfig }));
136
- }, // here we are replicating the setState(prev => do something) behaviour
137
- colWidthConfig: value.colWidthConfig,
138
- theme: theme,
139
- }), resetColResizeState = _f.resetColResizeState, hideShowDragZoneIndicator = _f.hideShowDragZoneIndicator, initColResizeState = _f.initColResizeState, resetDragZoneIndicator = _f.resetDragZoneIndicator, handleResizeColumn = _f.handleResizeColumn, colResizeState = _f.colResizeState, dragZoneWidth = _f.dragZoneWidth;
140
- (0, react_1.useEffect)(function () {
141
- window.addEventListener("mouseup", resetColResizeState);
142
- window.addEventListener("mousemove", handleResizeColumn);
143
- return function () {
144
- window.removeEventListener("mousemove", handleResizeColumn);
145
- window.removeEventListener("mouseup", resetColResizeState);
146
- };
147
- }, [colResizeState]);
148
- var CellContentBlocks = {
149
- RichTextEditor: RichTextEditor,
150
- DropdownSingle: DropdownSingle_1.DropdownSingle,
151
- NumberInput: TextInputs_1.NumberInput,
152
- TextInput: TextInputs_1.TextInput,
153
- };
154
- var CellContentBlockDefaultProps = {
155
- RichTextEditor: {
156
- variant: "simple",
157
- typo: "SANS_3",
158
- placeholder: " ",
159
- style: {
160
- padding: "0.9rem 1rem",
161
- },
162
- },
163
- DropdownSingle: {
164
- selectStyleOverride: {
165
- backgroundColor: themes_1.colors.none,
166
- },
167
- popOutOfOverflowHiddenParent: true,
168
- },
169
- NumberInput: {
170
- selectStyleOverride: {
171
- backgroundColor: themes_1.colors.none,
172
- },
173
- },
174
- TextInput: {
175
- selectStyleOverride: {
176
- backgroundColor: themes_1.colors.none,
177
- },
178
- },
179
- };
180
- var CellValueGetters = {
181
- RichTextEditor: function (v) { return (convertToRichText ? convertToRichText(v) : v); },
182
- }; //prob dont need this..
183
- var _g = (0, react_1.useState)(undefined), actionsActiveOnRow = _g[0], setActionsActiveOnRow = _g[1];
184
- var _h = (0, react_1.useState)(undefined), actionsActiveOnCol = _h[0], setActionsActiveOnCol = _h[1];
185
- var _j = (0, react_1.useState)({
186
- rowIdx: undefined,
187
- colIdx: undefined,
188
- }), hoveredRowAndCol = _j[0], setHoveredRowAndCol = _j[1];
189
- var handleCellInputChange = function (_a) {
190
- var cellIdx = _a.cellIdx, rowIdx = _a.rowIdx, v = _a.v;
191
- var valData = value.data;
192
- var colWidthConfig = value.colWidthConfig;
193
- var newData = __spreadArray([], valData, true);
194
- newData[rowIdx].cellData[cellIdx].value = v;
195
- onChange && onChange(id, { data: newData, colWidthConfig: colWidthConfig });
196
- };
197
- /**
198
- * we are explicitly defining this here and passing it on to AddColButton comp
199
- * since we need this width to calculate stretch to full width
200
- */
201
- var addColButtonWidth = 20;
202
- // these are explicitly defined here cuz we need to calc offset padding and margin using these, so that overflowX doesnt hide them
203
- var rowActionsButtonWidth = 15;
204
- var colActionsButtonHeight = 15;
205
- var primaryTableActionsMenuHeight = 30;
206
- var primaryTableActionsMenuGap = 5;
207
- var genCell = function (_a) {
208
- var cell = _a.cell, cellIdx = _a.cellIdx, rowIdx = _a.rowIdx, _b = _a.enableColResizeActions // cuz in the case of pre fixed column (via config.rowHeaderData), enableResize will be set to false
209
- , enableColResizeActions = _b === void 0 ? true : _b // cuz in the case of pre fixed column (via config.rowHeaderData), enableResize will be set to false
210
- ;
211
- var cellCompName = cell.comp || 'RichTextEditor';
212
- var NoCompPlaceholder = function () { return react_1.default.createElement("div", null, "No comp exists"); };
213
- console.log({ cellCompName: cellCompName, CellContentBlocks: CellContentBlocks });
214
- var CellComp = CellContentBlocks[cellCompName] || NoCompPlaceholder;
215
- console.log({ CellComp: CellComp });
216
- var cellProps = CellContentBlockDefaultProps[cellCompName] ? __assign(__assign({}, CellContentBlockDefaultProps[cellCompName]), (cell.props || {})) : {};
217
- var cellValue = CellValueGetters[cellCompName] ? CellValueGetters[cellCompName](cell.value) : cell.value;
218
- var cellWidth = value.colWidthConfig["col_".concat(cellIdx)] || defaultColWidth + 'px'; //cuz when pre-fixed column is applied via config.rowHeaderData, no colWidthConfig will be there for it in value.colWidthConfig
219
- //(100% - totalExplicitWidths)/(totalColumns - noOfColsWithExplicitWidths)
220
- // let cellProps = {
221
- // ...CellContentBlockDefaultProps[cell.comp],
222
- // ...(cell.props ? cell.props : {}),
223
- // }
224
- if (cell.isRowHeader)
225
- console.log({ cell: cell });
226
- var StyledCellWrapper = cell.isRowHeader
227
- ? styled_1.StyledSimpleTableHeaderCell
228
- : styled_1.StyledSimpleTableCell;
229
- return (react_1.default.createElement(StyledCellWrapper, __assign({ key: cell.id, id: "kp_table__cell__".concat(cell.id), readOnly: readOnly || cell.readOnly, style: {
230
- color: greyColor100,
231
- width: "".concat(cellWidth),
232
- borderRight: (colResizeState === null || colResizeState === void 0 ? void 0 : colResizeState.colId) === "col_".concat(cellIdx) &&
233
- "2px solid ".concat((0, utilsOolib_1.getPrimaryColor100)(theme === null || theme === void 0 ? void 0 : theme.colors)),
234
- }, actionsActiveOnRow: actionsActiveOnRow, colIdx: cellIdx, rowIdx: rowIdx, totRows: value.data.length, actionsActiveOnCol: actionsActiveOnCol }, (enableColResizeActions
235
- ? {
236
- onMouseEnter: function (e) {
237
- setHoveredRowAndCol({
238
- rowIdx: rowIdx,
239
- colIdx: cellIdx,
240
- });
241
- },
242
- onMouseDown: function (e) {
243
- initColResizeState(e, { colId: "col_".concat(cellIdx) });
244
- },
245
- onMouseOut: function (e) { return resetDragZoneIndicator(__assign({ e: e }, (cell.isRowHeader ? { borderStyleInactive: "2px solid ".concat(themes_1.colors.greyColor10) } : {}))); },
246
- onMouseMove: function (e) { return hideShowDragZoneIndicator(__assign({ e: e }, (cell.isRowHeader ? {
247
- borderStyleInactive: "2px solid ".concat(themes_1.colors.greyColor10),
248
- borderStyleActive: "2px solid ".concat((0, utilsOolib_1.getPrimaryColor100)(theme === null || theme === void 0 ? void 0 : theme.colors))
249
- } : {}))); }
250
- } : {}), { tabIndex: 0 }),
251
- react_1.default.createElement(ColActionsMenu_1.ColActionsMenu, { value: value, colIdx: cellIdx, onChange: onChange, id: id, defaultColWidth: defaultColWidth, setActionsActiveOnCol: setActionsActiveOnCol, colActionsButtonHeight: colActionsButtonHeight, conditionsToRender: !readOnly &&
252
- enableColActions &&
253
- rowIdx === 0 &&
254
- hoveredRowAndCol.colIdx === cellIdx }),
255
- !config.disableRowActionsMenu && react_1.default.createElement(RowActionsMenu_1.RowActionsMenu, { value: value, rowIdx: rowIdx, onChange: onChange, id: id, setActionsActiveOnRow: setActionsActiveOnRow, rowActionsButtonWidth: rowActionsButtonWidth, disableAddRow: config === null || config === void 0 ? void 0 : config.disableAddRow,
256
- blockConfig: config === null || config === void 0 ? void 0 : config.blockConfig,
257
- conditionsToRender: !readOnly &&
258
- enableRowActions &&
259
- cellIdx === 0 &&
260
- rowIdx !== undefined && //cuz for fixed col headers, rowIdx is undefined
261
- hoveredRowAndCol.rowIdx === rowIdx }),
262
- react_1.default.createElement("div", { style: { marginRight: dragZoneWidth + "px" } },
263
- 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) {
264
- return handleCellInputChange({ v: v, rowIdx: rowIdx, cellIdx: cellIdx });
265
- } })))));
266
- };
267
- var genRow = function (_a) {
268
- var row = _a.row, rowIdx = _a.rowIdx;
269
- var StyledWrapper = row.isColHeader
270
- ? styled_1.StyledSimpleTableHeader
271
- : styled_1.StyledSimpleTableRow;
272
- // const NoCompPlaceholder = () => <div>No comp exists</div>;
273
- // let CellCompNameForHeaderForRowHeadersColumn = CellContentBlocks["RichTextEditor"] || NoCompPlaceholder
274
- return (react_1.default.createElement(StyledWrapper, { actionsActiveOnRow: actionsActiveOnRow,
275
- // onClick={() => row.link && history.push(row.link)}
276
- style: { display: "flex" }, readOnly: readOnly, rowIdx: rowIdx, key: row.id },
277
- config.rowHeaderData && (row.isColHeader && config.headerForRowHeadersColumn !== undefined ? (react_1.default.createElement(styled_1.StyledSimpleTableHeaderCell, { key: "cornerHeaderCell", id: "kp_table__cell__cornerHeaderCell", readOnly: true, style: {
278
- color: greyColor100,
279
- width: value.colWidthConfig["col_corner"] || defaultColWidth + 'px',
280
- } },
281
- react_1.default.createElement("div", { style: { display: "flex", gap: "0.5rem", alignItems: "center", padding: "0.9rem 1rem" } },
282
- react_1.default.createElement(Typo2_1.UI_BODY_BOLD_SM, null, config.headerForRowHeadersColumn),
283
- react_1.default.createElement(ArrowDown, { size: 14, weight: "bold" })))) : (genCell({
284
- cell: (0, convertRowHeaderConfigToCellData_1.convertRowHeaderConfigToCellData)({
285
- rowHeaderData: config.rowHeaderData.map(function (d) { return localize(d); }),
286
- convertToRichText: convertToRichText,
287
- rowIdx: rowIdx
288
- }),
289
- enableColResizeActions: false
290
- }))),
291
- row.cellData.map(function (cell, cellIdx) { return genCell({ cell: cell, cellIdx: cellIdx, rowIdx: rowIdx }); })));
292
- };
293
- var fullWidthCompWrapper = (0, react_1.useRef)(null);
294
- return (react_1.default.createElement("div", null,
295
- react_1.default.createElement(BlockLabel_1.BlockLabel, __assign({}, (0, getBlockLabelProps_1.getBlockLabelProps)(props))),
296
- react_1.default.createElement("div", { style: {
297
- overflowX: "auto",
298
- paddingLeft: rowActionsButtonWidth / 2 + "px",
299
- marginLeft: "-" + rowActionsButtonWidth / 2 + "px",
300
- paddingTop: primaryTableActionsMenuGap + primaryTableActionsMenuHeight + "px",
301
- } },
302
- react_1.default.createElement("div", { ref: fullWidthCompWrapper, style: {
303
- display: "flex",
304
- alignItems: "stretch" /**without stretch AddColButton will be wonky */,
305
- } },
306
- react_1.default.createElement("div", { style: { position: "relative" } },
307
- !readOnly && !config.disablePrimaryActionsMenu && (react_1.default.createElement("div", { style: {
308
- position: "absolute",
309
- right: 0,
310
- top: "-" + primaryTableActionsMenuGap + "px",
311
- transform: "translateY(-100%)",
312
- zIndex: 10,
313
- } },
314
- react_1.default.createElement(ActionMenu_1.ActionMenu, { ButtonComp: "ButtonPrimary", actions: __spreadArray(__spreadArray([
315
- {
316
- display: UIContent_1.UIContent.SimpleTable.stretchToFullWidth,
317
- onClick: function () {
318
- return (0, handleStretchToFullWidth_1.handleStretchToFullWidth)({
319
- value: value,
320
- onChange: onChange,
321
- id: id,
322
- enableColActions: enableColActions,
323
- addColButtonWidth: addColButtonWidth,
324
- fullWidthCompWrapper: fullWidthCompWrapper,
325
- });
326
- },
327
- }
328
- ], (enableRowActions
329
- ? [
330
- {
331
- icon: "SquareHalf",
332
- display: value.data[0].cellData[0].isRowHeader
333
- ? UIContent_1.UIContent.SimpleTable.removeHeaderCol
334
- : UIContent_1.UIContent.SimpleTable.addHeaderCol,
335
- onClick: function () { return (0, handleToggleColHeader_1.handleToggleColHeader)({ value: value, onChange: onChange, id: id }); },
336
- },
337
- ]
338
- : []), true), (enableColActions
339
- ? [
340
- {
341
- icon: "SquareHalfBottom",
342
- display: value.data[0].isColHeader
343
- ? UIContent_1.UIContent.SimpleTable.removeHeaderRow
344
- : UIContent_1.UIContent.SimpleTable.addHeaderRow,
345
- onClick: function () {
346
- return (0, handleToggleRowHeader_1.handleToggleRowHeader)({ value: value, onChange: onChange, id: id });
347
- },
348
- },
349
- ]
350
- : []), true) }))),
351
- react_1.default.createElement(styled_1.StyledSimpleTable, { onMouseLeave: function () {
352
- return setHoveredRowAndCol({ rowIdx: undefined, colIdx: undefined });
353
- } },
354
- config.colHeaderData &&
355
- genRow({
356
- row: (0, convertColHeaderConfigToRowData_1.convertColHeaderConfigToRowData)({
357
- colHeaderData: config.colHeaderData.map(function (d) { return localize(d); }),
358
- convertToRichText: convertToRichText,
359
- }),
360
- }),
361
- value.data.map(function (row, rowIdx) { return genRow({ row: row, rowIdx: rowIdx }); })),
362
- !readOnly && enableRowActions && !config.disableAddRow && (react_1.default.createElement(AddRowColButtons_1.AddRowButton, { onClick: function () { return (0, handleRowActions_1.handleAddRow)(value, props); } }))),
363
- !readOnly && enableColActions && (react_1.default.createElement(AddRowColButtons_1.AddColButton, { enableRowActions: enableRowActions, addColButtonWidth: addColButtonWidth, onClick: function () {
364
- return (0, handleColActions_1.handleAddCol)({ value: value, onChange: onChange, id: id, defaultColWidth: defaultColWidth });
365
- } }))))));
366
- }
@@ -1,5 +0,0 @@
1
- export const StyledSimpleTable: import("styled-components").StyledComponent<"div", any, {}, never>;
2
- export const StyledSimpleTableRow: import("styled-components").StyledComponent<"div", any, {}, never>;
3
- export const StyledSimpleTableCell: import("styled-components").StyledComponent<"div", any, {}, never>;
4
- export const StyledSimpleTableHeaderCell: import("styled-components").StyledComponent<"div", any, {}, never>;
5
- export const StyledSimpleTableHeader: import("styled-components").StyledComponent<"div", any, {}, never>;