@univerjs/core 1.0.0-alpha.2 → 1.0.0-alpha.4

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.
Files changed (77) hide show
  1. package/lib/cjs/facade.js +85 -27
  2. package/lib/cjs/index.js +16381 -10924
  3. package/lib/es/facade.js +86 -28
  4. package/lib/es/index.js +16321 -10901
  5. package/lib/facade.js +86 -28
  6. package/lib/index.js +16321 -10901
  7. package/lib/types/bases/base-data-model.d.ts +4 -0
  8. package/lib/types/bases/empty-snapshot.d.ts +2 -1
  9. package/lib/types/bases/index.d.ts +3 -2
  10. package/lib/types/bases/typedef.d.ts +80 -67
  11. package/lib/types/common/regexp/charset.d.ts +63 -0
  12. package/lib/types/common/regexp/escape.d.ts +30 -0
  13. package/lib/types/common/regexp/factory.d.ts +16 -0
  14. package/lib/types/common/regexp/index.d.ts +37 -0
  15. package/lib/types/common/regexp/or.d.ts +57 -0
  16. package/lib/types/docs/data-model/empty-snapshot.d.ts +2 -1
  17. package/lib/types/docs/data-model/index.d.ts +21 -0
  18. package/lib/types/docs/data-model/paragraph-style.d.ts +22 -0
  19. package/lib/types/docs/data-model/preset-list-type.d.ts +19 -6
  20. package/lib/types/docs/data-model/rich-text-builder.d.ts +455 -1
  21. package/lib/types/docs/data-model/text-x/action-types.d.ts +1 -0
  22. package/lib/types/docs/data-model/text-x/apply-utils/common.d.ts +4 -1
  23. package/lib/types/docs/data-model/text-x/build-utils/data-stream-change.d.ts +28 -0
  24. package/lib/types/docs/data-model/text-x/build-utils/drawings.d.ts +2 -2
  25. package/lib/types/docs/data-model/text-x/build-utils/index.d.ts +6 -0
  26. package/lib/types/docs/data-model/text-x/build-utils/paragraph.d.ts +4 -1
  27. package/lib/types/docs/data-model/text-x/build-utils/range-interval.d.ts +74 -0
  28. package/lib/types/docs/data-model/text-x/structure-validator.d.ts +31 -0
  29. package/lib/types/docs/data-model/text-x/utils.d.ts +12 -4
  30. package/lib/types/docs/index.d.ts +5 -0
  31. package/lib/types/docs/section-break-id.d.ts +19 -0
  32. package/lib/types/docs/section-header-footer.d.ts +32 -0
  33. package/lib/types/facade/f-enum.d.ts +40 -1
  34. package/lib/types/facade/f-hooks.d.ts +8 -0
  35. package/lib/types/facade/f-univer.d.ts +28 -27
  36. package/lib/types/index.d.ts +3 -32
  37. package/lib/types/services/authz-io/authz-io-local.service.d.ts +1 -1
  38. package/lib/types/services/instance/instance.service.d.ts +26 -0
  39. package/lib/types/services/resource-manager/type.d.ts +1 -1
  40. package/lib/types/shared/date-kit.d.ts +1 -0
  41. package/lib/types/shared/numfmt/api.d.ts +82 -0
  42. package/lib/types/shared/numfmt/clamp.d.ts +16 -0
  43. package/lib/types/shared/numfmt/code-to-locale.d.ts +16 -0
  44. package/lib/types/shared/numfmt/constants.d.ts +68 -0
  45. package/lib/types/shared/numfmt/dec-to-frac.d.ts +26 -0
  46. package/lib/types/shared/numfmt/decimal.d.ts +37 -0
  47. package/lib/types/shared/numfmt/format-info.d.ts +21 -0
  48. package/lib/types/shared/numfmt/format-number.d.ts +18 -0
  49. package/lib/types/shared/numfmt/general.d.ts +18 -0
  50. package/lib/types/shared/numfmt/index.d.ts +18 -0
  51. package/lib/types/shared/numfmt/locale.d.ts +89 -0
  52. package/lib/types/shared/numfmt/num-dec.d.ts +17 -0
  53. package/lib/types/shared/numfmt/number-props.d.ts +17 -0
  54. package/lib/types/shared/numfmt/options.d.ts +17 -0
  55. package/lib/types/shared/numfmt/pad.d.ts +22 -0
  56. package/lib/types/shared/numfmt/parse-format-section.d.ts +17 -0
  57. package/lib/types/shared/numfmt/parse-pattern.d.ts +18 -0
  58. package/lib/types/shared/numfmt/parse-value.d.ts +30 -0
  59. package/lib/types/shared/numfmt/round.d.ts +26 -0
  60. package/lib/types/shared/numfmt/run-part.d.ts +18 -0
  61. package/lib/types/shared/numfmt/serial-date.d.ts +32 -0
  62. package/lib/types/shared/numfmt/to-ymd.d.ts +20 -0
  63. package/lib/types/shared/numfmt/tokenize.d.ts +20 -0
  64. package/lib/types/shared/numfmt/types.d.ts +193 -0
  65. package/lib/types/shared/{numfmt.d.ts → numfmt/utils.d.ts} +3 -4
  66. package/lib/types/shared/tools.d.ts +0 -11
  67. package/lib/types/sheets/index.d.ts +26 -0
  68. package/lib/types/sheets/typedef.d.ts +2 -0
  69. package/lib/types/types/const/const.d.ts +0 -1
  70. package/lib/types/types/enum/locale-type.d.ts +9 -0
  71. package/lib/types/types/interfaces/i-document-data-interceptor.d.ts +1 -0
  72. package/lib/types/types/interfaces/i-document-data.d.ts +39 -2
  73. package/lib/types/types/interfaces/i-drawing.d.ts +25 -1
  74. package/lib/types/types/interfaces/i-style-data.d.ts +4 -6
  75. package/lib/umd/facade.js +1 -1
  76. package/lib/umd/index.js +21 -11
  77. package/package.json +5 -6
