@leankylin-sheet/react 7.0.11 → 7.0.13

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/index.css CHANGED
@@ -3202,8 +3202,15 @@ label {
3202
3202
  border-color: #1a73e8;
3203
3203
  }
3204
3204
 
3205
+ .custom-format-error {
3206
+ margin-top: 6px;
3207
+ color: #d93025;
3208
+ font-size: 12px;
3209
+ line-height: 16px;
3210
+ }
3211
+
3205
3212
  .custom-format-list {
3206
- margin-top: 12px;
3213
+ margin-top: 10px;
3207
3214
  border: 1px solid #d4d4d4;
3208
3215
  border-radius: 2px;
3209
3216
  font-size: 12px;
@@ -3239,6 +3246,42 @@ label {
3239
3246
  background: #e3edfd;
3240
3247
  }
3241
3248
 
3249
+ .custom-format-preview {
3250
+ display: flex;
3251
+ align-items: center;
3252
+ margin-top: 10px;
3253
+ padding: 6px 10px;
3254
+ background: #f5f6f7;
3255
+ border-radius: 2px;
3256
+ font-size: 12px;
3257
+ }
3258
+
3259
+ .custom-format-preview-title {
3260
+ color: #666;
3261
+ flex-shrink: 0;
3262
+ }
3263
+
3264
+ .custom-format-preview-origin {
3265
+ margin-left: 4px;
3266
+ color: #333;
3267
+ }
3268
+
3269
+ .custom-format-preview-arrow {
3270
+ margin: 0 8px;
3271
+ color: #999;
3272
+ }
3273
+
3274
+ .custom-format-preview-result {
3275
+ color: #1a73e8;
3276
+ font-weight: 600;
3277
+ word-break: break-all;
3278
+ }
3279
+
3280
+ .custom-format-preview-result.invalid {
3281
+ color: #d93025;
3282
+ font-weight: 400;
3283
+ }
3284
+
3242
3285
  .leankylin-fx-editor {
3243
3286
  display: flex;
3244
3287
  flex-direction: row;
@@ -3202,8 +3202,15 @@ label {
3202
3202
  border-color: #1a73e8;
3203
3203
  }
3204
3204
 
3205
+ .custom-format-error {
3206
+ margin-top: 6px;
3207
+ color: #d93025;
3208
+ font-size: 12px;
3209
+ line-height: 16px;
3210
+ }
3211
+
3205
3212
  .custom-format-list {
3206
- margin-top: 12px;
3213
+ margin-top: 10px;
3207
3214
  border: 1px solid #d4d4d4;
3208
3215
  border-radius: 2px;
3209
3216
  font-size: 12px;
@@ -3239,6 +3246,42 @@ label {
3239
3246
  background: #e3edfd;
3240
3247
  }
3241
3248
 
3249
+ .custom-format-preview {
3250
+ display: flex;
3251
+ align-items: center;
3252
+ margin-top: 10px;
3253
+ padding: 6px 10px;
3254
+ background: #f5f6f7;
3255
+ border-radius: 2px;
3256
+ font-size: 12px;
3257
+ }
3258
+
3259
+ .custom-format-preview-title {
3260
+ color: #666;
3261
+ flex-shrink: 0;
3262
+ }
3263
+
3264
+ .custom-format-preview-origin {
3265
+ margin-left: 4px;
3266
+ color: #333;
3267
+ }
3268
+
3269
+ .custom-format-preview-arrow {
3270
+ margin: 0 8px;
3271
+ color: #999;
3272
+ }
3273
+
3274
+ .custom-format-preview-result {
3275
+ color: #1a73e8;
3276
+ font-weight: 600;
3277
+ word-break: break-all;
3278
+ }
3279
+
3280
+ .custom-format-preview-result.invalid {
3281
+ color: #d93025;
3282
+ font-weight: 400;
3283
+ }
3284
+
3242
3285
  .leankylin-fx-editor {
3243
3286
  display: flex;
3244
3287
  flex-direction: row;
package/dist/index.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import { defaultContext, defaultSettings, getSheetIndex, colLocationByIndex, fixPositionOnFrozenCells, colLocation, getFlowdata, isAllowEdit, handleColumnHeaderMouseDown, handleColSizeHandleMouseDown, handleColFreezeHandleMouseDown, handleContextMenu, selectTitlesMap, selectTitlesRange, fixColumnStyleOverflowInFreeze, rowLocationByIndex, rowLocation, handleRowHeaderMouseDown, handleRowSizeHandleMouseDown, handleRowFreezeHandleMouseDown, fixRowStyleOverflowInFreeze, functionHTMLGenerate, locale, getCellValue, createRangeHightlight, isInlineStringCell, getInlineStringHTML, valueShowEs, escapeHTMLTag, escapeScriptTag, isShowHidenCR, cancelNormalSelected, moveHighlightCell, updateCell, israngeseleciton, handleFormulaInput, onSearchDialogMoveStart, replaceAll, replace, searchAll, searchNext, changeSheet, normalizeSelection, scrollToHighlightCell, chatatABC, getCellHyperlink, isLinkValid, getRangetxt, goToLink, replaceHtml, removeHyperlink, onRangeSelectionModalMoveStart, saveHyperlink, createFilterOptions, onImageMoveStart, onImageResizeStart, showComments, setEditingComment, onCommentBoxMoveStart, onCommentBoxResizeStart, confirmMessage, getRangeByTxt, getDropdownList, setCellValue, setConditionRules, mergeBorder, setDropcownValue, handleCellAreaMouseDown, handleCellAreaMouseMove, handleCellAreaDragOver, handleCellDrop, handleCellAreaDoubleClick, selectAll, showLinkCard, getCellRowColumn, handleOverlayMouseMove, handleOverlayMouseUp, handleKeydownForZoom, handleOverlayTouchStart, handleOverlayTouchMove, handleOverlayTouchEnd, PAINT_MODEL_CURSOR, onCellsMoveStart, createDropCellRange, handleDropCellDoubleClick, updateContextWithSheetData, updateContextWithCanvas, initFreeze, Canvas, handleGlobalWheel, setCaretPosition, getDataArr, updateMoreCell, getRegStr, getOptionValue, getSelectRange, applyLocation, updateItem, normalizedCellAttr, updateFormat, handleTextSize, handleHorizontalAlign, handleVerticalAlign, handleScreenShot, showImgChooser, insertImage, editComment, deleteComment, showHideComment, showHideAllComments, newComment, handleSum, autoSelectionFormula, handleMerge, handleBorder, handleFreeze, handleSort, createFilter, clearFilter, toolbarItemSelectedFunc, toolbarItemClickHandler, handleTextColor, handleTextBackground, getDataBySelectionNoCopy, getInlineStringNoStyle, rangeHightlightselected, editSheetName, setNextSheet, MAX_ZOOM_RATIO, MIN_ZOOM_RATIO, addSheet, indexToColumnChar, sortSelection, handleCopy, insertRowCol, deleteRowCol, hideSelected, showSelected, api, removeActiveImage, deleteSelectedCellText, jfrefreshgrid, handleLink, deleteSheet, opToPatch, orderbydatafiler, getFilterColumnValues, getFilterColumnColors, saveFilter, cancelActiveImgItem, patchToOp, filterPatch, inverseRowColOptions, ensureSheetIndex, initSheetIndex, handleGlobalKeyDown, handlePasteByLeanklin, groupValuesRefresh } from '@leankylin-sheet/core';
1
+ import { defaultContext, defaultSettings, getSheetIndex, colLocationByIndex, fixPositionOnFrozenCells, colLocation, getFlowdata, isAllowEdit, handleColumnHeaderMouseDown, handleColSizeHandleMouseDown, handleColFreezeHandleMouseDown, handleContextMenu, selectTitlesMap, selectTitlesRange, fixColumnStyleOverflowInFreeze, rowLocationByIndex, rowLocation, handleRowHeaderMouseDown, handleRowSizeHandleMouseDown, handleRowFreezeHandleMouseDown, fixRowStyleOverflowInFreeze, functionHTMLGenerate, locale, getCellValue, createRangeHightlight, isInlineStringCell, getInlineStringHTML, valueShowEs, escapeHTMLTag, escapeScriptTag, isShowHidenCR, cancelNormalSelected, moveHighlightCell, updateCell, israngeseleciton, handleFormulaInput, onSearchDialogMoveStart, replaceAll, replace, searchAll, searchNext, changeSheet, normalizeSelection, scrollToHighlightCell, chatatABC, getCellHyperlink, isLinkValid, getRangetxt, goToLink, replaceHtml, removeHyperlink, onRangeSelectionModalMoveStart, saveHyperlink, createFilterOptions, onImageMoveStart, onImageResizeStart, showComments, setEditingComment, onCommentBoxMoveStart, onCommentBoxResizeStart, confirmMessage, getRangeByTxt, getDropdownList, setCellValue, setConditionRules, mergeBorder, setDropcownValue, handleCellAreaMouseDown, handleCellAreaMouseMove, handleCellAreaDragOver, handleCellDrop, handleCellAreaDoubleClick, selectAll, showLinkCard, getCellRowColumn, handleOverlayMouseMove, handleOverlayMouseUp, handleKeydownForZoom, handleOverlayTouchStart, handleOverlayTouchMove, handleOverlayTouchEnd, PAINT_MODEL_CURSOR, onCellsMoveStart, createDropCellRange, handleDropCellDoubleClick, updateContextWithSheetData, updateContextWithCanvas, initFreeze, Canvas, handleGlobalWheel, setCaretPosition, getDataArr, updateMoreCell, getRegStr, getOptionValue, getSelectRange, applyLocation, updateItem, normalizedCellAttr, update, updateFormat, handleTextSize, handleHorizontalAlign, handleVerticalAlign, handleScreenShot, showImgChooser, insertImage, editComment, deleteComment, showHideComment, showHideAllComments, newComment, handleSum, autoSelectionFormula, handleMerge, handleBorder, handleFreeze, handleSort, createFilter, clearFilter, toolbarItemSelectedFunc, toolbarItemClickHandler, handleTextColor, handleTextBackground, getDataBySelectionNoCopy, getInlineStringNoStyle, rangeHightlightselected, editSheetName, setNextSheet, MAX_ZOOM_RATIO, MIN_ZOOM_RATIO, addSheet, indexToColumnChar, sortSelection, handleCopy, insertRowCol, deleteRowCol, hideSelected, showSelected, api, removeActiveImage, deleteSelectedCellText, jfrefreshgrid, handleLink, deleteSheet, opToPatch, orderbydatafiler, getFilterColumnValues, getFilterColumnColors, saveFilter, cancelActiveImgItem, patchToOp, filterPatch, inverseRowColOptions, ensureSheetIndex, initSheetIndex, handleGlobalKeyDown, handlePasteByLeanklin, groupValuesRefresh } from '@leankylin-sheet/core';
2
2
  import { useInViewport, useMemoizedFn, useThrottleFn } from 'ahooks';
3
3
  import React, { useContext, useRef, useState, useMemo, useCallback, useEffect, useLayoutEffect, useImperativeHandle } from 'react';
4
4
  import produce, { applyPatches, enablePatches, produceWithPatches } from 'immer';
@@ -6507,22 +6507,44 @@ var CustomFormat = function CustomFormat(_ref) {
6507
6507
  var col = firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.column_focus;
6508
6508
  var cell = flowdata != null && row != null && col != null ? (_flowdata$row = flowdata[row]) === null || _flowdata$row === void 0 ? void 0 : _flowdata$row[col] : undefined;
6509
6509
  var ct = cell == null ? undefined : normalizedCellAttr(cell, "ct");
6510
- return (ct === null || ct === void 0 ? void 0 : ct.fa) != null && ct.fa !== "fmtOtherSelf" ? ct.fa : "#0.00";
6510
+ return {
6511
+ fa: (ct === null || ct === void 0 ? void 0 : ct.fa) != null && ct.fa !== "fmtOtherSelf" ? ct.fa : "#0.00",
6512
+ v: cell === null || cell === void 0 ? void 0 : cell.v
6513
+ };
6511
6514
  }),
6512
- _useState2 = _slicedToArray(_useState, 2),
6513
- formatStr = _useState2[0],
6514
- setFormatStr = _useState2[1];
6515
+ _useState2 = _slicedToArray(_useState, 1),
6516
+ initialState = _useState2[0];
6517
+ var _useState3 = useState(initialState.fa),
6518
+ _useState4 = _slicedToArray(_useState3, 2),
6519
+ formatStr = _useState4[0],
6520
+ setFormatStr = _useState4[1];
6515
6521
  var _locale = locale(context),
6516
6522
  button = _locale.button,
6517
6523
  format = _locale.format,
6518
6524
  defaultFmt = _locale.defaultFmt;
6519
6525
  var _useDialog = useDialog(),
6520
6526
  showDialog = _useDialog.showDialog;
6527
+ var _useState5 = useState(""),
6528
+ _useState6 = _slicedToArray(_useState5, 2),
6529
+ errorMsg = _useState6[0],
6530
+ setErrorMsg = _useState6[1];
6521
6531
  var presetFmtList = useMemo(function () {
6522
6532
  return defaultFmt.filter(function (v) {
6523
6533
  return v.value !== "split" && v.value !== "fmtOtherSelf";
6524
6534
  });
6525
6535
  }, [defaultFmt]);
6536
+ var previewValue = useMemo(function () {
6537
+ var fmt = formatStr.trim();
6538
+ var v = initialState.v;
6539
+ if (fmt === "" || fmt === "fmtOtherSelf" || v == null || v === "") {
6540
+ return "";
6541
+ }
6542
+ try {
6543
+ return update(fmt, v);
6544
+ } catch (error) {
6545
+ return "";
6546
+ }
6547
+ }, [formatStr, initialState]);
6526
6548
  var onConfirm = useCallback(function () {
6527
6549
  var fmt = formatStr.trim();
6528
6550
  if (fmt === "" || fmt === "fmtOtherSelf") {
@@ -6530,14 +6552,18 @@ var CustomFormat = function CustomFormat(_ref) {
6530
6552
  showDialog(format.tipCustomFormat, "ok");
6531
6553
  return;
6532
6554
  }
6533
- setContext(function (ctx) {
6534
- var d = getFlowdata(ctx);
6535
- if (d == null) return;
6536
- updateFormat(ctx, cellInput.current, d, "ct", fmt);
6537
- cancelNormalSelected(ctx);
6555
+ try {
6556
+ setContext(function (ctx) {
6557
+ var d = getFlowdata(ctx);
6558
+ if (d == null) return;
6559
+ updateFormat(ctx, cellInput.current, d, "ct", fmt);
6560
+ cancelNormalSelected(ctx);
6561
+ });
6538
6562
  _onCancel();
6539
- });
6540
- }, [_onCancel, cellInput, format.tipCustomFormat, formatStr, setContext, showDialog]);
6563
+ } catch (error) {
6564
+ setErrorMsg(format.tipUnsupportedFormat);
6565
+ }
6566
+ }, [_onCancel, cellInput, format.tipCustomFormat, format.tipUnsupportedFormat, formatStr, setContext, showDialog]);
6541
6567
  var onCancel = useCallback(function () {
6542
6568
  setContext(function (ctx) {
6543
6569
  cancelNormalSelected(ctx);
@@ -6564,10 +6590,23 @@ var CustomFormat = function CustomFormat(_ref) {
6564
6590
  placeholder: format.customFormatExample,
6565
6591
  value: formatStr,
6566
6592
  onChange: function onChange(e) {
6567
- return setFormatStr(e.target.value);
6593
+ setFormatStr(e.target.value);
6594
+ setErrorMsg("");
6568
6595
  },
6569
6596
  onKeyDown: onKeyDown
6570
- })), /*#__PURE__*/React.createElement("div", {
6597
+ })), errorMsg !== "" && ( /*#__PURE__*/React.createElement("div", {
6598
+ className: "custom-format-error"
6599
+ }, errorMsg)), initialState.v != null && initialState.v !== "" && ( /*#__PURE__*/React.createElement("div", {
6600
+ className: "custom-format-preview"
6601
+ }, /*#__PURE__*/React.createElement("span", {
6602
+ className: "custom-format-preview-title"
6603
+ }, format.customFormatPreview, "\uFF1A"), /*#__PURE__*/React.createElement("span", {
6604
+ className: "custom-format-preview-origin"
6605
+ }, String(initialState.v)), /*#__PURE__*/React.createElement("span", {
6606
+ className: "custom-format-preview-arrow"
6607
+ }, "\u2192"), /*#__PURE__*/React.createElement("span", {
6608
+ className: "custom-format-preview-result".concat(previewValue === "" ? " invalid" : "")
6609
+ }, previewValue === "" ? format.tipUnsupportedFormat : previewValue))), /*#__PURE__*/React.createElement("div", {
6571
6610
  className: "custom-format-list"
6572
6611
  }, /*#__PURE__*/React.createElement("div", {
6573
6612
  className: "custom-format-list-row custom-format-list-header"
package/dist/index.js CHANGED
@@ -6517,22 +6517,44 @@ var CustomFormat = function CustomFormat(_ref) {
6517
6517
  var col = firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.column_focus;
6518
6518
  var cell = flowdata != null && row != null && col != null ? (_flowdata$row = flowdata[row]) === null || _flowdata$row === void 0 ? void 0 : _flowdata$row[col] : undefined;
6519
6519
  var ct = cell == null ? undefined : core.normalizedCellAttr(cell, "ct");
6520
- return (ct === null || ct === void 0 ? void 0 : ct.fa) != null && ct.fa !== "fmtOtherSelf" ? ct.fa : "#0.00";
6520
+ return {
6521
+ fa: (ct === null || ct === void 0 ? void 0 : ct.fa) != null && ct.fa !== "fmtOtherSelf" ? ct.fa : "#0.00",
6522
+ v: cell === null || cell === void 0 ? void 0 : cell.v
6523
+ };
6521
6524
  }),
6522
- _useState2 = _slicedToArray(_useState, 2),
6523
- formatStr = _useState2[0],
6524
- setFormatStr = _useState2[1];
6525
+ _useState2 = _slicedToArray(_useState, 1),
6526
+ initialState = _useState2[0];
6527
+ var _useState3 = React.useState(initialState.fa),
6528
+ _useState4 = _slicedToArray(_useState3, 2),
6529
+ formatStr = _useState4[0],
6530
+ setFormatStr = _useState4[1];
6525
6531
  var _locale = core.locale(context),
6526
6532
  button = _locale.button,
6527
6533
  format = _locale.format,
6528
6534
  defaultFmt = _locale.defaultFmt;
6529
6535
  var _useDialog = useDialog(),
6530
6536
  showDialog = _useDialog.showDialog;
6537
+ var _useState5 = React.useState(""),
6538
+ _useState6 = _slicedToArray(_useState5, 2),
6539
+ errorMsg = _useState6[0],
6540
+ setErrorMsg = _useState6[1];
6531
6541
  var presetFmtList = React.useMemo(function () {
6532
6542
  return defaultFmt.filter(function (v) {
6533
6543
  return v.value !== "split" && v.value !== "fmtOtherSelf";
6534
6544
  });
6535
6545
  }, [defaultFmt]);
6546
+ var previewValue = React.useMemo(function () {
6547
+ var fmt = formatStr.trim();
6548
+ var v = initialState.v;
6549
+ if (fmt === "" || fmt === "fmtOtherSelf" || v == null || v === "") {
6550
+ return "";
6551
+ }
6552
+ try {
6553
+ return core.update(fmt, v);
6554
+ } catch (error) {
6555
+ return "";
6556
+ }
6557
+ }, [formatStr, initialState]);
6536
6558
  var onConfirm = React.useCallback(function () {
6537
6559
  var fmt = formatStr.trim();
6538
6560
  if (fmt === "" || fmt === "fmtOtherSelf") {
@@ -6540,14 +6562,18 @@ var CustomFormat = function CustomFormat(_ref) {
6540
6562
  showDialog(format.tipCustomFormat, "ok");
6541
6563
  return;
6542
6564
  }
6543
- setContext(function (ctx) {
6544
- var d = core.getFlowdata(ctx);
6545
- if (d == null) return;
6546
- core.updateFormat(ctx, cellInput.current, d, "ct", fmt);
6547
- core.cancelNormalSelected(ctx);
6565
+ try {
6566
+ setContext(function (ctx) {
6567
+ var d = core.getFlowdata(ctx);
6568
+ if (d == null) return;
6569
+ core.updateFormat(ctx, cellInput.current, d, "ct", fmt);
6570
+ core.cancelNormalSelected(ctx);
6571
+ });
6548
6572
  _onCancel();
6549
- });
6550
- }, [_onCancel, cellInput, format.tipCustomFormat, formatStr, setContext, showDialog]);
6573
+ } catch (error) {
6574
+ setErrorMsg(format.tipUnsupportedFormat);
6575
+ }
6576
+ }, [_onCancel, cellInput, format.tipCustomFormat, format.tipUnsupportedFormat, formatStr, setContext, showDialog]);
6551
6577
  var onCancel = React.useCallback(function () {
6552
6578
  setContext(function (ctx) {
6553
6579
  core.cancelNormalSelected(ctx);
@@ -6574,10 +6600,23 @@ var CustomFormat = function CustomFormat(_ref) {
6574
6600
  placeholder: format.customFormatExample,
6575
6601
  value: formatStr,
6576
6602
  onChange: function onChange(e) {
6577
- return setFormatStr(e.target.value);
6603
+ setFormatStr(e.target.value);
6604
+ setErrorMsg("");
6578
6605
  },
6579
6606
  onKeyDown: onKeyDown
6580
- })), /*#__PURE__*/React__default['default'].createElement("div", {
6607
+ })), errorMsg !== "" && ( /*#__PURE__*/React__default['default'].createElement("div", {
6608
+ className: "custom-format-error"
6609
+ }, errorMsg)), initialState.v != null && initialState.v !== "" && ( /*#__PURE__*/React__default['default'].createElement("div", {
6610
+ className: "custom-format-preview"
6611
+ }, /*#__PURE__*/React__default['default'].createElement("span", {
6612
+ className: "custom-format-preview-title"
6613
+ }, format.customFormatPreview, "\uFF1A"), /*#__PURE__*/React__default['default'].createElement("span", {
6614
+ className: "custom-format-preview-origin"
6615
+ }, String(initialState.v)), /*#__PURE__*/React__default['default'].createElement("span", {
6616
+ className: "custom-format-preview-arrow"
6617
+ }, "\u2192"), /*#__PURE__*/React__default['default'].createElement("span", {
6618
+ className: "custom-format-preview-result".concat(previewValue === "" ? " invalid" : "")
6619
+ }, previewValue === "" ? format.tipUnsupportedFormat : previewValue))), /*#__PURE__*/React__default['default'].createElement("div", {
6581
6620
  className: "custom-format-list"
6582
6621
  }, /*#__PURE__*/React__default['default'].createElement("div", {
6583
6622
  className: "custom-format-list-row custom-format-list-header"
@@ -3202,8 +3202,15 @@ label {
3202
3202
  border-color: #1a73e8;
3203
3203
  }
3204
3204
 
3205
+ .custom-format-error {
3206
+ margin-top: 6px;
3207
+ color: #d93025;
3208
+ font-size: 12px;
3209
+ line-height: 16px;
3210
+ }
3211
+
3205
3212
  .custom-format-list {
3206
- margin-top: 12px;
3213
+ margin-top: 10px;
3207
3214
  border: 1px solid #d4d4d4;
3208
3215
  border-radius: 2px;
3209
3216
  font-size: 12px;
@@ -3239,6 +3246,42 @@ label {
3239
3246
  background: #e3edfd;
3240
3247
  }
3241
3248
 
3249
+ .custom-format-preview {
3250
+ display: flex;
3251
+ align-items: center;
3252
+ margin-top: 10px;
3253
+ padding: 6px 10px;
3254
+ background: #f5f6f7;
3255
+ border-radius: 2px;
3256
+ font-size: 12px;
3257
+ }
3258
+
3259
+ .custom-format-preview-title {
3260
+ color: #666;
3261
+ flex-shrink: 0;
3262
+ }
3263
+
3264
+ .custom-format-preview-origin {
3265
+ margin-left: 4px;
3266
+ color: #333;
3267
+ }
3268
+
3269
+ .custom-format-preview-arrow {
3270
+ margin: 0 8px;
3271
+ color: #999;
3272
+ }
3273
+
3274
+ .custom-format-preview-result {
3275
+ color: #1a73e8;
3276
+ font-weight: 600;
3277
+ word-break: break-all;
3278
+ }
3279
+
3280
+ .custom-format-preview-result.invalid {
3281
+ color: #d93025;
3282
+ font-weight: 400;
3283
+ }
3284
+
3242
3285
  .leankylin-fx-editor {
3243
3286
  display: flex;
3244
3287
  flex-direction: row;
package/dist/index.umd.js CHANGED
@@ -25591,22 +25591,44 @@
25591
25591
  var col = firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.column_focus;
25592
25592
  var cell = flowdata != null && row != null && col != null ? (_flowdata$row = flowdata[row]) === null || _flowdata$row === void 0 ? void 0 : _flowdata$row[col] : undefined;
25593
25593
  var ct = cell == null ? undefined : core.normalizedCellAttr(cell, "ct");
25594
- return (ct === null || ct === void 0 ? void 0 : ct.fa) != null && ct.fa !== "fmtOtherSelf" ? ct.fa : "#0.00";
25594
+ return {
25595
+ fa: (ct === null || ct === void 0 ? void 0 : ct.fa) != null && ct.fa !== "fmtOtherSelf" ? ct.fa : "#0.00",
25596
+ v: cell === null || cell === void 0 ? void 0 : cell.v
25597
+ };
25595
25598
  }),
25596
- _useState2 = _slicedToArray(_useState, 2),
25597
- formatStr = _useState2[0],
25598
- setFormatStr = _useState2[1];
25599
+ _useState2 = _slicedToArray(_useState, 1),
25600
+ initialState = _useState2[0];
25601
+ var _useState3 = React.useState(initialState.fa),
25602
+ _useState4 = _slicedToArray(_useState3, 2),
25603
+ formatStr = _useState4[0],
25604
+ setFormatStr = _useState4[1];
25599
25605
  var _locale = core.locale(context),
25600
25606
  button = _locale.button,
25601
25607
  format = _locale.format,
25602
25608
  defaultFmt = _locale.defaultFmt;
25603
25609
  var _useDialog = useDialog(),
25604
25610
  showDialog = _useDialog.showDialog;
25611
+ var _useState5 = React.useState(""),
25612
+ _useState6 = _slicedToArray(_useState5, 2),
25613
+ errorMsg = _useState6[0],
25614
+ setErrorMsg = _useState6[1];
25605
25615
  var presetFmtList = React.useMemo(function () {
25606
25616
  return defaultFmt.filter(function (v) {
25607
25617
  return v.value !== "split" && v.value !== "fmtOtherSelf";
25608
25618
  });
25609
25619
  }, [defaultFmt]);
25620
+ var previewValue = React.useMemo(function () {
25621
+ var fmt = formatStr.trim();
25622
+ var v = initialState.v;
25623
+ if (fmt === "" || fmt === "fmtOtherSelf" || v == null || v === "") {
25624
+ return "";
25625
+ }
25626
+ try {
25627
+ return core.update(fmt, v);
25628
+ } catch (error) {
25629
+ return "";
25630
+ }
25631
+ }, [formatStr, initialState]);
25610
25632
  var onConfirm = React.useCallback(function () {
25611
25633
  var fmt = formatStr.trim();
25612
25634
  if (fmt === "" || fmt === "fmtOtherSelf") {
@@ -25614,14 +25636,18 @@
25614
25636
  showDialog(format.tipCustomFormat, "ok");
25615
25637
  return;
25616
25638
  }
25617
- setContext(function (ctx) {
25618
- var d = core.getFlowdata(ctx);
25619
- if (d == null) return;
25620
- core.updateFormat(ctx, cellInput.current, d, "ct", fmt);
25621
- core.cancelNormalSelected(ctx);
25639
+ try {
25640
+ setContext(function (ctx) {
25641
+ var d = core.getFlowdata(ctx);
25642
+ if (d == null) return;
25643
+ core.updateFormat(ctx, cellInput.current, d, "ct", fmt);
25644
+ core.cancelNormalSelected(ctx);
25645
+ });
25622
25646
  _onCancel();
25623
- });
25624
- }, [_onCancel, cellInput, format.tipCustomFormat, formatStr, setContext, showDialog]);
25647
+ } catch (error) {
25648
+ setErrorMsg(format.tipUnsupportedFormat);
25649
+ }
25650
+ }, [_onCancel, cellInput, format.tipCustomFormat, format.tipUnsupportedFormat, formatStr, setContext, showDialog]);
25625
25651
  var onCancel = React.useCallback(function () {
25626
25652
  setContext(function (ctx) {
25627
25653
  core.cancelNormalSelected(ctx);
@@ -25648,10 +25674,23 @@
25648
25674
  placeholder: format.customFormatExample,
25649
25675
  value: formatStr,
25650
25676
  onChange: function onChange(e) {
25651
- return setFormatStr(e.target.value);
25677
+ setFormatStr(e.target.value);
25678
+ setErrorMsg("");
25652
25679
  },
25653
25680
  onKeyDown: onKeyDown
25654
- })), /*#__PURE__*/React__default['default'].createElement("div", {
25681
+ })), errorMsg !== "" && ( /*#__PURE__*/React__default['default'].createElement("div", {
25682
+ className: "custom-format-error"
25683
+ }, errorMsg)), initialState.v != null && initialState.v !== "" && ( /*#__PURE__*/React__default['default'].createElement("div", {
25684
+ className: "custom-format-preview"
25685
+ }, /*#__PURE__*/React__default['default'].createElement("span", {
25686
+ className: "custom-format-preview-title"
25687
+ }, format.customFormatPreview, "\uFF1A"), /*#__PURE__*/React__default['default'].createElement("span", {
25688
+ className: "custom-format-preview-origin"
25689
+ }, String(initialState.v)), /*#__PURE__*/React__default['default'].createElement("span", {
25690
+ className: "custom-format-preview-arrow"
25691
+ }, "\u2192"), /*#__PURE__*/React__default['default'].createElement("span", {
25692
+ className: "custom-format-preview-result".concat(previewValue === "" ? " invalid" : "")
25693
+ }, previewValue === "" ? format.tipUnsupportedFormat : previewValue))), /*#__PURE__*/React__default['default'].createElement("div", {
25655
25694
  className: "custom-format-list"
25656
25695
  }, /*#__PURE__*/React__default['default'].createElement("div", {
25657
25696
  className: "custom-format-list-row custom-format-list-header"