@univerjs/sheets-numfmt 1.0.0-alpha.7 → 1.0.0-beta.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 CHANGED
@@ -38,14 +38,14 @@ var FRangeSheetsNumfmtMixin = class extends _univerjs_sheets_facade.FRange {
38
38
  return this;
39
39
  }
40
40
  getNumberFormat() {
41
- var _style$numberFormat$p, _style$numberFormat;
41
+ var _style$numberFormat;
42
42
  const style = this.getCellStyle();
43
- return (_style$numberFormat$p = style === null || style === void 0 || (_style$numberFormat = style.numberFormat) === null || _style$numberFormat === void 0 ? void 0 : _style$numberFormat.pattern) !== null && _style$numberFormat$p !== void 0 ? _style$numberFormat$p : "";
43
+ return (style === null || style === void 0 || (_style$numberFormat = style.numberFormat) === null || _style$numberFormat === void 0 ? void 0 : _style$numberFormat.pattern) ?? "";
44
44
  }
45
45
  getNumberFormats() {
46
46
  return this.getCellStyles().map((row) => row.map((cellStyle) => {
47
- var _cellStyle$numberForm, _cellStyle$numberForm2;
48
- return (_cellStyle$numberForm = cellStyle === null || cellStyle === void 0 || (_cellStyle$numberForm2 = cellStyle.numberFormat) === null || _cellStyle$numberForm2 === void 0 ? void 0 : _cellStyle$numberForm2.pattern) !== null && _cellStyle$numberForm !== void 0 ? _cellStyle$numberForm : "";
47
+ var _cellStyle$numberForm;
48
+ return (cellStyle === null || cellStyle === void 0 || (_cellStyle$numberForm = cellStyle.numberFormat) === null || _cellStyle$numberForm === void 0 ? void 0 : _cellStyle$numberForm.pattern) ?? "";
49
49
  }));
50
50
  }
51
51
  };