@@ -0,0 +1,26 @@
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
+ /**
17
+ * Split a fractional number into a numerator and denominator for display as
18
+ * vulgar fractions.
19
+ *
20
+ * @ignore
21
+ * @param {number} number The value to split
22
+ * @param {number} [numeratorMaxDigits] The maxdigits number
23
+ * @param {number} [denominatorMaxDigits] The maxdigits de
24
+ * @returns {Array<number>} Array of two numbers, numerator and denominator.
25
+ */
26
+ export declare function dec2frac(number: number, numeratorMaxDigits?: number, denominatorMaxDigits?: number): [number, number];
@@ -0,0 +1,37 @@
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
+ export declare const SPREADSHEET_SIGNIFICANT_DIGITS = 15;
17
+ export interface IDecimalValue {
18
+ readonly negative: boolean;
19
+ readonly digits: string;
20
+ readonly exponent: number;
21
+ }
22
+ export interface IRoundedDecimalParts {
23
+ readonly negative: boolean;
24
+ readonly integer: string;
25
+ readonly fraction: string;
26
+ readonly zero: boolean;
27
+ }
28
+ export interface IScientificDecimalParts {
29
+ readonly exponent: number;
30
+ readonly rounded: IRoundedDecimalParts;
31
+ }
32
+ export declare function decimalFromNumber(value: number): IDecimalValue;
33
+ export declare function shiftDecimal(value: IDecimalValue, power: number): IDecimalValue;
34
+ export declare function roundDecimal(value: IDecimalValue, places?: number): IRoundedDecimalParts;
35
+ export declare function decimalPartsToNumber(value: IRoundedDecimalParts): number;
36
+ export declare function decimalPartsToPlainString(value: IRoundedDecimalParts): string;
37
+ export declare function roundScientificDecimal(value: IDecimalValue, integerDigits: number, hasIntegerPattern: boolean, fractionDigits: number): IScientificDecimalParts;
@@ -0,0 +1,21 @@
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
+ import type { FormatDateInfo, FormatInfo, FormatSection } from './types';
17
+ export declare function isPercent(partitions: Array<FormatSection | undefined>): boolean;
18
+ export declare function isDate(partitions: Array<FormatSection | undefined>): boolean;
19
+ export declare function isText(partitions: Array<FormatSection | undefined>): boolean;
20
+ export declare function info(partitions: Array<FormatSection | undefined>, currencyId?: string | null): FormatInfo;
21
+ export declare function dateInfo(partitions: Array<FormatSection | undefined>): FormatDateInfo;
@@ -0,0 +1,18 @@
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
+ import type { FormatColor, ParsedPattern, ResolvedFormatOptions } from './types';
17
+ export declare function formatColor(value: unknown, pattern: ParsedPattern, options: ResolvedFormatOptions): FormatColor;
18
+ export declare function formatValue(value: unknown, pattern: ParsedPattern, options: ResolvedFormatOptions): string;
@@ -0,0 +1,18 @@
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
+ import type { IDecimalValue } from './decimal';
17
+ import type { LocaleData, ParsedFormatSection } from './types';
18
+ export declare function general(output: Array<string | number>, part: Partial<ParsedFormatSection>, value: number | string, locale: LocaleData, decimalValue?: IDecimalValue | null): Array<string | number>;
@@ -0,0 +1,18 @@
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
+ export * as numfmt from './api';
17
+ export type { INumfmtLocaleTag } from './utils';
18
+ export { currencySymbols, DEFAULT_NUMBER_FORMAT, DEFAULT_TEXT_FORMAT, DEFAULT_TEXT_FORMAT_EXCEL, getNumfmtParseValueFilter, isDefaultFormat, isPatternEqualWithoutDecimal, isTextFormat, } from './utils';
@@ -0,0 +1,89 @@
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
+ import type { LocaleData, LocaleSettings, LocaleToken } from './types';
17
+ /**
18
+ * @typedef {object} LocaleToken - An object of properties for a locale tag.
19
+ * @property {string} lang - The basic tag such as `zh_CN` or `fi`
20
+ * @property {string} language - The language section (`zh` for `zh_CN`)
21
+ * @property {string} territory - The territory section (`CN` for `zh_CN`)
22
+ */
23
+ /**
24
+ * Parse a regular IETF BCP 47 locale tag and emit an object of its parts.
25
+ * Irregular tags and subtags are not supported.
26
+ *
27
+ * @param {string} locale - A BCP 47 string tag of the locale.
28
+ * @returns {LocaleToken} - An object describing the locale.
29
+ */
30
+ export declare function parseLocale(locale: string): LocaleToken;
31
+ export declare function resolveLocale(locale: string | number): string | null;
32
+ /**
33
+ * Used by the formatter to pull a locate from its registered locales. If
34
+ * subtag isn't available but the base language is, the base language is used.
35
+ * So if `en-CA` is not found, the formatter tries to find `en` else it
36
+ * returns a `null`.
37
+ *
38
+ * @param {string} locale - A BCP 47 string tag of the locale, or an Excel locale code.
39
+ * @returns {LocaleData | null} - An object of format date properties.
40
+ */
41
+ export declare function getLocale(locale: string | number): LocaleData | null;
42
+ export declare function createLocale(settings: LocaleSettings): LocaleData;
43
+ /**
44
+ * Register locale data for a language so for use when formatting.
45
+ *
46
+ * Any partial set of properties may be returned to have the defaults used where properties are missing.
47
+ *
48
+ * @see {LocaleData}
49
+ * @param {object} settings - A collection of settings for a locale.
50
+ * @param {string} [settings.group]
51
+ * Symbol used as a grouping separator (`1,000,000` uses `,`)
52
+ * @param {string} [settings.decimal]
53
+ * Symbol used to separate integers from fractions (usually `.`)
54
+ * @param {string} [settings.positive]
55
+ * Symbol used to indicate positive numbers (usually `+`)
56
+ * @param {string} [settings.negative]
57
+ * Symbol used to indicate positive numbers (usually `-`)
58
+ * @param {string} [settings.percent]
59
+ * Symbol used to indicate a percentage (usually `%`)
60
+ * @param {string} [settings.exponent]
61
+ * Symbol used to indicate an exponent (usually `E`)
62
+ * @param {string} [settings.nan]
63
+ * Symbol used to indicate NaN values (`NaN`)
64
+ * @param {string} [settings.infinity]
65
+ * Symbol used to indicate infinite values (`∞`)
66
+ * @param {Array<string>} [settings.ampm]
67
+ * How AM and PM should be presented.
68
+ * @param {Array<string>} [settings.mmmm6]
69
+ * Long month names for the Islamic calendar (e.g. `Rajab`)
70
+ * @param {Array<string>} [settings.mmm6]
71
+ * Short month names for the Islamic calendar (e.g. `Raj.`)
72
+ * @param {Array<string>} [settings.mmmm]
73
+ * Long month names for the Gregorian calendar (e.g. `November`)
74
+ * @param {Array<string>} [settings.mmm]
75
+ * Short month names for the Gregorian calendar (e.g. `Nov`)
76
+ * @param {Array<string>} [settings.dddd]
77
+ * Long day names (e.g. `Wednesday`)
78
+ * @param {Array<string>} [settings.ddd]
79
+ * Shortened day names (e.g. `Wed`)
80
+ * @param {Array<string>} [settings.bool]
81
+ * How TRUE and FALSE should be presented.
82
+ * @param {boolean} [settings.preferMDY]
83
+ * Is the prefered date format month first (12/31/2025) or day first (31/12/2025)
84
+ * @param {string | LocaleToken} locale - A string BCP 47 tag or parsed locale token.
85
+ * @returns {LocaleData} - A full collection of settings for a locale
86
+ */
87
+ export declare function addLocale(settings: LocaleSettings, locale: string | LocaleToken): LocaleData;
88
+ export declare function listLocales(): string[];
89
+ export declare const defaultLocale: LocaleData;
@@ -0,0 +1,17 @@
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
+ import type { NumberDigits } from './types';
17
+ export declare function numDec(value: number, includeSign?: boolean): NumberDigits;
@@ -0,0 +1,17 @@
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
+ export declare function getExponent(number: number, intMax?: number): number;
17
+ export declare function getSignificand(number: number, exponent?: number): number;
@@ -0,0 +1,17 @@
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
+ import type { ResolvedFormatOptions } from './types';
17
+ export declare const defaultOptions: Readonly<ResolvedFormatOptions>;
@@ -0,0 +1,22 @@
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
+ /**
17
+ * @ignore
18
+ * @param {string} char Instruction character (['#', '?', '0'])
19
+ * @param {boolean} [nbsp] Use nonbreaking space or not?
20
+ * @returns {string} Padding character
21
+ */
22
+ export declare function pad(char: string, nbsp?: boolean): string;
@@ -0,0 +1,17 @@
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
+ import type { FormatToken, ParsedFormatSection } from './types';
17
+ export declare function parseFormatSection(inputTokens: FormatToken[]): ParsedFormatSection;
@@ -0,0 +1,18 @@
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
+ import type { ParsedPattern } from './types';
17
+ export declare function parsePattern(pattern: string): ParsedPattern;
18
+ export declare function parseCatch(pattern: string): ParsedPattern;
@@ -0,0 +1,30 @@
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
+ import type { ParseData } from './types';
17
+ export interface ParseOptions {
18
+ locale?: string;
19
+ }
20
+ /** Parse a numeric string and return its value and inferred format. */
21
+ export declare function parseNumber(value: string, options?: ParseOptions): ParseData<number> | null;
22
+ export declare function isValidDate(year: number, month: number, day: number): boolean;
23
+ /** Parse a date or datetime string and return its serial value and format. */
24
+ export declare function parseDate(value: string, options?: ParseOptions): ParseData<number> | null;
25
+ /** Parse a time string and return its day fraction and inferred format. */
26
+ export declare function parseTime(value: string, options?: ParseOptions): ParseData<number> | null;
27
+ /** Parse a localized or English boolean string. */
28
+ export declare function parseBool(value: string, options?: ParseOptions): ParseData<boolean> | null;
29
+ /** Parse a spreadsheet input as a number, date, time, or boolean. */
30
+ export declare function parseValue(value: string, options?: ParseOptions): ParseData | null;
@@ -0,0 +1,26 @@
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
+ /**
17
+ * Return a number rounded to the specified amount of places. This is the
18
+ * rounding function used internally by the formatter (symmetric arithmetic
19
+ * rounding).
20
+ *
21
+ * @param {number} number - The number to round.
22
+ * @param {number} [places] - The number of decimals to round to.
23
+ * @returns {number} A rounded number.
24
+ */
25
+ export declare function round(number: number, places?: number): number;
26
+ export declare function round(number: unknown, places?: number): unknown;
@@ -0,0 +1,18 @@
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
+ import type { IDecimalValue } from './decimal';
17
+ import type { FormatSection, LocaleData, ResolvedFormatOptions } from './types';
18
+ export declare function runPart(value: unknown, part: FormatSection, options: ResolvedFormatOptions, locale?: LocaleData | null, decimalValue?: IDecimalValue | null): string;
@@ -0,0 +1,32 @@
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
+ import type { DateTimeParts } from './types';
17
+ /**
18
+ * Convert a native JavaScript Date, or array to a spreadsheet serial date.
19
+ *
20
+ * Returns a serial date number if input was a Date object or an array of
21
+ * numbers, or null.
22
+ */
23
+ export declare function dateToSerial(date: unknown, options?: {
24
+ ignoreTimezone?: boolean;
25
+ }): number | null;
26
+ /**
27
+ * Convert a spreadsheet serial date to an array of date parts, accurate to a
28
+ * second.
29
+ */
30
+ export declare function dateFromSerial(serial: number, options?: {
31
+ leap1900?: boolean;
32
+ }): DateTimeParts;
@@ -0,0 +1,20 @@
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
+ import type { DateParts } from './types';
17
+ export declare function toYMD1900(serial: number, leap1900?: boolean): DateParts;
18
+ export declare function toYMD1904(serial: number): DateParts;
19
+ export declare function toYMD1317(serial: number): DateParts;
20
+ export declare function toYMD(serial: number, system?: number, leap1900?: boolean): DateParts;
@@ -0,0 +1,20 @@
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
+ import type { FormatToken } from './types';
17
+ /**
18
+ * Breaks a format pattern string into a list of tokens.
19
+ */
20
+ export declare function tokenize(pattern: string): FormatToken[];