@univerjs/preset-docs-drawing 1.0.0-alpha.3 → 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.
- package/lib/cjs/index.js +297 -273
- package/lib/es/index.js +297 -273
- package/lib/index.js +297 -273
- package/lib/types/preset.d.ts +2 -0
- package/package.json +8 -8
package/lib/cjs/index.js
CHANGED
|
@@ -6,6 +6,7 @@ let _univerjs_docs_drawing = require("@univerjs/docs-drawing");
|
|
|
6
6
|
let _univerjs_docs_drawing_ui = require("@univerjs/docs-drawing-ui");
|
|
7
7
|
let _univerjs_drawing = require("@univerjs/drawing");
|
|
8
8
|
let _univerjs_drawing_ui = require("@univerjs/drawing-ui");
|
|
9
|
+
require("@univerjs/docs-drawing/facade");
|
|
9
10
|
|
|
10
11
|
//#region ../../../packages/core/src/common/shims.ts
|
|
11
12
|
/**
|
|
@@ -871,7 +872,7 @@ function composeStyles(...styles) {
|
|
|
871
872
|
//#endregion
|
|
872
873
|
//#region ../../../packages/core/package.json
|
|
873
874
|
var name = "@univerjs/core";
|
|
874
|
-
var version = "1.0.0-alpha.
|
|
875
|
+
var version = "1.0.0-alpha.4";
|
|
875
876
|
|
|
876
877
|
//#endregion
|
|
877
878
|
//#region ../../../packages/core/src/common/array.ts
|
|
@@ -6122,7 +6123,7 @@ const THEME_COLORS = { ["Office"]: {
|
|
|
6122
6123
|
} };
|
|
6123
6124
|
|
|
6124
6125
|
//#endregion
|
|
6125
|
-
//#region ../../../
|
|
6126
|
+
//#region ../../../packages/core/src/shared/numfmt/constants.ts
|
|
6126
6127
|
const TOKEN_GENERAL = "general";
|
|
6127
6128
|
const TOKEN_HASH = "hash";
|
|
6128
6129
|
const TOKEN_ZERO = "zero";
|
|
@@ -6185,11 +6186,26 @@ const currencySymbols$1 = [
|
|
|
6185
6186
|
"₾",
|
|
6186
6187
|
"₿"
|
|
6187
6188
|
];
|
|
6188
|
-
const reCurrencySymbols = new RegExp(
|
|
6189
|
+
const reCurrencySymbols = new RegExp(`[${currencySymbols$1.join("")}]`);
|
|
6189
6190
|
|
|
6190
6191
|
//#endregion
|
|
6191
|
-
//#region ../../../
|
|
6192
|
-
|
|
6192
|
+
//#region ../../../packages/core/src/shared/numfmt/code-to-locale.ts
|
|
6193
|
+
/**
|
|
6194
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
6195
|
+
*
|
|
6196
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6197
|
+
* you may not use this file except in compliance with the License.
|
|
6198
|
+
* You may obtain a copy of the License at
|
|
6199
|
+
*
|
|
6200
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
6201
|
+
*
|
|
6202
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
6203
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
6204
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
6205
|
+
* See the License for the specific language governing permissions and
|
|
6206
|
+
* limitations under the License.
|
|
6207
|
+
*/
|
|
6208
|
+
const codeToLocale = Object.freeze({
|
|
6193
6209
|
1078: "af",
|
|
6194
6210
|
1052: "sq",
|
|
6195
6211
|
1118: "am",
|
|
@@ -6379,34 +6395,17 @@ var codeToLocale_default = Object.freeze({
|
|
|
6379
6395
|
});
|
|
6380
6396
|
|
|
6381
6397
|
//#endregion
|
|
6382
|
-
//#region ../../../
|
|
6398
|
+
//#region ../../../packages/core/src/shared/numfmt/locale.ts
|
|
6383
6399
|
const re_locale = /^([a-z\d]+)(?:[_-]([a-z\d]+))?(?:\.([a-z\d]+))?(?:@([a-z\d]+))?$/i;
|
|
6384
6400
|
const locales = {};
|
|
6385
6401
|
/**
|
|
6386
6402
|
* Split a semicolon delimited string and replace instances of characters
|
|
6387
6403
|
* @ignore
|
|
6388
6404
|
* @param {string} str Semicolon delimited string
|
|
6389
|
-
* @param {string} [tilde
|
|
6405
|
+
* @param {string} [tilde] String to be inserted on every instance of ~
|
|
6390
6406
|
* @returns {string[]} Array of strings
|
|
6391
6407
|
*/
|
|
6392
6408
|
const _ = (str, tilde = "") => str.replace(/~/g, tilde).split(";");
|
|
6393
|
-
/**
|
|
6394
|
-
* Generate mmm and ddd properties as needed for locales. Many of them
|
|
6395
|
-
* are straightforward abreviations of mmmm and dddd so we can save some
|
|
6396
|
-
* bytes by auto-generating them.
|
|
6397
|
-
*
|
|
6398
|
-
* Both rule parameters use the same system. If shortform prop is missing:
|
|
6399
|
-
*
|
|
6400
|
-
* - 0 - use long form array unchanged
|
|
6401
|
-
* - 1...9 - shorten to N many characters
|
|
6402
|
-
* - 11...19 - shorten to 1...9 characters and add periods
|
|
6403
|
-
*
|
|
6404
|
-
* @ignore
|
|
6405
|
-
* @param {object} o Locale object
|
|
6406
|
-
* @param {number} [ml=0] Month list rule
|
|
6407
|
-
* @param {number} [dl=0] Day list rule
|
|
6408
|
-
* @returns {object} The same input object, but with ddd and mmm filled in.
|
|
6409
|
-
*/
|
|
6410
6409
|
const xm = (o, ml = 0, dl = 0) => {
|
|
6411
6410
|
if (!o.mmm) o.mmm = ml < 1 ? o.mmmm.concat() : o.mmmm.map((d) => {
|
|
6412
6411
|
const s = d.slice(0, ml % 10);
|
|
@@ -6480,20 +6479,20 @@ function parseLocale(locale) {
|
|
|
6480
6479
|
const lm = re_locale.exec(locale);
|
|
6481
6480
|
if (!lm) throw new SyntaxError(`Malformed locale: ${locale}`);
|
|
6482
6481
|
return {
|
|
6483
|
-
lang: lm[1] + (lm[2] ?
|
|
6482
|
+
lang: lm[1] + (lm[2] ? `_${lm[2]}` : ""),
|
|
6484
6483
|
language: lm[1],
|
|
6485
6484
|
territory: lm[2] || ""
|
|
6486
6485
|
};
|
|
6487
6486
|
}
|
|
6488
|
-
function resolveLocale(
|
|
6489
|
-
if (typeof
|
|
6490
|
-
const wincode = parseInt(
|
|
6491
|
-
if (isFinite(wincode) &&
|
|
6492
|
-
if (re_locale.test(
|
|
6487
|
+
function resolveLocale(locale) {
|
|
6488
|
+
if (typeof locale === "number") return codeToLocale[locale & 65535] || null;
|
|
6489
|
+
const wincode = Number.parseInt(locale, 16);
|
|
6490
|
+
if (Number.isFinite(wincode) && codeToLocale[wincode & 65535]) return codeToLocale[wincode & 65535] || null;
|
|
6491
|
+
if (re_locale.test(locale)) return locale;
|
|
6493
6492
|
return null;
|
|
6494
6493
|
}
|
|
6495
|
-
function createLocale(
|
|
6496
|
-
return Object.assign({}, baseLocaleData,
|
|
6494
|
+
function createLocale(settings) {
|
|
6495
|
+
return Object.assign({}, baseLocaleData, settings);
|
|
6497
6496
|
}
|
|
6498
6497
|
/**
|
|
6499
6498
|
* Register locale data for a language so for use when formatting.
|
|
@@ -6501,48 +6500,48 @@ function createLocale(data) {
|
|
|
6501
6500
|
* Any partial set of properties may be returned to have the defaults used where properties are missing.
|
|
6502
6501
|
*
|
|
6503
6502
|
* @see {LocaleData}
|
|
6504
|
-
* @param {object}
|
|
6505
|
-
* @param {string} [
|
|
6503
|
+
* @param {object} settings - A collection of settings for a locale.
|
|
6504
|
+
* @param {string} [settings.group]
|
|
6506
6505
|
* Symbol used as a grouping separator (`1,000,000` uses `,`)
|
|
6507
|
-
* @param {string} [
|
|
6506
|
+
* @param {string} [settings.decimal]
|
|
6508
6507
|
* Symbol used to separate integers from fractions (usually `.`)
|
|
6509
|
-
* @param {string} [
|
|
6508
|
+
* @param {string} [settings.positive]
|
|
6510
6509
|
* Symbol used to indicate positive numbers (usually `+`)
|
|
6511
|
-
* @param {string} [
|
|
6510
|
+
* @param {string} [settings.negative]
|
|
6512
6511
|
* Symbol used to indicate positive numbers (usually `-`)
|
|
6513
|
-
* @param {string} [
|
|
6512
|
+
* @param {string} [settings.percent]
|
|
6514
6513
|
* Symbol used to indicate a percentage (usually `%`)
|
|
6515
|
-
* @param {string} [
|
|
6514
|
+
* @param {string} [settings.exponent]
|
|
6516
6515
|
* Symbol used to indicate an exponent (usually `E`)
|
|
6517
|
-
* @param {string} [
|
|
6516
|
+
* @param {string} [settings.nan]
|
|
6518
6517
|
* Symbol used to indicate NaN values (`NaN`)
|
|
6519
|
-
* @param {string} [
|
|
6518
|
+
* @param {string} [settings.infinity]
|
|
6520
6519
|
* Symbol used to indicate infinite values (`∞`)
|
|
6521
|
-
* @param {Array<string>} [
|
|
6520
|
+
* @param {Array<string>} [settings.ampm]
|
|
6522
6521
|
* How AM and PM should be presented.
|
|
6523
|
-
* @param {Array<string>} [
|
|
6522
|
+
* @param {Array<string>} [settings.mmmm6]
|
|
6524
6523
|
* Long month names for the Islamic calendar (e.g. `Rajab`)
|
|
6525
|
-
* @param {Array<string>} [
|
|
6524
|
+
* @param {Array<string>} [settings.mmm6]
|
|
6526
6525
|
* Short month names for the Islamic calendar (e.g. `Raj.`)
|
|
6527
|
-
* @param {Array<string>} [
|
|
6526
|
+
* @param {Array<string>} [settings.mmmm]
|
|
6528
6527
|
* Long month names for the Gregorian calendar (e.g. `November`)
|
|
6529
|
-
* @param {Array<string>} [
|
|
6528
|
+
* @param {Array<string>} [settings.mmm]
|
|
6530
6529
|
* Short month names for the Gregorian calendar (e.g. `Nov`)
|
|
6531
|
-
* @param {Array<string>} [
|
|
6530
|
+
* @param {Array<string>} [settings.dddd]
|
|
6532
6531
|
* Long day names (e.g. `Wednesday`)
|
|
6533
|
-
* @param {Array<string>} [
|
|
6532
|
+
* @param {Array<string>} [settings.ddd]
|
|
6534
6533
|
* Shortened day names (e.g. `Wed`)
|
|
6535
|
-
* @param {Array<string>} [
|
|
6534
|
+
* @param {Array<string>} [settings.bool]
|
|
6536
6535
|
* How TRUE and FALSE should be presented.
|
|
6537
|
-
* @param {boolean} [
|
|
6536
|
+
* @param {boolean} [settings.preferMDY]
|
|
6538
6537
|
* Is the prefered date format month first (12/31/2025) or day first (31/12/2025)
|
|
6539
|
-
* @param {string}
|
|
6538
|
+
* @param {string | LocaleToken} locale - A string BCP 47 tag or parsed locale token.
|
|
6540
6539
|
* @returns {LocaleData} - A full collection of settings for a locale
|
|
6541
6540
|
*/
|
|
6542
|
-
function addLocale(
|
|
6543
|
-
const c = typeof
|
|
6544
|
-
locales[c.lang] = createLocale(
|
|
6545
|
-
if (c.language !== c.lang && !locales[c.language]) locales[c.language] = createLocale(
|
|
6541
|
+
function addLocale(settings, locale) {
|
|
6542
|
+
const c = typeof locale === "object" ? locale : parseLocale(locale);
|
|
6543
|
+
locales[c.lang] = createLocale(settings);
|
|
6544
|
+
if (c.language !== c.lang && !locales[c.language]) locales[c.language] = createLocale(settings);
|
|
6546
6545
|
return locales[c.lang];
|
|
6547
6546
|
}
|
|
6548
6547
|
const defaultLocale = createLocale({
|
|
@@ -7059,131 +7058,62 @@ addLocale({
|
|
|
7059
7058
|
}, "hi");
|
|
7060
7059
|
|
|
7061
7060
|
//#endregion
|
|
7062
|
-
//#region ../../../
|
|
7063
|
-
|
|
7064
|
-
|
|
7065
|
-
|
|
7066
|
-
|
|
7067
|
-
|
|
7068
|
-
|
|
7069
|
-
|
|
7070
|
-
|
|
7071
|
-
"!j-m-y",
|
|
7072
|
-
"!j-m-Y",
|
|
7073
|
-
"!d-n-y",
|
|
7074
|
-
"!d-n-Y",
|
|
7075
|
-
"!j-n-y",
|
|
7076
|
-
"!j-n-Y",
|
|
7077
|
-
"?m-d-y",
|
|
7078
|
-
"?m-d-Y",
|
|
7079
|
-
"?m-j-y",
|
|
7080
|
-
"?m-j-Y",
|
|
7081
|
-
"?n-d-y",
|
|
7082
|
-
"?n-d-Y",
|
|
7083
|
-
"?n-j-y",
|
|
7084
|
-
"?n-j-Y",
|
|
7085
|
-
"d-M-y",
|
|
7086
|
-
"d-M-Y",
|
|
7087
|
-
"j-M-y",
|
|
7088
|
-
"j-M-Y",
|
|
7089
|
-
"M-d-y",
|
|
7090
|
-
"M-d-Y",
|
|
7091
|
-
"M-j-y",
|
|
7092
|
-
"M-j-Y",
|
|
7093
|
-
"d-F-y",
|
|
7094
|
-
"d-F-Y",
|
|
7095
|
-
"F-d-y",
|
|
7096
|
-
"F-d-Y",
|
|
7097
|
-
"F-j-y",
|
|
7098
|
-
"F-j-Y",
|
|
7099
|
-
"j-F-y",
|
|
7100
|
-
"j-F-Y",
|
|
7101
|
-
"y-F-d",
|
|
7102
|
-
"y-F-j",
|
|
7103
|
-
"y-M-d",
|
|
7104
|
-
"y-M-j",
|
|
7105
|
-
"Y-F-d",
|
|
7106
|
-
"Y-F-j",
|
|
7107
|
-
"Y-M-d",
|
|
7108
|
-
"Y-m-d",
|
|
7109
|
-
"Y-M-j",
|
|
7110
|
-
"Y-m-j",
|
|
7111
|
-
"Y-n-d",
|
|
7112
|
-
"Y-n-j",
|
|
7113
|
-
"j-F",
|
|
7114
|
-
"j-M",
|
|
7115
|
-
"d-F",
|
|
7116
|
-
"d-M",
|
|
7117
|
-
"n-d",
|
|
7118
|
-
"n-j",
|
|
7119
|
-
"n-Y",
|
|
7120
|
-
"m-d",
|
|
7121
|
-
"m-j",
|
|
7122
|
-
"m-Y",
|
|
7123
|
-
"M-Y",
|
|
7124
|
-
"M-y",
|
|
7125
|
-
"F-y",
|
|
7126
|
-
"F-Y",
|
|
7127
|
-
"Y-M",
|
|
7128
|
-
"Y-n",
|
|
7129
|
-
"Y-m",
|
|
7130
|
-
"Y-F",
|
|
7131
|
-
"Y-M"
|
|
7132
|
-
];
|
|
7133
|
-
const dateTrieDM = {};
|
|
7134
|
-
const dateTrieMD = {};
|
|
7135
|
-
function packDate(f, node, allowType = 1) {
|
|
7136
|
-
if (f) {
|
|
7137
|
-
const char = f[0];
|
|
7138
|
-
const next = f.slice(1);
|
|
7139
|
-
if (char === "!") packDate(next, node, 4);
|
|
7140
|
-
else if (char === "?") packDate(next, node, 2);
|
|
7141
|
-
else {
|
|
7142
|
-
node[char] = node[char] || {};
|
|
7143
|
-
packDate(next, node[char], allowType);
|
|
7144
|
-
}
|
|
7145
|
-
} else node.$ = allowType;
|
|
7061
|
+
//#region ../../../packages/core/src/shared/numfmt/parse-format-section.ts
|
|
7062
|
+
function getNumberPattern(part, prefix) {
|
|
7063
|
+
switch (prefix) {
|
|
7064
|
+
case "int": return part.int_pattern;
|
|
7065
|
+
case "frac": return part.frac_pattern;
|
|
7066
|
+
case "man": return part.man_pattern;
|
|
7067
|
+
case "den": return part.den_pattern;
|
|
7068
|
+
case "num": return part.num_pattern;
|
|
7069
|
+
}
|
|
7146
7070
|
}
|
|
7147
|
-
function addFormatToTrie(fmt, trie) {
|
|
7148
|
-
packDate(fmt, trie);
|
|
7149
|
-
packDate(fmt + " x", trie);
|
|
7150
|
-
packDate(fmt + " l", trie);
|
|
7151
|
-
packDate(fmt + " l x", trie);
|
|
7152
|
-
packDate("l " + fmt, trie);
|
|
7153
|
-
packDate("l " + fmt + " x", trie);
|
|
7154
|
-
packDate(fmt + " D", trie);
|
|
7155
|
-
packDate(fmt + " D x", trie);
|
|
7156
|
-
packDate("D " + fmt, trie);
|
|
7157
|
-
packDate("D " + fmt + " x", trie);
|
|
7158
|
-
}
|
|
7159
|
-
okDateFormats.forEach((fmt) => {
|
|
7160
|
-
if (!fmt.startsWith("?")) addFormatToTrie(fmt, dateTrieDM);
|
|
7161
|
-
if (!fmt.startsWith("!")) addFormatToTrie(fmt, dateTrieMD);
|
|
7162
|
-
});
|
|
7163
|
-
const currentYear = (/* @__PURE__ */ new Date()).getUTCFullYear();
|
|
7164
|
-
|
|
7165
|
-
//#endregion
|
|
7166
|
-
//#region ../../../node_modules/.pnpm/numfmt@3.2.6/node_modules/numfmt/lib/parseFormatSection.js
|
|
7167
7071
|
function minMaxPad(str, part, prefix) {
|
|
7168
|
-
|
|
7169
|
-
|
|
7072
|
+
const max = str.length;
|
|
7073
|
+
const min = str.replace(/#/g, "").length;
|
|
7074
|
+
switch (prefix) {
|
|
7075
|
+
case "int":
|
|
7076
|
+
part.int_max = max;
|
|
7077
|
+
part.int_min = min;
|
|
7078
|
+
break;
|
|
7079
|
+
case "frac":
|
|
7080
|
+
part.frac_max = max;
|
|
7081
|
+
part.frac_min = min;
|
|
7082
|
+
break;
|
|
7083
|
+
case "man":
|
|
7084
|
+
part.man_max = max;
|
|
7085
|
+
part.man_min = min;
|
|
7086
|
+
break;
|
|
7087
|
+
case "den":
|
|
7088
|
+
part.den_max = max;
|
|
7089
|
+
part.den_min = min;
|
|
7090
|
+
break;
|
|
7091
|
+
case "num":
|
|
7092
|
+
part.num_max = max;
|
|
7093
|
+
part.num_min = min;
|
|
7094
|
+
break;
|
|
7095
|
+
}
|
|
7170
7096
|
return part;
|
|
7171
7097
|
}
|
|
7172
|
-
function add(
|
|
7173
|
-
if (typeof
|
|
7098
|
+
function add(token, tokens) {
|
|
7099
|
+
if (typeof token === "string") tokens.push({
|
|
7174
7100
|
type: "string",
|
|
7175
|
-
value:
|
|
7101
|
+
value: token
|
|
7176
7102
|
});
|
|
7177
|
-
else tokens.push(
|
|
7103
|
+
else tokens.push(token);
|
|
7178
7104
|
}
|
|
7179
7105
|
function isNumOp(token, activePattern) {
|
|
7180
7106
|
const type = token === null || token === void 0 ? void 0 : token.type;
|
|
7181
7107
|
return type === "hash" || type === "zero" || type === "qmark" || type === "digit" && activePattern === "den";
|
|
7182
7108
|
}
|
|
7109
|
+
function assertNumberChunk(token) {
|
|
7110
|
+
if (token === null) throw new TypeError("Cannot read properties of null (reading 'num')");
|
|
7111
|
+
}
|
|
7183
7112
|
function parseFormatSection(inputTokens) {
|
|
7184
7113
|
const outputTokens = [];
|
|
7185
7114
|
const part = {
|
|
7186
7115
|
scale: 1,
|
|
7116
|
+
scaleExponent: 0,
|
|
7187
7117
|
percent: false,
|
|
7188
7118
|
text: false,
|
|
7189
7119
|
date: 0,
|
|
@@ -7197,7 +7127,24 @@ function parseFormatSection(inputTokens) {
|
|
|
7197
7127
|
man_pattern: [],
|
|
7198
7128
|
den_pattern: [],
|
|
7199
7129
|
num_pattern: [],
|
|
7200
|
-
tokens: outputTokens
|
|
7130
|
+
tokens: outputTokens,
|
|
7131
|
+
tokensUsed: 0,
|
|
7132
|
+
pattern: "",
|
|
7133
|
+
int_max: 0,
|
|
7134
|
+
int_min: 0,
|
|
7135
|
+
frac_max: 0,
|
|
7136
|
+
frac_min: 0,
|
|
7137
|
+
man_max: 0,
|
|
7138
|
+
man_min: 0,
|
|
7139
|
+
num_max: 0,
|
|
7140
|
+
num_min: 0,
|
|
7141
|
+
den_max: 0,
|
|
7142
|
+
den_min: 0,
|
|
7143
|
+
int_p: "",
|
|
7144
|
+
man_p: "",
|
|
7145
|
+
num_p: "",
|
|
7146
|
+
den_p: "",
|
|
7147
|
+
integer: false
|
|
7201
7148
|
};
|
|
7202
7149
|
let currentPattern = "int";
|
|
7203
7150
|
let lastNumberChunk = null;
|
|
@@ -7217,12 +7164,13 @@ function parseFormatSection(inputTokens) {
|
|
|
7217
7164
|
part.general = true;
|
|
7218
7165
|
add(token, outputTokens);
|
|
7219
7166
|
} else if (isNumOp(token, currentPattern)) {
|
|
7220
|
-
const
|
|
7167
|
+
const pattern = getNumberPattern(part, currentPattern);
|
|
7221
7168
|
if (isNumOp(last, currentPattern) || (last === null || last === void 0 ? void 0 : last.type) === "group") {
|
|
7222
|
-
|
|
7169
|
+
pattern.push((pattern.pop() || "") + token.value);
|
|
7170
|
+
assertNumberChunk(lastNumberChunk);
|
|
7223
7171
|
lastNumberChunk.num += token.value;
|
|
7224
7172
|
} else {
|
|
7225
|
-
|
|
7173
|
+
pattern.push(token.value);
|
|
7226
7174
|
lastNumberChunk = {
|
|
7227
7175
|
type: currentPattern,
|
|
7228
7176
|
num: token.value
|
|
@@ -7235,17 +7183,22 @@ function parseFormatSection(inputTokens) {
|
|
|
7235
7183
|
} else if (type === "digit") add(token.value, outputTokens);
|
|
7236
7184
|
else if (type === "slash") {
|
|
7237
7185
|
haveSlash = true;
|
|
7238
|
-
|
|
7186
|
+
const pattern = getNumberPattern(part, currentPattern);
|
|
7187
|
+
if (pattern.length) {
|
|
7239
7188
|
if (!lastNumberChunk) throw new SyntaxError("Format pattern is missing a numerator");
|
|
7240
7189
|
part.fractions = true;
|
|
7241
|
-
|
|
7190
|
+
const numerator = pattern.pop();
|
|
7191
|
+
if (numerator === void 0) throw new SyntaxError("Format pattern is missing a numerator");
|
|
7192
|
+
part.num_pattern.push(numerator);
|
|
7242
7193
|
lastNumberChunk.type = "num";
|
|
7243
7194
|
currentPattern = "den";
|
|
7244
7195
|
add({ type: "div" }, outputTokens);
|
|
7245
7196
|
} else add(token.value, outputTokens);
|
|
7246
7197
|
} else if (type === "comma") add(",", outputTokens);
|
|
7247
|
-
else if (type === "scale")
|
|
7248
|
-
|
|
7198
|
+
else if (type === "scale") {
|
|
7199
|
+
part.scale = .001 ** token.raw.length;
|
|
7200
|
+
part.scaleExponent = -3 * token.raw.length;
|
|
7201
|
+
} else if (type === "group") {
|
|
7249
7202
|
if (currentPattern === "int") part.grouping = true;
|
|
7250
7203
|
if (currentPattern === "den") throw new SyntaxError("Cannot group denominator digits");
|
|
7251
7204
|
} else if (type === "space") add(token, outputTokens);
|
|
@@ -7280,17 +7233,17 @@ function parseFormatSection(inputTokens) {
|
|
|
7280
7233
|
add(bit, outputTokens);
|
|
7281
7234
|
} else if (part.date && type === "point" && ((_inputTokens = inputTokens[index + 1]) === null || _inputTokens === void 0 ? void 0 : _inputTokens.type) === "zero") {
|
|
7282
7235
|
var _inputTokens2, _inputTokens3;
|
|
7283
|
-
let
|
|
7236
|
+
let decimals = 1;
|
|
7284
7237
|
index++;
|
|
7285
7238
|
let raw = "0";
|
|
7286
7239
|
if (((_inputTokens2 = inputTokens[index + 1]) === null || _inputTokens2 === void 0 ? void 0 : _inputTokens2.type) === "zero") {
|
|
7287
7240
|
raw += "0";
|
|
7288
|
-
|
|
7241
|
+
decimals = 2;
|
|
7289
7242
|
index++;
|
|
7290
7243
|
}
|
|
7291
7244
|
if (((_inputTokens3 = inputTokens[index + 1]) === null || _inputTokens3 === void 0 ? void 0 : _inputTokens3.type) === "zero") {
|
|
7292
7245
|
raw += "0";
|
|
7293
|
-
|
|
7246
|
+
decimals = 3;
|
|
7294
7247
|
index++;
|
|
7295
7248
|
}
|
|
7296
7249
|
patternSource += raw;
|
|
@@ -7299,14 +7252,14 @@ function parseFormatSection(inputTokens) {
|
|
|
7299
7252
|
128,
|
|
7300
7253
|
256,
|
|
7301
7254
|
512
|
|
7302
|
-
][
|
|
7255
|
+
][decimals];
|
|
7303
7256
|
part.date = part.date | size;
|
|
7304
7257
|
part.date_eval = true;
|
|
7305
|
-
part.sec_decimals = Math.max(part.sec_decimals,
|
|
7258
|
+
part.sec_decimals = Math.max(part.sec_decimals, decimals);
|
|
7306
7259
|
add({
|
|
7307
7260
|
type: "subsec",
|
|
7308
7261
|
size,
|
|
7309
|
-
decimals
|
|
7262
|
+
decimals,
|
|
7310
7263
|
date: 1
|
|
7311
7264
|
}, outputTokens);
|
|
7312
7265
|
} else if (type === "calendar") {
|
|
@@ -7357,9 +7310,9 @@ function parseFormatSection(inputTokens) {
|
|
|
7357
7310
|
bit.size = 4;
|
|
7358
7311
|
bit.type = "monthname";
|
|
7359
7312
|
}
|
|
7360
|
-
const
|
|
7361
|
-
if (!bit.type &&
|
|
7362
|
-
|
|
7313
|
+
const lastDateChunk = dateChunks[dateChunks.length - 1];
|
|
7314
|
+
if (!bit.type && lastDateChunk && !lastDateChunk.used && lastDateChunk.size & (16 | 64)) {
|
|
7315
|
+
lastDateChunk.used = true;
|
|
7363
7316
|
bit.size = 32;
|
|
7364
7317
|
bit.type = "min";
|
|
7365
7318
|
bit.pad = /mm/.test(value);
|
|
@@ -7374,12 +7327,12 @@ function parseFormatSection(inputTokens) {
|
|
|
7374
7327
|
bit.size = 64;
|
|
7375
7328
|
bit.type = "sec";
|
|
7376
7329
|
bit.pad = /ss/.test(value);
|
|
7377
|
-
const
|
|
7378
|
-
if (
|
|
7379
|
-
else if (
|
|
7380
|
-
delete
|
|
7381
|
-
|
|
7382
|
-
|
|
7330
|
+
const lastDateChunk = dateChunks[dateChunks.length - 1];
|
|
7331
|
+
if (lastDateChunk && lastDateChunk.size & 32) bit.used = true;
|
|
7332
|
+
else if (lastDateChunk === null || lastDateChunk === void 0 ? void 0 : lastDateChunk.indeterminate) {
|
|
7333
|
+
delete lastDateChunk.indeterminate;
|
|
7334
|
+
lastDateChunk.size = 32;
|
|
7335
|
+
lastDateChunk.type = "min";
|
|
7383
7336
|
bit.used = true;
|
|
7384
7337
|
}
|
|
7385
7338
|
} else if (startsWith === "g") {}
|
|
@@ -7394,26 +7347,28 @@ function parseFormatSection(inputTokens) {
|
|
|
7394
7347
|
token.short = token.value === "A/P";
|
|
7395
7348
|
add(token, outputTokens);
|
|
7396
7349
|
} else if (type === "string" || type === "escaped" || type === "char") add(token.value, outputTokens);
|
|
7397
|
-
else if (type === "condition") part.condition = [token.value[0], parseFloat(token.value[1])];
|
|
7350
|
+
else if (type === "condition") part.condition = [token.value[0], Number.parseFloat(token.value[1])];
|
|
7398
7351
|
else if (type === "locale") {
|
|
7399
7352
|
const bits = token.value.split("-");
|
|
7400
7353
|
const code = bits.length < 2 ? "" : bits.slice(1).join("-");
|
|
7401
7354
|
const currency = bits[0];
|
|
7402
7355
|
if (currency) add(currency, outputTokens);
|
|
7403
|
-
const
|
|
7404
|
-
if (
|
|
7405
|
-
const
|
|
7406
|
-
if (isFinite(
|
|
7407
|
-
if ((
|
|
7356
|
+
const locale = resolveLocale(code);
|
|
7357
|
+
if (locale) part.locale = locale;
|
|
7358
|
+
const windowsCode = Number.parseInt(code, 16);
|
|
7359
|
+
if (Number.isFinite(windowsCode) && windowsCode & 16711680) {
|
|
7360
|
+
if ((windowsCode >> 16 & 255) === 6) part.date_system = 6;
|
|
7408
7361
|
}
|
|
7409
7362
|
haveLocale = true;
|
|
7410
7363
|
} else if (type === "color") {
|
|
7411
|
-
|
|
7412
|
-
let
|
|
7413
|
-
|
|
7414
|
-
|
|
7364
|
+
const normalizedColor = token.value.toLowerCase();
|
|
7365
|
+
let color = normalizedColor;
|
|
7366
|
+
const colorMatch = /^color\s*(\d+)$/i.exec(normalizedColor);
|
|
7367
|
+
if (colorMatch) color = Number.parseInt(colorMatch[1], 10);
|
|
7368
|
+
part.color = color;
|
|
7415
7369
|
} else if (type === "percent") {
|
|
7416
7370
|
part.scale = 100;
|
|
7371
|
+
part.scaleExponent = 2;
|
|
7417
7372
|
part.percent = true;
|
|
7418
7373
|
add("%", outputTokens);
|
|
7419
7374
|
} else if (type === "point") {
|
|
@@ -7430,8 +7385,7 @@ function parseFormatSection(inputTokens) {
|
|
|
7430
7385
|
type: "exp",
|
|
7431
7386
|
plus: part.exp_plus
|
|
7432
7387
|
}, outputTokens);
|
|
7433
|
-
} else if (type === "skip") add(token, outputTokens);
|
|
7434
|
-
else if (type === "fill") add(token, outputTokens);
|
|
7388
|
+
} else if (type === "skip" || type === "fill") add(token, outputTokens);
|
|
7435
7389
|
else if (type === "dbnum" || type === "natnum") {} else if (type === "error") throw new SyntaxError(`Illegal character: ${patternSource}`);
|
|
7436
7390
|
else throw new SyntaxError(`Unknown token ${type} in ${patternSource}`);
|
|
7437
7391
|
last = token;
|
|
@@ -7445,34 +7399,34 @@ function parseFormatSection(inputTokens) {
|
|
|
7445
7399
|
const fracPattern = part.frac_pattern.join("");
|
|
7446
7400
|
minMaxPad(intPattern, part, "int");
|
|
7447
7401
|
let min = 0;
|
|
7448
|
-
for (let
|
|
7449
|
-
const
|
|
7450
|
-
if (/^[0-9?]/.test(
|
|
7402
|
+
for (let patternIndex = 0; patternIndex < intPattern.length; patternIndex++) {
|
|
7403
|
+
const character = intPattern[intPattern.length - 1 - patternIndex];
|
|
7404
|
+
if (/^[0-9?]/.test(character)) min = patternIndex + 1;
|
|
7451
7405
|
}
|
|
7452
7406
|
part.int_min = min;
|
|
7453
7407
|
minMaxPad(fracPattern, part, "frac");
|
|
7454
7408
|
minMaxPad(manPattern, part, "man");
|
|
7455
|
-
let
|
|
7456
|
-
let
|
|
7457
|
-
if (
|
|
7458
|
-
|
|
7459
|
-
|
|
7460
|
-
minMaxPad(
|
|
7461
|
-
minMaxPad(
|
|
7462
|
-
|
|
7409
|
+
let numeratorPattern = part.num_pattern.join("");
|
|
7410
|
+
let denominatorPattern = part.den_pattern[0] || "";
|
|
7411
|
+
if (denominatorPattern.includes("?") || numeratorPattern.includes("?")) {
|
|
7412
|
+
denominatorPattern = denominatorPattern.replace(/\d/g, "?");
|
|
7413
|
+
denominatorPattern = denominatorPattern.replace(/#$/g, "?");
|
|
7414
|
+
minMaxPad(numeratorPattern, part, "num");
|
|
7415
|
+
minMaxPad(denominatorPattern, part, "den");
|
|
7416
|
+
numeratorPattern = numeratorPattern.replace(/#$/g, "?");
|
|
7463
7417
|
} else {
|
|
7464
|
-
minMaxPad(
|
|
7465
|
-
minMaxPad(
|
|
7418
|
+
minMaxPad(numeratorPattern, part, "num");
|
|
7419
|
+
minMaxPad(denominatorPattern, part, "den");
|
|
7466
7420
|
}
|
|
7467
7421
|
part.int_p = intPattern;
|
|
7468
7422
|
part.man_p = manPattern;
|
|
7469
|
-
part.num_p =
|
|
7470
|
-
part.den_p =
|
|
7471
|
-
if (part.den_pattern.length) part.denominator = parseInt(part.den_pattern.join("").replace(/\D/g, ""), 10);
|
|
7423
|
+
part.num_p = numeratorPattern;
|
|
7424
|
+
part.den_p = denominatorPattern;
|
|
7425
|
+
if (part.den_pattern.length) part.denominator = Number.parseInt(part.den_pattern.join("").replace(/\D/g, ""), 10);
|
|
7472
7426
|
part.integer = !!intPattern.length;
|
|
7473
7427
|
if (!part.integer && !part.exponential && fracPattern.length) {
|
|
7474
|
-
const
|
|
7475
|
-
part.tokens.splice(
|
|
7428
|
+
const pointIndex = part.tokens.findIndex((token) => token.type === "point");
|
|
7429
|
+
part.tokens.splice(pointIndex, 0, {
|
|
7476
7430
|
type: "int",
|
|
7477
7431
|
value: "#"
|
|
7478
7432
|
});
|
|
@@ -7480,71 +7434,136 @@ function parseFormatSection(inputTokens) {
|
|
|
7480
7434
|
part.int_pattern = ["#"];
|
|
7481
7435
|
part.int_p = "#";
|
|
7482
7436
|
}
|
|
7483
|
-
if (part.fractions) for (let
|
|
7484
|
-
const
|
|
7485
|
-
if (
|
|
7486
|
-
const nextType = outputTokens[
|
|
7487
|
-
if (nextType === "num")
|
|
7488
|
-
else if (nextType === "div")
|
|
7489
|
-
else if (nextType === "den")
|
|
7490
|
-
}
|
|
7491
|
-
if (part.grouping) {
|
|
7492
|
-
if (part.int_pattern.length > 1) part.grouping = false;
|
|
7437
|
+
if (part.fractions) for (let tokenIndex = 0; tokenIndex < outputTokens.length - 1; tokenIndex++) {
|
|
7438
|
+
const token = outputTokens[tokenIndex];
|
|
7439
|
+
if (token.type !== "string" && token.type !== "space") continue;
|
|
7440
|
+
const nextType = outputTokens[tokenIndex + 1].type;
|
|
7441
|
+
if (nextType === "num") token.rule = "num+int";
|
|
7442
|
+
else if (nextType === "div") token.rule = "num";
|
|
7443
|
+
else if (nextType === "den") token.rule = "den";
|
|
7493
7444
|
}
|
|
7445
|
+
if (part.grouping && part.int_pattern.length > 1) part.grouping = false;
|
|
7494
7446
|
return part;
|
|
7495
7447
|
}
|
|
7496
7448
|
|
|
7497
7449
|
//#endregion
|
|
7498
|
-
//#region ../../../
|
|
7499
|
-
const
|
|
7450
|
+
//#region ../../../packages/core/src/shared/numfmt/format-number.ts
|
|
7451
|
+
const defaultText = parseFormatSection([{
|
|
7500
7452
|
type: TOKEN_TEXT,
|
|
7501
7453
|
value: "@",
|
|
7502
7454
|
raw: "@"
|
|
7503
7455
|
}]);
|
|
7504
7456
|
|
|
7505
7457
|
//#endregion
|
|
7506
|
-
//#region ../../../
|
|
7507
|
-
|
|
7508
|
-
|
|
7509
|
-
|
|
7510
|
-
|
|
7511
|
-
|
|
7512
|
-
|
|
7513
|
-
|
|
7514
|
-
|
|
7515
|
-
|
|
7516
|
-
|
|
7517
|
-
|
|
7518
|
-
|
|
7519
|
-
|
|
7520
|
-
|
|
7521
|
-
|
|
7522
|
-
|
|
7523
|
-
|
|
7524
|
-
|
|
7525
|
-
|
|
7526
|
-
|
|
7527
|
-
|
|
7528
|
-
|
|
7529
|
-
|
|
7530
|
-
|
|
7531
|
-
|
|
7532
|
-
|
|
7533
|
-
|
|
7534
|
-
|
|
7535
|
-
|
|
7536
|
-
|
|
7537
|
-
|
|
7538
|
-
|
|
7539
|
-
|
|
7540
|
-
|
|
7541
|
-
|
|
7542
|
-
|
|
7543
|
-
|
|
7544
|
-
|
|
7545
|
-
|
|
7546
|
-
|
|
7547
|
-
|
|
7458
|
+
//#region ../../../packages/core/src/shared/numfmt/serial-date.ts
|
|
7459
|
+
const dateUTC = Date.UTC;
|
|
7460
|
+
|
|
7461
|
+
//#endregion
|
|
7462
|
+
//#region ../../../packages/core/src/shared/numfmt/parse-value.ts
|
|
7463
|
+
const okDateFormats = [
|
|
7464
|
+
"!d-m-y",
|
|
7465
|
+
"!d-m-Y",
|
|
7466
|
+
"!j-m-y",
|
|
7467
|
+
"!j-m-Y",
|
|
7468
|
+
"!d-n-y",
|
|
7469
|
+
"!d-n-Y",
|
|
7470
|
+
"!j-n-y",
|
|
7471
|
+
"!j-n-Y",
|
|
7472
|
+
"?m-d-y",
|
|
7473
|
+
"?m-d-Y",
|
|
7474
|
+
"?m-j-y",
|
|
7475
|
+
"?m-j-Y",
|
|
7476
|
+
"?n-d-y",
|
|
7477
|
+
"?n-d-Y",
|
|
7478
|
+
"?n-j-y",
|
|
7479
|
+
"?n-j-Y",
|
|
7480
|
+
"d-M-y",
|
|
7481
|
+
"d-M-Y",
|
|
7482
|
+
"j-M-y",
|
|
7483
|
+
"j-M-Y",
|
|
7484
|
+
"M-d-y",
|
|
7485
|
+
"M-d-Y",
|
|
7486
|
+
"M-j-y",
|
|
7487
|
+
"M-j-Y",
|
|
7488
|
+
"d-F-y",
|
|
7489
|
+
"d-F-Y",
|
|
7490
|
+
"F-d-y",
|
|
7491
|
+
"F-d-Y",
|
|
7492
|
+
"F-j-y",
|
|
7493
|
+
"F-j-Y",
|
|
7494
|
+
"j-F-y",
|
|
7495
|
+
"j-F-Y",
|
|
7496
|
+
"y-F-d",
|
|
7497
|
+
"y-F-j",
|
|
7498
|
+
"y-M-d",
|
|
7499
|
+
"y-M-j",
|
|
7500
|
+
"Y-F-d",
|
|
7501
|
+
"Y-F-j",
|
|
7502
|
+
"Y-M-d",
|
|
7503
|
+
"Y-m-d",
|
|
7504
|
+
"Y-M-j",
|
|
7505
|
+
"Y-m-j",
|
|
7506
|
+
"Y-n-d",
|
|
7507
|
+
"Y-n-j",
|
|
7508
|
+
"j-F",
|
|
7509
|
+
"j-M",
|
|
7510
|
+
"d-F",
|
|
7511
|
+
"d-M",
|
|
7512
|
+
"n-d",
|
|
7513
|
+
"n-j",
|
|
7514
|
+
"n-Y",
|
|
7515
|
+
"m-d",
|
|
7516
|
+
"m-j",
|
|
7517
|
+
"m-Y",
|
|
7518
|
+
"M-Y",
|
|
7519
|
+
"M-y",
|
|
7520
|
+
"F-y",
|
|
7521
|
+
"F-Y",
|
|
7522
|
+
"Y-M",
|
|
7523
|
+
"Y-n",
|
|
7524
|
+
"Y-m",
|
|
7525
|
+
"Y-F",
|
|
7526
|
+
"Y-M"
|
|
7527
|
+
];
|
|
7528
|
+
const dateTrieDM = {};
|
|
7529
|
+
const dateTrieMD = {};
|
|
7530
|
+
function packDate(format, node, allowType = 1) {
|
|
7531
|
+
if (format) {
|
|
7532
|
+
const char = format[0];
|
|
7533
|
+
const next = format.slice(1);
|
|
7534
|
+
if (char === "!") packDate(next, node, 4);
|
|
7535
|
+
else if (char === "?") packDate(next, node, 2);
|
|
7536
|
+
else {
|
|
7537
|
+
let branch = node[char];
|
|
7538
|
+
if (typeof branch !== "object") {
|
|
7539
|
+
branch = {};
|
|
7540
|
+
node[char] = branch;
|
|
7541
|
+
}
|
|
7542
|
+
packDate(next, branch, allowType);
|
|
7543
|
+
}
|
|
7544
|
+
} else node.$ = allowType;
|
|
7545
|
+
}
|
|
7546
|
+
function addFormatToTrie(format, trie) {
|
|
7547
|
+
packDate(format, trie);
|
|
7548
|
+
packDate(`${format} x`, trie);
|
|
7549
|
+
packDate(`${format} l`, trie);
|
|
7550
|
+
packDate(`${format} l x`, trie);
|
|
7551
|
+
packDate(`l ${format}`, trie);
|
|
7552
|
+
packDate(`l ${format} x`, trie);
|
|
7553
|
+
packDate(`${format} D`, trie);
|
|
7554
|
+
packDate(`${format} D x`, trie);
|
|
7555
|
+
packDate(`D ${format}`, trie);
|
|
7556
|
+
packDate(`D ${format} x`, trie);
|
|
7557
|
+
}
|
|
7558
|
+
okDateFormats.forEach((format) => {
|
|
7559
|
+
if (!format.startsWith("?")) addFormatToTrie(format, dateTrieDM);
|
|
7560
|
+
if (!format.startsWith("!")) addFormatToTrie(format, dateTrieMD);
|
|
7561
|
+
});
|
|
7562
|
+
const currentYear = (/* @__PURE__ */ new Date()).getUTCFullYear();
|
|
7563
|
+
|
|
7564
|
+
//#endregion
|
|
7565
|
+
//#region ../../../packages/core/src/shared/numfmt/api.ts
|
|
7566
|
+
/** A dictionary of the types used to identify token variants. */
|
|
7548
7567
|
const tokenTypes = Object.freeze({
|
|
7549
7568
|
AMPM: TOKEN_AMPM,
|
|
7550
7569
|
BREAK: TOKEN_BREAK,
|
|
@@ -7896,7 +7915,7 @@ const regexp = {
|
|
|
7896
7915
|
};
|
|
7897
7916
|
|
|
7898
7917
|
//#endregion
|
|
7899
|
-
//#region ../../../packages/core/src/shared/numfmt.ts
|
|
7918
|
+
//#region ../../../packages/core/src/shared/numfmt/utils.ts
|
|
7900
7919
|
const currencySymbols = [
|
|
7901
7920
|
"Rp",
|
|
7902
7921
|
"zł",
|
|
@@ -9298,6 +9317,7 @@ const STYLE_KEYS = defineExactKeys()([
|
|
|
9298
9317
|
"cl",
|
|
9299
9318
|
"va",
|
|
9300
9319
|
"n",
|
|
9320
|
+
"stf",
|
|
9301
9321
|
"tr",
|
|
9302
9322
|
"td",
|
|
9303
9323
|
"ht",
|
|
@@ -18048,6 +18068,10 @@ _defineProperty(BuildTextUtils, "paragraph", {
|
|
|
18048
18068
|
});
|
|
18049
18069
|
_defineProperty(BuildTextUtils, "drawing", { add: addDrawing });
|
|
18050
18070
|
|
|
18071
|
+
//#endregion
|
|
18072
|
+
//#region ../../../packages/core/src/docs/data-model/rich-text-builder.ts
|
|
18073
|
+
const NON_EDITABLE_RICH_TEXT_TOKENS = new Set(Object.values(DataStreamTreeTokenType).filter((token) => token !== "" && token !== " "));
|
|
18074
|
+
|
|
18051
18075
|
//#endregion
|
|
18052
18076
|
//#region ../../../packages/core/src/services/resource-manager/type.ts
|
|
18053
18077
|
const IResourceManagerService = createIdentifier("core.resource-manager.service");
|