@fileverse-dev/fortune-react 1.3.11 → 1.3.12-copyPaste-4

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.
@@ -123,7 +123,7 @@ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
123
123
  return to.concat(ar || Array.prototype.slice.call(from));
124
124
  };
125
125
  import React, { useContext, useCallback, useRef, useEffect, useState } from "react";
126
- import { toolbarItemClickHandler, handleTextBackground, handleTextColor, handleTextSize, normalizedCellAttr, getFlowdata, newComment, editComment, deleteComment, showHideComment, showHideAllComments, autoSelectionFormula, handleSum, locale, handleMerge, handleBorder, toolbarItemSelectedFunc, handleFreeze, insertImage, showImgChooser, updateFormat, handleSort, handleHorizontalAlign, handleVerticalAlign, handleScreenShot, createFilter, clearFilter, applyLocation, insertDuneChart, api, getSheetIndex } from "@fileverse-dev/fortune-core";
126
+ import { toolbarItemClickHandler, handleTextBackground, handleTextColor, handleTextSize, normalizedCellAttr, getFlowdata, newComment, editComment, deleteComment, showHideComment, showHideAllComments, autoSelectionFormula, handleSum, locale, handleMerge, handleBorder, toolbarItemSelectedFunc, handleFreeze, insertImage, showImgChooser, updateFormat, handleSort, handleHorizontalAlign, handleVerticalAlign, handleScreenShot, createFilter, clearFilter, applyLocation, insertDuneChart, api, getSheetIndex, is_date } from "@fileverse-dev/fortune-core";
127
127
  import _ from "lodash";
128
128
  import { IconButton, LucideIcon, Tooltip, Command, CommandInput, CommandList, CommandEmpty, CommandGroup, CommandItem } from "@fileverse/ui";
129
129
  import DataVerificationPortal from "./dataVerificationPortal";
@@ -649,7 +649,7 @@ var Toolbar = function Toolbar(_a) {
649
649
  }
650
650
  }, [cell, refs.globalCache]);
