@univerjs/sheets-numfmt 1.3.0 → 1.4.0
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/lib/cjs/facade.js +2 -5
- package/lib/cjs/index.js +48 -60
- package/lib/es/facade.js +2 -4
- package/lib/es/index.js +49 -61
- package/lib/facade.js +2 -4
- package/lib/index.js +49 -61
- package/lib/types/controllers/numfmt-cell-content.controller.d.ts +2 -0
- package/lib/types/controllers/type.d.ts +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +9 -9
package/lib/cjs/facade.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
let _univerjs_sheets_numfmt = require("@univerjs/sheets-numfmt");
|
|
2
2
|
let _univerjs_sheets_facade = require("@univerjs/sheets/facade");
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/facade/f-range.ts
|
|
5
5
|
var FRangeSheetsNumfmtMixin = class extends _univerjs_sheets_facade.FRange {
|
|
6
6
|
setNumberFormat(pattern) {
|
|
7
7
|
const values = [];
|
|
@@ -51,8 +51,7 @@ var FRangeSheetsNumfmtMixin = class extends _univerjs_sheets_facade.FRange {
|
|
|
51
51
|
};
|
|
52
52
|
_univerjs_sheets_facade.FRange.extend(FRangeSheetsNumfmtMixin);
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
//#region src/facade/f-workbook.ts
|
|
54
|
+
// src/facade/f-workbook.ts
|
|
56
55
|
var FWorkbookSheetsNumfmtMixin = class extends _univerjs_sheets_facade.FWorkbook {
|
|
57
56
|
setNumfmtLocal(locale) {
|
|
58
57
|
this._injector.get(_univerjs_sheets_numfmt.SheetsNumfmtCellContentController).setNumfmtLocal(locale);
|
|
@@ -60,5 +59,3 @@ var FWorkbookSheetsNumfmtMixin = class extends _univerjs_sheets_facade.FWorkbook
|
|
|
60
59
|
}
|
|
61
60
|
};
|
|
62
61
|
_univerjs_sheets_facade.FWorkbook.extend(FWorkbookSheetsNumfmtMixin);
|
|
63
|
-
|
|
64
|
-
//#endregion
|
package/lib/cjs/index.js
CHANGED
|
@@ -4,7 +4,7 @@ let _univerjs_sheets = require("@univerjs/sheets");
|
|
|
4
4
|
let _univerjs_engine_formula = require("@univerjs/engine-formula");
|
|
5
5
|
let rxjs = require("rxjs");
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
// src/base/const/currency-symbols.ts
|
|
8
8
|
/**
|
|
9
9
|
* Copyright 2023-present DreamNum Co., Ltd.
|
|
10
10
|
*
|
|
@@ -121,8 +121,7 @@ function getCurrencyFormat(locale, numberDigits = 2) {
|
|
|
121
121
|
return `"${getCurrencySymbolByLocale(locale)}"#,##0${decimal}_);[Red]("${getCurrencySymbolByLocale(locale)}"#,##0${decimal})`;
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
-
|
|
125
|
-
//#region src/base/const/formatdetail.ts
|
|
124
|
+
// src/base/const/formatdetail.ts
|
|
126
125
|
/**
|
|
127
126
|
* Copyright 2023-present DreamNum Co., Ltd.
|
|
128
127
|
*
|
|
@@ -243,8 +242,7 @@ const CURRENCYFORMAT = [
|
|
|
243
242
|
}
|
|
244
243
|
];
|
|
245
244
|
|
|
246
|
-
|
|
247
|
-
//#region src/utils/decimal.ts
|
|
245
|
+
// src/utils/decimal.ts
|
|
248
246
|
/**
|
|
249
247
|
* Copyright 2023-present DreamNum Co., Ltd.
|
|
250
248
|
*
|
|
@@ -277,8 +275,7 @@ const setPatternDecimal = (patterns, decimalLength) => {
|
|
|
277
275
|
};
|
|
278
276
|
const isPatternHasDecimal = (pattern) => /\.0?/.test(pattern) || /0([^0]?)|0$/.test(pattern);
|
|
279
277
|
|
|
280
|
-
|
|
281
|
-
//#region src/utils/pattern.ts
|
|
278
|
+
// src/utils/pattern.ts
|
|
282
279
|
const getPatternType = (pattern) => {
|
|
283
280
|
const type = _univerjs_core.numfmt.getFormatInfo(pattern).type || "unknown";
|
|
284
281
|
if (type === "general" && _univerjs_core.numfmt.tokenize(pattern).some((token) => token.type === _univerjs_core.numfmt.tokenTypes.CONDITION)) return "number";
|
|
@@ -306,8 +303,7 @@ const getPatternPreviewIgnoreGeneral = (pattern, value, locale, dateSystem) => {
|
|
|
306
303
|
return getPatternPreview(pattern, value, locale, dateSystem);
|
|
307
304
|
};
|
|
308
305
|
|
|
309
|
-
|
|
310
|
-
//#region src/utils/scientific-notation.ts
|
|
306
|
+
// src/utils/scientific-notation.ts
|
|
311
307
|
function isScientificNotationNumericCell(cell) {
|
|
312
308
|
return (cell === null || cell === void 0 ? void 0 : cell.t) === _univerjs_core.CellValueType.NUMBER && cell.v !== void 0 && cell.v !== null && /e/i.test(String(cell.v));
|
|
313
309
|
}
|
|
@@ -322,8 +318,7 @@ function isAllowedPatternForScientificNotationNumber(pattern) {
|
|
|
322
318
|
return (0, _univerjs_core.isDefaultFormat)(pattern) || (0, _univerjs_core.isTextFormat)(pattern) || getPatternType(pattern) === "scientific";
|
|
323
319
|
}
|
|
324
320
|
|
|
325
|
-
|
|
326
|
-
//#region src/commands/commands/set-numfmt.command.ts
|
|
321
|
+
// src/commands/commands/set-numfmt.command.ts
|
|
327
322
|
const SetNumfmtCommand = {
|
|
328
323
|
id: "sheet.command.numfmt.set.numfmt",
|
|
329
324
|
type: _univerjs_core.CommandType.COMMAND,
|
|
@@ -429,8 +424,7 @@ const SetNumfmtCommand = {
|
|
|
429
424
|
}
|
|
430
425
|
};
|
|
431
426
|
|
|
432
|
-
|
|
433
|
-
//#region src/commands/commands/add-decimal.command.ts
|
|
427
|
+
// src/commands/commands/add-decimal.command.ts
|
|
434
428
|
const AddDecimalCommand = {
|
|
435
429
|
id: "sheet.command.numfmt.add.decimal.command",
|
|
436
430
|
type: _univerjs_core.CommandType.COMMAND,
|
|
@@ -497,8 +491,7 @@ const AddDecimalCommand = {
|
|
|
497
491
|
}
|
|
498
492
|
};
|
|
499
493
|
|
|
500
|
-
|
|
501
|
-
//#region src/commands/commands/set-currency.command.ts
|
|
494
|
+
// src/commands/commands/set-currency.command.ts
|
|
502
495
|
/**
|
|
503
496
|
* This command is triggered by clicking the currency symbol icon in the menu.
|
|
504
497
|
* So the currency format is determined by the currency symbol icon.
|
|
@@ -529,8 +522,7 @@ const SetCurrencyCommand = {
|
|
|
529
522
|
}
|
|
530
523
|
};
|
|
531
524
|
|
|
532
|
-
|
|
533
|
-
//#region src/commands/commands/set-percent.command.ts
|
|
525
|
+
// src/commands/commands/set-percent.command.ts
|
|
534
526
|
const SetPercentCommand = {
|
|
535
527
|
id: "sheet.command.numfmt.set.percent",
|
|
536
528
|
type: _univerjs_core.CommandType.COMMAND,
|
|
@@ -554,8 +546,7 @@ const SetPercentCommand = {
|
|
|
554
546
|
}
|
|
555
547
|
};
|
|
556
548
|
|
|
557
|
-
|
|
558
|
-
//#region src/commands/commands/subtract-decimal.command.ts
|
|
549
|
+
// src/commands/commands/subtract-decimal.command.ts
|
|
559
550
|
const SubtractDecimalCommand = {
|
|
560
551
|
id: "sheet.command.numfmt.subtract.decimal.command",
|
|
561
552
|
type: _univerjs_core.CommandType.COMMAND,
|
|
@@ -620,8 +611,7 @@ const SubtractDecimalCommand = {
|
|
|
620
611
|
}
|
|
621
612
|
};
|
|
622
613
|
|
|
623
|
-
|
|
624
|
-
//#region src/config/config.ts
|
|
614
|
+
// src/config/config.ts
|
|
625
615
|
/**
|
|
626
616
|
* Copyright 2023-present DreamNum Co., Ltd.
|
|
627
617
|
*
|
|
@@ -641,8 +631,7 @@ const SHEETS_NUMFMT_PLUGIN_CONFIG_KEY = "sheets-numfmt.config";
|
|
|
641
631
|
const configSymbol = Symbol(SHEETS_NUMFMT_PLUGIN_CONFIG_KEY);
|
|
642
632
|
const defaultPluginConfig = {};
|
|
643
633
|
|
|
644
|
-
|
|
645
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/typeof.js
|
|
634
|
+
// \0@oxc-project+runtime@0.156.0/helpers/esm/typeof.js
|
|
646
635
|
function _typeof(o) {
|
|
647
636
|
"@babel/helpers - typeof";
|
|
648
637
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -652,8 +641,7 @@ function _typeof(o) {
|
|
|
652
641
|
}, _typeof(o);
|
|
653
642
|
}
|
|
654
643
|
|
|
655
|
-
|
|
656
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPrimitive.js
|
|
644
|
+
// \0@oxc-project+runtime@0.156.0/helpers/esm/toPrimitive.js
|
|
657
645
|
function toPrimitive(t, r) {
|
|
658
646
|
if ("object" != _typeof(t) || !t) return t;
|
|
659
647
|
var e = t[Symbol.toPrimitive];
|
|
@@ -665,15 +653,13 @@ function toPrimitive(t, r) {
|
|
|
665
653
|
return ("string" === r ? String : Number)(t);
|
|
666
654
|
}
|
|
667
655
|
|
|
668
|
-
|
|
669
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPropertyKey.js
|
|
656
|
+
// \0@oxc-project+runtime@0.156.0/helpers/esm/toPropertyKey.js
|
|
670
657
|
function toPropertyKey(t) {
|
|
671
658
|
var i = toPrimitive(t, "string");
|
|
672
659
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
673
660
|
}
|
|
674
661
|
|
|
675
|
-
|
|
676
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/defineProperty.js
|
|
662
|
+
// \0@oxc-project+runtime@0.156.0/helpers/esm/defineProperty.js
|
|
677
663
|
function _defineProperty(e, r, t) {
|
|
678
664
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
679
665
|
value: t,
|
|
@@ -683,16 +669,14 @@ function _defineProperty(e, r, t) {
|
|
|
683
669
|
}) : e[r] = t, e;
|
|
684
670
|
}
|
|
685
671
|
|
|
686
|
-
|
|
687
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorateParam.js
|
|
672
|
+
// \0@oxc-project+runtime@0.156.0/helpers/esm/decorateParam.js
|
|
688
673
|
function __decorateParam(paramIndex, decorator) {
|
|
689
674
|
return function(target, key) {
|
|
690
675
|
decorator(target, key, paramIndex);
|
|
691
676
|
};
|
|
692
677
|
}
|
|
693
678
|
|
|
694
|
-
|
|
695
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorate.js
|
|
679
|
+
// \0@oxc-project+runtime@0.156.0/helpers/esm/decorate.js
|
|
696
680
|
function __decorate(decorators, target, key, desc) {
|
|
697
681
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
698
682
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -700,8 +684,7 @@ function __decorate(decorators, target, key, desc) {
|
|
|
700
684
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
701
685
|
}
|
|
702
686
|
|
|
703
|
-
|
|
704
|
-
//#region src/controllers/numfmt-cell-content.controller.ts
|
|
687
|
+
// src/controllers/numfmt-cell-content.controller.ts
|
|
705
688
|
const TEXT_FORMAT_MARK = { tl: {
|
|
706
689
|
size: 6,
|
|
707
690
|
color: "#409f11"
|
|
@@ -755,26 +738,28 @@ let SheetsNumfmtCellContentController = class SheetsNumfmtCellContentController
|
|
|
755
738
|
}));
|
|
756
739
|
this.disposeWithMe(this._instanceService.getCurrentTypeOfUnit$(_univerjs_core.UniverInstanceType.UNIVER_SHEET).pipe((0, rxjs.switchMap)((workbook) => (workbook === null || workbook === void 0 ? void 0 : workbook.activeSheet$) ?? (0, rxjs.of)(null)), (0, rxjs.skip)(1)).subscribe(() => this._renderCache.reset()));
|
|
757
740
|
}
|
|
741
|
+
_getNumfmtValue(cell, location) {
|
|
742
|
+
var _cell$themeStyle, _workbook$getStyles$g2;
|
|
743
|
+
const { unitId, subUnitId: sheetId, row, col, workbook } = location;
|
|
744
|
+
const tableDxfNumfmt = (_cell$themeStyle = cell.themeStyle) === null || _cell$themeStyle === void 0 ? void 0 : _cell$themeStyle.n;
|
|
745
|
+
if (tableDxfNumfmt === void 0) {
|
|
746
|
+
var _workbook$getStyles$g;
|
|
747
|
+
return ((_workbook$getStyles$g = workbook.getStyles().get(cell.s)) === null || _workbook$getStyles$g === void 0 ? void 0 : _workbook$getStyles$g.n) ?? this._numfmtService.getValue(unitId, sheetId, row, col);
|
|
748
|
+
}
|
|
749
|
+
const directNumfmt = (_workbook$getStyles$g2 = workbook.getStyles().getStyleByCell(cell)) === null || _workbook$getStyles$g2 === void 0 ? void 0 : _workbook$getStyles$g2.n;
|
|
750
|
+
return directNumfmt !== void 0 ? directNumfmt : this._numfmtService.getValue(unitId, sheetId, row, col) ?? tableDxfNumfmt;
|
|
751
|
+
}
|
|
758
752
|
_formatCell(cell, location) {
|
|
759
|
-
var _workbook$getStyles$g;
|
|
760
753
|
if (!cell || cell.v == null || cell.t === _univerjs_core.CellValueType.BOOLEAN || cell.t === _univerjs_core.CellValueType.FORCE_STRING) return cell;
|
|
761
754
|
const { unitId, subUnitId: sheetId, row, col, workbook } = location;
|
|
762
755
|
const locale = this.getLocale(workbook);
|
|
763
756
|
const dateSystem = workbook.getDateSystem();
|
|
764
|
-
const numfmtValue =
|
|
757
|
+
const numfmtValue = this._getNumfmtValue(cell, location);
|
|
765
758
|
const pattern = numfmtValue === null || numfmtValue === void 0 ? void 0 : numfmtValue.pattern;
|
|
766
759
|
if ((0, _univerjs_core.isDefaultFormat)(pattern)) return cell;
|
|
767
760
|
if (!this._isNumericCell(cell, pattern, locale, dateSystem)) return cell;
|
|
768
761
|
const formattedCell = cell === location.rawData ? { ...cell } : cell;
|
|
769
|
-
if ((0, _univerjs_core.isTextFormat)(pattern))
|
|
770
|
-
var _this$_configService$;
|
|
771
|
-
formattedCell.t = _univerjs_core.CellValueType.STRING;
|
|
772
|
-
if (!((_this$_configService$ = this._configService.getConfig("sheets-numfmt.config")) === null || _this$_configService$ === void 0 ? void 0 : _this$_configService$.disableTextFormatMark)) formattedCell.markers = {
|
|
773
|
-
...formattedCell.markers,
|
|
774
|
-
...TEXT_FORMAT_MARK
|
|
775
|
-
};
|
|
776
|
-
return formattedCell;
|
|
777
|
-
}
|
|
762
|
+
if ((0, _univerjs_core.isTextFormat)(pattern)) return this._formatTextCell(cell, formattedCell);
|
|
778
763
|
const cacheParameters = `${unitId}_${sheetId}_${cell.v}_${pattern}_${locale}_${dateSystem}`;
|
|
779
764
|
const cache = this._renderCache.getValue(row, col);
|
|
780
765
|
if (cache && cache.parameters === cacheParameters) return {
|
|
@@ -798,6 +783,16 @@ let SheetsNumfmtCellContentController = class SheetsNumfmtCellContentController
|
|
|
798
783
|
Object.assign(formattedCell, res);
|
|
799
784
|
return formattedCell;
|
|
800
785
|
}
|
|
786
|
+
_formatTextCell(cell, formattedCell) {
|
|
787
|
+
var _this$_configService$;
|
|
788
|
+
if (cell.t === _univerjs_core.CellValueType.NUMBER && (0, _univerjs_core.isRealNum)(formattedCell.v)) formattedCell.v = (0, _univerjs_engine_formula.stripErrorMargin)(Number(formattedCell.v));
|
|
789
|
+
else formattedCell.t = _univerjs_core.CellValueType.STRING;
|
|
790
|
+
if (!((_this$_configService$ = this._configService.getConfig("sheets-numfmt.config")) === null || _this$_configService$ === void 0 ? void 0 : _this$_configService$.disableTextFormatMark)) formattedCell.markers = {
|
|
791
|
+
...formattedCell.markers,
|
|
792
|
+
...TEXT_FORMAT_MARK
|
|
793
|
+
};
|
|
794
|
+
return formattedCell;
|
|
795
|
+
}
|
|
801
796
|
_isNumericCell(cell, pattern, locale, dateSystem) {
|
|
802
797
|
var _getNumfmtParseValueF;
|
|
803
798
|
return cell.t === _univerjs_core.CellValueType.NUMBER || (0, _univerjs_sheets.checkCellValueType)(cell.v, cell.t) === _univerjs_core.CellValueType.NUMBER || (0, _univerjs_core.isTextFormat)(pattern) && typeof cell.v === "string" && typeof ((_getNumfmtParseValueF = (0, _univerjs_core.getNumfmtParseValueFilter)(cell.v, {
|
|
@@ -819,13 +814,11 @@ SheetsNumfmtCellContentController = __decorate([
|
|
|
819
814
|
__decorateParam(6, _univerjs_core.IConfigService)
|
|
820
815
|
], SheetsNumfmtCellContentController);
|
|
821
816
|
|
|
822
|
-
|
|
823
|
-
//#region package.json
|
|
817
|
+
// package.json
|
|
824
818
|
var name = "@univerjs/sheets-numfmt";
|
|
825
|
-
var version = "1.
|
|
819
|
+
var version = "1.4.0";
|
|
826
820
|
|
|
827
|
-
|
|
828
|
-
//#region src/base/const/plugin-name.ts
|
|
821
|
+
// src/base/const/plugin-name.ts
|
|
829
822
|
/**
|
|
830
823
|
* Copyright 2023-present DreamNum Co., Ltd.
|
|
831
824
|
*
|
|
@@ -843,8 +836,7 @@ var version = "1.3.0";
|
|
|
843
836
|
*/
|
|
844
837
|
const SHEET_NUMFMT_PLUGIN = "SHEET_NUMFMT_PLUGIN";
|
|
845
838
|
|
|
846
|
-
|
|
847
|
-
//#region src/plugin.ts
|
|
839
|
+
// src/plugin.ts
|
|
848
840
|
let UniverSheetsNumfmtPlugin = class UniverSheetsNumfmtPlugin extends _univerjs_core.Plugin {
|
|
849
841
|
constructor(_config = defaultPluginConfig, _injector, _configService, _commandService) {
|
|
850
842
|
super();
|
|
@@ -880,8 +872,7 @@ UniverSheetsNumfmtPlugin = __decorate([
|
|
|
880
872
|
__decorateParam(3, _univerjs_core.ICommandService)
|
|
881
873
|
], UniverSheetsNumfmtPlugin);
|
|
882
874
|
|
|
883
|
-
|
|
884
|
-
//#region src/utils/currency.ts
|
|
875
|
+
// src/utils/currency.ts
|
|
885
876
|
/**
|
|
886
877
|
* Copyright 2023-present DreamNum Co., Ltd.
|
|
887
878
|
*
|
|
@@ -901,8 +892,7 @@ const getCurrencyType = (pattern) => {
|
|
|
901
892
|
return _univerjs_core.currencySymbols.find((code) => pattern.includes(code));
|
|
902
893
|
};
|
|
903
894
|
|
|
904
|
-
|
|
905
|
-
//#region src/base/const/date-format.ts
|
|
895
|
+
// src/base/const/date-format.ts
|
|
906
896
|
/**
|
|
907
897
|
* Copyright 2023-present DreamNum Co., Ltd.
|
|
908
898
|
*
|
|
@@ -1027,8 +1017,7 @@ function getDateFormatPatterns(locale) {
|
|
|
1027
1017
|
])];
|
|
1028
1018
|
}
|
|
1029
1019
|
|
|
1030
|
-
|
|
1031
|
-
//#region src/utils/options.ts
|
|
1020
|
+
// src/utils/options.ts
|
|
1032
1021
|
const getCurrencyOptions = () => _univerjs_core.currencySymbols.map((item) => ({
|
|
1033
1022
|
label: item,
|
|
1034
1023
|
value: item
|
|
@@ -1058,7 +1047,6 @@ const getNumberFormatOptions = () => NUMBERFORMAT.map((item) => ({
|
|
|
1058
1047
|
color: item.color
|
|
1059
1048
|
}));
|
|
1060
1049
|
|
|
1061
|
-
//#endregion
|
|
1062
1050
|
exports.AddDecimalCommand = AddDecimalCommand;
|
|
1063
1051
|
exports.CURRENCYFORMAT = CURRENCYFORMAT;
|
|
1064
1052
|
exports.DATEFMTLISG = DATEFMTLISG;
|
package/lib/es/facade.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SetNumfmtCommand, SheetsNumfmtCellContentController } from "@univerjs/sheets-numfmt";
|
|
2
2
|
import { FRange, FWorkbook } from "@univerjs/sheets/facade";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/facade/f-range.ts
|
|
5
5
|
var FRangeSheetsNumfmtMixin = class extends FRange {
|
|
6
6
|
setNumberFormat(pattern) {
|
|
7
7
|
const values = [];
|
|
@@ -51,8 +51,7 @@ var FRangeSheetsNumfmtMixin = class extends FRange {
|
|
|
51
51
|
};
|
|
52
52
|
FRange.extend(FRangeSheetsNumfmtMixin);
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
//#region src/facade/f-workbook.ts
|
|
54
|
+
// src/facade/f-workbook.ts
|
|
56
55
|
var FWorkbookSheetsNumfmtMixin = class extends FWorkbook {
|
|
57
56
|
setNumfmtLocal(locale) {
|
|
58
57
|
this._injector.get(SheetsNumfmtCellContentController).setNumfmtLocal(locale);
|
|
@@ -61,5 +60,4 @@ var FWorkbookSheetsNumfmtMixin = class extends FWorkbook {
|
|
|
61
60
|
};
|
|
62
61
|
FWorkbook.extend(FWorkbookSheetsNumfmtMixin);
|
|
63
62
|
|
|
64
|
-
//#endregion
|
|
65
63
|
export { };
|
package/lib/es/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { CellValueType, CommandType, DEFAULT_NUMBER_FORMAT, DependentOn, Disposable, ICommandService, IConfigService, IUndoRedoService, IUniverInstanceService, Inject, Injector, InterceptorEffectEnum, LocaleService, LocaleType, ObjectMatrix, Plugin, Range, RegionService, ThemeService, UniverInstanceType, currencySymbols, excelDateTimeSerial, getNumfmtLocaleTag, getNumfmtParseValueFilter, isDefaultFormat, isTextFormat, merge, numfmt, registerDependencies, sequenceExecute, touchDependencies } from "@univerjs/core";
|
|
1
|
+
import { CellValueType, CommandType, DEFAULT_NUMBER_FORMAT, DependentOn, Disposable, ICommandService, IConfigService, IUndoRedoService, IUniverInstanceService, Inject, Injector, InterceptorEffectEnum, LocaleService, LocaleType, ObjectMatrix, Plugin, Range, RegionService, ThemeService, UniverInstanceType, currencySymbols, excelDateTimeSerial, getNumfmtLocaleTag, getNumfmtParseValueFilter, isDefaultFormat, isRealNum, isTextFormat, merge, numfmt, registerDependencies, sequenceExecute, touchDependencies } from "@univerjs/core";
|
|
2
2
|
import { INTERCEPTOR_POINT, INumfmtService, InterceptCellContentPriority, RemoveNumfmtMutation, SetNumfmtMutation, SetRangeValuesMutation, SheetInterceptorService, SheetsSelectionsService, UniverSheetsPlugin, checkCellValueType, factoryRemoveNumfmtUndoMutation, factorySetNumfmtUndoMutation, getSheetCommandTarget, rangeMerge, transformCellsToRange } from "@univerjs/sheets";
|
|
3
3
|
import { stripErrorMargin } from "@univerjs/engine-formula";
|
|
4
4
|
import { BehaviorSubject, merge as merge$1, of, skip, switchMap } from "rxjs";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
// src/base/const/currency-symbols.ts
|
|
7
7
|
/**
|
|
8
8
|
* Copyright 2023-present DreamNum Co., Ltd.
|
|
9
9
|
*
|
|
@@ -120,8 +120,7 @@ function getCurrencyFormat(locale, numberDigits = 2) {
|
|
|
120
120
|
return `"${getCurrencySymbolByLocale(locale)}"#,##0${decimal}_);[Red]("${getCurrencySymbolByLocale(locale)}"#,##0${decimal})`;
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
|
|
124
|
-
//#region src/base/const/formatdetail.ts
|
|
123
|
+
// src/base/const/formatdetail.ts
|
|
125
124
|
/**
|
|
126
125
|
* Copyright 2023-present DreamNum Co., Ltd.
|
|
127
126
|
*
|
|
@@ -242,8 +241,7 @@ const CURRENCYFORMAT = [
|
|
|
242
241
|
}
|
|
243
242
|
];
|
|
244
243
|
|
|
245
|
-
|
|
246
|
-
//#region src/utils/decimal.ts
|
|
244
|
+
// src/utils/decimal.ts
|
|
247
245
|
/**
|
|
248
246
|
* Copyright 2023-present DreamNum Co., Ltd.
|
|
249
247
|
*
|
|
@@ -276,8 +274,7 @@ const setPatternDecimal = (patterns, decimalLength) => {
|
|
|
276
274
|
};
|
|
277
275
|
const isPatternHasDecimal = (pattern) => /\.0?/.test(pattern) || /0([^0]?)|0$/.test(pattern);
|
|
278
276
|
|
|
279
|
-
|
|
280
|
-
//#region src/utils/pattern.ts
|
|
277
|
+
// src/utils/pattern.ts
|
|
281
278
|
const getPatternType = (pattern) => {
|
|
282
279
|
const type = numfmt.getFormatInfo(pattern).type || "unknown";
|
|
283
280
|
if (type === "general" && numfmt.tokenize(pattern).some((token) => token.type === numfmt.tokenTypes.CONDITION)) return "number";
|
|
@@ -305,8 +302,7 @@ const getPatternPreviewIgnoreGeneral = (pattern, value, locale, dateSystem) => {
|
|
|
305
302
|
return getPatternPreview(pattern, value, locale, dateSystem);
|
|
306
303
|
};
|
|
307
304
|
|
|
308
|
-
|
|
309
|
-
//#region src/utils/scientific-notation.ts
|
|
305
|
+
// src/utils/scientific-notation.ts
|
|
310
306
|
function isScientificNotationNumericCell(cell) {
|
|
311
307
|
return (cell === null || cell === void 0 ? void 0 : cell.t) === CellValueType.NUMBER && cell.v !== void 0 && cell.v !== null && /e/i.test(String(cell.v));
|
|
312
308
|
}
|
|
@@ -321,8 +317,7 @@ function isAllowedPatternForScientificNotationNumber(pattern) {
|
|
|
321
317
|
return isDefaultFormat(pattern) || isTextFormat(pattern) || getPatternType(pattern) === "scientific";
|
|
322
318
|
}
|
|
323
319
|
|
|
324
|
-
|
|
325
|
-
//#region src/commands/commands/set-numfmt.command.ts
|
|
320
|
+
// src/commands/commands/set-numfmt.command.ts
|
|
326
321
|
const SetNumfmtCommand = {
|
|
327
322
|
id: "sheet.command.numfmt.set.numfmt",
|
|
328
323
|
type: CommandType.COMMAND,
|
|
@@ -428,8 +423,7 @@ const SetNumfmtCommand = {
|
|
|
428
423
|
}
|
|
429
424
|
};
|
|
430
425
|
|
|
431
|
-
|
|
432
|
-
//#region src/commands/commands/add-decimal.command.ts
|
|
426
|
+
// src/commands/commands/add-decimal.command.ts
|
|
433
427
|
const AddDecimalCommand = {
|
|
434
428
|
id: "sheet.command.numfmt.add.decimal.command",
|
|
435
429
|
type: CommandType.COMMAND,
|
|
@@ -496,8 +490,7 @@ const AddDecimalCommand = {
|
|
|
496
490
|
}
|
|
497
491
|
};
|
|
498
492
|
|
|
499
|
-
|
|
500
|
-
//#region src/commands/commands/set-currency.command.ts
|
|
493
|
+
// src/commands/commands/set-currency.command.ts
|
|
501
494
|
/**
|
|
502
495
|
* This command is triggered by clicking the currency symbol icon in the menu.
|
|
503
496
|
* So the currency format is determined by the currency symbol icon.
|
|
@@ -528,8 +521,7 @@ const SetCurrencyCommand = {
|
|
|
528
521
|
}
|
|
529
522
|
};
|
|
530
523
|
|
|
531
|
-
|
|
532
|
-
//#region src/commands/commands/set-percent.command.ts
|
|
524
|
+
// src/commands/commands/set-percent.command.ts
|
|
533
525
|
const SetPercentCommand = {
|
|
534
526
|
id: "sheet.command.numfmt.set.percent",
|
|
535
527
|
type: CommandType.COMMAND,
|
|
@@ -553,8 +545,7 @@ const SetPercentCommand = {
|
|
|
553
545
|
}
|
|
554
546
|
};
|
|
555
547
|
|
|
556
|
-
|
|
557
|
-
//#region src/commands/commands/subtract-decimal.command.ts
|
|
548
|
+
// src/commands/commands/subtract-decimal.command.ts
|
|
558
549
|
const SubtractDecimalCommand = {
|
|
559
550
|
id: "sheet.command.numfmt.subtract.decimal.command",
|
|
560
551
|
type: CommandType.COMMAND,
|
|
@@ -619,8 +610,7 @@ const SubtractDecimalCommand = {
|
|
|
619
610
|
}
|
|
620
611
|
};
|
|
621
612
|
|
|
622
|
-
|
|
623
|
-
//#region src/config/config.ts
|
|
613
|
+
// src/config/config.ts
|
|
624
614
|
/**
|
|
625
615
|
* Copyright 2023-present DreamNum Co., Ltd.
|
|
626
616
|
*
|
|
@@ -640,8 +630,7 @@ const SHEETS_NUMFMT_PLUGIN_CONFIG_KEY = "sheets-numfmt.config";
|
|
|
640
630
|
const configSymbol = Symbol(SHEETS_NUMFMT_PLUGIN_CONFIG_KEY);
|
|
641
631
|
const defaultPluginConfig = {};
|
|
642
632
|
|
|
643
|
-
|
|
644
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/typeof.js
|
|
633
|
+
// \0@oxc-project+runtime@0.156.0/helpers/esm/typeof.js
|
|
645
634
|
function _typeof(o) {
|
|
646
635
|
"@babel/helpers - typeof";
|
|
647
636
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -651,8 +640,7 @@ function _typeof(o) {
|
|
|
651
640
|
}, _typeof(o);
|
|
652
641
|
}
|
|
653
642
|
|
|
654
|
-
|
|
655
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPrimitive.js
|
|
643
|
+
// \0@oxc-project+runtime@0.156.0/helpers/esm/toPrimitive.js
|
|
656
644
|
function toPrimitive(t, r) {
|
|
657
645
|
if ("object" != _typeof(t) || !t) return t;
|
|
658
646
|
var e = t[Symbol.toPrimitive];
|
|
@@ -664,15 +652,13 @@ function toPrimitive(t, r) {
|
|
|
664
652
|
return ("string" === r ? String : Number)(t);
|
|
665
653
|
}
|
|
666
654
|
|
|
667
|
-
|
|
668
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPropertyKey.js
|
|
655
|
+
// \0@oxc-project+runtime@0.156.0/helpers/esm/toPropertyKey.js
|
|
669
656
|
function toPropertyKey(t) {
|
|
670
657
|
var i = toPrimitive(t, "string");
|
|
671
658
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
672
659
|
}
|
|
673
660
|
|
|
674
|
-
|
|
675
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/defineProperty.js
|
|
661
|
+
// \0@oxc-project+runtime@0.156.0/helpers/esm/defineProperty.js
|
|
676
662
|
function _defineProperty(e, r, t) {
|
|
677
663
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
678
664
|
value: t,
|
|
@@ -682,16 +668,14 @@ function _defineProperty(e, r, t) {
|
|
|
682
668
|
}) : e[r] = t, e;
|
|
683
669
|
}
|
|
684
670
|
|
|
685
|
-
|
|
686
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorateParam.js
|
|
671
|
+
// \0@oxc-project+runtime@0.156.0/helpers/esm/decorateParam.js
|
|
687
672
|
function __decorateParam(paramIndex, decorator) {
|
|
688
673
|
return function(target, key) {
|
|
689
674
|
decorator(target, key, paramIndex);
|
|
690
675
|
};
|
|
691
676
|
}
|
|
692
677
|
|
|
693
|
-
|
|
694
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorate.js
|
|
678
|
+
// \0@oxc-project+runtime@0.156.0/helpers/esm/decorate.js
|
|
695
679
|
function __decorate(decorators, target, key, desc) {
|
|
696
680
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
697
681
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -699,8 +683,7 @@ function __decorate(decorators, target, key, desc) {
|
|
|
699
683
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
700
684
|
}
|
|
701
685
|
|
|
702
|
-
|
|
703
|
-
//#region src/controllers/numfmt-cell-content.controller.ts
|
|
686
|
+
// src/controllers/numfmt-cell-content.controller.ts
|
|
704
687
|
const TEXT_FORMAT_MARK = { tl: {
|
|
705
688
|
size: 6,
|
|
706
689
|
color: "#409f11"
|
|
@@ -754,26 +737,28 @@ let SheetsNumfmtCellContentController = class SheetsNumfmtCellContentController
|
|
|
754
737
|
}));
|
|
755
738
|
this.disposeWithMe(this._instanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET).pipe(switchMap((workbook) => (workbook === null || workbook === void 0 ? void 0 : workbook.activeSheet$) ?? of(null)), skip(1)).subscribe(() => this._renderCache.reset()));
|
|
756
739
|
}
|
|
740
|
+
_getNumfmtValue(cell, location) {
|
|
741
|
+
var _cell$themeStyle, _workbook$getStyles$g2;
|
|
742
|
+
const { unitId, subUnitId: sheetId, row, col, workbook } = location;
|
|
743
|
+
const tableDxfNumfmt = (_cell$themeStyle = cell.themeStyle) === null || _cell$themeStyle === void 0 ? void 0 : _cell$themeStyle.n;
|
|
744
|
+
if (tableDxfNumfmt === void 0) {
|
|
745
|
+
var _workbook$getStyles$g;
|
|
746
|
+
return ((_workbook$getStyles$g = workbook.getStyles().get(cell.s)) === null || _workbook$getStyles$g === void 0 ? void 0 : _workbook$getStyles$g.n) ?? this._numfmtService.getValue(unitId, sheetId, row, col);
|
|
747
|
+
}
|
|
748
|
+
const directNumfmt = (_workbook$getStyles$g2 = workbook.getStyles().getStyleByCell(cell)) === null || _workbook$getStyles$g2 === void 0 ? void 0 : _workbook$getStyles$g2.n;
|
|
749
|
+
return directNumfmt !== void 0 ? directNumfmt : this._numfmtService.getValue(unitId, sheetId, row, col) ?? tableDxfNumfmt;
|
|
750
|
+
}
|
|
757
751
|
_formatCell(cell, location) {
|
|
758
|
-
var _workbook$getStyles$g;
|
|
759
752
|
if (!cell || cell.v == null || cell.t === CellValueType.BOOLEAN || cell.t === CellValueType.FORCE_STRING) return cell;
|
|
760
753
|
const { unitId, subUnitId: sheetId, row, col, workbook } = location;
|
|
761
754
|
const locale = this.getLocale(workbook);
|
|
762
755
|
const dateSystem = workbook.getDateSystem();
|
|
763
|
-
const numfmtValue =
|
|
756
|
+
const numfmtValue = this._getNumfmtValue(cell, location);
|
|
764
757
|
const pattern = numfmtValue === null || numfmtValue === void 0 ? void 0 : numfmtValue.pattern;
|
|
765
758
|
if (isDefaultFormat(pattern)) return cell;
|
|
766
759
|
if (!this._isNumericCell(cell, pattern, locale, dateSystem)) return cell;
|
|
767
760
|
const formattedCell = cell === location.rawData ? { ...cell } : cell;
|
|
768
|
-
if (isTextFormat(pattern))
|
|
769
|
-
var _this$_configService$;
|
|
770
|
-
formattedCell.t = CellValueType.STRING;
|
|
771
|
-
if (!((_this$_configService$ = this._configService.getConfig("sheets-numfmt.config")) === null || _this$_configService$ === void 0 ? void 0 : _this$_configService$.disableTextFormatMark)) formattedCell.markers = {
|
|
772
|
-
...formattedCell.markers,
|
|
773
|
-
...TEXT_FORMAT_MARK
|
|
774
|
-
};
|
|
775
|
-
return formattedCell;
|
|
776
|
-
}
|
|
761
|
+
if (isTextFormat(pattern)) return this._formatTextCell(cell, formattedCell);
|
|
777
762
|
const cacheParameters = `${unitId}_${sheetId}_${cell.v}_${pattern}_${locale}_${dateSystem}`;
|
|
778
763
|
const cache = this._renderCache.getValue(row, col);
|
|
779
764
|
if (cache && cache.parameters === cacheParameters) return {
|
|
@@ -797,6 +782,16 @@ let SheetsNumfmtCellContentController = class SheetsNumfmtCellContentController
|
|
|
797
782
|
Object.assign(formattedCell, res);
|
|
798
783
|
return formattedCell;
|
|
799
784
|
}
|
|
785
|
+
_formatTextCell(cell, formattedCell) {
|
|
786
|
+
var _this$_configService$;
|
|
787
|
+
if (cell.t === CellValueType.NUMBER && isRealNum(formattedCell.v)) formattedCell.v = stripErrorMargin(Number(formattedCell.v));
|
|
788
|
+
else formattedCell.t = CellValueType.STRING;
|
|
789
|
+
if (!((_this$_configService$ = this._configService.getConfig("sheets-numfmt.config")) === null || _this$_configService$ === void 0 ? void 0 : _this$_configService$.disableTextFormatMark)) formattedCell.markers = {
|
|
790
|
+
...formattedCell.markers,
|
|
791
|
+
...TEXT_FORMAT_MARK
|
|
792
|
+
};
|
|
793
|
+
return formattedCell;
|
|
794
|
+
}
|
|
800
795
|
_isNumericCell(cell, pattern, locale, dateSystem) {
|
|
801
796
|
var _getNumfmtParseValueF;
|
|
802
797
|
return cell.t === CellValueType.NUMBER || checkCellValueType(cell.v, cell.t) === CellValueType.NUMBER || isTextFormat(pattern) && typeof cell.v === "string" && typeof ((_getNumfmtParseValueF = getNumfmtParseValueFilter(cell.v, {
|
|
@@ -818,13 +813,11 @@ SheetsNumfmtCellContentController = __decorate([
|
|
|
818
813
|
__decorateParam(6, IConfigService)
|
|
819
814
|
], SheetsNumfmtCellContentController);
|
|
820
815
|
|
|
821
|
-
|
|
822
|
-
//#region package.json
|
|
816
|
+
// package.json
|
|
823
817
|
var name = "@univerjs/sheets-numfmt";
|
|
824
|
-
var version = "1.
|
|
818
|
+
var version = "1.4.0";
|
|
825
819
|
|
|
826
|
-
|
|
827
|
-
//#region src/base/const/plugin-name.ts
|
|
820
|
+
// src/base/const/plugin-name.ts
|
|
828
821
|
/**
|
|
829
822
|
* Copyright 2023-present DreamNum Co., Ltd.
|
|
830
823
|
*
|
|
@@ -842,8 +835,7 @@ var version = "1.3.0";
|
|
|
842
835
|
*/
|
|
843
836
|
const SHEET_NUMFMT_PLUGIN = "SHEET_NUMFMT_PLUGIN";
|
|
844
837
|
|
|
845
|
-
|
|
846
|
-
//#region src/plugin.ts
|
|
838
|
+
// src/plugin.ts
|
|
847
839
|
let UniverSheetsNumfmtPlugin = class UniverSheetsNumfmtPlugin extends Plugin {
|
|
848
840
|
constructor(_config = defaultPluginConfig, _injector, _configService, _commandService) {
|
|
849
841
|
super();
|
|
@@ -879,8 +871,7 @@ UniverSheetsNumfmtPlugin = __decorate([
|
|
|
879
871
|
__decorateParam(3, ICommandService)
|
|
880
872
|
], UniverSheetsNumfmtPlugin);
|
|
881
873
|
|
|
882
|
-
|
|
883
|
-
//#region src/utils/currency.ts
|
|
874
|
+
// src/utils/currency.ts
|
|
884
875
|
/**
|
|
885
876
|
* Copyright 2023-present DreamNum Co., Ltd.
|
|
886
877
|
*
|
|
@@ -900,8 +891,7 @@ const getCurrencyType = (pattern) => {
|
|
|
900
891
|
return currencySymbols.find((code) => pattern.includes(code));
|
|
901
892
|
};
|
|
902
893
|
|
|
903
|
-
|
|
904
|
-
//#region src/base/const/date-format.ts
|
|
894
|
+
// src/base/const/date-format.ts
|
|
905
895
|
/**
|
|
906
896
|
* Copyright 2023-present DreamNum Co., Ltd.
|
|
907
897
|
*
|
|
@@ -1026,8 +1016,7 @@ function getDateFormatPatterns(locale) {
|
|
|
1026
1016
|
])];
|
|
1027
1017
|
}
|
|
1028
1018
|
|
|
1029
|
-
|
|
1030
|
-
//#region src/utils/options.ts
|
|
1019
|
+
// src/utils/options.ts
|
|
1031
1020
|
const getCurrencyOptions = () => currencySymbols.map((item) => ({
|
|
1032
1021
|
label: item,
|
|
1033
1022
|
value: item
|
|
@@ -1057,5 +1046,4 @@ const getNumberFormatOptions = () => NUMBERFORMAT.map((item) => ({
|
|
|
1057
1046
|
color: item.color
|
|
1058
1047
|
}));
|
|
1059
1048
|
|
|
1060
|
-
//#endregion
|
|
1061
1049
|
export { AddDecimalCommand, CURRENCYFORMAT, DATEFMTLISG, NUMBERFORMAT, SHEETS_NUMFMT_PLUGIN_CONFIG_KEY, SetCurrencyCommand, SetNumfmtCommand, SetPercentCommand, SheetsNumfmtCellContentController, SubtractDecimalCommand, UniverSheetsNumfmtPlugin, getCurrencyFormat, getCurrencyFormatOptions, getCurrencyOptions, getCurrencySymbolByLocale, getCurrencySymbolIconByLocale, getCurrencyType, getDateFormatOptions, getDecimalFromPattern, getDecimalString, getNumberFormatOptions, getPatternPreview, getPatternPreviewIgnoreGeneral, getPatternType, isPatternHasDecimal, localeCurrencySymbolMap, setPatternDecimal };
|
package/lib/facade.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SetNumfmtCommand, SheetsNumfmtCellContentController } from "@univerjs/sheets-numfmt";
|
|
2
2
|
import { FRange, FWorkbook } from "@univerjs/sheets/facade";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/facade/f-range.ts
|
|
5
5
|
var FRangeSheetsNumfmtMixin = class extends FRange {
|
|
6
6
|
setNumberFormat(pattern) {
|
|
7
7
|
const values = [];
|
|
@@ -51,8 +51,7 @@ var FRangeSheetsNumfmtMixin = class extends FRange {
|
|
|
51
51
|
};
|
|
52
52
|
FRange.extend(FRangeSheetsNumfmtMixin);
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
//#region src/facade/f-workbook.ts
|
|
54
|
+
// src/facade/f-workbook.ts
|
|
56
55
|
var FWorkbookSheetsNumfmtMixin = class extends FWorkbook {
|
|
57
56
|
setNumfmtLocal(locale) {
|
|
58
57
|
this._injector.get(SheetsNumfmtCellContentController).setNumfmtLocal(locale);
|
|
@@ -61,5 +60,4 @@ var FWorkbookSheetsNumfmtMixin = class extends FWorkbook {
|
|
|
61
60
|
};
|
|
62
61
|
FWorkbook.extend(FWorkbookSheetsNumfmtMixin);
|
|
63
62
|
|
|
64
|
-
//#endregion
|
|
65
63
|
export { };
|
package/lib/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { CellValueType, CommandType, DEFAULT_NUMBER_FORMAT, DependentOn, Disposable, ICommandService, IConfigService, IUndoRedoService, IUniverInstanceService, Inject, Injector, InterceptorEffectEnum, LocaleService, LocaleType, ObjectMatrix, Plugin, Range, RegionService, ThemeService, UniverInstanceType, currencySymbols, excelDateTimeSerial, getNumfmtLocaleTag, getNumfmtParseValueFilter, isDefaultFormat, isTextFormat, merge, numfmt, registerDependencies, sequenceExecute, touchDependencies } from "@univerjs/core";
|
|
1
|
+
import { CellValueType, CommandType, DEFAULT_NUMBER_FORMAT, DependentOn, Disposable, ICommandService, IConfigService, IUndoRedoService, IUniverInstanceService, Inject, Injector, InterceptorEffectEnum, LocaleService, LocaleType, ObjectMatrix, Plugin, Range, RegionService, ThemeService, UniverInstanceType, currencySymbols, excelDateTimeSerial, getNumfmtLocaleTag, getNumfmtParseValueFilter, isDefaultFormat, isRealNum, isTextFormat, merge, numfmt, registerDependencies, sequenceExecute, touchDependencies } from "@univerjs/core";
|
|
2
2
|
import { INTERCEPTOR_POINT, INumfmtService, InterceptCellContentPriority, RemoveNumfmtMutation, SetNumfmtMutation, SetRangeValuesMutation, SheetInterceptorService, SheetsSelectionsService, UniverSheetsPlugin, checkCellValueType, factoryRemoveNumfmtUndoMutation, factorySetNumfmtUndoMutation, getSheetCommandTarget, rangeMerge, transformCellsToRange } from "@univerjs/sheets";
|
|
3
3
|
import { stripErrorMargin } from "@univerjs/engine-formula";
|
|
4
4
|
import { BehaviorSubject, merge as merge$1, of, skip, switchMap } from "rxjs";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
// src/base/const/currency-symbols.ts
|
|
7
7
|
/**
|
|
8
8
|
* Copyright 2023-present DreamNum Co., Ltd.
|
|
9
9
|
*
|
|
@@ -120,8 +120,7 @@ function getCurrencyFormat(locale, numberDigits = 2) {
|
|
|
120
120
|
return `"${getCurrencySymbolByLocale(locale)}"#,##0${decimal}_);[Red]("${getCurrencySymbolByLocale(locale)}"#,##0${decimal})`;
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
|
|
124
|
-
//#region src/base/const/formatdetail.ts
|
|
123
|
+
// src/base/const/formatdetail.ts
|
|
125
124
|
/**
|
|
126
125
|
* Copyright 2023-present DreamNum Co., Ltd.
|
|
127
126
|
*
|
|
@@ -242,8 +241,7 @@ const CURRENCYFORMAT = [
|
|
|
242
241
|
}
|
|
243
242
|
];
|
|
244
243
|
|
|
245
|
-
|
|
246
|
-
//#region src/utils/decimal.ts
|
|
244
|
+
// src/utils/decimal.ts
|
|
247
245
|
/**
|
|
248
246
|
* Copyright 2023-present DreamNum Co., Ltd.
|
|
249
247
|
*
|
|
@@ -276,8 +274,7 @@ const setPatternDecimal = (patterns, decimalLength) => {
|
|
|
276
274
|
};
|
|
277
275
|
const isPatternHasDecimal = (pattern) => /\.0?/.test(pattern) || /0([^0]?)|0$/.test(pattern);
|
|
278
276
|
|
|
279
|
-
|
|
280
|
-
//#region src/utils/pattern.ts
|
|
277
|
+
// src/utils/pattern.ts
|
|
281
278
|
const getPatternType = (pattern) => {
|
|
282
279
|
const type = numfmt.getFormatInfo(pattern).type || "unknown";
|
|
283
280
|
if (type === "general" && numfmt.tokenize(pattern).some((token) => token.type === numfmt.tokenTypes.CONDITION)) return "number";
|
|
@@ -305,8 +302,7 @@ const getPatternPreviewIgnoreGeneral = (pattern, value, locale, dateSystem) => {
|
|
|
305
302
|
return getPatternPreview(pattern, value, locale, dateSystem);
|
|
306
303
|
};
|
|
307
304
|
|
|
308
|
-
|
|
309
|
-
//#region src/utils/scientific-notation.ts
|
|
305
|
+
// src/utils/scientific-notation.ts
|
|
310
306
|
function isScientificNotationNumericCell(cell) {
|
|
311
307
|
return (cell === null || cell === void 0 ? void 0 : cell.t) === CellValueType.NUMBER && cell.v !== void 0 && cell.v !== null && /e/i.test(String(cell.v));
|
|
312
308
|
}
|
|
@@ -321,8 +317,7 @@ function isAllowedPatternForScientificNotationNumber(pattern) {
|
|
|
321
317
|
return isDefaultFormat(pattern) || isTextFormat(pattern) || getPatternType(pattern) === "scientific";
|
|
322
318
|
}
|
|
323
319
|
|
|
324
|
-
|
|
325
|
-
//#region src/commands/commands/set-numfmt.command.ts
|
|
320
|
+
// src/commands/commands/set-numfmt.command.ts
|
|
326
321
|
const SetNumfmtCommand = {
|
|
327
322
|
id: "sheet.command.numfmt.set.numfmt",
|
|
328
323
|
type: CommandType.COMMAND,
|
|
@@ -428,8 +423,7 @@ const SetNumfmtCommand = {
|
|
|
428
423
|
}
|
|
429
424
|
};
|
|
430
425
|
|
|
431
|
-
|
|
432
|
-
//#region src/commands/commands/add-decimal.command.ts
|
|
426
|
+
// src/commands/commands/add-decimal.command.ts
|
|
433
427
|
const AddDecimalCommand = {
|
|
434
428
|
id: "sheet.command.numfmt.add.decimal.command",
|
|
435
429
|
type: CommandType.COMMAND,
|
|
@@ -496,8 +490,7 @@ const AddDecimalCommand = {
|
|
|
496
490
|
}
|
|
497
491
|
};
|
|
498
492
|
|
|
499
|
-
|
|
500
|
-
//#region src/commands/commands/set-currency.command.ts
|
|
493
|
+
// src/commands/commands/set-currency.command.ts
|
|
501
494
|
/**
|
|
502
495
|
* This command is triggered by clicking the currency symbol icon in the menu.
|
|
503
496
|
* So the currency format is determined by the currency symbol icon.
|
|
@@ -528,8 +521,7 @@ const SetCurrencyCommand = {
|
|
|
528
521
|
}
|
|
529
522
|
};
|
|
530
523
|
|
|
531
|
-
|
|
532
|
-
//#region src/commands/commands/set-percent.command.ts
|
|
524
|
+
// src/commands/commands/set-percent.command.ts
|
|
533
525
|
const SetPercentCommand = {
|
|
534
526
|
id: "sheet.command.numfmt.set.percent",
|
|
535
527
|
type: CommandType.COMMAND,
|
|
@@ -553,8 +545,7 @@ const SetPercentCommand = {
|
|
|
553
545
|
}
|
|
554
546
|
};
|
|
555
547
|
|
|
556
|
-
|
|
557
|
-
//#region src/commands/commands/subtract-decimal.command.ts
|
|
548
|
+
// src/commands/commands/subtract-decimal.command.ts
|
|
558
549
|
const SubtractDecimalCommand = {
|
|
559
550
|
id: "sheet.command.numfmt.subtract.decimal.command",
|
|
560
551
|
type: CommandType.COMMAND,
|
|
@@ -619,8 +610,7 @@ const SubtractDecimalCommand = {
|
|
|
619
610
|
}
|
|
620
611
|
};
|
|
621
612
|
|
|
622
|
-
|
|
623
|
-
//#region src/config/config.ts
|
|
613
|
+
// src/config/config.ts
|
|
624
614
|
/**
|
|
625
615
|
* Copyright 2023-present DreamNum Co., Ltd.
|
|
626
616
|
*
|
|
@@ -640,8 +630,7 @@ const SHEETS_NUMFMT_PLUGIN_CONFIG_KEY = "sheets-numfmt.config";
|
|
|
640
630
|
const configSymbol = Symbol(SHEETS_NUMFMT_PLUGIN_CONFIG_KEY);
|
|
641
631
|
const defaultPluginConfig = {};
|
|
642
632
|
|
|
643
|
-
|
|
644
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/typeof.js
|
|
633
|
+
// \0@oxc-project+runtime@0.156.0/helpers/esm/typeof.js
|
|
645
634
|
function _typeof(o) {
|
|
646
635
|
"@babel/helpers - typeof";
|
|
647
636
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -651,8 +640,7 @@ function _typeof(o) {
|
|
|
651
640
|
}, _typeof(o);
|
|
652
641
|
}
|
|
653
642
|
|
|
654
|
-
|
|
655
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPrimitive.js
|
|
643
|
+
// \0@oxc-project+runtime@0.156.0/helpers/esm/toPrimitive.js
|
|
656
644
|
function toPrimitive(t, r) {
|
|
657
645
|
if ("object" != _typeof(t) || !t) return t;
|
|
658
646
|
var e = t[Symbol.toPrimitive];
|
|
@@ -664,15 +652,13 @@ function toPrimitive(t, r) {
|
|
|
664
652
|
return ("string" === r ? String : Number)(t);
|
|
665
653
|
}
|
|
666
654
|
|
|
667
|
-
|
|
668
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPropertyKey.js
|
|
655
|
+
// \0@oxc-project+runtime@0.156.0/helpers/esm/toPropertyKey.js
|
|
669
656
|
function toPropertyKey(t) {
|
|
670
657
|
var i = toPrimitive(t, "string");
|
|
671
658
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
672
659
|
}
|
|
673
660
|
|
|
674
|
-
|
|
675
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/defineProperty.js
|
|
661
|
+
// \0@oxc-project+runtime@0.156.0/helpers/esm/defineProperty.js
|
|
676
662
|
function _defineProperty(e, r, t) {
|
|
677
663
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
678
664
|
value: t,
|
|
@@ -682,16 +668,14 @@ function _defineProperty(e, r, t) {
|
|
|
682
668
|
}) : e[r] = t, e;
|
|
683
669
|
}
|
|
684
670
|
|
|
685
|
-
|
|
686
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorateParam.js
|
|
671
|
+
// \0@oxc-project+runtime@0.156.0/helpers/esm/decorateParam.js
|
|
687
672
|
function __decorateParam(paramIndex, decorator) {
|
|
688
673
|
return function(target, key) {
|
|
689
674
|
decorator(target, key, paramIndex);
|
|
690
675
|
};
|
|
691
676
|
}
|
|
692
677
|
|
|
693
|
-
|
|
694
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorate.js
|
|
678
|
+
// \0@oxc-project+runtime@0.156.0/helpers/esm/decorate.js
|
|
695
679
|
function __decorate(decorators, target, key, desc) {
|
|
696
680
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
697
681
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -699,8 +683,7 @@ function __decorate(decorators, target, key, desc) {
|
|
|
699
683
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
700
684
|
}
|
|
701
685
|
|
|
702
|
-
|
|
703
|
-
//#region src/controllers/numfmt-cell-content.controller.ts
|
|
686
|
+
// src/controllers/numfmt-cell-content.controller.ts
|
|
704
687
|
const TEXT_FORMAT_MARK = { tl: {
|
|
705
688
|
size: 6,
|
|
706
689
|
color: "#409f11"
|
|
@@ -754,26 +737,28 @@ let SheetsNumfmtCellContentController = class SheetsNumfmtCellContentController
|
|
|
754
737
|
}));
|
|
755
738
|
this.disposeWithMe(this._instanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET).pipe(switchMap((workbook) => (workbook === null || workbook === void 0 ? void 0 : workbook.activeSheet$) ?? of(null)), skip(1)).subscribe(() => this._renderCache.reset()));
|
|
756
739
|
}
|
|
740
|
+
_getNumfmtValue(cell, location) {
|
|
741
|
+
var _cell$themeStyle, _workbook$getStyles$g2;
|
|
742
|
+
const { unitId, subUnitId: sheetId, row, col, workbook } = location;
|
|
743
|
+
const tableDxfNumfmt = (_cell$themeStyle = cell.themeStyle) === null || _cell$themeStyle === void 0 ? void 0 : _cell$themeStyle.n;
|
|
744
|
+
if (tableDxfNumfmt === void 0) {
|
|
745
|
+
var _workbook$getStyles$g;
|
|
746
|
+
return ((_workbook$getStyles$g = workbook.getStyles().get(cell.s)) === null || _workbook$getStyles$g === void 0 ? void 0 : _workbook$getStyles$g.n) ?? this._numfmtService.getValue(unitId, sheetId, row, col);
|
|
747
|
+
}
|
|
748
|
+
const directNumfmt = (_workbook$getStyles$g2 = workbook.getStyles().getStyleByCell(cell)) === null || _workbook$getStyles$g2 === void 0 ? void 0 : _workbook$getStyles$g2.n;
|
|
749
|
+
return directNumfmt !== void 0 ? directNumfmt : this._numfmtService.getValue(unitId, sheetId, row, col) ?? tableDxfNumfmt;
|
|
750
|
+
}
|
|
757
751
|
_formatCell(cell, location) {
|
|
758
|
-
var _workbook$getStyles$g;
|
|
759
752
|
if (!cell || cell.v == null || cell.t === CellValueType.BOOLEAN || cell.t === CellValueType.FORCE_STRING) return cell;
|
|
760
753
|
const { unitId, subUnitId: sheetId, row, col, workbook } = location;
|
|
761
754
|
const locale = this.getLocale(workbook);
|
|
762
755
|
const dateSystem = workbook.getDateSystem();
|
|
763
|
-
const numfmtValue =
|
|
756
|
+
const numfmtValue = this._getNumfmtValue(cell, location);
|
|
764
757
|
const pattern = numfmtValue === null || numfmtValue === void 0 ? void 0 : numfmtValue.pattern;
|
|
765
758
|
if (isDefaultFormat(pattern)) return cell;
|
|
766
759
|
if (!this._isNumericCell(cell, pattern, locale, dateSystem)) return cell;
|
|
767
760
|
const formattedCell = cell === location.rawData ? { ...cell } : cell;
|
|
768
|
-
if (isTextFormat(pattern))
|
|
769
|
-
var _this$_configService$;
|
|
770
|
-
formattedCell.t = CellValueType.STRING;
|
|
771
|
-
if (!((_this$_configService$ = this._configService.getConfig("sheets-numfmt.config")) === null || _this$_configService$ === void 0 ? void 0 : _this$_configService$.disableTextFormatMark)) formattedCell.markers = {
|
|
772
|
-
...formattedCell.markers,
|
|
773
|
-
...TEXT_FORMAT_MARK
|
|
774
|
-
};
|
|
775
|
-
return formattedCell;
|
|
776
|
-
}
|
|
761
|
+
if (isTextFormat(pattern)) return this._formatTextCell(cell, formattedCell);
|
|
777
762
|
const cacheParameters = `${unitId}_${sheetId}_${cell.v}_${pattern}_${locale}_${dateSystem}`;
|
|
778
763
|
const cache = this._renderCache.getValue(row, col);
|
|
779
764
|
if (cache && cache.parameters === cacheParameters) return {
|
|
@@ -797,6 +782,16 @@ let SheetsNumfmtCellContentController = class SheetsNumfmtCellContentController
|
|
|
797
782
|
Object.assign(formattedCell, res);
|
|
798
783
|
return formattedCell;
|
|
799
784
|
}
|
|
785
|
+
_formatTextCell(cell, formattedCell) {
|
|
786
|
+
var _this$_configService$;
|
|
787
|
+
if (cell.t === CellValueType.NUMBER && isRealNum(formattedCell.v)) formattedCell.v = stripErrorMargin(Number(formattedCell.v));
|
|
788
|
+
else formattedCell.t = CellValueType.STRING;
|
|
789
|
+
if (!((_this$_configService$ = this._configService.getConfig("sheets-numfmt.config")) === null || _this$_configService$ === void 0 ? void 0 : _this$_configService$.disableTextFormatMark)) formattedCell.markers = {
|
|
790
|
+
...formattedCell.markers,
|
|
791
|
+
...TEXT_FORMAT_MARK
|
|
792
|
+
};
|
|
793
|
+
return formattedCell;
|
|
794
|
+
}
|
|
800
795
|
_isNumericCell(cell, pattern, locale, dateSystem) {
|
|
801
796
|
var _getNumfmtParseValueF;
|
|
802
797
|
return cell.t === CellValueType.NUMBER || checkCellValueType(cell.v, cell.t) === CellValueType.NUMBER || isTextFormat(pattern) && typeof cell.v === "string" && typeof ((_getNumfmtParseValueF = getNumfmtParseValueFilter(cell.v, {
|
|
@@ -818,13 +813,11 @@ SheetsNumfmtCellContentController = __decorate([
|
|
|
818
813
|
__decorateParam(6, IConfigService)
|
|
819
814
|
], SheetsNumfmtCellContentController);
|
|
820
815
|
|
|
821
|
-
|
|
822
|
-
//#region package.json
|
|
816
|
+
// package.json
|
|
823
817
|
var name = "@univerjs/sheets-numfmt";
|
|
824
|
-
var version = "1.
|
|
818
|
+
var version = "1.4.0";
|
|
825
819
|
|
|
826
|
-
|
|
827
|
-
//#region src/base/const/plugin-name.ts
|
|
820
|
+
// src/base/const/plugin-name.ts
|
|
828
821
|
/**
|
|
829
822
|
* Copyright 2023-present DreamNum Co., Ltd.
|
|
830
823
|
*
|
|
@@ -842,8 +835,7 @@ var version = "1.3.0";
|
|
|
842
835
|
*/
|
|
843
836
|
const SHEET_NUMFMT_PLUGIN = "SHEET_NUMFMT_PLUGIN";
|
|
844
837
|
|
|
845
|
-
|
|
846
|
-
//#region src/plugin.ts
|
|
838
|
+
// src/plugin.ts
|
|
847
839
|
let UniverSheetsNumfmtPlugin = class UniverSheetsNumfmtPlugin extends Plugin {
|
|
848
840
|
constructor(_config = defaultPluginConfig, _injector, _configService, _commandService) {
|
|
849
841
|
super();
|
|
@@ -879,8 +871,7 @@ UniverSheetsNumfmtPlugin = __decorate([
|
|
|
879
871
|
__decorateParam(3, ICommandService)
|
|
880
872
|
], UniverSheetsNumfmtPlugin);
|
|
881
873
|
|
|
882
|
-
|
|
883
|
-
//#region src/utils/currency.ts
|
|
874
|
+
// src/utils/currency.ts
|
|
884
875
|
/**
|
|
885
876
|
* Copyright 2023-present DreamNum Co., Ltd.
|
|
886
877
|
*
|
|
@@ -900,8 +891,7 @@ const getCurrencyType = (pattern) => {
|
|
|
900
891
|
return currencySymbols.find((code) => pattern.includes(code));
|
|
901
892
|
};
|
|
902
893
|
|
|
903
|
-
|
|
904
|
-
//#region src/base/const/date-format.ts
|
|
894
|
+
// src/base/const/date-format.ts
|
|
905
895
|
/**
|
|
906
896
|
* Copyright 2023-present DreamNum Co., Ltd.
|
|
907
897
|
*
|
|
@@ -1026,8 +1016,7 @@ function getDateFormatPatterns(locale) {
|
|
|
1026
1016
|
])];
|
|
1027
1017
|
}
|
|
1028
1018
|
|
|
1029
|
-
|
|
1030
|
-
//#region src/utils/options.ts
|
|
1019
|
+
// src/utils/options.ts
|
|
1031
1020
|
const getCurrencyOptions = () => currencySymbols.map((item) => ({
|
|
1032
1021
|
label: item,
|
|
1033
1022
|
value: item
|
|
@@ -1057,5 +1046,4 @@ const getNumberFormatOptions = () => NUMBERFORMAT.map((item) => ({
|
|
|
1057
1046
|
color: item.color
|
|
1058
1047
|
}));
|
|
1059
1048
|
|
|
1060
|
-
//#endregion
|
|
1061
1049
|
export { AddDecimalCommand, CURRENCYFORMAT, DATEFMTLISG, NUMBERFORMAT, SHEETS_NUMFMT_PLUGIN_CONFIG_KEY, SetCurrencyCommand, SetNumfmtCommand, SetPercentCommand, SheetsNumfmtCellContentController, SubtractDecimalCommand, UniverSheetsNumfmtPlugin, getCurrencyFormat, getCurrencyFormatOptions, getCurrencyOptions, getCurrencySymbolByLocale, getCurrencySymbolIconByLocale, getCurrencyType, getDateFormatOptions, getDecimalFromPattern, getDecimalString, getNumberFormatOptions, getPatternPreview, getPatternPreviewIgnoreGeneral, getPatternType, isPatternHasDecimal, localeCurrencySymbolMap, setPatternDecimal };
|
|
@@ -31,7 +31,9 @@ export declare class SheetsNumfmtCellContentController extends Disposable {
|
|
|
31
31
|
get locale(): INumfmtLocaleTag;
|
|
32
32
|
getLocale(workbook?: Workbook): INumfmtLocaleTag;
|
|
33
33
|
private _initInterceptorCellContent;
|
|
34
|
+
private _getNumfmtValue;
|
|
34
35
|
private _formatCell;
|
|
36
|
+
private _formatTextCell;
|
|
35
37
|
private _isNumericCell;
|
|
36
38
|
setNumfmtLocal(locale: INumfmtLocaleTag): void;
|
|
37
39
|
}
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
export declare const INumfmtController: import("@
|
|
16
|
+
export declare const INumfmtController: import("@univerjs/core").IdentifierDecorator<INumfmtController>;
|
|
17
17
|
export interface INumfmtController {
|
|
18
18
|
openPanel(): void;
|
|
19
19
|
}
|
package/lib/umd/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("@univerjs/engine-formula"),require("rxjs")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/sheets`,`@univerjs/engine-formula`,`rxjs`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverSheetsNumfmt={},e.UniverCore,e.UniverSheets,e.UniverEngineFormula,e.rxjs))})(this,function(e,t,n,r,i){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});let a=/* @__PURE__ */ new Map([[t.LocaleType.EN_US,`$`],[t.LocaleType.RU_RU,`₽`],[t.LocaleType.VI_VN,`₫`],[t.LocaleType.ZH_CN,`¥`],[t.LocaleType.ZH_TW,`NT$`],[t.LocaleType.ZH_HK,`HK$`],[t.LocaleType.FR_FR,`€`],[t.LocaleType.FA_IR,`﷼`],[t.LocaleType.KO_KR,`₩`],[t.LocaleType.ES_ES,`€`],[t.LocaleType.CA_ES,`€`],[t.LocaleType.SK_SK,`€`],[t.LocaleType.JA_JP,`¥`],[t.LocaleType.PT_BR,`R$`],[t.LocaleType.DE_DE,`€`],[t.LocaleType.IT_IT,`€`],[t.LocaleType.ID_ID,`Rp`],[t.LocaleType.PL_PL,`zł`],[t.LocaleType.AR_SA,`﷼`]]);function o(e){switch(e){case t.LocaleType.CA_ES:case t.LocaleType.DE_DE:case t.LocaleType.ES_ES:case t.LocaleType.FR_FR:case t.LocaleType.IT_IT:case t.LocaleType.SK_SK:return{icon:`EuroIcon`,symbol:a.get(e)||`€`,locale:e};case t.LocaleType.RU_RU:return{icon:`RoubleIcon`,symbol:a.get(e)||`₽`,locale:e};case t.LocaleType.JA_JP:case t.LocaleType.ZH_CN:return{icon:`RmbIcon`,symbol:a.get(e)||`¥`,locale:e};case t.LocaleType.VI_VN:return{icon:`DongIcon`,symbol:a.get(e)||`₫`,locale:e};case t.LocaleType.AR_SA:case t.LocaleType.FA_IR:return{icon:`RialIcon`,symbol:a.get(e)||`﷼`,locale:e};case t.LocaleType.KO_KR:return{icon:`WonIcon`,symbol:a.get(e)||`₩`,locale:e};case t.LocaleType.ID_ID:return{icon:`RupiahIcon`,symbol:a.get(e)||`Rp`,locale:e};case t.LocaleType.PL_PL:return{icon:`ZlotyIcon`,symbol:a.get(e)||`zł`,locale:e};case t.LocaleType.EN_US:case t.LocaleType.PT_BR:case t.LocaleType.ZH_HK:case t.LocaleType.ZH_TW:default:return{icon:`DollarIcon`,symbol:a.get(e)||`$`,locale:e}}}function s(e){return a.get(e)||`$`}function c(e,t=2){let n=t;t>127&&(n=127);let r=``;return n>0&&(r=`.${`0`.repeat(n)}`),`"${s(e)}"#,##0${r}_);[Red]("${s(e)}"#,##0${r})`}let l=[{label:`1930-08-05`,suffix:`yyyy-MM-dd`},{label:`1930/08/05`,suffix:`yyyy/MM/dd`},{label:`1930年08月05日`,suffix:`yyyy"年"MM"月"dd"日"`},{label:`08-05`,suffix:`MM-dd`},{label:`8月5日`,suffix:`M"月"d"日"`},{label:`13:30:30`,suffix:`h:mm:ss`},{label:`13:30`,suffix:`h:mm`},{label:`下午01:30`,suffix:`A/P hh:mm`},{label:`下午1:30`,suffix:`A/P h:mm`},{label:`下午1:30:30`,suffix:`A/P h:mm:ss`},{label:`08-05 下午 01:30`,suffix:`MM-dd A/P hh:mm`}],u=[{label:`(1,235)`,suffix:`#,##0_);(#,##0)`},{label:`(1,235) `,suffix:`#,##0_);[Red](#,##0)`,color:`red`},{label:`1,234.56`,suffix:`#,##0.00_);#,##0.00`},{label:`1,234.56`,suffix:`#,##0.00_);[Red]#,##0.00`,color:`red`},{label:`-1,234.56`,suffix:`#,##0.00_);-#,##0.00`},{label:`-1,234.56`,suffix:`#,##0.00_);[Red]-#,##0.00`,color:`red`}],d=[{label:e=>`${e}1,235`,suffix:e=>`"${e}"#,##0.00_);"${e}"#,##0.00`},{label:e=>`${e}1,235`,suffix:e=>`"${e}"#,##0.00_);[Red]"${e}"#,##0.00`,color:`red`},{label:e=>`(${e}1,235)`,suffix:e=>`"${e}"#,##0.00_);("${e}"#,##0.00)`},{label:e=>`(${e}1,235)`,suffix:e=>`"${e}"#,##0.00_);[Red]("${e}"#,##0.00)`,color:`red`},{label:e=>`-${e}1,235`,suffix:e=>`"${e}"#,##0.00_);-"${e}"#,##0.00`},{label:e=>`-${e}1,235`,suffix:e=>`"${e}"#,##0.00_);[Red]-"${e}"#,##0.00`,color:`red`}],f=(e,n=0)=>e?t.numfmt.getFormatInfo(e).maxDecimals??n:n,p=e=>Array(Math.min(Math.max(0,Number(e)),30)).fill(0).join(``),m=(e,t)=>e.split(`;`).map(e=>/\.0?/.test(e)?e.replace(/\.0*/g,`${t>0?`.`:``}${p(Number(t||0))}`):/0([^0]?)|0$/.test(e)?e.replace(/0([^0]+)|0$/,`0${t>0?`.`:``}${p(Number(t||0))}$1`):e).join(`;`),h=e=>/\.0?/.test(e)||/0([^0]?)|0$/.test(e),g=e=>{let n=t.numfmt.getFormatInfo(e).type||`unknown`;return n===`general`&&t.numfmt.tokenize(e).some(e=>e.type===t.numfmt.tokenTypes.CONDITION)?`number`:n},_=(e,n,r=`en`,i)=>{try{let a=t.numfmt.formatColor(e,n),o=a?String(a):void 0;return{result:t.numfmt.format(e,n,{locale:r,dateSystem:i,throws:!1}),color:o}}catch(t){console.warn(`getPatternPreview error:`,e,t)}return{result:String(n)}},v=(e,n,i,a)=>e===t.DEFAULT_NUMBER_FORMAT?{result:String((0,r.stripErrorMargin)(n))}:_(e,n,i,a);function y(e){return(e==null?void 0:e.t)===t.CellValueType.NUMBER&&e.v!==void 0&&e.v!==null&&/e/i.test(String(e.v))}function b(e){let t=String(e==null?void 0:e.v),n=t.search(/e/i),r=t.indexOf(`.`),i=n>-1&&r>-1?n-r-1:0;return`0.${`0`.repeat(Math.max(2,i))}E+00`}function x(e){return(0,t.isDefaultFormat)(e)||(0,t.isTextFormat)(e)||g(e)===`scientific`}let S={id:`sheet.command.numfmt.set.numfmt`,type:t.CommandType.COMMAND,handler:(e,r)=>{if(!r)return!1;let i=e.get(t.ICommandService),a=e.get(t.IUniverInstanceService),o=e.get(t.IUndoRedoService),s=(0,n.getSheetCommandTarget)(a,r);if(!s)return!1;let{unitId:c,subUnitId:l,worksheet:u}=s,d=r.values.filter(e=>!y(u.getCellRaw(e.row,e.col))||x(e.pattern)),f=d.filter(e=>!!e.pattern),p=d.filter(e=>!e.pattern);if(!f.length&&!p.length)return!1;let m=(0,n.transformCellsToRange)(c,l,f),h={unitId:c,subUnitId:l,ranges:p.map(e=>({startColumn:e.col,startRow:e.row,endColumn:e.col,endRow:e.row}))},g=[],_=[];if(f.length){let r=f.reduce((e,r)=>{(0,t.isTextFormat)(r.pattern)&&e.setValue(r.row,r.col,{t:t.CellValueType.STRING});let i=u.getCellRaw(r.row,r.col);if(i){let t=(0,n.checkCellValueType)(i.v);t!==i.t&&e.setValue(r.row,r.col,{t})}return e},new t.ObjectMatrix).getMatrix(),i=new t.ObjectMatrix;new t.ObjectMatrix(r).forValue((e,t)=>{let n=u.getCellRaw(e,t);n?i.setValue(e,t,{t:n.t}):i.setValue(e,t,{t:void 0})}),Object.keys(m.values).forEach(e=>{let t=m.values[e];t.ranges=(0,n.rangeMerge)(t.ranges)}),g.push({id:n.SetNumfmtMutation.id,params:m});let a=(0,n.factorySetNumfmtUndoMutation)(e,m);_.push(...a)}if(p.length){h.ranges=(0,n.rangeMerge)(h.ranges);let r=p.reduce((e,t)=>{let r=u.getCellRaw(t.row,t.col);if(r){let i=(0,n.checkCellValueType)(r.v);i!==r.t&&e.setValue(t.row,t.col,{t:i})}return e},new t.ObjectMatrix).getMatrix(),i=new t.ObjectMatrix;new t.ObjectMatrix(r).forValue((e,t)=>{let n=u.getCellRaw(e,t);n?i.setValue(e,t,{t:n.t}):i.setValue(e,t,{t:void 0})}),g.push({id:n.RemoveNumfmtMutation.id,params:h},{id:n.SetRangeValuesMutation.id,params:{unitId:c,subUnitId:l,cellValue:r}});let a=(0,n.factoryRemoveNumfmtUndoMutation)(e,h);_.push({id:n.SetRangeValuesMutation.id,params:{unitId:c,subUnitId:l,cellValue:i.getMatrix()}},...a)}let v=(0,t.sequenceExecute)(g,i).result;return v&&o.pushUndoRedo({unitID:c,undoMutations:_,redoMutations:g}),v}},C={id:`sheet.command.numfmt.add.decimal.command`,type:t.CommandType.COMMAND,handler:async e=>{let r=e.get(t.ICommandService),i=e.get(n.SheetsSelectionsService),a=e.get(n.INumfmtService),o=e.get(t.IUniverInstanceService),s=i.getCurrentSelections();if(!s||!s.length)return!1;let c=(0,n.getSheetCommandTarget)(o);if(!c)return!1;let{unitId:l,subUnitId:u}=c,d=0;s.forEach(e=>{t.Range.foreach(e.range,(e,n)=>{let r=a.getValue(l,u,e,n);if(!r){let r=c.worksheet.getCellRaw(e,n);if(y(r)){d=Math.max(d,f(b(r)));return}if(!d&&r&&r.t===t.CellValueType.NUMBER&&r.v){let e=/\.(\d*)$/.exec(String(r.v));if(e){let t=e[1].length;if(!t)return;d=Math.max(d,t)}}return}let i=f(r.pattern);d=i>d?i:d})});let p=d+1,h=m(`0${p>0?`.0`:``}`,p),g=[];return s.forEach(e=>{t.Range.foreach(e.range,(e,n)=>{let r=a.getValue(l,u,e,n);if((0,t.isDefaultFormat)(r==null?void 0:r.pattern)){let t=c.worksheet.getCellRaw(e,n);g.push({row:e,col:n,pattern:y(t)?m(b(t),p):h})}else{let t=f(r.pattern),i=m(r.pattern,t+1);i!==r.pattern&&g.push({row:e,col:n,pattern:i})}})}),g.length?await r.executeCommand(S.id,{values:g}):!1}},w={id:`sheet.command.numfmt.set.currency`,type:t.CommandType.COMMAND,handler:async e=>{let r=e.get(t.ICommandService),i=e.get(n.SheetsSelectionsService),a=e.get(t.RegionService),s=i.getCurrentSelections();if(!s||!s.length)return!1;let l=[],u=c(o(a.getCurrentRegion()).locale);return s.forEach(e=>{t.Range.foreach(e.range,(e,t)=>{l.push({row:e,col:t,pattern:u,type:`currency`})})}),await r.executeCommand(S.id,{values:l})}},T={id:`sheet.command.numfmt.set.percent`,type:t.CommandType.COMMAND,handler:async e=>{let r=e.get(t.ICommandService),i=e.get(n.SheetsSelectionsService).getCurrentSelections();if(!i||!i.length)return!1;let a=[];return i.forEach(e=>{t.Range.foreach(e.range,(e,t)=>{a.push({row:e,col:t,pattern:`0%`,type:`percent`})})}),await r.executeCommand(S.id,{values:a})}},E={id:`sheet.command.numfmt.subtract.decimal.command`,type:t.CommandType.COMMAND,handler:async e=>{let r=e.get(t.ICommandService),i=e.get(n.SheetsSelectionsService),a=e.get(n.INumfmtService),o=e.get(t.IUniverInstanceService),s=i.getCurrentSelections();if(!s||!s.length)return!1;let c=(0,n.getSheetCommandTarget)(o);if(!c)return!1;let{unitId:l,subUnitId:u}=c,d=0;s.forEach(e=>{t.Range.foreach(e.range,(e,n)=>{let r=a.getValue(l,u,e,n);if(!r){let r=c.worksheet.getCellRaw(e,n);if(y(r)){d=Math.max(d,f(b(r)));return}if(!d&&r&&r.t===t.CellValueType.NUMBER&&r.v){let e=/\.(\d*)$/.exec(String(r.v));if(e){let t=e[1].length;if(!t)return;d=Math.max(d,t)}}return}let i=f(r.pattern);d=i>d?i:d})});let p=d-1,h=m(`0${p>0?`.0`:`.`}`,p),g=[];return s.forEach(e=>{t.Range.foreach(e.range,(e,n)=>{let r=a.getValue(l,u,e,n);if((0,t.isDefaultFormat)(r==null?void 0:r.pattern)){let t=c.worksheet.getCellRaw(e,n);g.push({row:e,col:n,pattern:y(t)?m(b(t),p):h})}else{let t=f(r.pattern);g.push({row:e,col:n,pattern:m(r.pattern,t-1)})}})}),await r.executeCommand(S.id,{values:g})}},D=`sheets-numfmt.config`,O={};function k(e){"@babel/helpers - typeof";return k=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},k(e)}function A(e,t){if(k(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(k(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function j(e){var t=A(e,`string`);return k(t)==`symbol`?t:t+``}function M(e,t,n){return(t=j(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function N(e,t){return function(n,r){t(n,r,e)}}function P(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let F={tl:{size:6,color:`#409f11`}},I=class extends t.Disposable{constructor(e,n,r,a,o,s,c){super(),this._instanceService=e,this._sheetInterceptorService=n,this._themeService=r,this._commandService=a,this._numfmtService=o,this._localeService=s,this._configService=c,M(this,`_renderCache`,new t.ObjectMatrix),M(this,`_locale$`,new i.BehaviorSubject(null)),M(this,`locale$`,this._locale$.asObservable()),this._initInterceptorCellContent()}get locale(){return this.getLocale()}getLocale(e){return this._locale$.getValue()??(0,t.getNumfmtLocaleTag)((e==null?void 0:e.getSnapshot().locale)??this._localeService.getCurrentLocale())}_initInterceptorCellContent(){this.disposeWithMe((0,i.merge)(this._locale$,this._localeService.currentLocale$).subscribe(()=>{this._renderCache.reset()})),this.disposeWithMe(this._sheetInterceptorService.intercept(n.INTERCEPTOR_POINT.CELL_CONTENT,{effect:t.InterceptorEffectEnum.Value|t.InterceptorEffectEnum.Style,handler:(e,t,n)=>n(this._formatCell(e,t)),priority:n.InterceptCellContentPriority.NUMFMT})),this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id===n.SetNumfmtMutation.id){let n=e.params;Object.keys(n.values).forEach(e=>{n.values[e].ranges.forEach(e=>{t.Range.foreach(e,(e,t)=>{this._renderCache.realDeleteValue(e,t)})})})}else if(e.id===n.SetRangeValuesMutation.id){let n=e.params;new t.ObjectMatrix(n.cellValue).forValue((e,t)=>{this._renderCache.realDeleteValue(e,t)})}})),this.disposeWithMe(this._instanceService.getCurrentTypeOfUnit$(t.UniverInstanceType.UNIVER_SHEET).pipe((0,i.switchMap)(e=>(e==null?void 0:e.activeSheet$)??(0,i.of)(null)),(0,i.skip)(1)).subscribe(()=>this._renderCache.reset()))}_formatCell(e,n){var r;if(!e||e.v==null||e.t===t.CellValueType.BOOLEAN||e.t===t.CellValueType.FORCE_STRING)return e;let{unitId:i,subUnitId:a,row:o,col:s,workbook:c}=n,l=this.getLocale(c),u=c.getDateSystem(),d=((r=c.getStyles().get(e.s))==null?void 0:r.n)??this._numfmtService.getValue(i,a,o,s),f=d==null?void 0:d.pattern;if((0,t.isDefaultFormat)(f)||!this._isNumericCell(e,f,l,u))return e;let p=e===n.rawData?{...e}:e;if((0,t.isTextFormat)(f)){var m;return p.t=t.CellValueType.STRING,(m=this._configService.getConfig(`sheets-numfmt.config`))!=null&&m.disableTextFormatMark||(p.markers={...p.markers,...F}),p}let h=`${i}_${a}_${e.v}_${f}_${l}_${u}`,g=this._renderCache.getValue(o,s);if(g&&g.parameters===h)return{...p,...g.result};let _=v(f,Number(e.v),l,u),y={v:_.result,t:t.CellValueType.NUMBER};if(_.result===``&&(y.coverable=!1),_.color){let e=this._themeService.getColorFromTheme(`${_.color}.500`)??_.color;e&&(y.interceptorStyle={cl:{rgb:e}})}return this._renderCache.setValue(o,s,{result:y,parameters:h}),Object.assign(p,y),p}_isNumericCell(e,r,i,a){var o;return e.t===t.CellValueType.NUMBER||(0,n.checkCellValueType)(e.v,e.t)===t.CellValueType.NUMBER||(0,t.isTextFormat)(r)&&typeof e.v==`string`&&typeof((o=(0,t.getNumfmtParseValueFilter)(e.v,{locale:i,dateSystem:a}))==null?void 0:o.v)==`number`}setNumfmtLocal(e){this._locale$.next(e)}};I=P([N(0,t.IUniverInstanceService),N(1,(0,t.Inject)(n.SheetInterceptorService)),N(2,(0,t.Inject)(t.ThemeService)),N(3,(0,t.Inject)(t.ICommandService)),N(4,(0,t.Inject)(n.INumfmtService)),N(5,(0,t.Inject)(t.LocaleService)),N(6,t.IConfigService)],I);var L=`@univerjs/sheets-numfmt`,R=`1.3.0`;let z=class extends t.Plugin{constructor(e=O,n,r,i){super(),this._config=e,this._injector=n,this._configService=r,this._commandService=i;let{...a}=(0,t.merge)({},O,this._config);this._configService.setConfig(D,a)}onStarting(){(0,t.registerDependencies)(this._injector,[[I]]),(0,t.touchDependencies)(this._injector,[[I]]),[C,E,w,T,S].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}};M(z,`pluginName`,`SHEET_NUMFMT_PLUGIN`),M(z,`packageName`,L),M(z,`version`,R),M(z,`type`,t.UniverInstanceType.UNIVER_SHEET),z=P([(0,t.DependentOn)(n.UniverSheetsPlugin),N(1,(0,t.Inject)(t.Injector)),N(2,t.IConfigService),N(3,t.ICommandService)],z);let B=e=>t.currencySymbols.find(t=>e.includes(t)),V={dates:[`yyyy/MM/dd`,`MM-dd`],shortDate:`MM-dd`},H={dates:[`m/d/yyyy`,`mm/dd/yyyy`,`mmm d, yyyy`,`m/d`,`mmmm d`],shortDate:`m/d`},U={dates:[`dd/mm/yyyy`,`d/m/yyyy`,`d mmm yyyy`,`dd/mm`,`d mmmm`],shortDate:`dd/mm`},W={dates:[`dd.mm.yyyy`,`d.m.yyyy`,`d mmm yyyy`,`dd.mm`,`d mmmm`],shortDate:`dd.mm`},G={dates:[`yyyy/MM/dd`,`yyyy"年"MM"月"dd"日"`,`MM-dd`,`M"月"d"日"`],shortDate:`MM-dd`,periodBeforeTime:!0},K={[t.LocaleType.EN_US]:H,[t.LocaleType.FR_FR]:U,[t.LocaleType.ZH_CN]:G,[t.LocaleType.RU_RU]:W,[t.LocaleType.ZH_TW]:G,[t.LocaleType.ZH_HK]:{...G,dates:[`dd/MM/yyyy`,...G.dates],shortDate:`dd/MM`},[t.LocaleType.VI_VN]:U,[t.LocaleType.FA_IR]:V,[t.LocaleType.CA_ES]:{dates:[`dd/mm/yyyy`,`d/m/yyyy`,`dd/mm`],shortDate:`dd/mm`},[t.LocaleType.JA_JP]:G,[t.LocaleType.KO_KR]:{dates:[`yyyy. mm. dd.`,`yyyy"년" m"월" d"일"`,`mm-dd`,`m"월" d"일"`],shortDate:`mm-dd`,periodBeforeTime:!0},[t.LocaleType.ES_ES]:U,[t.LocaleType.SK_SK]:W,[t.LocaleType.PT_BR]:U,[t.LocaleType.DE_DE]:W,[t.LocaleType.IT_IT]:U,[t.LocaleType.ID_ID]:U,[t.LocaleType.PL_PL]:W,[t.LocaleType.AR_SA]:{dates:[`dd/mm/yyyy`,`d/m/yyyy`,`dd/mm`],shortDate:`dd/mm`}};function q(e){let t=K[e]??V,n=[`hh:mm`,`h:mm`,`h:mm:ss`].map(e=>t.periodBeforeTime?`AM/PM ${e}`:`${e} AM/PM`);return[.../* @__PURE__ */ new Set([`yyyy-MM-dd`,...t.dates,`h:mm:ss`,`h:mm`,...n,`${t.shortDate} ${n[0]}`])]}let J=()=>t.currencySymbols.map(e=>({label:e,value:e})),Y=e=>d.map(t=>({label:t.label(e),value:t.suffix(e),color:t.color})),X=(0,t.excelDateTimeSerial)(new Date(Date.UTC(1930,7,5,13,30,30)));e.AddDecimalCommand=C,e.CURRENCYFORMAT=d,e.DATEFMTLISG=l,e.NUMBERFORMAT=u,e.SHEETS_NUMFMT_PLUGIN_CONFIG_KEY=D,e.SetCurrencyCommand=w,e.SetNumfmtCommand=S,e.SetPercentCommand=T,Object.defineProperty(e,"SheetsNumfmtCellContentController",{enumerable:!0,get:function(){return I}}),e.SubtractDecimalCommand=E,Object.defineProperty(e,"UniverSheetsNumfmtPlugin",{enumerable:!0,get:function(){return z}}),e.getCurrencyFormat=c,e.getCurrencyFormatOptions=Y,e.getCurrencyOptions=J,e.getCurrencySymbolByLocale=s,e.getCurrencySymbolIconByLocale=o,e.getCurrencyType=B,e.getDateFormatOptions=(e,n)=>{if(e===void 0)return l.map(e=>({label:e.label,value:e.suffix}));let r=(0,t.getNumfmtLocaleTag)(e),i=q(e);return n&&!i.includes(n)&&i.unshift(n),i.map(e=>({label:t.numfmt.format(e,X,{locale:r}),value:e}))},e.getDecimalFromPattern=f,e.getDecimalString=p,e.getNumberFormatOptions=()=>u.map(e=>({label:e.label,value:e.suffix,color:e.color})),e.getPatternPreview=_,e.getPatternPreviewIgnoreGeneral=v,e.getPatternType=g,e.isPatternHasDecimal=h,e.localeCurrencySymbolMap=a,e.setPatternDecimal=m});
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("@univerjs/engine-formula"),require("rxjs")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/sheets`,`@univerjs/engine-formula`,`rxjs`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverSheetsNumfmt={},e.UniverCore,e.UniverSheets,e.UniverEngineFormula,e.rxjs))})(this,function(e,t,n,r,i){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});let a=/* @__PURE__ */ new Map([[t.LocaleType.EN_US,`$`],[t.LocaleType.RU_RU,`₽`],[t.LocaleType.VI_VN,`₫`],[t.LocaleType.ZH_CN,`¥`],[t.LocaleType.ZH_TW,`NT$`],[t.LocaleType.ZH_HK,`HK$`],[t.LocaleType.FR_FR,`€`],[t.LocaleType.FA_IR,`﷼`],[t.LocaleType.KO_KR,`₩`],[t.LocaleType.ES_ES,`€`],[t.LocaleType.CA_ES,`€`],[t.LocaleType.SK_SK,`€`],[t.LocaleType.JA_JP,`¥`],[t.LocaleType.PT_BR,`R$`],[t.LocaleType.DE_DE,`€`],[t.LocaleType.IT_IT,`€`],[t.LocaleType.ID_ID,`Rp`],[t.LocaleType.PL_PL,`zł`],[t.LocaleType.AR_SA,`﷼`]]);function o(e){switch(e){case t.LocaleType.CA_ES:case t.LocaleType.DE_DE:case t.LocaleType.ES_ES:case t.LocaleType.FR_FR:case t.LocaleType.IT_IT:case t.LocaleType.SK_SK:return{icon:`EuroIcon`,symbol:a.get(e)||`€`,locale:e};case t.LocaleType.RU_RU:return{icon:`RoubleIcon`,symbol:a.get(e)||`₽`,locale:e};case t.LocaleType.JA_JP:case t.LocaleType.ZH_CN:return{icon:`RmbIcon`,symbol:a.get(e)||`¥`,locale:e};case t.LocaleType.VI_VN:return{icon:`DongIcon`,symbol:a.get(e)||`₫`,locale:e};case t.LocaleType.AR_SA:case t.LocaleType.FA_IR:return{icon:`RialIcon`,symbol:a.get(e)||`﷼`,locale:e};case t.LocaleType.KO_KR:return{icon:`WonIcon`,symbol:a.get(e)||`₩`,locale:e};case t.LocaleType.ID_ID:return{icon:`RupiahIcon`,symbol:a.get(e)||`Rp`,locale:e};case t.LocaleType.PL_PL:return{icon:`ZlotyIcon`,symbol:a.get(e)||`zł`,locale:e};case t.LocaleType.EN_US:case t.LocaleType.PT_BR:case t.LocaleType.ZH_HK:case t.LocaleType.ZH_TW:default:return{icon:`DollarIcon`,symbol:a.get(e)||`$`,locale:e}}}function s(e){return a.get(e)||`$`}function c(e,t=2){let n=t;t>127&&(n=127);let r=``;return n>0&&(r=`.${`0`.repeat(n)}`),`"${s(e)}"#,##0${r}_);[Red]("${s(e)}"#,##0${r})`}let l=[{label:`1930-08-05`,suffix:`yyyy-MM-dd`},{label:`1930/08/05`,suffix:`yyyy/MM/dd`},{label:`1930年08月05日`,suffix:`yyyy"年"MM"月"dd"日"`},{label:`08-05`,suffix:`MM-dd`},{label:`8月5日`,suffix:`M"月"d"日"`},{label:`13:30:30`,suffix:`h:mm:ss`},{label:`13:30`,suffix:`h:mm`},{label:`下午01:30`,suffix:`A/P hh:mm`},{label:`下午1:30`,suffix:`A/P h:mm`},{label:`下午1:30:30`,suffix:`A/P h:mm:ss`},{label:`08-05 下午 01:30`,suffix:`MM-dd A/P hh:mm`}],u=[{label:`(1,235)`,suffix:`#,##0_);(#,##0)`},{label:`(1,235) `,suffix:`#,##0_);[Red](#,##0)`,color:`red`},{label:`1,234.56`,suffix:`#,##0.00_);#,##0.00`},{label:`1,234.56`,suffix:`#,##0.00_);[Red]#,##0.00`,color:`red`},{label:`-1,234.56`,suffix:`#,##0.00_);-#,##0.00`},{label:`-1,234.56`,suffix:`#,##0.00_);[Red]-#,##0.00`,color:`red`}],d=[{label:e=>`${e}1,235`,suffix:e=>`"${e}"#,##0.00_);"${e}"#,##0.00`},{label:e=>`${e}1,235`,suffix:e=>`"${e}"#,##0.00_);[Red]"${e}"#,##0.00`,color:`red`},{label:e=>`(${e}1,235)`,suffix:e=>`"${e}"#,##0.00_);("${e}"#,##0.00)`},{label:e=>`(${e}1,235)`,suffix:e=>`"${e}"#,##0.00_);[Red]("${e}"#,##0.00)`,color:`red`},{label:e=>`-${e}1,235`,suffix:e=>`"${e}"#,##0.00_);-"${e}"#,##0.00`},{label:e=>`-${e}1,235`,suffix:e=>`"${e}"#,##0.00_);[Red]-"${e}"#,##0.00`,color:`red`}],f=(e,n=0)=>e?t.numfmt.getFormatInfo(e).maxDecimals??n:n,p=e=>Array(Math.min(Math.max(0,Number(e)),30)).fill(0).join(``),m=(e,t)=>e.split(`;`).map(e=>/\.0?/.test(e)?e.replace(/\.0*/g,`${t>0?`.`:``}${p(Number(t||0))}`):/0([^0]?)|0$/.test(e)?e.replace(/0([^0]+)|0$/,`0${t>0?`.`:``}${p(Number(t||0))}$1`):e).join(`;`),h=e=>/\.0?/.test(e)||/0([^0]?)|0$/.test(e),g=e=>{let n=t.numfmt.getFormatInfo(e).type||`unknown`;return n===`general`&&t.numfmt.tokenize(e).some(e=>e.type===t.numfmt.tokenTypes.CONDITION)?`number`:n},_=(e,n,r=`en`,i)=>{try{let a=t.numfmt.formatColor(e,n),o=a?String(a):void 0;return{result:t.numfmt.format(e,n,{locale:r,dateSystem:i,throws:!1}),color:o}}catch(t){console.warn(`getPatternPreview error:`,e,t)}return{result:String(n)}},v=(e,n,i,a)=>e===t.DEFAULT_NUMBER_FORMAT?{result:String((0,r.stripErrorMargin)(n))}:_(e,n,i,a);function y(e){return(e==null?void 0:e.t)===t.CellValueType.NUMBER&&e.v!==void 0&&e.v!==null&&/e/i.test(String(e.v))}function b(e){let t=String(e==null?void 0:e.v),n=t.search(/e/i),r=t.indexOf(`.`),i=n>-1&&r>-1?n-r-1:0;return`0.${`0`.repeat(Math.max(2,i))}E+00`}function x(e){return(0,t.isDefaultFormat)(e)||(0,t.isTextFormat)(e)||g(e)===`scientific`}let S={id:`sheet.command.numfmt.set.numfmt`,type:t.CommandType.COMMAND,handler:(e,r)=>{if(!r)return!1;let i=e.get(t.ICommandService),a=e.get(t.IUniverInstanceService),o=e.get(t.IUndoRedoService),s=(0,n.getSheetCommandTarget)(a,r);if(!s)return!1;let{unitId:c,subUnitId:l,worksheet:u}=s,d=r.values.filter(e=>!y(u.getCellRaw(e.row,e.col))||x(e.pattern)),f=d.filter(e=>!!e.pattern),p=d.filter(e=>!e.pattern);if(!f.length&&!p.length)return!1;let m=(0,n.transformCellsToRange)(c,l,f),h={unitId:c,subUnitId:l,ranges:p.map(e=>({startColumn:e.col,startRow:e.row,endColumn:e.col,endRow:e.row}))},g=[],_=[];if(f.length){let r=f.reduce((e,r)=>{(0,t.isTextFormat)(r.pattern)&&e.setValue(r.row,r.col,{t:t.CellValueType.STRING});let i=u.getCellRaw(r.row,r.col);if(i){let t=(0,n.checkCellValueType)(i.v);t!==i.t&&e.setValue(r.row,r.col,{t})}return e},new t.ObjectMatrix).getMatrix(),i=new t.ObjectMatrix;new t.ObjectMatrix(r).forValue((e,t)=>{let n=u.getCellRaw(e,t);n?i.setValue(e,t,{t:n.t}):i.setValue(e,t,{t:void 0})}),Object.keys(m.values).forEach(e=>{let t=m.values[e];t.ranges=(0,n.rangeMerge)(t.ranges)}),g.push({id:n.SetNumfmtMutation.id,params:m});let a=(0,n.factorySetNumfmtUndoMutation)(e,m);_.push(...a)}if(p.length){h.ranges=(0,n.rangeMerge)(h.ranges);let r=p.reduce((e,t)=>{let r=u.getCellRaw(t.row,t.col);if(r){let i=(0,n.checkCellValueType)(r.v);i!==r.t&&e.setValue(t.row,t.col,{t:i})}return e},new t.ObjectMatrix).getMatrix(),i=new t.ObjectMatrix;new t.ObjectMatrix(r).forValue((e,t)=>{let n=u.getCellRaw(e,t);n?i.setValue(e,t,{t:n.t}):i.setValue(e,t,{t:void 0})}),g.push({id:n.RemoveNumfmtMutation.id,params:h},{id:n.SetRangeValuesMutation.id,params:{unitId:c,subUnitId:l,cellValue:r}});let a=(0,n.factoryRemoveNumfmtUndoMutation)(e,h);_.push({id:n.SetRangeValuesMutation.id,params:{unitId:c,subUnitId:l,cellValue:i.getMatrix()}},...a)}let v=(0,t.sequenceExecute)(g,i).result;return v&&o.pushUndoRedo({unitID:c,undoMutations:_,redoMutations:g}),v}},C={id:`sheet.command.numfmt.add.decimal.command`,type:t.CommandType.COMMAND,handler:async e=>{let r=e.get(t.ICommandService),i=e.get(n.SheetsSelectionsService),a=e.get(n.INumfmtService),o=e.get(t.IUniverInstanceService),s=i.getCurrentSelections();if(!s||!s.length)return!1;let c=(0,n.getSheetCommandTarget)(o);if(!c)return!1;let{unitId:l,subUnitId:u}=c,d=0;s.forEach(e=>{t.Range.foreach(e.range,(e,n)=>{let r=a.getValue(l,u,e,n);if(!r){let r=c.worksheet.getCellRaw(e,n);if(y(r)){d=Math.max(d,f(b(r)));return}if(!d&&r&&r.t===t.CellValueType.NUMBER&&r.v){let e=/\.(\d*)$/.exec(String(r.v));if(e){let t=e[1].length;if(!t)return;d=Math.max(d,t)}}return}let i=f(r.pattern);d=i>d?i:d})});let p=d+1,h=m(`0${p>0?`.0`:``}`,p),g=[];return s.forEach(e=>{t.Range.foreach(e.range,(e,n)=>{let r=a.getValue(l,u,e,n);if((0,t.isDefaultFormat)(r==null?void 0:r.pattern)){let t=c.worksheet.getCellRaw(e,n);g.push({row:e,col:n,pattern:y(t)?m(b(t),p):h})}else{let t=f(r.pattern),i=m(r.pattern,t+1);i!==r.pattern&&g.push({row:e,col:n,pattern:i})}})}),g.length?await r.executeCommand(S.id,{values:g}):!1}},w={id:`sheet.command.numfmt.set.currency`,type:t.CommandType.COMMAND,handler:async e=>{let r=e.get(t.ICommandService),i=e.get(n.SheetsSelectionsService),a=e.get(t.RegionService),s=i.getCurrentSelections();if(!s||!s.length)return!1;let l=[],u=c(o(a.getCurrentRegion()).locale);return s.forEach(e=>{t.Range.foreach(e.range,(e,t)=>{l.push({row:e,col:t,pattern:u,type:`currency`})})}),await r.executeCommand(S.id,{values:l})}},T={id:`sheet.command.numfmt.set.percent`,type:t.CommandType.COMMAND,handler:async e=>{let r=e.get(t.ICommandService),i=e.get(n.SheetsSelectionsService).getCurrentSelections();if(!i||!i.length)return!1;let a=[];return i.forEach(e=>{t.Range.foreach(e.range,(e,t)=>{a.push({row:e,col:t,pattern:`0%`,type:`percent`})})}),await r.executeCommand(S.id,{values:a})}},E={id:`sheet.command.numfmt.subtract.decimal.command`,type:t.CommandType.COMMAND,handler:async e=>{let r=e.get(t.ICommandService),i=e.get(n.SheetsSelectionsService),a=e.get(n.INumfmtService),o=e.get(t.IUniverInstanceService),s=i.getCurrentSelections();if(!s||!s.length)return!1;let c=(0,n.getSheetCommandTarget)(o);if(!c)return!1;let{unitId:l,subUnitId:u}=c,d=0;s.forEach(e=>{t.Range.foreach(e.range,(e,n)=>{let r=a.getValue(l,u,e,n);if(!r){let r=c.worksheet.getCellRaw(e,n);if(y(r)){d=Math.max(d,f(b(r)));return}if(!d&&r&&r.t===t.CellValueType.NUMBER&&r.v){let e=/\.(\d*)$/.exec(String(r.v));if(e){let t=e[1].length;if(!t)return;d=Math.max(d,t)}}return}let i=f(r.pattern);d=i>d?i:d})});let p=d-1,h=m(`0${p>0?`.0`:`.`}`,p),g=[];return s.forEach(e=>{t.Range.foreach(e.range,(e,n)=>{let r=a.getValue(l,u,e,n);if((0,t.isDefaultFormat)(r==null?void 0:r.pattern)){let t=c.worksheet.getCellRaw(e,n);g.push({row:e,col:n,pattern:y(t)?m(b(t),p):h})}else{let t=f(r.pattern);g.push({row:e,col:n,pattern:m(r.pattern,t-1)})}})}),await r.executeCommand(S.id,{values:g})}},D=`sheets-numfmt.config`,O={};function k(e){"@babel/helpers - typeof";return k=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},k(e)}function A(e,t){if(k(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(k(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function j(e){var t=A(e,`string`);return k(t)==`symbol`?t:t+``}function M(e,t,n){return(t=j(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function N(e,t){return function(n,r){t(n,r,e)}}function P(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let F={tl:{size:6,color:`#409f11`}},I=class extends t.Disposable{constructor(e,n,r,a,o,s,c){super(),this._instanceService=e,this._sheetInterceptorService=n,this._themeService=r,this._commandService=a,this._numfmtService=o,this._localeService=s,this._configService=c,M(this,`_renderCache`,new t.ObjectMatrix),M(this,`_locale$`,new i.BehaviorSubject(null)),M(this,`locale$`,this._locale$.asObservable()),this._initInterceptorCellContent()}get locale(){return this.getLocale()}getLocale(e){return this._locale$.getValue()??(0,t.getNumfmtLocaleTag)((e==null?void 0:e.getSnapshot().locale)??this._localeService.getCurrentLocale())}_initInterceptorCellContent(){this.disposeWithMe((0,i.merge)(this._locale$,this._localeService.currentLocale$).subscribe(()=>{this._renderCache.reset()})),this.disposeWithMe(this._sheetInterceptorService.intercept(n.INTERCEPTOR_POINT.CELL_CONTENT,{effect:t.InterceptorEffectEnum.Value|t.InterceptorEffectEnum.Style,handler:(e,t,n)=>n(this._formatCell(e,t)),priority:n.InterceptCellContentPriority.NUMFMT})),this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id===n.SetNumfmtMutation.id){let n=e.params;Object.keys(n.values).forEach(e=>{n.values[e].ranges.forEach(e=>{t.Range.foreach(e,(e,t)=>{this._renderCache.realDeleteValue(e,t)})})})}else if(e.id===n.SetRangeValuesMutation.id){let n=e.params;new t.ObjectMatrix(n.cellValue).forValue((e,t)=>{this._renderCache.realDeleteValue(e,t)})}})),this.disposeWithMe(this._instanceService.getCurrentTypeOfUnit$(t.UniverInstanceType.UNIVER_SHEET).pipe((0,i.switchMap)(e=>(e==null?void 0:e.activeSheet$)??(0,i.of)(null)),(0,i.skip)(1)).subscribe(()=>this._renderCache.reset()))}_getNumfmtValue(e,t){var n,r;let{unitId:i,subUnitId:a,row:o,col:s,workbook:c}=t,l=(n=e.themeStyle)==null?void 0:n.n;if(l===void 0){var u;return((u=c.getStyles().get(e.s))==null?void 0:u.n)??this._numfmtService.getValue(i,a,o,s)}let d=(r=c.getStyles().getStyleByCell(e))==null?void 0:r.n;return d===void 0?this._numfmtService.getValue(i,a,o,s)??l:d}_formatCell(e,n){if(!e||e.v==null||e.t===t.CellValueType.BOOLEAN||e.t===t.CellValueType.FORCE_STRING)return e;let{unitId:r,subUnitId:i,row:a,col:o,workbook:s}=n,c=this.getLocale(s),l=s.getDateSystem(),u=this._getNumfmtValue(e,n),d=u==null?void 0:u.pattern;if((0,t.isDefaultFormat)(d)||!this._isNumericCell(e,d,c,l))return e;let f=e===n.rawData?{...e}:e;if((0,t.isTextFormat)(d))return this._formatTextCell(e,f);let p=`${r}_${i}_${e.v}_${d}_${c}_${l}`,m=this._renderCache.getValue(a,o);if(m&&m.parameters===p)return{...f,...m.result};let h=v(d,Number(e.v),c,l),g={v:h.result,t:t.CellValueType.NUMBER};if(h.result===``&&(g.coverable=!1),h.color){let e=this._themeService.getColorFromTheme(`${h.color}.500`)??h.color;e&&(g.interceptorStyle={cl:{rgb:e}})}return this._renderCache.setValue(a,o,{result:g,parameters:p}),Object.assign(f,g),f}_formatTextCell(e,n){var i;return e.t===t.CellValueType.NUMBER&&(0,t.isRealNum)(n.v)?n.v=(0,r.stripErrorMargin)(Number(n.v)):n.t=t.CellValueType.STRING,(i=this._configService.getConfig(`sheets-numfmt.config`))!=null&&i.disableTextFormatMark||(n.markers={...n.markers,...F}),n}_isNumericCell(e,r,i,a){var o;return e.t===t.CellValueType.NUMBER||(0,n.checkCellValueType)(e.v,e.t)===t.CellValueType.NUMBER||(0,t.isTextFormat)(r)&&typeof e.v==`string`&&typeof((o=(0,t.getNumfmtParseValueFilter)(e.v,{locale:i,dateSystem:a}))==null?void 0:o.v)==`number`}setNumfmtLocal(e){this._locale$.next(e)}};I=P([N(0,t.IUniverInstanceService),N(1,(0,t.Inject)(n.SheetInterceptorService)),N(2,(0,t.Inject)(t.ThemeService)),N(3,(0,t.Inject)(t.ICommandService)),N(4,(0,t.Inject)(n.INumfmtService)),N(5,(0,t.Inject)(t.LocaleService)),N(6,t.IConfigService)],I);var L=`@univerjs/sheets-numfmt`,R=`1.4.0`;let z=class extends t.Plugin{constructor(e=O,n,r,i){super(),this._config=e,this._injector=n,this._configService=r,this._commandService=i;let{...a}=(0,t.merge)({},O,this._config);this._configService.setConfig(D,a)}onStarting(){(0,t.registerDependencies)(this._injector,[[I]]),(0,t.touchDependencies)(this._injector,[[I]]),[C,E,w,T,S].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}};M(z,`pluginName`,`SHEET_NUMFMT_PLUGIN`),M(z,`packageName`,L),M(z,`version`,R),M(z,`type`,t.UniverInstanceType.UNIVER_SHEET),z=P([(0,t.DependentOn)(n.UniverSheetsPlugin),N(1,(0,t.Inject)(t.Injector)),N(2,t.IConfigService),N(3,t.ICommandService)],z);let B=e=>t.currencySymbols.find(t=>e.includes(t)),V={dates:[`yyyy/MM/dd`,`MM-dd`],shortDate:`MM-dd`},H={dates:[`m/d/yyyy`,`mm/dd/yyyy`,`mmm d, yyyy`,`m/d`,`mmmm d`],shortDate:`m/d`},U={dates:[`dd/mm/yyyy`,`d/m/yyyy`,`d mmm yyyy`,`dd/mm`,`d mmmm`],shortDate:`dd/mm`},W={dates:[`dd.mm.yyyy`,`d.m.yyyy`,`d mmm yyyy`,`dd.mm`,`d mmmm`],shortDate:`dd.mm`},G={dates:[`yyyy/MM/dd`,`yyyy"年"MM"月"dd"日"`,`MM-dd`,`M"月"d"日"`],shortDate:`MM-dd`,periodBeforeTime:!0},K={[t.LocaleType.EN_US]:H,[t.LocaleType.FR_FR]:U,[t.LocaleType.ZH_CN]:G,[t.LocaleType.RU_RU]:W,[t.LocaleType.ZH_TW]:G,[t.LocaleType.ZH_HK]:{...G,dates:[`dd/MM/yyyy`,...G.dates],shortDate:`dd/MM`},[t.LocaleType.VI_VN]:U,[t.LocaleType.FA_IR]:V,[t.LocaleType.CA_ES]:{dates:[`dd/mm/yyyy`,`d/m/yyyy`,`dd/mm`],shortDate:`dd/mm`},[t.LocaleType.JA_JP]:G,[t.LocaleType.KO_KR]:{dates:[`yyyy. mm. dd.`,`yyyy"년" m"월" d"일"`,`mm-dd`,`m"월" d"일"`],shortDate:`mm-dd`,periodBeforeTime:!0},[t.LocaleType.ES_ES]:U,[t.LocaleType.SK_SK]:W,[t.LocaleType.PT_BR]:U,[t.LocaleType.DE_DE]:W,[t.LocaleType.IT_IT]:U,[t.LocaleType.ID_ID]:U,[t.LocaleType.PL_PL]:W,[t.LocaleType.AR_SA]:{dates:[`dd/mm/yyyy`,`d/m/yyyy`,`dd/mm`],shortDate:`dd/mm`}};function q(e){let t=K[e]??V,n=[`hh:mm`,`h:mm`,`h:mm:ss`].map(e=>t.periodBeforeTime?`AM/PM ${e}`:`${e} AM/PM`);return[.../* @__PURE__ */ new Set([`yyyy-MM-dd`,...t.dates,`h:mm:ss`,`h:mm`,...n,`${t.shortDate} ${n[0]}`])]}let J=()=>t.currencySymbols.map(e=>({label:e,value:e})),Y=e=>d.map(t=>({label:t.label(e),value:t.suffix(e),color:t.color})),X=(0,t.excelDateTimeSerial)(new Date(Date.UTC(1930,7,5,13,30,30)));e.AddDecimalCommand=C,e.CURRENCYFORMAT=d,e.DATEFMTLISG=l,e.NUMBERFORMAT=u,e.SHEETS_NUMFMT_PLUGIN_CONFIG_KEY=D,e.SetCurrencyCommand=w,e.SetNumfmtCommand=S,e.SetPercentCommand=T,Object.defineProperty(e,"SheetsNumfmtCellContentController",{enumerable:!0,get:function(){return I}}),e.SubtractDecimalCommand=E,Object.defineProperty(e,"UniverSheetsNumfmtPlugin",{enumerable:!0,get:function(){return z}}),e.getCurrencyFormat=c,e.getCurrencyFormatOptions=Y,e.getCurrencyOptions=J,e.getCurrencySymbolByLocale=s,e.getCurrencySymbolIconByLocale=o,e.getCurrencyType=B,e.getDateFormatOptions=(e,n)=>{if(e===void 0)return l.map(e=>({label:e.label,value:e.suffix}));let r=(0,t.getNumfmtLocaleTag)(e),i=q(e);return n&&!i.includes(n)&&i.unshift(n),i.map(e=>({label:t.numfmt.format(e,X,{locale:r}),value:e}))},e.getDecimalFromPattern=f,e.getDecimalString=p,e.getNumberFormatOptions=()=>u.map(e=>({label:e.label,value:e.suffix,color:e.color})),e.getPatternPreview=_,e.getPatternPreviewIgnoreGeneral=v,e.getPatternType=g,e.isPatternHasDecimal=h,e.localeCurrencySymbolMap=a,e.setPatternDecimal=m});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/sheets-numfmt",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Number format services and commands for Univer Sheets.",
|
|
6
6
|
"author": "DreamNum Co., Ltd. <developer@univer.ai>",
|
|
@@ -62,23 +62,23 @@
|
|
|
62
62
|
"rxjs": ">=7.0.0"
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@univerjs/core": "1.
|
|
66
|
-
"@univerjs/engine-formula": "1.
|
|
67
|
-
"@univerjs/sheets": "1.
|
|
65
|
+
"@univerjs/core": "1.4.0",
|
|
66
|
+
"@univerjs/engine-formula": "1.4.0",
|
|
67
|
+
"@univerjs/sheets": "1.4.0"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
|
-
"@univerjs-infra/shared": "1.
|
|
70
|
+
"@univerjs-infra/shared": "1.4.0",
|
|
71
71
|
"rxjs": "7.8.2",
|
|
72
|
-
"
|
|
73
|
-
"vitest": "^5.0.
|
|
72
|
+
"tsrs": "0.20.1-ts7.1.0-beta",
|
|
73
|
+
"vitest": "^5.0.5"
|
|
74
74
|
},
|
|
75
75
|
"scripts": {
|
|
76
76
|
"test": "vitest run",
|
|
77
77
|
"test:watch": "vitest",
|
|
78
78
|
"coverage": "vitest run --coverage",
|
|
79
|
-
"typecheck": "
|
|
79
|
+
"typecheck": "tsrs --noEmit",
|
|
80
80
|
"build:bundle": "univer-cli build",
|
|
81
|
-
"build:types": "
|
|
81
|
+
"build:types": "tsrs -p tsconfig.node.json",
|
|
82
82
|
"build": "pnpm run build:bundle && pnpm run build:types"
|
|
83
83
|
},
|
|
84
84
|
"module": "./lib/es/index.js"
|