package/lib/cjs/index.js CHANGED
@@ -264,9 +264,8 @@ const CURRENCYFORMAT = [
264
264
  * the function decimal just use positive,negative configuration ignored
265
265
  */
266
266
  const getDecimalFromPattern = (pattern, defaultValue = 0) => {
267
- var _info$maxDecimals;
268
267
  if (!pattern) return defaultValue;
269
- return (_info$maxDecimals = _univerjs_core.numfmt.getFormatInfo(pattern).maxDecimals) !== null && _info$maxDecimals !== void 0 ? _info$maxDecimals : defaultValue;
268
+ return _univerjs_core.numfmt.getFormatInfo(pattern).maxDecimals ?? defaultValue;
270
269
  };
271
270
  const getDecimalString = (length) => new Array(Math.min(Math.max(0, Number(length)), 30)).fill(0).join("");
272
271
  const setPatternDecimal = (patterns, decimalLength) => {
@@ -638,7 +637,7 @@ const configSymbol = Symbol(SHEETS_NUMFMT_PLUGIN_CONFIG_KEY);
638
637
  const defaultPluginConfig = {};
639
638
 
640
639
  //#endregion
641
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/typeof.js
640
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/typeof.js
642
641
  function _typeof(o) {
643
642
  "@babel/helpers - typeof";
644
643
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -649,7 +648,7 @@ function _typeof(o) {
649
648
  }
650
649
 
651
650
  //#endregion
652
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPrimitive.js
651
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPrimitive.js
653
652
  function toPrimitive(t, r) {
654
653
  if ("object" != _typeof(t) || !t) return t;
655
654
  var e = t[Symbol.toPrimitive];
@@ -662,14 +661,14 @@ function toPrimitive(t, r) {
662
661
  }
663
662
 
664
663
  //#endregion
665
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPropertyKey.js
664
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPropertyKey.js
666
665
  function toPropertyKey(t) {
667
666
  var i = toPrimitive(t, "string");
668
667
  return "symbol" == _typeof(i) ? i : i + "";
669
668
  }
670
669
 
671
670
  //#endregion
672
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/defineProperty.js
671
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/defineProperty.js
673
672
  function _defineProperty(e, r, t) {
674
673
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
675
674
  value: t,
@@ -680,7 +679,7 @@ function _defineProperty(e, r, t) {
680
679
  }
681
680
 
682
681
  //#endregion
683
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorateParam.js
682
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorateParam.js
684
683
  function __decorateParam(paramIndex, decorator) {
685
684
  return function(target, key) {
686
685
  decorator(target, key, paramIndex);
@@ -688,7 +687,7 @@ function __decorateParam(paramIndex, decorator) {
688
687
  }
689
688
 
690
689
  //#endregion
691
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorate.js
690
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorate.js
692
691
  function __decorate(decorators, target, key, desc) {
693
692
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
694
693
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -778,22 +777,20 @@ let SheetsNumfmtCellContentController = class SheetsNumfmtCellContentController
778
777
  };
779
778
  return next(cell);
780
779
  }
781
- let numfmtRes = "";
782
780
  const cache = renderCache.getValue(location.row, location.col);
783
781
  if (cache && cache.parameters === `${originCellValue.v}_${numfmtValue === null || numfmtValue === void 0 ? void 0 : numfmtValue.pattern}`) return next({
784
782
  ...cell,
785
783
  ...cache.result
786
784
  });
787
785
  const info = getPatternPreviewIgnoreGeneral(numfmtValue === null || numfmtValue === void 0 ? void 0 : numfmtValue.pattern, Number(originCellValue.v), this.locale);
788
- numfmtRes = info.result;
789
- if (!numfmtRes) return next(cell);
786
+ const numfmtRes = info.result;
790
787
  const res = {
791
788
  v: numfmtRes,
792
789
  t: _univerjs_core.CellValueType.NUMBER
793
790
  };
791
+ if (numfmtRes === "") res.coverable = false;
794
792
  if (info.color) {
795
- var _this$_themeService$g;
796
- const color = (_this$_themeService$g = this._themeService.getColorFromTheme(`${info.color}.500`)) !== null && _this$_themeService$g !== void 0 ? _this$_themeService$g : info.color;
793
+ const color = this._themeService.getColorFromTheme(`${info.color}.500`) ?? info.color;
797
794
  if (color) res.interceptorStyle = { cl: { rgb: color } };
798
795
  }
799
796
  renderCache.setValue(location.row, location.col, {
@@ -822,10 +819,7 @@ let SheetsNumfmtCellContentController = class SheetsNumfmtCellContentController
822
819
  });
823
820
  }
824
821
  }));
825
- this.disposeWithMe(this._instanceService.getCurrentTypeOfUnit$(_univerjs_core.UniverInstanceType.UNIVER_SHEET).pipe((0, rxjs.switchMap)((workbook) => {
826
- var _workbook$activeSheet;
827
- return (_workbook$activeSheet = workbook === null || workbook === void 0 ? void 0 : workbook.activeSheet$) !== null && _workbook$activeSheet !== void 0 ? _workbook$activeSheet : (0, rxjs.of)(null);
828
- }), (0, rxjs.skip)(1)).subscribe(() => renderCache.reset()));
822
+ 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(() => renderCache.reset()));
829
823
  }
