@fileverse-dev/fortune-react 1.0.2-mod-54 → 1.0.2-mod-56
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/components/ResetColumnWidth/index.d.ts +2 -0
- package/dist/index.esm.js +145 -36
- package/dist/index.js +143 -34
- package/dist/index.umd.js +2713 -4429
- package/dist/index.umd.min.js +9 -9
- package/package.json +2 -2
package/dist/index.esm.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { defaultContext, defaultSettings, getSheetIndex, colLocationByIndex, fixPositionOnFrozenCells, colLocation, getFlowdata, isAllowEdit, handleColumnHeaderMouseDown, handleColSizeHandleMouseDown, handleColFreezeHandleMouseDown, handleContextMenu, selectTitlesMap, selectTitlesRange, fixColumnStyleOverflowInFreeze, rowLocationByIndex, rowLocation, handleRowHeaderMouseDown, handleRowSizeHandleMouseDown, handleRowFreezeHandleMouseDown, fixRowStyleOverflowInFreeze, locale, getStyleByCell, getCellValue, createRangeHightlight, isInlineStringCell, getInlineStringHTML, valueShowEs, escapeHTMLTag, escapeScriptTag, moveToEnd, isShowHidenCR, getrangeseleciton, cancelNormalSelected, moveHighlightCell, israngeseleciton, handleFormulaInput, onSearchDialogMoveStart, replaceAll, replace, searchAll, searchNext, normalizeSelection, scrollToHighlightCell, isLinkValid, goToLink, replaceHtml, removeHyperlink, saveHyperlink, createFilterOptions, onImageMoveStart, onImageResizeStart, showComments, setEditingComment, onCommentBoxMoveStart, confirmMessage, getRangeByTxt, getDropdownList, setCellValue, getRangetxt, setConditionRules, mergeBorder, setDropdownValue, onIframeMoveStart, onIframeResizeStart, onIframeMove, onIframeMoveEnd, onIframeResize, onIframeResizeEnd, handleCellAreaMouseDown, handleCellAreaDoubleClick, selectAll, showLinkCard, getCellRowColumn, getCellHyperlink, handleOverlayMouseMove, handleOverlayMouseUp, handleKeydownForZoom, handleOverlayTouchStart, handleOverlayTouchMove, handleOverlayTouchEnd, insertRowCol, drawArrow, onCellsMoveStart, createDropCellRange, updateContextWithSheetData, updateContextWithCanvas, initFreeze, Canvas, handleGlobalWheel, getDataArr, updateMoreCell, getRegStr, getOptionValue, getSelectRange, applyLocation, updateItem, update, sanitizeDuneUrl, normalizedCellAttr, updateFormat, handleTextSize, handleHorizontalAlign, handleVerticalAlign, handleScreenShot, showImgChooser, insertImage, editComment, deleteComment, showHideComment, showHideAllComments, newComment, handleSum, autoSelectionFormula, handleMerge, handleBorder, handleFreeze, handleSort, createFilter, clearFilter, toolbarItemSelectedFunc, toolbarItemClickHandler, insertDuneChart, handleTextColor, handleTextBackground, getInlineStringNoStyle, rangeHightlightselected, updateCell, editSheetName, cancelActiveImgItem, MAX_ZOOM_RATIO, MIN_ZOOM_RATIO, addSheet, getFreezeState, toggleFreeze, jfrefreshgrid, handleCopy, removeActiveImage, deleteSelectedCellText, deleteRowCol, hideSelected, showSelected,
|
|
1
|
+
import { defaultContext, defaultSettings, getSheetIndex, colLocationByIndex, fixPositionOnFrozenCells, colLocation, getFlowdata, isAllowEdit, handleColumnHeaderMouseDown, handleColSizeHandleMouseDown, handleColFreezeHandleMouseDown, handleContextMenu, selectTitlesMap, selectTitlesRange, fixColumnStyleOverflowInFreeze, rowLocationByIndex, rowLocation, handleRowHeaderMouseDown, handleRowSizeHandleMouseDown, handleRowFreezeHandleMouseDown, fixRowStyleOverflowInFreeze, locale, getStyleByCell, getCellValue, createRangeHightlight, isInlineStringCell, getInlineStringHTML, valueShowEs, escapeHTMLTag, escapeScriptTag, moveToEnd, isShowHidenCR, getrangeseleciton, cancelNormalSelected, moveHighlightCell, israngeseleciton, handleFormulaInput, onSearchDialogMoveStart, replaceAll, replace, searchAll, searchNext, normalizeSelection, scrollToHighlightCell, isLinkValid, goToLink, replaceHtml, removeHyperlink, saveHyperlink, createFilterOptions, onImageMoveStart, onImageResizeStart, showComments, setEditingComment, onCommentBoxMoveStart, confirmMessage, getRangeByTxt, getDropdownList, setCellValue, getRangetxt, setConditionRules, mergeBorder, setDropdownValue, onIframeMoveStart, onIframeResizeStart, onIframeMove, onIframeMoveEnd, onIframeResize, onIframeResizeEnd, handleCellAreaMouseDown, handleCellAreaDoubleClick, selectAll, showLinkCard, getCellRowColumn, getCellHyperlink, handleOverlayMouseMove, handleOverlayMouseUp, handleKeydownForZoom, handleOverlayTouchStart, handleOverlayTouchMove, handleOverlayTouchEnd, insertRowCol, drawArrow, onCellsMoveStart, createDropCellRange, updateContextWithSheetData, updateContextWithCanvas, initFreeze, Canvas, handleGlobalWheel, getDataArr, updateMoreCell, getRegStr, getOptionValue, getSelectRange, applyLocation, updateItem, update, sanitizeDuneUrl, normalizedCellAttr, updateFormat, handleTextSize, handleHorizontalAlign, handleVerticalAlign, handleScreenShot, showImgChooser, insertImage, editComment, deleteComment, showHideComment, showHideAllComments, newComment, handleSum, autoSelectionFormula, handleMerge, handleBorder, handleFreeze, handleSort, createFilter, clearFilter, toolbarItemSelectedFunc, toolbarItemClickHandler, insertDuneChart, handleTextColor, handleTextBackground, getInlineStringNoStyle, rangeHightlightselected, updateCell, editSheetName, cancelActiveImgItem, MAX_ZOOM_RATIO, MIN_ZOOM_RATIO, addSheet, api, getFreezeState, toggleFreeze, jfrefreshgrid, handleCopy, removeActiveImage, deleteSelectedCellText, deleteRowCol, hideSelected, showSelected, sortSelection, handleLink, handlePasteByClick, deleteSheet, opToPatch, setCaretPosition, orderbydatafiler, getFilterColumnValues, getFilterColumnColors, saveFilter, calcSelectionInfo, patchToOp, filterPatch, inverseRowColOptions, ensureSheetIndex, initSheetIndex, handleGlobalKeyDown, handlePaste, groupValuesRefresh } from '@fileverse-dev/fortune-core';
|
|
2
2
|
import React, { useContext, useRef, useState, useMemo, useCallback, useEffect, useLayoutEffect, useImperativeHandle } from 'react';
|
|
3
3
|
import produce, { applyPatches, enablePatches, produceWithPatches } from 'immer';
|
|
4
4
|
import _ from 'lodash';
|
|
5
|
-
import { LucideIcon, TextField, Button as Button$1, cn, IconButton, Checkbox, Divider as Divider$2, Table, TableHeader, TableRow, TableHead, TableBody, TableCell, Select as Select$1, SelectTrigger, SelectValue, SelectContent, SelectItem as SelectItem$1 } from '@fileverse/ui';
|
|
5
|
+
import { LucideIcon, TextField, Button as Button$1, cn, IconButton, Checkbox, Divider as Divider$2, Table, TableHeader, TableRow, TableHead, TableBody, TableCell, Select as Select$1, SelectTrigger, SelectValue, SelectContent, SelectItem as SelectItem$1, RadioGroup, RadioGroupItem, Label } from '@fileverse/ui';
|
|
6
6
|
import regeneratorRuntime from 'regenerator-runtime';
|
|
7
7
|
import Tippy from '@tippyjs/react';
|
|
8
8
|
|
|
@@ -269,6 +269,15 @@ function _toPropertyKey(t) {
|
|
|
269
269
|
var i = _toPrimitive(t, "string");
|
|
270
270
|
return "symbol" == typeof i ? i : i + "";
|
|
271
271
|
}
|
|
272
|
+
function _typeof(o) {
|
|
273
|
+
"@babel/helpers - typeof";
|
|
274
|
+
|
|
275
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
276
|
+
return typeof o;
|
|
277
|
+
} : function (o) {
|
|
278
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
279
|
+
}, _typeof(o);
|
|
280
|
+
}
|
|
272
281
|
function _unsupportedIterableToArray(r, a) {
|
|
273
282
|
if (r) {
|
|
274
283
|
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|
@@ -4719,7 +4728,8 @@ var SplitColumn = function SplitColumn() {
|
|
|
4719
4728
|
tabIndex: 0
|
|
4720
4729
|
}), /*#__PURE__*/React.createElement("label", {
|
|
4721
4730
|
htmlFor: "other"
|
|
4722
|
-
}, "Custom"), /*#__PURE__*/React.createElement(
|
|
4731
|
+
}, "Custom"), /*#__PURE__*/React.createElement(TextField, {
|
|
4732
|
+
placeholder: "Custom separator",
|
|
4723
4733
|
id: "otherValue",
|
|
4724
4734
|
name: "otherValue",
|
|
4725
4735
|
type: "text",
|
|
@@ -7485,6 +7495,135 @@ var SheetTab = function SheetTab() {
|
|
|
7485
7495
|
}, /*#__PURE__*/React.createElement(ZoomControl, null)));
|
|
7486
7496
|
};
|
|
7487
7497
|
|
|
7498
|
+
var ResetColumnWidth = function ResetColumnWidth() {
|
|
7499
|
+
var _useContext = useContext(WorkbookContext),
|
|
7500
|
+
context = _useContext.context,
|
|
7501
|
+
setContext = _useContext.setContext;
|
|
7502
|
+
var _useAlert = useAlert(),
|
|
7503
|
+
showAlert = _useAlert.showAlert;
|
|
7504
|
+
var _locale = locale(context),
|
|
7505
|
+
button = _locale.button;
|
|
7506
|
+
var _useDialog = useDialog(),
|
|
7507
|
+
hideDialog = _useDialog.hideDialog;
|
|
7508
|
+
var _useState = useState("number"),
|
|
7509
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
7510
|
+
radioValue = _useState2[0],
|
|
7511
|
+
setRadioValue = _useState2[1];
|
|
7512
|
+
var _useState3 = useState(100),
|
|
7513
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
7514
|
+
numberValue = _useState4[0],
|
|
7515
|
+
setNumberValue = _useState4[1];
|
|
7516
|
+
var getMaxCellWidth = function getMaxCellWidth(col) {
|
|
7517
|
+
var data = getFlowdata(context);
|
|
7518
|
+
var maxWidth = 100;
|
|
7519
|
+
if (data) {
|
|
7520
|
+
for (var i = 0; i < data.length; i += 1) {
|
|
7521
|
+
var cellD = data[i][col];
|
|
7522
|
+
if (typeof cellD === 'string') {
|
|
7523
|
+
if (cellD.length * 7 > maxWidth) {
|
|
7524
|
+
maxWidth = cellD.length * 7;
|
|
7525
|
+
}
|
|
7526
|
+
} else if (_typeof(cellD) === 'object' && cellD !== null) {
|
|
7527
|
+
console.log(cellD, "cellD");
|
|
7528
|
+
var cellText = cellD.v || cellD.m;
|
|
7529
|
+
if (cellText.length * 7 > maxWidth) {
|
|
7530
|
+
maxWidth = cellText.length * 7;
|
|
7531
|
+
}
|
|
7532
|
+
}
|
|
7533
|
+
}
|
|
7534
|
+
}
|
|
7535
|
+
return maxWidth;
|
|
7536
|
+
};
|
|
7537
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
7538
|
+
id: "fortune-split-column"
|
|
7539
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
7540
|
+
className: ""
|
|
7541
|
+
}, /*#__PURE__*/React.createElement(RadioGroup, {
|
|
7542
|
+
defaultValue: radioValue,
|
|
7543
|
+
onValueChange: function onValueChange(value) {
|
|
7544
|
+
setRadioValue(value);
|
|
7545
|
+
}
|
|
7546
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
7547
|
+
className: "flex-col gap-4"
|
|
7548
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
7549
|
+
className: "flex items-center space-x-1"
|
|
7550
|
+
}, /*#__PURE__*/React.createElement(RadioGroupItem, {
|
|
7551
|
+
id: "r1",
|
|
7552
|
+
size: "lg",
|
|
7553
|
+
value: "number"
|
|
7554
|
+
}), /*#__PURE__*/React.createElement(Label, {
|
|
7555
|
+
className: "text-heading-xsm",
|
|
7556
|
+
htmlFor: "r1"
|
|
7557
|
+
}, "Enter new column width in pixels. (Default: 80)")), /*#__PURE__*/React.createElement(TextField, {
|
|
7558
|
+
className: "w-1/3 my-4",
|
|
7559
|
+
defaultValue: numberValue,
|
|
7560
|
+
isValid: true,
|
|
7561
|
+
onChange: function onChange(e) {
|
|
7562
|
+
setNumberValue(e.target.value);
|
|
7563
|
+
},
|
|
7564
|
+
placeholder: "Number"
|
|
7565
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
7566
|
+
className: "flex items-center space-x-1 mb-4"
|
|
7567
|
+
}, /*#__PURE__*/React.createElement(RadioGroupItem, {
|
|
7568
|
+
id: "r2",
|
|
7569
|
+
size: "lg",
|
|
7570
|
+
value: "fit"
|
|
7571
|
+
}), /*#__PURE__*/React.createElement(Label, {
|
|
7572
|
+
className: "text-heading-xsm",
|
|
7573
|
+
htmlFor: "r2"
|
|
7574
|
+
}, "Fit to data")))), /*#__PURE__*/React.createElement("div", {
|
|
7575
|
+
className: "flex justify-end gap-2"
|
|
7576
|
+
}, /*#__PURE__*/React.createElement(Button$1, {
|
|
7577
|
+
variant: "secondary",
|
|
7578
|
+
onClick: function onClick() {
|
|
7579
|
+
hideDialog();
|
|
7580
|
+
},
|
|
7581
|
+
tabIndex: 0
|
|
7582
|
+
}, button.cancel), /*#__PURE__*/React.createElement(Button$1, {
|
|
7583
|
+
onClick: function onClick() {
|
|
7584
|
+
if (radioValue === "number") {
|
|
7585
|
+
var targetColWidth = numberValue;
|
|
7586
|
+
setContext(function (draftCtx) {
|
|
7587
|
+
if (_.isUndefined(targetColWidth) || targetColWidth === null || targetColWidth <= 0 || targetColWidth > 2038) {
|
|
7588
|
+
showAlert("The column width must be between 0 ~ 2038", "ok");
|
|
7589
|
+
draftCtx.contextMenu = {};
|
|
7590
|
+
return;
|
|
7591
|
+
}
|
|
7592
|
+
var numColWidth = targetColWidth;
|
|
7593
|
+
var colWidthList = {};
|
|
7594
|
+
_.forEach(draftCtx.luckysheet_select_save, function (section) {
|
|
7595
|
+
for (var colNum = section.column[0]; colNum <= section.column[1]; colNum += 1) {
|
|
7596
|
+
getMaxCellWidth(colNum);
|
|
7597
|
+
colWidthList[colNum] = numColWidth;
|
|
7598
|
+
}
|
|
7599
|
+
});
|
|
7600
|
+
api.setColumnWidth(draftCtx, colWidthList, {}, true);
|
|
7601
|
+
draftCtx.contextMenu = {};
|
|
7602
|
+
});
|
|
7603
|
+
} else {
|
|
7604
|
+
var _targetColWidth = numberValue;
|
|
7605
|
+
setContext(function (draftCtx) {
|
|
7606
|
+
if (_.isUndefined(_targetColWidth) || _targetColWidth === null || _targetColWidth <= 0 || _targetColWidth > 2038) {
|
|
7607
|
+
showAlert("The column width must be between 0 ~ 2038", "ok");
|
|
7608
|
+
draftCtx.contextMenu = {};
|
|
7609
|
+
return;
|
|
7610
|
+
}
|
|
7611
|
+
var colWidthList = {};
|
|
7612
|
+
_.forEach(draftCtx.luckysheet_select_save, function (section) {
|
|
7613
|
+
for (var colNum = section.column[0]; colNum <= section.column[1]; colNum += 1) {
|
|
7614
|
+
colWidthList[colNum] = getMaxCellWidth(colNum);
|
|
7615
|
+
}
|
|
7616
|
+
});
|
|
7617
|
+
api.setColumnWidth(draftCtx, colWidthList, {}, true);
|
|
7618
|
+
draftCtx.contextMenu = {};
|
|
7619
|
+
});
|
|
7620
|
+
}
|
|
7621
|
+
hideDialog();
|
|
7622
|
+
},
|
|
7623
|
+
tabIndex: 0
|
|
7624
|
+
}, "Ok")));
|
|
7625
|
+
};
|
|
7626
|
+
|
|
7488
7627
|
var Divider$1 = function Divider() {
|
|
7489
7628
|
return /*#__PURE__*/React.createElement("div", {
|
|
7490
7629
|
className: "fortune-context-menu-divider"
|
|
@@ -8204,24 +8343,11 @@ var ContextMenu = function ContextMenu() {
|
|
|
8204
8343
|
})) ? (/*#__PURE__*/React.createElement(Menu, {
|
|
8205
8344
|
key: "set-column-width",
|
|
8206
8345
|
onClick: function onClick(e, container) {
|
|
8207
|
-
|
|
8208
|
-
var targetColWidth = (_container$querySelec2 = container.querySelector("input")) === null || _container$querySelec2 === void 0 ? void 0 : _container$querySelec2.value;
|
|
8346
|
+
showDialog(/*#__PURE__*/React.createElement(ResetColumnWidth, null), undefined, "Resize column");
|
|
8209
8347
|
setContext(function (draftCtx) {
|
|
8210
|
-
if (_.isUndefined(targetColWidth) || targetColWidth === "" || parseInt(targetColWidth, 10) <= 0 || parseInt(targetColWidth, 10) > 2038) {
|
|
8211
|
-
showAlert(info.tipColumnWidthLimit, "ok");
|
|
8212
|
-
draftCtx.contextMenu = {};
|
|
8213
|
-
return;
|
|
8214
|
-
}
|
|
8215
|
-
var numColWidth = parseInt(targetColWidth, 10);
|
|
8216
|
-
var colWidthList = {};
|
|
8217
|
-
_.forEach(draftCtx.luckysheet_select_save, function (section) {
|
|
8218
|
-
for (var colNum = section.column[0]; colNum <= section.column[1]; colNum += 1) {
|
|
8219
|
-
colWidthList[colNum] = numColWidth;
|
|
8220
|
-
}
|
|
8221
|
-
});
|
|
8222
|
-
api.setColumnWidth(draftCtx, colWidthList, {}, true);
|
|
8223
8348
|
draftCtx.contextMenu = {};
|
|
8224
8349
|
});
|
|
8350
|
+
return;
|
|
8225
8351
|
}
|
|
8226
8352
|
}, /*#__PURE__*/React.createElement("div", {
|
|
8227
8353
|
className: "context-item"
|
|
@@ -8232,24 +8358,7 @@ var ContextMenu = function ContextMenu() {
|
|
|
8232
8358
|
style: {
|
|
8233
8359
|
marginRight: "8px"
|
|
8234
8360
|
}
|
|
8235
|
-
}), /*#__PURE__*/React.createElement("div", null, "Resize column
|
|
8236
|
-
onClick: function onClick(e) {
|
|
8237
|
-
return e.stopPropagation();
|
|
8238
|
-
},
|
|
8239
|
-
onKeyDown: function onKeyDown(e) {
|
|
8240
|
-
return e.stopPropagation();
|
|
8241
|
-
},
|
|
8242
|
-
tabIndex: 0,
|
|
8243
|
-
type: "number",
|
|
8244
|
-
min: 1,
|
|
8245
|
-
max: 545,
|
|
8246
|
-
className: "luckysheet-mousedown-cancel",
|
|
8247
|
-
placeholder: rightclick.number,
|
|
8248
|
-
defaultValue: shownColWidth,
|
|
8249
|
-
style: {
|
|
8250
|
-
width: "40px"
|
|
8251
|
-
}
|
|
8252
|
-
}), "px")))) : null;
|
|
8361
|
+
}), /*#__PURE__*/React.createElement("div", null, "Resize column width")))) : null;
|
|
8253
8362
|
}
|
|
8254
8363
|
if (name === "clear") {
|
|
8255
8364
|
return /*#__PURE__*/React.createElement(Menu, {
|
package/dist/index.js
CHANGED
|
@@ -281,6 +281,15 @@ function _toPropertyKey(t) {
|
|
|
281
281
|
var i = _toPrimitive(t, "string");
|
|
282
282
|
return "symbol" == typeof i ? i : i + "";
|
|
283
283
|
}
|
|
284
|
+
function _typeof(o) {
|
|
285
|
+
"@babel/helpers - typeof";
|
|
286
|
+
|
|
287
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
288
|
+
return typeof o;
|
|
289
|
+
} : function (o) {
|
|
290
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
291
|
+
}, _typeof(o);
|
|
292
|
+
}
|
|
284
293
|
function _unsupportedIterableToArray(r, a) {
|
|
285
294
|
if (r) {
|
|
286
295
|
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|
@@ -4731,7 +4740,8 @@ var SplitColumn = function SplitColumn() {
|
|
|
4731
4740
|
tabIndex: 0
|
|
4732
4741
|
}), /*#__PURE__*/React__default['default'].createElement("label", {
|
|
4733
4742
|
htmlFor: "other"
|
|
4734
|
-
}, "Custom"), /*#__PURE__*/React__default['default'].createElement(
|
|
4743
|
+
}, "Custom"), /*#__PURE__*/React__default['default'].createElement(ui.TextField, {
|
|
4744
|
+
placeholder: "Custom separator",
|
|
4735
4745
|
id: "otherValue",
|
|
4736
4746
|
name: "otherValue",
|
|
4737
4747
|
type: "text",
|
|
@@ -7497,6 +7507,135 @@ var SheetTab = function SheetTab() {
|
|
|
7497
7507
|
}, /*#__PURE__*/React__default['default'].createElement(ZoomControl, null)));
|
|
7498
7508
|
};
|
|
7499
7509
|
|
|
7510
|
+
var ResetColumnWidth = function ResetColumnWidth() {
|
|
7511
|
+
var _useContext = React.useContext(WorkbookContext),
|
|
7512
|
+
context = _useContext.context,
|
|
7513
|
+
setContext = _useContext.setContext;
|
|
7514
|
+
var _useAlert = useAlert(),
|
|
7515
|
+
showAlert = _useAlert.showAlert;
|
|
7516
|
+
var _locale = fortuneCore.locale(context),
|
|
7517
|
+
button = _locale.button;
|
|
7518
|
+
var _useDialog = useDialog(),
|
|
7519
|
+
hideDialog = _useDialog.hideDialog;
|
|
7520
|
+
var _useState = React.useState("number"),
|
|
7521
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
7522
|
+
radioValue = _useState2[0],
|
|
7523
|
+
setRadioValue = _useState2[1];
|
|
7524
|
+
var _useState3 = React.useState(100),
|
|
7525
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
7526
|
+
numberValue = _useState4[0],
|
|
7527
|
+
setNumberValue = _useState4[1];
|
|
7528
|
+
var getMaxCellWidth = function getMaxCellWidth(col) {
|
|
7529
|
+
var data = fortuneCore.getFlowdata(context);
|
|
7530
|
+
var maxWidth = 100;
|
|
7531
|
+
if (data) {
|
|
7532
|
+
for (var i = 0; i < data.length; i += 1) {
|
|
7533
|
+
var cellD = data[i][col];
|
|
7534
|
+
if (typeof cellD === 'string') {
|
|
7535
|
+
if (cellD.length * 7 > maxWidth) {
|
|
7536
|
+
maxWidth = cellD.length * 7;
|
|
7537
|
+
}
|
|
7538
|
+
} else if (_typeof(cellD) === 'object' && cellD !== null) {
|
|
7539
|
+
console.log(cellD, "cellD");
|
|
7540
|
+
var cellText = cellD.v || cellD.m;
|
|
7541
|
+
if (cellText.length * 7 > maxWidth) {
|
|
7542
|
+
maxWidth = cellText.length * 7;
|
|
7543
|
+
}
|
|
7544
|
+
}
|
|
7545
|
+
}
|
|
7546
|
+
}
|
|
7547
|
+
return maxWidth;
|
|
7548
|
+
};
|
|
7549
|
+
return /*#__PURE__*/React__default['default'].createElement("div", {
|
|
7550
|
+
id: "fortune-split-column"
|
|
7551
|
+
}, /*#__PURE__*/React__default['default'].createElement("div", {
|
|
7552
|
+
className: ""
|
|
7553
|
+
}, /*#__PURE__*/React__default['default'].createElement(ui.RadioGroup, {
|
|
7554
|
+
defaultValue: radioValue,
|
|
7555
|
+
onValueChange: function onValueChange(value) {
|
|
7556
|
+
setRadioValue(value);
|
|
7557
|
+
}
|
|
7558
|
+
}, /*#__PURE__*/React__default['default'].createElement("div", {
|
|
7559
|
+
className: "flex-col gap-4"
|
|
7560
|
+
}, /*#__PURE__*/React__default['default'].createElement("div", {
|
|
7561
|
+
className: "flex items-center space-x-1"
|
|
7562
|
+
}, /*#__PURE__*/React__default['default'].createElement(ui.RadioGroupItem, {
|
|
7563
|
+
id: "r1",
|
|
7564
|
+
size: "lg",
|
|
7565
|
+
value: "number"
|
|
7566
|
+
}), /*#__PURE__*/React__default['default'].createElement(ui.Label, {
|
|
7567
|
+
className: "text-heading-xsm",
|
|
7568
|
+
htmlFor: "r1"
|
|
7569
|
+
}, "Enter new column width in pixels. (Default: 80)")), /*#__PURE__*/React__default['default'].createElement(ui.TextField, {
|
|
7570
|
+
className: "w-1/3 my-4",
|
|
7571
|
+
defaultValue: numberValue,
|
|
7572
|
+
isValid: true,
|
|
7573
|
+
onChange: function onChange(e) {
|
|
7574
|
+
setNumberValue(e.target.value);
|
|
7575
|
+
},
|
|
7576
|
+
placeholder: "Number"
|
|
7577
|
+
})), /*#__PURE__*/React__default['default'].createElement("div", {
|
|
7578
|
+
className: "flex items-center space-x-1 mb-4"
|
|
7579
|
+
}, /*#__PURE__*/React__default['default'].createElement(ui.RadioGroupItem, {
|
|
7580
|
+
id: "r2",
|
|
7581
|
+
size: "lg",
|
|
7582
|
+
value: "fit"
|
|
7583
|
+
}), /*#__PURE__*/React__default['default'].createElement(ui.Label, {
|
|
7584
|
+
className: "text-heading-xsm",
|
|
7585
|
+
htmlFor: "r2"
|
|
7586
|
+
}, "Fit to data")))), /*#__PURE__*/React__default['default'].createElement("div", {
|
|
7587
|
+
className: "flex justify-end gap-2"
|
|
7588
|
+
}, /*#__PURE__*/React__default['default'].createElement(ui.Button, {
|
|
7589
|
+
variant: "secondary",
|
|
7590
|
+
onClick: function onClick() {
|
|
7591
|
+
hideDialog();
|
|
7592
|
+
},
|
|
7593
|
+
tabIndex: 0
|
|
7594
|
+
}, button.cancel), /*#__PURE__*/React__default['default'].createElement(ui.Button, {
|
|
7595
|
+
onClick: function onClick() {
|
|
7596
|
+
if (radioValue === "number") {
|
|
7597
|
+
var targetColWidth = numberValue;
|
|
7598
|
+
setContext(function (draftCtx) {
|
|
7599
|
+
if (___default['default'].isUndefined(targetColWidth) || targetColWidth === null || targetColWidth <= 0 || targetColWidth > 2038) {
|
|
7600
|
+
showAlert("The column width must be between 0 ~ 2038", "ok");
|
|
7601
|
+
draftCtx.contextMenu = {};
|
|
7602
|
+
return;
|
|
7603
|
+
}
|
|
7604
|
+
var numColWidth = targetColWidth;
|
|
7605
|
+
var colWidthList = {};
|
|
7606
|
+
___default['default'].forEach(draftCtx.luckysheet_select_save, function (section) {
|
|
7607
|
+
for (var colNum = section.column[0]; colNum <= section.column[1]; colNum += 1) {
|
|
7608
|
+
getMaxCellWidth(colNum);
|
|
7609
|
+
colWidthList[colNum] = numColWidth;
|
|
7610
|
+
}
|
|
7611
|
+
});
|
|
7612
|
+
fortuneCore.api.setColumnWidth(draftCtx, colWidthList, {}, true);
|
|
7613
|
+
draftCtx.contextMenu = {};
|
|
7614
|
+
});
|
|
7615
|
+
} else {
|
|
7616
|
+
var _targetColWidth = numberValue;
|
|
7617
|
+
setContext(function (draftCtx) {
|
|
7618
|
+
if (___default['default'].isUndefined(_targetColWidth) || _targetColWidth === null || _targetColWidth <= 0 || _targetColWidth > 2038) {
|
|
7619
|
+
showAlert("The column width must be between 0 ~ 2038", "ok");
|
|
7620
|
+
draftCtx.contextMenu = {};
|
|
7621
|
+
return;
|
|
7622
|
+
}
|
|
7623
|
+
var colWidthList = {};
|
|
7624
|
+
___default['default'].forEach(draftCtx.luckysheet_select_save, function (section) {
|
|
7625
|
+
for (var colNum = section.column[0]; colNum <= section.column[1]; colNum += 1) {
|
|
7626
|
+
colWidthList[colNum] = getMaxCellWidth(colNum);
|
|
7627
|
+
}
|
|
7628
|
+
});
|
|
7629
|
+
fortuneCore.api.setColumnWidth(draftCtx, colWidthList, {}, true);
|
|
7630
|
+
draftCtx.contextMenu = {};
|
|
7631
|
+
});
|
|
7632
|
+
}
|
|
7633
|
+
hideDialog();
|
|
7634
|
+
},
|
|
7635
|
+
tabIndex: 0
|
|
7636
|
+
}, "Ok")));
|
|
7637
|
+
};
|
|
7638
|
+
|
|
7500
7639
|
var Divider$1 = function Divider() {
|
|
7501
7640
|
return /*#__PURE__*/React__default['default'].createElement("div", {
|
|
7502
7641
|
className: "fortune-context-menu-divider"
|
|
@@ -8216,24 +8355,11 @@ var ContextMenu = function ContextMenu() {
|
|
|
8216
8355
|
})) ? (/*#__PURE__*/React__default['default'].createElement(Menu, {
|
|
8217
8356
|
key: "set-column-width",
|
|
8218
8357
|
onClick: function onClick(e, container) {
|
|
8219
|
-
|
|
8220
|
-
var targetColWidth = (_container$querySelec2 = container.querySelector("input")) === null || _container$querySelec2 === void 0 ? void 0 : _container$querySelec2.value;
|
|
8358
|
+
showDialog(/*#__PURE__*/React__default['default'].createElement(ResetColumnWidth, null), undefined, "Resize column");
|
|
8221
8359
|
setContext(function (draftCtx) {
|
|
8222
|
-
if (___default['default'].isUndefined(targetColWidth) || targetColWidth === "" || parseInt(targetColWidth, 10) <= 0 || parseInt(targetColWidth, 10) > 2038) {
|
|
8223
|
-
showAlert(info.tipColumnWidthLimit, "ok");
|
|
8224
|
-
draftCtx.contextMenu = {};
|
|
8225
|
-
return;
|
|
8226
|
-
}
|
|
8227
|
-
var numColWidth = parseInt(targetColWidth, 10);
|
|
8228
|
-
var colWidthList = {};
|
|
8229
|
-
___default['default'].forEach(draftCtx.luckysheet_select_save, function (section) {
|
|
8230
|
-
for (var colNum = section.column[0]; colNum <= section.column[1]; colNum += 1) {
|
|
8231
|
-
colWidthList[colNum] = numColWidth;
|
|
8232
|
-
}
|
|
8233
|
-
});
|
|
8234
|
-
fortuneCore.api.setColumnWidth(draftCtx, colWidthList, {}, true);
|
|
8235
8360
|
draftCtx.contextMenu = {};
|
|
8236
8361
|
});
|
|
8362
|
+
return;
|
|
8237
8363
|
}
|
|
8238
8364
|
}, /*#__PURE__*/React__default['default'].createElement("div", {
|
|
8239
8365
|
className: "context-item"
|
|
@@ -8244,24 +8370,7 @@ var ContextMenu = function ContextMenu() {
|
|
|
8244
8370
|
style: {
|
|
8245
8371
|
marginRight: "8px"
|
|
8246
8372
|
}
|
|
8247
|
-
}), /*#__PURE__*/React__default['default'].createElement("div", null, "Resize column
|
|
8248
|
-
onClick: function onClick(e) {
|
|
8249
|
-
return e.stopPropagation();
|
|
8250
|
-
},
|
|
8251
|
-
onKeyDown: function onKeyDown(e) {
|
|
8252
|
-
return e.stopPropagation();
|
|
8253
|
-
},
|
|
8254
|
-
tabIndex: 0,
|
|
8255
|
-
type: "number",
|
|
8256
|
-
min: 1,
|
|
8257
|
-
max: 545,
|
|
8258
|
-
className: "luckysheet-mousedown-cancel",
|
|
8259
|
-
placeholder: rightclick.number,
|
|
8260
|
-
defaultValue: shownColWidth,
|
|
8261
|
-
style: {
|
|
8262
|
-
width: "40px"
|
|
8263
|
-
}
|
|
8264
|
-
}), "px")))) : null;
|
|
8373
|
+
}), /*#__PURE__*/React__default['default'].createElement("div", null, "Resize column width")))) : null;
|
|
8265
8374
|
}
|
|
8266
8375
|
if (name === "clear") {
|
|
8267
8376
|
return /*#__PURE__*/React__default['default'].createElement(Menu, {
|