oolib 2.88.2 → 2.89.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.
- package/dist/UIContent/index.d.ts +7 -0
- package/dist/UIContent/index.js +6 -0
- package/dist/components/ImageInput/comps/ImageUploadShell/index.d.ts +16 -1
- package/dist/components/ImageInput/comps/ImageUploadShell/index.js +62 -0
- package/dist/components/ImageInput/comps/Placeholder/index.js +12 -13
- package/dist/components/PlaceholderWrapper/index.d.ts +14 -0
- package/dist/components/PlaceholderWrapper/index.js +50 -0
- package/dist/components/PlaceholderWrapper/styled.d.ts +2 -0
- package/dist/components/PlaceholderWrapper/styled.js +35 -0
- package/dist/components/SimpleTable/handlers/handleToggleColHeader.d.ts +5 -0
- package/dist/components/SimpleTable/handlers/handleToggleColHeader.js +21 -0
- package/dist/components/SimpleTable/index.js +85 -62
- package/dist/components/SimpleTable/styled.d.ts +1 -0
- package/dist/components/SimpleTable/styled.js +6 -4
- package/dist/components/SimpleTable/useResizeTableColumns.d.ts +9 -2
- package/dist/components/SimpleTable/useResizeTableColumns.js +7 -5
- package/dist/components/SimpleTable/utils/convertRowHeaderConfigToCellData.d.ts +10 -0
- package/dist/components/SimpleTable/utils/convertRowHeaderConfigToCellData.js +13 -0
- package/package.json +1 -1
|
@@ -4,6 +4,13 @@ export namespace UIContent {
|
|
|
4
4
|
const onlyFirstFileConsiderErrMsg: string;
|
|
5
5
|
const corruptUrlErrMsg: string;
|
|
6
6
|
}
|
|
7
|
+
namespace VideoInput {
|
|
8
|
+
const uploadError: string;
|
|
9
|
+
}
|
|
10
|
+
namespace Pdf {
|
|
11
|
+
const uploadError_1: string;
|
|
12
|
+
export { uploadError_1 as uploadError };
|
|
13
|
+
}
|
|
7
14
|
namespace SimpleTable {
|
|
8
15
|
const _delete: string;
|
|
9
16
|
export { _delete as delete };
|
package/dist/UIContent/index.js
CHANGED
|
@@ -7,6 +7,12 @@ exports.UIContent = {
|
|
|
7
7
|
onlyFirstFileConsiderErrMsg: "This is a single image input. Only first file will be considered",
|
|
8
8
|
corruptUrlErrMsg: "Image URL seems to be corrupt. Cannot render it"
|
|
9
9
|
},
|
|
10
|
+
VideoInput: {
|
|
11
|
+
uploadError: "Unable to upload file"
|
|
12
|
+
},
|
|
13
|
+
Pdf: {
|
|
14
|
+
uploadError: "Unable to upload file"
|
|
15
|
+
},
|
|
10
16
|
SimpleTable: {
|
|
11
17
|
delete: 'Delete',
|
|
12
18
|
duplicate: 'Duplicate',
|
|
@@ -1,4 +1,20 @@
|
|
|
1
|
+
export function UploadShell({ isLoading, children, disabled, enableFilesDrop, setDragOverActive: parentSetDragOverActive, handleUpload, onChange, value, id, multiple, mediaType, height, width }: {
|
|
2
|
+
isLoading: any;
|
|
3
|
+
children: any;
|
|
4
|
+
disabled: any;
|
|
5
|
+
enableFilesDrop?: boolean;
|
|
6
|
+
setDragOverActive: any;
|
|
7
|
+
handleUpload: any;
|
|
8
|
+
onChange: any;
|
|
9
|
+
value: any;
|
|
10
|
+
id: any;
|
|
11
|
+
multiple: any;
|
|
12
|
+
mediaType: any;
|
|
13
|
+
height: any;
|
|
14
|
+
width: any;
|
|
15
|
+
}): React.JSX.Element;
|
|
1
16
|
export default ImageUploadShell;
|
|
17
|
+
import React from "react";
|
|
2
18
|
declare function ImageUploadShell({ style, isLoading, children, disabled, enableFilesDrop, setDragOverActive }: {
|
|
3
19
|
style: any;
|
|
4
20
|
isLoading: any;
|
|
@@ -7,4 +23,3 @@ declare function ImageUploadShell({ style, isLoading, children, disabled, enable
|
|
|
7
23
|
enableFilesDrop: any;
|
|
8
24
|
setDragOverActive: any;
|
|
9
25
|
}): React.JSX.Element;
|
|
10
|
-
import React from "react";
|
|
@@ -43,10 +43,72 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
43
43
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
44
44
|
};
|
|
45
45
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
|
+
exports.UploadShell = void 0;
|
|
46
47
|
var react_1 = __importStar(require("react"));
|
|
47
48
|
var ImageInputContext_1 = require("../../ImageInputContext");
|
|
48
49
|
var bannerContext_1 = require("../../../Banners/bannerContext");
|
|
49
50
|
var UIContent_1 = require("../../../../UIContent");
|
|
51
|
+
var mediaFormat = {
|
|
52
|
+
image: 'image/*',
|
|
53
|
+
video: 'video/*',
|
|
54
|
+
pdf: 'application/pdf'
|
|
55
|
+
};
|
|
56
|
+
var mediaErrorMessage = {
|
|
57
|
+
image: UIContent_1.UIContent.ImageInput.onlyFirstFileConsiderErrMsg,
|
|
58
|
+
video: UIContent_1.UIContent.VideoInput.uploadError,
|
|
59
|
+
pdf: UIContent_1.UIContent.Pdf.uploadError
|
|
60
|
+
};
|
|
61
|
+
var UploadShell = function (_a) {
|
|
62
|
+
var isLoading = _a.isLoading, children = _a.children, disabled = _a.disabled, _b = _a.enableFilesDrop, enableFilesDrop = _b === void 0 ? true : _b, parentSetDragOverActive = _a.setDragOverActive, handleUpload = _a.handleUpload, onChange = _a.onChange, value = _a.value, id = _a.id, multiple = _a.multiple, mediaType = _a.mediaType, height = _a.height, width = _a.width;
|
|
63
|
+
var SET_ALERT_BANNER = (0, bannerContext_1.useBannerContext)().SET_ALERT_BANNER;
|
|
64
|
+
var inputRef = (0, react_1.useRef)(null);
|
|
65
|
+
if (disabled)
|
|
66
|
+
return react_1.default.createElement("div", { style: { width: '100%', height: '100%' } }, children);
|
|
67
|
+
var fireHandleUpload = function (files) {
|
|
68
|
+
handleUpload({
|
|
69
|
+
files: files,
|
|
70
|
+
callback: function (_a) {
|
|
71
|
+
var successfulUploads = _a.successfulUploads;
|
|
72
|
+
onChange(id, multiple
|
|
73
|
+
? __spreadArray(__spreadArray([], successfulUploads, true), (value || []), true) : successfulUploads);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
78
|
+
react_1.default.createElement("input", { type: "file", accept: mediaFormat[mediaType], style: { display: 'none' }, ref: inputRef, onChange: function (e) { return fireHandleUpload(e.target.files); }, multiple: multiple }),
|
|
79
|
+
react_1.default.createElement("div", __assign({}, (isLoading
|
|
80
|
+
? {}
|
|
81
|
+
: {
|
|
82
|
+
onDragEnter: function (e) {
|
|
83
|
+
e.preventDefault();
|
|
84
|
+
parentSetDragOverActive(true);
|
|
85
|
+
},
|
|
86
|
+
onDragLeave: function (e) {
|
|
87
|
+
e.preventDefault();
|
|
88
|
+
parentSetDragOverActive(false);
|
|
89
|
+
},
|
|
90
|
+
onDragOver: enableFilesDrop
|
|
91
|
+
? function (e) { return e.preventDefault(); }
|
|
92
|
+
: function () { },
|
|
93
|
+
onDrop: enableFilesDrop
|
|
94
|
+
? function (e) {
|
|
95
|
+
var _a, _b;
|
|
96
|
+
e.preventDefault();
|
|
97
|
+
e.stopPropagation();
|
|
98
|
+
if ((_a = e.dataTransfer) === null || _a === void 0 ? void 0 : _a.files) {
|
|
99
|
+
if (!multiple && ((_b = e.dataTransfer) === null || _b === void 0 ? void 0 : _b.files.length) > 1) { //then set alert saying only first image will be attempted to upload
|
|
100
|
+
SET_ALERT_BANNER(mediaErrorMessage[mediaType], 'red', 3000);
|
|
101
|
+
}
|
|
102
|
+
var filesToUpload = multiple
|
|
103
|
+
? Array.from(e.dataTransfer.files)
|
|
104
|
+
: [Array.from(e.dataTransfer.files)[0]];
|
|
105
|
+
fireHandleUpload(filesToUpload);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
: function () { }
|
|
109
|
+
}), { onClick: function () { return inputRef.current.click(); }, style: { height: height || '100%', width: width || '100%' } }), children)));
|
|
110
|
+
};
|
|
111
|
+
exports.UploadShell = UploadShell;
|
|
50
112
|
var ImageUploadShell = function (_a) {
|
|
51
113
|
var style = _a.style, isLoading = _a.isLoading, children = _a.children, disabled = _a.disabled, enableFilesDrop = _a.enableFilesDrop, setDragOverActive = _a.setDragOverActive;
|
|
52
114
|
var SET_ALERT_BANNER = (0, bannerContext_1.useBannerContext)().SET_ALERT_BANNER;
|
|
@@ -47,6 +47,7 @@ var icons_1 = require("../../../../icons");
|
|
|
47
47
|
var themes_1 = require("../../../../themes");
|
|
48
48
|
var Typo_1 = require("../../../Typo");
|
|
49
49
|
var ProgressBar_1 = require("../../../LoadersAndProgress/ProgressBar");
|
|
50
|
+
var PlaceholderWrapper_1 = require("../../../PlaceholderWrapper");
|
|
50
51
|
var ImageSquare = icons_1.icons.ImageSquare;
|
|
51
52
|
var greyColor100 = themes_1.colors.greyColor100;
|
|
52
53
|
var Placeholder = function (_a) {
|
|
@@ -75,24 +76,22 @@ var Placeholder = function (_a) {
|
|
|
75
76
|
* then that image is rendered instead of placeholder
|
|
76
77
|
*
|
|
77
78
|
*/
|
|
78
|
-
|
|
79
|
+
// const [dragOverActive, setDragOverActive] = useState(false)
|
|
80
|
+
var _d = (0, ImageInputContext_1.useImageInputContext)(), handleUpload = _d.handleUpload, onChange = _d.onChange, value = _d.value, id = _d.id;
|
|
79
81
|
return (react_1.default.createElement(AspectRatioShell_1.default, __assign({}, {
|
|
80
82
|
aspectRatio: aspectRatio,
|
|
81
83
|
containerShape: containerShape,
|
|
82
84
|
stretchToFullHeight: stretchToFullHeight,
|
|
83
85
|
onShellPrepared: decideUIStyle,
|
|
84
86
|
}),
|
|
85
|
-
react_1.default.createElement(
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
react_1.default.createElement(
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
? "(optional)"
|
|
95
|
-
: "")),
|
|
96
|
-
react_1.default.createElement(Typo_1.SANS_2, null, dropzoneSublabel)))))))));
|
|
87
|
+
react_1.default.createElement(PlaceholderWrapper_1.PlaceHolderWrapper, { ref: styledPlaceholderWrapperRef, uploadProgress: uploadProgress, isLoading: isLoading, containerShape: containerShape, multiple: multiple, smallPlaceholderUI: smallPlaceholderUI, mediaType: 'image', handleUpload: handleUpload, onChange: onChange, value: value, id: id }, smallPlaceholderUI ? (react_1.default.createElement(react_1.Fragment, null,
|
|
88
|
+
react_1.default.createElement(ImageSquare, { size: 16, color: greyColor100 }),
|
|
89
|
+
react_1.default.createElement(Typo_1.SANS_0, { semibold: true }, dropzoneLabel),
|
|
90
|
+
showOptionalLabelInDropzone && isRequired === false && react_1.default.createElement(Typo_1.SANS_0, null, "(optional)"))) : (react_1.default.createElement(react_1.Fragment, null,
|
|
91
|
+
react_1.default.createElement(ImageSquare, { size: 30, color: greyColor100 }),
|
|
92
|
+
react_1.default.createElement(Typo_1.SANS_2, { semibold: true }, "".concat(dropzoneLabel, " ").concat(showOptionalLabelInDropzone && isRequired === false
|
|
93
|
+
? "(optional)"
|
|
94
|
+
: "")),
|
|
95
|
+
react_1.default.createElement(Typo_1.SANS_2, null, dropzoneSublabel))))));
|
|
97
96
|
};
|
|
98
97
|
exports.default = Placeholder;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export const PlaceHolderWrapper: React.ForwardRefExoticComponent<{
|
|
2
|
+
smallPlaceholderUI: any;
|
|
3
|
+
isLoading: any;
|
|
4
|
+
multiple: any;
|
|
5
|
+
containerShape: any;
|
|
6
|
+
uploadProgress: any;
|
|
7
|
+
mediaType: any;
|
|
8
|
+
handleUpload: any;
|
|
9
|
+
onChange: any;
|
|
10
|
+
value: any;
|
|
11
|
+
id: any;
|
|
12
|
+
children: any;
|
|
13
|
+
} & React.RefAttributes<any>>;
|
|
14
|
+
import React from "react";
|
|
@@ -0,0 +1,50 @@
|
|
|
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 (mod) {
|
|
30
|
+
if (mod && mod.__esModule) return mod;
|
|
31
|
+
var result = {};
|
|
32
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
33
|
+
__setModuleDefault(result, mod);
|
|
34
|
+
return result;
|
|
35
|
+
};
|
|
36
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
exports.PlaceHolderWrapper = void 0;
|
|
38
|
+
var react_1 = __importStar(require("react"));
|
|
39
|
+
var ProgressBar_1 = require("../LoadersAndProgress/ProgressBar");
|
|
40
|
+
var styled_1 = require("./styled");
|
|
41
|
+
var ImageUploadShell_1 = require("../ImageInput/comps/ImageUploadShell");
|
|
42
|
+
var PlaceHolder = function (_a, ref) {
|
|
43
|
+
var smallPlaceholderUI = _a.smallPlaceholderUI, isLoading = _a.isLoading, multiple = _a.multiple, containerShape = _a.containerShape, uploadProgress = _a.uploadProgress, mediaType = _a.mediaType, handleUpload = _a.handleUpload, onChange = _a.onChange, value = _a.value, id = _a.id, children = _a.children;
|
|
44
|
+
var _b = (0, react_1.useState)(false), dragOverActive = _b[0], setDragOverActive = _b[1];
|
|
45
|
+
return (react_1.default.createElement(styled_1.StyledPlaceholderWrapper, { smallPlaceholderUI: smallPlaceholderUI, ref: ref, dragOverActive: dragOverActive }, isLoading ? (react_1.default.createElement(ProgressBar_1.ProgressBar, { progress: uploadProgress, text: uploadProgress && uploadProgress !== 100
|
|
46
|
+
? uploadProgress + "%"
|
|
47
|
+
: "Almost Done..." })) : (react_1.default.createElement(ImageUploadShell_1.UploadShell, { isLoading: isLoading, enableFilesDrop: true, multiple: multiple, setDragOverActive: setDragOverActive, handleUpload: handleUpload, onChange: onChange, value: value, id: id, mediaType: mediaType },
|
|
48
|
+
react_1.default.createElement(styled_1.StyledPlaceholder, __assign({}, { containerShape: containerShape }, { smallPlaceholderUI: smallPlaceholderUI }), children)))));
|
|
49
|
+
};
|
|
50
|
+
exports.PlaceHolderWrapper = (0, react_1.forwardRef)(PlaceHolder);
|
|
@@ -0,0 +1,35 @@
|
|
|
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.StyledPlaceholder = exports.StyledPlaceholderWrapper = void 0;
|
|
11
|
+
var styled_components_1 = __importDefault(require("styled-components"));
|
|
12
|
+
var utilsOolib_1 = require("../../utilsOolib");
|
|
13
|
+
var mixins_1 = require("../../themes/mixins");
|
|
14
|
+
var themes_1 = require("../../themes");
|
|
15
|
+
var greyColor100 = themes_1.colors.greyColor100;
|
|
16
|
+
exports.StyledPlaceholderWrapper = styled_components_1.default.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n background-color: ", ";\n padding: ", ";\n width: 100%;\n height: 100%;\n ", "\n"], ["\n background-color: ", ";\n padding: ", ";\n width: 100%;\n height: 100%;\n ", "\n"])), function (_a) {
|
|
17
|
+
var theme = _a.theme, dragOverActive = _a.dragOverActive;
|
|
18
|
+
return dragOverActive
|
|
19
|
+
? (0, utilsOolib_1.getPrimaryColor40)(theme === null || theme === void 0 ? void 0 : theme.colors)
|
|
20
|
+
: (0, utilsOolib_1.getPrimaryColor10)(theme === null || theme === void 0 ? void 0 : theme.colors);
|
|
21
|
+
}, function (_a) {
|
|
22
|
+
var smallPlaceholderUI = _a.smallPlaceholderUI;
|
|
23
|
+
return !smallPlaceholderUI && "1.2rem";
|
|
24
|
+
}, (0, mixins_1.transition)("background-color"));
|
|
25
|
+
exports.StyledPlaceholder = styled_components_1.default.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n display: flex;\n flex-flow: column nowrap;\n height: 100%;\n width: 100%;\n gap: ", ";\n align-items: center;\n justify-content: center;\n text-align: center;\n border-radius: ", ";\n border: 0.12rem dashed ", ";\n padding: ", ";\n cursor: pointer;\n"], ["\n display: flex;\n flex-flow: column nowrap;\n height: 100%;\n width: 100%;\n gap: ", ";\n align-items: center;\n justify-content: center;\n text-align: center;\n border-radius: ", ";\n border: 0.12rem dashed ", ";\n padding: ", ";\n cursor: pointer;\n"])), function (_a) {
|
|
26
|
+
var smallPlaceholderUI = _a.smallPlaceholderUI;
|
|
27
|
+
return !smallPlaceholderUI && "0.3rem";
|
|
28
|
+
}, function (_a) {
|
|
29
|
+
var containerShape = _a.containerShape;
|
|
30
|
+
return containerShape === "circle" ? "50%" : "unset";
|
|
31
|
+
}, greyColor100, function (_a) {
|
|
32
|
+
var smallPlaceholderUI = _a.smallPlaceholderUI;
|
|
33
|
+
return !smallPlaceholderUI && "2rem";
|
|
34
|
+
});
|
|
35
|
+
var templateObject_1, templateObject_2;
|
|
@@ -0,0 +1,21 @@
|
|
|
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;
|
|
@@ -60,9 +60,11 @@ var handleColActions_1 = require("./handlers/handleColActions");
|
|
|
60
60
|
var handleRowActions_1 = require("./handlers/handleRowActions");
|
|
61
61
|
var handleStretchToFullWidth_1 = require("./handlers/handleStretchToFullWidth");
|
|
62
62
|
var handleToggleRowHeader_1 = require("./handlers/handleToggleRowHeader");
|
|
63
|
+
var handleToggleColHeader_1 = require("./handlers/handleToggleColHeader");
|
|
63
64
|
var styled_1 = require("./styled");
|
|
64
65
|
var useResizeTableColumns_1 = require("./useResizeTableColumns");
|
|
65
66
|
var convertColHeaderConfigToRowData_1 = require("./utils/convertColHeaderConfigToRowData");
|
|
67
|
+
var convertRowHeaderConfigToCellData_1 = require("./utils/convertRowHeaderConfigToCellData");
|
|
66
68
|
var prepInitValueFromConfigIfNoValue_1 = require("./utils/prepInitValueFromConfigIfNoValue");
|
|
67
69
|
var greyColor100 = themes_1.colors.greyColor100;
|
|
68
70
|
/*pending:
|
|
@@ -168,6 +170,75 @@ function SimpleTable(_a) {
|
|
|
168
170
|
var colActionsButtonHeight = 15;
|
|
169
171
|
var primaryTableActionsMenuHeight = 30;
|
|
170
172
|
var primaryTableActionsMenuGap = 5;
|
|
173
|
+
var genCell = function (_a) {
|
|
174
|
+
var cell = _a.cell, cellIdx = _a.cellIdx, rowIdx = _a.rowIdx;
|
|
175
|
+
var CellComp = RichTextEditor //cuz in oolib, richtexteditor will not be there for now
|
|
176
|
+
? CellContentBlocks["RichTextEditor"]
|
|
177
|
+
: function () { return react_1.default.createElement("div", null, "RTE Doesnt Exist"); };
|
|
178
|
+
var cellProps = __assign({}, CellContentBlockDefaultProps["RichTextEditor"]);
|
|
179
|
+
var cellValue = CellValueGetters["RichTextEditor"](cell.value);
|
|
180
|
+
var cellWidth = value.colWidthConfig["col_".concat(cellIdx)];
|
|
181
|
+
//(100% - totalExplicitWidths)/(totalColumns - noOfColsWithExplicitWidths)
|
|
182
|
+
// let cellProps = {
|
|
183
|
+
// ...CellContentBlockDefaultProps[cell.comp],
|
|
184
|
+
// ...(cell.props ? cell.props : {}),
|
|
185
|
+
// }
|
|
186
|
+
if (cell.isRowHeader)
|
|
187
|
+
console.log({ cell: cell });
|
|
188
|
+
var StyledCellWrapper = cell.isRowHeader
|
|
189
|
+
? styled_1.StyledSimpleTableHeaderCell
|
|
190
|
+
: styled_1.StyledSimpleTableCell;
|
|
191
|
+
return (react_1.default.createElement(StyledCellWrapper, { key: cell.id, id: "kp_table__cell__".concat(cell.id), readOnly: readOnly || cell.readOnly, style: {
|
|
192
|
+
color: greyColor100,
|
|
193
|
+
width: "".concat(cellWidth),
|
|
194
|
+
borderRight: (colResizeState === null || colResizeState === void 0 ? void 0 : colResizeState.colId) === "col_".concat(cellIdx) &&
|
|
195
|
+
"2px solid ".concat((0, utilsOolib_1.getPrimaryColor100)(theme === null || theme === void 0 ? void 0 : theme.colors)),
|
|
196
|
+
}, actionsActiveOnRow: actionsActiveOnRow, colIdx: cellIdx, rowIdx: rowIdx, totRows: value.data.length, actionsActiveOnCol: actionsActiveOnCol, onMouseEnter: function (e) {
|
|
197
|
+
setHoveredRowAndCol({
|
|
198
|
+
rowIdx: rowIdx,
|
|
199
|
+
colIdx: cellIdx,
|
|
200
|
+
});
|
|
201
|
+
},
|
|
202
|
+
// onMouseOver={e => {
|
|
203
|
+
// setHoveredRowAndCol(e.target.getBoundingClientRect())
|
|
204
|
+
// }}
|
|
205
|
+
onMouseDown: function (e) {
|
|
206
|
+
initColResizeState(e, { colId: "col_".concat(cellIdx) });
|
|
207
|
+
}, onMouseOut: function (e) { return resetDragZoneIndicator(__assign({ e: e }, (cell.isRowHeader ? { borderStyleInactive: "2px solid ".concat(themes_1.colors.greyColor10) } : {}))); }, onMouseMove: function (e) { return hideShowDragZoneIndicator(__assign({ e: e }, (cell.isRowHeader ? {
|
|
208
|
+
borderStyleInactive: "2px solid ".concat(themes_1.colors.greyColor10),
|
|
209
|
+
borderStyleActive: "2px solid ".concat((0, utilsOolib_1.getPrimaryColor100)(theme === null || theme === void 0 ? void 0 : theme.colors))
|
|
210
|
+
} : {}))); }, tabIndex: 0 },
|
|
211
|
+
react_1.default.createElement(ColActionsMenu_1.ColActionsMenu, __assign({}, {
|
|
212
|
+
value: value,
|
|
213
|
+
colIdx: cellIdx,
|
|
214
|
+
onChange: onChange,
|
|
215
|
+
id: id,
|
|
216
|
+
defaultColWidth: defaultColWidth,
|
|
217
|
+
setActionsActiveOnCol: setActionsActiveOnCol,
|
|
218
|
+
colActionsButtonHeight: colActionsButtonHeight,
|
|
219
|
+
conditionsToRender: !readOnly &&
|
|
220
|
+
enableColActions &&
|
|
221
|
+
rowIdx === 0 &&
|
|
222
|
+
hoveredRowAndCol.colIdx === cellIdx,
|
|
223
|
+
})),
|
|
224
|
+
react_1.default.createElement(RowActionsMenu_1.RowActionsMenu, __assign({}, {
|
|
225
|
+
value: value,
|
|
226
|
+
rowIdx: rowIdx,
|
|
227
|
+
onChange: onChange,
|
|
228
|
+
id: id,
|
|
229
|
+
setActionsActiveOnRow: setActionsActiveOnRow,
|
|
230
|
+
rowActionsButtonWidth: rowActionsButtonWidth,
|
|
231
|
+
conditionsToRender: !readOnly &&
|
|
232
|
+
enableRowActions &&
|
|
233
|
+
cellIdx === 0 &&
|
|
234
|
+
rowIdx !== undefined && //cuz for fixed col headers, rowIdx is undefined
|
|
235
|
+
hoveredRowAndCol.rowIdx === rowIdx,
|
|
236
|
+
})),
|
|
237
|
+
react_1.default.createElement("div", { style: { marginRight: dragZoneWidth + "px" } },
|
|
238
|
+
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) {
|
|
239
|
+
return handleCellInputChange({ v: v, rowIdx: rowIdx, cellIdx: cellIdx });
|
|
240
|
+
} })))));
|
|
241
|
+
};
|
|
171
242
|
var genRow = function (_a) {
|
|
172
243
|
var row = _a.row, rowIdx = _a.rowIdx;
|
|
173
244
|
var StyledWrapper = row.isColHeader
|
|
@@ -175,66 +246,16 @@ function SimpleTable(_a) {
|
|
|
175
246
|
: styled_1.StyledSimpleTableRow;
|
|
176
247
|
return (react_1.default.createElement(StyledWrapper, { actionsActiveOnRow: actionsActiveOnRow,
|
|
177
248
|
// onClick={() => row.link && history.push(row.link)}
|
|
178
|
-
style: { display: "flex" }, readOnly: readOnly, rowIdx: rowIdx, key: row.id },
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
// ...(cell.props ? cell.props : {}),
|
|
189
|
-
// }
|
|
190
|
-
return (react_1.default.createElement(styled_1.StyledSimpleTableCell, { key: cell.id, id: "kp_table__cell__".concat(cell.id), readOnly: readOnly || cell.readOnly, style: {
|
|
191
|
-
color: greyColor100,
|
|
192
|
-
width: "".concat(cellWidth),
|
|
193
|
-
borderRight: (colResizeState === null || colResizeState === void 0 ? void 0 : colResizeState.colId) === "col_".concat(cellIdx) &&
|
|
194
|
-
"2px solid ".concat((0, utilsOolib_1.getPrimaryColor100)(theme === null || theme === void 0 ? void 0 : theme.colors)),
|
|
195
|
-
}, actionsActiveOnRow: actionsActiveOnRow, colIdx: cellIdx, rowIdx: rowIdx, totRows: value.data.length, actionsActiveOnCol: actionsActiveOnCol, onMouseEnter: function (e) {
|
|
196
|
-
setHoveredRowAndCol({
|
|
197
|
-
rowIdx: rowIdx,
|
|
198
|
-
colIdx: cellIdx,
|
|
199
|
-
});
|
|
200
|
-
},
|
|
201
|
-
// onMouseOver={e => {
|
|
202
|
-
// setHoveredRowAndCol(e.target.getBoundingClientRect())
|
|
203
|
-
// }}
|
|
204
|
-
onMouseDown: function (e) {
|
|
205
|
-
initColResizeState(e, { colId: "col_".concat(cellIdx) });
|
|
206
|
-
}, onMouseOut: resetDragZoneIndicator, onMouseMove: hideShowDragZoneIndicator, tabIndex: 0 },
|
|
207
|
-
react_1.default.createElement(ColActionsMenu_1.ColActionsMenu, __assign({}, {
|
|
208
|
-
value: value,
|
|
209
|
-
colIdx: cellIdx,
|
|
210
|
-
onChange: onChange,
|
|
211
|
-
id: id,
|
|
212
|
-
defaultColWidth: defaultColWidth,
|
|
213
|
-
setActionsActiveOnCol: setActionsActiveOnCol,
|
|
214
|
-
colActionsButtonHeight: colActionsButtonHeight,
|
|
215
|
-
conditionsToRender: !readOnly &&
|
|
216
|
-
enableColActions &&
|
|
217
|
-
rowIdx === 0 &&
|
|
218
|
-
hoveredRowAndCol.colIdx === cellIdx,
|
|
219
|
-
})),
|
|
220
|
-
react_1.default.createElement(RowActionsMenu_1.RowActionsMenu, __assign({}, {
|
|
221
|
-
value: value,
|
|
222
|
-
rowIdx: rowIdx,
|
|
223
|
-
onChange: onChange,
|
|
224
|
-
id: id,
|
|
225
|
-
setActionsActiveOnRow: setActionsActiveOnRow,
|
|
226
|
-
rowActionsButtonWidth: rowActionsButtonWidth,
|
|
227
|
-
conditionsToRender: !readOnly &&
|
|
228
|
-
enableRowActions &&
|
|
229
|
-
cellIdx === 0 &&
|
|
230
|
-
rowIdx !== undefined && //cuz for fixed col headers, rowIdx is undefined
|
|
231
|
-
hoveredRowAndCol.rowIdx === rowIdx,
|
|
232
|
-
})),
|
|
233
|
-
react_1.default.createElement("div", { style: { marginRight: dragZoneWidth + "px" } },
|
|
234
|
-
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) {
|
|
235
|
-
return handleCellInputChange({ v: v, rowIdx: rowIdx, cellIdx: cellIdx });
|
|
236
|
-
} })))));
|
|
237
|
-
})));
|
|
249
|
+
style: { display: "flex" }, readOnly: readOnly, rowIdx: rowIdx, key: row.id },
|
|
250
|
+
config.rowHeaderData &&
|
|
251
|
+
genCell({
|
|
252
|
+
cell: (0, convertRowHeaderConfigToCellData_1.convertRowHeaderConfigToCellData)({
|
|
253
|
+
rowHeaderData: config.rowHeaderData,
|
|
254
|
+
convertToRichText: convertToRichText,
|
|
255
|
+
rowIdx: rowIdx
|
|
256
|
+
}),
|
|
257
|
+
}),
|
|
258
|
+
row.cellData.map(function (cell, cellIdx) { return genCell({ cell: cell, cellIdx: cellIdx, rowIdx: rowIdx }); })));
|
|
238
259
|
};
|
|
239
260
|
var fullWidthCompWrapper = (0, react_1.useRef)(null);
|
|
240
261
|
return (react_1.default.createElement("div", null,
|
|
@@ -275,8 +296,10 @@ function SimpleTable(_a) {
|
|
|
275
296
|
? [
|
|
276
297
|
{
|
|
277
298
|
icon: "SquareHalf",
|
|
278
|
-
display:
|
|
279
|
-
|
|
299
|
+
display: value.data[0].cellData[0].isRowHeader
|
|
300
|
+
? UIContent_1.UIContent.SimpleTable.removeHeaderCol
|
|
301
|
+
: UIContent_1.UIContent.SimpleTable.addHeaderCol,
|
|
302
|
+
onClick: function () { return (0, handleToggleColHeader_1.handleToggleColHeader)({ value: value, onChange: onChange, id: id }); },
|
|
280
303
|
},
|
|
281
304
|
]
|
|
282
305
|
: []), true), (enableColActions
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export const StyledSimpleTable: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
2
2
|
export const StyledSimpleTableRow: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
3
3
|
export const StyledSimpleTableCell: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
4
|
+
export const StyledSimpleTableHeaderCell: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
4
5
|
export const StyledSimpleTableHeader: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
@@ -27,7 +27,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
27
27
|
return result;
|
|
28
28
|
};
|
|
29
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
-
exports.StyledSimpleTableHeader = exports.StyledSimpleTableCell = exports.StyledSimpleTableRow = exports.StyledSimpleTable = void 0;
|
|
30
|
+
exports.StyledSimpleTableHeader = exports.StyledSimpleTableHeaderCell = exports.StyledSimpleTableCell = exports.StyledSimpleTableRow = exports.StyledSimpleTable = void 0;
|
|
31
31
|
var themes_1 = require("../../themes");
|
|
32
32
|
var transitions_1 = require("../../themes/mixins/transitions");
|
|
33
33
|
var styled_components_1 = __importStar(require("styled-components"));
|
|
@@ -50,9 +50,11 @@ var genActiveColBorder = function (_a) {
|
|
|
50
50
|
? (0, styled_components_1.css)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["border-bottom: none;"], ["border-bottom: none;"]))) : !isFirstRow && !isLastRow
|
|
51
51
|
? (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(["border-top:none;"], ["border-top:none;"]))));
|
|
52
52
|
};
|
|
53
|
-
|
|
53
|
+
var tableCellStyling = (0, styled_components_1.css)(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\nmin-height: 4rem;\n position: relative;\n border-right: 1px solid ", ";\n border-bottom: 1px solid ", ";\n ", ";\n \n ", "\n"], ["\nmin-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) {
|
|
54
54
|
var readOnly = _a.readOnly, theme = _a.theme, actionsActiveOnRow = _a.actionsActiveOnRow, actionsActiveOnCol = _a.actionsActiveOnCol, rowIdx = _a.rowIdx, totRows = _a.totRows, colIdx = _a.colIdx;
|
|
55
55
|
return !readOnly && (0, styled_components_1.css)(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n ", ";\n \n ", "\n\n ", "\n "], ["\n ", ";\n \n ", "\n\n ", "\n "])), globalVariables_1.globalHoverOnWhiteBG, !actionsActiveOnRow && !actionsActiveOnCol && (0, styled_components_1.css)(templateObject_8 || (templateObject_8 = __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({ theme: theme, actionsActiveOnCol: actionsActiveOnCol, rowIdx: rowIdx, totRows: totRows, colIdx: colIdx }));
|
|
56
56
|
});
|
|
57
|
-
exports.
|
|
58
|
-
|
|
57
|
+
exports.StyledSimpleTableCell = styled_components_1.default.div(templateObject_11 || (templateObject_11 = __makeTemplateObject(["\n ", "\n"], ["\n ", "\n"])), tableCellStyling);
|
|
58
|
+
exports.StyledSimpleTableHeaderCell = styled_components_1.default.div(templateObject_12 || (templateObject_12 = __makeTemplateObject(["\n ", "\n .public-DraftEditor-content {\n font-weight: 600;\n }\n border-right: 2px solid ", ";\n"], ["\n ", "\n .public-DraftEditor-content {\n font-weight: 600;\n }\n border-right: 2px solid ", ";\n"])), tableCellStyling, themes_1.colors.greyColor10);
|
|
59
|
+
exports.StyledSimpleTableHeader = styled_components_1.default.div(templateObject_13 || (templateObject_13 = __makeTemplateObject(["\n .public-DraftEditor-content {\n font-weight: 600;\n }\n border-bottom: 2px solid ", ";\n"], ["\n .public-DraftEditor-content {\n font-weight: 600;\n }\n border-bottom: 2px solid ", ";\n"])), themes_1.colors.greyColor10);
|
|
60
|
+
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;
|
|
@@ -5,9 +5,16 @@ export function useResizeTableColumns({ setColWidthConfig, colWidthConfig, theme
|
|
|
5
5
|
builderProps: any;
|
|
6
6
|
}): {
|
|
7
7
|
resetColResizeState: (e: any) => void;
|
|
8
|
-
hideShowDragZoneIndicator: (e
|
|
8
|
+
hideShowDragZoneIndicator: ({ e, borderStyleActive, borderStyleInactive }: {
|
|
9
|
+
e: any;
|
|
10
|
+
borderStyleActive?: string;
|
|
11
|
+
borderStyleInactive?: string;
|
|
12
|
+
}) => void;
|
|
9
13
|
initColResizeState: (e: any, d: any) => void;
|
|
10
|
-
resetDragZoneIndicator: (e
|
|
14
|
+
resetDragZoneIndicator: ({ e, borderStyleInactive }: {
|
|
15
|
+
e: any;
|
|
16
|
+
borderStyleInactive?: string;
|
|
17
|
+
}) => void;
|
|
11
18
|
handleResizeColumn: (e: any) => void;
|
|
12
19
|
colResizeState: any;
|
|
13
20
|
dragZoneWidth: number;
|
|
@@ -29,10 +29,11 @@ var useResizeTableColumns = function (_a) {
|
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
31
|
};
|
|
32
|
-
var resetDragZoneIndicator = function (
|
|
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;
|
|
33
34
|
if (colResizeState || e.currentTarget.id !== e.target.id)
|
|
34
35
|
return;
|
|
35
|
-
e.currentTarget.style.borderRight =
|
|
36
|
+
e.currentTarget.style.borderRight = borderStyleInactive;
|
|
36
37
|
e.currentTarget.style.cursor = 'pointer';
|
|
37
38
|
};
|
|
38
39
|
var isInDragZone = function (e) {
|
|
@@ -51,18 +52,19 @@ var useResizeTableColumns = function (_a) {
|
|
|
51
52
|
});
|
|
52
53
|
}
|
|
53
54
|
};
|
|
54
|
-
var hideShowDragZoneIndicator = function (
|
|
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;
|
|
55
57
|
e.preventDefault();
|
|
56
58
|
/** currentTarget is the element that this event is bound to */
|
|
57
59
|
if (e.currentTarget.id !== e.target.id)
|
|
58
60
|
return; //very important, else the indicator shows in some cases, when its not supposed to. we don't completely understand why...
|
|
59
61
|
if (!colResizeState) {
|
|
60
62
|
if (isInDragZone(e)) {
|
|
61
|
-
e.currentTarget.style.borderRight =
|
|
63
|
+
e.currentTarget.style.borderRight = borderStyleActive;
|
|
62
64
|
e.currentTarget.style.cursor = 'col-resize';
|
|
63
65
|
}
|
|
64
66
|
else {
|
|
65
|
-
e.currentTarget.style.borderRight =
|
|
67
|
+
e.currentTarget.style.borderRight = borderStyleInactive;
|
|
66
68
|
e.currentTarget.style.cursor = 'pointer';
|
|
67
69
|
}
|
|
68
70
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
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],
|
|
8
|
+
readOnly: true,
|
|
9
|
+
id: "rowHeaderCell_".concat(rowIdx),
|
|
10
|
+
isRowHeader: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
exports.convertRowHeaderConfigToCellData = convertRowHeaderConfigToCellData;
|