@univerjs/sheets-numfmt-ui 0.6.6 → 0.6.7-experimental.20250328-3aaa828
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/index.js +2 -2
- package/lib/es/index.js +415 -412
- package/lib/index.js +1097 -0
- package/lib/locale/en-US.js +41 -0
- package/lib/locale/fa-IR.js +41 -0
- package/lib/locale/fr-FR.js +41 -0
- package/lib/locale/ru-RU.js +41 -0
- package/lib/locale/vi-VN.js +41 -0
- package/lib/locale/zh-CN.js +41 -0
- package/lib/locale/zh-TW.js +41 -0
- package/lib/types/controllers/config.schema.d.ts +1 -1
- package/lib/types/controllers/numfmt-alert-render.controller.d.ts +3 -2
- package/lib/umd/index.js +2 -2
- package/package.json +15 -15
- package/LICENSE +0 -176
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const e = {
|
|
2
|
+
sheet: {
|
|
3
|
+
numfmt: {
|
|
4
|
+
percent: "Percentage",
|
|
5
|
+
title: "Number format",
|
|
6
|
+
numfmtType: "Format types",
|
|
7
|
+
cancel: "Cancel",
|
|
8
|
+
confirm: "Confirm",
|
|
9
|
+
general: "General",
|
|
10
|
+
accounting: "Accounting",
|
|
11
|
+
text: "Text",
|
|
12
|
+
number: "Number",
|
|
13
|
+
currency: "Currency",
|
|
14
|
+
date: "Date",
|
|
15
|
+
time: "Time",
|
|
16
|
+
thousandthPercentile: "Thousands separator",
|
|
17
|
+
preview: "Preview",
|
|
18
|
+
dateTime: "Date and time",
|
|
19
|
+
decimalLength: "Decimal places",
|
|
20
|
+
currencyType: "Currency Symbol",
|
|
21
|
+
moreFmt: "Formats",
|
|
22
|
+
financialValue: "Financial value",
|
|
23
|
+
roundingCurrency: "Rounding up the currency",
|
|
24
|
+
timeDuration: "Duration Time",
|
|
25
|
+
currencyDes: "The currency format is used to represent general currency values. The accounting format aligns a column of values with decimal points",
|
|
26
|
+
accountingDes: "The accounting number format aligns a column of values with currency symbols and decimal points",
|
|
27
|
+
dateType: "Date Type",
|
|
28
|
+
dateDes: "The date format presents date and time series values as date values.",
|
|
29
|
+
negType: "A negative number type",
|
|
30
|
+
generalDes: "The regular format does not contain any specific number format.",
|
|
31
|
+
thousandthPercentileDes: "The percentile format is used for the representation of ordinary numbers. Monetary and accounting formats provide a specialized format for monetary value calculations.",
|
|
32
|
+
addDecimal: "Increase decimal places",
|
|
33
|
+
subtractDecimal: "Decreasing decimal places",
|
|
34
|
+
customFormat: "Custom Format",
|
|
35
|
+
customFormatDes: "Generate custom number formats based on existing formats."
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
export {
|
|
40
|
+
e as default
|
|
41
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const e = {
|
|
2
|
+
sheet: {
|
|
3
|
+
numfmt: {
|
|
4
|
+
percent: "درصد",
|
|
5
|
+
title: "قالببندی عدد",
|
|
6
|
+
numfmtType: "انواع قالببندی",
|
|
7
|
+
cancel: "انصراف",
|
|
8
|
+
confirm: "تایید",
|
|
9
|
+
general: "عمومی",
|
|
10
|
+
accounting: "حسابداری",
|
|
11
|
+
text: "متن",
|
|
12
|
+
number: "عدد",
|
|
13
|
+
currency: "ارز",
|
|
14
|
+
date: "تاریخ",
|
|
15
|
+
time: "زمان",
|
|
16
|
+
thousandthPercentile: "جداساز هزارتایی",
|
|
17
|
+
preview: "پیشنمایش",
|
|
18
|
+
dateTime: "تاریخ و زمان",
|
|
19
|
+
decimalLength: "اعشار",
|
|
20
|
+
currencyType: "نماد ارز",
|
|
21
|
+
moreFmt: "قالبها",
|
|
22
|
+
financialValue: "مقدار مالی",
|
|
23
|
+
roundingCurrency: "گرد کردن ارز",
|
|
24
|
+
timeDuration: "مدت زمان",
|
|
25
|
+
currencyDes: "قالببندی ارز برای نمایش مقادیر عمومی ارز استفاده میشود. قالببندی حسابداری ستونی از مقادیر را با اعشار تراز میکند.",
|
|
26
|
+
accountingDes: "قالببندی عددی حسابداری ستونی از مقادیر را با نمادهای ارز و اعشار تراز میکند.",
|
|
27
|
+
dateType: "نوع تاریخ",
|
|
28
|
+
dateDes: "قالببندی تاریخ مقادیر سری تاریخ و زمان را به عنوان مقادیر تاریخ ارائه میدهد.",
|
|
29
|
+
negType: "نوع عدد منفی",
|
|
30
|
+
generalDes: "قالببندی معمولی حاوی هیچ قالببندی عدد خاصی نیست.",
|
|
31
|
+
thousandthPercentileDes: "قالببندی درصدی برای نمایش اعداد معمولی استفاده میشود. قالببندیهای پولی و حسابداری قالب تخصصی برای محاسبات مقدار پولی ارائه میدهند.",
|
|
32
|
+
addDecimal: "افزایش اعشار",
|
|
33
|
+
subtractDecimal: "کاهش اعشار",
|
|
34
|
+
customFormat: "قالببندی سفارشی",
|
|
35
|
+
customFormatDes: "ایجاد قالببندیهای عددی سفارشی بر اساس قالببندیهای موجود."
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
export {
|
|
40
|
+
e as default
|
|
41
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const e = {
|
|
2
|
+
sheet: {
|
|
3
|
+
numfmt: {
|
|
4
|
+
percent: "Pourcentage",
|
|
5
|
+
title: "Format de nombre",
|
|
6
|
+
numfmtType: "Types de format",
|
|
7
|
+
cancel: "Annuler",
|
|
8
|
+
confirm: "Confirmer",
|
|
9
|
+
general: "Général",
|
|
10
|
+
accounting: "Comptabilité",
|
|
11
|
+
text: "Texte",
|
|
12
|
+
number: "Nombre",
|
|
13
|
+
currency: "Devise",
|
|
14
|
+
date: "Date",
|
|
15
|
+
time: "Heure",
|
|
16
|
+
thousandthPercentile: "Séparateur de milliers",
|
|
17
|
+
preview: "Aperçu",
|
|
18
|
+
dateTime: "Date et heure",
|
|
19
|
+
decimalLength: "Nombre de décimales",
|
|
20
|
+
currencyType: "Symbole de devise",
|
|
21
|
+
moreFmt: "Formats",
|
|
22
|
+
financialValue: "Valeur financière",
|
|
23
|
+
roundingCurrency: "Arrondir la devise",
|
|
24
|
+
timeDuration: "Durée",
|
|
25
|
+
currencyDes: "Le format de devise est utilisé pour représenter des valeurs monétaires générales. Le format de comptabilité aligne une colonne de valeurs avec des points décimaux",
|
|
26
|
+
accountingDes: "Le format de nombre de comptabilité aligne une colonne de valeurs avec des symboles de devise et des points décimaux",
|
|
27
|
+
dateType: "Type de date",
|
|
28
|
+
dateDes: "Le format de date présente les valeurs de la série date et heure sous forme de valeurs de date.",
|
|
29
|
+
negType: "Type de nombre négatif",
|
|
30
|
+
generalDes: "Le format général ne contient aucun format de nombre spécifique.",
|
|
31
|
+
thousandthPercentileDes: "Le format de percentile est utilisé pour la représentation des nombres ordinaires. Les formats monétaires et comptables fournissent un format spécialisé pour les calculs de valeurs monétaires.",
|
|
32
|
+
addDecimal: "Augmenter les décimales",
|
|
33
|
+
subtractDecimal: "Diminuer les décimales",
|
|
34
|
+
customFormat: "Format personnalisé",
|
|
35
|
+
customFormatDes: "Générer des formats de nombre personnalisés basés sur des formats existants."
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
export {
|
|
40
|
+
e as default
|
|
41
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const e = {
|
|
2
|
+
sheet: {
|
|
3
|
+
numfmt: {
|
|
4
|
+
percent: "Процент",
|
|
5
|
+
title: "Формат числа",
|
|
6
|
+
numfmtType: "Типы форматов",
|
|
7
|
+
cancel: "Отмена",
|
|
8
|
+
confirm: "Подтвердить",
|
|
9
|
+
general: "Общий",
|
|
10
|
+
accounting: "Бухгалтерский",
|
|
11
|
+
text: "Текст",
|
|
12
|
+
number: "Число",
|
|
13
|
+
currency: "Валюта",
|
|
14
|
+
date: "Дата",
|
|
15
|
+
time: "Время",
|
|
16
|
+
thousandthPercentile: "Разделитель тысяч",
|
|
17
|
+
preview: "Предпросмотр",
|
|
18
|
+
dateTime: "Дата и время",
|
|
19
|
+
decimalLength: "Десятичные знаки",
|
|
20
|
+
currencyType: "Символ валюты",
|
|
21
|
+
moreFmt: "Другие форматы",
|
|
22
|
+
financialValue: "Финансовое значение",
|
|
23
|
+
roundingCurrency: "Округление валюты",
|
|
24
|
+
timeDuration: "Продолжительность времени",
|
|
25
|
+
currencyDes: "Формат валюты используется для представления общих значений валюты. Формат бухгалтерского учета выравнивает столбец значений по десятичным точкам.",
|
|
26
|
+
accountingDes: "Формат бухгалтерских чисел выравнивает столбец значений по символам валюты и десятичным точкам.",
|
|
27
|
+
dateType: "Тип даты",
|
|
28
|
+
dateDes: "Формат даты представляет значения времени и даты как значения даты.",
|
|
29
|
+
negType: "Тип отрицательного числа",
|
|
30
|
+
generalDes: "Обычный формат не содержит никакого специфического формата числа.",
|
|
31
|
+
thousandthPercentileDes: "Формат процента используется для представления обычных чисел. Монетарные и бухгалтерские форматы предоставляют специальный формат для вычислений монетарных значений.",
|
|
32
|
+
addDecimal: "Увеличить количество десятичных знаков",
|
|
33
|
+
subtractDecimal: "Уменьшить количество десятичных знаков",
|
|
34
|
+
customFormat: "Custom Format",
|
|
35
|
+
customFormatDes: "Generate custom number formats based on existing formats."
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
export {
|
|
40
|
+
e as default
|
|
41
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const n = {
|
|
2
|
+
sheet: {
|
|
3
|
+
numfmt: {
|
|
4
|
+
percent: "Phần trăm",
|
|
5
|
+
title: "Định dạng số",
|
|
6
|
+
numfmtType: "Loại định dạng",
|
|
7
|
+
cancel: "Hủy bỏ",
|
|
8
|
+
confirm: "Xác nhận",
|
|
9
|
+
general: "Chung",
|
|
10
|
+
accounting: "Kế toán",
|
|
11
|
+
text: "Văn bản",
|
|
12
|
+
number: "Số",
|
|
13
|
+
currency: "Tiền tệ",
|
|
14
|
+
date: "Ngày",
|
|
15
|
+
time: "Thời gian",
|
|
16
|
+
thousandthPercentile: "Phân vị phần nghìn",
|
|
17
|
+
preview: "Xem trước",
|
|
18
|
+
dateTime: "Ngày giờ",
|
|
19
|
+
decimalLength: "Số chữ số thập phân",
|
|
20
|
+
currencyType: "Loại tiền tệ",
|
|
21
|
+
moreFmt: "Nhiều định dạng hơn",
|
|
22
|
+
financialValue: "Giá trị tài chính",
|
|
23
|
+
roundingCurrency: "Tiền tệ làm tròn",
|
|
24
|
+
timeDuration: "Thời lượng",
|
|
25
|
+
currencyDes: "Định dạng tiền tệ được sử dụng để biểu thị các giá trị tiền tệ thông thường. Định dạng kế toán có thể căn chỉnh các giá trị trong một cột với dấu thập phân.",
|
|
26
|
+
accountingDes: "Định dạng số kế toán có thể căn chỉnh các ký hiệu tiền tệ và dấu thập phân trong một cột các giá trị.",
|
|
27
|
+
dateType: "Loại ngày",
|
|
28
|
+
dateDes: "Định dạng ngày biểu thị các giá trị chuỗi ngày và thời gian dưới dạng giá trị ngày.",
|
|
29
|
+
negType: "Loại số âm",
|
|
30
|
+
generalDes: "Định dạng chung không chứa bất kỳ định dạng số cụ thể nào.",
|
|
31
|
+
thousandthPercentileDes: "Định dạng phân vị phần nghìn được sử dụng để biểu thị các số thông thường. Các định dạng tiền tệ và kế toán cung cấp các định dạng chuyên dụng để tính toán giá trị tiền tệ.",
|
|
32
|
+
addDecimal: "Thêm chữ số thập phân",
|
|
33
|
+
subtractDecimal: "Giảm chữ số thập phân",
|
|
34
|
+
customFormat: "Custom Format",
|
|
35
|
+
customFormatDes: "Generate custom number formats based on existing formats."
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
export {
|
|
40
|
+
n as default
|
|
41
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const e = {
|
|
2
|
+
sheet: {
|
|
3
|
+
numfmt: {
|
|
4
|
+
percent: "百分比",
|
|
5
|
+
title: "数字格式",
|
|
6
|
+
numfmtType: "格式类型",
|
|
7
|
+
cancel: "取消",
|
|
8
|
+
confirm: "确认",
|
|
9
|
+
general: "常规",
|
|
10
|
+
accounting: "会计",
|
|
11
|
+
text: "文本",
|
|
12
|
+
number: "数值",
|
|
13
|
+
currency: "货币",
|
|
14
|
+
date: "日期",
|
|
15
|
+
time: "时间",
|
|
16
|
+
thousandthPercentile: "千分位符",
|
|
17
|
+
preview: "示例",
|
|
18
|
+
dateTime: "日期时间",
|
|
19
|
+
decimalLength: "小数位数",
|
|
20
|
+
currencyType: "货币类型",
|
|
21
|
+
moreFmt: "更多格式",
|
|
22
|
+
financialValue: "财务数值",
|
|
23
|
+
roundingCurrency: "货币取整",
|
|
24
|
+
timeDuration: "持续时间",
|
|
25
|
+
currencyDes: "货币格式用于表示一般货币数值。会计格式可以对一列数值进行小数点对齐",
|
|
26
|
+
accountingDes: "会计数字格式可对一列数值进行货币符号和小数点对齐",
|
|
27
|
+
dateType: "日期类型",
|
|
28
|
+
dateDes: "日期格式将日期和时间系列数值品示为日期值。",
|
|
29
|
+
negType: "负数类型",
|
|
30
|
+
generalDes: "常规格式不包含任何特定的数字格式。",
|
|
31
|
+
thousandthPercentileDes: "千分位符格式用于一般数字的表示。货币和会计格式则提供货币值计算的专用格式。",
|
|
32
|
+
addDecimal: "增加小数位",
|
|
33
|
+
subtractDecimal: "减少小数位",
|
|
34
|
+
customFormat: "自定义格式",
|
|
35
|
+
customFormatDes: "根据现有格式生成自定义数字格式。"
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
export {
|
|
40
|
+
e as default
|
|
41
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const e = {
|
|
2
|
+
sheet: {
|
|
3
|
+
numfmt: {
|
|
4
|
+
percent: "百分比",
|
|
5
|
+
title: "數字格式",
|
|
6
|
+
numfmtType: "格式類型",
|
|
7
|
+
cancel: "取消",
|
|
8
|
+
confirm: "確認",
|
|
9
|
+
general: "常規",
|
|
10
|
+
accounting: "會計",
|
|
11
|
+
text: "文字",
|
|
12
|
+
number: "數值",
|
|
13
|
+
currency: "貨幣",
|
|
14
|
+
date: "日期",
|
|
15
|
+
time: "時間",
|
|
16
|
+
thousandthPercentile: "千分位符",
|
|
17
|
+
preview: "範例",
|
|
18
|
+
dateTime: "日期時間",
|
|
19
|
+
decimalLength: "小數位數",
|
|
20
|
+
currencyType: "貨幣類型",
|
|
21
|
+
moreFmt: "更多格式",
|
|
22
|
+
financialValue: "財務數值",
|
|
23
|
+
roundingCurrency: "貨幣取整",
|
|
24
|
+
timeDuration: "持續時間",
|
|
25
|
+
currencyDes: "貨幣格式用來表示一般貨幣數值。會計格式可以對一列數值進行小數點對齊",
|
|
26
|
+
accountingDes: "會計數字格式可對一列數值進行貨幣符號和小數點對齊",
|
|
27
|
+
dateType: "日期類型",
|
|
28
|
+
dateDes: "日期格式將日期和時間系列數值品顯示為日期值。",
|
|
29
|
+
negType: "負數型別",
|
|
30
|
+
generalDes: "常規格式不包含任何特定的數字格式。",
|
|
31
|
+
thousandthPercentileDes: "千分位符號格式用於一般數字的表示。貨幣和會計格式則提供貨幣值計算的專用格式。",
|
|
32
|
+
addDecimal: "增加小數位",
|
|
33
|
+
subtractDecimal: "減少小數位",
|
|
34
|
+
customFormat: "Custom Format",
|
|
35
|
+
customFormatDes: "Generate custom number formats based on existing formats."
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
export {
|
|
40
|
+
e as default
|
|
41
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MenuConfig } from '@univerjs/ui';
|
|
2
|
-
export declare const SHEETS_NUMFMT_UI_PLUGIN_CONFIG_KEY = "sheets-numfmt.config";
|
|
2
|
+
export declare const SHEETS_NUMFMT_UI_PLUGIN_CONFIG_KEY = "sheets-numfmt-ui.config";
|
|
3
3
|
export declare const configSymbol: unique symbol;
|
|
4
4
|
export interface IUniverSheetsNumfmtUIConfig {
|
|
5
5
|
menu?: MenuConfig;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Workbook, Disposable, LocaleService } from '@univerjs/core';
|
|
1
|
+
import { Workbook, Disposable, IConfigService, LocaleService } from '@univerjs/core';
|
|
2
2
|
import { IRenderContext, IRenderModule } from '@univerjs/engine-render';
|
|
3
3
|
import { FormulaDataModel } from '@univerjs/engine-formula';
|
|
4
4
|
import { INumfmtService } from '@univerjs/sheets';
|
|
@@ -12,7 +12,8 @@ export declare class NumfmtAlertRenderController extends Disposable implements I
|
|
|
12
12
|
private readonly _formulaDataModel;
|
|
13
13
|
private readonly _zenZoneService;
|
|
14
14
|
private _numfmtService;
|
|
15
|
-
|
|
15
|
+
private readonly _configService;
|
|
16
|
+
constructor(_context: IRenderContext<Workbook>, _hoverManagerService: HoverManagerService, _cellAlertManagerService: CellAlertManagerService, _localeService: LocaleService, _formulaDataModel: FormulaDataModel, _zenZoneService: IZenZoneService, _numfmtService: INumfmtService, _configService: IConfigService);
|
|
16
17
|
private _init;
|
|
17
18
|
private _initCellAlertPopup;
|
|
18
19
|
private _initZenService;
|
package/lib/umd/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
(function(b,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@univerjs/core"),require("@univerjs/engine-render"),require("@univerjs/sheets-numfmt"),require("@univerjs/sheets-ui"),require("@univerjs/ui"),require("@univerjs/engine-formula"),require("@univerjs/engine-numfmt"),require("@univerjs/sheets"),require("rxjs"),require("rxjs/operators"),require("react/jsx-runtime"),require("react"),require("@univerjs/design")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/engine-render","@univerjs/sheets-numfmt","@univerjs/sheets-ui","@univerjs/ui","@univerjs/engine-formula","@univerjs/engine-numfmt","@univerjs/sheets","rxjs","rxjs/operators","react/jsx-runtime","react","@univerjs/design"],o):(b=typeof globalThis<"u"?globalThis:b||self,o(b.UniverSheetsNumfmtUi={},b.UniverCore,b.UniverEngineRender,b.UniverSheetsNumfmt,b.UniverSheetsUi,b.UniverUi,b.UniverEngineFormula,b.UniverEngineNumfmt,b.UniverSheets,b.rxjs,b.rxjs.operators,b.React,b.React,b.UniverDesign))})(this,function(b,o,F,m,M,C,ve,V,S,N,B,u,y,P){"use strict";var lt=Object.defineProperty;var ut=(b,o,F)=>o in b?lt(b,o,{enumerable:!0,configurable:!0,writable:!0,value:F}):b[o]=F;var Z=(b,o,F)=>ut(b,typeof o!="symbol"?o+"":o,F);const ie={};var fe=Object.getOwnPropertyDescriptor,he=(e,t,r,n)=>{for(var i=n>1?void 0:n?fe(t,r):t,a=e.length-1,s;a>=0;a--)(s=e[a])&&(i=s(i)||i);return i},j=(e,t)=>(r,n)=>t(r,n,e);const z="SHEET_NUMFMT_ALERT";let Y=class extends o.Disposable{constructor(e,t,r,n,i,a,s){super(),this._context=e,this._hoverManagerService=t,this._cellAlertManagerService=r,this._localeService=n,this._formulaDataModel=i,this._zenZoneService=a,this._numfmtService=s,this._init()}_init(){this._initCellAlertPopup(),this._initZenService()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(N.debounceTime(100)).subscribe(e=>{var t;if(e){const r=e.location,n=this._context.unit,i=n.getActiveSheet();if(!i)return;const a=r.unitId,s=r.subUnitId;let l;const c=i.getCell(r.row,r.col);if(c!=null&&c.s){const d=n.getStyles().get(c.s);d!=null&&d.n&&(l=d.n)}if(l||(l=this._numfmtService.getValue(a,s,r.row,r.col)),!l){this._hideAlert();return}if(V.isTextFormat(l.pattern)&&(c!=null&&c.v)&&o.isRealNum(c.v)){const d=this._cellAlertManagerService.currentAlert.get(z),f=(t=d==null?void 0:d.alert)==null?void 0:t.location;if(f&&f.row===r.row&&f.col===r.col&&f.subUnitId===r.subUnitId&&f.unitId===r.unitId)return;this._cellAlertManagerService.showAlert({type:M.CellAlertType.ERROR,title:this._localeService.t("info.error"),message:this._localeService.t("info.forceStringInfo"),location:r,width:200,height:74,key:z});return}}this._hideAlert()}))}_initZenService(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{e&&this._hideAlert()}))}_hideAlert(){this._cellAlertManagerService.removeAlert(z)}};Y=he([j(1,o.Inject(M.HoverManagerService)),j(2,o.Inject(M.CellAlertManagerService)),j(3,o.Inject(o.LocaleService)),j(4,o.Inject(ve.FormulaDataModel)),j(5,C.IZenZoneService),j(6,o.Inject(S.INumfmtService))],Y);const X={id:"sheet.operation.close.numfmt.panel",type:o.CommandType.OPERATION,handler:()=>!0},H={id:"sheet.operation.open.numfmt.panel",type:o.CommandType.OPERATION,handler:e=>(e.get(A).openPanel(),!0)};var Se=Object.getOwnPropertyDescriptor,ge=(e,t,r,n)=>{for(var i=n>1?void 0:n?Se(t,r):t,a=e.length-1,s;a>=0;a--)(s=e[a])&&(i=s(i)||i);return i},ye=(e,t)=>(r,n)=>t(r,n,e);const J=y.createContext([]);let x=class{constructor(e){this._localStorageService=e}_getKey(e){return`userHabitController_${e}`}async addHabit(e,t){const r=this._getKey(e);return this._localStorageService.getItem(r).then(n=>{n||this._localStorageService.setItem(r,t)})}markHabit(e,t){const r=this._getKey(e);this._localStorageService.getItem(r).then(n=>{if(n){const i=n.findIndex(a=>a===t);i>-1&&n.splice(i,1),n.unshift(t),this._localStorageService.setItem(r,n)}})}async getHabit(e,t){const r=this._getKey(e),n=await this._localStorageService.getItem(r);if(t&&n){const i=n.map((a,s,l)=>{const c=l.length;return{value:a,priority:c-s}});return t.sort((a,s)=>{var d,f;const l=((d=i.find(p=>p.value===a))==null?void 0:d.priority)||-1;return(((f=i.find(p=>p.value===s))==null?void 0:f.priority)||-1)-l})}return n||[]}deleteHabit(e){this._localStorageService.removeItem(e)}};x=ge([ye(0,o.Inject(o.ILocalStorageService))],x);const ae="numfmtCurrency",_e=e=>{const t=C.useDependency(x),[r,n]=y.useState(m.currencySymbols);return y.useEffect(()=>{t.addHabit("numfmtCurrency",[]).then(()=>{t.getHabit(ae,[...m.currencySymbols]).then(a=>{n(a),e&&e(a)})})},[]),{userHabitCurrency:r,mark:a=>{t.markHabit(ae,a)}}},Ce=()=>{const e=y.useRef([]),[t,r]=y.useState({});return y.useEffect(()=>{e.current.forEach(i=>{i()}),e.current=[]},[t]),i=>{e.current.push(i),r({})}},be=e=>!!m.getCurrencyType(e)&&e.startsWith("_("),Ie=e=>{const{defaultPattern:t,action:r,onChange:n}=e,[i,a]=y.useState(()=>m.getDecimalFromPattern(t||"",2)),s=y.useContext(J),[l,c]=y.useState(()=>m.getCurrencyType(t)||s[0]),d=y.useMemo(()=>s.map(_=>({label:_,value:_})),[]),p=C.useDependency(o.LocaleService).t;r.current=()=>m.setPatternDecimal(`_("${l}"* #,##0${i>0?".0":""}_)`,i);const v=_=>{c(_),n(m.setPatternDecimal(`_("${_}"* #,##0${i>0?".0":""}_)`,i))},g=_=>{const h=_||0;a(h),n(m.setPatternDecimal(`_("${l}"* #,##0${h>0?".0":""}_)`,h))};return u.jsxs("div",{children:[u.jsxs("div",{className:"m-t-16 options",children:[u.jsxs("div",{className:"option",children:[u.jsx("div",{className:"label",children:p("sheet.numfmt.decimalLength")}),u.jsx("div",{className:"m-t-8 w-120",children:u.jsx(P.InputNumber,{value:i,max:20,min:0,onChange:g})})]}),u.jsxs("div",{className:"option",children:[u.jsx("div",{className:"label",children:p("sheet.numfmt.currencyType")}),u.jsx("div",{className:"m-t-8 w-140",children:u.jsx(P.Select,{onChange:v,options:d,value:l})})]})]}),u.jsx("div",{className:"describe m-t-14",children:p("sheet.numfmt.accountingDes")})]})},Te=e=>!!m.getCurrencyType(e)&&!e.startsWith("_("),Ee=e=>{const r=C.useDependency(o.LocaleService).t,n=y.useContext(J),[i,a]=y.useState(()=>m.getCurrencyType(e.defaultPattern)||n[0]),[s,l]=y.useState(()=>m.getDecimalFromPattern(e.defaultPattern||"",2)),[c,d]=y.useState(()=>{var I;const h=m.getCurrencyFormatOptions(i);return((I=h.find(U=>m.isPatternEqualWithoutDecimal(U.value,e.defaultPattern)))==null?void 0:I.value)||h[0].value}),f=y.useMemo(()=>m.getCurrencyFormatOptions(i),[i]),p=y.useMemo(()=>n.map(h=>({label:h,value:h})),[n]);e.action.current=()=>m.setPatternDecimal(c,s);const v=h=>{if(h===void 0)return;a(h);const E=m.getCurrencyFormatOptions(h)[0].value;d(E),e.onChange(m.setPatternDecimal(E,s))},g=h=>{h!==void 0&&(d(h),e.onChange(m.setPatternDecimal(h,s)))},_=h=>{l(h||0),e.onChange(m.setPatternDecimal(c,h||0))};return u.jsxs("div",{children:[u.jsxs("div",{className:"m-t-16 options",children:[u.jsxs("div",{className:"option",children:[u.jsx("div",{className:"label",children:r("sheet.numfmt.decimalLength")}),u.jsx("div",{className:"m-t-8 w-120",children:u.jsx(P.InputNumber,{value:s,max:20,min:0,onChange:_})})]}),u.jsxs("div",{className:"option",children:[u.jsx("div",{className:"label",children:r("sheet.numfmt.currencyType")}),u.jsx("div",{className:"m-t-8 w-140",children:u.jsx(P.Select,{onChange:v,options:p,value:i})})]})]}),u.jsx("div",{className:"m-t-16 label",children:r("sheet.numfmt.negType")}),u.jsx("div",{className:"m-t-8",children:u.jsx(P.SelectList,{onChange:g,options:f,value:c})}),u.jsx("div",{className:"describe m-t-14",children:r("sheet.numfmt.currencyDes")})]})};var D=function(){return D=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++){t=arguments[r];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},D.apply(this,arguments)},Pe=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]]);return r},oe=y.forwardRef(function(e,t){var r=e.icon,n=e.id,i=e.className,a=e.extend,s=Pe(e,["icon","id","className","extend"]),l="univerjs-icon univerjs-icon-".concat(n," ").concat(i||"").trim(),c=y.useRef("_".concat(Ue()));return se(r,"".concat(n),{defIds:r.defIds,idSuffix:c.current},D({ref:t,className:l},s),a)});function se(e,t,r,n,i){return y.createElement(e.tag,D(D({key:t},Me(e,r,i)),n),(De(e,r).children||[]).map(function(a,s){return se(a,"".concat(t,"-").concat(e.tag,"-").concat(s),r,void 0,i)}))}function Me(e,t,r){var n=D({},e.attrs);r!=null&&r.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=r.colorChannel1),e.tag==="mask"&&n.id&&(n.id=n.id+t.idSuffix),Object.entries(n).forEach(function(a){var s=a[0],l=a[1];s==="mask"&&typeof l=="string"&&(n[s]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))});var i=t.defIds;return!i||i.length===0||(e.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(function(a){var s=a[0],l=a[1];typeof l=="string"&&(n[s]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function De(e,t){var r,n=t.defIds;return!n||n.length===0?e:e.tag==="defs"&&(!((r=e.children)===null||r===void 0)&&r.length)?D(D({},e),{children:e.children.map(function(i){return typeof i.attrs.id=="string"&&n&&n.indexOf(i.attrs.id)>-1?D(D({},i),{attrs:D(D({},i.attrs),{id:i.attrs.id+t.idSuffix})}):i})}):e}function Ue(){return Math.random().toString(36).substring(2,8)}oe.displayName="UniverIcon";var Oe={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ce=y.forwardRef(function(e,t){return y.createElement(oe,Object.assign({},e,{id:"check-mark-single",ref:t,icon:Oe}))});ce.displayName="CheckMarkSingle";const L={customFormatTitle:"univer-custom-format-title",customFormatInput:"univer-custom-format-input",customFormatHistoryList:"univer-custom-format-history-list",customFormatHistoryListItem:"univer-custom-format-history-list-item",customFormatHistoryListItemIconWrap:"univer-custom-format-history-list-item-icon-wrap",customFormatDes:"univer-custom-format-des"},Q="customFormat",ee="numfmt_custom_pattern";function Ne(e){const{defaultPattern:t,action:r,onChange:n}=e,i=C.useDependency(x),a=C.useDependency(o.ILocalStorageService),s=C.useDependency(o.LocaleService),[l,c]=y.useState(t);r.current=()=>(i.markHabit(Q,l),a.getItem(ee).then((g=[])=>{const _=[...new Set([l,...g||[]])].splice(0,10).filter(h=>!!h);a.setItem(ee,_)}),l);const[d,f]=y.useState([]);y.useEffect(()=>{a.getItem(ee).then(g=>{const _=[...m.CURRENCYFORMAT.map(h=>h.suffix("$")),...m.DATEFMTLISG.map(h=>h.suffix),...m.NUMBERFORMAT.map(h=>h.suffix)];_.push(...g||[]),i.addHabit(Q,[]).finally(()=>{i.getHabit(Q,_).then(h=>{f([...new Set(h)])})})})},[]);const p=g=>{c(g),n(g)},v=()=>{n(l)};return u.jsxs("div",{className:L.customFormat,children:[u.jsx("div",{className:L.customFormatTitle,children:s.t("sheet.numfmt.customFormat")}),u.jsx(P.Input,{placeholder:s.t("sheet.numfmt.customFormat"),onBlur:v,value:l,onChange:c,className:L.customFormatInput}),u.jsx("div",{className:L.customFormatHistoryList,children:d.map(g=>u.jsxs("div",{onClick:()=>p(g),className:L.customFormatHistoryListItem,children:[u.jsx("div",{className:L.customFormatHistoryListItemIconWrap,children:l===g&&u.jsx(ce,{})}),u.jsx("div",{children:g})]},g))}),u.jsx("div",{className:L.customFormatDes,children:s.t("sheet.numfmt.customFormatDes")})]})}const we=e=>{const t=o.numfmt.getInfo(e);return m.getDateFormatOptions().map(r=>r.value).includes(e)||["date","datetime","time"].includes(t.type)},ke=e=>{const t=y.useMemo(m.getDateFormatOptions,[]),n=C.useDependency(o.LocaleService).t,[i,a]=y.useState(()=>{if(e.defaultPattern){const l=t.find(c=>c.value===e.defaultPattern);if(l)return l.value}return t[0].value});e.action.current=()=>i;const s=l=>{l!==void 0&&(a(l),e.onChange(l))};return u.jsxs("div",{children:[u.jsx("div",{className:"m-t-16 label",children:n("sheet.numfmt.dateType")}),u.jsx("div",{className:"m-t-8",children:u.jsx(P.SelectList,{value:i,options:t,onChange:s})}),u.jsx("div",{className:"describe m-t-14",children:n("sheet.numfmt.dateDes")})]})},Fe=e=>!e,Le=e=>{const r=C.useDependency(o.LocaleService).t;return e.action.current=()=>"",u.jsx("div",{children:u.jsx("div",{className:"describe m-t-14",children:r("sheet.numfmt.generalDes")})})},je=e=>m.getNumberFormatOptions().some(t=>m.isPatternEqualWithoutDecimal(t.value,e)),$e=e=>{const t=C.useDependency(o.LocaleService),r=y.useMemo(m.getNumberFormatOptions,[]),[n,i]=y.useState(()=>m.getDecimalFromPattern(e.defaultPattern||"",0)),[a,s]=y.useState(()=>{const p=r.find(v=>m.isPatternEqualWithoutDecimal(v.value,e.defaultPattern||""));return(p==null?void 0:p.value)||r[0].value}),l=y.useMemo(()=>m.setPatternDecimal(a,Number(n||0)),[a,n]),c=y.useMemo(()=>!m.isPatternHasDecimal(a),[a]),d=p=>{i(p||0),e.onChange(m.setPatternDecimal(a,Number(p||0)))},f=p=>{p!==void 0&&(i(m.getDecimalFromPattern(p,0)),s(p),e.onChange(p))};return e.action.current=()=>l,u.jsxs("div",{children:[u.jsx("div",{className:"m-t-16 label",children:t.t("sheet.numfmt.decimalLength")}),u.jsx("div",{className:"m-t-8",children:u.jsx(P.InputNumber,{disabled:c,value:n,max:20,min:0,onChange:d})}),u.jsxs("div",{className:"m-t-16 label",children:[" ",t.t("sheet.numfmt.negType")]}),u.jsx("div",{className:"m-t-8",children:u.jsx(P.SelectList,{onChange:f,options:r,value:a})}),u.jsx("div",{className:"describe m-t-14",children:t.t("sheet.numfmt.thousandthPercentileDes")})]})},He=e=>{const{defaultValue:t,defaultPattern:r,row:n,col:i}=e.value,a=C.useDependency(o.LocaleService),s=y.useRef(()=>""),l=a.t,c=Ce(),d=y.useMemo(()=>[{label:"sheet.numfmt.general",component:Le},{label:"sheet.numfmt.accounting",component:Ie},{label:"sheet.numfmt.currency",component:Ee},{label:"sheet.numfmt.date",component:ke},{label:"sheet.numfmt.thousandthPercentile",component:$e},{label:"sheet.numfmt.customFormat",component:Ne}].map(T=>({...T,label:l(T.label)})),[]),[f,p]=y.useState(I),[v,g]=y.useState(()=>`${n}_${i}`),{mark:_,userHabitCurrency:h}=_e(()=>g(`${n}_${i}_userCurrency'`)),E=y.useMemo(()=>{var T;return(T=d.find($=>$.label===f))==null?void 0:T.component},[f]);function I(){return[Fe,be,Te,we,je].reduce(($,st,ct)=>$||(st(r)?d[ct].label:""),"")||d[0].label}const U=d.map(T=>({label:T.label,value:T.label})),w=T=>{p(T),c(()=>e.onChange({type:"change",value:s.current()||""}))},k=T=>{e.onChange({type:"change",value:T})},ne=()=>{const T=s.current()||"",$=m.getCurrencyType(T);$&&_($),e.onChange({type:"confirm",value:T})},W=()=>{e.onChange({type:"cancel",value:""})},re={onChange:k,defaultValue:t,defaultPattern:r,action:s};return y.useEffect(()=>{p(I()),g(`${n}_${i}`)},[n,i]),u.jsxs("div",{className:"numfmt-panel p-b-20",children:[u.jsxs("div",{children:[u.jsx("div",{className:"label m-t-14",children:l("sheet.numfmt.numfmtType")}),u.jsx("div",{className:"m-t-8",children:u.jsx(P.Select,{onChange:w,options:U,value:f,style:{width:"100%"}})}),u.jsx("div",{children:E&&u.jsx(J.Provider,{value:h,children:y.createElement(E,{...re,key:v})})})]}),u.jsxs("div",{className:"btn-list m-t-14 m-b-20",children:[u.jsx(P.Button,{size:"small",onClick:W,className:"m-r-12",children:l("sheet.numfmt.cancel")}),u.jsx(P.Button,{type:"primary",size:"small",onClick:ne,children:l("sheet.numfmt.confirm")})]})]})};var xe=Object.getOwnPropertyDescriptor,Ae=(e,t,r,n)=>{for(var i=n>1?void 0:n?xe(t,r):t,a=e.length-1,s;a>=0;a--)(s=e[a])&&(i=s(i)||i);return i},O=(e,t)=>(r,n)=>t(r,n,e);const le="SHEET_NUMFMT_PANEL";let A=class extends o.Disposable{constructor(t,r,n,i,a,s,l,c,d,f,p){super();Z(this,"_previewPattern","");Z(this,"_sidebarDisposable",null);this._sheetInterceptorService=t,this._themeService=r,this._univerInstanceService=n,this._commandService=i,this._selectionManagerService=a,this._renderManagerService=s,this._numfmtService=l,this._componentManager=c,this._sidebarService=d,this._localeService=f,this._sheetsNumfmtCellContentController=p,this._initRealTimeRenderingInterceptor(),this._initPanel(),this._initCommands(),this._initCloseListener(),this._commandExecutedListener(),this._initNumfmtLocalChange()}_initNumfmtLocalChange(){this.disposeWithMe(N.merge(this._sheetsNumfmtCellContentController.local$,this._localeService.currentLocale$).subscribe(()=>{this._forceUpdate()}))}openPanel(){var E;const t=this._sidebarService,r=this._selectionManagerService,n=this._commandService,i=this._univerInstanceService,a=this._numfmtService,s=this._localeService,c=(((E=r.getCurrentSelections())==null?void 0:E.map(I=>I.range))||[])[0];if(!c)return!1;const d=i.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET),f=d.getActiveSheet();if(!f)return!1;const p=f.getCellRaw(c.startRow,c.startColumn),v=a.getValue(d.getUnitId(),f.getSheetId(),c.startRow,c.startColumn);let g="";v&&(g=v.pattern);const _=(p==null?void 0:p.t)===o.CellValueType.NUMBER?p.v:12345678,h={onChange:I=>{var U;if(I.type==="change")this._previewPattern=I.value,this._forceUpdate();else if(I.type==="confirm"){const w=((U=r.getCurrentSelections())==null?void 0:U.map(W=>W.range))||[],k={values:[]},ne=m.getPatternType(I.value);w.forEach(W=>{o.Range.foreach(W,(re,T)=>{k.values.push({row:re,col:T,pattern:I.value,type:ne})})}),n.executeCommand(m.SetNumfmtCommand.id,k),t.close()}else I.type==="cancel"&&t.close()},value:{defaultPattern:g,defaultValue:_,row:c.startRow,col:c.startColumn}};return this._sidebarDisposable=t.open({header:{title:s.t("sheet.numfmt.title")},children:{label:le,...h},onClose:()=>{this._forceUpdate(),n.executeCommand(X.id)}}),!0}_forceUpdate(t){var n;const r=this._renderManagerService.getRenderById(t!=null?t:this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET).getUnitId());r==null||r.with(M.SheetSkeletonManagerService).reCalculate(),(n=r==null?void 0:r.mainComponent)==null||n.makeDirty()}_initCommands(){[H,X].forEach(t=>{this.disposeWithMe(this._commandService.registerCommand(t))})}_initPanel(){this._componentManager.register(le,He)}_initRealTimeRenderingInterceptor(){const t=new N.Observable(n=>{this._commandService.onCommandExecuted(i=>{i.id===H.id&&n.next(!0),i.id===X.id&&n.next(!1)})}),r=N.combineLatest([t,this._selectionManagerService.selectionMoveEnd$.pipe(B.map(n=>n?n.map(i=>i.range):[]))]);this.disposeWithMe(o.toDisposable(r.pipe(B.switchMap(([n,i])=>new N.Observable(a=>{const s=new o.DisposableCollection;return n&&i.length&&a.next({selectionRanges:i,disposableCollection:s}),()=>{s.dispose()}})),B.tap(()=>{this._previewPattern=null})).subscribe(({disposableCollection:n,selectionRanges:i})=>{var s,l;const a=this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);this.openPanel(),n.add(this._sheetInterceptorService.intercept(S.INTERCEPTOR_POINT.CELL_CONTENT,{priority:99,effect:o.InterceptorEffectEnum.Value|o.InterceptorEffectEnum.Style,handler:(c,d,f)=>{const{row:p,col:v}=d,g=f(c)||{};if(i.find(_=>_.startColumn<=v&&_.endColumn>=v&&_.startRow<=p&&_.endRow>=p)){const _=d.worksheet.getCellRaw(p,v),h=_==null?void 0:_.v,E=_==null?void 0:_.t;if(h==null||E!==o.CellValueType.NUMBER||this._previewPattern===null)return g;const I=m.getPatternPreviewIgnoreGeneral(this._previewPattern,h,this._sheetsNumfmtCellContentController.local);if(I.color){const w=this._themeService.getCurrentTheme()[`${I.color}500`];return{...g,v:I.result,t:o.CellValueType.STRING,s:{cl:{rgb:w}}}}return{...g,v:I.result,t:o.CellValueType.STRING}}return g}})),(l=(s=this._renderManagerService.getRenderById(a.getUnitId()))==null?void 0:s.mainComponent)==null||l.makeDirty()})))}_commandExecutedListener(){const t=[S.RemoveNumfmtMutation.id,S.SetNumfmtMutation.id];this.disposeWithMe(new N.Observable(r=>{const n=this._commandService.onCommandExecuted(i=>{if(t.includes(i.id)){const a=i.params;r.next(a.unitId)}});return()=>n.dispose()}).pipe(B.debounceTime(16)).subscribe(r=>this._forceUpdate(r)))}_initCloseListener(){this._univerInstanceService.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_SHEET).subscribe(t=>{var r;t||((r=this._sidebarDisposable)==null||r.dispose(),this._sidebarDisposable=null)})}};A=Ae([O(0,o.Inject(S.SheetInterceptorService)),O(1,o.Inject(o.ThemeService)),O(2,o.IUniverInstanceService),O(3,o.ICommandService),O(4,o.Inject(S.SheetsSelectionsService)),O(5,F.IRenderManagerService),O(6,S.INumfmtService),O(7,o.Inject(C.ComponentManager)),O(8,C.ISidebarService),O(9,o.Inject(o.LocaleService)),O(10,o.Inject(m.SheetsNumfmtCellContentController))],A);var Re=Object.getOwnPropertyDescriptor,We=(e,t,r,n)=>{for(var i=n>1?void 0:n?Re(t,r):t,a=e.length-1,s;a>=0;a--)(s=e[a])&&(i=s(i)||i);return i},R=(e,t)=>(r,n)=>t(r,n,e);const Ve=()=>{let e=[];return{add:(i,a,s,l,c)=>e.push({unitId:i,subUnitId:a,row:s,col:l,value:c}),getEffects:()=>e,clean:()=>{e=[]}}};let q=class extends o.Disposable{constructor(t,r,n,i,a){super();Z(this,"_collectEffectMutation",Ve());this._sheetInterceptorService=t,this._numfmtService=r,this._univerInstanceService=n,this._injector=i,this._editorBridgeService=a,this._initInterceptorEditorStart(),this._initInterceptorEditorEnd(),this._initInterceptorCommands()}_initInterceptorEditorStart(){this._editorBridgeService&&this.disposeWithMe(o.toDisposable(this._sheetInterceptorService.writeCellInterceptor.intercept(S.BEFORE_CELL_EDIT,{handler:(t,r,n)=>{const i=r.row,a=r.col,s=this._numfmtService.getValue(r.unitId,r.subUnitId,i,a);if(s)switch(m.getPatternType(s.pattern)){case"scientific":case"currency":case"grouped":case"number":{const c=r.worksheet.getCellRaw(i,a);return n&&n(c)}case"percent":case"date":case"time":case"datetime":default:return n&&n(t)}return n(t)}})))}_initInterceptorEditorEnd(){this.disposeWithMe(o.toDisposable(this._sheetInterceptorService.writeCellInterceptor.intercept(S.AFTER_CELL_EDIT,{handler:(t,r,n)=>{var f,p,v,g;this._collectEffectMutation.clean();const i=this._numfmtService.getValue(r.unitId,r.subUnitId,r.row,r.col),a=(f=i&&m.getPatternType(i.pattern))!=null?f:"",s=()=>{i&&this._collectEffectMutation.add(r.unitId,r.subUnitId,r.row,r.col,null)};if(!(t!=null&&t.v)&&!(t!=null&&t.p)||V.isTextFormat(i==null?void 0:i.pattern)||t.t===o.CellValueType.FORCE_STRING)return n(t);const l=(p=t.p)==null?void 0:p.body,c=(g=(v=t==null?void 0:t.p)==null?void 0:v.body)!=null&&g.dataStream?t.p.body.dataStream.replace(/\r\n$/,""):String(t.v),d=o.numfmt.parseDate(c)||o.numfmt.parseTime(c)||o.numfmt.parseNumber(c);if(l)if(qe(l)){const{dataStream:_}=l,h=_.replace(/\r\n$/,""),E=Number(h);if(Number.isNaN(E)&&!d)return n(t)}else return n(t);if(d){d.z&&this._collectEffectMutation.add(r.unitId,r.subUnitId,r.row,r.col,{pattern:d.z});const _=Number(d.v);return n({...t,p:void 0,v:_,t:o.CellValueType.NUMBER})}else(["date","time","datetime","percent"].includes(a)||!Be(c))&&s();return n(t)}})))}_initInterceptorCommands(){const t=this;this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations(r){var n;switch(r.id){case S.SetRangeValuesCommand.id:{const i=t._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET),a=i.getUnitId(),s=(n=i.getActiveSheet())==null?void 0:n.getSheetId();if(!s)return{redos:[],undos:[]};const l=t._collectEffectMutation.getEffects();if(t._collectEffectMutation.clean(),!l.length)return{redos:[],undos:[]};const c=l.filter(v=>{var g;return!!((g=v.value)!=null&&g.pattern)}).map(v=>({row:v.row,col:v.col,pattern:v.value.pattern})),d=l.filter(v=>{var g;return!((g=v.value)!=null&&g.pattern)}).map(v=>({startRow:v.row,endColumn:v.col,startColumn:v.col,endRow:v.row})),f=[],p=[];if(c.length){const v={id:S.SetNumfmtMutation.id,params:S.transformCellsToRange(a,s,c)};f.push(v),p.push(...S.factorySetNumfmtUndoMutation(t._injector,v.params))}if(d.length){const v={id:S.RemoveNumfmtMutation.id,params:{unitId:a,subUnitId:s,ranges:d}};f.push(v),p.push(...S.factoryRemoveNumfmtUndoMutation(t._injector,v.params))}return{redos:f,undos:p.reverse()}}}return{redos:[],undos:[]}}}))}};q=We([R(0,o.Inject(S.SheetInterceptorService)),R(1,o.Inject(S.INumfmtService)),R(2,o.Inject(o.IUniverInstanceService)),R(3,o.Inject(o.Injector)),R(4,o.Optional(M.IEditorBridgeService))],q);function Be(e){return/^-?\d+(\.\d+)?$/.test(e)}function qe(e){const{textRuns:t=[],paragraphs:r=[],customRanges:n,customBlocks:i=[]}=e,a=["va"];return!(t.some(s=>!!(s.ts&&Object.keys(s.ts).some(c=>a.includes(c))))||r.some(s=>s.bullet)||r.length>=2||n!=null&&n.length||i.length>0)}const G=[{label:"sheet.numfmt.general",pattern:null},{label:"sheet.numfmt.text",pattern:V.DEFAULT_TEXT_FORMAT_EXCEL},"|",{label:"sheet.numfmt.number",pattern:"0"},"|",{label:"sheet.numfmt.accounting",pattern:'"¥" #,##0.00_);[Red]("¥"#,##0.00)'},{label:"sheet.numfmt.financialValue",pattern:"#,##0.00;[Red]#,##0.00"},{label:"sheet.numfmt.currency",pattern:'"¥"#,##0.00_);[Red]("¥"#,##0.00)'},{label:"sheet.numfmt.roundingCurrency",pattern:'"¥"#,##0;[Red]"¥"#,##0'},"|",{label:"sheet.numfmt.date",pattern:"yyyy-mm-dd;@"},{label:"sheet.numfmt.time",pattern:'am/pm h":"mm":"ss'},{label:"sheet.numfmt.dateTime",pattern:"yyyy-m-d am/pm h:mm"},{label:"sheet.numfmt.timeDuration",pattern:"h:mm:ss"},"|",{label:"sheet.numfmt.percent",pattern:"0.00%"},"|",{label:"sheet.numfmt.moreFmt",pattern:""}],Ge=e=>({icon:new N.Observable(t=>{const r=e.get(m.MenuCurrencyService);function n(a){return{[m.countryCurrencyMap.US]:"DollarSingle",[m.countryCurrencyMap.RU]:"RoubleSingle",[m.countryCurrencyMap.CN]:"RmbSingle",[m.countryCurrencyMap.AT]:"EuroSingle"}[a]||"DollarSingle"}const i=m.countryCurrencyMap[r.getCurrencySymbol()]||"$";return t.next(n(i)),r.currencySymbol$.subscribe(a=>{const s=m.countryCurrencyMap[a]||"$";t.next(n(s))})}),id:m.SetCurrencyCommand.id,title:"sheet.numfmt.currency",tooltip:"sheet.numfmt.currency",type:C.MenuItemType.BUTTON,hidden$:C.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:M.getCurrentRangeDisable$(e,{workbookTypes:[S.WorkbookEditablePermission],worksheetTypes:[S.WorksheetEditPermission,S.WorksheetSetCellStylePermission],rangeTypes:[S.RangeProtectionPermissionEditPoint]})}),Ke=e=>({icon:"AddDigitsSingle",id:m.AddDecimalCommand.id,title:"sheet.numfmt.addDecimal",tooltip:"sheet.numfmt.addDecimal",type:C.MenuItemType.BUTTON,hidden$:C.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:M.getCurrentRangeDisable$(e,{workbookTypes:[S.WorkbookEditablePermission],worksheetTypes:[S.WorksheetEditPermission,S.WorksheetSetCellStylePermission],rangeTypes:[S.RangeProtectionPermissionEditPoint]})}),Ze=e=>({icon:"ReduceDigitsSingle",id:m.SubtractDecimalCommand.id,title:"sheet.numfmt.subtractDecimal",tooltip:"sheet.numfmt.subtractDecimal",type:C.MenuItemType.BUTTON,hidden$:C.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:M.getCurrentRangeDisable$(e,{workbookTypes:[S.WorkbookEditablePermission],worksheetTypes:[S.WorksheetEditPermission,S.WorksheetSetCellStylePermission],rangeTypes:[S.RangeProtectionPermissionEditPoint]})}),ze=e=>({icon:"PercentSingle",id:m.SetPercentCommand.id,title:"sheet.numfmt.percent",tooltip:"sheet.numfmt.percent",type:C.MenuItemType.BUTTON,hidden$:C.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:M.getCurrentRangeDisable$(e,{workbookTypes:[S.WorkbookEditablePermission],worksheetTypes:[S.WorksheetEditPermission,S.WorksheetSetCellStylePermission],rangeTypes:[S.RangeProtectionPermissionEditPoint]})}),Ye=e=>{const t=e.get(o.IUniverInstanceService),r=e.get(o.ICommandService),n=e.get(o.LocaleService),i=e.get(S.SheetsSelectionsService),a=[S.RemoveNumfmtMutation.id,S.SetNumfmtMutation.id],s=M.deriveStateFromActiveSheet$(t,"",({workbook:l,worksheet:c})=>new N.Observable(d=>N.merge(i.selectionMoveEnd$,o.fromCallback(r.onCommandExecuted.bind(r)).pipe(N.filter(([f])=>a.includes(f.id)))).subscribe(()=>{var p,v;const f=i.getCurrentSelections();if(f&&f[0]){const g=f[0].range,_=g.startRow,h=g.startColumn,E=(v=l.getStyles().get((p=c.getCell(_,h))==null?void 0:p.s))==null?void 0:v.n,I=E==null?void 0:E.pattern;let U=n.t("sheet.numfmt.general");if(V.isDefaultFormat(I)){d.next(U);return}if(I){const w=G.filter(k=>typeof k=="object"&&k.pattern).find(k=>m.isPatternEqualWithoutDecimal(I,k.pattern));w&&typeof w=="object"&&w.pattern?U=n.t(w.label):U=n.t("sheet.numfmt.moreFmt")}d.next(U)}})));return{label:ue,id:H.id,tooltip:"sheet.numfmt.title",type:C.MenuItemType.SELECTOR,slot:!0,selections:[{label:{name:me,hoverable:!1,selectable:!1}}],value$:s,hidden$:C.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:M.getCurrentRangeDisable$(e,{workbookTypes:[S.WorkbookEditablePermission],worksheetTypes:[S.WorksheetSetCellStylePermission,S.WorksheetEditPermission],rangeTypes:[S.RangeProtectionPermissionEditPoint]})}},ue="sheet.numfmt.moreNumfmtType",me="sheet.numfmt.moreNumfmtType.options",Xe=e=>{const{value:t}=e,r=C.useDependency(o.LocaleService),n=t!=null?t:r.t("sheet.numfmt.general");return u.jsx("span",{className:"univer-text-sm",children:n})},Je=()=>{const e=C.useDependency(o.ICommandService),t=C.useDependency(o.LocaleService),r=C.useDependency(C.ILayoutService),n=C.useDependency(m.SheetsNumfmtCellContentController),i=C.useDependency(S.SheetsSelectionsService),a=c=>{const d=i.getCurrentLastSelection();if(!d)return;const f=d.range,p=[];o.Range.foreach(f,(v,g)=>{c?p.push({row:v,col:g,pattern:c,type:m.getPatternType(c)}):p.push({row:v,col:g})}),e.executeCommand(m.SetNumfmtCommand.id,{values:p}),r.focus()},s=c=>{if(c===0)a(null);else if(c===G.length-1)e.executeCommand(H.id),r.focus();else{const d=G[c];d.pattern&&a(d.pattern)}},l=1220;return u.jsx("div",{className:"univer-grid univer-gap-1 univer-p-1.5",children:G.map((c,d)=>c==="|"?u.jsx(P.Separator,{},d):u.jsxs("div",{className:`
|
|
1
|
+
(function(b,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@univerjs/core"),require("@univerjs/engine-render"),require("@univerjs/sheets-numfmt"),require("@univerjs/sheets-ui"),require("@univerjs/ui"),require("@univerjs/engine-formula"),require("@univerjs/engine-numfmt"),require("@univerjs/sheets"),require("rxjs"),require("rxjs/operators"),require("react/jsx-runtime"),require("react"),require("@univerjs/design")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/engine-render","@univerjs/sheets-numfmt","@univerjs/sheets-ui","@univerjs/ui","@univerjs/engine-formula","@univerjs/engine-numfmt","@univerjs/sheets","rxjs","rxjs/operators","react/jsx-runtime","react","@univerjs/design"],o):(b=typeof globalThis<"u"?globalThis:b||self,o(b.UniverSheetsNumfmtUi={},b.UniverCore,b.UniverEngineRender,b.UniverSheetsNumfmt,b.UniverSheetsUi,b.UniverUi,b.UniverEngineFormula,b.UniverEngineNumfmt,b.UniverSheets,b.rxjs,b.rxjs.operators,b.React,b.React,b.UniverDesign))})(this,function(b,o,k,m,M,C,ve,V,S,O,B,l,y,P){"use strict";var lt=Object.defineProperty;var ut=(b,o,k)=>o in b?lt(b,o,{enumerable:!0,configurable:!0,writable:!0,value:k}):b[o]=k;var Y=(b,o,k)=>ut(b,typeof o!="symbol"?o+"":o,k);const ie={};var fe=Object.getOwnPropertyDescriptor,he=(e,n,r,t)=>{for(var i=t>1?void 0:t?fe(n,r):n,a=e.length-1,s;a>=0;a--)(s=e[a])&&(i=s(i)||i);return i},L=(e,n)=>(r,t)=>n(r,t,e);const Z="SHEET_NUMFMT_ALERT";let z=class extends o.Disposable{constructor(e,n,r,t,i,a,s,u){super(),this._context=e,this._hoverManagerService=n,this._cellAlertManagerService=r,this._localeService=t,this._formulaDataModel=i,this._zenZoneService=a,this._numfmtService=s,this._configService=u,this._init()}_init(){this._initCellAlertPopup(),this._initZenService()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(O.debounceTime(100)).subscribe(e=>{var n,r;if(e){const t=e.location,i=this._context.unit,a=i.getActiveSheet();if(!a)return;const s=t.unitId,u=t.subUnitId;let c;const p=a.getCell(t.row,t.col);if(p!=null&&p.s){const v=i.getStyles().get(p.s);v!=null&&v.n&&(c=v.n)}if(c||(c=this._numfmtService.getValue(s,u,t.row,t.col)),!c){this._hideAlert();return}if(V.isTextFormat(c.pattern)&&(p!=null&&p.v)&&o.isRealNum(p.v)){if((n=this._configService.getConfig(m.SHEETS_NUMFMT_PLUGIN_CONFIG_KEY))!=null&&n.disableTextFormatAlert)return;const v=this._cellAlertManagerService.currentAlert.get(Z),d=(r=v==null?void 0:v.alert)==null?void 0:r.location;if(d&&d.row===t.row&&d.col===t.col&&d.subUnitId===t.subUnitId&&d.unitId===t.unitId)return;this._cellAlertManagerService.showAlert({type:M.CellAlertType.WARNING,title:this._localeService.t("info.error"),message:this._localeService.t("info.forceStringInfo"),location:t,width:200,height:74,key:Z});return}}this._hideAlert()}))}_initZenService(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{e&&this._hideAlert()}))}_hideAlert(){this._cellAlertManagerService.removeAlert(Z)}};z=he([L(1,o.Inject(M.HoverManagerService)),L(2,o.Inject(M.CellAlertManagerService)),L(3,o.Inject(o.LocaleService)),L(4,o.Inject(ve.FormulaDataModel)),L(5,C.IZenZoneService),L(6,o.Inject(S.INumfmtService)),L(7,o.IConfigService)],z);const X={id:"sheet.operation.close.numfmt.panel",type:o.CommandType.OPERATION,handler:()=>!0},H={id:"sheet.operation.open.numfmt.panel",type:o.CommandType.OPERATION,handler:e=>(e.get(A).openPanel(),!0)};var Se=Object.getOwnPropertyDescriptor,ge=(e,n,r,t)=>{for(var i=t>1?void 0:t?Se(n,r):n,a=e.length-1,s;a>=0;a--)(s=e[a])&&(i=s(i)||i);return i},ye=(e,n)=>(r,t)=>n(r,t,e);const J=y.createContext([]);let x=class{constructor(e){this._localStorageService=e}_getKey(e){return`userHabitController_${e}`}async addHabit(e,n){const r=this._getKey(e);return this._localStorageService.getItem(r).then(t=>{t||this._localStorageService.setItem(r,n)})}markHabit(e,n){const r=this._getKey(e);this._localStorageService.getItem(r).then(t=>{if(t){const i=t.findIndex(a=>a===n);i>-1&&t.splice(i,1),t.unshift(n),this._localStorageService.setItem(r,t)}})}async getHabit(e,n){const r=this._getKey(e),t=await this._localStorageService.getItem(r);if(n&&t){const i=t.map((a,s,u)=>{const c=u.length;return{value:a,priority:c-s}});return n.sort((a,s)=>{var p,v;const u=((p=i.find(d=>d.value===a))==null?void 0:p.priority)||-1;return(((v=i.find(d=>d.value===s))==null?void 0:v.priority)||-1)-u})}return t||[]}deleteHabit(e){this._localStorageService.removeItem(e)}};x=ge([ye(0,o.Inject(o.ILocalStorageService))],x);const ae="numfmtCurrency",_e=e=>{const n=C.useDependency(x),[r,t]=y.useState(m.currencySymbols);return y.useEffect(()=>{n.addHabit("numfmtCurrency",[]).then(()=>{n.getHabit(ae,[...m.currencySymbols]).then(a=>{t(a),e&&e(a)})})},[]),{userHabitCurrency:r,mark:a=>{n.markHabit(ae,a)}}},Ce=()=>{const e=y.useRef([]),[n,r]=y.useState({});return y.useEffect(()=>{e.current.forEach(i=>{i()}),e.current=[]},[n]),i=>{e.current.push(i),r({})}},be=e=>!!m.getCurrencyType(e)&&e.startsWith("_("),Ie=e=>{const{defaultPattern:n,action:r,onChange:t}=e,[i,a]=y.useState(()=>m.getDecimalFromPattern(n||"",2)),s=y.useContext(J),[u,c]=y.useState(()=>m.getCurrencyType(n)||s[0]),p=y.useMemo(()=>s.map(_=>({label:_,value:_})),[]),d=C.useDependency(o.LocaleService).t;r.current=()=>m.setPatternDecimal(`_("${u}"* #,##0${i>0?".0":""}_)`,i);const f=_=>{c(_),t(m.setPatternDecimal(`_("${_}"* #,##0${i>0?".0":""}_)`,i))},g=_=>{const h=_||0;a(h),t(m.setPatternDecimal(`_("${u}"* #,##0${h>0?".0":""}_)`,h))};return l.jsxs("div",{children:[l.jsxs("div",{className:"m-t-16 options",children:[l.jsxs("div",{className:"option",children:[l.jsx("div",{className:"label",children:d("sheet.numfmt.decimalLength")}),l.jsx("div",{className:"m-t-8 w-120",children:l.jsx(P.InputNumber,{value:i,max:20,min:0,onChange:g})})]}),l.jsxs("div",{className:"option",children:[l.jsx("div",{className:"label",children:d("sheet.numfmt.currencyType")}),l.jsx("div",{className:"m-t-8 w-140",children:l.jsx(P.Select,{onChange:f,options:p,value:u})})]})]}),l.jsx("div",{className:"describe m-t-14",children:d("sheet.numfmt.accountingDes")})]})},Te=e=>!!m.getCurrencyType(e)&&!e.startsWith("_("),Ee=e=>{const r=C.useDependency(o.LocaleService).t,t=y.useContext(J),[i,a]=y.useState(()=>m.getCurrencyType(e.defaultPattern)||t[0]),[s,u]=y.useState(()=>m.getDecimalFromPattern(e.defaultPattern||"",2)),[c,p]=y.useState(()=>{var I;const h=m.getCurrencyFormatOptions(i);return((I=h.find(N=>m.isPatternEqualWithoutDecimal(N.value,e.defaultPattern)))==null?void 0:I.value)||h[0].value}),v=y.useMemo(()=>m.getCurrencyFormatOptions(i),[i]),d=y.useMemo(()=>t.map(h=>({label:h,value:h})),[t]);e.action.current=()=>m.setPatternDecimal(c,s);const f=h=>{if(h===void 0)return;a(h);const E=m.getCurrencyFormatOptions(h)[0].value;p(E),e.onChange(m.setPatternDecimal(E,s))},g=h=>{h!==void 0&&(p(h),e.onChange(m.setPatternDecimal(h,s)))},_=h=>{u(h||0),e.onChange(m.setPatternDecimal(c,h||0))};return l.jsxs("div",{children:[l.jsxs("div",{className:"m-t-16 options",children:[l.jsxs("div",{className:"option",children:[l.jsx("div",{className:"label",children:r("sheet.numfmt.decimalLength")}),l.jsx("div",{className:"m-t-8 w-120",children:l.jsx(P.InputNumber,{value:s,max:20,min:0,onChange:_})})]}),l.jsxs("div",{className:"option",children:[l.jsx("div",{className:"label",children:r("sheet.numfmt.currencyType")}),l.jsx("div",{className:"m-t-8 w-140",children:l.jsx(P.Select,{onChange:f,options:d,value:i})})]})]}),l.jsx("div",{className:"m-t-16 label",children:r("sheet.numfmt.negType")}),l.jsx("div",{className:"m-t-8",children:l.jsx(P.SelectList,{onChange:g,options:v,value:c})}),l.jsx("div",{className:"describe m-t-14",children:r("sheet.numfmt.currencyDes")})]})};var D=function(){return D=Object.assign||function(e){for(var n,r=1,t=arguments.length;r<t;r++){n=arguments[r];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},D.apply(this,arguments)},Pe=function(e,n){var r={};for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&n.indexOf(t)<0&&(r[t]=e[t]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,t=Object.getOwnPropertySymbols(e);i<t.length;i++)n.indexOf(t[i])<0&&Object.prototype.propertyIsEnumerable.call(e,t[i])&&(r[t[i]]=e[t[i]]);return r},oe=y.forwardRef(function(e,n){var r=e.icon,t=e.id,i=e.className,a=e.extend,s=Pe(e,["icon","id","className","extend"]),u="univerjs-icon univerjs-icon-".concat(t," ").concat(i||"").trim(),c=y.useRef("_".concat(Ne()));return se(r,"".concat(t),{defIds:r.defIds,idSuffix:c.current},D({ref:n,className:u},s),a)});function se(e,n,r,t,i){return y.createElement(e.tag,D(D({key:n},Me(e,r,i)),t),(De(e,r).children||[]).map(function(a,s){return se(a,"".concat(n,"-").concat(e.tag,"-").concat(s),r,void 0,i)}))}function Me(e,n,r){var t=D({},e.attrs);r!=null&&r.colorChannel1&&t.fill==="colorChannel1"&&(t.fill=r.colorChannel1),e.tag==="mask"&&t.id&&(t.id=t.id+n.idSuffix),Object.entries(t).forEach(function(a){var s=a[0],u=a[1];s==="mask"&&typeof u=="string"&&(t[s]=u.replace(/url\(#(.*)\)/,"url(#$1".concat(n.idSuffix,")")))});var i=n.defIds;return!i||i.length===0||(e.tag==="use"&&t["xlink:href"]&&(t["xlink:href"]=t["xlink:href"]+n.idSuffix),Object.entries(t).forEach(function(a){var s=a[0],u=a[1];typeof u=="string"&&(t[s]=u.replace(/url\(#(.*)\)/,"url(#$1".concat(n.idSuffix,")")))})),t}function De(e,n){var r,t=n.defIds;return!t||t.length===0?e:e.tag==="defs"&&(!((r=e.children)===null||r===void 0)&&r.length)?D(D({},e),{children:e.children.map(function(i){return typeof i.attrs.id=="string"&&t&&t.indexOf(i.attrs.id)>-1?D(D({},i),{attrs:D(D({},i.attrs),{id:i.attrs.id+n.idSuffix})}):i})}):e}function Ne(){return Math.random().toString(36).substring(2,8)}oe.displayName="UniverIcon";var Ue={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ce=y.forwardRef(function(e,n){return y.createElement(oe,Object.assign({},e,{id:"check-mark-single",ref:n,icon:Ue}))});ce.displayName="CheckMarkSingle";const j={customFormatTitle:"univer-custom-format-title",customFormatInput:"univer-custom-format-input",customFormatHistoryList:"univer-custom-format-history-list",customFormatHistoryListItem:"univer-custom-format-history-list-item",customFormatHistoryListItemIconWrap:"univer-custom-format-history-list-item-icon-wrap",customFormatDes:"univer-custom-format-des"},Q="customFormat",ee="numfmt_custom_pattern";function Oe(e){const{defaultPattern:n,action:r,onChange:t}=e,i=C.useDependency(x),a=C.useDependency(o.ILocalStorageService),s=C.useDependency(o.LocaleService),[u,c]=y.useState(n);r.current=()=>(i.markHabit(Q,u),a.getItem(ee).then((g=[])=>{const _=[...new Set([u,...g||[]])].splice(0,10).filter(h=>!!h);a.setItem(ee,_)}),u);const[p,v]=y.useState([]);y.useEffect(()=>{a.getItem(ee).then(g=>{const _=[...m.CURRENCYFORMAT.map(h=>h.suffix("$")),...m.DATEFMTLISG.map(h=>h.suffix),...m.NUMBERFORMAT.map(h=>h.suffix)];_.push(...g||[]),i.addHabit(Q,[]).finally(()=>{i.getHabit(Q,_).then(h=>{v([...new Set(h)])})})})},[]);const d=g=>{c(g),t(g)},f=()=>{t(u)};return l.jsxs("div",{className:j.customFormat,children:[l.jsx("div",{className:j.customFormatTitle,children:s.t("sheet.numfmt.customFormat")}),l.jsx(P.Input,{placeholder:s.t("sheet.numfmt.customFormat"),onBlur:f,value:u,onChange:c,className:j.customFormatInput}),l.jsx("div",{className:j.customFormatHistoryList,children:p.map(g=>l.jsxs("div",{onClick:()=>d(g),className:j.customFormatHistoryListItem,children:[l.jsx("div",{className:j.customFormatHistoryListItemIconWrap,children:u===g&&l.jsx(ce,{})}),l.jsx("div",{children:g})]},g))}),l.jsx("div",{className:j.customFormatDes,children:s.t("sheet.numfmt.customFormatDes")})]})}const we=e=>{const n=o.numfmt.getInfo(e);return m.getDateFormatOptions().map(r=>r.value).includes(e)||["date","datetime","time"].includes(n.type)},Fe=e=>{const n=y.useMemo(m.getDateFormatOptions,[]),t=C.useDependency(o.LocaleService).t,[i,a]=y.useState(()=>{if(e.defaultPattern){const u=n.find(c=>c.value===e.defaultPattern);if(u)return u.value}return n[0].value});e.action.current=()=>i;const s=u=>{u!==void 0&&(a(u),e.onChange(u))};return l.jsxs("div",{children:[l.jsx("div",{className:"m-t-16 label",children:t("sheet.numfmt.dateType")}),l.jsx("div",{className:"m-t-8",children:l.jsx(P.SelectList,{value:i,options:n,onChange:s})}),l.jsx("div",{className:"describe m-t-14",children:t("sheet.numfmt.dateDes")})]})},ke=e=>!e,Le=e=>{const r=C.useDependency(o.LocaleService).t;return e.action.current=()=>"",l.jsx("div",{children:l.jsx("div",{className:"describe m-t-14",children:r("sheet.numfmt.generalDes")})})},je=e=>m.getNumberFormatOptions().some(n=>m.isPatternEqualWithoutDecimal(n.value,e)),$e=e=>{const n=C.useDependency(o.LocaleService),r=y.useMemo(m.getNumberFormatOptions,[]),[t,i]=y.useState(()=>m.getDecimalFromPattern(e.defaultPattern||"",0)),[a,s]=y.useState(()=>{const d=r.find(f=>m.isPatternEqualWithoutDecimal(f.value,e.defaultPattern||""));return(d==null?void 0:d.value)||r[0].value}),u=y.useMemo(()=>m.setPatternDecimal(a,Number(t||0)),[a,t]),c=y.useMemo(()=>!m.isPatternHasDecimal(a),[a]),p=d=>{i(d||0),e.onChange(m.setPatternDecimal(a,Number(d||0)))},v=d=>{d!==void 0&&(i(m.getDecimalFromPattern(d,0)),s(d),e.onChange(d))};return e.action.current=()=>u,l.jsxs("div",{children:[l.jsx("div",{className:"m-t-16 label",children:n.t("sheet.numfmt.decimalLength")}),l.jsx("div",{className:"m-t-8",children:l.jsx(P.InputNumber,{disabled:c,value:t,max:20,min:0,onChange:p})}),l.jsxs("div",{className:"m-t-16 label",children:[" ",n.t("sheet.numfmt.negType")]}),l.jsx("div",{className:"m-t-8",children:l.jsx(P.SelectList,{onChange:v,options:r,value:a})}),l.jsx("div",{className:"describe m-t-14",children:n.t("sheet.numfmt.thousandthPercentileDes")})]})},He=e=>{const{defaultValue:n,defaultPattern:r,row:t,col:i}=e.value,a=C.useDependency(o.LocaleService),s=y.useRef(()=>""),u=a.t,c=Ce(),p=y.useMemo(()=>[{label:"sheet.numfmt.general",component:Le},{label:"sheet.numfmt.accounting",component:Ie},{label:"sheet.numfmt.currency",component:Ee},{label:"sheet.numfmt.date",component:Fe},{label:"sheet.numfmt.thousandthPercentile",component:$e},{label:"sheet.numfmt.customFormat",component:Oe}].map(T=>({...T,label:u(T.label)})),[]),[v,d]=y.useState(I),[f,g]=y.useState(()=>`${t}_${i}`),{mark:_,userHabitCurrency:h}=_e(()=>g(`${t}_${i}_userCurrency'`)),E=y.useMemo(()=>{var T;return(T=p.find($=>$.label===v))==null?void 0:T.component},[v]);function I(){return[ke,be,Te,we,je].reduce(($,st,ct)=>$||(st(r)?p[ct].label:""),"")||p[0].label}const N=p.map(T=>({label:T.label,value:T.label})),w=T=>{d(T),c(()=>e.onChange({type:"change",value:s.current()||""}))},F=T=>{e.onChange({type:"change",value:T})},ne=()=>{const T=s.current()||"",$=m.getCurrencyType(T);$&&_($),e.onChange({type:"confirm",value:T})},R=()=>{e.onChange({type:"cancel",value:""})},re={onChange:F,defaultValue:n,defaultPattern:r,action:s};return y.useEffect(()=>{d(I()),g(`${t}_${i}`)},[t,i]),l.jsxs("div",{className:"numfmt-panel p-b-20",children:[l.jsxs("div",{children:[l.jsx("div",{className:"label m-t-14",children:u("sheet.numfmt.numfmtType")}),l.jsx("div",{className:"m-t-8",children:l.jsx(P.Select,{onChange:w,options:N,value:v,style:{width:"100%"}})}),l.jsx("div",{children:E&&l.jsx(J.Provider,{value:h,children:y.createElement(E,{...re,key:f})})})]}),l.jsxs("div",{className:"btn-list m-t-14 m-b-20",children:[l.jsx(P.Button,{size:"small",onClick:R,className:"m-r-12",children:u("sheet.numfmt.cancel")}),l.jsx(P.Button,{type:"primary",size:"small",onClick:ne,children:u("sheet.numfmt.confirm")})]})]})};var xe=Object.getOwnPropertyDescriptor,Ae=(e,n,r,t)=>{for(var i=t>1?void 0:t?xe(n,r):n,a=e.length-1,s;a>=0;a--)(s=e[a])&&(i=s(i)||i);return i},U=(e,n)=>(r,t)=>n(r,t,e);const le="SHEET_NUMFMT_PANEL";let A=class extends o.Disposable{constructor(n,r,t,i,a,s,u,c,p,v,d){super();Y(this,"_previewPattern","");Y(this,"_sidebarDisposable",null);this._sheetInterceptorService=n,this._themeService=r,this._univerInstanceService=t,this._commandService=i,this._selectionManagerService=a,this._renderManagerService=s,this._numfmtService=u,this._componentManager=c,this._sidebarService=p,this._localeService=v,this._sheetsNumfmtCellContentController=d,this._initRealTimeRenderingInterceptor(),this._initPanel(),this._initCommands(),this._initCloseListener(),this._commandExecutedListener(),this._initNumfmtLocalChange()}_initNumfmtLocalChange(){this.disposeWithMe(O.merge(this._sheetsNumfmtCellContentController.local$,this._localeService.currentLocale$).subscribe(()=>{this._forceUpdate()}))}openPanel(){var E;const n=this._sidebarService,r=this._selectionManagerService,t=this._commandService,i=this._univerInstanceService,a=this._numfmtService,s=this._localeService,c=(((E=r.getCurrentSelections())==null?void 0:E.map(I=>I.range))||[])[0];if(!c)return!1;const p=i.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET),v=p.getActiveSheet();if(!v)return!1;const d=v.getCellRaw(c.startRow,c.startColumn),f=a.getValue(p.getUnitId(),v.getSheetId(),c.startRow,c.startColumn);let g="";f&&(g=f.pattern);const _=(d==null?void 0:d.t)===o.CellValueType.NUMBER?d.v:12345678,h={onChange:I=>{var N;if(I.type==="change")this._previewPattern=I.value,this._forceUpdate();else if(I.type==="confirm"){const w=((N=r.getCurrentSelections())==null?void 0:N.map(R=>R.range))||[],F={values:[]},ne=m.getPatternType(I.value);w.forEach(R=>{o.Range.foreach(R,(re,T)=>{F.values.push({row:re,col:T,pattern:I.value,type:ne})})}),t.executeCommand(m.SetNumfmtCommand.id,F),n.close()}else I.type==="cancel"&&n.close()},value:{defaultPattern:g,defaultValue:_,row:c.startRow,col:c.startColumn}};return this._sidebarDisposable=n.open({header:{title:s.t("sheet.numfmt.title")},children:{label:le,...h},onClose:()=>{this._forceUpdate(),t.executeCommand(X.id)}}),!0}_forceUpdate(n){var t;const r=this._renderManagerService.getRenderById(n!=null?n:this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET).getUnitId());r==null||r.with(M.SheetSkeletonManagerService).reCalculate(),(t=r==null?void 0:r.mainComponent)==null||t.makeDirty()}_initCommands(){[H,X].forEach(n=>{this.disposeWithMe(this._commandService.registerCommand(n))})}_initPanel(){this._componentManager.register(le,He)}_initRealTimeRenderingInterceptor(){const n=new O.Observable(t=>{this._commandService.onCommandExecuted(i=>{i.id===H.id&&t.next(!0),i.id===X.id&&t.next(!1)})}),r=O.combineLatest([n,this._selectionManagerService.selectionMoveEnd$.pipe(B.map(t=>t?t.map(i=>i.range):[]))]);this.disposeWithMe(o.toDisposable(r.pipe(B.switchMap(([t,i])=>new O.Observable(a=>{const s=new o.DisposableCollection;return t&&i.length&&a.next({selectionRanges:i,disposableCollection:s}),()=>{s.dispose()}})),B.tap(()=>{this._previewPattern=null})).subscribe(({disposableCollection:t,selectionRanges:i})=>{var s,u;const a=this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);this.openPanel(),t.add(this._sheetInterceptorService.intercept(S.INTERCEPTOR_POINT.CELL_CONTENT,{priority:99,effect:o.InterceptorEffectEnum.Value|o.InterceptorEffectEnum.Style,handler:(c,p,v)=>{const{row:d,col:f}=p,g=v(c)||{};if(i.find(_=>_.startColumn<=f&&_.endColumn>=f&&_.startRow<=d&&_.endRow>=d)){const _=p.worksheet.getCellRaw(d,f),h=_==null?void 0:_.v,E=_==null?void 0:_.t;if(h==null||E!==o.CellValueType.NUMBER||this._previewPattern===null)return g;const I=m.getPatternPreviewIgnoreGeneral(this._previewPattern,h,this._sheetsNumfmtCellContentController.local);if(I.color){const w=this._themeService.getCurrentTheme()[`${I.color}500`];return{...g,v:I.result,t:o.CellValueType.STRING,s:{cl:{rgb:w}}}}return{...g,v:I.result,t:o.CellValueType.STRING}}return g}})),(u=(s=this._renderManagerService.getRenderById(a.getUnitId()))==null?void 0:s.mainComponent)==null||u.makeDirty()})))}_commandExecutedListener(){const n=[S.RemoveNumfmtMutation.id,S.SetNumfmtMutation.id];this.disposeWithMe(new O.Observable(r=>{const t=this._commandService.onCommandExecuted(i=>{if(n.includes(i.id)){const a=i.params;r.next(a.unitId)}});return()=>t.dispose()}).pipe(B.debounceTime(16)).subscribe(r=>this._forceUpdate(r)))}_initCloseListener(){this._univerInstanceService.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_SHEET).subscribe(n=>{var r;n||((r=this._sidebarDisposable)==null||r.dispose(),this._sidebarDisposable=null)})}};A=Ae([U(0,o.Inject(S.SheetInterceptorService)),U(1,o.Inject(o.ThemeService)),U(2,o.IUniverInstanceService),U(3,o.ICommandService),U(4,o.Inject(S.SheetsSelectionsService)),U(5,k.IRenderManagerService),U(6,S.INumfmtService),U(7,o.Inject(C.ComponentManager)),U(8,C.ISidebarService),U(9,o.Inject(o.LocaleService)),U(10,o.Inject(m.SheetsNumfmtCellContentController))],A);var We=Object.getOwnPropertyDescriptor,Re=(e,n,r,t)=>{for(var i=t>1?void 0:t?We(n,r):n,a=e.length-1,s;a>=0;a--)(s=e[a])&&(i=s(i)||i);return i},W=(e,n)=>(r,t)=>n(r,t,e);const Ve=()=>{let e=[];return{add:(i,a,s,u,c)=>e.push({unitId:i,subUnitId:a,row:s,col:u,value:c}),getEffects:()=>e,clean:()=>{e=[]}}};let q=class extends o.Disposable{constructor(n,r,t,i,a){super();Y(this,"_collectEffectMutation",Ve());this._sheetInterceptorService=n,this._numfmtService=r,this._univerInstanceService=t,this._injector=i,this._editorBridgeService=a,this._initInterceptorEditorStart(),this._initInterceptorEditorEnd(),this._initInterceptorCommands()}_initInterceptorEditorStart(){this._editorBridgeService&&this.disposeWithMe(o.toDisposable(this._sheetInterceptorService.writeCellInterceptor.intercept(S.BEFORE_CELL_EDIT,{handler:(n,r,t)=>{const i=r.row,a=r.col,s=this._numfmtService.getValue(r.unitId,r.subUnitId,i,a);if(s)switch(m.getPatternType(s.pattern)){case"scientific":case"currency":case"grouped":case"number":{const c=r.worksheet.getCellRaw(i,a);return t&&t(c)}case"percent":case"date":case"time":case"datetime":default:return t&&t(n)}return t(n)}})))}_initInterceptorEditorEnd(){this.disposeWithMe(o.toDisposable(this._sheetInterceptorService.writeCellInterceptor.intercept(S.AFTER_CELL_EDIT,{handler:(n,r,t)=>{var v,d,f,g;this._collectEffectMutation.clean();const i=this._numfmtService.getValue(r.unitId,r.subUnitId,r.row,r.col),a=(v=i&&m.getPatternType(i.pattern))!=null?v:"",s=()=>{i&&this._collectEffectMutation.add(r.unitId,r.subUnitId,r.row,r.col,null)};if(!(n!=null&&n.v)&&!(n!=null&&n.p)||V.isTextFormat(i==null?void 0:i.pattern)||n.t===o.CellValueType.FORCE_STRING)return t(n);const u=(d=n.p)==null?void 0:d.body,c=(g=(f=n==null?void 0:n.p)==null?void 0:f.body)!=null&&g.dataStream?n.p.body.dataStream.replace(/\r\n$/,""):String(n.v),p=o.numfmt.parseDate(c)||o.numfmt.parseTime(c)||o.numfmt.parseNumber(c);if(u)if(qe(u)){const{dataStream:_}=u,h=_.replace(/\r\n$/,""),E=Number(h);if(Number.isNaN(E)&&!p)return t(n)}else return t(n);if(p){p.z&&this._collectEffectMutation.add(r.unitId,r.subUnitId,r.row,r.col,{pattern:p.z});const _=Number(p.v);return t({...n,p:void 0,v:_,t:o.CellValueType.NUMBER})}else(["date","time","datetime","percent"].includes(a)||!Be(c))&&s();return t(n)}})))}_initInterceptorCommands(){const n=this;this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations(r){var t;switch(r.id){case S.SetRangeValuesCommand.id:{const i=n._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET),a=i.getUnitId(),s=(t=i.getActiveSheet())==null?void 0:t.getSheetId();if(!s)return{redos:[],undos:[]};const u=n._collectEffectMutation.getEffects();if(n._collectEffectMutation.clean(),!u.length)return{redos:[],undos:[]};const c=u.filter(f=>{var g;return!!((g=f.value)!=null&&g.pattern)}).map(f=>({row:f.row,col:f.col,pattern:f.value.pattern})),p=u.filter(f=>{var g;return!((g=f.value)!=null&&g.pattern)}).map(f=>({startRow:f.row,endColumn:f.col,startColumn:f.col,endRow:f.row})),v=[],d=[];if(c.length){const f={id:S.SetNumfmtMutation.id,params:S.transformCellsToRange(a,s,c)};v.push(f),d.push(...S.factorySetNumfmtUndoMutation(n._injector,f.params))}if(p.length){const f={id:S.RemoveNumfmtMutation.id,params:{unitId:a,subUnitId:s,ranges:p}};v.push(f),d.push(...S.factoryRemoveNumfmtUndoMutation(n._injector,f.params))}return{redos:v,undos:d.reverse()}}}return{redos:[],undos:[]}}}))}};q=Re([W(0,o.Inject(S.SheetInterceptorService)),W(1,o.Inject(S.INumfmtService)),W(2,o.Inject(o.IUniverInstanceService)),W(3,o.Inject(o.Injector)),W(4,o.Optional(M.IEditorBridgeService))],q);function Be(e){return/^-?\d+(\.\d+)?$/.test(e)}function qe(e){const{textRuns:n=[],paragraphs:r=[],customRanges:t,customBlocks:i=[]}=e,a=["va"];return!(n.some(s=>!!(s.ts&&Object.keys(s.ts).some(c=>a.includes(c))))||r.some(s=>s.bullet)||r.length>=2||t!=null&&t.length||i.length>0)}const G=[{label:"sheet.numfmt.general",pattern:null},{label:"sheet.numfmt.text",pattern:V.DEFAULT_TEXT_FORMAT_EXCEL},"|",{label:"sheet.numfmt.number",pattern:"0"},"|",{label:"sheet.numfmt.accounting",pattern:'"¥" #,##0.00_);[Red]("¥"#,##0.00)'},{label:"sheet.numfmt.financialValue",pattern:"#,##0.00;[Red]#,##0.00"},{label:"sheet.numfmt.currency",pattern:'"¥"#,##0.00_);[Red]("¥"#,##0.00)'},{label:"sheet.numfmt.roundingCurrency",pattern:'"¥"#,##0;[Red]"¥"#,##0'},"|",{label:"sheet.numfmt.date",pattern:"yyyy-mm-dd;@"},{label:"sheet.numfmt.time",pattern:'am/pm h":"mm":"ss'},{label:"sheet.numfmt.dateTime",pattern:"yyyy-m-d am/pm h:mm"},{label:"sheet.numfmt.timeDuration",pattern:"h:mm:ss"},"|",{label:"sheet.numfmt.percent",pattern:"0.00%"},"|",{label:"sheet.numfmt.moreFmt",pattern:""}],Ge=e=>({icon:new O.Observable(n=>{const r=e.get(m.MenuCurrencyService);function t(a){return{[m.countryCurrencyMap.US]:"DollarSingle",[m.countryCurrencyMap.RU]:"RoubleSingle",[m.countryCurrencyMap.CN]:"RmbSingle",[m.countryCurrencyMap.AT]:"EuroSingle"}[a]||"DollarSingle"}const i=m.countryCurrencyMap[r.getCurrencySymbol()]||"$";return n.next(t(i)),r.currencySymbol$.subscribe(a=>{const s=m.countryCurrencyMap[a]||"$";n.next(t(s))})}),id:m.SetCurrencyCommand.id,title:"sheet.numfmt.currency",tooltip:"sheet.numfmt.currency",type:C.MenuItemType.BUTTON,hidden$:C.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:M.getCurrentRangeDisable$(e,{workbookTypes:[S.WorkbookEditablePermission],worksheetTypes:[S.WorksheetEditPermission,S.WorksheetSetCellStylePermission],rangeTypes:[S.RangeProtectionPermissionEditPoint]})}),Ke=e=>({icon:"AddDigitsSingle",id:m.AddDecimalCommand.id,title:"sheet.numfmt.addDecimal",tooltip:"sheet.numfmt.addDecimal",type:C.MenuItemType.BUTTON,hidden$:C.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:M.getCurrentRangeDisable$(e,{workbookTypes:[S.WorkbookEditablePermission],worksheetTypes:[S.WorksheetEditPermission,S.WorksheetSetCellStylePermission],rangeTypes:[S.RangeProtectionPermissionEditPoint]})}),Ye=e=>({icon:"ReduceDigitsSingle",id:m.SubtractDecimalCommand.id,title:"sheet.numfmt.subtractDecimal",tooltip:"sheet.numfmt.subtractDecimal",type:C.MenuItemType.BUTTON,hidden$:C.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:M.getCurrentRangeDisable$(e,{workbookTypes:[S.WorkbookEditablePermission],worksheetTypes:[S.WorksheetEditPermission,S.WorksheetSetCellStylePermission],rangeTypes:[S.RangeProtectionPermissionEditPoint]})}),Ze=e=>({icon:"PercentSingle",id:m.SetPercentCommand.id,title:"sheet.numfmt.percent",tooltip:"sheet.numfmt.percent",type:C.MenuItemType.BUTTON,hidden$:C.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:M.getCurrentRangeDisable$(e,{workbookTypes:[S.WorkbookEditablePermission],worksheetTypes:[S.WorksheetEditPermission,S.WorksheetSetCellStylePermission],rangeTypes:[S.RangeProtectionPermissionEditPoint]})}),ze=e=>{const n=e.get(o.IUniverInstanceService),r=e.get(o.ICommandService),t=e.get(o.LocaleService),i=e.get(S.SheetsSelectionsService),a=[S.RemoveNumfmtMutation.id,S.SetNumfmtMutation.id],s=M.deriveStateFromActiveSheet$(n,"",({workbook:u,worksheet:c})=>new O.Observable(p=>O.merge(i.selectionMoveEnd$,o.fromCallback(r.onCommandExecuted.bind(r)).pipe(O.filter(([v])=>a.includes(v.id)))).subscribe(()=>{var d,f;const v=i.getCurrentSelections();if(v&&v[0]){const g=v[0].range,_=g.startRow,h=g.startColumn,E=(f=u.getStyles().get((d=c.getCell(_,h))==null?void 0:d.s))==null?void 0:f.n,I=E==null?void 0:E.pattern;let N=t.t("sheet.numfmt.general");if(V.isDefaultFormat(I)){p.next(N);return}if(I){const w=G.filter(F=>typeof F=="object"&&F.pattern).find(F=>m.isPatternEqualWithoutDecimal(I,F.pattern));w&&typeof w=="object"&&w.pattern?N=t.t(w.label):N=t.t("sheet.numfmt.moreFmt")}p.next(N)}})));return{label:ue,id:H.id,tooltip:"sheet.numfmt.title",type:C.MenuItemType.SELECTOR,slot:!0,selections:[{label:{name:me,hoverable:!1,selectable:!1}}],value$:s,hidden$:C.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:M.getCurrentRangeDisable$(e,{workbookTypes:[S.WorkbookEditablePermission],worksheetTypes:[S.WorksheetSetCellStylePermission,S.WorksheetEditPermission],rangeTypes:[S.RangeProtectionPermissionEditPoint]})}},ue="sheet.numfmt.moreNumfmtType",me="sheet.numfmt.moreNumfmtType.options",Xe=e=>{const{value:n}=e,r=C.useDependency(o.LocaleService),t=n!=null?n:r.t("sheet.numfmt.general");return l.jsx("span",{className:"univer-text-sm",children:t})},Je=()=>{const e=C.useDependency(o.ICommandService),n=C.useDependency(o.LocaleService),r=C.useDependency(C.ILayoutService),t=C.useDependency(m.SheetsNumfmtCellContentController),i=C.useDependency(S.SheetsSelectionsService),a=c=>{const p=i.getCurrentLastSelection();if(!p)return;const v=p.range,d=[];o.Range.foreach(v,(f,g)=>{c?d.push({row:f,col:g,pattern:c,type:m.getPatternType(c)}):d.push({row:f,col:g})}),e.executeCommand(m.SetNumfmtCommand.id,{values:d}),r.focus()},s=c=>{if(c===0)a(null);else if(c===G.length-1)e.executeCommand(H.id),r.focus();else{const p=G[c];p.pattern&&a(p.pattern)}},u=1220;return l.jsx("div",{className:"univer-grid univer-gap-1 univer-p-1.5",children:G.map((c,p)=>c==="|"?l.jsx(P.Separator,{},p):l.jsxs("div",{className:`
|
|
2
2
|
univer-flex univer-h-7 univer-items-center univer-justify-between univer-gap-6 univer-rounded
|
|
3
3
|
univer-px-2 univer-text-[13px]
|
|
4
4
|
hover:univer-bg-gray-100
|
|
5
|
-
`,onClick:()=>{s(
|
|
5
|
+
`,onClick:()=>{s(p)},children:[l.jsx("span",{children:n.t(c.label)}),l.jsx("span",{className:"univer-text-xs univer-text-gray-500",children:c.pattern?m.getPatternPreview(c.pattern||"",u,t.local).result.trim():""})]},p))})},Qe={[C.RibbonStartGroup.FORMULAS_INSERT]:{[m.SetCurrencyCommand.id]:{order:4,menuItemFactory:Ge},[m.AddDecimalCommand.id]:{order:5,menuItemFactory:Ke},[m.SubtractDecimalCommand.id]:{order:6,menuItemFactory:Ye},[m.SetPercentCommand.id]:{order:7,menuItemFactory:Ze},[H.id]:{order:8,menuItemFactory:ze}}};var et=Object.getOwnPropertyDescriptor,tt=(e,n,r,t)=>{for(var i=t>1?void 0:t?et(n,r):n,a=e.length-1,s;a>=0;a--)(s=e[a])&&(i=s(i)||i);return i},de=(e,n)=>(r,t)=>n(r,t,e);let K=class extends o.Disposable{constructor(e,n){super(),this._componentManager=e,this._menuManagerService=n,this._initMenu()}_initMenu(){this._menuManagerService.mergeMenu(Qe),this.disposeWithMe(this._componentManager.register(ue,Xe)),this.disposeWithMe(this._componentManager.register(me,Je))}};K=tt([de(0,o.Inject(C.ComponentManager)),de(1,C.IMenuManagerService)],K);var nt=Object.defineProperty,rt=Object.getOwnPropertyDescriptor,it=(e,n,r)=>n in e?nt(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r,at=(e,n,r,t)=>{for(var i=t>1?void 0:t?rt(n,r):n,a=e.length-1,s;a>=0;a--)(s=e[a])&&(i=s(i)||i);return i},te=(e,n)=>(r,t)=>n(r,t,e),pe=(e,n,r)=>it(e,typeof n!="symbol"?n+"":n,r);const ot="SHEET_NUMFMT_UI_PLUGIN";b.UniverSheetsNumfmtUIPlugin=class extends o.Plugin{constructor(n=ie,r,t,i){super(),this._config=n,this._injector=r,this._configService=t,this._renderManagerService=i;const{menu:a,...s}=o.merge({},ie,this._config);a&&this._configService.setConfig("menu",a,{merge:!0}),this._configService.setConfig(C.UI_PLUGIN_CONFIG_KEY,s)}onStarting(){o.registerDependencies(this._injector,[[A],[q],[x],[K]])}onRendered(){this._registerRenderModules(),o.touchDependencies(this._injector,[[A],[q],[K]])}_registerRenderModules(){[[z]].forEach(r=>{this.disposeWithMe(this._renderManagerService.registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,r))})}},pe(b.UniverSheetsNumfmtUIPlugin,"pluginName",ot),pe(b.UniverSheetsNumfmtUIPlugin,"type",o.UniverInstanceType.UNIVER_SHEET),b.UniverSheetsNumfmtUIPlugin=at([o.DependentOn(M.UniverSheetsUIPlugin,m.UniverSheetsNumfmtPlugin),te(1,o.Inject(o.Injector)),te(2,o.IConfigService),te(3,k.IRenderManagerService)],b.UniverSheetsNumfmtUIPlugin),Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/sheets-numfmt-ui",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.7-experimental.20250328-3aaa828",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "UniverSheet numfmt plugin",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -50,20 +50,20 @@
|
|
|
50
50
|
"lib"
|
|
51
51
|
],
|
|
52
52
|
"peerDependencies": {
|
|
53
|
-
"react": "
|
|
53
|
+
"react": "^16.9.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc",
|
|
54
54
|
"rxjs": ">=7.0.0"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@univerjs/icons": "^0.2.
|
|
58
|
-
"@univerjs/core": "0.6.
|
|
59
|
-
"@univerjs/design": "0.6.
|
|
60
|
-
"@univerjs/engine-numfmt": "0.6.
|
|
61
|
-
"@univerjs/engine-formula": "0.6.
|
|
62
|
-
"@univerjs/engine-render": "0.6.
|
|
63
|
-
"@univerjs/sheets": "0.6.
|
|
64
|
-
"@univerjs/sheets-numfmt": "0.6.
|
|
65
|
-
"@univerjs/ui": "0.6.
|
|
66
|
-
"@univerjs/
|
|
57
|
+
"@univerjs/icons": "^0.2.30",
|
|
58
|
+
"@univerjs/core": "0.6.7-experimental.20250328-3aaa828",
|
|
59
|
+
"@univerjs/design": "0.6.7-experimental.20250328-3aaa828",
|
|
60
|
+
"@univerjs/engine-numfmt": "0.6.7-experimental.20250328-3aaa828",
|
|
61
|
+
"@univerjs/engine-formula": "0.6.7-experimental.20250328-3aaa828",
|
|
62
|
+
"@univerjs/engine-render": "0.6.7-experimental.20250328-3aaa828",
|
|
63
|
+
"@univerjs/sheets": "0.6.7-experimental.20250328-3aaa828",
|
|
64
|
+
"@univerjs/sheets-numfmt": "0.6.7-experimental.20250328-3aaa828",
|
|
65
|
+
"@univerjs/sheets-ui": "0.6.7-experimental.20250328-3aaa828",
|
|
66
|
+
"@univerjs/ui": "0.6.7-experimental.20250328-3aaa828"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"less": "^4.2.2",
|
|
@@ -72,9 +72,9 @@
|
|
|
72
72
|
"rxjs": "^7.8.1",
|
|
73
73
|
"tailwindcss": "^3.4.17",
|
|
74
74
|
"typescript": "^5.8.2",
|
|
75
|
-
"vite": "^6.2.
|
|
76
|
-
"vitest": "^3.0.
|
|
77
|
-
"@univerjs-infra/shared": "0.6.
|
|
75
|
+
"vite": "^6.2.3",
|
|
76
|
+
"vitest": "^3.0.9",
|
|
77
|
+
"@univerjs-infra/shared": "0.6.7"
|
|
78
78
|
},
|
|
79
79
|
"scripts": {
|
|
80
80
|
"test": "vitest run",
|