651
651
  var getToolbarItem = useCallback(function (name, i) {
652
- var _a, _b, _c, _d, _e, _f, _g;
652
+ var _a, _b, _c, _d, _e, _f;
653
653
  var tooltip = toolbar[name];
654
654
  if (name === "|") {
655
655
  return /*#__PURE__*/React.createElement(Divider, {
@@ -714,10 +714,15 @@ var Toolbar = function Toolbar(_a) {
714
714
  return v.value === (curr_2 === null || curr_2 === void 0 ? void 0 : curr_2.fa);
715
715
  });
716
716
  if ((curr_2 === null || curr_2 === void 0 ? void 0 : curr_2.fa) != null) {
717
- if (format != null) {
718
- currentFmt_1 = format.text;
719
- } else if (((_a = curr_2 === null || curr_2 === void 0 ? void 0 : curr_2.fa) === null || _a === void 0 ? void 0 : _a.includes("#,##0")) || (curr_2 === null || curr_2 === void 0 ? void 0 : curr_2.fa) === "0" || (curr_2 === null || curr_2 === void 0 ? void 0 : curr_2.fa) === "0.00") {
717
+ var hasTime = /[hH]:/.test(curr_2.fa);
718
+ if (curr_2.t === "d") {
719
+ currentFmt_1 = hasTime ? "Date time" : "Date";
720
+ } else if (curr_2.t === "n" || curr_2.fa.includes("#,##0") || curr_2.fa === "0" || curr_2.fa === "0.00") {
720
721
  currentFmt_1 = "Number";
722
+ } else if (is_date(curr_2.fa)) {
723
+ currentFmt_1 = hasTime ? "Date time" : "Date";
724
+ } else if (format != null) {
725
+ currentFmt_1 = format.text;
721
726
  } else {
722
727
  currentFmt_1 = defaultFormat[defaultFormat.length - 1].text;
723
728
  }
@@ -872,9 +877,9 @@ var Toolbar = function Toolbar(_a) {
872
877
  value: 2
873
878
  }];
874
879
  return /*#__PURE__*/React.createElement(Combo, {
875
- iconId: ((_b = _.find(items_1, function (item) {
880
+ iconId: ((_a = _.find(items_1, function (item) {
876
881
  return "".concat(item.value) === "".concat(cell === null || cell === void 0 ? void 0 : cell.ht);
877
- })) === null || _b === void 0 ? void 0 : _b.title) || "align-left",
882
+ })) === null || _a === void 0 ? void 0 : _a.title) || "align-left",
878
883
  key: name,
879
884
  tooltip: toolbar.horizontalAlign,
880
885
  showArrow: false
@@ -924,9 +929,9 @@ var Toolbar = function Toolbar(_a) {
924
929
  value: 2
925
930
  }];
926
931
  return /*#__PURE__*/React.createElement(Combo, {
927
- iconId: ((_c = _.find(items_2, function (item) {
932
+ iconId: ((_b = _.find(items_2, function (item) {
928
933
  return "".concat(item.value) === "".concat(cell === null || cell === void 0 ? void 0 : cell.vt);
929
- })) === null || _c === void 0 ? void 0 : _c.title) || "align-top",
934
+ })) === null || _b === void 0 ? void 0 : _b.title) || "align-top",
930
935
  key: name,
931
936
  tooltip: toolbar.verticalAlign,
932
937
  showArrow: false
@@ -1167,7 +1172,7 @@ var Toolbar = function Toolbar(_a) {
1167
1172
  });
1168
1173
  }
1169
1174
  if (name === "comment") {
1170
- var last = (_d = context.luckysheet_select_save) === null || _d === void 0 ? void 0 : _d[context.luckysheet_select_save.length - 1];
1175
+ var last = (_c = context.luckysheet_select_save) === null || _c === void 0 ? void 0 : _c[context.luckysheet_select_save.length - 1];
1171
1176
  var row_index_1 = last === null || last === void 0 ? void 0 : last.row_focus;
1172
1177
  var col_index_1 = last === null || last === void 0 ? void 0 : last.column_focus;
1173
1178
  if (!last) {
@@ -1182,7 +1187,7 @@ var Toolbar = function Toolbar(_a) {
1182
1187
  }
1183
1188
  }
1184
1189
  var itemData_1;
1185
- if (((_f = (_e = flowdata === null || flowdata === void 0 ? void 0 : flowdata[row_index_1]) === null || _e === void 0 ? void 0 : _e[col_index_1]) === null || _f === void 0 ? void 0 : _f.ps) != null) {
1190
+ if (((_e = (_d = flowdata === null || flowdata === void 0 ? void 0 : flowdata[row_index_1]) === null || _d === void 0 ? void 0 : _d[col_index_1]) === null || _e === void 0 ? void 0 : _e.ps) != null) {
1186
1191
  itemData_1 = [{
1187
1192
  key: "edit",
1188
1193
  text: comment.edit,
@@ -1695,7 +1700,7 @@ var Toolbar = function Toolbar(_a) {
1695
1700
  iconId: name,
1696
1701
  tooltip: tooltip,
1697
1702
  key: name,
1698
- selected: (_g = toolbarItemSelectedFunc(name)) === null || _g === void 0 ? void 0 : _g(cell),
1703
+ selected: (_f = toolbarItemSelectedFunc(name)) === null || _f === void 0 ? void 0 : _f(cell),
1699
1704
  onClick: function onClick() {
1700
1705
  return setContext(function (draftCtx) {
1701
1706
  var _a;
@@ -25,7 +25,7 @@ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
25
25
  }
26
26
  return to.concat(ar || Array.prototype.slice.call(from));
27
27
  };
28
- import { defaultContext, defaultSettings, initSheetIndex, handleGlobalKeyDown, getSheetIndex, handlePaste, filterPatch, patchToOp, inverseRowColOptions, ensureSheetIndex, insertRowCol, deleteRowCol, groupValuesRefresh, insertDuneChart, getFlowdata, api, handlePasteByClick } from "@fileverse-dev/fortune-core";
28
+ import { defaultContext, defaultSettings, initSheetIndex, handleGlobalKeyDown, getSheetIndex, handlePaste, filterPatch, patchToOp, inverseRowColOptions, ensureSheetIndex, insertRowCol, deleteRowCol, groupValuesRefresh, insertDuneChart, getFlowdata, api, handlePasteByClick, update } from "@fileverse-dev/fortune-core";
29
29
  import React, { useMemo, useState, useCallback, useEffect, useRef, useImperativeHandle } from "react";
30
30
  import "./index.css";
31
31
  import produce, { applyPatches, enablePatches, produceWithPatches } from "immer";
@@ -124,6 +124,12 @@ var Workbook = /*#__PURE__*/React.forwardRef(function (_a, ref) {
124
124
  });
125
125
  celldata === null || celldata === void 0 ? void 0 : celldata.forEach(function (d) {
126
126
  expandedData_1[d.r][d.c] = d.v;
127
+ var cell = d.v;
128
+ if (cell && cell.ct && cell.ct.t === "d" && (cell.m === undefined || cell.m === null)) {
129
+ try {
130
+ cell.m = update(cell.ct.fa || "General", cell.v);
131
+ } catch (e) {}
132
+ }
127
133
  });
128
134
  draftCtx.luckysheetfile = produce(draftCtx.luckysheetfile, function (d) {
129
135
  d[index].data = expandedData_1;
@@ -658,7 +658,7 @@ var Toolbar = function Toolbar(_a) {
658
658
  }
659
659
  }, [cell, refs.globalCache]);
660
660
  var getToolbarItem = (0, _react.useCallback)(function (name, i) {
661
- var _a, _b, _c, _d, _e, _f, _g;
661
+ var _a, _b, _c, _d, _e, _f;
662
662
  var tooltip = toolbar[name];
663
663
  if (name === "|") {
664
664
  return /*#__PURE__*/_react.default.createElement(_Divider.default, {
@@ -723,10 +723,15 @@ var Toolbar = function Toolbar(_a) {
723
723
  return v.value === (curr_2 === null || curr_2 === void 0 ? void 0 : curr_2.fa);
724
724
  });
725
725
  if ((curr_2 === null || curr_2 === void 0 ? void 0 : curr_2.fa) != null) {
726
- if (format != null) {
727
- currentFmt_1 = format.text;
728
- } else if (((_a = curr_2 === null || curr_2 === void 0 ? void 0 : curr_2.fa) === null || _a === void 0 ? void 0 : _a.includes("#,##0")) || (curr_2 === null || curr_2 === void 0 ? void 0 : curr_2.fa) === "0" || (curr_2 === null || curr_2 === void 0 ? void 0 : curr_2.fa) === "0.00") {
726
+ var hasTime = /[hH]:/.test(curr_2.fa);
727
+ if (curr_2.t === "d") {
728
+ currentFmt_1 = hasTime ? "Date time" : "Date";
729
+ } else if (curr_2.t === "n" || curr_2.fa.includes("#,##0") || curr_2.fa === "0" || curr_2.fa === "0.00") {
729
730
  currentFmt_1 = "Number";
731
+ } else if ((0, _fortuneCore.is_date)(curr_2.fa)) {
732
+ currentFmt_1 = hasTime ? "Date time" : "Date";
733
+ } else if (format != null) {
734
+ currentFmt_1 = format.text;
730
735
  } else {
731
736
  currentFmt_1 = defaultFormat[defaultFormat.length - 1].text;
732
737
  }
@@ -881,9 +886,9 @@ var Toolbar = function Toolbar(_a) {
881
886
  value: 2
882
887
  }];
883
888
  return /*#__PURE__*/_react.default.createElement(_Combo.default, {
884
- iconId: ((_b = _lodash.default.find(items_1, function (item) {
889
+ iconId: ((_a = _lodash.default.find(items_1, function (item) {
885
890
  return "".concat(item.value) === "".concat(cell === null || cell === void 0 ? void 0 : cell.ht);
886
- })) === null || _b === void 0 ? void 0 : _b.title) || "align-left",
891
+ })) === null || _a === void 0 ? void 0 : _a.title) || "align-left",
887
892
  key: name,
888
893
  tooltip: toolbar.horizontalAlign,
889
894
  showArrow: false
@@ -933,9 +938,9 @@ var Toolbar = function Toolbar(_a) {
933
938
  value: 2
934
939
  }];
935
940
  return /*#__PURE__*/_react.default.createElement(_Combo.default, {
936
- iconId: ((_c = _lodash.default.find(items_2, function (item) {
941
+ iconId: ((_b = _lodash.default.find(items_2, function (item) {
937
942
  return "".concat(item.value) === "".concat(cell === null || cell === void 0 ? void 0 : cell.vt);
938
- })) === null || _c === void 0 ? void 0 : _c.title) || "align-top",
943
+ })) === null || _b === void 0 ? void 0 : _b.title) || "align-top",
939
944
  key: name,
940
945
  tooltip: toolbar.verticalAlign,
941
946
  showArrow: false
@@ -1176,7 +1181,7 @@ var Toolbar = function Toolbar(_a) {
1176
1181
  });
1177
1182
  }
1178
1183
  if (name === "comment") {
1179
- var last = (_d = context.luckysheet_select_save) === null || _d === void 0 ? void 0 : _d[context.luckysheet_select_save.length - 1];
1184
+ var last = (_c = context.luckysheet_select_save) === null || _c === void 0 ? void 0 : _c[context.luckysheet_select_save.length - 1];
1180
1185
  var row_index_1 = last === null || last === void 0 ? void 0 : last.row_focus;
1181
1186
  var col_index_1 = last === null || last === void 0 ? void 0 : last.column_focus;
1182
1187
  if (!last) {
@@ -1191,7 +1196,7 @@ var Toolbar = function Toolbar(_a) {
1191
1196
  }
1192
1197
  }
1193
1198
  var itemData_1;
1194
- if (((_f = (_e = flowdata === null || flowdata === void 0 ? void 0 : flowdata[row_index_1]) === null || _e === void 0 ? void 0 : _e[col_index_1]) === null || _f === void 0 ? void 0 : _f.ps) != null) {
1199
+ if (((_e = (_d = flowdata === null || flowdata === void 0 ? void 0 : flowdata[row_index_1]) === null || _d === void 0 ? void 0 : _d[col_index_1]) === null || _e === void 0 ? void 0 : _e.ps) != null) {
1195
1200
  itemData_1 = [{
1196
1201
  key: "edit",
1197
1202
  text: comment.edit,
@@ -1704,7 +1709,7 @@ var Toolbar = function Toolbar(_a) {
1704
1709
  iconId: name,
1705
1710
  tooltip: tooltip,
1706
1711
  key: name,
1707
- selected: (_g = (0, _fortuneCore.toolbarItemSelectedFunc)(name)) === null || _g === void 0 ? void 0 : _g(cell),
1712
+ selected: (_f = (0, _fortuneCore.toolbarItemSelectedFunc)(name)) === null || _f === void 0 ? void 0 : _f(cell),
1708
1713
  onClick: function onClick() {
1709
1714
  return setContext(function (draftCtx) {
1710
1715
  var _a;
@@ -133,6 +133,12 @@ var Workbook = /*#__PURE__*/_react.default.forwardRef(function (_a, ref) {
133
133
  });
134
134
  celldata === null || celldata === void 0 ? void 0 : celldata.forEach(function (d) {
135
135
  expandedData_1[d.r][d.c] = d.v;
136
+ var cell = d.v;
137
+ if (cell && cell.ct && cell.ct.t === "d" && (cell.m === undefined || cell.m === null)) {
138
+ try {
139
+ cell.m = (0, _fortuneCore.update)(cell.ct.fa || "General", cell.v);
140
+ } catch (e) {}
141
+ }
136
142
  });
137
143
  draftCtx.luckysheetfile = (0, _immer.default)(draftCtx.luckysheetfile, function (d) {
138
144
  d[index].data = expandedData_1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fileverse-dev/fortune-react",
3
- "version": "1.3.11",
3
+ "version": "1.3.12-copyPaste-4",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "module": "es/index.js",
@@ -16,7 +16,7 @@
16
16
  "tsc": "tsc"
17
17
  },
18
18
  "dependencies": {
19
- "@fileverse-dev/fortune-core": "1.3.11",
19
+ "@fileverse-dev/fortune-core": "1.3.12-copyPaste-4",
20
20
  "@fileverse/ui": "5.0.0",
21
21
  "@tippyjs/react": "^4.2.6",
22
22
  "@types/regenerator-runtime": "^0.13.6",