@univerjs/core 0.7.0 → 0.8.0-beta.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/core",
3
- "version": "0.7.0",
3
+ "version": "0.8.0-beta.1",
4
4
  "private": false,
5
5
  "description": "Core library for Univer.",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -67,22 +67,20 @@
67
67
  "kdbush": "^4.0.2",
68
68
  "lodash-es": "^4.17.21",
69
69
  "nanoid": "5.1.5",
70
- "numeral": "^2.0.6",
71
- "numfmt": "^2.5.2",
70
+ "numfmt": "^3.2.2",
72
71
  "ot-json1": "^1.0.2",
73
72
  "rbush": "^4.0.1",
74
- "@univerjs/themes": "0.7.0"
73
+ "@univerjs/themes": "0.8.0-beta.1"
75
74
  },
76
75
  "devDependencies": {
77
76
  "@types/async-lock": "^1.4.2",
78
77
  "@types/lodash-es": "^4.17.12",
79
- "@types/numeral": "^2.0.5",
80
78
  "@types/rbush": "^4.0.0",
81
79
  "rxjs": "^7.8.2",
82
80
  "typescript": "^5.8.3",
83
81
  "vite": "^6.3.5",
84
- "vitest": "^3.1.3",
85
- "@univerjs-infra/shared": "0.7.0"
82
+ "vitest": "^3.1.4",
83
+ "@univerjs-infra/shared": "0.8.0-beta.1"
86
84
  },