830
824
  setNumfmtLocal(locale) {
831
825
  this._locale$.next(locale);
@@ -844,7 +838,7 @@ SheetsNumfmtCellContentController = __decorate([
844
838
  //#endregion
845
839
  //#region package.json
846
840
  var name = "@univerjs/sheets-numfmt";
847
- var version = "1.0.0-alpha.7";
841
+ var version = "1.0.0-beta.0";
848
842
 
849
843
  //#endregion
850
844
  //#region src/base/const/plugin-name.ts
package/lib/es/facade.js CHANGED
@@ -38,14 +38,14 @@ var FRangeSheetsNumfmtMixin = class extends FRange {
38
38
  return this;
39
39
  }
40
40
  getNumberFormat() {
41
- var _style$numberFormat$p, _style$numberFormat;
41
+ var _style$numberFormat;
42
42
  const style = this.getCellStyle();
43
- return (_style$numberFormat$p = style === null || style === void 0 || (_style$numberFormat = style.numberFormat) === null || _style$numberFormat === void 0 ? void 0 : _style$numberFormat.pattern) !== null && _style$numberFormat$p !== void 0 ? _style$numberFormat$p : "";
43
+ return (style === null || style === void 0 || (_style$numberFormat = style.numberFormat) === null || _style$numberFormat === void 0 ? void 0 : _style$numberFormat.pattern) ?? "";
44
44
  }
45
45
  getNumberFormats() {
46
46
  return this.getCellStyles().map((row) => row.map((cellStyle) => {
47
- var _cellStyle$numberForm, _cellStyle$numberForm2;
48
- return (_cellStyle$numberForm = cellStyle === null || cellStyle === void 0 || (_cellStyle$numberForm2 = cellStyle.numberFormat) === null || _cellStyle$numberForm2 === void 0 ? void 0 : _cellStyle$numberForm2.pattern) !== null && _cellStyle$numberForm !== void 0 ? _cellStyle$numberForm : "";
47
+ var _cellStyle$numberForm;
48
+ return (cellStyle === null || cellStyle === void 0 || (_cellStyle$numberForm = cellStyle.numberFormat) === null || _cellStyle$numberForm === void 0 ? void 0 : _cellStyle$numberForm.pattern) ?? "";
49
49
  }));
50
50
  }
51
51
  };
package/lib/es/index.js CHANGED
@@ -263,9 +263,8 @@ const CURRENCYFORMAT = [
263
263
  * the function decimal just use positive,negative configuration ignored
264
264
  */
265
265
  const getDecimalFromPattern = (pattern, defaultValue = 0) => {
266
- var _info$maxDecimals;
267
266
  if (!pattern) return defaultValue;
268
- return (_info$maxDecimals = numfmt.getFormatInfo(pattern).maxDecimals) !== null && _info$maxDecimals !== void 0 ? _info$maxDecimals : defaultValue;
267
+ return numfmt.getFormatInfo(pattern).maxDecimals ?? defaultValue;
269
268
  };
270
269
  const getDecimalString = (length) => new Array(Math.min(Math.max(0, Number(length)), 30)).fill(0).join("");
271
270
  const setPatternDecimal = (patterns, decimalLength) => {
@@ -637,7 +636,7 @@ const configSymbol = Symbol(SHEETS_NUMFMT_PLUGIN_CONFIG_KEY);
637
636
  const defaultPluginConfig = {};
638
637
 
639
638
  //#endregion
640
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/typeof.js
639
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/typeof.js
641
640
  function _typeof(o) {
642
641
  "@babel/helpers - typeof";
643
642
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -648,7 +647,7 @@ function _typeof(o) {
648
647
  }
649
648
 
650
649
  //#endregion
651
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPrimitive.js
650
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPrimitive.js
652
651
  function toPrimitive(t, r) {
653
652
  if ("object" != _typeof(t) || !t) return t;
654
653
  var e = t[Symbol.toPrimitive];
@@ -661,14 +660,14 @@ function toPrimitive(t, r) {
661
660
  }
662
661
 
663
662
  //#endregion
664
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPropertyKey.js
663
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPropertyKey.js
665
664
  function toPropertyKey(t) {
666
665
  var i = toPrimitive(t, "string");
667
666
  return "symbol" == _typeof(i) ? i : i + "";
668
667
  }
669
668
 
670
669
  //#endregion
671
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/defineProperty.js
670
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/defineProperty.js
672
671
  function _defineProperty(e, r, t) {
673
672
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
674
673
  value: t,
@@ -679,7 +678,7 @@ function _defineProperty(e, r, t) {
679
678
  }
680
679
 
681
680
  //#endregion
682
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorateParam.js
681
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorateParam.js
683
682
  function __decorateParam(paramIndex, decorator) {
684
683
  return function(target, key) {
685
684
  decorator(target, key, paramIndex);
@@ -687,7 +686,7 @@ function __decorateParam(paramIndex, decorator) {
687
686
  }
688
687
 
689
688
  //#endregion
690
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorate.js
689
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorate.js
691
690
  function __decorate(decorators, target, key, desc) {
692
691
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
693
692
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -777,22 +776,20 @@ let SheetsNumfmtCellContentController = class SheetsNumfmtCellContentController
777
776
  };
778
777
  return next(cell);
779
778
  }
780
- let numfmtRes = "";
781
779
  const cache = renderCache.getValue(location.row, location.col);
782
780
  if (cache && cache.parameters === `${originCellValue.v}_${numfmtValue === null || numfmtValue === void 0 ? void 0 : numfmtValue.pattern}`) return next({
783
781
  ...cell,
784
782
  ...cache.result
785
783
  });
786
784
  const info = getPatternPreviewIgnoreGeneral(numfmtValue === null || numfmtValue === void 0 ? void 0 : numfmtValue.pattern, Number(originCellValue.v), this.locale);
787
- numfmtRes = info.result;
788
- if (!numfmtRes) return next(cell);
785
+ const numfmtRes = info.result;
789
786
  const res = {
790
787
  v: numfmtRes,
791
788
  t: CellValueType.NUMBER
792
789
  };
790
+ if (numfmtRes === "") res.coverable = false;
793
791
  if (info.color) {
794
- var _this$_themeService$g;
795
- const color = (_this$_themeService$g = this._themeService.getColorFromTheme(`${info.color}.500`)) !== null && _this$_themeService$g !== void 0 ? _this$_themeService$g : info.color;
792
+ const color = this._themeService.getColorFromTheme(`${info.color}.500`) ?? info.color;
796
793
  if (color) res.interceptorStyle = { cl: { rgb: color } };
797
794
  }
798
795
  renderCache.setValue(location.row, location.col, {
@@ -821,10 +818,7 @@ let SheetsNumfmtCellContentController = class SheetsNumfmtCellContentController
821
818
  });
822
819
  }
823
820
  }));
824
- this.disposeWithMe(this._instanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET).pipe(switchMap((workbook) => {
825
- var _workbook$activeSheet;
826
- return (_workbook$activeSheet = workbook === null || workbook === void 0 ? void 0 : workbook.activeSheet$) !== null && _workbook$activeSheet !== void 0 ? _workbook$activeSheet : of(null);
827
- }), skip(1)).subscribe(() => renderCache.reset()));
821
+ 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(() => renderCache.reset()));
828
822
  }
829
823
  setNumfmtLocal(locale) {
830
824
  this._locale$.next(locale);
@@ -843,7 +837,7 @@ SheetsNumfmtCellContentController = __decorate([
843
837
  //#endregion
844
838
  //#region package.json
845
839
  var name = "@univerjs/sheets-numfmt";
846
- var version = "1.0.0-alpha.7";
840
+ var version = "1.0.0-beta.0";
847
841
 
848
842
  //#endregion
849
843
  //#region src/base/const/plugin-name.ts
package/lib/facade.js CHANGED
@@ -38,14 +38,14 @@ var FRangeSheetsNumfmtMixin = class extends FRange {
38
38
  return this;
39
39
  }
40
40
  getNumberFormat() {
41
- var _style$numberFormat$p, _style$numberFormat;
41
+ var _style$numberFormat;
42
42
  const style = this.getCellStyle();
43
- return (_style$numberFormat$p = style === null || style === void 0 || (_style$numberFormat = style.numberFormat) === null || _style$numberFormat === void 0 ? void 0 : _style$numberFormat.pattern) !== null && _style$numberFormat$p !== void 0 ? _style$numberFormat$p : "";
43
+ return (style === null || style === void 0 || (_style$numberFormat = style.numberFormat) === null || _style$numberFormat === void 0 ? void 0 : _style$numberFormat.pattern) ?? "";
44
44
  }
45
45
  getNumberFormats() {
46
46
  return this.getCellStyles().map((row) => row.map((cellStyle) => {
47
- var _cellStyle$numberForm, _cellStyle$numberForm2;
48
- return (_cellStyle$numberForm = cellStyle === null || cellStyle === void 0 || (_cellStyle$numberForm2 = cellStyle.numberFormat) === null || _cellStyle$numberForm2 === void 0 ? void 0 : _cellStyle$numberForm2.pattern) !== null && _cellStyle$numberForm !== void 0 ? _cellStyle$numberForm : "";
47
+ var _cellStyle$numberForm;
48
+ return (cellStyle === null || cellStyle === void 0 || (_cellStyle$numberForm = cellStyle.numberFormat) === null || _cellStyle$numberForm === void 0 ? void 0 : _cellStyle$numberForm.pattern) ?? "";
49
49
  }));
50
50
  }
51
51
  };
package/lib/index.js CHANGED
@@ -263,9 +263,8 @@ const CURRENCYFORMAT = [
263
263
  * the function decimal just use positive,negative configuration ignored
264
264
  */
265
265
  const getDecimalFromPattern = (pattern, defaultValue = 0) => {
266
- var _info$maxDecimals;
267
266
  if (!pattern) return defaultValue;
268
- return (_info$maxDecimals = numfmt.getFormatInfo(pattern).maxDecimals) !== null && _info$maxDecimals !== void 0 ? _info$maxDecimals : defaultValue;
267
+ return numfmt.getFormatInfo(pattern).maxDecimals ?? defaultValue;
269
268
  };
270
269
  const getDecimalString = (length) => new Array(Math.min(Math.max(0, Number(length)), 30)).fill(0).join("");
271
270
  const setPatternDecimal = (patterns, decimalLength) => {
@@ -637,7 +636,7 @@ const configSymbol = Symbol(SHEETS_NUMFMT_PLUGIN_CONFIG_KEY);
637
636
  const defaultPluginConfig = {};
638
637
 
639
638
  //#endregion
640
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/typeof.js
639
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/typeof.js
641
640
  function _typeof(o) {
642
641
  "@babel/helpers - typeof";
643
642
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -648,7 +647,7 @@ function _typeof(o) {
648
647
  }
649
648
 
650
649
  //#endregion
651
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPrimitive.js
650
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPrimitive.js
652
651
  function toPrimitive(t, r) {
653
652
  if ("object" != _typeof(t) || !t) return t;
654
653
  var e = t[Symbol.toPrimitive];
@@ -661,14 +660,14 @@ function toPrimitive(t, r) {
661
660
  }
662
661
 
663
662
  //#endregion
664
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPropertyKey.js
663
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPropertyKey.js
665
664
  function toPropertyKey(t) {
666
665
  var i = toPrimitive(t, "string");
667
666
  return "symbol" == _typeof(i) ? i : i + "";
668
667
  }
669
668
 
670
669
  //#endregion
671
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/defineProperty.js
670
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/defineProperty.js
672
671
  function _defineProperty(e, r, t) {
673
672
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
674
673
  value: t,
@@ -679,7 +678,7 @@ function _defineProperty(e, r, t) {
679
678
  }
680
679
 
681
680
  //#endregion
682
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorateParam.js
681
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorateParam.js
683
682
  function __decorateParam(paramIndex, decorator) {
684
683
  return function(target, key) {
685
684
  decorator(target, key, paramIndex);
@@ -687,7 +686,7 @@ function __decorateParam(paramIndex, decorator) {
687
686
  }
688
687
 
689
688
  //#endregion
690
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorate.js
689
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorate.js
691
690
  function __decorate(decorators, target, key, desc) {
692
691
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
693
692
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -777,22 +776,20 @@ let SheetsNumfmtCellContentController = class SheetsNumfmtCellContentController
777
776
  };
778
777
  return next(cell);
779
778
  }
780
- let numfmtRes = "";
781
779
  const cache = renderCache.getValue(location.row, location.col);
782
780
  if (cache && cache.parameters === `${originCellValue.v}_${numfmtValue === null || numfmtValue === void 0 ? void 0 : numfmtValue.pattern}`) return next({
783
781
  ...cell,
784
782
  ...cache.result
785
783
  });
786
784
  const info = getPatternPreviewIgnoreGeneral(numfmtValue === null || numfmtValue === void 0 ? void 0 : numfmtValue.pattern, Number(originCellValue.v), this.locale);
787
- numfmtRes = info.result;
788
- if (!numfmtRes) return next(cell);
785
+ const numfmtRes = info.result;
789
786
  const res = {
790
787
  v: numfmtRes,
791
788
  t: CellValueType.NUMBER
792
789
  };
790
+ if (numfmtRes === "") res.coverable = false;
793
791
  if (info.color) {
794
- var _this$_themeService$g;
795
- const color = (_this$_themeService$g = this._themeService.getColorFromTheme(`${info.color}.500`)) !== null && _this$_themeService$g !== void 0 ? _this$_themeService$g : info.color;
792
+ const color = this._themeService.getColorFromTheme(`${info.color}.500`) ?? info.color;
796
793
  if (color) res.interceptorStyle = { cl: { rgb: color } };
797
794
  }
798
795
  renderCache.setValue(location.row, location.col, {
@@ -821,10 +818,7 @@ let SheetsNumfmtCellContentController = class SheetsNumfmtCellContentController
821
818
  });
822
819
  }
823
820
  }));
824
- this.disposeWithMe(this._instanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET).pipe(switchMap((workbook) => {
825
- var _workbook$activeSheet;
826
- return (_workbook$activeSheet = workbook === null || workbook === void 0 ? void 0 : workbook.activeSheet$) !== null && _workbook$activeSheet !== void 0 ? _workbook$activeSheet : of(null);
827
- }), skip(1)).subscribe(() => renderCache.reset()));
821
+ 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(() => renderCache.reset()));
828
822
  }
829
823
  setNumfmtLocal(locale) {
830
824
  this._locale$.next(locale);
@@ -843,7 +837,7 @@ SheetsNumfmtCellContentController = __decorate([
843
837
  //#endregion
844
838
  //#region package.json
845
839
  var name = "@univerjs/sheets-numfmt";
846
- var version = "1.0.0-alpha.7";
840
+ var version = "1.0.0-beta.0";
847
841
 
848
842
  //#endregion
849
843
  //#region src/base/const/plugin-name.ts
package/lib/umd/facade.js CHANGED
@@ -1 +1 @@
1
- (function(e,t){typeof exports==`object`&&typeof module<`u`?t(require("@univerjs/sheets-numfmt"),require("@univerjs/sheets/facade")):typeof define==`function`&&define.amd?define([`@univerjs/sheets-numfmt`,`@univerjs/sheets/facade`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverSheetsNumfmt,e.UniverSheetsFacade))})(this,function(e,t){var n=class extends t.FRange{setNumberFormat(t){let n=[],{startColumn:r,startRow:i,endColumn:a,endRow:o}=this._range;for(let e=i;e<=o;e++)for(let i=r;i<=a;i++)n.push({row:e,col:i,pattern:t});return this._commandService.syncExecuteCommand(e.SetNumfmtCommand.id,{unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),values:n}),this}setNumberFormats(t){let n=[],{startColumn:r,startRow:i,endColumn:a,endRow:o}=this._range;for(let e=i;e<=o;e++)for(let o=r;o<=a;o++){var s;let a=(s=t[e-i])==null?void 0:s[o-r];n.push({row:e,col:o,pattern:a})}return this._commandService.syncExecuteCommand(e.SetNumfmtCommand.id,{unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),values:n}),this}getNumberFormat(){var e,t;let n=this.getCellStyle();return(e=n==null||(t=n.numberFormat)==null?void 0:t.pattern)==null?``:e}getNumberFormats(){return this.getCellStyles().map(e=>e.map(e=>{var t,n;return(t=e==null||(n=e.numberFormat)==null?void 0:n.pattern)==null?``:t}))}};t.FRange.extend(n);var r=class extends t.FWorkbook{setNumfmtLocal(t){return this._injector.get(e.SheetsNumfmtCellContentController).setNumfmtLocal(t),this}};t.FWorkbook.extend(r)});
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(require("@univerjs/sheets-numfmt"),require("@univerjs/sheets/facade")):typeof define==`function`&&define.amd?define([`@univerjs/sheets-numfmt`,`@univerjs/sheets/facade`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverSheetsNumfmt,e.UniverSheetsFacade))})(this,function(e,t){var n=class extends t.FRange{setNumberFormat(t){let n=[],{startColumn:r,startRow:i,endColumn:a,endRow:o}=this._range;for(let e=i;e<=o;e++)for(let i=r;i<=a;i++)n.push({row:e,col:i,pattern:t});return this._commandService.syncExecuteCommand(e.SetNumfmtCommand.id,{unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),values:n}),this}setNumberFormats(t){let n=[],{startColumn:r,startRow:i,endColumn:a,endRow:o}=this._range;for(let e=i;e<=o;e++)for(let o=r;o<=a;o++){var s;let a=(s=t[e-i])==null?void 0:s[o-r];n.push({row:e,col:o,pattern:a})}return this._commandService.syncExecuteCommand(e.SetNumfmtCommand.id,{unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),values:n}),this}getNumberFormat(){var e;let t=this.getCellStyle();return(t==null||(e=t.numberFormat)==null?void 0:e.pattern)??``}getNumberFormats(){return this.getCellStyles().map(e=>e.map(e=>{var t;return(e==null||(t=e.numberFormat)==null?void 0:t.pattern)??``}))}};t.FRange.extend(n);var r=class extends t.FWorkbook{setNumfmtLocal(t){return this._injector.get(e.SheetsNumfmtCellContentController).setNumfmtLocal(t),this}};t.FWorkbook.extend(r)});
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)=>{var r;return e?(r=t.numfmt.getFormatInfo(e).maxDecimals)==null?n:r: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||(c=this._numfmtService.getValue(o,s,i.row,i.col)),(0,t.isDefaultFormat)(c==null?void 0:c.pattern)||r.t!==t.CellValueType.NUMBER&&(0,n.checkCellValueType)(r.v,r.t)!==t.CellValueType.NUMBER)return a(r);let l=r;if((!r||r===i.rawData)&&(r={...i.rawData}),(0,t.isTextFormat)(c==null?void 0:c.pattern)){var u;return(u=this._configService.getConfig(`sheets-numfmt.config`))!=null&&u.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 d=``,f=e.getValue(i.row,i.col);if(f&&f.parameters===`${l.v}_${c==null?void 0:c.pattern}`)return a({...r,...f.result});let p=v(c==null?void 0:c.pattern,Number(l.v),this.locale);if(d=p.result,!d)return a(r);let m={v:d,t:t.CellValueType.NUMBER};if(p.color){var h;let e=(h=this._themeService.getColorFromTheme(`${p.color}.500`))==null?p.color:h;e&&(m.interceptorStyle={cl:{rgb:e}})}return e.setValue(i.row,i.col,{result:m,parameters:`${l.v}_${c==null?void 0:c.pattern}`}),Object.assign(r,m),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=>{var t;return(t=e==null?void 0:e.activeSheet$)==null?(0,i.of)(null):t}),(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-alpha.7`;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=>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)||r.t!==t.CellValueType.NUMBER&&(0,n.checkCellValueType)(r.v,r.t)!==t.CellValueType.NUMBER)return a(r);let l=r;if((!r||r===i.rawData)&&(r={...i.rawData}),(0,t.isTextFormat)(c==null?void 0:c.pattern)){var u;return(u=this._configService.getConfig(`sheets-numfmt.config`))!=null&&u.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 d=e.getValue(i.row,i.col);if(d&&d.parameters===`${l.v}_${c==null?void 0:c.pattern}`)return a({...r,...d.result});let f=v(c==null?void 0:c.pattern,Number(l.v),this.locale),p=f.result,m={v:p,t:t.CellValueType.NUMBER};if(p===``&&(m.coverable=!1),f.color){let e=this._themeService.getColorFromTheme(`${f.color}.500`)??f.color;e&&(m.interceptorStyle={cl:{rgb:e}})}return e.setValue(i.row,i.col,{result:m,parameters:`${l.v}_${c==null?void 0:c.pattern}`}),Object.assign(r,m),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-beta.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-alpha.7",
3
+ "version": "1.0.0-beta.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-alpha.7",
66
- "@univerjs/engine-formula": "1.0.0-alpha.7",
67
- "@univerjs/sheets": "1.0.0-alpha.7"
65
+ "@univerjs/core": "1.0.0-beta.0",
66
+ "@univerjs/engine-formula": "1.0.0-beta.0",
67
+ "@univerjs/sheets": "1.0.0-beta.0"
68
68
  },
69
69
  "devDependencies": {
70
70
  "rxjs": "^7.8.2",
71
71
  "typescript": "^6.0.3",
72
72
  "vitest": "^4.1.10",
73
- "@univerjs-infra/shared": "1.0.0-alpha.7"
73
+ "@univerjs-infra/shared": "1.0.0-beta.0"
74
74
  },
75
75
  "scripts": {
76
76
  "test": "vitest run",