oolib 2.227.6 → 2.227.8

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 (41) 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/dist/v2/components/TextInputs/index.d.ts +3 -2
  6. package/dist/v2/components/TextInputs/index.js +6 -6
  7. package/package.json +1 -1
  8. package/dist/components/SimpleTable/comps/AddRowColButtons/index.d.ts +0 -9
  9. package/dist/components/SimpleTable/comps/AddRowColButtons/index.js +0 -77
  10. package/dist/components/SimpleTable/comps/rowColActionMenus/ColActionsMenu/index.d.ts +0 -11
  11. package/dist/components/SimpleTable/comps/rowColActionMenus/ColActionsMenu/index.js +0 -95
  12. package/dist/components/SimpleTable/comps/rowColActionMenus/RowActionsMenu/index.d.ts +0 -12
  13. package/dist/components/SimpleTable/comps/rowColActionMenus/RowActionsMenu/index.js +0 -120
  14. package/dist/components/SimpleTable/comps/rowColActionMenus/styled.d.ts +0 -1
  15. package/dist/components/SimpleTable/comps/rowColActionMenus/styled.js +0 -18
  16. package/dist/components/SimpleTable/handlers/handleColActions.d.ts +0 -38
  17. package/dist/components/SimpleTable/handlers/handleColActions.js +0 -155
  18. package/dist/components/SimpleTable/handlers/handleRowActions.d.ts +0 -34
  19. package/dist/components/SimpleTable/handlers/handleRowActions.js +0 -96
  20. package/dist/components/SimpleTable/handlers/handleStretchToFullWidth.d.ts +0 -8
  21. package/dist/components/SimpleTable/handlers/handleStretchToFullWidth.js +0 -34
  22. package/dist/components/SimpleTable/handlers/handleToggleColHeader.d.ts +0 -5
  23. package/dist/components/SimpleTable/handlers/handleToggleColHeader.js +0 -21
  24. package/dist/components/SimpleTable/handlers/handleToggleRowHeader.d.ts +0 -5
  25. package/dist/components/SimpleTable/handlers/handleToggleRowHeader.js +0 -31
  26. package/dist/components/SimpleTable/index.d.ts +0 -31
  27. package/dist/components/SimpleTable/index.js +0 -366
  28. package/dist/components/SimpleTable/styled.d.ts +0 -5
  29. package/dist/components/SimpleTable/styled.js +0 -80
  30. package/dist/components/SimpleTable/useResizeTableColumns.d.ts +0 -21
  31. package/dist/components/SimpleTable/useResizeTableColumns.js +0 -88
  32. package/dist/components/SimpleTable/utils/convertColHeaderConfigToRowData.d.ts +0 -8
  33. package/dist/components/SimpleTable/utils/convertColHeaderConfigToRowData.js +0 -16
  34. package/dist/components/SimpleTable/utils/convertRowHeaderConfigToCellData.d.ts +0 -10
  35. package/dist/components/SimpleTable/utils/convertRowHeaderConfigToCellData.js +0 -13
  36. package/dist/components/SimpleTable/utils/genHash.d.ts +0 -1
  37. package/dist/components/SimpleTable/utils/genHash.js +0 -13
  38. package/dist/components/SimpleTable/utils/prepInitValueFromConfigIfNoValue.d.ts +0 -10
  39. package/dist/components/SimpleTable/utils/prepInitValueFromConfigIfNoValue.js +0 -79
  40. package/dist/stories/Oolib/components/SimpleTable.stories.d.ts +0 -67
  41. package/dist/stories/Oolib/components/SimpleTable.stories.js +0 -128
