@rowsncolumns/utils 9.5.4 → 9.5.6

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.
@@ -16,5 +16,45 @@ export declare const hexToRgb: (hex: string) => {
16
16
  b: number;
17
17
  };
18
18
  export declare const rgbToHex: (r: number, g: number, b: number) => string;
19
+ /**
20
+ * Excel's colour variations for a chart palette that runs out of entries —
21
+ * the default chart colour style ("Colorful Palette 1", `colors1.xml`,
22
+ * `meth="cycle"`): the palette's entries are used as-is on the first pass,
23
+ * and every further pass reuses them with a luminance modification
24
+ * (`lumMod` scales each channel, `lumOff` adds toward white; 1 = 100%):
25
+ * darker, lighter, slightly darker, lighter still, … Nine passes, then the
26
+ * sequence repeats — 54 distinguishable shades over the six theme accents
27
+ * before any exact repeat. A pie with seven slices therefore gets accent 1
28
+ * darkened for slice 7, not accent 1 again.
29
+ */
30
+ export declare const CHART_PALETTE_VARIATIONS: ReadonlyArray<{
31
+ lumMod: number;
32
+ lumOff: number;
33
+ }>;
34
+ /**
35
+ * Apply DrawingML `lumMod` / `lumOff` (as fractions, 1 = 100%) to a colour:
36
+ * each channel becomes `c * lumMod + 255 * lumOff`, clamped — the arithmetic
37
+ * the xlsx importer uses for `<a:schemeClr>` modifiers, so a derived palette
38
+ * colour renders exactly as the same modifier read back from a file. A colour
39
+ * the normalizer cannot parse is returned unchanged; the result is `#RRGGBB`
40
+ * upper-case (the exporter's and importer's hex convention).
41
+ */
42
+ export declare const applyLumModOff: (color: string, lumMod: number, lumOff: number) => string;
43
+ /**
44
+ * The colour for point / series `index` of a chart palette: the palette
45
+ * cycles, and each pass past its length applies the next
46
+ * {@link CHART_PALETTE_VARIATIONS} entry to the base colour (Excel's
47
+ * `varyColors` behaviour). Indexing an empty palette behaves like
48
+ * `palette[i]` (undefined at runtime); callers pass a non-empty palette.
49
+ */
50
+ export declare const chartPaletteColorAt: (palette: readonly string[], index: number) => string;
51
+ /**
52
+ * The palette unrolled through every variation pass — what to hand a
53
+ * renderer that cycles a colour list itself (echarts' option-level `color`,
54
+ * plotly's `marker.colors`): the first `palette.length` entries are the
55
+ * palette, the rest its variations, so the renderer's own wrap-around only
56
+ * starts where Excel's does.
57
+ */
58
+ export declare const expandChartPalette: (palette: readonly string[]) => string[];
19
59
  export declare const getContrastColor: (backgroundColor: string, lightColor: string, darkColor: string) => string | undefined;
20
60
  //# sourceMappingURL=color.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"color.d.ts","sourceRoot":"","sources":["../../color.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,wBAAwB,GAAI,KAAK,MAAM,WAoCnD,CAAC;AAEF,MAAM,MAAM,IAAI,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAYnE,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAkBzD;AAED,eAAO,MAAM,aAAa,GAAI,gBAAoB,IAAI,WAUrD,CAAC;AAEF,eAAO,MAAM,WAAW,GACtB,QAAQ,MAAM,GAAG,SAAS,EAC1B,QAAQ,MAAM,GAAG,SAAS,wBAiB3B,CAAC;AAQF,eAAO,MAAM,gBAAgB,GAAI,OAAO,MAAM,GAAG,SAAS,uBAczD,CAAC;AAGF,eAAO,MAAM,YAAY,GAAI,wBAAU,EAAE,OAAO,MAAM,uBAGrD,CAAC;AAEF,eAAO,MAAM,QAAQ,GAAI,KAAK,MAAM;;;;CAOnC,CAAC;AAEF,eAAO,MAAM,QAAQ,GAAI,GAAG,MAAM,EAAE,GAAG,MAAM,EAAE,GAAG,MAAM,WAGvD,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAC3B,iBAAiB,MAAM,EACvB,YAAY,MAAM,EAClB,WAAW,MAAM,uBAUlB,CAAC"}
