@univerjs/core 1.0.0-alpha.3 → 1.0.0-alpha.5
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 +3899 -92
- package/lib/es/index.js +3902 -93
- package/lib/index.js +3902 -93
- package/lib/types/docs/data-model/index.d.ts +2 -1
- package/lib/types/docs/data-model/rich-text-builder.d.ts +186 -0
- package/lib/types/docs/data-model/text-x/build-utils/drawings.d.ts +2 -2
- package/lib/types/docs/data-model/text-x/build-utils/index.d.ts +1 -0
- package/lib/types/shared/numfmt/api.d.ts +82 -0
- package/lib/types/shared/numfmt/clamp.d.ts +16 -0
- package/lib/types/shared/numfmt/code-to-locale.d.ts +16 -0
- package/lib/types/shared/numfmt/constants.d.ts +68 -0
- package/lib/types/shared/numfmt/dec-to-frac.d.ts +26 -0
- package/lib/types/shared/numfmt/decimal.d.ts +37 -0
- package/lib/types/shared/numfmt/format-info.d.ts +21 -0
- package/lib/types/shared/numfmt/format-number.d.ts +18 -0
- package/lib/types/shared/numfmt/general.d.ts +18 -0
- package/lib/types/shared/numfmt/index.d.ts +18 -0
- package/lib/types/shared/numfmt/locale.d.ts +89 -0
- package/lib/types/shared/numfmt/num-dec.d.ts +17 -0
- package/lib/types/shared/numfmt/number-props.d.ts +17 -0
- package/lib/types/shared/numfmt/options.d.ts +17 -0
- package/lib/types/shared/numfmt/pad.d.ts +22 -0
- package/lib/types/shared/numfmt/parse-format-section.d.ts +17 -0
- package/lib/types/shared/numfmt/parse-pattern.d.ts +18 -0
- package/lib/types/shared/numfmt/parse-value.d.ts +30 -0
- package/lib/types/shared/numfmt/round.d.ts +26 -0
- package/lib/types/shared/numfmt/run-part.d.ts +18 -0
- package/lib/types/shared/numfmt/serial-date.d.ts +32 -0
- package/lib/types/shared/numfmt/to-ymd.d.ts +20 -0
- package/lib/types/shared/numfmt/tokenize.d.ts +20 -0
- package/lib/types/shared/numfmt/types.d.ts +193 -0
- package/lib/types/shared/{numfmt.d.ts → numfmt/utils.d.ts} +3 -4
- package/lib/types/types/interfaces/i-document-data.d.ts +4 -0
- package/lib/types/types/interfaces/i-style-data.d.ts +3 -1
- package/lib/umd/index.js +21 -19
- package/package.json +4 -5
|
@@ -21,7 +21,8 @@ export { resolveDocumentParagraphStyle } from './paragraph-style';
|
|
|
21
21
|
export type { IResolveDocumentParagraphStyleOptions } from './paragraph-style';
|
|
22
22
|
export * from './preset-list-type';
|
|
23
23
|
export { replaceInDocumentBody } from './replacement';
|
|
24
|
-
export { ParagraphStyleBuilder, ParagraphStyleValue, RichTextBuilder, RichTextValue, TextDecorationBuilder, TextStyleBuilder, TextStyleValue, } from './rich-text-builder';
|
|
24
|
+
export { ParagraphStyleBuilder, ParagraphStyleValue, RichTextBuilder, RichTextParagraphBuilder, RichTextRunBuilder, RichTextValue, TextDecorationBuilder, TextStyleBuilder, TextStyleValue, } from './rich-text-builder';
|
|
25
|
+
export type { IRichTextColumnsOptions, IRichTextRange } from './rich-text-builder';
|
|
25
26
|
export { DEFAULT_DOCUMENT_SUB_COMPONENT_ID } from './subdocument';
|
|
26
27
|
export { ActionIterator } from './text-x/action-iterator';
|
|
27
28
|
export { PRESERVE_INSERTED_PARAGRAPH_IDS, TextXActionType } from './text-x/action-types';
|
|
@@ -18,6 +18,14 @@ import type { BaselineOffset, HorizontalAlign, TextDecoration, TextDirection, Ve
|
|
|
18
18
|
import type { IBorderData, IColorStyle, IDocumentBody, IDocumentData, INumberUnit, IParagraphBorder, IParagraphStyle, IShading, ITabStop, ITextDecoration, ITextStyle, NamedStyleType, SpacingRule } from '../../types/interfaces';
|
|
19
19
|
import { BooleanNumber } from '../../types/enum';
|
|
20
20
|
import { PresetListType } from './preset-list-type';
|
|
21
|
+
/** A half-open range in a rich-text document data stream. */
|
|
22
|
+
export interface IRichTextRange {
|
|
23
|
+
/** Inclusive offset of the first character. */
|
|
24
|
+
startOffset: number;
|
|
25
|
+
/** Exclusive offset immediately after the last character. */
|
|
26
|
+
endOffset: number;
|
|
27
|
+
}
|
|
28
|
+
type IMutableRichTextRange = IRichTextRange;
|
|
21
29
|
export declare function normalizeBody(body: IDocumentBody): IDocumentBody;
|
|
22
30
|
export declare function normalizeData(data: IDocumentData): IDocumentData;
|
|
23
31
|
/**
|
|
@@ -123,6 +131,12 @@ export interface IRichTextAlignment {
|
|
|
123
131
|
/** Vertical alignment inside the host text container. */
|
|
124
132
|
vertical?: VerticalAlign;
|
|
125
133
|
}
|
|
134
|
+
export interface IRichTextColumnsOptions {
|
|
135
|
+
/** Number of text-flow columns. Use 1 to clear multi-column layout. */
|
|
136
|
+
count: number;
|
|
137
|
+
/** Spacing between columns in px. Defaults to 0. */
|
|
138
|
+
spacing?: number;
|
|
139
|
+
}
|
|
126
140
|
/**
|
|
127
141
|
* Agent-friendly options for one paragraph list item.
|
|
128
142
|
*
|
|
@@ -1360,7 +1374,48 @@ export declare class RichTextBuilder extends RichTextValue {
|
|
|
1360
1374
|
*/
|
|
1361
1375
|
static create(data?: IDocumentData): RichTextBuilder;
|
|
1362
1376
|
private _doc;
|
|
1377
|
+
private readonly _trackedRanges;
|
|
1363
1378
|
constructor(data: IDocumentData);
|
|
1379
|
+
/**
|
|
1380
|
+
* Returns editable paragraph handles backed by this detached rich-text builder.
|
|
1381
|
+
*
|
|
1382
|
+
* Paragraph boundaries come from the document model rather than splitting plain text. Each handle stays aligned
|
|
1383
|
+
* when text in this builder grows or shrinks, so callers can safely iterate from the first paragraph to the last.
|
|
1384
|
+
*
|
|
1385
|
+
* @returns Editable paragraphs in document order.
|
|
1386
|
+
* @example
|
|
1387
|
+
* ```ts
|
|
1388
|
+
* const richText = univerAPI.newRichText()
|
|
1389
|
+
* .text('Quarterly Review')
|
|
1390
|
+
* .paragraph()
|
|
1391
|
+
* .text('Revenue increased by 18%.');
|
|
1392
|
+
* for (const paragraph of richText.getParagraphs()) {
|
|
1393
|
+
* console.log(paragraph.getText());
|
|
1394
|
+
* }
|
|
1395
|
+
* ```
|
|
1396
|
+
*/
|
|
1397
|
+
getParagraphs(): RichTextParagraphBuilder[];
|
|
1398
|
+
/**
|
|
1399
|
+
* Returns editable text-run handles for all paragraph text in this builder.
|
|
1400
|
+
*
|
|
1401
|
+
* Unlike the read-only value API, this method also returns unstyled gaps. Paragraph and section markers are never
|
|
1402
|
+
* exposed as text runs. Prefer `getParagraphs()` when paragraph context matters.
|
|
1403
|
+
*
|
|
1404
|
+
* @returns Editable text runs in document order.
|
|
1405
|
+
* @example
|
|
1406
|
+
* ```ts
|
|
1407
|
+
* const richText = univerAPI.newRichText()
|
|
1408
|
+
* .text('Status: ')
|
|
1409
|
+
* .span('Ready', { bold: true, color: '#16a34a' });
|
|
1410
|
+
* for (const run of richText.getTextRuns()) {
|
|
1411
|
+
* console.log(run.getText(), run.getTextStyle()?.getValue());
|
|
1412
|
+
* }
|
|
1413
|
+
* ```
|
|
1414
|
+
*/
|
|
1415
|
+
getTextRuns(): RichTextRunBuilder[];
|
|
1416
|
+
private _createParagraphBuilder;
|
|
1417
|
+
private _trackRange;
|
|
1418
|
+
private _rebaseTrackedRanges;
|
|
1364
1419
|
/**
|
|
1365
1420
|
* Appends plain text to the rich text.
|
|
1366
1421
|
*
|
|
@@ -1399,6 +1454,38 @@ export declare class RichTextBuilder extends RichTextValue {
|
|
|
1399
1454
|
* ```
|
|
1400
1455
|
*/
|
|
1401
1456
|
align(alignment: IRichTextAlignment): RichTextBuilder;
|
|
1457
|
+
/**
|
|
1458
|
+
* Sets the column layout for this rich-text document.
|
|
1459
|
+
*
|
|
1460
|
+
* Columns are stored in the rich-text document section layout. This creates text-flow columns, not table columns.
|
|
1461
|
+
* The host renderer must support rich-text columns for the layout to be visible.
|
|
1462
|
+
*
|
|
1463
|
+
* @param options The column layout options.
|
|
1464
|
+
* @param options.count The number of text columns. Must be a positive integer. Use `1` to clear multi-column layout.
|
|
1465
|
+
* @param options.spacing The spacing between columns, in px. Defaults to `0`.
|
|
1466
|
+
* @returns The current builder for chaining.
|
|
1467
|
+
*
|
|
1468
|
+
* @example
|
|
1469
|
+
* ```ts
|
|
1470
|
+
* const presentation = univerAPI.getActivePresentation();
|
|
1471
|
+
* if (!presentation) throw new Error('No active presentation');
|
|
1472
|
+
*
|
|
1473
|
+
* const slide = presentation.getSlideByIndex(0);
|
|
1474
|
+
* if (!slide) throw new Error('The presentation has no slides');
|
|
1475
|
+
* const richText = univerAPI.newRichText()
|
|
1476
|
+
* .columns({ count: 2, spacing: 12 })
|
|
1477
|
+
* .text('Column text');
|
|
1478
|
+
*
|
|
1479
|
+
* const shapeInfo = slide.newShape()
|
|
1480
|
+
* .setRichText(richText)
|
|
1481
|
+
* .setAbsolutePosition(80, 80)
|
|
1482
|
+
* .setSize(360, 160)
|
|
1483
|
+
* .build();
|
|
1484
|
+
*
|
|
1485
|
+
* slide.insertShape(shapeInfo);
|
|
1486
|
+
* ```
|
|
1487
|
+
*/
|
|
1488
|
+
columns(options: IRichTextColumnsOptions): RichTextBuilder;
|
|
1402
1489
|
/**
|
|
1403
1490
|
* Appends one text span with explicit style.
|
|
1404
1491
|
*
|
|
@@ -1676,3 +1763,102 @@ export declare class RichTextBuilder extends RichTextValue {
|
|
|
1676
1763
|
insertLink(text: string, url: string): RichTextBuilder;
|
|
1677
1764
|
insertLink(start: number, text: string, url: string): RichTextBuilder;
|
|
1678
1765
|
}
|
|
1766
|
+
/**
|
|
1767
|
+
* An editable paragraph handle owned by a detached {@link RichTextBuilder}.
|
|
1768
|
+
*
|
|
1769
|
+
* The paragraph is resolved by its persisted paragraph id, while its tracked range is rebased after every run edit.
|
|
1770
|
+
* This keeps paragraph traversal safe when earlier translated text becomes longer or shorter.
|
|
1771
|
+
*/
|
|
1772
|
+
export declare class RichTextParagraphBuilder extends RichTextValue {
|
|
1773
|
+
private readonly _owner;
|
|
1774
|
+
private readonly _paragraphId;
|
|
1775
|
+
private readonly _range;
|
|
1776
|
+
/** @hideconstructor */
|
|
1777
|
+
constructor(_owner: RichTextBuilder, _paragraphId: string, _range: IMutableRichTextRange);
|
|
1778
|
+
/** Returns the persisted paragraph id. */
|
|
1779
|
+
getId(): string;
|
|
1780
|
+
/** Returns the current paragraph range without its trailing paragraph marker. */
|
|
1781
|
+
getRange(): IRichTextRange;
|
|
1782
|
+
/**
|
|
1783
|
+
* Returns the current paragraph text without its trailing paragraph marker.
|
|
1784
|
+
* @example
|
|
1785
|
+
* ```ts
|
|
1786
|
+
* const richText = univerAPI.newRichText().text('Quarterly Review');
|
|
1787
|
+
* const paragraph = richText.getParagraphs()[0];
|
|
1788
|
+
* console.log(paragraph.getText());
|
|
1789
|
+
* ```
|
|
1790
|
+
*/
|
|
1791
|
+
getText(): string;
|
|
1792
|
+
toPlainText(): string;
|
|
1793
|
+
/**
|
|
1794
|
+
* Returns editable runs that cover all text in this paragraph, including unstyled gaps.
|
|
1795
|
+
* @returns Editable text runs in document order.
|
|
1796
|
+
*/
|
|
1797
|
+
getTextRuns(): RichTextRunBuilder[];
|
|
1798
|
+
getParagraphStyle(): ParagraphStyleValue;
|
|
1799
|
+
getParagraphBullet(): import("../..").IBullet | undefined;
|
|
1800
|
+
getLinks(): import("../..").ICustomRange<Record<string, any>>[];
|
|
1801
|
+
/** Agent-friendly alias of `getParagraphBullet()`. */
|
|
1802
|
+
getBullet(): import("../..").IBullet | undefined;
|
|
1803
|
+
getData(): IDocumentData;
|
|
1804
|
+
copy(): RichTextBuilder;
|
|
1805
|
+
private _getParagraph;
|
|
1806
|
+
}
|
|
1807
|
+
/**
|
|
1808
|
+
* An editable text-run handle owned by a detached {@link RichTextBuilder}.
|
|
1809
|
+
*
|
|
1810
|
+
* Calling {@link setText} replaces only the run text. The builder automatically updates this run, every later run,
|
|
1811
|
+
* paragraph indexes, hyperlinks, decorations, and other offset-based document metadata through TextX.
|
|
1812
|
+
*/
|
|
1813
|
+
export declare class RichTextRunBuilder {
|
|
1814
|
+
private readonly _owner;
|
|
1815
|
+
private readonly _range;
|
|
1816
|
+
private readonly _textStyle;
|
|
1817
|
+
private readonly _styleId;
|
|
1818
|
+
private readonly _hasExplicitTextStyle;
|
|
1819
|
+
private _active;
|
|
1820
|
+
/** @hideconstructor */
|
|
1821
|
+
constructor(_owner: RichTextBuilder, _range: IMutableRichTextRange, _textStyle: ITextStyle | undefined, _styleId: string | undefined, _hasExplicitTextStyle: boolean);
|
|
1822
|
+
/** Inclusive start offset, kept for compatibility with existing `getTextRuns()` callers. */
|
|
1823
|
+
get st(): number;
|
|
1824
|
+
/** Exclusive end offset, automatically updated after text replacement. */
|
|
1825
|
+
get ed(): number;
|
|
1826
|
+
/** Optional persisted style id. This is not a stable run identity. */
|
|
1827
|
+
get sId(): string | undefined;
|
|
1828
|
+
/** Existing text-style value property exposed by `getTextRuns()`. */
|
|
1829
|
+
get ts(): TextStyleValue | null;
|
|
1830
|
+
/** Returns the current run range. */
|
|
1831
|
+
getRange(): IRichTextRange;
|
|
1832
|
+
/** Returns the current run text. */
|
|
1833
|
+
getText(): string;
|
|
1834
|
+
/** Returns this run's explicit text style, or `null` for an unstyled text segment. */
|
|
1835
|
+
getTextStyle(): TextStyleValue | null;
|
|
1836
|
+
/** Returns whether this segment is backed by an explicit document text run. */
|
|
1837
|
+
hasTextStyle(): boolean;
|
|
1838
|
+
/**
|
|
1839
|
+
* Replaces this run's text without changing its style or paragraph structure.
|
|
1840
|
+
*
|
|
1841
|
+
* Replacement text may be longer or shorter than the original. Offsets are updated automatically, so handles
|
|
1842
|
+
* returned in the same `getTextRuns()` call remain safe to use in forward order. Paragraph and section breaks are
|
|
1843
|
+
* rejected because a text run cannot create or remove paragraphs.
|
|
1844
|
+
*
|
|
1845
|
+
* @param text New text for this run.
|
|
1846
|
+
* @returns This run handle for chaining. A handle becomes invalid after it is replaced with an empty string.
|
|
1847
|
+
* @example
|
|
1848
|
+
* ```ts
|
|
1849
|
+
* const richText = univerAPI.newRichText()
|
|
1850
|
+
* .span('标题', { bold: true, fontSize: 24 })
|
|
1851
|
+
* .paragraph()
|
|
1852
|
+
* .text('正文内容');
|
|
1853
|
+
* const replacements = ['Quarterly Review', 'Revenue increased by 18%.'];
|
|
1854
|
+
* let index = 0;
|
|
1855
|
+
* for (const run of richText.getTextRuns()) {
|
|
1856
|
+
* const replacement = replacements[index++];
|
|
1857
|
+
* if (replacement !== undefined) run.setText(replacement);
|
|
1858
|
+
* }
|
|
1859
|
+
* console.log(richText.toPlainText());
|
|
1860
|
+
* ```
|
|
1861
|
+
*/
|
|
1862
|
+
setText(text: string): this;
|
|
1863
|
+
}
|
|
1864
|
+
export {};
|
|
@@ -14,13 +14,13 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import type { ITextRange, ITextRangeParam } from '../../../../sheets/typedef';
|
|
17
|
-
import type { IDocumentBody } from '../../../../types/interfaces';
|
|
17
|
+
import type { IDocumentBody, IDrawingParam } from '../../../../types/interfaces';
|
|
18
18
|
import type { DocumentDataModel } from '../../document-data-model';
|
|
19
19
|
import type { JSONXActions } from '../../json-x/json-x';
|
|
20
20
|
export interface IAddDrawingParam {
|
|
21
21
|
selection: ITextRangeParam;
|
|
22
22
|
documentDataModel: DocumentDataModel;
|
|
23
|
-
drawings:
|
|
23
|
+
drawings: IDrawingParam[];
|
|
24
24
|
}
|
|
25
25
|
export declare function getCustomBlockIdsInSelections(body: IDocumentBody, selections: ITextRange[]): string[];
|
|
26
26
|
export declare const addDrawing: (param: IAddDrawingParam) => false | JSONXActions;
|
|
@@ -69,6 +69,7 @@ export declare class BuildTextUtils {
|
|
|
69
69
|
}
|
|
70
70
|
export { getSingleDataStreamChange } from './data-stream-change';
|
|
71
71
|
export type { IDataStreamChange } from './data-stream-change';
|
|
72
|
+
export { getCustomBlockIdsInSelections } from './drawings';
|
|
72
73
|
export { getParagraphContentStartOffset, getParagraphContentStartOffsets, getParagraphFollowingBlockOffset } from './paragraph';
|
|
73
74
|
export { containsInteriorInsertionOffset, containsStreamIndex, getBlockRangeInterval, getColumnGroupRangeInterval, getCustomBlockInterval, getCustomRangeInterval, getExclusiveRangeInterval, getInclusiveRangeInterval, getTableCellTokenInterval, getTableRangeInterval, getTableRowTokenInterval, intersectsOperationalIntervals, shiftExclusiveRangeOnDelete, shiftExclusiveRangeOnInsert, shiftInclusiveRangeOnDelete, shiftInclusiveRangeOnInsert, } from './range-interval';
|
|
74
75
|
export type { IDocOperationalInterval } from './range-interval';
|
|
@@ -0,0 +1,82 @@
|
|
|
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, FormatDateInfo, FormatInfo, FormatOptions } from './types';
|
|
17
|
+
export { dec2frac } from './dec-to-frac';
|
|
18
|
+
export { addLocale, getLocale, parseLocale } from './locale';
|
|
19
|
+
export { parseBool, parseDate, parseNumber, parseTime, parseValue } from './parse-value';
|
|
20
|
+
export { round } from './round';
|
|
21
|
+
export { dateFromSerial, dateToSerial } from './serial-date';
|
|
22
|
+
export { tokenize } from './tokenize';
|
|
23
|
+
export type { FormatDateInfo, FormatInfo, FormatToken, LocaleData, LocaleToken, ParseData, } from './types';
|
|
24
|
+
/**
|
|
25
|
+
* Formats a value as a string and returns the result.
|
|
26
|
+
*/
|
|
27
|
+
export declare function format(pattern: string, value: unknown, options?: FormatOptions): string;
|
|
28
|
+
/**
|
|
29
|
+
* Find the color appropriate to a value as dictated by a format pattern.
|
|
30
|
+
*/
|
|
31
|
+
export declare function formatColor(pattern: string, value: unknown, options?: FormatOptions): FormatColor;
|
|
32
|
+
/** Determine if a given format pattern is a date pattern. */
|
|
33
|
+
export declare function isDateFormat(pattern: string): boolean;
|
|
34
|
+
/** Determine if a given format pattern is a percentage pattern. */
|
|
35
|
+
export declare function isPercentFormat(pattern: string): boolean;
|
|
36
|
+
/** Determine if a given format pattern is a text only pattern. */
|
|
37
|
+
export declare function isTextFormat(pattern: string): boolean;
|
|
38
|
+
/** Determine if a given format pattern is valid. */
|
|
39
|
+
export declare function isValidFormat(pattern: string): boolean;
|
|
40
|
+
/** Returns metadata describing a parsed format pattern. */
|
|
41
|
+
export declare function getFormatInfo(pattern: string, options?: {
|
|
42
|
+
currency?: string;
|
|
43
|
+
}): FormatInfo;
|
|
44
|
+
/** Gets information about date codes used in a format string. */
|
|
45
|
+
export declare function getFormatDateInfo(pattern: string): FormatDateInfo;
|
|
46
|
+
/** A dictionary of the types used to identify token variants. */
|
|
47
|
+
export declare const tokenTypes: Readonly<{
|
|
48
|
+
AMPM: "ampm";
|
|
49
|
+
BREAK: "break";
|
|
50
|
+
CALENDAR: "calendar";
|
|
51
|
+
CHAR: "char";
|
|
52
|
+
COLOR: "color";
|
|
53
|
+
COMMA: "comma";
|
|
54
|
+
CONDITION: "condition";
|
|
55
|
+
DATETIME: "datetime";
|
|
56
|
+
DBNUM: "dbnum";
|
|
57
|
+
DIGIT: "digit";
|
|
58
|
+
DURATION: "duration";
|
|
59
|
+
ERROR: "error";
|
|
60
|
+
ESCAPED: "escaped";
|
|
61
|
+
EXP: "exp";
|
|
62
|
+
FILL: "fill";
|
|
63
|
+
GENERAL: "general";
|
|
64
|
+
GROUP: "group";
|
|
65
|
+
HASH: "hash";
|
|
66
|
+
LOCALE: "locale";
|
|
67
|
+
MINUS: "minus";
|
|
68
|
+
MODIFIER: "modifier";
|
|
69
|
+
NATNUM: "natnum";
|
|
70
|
+
PAREN: "paren";
|
|
71
|
+
PERCENT: "percent";
|
|
72
|
+
PLUS: "plus";
|
|
73
|
+
POINT: "point";
|
|
74
|
+
QMARK: "qmark";
|
|
75
|
+
SCALE: "scale";
|
|
76
|
+
SKIP: "skip";
|
|
77
|
+
SLASH: "slash";
|
|
78
|
+
SPACE: "space";
|
|
79
|
+
STRING: "string";
|
|
80
|
+
TEXT: "text";
|
|
81
|
+
ZERO: "zero";
|
|
82
|
+
}>;
|
|
@@ -0,0 +1,16 @@
|
|
|
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 clamp(number: number): number;
|
|
@@ -0,0 +1,16 @@
|
|
|
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 codeToLocale: Readonly<Record<number, string>>;
|
|
@@ -0,0 +1,68 @@
|
|
|
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 u_YEAR = 2;
|
|
17
|
+
export declare const u_MONTH: number;
|
|
18
|
+
export declare const u_DAY: number;
|
|
19
|
+
export declare const u_HOUR: number;
|
|
20
|
+
export declare const u_MIN: number;
|
|
21
|
+
export declare const u_SEC: number;
|
|
22
|
+
export declare const u_DSEC: number;
|
|
23
|
+
export declare const u_CSEC: number;
|
|
24
|
+
export declare const u_MSEC: number;
|
|
25
|
+
export declare const MIN_S_DATE = 0;
|
|
26
|
+
export declare const MAX_S_DATE = 2958466;
|
|
27
|
+
export declare const MIN_L_DATE = -694324;
|
|
28
|
+
export declare const MAX_L_DATE = 35830291;
|
|
29
|
+
export declare const EPOCH_1904 = -1;
|
|
30
|
+
export declare const EPOCH_1900 = 1;
|
|
31
|
+
export declare const EPOCH_1317 = 6;
|
|
32
|
+
export declare const TOKEN_GENERAL = "general";
|
|
33
|
+
export declare const TOKEN_HASH = "hash";
|
|
34
|
+
export declare const TOKEN_ZERO = "zero";
|
|
35
|
+
export declare const TOKEN_QMARK = "qmark";
|
|
36
|
+
export declare const TOKEN_SLASH = "slash";
|
|
37
|
+
export declare const TOKEN_GROUP = "group";
|
|
38
|
+
export declare const TOKEN_SCALE = "scale";
|
|
39
|
+
export declare const TOKEN_COMMA = "comma";
|
|
40
|
+
export declare const TOKEN_BREAK = "break";
|
|
41
|
+
export declare const TOKEN_TEXT = "text";
|
|
42
|
+
export declare const TOKEN_PLUS = "plus";
|
|
43
|
+
export declare const TOKEN_MINUS = "minus";
|
|
44
|
+
export declare const TOKEN_POINT = "point";
|
|
45
|
+
export declare const TOKEN_SPACE = "space";
|
|
46
|
+
export declare const TOKEN_PERCENT = "percent";
|
|
47
|
+
export declare const TOKEN_DIGIT = "digit";
|
|
48
|
+
export declare const TOKEN_CALENDAR = "calendar";
|
|
49
|
+
export declare const TOKEN_ERROR = "error";
|
|
50
|
+
export declare const TOKEN_DATETIME = "datetime";
|
|
51
|
+
export declare const TOKEN_DURATION = "duration";
|
|
52
|
+
export declare const TOKEN_CONDITION = "condition";
|
|
53
|
+
export declare const TOKEN_DBNUM = "dbnum";
|
|
54
|
+
export declare const TOKEN_NATNUM = "natnum";
|
|
55
|
+
export declare const TOKEN_LOCALE = "locale";
|
|
56
|
+
export declare const TOKEN_COLOR = "color";
|
|
57
|
+
export declare const TOKEN_MODIFIER = "modifier";
|
|
58
|
+
export declare const TOKEN_AMPM = "ampm";
|
|
59
|
+
export declare const TOKEN_ESCAPED = "escaped";
|
|
60
|
+
export declare const TOKEN_STRING = "string";
|
|
61
|
+
export declare const TOKEN_SKIP = "skip";
|
|
62
|
+
export declare const TOKEN_EXP = "exp";
|
|
63
|
+
export declare const TOKEN_FILL = "fill";
|
|
64
|
+
export declare const TOKEN_PAREN = "paren";
|
|
65
|
+
export declare const TOKEN_CHAR = "char";
|
|
66
|
+
export declare const indexColors: string[];
|
|
67
|
+
export declare const currencySymbols: string[];
|
|
68
|
+
export declare const reCurrencySymbols: RegExp;
|
|
@@ -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';
|