87
85
  "scripts": {
88
86
  "test": "vitest run",
@@ -1,223 +0,0 @@
1
- /**
2
- * Copyright 2023-present DreamNum Co., Ltd.
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
- type FormatType = 'currency' | 'date' | 'datetime' | 'error' | 'fraction' | 'general' | 'grouped' | 'number' | 'percent' | 'scientific' | 'text' | 'time';
17
- /**
18
- * An arbirarty number that represents the format's specificity if you want to compare one to another. Integer comparisons roughly match Excel's resolutions when it determines which format wins out.
19
- *
20
- * text: 15
21
- * datetime: 10.8
22
- * date: 10.8
23
- * time: 10.8
24
- * percent: 10.6
25
- * currency: 10.4
26
- * grouped: 10.2
27
- * scientific: 6
28
- * number: 4
29
- * fraction: 2
30
- * general: 0
31
- * error: 0
32
- */
33
- type Level = 15 | 10.8 | 10.6 | 10.4 | 10.2 | 6 | 4 | 2 | 0;
34
- interface Info {
35
- type: FormatType;
36
- /**
37
- * Correspond to the output from same named functions found on the formatters.
38
- */
39
- isDate: boolean;
40
- isText: boolean;
41
- isPercent: boolean;
42
- /** The maximum number of decimals this format will emit. */
43
- maxDecimals: number;
44
- /**
45
- * 1 if the format uses color on the negative portion of the string, else a 0. This replicates Excel's CELL("color") functionality.
46
- */
47
- color: 0 | 1;
48
- /**
49
- * 1 if the positive portion of the number format contains an open parenthesis, else a 0. This is replicates Excel's CELL("parentheses") functionality.
50
- */
51
- parentheses: 0 | 1;
52
- /**
53
- * 1 if the positive portion of the format uses a thousands separator, else a 0.
54
- */
55
- grouped: 1;
56
- /**
57
- * Corresponds to Excel's CELL("format") functionality. It is should match Excel's quirky behaviour fairly well.
58
- */
59
- code: string;
60
- /**
61
- * The multiplier used when formatting the number (100 for percentages).
62
- */
63
- scale: 1;
64
- /**
65
- * An arbirarty number that represents the format's specificity if you want to compare one to another. Integer comparisons roughly match Excel's resolutions when it determines which format wins out.
66
- */
67
- level: Level;
68
- _partitions: Array<{
69
- color: string;
70
- tokens: Array<{
71
- type: 'num';
72
- num: string;
73
- } | {
74
- type: 'point';
75
- value: string;
76
- } | {
77
- type: 'frac';
78
- num: string;
79
- }>;
80
- }>;
81
- }
82
- interface DateInfo {
83
- /** If any `y` or `b` operator was found in the pattern. */
84
- year: boolean;
85
- /** If any `m` operator was found in the pattern. */
86
- month: boolean;
87
- /** If any `d` operator was found in the pattern (including ones that emit weekday). */
88
- day: boolean;
89
- /** If any `h` operator was found in the pattern. */
90
- hours: boolean;
91
- /** If any `:m` operator was found in the pattern. */
92
- minutes: boolean;
93
- /** If any `s` operator was found in the pattern. */
94
- seconds: boolean;
95
- /** Will be set to `12` if AM/PM operators are being used in the formatting string, else it will be set to `24`. */
96
- clockType: 24 | 12;
97
- }
98
- interface Options {
99
- /**
100
- * A [BCP 47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) string tag. Locale default is english with a \u00a0 grouping symbol
101
- *
102
- * @default ""
103
- */
104
- locale: LocaleTag;
105
- /**
106
- * Should the formatter throw an error if a provided pattern is invalid. If not, a formatter will be constructed which only ever outputs an error string (see invalid in this table).
107
- * @default true
108
- */
109
- throws: boolean;
110
- /**
111
- * The string emitted when no-throw mode fails to parse a pattern.
112
- * @default "######"
113
- */
114
- invalid: string;
115
- /**
116
- * By default the formatters will emit [non-breaking-space](https://en.wikipedia.org/wiki/Non-breaking_space) rather than a regular space when emitting the formatted number. Setting this to false will make it use regular spaces instead.
117
- * @default true
118
- */
119
- nbsp: boolean;
120
- /**
121
- * Simulate the Lotus 1-2-3 [1900 leap year bug](https://docs.microsoft.com/en-us/office/troubleshoot/excel/wrongly-assumes-1900-is-leap-year). It is a requirement in the Ecma OOXML specification so it is on by default.
122
- *
123
- * @default false
124
- */
125
- leap1900: boolean;
126
- /**
127
- * Should the formatter throw an error when trying to format a date that is out of bounds?
128
- *
129
- * @default false
130
- */
131
- dateErrorThrows: boolean;
132
- /**
133
- * Should the formatter switch to a General number format when trying to format a date that is out of bounds?
134
- * @default true
135
- */
136
- dateErrorNumber: boolean;
137
- /**
138
- * The string emitted when a formatter fails to format a date that is out of bounds.
139
- * @default "######"
140
- */
141
- overflow: string;
142
- /**
143
- * Extends the allowed range of dates from Excel bounds (1900–9999) to Google Sheet bounds (0–99999).
144
- * @default true
145
- */
146
- dateSpanLarge: boolean;
147
- /**
148
- * Normally when date objects are used with the formatter, time zone is taken into account. This makes the formatter ignore the timezone offset.
149
- * @default false
150
- */
151
- ignoreTimezone: boolean;
152
- /**
153
- * when using the numfmt.parseDate, numfmt.parseValue and numfmt.dateFromSerial functions, the output will be a Date object.
154
- * @default false
155
- */
156
- nativeDate: boolean;
157
- }
158
- interface LocaleData {
159
- group: string;
160
- decimal: string;
161
- positive: string;
162
- negative: string;
163
- percent: string;
164
- exponent: string;
165
- nan: string;
166
- infinity: string;
167
- ampm: [string, string];
168
- mmmm: string[];
169
- mmm: string[];
170
- dddd: string[];
171
- ddd: string[];
172
- mmmm6: string[];
173
- mmm6: string[];
174
- }
175
- interface Formatter {
176
- isDate(): boolean;
177
- isPercent(): boolean;
178
- isText(): boolean;
179
- color(value: number): string;
180
- info: Info;
181
- dateInfo: DateInfo;
182
- (value: number): string;
183
- }
184
- export type LocaleTag = 'zh-CN' | 'zh-TW' | 'cs' | 'da' | 'nl' | 'en' | 'fi' | 'fr' | 'de' | 'el' | 'hu' | 'is' | 'id' | 'it' | 'ja' | 'ko' | 'nb' | 'pl' | 'pt' | 'ru' | 'sk' | 'es' | 'sv' | 'th' | 'tr' | 'vi';
185
- export interface ParsedReturnType {
186
- /**
187
- * The parsed value. For dates, this will be an Excel style serial date unless the nativeDate option is used.
188
- */
189
- v: number | string | boolean | Date;
190
- /**
191
- * (Optionally) the number format string of the input. This property will not be present if it amounts to the General format.
192
- */
193
- z?: string;
194
- }
195
- type _Year = number;
196
- type _MonthIndex = number;
197
- type _Date = number | undefined;
198
- type _Hours = number | undefined;
199
- type _Minutes = number | undefined;
200
- type _Seconds = number | undefined;
201
- type _Ms = number | undefined;
202
- type DateValue = [_Year, _MonthIndex, _Date, _Hours, _Minutes, _Seconds, _Ms];
203
- type ParseValue = number | boolean | DateValue | Date | null;
204
- export interface INumfmt {
205
- (value: string, opt?: Options): Formatter;
206
- format(pattern: string, value: ParseValue, opt?: Partial<Options>): string;
207
- round(value: number, places?: number): number;
208
- getLocale(tag: LocaleTag): LocaleData | null;
209
- addLocale(data: Partial<LocaleData>, tag: LocaleTag): void;
210
- isDate(format: string): boolean;
211
- isPercent(format: string): boolean;
212
- isText(format: string): boolean;
213
- getInfo(format: string): Info;
214
- parseValue(value: string, op?: Options): ParsedReturnType;
215
- parseNumber(value: string, op?: Options): ParsedReturnType;
216
- parseDate(value: string, op?: Options): ParsedReturnType;
217
- parseTime(value: string, op?: Options): ParsedReturnType;
218
- parseBool(value: string, op?: Options): ParsedReturnType;
219
- dateToSerial(value: Date | [number, number, number], opt?: Options): number | string;
220
- dateFromSerial(value: number, opt?: Options): [number, number, number, number, number, number];
221
- options(op: Partial<Options>): void;
222
- }
223
- export {};