1
+ {"version":3,"file":"color.d.ts","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EAAE,KAAG,MAAM,EAInE,CAAC;AAEJ,eAAO,MAAM,gBAAgB,GAC3B,iBAAiB,MAAM,EACvB,YAAY,MAAM,EAClB,WAAW,MAAM,uBAUlB,CAAC"}
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.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.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");
@@ -139,6 +139,78 @@ var rgbToHex = function (r, g, b) {
139
139
  return "#" + ("000000" + hex).slice(-6);
140
140
  };
141
141
  exports.rgbToHex = rgbToHex;
142
+ /**
143
+ * Excel's colour variations for a chart palette that runs out of entries —
144
+ * the default chart colour style ("Colorful Palette 1", `colors1.xml`,
145
+ * `meth="cycle"`): the palette's entries are used as-is on the first pass,
146
+ * and every further pass reuses them with a luminance modification
147
+ * (`lumMod` scales each channel, `lumOff` adds toward white; 1 = 100%):
148
+ * darker, lighter, slightly darker, lighter still, … Nine passes, then the
149
+ * sequence repeats — 54 distinguishable shades over the six theme accents
150
+ * before any exact repeat. A pie with seven slices therefore gets accent 1
151
+ * darkened for slice 7, not accent 1 again.
152
+ */
153
+ exports.CHART_PALETTE_VARIATIONS = [
154
+ { lumMod: 1, lumOff: 0 },
155
+ { lumMod: 0.6, lumOff: 0 },
156
+ { lumMod: 0.8, lumOff: 0.2 },
157
+ { lumMod: 0.8, lumOff: 0 },
158
+ { lumMod: 0.6, lumOff: 0.4 },
159
+ { lumMod: 0.5, lumOff: 0 },
160
+ { lumMod: 0.7, lumOff: 0.3 },
161
+ { lumMod: 0.7, lumOff: 0 },
162
+ { lumMod: 0.5, lumOff: 0.5 },
163
+ ];
164
+ /**
165
+ * Apply DrawingML `lumMod` / `lumOff` (as fractions, 1 = 100%) to a colour:
166
+ * each channel becomes `c * lumMod + 255 * lumOff`, clamped — the arithmetic
167
+ * the xlsx importer uses for `<a:schemeClr>` modifiers, so a derived palette
168
+ * colour renders exactly as the same modifier read back from a file. A colour
169
+ * the normalizer cannot parse is returned unchanged; the result is `#RRGGBB`
170
+ * upper-case (the exporter's and importer's hex convention).
171
+ */
172
+ var applyLumModOff = function (color, lumMod, lumOff) {
173
+ if (lumMod === 1 && lumOff === 0)
174
+ return color;
175
+ var rgba = normalizeColor(color.trim());
176
+ if (!rgba || !Number.isFinite(rgba.r + rgba.g + rgba.b))
177
+ return color;
178
+ var channel = function (c) {
179
+ return Math.max(0, Math.min(255, Math.round(c * lumMod + 255 * lumOff)))
180
+ .toString(16)
181
+ .padStart(2, "0")
182
+ .toUpperCase();
183
+ };
184
+ return "#".concat(channel(rgba.r)).concat(channel(rgba.g)).concat(channel(rgba.b));
185
+ };
186
+ exports.applyLumModOff = applyLumModOff;
187
+ /**
188
+ * The colour for point / series `index` of a chart palette: the palette
189
+ * cycles, and each pass past its length applies the next
190
+ * {@link CHART_PALETTE_VARIATIONS} entry to the base colour (Excel's
191
+ * `varyColors` behaviour). Indexing an empty palette behaves like
192
+ * `palette[i]` (undefined at runtime); callers pass a non-empty palette.
193
+ */
194
+ var chartPaletteColorAt = function (palette, index) {
195
+ var base = palette[index % palette.length];
196
+ if (typeof base !== "string")
197
+ return base;
198
+ var pass = Math.floor(index / palette.length) % exports.CHART_PALETTE_VARIATIONS.length;
199
+ var _a = exports.CHART_PALETTE_VARIATIONS[pass], lumMod = _a.lumMod, lumOff = _a.lumOff;
200
+ return (0, exports.applyLumModOff)(base, lumMod, lumOff);
201
+ };
202
+ exports.chartPaletteColorAt = chartPaletteColorAt;
203
+ /**
204
+ * The palette unrolled through every variation pass — what to hand a
205
+ * renderer that cycles a colour list itself (echarts' option-level `color`,
206
+ * plotly's `marker.colors`): the first `palette.length` entries are the
207
+ * palette, the rest its variations, so the renderer's own wrap-around only
208
+ * starts where Excel's does.
209
+ */
210
+ var expandChartPalette = function (palette) {
211
+ return Array.from({ length: palette.length * exports.CHART_PALETTE_VARIATIONS.length }, function (_, index) { return (0, exports.chartPaletteColorAt)(palette, index); });
212
+ };
213
+ exports.expandChartPalette = expandChartPalette;
142
214
  var getContrastColor = function (backgroundColor, lightColor, darkColor) {
143
215
  var rgbColor = normalizeColor(backgroundColor);
144
216
  if (rgbColor) {
@@ -1 +1 @@
1
- {"version":3,"file":"formula-locale-data.generated.d.ts","sourceRoot":"","sources":["../../../formula-locale/formula-locale-data.generated.ts"],"names":[],"mappings":"AAMA,oFAAoF;AACpF,MAAM,WAAW,uBAAuB;IACtC,2DAA2D;IAC3D,gBAAgB,EAAE,MAAM,CAAC;IACzB,+FAA+F;IAC/F,iBAAiB,EAAE,MAAM,CAAC;IAC1B,8EAA8E;IAC9E,oBAAoB,EAAE,MAAM,CAAC;IAC7B,2EAA2E;IAC3E,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED;8FAC8F;AAC9F,MAAM,WAAW,sBAAsB;IACrC,qDAAqD;IACrD,IAAI,EAAE,MAAM,CAAC;IACb,+FAA+F;IAC/F,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,uBAAuB,CAAC;IAChC,qFAAqF;IACrF,SAAS,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC7C,iFAAiF;IACjF,MAAM,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC1C,iGAAiG;IACjG,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC/B;AAED,qDAAqD;AACrD,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;CAa5B,CAAC;AAEb,yGAAyG;AACzG,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAs6KhF,CAAC"}
1
+ {"version":3,"file":"formula-locale-data.generated.d.ts","sourceRoot":"","sources":["../../../formula-locale/formula-locale-data.generated.ts"],"names":[],"mappings":"AAMA,oFAAoF;AACpF,MAAM,WAAW,uBAAuB;IACtC,2DAA2D;IAC3D,gBAAgB,EAAE,MAAM,CAAC;IACzB,+FAA+F;IAC/F,iBAAiB,EAAE,MAAM,CAAC;IAC1B,8EAA8E;IAC9E,oBAAoB,EAAE,MAAM,CAAC;IAC7B,2EAA2E;IAC3E,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED;8FAC8F;AAC9F,MAAM,WAAW,sBAAsB;IACrC,qDAAqD;IACrD,IAAI,EAAE,MAAM,CAAC;IACb,+FAA+F;IAC/F,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,uBAAuB,CAAC;IAChC,qFAAqF;IACrF,SAAS,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC7C,iFAAiF;IACjF,MAAM,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC1C,iGAAiG;IACjG,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC/B;AAED,qDAAqD;AACrD,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;CAa5B,CAAC;AAEb,yGAAyG;AACzG,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAu6KhF,CAAC"}
@@ -1419,6 +1419,7 @@ exports.FORMULA_LOCALE_DATA = {
1419
1419
  "ISNUMBER": "ESTNUM",
1420
1420
  "ISO.CEILING": "ISO.PLAFOND",
1421
1421
  "ISODD": "EST.IMPAIR",
1422
+ "ISOMITTED": "ISOMITTED",
1422
1423
  "ISOWEEKNUM": "NO.SEMAINE.ISO",
1423
1424
  "ISPMT": "ISPMT",
1424
1425
  "ISREF": "ESTREF",
@@ -16,5 +16,45 @@ export declare const hexToRgb: (hex: string) => {
16
16
  b: number;
17
17
  };
18
18
  export declare const rgbToHex: (r: number, g: number, b: number) => string;
19
+ /**
20
+ * Excel's colour variations for a chart palette that runs out of entries —
21
+ * the default chart colour style ("Colorful Palette 1", `colors1.xml`,
22
+ * `meth="cycle"`): the palette's entries are used as-is on the first pass,
23
+ * and every further pass reuses them with a luminance modification
24
+ * (`lumMod` scales each channel, `lumOff` adds toward white; 1 = 100%):
25
+ * darker, lighter, slightly darker, lighter still, … Nine passes, then the
26
+ * sequence repeats — 54 distinguishable shades over the six theme accents
27
+ * before any exact repeat. A pie with seven slices therefore gets accent 1
28
+ * darkened for slice 7, not accent 1 again.
29
+ */
30
+ export declare const CHART_PALETTE_VARIATIONS: ReadonlyArray<{
31
+ lumMod: number;
32
+ lumOff: number;
33
+ }>;
34
+ /**
35
+ * Apply DrawingML `lumMod` / `lumOff` (as fractions, 1 = 100%) to a colour:
36
+ * each channel becomes `c * lumMod + 255 * lumOff`, clamped — the arithmetic
37
+ * the xlsx importer uses for `<a:schemeClr>` modifiers, so a derived palette
38
+ * colour renders exactly as the same modifier read back from a file. A colour
39
+ * the normalizer cannot parse is returned unchanged; the result is `#RRGGBB`
40
+ * upper-case (the exporter's and importer's hex convention).
41
+ */
42
+ export declare const applyLumModOff: (color: string, lumMod: number, lumOff: number) => string;
43
+ /**
44
+ * The colour for point / series `index` of a chart palette: the palette
45
+ * cycles, and each pass past its length applies the next
46
+ * {@link CHART_PALETTE_VARIATIONS} entry to the base colour (Excel's
47
+ * `varyColors` behaviour). Indexing an empty palette behaves like
48
+ * `palette[i]` (undefined at runtime); callers pass a non-empty palette.
49
+ */
50
+ export declare const chartPaletteColorAt: (palette: readonly string[], index: number) => string;
51
+ /**
52
+ * The palette unrolled through every variation pass — what to hand a
53
+ * renderer that cycles a colour list itself (echarts' option-level `color`,
54
+ * plotly's `marker.colors`): the first `palette.length` entries are the
55
+ * palette, the rest its variations, so the renderer's own wrap-around only
56
+ * starts where Excel's does.
57
+ */
58
+ export declare const expandChartPalette: (palette: readonly string[]) => string[];
19
59
  export declare const getContrastColor: (backgroundColor: string, lightColor: string, darkColor: string) => string | undefined;
20
60
  //# sourceMappingURL=color.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"color.d.ts","sourceRoot":"","sources":["../../color.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,wBAAwB,GAAI,KAAK,MAAM,WAoCnD,CAAC;AAEF,MAAM,MAAM,IAAI,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAYnE,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAkBzD;AAED,eAAO,MAAM,aAAa,GAAI,gBAAoB,IAAI,WAUrD,CAAC;AAEF,eAAO,MAAM,WAAW,GACtB,QAAQ,MAAM,GAAG,SAAS,EAC1B,QAAQ,MAAM,GAAG,SAAS,wBAiB3B,CAAC;AAQF,eAAO,MAAM,gBAAgB,GAAI,OAAO,MAAM,GAAG,SAAS,uBAczD,CAAC;AAGF,eAAO,MAAM,YAAY,GAAI,wBAAU,EAAE,OAAO,MAAM,uBAGrD,CAAC;AAEF,eAAO,MAAM,QAAQ,GAAI,KAAK,MAAM;;;;CAOnC,CAAC;AAEF,eAAO,MAAM,QAAQ,GAAI,GAAG,MAAM,EAAE,GAAG,MAAM,EAAE,GAAG,MAAM,WAGvD,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAC3B,iBAAiB,MAAM,E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MF,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,GAAI,SAAS,SAAS,MAAM,EAAE,KAAG,MAAM,EAInE,CAAC;AAEJ,eAAO,MAAM,gBAAgB,GAC3B,iBAAiB,MAAM,EACvB,YAAY,MAAM,EAClB,WAAW,MAAM,uBAUlB,CAAC"}
package/dist/esm/color.js CHANGED
@@ -125,6 +125,71 @@ export const rgbToHex = (r, g, b) => {
125
125
  const hex = ((r << 16) | (g << 8) | b).toString(16);
126
126
  return "#" + ("000000" + hex).slice(-6);
127
127
  };
128
+ /**
129
+ * Excel's colour variations for a chart palette that runs out of entries —
130
+ * the default chart colour style ("Colorful Palette 1", `colors1.xml`,
131
+ * `meth="cycle"`): the palette's entries are used as-is on the first pass,
132
+ * and every further pass reuses them with a luminance modification
133
+ * (`lumMod` scales each channel, `lumOff` adds toward white; 1 = 100%):
134
+ * darker, lighter, slightly darker, lighter still, … Nine passes, then the
135
+ * sequence repeats — 54 distinguishable shades over the six theme accents
136
+ * before any exact repeat. A pie with seven slices therefore gets accent 1
137
+ * darkened for slice 7, not accent 1 again.
138
+ */
139
+ export const CHART_PALETTE_VARIATIONS = [
140
+ { lumMod: 1, lumOff: 0 },
141
+ { lumMod: 0.6, lumOff: 0 },
142
+ { lumMod: 0.8, lumOff: 0.2 },
143
+ { lumMod: 0.8, lumOff: 0 },
144
+ { lumMod: 0.6, lumOff: 0.4 },
145
+ { lumMod: 0.5, lumOff: 0 },
146
+ { lumMod: 0.7, lumOff: 0.3 },
147
+ { lumMod: 0.7, lumOff: 0 },
148
+ { lumMod: 0.5, lumOff: 0.5 },
149
+ ];
150
+ /**
151
+ * Apply DrawingML `lumMod` / `lumOff` (as fractions, 1 = 100%) to a colour:
152
+ * each channel becomes `c * lumMod + 255 * lumOff`, clamped — the arithmetic
153
+ * the xlsx importer uses for `<a:schemeClr>` modifiers, so a derived palette
154
+ * colour renders exactly as the same modifier read back from a file. A colour
155
+ * the normalizer cannot parse is returned unchanged; the result is `#RRGGBB`
156
+ * upper-case (the exporter's and importer's hex convention).
157
+ */
158
+ export const applyLumModOff = (color, lumMod, lumOff) => {
159
+ if (lumMod === 1 && lumOff === 0)
160
+ return color;
161
+ const rgba = normalizeColor(color.trim());
162
+ if (!rgba || !Number.isFinite(rgba.r + rgba.g + rgba.b))
163
+ return color;
164
+ const channel = (c) => Math.max(0, Math.min(255, Math.round(c * lumMod + 255 * lumOff)))
165
+ .toString(16)
166
+ .padStart(2, "0")
167
+ .toUpperCase();
168
+ return `#${channel(rgba.r)}${channel(rgba.g)}${channel(rgba.b)}`;
169
+ };
170
+ /**
171
+ * The colour for point / series `index` of a chart palette: the palette
172
+ * cycles, and each pass past its length applies the next
173
+ * {@link CHART_PALETTE_VARIATIONS} entry to the base colour (Excel's
174
+ * `varyColors` behaviour). Indexing an empty palette behaves like
175
+ * `palette[i]` (undefined at runtime); callers pass a non-empty palette.
176
+ */
177
+ export const chartPaletteColorAt = (palette, index) => {
178
+ const base = palette[index % palette.length];
179
+ if (typeof base !== "string")
180
+ return base;
181
+ const pass = Math.floor(index / palette.length) % CHART_PALETTE_VARIATIONS.length;
182
+ const { lumMod, lumOff } = CHART_PALETTE_VARIATIONS[pass];
183
+ return applyLumModOff(base, lumMod, lumOff);
184
+ };
185
+ /**
186
+ * The palette unrolled through every variation pass — what to hand a
187
+ * renderer that cycles a colour list itself (echarts' option-level `color`,
188
+ * plotly's `marker.colors`): the first `palette.length` entries are the
189
+ * palette, the rest its variations, so the renderer's own wrap-around only
190
+ * starts where Excel's does.
191
+ */
192
+ export const expandChartPalette = (palette) => Array.from({ length: palette.length * CHART_PALETTE_VARIATIONS.length }, (_, index) => chartPaletteColorAt(palette, index));
128
193
  export const getContrastColor = (backgroundColor, lightColor, darkColor) => {
129
194
  const rgbColor = normalizeColor(backgroundColor);
130
195
  if (rgbColor) {
@@ -1 +1 @@
1
- {"version":3,"file":"formula-locale-data.generated.d.ts","sourceRoot":"","sources":["../../../formula-locale/formula-locale-data.generated.ts"],"names":[],"mappings":"AAMA,oFAAoF;AACpF,MAAM,WAAW,uBAAuB;IACtC,2DAA2D;IAC3D,gBAAgB,EAAE,MAAM,CAAC;IACzB,+FAA+F;IAC/F,iBAAiB,EAAE,MAAM,CAAC;IAC1B,8EAA8E;IAC9E,oBAAoB,EAAE,MAAM,CAAC;IAC7B,2EAA2E;IAC3E,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED;8FAC8F;AAC9F,MAAM,WAAW,sBAAsB;IACrC,qDAAqD;IACrD,IAAI,EAAE,MAAM,CAAC;IACb,+FAA+F;IAC/F,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,uBAAuB,CAAC;IAChC,qFAAqF;IACrF,SAAS,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC7C,iFAAiF;IACjF,MAAM,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC1C,iGAAiG;IACjG,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC/B;AAED,qDAAqD;AACrD,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;CAa5B,CAAC;AAEb,yGAAyG;AACzG,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAs6KhF,CAAC"}
1
+ {"version":3,"file":"formula-locale-data.generated.d.ts","sourceRoot":"","sources":["../../../formula-locale/formula-locale-data.generated.ts"],"names":[],"mappings":"AAMA,oFAAoF;AACpF,MAAM,WAAW,uBAAuB;IACtC,2DAA2D;IAC3D,gBAAgB,EAAE,MAAM,CAAC;IACzB,+FAA+F;IAC/F,iBAAiB,EAAE,MAAM,CAAC;IAC1B,8EAA8E;IAC9E,oBAAoB,EAAE,MAAM,CAAC;IAC7B,2EAA2E;IAC3E,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED;8FAC8F;AAC9F,MAAM,WAAW,sBAAsB;IACrC,qDAAqD;IACrD,IAAI,EAAE,MAAM,CAAC;IACb,+FAA+F;IAC/F,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,uBAAuB,CAAC;IAChC,qFAAqF;IACrF,SAAS,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC7C,iFAAiF;IACjF,MAAM,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC1C,iGAAiG;IACjG,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC/B;AAED,qDAAqD;AACrD,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;CAa5B,CAAC;AAEb,yGAAyG;AACzG,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAu6KhF,CAAC"}
@@ -1416,6 +1416,7 @@ export const FORMULA_LOCALE_DATA = {
1416
1416
  "ISNUMBER": "ESTNUM",
1417
1417
  "ISO.CEILING": "ISO.PLAFOND",
1418
1418
  "ISODD": "EST.IMPAIR",
1419
+ "ISOMITTED": "ISOMITTED",
1419
1420
  "ISOWEEKNUM": "NO.SEMAINE.ISO",
1420
1421
  "ISPMT": "ISPMT",
1421
1422
  "ISREF": "ESTREF",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rowsncolumns/utils",
3
- "version": "9.5.4",
3
+ "version": "9.5.6",
4
4
  "author": "Vinay M",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "main": "./dist/cjs/index.js",