oolib 2.67.3 → 2.67.5

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.
@@ -99,7 +99,8 @@ function ImageEditor(_a) {
99
99
  aspectRatio: aspectRatio,
100
100
  underEditImageData: underEditImageData,
101
101
  isFirstMount: isFirstMount,
102
- handleDeleteSingleImage: handleDeleteSingleImage
102
+ handleDeleteSingleImage: handleDeleteSingleImage,
103
+ readOnly: readOnly
103
104
  }), reorientedImageTempUrl = _l.reorientedImageTempUrl, imageLazyLoading = _l.imageLazyLoading;
104
105
  var _m = (0, react_1.useState)(undefined), showDeleteImageModal = _m[0], setShowDeleteImageModal = _m[1];
105
106
  var inputRef = (0, react_1.useRef)(null);
@@ -1,4 +1,4 @@
1
- export function useReorientImage({ imageRotate, setFullWidthOrFullHeightImg, setUnderEditImageData, publicUrl, aspectRatio, isFirstMount, handleDeleteSingleImage }: {
1
+ export function useReorientImage({ imageRotate, setFullWidthOrFullHeightImg, setUnderEditImageData, publicUrl, aspectRatio, isFirstMount, handleDeleteSingleImage, readOnly }: {
2
2
  imageRotate: any;
3
3
  setFullWidthOrFullHeightImg: any;
4
4
  setUnderEditImageData: any;
@@ -6,6 +6,7 @@ export function useReorientImage({ imageRotate, setFullWidthOrFullHeightImg, set
6
6
  aspectRatio: any;
7
7
  isFirstMount: any;
8
8
  handleDeleteSingleImage: any;
9
+ readOnly: any;
9
10
  }): {
10
11
  reorientedImageTempUrl: any;
11
12
  imageLazyLoading: boolean;
@@ -6,8 +6,9 @@ var react_1 = require("react");
6
6
  var decideIfFullWidthOrFullHeightImg_1 = require("../decideIfFullWidthOrFullHeightImg");
7
7
  var changeImageOrientation_1 = require("./changeImageOrientation");
8
8
  var bannerContext_1 = require("../../../../../Banners/bannerContext");
9
+ var UIContent_1 = require("../../../../../../UIContent");
9
10
  var useReorientImage = function (_a) {
10
- var imageRotate = _a.imageRotate, setFullWidthOrFullHeightImg = _a.setFullWidthOrFullHeightImg, setUnderEditImageData = _a.setUnderEditImageData, publicUrl = _a.publicUrl, aspectRatio = _a.aspectRatio, isFirstMount = _a.isFirstMount, handleDeleteSingleImage = _a.handleDeleteSingleImage;
11
+ var imageRotate = _a.imageRotate, setFullWidthOrFullHeightImg = _a.setFullWidthOrFullHeightImg, setUnderEditImageData = _a.setUnderEditImageData, publicUrl = _a.publicUrl, aspectRatio = _a.aspectRatio, isFirstMount = _a.isFirstMount, handleDeleteSingleImage = _a.handleDeleteSingleImage, readOnly = _a.readOnly;
11
12
  var SET_ALERT_BANNER = (0, bannerContext_1.useBannerContext)().SET_ALERT_BANNER;
12
13
  var _b = (0, react_1.useState)(true), imageLazyLoading = _b[0], setImageLazyLoading = _b[1];
13
14
  var _c = (0, react_1.useState)(undefined), reorientedImageTempUrl = _c[0], setReorientedImageTempUrl = _c[1];
@@ -29,8 +30,13 @@ var useReorientImage = function (_a) {
29
30
  * this component. In such cases, an error will fire here, and we need to
30
31
  * handle it, by deleting said url and throwing an alert
31
32
  */
32
- handleDeleteSingleImage({ publicUrl: publicUrl });
33
- SET_ALERT_BANNER(UIContent.ImageInput.corruptUrlErrMsg, 'red', 3000);
33
+ if (!readOnly) { //this also fixes another issue. in readonly in some cases (LinkEmbed) on change prop is not available. handleDelete uses the onChange, so this !readOnly condition solves that problem as well
34
+ handleDeleteSingleImage({ publicUrl: publicUrl });
35
+ SET_ALERT_BANNER(UIContent_1.UIContent.ImageInput.corruptUrlErrMsg, 'red', 3000);
36
+ }
37
+ else {
38
+ setImageLazyLoading(false); // in read only, let the broken image attempt to render and browser will show some default UI for the error
39
+ }
34
40
  };
35
41
  img.onload = function () {
36
42
  setFullWidthOrFullHeightImg((0, decideIfFullWidthOrFullHeightImg_1.decideIfFullWidthOrFullHeightImg)({
@@ -56,6 +56,7 @@ var functions_1 = require("./functions");
56
56
  var styled_1 = require("./styled");
57
57
  var useResizeTableColumns_1 = require("./useResizeTableColumns");
58
58
  var prepInitValueFromConfigIfNoValue_1 = require("./utils/prepInitValueFromConfigIfNoValue");
59
+ var convertColHeaderConfigToRowData_1 = require("./utils/convertColHeaderConfigToRowData");
59
60
  var greyColor100 = themes_1.colors.greyColor100;
60
61
  /*pending:
61
62
  - first test whatever is done on okf
@@ -81,11 +82,9 @@ function SimpleTable(_a) {
81
82
  _value: _value,
82
83
  config: config,
83
84
  defaultColWidth: defaultColWidth,
84
- convertToRichText: convertToRichText
85
85
  }), value = _f.value, canAddCols = _f.canAddCols, //returns true if no config.colHeaderData is defined. else false
86
86
  canToggleColHeaderStyle = _f.canToggleColHeaderStyle // returns true if no config.colHeaderData is defined. else false
87
87
  ;
88
- console.log({ value: value });
89
88
  var _g = (0, useResizeTableColumns_1.useResizeTableColumns)({
90
89
  setColWidthConfig: function (setterFn) {
91
90
  var newColWidthConfig = setterFn(value.colWidthConfig);
@@ -172,7 +171,9 @@ function SimpleTable(_a) {
172
171
  alignItems: "stretch" /**without stretch AddColButton will be wonky */,
173
172
  } },
174
173
  react_1.default.createElement("div", null,
175
- react_1.default.createElement(styled_1.StyledSimpleTable, null, value.data.map(function (row, rowIdx) { return genRow({ row: row, rowIdx: rowIdx }); })),
174
+ react_1.default.createElement(styled_1.StyledSimpleTable, null,
175
+ config.colHeaderData && genRow({ row: (0, convertColHeaderConfigToRowData_1.convertColHeaderConfigToRowData)({ colHeaderData: config.colHeaderData, convertToRichText: convertToRichText }) }),
176
+ value.data.map(function (row, rowIdx) { return genRow({ row: row, rowIdx: rowIdx }); })),
176
177
  !readOnly && canAddRows && (react_1.default.createElement(AddRowColButtons_1.AddRowButton, { onClick: function () { return (0, functions_1.handleAddRow)(value, props); } }))),
177
178
  !readOnly && canAddCols && (react_1.default.createElement(AddRowColButtons_1.AddColButton, { onClick: function () { return (0, functions_1.handleAddCol)(value, props); } })))));
178
179
  }
@@ -35,7 +35,7 @@ var utilsOolib_1 = require("../../utilsOolib");
35
35
  exports.StyledSimpleTable = styled_components_1.default.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n border-top: 1px solid ", ";\n border-bottom: 1px solid ", ";\n border-left: 1px solid ", ";\n"], ["\n border-top: 1px solid ", ";\n border-bottom: 1px solid ", ";\n border-left: 1px solid ", ";\n"])), themes_1.colors.greyColor10, themes_1.colors.greyColor10, themes_1.colors.greyColor10);
36
36
  exports.StyledSimpleTableRow = styled_components_1.default.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n display: flex;\n ", ";\n background-color: ", ";\n"], ["\n display: flex;\n ", ";\n background-color: ", ";\n"])), (0, transitions_1.transition)("background-color"), function (_a) {
37
37
  var rowIdx = _a.rowIdx;
38
- return rowIdx % 2 === 1 ? themes_1.colors.greyColor3 : themes_1.colors.white;
38
+ return rowIdx % 2 === 1 ? themes_1.colors.white : themes_1.colors.greyColor3;
39
39
  });
40
40
  exports.StyledSimpleTableCell = styled_components_1.default.div(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n /* max-width: 300px; */\n padding: 0.8rem 1rem;\n /* margin: 0 1rem; */\n border-right: 1px solid ", ";\n ", ";\n ", "\n"], ["\n /* max-width: 300px; */\n padding: 0.8rem 1rem;\n /* margin: 0 1rem; */\n border-right: 1px solid ", ";\n ", ";\n ", "\n"])), themes_1.colors.greyColor10, (0, transitions_1.transition)("background-color"), function (_a) {
41
41
  var readOnly = _a.readOnly, theme = _a.theme;
@@ -0,0 +1,8 @@
1
+ export function convertColHeaderConfigToRowData({ colHeaderData, convertToRichText }: {
2
+ colHeaderData: any;
3
+ convertToRichText: any;
4
+ }): {
5
+ id: string;
6
+ isColHeader: boolean;
7
+ cellData: any;
8
+ };
@@ -0,0 +1,16 @@
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,
11
+ readOnly: true,
12
+ id: "colHeaderCell_".concat(i),
13
+ }); }),
14
+ };
15
+ };
16
+ exports.convertColHeaderConfigToRowData = convertColHeaderConfigToRowData;
@@ -1,8 +1,7 @@
1
- export function prepInitValueFromConfigIfNoValue({ _value, config, defaultColWidth, convertToRichText }: {
1
+ export function prepInitValueFromConfigIfNoValue({ _value, config, defaultColWidth, }: {
2
2
  _value: any;
3
3
  config: any;
4
4
  defaultColWidth: any;
5
- convertToRichText: any;
6
5
  }): {
7
6
  value: any;
8
7
  canAddCols: boolean;
@@ -22,46 +22,36 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
23
  exports.prepInitValueFromConfigIfNoValue = void 0;
24
24
  var makeArrayFromLength_1 = require("../../../utils/makeArrayFromLength");
25
- var toArray_1 = require("../../../utils/toArray");
26
25
  var functions_1 = require("../functions");
27
26
  var prepInitValueFromConfigIfNoValue = function (_a) {
28
- var _b;
29
- var _value = _a._value, config = _a.config, defaultColWidth = _a.defaultColWidth, convertToRichText = _a.convertToRichText;
27
+ var _b, _c;
28
+ var _value = _a._value, config = _a.config, defaultColWidth = _a.defaultColWidth;
30
29
  //if colHeaderData is defined then that decides the noOfCols.
31
30
  var noOfCols = ((_b = config.colHeaderData) === null || _b === void 0 ? void 0 : _b.length) || config.noOfCols;
32
- var value = !_value
33
- ? {
34
- data: __spreadArray(__spreadArray([], (config.colHeaderData ? [convertColHeaderConfigToRowData({ colHeaderData: config.colHeaderData, convertToRichText: convertToRichText })] : []), true), insertRowAndCellIds({
35
- noOfRows: config.noOfRows,
36
- noOfCols: noOfCols
37
- }), true),
38
- colWidthConfig: getInitColWidthConfigs({ noOfCols: noOfCols, defaultColWidth: defaultColWidth }),
39
- }
40
- : !_value.data
31
+ var value = ((_c = _value === null || _value === void 0 ? void 0 : _value.data) === null || _c === void 0 ? void 0 : _c.length) > 0 //value exists in the correct shape
32
+ ? _value
33
+ : Array.isArray(_value) && _value.length > 0 //value exists but in deprecated shape
41
34
  ? {
42
35
  data: _value,
43
- colWidthConfig: getInitColWidthConfigs({ noOfCols: _value[0].cellData.length, defaultColWidth: defaultColWidth }),
44
- } //backwars compat
45
- : _value;
46
- return ({
36
+ colWidthConfig: getInitColWidthConfigs({
37
+ noOfCols: _value[0].cellData.length,
38
+ defaultColWidth: defaultColWidth,
39
+ }),
40
+ } //backwards compat
41
+ : {
42
+ data: __spreadArray([], insertRowAndCellIds({
43
+ noOfRows: config.noOfRows,
44
+ noOfCols: noOfCols,
45
+ }), true),
46
+ colWidthConfig: getInitColWidthConfigs({ noOfCols: noOfCols, defaultColWidth: defaultColWidth }),
47
+ };
48
+ return {
47
49
  value: value,
48
50
  canAddCols: !!!config.colHeaderData,
49
- canToggleColHeaderStyle: !!!config.colHeaderData // meaning its true if no config.colHeaderData is defined. else false
50
- });
51
- };
52
- exports.prepInitValueFromConfigIfNoValue = prepInitValueFromConfigIfNoValue;
53
- var convertColHeaderConfigToRowData = function (_a) {
54
- var colHeaderData = _a.colHeaderData, convertToRichText = _a.convertToRichText;
55
- return {
56
- id: "colHeader",
57
- isColHeader: true,
58
- cellData: colHeaderData.map(function (d, i) { return ({
59
- value: convertToRichText ? convertToRichText(d) : d,
60
- readOnly: true,
61
- id: "colHeaderCell_".concat(i),
62
- }); }),
51
+ canToggleColHeaderStyle: !!!config.colHeaderData, // meaning its true if no config.colHeaderData is defined. else false
63
52
  };
64
53
  };
54
+ exports.prepInitValueFromConfigIfNoValue = prepInitValueFromConfigIfNoValue;
65
55
  var getInitColWidthConfigs = function (_a) {
66
56
  var noOfCols = _a.noOfCols, defaultColWidth = _a.defaultColWidth;
67
57
  return (0, makeArrayFromLength_1.makeArrayFromLength)(noOfCols)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oolib",
3
- "version": "2.67.3",
3
+ "version": "2.67.5",
4
4
  "description": " OKE Component Library",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",