@fileverse-dev/fortune-core 1.0.5 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{dist/packages/core/src → es}/api/cell.d.ts +10 -10
- package/es/api/cell.js +204 -0
- package/{dist/packages/core/src → es}/api/common.d.ts +66 -66
- package/es/api/common.js +79 -0
- package/{dist/packages/core/src → es}/api/errors.d.ts +2 -2
- package/es/api/errors.js +2 -0
- package/{dist/packages/core/src → es}/api/index.d.ts +9 -9
- package/es/api/index.js +8 -0
- package/{dist/packages/core/src → es}/api/merge.d.ts +5 -5
- package/es/api/merge.js +15 -0
- package/{dist/packages/core/src → es}/api/range.d.ts +22 -22
- package/es/api/range.js +123 -0
- package/{dist/packages/core/src → es}/api/rowcol.d.ts +14 -14
- package/es/api/rowcol.js +207 -0
- package/{dist/packages/core/src → es}/api/sheet.d.ts +10 -10
- package/es/api/sheet.js +128 -0
- package/{dist/packages/core/src → es}/api/workbook.d.ts +15 -15
- package/es/api/workbook.js +85 -0
- package/{dist/packages/core/src → es}/canvas.d.ts +46 -46
- package/es/canvas.js +1350 -0
- package/{dist/packages/core/src → es}/context.d.ts +197 -197
- package/es/context.js +380 -0
- package/{dist/packages/core/src → es}/events/copy.d.ts +2 -2
- package/es/events/copy.js +78 -0
- package/{dist/packages/core/src → es}/events/index.d.ts +4 -4
- package/es/events/index.js +4 -0
- package/{dist/packages/core/src → es}/events/keyboard.d.ts +6 -6
- package/es/events/keyboard.js +332 -0
- package/{dist/packages/core/src → es}/events/mouse.d.ts +22 -22
- package/es/events/mouse.js +1725 -0
- package/{dist/packages/core/src → es}/events/paste.d.ts +3 -3
- package/es/events/paste.js +1358 -0
- package/{dist/packages/core/src → es}/index.d.ts +10 -10
- package/es/index.js +10 -0
- package/{dist/packages/core/src → es}/locale/en.d.ts +992 -992
- package/es/locale/en.js +10564 -0
- package/{dist/packages/core/src → es}/locale/es.d.ts +1134 -1134
- package/es/locale/es.js +10010 -0
- package/{dist/packages/core/src → es}/locale/hi.d.ts +1030 -1030
- package/es/locale/hi.js +10550 -0
- package/{dist/packages/core/src → es}/locale/index.d.ts +1049 -1049
- package/es/locale/index.js +23 -0
- package/{dist/packages/core/src → es}/locale/zh.d.ts +1048 -1048
- package/es/locale/zh.js +10568 -0
- package/{dist/packages/core/src → es}/locale/zh_tw.d.ts +1187 -1187
- package/es/locale/zh_tw.js +10072 -0
- package/{dist/packages/core/src → es}/modules/ConditionFormat.d.ts +17 -17
- package/es/modules/ConditionFormat.js +1258 -0
- package/{dist/packages/core/src → es}/modules/border.d.ts +3 -3
- package/es/modules/border.js +1240 -0
- package/{dist/packages/core/src → es}/modules/cell.d.ts +32 -32
- package/es/modules/cell.js +1055 -0
- package/{dist/packages/core/src → es}/modules/clipboard.d.ts +3 -3
- package/es/modules/clipboard.js +36 -0
- package/{dist/packages/core/src → es}/modules/color.d.ts +1 -1
- package/es/modules/color.js +1 -0
- package/{dist/packages/core/src → es}/modules/comment.d.ts +97 -97
- package/es/modules/comment.js +597 -0
- package/{dist/packages/core/src → es}/modules/conditionalFormat.d.ts +2 -2
- package/es/modules/conditionalFormat.js +441 -0
- package/{dist/packages/core/src → es}/modules/cursor.d.ts +3 -3
- package/es/modules/cursor.js +62 -0
- package/{dist/packages/core/src → es}/modules/dataVerification.d.ts +11 -11
- package/es/modules/dataVerification.js +700 -0
- package/{dist/packages/core/src → es}/modules/dropCell.d.ts +10 -10
- package/es/modules/dropCell.js +2266 -0
- package/{dist/packages/core/src → es}/modules/filter.d.ts +45 -45
- package/es/modules/filter.js +434 -0
- package/{dist/packages/core/src → es}/modules/format.d.ts +6 -6
- package/es/modules/format.js +323 -0
- package/{dist/packages/core/src → es}/modules/formula.d.ts +54 -54
- package/es/modules/formula.js +2301 -0
- package/{dist/packages/core/src → es}/modules/freeze.d.ts +5 -5
- package/es/modules/freeze.js +148 -0
- package/{dist/packages/core/src → es}/modules/hyperlink.d.ts +21 -21
- package/es/modules/hyperlink.js +216 -0
- package/{dist/packages/core/src → es}/modules/iframe.d.ts +12 -12
- package/es/modules/iframe.js +220 -0
- package/{dist/packages/core/src → es}/modules/image.d.ts +31 -31
- package/es/modules/image.js +253 -0
- package/{dist/packages/core/src → es}/modules/index.d.ts +36 -36
- package/es/modules/index.js +36 -0
- package/{dist/packages/core/src → es}/modules/inline-string.d.ts +36 -36
- package/es/modules/inline-string.js +437 -0
- package/{dist/packages/core/src → es}/modules/location.d.ts +6 -6
- package/es/modules/location.js +46 -0
- package/{dist/packages/core/src → es}/modules/locationCondition.d.ts +21 -21
- package/es/modules/locationCondition.js +218 -0
- package/{dist/packages/core/src → es}/modules/merge.d.ts +3 -3
- package/es/modules/merge.js +216 -0
- package/{dist/packages/core/src → es}/modules/mobile.d.ts +5 -5
- package/es/modules/mobile.js +33 -0
- package/{dist/packages/core/src → es}/modules/moveCells.d.ts +5 -5
- package/es/modules/moveCells.js +348 -0
- package/{dist/packages/core/src → es}/modules/protection.d.ts +5 -5
- package/es/modules/protection.js +96 -0
- package/{dist/packages/core/src → es}/modules/refresh.d.ts +3 -3
- package/es/modules/refresh.js +34 -0
- package/{dist/packages/core/src → es}/modules/rowcol.d.ts +19 -19
- package/es/modules/rowcol.js +1922 -0
- package/{dist/packages/core/src → es}/modules/screenshot.d.ts +2 -2
- package/es/modules/screenshot.js +90 -0
- package/{dist/packages/core/src → es}/modules/searchReplace.d.ts +36 -36
- package/es/modules/searchReplace.js +388 -0
- package/{dist/packages/core/src → es}/modules/selection.d.ts +46 -46
- package/es/modules/selection.js +1674 -0
- package/{dist/packages/core/src → es}/modules/sheet.d.ts +10 -10
- package/es/modules/sheet.js +237 -0
- package/{dist/packages/core/src → es}/modules/sort.d.ts +7 -7
- package/es/modules/sort.js +150 -0
- package/{dist/packages/core/src → es}/modules/splitColumn.d.ts +5 -5
- package/es/modules/splitColumn.js +126 -0
- package/es/modules/ssf.js +1533 -0
- package/{dist/packages/core/src → es}/modules/text.d.ts +10 -10
- package/es/modules/text.js +1207 -0
- package/{dist/packages/core/src → es}/modules/toolbar.d.ts +32 -32
- package/es/modules/toolbar.js +970 -0
- package/{dist/packages/core/src → es}/modules/validation.d.ts +19 -19
- package/es/modules/validation.js +190 -0
- package/{dist/packages/core/src → es}/modules/zoom.d.ts +3 -3
- package/es/modules/zoom.js +29 -0
- package/{dist/packages/core/src → es}/settings.d.ts +100 -100
- package/es/settings.js +36 -0
- package/{dist/packages/core/src → es}/types.d.ts +371 -371
- package/es/types.js +1 -0
- package/{dist/packages/core/src → es}/utils/freeze.d.ts +7 -7
- package/es/utils/freeze.js +86 -0
- package/{dist/packages/core/src → es}/utils/index.d.ts +18 -18
- package/es/utils/index.js +173 -0
- package/{dist/packages/core/src → es}/utils/patch.d.ts +37 -37
- package/es/utils/patch.js +381 -0
- package/lib/api/cell.d.ts +10 -0
- package/lib/api/cell.js +215 -0
- package/lib/api/common.d.ts +66 -0
- package/lib/api/common.js +88 -0
- package/lib/api/errors.d.ts +2 -0
- package/lib/api/errors.js +8 -0
- package/lib/api/index.d.ts +9 -0
- package/lib/api/index.js +101 -0
- package/lib/api/merge.d.ts +5 -0
- package/lib/api/merge.js +22 -0
- package/lib/api/range.d.ts +22 -0
- package/lib/api/range.js +138 -0
- package/lib/api/rowcol.d.ts +14 -0
- package/lib/api/rowcol.js +222 -0
- package/lib/api/sheet.d.ts +10 -0
- package/lib/api/sheet.js +145 -0
- package/lib/api/workbook.d.ts +15 -0
- package/lib/api/workbook.js +98 -0
- package/lib/canvas.d.ts +46 -0
- package/lib/canvas.js +1356 -0
- package/lib/context.d.ts +197 -0
- package/lib/context.js +392 -0
- package/lib/events/copy.d.ts +2 -0
- package/lib/events/copy.js +85 -0
- package/lib/events/index.d.ts +4 -0
- package/lib/events/index.js +49 -0
- package/lib/events/keyboard.d.ts +6 -0
- package/lib/events/keyboard.js +342 -0
- package/lib/events/mouse.d.ts +22 -0
- package/lib/events/mouse.js +1744 -0
- package/lib/events/paste.d.ts +3 -0
- package/lib/events/paste.js +1366 -0
- package/lib/index.d.ts +10 -0
- package/lib/index.js +109 -0
- package/lib/locale/en.d.ts +992 -0
- package/lib/locale/en.js +10570 -0
- package/lib/locale/es.d.ts +1134 -0
- package/lib/locale/es.js +10016 -0
- package/lib/locale/hi.d.ts +1030 -0
- package/lib/locale/hi.js +10556 -0
- package/lib/locale/index.d.ts +1049 -0
- package/lib/locale/index.js +29 -0
- package/lib/locale/zh.d.ts +1048 -0
- package/lib/locale/zh.js +10574 -0
- package/lib/locale/zh_tw.d.ts +1187 -0
- package/lib/locale/zh_tw.js +10078 -0
- package/lib/modules/ConditionFormat.d.ts +17 -0
- package/lib/modules/ConditionFormat.js +1273 -0
- package/lib/modules/border.d.ts +3 -0
- package/lib/modules/border.js +1248 -0
- package/lib/modules/cell.d.ts +32 -0
- package/lib/modules/cell.js +1085 -0
- package/lib/modules/clipboard.d.ts +3 -0
- package/lib/modules/clipboard.js +42 -0
- package/lib/modules/color.d.ts +1 -0
- package/lib/modules/color.js +7 -0
- package/lib/modules/comment.d.ts +97 -0
- package/lib/modules/comment.js +625 -0
- package/lib/modules/conditionalFormat.d.ts +2 -0
- package/lib/modules/conditionalFormat.js +447 -0
- package/lib/modules/cursor.d.ts +3 -0
- package/lib/modules/cursor.js +70 -0
- package/lib/modules/dataVerification.d.ts +11 -0
- package/lib/modules/dataVerification.js +715 -0
- package/lib/modules/dropCell.d.ts +10 -0
- package/lib/modules/dropCell.js +2282 -0
- package/lib/modules/filter.d.ts +45 -0
- package/lib/modules/filter.js +448 -0
- package/lib/modules/format.d.ts +6 -0
- package/lib/modules/format.js +334 -0
- package/lib/modules/formula.d.ts +54 -0
- package/lib/modules/formula.js +2330 -0
- package/lib/modules/freeze.d.ts +5 -0
- package/lib/modules/freeze.js +158 -0
- package/lib/modules/hyperlink.d.ts +21 -0
- package/lib/modules/hyperlink.js +232 -0
- package/lib/modules/iframe.d.ts +12 -0
- package/lib/modules/iframe.js +236 -0
- package/lib/modules/image.d.ts +31 -0
- package/lib/modules/image.js +272 -0
- package/lib/modules/index.d.ts +36 -0
- package/lib/modules/index.js +401 -0
- package/lib/modules/inline-string.d.ts +36 -0
- package/lib/modules/inline-string.js +452 -0
- package/lib/modules/location.d.ts +6 -0
- package/lib/modules/location.js +57 -0
- package/lib/modules/locationCondition.d.ts +21 -0
- package/lib/modules/locationCondition.js +229 -0
- package/lib/modules/merge.d.ts +3 -0
- package/lib/modules/merge.js +223 -0
- package/lib/modules/mobile.d.ts +5 -0
- package/lib/modules/mobile.js +41 -0
- package/lib/modules/moveCells.d.ts +5 -0
- package/lib/modules/moveCells.js +357 -0
- package/lib/modules/protection.d.ts +5 -0
- package/lib/modules/protection.js +106 -0
- package/lib/modules/refresh.d.ts +3 -0
- package/lib/modules/refresh.js +40 -0
- package/lib/modules/rowcol.d.ts +19 -0
- package/lib/modules/rowcol.js +1935 -0
- package/lib/modules/screenshot.d.ts +2 -0
- package/lib/modules/screenshot.js +96 -0
- package/lib/modules/searchReplace.d.ts +36 -0
- package/lib/modules/searchReplace.js +402 -0
- package/lib/modules/selection.d.ts +46 -0
- package/lib/modules/selection.js +1703 -0
- package/lib/modules/sheet.d.ts +10 -0
- package/lib/modules/sheet.js +250 -0
- package/lib/modules/sort.d.ts +7 -0
- package/lib/modules/sort.js +159 -0
- package/lib/modules/splitColumn.d.ts +5 -0
- package/lib/modules/splitColumn.js +136 -0
- package/lib/modules/ssf.js +1539 -0
- package/lib/modules/text.d.ts +10 -0
- package/lib/modules/text.js +1221 -0
- package/lib/modules/toolbar.d.ts +32 -0
- package/lib/modules/toolbar.js +1003 -0
- package/lib/modules/validation.d.ts +19 -0
- package/lib/modules/validation.js +205 -0
- package/lib/modules/zoom.d.ts +3 -0
- package/lib/modules/zoom.js +36 -0
- package/lib/settings.d.ts +100 -0
- package/lib/settings.js +42 -0
- package/lib/types.d.ts +371 -0
- package/lib/types.js +5 -0
- package/lib/utils/freeze.d.ts +7 -0
- package/lib/utils/freeze.js +92 -0
- package/lib/utils/index.d.ts +18 -0
- package/lib/utils/index.js +231 -0
- package/lib/utils/patch.d.ts +37 -0
- package/lib/utils/patch.js +392 -0
- package/package.json +6 -5
- package/dist/index.esm.js +0 -80253
- package/dist/index.js +0 -80599
- package/dist/packages/react/src/components/ChangeColor/index.d.ts +0 -7
- package/dist/packages/react/src/components/ConditionFormat/ConditionRules.d.ts +0 -6
- package/dist/packages/react/src/components/ConditionFormat/index.d.ts +0 -7
- package/dist/packages/react/src/components/ContextMenu/Divider.d.ts +0 -3
- package/dist/packages/react/src/components/ContextMenu/FilterMenu.d.ts +0 -3
- package/dist/packages/react/src/components/ContextMenu/Menu.d.ts +0 -8
- package/dist/packages/react/src/components/ContextMenu/SheetTab.d.ts +0 -4
- package/dist/packages/react/src/components/ContextMenu/index.d.ts +0 -5
- package/dist/packages/react/src/components/CustomSort/index.d.ts +0 -4
- package/dist/packages/react/src/components/DataVerification/DropdownList.d.ts +0 -4
- package/dist/packages/react/src/components/DataVerification/RangeDialog.d.ts +0 -4
- package/dist/packages/react/src/components/DataVerification/getDisplayedRangeTxt.d.ts +0 -2
- package/dist/packages/react/src/components/DataVerification/index.d.ts +0 -4
- package/dist/packages/react/src/components/Dialog/index.d.ts +0 -15
- package/dist/packages/react/src/components/DuneChartsInputModal/DuneChartsInputModal.d.ts +0 -11
- package/dist/packages/react/src/components/DunePreview/DunePreview.d.ts +0 -13
- package/dist/packages/react/src/components/FilterOption/index.d.ts +0 -5
- package/dist/packages/react/src/components/FormatSearch/index.d.ts +0 -6
- package/dist/packages/react/src/components/FormulaSearch/index.d.ts +0 -5
- package/dist/packages/react/src/components/FxEditor/NameBox.d.ts +0 -3
- package/dist/packages/react/src/components/FxEditor/index.d.ts +0 -4
- package/dist/packages/react/src/components/IFrameBoxs/iFrameBoxs.d.ts +0 -4
- package/dist/packages/react/src/components/ImgBoxs/index.d.ts +0 -3
- package/dist/packages/react/src/components/LinkEidtCard/index.d.ts +0 -5
- package/dist/packages/react/src/components/LocationCondition/index.d.ts +0 -3
- package/dist/packages/react/src/components/MessageBox/index.d.ts +0 -9
- package/dist/packages/react/src/components/NotationBoxes/index.d.ts +0 -3
- package/dist/packages/react/src/components/ResetColumnWidth/index.d.ts +0 -2
- package/dist/packages/react/src/components/SVGDefines.d.ts +0 -5
- package/dist/packages/react/src/components/SVGIcon.d.ts +0 -9
- package/dist/packages/react/src/components/SearchReplace/index.d.ts +0 -6
- package/dist/packages/react/src/components/Sheet/index.d.ts +0 -8
- package/dist/packages/react/src/components/SheetList/SheetHiddenButton.d.ts +0 -8
- package/dist/packages/react/src/components/SheetList/SheetListItem.d.ts +0 -9
- package/dist/packages/react/src/components/SheetList/index.d.ts +0 -4
- package/dist/packages/react/src/components/SheetOverlay/ColumnHeader.d.ts +0 -3
- package/dist/packages/react/src/components/SheetOverlay/ContentEditable.d.ts +0 -11
- package/dist/packages/react/src/components/SheetOverlay/FormulaHint/index.d.ts +0 -4
- package/dist/packages/react/src/components/SheetOverlay/FormulaSearch/constant.d.ts +0 -63
- package/dist/packages/react/src/components/SheetOverlay/FormulaSearch/index.d.ts +0 -4
- package/dist/packages/react/src/components/SheetOverlay/InputBox.d.ts +0 -3
- package/dist/packages/react/src/components/SheetOverlay/RowHeader.d.ts +0 -3
- package/dist/packages/react/src/components/SheetOverlay/ScrollBar/index.d.ts +0 -7
- package/dist/packages/react/src/components/SheetOverlay/index.d.ts +0 -4
- package/dist/packages/react/src/components/SheetTab/SheetItem.d.ts +0 -8
- package/dist/packages/react/src/components/SheetTab/index.d.ts +0 -4
- package/dist/packages/react/src/components/SplitColumn/index.d.ts +0 -3
- package/dist/packages/react/src/components/Toolbar/Button.d.ts +0 -12
- package/dist/packages/react/src/components/Toolbar/ColorPicker.d.ts +0 -6
- package/dist/packages/react/src/components/Toolbar/Combo.d.ts +0 -12
- package/dist/packages/react/src/components/Toolbar/CustomBorder.d.ts +0 -7
- package/dist/packages/react/src/components/Toolbar/CustomButton.d.ts +0 -11
- package/dist/packages/react/src/components/Toolbar/CustomColor.d.ts +0 -8
- package/dist/packages/react/src/components/Toolbar/CustomIcon.d.ts +0 -9
- package/dist/packages/react/src/components/Toolbar/Divider.d.ts +0 -4
- package/dist/packages/react/src/components/Toolbar/MoreItemsContainer.d.ts +0 -6
- package/dist/packages/react/src/components/Toolbar/Select.d.ts +0 -14
- package/dist/packages/react/src/components/Toolbar/index.d.ts +0 -10
- package/dist/packages/react/src/components/Workbook/api.d.ts +0 -1177
- package/dist/packages/react/src/components/Workbook/index.d.ts +0 -1185
- package/dist/packages/react/src/components/ZoomControl/index.d.ts +0 -4
- package/dist/packages/react/src/components/index.d.ts +0 -4
- package/dist/packages/react/src/constants.d.ts +0 -1
- package/dist/packages/react/src/context/index.d.ts +0 -25
- package/dist/packages/react/src/context/modal.d.ts +0 -10
- package/dist/packages/react/src/hooks/useAlert.d.ts +0 -4
- package/dist/packages/react/src/hooks/useDialog.d.ts +0 -5
- package/dist/packages/react/src/hooks/useOutsideClick.d.ts +0 -2
- package/dist/packages/react/src/hooks/usePrevious.d.ts +0 -2
- package/dist/packages/react/src/index.d.ts +0 -1
- package/dist/packages/react/src/utils/datepickerStyles.d.ts +0 -2
- package/dist/stories/API.stories.d.ts +0 -1210
- package/dist/stories/Collabration.stories.d.ts +0 -2359
- package/dist/stories/Features.stories.d.ts +0 -9430
- package/dist/stories/data/cell.d.ts +0 -983
- package/dist/stories/data/dataVerification.d.ts +0 -131
- package/dist/stories/data/empty.d.ts +0 -10
- package/dist/stories/data/formula.d.ts +0 -362
- package/dist/stories/data/freeze.d.ts +0 -34
- package/dist/stories/data/protected.d.ts +0 -40
- package/dist/stories/utils.d.ts +0 -1
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.dataToCelldata = exports.celldataToData = void 0;
|
|
7
|
+
exports.getSheet = getSheet;
|
|
8
|
+
exports.getSheetWithLatestCelldata = getSheetWithLatestCelldata;
|
|
9
|
+
var _lodash = _interopRequireDefault(require("lodash"));
|
|
10
|
+
var _utils = require("../utils");
|
|
11
|
+
var _errors = require("./errors");
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
+
var __assign = void 0 && (void 0).__assign || function () {
|
|
14
|
+
__assign = Object.assign || function (t) {
|
|
15
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
16
|
+
s = arguments[i];
|
|
17
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
18
|
+
}
|
|
19
|
+
return t;
|
|
20
|
+
};
|
|
21
|
+
return __assign.apply(this, arguments);
|
|
22
|
+
};
|
|
23
|
+
var dataToCelldata = exports.dataToCelldata = function dataToCelldata(data) {
|
|
24
|
+
var celldata = [];
|
|
25
|
+
if (data == null) {
|
|
26
|
+
return celldata;
|
|
27
|
+
}
|
|
28
|
+
for (var r = 0; r < data.length; r += 1) {
|
|
29
|
+
for (var c = 0; c < data[r].length; c += 1) {
|
|
30
|
+
var v = data[r][c];
|
|
31
|
+
if (v != null) {
|
|
32
|
+
celldata.push({
|
|
33
|
+
r: r,
|
|
34
|
+
c: c,
|
|
35
|
+
v: v
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return celldata;
|
|
41
|
+
};
|
|
42
|
+
var celldataToData = exports.celldataToData = function celldataToData(celldata, rowCount, colCount) {
|
|
43
|
+
var _a, _b;
|
|
44
|
+
var lastRow = _lodash.default.maxBy(celldata, "r");
|
|
45
|
+
var lastCol = _lodash.default.maxBy(celldata, "c");
|
|
46
|
+
var lastRowNum = ((_a = lastRow === null || lastRow === void 0 ? void 0 : lastRow.r) !== null && _a !== void 0 ? _a : 0) + 1;
|
|
47
|
+
var lastColNum = ((_b = lastCol === null || lastCol === void 0 ? void 0 : lastCol.c) !== null && _b !== void 0 ? _b : 0) + 1;
|
|
48
|
+
if (rowCount != null && colCount != null && rowCount > 0 && colCount > 0) {
|
|
49
|
+
lastRowNum = Math.max(lastRowNum, rowCount);
|
|
50
|
+
lastColNum = Math.max(lastColNum, colCount);
|
|
51
|
+
}
|
|
52
|
+
if (lastRowNum && lastColNum) {
|
|
53
|
+
var expandedData_1 = _lodash.default.times(lastRowNum, function () {
|
|
54
|
+
return _lodash.default.times(lastColNum, function () {
|
|
55
|
+
return null;
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
celldata === null || celldata === void 0 ? void 0 : celldata.forEach(function (d) {
|
|
59
|
+
expandedData_1[d.r][d.c] = d.v;
|
|
60
|
+
});
|
|
61
|
+
return expandedData_1;
|
|
62
|
+
}
|
|
63
|
+
return null;
|
|
64
|
+
};
|
|
65
|
+
function getSheet(ctx, options) {
|
|
66
|
+
if (options === void 0) {
|
|
67
|
+
options = {};
|
|
68
|
+
}
|
|
69
|
+
var _a = options.index,
|
|
70
|
+
index = _a === void 0 ? (0, _utils.getSheetIndex)(ctx, options.id || ctx.currentSheetId) : _a;
|
|
71
|
+
if (index == null) {
|
|
72
|
+
throw _errors.SHEET_NOT_FOUND;
|
|
73
|
+
}
|
|
74
|
+
var sheet = ctx.luckysheetfile[index];
|
|
75
|
+
if (sheet == null) {
|
|
76
|
+
throw _errors.SHEET_NOT_FOUND;
|
|
77
|
+
}
|
|
78
|
+
return sheet;
|
|
79
|
+
}
|
|
80
|
+
function getSheetWithLatestCelldata(ctx, options) {
|
|
81
|
+
if (options === void 0) {
|
|
82
|
+
options = {};
|
|
83
|
+
}
|
|
84
|
+
var sheet = getSheet(ctx, options);
|
|
85
|
+
return __assign(__assign({}, sheet), {
|
|
86
|
+
celldata: dataToCelldata(sheet.data)
|
|
87
|
+
});
|
|
88
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.SHEET_NOT_FOUND = exports.INVALID_PARAMS = void 0;
|
|
7
|
+
var INVALID_PARAMS = exports.INVALID_PARAMS = new Error("invalid params");
|
|
8
|
+
var SHEET_NOT_FOUND = exports.SHEET_NOT_FOUND = new Error("sheet not found");
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { getSheetWithLatestCelldata, CommonOptions, dataToCelldata, celldataToData } from "./common";
|
|
2
|
+
export type { CommonOptions };
|
|
3
|
+
export { getSheetWithLatestCelldata, dataToCelldata, celldataToData };
|
|
4
|
+
export * from "./cell";
|
|
5
|
+
export * from "./rowcol";
|
|
6
|
+
export * from "./range";
|
|
7
|
+
export * from "./merge";
|
|
8
|
+
export * from "./sheet";
|
|
9
|
+
export * from "./workbook";
|
package/lib/api/index.js
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
getSheetWithLatestCelldata: true,
|
|
8
|
+
dataToCelldata: true,
|
|
9
|
+
celldataToData: true
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "celldataToData", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function get() {
|
|
14
|
+
return _common.celldataToData;
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "dataToCelldata", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function get() {
|
|
20
|
+
return _common.dataToCelldata;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports, "getSheetWithLatestCelldata", {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
get: function get() {
|
|
26
|
+
return _common.getSheetWithLatestCelldata;
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
var _common = require("./common");
|
|
30
|
+
var _cell = require("./cell");
|
|
31
|
+
Object.keys(_cell).forEach(function (key) {
|
|
32
|
+
if (key === "default" || key === "__esModule") return;
|
|
33
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
34
|
+
if (key in exports && exports[key] === _cell[key]) return;
|
|
35
|
+
Object.defineProperty(exports, key, {
|
|
36
|
+
enumerable: true,
|
|
37
|
+
get: function get() {
|
|
38
|
+
return _cell[key];
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
var _rowcol = require("./rowcol");
|
|
43
|
+
Object.keys(_rowcol).forEach(function (key) {
|
|
44
|
+
if (key === "default" || key === "__esModule") return;
|
|
45
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
46
|
+
if (key in exports && exports[key] === _rowcol[key]) return;
|
|
47
|
+
Object.defineProperty(exports, key, {
|
|
48
|
+
enumerable: true,
|
|
49
|
+
get: function get() {
|
|
50
|
+
return _rowcol[key];
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
var _range = require("./range");
|
|
55
|
+
Object.keys(_range).forEach(function (key) {
|
|
56
|
+
if (key === "default" || key === "__esModule") return;
|
|
57
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
58
|
+
if (key in exports && exports[key] === _range[key]) return;
|
|
59
|
+
Object.defineProperty(exports, key, {
|
|
60
|
+
enumerable: true,
|
|
61
|
+
get: function get() {
|
|
62
|
+
return _range[key];
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
var _merge = require("./merge");
|
|
67
|
+
Object.keys(_merge).forEach(function (key) {
|
|
68
|
+
if (key === "default" || key === "__esModule") return;
|
|
69
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
70
|
+
if (key in exports && exports[key] === _merge[key]) return;
|
|
71
|
+
Object.defineProperty(exports, key, {
|
|
72
|
+
enumerable: true,
|
|
73
|
+
get: function get() {
|
|
74
|
+
return _merge[key];
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
var _sheet = require("./sheet");
|
|
79
|
+
Object.keys(_sheet).forEach(function (key) {
|
|
80
|
+
if (key === "default" || key === "__esModule") return;
|
|
81
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
82
|
+
if (key in exports && exports[key] === _sheet[key]) return;
|
|
83
|
+
Object.defineProperty(exports, key, {
|
|
84
|
+
enumerable: true,
|
|
85
|
+
get: function get() {
|
|
86
|
+
return _sheet[key];
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
var _workbook = require("./workbook");
|
|
91
|
+
Object.keys(_workbook).forEach(function (key) {
|
|
92
|
+
if (key === "default" || key === "__esModule") return;
|
|
93
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
94
|
+
if (key in exports && exports[key] === _workbook[key]) return;
|
|
95
|
+
Object.defineProperty(exports, key, {
|
|
96
|
+
enumerable: true,
|
|
97
|
+
get: function get() {
|
|
98
|
+
return _workbook[key];
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Context } from "..";
|
|
2
|
+
import { Range } from "../types";
|
|
3
|
+
import { CommonOptions } from "./common";
|
|
4
|
+
export declare function mergeCells(ctx: Context, ranges: Range, type: string, options?: CommonOptions): void;
|
|
5
|
+
export declare function cancelMerge(ctx: Context, ranges: Range, options?: CommonOptions): void;
|
package/lib/api/merge.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.cancelMerge = cancelMerge;
|
|
7
|
+
exports.mergeCells = mergeCells;
|
|
8
|
+
var _common = require("./common");
|
|
9
|
+
var _modules = require("../modules");
|
|
10
|
+
function mergeCells(ctx, ranges, type, options) {
|
|
11
|
+
if (options === void 0) {
|
|
12
|
+
options = {};
|
|
13
|
+
}
|
|
14
|
+
var sheet = (0, _common.getSheet)(ctx, options);
|
|
15
|
+
(0, _modules.mergeCells)(ctx, sheet.id, ranges, type);
|
|
16
|
+
}
|
|
17
|
+
function cancelMerge(ctx, ranges, options) {
|
|
18
|
+
if (options === void 0) {
|
|
19
|
+
options = {};
|
|
20
|
+
}
|
|
21
|
+
mergeCells(ctx, ranges, "merge-cancel", options);
|
|
22
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Selection } from "..";
|
|
2
|
+
import { Context } from "../context";
|
|
3
|
+
import { Cell, Range, SingleRange } from "../types";
|
|
4
|
+
import { CommonOptions } from "./common";
|
|
5
|
+
export declare function getSelection(ctx: Context): {
|
|
6
|
+
row: number[];
|
|
7
|
+
column: number[];
|
|
8
|
+
}[] | undefined;
|
|
9
|
+
export declare function getFlattenRange(ctx: Context, range?: Range): {
|
|
10
|
+
r: number;
|
|
11
|
+
c: number;
|
|
12
|
+
}[];
|
|
13
|
+
export declare function getCellsByFlattenRange(ctx: Context, range?: {
|
|
14
|
+
r: number;
|
|
15
|
+
c: number;
|
|
16
|
+
}[]): (Cell | null)[];
|
|
17
|
+
export declare function getSelectionCoordinates(ctx: Context): string[];
|
|
18
|
+
export declare function getCellsByRange(ctx: Context, range: Selection, options?: CommonOptions): (Cell | null)[][];
|
|
19
|
+
export declare function getHtmlByRange(ctx: Context, range: Range, options?: CommonOptions): string | null;
|
|
20
|
+
export declare function setSelection(ctx: Context, range: Range, options: CommonOptions): void;
|
|
21
|
+
export declare function setCellValuesByRange(ctx: Context, data: any[][], range: SingleRange, cellInput: HTMLDivElement | null, options?: CommonOptions): void;
|
|
22
|
+
export declare function setCellFormatByRange(ctx: Context, attr: keyof Cell, value: any, range: Range | SingleRange, options?: CommonOptions): void;
|
package/lib/api/range.js
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getCellsByFlattenRange = getCellsByFlattenRange;
|
|
7
|
+
exports.getCellsByRange = getCellsByRange;
|
|
8
|
+
exports.getFlattenRange = getFlattenRange;
|
|
9
|
+
exports.getHtmlByRange = getHtmlByRange;
|
|
10
|
+
exports.getSelection = getSelection;
|
|
11
|
+
exports.getSelectionCoordinates = getSelectionCoordinates;
|
|
12
|
+
exports.setCellFormatByRange = setCellFormatByRange;
|
|
13
|
+
exports.setCellValuesByRange = setCellValuesByRange;
|
|
14
|
+
exports.setSelection = setSelection;
|
|
15
|
+
var _lodash = _interopRequireDefault(require("lodash"));
|
|
16
|
+
var _2 = require("..");
|
|
17
|
+
var _modules = require("../modules");
|
|
18
|
+
var _cell = require("./cell");
|
|
19
|
+
var _common = require("./common");
|
|
20
|
+
var _errors = require("./errors");
|
|
21
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
22
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
23
|
+
function getSelection(ctx) {
|
|
24
|
+
var _a;
|
|
25
|
+
return (_a = ctx.luckysheet_select_save) === null || _a === void 0 ? void 0 : _a.map(function (selection) {
|
|
26
|
+
return {
|
|
27
|
+
row: selection.row,
|
|
28
|
+
column: selection.column
|
|
29
|
+
};
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
function getFlattenRange(ctx, range) {
|
|
33
|
+
range = range || getSelection(ctx);
|
|
34
|
+
var result = [];
|
|
35
|
+
range === null || range === void 0 ? void 0 : range.forEach(function (ele) {
|
|
36
|
+
var rs = ele.row;
|
|
37
|
+
var cs = ele.column;
|
|
38
|
+
for (var r = rs[0]; r <= rs[1]; r += 1) {
|
|
39
|
+
for (var c = cs[0]; c <= cs[1]; c += 1) {
|
|
40
|
+
result.push({
|
|
41
|
+
r: r,
|
|
42
|
+
c: c
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
return result;
|
|
48
|
+
}
|
|
49
|
+
function getCellsByFlattenRange(ctx, range) {
|
|
50
|
+
range = range || getFlattenRange(ctx);
|
|
51
|
+
var flowdata = (0, _2.getFlowdata)(ctx);
|
|
52
|
+
if (!flowdata) return [];
|
|
53
|
+
return range.map(function (item) {
|
|
54
|
+
var _a;
|
|
55
|
+
return (_a = flowdata[item.r]) === null || _a === void 0 ? void 0 : _a[item.c];
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
function getSelectionCoordinates(ctx) {
|
|
59
|
+
var result = [];
|
|
60
|
+
var rangeArr = _lodash.default.cloneDeep(ctx.luckysheet_select_save);
|
|
61
|
+
var sheetId = ctx.currentSheetId;
|
|
62
|
+
rangeArr === null || rangeArr === void 0 ? void 0 : rangeArr.forEach(function (ele) {
|
|
63
|
+
var rangeText = (0, _2.getRangetxt)(ctx, sheetId, {
|
|
64
|
+
column: ele.column,
|
|
65
|
+
row: ele.row
|
|
66
|
+
});
|
|
67
|
+
result.push(rangeText);
|
|
68
|
+
});
|
|
69
|
+
return result;
|
|
70
|
+
}
|
|
71
|
+
function getCellsByRange(ctx, range, options) {
|
|
72
|
+
if (options === void 0) {
|
|
73
|
+
options = {};
|
|
74
|
+
}
|
|
75
|
+
var sheet = (0, _common.getSheet)(ctx, options);
|
|
76
|
+
if (!range || _typeof(range) === "object") {
|
|
77
|
+
return (0, _2.getdatabyselection)(ctx, range, sheet.id);
|
|
78
|
+
}
|
|
79
|
+
throw _errors.INVALID_PARAMS;
|
|
80
|
+
}
|
|
81
|
+
function getHtmlByRange(ctx, range, options) {
|
|
82
|
+
if (options === void 0) {
|
|
83
|
+
options = {};
|
|
84
|
+
}
|
|
85
|
+
var sheet = (0, _common.getSheet)(ctx, options);
|
|
86
|
+
return (0, _modules.rangeValueToHtml)(ctx, sheet.id, range);
|
|
87
|
+
}
|
|
88
|
+
function setSelection(ctx, range, options) {
|
|
89
|
+
var sheet = (0, _common.getSheet)(ctx, options);
|
|
90
|
+
sheet.luckysheet_select_save = (0, _modules.normalizeSelection)(ctx, range);
|
|
91
|
+
if (ctx.currentSheetId === sheet.id) {
|
|
92
|
+
ctx.luckysheet_select_save = sheet.luckysheet_select_save;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
function setCellValuesByRange(ctx, data, range, cellInput, options) {
|
|
96
|
+
if (options === void 0) {
|
|
97
|
+
options = {};
|
|
98
|
+
}
|
|
99
|
+
if (data == null) {
|
|
100
|
+
throw _errors.INVALID_PARAMS;
|
|
101
|
+
}
|
|
102
|
+
if (range instanceof Array) {
|
|
103
|
+
throw new Error("setCellValuesByRange does not support multiple ranges");
|
|
104
|
+
}
|
|
105
|
+
if (!_lodash.default.isPlainObject(range)) {
|
|
106
|
+
throw _errors.INVALID_PARAMS;
|
|
107
|
+
}
|
|
108
|
+
var rowCount = range.row[1] - range.row[0] + 1;
|
|
109
|
+
var columnCount = range.column[1] - range.column[0] + 1;
|
|
110
|
+
if (data.length !== rowCount || data[0].length !== columnCount) {
|
|
111
|
+
throw new Error("data size does not match range");
|
|
112
|
+
}
|
|
113
|
+
for (var i = 0; i < rowCount; i += 1) {
|
|
114
|
+
for (var j = 0; j < columnCount; j += 1) {
|
|
115
|
+
var row = range.row[0] + i;
|
|
116
|
+
var column = range.column[0] + j;
|
|
117
|
+
(0, _cell.setCellValue)(ctx, row, column, data[i][j], cellInput, options);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
function setCellFormatByRange(ctx, attr, value, range, options) {
|
|
122
|
+
if (options === void 0) {
|
|
123
|
+
options = {};
|
|
124
|
+
}
|
|
125
|
+
if (_lodash.default.isPlainObject(range)) {
|
|
126
|
+
range = [range];
|
|
127
|
+
}
|
|
128
|
+
if (!_lodash.default.isArray(range)) {
|
|
129
|
+
throw _errors.INVALID_PARAMS;
|
|
130
|
+
}
|
|
131
|
+
range.forEach(function (singleRange) {
|
|
132
|
+
for (var r = singleRange.row[0]; r <= singleRange.row[1]; r += 1) {
|
|
133
|
+
for (var c = singleRange.column[0]; c <= singleRange.column[1]; c += 1) {
|
|
134
|
+
(0, _cell.setCellFormat)(ctx, r, c, attr, value, options);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Context } from "../context";
|
|
2
|
+
import { CommonOptions } from "./common";
|
|
3
|
+
export declare function freeze(ctx: Context, type: "row" | "column" | "both", range: {
|
|
4
|
+
row: number;
|
|
5
|
+
column: number;
|
|
6
|
+
}, options?: CommonOptions): void;
|
|
7
|
+
export declare function insertRowOrColumn(ctx: Context, type: "row" | "column", index: number, count: number, direction: "lefttop" | "rightbottom", options?: CommonOptions): void;
|
|
8
|
+
export declare function deleteRowOrColumn(ctx: Context, type: "row" | "column", start: number, end: number, options?: CommonOptions): void;
|
|
9
|
+
export declare function hideRowOrColumn(ctx: Context, rowColInfo: string[], type: "row" | "column"): void;
|
|
10
|
+
export declare function showRowOrColumn(ctx: Context, rowColInfo: string[], type: "row" | "column"): void;
|
|
11
|
+
export declare function setRowHeight(ctx: Context, rowInfo: Record<string, number>, options?: CommonOptions, custom?: boolean): void;
|
|
12
|
+
export declare function setColumnWidth(ctx: Context, columnInfo: Record<string, number>, options?: CommonOptions, custom?: boolean): void;
|
|
13
|
+
export declare function getRowHeight(ctx: Context, rows: number[], options?: CommonOptions): Record<number, number>;
|
|
14
|
+
export declare function getColumnWidth(ctx: Context, columns: number[], options?: CommonOptions): Record<number, number>;
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.deleteRowOrColumn = deleteRowOrColumn;
|
|
7
|
+
exports.freeze = freeze;
|
|
8
|
+
exports.getColumnWidth = getColumnWidth;
|
|
9
|
+
exports.getRowHeight = getRowHeight;
|
|
10
|
+
exports.hideRowOrColumn = hideRowOrColumn;
|
|
11
|
+
exports.insertRowOrColumn = insertRowOrColumn;
|
|
12
|
+
exports.setColumnWidth = setColumnWidth;
|
|
13
|
+
exports.setRowHeight = setRowHeight;
|
|
14
|
+
exports.showRowOrColumn = showRowOrColumn;
|
|
15
|
+
var _lodash = _interopRequireDefault(require("lodash"));
|
|
16
|
+
var _modules = require("../modules");
|
|
17
|
+
var _common = require("./common");
|
|
18
|
+
var _errors = require("./errors");
|
|
19
|
+
var _utils = require("../utils");
|
|
20
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
21
|
+
function freeze(ctx, type, range, options) {
|
|
22
|
+
if (options === void 0) {
|
|
23
|
+
options = {};
|
|
24
|
+
}
|
|
25
|
+
var sheet = (0, _common.getSheet)(ctx, options);
|
|
26
|
+
var typeMap = {
|
|
27
|
+
row: "rangeRow",
|
|
28
|
+
column: "rangeColumn",
|
|
29
|
+
both: "rangeBoth"
|
|
30
|
+
};
|
|
31
|
+
var innerType = typeMap[type];
|
|
32
|
+
sheet.frozen = {
|
|
33
|
+
type: innerType,
|
|
34
|
+
range: {
|
|
35
|
+
column_focus: range.column,
|
|
36
|
+
row_focus: range.row
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function insertRowOrColumn(ctx, type, index, count, direction, options) {
|
|
41
|
+
if (options === void 0) {
|
|
42
|
+
options = {};
|
|
43
|
+
}
|
|
44
|
+
if (!["row", "column"].includes(type) || !_lodash.default.isNumber(index) || !_lodash.default.isNumber(count) || !["lefttop", "rightbottom"].includes(direction)) {
|
|
45
|
+
throw _errors.INVALID_PARAMS;
|
|
46
|
+
}
|
|
47
|
+
var sheet = (0, _common.getSheet)(ctx, options);
|
|
48
|
+
try {
|
|
49
|
+
(0, _modules.insertRowCol)(ctx, {
|
|
50
|
+
type: type,
|
|
51
|
+
index: index,
|
|
52
|
+
count: count,
|
|
53
|
+
direction: direction,
|
|
54
|
+
id: sheet.id
|
|
55
|
+
});
|
|
56
|
+
} catch (e) {
|
|
57
|
+
console.error(e);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function deleteRowOrColumn(ctx, type, start, end, options) {
|
|
61
|
+
if (options === void 0) {
|
|
62
|
+
options = {};
|
|
63
|
+
}
|
|
64
|
+
if (!["row", "column"].includes(type) || !_lodash.default.isNumber(start) || !_lodash.default.isNumber(end)) {
|
|
65
|
+
throw _errors.INVALID_PARAMS;
|
|
66
|
+
}
|
|
67
|
+
var sheet = (0, _common.getSheet)(ctx, options);
|
|
68
|
+
(0, _modules.deleteRowCol)(ctx, {
|
|
69
|
+
type: type,
|
|
70
|
+
start: start,
|
|
71
|
+
end: end,
|
|
72
|
+
id: sheet.id
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
function hideRowOrColumn(ctx, rowColInfo, type) {
|
|
76
|
+
var _a, _b;
|
|
77
|
+
if (!["row", "column"].includes(type)) {
|
|
78
|
+
throw _errors.INVALID_PARAMS;
|
|
79
|
+
}
|
|
80
|
+
if (!ctx || !ctx.config) return;
|
|
81
|
+
var index = (0, _utils.getSheetIndex)(ctx, ctx.currentSheetId);
|
|
82
|
+
if (type === "row") {
|
|
83
|
+
var rowhidden_1 = (_a = ctx.config.rowhidden) !== null && _a !== void 0 ? _a : {};
|
|
84
|
+
rowColInfo.forEach(function (r) {
|
|
85
|
+
rowhidden_1[r] = 0;
|
|
86
|
+
});
|
|
87
|
+
ctx.config.rowhidden = rowhidden_1;
|
|
88
|
+
} else if (type === "column") {
|
|
89
|
+
var colhidden_1 = (_b = ctx.config.colhidden) !== null && _b !== void 0 ? _b : {};
|
|
90
|
+
rowColInfo.forEach(function (r) {
|
|
91
|
+
colhidden_1[r] = 0;
|
|
92
|
+
});
|
|
93
|
+
ctx.config.colhidden = colhidden_1;
|
|
94
|
+
}
|
|
95
|
+
ctx.luckysheetfile[index].config = ctx.config;
|
|
96
|
+
}
|
|
97
|
+
function showRowOrColumn(ctx, rowColInfo, type) {
|
|
98
|
+
var _a, _b;
|
|
99
|
+
if (!["row", "column"].includes(type)) {
|
|
100
|
+
throw _errors.INVALID_PARAMS;
|
|
101
|
+
}
|
|
102
|
+
if (!ctx || !ctx.config) return;
|
|
103
|
+
var index = (0, _utils.getSheetIndex)(ctx, ctx.currentSheetId);
|
|
104
|
+
if (type === "row") {
|
|
105
|
+
var rowhidden_2 = (_a = ctx.config.rowhidden) !== null && _a !== void 0 ? _a : {};
|
|
106
|
+
rowColInfo.forEach(function (r) {
|
|
107
|
+
delete rowhidden_2[r];
|
|
108
|
+
});
|
|
109
|
+
ctx.config.rowhidden = rowhidden_2;
|
|
110
|
+
} else if (type === "column") {
|
|
111
|
+
var colhidden_2 = (_b = ctx.config.colhidden) !== null && _b !== void 0 ? _b : {};
|
|
112
|
+
rowColInfo.forEach(function (r) {
|
|
113
|
+
delete colhidden_2[r];
|
|
114
|
+
});
|
|
115
|
+
ctx.config.colhidden = colhidden_2;
|
|
116
|
+
}
|
|
117
|
+
ctx.luckysheetfile[index].config = ctx.config;
|
|
118
|
+
}
|
|
119
|
+
function setRowHeight(ctx, rowInfo, options, custom) {
|
|
120
|
+
if (options === void 0) {
|
|
121
|
+
options = {};
|
|
122
|
+
}
|
|
123
|
+
if (custom === void 0) {
|
|
124
|
+
custom = false;
|
|
125
|
+
}
|
|
126
|
+
if (!_lodash.default.isPlainObject(rowInfo)) {
|
|
127
|
+
throw _errors.INVALID_PARAMS;
|
|
128
|
+
}
|
|
129
|
+
var sheet = (0, _common.getSheet)(ctx, options);
|
|
130
|
+
var cfg = sheet.config || {};
|
|
131
|
+
if (cfg.rowlen == null) {
|
|
132
|
+
cfg.rowlen = {};
|
|
133
|
+
}
|
|
134
|
+
_lodash.default.forEach(rowInfo, function (len, r) {
|
|
135
|
+
var _a;
|
|
136
|
+
if (Number(r) >= 0) {
|
|
137
|
+
if (Number(len) >= 0) {
|
|
138
|
+
cfg.rowlen[Number(r)] = Number(len);
|
|
139
|
+
if (custom && _lodash.default.isUndefined(cfg.customHeight)) {
|
|
140
|
+
cfg.customHeight = (_a = {}, _a[r] = 1, _a);
|
|
141
|
+
} else if (custom) {
|
|
142
|
+
cfg.customHeight[r] = 1;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
sheet.config = cfg;
|
|
148
|
+
if (ctx.currentSheetId === sheet.id) {
|
|
149
|
+
ctx.config = cfg;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
function setColumnWidth(ctx, columnInfo, options, custom) {
|
|
153
|
+
if (options === void 0) {
|
|
154
|
+
options = {};
|
|
155
|
+
}
|
|
156
|
+
if (custom === void 0) {
|
|
157
|
+
custom = false;
|
|
158
|
+
}
|
|
159
|
+
if (!_lodash.default.isPlainObject(columnInfo)) {
|
|
160
|
+
throw _errors.INVALID_PARAMS;
|
|
161
|
+
}
|
|
162
|
+
var sheet = (0, _common.getSheet)(ctx, options);
|
|
163
|
+
var cfg = sheet.config || {};
|
|
164
|
+
if (cfg.columnlen == null) {
|
|
165
|
+
cfg.columnlen = {};
|
|
166
|
+
}
|
|
167
|
+
_lodash.default.forEach(columnInfo, function (len, c) {
|
|
168
|
+
var _a;
|
|
169
|
+
if (Number(c) >= 0) {
|
|
170
|
+
if (Number(len) >= 0) {
|
|
171
|
+
cfg.columnlen[Number(c)] = Number(len);
|
|
172
|
+
if (custom && _lodash.default.isUndefined(cfg.customWidth)) {
|
|
173
|
+
cfg.customWidth = (_a = {}, _a[c] = 1, _a);
|
|
174
|
+
} else if (custom) {
|
|
175
|
+
cfg.customWidth[c] = 1;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
sheet.config = cfg;
|
|
181
|
+
if (ctx.currentSheetId === sheet.id) {
|
|
182
|
+
ctx.config = cfg;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
function getRowHeight(ctx, rows, options) {
|
|
186
|
+
if (options === void 0) {
|
|
187
|
+
options = {};
|
|
188
|
+
}
|
|
189
|
+
if (!_lodash.default.isArray(rows) || rows.length === 0) {
|
|
190
|
+
throw _errors.INVALID_PARAMS;
|
|
191
|
+
}
|
|
192
|
+
var sheet = (0, _common.getSheet)(ctx, options);
|
|
193
|
+
var cfg = sheet.config || {};
|
|
194
|
+
var rowlen = cfg.rowlen || {};
|
|
195
|
+
var rowlenObj = {};
|
|
196
|
+
rows.forEach(function (item) {
|
|
197
|
+
if (Number(item) >= 0) {
|
|
198
|
+
var size = rowlen[Number(item)] || ctx.defaultrowlen;
|
|
199
|
+
rowlenObj[Number(item)] = size;
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
return rowlenObj;
|
|
203
|
+
}
|
|
204
|
+
function getColumnWidth(ctx, columns, options) {
|
|
205
|
+
if (options === void 0) {
|
|
206
|
+
options = {};
|
|
207
|
+
}
|
|
208
|
+
if (!_lodash.default.isArray(columns) || columns.length === 0) {
|
|
209
|
+
throw _errors.INVALID_PARAMS;
|
|
210
|
+
}
|
|
211
|
+
var sheet = (0, _common.getSheet)(ctx, options);
|
|
212
|
+
var cfg = sheet.config || {};
|
|
213
|
+
var columnlen = cfg.columnlen || {};
|
|
214
|
+
var columnlenObj = {};
|
|
215
|
+
columns.forEach(function (item) {
|
|
216
|
+
if (Number(item) >= 0) {
|
|
217
|
+
var size = columnlen[Number(item)] || ctx.defaultcollen;
|
|
218
|
+
columnlenObj[Number(item)] = size;
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
return columnlenObj;
|
|
222
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { getSheet } from "./common";
|
|
2
|
+
import { Context } from "../context";
|
|
3
|
+
import { CellMatrix, Sheet } from "../types";
|
|
4
|
+
export declare function getAllSheets(ctx: Context): Sheet[];
|
|
5
|
+
export { getSheet };
|
|
6
|
+
export declare function initSheetData(draftCtx: Context, index: number, newData: Sheet): CellMatrix | null;
|
|
7
|
+
export declare function hideSheet(ctx: Context, sheetId: string): void;
|
|
8
|
+
export declare function showSheet(ctx: Context, sheetId: string): void;
|
|
9
|
+
export declare function copySheet(ctx: Context, sheetId: string): void;
|
|
10
|
+
export declare function calculateSheetFromula(ctx: Context, id: string): void;
|