@fileverse-dev/fortune-react 1.3.6 → 1.3.7-dateImport-2

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";
@@ -650,7 +650,7 @@ var Toolbar = function Toolbar(_a) {
650
650
  }
651
651
  }, [cell, refs.globalCache]);
652
652
  var getToolbarItem = useCallback(function (name, i) {
653
- var _a, _b, _c, _d, _e, _f, _g;
653
+ var _a, _b, _c, _d, _e, _f;
654
654
  var tooltip = toolbar[name];
655
655
  if (name === "|") {
656
656
  return /*#__PURE__*/React.createElement(Divider, {
@@ -715,10 +715,15 @@ var Toolbar = function Toolbar(_a) {
715
715
  return v.value === (curr_2 === null || curr_2 === void 0 ? void 0 : curr_2.fa);
716
716
  });
717
717
  if ((curr_2 === null || curr_2 === void 0 ? void 0 : curr_2.fa) != null) {
718
- if (format != null) {
719
- currentFmt_1 = format.text;
720
- } 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") {
718
+ var hasTime = /[hH]:/.test(curr_2.fa);
719
+ if (curr_2.t === "d") {
720
+ currentFmt_1 = hasTime ? "Date time" : "Date";
721
+ } else if (curr_2.t === "n" || curr_2.fa.includes("#,##0") || curr_2.fa === "0" || curr_2.fa === "0.00") {
721
722
  currentFmt_1 = "Number";
723
+ } else if (is_date(curr_2.fa)) {
724
+ currentFmt_1 = hasTime ? "Date time" : "Date";
725
+ } else if (format != null) {
726
+ currentFmt_1 = format.text;
722
727
  } else {
723
728
  currentFmt_1 = defaultFormat[defaultFormat.length - 1].text;
724
729
  }
@@ -873,9 +878,9 @@ var Toolbar = function Toolbar(_a) {
873
878
  value: 2
874
879
  }];
875
880
  return /*#__PURE__*/React.createElement(Combo, {
876
- iconId: ((_b = _.find(items_1, function (item) {
881
+ iconId: ((_a = _.find(items_1, function (item) {
877
882
  return "".concat(item.value) === "".concat(cell === null || cell === void 0 ? void 0 : cell.ht);
878
- })) === null || _b === void 0 ? void 0 : _b.title) || "align-left",
883
+ })) === null || _a === void 0 ? void 0 : _a.title) || "align-left",
879
884
  key: name,
880
885
  tooltip: toolbar.horizontalAlign,
881
886
  showArrow: false
@@ -925,9 +930,9 @@ var Toolbar = function Toolbar(_a) {
925
930
  value: 2
926
931
  }];
927
932
  return /*#__PURE__*/React.createElement(Combo, {
928
- iconId: ((_c = _.find(items_2, function (item) {
933
+ iconId: ((_b = _.find(items_2, function (item) {
929
934
  return "".concat(item.value) === "".concat(cell === null || cell === void 0 ? void 0 : cell.vt);
930
- })) === null || _c === void 0 ? void 0 : _c.title) || "align-top",
935
+ })) === null || _b === void 0 ? void 0 : _b.title) || "align-top",
931
936
  key: name,
932
937
  tooltip: toolbar.verticalAlign,
933
938
  showArrow: false
@@ -1168,7 +1173,7 @@ var Toolbar = function Toolbar(_a) {
1168
1173
  });
1169
1174
  }
1170
1175
  if (name === "comment") {
1171
- var last = (_d = context.luckysheet_select_save) === null || _d === void 0 ? void 0 : _d[context.luckysheet_select_save.length - 1];
1176
+ var last = (_c = context.luckysheet_select_save) === null || _c === void 0 ? void 0 : _c[context.luckysheet_select_save.length - 1];
1172
1177
  var row_index_1 = last === null || last === void 0 ? void 0 : last.row_focus;
1173
1178
  var col_index_1 = last === null || last === void 0 ? void 0 : last.column_focus;
1174
1179
  if (!last) {
@@ -1183,7 +1188,7 @@ var Toolbar = function Toolbar(_a) {
1183
1188
  }
1184
1189
  }
1185
1190
  var itemData_1;
1186
- 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) {
1191
+ 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) {
1187
1192
  itemData_1 = [{
1188
1193
  key: "edit",
1189
1194
  text: comment.edit,
@@ -1696,7 +1701,7 @@ var Toolbar = function Toolbar(_a) {
1696
1701
  iconId: name,
1697
1702
  tooltip: tooltip,
1698
1703
  key: name,
1699
- selected: (_g = toolbarItemSelectedFunc(name)) === null || _g === void 0 ? void 0 : _g(cell),
1704
+ selected: (_f = toolbarItemSelectedFunc(name)) === null || _f === void 0 ? void 0 : _f(cell),
1700
1705
  onClick: function onClick() {
1701
1706
  return setContext(function (draftCtx) {
1702
1707
  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;
@@ -659,7 +659,7 @@ var Toolbar = function Toolbar(_a) {
659
659
  }
660
660
  }, [cell, refs.globalCache]);
661
661
  var getToolbarItem = (0, _react.useCallback)(function (name, i) {
662
- var _a, _b, _c, _d, _e, _f, _g;
662
+ var _a, _b, _c, _d, _e, _f;
663
663
  var tooltip = toolbar[name];
664
664
  if (name === "|") {
665
665
  return /*#__PURE__*/_react.default.createElement(_Divider.default, {
@@ -724,10 +724,15 @@ var Toolbar = function Toolbar(_a) {
724
724
  return v.value === (curr_2 === null || curr_2 === void 0 ? void 0 : curr_2.fa);
725
725
  });
726
726
  if ((curr_2 === null || curr_2 === void 0 ? void 0 : curr_2.fa) != null) {
727
- if (format != null) {
728
- currentFmt_1 = format.text;
729
- } 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") {
727
+ var hasTime = /[hH]:/.test(curr_2.fa);
728
+ if (curr_2.t === "d") {
729
+ currentFmt_1 = hasTime ? "Date time" : "Date";
730
+ } else if (curr_2.t === "n" || curr_2.fa.includes("#,##0") || curr_2.fa === "0" || curr_2.fa === "0.00") {
730
731
  currentFmt_1 = "Number";
732
+ } else if ((0, _fortuneCore.is_date)(curr_2.fa)) {
733
+ currentFmt_1 = hasTime ? "Date time" : "Date";
734
+ } else if (format != null) {
735
+ currentFmt_1 = format.text;
731
736
  } else {
732
737
  currentFmt_1 = defaultFormat[defaultFormat.length - 1].text;
733
738
  }
@@ -882,9 +887,9 @@ var Toolbar = function Toolbar(_a) {
882
887
  value: 2
883
888
  }];
884
889
  return /*#__PURE__*/_react.default.createElement(_Combo.default, {
885
- iconId: ((_b = _lodash.default.find(items_1, function (item) {
890
+ iconId: ((_a = _lodash.default.find(items_1, function (item) {
886
891
  return "".concat(item.value) === "".concat(cell === null || cell === void 0 ? void 0 : cell.ht);
887
- })) === null || _b === void 0 ? void 0 : _b.title) || "align-left",
892
+ })) === null || _a === void 0 ? void 0 : _a.title) || "align-left",
888
893
  key: name,
889
894
  tooltip: toolbar.horizontalAlign,
890
895
  showArrow: false
@@ -934,9 +939,9 @@ var Toolbar = function Toolbar(_a) {
934
939
  value: 2
935
940
  }];
936
941
  return /*#__PURE__*/_react.default.createElement(_Combo.default, {
937
- iconId: ((_c = _lodash.default.find(items_2, function (item) {
942
+ iconId: ((_b = _lodash.default.find(items_2, function (item) {
938
943
  return "".concat(item.value) === "".concat(cell === null || cell === void 0 ? void 0 : cell.vt);
939
- })) === null || _c === void 0 ? void 0 : _c.title) || "align-top",
944
+ })) === null || _b === void 0 ? void 0 : _b.title) || "align-top",
940
945
  key: name,
941
946
  tooltip: toolbar.verticalAlign,
942
947
  showArrow: false
@@ -1177,7 +1182,7 @@ var Toolbar = function Toolbar(_a) {
1177
1182
  });
1178
1183
  }
1179
1184
  if (name === "comment") {
1180
- var last = (_d = context.luckysheet_select_save) === null || _d === void 0 ? void 0 : _d[context.luckysheet_select_save.length - 1];
1185
+ var last = (_c = context.luckysheet_select_save) === null || _c === void 0 ? void 0 : _c[context.luckysheet_select_save.length - 1];
1181
1186
  var row_index_1 = last === null || last === void 0 ? void 0 : last.row_focus;
1182
1187
  var col_index_1 = last === null || last === void 0 ? void 0 : last.column_focus;
1183
1188
  if (!last) {
@@ -1192,7 +1197,7 @@ var Toolbar = function Toolbar(_a) {
1192
1197
  }
1193
1198
  }
1194
1199
  var itemData_1;
1195
- 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) {
1200
+ 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) {
1196
1201
  itemData_1 = [{
1197
1202
  key: "edit",
1198
1203
  text: comment.edit,
@@ -1705,7 +1710,7 @@ var Toolbar = function Toolbar(_a) {
1705
1710
  iconId: name,
1706
1711
  tooltip: tooltip,
1707
1712
  key: name,
1708
- selected: (_g = (0, _fortuneCore.toolbarItemSelectedFunc)(name)) === null || _g === void 0 ? void 0 : _g(cell),
1713
+ selected: (_f = (0, _fortuneCore.toolbarItemSelectedFunc)(name)) === null || _f === void 0 ? void 0 : _f(cell),
1709
1714
  onClick: function onClick() {
1710
1715
  return setContext(function (draftCtx) {
1711
1716
  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.6",
3
+ "version": "1.3.7-dateImport-2",
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.6",
19
+ "@fileverse-dev/fortune-core": "1.3.7-dateImport-2",
20
20
  "@fileverse/ui": "5.0.0",
21
21
  "@tippyjs/react": "^4.2.6",
22
22
  "@types/regenerator-runtime": "^0.13.6",