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