@@ -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>;
@@ -1,80 +0,0 @@
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 __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
- if (k2 === undefined) k2 = k;
8
- var desc = Object.getOwnPropertyDescriptor(m, k);
9
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
10
- desc = { enumerable: true, get: function() { return m[k]; } };
11
- }
12
- Object.defineProperty(o, k2, desc);
13
- }) : (function(o, m, k, k2) {
14
- if (k2 === undefined) k2 = k;
15
- o[k2] = m[k];
16
- }));
17
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
18
- Object.defineProperty(o, "default", { enumerable: true, value: v });
19
- }) : function(o, v) {
20
- o["default"] = v;
21
- });
22
- var __importStar = (this && this.__importStar) || (function () {
23
- var ownKeys = function(o) {
24
- ownKeys = Object.getOwnPropertyNames || function (o) {
25
- var ar = [];
26
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
27
- return ar;
28
- };
29
- return ownKeys(o);
30
- };
31
- return function (mod) {
32
- if (mod && mod.__esModule) return mod;
33
- var result = {};
34
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
35
- __setModuleDefault(result, mod);
36
- return result;
37
- };
38
- })();
39
- Object.defineProperty(exports, "__esModule", { value: true });
40
- exports.StyledSimpleTableHeader = exports.StyledSimpleTableHeaderCell = exports.StyledSimpleTableCell = exports.StyledSimpleTableRow = exports.StyledSimpleTable = void 0;
41
- var themes_1 = require("../../themes");
42
- var transitions_1 = require("../../themes/mixins/transitions");
43
- var styled_components_1 = __importStar(require("styled-components"));
44
- var utilsOolib_1 = require("../../utilsOolib");
45
- var globalVariables_1 = require("../../globalStyles/globalVariables");
46
- 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);
47
- 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) {
48
- var rowIdx = _a.rowIdx;
49
- return rowIdx % 2 === 1 ? themes_1.colors.white : themes_1.colors.greyColor3;
50
- }, function (_a) {
51
- var actionsActiveOnRow = _a.actionsActiveOnRow, rowIdx = _a.rowIdx, theme = _a.theme;
52
- 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));
53
- });
54
- var genActiveColBorder = function (_a) {
55
- var actionsActiveOnCol = _a.actionsActiveOnCol, colIdx = _a.colIdx, rowIdx = _a.rowIdx, totRows = _a.totRows, theme = _a.theme;
56
- var isActiveCol = actionsActiveOnCol === colIdx;
57
- var isFirstRow = rowIdx === 0;
58
- var isLastRow = rowIdx === totRows - 1;
59
- return (isActiveCol && (0, styled_components_1.css)(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n &::before {\n content: \"\";\n position: absolute;\n left: -1px;\n top: -1px;\n width: calc(100% + 2px);\n height: calc(100% + 2px);\n border: 2px solid ", ";\n z-index: 1;\n ", "\n }\n "], ["\n &::before {\n content: \"\";\n position: absolute;\n left: -1px;\n top: -1px;\n width: calc(100% + 2px);\n height: calc(100% + 2px);\n border: 2px solid ", ";\n z-index: 1;\n ", "\n }\n "])), (0, utilsOolib_1.getPrimaryColor100)(theme === null || theme === void 0 ? void 0 : theme.colors), isFirstRow
60
- ? (0, styled_components_1.css)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n border-bottom: none;\n "], ["\n border-bottom: none;\n "]))) : !isFirstRow && !isLastRow
61
- ? (0, styled_components_1.css)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n border-bottom: none;\n border-top: none;\n "], ["\n border-bottom: none;\n border-top: none;\n "]))) : isLastRow && (0, styled_components_1.css)(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n border-top: none;\n "], ["\n border-top: none;\n "])))));
62
- };
63
- var tableCellStyling = (0, styled_components_1.css)(templateObject_11 || (templateObject_11 = __makeTemplateObject(["\n min-height: 4rem;\n position: relative;\n border-right: 1px solid ", ";\n border-bottom: 1px solid ", ";\n ", ";\n\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\n ", "\n"])), themes_1.colors.greyColor10, themes_1.colors.greyColor10, (0, transitions_1.transition)("background-color"), function (_a) {
64
- var readOnly = _a.readOnly;
65
- return readOnly && (0, styled_components_1.css)(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n cursor: default !important;\n "], ["\n cursor: default !important;\n "])));
66
- }, function (_a) {
67
- var readOnly = _a.readOnly, theme = _a.theme, actionsActiveOnRow = _a.actionsActiveOnRow, actionsActiveOnCol = _a.actionsActiveOnCol, rowIdx = _a.rowIdx, totRows = _a.totRows, colIdx = _a.colIdx;
68
- return !readOnly && (0, styled_components_1.css)(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n ", ";\n\n ", "\n\n ", "\n "], ["\n ", ";\n\n ", "\n\n ", "\n "])), globalVariables_1.globalHoverOnWhiteBG, !actionsActiveOnRow &&
69
- !actionsActiveOnCol && (0, styled_components_1.css)(templateObject_9 || (templateObject_9 = __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), genActiveColBorder({
70
- theme: theme,
71
- actionsActiveOnCol: actionsActiveOnCol,
72
- rowIdx: rowIdx,
73
- totRows: totRows,
74
- colIdx: colIdx,
75
- }));
76
- });
77
- exports.StyledSimpleTableCell = styled_components_1.default.div(templateObject_12 || (templateObject_12 = __makeTemplateObject(["\n ", "\n"], ["\n ", "\n"])), tableCellStyling);
78
- exports.StyledSimpleTableHeaderCell = styled_components_1.default.div(templateObject_13 || (templateObject_13 = __makeTemplateObject(["\n ", "\n .public-DraftEditor-content {\n font-weight: 600;\n }\n background-color: ", ";\n border-right: 2px solid ", ";\n"], ["\n ", "\n .public-DraftEditor-content {\n font-weight: 600;\n }\n background-color: ", ";\n border-right: 2px solid ", ";\n"])), tableCellStyling, themes_1.colors.greyColor3, themes_1.colors.greyColor10);
79
- exports.StyledSimpleTableHeader = styled_components_1.default.div(templateObject_14 || (templateObject_14 = __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.greyColor3, themes_1.colors.greyColor10);
80
- var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10, templateObject_11, templateObject_12, templateObject_13, templateObject_14;
@@ -1,21 +0,0 @@
1
- export function useResizeTableColumns({ setColWidthConfig, colWidthConfig, theme, builderProps }: {
2
- setColWidthConfig: any;
3
- colWidthConfig: any;
4
- theme: any;
5
- builderProps: any;
6
- }): {
7
- resetColResizeState: (e: any) => void;
8
- hideShowDragZoneIndicator: ({ e, borderStyleActive, borderStyleInactive }: {
9
- e: any;
10
- borderStyleActive?: string;
11
- borderStyleInactive?: string;
12
- }) => void;
13
- initColResizeState: (e: any, d: any) => void;
14
- resetDragZoneIndicator: ({ e, borderStyleInactive }: {
15
- e: any;
16
- borderStyleInactive?: string;
17
- }) => void;
18
- handleResizeColumn: (e: any) => void;
19
- colResizeState: any;
20
- dragZoneWidth: number;
21
- };
@@ -1,88 +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.useResizeTableColumns = void 0;
15
- var react_1 = require("react");
16
- var themes_1 = require("../../themes");
17
- var utilsOolib_1 = require("../../utilsOolib");
18
- var useResizeTableColumns = function (_a) {
19
- var setColWidthConfig = _a.setColWidthConfig, colWidthConfig = _a.colWidthConfig, theme = _a.theme, builderProps = _a.builderProps;
20
- var _b = (0, react_1.useState)(undefined), colResizeState = _b[0], setColResizeState = _b[1];
21
- var dragZoneWidth = 5;
22
- var handleResizeColumn = function (e) {
23
- e.preventDefault();
24
- e.stopPropagation();
25
- if (colResizeState) {
26
- setColWidthConfig(function (prev) {
27
- var _a;
28
- return (__assign(__assign({}, prev), (_a = {}, _a[colResizeState.colId] = (colResizeState.initWidth + (e.clientX - colResizeState.mousePos)) + 'px', _a)));
29
- });
30
- }
31
- };
32
- var resetDragZoneIndicator = function (_a) {
33
- var e = _a.e, _b = _a.borderStyleInactive, borderStyleInactive = _b === void 0 ? "1px solid ".concat(themes_1.colors.greyColor10) : _b;
34
- if (colResizeState || e.currentTarget.id !== e.target.id)
35
- return;
36
- e.currentTarget.style.borderRight = borderStyleInactive;
37
- e.currentTarget.style.cursor = 'pointer';
38
- };
39
- var isInDragZone = function (e) {
40
- var mouseX = e.clientX;
41
- var colRightEdge = e.currentTarget.getBoundingClientRect().right;
42
- return mouseX > colRightEdge - dragZoneWidth;
43
- };
44
- var initColResizeState = function (e, d) {
45
- if (isInDragZone(e)) {
46
- e.preventDefault(); // these have to be inside isInDragZone, else clicking on cell wont allow rte to get focussed in SimpleTable
47
- e.stopPropagation();
48
- setColResizeState({
49
- mousePos: e.clientX,
50
- initWidth: parseInt(colWidthConfig[d.colId].replace('px', '')),
51
- colId: d.colId
52
- });
53
- }
54
- };
55
- var hideShowDragZoneIndicator = function (_a) {
56
- var e = _a.e, _b = _a.borderStyleActive, borderStyleActive = _b === void 0 ? "1px solid ".concat((0, utilsOolib_1.getPrimaryColor100)(theme === null || theme === void 0 ? void 0 : theme.colors)) : _b, _c = _a.borderStyleInactive, borderStyleInactive = _c === void 0 ? "1px solid ".concat(themes_1.colors.greyColor10) : _c;
57
- e.preventDefault();
58
- /** currentTarget is the element that this event is bound to */
59
- if (e.currentTarget.id !== e.target.id)
60
- return; //very important, else the indicator shows in some cases, when its not supposed to. we don't completely understand why...
61
- if (!colResizeState) {
62
- if (isInDragZone(e)) {
63
- e.currentTarget.style.borderRight = borderStyleActive;
64
- e.currentTarget.style.setProperty('cursor', 'col-resize', 'important'); // using the setProperty approach only so that we can apply !important
65
- }
66
- else {
67
- e.currentTarget.style.borderRight = borderStyleInactive;
68
- e.currentTarget.style.cursor = 'pointer';
69
- }
70
- }
71
- };
72
- var resetColResizeState = function (e) {
73
- setColResizeState(undefined);
74
- if (builderProps === null || builderProps === void 0 ? void 0 : builderProps.updateColWidthsInTableConfig) {
75
- builderProps.updateColWidthsInTableConfig(colWidthConfig);
76
- }
77
- };
78
- return ({
79
- resetColResizeState: resetColResizeState,
80
- hideShowDragZoneIndicator: hideShowDragZoneIndicator,
81
- initColResizeState: initColResizeState,
82
- resetDragZoneIndicator: resetDragZoneIndicator,
83
- handleResizeColumn: handleResizeColumn,
84
- colResizeState: colResizeState,
85
- dragZoneWidth: dragZoneWidth
86
- });
87
- };
88
- exports.useResizeTableColumns = useResizeTableColumns;
@@ -1,8 +0,0 @@
1
- export function convertColHeaderConfigToRowData({ colHeaderData, convertToRichText }: {
2
- colHeaderData: any;
3
- convertToRichText: any;
4
- }): {
5
- id: string;
6
- isColHeader: boolean;
7
- cellData: any;
8
- };
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.convertColHeaderConfigToRowData = void 0;
4
- var convertColHeaderConfigToRowData = function (_a) {
5
- var colHeaderData = _a.colHeaderData, convertToRichText = _a.convertToRichText;
6
- return {
7
- id: "colHeader",
8
- isColHeader: true,
9
- cellData: colHeaderData.map(function (d, i) { return ({
10
- value: convertToRichText ? convertToRichText(d) : d, //draftjs data shape
11
- readOnly: true,
12
- id: "colHeaderCell_".concat(i),
13
- }); }),
14
- };
15
- };
16
- exports.convertColHeaderConfigToRowData = convertColHeaderConfigToRowData;
@@ -1,10 +0,0 @@
1
- export function convertRowHeaderConfigToCellData({ rowHeaderData, rowIdx, convertToRichText }: {
2
- rowHeaderData: any;
3
- rowIdx: any;
4
- convertToRichText: any;
5
- }): {
6
- value: any;
7
- readOnly: boolean;
8
- id: string;
9
- isRowHeader: boolean;
10
- };
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.convertRowHeaderConfigToCellData = void 0;
4
- var convertRowHeaderConfigToCellData = function (_a) {
5
- var rowHeaderData = _a.rowHeaderData, rowIdx = _a.rowIdx, convertToRichText = _a.convertToRichText;
6
- return ({
7
- value: convertToRichText ? convertToRichText(rowHeaderData[rowIdx]) : rowHeaderData[rowIdx], //draftjs data shape
8
- readOnly: true,
9
- id: "rowHeaderCell_".concat(rowIdx),
10
- isRowHeader: true
11
- });
12
- };
13
- exports.convertRowHeaderConfigToCellData = convertRowHeaderConfigToCellData;
@@ -1 +0,0 @@
1
- export function genHash(len: any): string;
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.genHash = void 0;
4
- var makeArrayFromLength_1 = require("../../../utils/makeArrayFromLength");
5
- var genHash = function (len) {
6
- var arr = "1234567890abcdefghijklmnopqrstuvwxyz";
7
- var ans = "";
8
- for (var i = len; i > 0; i--) {
9
- ans += arr[Math.floor(Math.random() * arr.length)];
10
- }
11
- return ans;
12
- };
13
- exports.genHash = genHash;