@univerjs/sheets-numfmt 1.0.0-insiders.20260813-7c9aa50 → 1.0.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/LICENSE ADDED
@@ -0,0 +1,176 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
package/README.md CHANGED
@@ -39,4 +39,3 @@ Use this package with `@univerjs/sheets-numfmt-ui` when users need number-format
39
39
  - [Documentation](https://docs.univer.ai)
40
40
  - [NPM package](https://npmjs.com/package/@univerjs/sheets-numfmt)
41
41
  - [GitHub repository](https://github.com/dream-num/univer)
42
-
package/lib/cjs/index.js CHANGED
@@ -279,13 +279,18 @@ const isPatternHasDecimal = (pattern) => /\.0?/.test(pattern) || /0([^0]?)|0$/.t
279
279
 
280
280
  //#endregion
281
281
  //#region src/utils/pattern.ts
282
- const getPatternType = (pattern) => _univerjs_core.numfmt.getFormatInfo(pattern).type || "unknown";
283
- const getPatternPreview = (pattern, value, locale = "en") => {
282
+ const getPatternType = (pattern) => {
283
+ const type = _univerjs_core.numfmt.getFormatInfo(pattern).type || "unknown";
284
+ if (type === "general" && _univerjs_core.numfmt.tokenize(pattern).some((token) => token.type === _univerjs_core.numfmt.tokenTypes.CONDITION)) return "number";
285
+ return type;
286
+ };
287
+ const getPatternPreview = (pattern, value, locale = "en", dateSystem) => {
284
288
  try {
285
289
  const formatColor = _univerjs_core.numfmt.formatColor(pattern, value);
286
290
  const color = formatColor ? String(formatColor) : void 0;
287
291
  const result = _univerjs_core.numfmt.format(pattern, value, {
288
292
  locale,
293
+ dateSystem,
289
294
  throws: false
290
295
  });
291
296
  if (value < 0) return {
@@ -298,9 +303,9 @@ const getPatternPreview = (pattern, value, locale = "en") => {
298
303
  }
299
304
  return { result: String(value) };
300
305
  };
301
- const getPatternPreviewIgnoreGeneral = (pattern, value, locale) => {
306
+ const getPatternPreviewIgnoreGeneral = (pattern, value, locale, dateSystem) => {
302
307
  if (pattern === _univerjs_core.DEFAULT_NUMBER_FORMAT) return { result: String((0, _univerjs_engine_formula.stripErrorMargin)(value)) };
303
- return getPatternPreview(pattern, value, locale);
308
+ return getPatternPreview(pattern, value, locale, dateSystem);
304
309
  };
305
310
 
306
311
  //#endregion
@@ -333,7 +338,8 @@ const SetNumfmtCommand = {
333
338
  if (!target) return false;
334
339
  const { unitId, subUnitId, worksheet } = target;
335
340
  const values = params.values.filter((value) => {
336
- return !isScientificNotationNumericCell(worksheet.getCellRaw(value.row, value.col)) || isAllowedPatternForScientificNotationNumber(value.pattern);
341
+ const cell = worksheet.getCellRaw(value.row, value.col);
342
+ return !isScientificNotationNumericCell(cell) || isAllowedPatternForScientificNotationNumber(value.pattern);
337
343
  });
338
344
  const setCells = values.filter((value) => !!value.pattern);
339
345
  const removeCells = values.filter((value) => !value.pattern);
@@ -509,7 +515,8 @@ const SetCurrencyCommand = {
509
515
  const selections = selectionManagerService.getCurrentSelections();
510
516
  if (!selections || !selections.length) return false;
511
517
  const values = [];
512
- const currencyFormat = getCurrencyFormat(getCurrencySymbolIconByLocale(regionService.getCurrentRegion()).locale);
518
+ const currencySymbolIcon = getCurrencySymbolIconByLocale(regionService.getCurrentRegion());
519
+ const currencyFormat = getCurrencyFormat(currencySymbolIcon.locale);
513
520
  selections.forEach((selection) => {
514
521
  _univerjs_core.Range.foreach(selection.range, (row, col) => {
515
522
  values.push({
@@ -637,7 +644,7 @@ const configSymbol = Symbol(SHEETS_NUMFMT_PLUGIN_CONFIG_KEY);
637
644
  const defaultPluginConfig = {};
638
645
 
639
646
  //#endregion
640
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/typeof.js
647
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/typeof.js
641
648
  function _typeof(o) {
642
649
  "@babel/helpers - typeof";
643
650
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -648,7 +655,7 @@ function _typeof(o) {
648
655
  }
649
656
 
650
657
  //#endregion
651
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPrimitive.js
658
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPrimitive.js
652
659
  function toPrimitive(t, r) {
653
660
  if ("object" != _typeof(t) || !t) return t;
654
661
  var e = t[Symbol.toPrimitive];
@@ -661,14 +668,14 @@ function toPrimitive(t, r) {
661
668
  }
662
669
 
663
670
  //#endregion
664
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPropertyKey.js
671
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPropertyKey.js
665
672
  function toPropertyKey(t) {
666
673
  var i = toPrimitive(t, "string");
667
674
  return "symbol" == _typeof(i) ? i : i + "";
668
675
  }
669
676
 
670
677
  //#endregion
671
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/defineProperty.js
678
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/defineProperty.js
672
679
  function _defineProperty(e, r, t) {
673
680
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
674
681
  value: t,
@@ -679,7 +686,7 @@ function _defineProperty(e, r, t) {
679
686
  }
680
687
 
681
688
  //#endregion
682
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorateParam.js
689
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorateParam.js
683
690
  function __decorateParam(paramIndex, decorator) {
684
691
  return function(target, key) {
685
692
  decorator(target, key, paramIndex);
@@ -687,7 +694,7 @@ function __decorateParam(paramIndex, decorator) {
687
694
  }
688
695
 
689
696
  //#endregion
690
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorate.js
697
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorate.js
691
698
  function __decorate(decorators, target, key, desc) {
692
699
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
693
700
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -711,35 +718,15 @@ let SheetsNumfmtCellContentController = class SheetsNumfmtCellContentController
711
718
  this._numfmtService = _numfmtService;
712
719
  this._localeService = _localeService;
713
720
  this._configService = _configService;
714
- _defineProperty(this, "_locale$", new rxjs.BehaviorSubject("en"));
721
+ _defineProperty(this, "_locale$", new rxjs.BehaviorSubject(null));
715
722
  _defineProperty(this, "locale$", this._locale$.asObservable());
716
723
  this._initInterceptorCellContent();
717
724
  }
718
725
  get locale() {
719
- const _locale = this._locale$.getValue();
720
- if (_locale) return _locale;
721
- switch (this._localeService.getCurrentLocale()) {
722
- case _univerjs_core.LocaleType.FR_FR: return "fr";
723
- case _univerjs_core.LocaleType.RU_RU: return "ru";
724
- case _univerjs_core.LocaleType.VI_VN: return "vi";
725
- case _univerjs_core.LocaleType.ZH_CN: return "zh-CN";
726
- case _univerjs_core.LocaleType.KO_KR: return "ko";
727
- case _univerjs_core.LocaleType.ZH_TW: return "zh-TW";
728
- case _univerjs_core.LocaleType.ZH_HK: return "zh-HK";
729
- case _univerjs_core.LocaleType.ES_ES:
730
- case _univerjs_core.LocaleType.CA_ES: return "es";
731
- case _univerjs_core.LocaleType.SK_SK: return "sk";
732
- case _univerjs_core.LocaleType.JA_JP: return "ja";
733
- case _univerjs_core.LocaleType.PT_BR: return "pt";
734
- case _univerjs_core.LocaleType.DE_DE: return "de";
735
- case _univerjs_core.LocaleType.IT_IT: return "it";
736
- case _univerjs_core.LocaleType.ID_ID: return "id";
737
- case _univerjs_core.LocaleType.PL_PL: return "pl";
738
- case _univerjs_core.LocaleType.AR_SA: return "ar";
739
- case _univerjs_core.LocaleType.EN_US:
740
- case _univerjs_core.LocaleType.FA_IR:
741
- default: return "en";
742
- }
726
+ return this.getLocale();
727
+ }
728
+ getLocale(workbook) {
729
+ return this._locale$.getValue() ?? (0, _univerjs_core.getNumfmtLocaleTag)((workbook === null || workbook === void 0 ? void 0 : workbook.getSnapshot().locale) ?? this._localeService.getCurrentLocale());
743
730
  }
744
731
  _initInterceptorCellContent() {
745
732
  const renderCache = new _univerjs_core.ObjectMatrix();
@@ -752,6 +739,8 @@ let SheetsNumfmtCellContentController = class SheetsNumfmtCellContentController
752
739
  if (!cell || cell.v === void 0 || cell.v === null || cell.t === _univerjs_core.CellValueType.BOOLEAN || cell.t === _univerjs_core.CellValueType.FORCE_STRING) return next(cell);
753
740
  const unitId = location.unitId;
754
741
  const sheetId = location.subUnitId;
742
+ const locale = this.getLocale(location.workbook);
743
+ const dateSystem = location.workbook.getDateSystem();
755
744
  let numfmtValue;
756
745
  if (cell === null || cell === void 0 ? void 0 : cell.s) {
757
746
  const style = location.workbook.getStyles().get(cell.s);
@@ -761,7 +750,10 @@ let SheetsNumfmtCellContentController = class SheetsNumfmtCellContentController
761
750
  if ((0, _univerjs_core.isDefaultFormat)(numfmtValue === null || numfmtValue === void 0 ? void 0 : numfmtValue.pattern)) return next(cell);
762
751
  if (cell.t !== _univerjs_core.CellValueType.NUMBER) {
763
752
  var _getNumfmtParseValueF;
764
- if ((0, _univerjs_sheets.checkCellValueType)(cell.v, cell.t) !== _univerjs_core.CellValueType.NUMBER && !((0, _univerjs_core.isTextFormat)(numfmtValue === null || numfmtValue === void 0 ? void 0 : numfmtValue.pattern) && typeof cell.v === "string" && typeof ((_getNumfmtParseValueF = (0, _univerjs_core.getNumfmtParseValueFilter)(cell.v)) === null || _getNumfmtParseValueF === void 0 ? void 0 : _getNumfmtParseValueF.v) === "number")) return next(cell);
753
+ if ((0, _univerjs_sheets.checkCellValueType)(cell.v, cell.t) !== _univerjs_core.CellValueType.NUMBER && !((0, _univerjs_core.isTextFormat)(numfmtValue === null || numfmtValue === void 0 ? void 0 : numfmtValue.pattern) && typeof cell.v === "string" && typeof ((_getNumfmtParseValueF = (0, _univerjs_core.getNumfmtParseValueFilter)(cell.v, {
754
+ locale,
755
+ dateSystem
756
+ })) === null || _getNumfmtParseValueF === void 0 ? void 0 : _getNumfmtParseValueF.v) === "number")) return next(cell);
765
757
  }
766
758
  const originCellValue = cell;
767
759
  if (!cell || cell === location.rawData) cell = { ...location.rawData };
@@ -778,12 +770,13 @@ let SheetsNumfmtCellContentController = class SheetsNumfmtCellContentController
778
770
  };
779
771
  return next(cell);
780
772
  }
773
+ const cacheParameters = `${unitId}_${sheetId}_${originCellValue.v}_${numfmtValue === null || numfmtValue === void 0 ? void 0 : numfmtValue.pattern}_${locale}_${dateSystem}`;
781
774
  const cache = renderCache.getValue(location.row, location.col);
782
- if (cache && cache.parameters === `${originCellValue.v}_${numfmtValue === null || numfmtValue === void 0 ? void 0 : numfmtValue.pattern}`) return next({
775
+ if (cache && cache.parameters === cacheParameters) return next({
783
776
  ...cell,
784
777
  ...cache.result
785
778
  });
786
- const info = getPatternPreviewIgnoreGeneral(numfmtValue === null || numfmtValue === void 0 ? void 0 : numfmtValue.pattern, Number(originCellValue.v), this.locale);
779
+ const info = getPatternPreviewIgnoreGeneral(numfmtValue === null || numfmtValue === void 0 ? void 0 : numfmtValue.pattern, Number(originCellValue.v), locale, dateSystem);
787
780
  const numfmtRes = info.result;
788
781
  const res = {
789
782
  v: numfmtRes,
@@ -796,7 +789,7 @@ let SheetsNumfmtCellContentController = class SheetsNumfmtCellContentController
796
789
  }
797
790
  renderCache.setValue(location.row, location.col, {
798
791
  result: res,
799
- parameters: `${originCellValue.v}_${numfmtValue === null || numfmtValue === void 0 ? void 0 : numfmtValue.pattern}`
792
+ parameters: cacheParameters
800
793
  });
801
794
  Object.assign(cell, res);
802
795
  return next(cell);
@@ -839,7 +832,7 @@ SheetsNumfmtCellContentController = __decorate([
839
832
  //#endregion
840
833
  //#region package.json
841
834
  var name = "@univerjs/sheets-numfmt";
842
- var version = "1.0.0-insiders.20260813-7c9aa50";
835
+ var version = "1.0.0";
843
836
 
844
837
  //#endregion
845
838
  //#region src/base/const/plugin-name.ts
package/lib/es/index.js CHANGED
@@ -1,4 +1,4 @@
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, 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, getNumfmtLocaleTag, getNumfmtParseValueFilter, isDefaultFormat, 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";
@@ -278,13 +278,18 @@ const isPatternHasDecimal = (pattern) => /\.0?/.test(pattern) || /0([^0]?)|0$/.t
278
278
 
279
279
  //#endregion
280
280
  //#region src/utils/pattern.ts
281
- const getPatternType = (pattern) => numfmt.getFormatInfo(pattern).type || "unknown";
282
- const getPatternPreview = (pattern, value, locale = "en") => {
281
+ const getPatternType = (pattern) => {
282
+ const type = numfmt.getFormatInfo(pattern).type || "unknown";
283
+ if (type === "general" && numfmt.tokenize(pattern).some((token) => token.type === numfmt.tokenTypes.CONDITION)) return "number";
284
+ return type;
285
+ };
286
+ const getPatternPreview = (pattern, value, locale = "en", dateSystem) => {
283
287
  try {
284
288
  const formatColor = numfmt.formatColor(pattern, value);
285
289
  const color = formatColor ? String(formatColor) : void 0;
286
290
  const result = numfmt.format(pattern, value, {
287
291
  locale,
292
+ dateSystem,
288
293
  throws: false
289
294
  });
290
295
  if (value < 0) return {
@@ -297,9 +302,9 @@ const getPatternPreview = (pattern, value, locale = "en") => {
297
302
  }
298
303
  return { result: String(value) };
299
304
  };
300
- const getPatternPreviewIgnoreGeneral = (pattern, value, locale) => {
305
+ const getPatternPreviewIgnoreGeneral = (pattern, value, locale, dateSystem) => {
301
306
  if (pattern === DEFAULT_NUMBER_FORMAT) return { result: String(stripErrorMargin(value)) };
302
- return getPatternPreview(pattern, value, locale);
307
+ return getPatternPreview(pattern, value, locale, dateSystem);
303
308
  };
304
309
 
305
310
  //#endregion
@@ -332,7 +337,8 @@ const SetNumfmtCommand = {
332
337
  if (!target) return false;
333
338
  const { unitId, subUnitId, worksheet } = target;
334
339
  const values = params.values.filter((value) => {
335
- return !isScientificNotationNumericCell(worksheet.getCellRaw(value.row, value.col)) || isAllowedPatternForScientificNotationNumber(value.pattern);
340
+ const cell = worksheet.getCellRaw(value.row, value.col);
341
+ return !isScientificNotationNumericCell(cell) || isAllowedPatternForScientificNotationNumber(value.pattern);
336
342
  });
337
343
  const setCells = values.filter((value) => !!value.pattern);
338
344
  const removeCells = values.filter((value) => !value.pattern);
@@ -508,7 +514,8 @@ const SetCurrencyCommand = {
508
514
  const selections = selectionManagerService.getCurrentSelections();
509
515
  if (!selections || !selections.length) return false;
510
516
  const values = [];
511
- const currencyFormat = getCurrencyFormat(getCurrencySymbolIconByLocale(regionService.getCurrentRegion()).locale);
517
+ const currencySymbolIcon = getCurrencySymbolIconByLocale(regionService.getCurrentRegion());
518
+ const currencyFormat = getCurrencyFormat(currencySymbolIcon.locale);
512
519
  selections.forEach((selection) => {
513
520
  Range.foreach(selection.range, (row, col) => {
514
521
  values.push({
@@ -636,7 +643,7 @@ const configSymbol = Symbol(SHEETS_NUMFMT_PLUGIN_CONFIG_KEY);
636
643
  const defaultPluginConfig = {};
637
644
 
638
645
  //#endregion
639
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/typeof.js
646
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/typeof.js
640
647
  function _typeof(o) {
641
648
  "@babel/helpers - typeof";
642
649
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -647,7 +654,7 @@ function _typeof(o) {
647
654
  }
648
655
 
649
656
  //#endregion
650
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPrimitive.js
657
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPrimitive.js
651
658
  function toPrimitive(t, r) {
652
659
  if ("object" != _typeof(t) || !t) return t;
653
660
  var e = t[Symbol.toPrimitive];
@@ -660,14 +667,14 @@ function toPrimitive(t, r) {
660
667
  }
661
668
 
662
669
  //#endregion
663
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPropertyKey.js
670
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPropertyKey.js
664
671
  function toPropertyKey(t) {
665
672
  var i = toPrimitive(t, "string");
666
673
  return "symbol" == _typeof(i) ? i : i + "";
667
674
  }
668
675
 
669
676
  //#endregion
670
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/defineProperty.js
677
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/defineProperty.js
671
678
  function _defineProperty(e, r, t) {
672
679
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
673
680
  value: t,
@@ -678,7 +685,7 @@ function _defineProperty(e, r, t) {
678
685
  }
679
686
 
680
687
  //#endregion
681
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorateParam.js
688
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorateParam.js
682
689
  function __decorateParam(paramIndex, decorator) {
683
690
  return function(target, key) {
684
691
  decorator(target, key, paramIndex);
@@ -686,7 +693,7 @@ function __decorateParam(paramIndex, decorator) {
686
693
  }
687
694
 
688
695
  //#endregion
689
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorate.js
696
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorate.js
690
697
  function __decorate(decorators, target, key, desc) {
691
698
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
692
699
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -710,35 +717,15 @@ let SheetsNumfmtCellContentController = class SheetsNumfmtCellContentController
710
717
  this._numfmtService = _numfmtService;
711
718
  this._localeService = _localeService;
712
719
  this._configService = _configService;
713
- _defineProperty(this, "_locale$", new BehaviorSubject("en"));
720
+ _defineProperty(this, "_locale$", new BehaviorSubject(null));
714
721
  _defineProperty(this, "locale$", this._locale$.asObservable());
715
722
  this._initInterceptorCellContent();
716
723
  }
717
724
  get locale() {
718
- const _locale = this._locale$.getValue();
719
- if (_locale) return _locale;
720
- switch (this._localeService.getCurrentLocale()) {
721
- case LocaleType.FR_FR: return "fr";
722
- case LocaleType.RU_RU: return "ru";
723
- case LocaleType.VI_VN: return "vi";
724
- case LocaleType.ZH_CN: return "zh-CN";
725
- case LocaleType.KO_KR: return "ko";
726
- case LocaleType.ZH_TW: return "zh-TW";
727
- case LocaleType.ZH_HK: return "zh-HK";
728
- case LocaleType.ES_ES:
729
- case LocaleType.CA_ES: return "es";
730
- case LocaleType.SK_SK: return "sk";
731
- case LocaleType.JA_JP: return "ja";
732
- case LocaleType.PT_BR: return "pt";
733
- case LocaleType.DE_DE: return "de";
734
- case LocaleType.IT_IT: return "it";
735
- case LocaleType.ID_ID: return "id";
736
- case LocaleType.PL_PL: return "pl";
737
- case LocaleType.AR_SA: return "ar";
738
- case LocaleType.EN_US:
739
- case LocaleType.FA_IR:
740
- default: return "en";
741
- }
725
+ return this.getLocale();
726
+ }
727
+ getLocale(workbook) {
728
+ return this._locale$.getValue() ?? getNumfmtLocaleTag((workbook === null || workbook === void 0 ? void 0 : workbook.getSnapshot().locale) ?? this._localeService.getCurrentLocale());
742
729
  }
743
730
  _initInterceptorCellContent() {
744
731
  const renderCache = new ObjectMatrix();
@@ -751,6 +738,8 @@ let SheetsNumfmtCellContentController = class SheetsNumfmtCellContentController
751
738
  if (!cell || cell.v === void 0 || cell.v === null || cell.t === CellValueType.BOOLEAN || cell.t === CellValueType.FORCE_STRING) return next(cell);
752
739
  const unitId = location.unitId;
753
740
  const sheetId = location.subUnitId;
741
+ const locale = this.getLocale(location.workbook);
742
+ const dateSystem = location.workbook.getDateSystem();
754
743
  let numfmtValue;
755
744
  if (cell === null || cell === void 0 ? void 0 : cell.s) {
756
745
  const style = location.workbook.getStyles().get(cell.s);
@@ -760,7 +749,10 @@ let SheetsNumfmtCellContentController = class SheetsNumfmtCellContentController
760
749
  if (isDefaultFormat(numfmtValue === null || numfmtValue === void 0 ? void 0 : numfmtValue.pattern)) return next(cell);
761
750
  if (cell.t !== CellValueType.NUMBER) {
762
751
  var _getNumfmtParseValueF;
763
- if (checkCellValueType(cell.v, cell.t) !== CellValueType.NUMBER && !(isTextFormat(numfmtValue === null || numfmtValue === void 0 ? void 0 : numfmtValue.pattern) && typeof cell.v === "string" && typeof ((_getNumfmtParseValueF = getNumfmtParseValueFilter(cell.v)) === null || _getNumfmtParseValueF === void 0 ? void 0 : _getNumfmtParseValueF.v) === "number")) return next(cell);
752
+ if (checkCellValueType(cell.v, cell.t) !== CellValueType.NUMBER && !(isTextFormat(numfmtValue === null || numfmtValue === void 0 ? void 0 : numfmtValue.pattern) && typeof cell.v === "string" && typeof ((_getNumfmtParseValueF = getNumfmtParseValueFilter(cell.v, {
753
+ locale,
754
+ dateSystem
755
+ })) === null || _getNumfmtParseValueF === void 0 ? void 0 : _getNumfmtParseValueF.v) === "number")) return next(cell);
764
756
  }
765
757
  const originCellValue = cell;
766
758
  if (!cell || cell === location.rawData) cell = { ...location.rawData };
@@ -777,12 +769,13 @@ let SheetsNumfmtCellContentController = class SheetsNumfmtCellContentController
777
769
  };
778
770
  return next(cell);
779
771
  }
772
+ const cacheParameters = `${unitId}_${sheetId}_${originCellValue.v}_${numfmtValue === null || numfmtValue === void 0 ? void 0 : numfmtValue.pattern}_${locale}_${dateSystem}`;
780
773
  const cache = renderCache.getValue(location.row, location.col);
781
- if (cache && cache.parameters === `${originCellValue.v}_${numfmtValue === null || numfmtValue === void 0 ? void 0 : numfmtValue.pattern}`) return next({
774
+ if (cache && cache.parameters === cacheParameters) return next({
782
775
  ...cell,
783
776
  ...cache.result
784
777
  });
785
- const info = getPatternPreviewIgnoreGeneral(numfmtValue === null || numfmtValue === void 0 ? void 0 : numfmtValue.pattern, Number(originCellValue.v), this.locale);
778
+ const info = getPatternPreviewIgnoreGeneral(numfmtValue === null || numfmtValue === void 0 ? void 0 : numfmtValue.pattern, Number(originCellValue.v), locale, dateSystem);
786
779
  const numfmtRes = info.result;
787
780
  const res = {
788
781
  v: numfmtRes,
@@ -795,7 +788,7 @@ let SheetsNumfmtCellContentController = class SheetsNumfmtCellContentController
795
788
  }
796
789
  renderCache.setValue(location.row, location.col, {
797
790
  result: res,
798
- parameters: `${originCellValue.v}_${numfmtValue === null || numfmtValue === void 0 ? void 0 : numfmtValue.pattern}`
791
+ parameters: cacheParameters
799
792
  });
800
793
  Object.assign(cell, res);
801
794
  return next(cell);
@@ -838,7 +831,7 @@ SheetsNumfmtCellContentController = __decorate([
838
831
  //#endregion
839
832
  //#region package.json
840
833
  var name = "@univerjs/sheets-numfmt";
841
- var version = "1.0.0-insiders.20260813-7c9aa50";
834
+ var version = "1.0.0";
842
835
 
843
836
  //#endregion
844
837
  //#region src/base/const/plugin-name.ts
package/lib/index.js CHANGED
@@ -1,4 +1,4 @@
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, 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, getNumfmtLocaleTag, getNumfmtParseValueFilter, isDefaultFormat, 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";
@@ -278,13 +278,18 @@ const isPatternHasDecimal = (pattern) => /\.0?/.test(pattern) || /0([^0]?)|0$/.t
278
278
 
279
279
  //#endregion
280
280
  //#region src/utils/pattern.ts
281
- const getPatternType = (pattern) => numfmt.getFormatInfo(pattern).type || "unknown";
282
- const getPatternPreview = (pattern, value, locale = "en") => {
281
+ const getPatternType = (pattern) => {
282
+ const type = numfmt.getFormatInfo(pattern).type || "unknown";
283
+ if (type === "general" && numfmt.tokenize(pattern).some((token) => token.type === numfmt.tokenTypes.CONDITION)) return "number";
284
+ return type;
285
+ };
286
+ const getPatternPreview = (pattern, value, locale = "en", dateSystem) => {
283
287
  try {
284
288
  const formatColor = numfmt.formatColor(pattern, value);
285
289
  const color = formatColor ? String(formatColor) : void 0;
286
290
  const result = numfmt.format(pattern, value, {
287
291
  locale,
292
+ dateSystem,
288
293
  throws: false
289
294
  });
290
295
  if (value < 0) return {
@@ -297,9 +302,9 @@ const getPatternPreview = (pattern, value, locale = "en") => {
297
302
  }
298
303
  return { result: String(value) };
299
304
  };
300
- const getPatternPreviewIgnoreGeneral = (pattern, value, locale) => {
305
+ const getPatternPreviewIgnoreGeneral = (pattern, value, locale, dateSystem) => {
301
306
  if (pattern === DEFAULT_NUMBER_FORMAT) return { result: String(stripErrorMargin(value)) };
302
- return getPatternPreview(pattern, value, locale);
307
+ return getPatternPreview(pattern, value, locale, dateSystem);
303
308
  };
304
309
 
305
310
  //#endregion
@@ -332,7 +337,8 @@ const SetNumfmtCommand = {
332
337
  if (!target) return false;
333
338
  const { unitId, subUnitId, worksheet } = target;
334
339
  const values = params.values.filter((value) => {
335
- return !isScientificNotationNumericCell(worksheet.getCellRaw(value.row, value.col)) || isAllowedPatternForScientificNotationNumber(value.pattern);
340
+ const cell = worksheet.getCellRaw(value.row, value.col);
341
+ return !isScientificNotationNumericCell(cell) || isAllowedPatternForScientificNotationNumber(value.pattern);
336
342
  });
337
343
  const setCells = values.filter((value) => !!value.pattern);
338
344
  const removeCells = values.filter((value) => !value.pattern);
@@ -508,7 +514,8 @@ const SetCurrencyCommand = {
508
514
  const selections = selectionManagerService.getCurrentSelections();
509
515
  if (!selections || !selections.length) return false;
510
516
  const values = [];
511
- const currencyFormat = getCurrencyFormat(getCurrencySymbolIconByLocale(regionService.getCurrentRegion()).locale);
517
+ const currencySymbolIcon = getCurrencySymbolIconByLocale(regionService.getCurrentRegion());
518
+ const currencyFormat = getCurrencyFormat(currencySymbolIcon.locale);
512
519
  selections.forEach((selection) => {
513
520
  Range.foreach(selection.range, (row, col) => {
514
521
  values.push({
@@ -636,7 +643,7 @@ const configSymbol = Symbol(SHEETS_NUMFMT_PLUGIN_CONFIG_KEY);
636
643
  const defaultPluginConfig = {};
637
644
 
638
645
  //#endregion
639
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/typeof.js
646
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/typeof.js
640
647
  function _typeof(o) {
641
648
  "@babel/helpers - typeof";
642
649
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -647,7 +654,7 @@ function _typeof(o) {
647
654
  }
648
655
 
649
656
  //#endregion
650
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPrimitive.js
657
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPrimitive.js
651
658
  function toPrimitive(t, r) {
652
659
  if ("object" != _typeof(t) || !t) return t;
653
660
  var e = t[Symbol.toPrimitive];
@@ -660,14 +667,14 @@ function toPrimitive(t, r) {
660
667
  }
661
668
 
662
669
  //#endregion
663
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPropertyKey.js
670
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPropertyKey.js
664
671
  function toPropertyKey(t) {
665
672
  var i = toPrimitive(t, "string");
666
673
  return "symbol" == _typeof(i) ? i : i + "";
667
674
  }
668
675
 
669
676
  //#endregion
670
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/defineProperty.js
677
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/defineProperty.js
671
678
  function _defineProperty(e, r, t) {
672
679
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
673
680
  value: t,
@@ -678,7 +685,7 @@ function _defineProperty(e, r, t) {
678
685
  }
679
686
 
680
687
  //#endregion
681
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorateParam.js
688
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorateParam.js
682
689
  function __decorateParam(paramIndex, decorator) {
683
690
  return function(target, key) {
684
691
  decorator(target, key, paramIndex);
@@ -686,7 +693,7 @@ function __decorateParam(paramIndex, decorator) {
686
693
  }
687
694
 
688
695
  //#endregion
689
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorate.js
696
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorate.js
690
697
  function __decorate(decorators, target, key, desc) {
691
698
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
692
699
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -710,35 +717,15 @@ let SheetsNumfmtCellContentController = class SheetsNumfmtCellContentController
710
717
  this._numfmtService = _numfmtService;
711
718
  this._localeService = _localeService;
712
719
  this._configService = _configService;
713
- _defineProperty(this, "_locale$", new BehaviorSubject("en"));
720
+ _defineProperty(this, "_locale$", new BehaviorSubject(null));
714
721
  _defineProperty(this, "locale$", this._locale$.asObservable());
715
722
  this._initInterceptorCellContent();
716
723
  }
717
724
  get locale() {
718
- const _locale = this._locale$.getValue();
719
- if (_locale) return _locale;
720
- switch (this._localeService.getCurrentLocale()) {
721
- case LocaleType.FR_FR: return "fr";
722
- case LocaleType.RU_RU: return "ru";
723
- case LocaleType.VI_VN: return "vi";
724
- case LocaleType.ZH_CN: return "zh-CN";
725
- case LocaleType.KO_KR: return "ko";
726
- case LocaleType.ZH_TW: return "zh-TW";
727
- case LocaleType.ZH_HK: return "zh-HK";
728
- case LocaleType.ES_ES:
729
- case LocaleType.CA_ES: return "es";
730
- case LocaleType.SK_SK: return "sk";
731
- case LocaleType.JA_JP: return "ja";
732
- case LocaleType.PT_BR: return "pt";
733
- case LocaleType.DE_DE: return "de";
734
- case LocaleType.IT_IT: return "it";
735
- case LocaleType.ID_ID: return "id";
736
- case LocaleType.PL_PL: return "pl";
737
- case LocaleType.AR_SA: return "ar";
738
- case LocaleType.EN_US:
739
- case LocaleType.FA_IR:
740
- default: return "en";
741
- }
725
+ return this.getLocale();
726
+ }
727
+ getLocale(workbook) {
728
+ return this._locale$.getValue() ?? getNumfmtLocaleTag((workbook === null || workbook === void 0 ? void 0 : workbook.getSnapshot().locale) ?? this._localeService.getCurrentLocale());
742
729
  }
743
730
  _initInterceptorCellContent() {
744
731
  const renderCache = new ObjectMatrix();
@@ -751,6 +738,8 @@ let SheetsNumfmtCellContentController = class SheetsNumfmtCellContentController
751
738
  if (!cell || cell.v === void 0 || cell.v === null || cell.t === CellValueType.BOOLEAN || cell.t === CellValueType.FORCE_STRING) return next(cell);
752
739
  const unitId = location.unitId;
753
740
  const sheetId = location.subUnitId;
741
+ const locale = this.getLocale(location.workbook);
742
+ const dateSystem = location.workbook.getDateSystem();
754
743
  let numfmtValue;
755
744
  if (cell === null || cell === void 0 ? void 0 : cell.s) {
756
745
  const style = location.workbook.getStyles().get(cell.s);
@@ -760,7 +749,10 @@ let SheetsNumfmtCellContentController = class SheetsNumfmtCellContentController
760
749
  if (isDefaultFormat(numfmtValue === null || numfmtValue === void 0 ? void 0 : numfmtValue.pattern)) return next(cell);
761
750
  if (cell.t !== CellValueType.NUMBER) {
762
751
  var _getNumfmtParseValueF;
763
- if (checkCellValueType(cell.v, cell.t) !== CellValueType.NUMBER && !(isTextFormat(numfmtValue === null || numfmtValue === void 0 ? void 0 : numfmtValue.pattern) && typeof cell.v === "string" && typeof ((_getNumfmtParseValueF = getNumfmtParseValueFilter(cell.v)) === null || _getNumfmtParseValueF === void 0 ? void 0 : _getNumfmtParseValueF.v) === "number")) return next(cell);
752
+ if (checkCellValueType(cell.v, cell.t) !== CellValueType.NUMBER && !(isTextFormat(numfmtValue === null || numfmtValue === void 0 ? void 0 : numfmtValue.pattern) && typeof cell.v === "string" && typeof ((_getNumfmtParseValueF = getNumfmtParseValueFilter(cell.v, {
753
+ locale,
754
+ dateSystem
755
+ })) === null || _getNumfmtParseValueF === void 0 ? void 0 : _getNumfmtParseValueF.v) === "number")) return next(cell);
764
756
  }
765
757
  const originCellValue = cell;
766
758
  if (!cell || cell === location.rawData) cell = { ...location.rawData };
@@ -777,12 +769,13 @@ let SheetsNumfmtCellContentController = class SheetsNumfmtCellContentController
777
769
  };
778
770
  return next(cell);
779
771
  }
772
+ const cacheParameters = `${unitId}_${sheetId}_${originCellValue.v}_${numfmtValue === null || numfmtValue === void 0 ? void 0 : numfmtValue.pattern}_${locale}_${dateSystem}`;
780
773
  const cache = renderCache.getValue(location.row, location.col);
781
- if (cache && cache.parameters === `${originCellValue.v}_${numfmtValue === null || numfmtValue === void 0 ? void 0 : numfmtValue.pattern}`) return next({
774
+ if (cache && cache.parameters === cacheParameters) return next({
782
775
  ...cell,
783
776
  ...cache.result
784
777
  });
785
- const info = getPatternPreviewIgnoreGeneral(numfmtValue === null || numfmtValue === void 0 ? void 0 : numfmtValue.pattern, Number(originCellValue.v), this.locale);
778
+ const info = getPatternPreviewIgnoreGeneral(numfmtValue === null || numfmtValue === void 0 ? void 0 : numfmtValue.pattern, Number(originCellValue.v), locale, dateSystem);
786
779
  const numfmtRes = info.result;
787
780
  const res = {
788
781
  v: numfmtRes,
@@ -795,7 +788,7 @@ let SheetsNumfmtCellContentController = class SheetsNumfmtCellContentController
795
788
  }
796
789
  renderCache.setValue(location.row, location.col, {
797
790
  result: res,
798
- parameters: `${originCellValue.v}_${numfmtValue === null || numfmtValue === void 0 ? void 0 : numfmtValue.pattern}`
791
+ parameters: cacheParameters
799
792
  });
800
793
  Object.assign(cell, res);
801
794
  return next(cell);
@@ -838,7 +831,7 @@ SheetsNumfmtCellContentController = __decorate([
838
831
  //#endregion
839
832
  //#region package.json
840
833
  var name = "@univerjs/sheets-numfmt";
841
- var version = "1.0.0-insiders.20260813-7c9aa50";
834
+ var version = "1.0.0";
842
835
 
843
836
  //#endregion
844
837
  //#region src/base/const/plugin-name.ts
@@ -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
- import type { INumfmtLocaleTag } from '@univerjs/core';
16
+ import type { INumfmtLocaleTag, Workbook } from '@univerjs/core';
17
17
  import { Disposable, ICommandService, IConfigService, IUniverInstanceService, LocaleService, ThemeService } from '@univerjs/core';
18
18
  import { INumfmtService, SheetInterceptorService } from '@univerjs/sheets';
19
19
  export declare class SheetsNumfmtCellContentController extends Disposable {
@@ -25,9 +25,10 @@ export declare class SheetsNumfmtCellContentController extends Disposable {
25
25
  private _localeService;
26
26
  private readonly _configService;
27
27
  private _locale$;
28
- locale$: import("rxjs").Observable<INumfmtLocaleTag>;
28
+ locale$: import("rxjs").Observable<INumfmtLocaleTag | null>;
29
29
  constructor(_instanceService: IUniverInstanceService, _sheetInterceptorService: SheetInterceptorService, _themeService: ThemeService, _commandService: ICommandService, _numfmtService: INumfmtService, _localeService: LocaleService, _configService: IConfigService);
30
30
  get locale(): INumfmtLocaleTag;
31
+ getLocale(workbook?: Workbook): INumfmtLocaleTag;
31
32
  private _initInterceptorCellContent;
32
33
  setNumfmtLocal(locale: INumfmtLocaleTag): void;
33
34
  }
@@ -54,12 +54,12 @@ export interface IFRangeSheetsNumfmtMixin {
54
54
  * ['#,##0.00', '0.00%'],
55
55
  * ['yyyy-MM-DD', '']
56
56
  * ]);
57
- * console.log(fRange.getDisplayValues()); // [['1,234.57', '12.34%'], ['2025-01-01', 0.9876]]
57
+ * console.log(fRange.getDisplayValues()); // [['1,234.57', '12.34%'], ['2025-01-01', '0.9876']]
58
58
  * ```
59
59
  */
60
60
  setNumberFormats(patterns: string[][]): FRange;
61
61
  /**
62
- * Get the number formatting of the top-left cell of the given range. Empty cells return an empty string.
62
+ * Get the number formatting of the top-left cell of the given range. Returns an empty string when no number format is set, even if the cell contains a value.
63
63
  * @returns {string} The number format of the top-left cell of the range.
64
64
  * @example
65
65
  * ```ts
@@ -13,13 +13,13 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import type { INumfmtLocaleTag } from '@univerjs/core';
16
+ import type { DateSystem, INumfmtLocaleTag } from '@univerjs/core';
17
17
  import type { FormatType } from '@univerjs/sheets';
18
18
  export declare const getPatternType: (pattern: string) => FormatType;
19
19
  interface IPatternPreview {
20
20
  result: string;
21
21
  color?: string;
22
22
  }
23
- export declare const getPatternPreview: (pattern: string, value: number, locale?: INumfmtLocaleTag) => IPatternPreview;
24
- export declare const getPatternPreviewIgnoreGeneral: (pattern: string, value: number, locale?: INumfmtLocaleTag) => IPatternPreview;
23
+ export declare const getPatternPreview: (pattern: string, value: number, locale?: INumfmtLocaleTag, dateSystem?: DateSystem) => IPatternPreview;
24
+ export declare const getPatternPreviewIgnoreGeneral: (pattern: string, value: number, locale?: INumfmtLocaleTag, dateSystem?: DateSystem) => IPatternPreview;
25
25
  export {};
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=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=>t.numfmt.getFormatInfo(e).type||`unknown`,_=(e,n,r=`en`)=>{try{let i=t.numfmt.formatColor(e,n),a=i?String(i):void 0,o=t.numfmt.format(e,n,{locale:r,throws:!1});return n<0?{result:o,color:a}:{result:o}}catch(t){console.warn(`getPatternPreview error:`,e,t)}return{result:String(n)}},v=(e,n,i)=>e===t.DEFAULT_NUMBER_FORMAT?{result:String((0,r.stripErrorMargin)(n))}:_(e,n,i);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,t,n,r,a,o,s){super(),this._instanceService=e,this._sheetInterceptorService=t,this._themeService=n,this._commandService=r,this._numfmtService=a,this._localeService=o,this._configService=s,M(this,`_locale$`,new i.BehaviorSubject(`en`)),M(this,`locale$`,this._locale$.asObservable()),this._initInterceptorCellContent()}get locale(){let e=this._locale$.getValue();if(e)return e;switch(this._localeService.getCurrentLocale()){case t.LocaleType.FR_FR:return`fr`;case t.LocaleType.RU_RU:return`ru`;case t.LocaleType.VI_VN:return`vi`;case t.LocaleType.ZH_CN:return`zh-CN`;case t.LocaleType.KO_KR:return`ko`;case t.LocaleType.ZH_TW:return`zh-TW`;case t.LocaleType.ZH_HK:return`zh-HK`;case t.LocaleType.ES_ES:case t.LocaleType.CA_ES:return`es`;case t.LocaleType.SK_SK:return`sk`;case t.LocaleType.JA_JP:return`ja`;case t.LocaleType.PT_BR:return`pt`;case t.LocaleType.DE_DE:return`de`;case t.LocaleType.IT_IT:return`it`;case t.LocaleType.ID_ID:return`id`;case t.LocaleType.PL_PL:return`pl`;case t.LocaleType.AR_SA:return`ar`;case t.LocaleType.EN_US:case t.LocaleType.FA_IR:default:return`en`}}_initInterceptorCellContent(){let e=new t.ObjectMatrix;this.disposeWithMe((0,i.merge)(this._locale$,this._localeService.currentLocale$).subscribe(()=>{e.reset()})),this.disposeWithMe(this._sheetInterceptorService.intercept(n.INTERCEPTOR_POINT.CELL_CONTENT,{effect:t.InterceptorEffectEnum.Value|t.InterceptorEffectEnum.Style,handler:(r,i,a)=>{if(!r||r.v===void 0||r.v===null||r.t===t.CellValueType.BOOLEAN||r.t===t.CellValueType.FORCE_STRING)return a(r);let o=i.unitId,s=i.subUnitId,c;if(r!=null&&r.s){let e=i.workbook.getStyles().get(r.s);e!=null&&e.n&&(c=e.n)}if(c||=this._numfmtService.getValue(o,s,i.row,i.col),(0,t.isDefaultFormat)(c==null?void 0:c.pattern))return a(r);if(r.t!==t.CellValueType.NUMBER){var l;if((0,n.checkCellValueType)(r.v,r.t)!==t.CellValueType.NUMBER&&!((0,t.isTextFormat)(c==null?void 0:c.pattern)&&typeof r.v==`string`&&typeof((l=(0,t.getNumfmtParseValueFilter)(r.v))==null?void 0:l.v)==`number`))return a(r)}let u=r;if((!r||r===i.rawData)&&(r={...i.rawData}),(0,t.isTextFormat)(c==null?void 0:c.pattern)){var d;return(d=this._configService.getConfig(`sheets-numfmt.config`))!=null&&d.disableTextFormatMark?(r.t=t.CellValueType.STRING,a(r)):(r.t=t.CellValueType.STRING,r.markers={...r==null?void 0:r.markers,...F},a(r))}let f=e.getValue(i.row,i.col);if(f&&f.parameters===`${u.v}_${c==null?void 0:c.pattern}`)return a({...r,...f.result});let p=v(c==null?void 0:c.pattern,Number(u.v),this.locale),m=p.result,h={v:m,t:t.CellValueType.NUMBER};if(m===``&&(h.coverable=!1),p.color){let e=this._themeService.getColorFromTheme(`${p.color}.500`)??p.color;e&&(h.interceptorStyle={cl:{rgb:e}})}return e.setValue(i.row,i.col,{result:h,parameters:`${u.v}_${c==null?void 0:c.pattern}`}),Object.assign(r,h),a(r)},priority:n.InterceptCellContentPriority.NUMFMT})),this.disposeWithMe(this._commandService.onCommandExecuted(r=>{if(r.id===n.SetNumfmtMutation.id){let n=r.params;Object.keys(n.values).forEach(r=>{n.values[r].ranges.forEach(n=>{t.Range.foreach(n,(t,n)=>{e.realDeleteValue(t,n)})})})}else if(r.id===n.SetRangeValuesMutation.id){let n=r.params;new t.ObjectMatrix(n.cellValue).forValue((t,n)=>{e.realDeleteValue(t,n)})}})),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(()=>e.reset()))}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.0.0-insiders.20260813-7c9aa50`;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),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=e=>d.map(t=>({label:t.label(e),value:t.suffix(e),color:t.color})),e.getCurrencyOptions=()=>t.currencySymbols.map(e=>({label:e,value:e})),e.getCurrencySymbolByLocale=s,e.getCurrencySymbolIconByLocale=o,e.getCurrencyType=e=>t.currencySymbols.find(t=>e.includes(t)),e.getDateFormatOptions=()=>l.map(e=>({label:e.label,value:e.suffix})),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=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,s=t.numfmt.format(e,n,{locale:r,dateSystem:i,throws:!1});return n<0?{result:s,color:o}:{result:s}}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,t,n,r,a,o,s){super(),this._instanceService=e,this._sheetInterceptorService=t,this._themeService=n,this._commandService=r,this._numfmtService=a,this._localeService=o,this._configService=s,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(){let e=new t.ObjectMatrix;this.disposeWithMe((0,i.merge)(this._locale$,this._localeService.currentLocale$).subscribe(()=>{e.reset()})),this.disposeWithMe(this._sheetInterceptorService.intercept(n.INTERCEPTOR_POINT.CELL_CONTENT,{effect:t.InterceptorEffectEnum.Value|t.InterceptorEffectEnum.Style,handler:(r,i,a)=>{if(!r||r.v===void 0||r.v===null||r.t===t.CellValueType.BOOLEAN||r.t===t.CellValueType.FORCE_STRING)return a(r);let o=i.unitId,s=i.subUnitId,c=this.getLocale(i.workbook),l=i.workbook.getDateSystem(),u;if(r!=null&&r.s){let e=i.workbook.getStyles().get(r.s);e!=null&&e.n&&(u=e.n)}if(u||=this._numfmtService.getValue(o,s,i.row,i.col),(0,t.isDefaultFormat)(u==null?void 0:u.pattern))return a(r);if(r.t!==t.CellValueType.NUMBER){var d;if((0,n.checkCellValueType)(r.v,r.t)!==t.CellValueType.NUMBER&&!((0,t.isTextFormat)(u==null?void 0:u.pattern)&&typeof r.v==`string`&&typeof((d=(0,t.getNumfmtParseValueFilter)(r.v,{locale:c,dateSystem:l}))==null?void 0:d.v)==`number`))return a(r)}let f=r;if((!r||r===i.rawData)&&(r={...i.rawData}),(0,t.isTextFormat)(u==null?void 0:u.pattern)){var p;return(p=this._configService.getConfig(`sheets-numfmt.config`))!=null&&p.disableTextFormatMark?(r.t=t.CellValueType.STRING,a(r)):(r.t=t.CellValueType.STRING,r.markers={...r==null?void 0:r.markers,...F},a(r))}let m=`${o}_${s}_${f.v}_${u==null?void 0:u.pattern}_${c}_${l}`,h=e.getValue(i.row,i.col);if(h&&h.parameters===m)return a({...r,...h.result});let g=v(u==null?void 0:u.pattern,Number(f.v),c,l),_=g.result,y={v:_,t:t.CellValueType.NUMBER};if(_===``&&(y.coverable=!1),g.color){let e=this._themeService.getColorFromTheme(`${g.color}.500`)??g.color;e&&(y.interceptorStyle={cl:{rgb:e}})}return e.setValue(i.row,i.col,{result:y,parameters:m}),Object.assign(r,y),a(r)},priority:n.InterceptCellContentPriority.NUMFMT})),this.disposeWithMe(this._commandService.onCommandExecuted(r=>{if(r.id===n.SetNumfmtMutation.id){let n=r.params;Object.keys(n.values).forEach(r=>{n.values[r].ranges.forEach(n=>{t.Range.foreach(n,(t,n)=>{e.realDeleteValue(t,n)})})})}else if(r.id===n.SetRangeValuesMutation.id){let n=r.params;new t.ObjectMatrix(n.cellValue).forValue((t,n)=>{e.realDeleteValue(t,n)})}})),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(()=>e.reset()))}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.0.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),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=e=>d.map(t=>({label:t.label(e),value:t.suffix(e),color:t.color})),e.getCurrencyOptions=()=>t.currencySymbols.map(e=>({label:e,value:e})),e.getCurrencySymbolByLocale=s,e.getCurrencySymbolIconByLocale=o,e.getCurrencyType=e=>t.currencySymbols.find(t=>e.includes(t)),e.getDateFormatOptions=()=>l.map(e=>({label:e.label,value:e.suffix})),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.0.0-insiders.20260813-7c9aa50",
3
+ "version": "1.0.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,15 +62,15 @@
62
62
  "rxjs": ">=7.0.0"
63
63
  },
64
64
  "dependencies": {
65
- "@univerjs/core": "1.0.0-insiders.20260813-7c9aa50",
66
- "@univerjs/sheets": "1.0.0-insiders.20260813-7c9aa50",
67
- "@univerjs/engine-formula": "1.0.0-insiders.20260813-7c9aa50"
65
+ "@univerjs/core": "1.0.0",
66
+ "@univerjs/engine-formula": "1.0.0",
67
+ "@univerjs/sheets": "1.0.0"
68
68
  },
69
69
  "devDependencies": {
70
+ "@univerjs-infra/shared": "1.0.0",
70
71
  "rxjs": "^7.8.2",
71
72
  "typescript": "^6.0.3",
72
- "vitest": "^4.1.10",
73
- "@univerjs-infra/shared": "1.0.0-beta.0"
73
+ "vitest": "^5.0.0"
74
74
  },
75
75
  "scripts": {
76
76
  "test": "vitest run",