@rowsncolumns/utils 9.5.7 → 9.6.1
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/dist/cjs/cell-data-helpers.d.ts +8 -2
- package/dist/cjs/cell-data-helpers.d.ts.map +1 -1
- package/dist/cjs/cell-data-helpers.js +11 -3
- package/dist/cjs/cjk-number-format.d.ts +11 -0
- package/dist/cjs/cjk-number-format.d.ts.map +1 -0
- package/dist/cjs/cjk-number-format.js +533 -0
- package/dist/cjs/color.d.ts +9 -0
- package/dist/cjs/color.d.ts.map +1 -1
- package/dist/cjs/color.js +55 -1
- package/dist/cjs/formatter.d.ts +42 -0
- package/dist/cjs/formatter.d.ts.map +1 -1
- package/dist/cjs/formatter.js +179 -6
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/esm/cell-data-helpers.d.ts +8 -2
- package/dist/esm/cell-data-helpers.d.ts.map +1 -1
- package/dist/esm/cell-data-helpers.js +9 -2
- package/dist/esm/cjk-number-format.d.ts +11 -0
- package/dist/esm/cjk-number-format.d.ts.map +1 -0
- package/dist/esm/cjk-number-format.js +494 -0
- package/dist/esm/color.d.ts +9 -0
- package/dist/esm/color.d.ts.map +1 -1
- package/dist/esm/color.js +53 -0
- package/dist/esm/formatter.d.ts +42 -0
- package/dist/esm/formatter.d.ts.map +1 -1
- package/dist/esm/formatter.js +162 -4
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +2 -2
package/dist/cjs/color.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getContrastColor = exports.expandChartPalette = exports.chartPaletteColorAt = exports.applyLumModOff = exports.CHART_PALETTE_VARIATIONS = exports.rgbToHex = exports.hexToRgb = exports.lightenColor = exports.colorStringToHex = exports.isSameColor = exports.rgbaToArgbHex = exports.getSelectionColorAtIndex = void 0;
|
|
3
|
+
exports.getContrastColor = exports.expandChartPalette = exports.chartPaletteColorAt = exports.applyLumModOff = exports.CHART_PALETTE_VARIATIONS = exports.rgbToHex = exports.hexToRgb = exports.applyTint = exports.lightenColor = exports.colorStringToHex = exports.isSameColor = exports.rgbaToArgbHex = exports.getSelectionColorAtIndex = void 0;
|
|
4
4
|
exports.normalizeColor = normalizeColor;
|
|
5
5
|
var tslib_1 = require("tslib");
|
|
6
6
|
var typeguards_1 = require("./typeguards");
|
|
@@ -126,6 +126,60 @@ var lightenColor = function (unit, color) {
|
|
|
126
126
|
return rgbColor ? shade(unit, rgbColor) : undefined;
|
|
127
127
|
};
|
|
128
128
|
exports.lightenColor = lightenColor;
|
|
129
|
+
/**
|
|
130
|
+
* Excel's tint (ECMA-376 Part 1, §18.8.19 `CT_Color@tint`) — what a `{ theme, tint }` colour paints
|
|
131
|
+
* as. Unlike `lightenColor`, which blends each channel toward black or white, the colour moves to
|
|
132
|
+
* HLS and only its luminance changes: `L·(1+tint)` for a negative tint, `L·(1−tint) + tint` for a
|
|
133
|
+
* positive one. Hue and saturation stay, so accent1 `#4472C4` at −25 % is Excel's `#2F5597` (not
|
|
134
|
+
* `#335693`) and accent2 `#ED7D31` at −25 % is `#C55A11`. The engine's `rnc_model::apply_tint`
|
|
135
|
+
* is the same rule. Returns `#rrggbb` (as `rgbToHex`); `undefined` for a colour it cannot read.
|
|
136
|
+
*/
|
|
137
|
+
var applyTint = function (tint, color) {
|
|
138
|
+
var rgba = normalizeColor(color);
|
|
139
|
+
if (!rgba || rgba.a === 0)
|
|
140
|
+
return undefined;
|
|
141
|
+
if (!Number.isFinite(tint) || tint === 0) {
|
|
142
|
+
return (0, exports.rgbToHex)(Math.round(rgba.r), Math.round(rgba.g), Math.round(rgba.b));
|
|
143
|
+
}
|
|
144
|
+
var t = Math.max(-1, Math.min(1, tint));
|
|
145
|
+
var _a = tslib_1.__read(rgbToHls(rgba.r / 255, rgba.g / 255, rgba.b / 255), 3), h = _a[0], l = _a[1], s = _a[2];
|
|
146
|
+
var lum = Math.max(0, Math.min(1, t < 0 ? l * (1 + t) : l * (1 - t) + t));
|
|
147
|
+
var _b = tslib_1.__read(hlsToRgb(h, lum, s), 3), r = _b[0], g = _b[1], b = _b[2];
|
|
148
|
+
var byte = function (c) { return Math.max(0, Math.min(255, Math.round(c * 255))); };
|
|
149
|
+
return (0, exports.rgbToHex)(byte(r), byte(g), byte(b));
|
|
150
|
+
};
|
|
151
|
+
exports.applyTint = applyTint;
|
|
152
|
+
var rgbToHls = function (r, g, b) {
|
|
153
|
+
var max = Math.max(r, g, b);
|
|
154
|
+
var min = Math.min(r, g, b);
|
|
155
|
+
var l = (max + min) / 2;
|
|
156
|
+
if (max === min)
|
|
157
|
+
return [0, l, 0];
|
|
158
|
+
var range = max - min;
|
|
159
|
+
var s = l <= 0.5 ? range / (max + min) : range / (2 - max - min);
|
|
160
|
+
var rc = (max - r) / range;
|
|
161
|
+
var gc = (max - g) / range;
|
|
162
|
+
var bc = (max - b) / range;
|
|
163
|
+
var h = r === max ? bc - gc : g === max ? 2 + rc - bc : 4 + gc - rc;
|
|
164
|
+
return [(((h / 6) % 1) + 1) % 1, l, s];
|
|
165
|
+
};
|
|
166
|
+
var hlsToRgb = function (h, l, s) {
|
|
167
|
+
if (s === 0)
|
|
168
|
+
return [l, l, l];
|
|
169
|
+
var m2 = l <= 0.5 ? l * (1 + s) : l + s - l * s;
|
|
170
|
+
var m1 = 2 * l - m2;
|
|
171
|
+
var v = function (hue) {
|
|
172
|
+
var x = ((hue % 1) + 1) % 1;
|
|
173
|
+
if (x < 1 / 6)
|
|
174
|
+
return m1 + (m2 - m1) * x * 6;
|
|
175
|
+
if (x < 0.5)
|
|
176
|
+
return m2;
|
|
177
|
+
if (x < 2 / 3)
|
|
178
|
+
return m1 + (m2 - m1) * (2 / 3 - x) * 6;
|
|
179
|
+
return m1;
|
|
180
|
+
};
|
|
181
|
+
return [v(h + 1 / 3), v(h), v(h - 1 / 3)];
|
|
182
|
+
};
|
|
129
183
|
var hexToRgb = function (hex) {
|
|
130
184
|
var bigint = parseInt(hex.slice(1), 16);
|
|
131
185
|
var r = (bigint >> 16) & 255;
|
package/dist/cjs/formatter.d.ts
CHANGED
|
@@ -44,5 +44,47 @@ export declare const withShortAmPmMarker: (pattern: string) => string | undefine
|
|
|
44
44
|
*/
|
|
45
45
|
export declare const withWorkbookSeparators: (pattern: string, locale?: string) => string | undefined;
|
|
46
46
|
export declare const ssfFormat: (pattern: string, value: any, locale?: string) => string;
|
|
47
|
+
/**
|
|
48
|
+
* One piece of a number format's width-aware output (see
|
|
49
|
+
* {@link ssfFormatLayout}):
|
|
50
|
+
* - `text` — literal characters, painted as they are;
|
|
51
|
+
* - `fill` — Excel's `*x`: `x` repeated to fill the cell's free width;
|
|
52
|
+
* - `skip` — Excel's `_x`: blank space as wide as the glyph `x`;
|
|
53
|
+
* - `digit` — a `?` placeholder with no digit: blank space as wide as a
|
|
54
|
+
* digit.
|
|
55
|
+
*/
|
|
56
|
+
export type NumberFormatLayoutPart = {
|
|
57
|
+
type: "text";
|
|
58
|
+
text: string;
|
|
59
|
+
} | {
|
|
60
|
+
type: "fill";
|
|
61
|
+
char: string;
|
|
62
|
+
} | {
|
|
63
|
+
type: "skip";
|
|
64
|
+
char: string;
|
|
65
|
+
} | {
|
|
66
|
+
type: "digit";
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Excel's width-aware number-format output: `*x` repeats `x` to the cell's
|
|
70
|
+
* width, `_x` reserves the width of `x` and `?` reserves a digit's width
|
|
71
|
+
* ("Number format codes", support.microsoft.com). A plain formatted string
|
|
72
|
+
* cannot carry that — `ssfFormat` drops the fill and renders the reserves as
|
|
73
|
+
* single spaces — so the painter asks for the parts and expands them with
|
|
74
|
+
* measured glyph widths.
|
|
75
|
+
*
|
|
76
|
+
* Returns `undefined` when the pattern has none of those tokens (the plain
|
|
77
|
+
* string is already exact), and for East Asian numeral codes. The parts'
|
|
78
|
+
* plain text ({@link numberFormatLayoutText}) equals `ssfFormat`'s output;
|
|
79
|
+
* callers compare it against the string they paint and ignore the layout
|
|
80
|
+
* when the two disagree.
|
|
81
|
+
*/
|
|
82
|
+
export declare const ssfFormatLayout: (pattern: string, value: any, locale?: string) => NumberFormatLayoutPart[] | undefined;
|
|
83
|
+
/**
|
|
84
|
+
* The plain string a layout stands for — what `ssfFormat` returns for the
|
|
85
|
+
* same pattern and value: fills drop out, skips and digit pads are one
|
|
86
|
+
* space each.
|
|
87
|
+
*/
|
|
88
|
+
export declare const numberFormatLayoutText: (parts: readonly NumberFormatLayoutPart[]) => string;
|
|
47
89
|
export declare const ssfFormatColor: (pattern: string, value: any) => string | undefined;
|
|
48
90
|
//# sourceMappingURL=formatter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatter.d.ts","sourceRoot":"","sources":["../../formatter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"formatter.d.ts","sourceRoot":"","sources":["../../formatter.ts"],"names":[],"mappings":"AAkBA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,aAAa,GAAI,SAAS,MAAM,GAAG,SAAS,GAAG,IAAI,KAAG,OASlE,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAC5B,SAAS,MAAM,GAAG,SAAS,GAAG,IAAI,KACjC,OAWF,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,SAAS,MAAM,GAAG,SAAS,GAAG,IAAI,KAAG,OAWlE,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,SAAS,MAAM,GAAG,SAAS,GAAG,IAAI,KAAG,OAOlE,CAAC;AAMF;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,GAAI,SAAS,MAAM,KAAG,OA4B1D,CAAC;AA+LF;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,GAAI,SAAS,MAAM,KAAG,MAAM,GAAG,SA4C9D,CAAC;AAiIF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,sBAAsB,GACjC,SAAS,MAAM,EACf,SAAS,MAAM,KACd,MAAM,GAAG,SAiBX,CAAC;AAiBF,eAAO,MAAM,SAAS,GACpB,SAAS,MAAM,EACf,OAAO,GAAG,EACV,SAAS,MAAM,KACd,MASF,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,sBAAsB,GAC9B;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC9B;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC9B;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC9B;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC;AAoDtB;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,eAAe,GAC1B,SAAS,MAAM,EACf,OAAO,GAAG,EACV,SAAS,MAAM,KACd,sBAAsB,EAAE,GAAG,SA8C7B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,GACjC,OAAO,SAAS,sBAAsB,EAAE,KACvC,MAOF,CAAC;AAkQF,eAAO,MAAM,cAAc,GACzB,SAAS,MAAM,EACf,OAAO,GAAG,KACT,MAAM,GAAG,SAoBX,CAAC"}
|
package/dist/cjs/formatter.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ssfFormatColor = exports.ssfFormat = exports.withWorkbookSeparators = exports.withShortAmPmMarker = exports.isStandaloneMonthPattern = exports.isTextPattern = exports.isTimePattern = exports.isDateTimePattern = exports.isDatePattern = void 0;
|
|
3
|
+
exports.ssfFormatColor = exports.numberFormatLayoutText = exports.ssfFormatLayout = exports.ssfFormat = exports.withWorkbookSeparators = exports.withShortAmPmMarker = exports.isStandaloneMonthPattern = exports.isTextPattern = exports.isTimePattern = exports.isDateTimePattern = exports.isDatePattern = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
var numfmt_1 = require("numfmt");
|
|
6
|
+
var cjk_number_format_1 = require("./cjk-number-format");
|
|
6
7
|
var colors_1 = require("./colors");
|
|
7
8
|
var excel_number_format_1 = require("./excel-number-format");
|
|
8
9
|
/**
|
|
@@ -529,6 +530,169 @@ var withWorkbookSeparatorsCached = function (code, locale) {
|
|
|
529
530
|
return rewritten;
|
|
530
531
|
};
|
|
531
532
|
var ssfFormat = function (pattern, value, locale) {
|
|
533
|
+
// East Asian tokens numfmt does not render (`[DBNumN]`, Japanese era `g`/`e`,
|
|
534
|
+
// `aaa` weekdays): rewrite the code to plain literals, then convert the
|
|
535
|
+
// rendered digits to the `[DBNumN]` numeral system (see cjk-number-format).
|
|
536
|
+
if (typeof value === "number") {
|
|
537
|
+
var cjk = (0, cjk_number_format_1.prepareCjkNumberFormat)(pattern, value, locale);
|
|
538
|
+
if (cjk)
|
|
539
|
+
return cjk.finish(ssfFormatBase(cjk.code, value, locale));
|
|
540
|
+
}
|
|
541
|
+
return ssfFormatBase(pattern, value, locale);
|
|
542
|
+
};
|
|
543
|
+
exports.ssfFormat = ssfFormat;
|
|
544
|
+
var LAYOUT_FILL_MARK = "\uE000";
|
|
545
|
+
var LAYOUT_SKIP_MARK = "\uE001";
|
|
546
|
+
var LAYOUT_LITERAL_SPACE = "\uE002";
|
|
547
|
+
var LAYOUT_DIGIT_PAD = "\u00a0";
|
|
548
|
+
/**
|
|
549
|
+
* Quote every literal space of `code` as a private-use sentinel so that,
|
|
550
|
+
* rendered with numfmt's `nbsp` option, the only non-breaking spaces left
|
|
551
|
+
* in the output are the `?` digit pads.
|
|
552
|
+
*/
|
|
553
|
+
var markLiteralSpaces = function (code) {
|
|
554
|
+
var _a;
|
|
555
|
+
var out = "";
|
|
556
|
+
var inQuotes = false;
|
|
557
|
+
var inBrackets = false;
|
|
558
|
+
for (var i = 0; i < code.length; i++) {
|
|
559
|
+
var char = code[i];
|
|
560
|
+
if (inQuotes) {
|
|
561
|
+
if (char === '"')
|
|
562
|
+
inQuotes = false;
|
|
563
|
+
out += char === " " ? LAYOUT_LITERAL_SPACE : char;
|
|
564
|
+
continue;
|
|
565
|
+
}
|
|
566
|
+
if (inBrackets) {
|
|
567
|
+
if (char === "]")
|
|
568
|
+
inBrackets = false;
|
|
569
|
+
out += char;
|
|
570
|
+
continue;
|
|
571
|
+
}
|
|
572
|
+
if (char === '"') {
|
|
573
|
+
inQuotes = true;
|
|
574
|
+
}
|
|
575
|
+
else if (char === "[") {
|
|
576
|
+
inBrackets = true;
|
|
577
|
+
}
|
|
578
|
+
else if (char === "\\" && code[i + 1] === " ") {
|
|
579
|
+
out += "\"".concat(LAYOUT_LITERAL_SPACE, "\"");
|
|
580
|
+
i++;
|
|
581
|
+
continue;
|
|
582
|
+
}
|
|
583
|
+
else if (char === "\\" || char === "_" || char === "*") {
|
|
584
|
+
out += char + ((_a = code[i + 1]) !== null && _a !== void 0 ? _a : "");
|
|
585
|
+
i++;
|
|
586
|
+
continue;
|
|
587
|
+
}
|
|
588
|
+
else if (char === " ") {
|
|
589
|
+
out += "\"".concat(LAYOUT_LITERAL_SPACE, "\"");
|
|
590
|
+
continue;
|
|
591
|
+
}
|
|
592
|
+
out += char;
|
|
593
|
+
}
|
|
594
|
+
return out;
|
|
595
|
+
};
|
|
596
|
+
/** Does the pattern carry a `*` fill, `_` skip or `?` placeholder at all? */
|
|
597
|
+
var LAYOUT_TOKEN_REGEX = /[*_?]/;
|
|
598
|
+
/**
|
|
599
|
+
* Excel's width-aware number-format output: `*x` repeats `x` to the cell's
|
|
600
|
+
* width, `_x` reserves the width of `x` and `?` reserves a digit's width
|
|
601
|
+
* ("Number format codes", support.microsoft.com). A plain formatted string
|
|
602
|
+
* cannot carry that — `ssfFormat` drops the fill and renders the reserves as
|
|
603
|
+
* single spaces — so the painter asks for the parts and expands them with
|
|
604
|
+
* measured glyph widths.
|
|
605
|
+
*
|
|
606
|
+
* Returns `undefined` when the pattern has none of those tokens (the plain
|
|
607
|
+
* string is already exact), and for East Asian numeral codes. The parts'
|
|
608
|
+
* plain text ({@link numberFormatLayoutText}) equals `ssfFormat`'s output;
|
|
609
|
+
* callers compare it against the string they paint and ignore the layout
|
|
610
|
+
* when the two disagree.
|
|
611
|
+
*/
|
|
612
|
+
var ssfFormatLayout = function (pattern, value, locale) {
|
|
613
|
+
var _a;
|
|
614
|
+
if (!pattern || !LAYOUT_TOKEN_REGEX.test(pattern))
|
|
615
|
+
return undefined;
|
|
616
|
+
if (typeof value === "number" && (0, cjk_number_format_1.prepareCjkNumberFormat)(pattern, value, locale)) {
|
|
617
|
+
return undefined;
|
|
618
|
+
}
|
|
619
|
+
var raw = ssfFormatBase(pattern, value, locale, {
|
|
620
|
+
nbsp: true,
|
|
621
|
+
fillChar: LAYOUT_FILL_MARK,
|
|
622
|
+
skipChar: LAYOUT_SKIP_MARK,
|
|
623
|
+
transform: markLiteralSpaces,
|
|
624
|
+
});
|
|
625
|
+
if (raw === undefined)
|
|
626
|
+
return undefined;
|
|
627
|
+
// A locale whose group separator is itself a non-breaking space makes the
|
|
628
|
+
// digit pads ambiguous: keep those as plain spaces.
|
|
629
|
+
var digitPads = separatorsFor(locale).group !== LAYOUT_DIGIT_PAD;
|
|
630
|
+
var parts = [];
|
|
631
|
+
var text = "";
|
|
632
|
+
var flush = function () {
|
|
633
|
+
if (text)
|
|
634
|
+
parts.push({ type: "text", text: text });
|
|
635
|
+
text = "";
|
|
636
|
+
};
|
|
637
|
+
for (var i = 0; i < raw.length; i++) {
|
|
638
|
+
var char = raw[i];
|
|
639
|
+
if (char === LAYOUT_FILL_MARK || char === LAYOUT_SKIP_MARK) {
|
|
640
|
+
var next = (_a = raw[i + 1]) !== null && _a !== void 0 ? _a : " ";
|
|
641
|
+
flush();
|
|
642
|
+
parts.push({
|
|
643
|
+
type: char === LAYOUT_FILL_MARK ? "fill" : "skip",
|
|
644
|
+
char: next,
|
|
645
|
+
});
|
|
646
|
+
i++;
|
|
647
|
+
}
|
|
648
|
+
else if (char === LAYOUT_DIGIT_PAD) {
|
|
649
|
+
if (digitPads) {
|
|
650
|
+
flush();
|
|
651
|
+
parts.push({ type: "digit" });
|
|
652
|
+
}
|
|
653
|
+
else {
|
|
654
|
+
text += char;
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
else if (char === LAYOUT_LITERAL_SPACE) {
|
|
658
|
+
text += " ";
|
|
659
|
+
}
|
|
660
|
+
else {
|
|
661
|
+
text += char;
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
flush();
|
|
665
|
+
return parts.some(function (part) { return part.type !== "text"; }) ? parts : undefined;
|
|
666
|
+
};
|
|
667
|
+
exports.ssfFormatLayout = ssfFormatLayout;
|
|
668
|
+
/**
|
|
669
|
+
* The plain string a layout stands for — what `ssfFormat` returns for the
|
|
670
|
+
* same pattern and value: fills drop out, skips and digit pads are one
|
|
671
|
+
* space each.
|
|
672
|
+
*/
|
|
673
|
+
var numberFormatLayoutText = function (parts) {
|
|
674
|
+
var e_2, _a;
|
|
675
|
+
var out = "";
|
|
676
|
+
try {
|
|
677
|
+
for (var parts_1 = tslib_1.__values(parts), parts_1_1 = parts_1.next(); !parts_1_1.done; parts_1_1 = parts_1.next()) {
|
|
678
|
+
var part = parts_1_1.value;
|
|
679
|
+
if (part.type === "text")
|
|
680
|
+
out += part.text;
|
|
681
|
+
else if (part.type !== "fill")
|
|
682
|
+
out += " ";
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
686
|
+
finally {
|
|
687
|
+
try {
|
|
688
|
+
if (parts_1_1 && !parts_1_1.done && (_a = parts_1.return)) _a.call(parts_1);
|
|
689
|
+
}
|
|
690
|
+
finally { if (e_2) throw e_2.error; }
|
|
691
|
+
}
|
|
692
|
+
return out;
|
|
693
|
+
};
|
|
694
|
+
exports.numberFormatLayoutText = numberFormatLayoutText;
|
|
695
|
+
function ssfFormatBase(pattern, value, locale, layout) {
|
|
532
696
|
try {
|
|
533
697
|
if (locale)
|
|
534
698
|
ensureNumfmtLocale(locale);
|
|
@@ -537,12 +701,22 @@ var ssfFormat = function (pattern, value, locale) {
|
|
|
537
701
|
shortAmPm = (0, exports.withShortAmPmMarker)(pattern);
|
|
538
702
|
shortAmPmPatternCache.set(pattern, shortAmPm);
|
|
539
703
|
}
|
|
540
|
-
var
|
|
704
|
+
var baseCode = withWorkbookSeparatorsCached(shortAmPm !== null && shortAmPm !== void 0 ? shortAmPm : pattern, locale);
|
|
705
|
+
var code = layout ? layout.transform(baseCode) : baseCode;
|
|
541
706
|
var patternLocale = localeForPattern(pattern, locale);
|
|
542
707
|
if (shortAmPm !== undefined && patternLocale) {
|
|
543
708
|
patternLocale = getShortAmPmLocale(patternLocale);
|
|
544
709
|
}
|
|
545
|
-
|
|
710
|
+
// numfmt types `fillChar` / `skipChar` as booleans; at runtime they are
|
|
711
|
+
// the marker strings it emits ahead of the fill / skip character.
|
|
712
|
+
var options_1 = layout
|
|
713
|
+
? {
|
|
714
|
+
locale: patternLocale,
|
|
715
|
+
nbsp: layout.nbsp,
|
|
716
|
+
fillChar: layout.fillChar,
|
|
717
|
+
skipChar: layout.skipChar,
|
|
718
|
+
}
|
|
719
|
+
: { locale: patternLocale };
|
|
546
720
|
if (typeof value === "number") {
|
|
547
721
|
// Excel decides rounding, `General`, huge magnitudes and conditional
|
|
548
722
|
// sections from the 15-significant-digit decimal, not the binary
|
|
@@ -560,10 +734,9 @@ var ssfFormat = function (pattern, value, locale) {
|
|
|
560
734
|
return isNegativeElapsedTime ? "-".concat(formatted) : formatted;
|
|
561
735
|
}
|
|
562
736
|
catch (err) {
|
|
563
|
-
return String(value);
|
|
737
|
+
return layout ? undefined : String(value);
|
|
564
738
|
}
|
|
565
|
-
}
|
|
566
|
-
exports.ssfFormat = ssfFormat;
|
|
739
|
+
}
|
|
567
740
|
/**
|
|
568
741
|
* Excel's legacy fixed 56-color palette used by `[ColorN]` directives
|
|
569
742
|
* inside number format patterns (1-indexed). This palette is INDEPENDENT
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["../../array.ts","../../cell-data-helpers.ts","../../clipboard-html-sanitize.ts","../../color.ts","../../colors.ts","../../condition-operand.ts","../../conditional-format.ts","../../content-hash.ts","../../data-validation.ts","../../date.ts","../../dom.ts","../../excel-number-format.ts","../../formatter.ts","../../formula-locale.ts","../../formula-refs.ts","../../formula.ts","../../index.ts","../../keyboard.ts","../../locale.ts","../../log.ts","../../memoize.ts","../../numbers.ts","../../rich-text-html.ts","../../rich-text-links.ts","../../selection.ts","../../shared-string-canonical.ts","../../sheet-names.ts","../../sheet-protection.ts","../../sheet-span.ts","../../sort.ts","../../sparkline-groups.ts","../../string.ts","../../table-names.ts","../../table-styles.ts","../../table-totals.ts","../../typeguards.ts","../../uuid.ts","../../vitest.config.ts","../../formula-locale/formula-locale-data.generated.ts"],"version":"5.8.3"}
|
|
1
|
+
{"root":["../../array.ts","../../cell-data-helpers.ts","../../cjk-number-format.ts","../../clipboard-html-sanitize.ts","../../color.ts","../../colors.ts","../../condition-operand.ts","../../conditional-format.ts","../../content-hash.ts","../../data-validation.ts","../../date.ts","../../dom.ts","../../excel-number-format.ts","../../formatter.ts","../../formula-locale.ts","../../formula-refs.ts","../../formula.ts","../../index.ts","../../keyboard.ts","../../locale.ts","../../log.ts","../../memoize.ts","../../numbers.ts","../../rich-text-html.ts","../../rich-text-links.ts","../../selection.ts","../../shared-string-canonical.ts","../../sheet-names.ts","../../sheet-protection.ts","../../sheet-span.ts","../../sort.ts","../../sparkline-groups.ts","../../string.ts","../../table-names.ts","../../table-styles.ts","../../table-totals.ts","../../typeguards.ts","../../uuid.ts","../../vitest.config.ts","../../formula-locale/formula-locale-data.generated.ts"],"version":"5.8.3"}
|
|
@@ -39,11 +39,17 @@ export declare const getExtendedValueError: (extValue?: Record<string, any> | nu
|
|
|
39
39
|
* state hooks' row auto-height so both agree on which cells wrap.
|
|
40
40
|
*/
|
|
41
41
|
export declare const alignmentImpliesWrap: (align: HorizontalAlign | string | null | undefined) => boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Excel's vertical `justify` and `distributed` wrap the text too: the lines
|
|
44
|
+
* are spread over the cell height, so there must be lines to spread.
|
|
45
|
+
*/
|
|
46
|
+
export declare const verticalAlignmentImpliesWrap: (align: string | null | undefined) => boolean;
|
|
42
47
|
/**
|
|
43
48
|
* Whether a cell format wraps its text — explicit `wrapStrategy: "wrap"` or
|
|
44
|
-
* an alignment that wraps implicitly ({@link alignmentImpliesWrap}
|
|
49
|
+
* an alignment that wraps implicitly ({@link alignmentImpliesWrap},
|
|
50
|
+
* {@link verticalAlignmentImpliesWrap}).
|
|
45
51
|
*/
|
|
46
|
-
export declare const cellFormatWrapsText: (format: Pick<CellFormat, "wrapStrategy" | "horizontalAlignment"> | null | undefined) => boolean;
|
|
52
|
+
export declare const cellFormatWrapsText: (format: Pick<CellFormat, "wrapStrategy" | "horizontalAlignment" | "verticalAlignment"> | null | undefined) => boolean;
|
|
47
53
|
export declare const resolveDefaultHorizontalAlignment: ({ errorValue, userEnteredValue, effectiveValue, dataValidation, }: {
|
|
48
54
|
errorValue: unknown;
|
|
49
55
|
userEnteredValue: Record<string, any> | null | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cell-data-helpers.d.ts","sourceRoot":"","sources":["../../cell-data-helpers.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,QAAQ,EACR,UAAU,EACV,kBAAkB,EAClB,eAAe,EACf,cAAc,EACf,MAAM,4BAA4B,CAAC;AAEpC,eAAO,MAAM,uBAAuB,GAAI,CAAC,SAAS,QAAQ,EACxD,OAAO,CAAC,GAAG,IAAI,KACd,CAAC,CAAC,IAAI,CAER,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAAI,CAAC,SAAS,QAAQ,EACtD,OAAO,CAAC,GAAG,IAAI,KACd,C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AAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,KACpC,OAAO,GAAG,SAEZ,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAClC,WAAW,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,KACpC,MAAM,GAAG,SAEX,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAChC,WAAW,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,KACpC,GAAG,GAAG,SAER,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,GAC/B,OAAO,eAAe,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,KACjD,OAAyD,CAAC;AAE7D;;;GAGG;AACH,eAAO,MAAM,4BAA4B,GACvC,OAAO,MAAM,GAAG,IAAI,GAAG,SAAS,KAC/B,OAAyD,CAAC;AAE7D;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAC9B,QACI,IAAI,CACF,UAAU,EACV,cAAc,GAAG,qBAAqB,GAAG,mBAAmB,CAC7D,GACD,IAAI,GACJ,SAAS,KACZ,OAGsD,CAAC;AAE1D,eAAO,MAAM,iCAAiC,GAAI,mEAK/C;IACD,UAAU,EAAE,OAAO,CAAC;IACpB,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC;IACzD,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC;IACvD,cAAc,EAAE,IAAI,CAAC,kBAAkB,EAAE,WAAW,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC;CAC1E,KAAG,eAAe,GAAG,SASrB,CAAC"}
|
|
@@ -60,12 +60,19 @@ export const getExtendedValueError = (extValue) => {
|
|
|
60
60
|
* state hooks' row auto-height so both agree on which cells wrap.
|
|
61
61
|
*/
|
|
62
62
|
export const alignmentImpliesWrap = (align) => align === "justify" || align === "distributed";
|
|
63
|
+
/**
|
|
64
|
+
* Excel's vertical `justify` and `distributed` wrap the text too: the lines
|
|
65
|
+
* are spread over the cell height, so there must be lines to spread.
|
|
66
|
+
*/
|
|
67
|
+
export const verticalAlignmentImpliesWrap = (align) => align === "justify" || align === "distributed";
|
|
63
68
|
/**
|
|
64
69
|
* Whether a cell format wraps its text — explicit `wrapStrategy: "wrap"` or
|
|
65
|
-
* an alignment that wraps implicitly ({@link alignmentImpliesWrap}
|
|
70
|
+
* an alignment that wraps implicitly ({@link alignmentImpliesWrap},
|
|
71
|
+
* {@link verticalAlignmentImpliesWrap}).
|
|
66
72
|
*/
|
|
67
73
|
export const cellFormatWrapsText = (format) => format?.wrapStrategy === "wrap" ||
|
|
68
|
-
alignmentImpliesWrap(format?.horizontalAlignment)
|
|
74
|
+
alignmentImpliesWrap(format?.horizontalAlignment) ||
|
|
75
|
+
verticalAlignmentImpliesWrap(format?.verticalAlignment);
|
|
69
76
|
export const resolveDefaultHorizontalAlignment = ({ errorValue, userEnteredValue, effectiveValue, dataValidation, }) => {
|
|
70
77
|
const isBoolean = getExtendedValueBool(userEnteredValue) !== undefined;
|
|
71
78
|
const isCheckbox = dataValidation?.condition?.type === "BOOLEAN";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type CjkLang = "ja" | "zh-Hans" | "zh-Hant" | "ko";
|
|
2
|
+
export interface CjkPreparedFormat {
|
|
3
|
+
/** The rewritten code for the base formatter. */
|
|
4
|
+
code: string;
|
|
5
|
+
/** Converts the rendered text's digits into the `[DBNumN]` numeral system, if any. */
|
|
6
|
+
finish: (out: string) => string;
|
|
7
|
+
}
|
|
8
|
+
export declare const prepareCjkNumberFormat: (code: string, value: number, workbookLocale?: string) => CjkPreparedFormat | undefined;
|
|
9
|
+
/** Language of an LCID (hex, low 16 bits) or a BCP-47 tag, for the CJK locales. */
|
|
10
|
+
export declare const cjkLangOfTag: (input: string) => CjkLang | undefined;
|
|
11
|
+
//# sourceMappingURL=cjk-number-format.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cjk-number-format.d.ts","sourceRoot":"","sources":["../../cjk-number-format.ts"],"names":[],"mappings":"AAuBA,MAAM,MAAM,OAAO,GAAG,IAAI,GAAG,SAAS,GAAG,SAAS,GAAG,IAAI,CAAC;AAS1D,MAAM,WAAW,iBAAiB;IAChC,iDAAiD;IACjD,IAAI,EAAE,MAAM,CAAC;IACb,sFAAsF;IACtF,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;CACjC;AAgBD,eAAO,MAAM,sBAAsB,GACjC,MAAM,MAAM,EACZ,OAAO,MAAM,EACb,iBAAiB,MAAM,KACtB,iBAAiB,GAAG,SAsEtB,CAAC;AAqLF,mFAAmF;AACnF,eAAO,MAAM,YAAY,GAAI,OAAO,MAAM,KAAG,OAAO,GAAG,SA8BtD,CAAC"}
|