@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/es/index.js
CHANGED
|
@@ -910,7 +910,7 @@ function composeStyles(...styles) {
|
|
|
910
910
|
//#endregion
|
|
911
911
|
//#region ../../../packages/core/package.json
|
|
912
912
|
var name = "@univerjs/core";
|
|
913
|
-
var version = "1.0.0-alpha.
|
|
913
|
+
var version = "1.0.0-alpha.4";
|
|
914
914
|
|
|
915
915
|
//#endregion
|
|
916
916
|
//#region ../../../packages/core/src/common/array.ts
|
|
@@ -6146,7 +6146,7 @@ const THEME_COLORS = { ["Office"]: {
|
|
|
6146
6146
|
} };
|
|
6147
6147
|
|
|
6148
6148
|
//#endregion
|
|
6149
|
-
//#region ../../../
|
|
6149
|
+
//#region ../../../packages/core/src/shared/numfmt/constants.ts
|
|
6150
6150
|
const TOKEN_GENERAL = "general";
|
|
6151
6151
|
const TOKEN_HASH = "hash";
|
|
6152
6152
|
const TOKEN_ZERO = "zero";
|
|
@@ -6209,11 +6209,26 @@ const currencySymbols$1 = [
|
|
|
6209
6209
|
"₾",
|
|
6210
6210
|
"₿"
|
|
6211
6211
|
];
|
|
6212
|
-
const reCurrencySymbols = new RegExp(
|
|
6212
|
+
const reCurrencySymbols = new RegExp(`[${currencySymbols$1.join("")}]`);
|
|
6213
6213
|
|
|
6214
6214
|
//#endregion
|
|
6215
|
-
//#region ../../../
|
|
6216
|
-
|
|
6215
|
+
//#region ../../../packages/core/src/shared/numfmt/code-to-locale.ts
|
|
6216
|
+
/**
|
|
6217
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
6218
|
+
*
|
|
6219
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6220
|
+
* you may not use this file except in compliance with the License.
|
|
6221
|
+
* You may obtain a copy of the License at
|
|
6222
|
+
*
|
|
6223
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
6224
|
+
*
|
|
6225
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
6226
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
6227
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
6228
|
+
* See the License for the specific language governing permissions and
|
|
6229
|
+
* limitations under the License.
|
|
6230
|
+
*/
|
|
6231
|
+
const codeToLocale = Object.freeze({
|
|
6217
6232
|
1078: "af",
|
|
6218
6233
|
1052: "sq",
|
|
6219
6234
|
1118: "am",
|
|
@@ -6403,34 +6418,17 @@ var codeToLocale_default = Object.freeze({
|
|
|
6403
6418
|
});
|
|
6404
6419
|
|
|
6405
6420
|
//#endregion
|
|
6406
|
-
//#region ../../../
|
|
6421
|
+
//#region ../../../packages/core/src/shared/numfmt/locale.ts
|
|
6407
6422
|
const re_locale = /^([a-z\d]+)(?:[_-]([a-z\d]+))?(?:\.([a-z\d]+))?(?:@([a-z\d]+))?$/i;
|
|
6408
6423
|
const locales = {};
|
|
6409
6424
|
/**
|
|
6410
6425
|
* Split a semicolon delimited string and replace instances of characters
|
|
6411
6426
|
* @ignore
|
|
6412
6427
|
* @param {string} str Semicolon delimited string
|
|
6413
|
-
* @param {string} [tilde
|
|
6428
|
+
* @param {string} [tilde] String to be inserted on every instance of ~
|
|
6414
6429
|
* @returns {string[]} Array of strings
|
|
6415
6430
|
*/
|
|
6416
6431
|
const _ = (str, tilde = "") => str.replace(/~/g, tilde).split(";");
|
|
6417
|
-
/**
|
|
6418
|
-
* Generate mmm and ddd properties as needed for locales. Many of them
|
|
6419
|
-
* are straightforward abreviations of mmmm and dddd so we can save some
|
|
6420
|
-
* bytes by auto-generating them.
|
|
6421
|
-
*
|
|
6422
|
-
* Both rule parameters use the same system. If shortform prop is missing:
|
|
6423
|
-
*
|
|
6424
|
-
* - 0 - use long form array unchanged
|
|
6425
|
-
* - 1...9 - shorten to N many characters
|
|
6426
|
-
* - 11...19 - shorten to 1...9 characters and add periods
|
|
6427
|
-
*
|
|
6428
|
-
* @ignore
|
|
6429
|
-
* @param {object} o Locale object
|
|
6430
|
-
* @param {number} [ml=0] Month list rule
|
|
6431
|
-
* @param {number} [dl=0] Day list rule
|
|
6432
|
-
* @returns {object} The same input object, but with ddd and mmm filled in.
|
|
6433
|
-
*/
|
|
6434
6432
|
const xm = (o, ml = 0, dl = 0) => {
|
|
6435
6433
|
if (!o.mmm) o.mmm = ml < 1 ? o.mmmm.concat() : o.mmmm.map((d) => {
|
|
6436
6434
|
const s = d.slice(0, ml % 10);
|
|
@@ -6504,20 +6502,20 @@ function parseLocale(locale) {
|
|
|
6504
6502
|
const lm = re_locale.exec(locale);
|
|
6505
6503
|
if (!lm) throw new SyntaxError(`Malformed locale: ${locale}`);
|
|
6506
6504
|
return {
|
|
6507
|
-
lang: lm[1] + (lm[2] ?
|
|
6505
|
+
lang: lm[1] + (lm[2] ? `_${lm[2]}` : ""),
|
|
6508
6506
|
language: lm[1],
|
|
6509
6507
|
territory: lm[2] || ""
|
|
6510
6508
|
};
|
|
6511
6509
|
}
|
|
6512
|
-
function resolveLocale(
|
|
6513
|
-
if (typeof
|
|
6514
|
-
const wincode = parseInt(
|
|
6515
|
-
if (isFinite(wincode) &&
|
|
6516
|
-
if (re_locale.test(
|
|
6510
|
+
function resolveLocale(locale) {
|
|
6511
|
+
if (typeof locale === "number") return codeToLocale[locale & 65535] || null;
|
|
6512
|
+
const wincode = Number.parseInt(locale, 16);
|
|
6513
|
+
if (Number.isFinite(wincode) && codeToLocale[wincode & 65535]) return codeToLocale[wincode & 65535] || null;
|
|
6514
|
+
if (re_locale.test(locale)) return locale;
|
|
6517
6515
|
return null;
|
|
6518
6516
|
}
|
|
6519
|
-
function createLocale(
|
|
6520
|
-
return Object.assign({}, baseLocaleData,
|
|
6517
|
+
function createLocale(settings) {
|
|
6518
|
+
return Object.assign({}, baseLocaleData, settings);
|
|
6521
6519
|
}
|
|
6522
6520
|
/**
|
|
6523
6521
|
* Register locale data for a language so for use when formatting.
|
|
@@ -6525,48 +6523,48 @@ function createLocale(data) {
|
|
|
6525
6523
|
* Any partial set of properties may be returned to have the defaults used where properties are missing.
|
|
6526
6524
|
*
|
|
6527
6525
|
* @see {LocaleData}
|
|
6528
|
-
* @param {object}
|
|
6529
|
-
* @param {string} [
|
|
6526
|
+
* @param {object} settings - A collection of settings for a locale.
|
|
6527
|
+
* @param {string} [settings.group]
|
|
6530
6528
|
* Symbol used as a grouping separator (`1,000,000` uses `,`)
|
|
6531
|
-
* @param {string} [
|
|
6529
|
+
* @param {string} [settings.decimal]
|
|
6532
6530
|
* Symbol used to separate integers from fractions (usually `.`)
|
|
6533
|
-
* @param {string} [
|
|
6531
|
+
* @param {string} [settings.positive]
|
|
6534
6532
|
* Symbol used to indicate positive numbers (usually `+`)
|
|
6535
|
-
* @param {string} [
|
|
6533
|
+
* @param {string} [settings.negative]
|
|
6536
6534
|
* Symbol used to indicate positive numbers (usually `-`)
|
|
6537
|
-
* @param {string} [
|
|
6535
|
+
* @param {string} [settings.percent]
|
|
6538
6536
|
* Symbol used to indicate a percentage (usually `%`)
|
|
6539
|
-
* @param {string} [
|
|
6537
|
+
* @param {string} [settings.exponent]
|
|
6540
6538
|
* Symbol used to indicate an exponent (usually `E`)
|
|
6541
|
-
* @param {string} [
|
|
6539
|
+
* @param {string} [settings.nan]
|
|
6542
6540
|
* Symbol used to indicate NaN values (`NaN`)
|
|
6543
|
-
* @param {string} [
|
|
6541
|
+
* @param {string} [settings.infinity]
|
|
6544
6542
|
* Symbol used to indicate infinite values (`∞`)
|
|
6545
|
-
* @param {Array<string>} [
|
|
6543
|
+
* @param {Array<string>} [settings.ampm]
|
|
6546
6544
|
* How AM and PM should be presented.
|
|
6547
|
-
* @param {Array<string>} [
|
|
6545
|
+
* @param {Array<string>} [settings.mmmm6]
|
|
6548
6546
|
* Long month names for the Islamic calendar (e.g. `Rajab`)
|
|
6549
|
-
* @param {Array<string>} [
|
|
6547
|
+
* @param {Array<string>} [settings.mmm6]
|
|
6550
6548
|
* Short month names for the Islamic calendar (e.g. `Raj.`)
|
|
6551
|
-
* @param {Array<string>} [
|
|
6549
|
+
* @param {Array<string>} [settings.mmmm]
|
|
6552
6550
|
* Long month names for the Gregorian calendar (e.g. `November`)
|
|
6553
|
-
* @param {Array<string>} [
|
|
6551
|
+
* @param {Array<string>} [settings.mmm]
|
|
6554
6552
|
* Short month names for the Gregorian calendar (e.g. `Nov`)
|
|
6555
|
-
* @param {Array<string>} [
|
|
6553
|
+
* @param {Array<string>} [settings.dddd]
|
|
6556
6554
|
* Long day names (e.g. `Wednesday`)
|
|
6557
|
-
* @param {Array<string>} [
|
|
6555
|
+
* @param {Array<string>} [settings.ddd]
|
|
6558
6556
|
* Shortened day names (e.g. `Wed`)
|
|
6559
|
-
* @param {Array<string>} [
|
|
6557
|
+
* @param {Array<string>} [settings.bool]
|
|
6560
6558
|
* How TRUE and FALSE should be presented.
|
|
6561
|
-
* @param {boolean} [
|
|
6559
|
+
* @param {boolean} [settings.preferMDY]
|
|
6562
6560
|
* Is the prefered date format month first (12/31/2025) or day first (31/12/2025)
|
|
6563
|
-
* @param {string}
|
|
6561
|
+
* @param {string | LocaleToken} locale - A string BCP 47 tag or parsed locale token.
|
|
6564
6562
|
* @returns {LocaleData} - A full collection of settings for a locale
|
|
6565
6563
|
*/
|
|
6566
|
-
function addLocale(
|
|
6567
|
-
const c = typeof
|
|
6568
|
-
locales[c.lang] = createLocale(
|
|
6569
|
-
if (c.language !== c.lang && !locales[c.language]) locales[c.language] = createLocale(
|
|
6564
|
+
function addLocale(settings, locale) {
|
|
6565
|
+
const c = typeof locale === "object" ? locale : parseLocale(locale);
|
|
6566
|
+
locales[c.lang] = createLocale(settings);
|
|
6567
|
+
if (c.language !== c.lang && !locales[c.language]) locales[c.language] = createLocale(settings);
|
|
6570
6568
|
return locales[c.lang];
|
|
6571
6569
|
}
|
|
6572
6570
|
const defaultLocale = createLocale({
|
|
@@ -7083,131 +7081,62 @@ addLocale({
|
|
|
7083
7081
|
}, "hi");
|
|
7084
7082
|
|
|
7085
7083
|
//#endregion
|
|
7086
|
-
//#region ../../../
|
|
7087
|
-
|
|
7088
|
-
|
|
7089
|
-
|
|
7090
|
-
|
|
7091
|
-
|
|
7092
|
-
|
|
7093
|
-
|
|
7094
|
-
|
|
7095
|
-
"!j-m-y",
|
|
7096
|
-
"!j-m-Y",
|
|
7097
|
-
"!d-n-y",
|
|
7098
|
-
"!d-n-Y",
|
|
7099
|
-
"!j-n-y",
|
|
7100
|
-
"!j-n-Y",
|
|
7101
|
-
"?m-d-y",
|
|
7102
|
-
"?m-d-Y",
|
|
7103
|
-
"?m-j-y",
|
|
7104
|
-
"?m-j-Y",
|
|
7105
|
-
"?n-d-y",
|
|
7106
|
-
"?n-d-Y",
|
|
7107
|
-
"?n-j-y",
|
|
7108
|
-
"?n-j-Y",
|
|
7109
|
-
"d-M-y",
|
|
7110
|
-
"d-M-Y",
|
|
7111
|
-
"j-M-y",
|
|
7112
|
-
"j-M-Y",
|
|
7113
|
-
"M-d-y",
|
|
7114
|
-
"M-d-Y",
|
|
7115
|
-
"M-j-y",
|
|
7116
|
-
"M-j-Y",
|
|
7117
|
-
"d-F-y",
|
|
7118
|
-
"d-F-Y",
|
|
7119
|
-
"F-d-y",
|
|
7120
|
-
"F-d-Y",
|
|
7121
|
-
"F-j-y",
|
|
7122
|
-
"F-j-Y",
|
|
7123
|
-
"j-F-y",
|
|
7124
|
-
"j-F-Y",
|
|
7125
|
-
"y-F-d",
|
|
7126
|
-
"y-F-j",
|
|
7127
|
-
"y-M-d",
|
|
7128
|
-
"y-M-j",
|
|
7129
|
-
"Y-F-d",
|
|
7130
|
-
"Y-F-j",
|
|
7131
|
-
"Y-M-d",
|
|
7132
|
-
"Y-m-d",
|
|
7133
|
-
"Y-M-j",
|
|
7134
|
-
"Y-m-j",
|
|
7135
|
-
"Y-n-d",
|
|
7136
|
-
"Y-n-j",
|
|
7137
|
-
"j-F",
|
|
7138
|
-
"j-M",
|
|
7139
|
-
"d-F",
|
|
7140
|
-
"d-M",
|
|
7141
|
-
"n-d",
|
|
7142
|
-
"n-j",
|
|
7143
|
-
"n-Y",
|
|
7144
|
-
"m-d",
|
|
7145
|
-
"m-j",
|
|
7146
|
-
"m-Y",
|
|
7147
|
-
"M-Y",
|
|
7148
|
-
"M-y",
|
|
7149
|
-
"F-y",
|
|
7150
|
-
"F-Y",
|
|
7151
|
-
"Y-M",
|
|
7152
|
-
"Y-n",
|
|
7153
|
-
"Y-m",
|
|
7154
|
-
"Y-F",
|
|
7155
|
-
"Y-M"
|
|
7156
|
-
];
|
|
7157
|
-
const dateTrieDM = {};
|
|
7158
|
-
const dateTrieMD = {};
|
|
7159
|
-
function packDate(f, node, allowType = 1) {
|
|
7160
|
-
if (f) {
|
|
7161
|
-
const char = f[0];
|
|
7162
|
-
const next = f.slice(1);
|
|
7163
|
-
if (char === "!") packDate(next, node, 4);
|
|
7164
|
-
else if (char === "?") packDate(next, node, 2);
|
|
7165
|
-
else {
|
|
7166
|
-
node[char] = node[char] || {};
|
|
7167
|
-
packDate(next, node[char], allowType);
|
|
7168
|
-
}
|
|
7169
|
-
} else node.$ = allowType;
|
|
7084
|
+
//#region ../../../packages/core/src/shared/numfmt/parse-format-section.ts
|
|
7085
|
+
function getNumberPattern(part, prefix) {
|
|
7086
|
+
switch (prefix) {
|
|
7087
|
+
case "int": return part.int_pattern;
|
|
7088
|
+
case "frac": return part.frac_pattern;
|
|
7089
|
+
case "man": return part.man_pattern;
|
|
7090
|
+
case "den": return part.den_pattern;
|
|
7091
|
+
case "num": return part.num_pattern;
|
|
7092
|
+
}
|
|
7170
7093
|
}
|
|
7171
|
-
function addFormatToTrie(fmt, trie) {
|
|
7172
|
-
packDate(fmt, trie);
|
|
7173
|
-
packDate(fmt + " x", trie);
|
|
7174
|
-
packDate(fmt + " l", trie);
|
|
7175
|
-
packDate(fmt + " l x", trie);
|
|
7176
|
-
packDate("l " + fmt, trie);
|
|
7177
|
-
packDate("l " + fmt + " x", trie);
|
|
7178
|
-
packDate(fmt + " D", trie);
|
|
7179
|
-
packDate(fmt + " D x", trie);
|
|
7180
|
-
packDate("D " + fmt, trie);
|
|
7181
|
-
packDate("D " + fmt + " x", trie);
|
|
7182
|
-
}
|
|
7183
|
-
okDateFormats.forEach((fmt) => {
|
|
7184
|
-
if (!fmt.startsWith("?")) addFormatToTrie(fmt, dateTrieDM);
|
|
7185
|
-
if (!fmt.startsWith("!")) addFormatToTrie(fmt, dateTrieMD);
|
|
7186
|
-
});
|
|
7187
|
-
const currentYear = (/* @__PURE__ */ new Date()).getUTCFullYear();
|
|
7188
|
-
|
|
7189
|
-
//#endregion
|
|
7190
|
-
//#region ../../../node_modules/.pnpm/numfmt@3.2.6/node_modules/numfmt/lib/parseFormatSection.js
|
|
7191
7094
|
function minMaxPad(str, part, prefix) {
|
|
7192
|
-
|
|
7193
|
-
|
|
7095
|
+
const max = str.length;
|
|
7096
|
+
const min = str.replace(/#/g, "").length;
|
|
7097
|
+
switch (prefix) {
|
|
7098
|
+
case "int":
|
|
7099
|
+
part.int_max = max;
|
|
7100
|
+
part.int_min = min;
|
|
7101
|
+
break;
|
|
7102
|
+
case "frac":
|
|
7103
|
+
part.frac_max = max;
|
|
7104
|
+
part.frac_min = min;
|
|
7105
|
+
break;
|
|
7106
|
+
case "man":
|
|
7107
|
+
part.man_max = max;
|
|
7108
|
+
part.man_min = min;
|
|
7109
|
+
break;
|
|
7110
|
+
case "den":
|
|
7111
|
+
part.den_max = max;
|
|
7112
|
+
part.den_min = min;
|
|
7113
|
+
break;
|
|
7114
|
+
case "num":
|
|
7115
|
+
part.num_max = max;
|
|
7116
|
+
part.num_min = min;
|
|
7117
|
+
break;
|
|
7118
|
+
}
|
|
7194
7119
|
return part;
|
|
7195
7120
|
}
|
|
7196
|
-
function add(
|
|
7197
|
-
if (typeof
|
|
7121
|
+
function add(token, tokens) {
|
|
7122
|
+
if (typeof token === "string") tokens.push({
|
|
7198
7123
|
type: "string",
|
|
7199
|
-
value:
|
|
7124
|
+
value: token
|
|
7200
7125
|
});
|
|
7201
|
-
else tokens.push(
|
|
7126
|
+
else tokens.push(token);
|
|
7202
7127
|
}
|
|
7203
7128
|
function isNumOp(token, activePattern) {
|
|
7204
7129
|
const type = token === null || token === void 0 ? void 0 : token.type;
|
|
7205
7130
|
return type === "hash" || type === "zero" || type === "qmark" || type === "digit" && activePattern === "den";
|
|
7206
7131
|
}
|
|
7132
|
+
function assertNumberChunk(token) {
|
|
7133
|
+
if (token === null) throw new TypeError("Cannot read properties of null (reading 'num')");
|
|
7134
|
+
}
|
|
7207
7135
|
function parseFormatSection(inputTokens) {
|
|
7208
7136
|
const outputTokens = [];
|
|
7209
7137
|
const part = {
|
|
7210
7138
|
scale: 1,
|
|
7139
|
+
scaleExponent: 0,
|
|
7211
7140
|
percent: false,
|
|
7212
7141
|
text: false,
|
|
7213
7142
|
date: 0,
|
|
@@ -7221,7 +7150,24 @@ function parseFormatSection(inputTokens) {
|
|
|
7221
7150
|
man_pattern: [],
|
|
7222
7151
|
den_pattern: [],
|
|
7223
7152
|
num_pattern: [],
|
|
7224
|
-
tokens: outputTokens
|
|
7153
|
+
tokens: outputTokens,
|
|
7154
|
+
tokensUsed: 0,
|
|
7155
|
+
pattern: "",
|
|
7156
|
+
int_max: 0,
|
|
7157
|
+
int_min: 0,
|
|
7158
|
+
frac_max: 0,
|
|
7159
|
+
frac_min: 0,
|
|
7160
|
+
man_max: 0,
|
|
7161
|
+
man_min: 0,
|
|
7162
|
+
num_max: 0,
|
|
7163
|
+
num_min: 0,
|
|
7164
|
+
den_max: 0,
|
|
7165
|
+
den_min: 0,
|
|
7166
|
+
int_p: "",
|
|
7167
|
+
man_p: "",
|
|
7168
|
+
num_p: "",
|
|
7169
|
+
den_p: "",
|
|
7170
|
+
integer: false
|
|
7225
7171
|
};
|
|
7226
7172
|
let currentPattern = "int";
|
|
7227
7173
|
let lastNumberChunk = null;
|
|
@@ -7241,12 +7187,13 @@ function parseFormatSection(inputTokens) {
|
|
|
7241
7187
|
part.general = true;
|
|
7242
7188
|
add(token, outputTokens);
|
|
7243
7189
|
} else if (isNumOp(token, currentPattern)) {
|
|
7244
|
-
const
|
|
7190
|
+
const pattern = getNumberPattern(part, currentPattern);
|
|
7245
7191
|
if (isNumOp(last, currentPattern) || (last === null || last === void 0 ? void 0 : last.type) === "group") {
|
|
7246
|
-
|
|
7192
|
+
pattern.push((pattern.pop() || "") + token.value);
|
|
7193
|
+
assertNumberChunk(lastNumberChunk);
|
|
7247
7194
|
lastNumberChunk.num += token.value;
|
|
7248
7195
|
} else {
|
|
7249
|
-
|
|
7196
|
+
pattern.push(token.value);
|
|
7250
7197
|
lastNumberChunk = {
|
|
7251
7198
|
type: currentPattern,
|
|
7252
7199
|
num: token.value
|
|
@@ -7259,17 +7206,22 @@ function parseFormatSection(inputTokens) {
|
|
|
7259
7206
|
} else if (type === "digit") add(token.value, outputTokens);
|
|
7260
7207
|
else if (type === "slash") {
|
|
7261
7208
|
haveSlash = true;
|
|
7262
|
-
|
|
7209
|
+
const pattern = getNumberPattern(part, currentPattern);
|
|
7210
|
+
if (pattern.length) {
|
|
7263
7211
|
if (!lastNumberChunk) throw new SyntaxError("Format pattern is missing a numerator");
|
|
7264
7212
|
part.fractions = true;
|
|
7265
|
-
|
|
7213
|
+
const numerator = pattern.pop();
|
|
7214
|
+
if (numerator === void 0) throw new SyntaxError("Format pattern is missing a numerator");
|
|
7215
|
+
part.num_pattern.push(numerator);
|
|
7266
7216
|
lastNumberChunk.type = "num";
|
|
7267
7217
|
currentPattern = "den";
|
|
7268
7218
|
add({ type: "div" }, outputTokens);
|
|
7269
7219
|
} else add(token.value, outputTokens);
|
|
7270
7220
|
} else if (type === "comma") add(",", outputTokens);
|
|
7271
|
-
else if (type === "scale")
|
|
7272
|
-
|
|
7221
|
+
else if (type === "scale") {
|
|
7222
|
+
part.scale = .001 ** token.raw.length;
|
|
7223
|
+
part.scaleExponent = -3 * token.raw.length;
|
|
7224
|
+
} else if (type === "group") {
|
|
7273
7225
|
if (currentPattern === "int") part.grouping = true;
|
|
7274
7226
|
if (currentPattern === "den") throw new SyntaxError("Cannot group denominator digits");
|
|
7275
7227
|
} else if (type === "space") add(token, outputTokens);
|
|
@@ -7304,17 +7256,17 @@ function parseFormatSection(inputTokens) {
|
|
|
7304
7256
|
add(bit, outputTokens);
|
|
7305
7257
|
} else if (part.date && type === "point" && ((_inputTokens = inputTokens[index + 1]) === null || _inputTokens === void 0 ? void 0 : _inputTokens.type) === "zero") {
|
|
7306
7258
|
var _inputTokens2, _inputTokens3;
|
|
7307
|
-
let
|
|
7259
|
+
let decimals = 1;
|
|
7308
7260
|
index++;
|
|
7309
7261
|
let raw = "0";
|
|
7310
7262
|
if (((_inputTokens2 = inputTokens[index + 1]) === null || _inputTokens2 === void 0 ? void 0 : _inputTokens2.type) === "zero") {
|
|
7311
7263
|
raw += "0";
|
|
7312
|
-
|
|
7264
|
+
decimals = 2;
|
|
7313
7265
|
index++;
|
|
7314
7266
|
}
|
|
7315
7267
|
if (((_inputTokens3 = inputTokens[index + 1]) === null || _inputTokens3 === void 0 ? void 0 : _inputTokens3.type) === "zero") {
|
|
7316
7268
|
raw += "0";
|
|
7317
|
-
|
|
7269
|
+
decimals = 3;
|
|
7318
7270
|
index++;
|
|
7319
7271
|
}
|
|
7320
7272
|
patternSource += raw;
|
|
@@ -7323,14 +7275,14 @@ function parseFormatSection(inputTokens) {
|
|
|
7323
7275
|
128,
|
|
7324
7276
|
256,
|
|
7325
7277
|
512
|
|
7326
|
-
][
|
|
7278
|
+
][decimals];
|
|
7327
7279
|
part.date = part.date | size;
|
|
7328
7280
|
part.date_eval = true;
|
|
7329
|
-
part.sec_decimals = Math.max(part.sec_decimals,
|
|
7281
|
+
part.sec_decimals = Math.max(part.sec_decimals, decimals);
|
|
7330
7282
|
add({
|
|
7331
7283
|
type: "subsec",
|
|
7332
7284
|
size,
|
|
7333
|
-
decimals
|
|
7285
|
+
decimals,
|
|
7334
7286
|
date: 1
|
|
7335
7287
|
}, outputTokens);
|
|
7336
7288
|
} else if (type === "calendar") {
|
|
@@ -7381,9 +7333,9 @@ function parseFormatSection(inputTokens) {
|
|
|
7381
7333
|
bit.size = 4;
|
|
7382
7334
|
bit.type = "monthname";
|
|
7383
7335
|
}
|
|
7384
|
-
const
|
|
7385
|
-
if (!bit.type &&
|
|
7386
|
-
|
|
7336
|
+
const lastDateChunk = dateChunks[dateChunks.length - 1];
|
|
7337
|
+
if (!bit.type && lastDateChunk && !lastDateChunk.used && lastDateChunk.size & (16 | 64)) {
|
|
7338
|
+
lastDateChunk.used = true;
|
|
7387
7339
|
bit.size = 32;
|
|
7388
7340
|
bit.type = "min";
|
|
7389
7341
|
bit.pad = /mm/.test(value);
|
|
@@ -7398,12 +7350,12 @@ function parseFormatSection(inputTokens) {
|
|
|
7398
7350
|
bit.size = 64;
|
|
7399
7351
|
bit.type = "sec";
|
|
7400
7352
|
bit.pad = /ss/.test(value);
|
|
7401
|
-
const
|
|
7402
|
-
if (
|
|
7403
|
-
else if (
|
|
7404
|
-
delete
|
|
7405
|
-
|
|
7406
|
-
|
|
7353
|
+
const lastDateChunk = dateChunks[dateChunks.length - 1];
|
|
7354
|
+
if (lastDateChunk && lastDateChunk.size & 32) bit.used = true;
|
|
7355
|
+
else if (lastDateChunk === null || lastDateChunk === void 0 ? void 0 : lastDateChunk.indeterminate) {
|
|
7356
|
+
delete lastDateChunk.indeterminate;
|
|
7357
|
+
lastDateChunk.size = 32;
|
|
7358
|
+
lastDateChunk.type = "min";
|
|
7407
7359
|
bit.used = true;
|
|
7408
7360
|
}
|
|
7409
7361
|
} else if (startsWith === "g") {}
|
|
@@ -7418,26 +7370,28 @@ function parseFormatSection(inputTokens) {
|
|
|
7418
7370
|
token.short = token.value === "A/P";
|
|
7419
7371
|
add(token, outputTokens);
|
|
7420
7372
|
} else if (type === "string" || type === "escaped" || type === "char") add(token.value, outputTokens);
|
|
7421
|
-
else if (type === "condition") part.condition = [token.value[0], parseFloat(token.value[1])];
|
|
7373
|
+
else if (type === "condition") part.condition = [token.value[0], Number.parseFloat(token.value[1])];
|
|
7422
7374
|
else if (type === "locale") {
|
|
7423
7375
|
const bits = token.value.split("-");
|
|
7424
7376
|
const code = bits.length < 2 ? "" : bits.slice(1).join("-");
|
|
7425
7377
|
const currency = bits[0];
|
|
7426
7378
|
if (currency) add(currency, outputTokens);
|
|
7427
|
-
const
|
|
7428
|
-
if (
|
|
7429
|
-
const
|
|
7430
|
-
if (isFinite(
|
|
7431
|
-
if ((
|
|
7379
|
+
const locale = resolveLocale(code);
|
|
7380
|
+
if (locale) part.locale = locale;
|
|
7381
|
+
const windowsCode = Number.parseInt(code, 16);
|
|
7382
|
+
if (Number.isFinite(windowsCode) && windowsCode & 16711680) {
|
|
7383
|
+
if ((windowsCode >> 16 & 255) === 6) part.date_system = 6;
|
|
7432
7384
|
}
|
|
7433
7385
|
haveLocale = true;
|
|
7434
7386
|
} else if (type === "color") {
|
|
7435
|
-
|
|
7436
|
-
let
|
|
7437
|
-
|
|
7438
|
-
|
|
7387
|
+
const normalizedColor = token.value.toLowerCase();
|
|
7388
|
+
let color = normalizedColor;
|
|
7389
|
+
const colorMatch = /^color\s*(\d+)$/i.exec(normalizedColor);
|
|
7390
|
+
if (colorMatch) color = Number.parseInt(colorMatch[1], 10);
|
|
7391
|
+
part.color = color;
|
|
7439
7392
|
} else if (type === "percent") {
|
|
7440
7393
|
part.scale = 100;
|
|
7394
|
+
part.scaleExponent = 2;
|
|
7441
7395
|
part.percent = true;
|
|
7442
7396
|
add("%", outputTokens);
|
|
7443
7397
|
} else if (type === "point") {
|
|
@@ -7454,8 +7408,7 @@ function parseFormatSection(inputTokens) {
|
|
|
7454
7408
|
type: "exp",
|
|
7455
7409
|
plus: part.exp_plus
|
|
7456
7410
|
}, outputTokens);
|
|
7457
|
-
} else if (type === "skip") add(token, outputTokens);
|
|
7458
|
-
else if (type === "fill") add(token, outputTokens);
|
|
7411
|
+
} else if (type === "skip" || type === "fill") add(token, outputTokens);
|
|
7459
7412
|
else if (type === "dbnum" || type === "natnum") {} else if (type === "error") throw new SyntaxError(`Illegal character: ${patternSource}`);
|
|
7460
7413
|
else throw new SyntaxError(`Unknown token ${type} in ${patternSource}`);
|
|
7461
7414
|
last = token;
|
|
@@ -7469,34 +7422,34 @@ function parseFormatSection(inputTokens) {
|
|
|
7469
7422
|
const fracPattern = part.frac_pattern.join("");
|
|
7470
7423
|
minMaxPad(intPattern, part, "int");
|
|
7471
7424
|
let min = 0;
|
|
7472
|
-
for (let
|
|
7473
|
-
const
|
|
7474
|
-
if (/^[0-9?]/.test(
|
|
7425
|
+
for (let patternIndex = 0; patternIndex < intPattern.length; patternIndex++) {
|
|
7426
|
+
const character = intPattern[intPattern.length - 1 - patternIndex];
|
|
7427
|
+
if (/^[0-9?]/.test(character)) min = patternIndex + 1;
|
|
7475
7428
|
}
|
|
7476
7429
|
part.int_min = min;
|
|
7477
7430
|
minMaxPad(fracPattern, part, "frac");
|
|
7478
7431
|
minMaxPad(manPattern, part, "man");
|
|
7479
|
-
let
|
|
7480
|
-
let
|
|
7481
|
-
if (
|
|
7482
|
-
|
|
7483
|
-
|
|
7484
|
-
minMaxPad(
|
|
7485
|
-
minMaxPad(
|
|
7486
|
-
|
|
7432
|
+
let numeratorPattern = part.num_pattern.join("");
|
|
7433
|
+
let denominatorPattern = part.den_pattern[0] || "";
|
|
7434
|
+
if (denominatorPattern.includes("?") || numeratorPattern.includes("?")) {
|
|
7435
|
+
denominatorPattern = denominatorPattern.replace(/\d/g, "?");
|
|
7436
|
+
denominatorPattern = denominatorPattern.replace(/#$/g, "?");
|
|
7437
|
+
minMaxPad(numeratorPattern, part, "num");
|
|
7438
|
+
minMaxPad(denominatorPattern, part, "den");
|
|
7439
|
+
numeratorPattern = numeratorPattern.replace(/#$/g, "?");
|
|
7487
7440
|
} else {
|
|
7488
|
-
minMaxPad(
|
|
7489
|
-
minMaxPad(
|
|
7441
|
+
minMaxPad(numeratorPattern, part, "num");
|
|
7442
|
+
minMaxPad(denominatorPattern, part, "den");
|
|
7490
7443
|
}
|
|
7491
7444
|
part.int_p = intPattern;
|
|
7492
7445
|
part.man_p = manPattern;
|
|
7493
|
-
part.num_p =
|
|
7494
|
-
part.den_p =
|
|
7495
|
-
if (part.den_pattern.length) part.denominator = parseInt(part.den_pattern.join("").replace(/\D/g, ""), 10);
|
|
7446
|
+
part.num_p = numeratorPattern;
|
|
7447
|
+
part.den_p = denominatorPattern;
|
|
7448
|
+
if (part.den_pattern.length) part.denominator = Number.parseInt(part.den_pattern.join("").replace(/\D/g, ""), 10);
|
|
7496
7449
|
part.integer = !!intPattern.length;
|
|
7497
7450
|
if (!part.integer && !part.exponential && fracPattern.length) {
|
|
7498
|
-
const
|
|
7499
|
-
part.tokens.splice(
|
|
7451
|
+
const pointIndex = part.tokens.findIndex((token) => token.type === "point");
|
|
7452
|
+
part.tokens.splice(pointIndex, 0, {
|
|
7500
7453
|
type: "int",
|
|
7501
7454
|
value: "#"
|
|
7502
7455
|
});
|
|
@@ -7504,71 +7457,136 @@ function parseFormatSection(inputTokens) {
|
|
|
7504
7457
|
part.int_pattern = ["#"];
|
|
7505
7458
|
part.int_p = "#";
|
|
7506
7459
|
}
|
|
7507
|
-
if (part.fractions) for (let
|
|
7508
|
-
const
|
|
7509
|
-
if (
|
|
7510
|
-
const nextType = outputTokens[
|
|
7511
|
-
if (nextType === "num")
|
|
7512
|
-
else if (nextType === "div")
|
|
7513
|
-
else if (nextType === "den")
|
|
7514
|
-
}
|
|
7515
|
-
if (part.grouping) {
|
|
7516
|
-
if (part.int_pattern.length > 1) part.grouping = false;
|
|
7460
|
+
if (part.fractions) for (let tokenIndex = 0; tokenIndex < outputTokens.length - 1; tokenIndex++) {
|
|
7461
|
+
const token = outputTokens[tokenIndex];
|
|
7462
|
+
if (token.type !== "string" && token.type !== "space") continue;
|
|
7463
|
+
const nextType = outputTokens[tokenIndex + 1].type;
|
|
7464
|
+
if (nextType === "num") token.rule = "num+int";
|
|
7465
|
+
else if (nextType === "div") token.rule = "num";
|
|
7466
|
+
else if (nextType === "den") token.rule = "den";
|
|
7517
7467
|
}
|
|
7468
|
+
if (part.grouping && part.int_pattern.length > 1) part.grouping = false;
|
|
7518
7469
|
return part;
|
|
7519
7470
|
}
|
|
7520
7471
|
|
|
7521
7472
|
//#endregion
|
|
7522
|
-
//#region ../../../
|
|
7523
|
-
const
|
|
7473
|
+
//#region ../../../packages/core/src/shared/numfmt/format-number.ts
|
|
7474
|
+
const defaultText = parseFormatSection([{
|
|
7524
7475
|
type: TOKEN_TEXT,
|
|
7525
7476
|
value: "@",
|
|
7526
7477
|
raw: "@"
|
|
7527
7478
|
}]);
|
|
7528
7479
|
|
|
7529
7480
|
//#endregion
|
|
7530
|
-
//#region ../../../
|
|
7531
|
-
|
|
7532
|
-
|
|
7533
|
-
|
|
7534
|
-
|
|
7535
|
-
|
|
7536
|
-
|
|
7537
|
-
|
|
7538
|
-
|
|
7539
|
-
|
|
7540
|
-
|
|
7541
|
-
|
|
7542
|
-
|
|
7543
|
-
|
|
7544
|
-
|
|
7545
|
-
|
|
7546
|
-
|
|
7547
|
-
|
|
7548
|
-
|
|
7549
|
-
|
|
7550
|
-
|
|
7551
|
-
|
|
7552
|
-
|
|
7553
|
-
|
|
7554
|
-
|
|
7555
|
-
|
|
7556
|
-
|
|
7557
|
-
|
|
7558
|
-
|
|
7559
|
-
|
|
7560
|
-
|
|
7561
|
-
|
|
7562
|
-
|
|
7563
|
-
|
|
7564
|
-
|
|
7565
|
-
|
|
7566
|
-
|
|
7567
|
-
|
|
7568
|
-
|
|
7569
|
-
|
|
7570
|
-
|
|
7571
|
-
|
|
7481
|
+
//#region ../../../packages/core/src/shared/numfmt/serial-date.ts
|
|
7482
|
+
const dateUTC = Date.UTC;
|
|
7483
|
+
|
|
7484
|
+
//#endregion
|
|
7485
|
+
//#region ../../../packages/core/src/shared/numfmt/parse-value.ts
|
|
7486
|
+
const okDateFormats = [
|
|
7487
|
+
"!d-m-y",
|
|
7488
|
+
"!d-m-Y",
|
|
7489
|
+
"!j-m-y",
|
|
7490
|
+
"!j-m-Y",
|
|
7491
|
+
"!d-n-y",
|
|
7492
|
+
"!d-n-Y",
|
|
7493
|
+
"!j-n-y",
|
|
7494
|
+
"!j-n-Y",
|
|
7495
|
+
"?m-d-y",
|
|
7496
|
+
"?m-d-Y",
|
|
7497
|
+
"?m-j-y",
|
|
7498
|
+
"?m-j-Y",
|
|
7499
|
+
"?n-d-y",
|
|
7500
|
+
"?n-d-Y",
|
|
7501
|
+
"?n-j-y",
|
|
7502
|
+
"?n-j-Y",
|
|
7503
|
+
"d-M-y",
|
|
7504
|
+
"d-M-Y",
|
|
7505
|
+
"j-M-y",
|
|
7506
|
+
"j-M-Y",
|
|
7507
|
+
"M-d-y",
|
|
7508
|
+
"M-d-Y",
|
|
7509
|
+
"M-j-y",
|
|
7510
|
+
"M-j-Y",
|
|
7511
|
+
"d-F-y",
|
|
7512
|
+
"d-F-Y",
|
|
7513
|
+
"F-d-y",
|
|
7514
|
+
"F-d-Y",
|
|
7515
|
+
"F-j-y",
|
|
7516
|
+
"F-j-Y",
|
|
7517
|
+
"j-F-y",
|
|
7518
|
+
"j-F-Y",
|
|
7519
|
+
"y-F-d",
|
|
7520
|
+
"y-F-j",
|
|
7521
|
+
"y-M-d",
|
|
7522
|
+
"y-M-j",
|
|
7523
|
+
"Y-F-d",
|
|
7524
|
+
"Y-F-j",
|
|
7525
|
+
"Y-M-d",
|
|
7526
|
+
"Y-m-d",
|
|
7527
|
+
"Y-M-j",
|
|
7528
|
+
"Y-m-j",
|
|
7529
|
+
"Y-n-d",
|
|
7530
|
+
"Y-n-j",
|
|
7531
|
+
"j-F",
|
|
7532
|
+
"j-M",
|
|
7533
|
+
"d-F",
|
|
7534
|
+
"d-M",
|
|
7535
|
+
"n-d",
|
|
7536
|
+
"n-j",
|
|
7537
|
+
"n-Y",
|
|
7538
|
+
"m-d",
|
|
7539
|
+
"m-j",
|
|
7540
|
+
"m-Y",
|
|
7541
|
+
"M-Y",
|
|
7542
|
+
"M-y",
|
|
7543
|
+
"F-y",
|
|
7544
|
+
"F-Y",
|
|
7545
|
+
"Y-M",
|
|
7546
|
+
"Y-n",
|
|
7547
|
+
"Y-m",
|
|
7548
|
+
"Y-F",
|
|
7549
|
+
"Y-M"
|
|
7550
|
+
];
|
|
7551
|
+
const dateTrieDM = {};
|
|
7552
|
+
const dateTrieMD = {};
|
|
7553
|
+
function packDate(format, node, allowType = 1) {
|
|
7554
|
+
if (format) {
|
|
7555
|
+
const char = format[0];
|
|
7556
|
+
const next = format.slice(1);
|
|
7557
|
+
if (char === "!") packDate(next, node, 4);
|
|
7558
|
+
else if (char === "?") packDate(next, node, 2);
|
|
7559
|
+
else {
|
|
7560
|
+
let branch = node[char];
|
|
7561
|
+
if (typeof branch !== "object") {
|
|
7562
|
+
branch = {};
|
|
7563
|
+
node[char] = branch;
|
|
7564
|
+
}
|
|
7565
|
+
packDate(next, branch, allowType);
|
|
7566
|
+
}
|
|
7567
|
+
} else node.$ = allowType;
|
|
7568
|
+
}
|
|
7569
|
+
function addFormatToTrie(format, trie) {
|
|
7570
|
+
packDate(format, trie);
|
|
7571
|
+
packDate(`${format} x`, trie);
|
|
7572
|
+
packDate(`${format} l`, trie);
|
|
7573
|
+
packDate(`${format} l x`, trie);
|
|
7574
|
+
packDate(`l ${format}`, trie);
|
|
7575
|
+
packDate(`l ${format} x`, trie);
|
|
7576
|
+
packDate(`${format} D`, trie);
|
|
7577
|
+
packDate(`${format} D x`, trie);
|
|
7578
|
+
packDate(`D ${format}`, trie);
|
|
7579
|
+
packDate(`D ${format} x`, trie);
|
|
7580
|
+
}
|
|
7581
|
+
okDateFormats.forEach((format) => {
|
|
7582
|
+
if (!format.startsWith("?")) addFormatToTrie(format, dateTrieDM);
|
|
7583
|
+
if (!format.startsWith("!")) addFormatToTrie(format, dateTrieMD);
|
|
7584
|
+
});
|
|
7585
|
+
const currentYear = (/* @__PURE__ */ new Date()).getUTCFullYear();
|
|
7586
|
+
|
|
7587
|
+
//#endregion
|
|
7588
|
+
//#region ../../../packages/core/src/shared/numfmt/api.ts
|
|
7589
|
+
/** A dictionary of the types used to identify token variants. */
|
|
7572
7590
|
const tokenTypes = Object.freeze({
|
|
7573
7591
|
AMPM: TOKEN_AMPM,
|
|
7574
7592
|
BREAK: TOKEN_BREAK,
|
|
@@ -7920,7 +7938,7 @@ const regexp = {
|
|
|
7920
7938
|
};
|
|
7921
7939
|
|
|
7922
7940
|
//#endregion
|
|
7923
|
-
//#region ../../../packages/core/src/shared/numfmt.ts
|
|
7941
|
+
//#region ../../../packages/core/src/shared/numfmt/utils.ts
|
|
7924
7942
|
const currencySymbols = [
|
|
7925
7943
|
"Rp",
|
|
7926
7944
|
"zł",
|
|
@@ -9322,6 +9340,7 @@ const STYLE_KEYS = defineExactKeys()([
|
|
|
9322
9340
|
"cl",
|
|
9323
9341
|
"va",
|
|
9324
9342
|
"n",
|
|
9343
|
+
"stf",
|
|
9325
9344
|
"tr",
|
|
9326
9345
|
"td",
|
|
9327
9346
|
"ht",
|
|
@@ -18072,6 +18091,10 @@ _defineProperty(BuildTextUtils, "paragraph", {
|
|
|
18072
18091
|
});
|
|
18073
18092
|
_defineProperty(BuildTextUtils, "drawing", { add: addDrawing });
|
|
18074
18093
|
|
|
18094
|
+
//#endregion
|
|
18095
|
+
//#region ../../../packages/core/src/docs/data-model/rich-text-builder.ts
|
|
18096
|
+
const NON_EDITABLE_RICH_TEXT_TOKENS = new Set(Object.values(DataStreamTreeTokenType).filter((token) => token !== "" && token !== " "));
|
|
18097
|
+
|
|
18075
18098
|
//#endregion
|
|
18076
18099
|
//#region ../../../packages/core/src/services/resource-manager/type.ts
|
|
18077
18100
|
const IResourceManagerService = createIdentifier("core.resource-manager.service");
|