@rowsncolumns/utils 9.2.35

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.
Files changed (154) hide show
  1. package/LICENSE.md +100 -0
  2. package/dist/cjs/array.d.ts +3 -0
  3. package/dist/cjs/array.d.ts.map +1 -0
  4. package/dist/cjs/array.js +19 -0
  5. package/dist/cjs/cell-data-helpers.d.ts +19 -0
  6. package/dist/cjs/cell-data-helpers.d.ts.map +1 -0
  7. package/dist/cjs/cell-data-helpers.js +64 -0
  8. package/dist/cjs/color.d.ts +20 -0
  9. package/dist/cjs/color.d.ts.map +1 -0
  10. package/dist/cjs/color.js +168 -0
  11. package/dist/cjs/colors.d.ts +2 -0
  12. package/dist/cjs/colors.d.ts.map +1 -0
  13. package/dist/cjs/colors.js +78 -0
  14. package/dist/cjs/conditional-format.d.ts +49 -0
  15. package/dist/cjs/conditional-format.d.ts.map +1 -0
  16. package/dist/cjs/conditional-format.js +227 -0
  17. package/dist/cjs/content-hash.d.ts +16 -0
  18. package/dist/cjs/content-hash.d.ts.map +1 -0
  19. package/dist/cjs/content-hash.js +72 -0
  20. package/dist/cjs/data-validation.d.ts +54 -0
  21. package/dist/cjs/data-validation.d.ts.map +1 -0
  22. package/dist/cjs/data-validation.js +249 -0
  23. package/dist/cjs/date.d.ts +15 -0
  24. package/dist/cjs/date.d.ts.map +1 -0
  25. package/dist/cjs/date.js +56 -0
  26. package/dist/cjs/dom.d.ts +10 -0
  27. package/dist/cjs/dom.d.ts.map +1 -0
  28. package/dist/cjs/dom.js +97 -0
  29. package/dist/cjs/formatter.d.ts +22 -0
  30. package/dist/cjs/formatter.d.ts.map +1 -0
  31. package/dist/cjs/formatter.js +264 -0
  32. package/dist/cjs/formula-refs.d.ts +7 -0
  33. package/dist/cjs/formula-refs.d.ts.map +1 -0
  34. package/dist/cjs/formula-refs.js +54 -0
  35. package/dist/cjs/formula.d.ts +80 -0
  36. package/dist/cjs/formula.d.ts.map +1 -0
  37. package/dist/cjs/formula.js +401 -0
  38. package/dist/cjs/index.d.ts +24 -0
  39. package/dist/cjs/index.d.ts.map +1 -0
  40. package/dist/cjs/index.js +26 -0
  41. package/dist/cjs/locale.d.ts +34 -0
  42. package/dist/cjs/locale.d.ts.map +1 -0
  43. package/dist/cjs/locale.js +260 -0
  44. package/dist/cjs/log.d.ts +4 -0
  45. package/dist/cjs/log.d.ts.map +1 -0
  46. package/dist/cjs/log.js +28 -0
  47. package/dist/cjs/memoize.d.ts +18 -0
  48. package/dist/cjs/memoize.d.ts.map +1 -0
  49. package/dist/cjs/memoize.js +128 -0
  50. package/dist/cjs/numbers.d.ts +19 -0
  51. package/dist/cjs/numbers.d.ts.map +1 -0
  52. package/dist/cjs/numbers.js +47 -0
  53. package/dist/cjs/selection.d.ts +88 -0
  54. package/dist/cjs/selection.d.ts.map +1 -0
  55. package/dist/cjs/selection.js +368 -0
  56. package/dist/cjs/shared-string-canonical.d.ts +18 -0
  57. package/dist/cjs/shared-string-canonical.d.ts.map +1 -0
  58. package/dist/cjs/shared-string-canonical.js +74 -0
  59. package/dist/cjs/sort.d.ts +15 -0
  60. package/dist/cjs/sort.d.ts.map +1 -0
  61. package/dist/cjs/sort.js +44 -0
  62. package/dist/cjs/string.d.ts +74 -0
  63. package/dist/cjs/string.d.ts.map +1 -0
  64. package/dist/cjs/string.js +237 -0
  65. package/dist/cjs/table-styles.d.ts +56 -0
  66. package/dist/cjs/table-styles.d.ts.map +1 -0
  67. package/dist/cjs/table-styles.js +362 -0
  68. package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -0
  69. package/dist/cjs/typeguards.d.ts +4 -0
  70. package/dist/cjs/typeguards.d.ts.map +1 -0
  71. package/dist/cjs/typeguards.js +15 -0
  72. package/dist/cjs/uuid.d.ts +8 -0
  73. package/dist/cjs/uuid.d.ts.map +1 -0
  74. package/dist/cjs/uuid.js +30 -0
  75. package/dist/cjs/vitest.config.d.ts +3 -0
  76. package/dist/cjs/vitest.config.d.ts.map +1 -0
  77. package/dist/cjs/vitest.config.js +9 -0
  78. package/dist/esm/array.d.ts +3 -0
  79. package/dist/esm/array.d.ts.map +1 -0
  80. package/dist/esm/array.js +14 -0
  81. package/dist/esm/cell-data-helpers.d.ts +19 -0
  82. package/dist/esm/cell-data-helpers.d.ts.map +1 -0
  83. package/dist/esm/cell-data-helpers.js +39 -0
  84. package/dist/esm/color.d.ts +20 -0
  85. package/dist/esm/color.d.ts.map +1 -0
  86. package/dist/esm/color.js +152 -0
  87. package/dist/esm/colors.d.ts +2 -0
  88. package/dist/esm/colors.d.ts.map +1 -0
  89. package/dist/esm/colors.js +75 -0
  90. package/dist/esm/conditional-format.d.ts +49 -0
  91. package/dist/esm/conditional-format.d.ts.map +1 -0
  92. package/dist/esm/conditional-format.js +219 -0
  93. package/dist/esm/content-hash.d.ts +16 -0
  94. package/dist/esm/content-hash.d.ts.map +1 -0
  95. package/dist/esm/content-hash.js +68 -0
  96. package/dist/esm/data-validation.d.ts +54 -0
  97. package/dist/esm/data-validation.d.ts.map +1 -0
  98. package/dist/esm/data-validation.js +237 -0
  99. package/dist/esm/date.d.ts +15 -0
  100. package/dist/esm/date.d.ts.map +1 -0
  101. package/dist/esm/date.js +46 -0
  102. package/dist/esm/dom.d.ts +10 -0
  103. package/dist/esm/dom.d.ts.map +1 -0
  104. package/dist/esm/dom.js +90 -0
  105. package/dist/esm/formatter.d.ts +22 -0
  106. package/dist/esm/formatter.d.ts.map +1 -0
  107. package/dist/esm/formatter.js +253 -0
  108. package/dist/esm/formula-refs.d.ts +7 -0
  109. package/dist/esm/formula-refs.d.ts.map +1 -0
  110. package/dist/esm/formula-refs.js +49 -0
  111. package/dist/esm/formula.d.ts +80 -0
  112. package/dist/esm/formula.d.ts.map +1 -0
  113. package/dist/esm/formula.js +298 -0
  114. package/dist/esm/index.d.ts +24 -0
  115. package/dist/esm/index.d.ts.map +1 -0
  116. package/dist/esm/index.js +23 -0
  117. package/dist/esm/locale.d.ts +34 -0
  118. package/dist/esm/locale.d.ts.map +1 -0
  119. package/dist/esm/locale.js +223 -0
  120. package/dist/esm/log.d.ts +4 -0
  121. package/dist/esm/log.d.ts.map +1 -0
  122. package/dist/esm/log.js +3 -0
  123. package/dist/esm/memoize.d.ts +18 -0
  124. package/dist/esm/memoize.d.ts.map +1 -0
  125. package/dist/esm/memoize.js +95 -0
  126. package/dist/esm/numbers.d.ts +19 -0
  127. package/dist/esm/numbers.d.ts.map +1 -0
  128. package/dist/esm/numbers.js +40 -0
  129. package/dist/esm/selection.d.ts +88 -0
  130. package/dist/esm/selection.d.ts.map +1 -0
  131. package/dist/esm/selection.js +311 -0
  132. package/dist/esm/shared-string-canonical.d.ts +18 -0
  133. package/dist/esm/shared-string-canonical.d.ts.map +1 -0
  134. package/dist/esm/shared-string-canonical.js +68 -0
  135. package/dist/esm/sort.d.ts +15 -0
  136. package/dist/esm/sort.d.ts.map +1 -0
  137. package/dist/esm/sort.js +39 -0
  138. package/dist/esm/string.d.ts +74 -0
  139. package/dist/esm/string.d.ts.map +1 -0
  140. package/dist/esm/string.js +213 -0
  141. package/dist/esm/table-styles.d.ts +56 -0
  142. package/dist/esm/table-styles.d.ts.map +1 -0
  143. package/dist/esm/table-styles.js +367 -0
  144. package/dist/esm/tsconfig.esm.tsbuildinfo +1 -0
  145. package/dist/esm/typeguards.d.ts +4 -0
  146. package/dist/esm/typeguards.d.ts.map +1 -0
  147. package/dist/esm/typeguards.js +7 -0
  148. package/dist/esm/uuid.d.ts +8 -0
  149. package/dist/esm/uuid.d.ts.map +1 -0
  150. package/dist/esm/uuid.js +25 -0
  151. package/dist/esm/vitest.config.d.ts +3 -0
  152. package/dist/esm/vitest.config.d.ts.map +1 -0
  153. package/dist/esm/vitest.config.js +7 -0
  154. package/package.json +49 -0
package/LICENSE.md ADDED
@@ -0,0 +1,100 @@
1
+ # Rows n' Columns Commercial License Agreement
2
+
3
+ This Rows n' Columns Commercial License Agreement (the "Agreement") governs
4
+ the use of the Rows n' Columns software packages published under the
5
+ `@rowsncolumns` npm scope, including associated JavaScript, WebAssembly
6
+ binaries, stylesheets, type definitions and documentation (the "Software").
7
+
8
+ The Software is **not** open source. Downloading or installing the Software
9
+ from a public package registry does not grant any right to use it beyond the
10
+ evaluation use described below.
11
+
12
+ ## 1. Definitions
13
+
14
+ - **"Licensor"** means Rows n' Columns (rowsncolumns.app).
15
+ - **"Licensee"** means the individual or legal entity identified in an Order.
16
+ - **"Order"** means a purchase of a license for the Software from Licensor,
17
+ identified by an order ID and associated with a License Key.
18
+ - **"License Key"** means the signed key issued by Licensor that identifies
19
+ the Licensee, license tier, and Update Window.
20
+ - **"Update Window"** means the period stated in the Order during which
21
+ Software versions released by Licensor are covered by the License Key.
22
+
23
+ ## 2. License Grant
24
+
25
+ Subject to payment of the applicable fees and compliance with this Agreement,
26
+ Licensor grants Licensee a non-exclusive, non-transferable, worldwide license
27
+ to use, and to distribute in compiled form as an embedded component of
28
+ Licensee's own applications, any version of the Software released during the
29
+ Update Window, in accordance with the license tier stated in the Order.
30
+
31
+ This grant is perpetual for versions released during the Update Window:
32
+ Licensee may continue to use those versions after the Update Window ends.
33
+ Versions released after the Update Window ends require a new or renewed
34
+ Order.
35
+
36
+ ## 3. Evaluation Use
37
+
38
+ The Software may be used without a License Key solely for internal
39
+ evaluation and development purposes. Evaluation use in production, or
40
+ removal or suppression of evaluation notices, is not permitted.
41
+
42
+ ## 4. Restrictions
43
+
44
+ Except as expressly permitted by this Agreement or by applicable law that
45
+ cannot be contractually waived, Licensee shall not:
46
+
47
+ 1. redistribute, resell, sublicense, or otherwise make the Software
48
+ available as a standalone product, library, or development component;
49
+ 2. use the Software to build a product that competes with the Software;
50
+ 3. remove, alter, or circumvent License Key validation, evaluation notices,
51
+ watermarks, or copyright notices in the Software;
52
+ 4. share License Keys with any third party, or use a License Key outside
53
+ the scope of the tier stated in the Order;
54
+ 5. reverse engineer, decompile, or disassemble the Software except to the
55
+ extent permitted by applicable law.
56
+
57
+ ## 5. Ownership
58
+
59
+ The Software is licensed, not sold. Licensor and its licensors retain all
60
+ right, title, and interest in and to the Software, including all
61
+ intellectual property rights.
62
+
63
+ ## 6. Third-Party Components
64
+
65
+ The Software may include third-party open-source components. Those
66
+ components remain governed by their own license terms, which are included
67
+ with the applicable component and are not limited by this Agreement.
68
+
69
+ ## 7. Termination
70
+
71
+ This Agreement terminates automatically upon material breach by Licensee
72
+ that remains uncured 30 days after written notice. Upon termination,
73
+ Licensee must cease use and distribution of the Software, except that
74
+ end-user copies of Licensee applications already distributed in compliance
75
+ with this Agreement are unaffected.
76
+
77
+ ## 8. Warranty Disclaimer
78
+
79
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
80
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
81
+ FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
82
+
83
+ ## 9. Limitation of Liability
84
+
85
+ TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL LICENSOR BE LIABLE
86
+ FOR ANY INDIRECT, INCIDENTAL, SPECIAL, CONSEQUENTIAL, OR PUNITIVE DAMAGES,
87
+ OR ANY LOSS OF PROFITS, DATA, OR GOODWILL, ARISING OUT OF OR RELATED TO THIS
88
+ AGREEMENT, AND LICENSOR'S AGGREGATE LIABILITY SHALL NOT EXCEED THE FEES PAID
89
+ BY LICENSEE IN THE TWELVE MONTHS PRECEDING THE CLAIM.
90
+
91
+ ## 10. General
92
+
93
+ This Agreement constitutes the entire agreement between the parties
94
+ concerning the Software and supersedes any prior agreements. If any
95
+ provision is held unenforceable, the remainder remains in effect. Failure to
96
+ enforce a provision is not a waiver.
97
+
98
+ For licensing inquiries, visit <https://www.rowsncolumns.app/pricing>.
99
+
100
+ Copyright © Rows n' Columns. All rights reserved.
@@ -0,0 +1,3 @@
1
+ export declare function findLastIndex<T>(array: Array<T>, predicate: (value: T, index: number, obj: T[]) => boolean): number;
2
+ export declare const createArrayRange: (start: number, end: number) => number[];
3
+ //# sourceMappingURL=array.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../../array.ts"],"names":[],"mappings":"AAAA,wBAAgB,aAAa,CAAC,CAAC,EAC7B,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,EACf,SAAS,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,OAAO,GACxD,MAAM,CAMR;AAED,eAAO,MAAM,gBAAgB,GAAI,OAAO,MAAM,EAAE,KAAK,MAAM,KAAG,MAAM,EAKnE,CAAC"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createArrayRange = void 0;
4
+ exports.findLastIndex = findLastIndex;
5
+ function findLastIndex(array, predicate) {
6
+ var l = array.length;
7
+ while (l--) {
8
+ if (predicate(array[l], l, array))
9
+ return l;
10
+ }
11
+ return -1;
12
+ }
13
+ var createArrayRange = function (start, end) {
14
+ if (end < start) {
15
+ return [];
16
+ }
17
+ return Array.from({ length: end - start + 1 }, function (_, index) { return start + index; });
18
+ };
19
+ exports.createArrayRange = createArrayRange;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Utility functions for CellData property access with fallback logic
3
+ * Prioritizes short keys (ue, ev) over long keys (userEnteredValue, effectiveValue)
4
+ *
5
+ * Note: These functions use generic types to avoid circular dependencies
6
+ */
7
+ import type { CellData, CellFormat, StyleReference } from "@rowsncolumns/common-types";
8
+ export declare const getCellUserEnteredValue: <T extends CellData>(cell?: T | null) => T["ue"];
9
+ export declare const getCellEffectiveValue: <T extends CellData>(cell?: T | null) => T["ev"];
10
+ export declare const getCellUserEnteredFormat: <T extends CellData>(cell?: T | null) => T["uf"];
11
+ export declare const getCellEffectiveFormat: <T extends CellData>(cell?: T | null) => CellFormat | StyleReference | null | undefined;
12
+ export declare const getCellFormattedValue: <T extends CellData>(cell?: T | null) => string | undefined | null;
13
+ export declare const getStyleId: (styleRef: Record<string, any>) => string;
14
+ export declare const getExtendedValueNumber: (extValue?: Record<string, any> | null) => number | undefined;
15
+ export declare const getExtendedValueString: (extValue?: Record<string, any> | null) => string | undefined;
16
+ export declare const getExtendedValueBool: (extValue?: Record<string, any> | null) => boolean | undefined;
17
+ export declare const getExtendedValueFormula: (extValue?: Record<string, any> | null) => string | undefined;
18
+ export declare const getExtendedValueError: (extValue?: Record<string, any> | null) => any | undefined;
19
+ //# sourceMappingURL=cell-data-helpers.d.ts.map
@@ -0,0 +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,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,CAAC,CAAC,IAAI,CAER,CAAC;AAEF,eAAO,MAAM,wBAAwB,GAAI,CAAC,SAAS,QAAQ,EACzD,OAAO,CAAC,GAAG,IAAI,KACd,CAAC,CAAC,IAAI,CAER,CAAC;AAEF,eAAO,MAAM,sBAAsB,GAAI,CAAC,SAAS,QAAQ,EACvD,OAAO,CAAC,GAAG,IAAI,KACd,UAAU,GAAG,cAAc,GAAG,IAAI,GAAG,SAEvC,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAAI,CAAC,SAAS,QAAQ,EACtD,OAAO,CAAC,GAAG,IAAI,KACd,MAAM,GAAG,SAAS,GAAG,IAEvB,CAAC;AAEF,eAAO,MAAM,UAAU,GAAI,UAAU,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAG,MAE1D,CAAC;AAEF,eAAO,MAAM,sBAAsB,GACjC,WAAW,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,KACpC,MAAM,GAAG,SAEX,CAAC;AAEF,eAAO,MAAM,sBAAsB,GACjC,WAAW,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,KACpC,MAAM,GAAG,SAEX,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAC/B,WAAW,MAAM,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"}
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ /**
3
+ * Utility functions for CellData property access with fallback logic
4
+ * Prioritizes short keys (ue, ev) over long keys (userEnteredValue, effectiveValue)
5
+ *
6
+ * Note: These functions use generic types to avoid circular dependencies
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.getExtendedValueError = exports.getExtendedValueFormula = exports.getExtendedValueBool = exports.getExtendedValueString = exports.getExtendedValueNumber = exports.getStyleId = exports.getCellFormattedValue = exports.getCellEffectiveFormat = exports.getCellUserEnteredFormat = exports.getCellEffectiveValue = exports.getCellUserEnteredValue = void 0;
10
+ var getCellUserEnteredValue = function (cell) {
11
+ var _a;
12
+ return (_a = cell === null || cell === void 0 ? void 0 : cell.ue) !== null && _a !== void 0 ? _a : cell === null || cell === void 0 ? void 0 : cell.userEnteredValue;
13
+ };
14
+ exports.getCellUserEnteredValue = getCellUserEnteredValue;
15
+ var getCellEffectiveValue = function (cell) {
16
+ var _a;
17
+ return (_a = cell === null || cell === void 0 ? void 0 : cell.ev) !== null && _a !== void 0 ? _a : cell === null || cell === void 0 ? void 0 : cell.effectiveValue;
18
+ };
19
+ exports.getCellEffectiveValue = getCellEffectiveValue;
20
+ var getCellUserEnteredFormat = function (cell) {
21
+ var _a;
22
+ return (_a = cell === null || cell === void 0 ? void 0 : cell.uf) !== null && _a !== void 0 ? _a : cell === null || cell === void 0 ? void 0 : cell.userEnteredFormat;
23
+ };
24
+ exports.getCellUserEnteredFormat = getCellUserEnteredFormat;
25
+ var getCellEffectiveFormat = function (cell) {
26
+ var _a;
27
+ return (_a = cell === null || cell === void 0 ? void 0 : cell.ef) !== null && _a !== void 0 ? _a : cell === null || cell === void 0 ? void 0 : cell.effectiveFormat;
28
+ };
29
+ exports.getCellEffectiveFormat = getCellEffectiveFormat;
30
+ var getCellFormattedValue = function (cell) {
31
+ var _a;
32
+ return (_a = cell === null || cell === void 0 ? void 0 : cell.fv) !== null && _a !== void 0 ? _a : cell === null || cell === void 0 ? void 0 : cell.formattedValue;
33
+ };
34
+ exports.getCellFormattedValue = getCellFormattedValue;
35
+ var getStyleId = function (styleRef) {
36
+ var _a;
37
+ return (_a = styleRef.sid) !== null && _a !== void 0 ? _a : styleRef.styleId;
38
+ };
39
+ exports.getStyleId = getStyleId;
40
+ var getExtendedValueNumber = function (extValue) {
41
+ var _a;
42
+ return (_a = extValue === null || extValue === void 0 ? void 0 : extValue.nv) !== null && _a !== void 0 ? _a : extValue === null || extValue === void 0 ? void 0 : extValue.numberValue;
43
+ };
44
+ exports.getExtendedValueNumber = getExtendedValueNumber;
45
+ var getExtendedValueString = function (extValue) {
46
+ var _a;
47
+ return (_a = extValue === null || extValue === void 0 ? void 0 : extValue.sv) !== null && _a !== void 0 ? _a : extValue === null || extValue === void 0 ? void 0 : extValue.stringValue;
48
+ };
49
+ exports.getExtendedValueString = getExtendedValueString;
50
+ var getExtendedValueBool = function (extValue) {
51
+ var _a;
52
+ return (_a = extValue === null || extValue === void 0 ? void 0 : extValue.bv) !== null && _a !== void 0 ? _a : extValue === null || extValue === void 0 ? void 0 : extValue.boolValue;
53
+ };
54
+ exports.getExtendedValueBool = getExtendedValueBool;
55
+ var getExtendedValueFormula = function (extValue) {
56
+ var _a;
57
+ return (_a = extValue === null || extValue === void 0 ? void 0 : extValue.fv) !== null && _a !== void 0 ? _a : extValue === null || extValue === void 0 ? void 0 : extValue.formulaValue;
58
+ };
59
+ exports.getExtendedValueFormula = getExtendedValueFormula;
60
+ var getExtendedValueError = function (extValue) {
61
+ var _a;
62
+ return (_a = extValue === null || extValue === void 0 ? void 0 : extValue.ev) !== null && _a !== void 0 ? _a : extValue === null || extValue === void 0 ? void 0 : extValue.errorValue;
63
+ };
64
+ exports.getExtendedValueError = getExtendedValueError;
@@ -0,0 +1,20 @@
1
+ export declare const getSelectionColorAtIndex: (key: number) => string;
2
+ export type RGBA = {
3
+ r: number;
4
+ g: number;
5
+ b: number;
6
+ a?: number;
7
+ };
8
+ export declare function normalizeColor(color: string): RGBA | null;
9
+ export declare const rgbaToArgbHex: ({ r, g, b, a }: RGBA) => string;
10
+ export declare const isSameColor: (colorA: string | undefined, colorB: string | undefined) => boolean | undefined;
11
+ export declare const colorStringToHex: (color: string | undefined) => string | undefined;
12
+ export declare const lightenColor: (unit: number | undefined, color: string) => string | undefined;
13
+ export declare const hexToRgb: (hex: string) => {
14
+ r: number;
15
+ g: number;
16
+ b: number;
17
+ };
18
+ export declare const rgbToHex: (r: number, g: number, b: number) => string;
19
+ export declare const getContrastColor: (backgroundColor: string, lightColor: string, darkColor: string) => string | undefined;
20
+ //# sourceMappingURL=color.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,168 @@
1
+ "use strict";
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;
4
+ exports.normalizeColor = normalizeColor;
5
+ var tslib_1 = require("tslib");
6
+ var typeguards_1 = require("./typeguards");
7
+ // Shared by editor decorator + spreadsheet
8
+ var getSelectionColorAtIndex = function (key) {
9
+ var hash = 0;
10
+ var colors = [
11
+ "#11a9cc",
12
+ "#a61d4c",
13
+ "#4285f4",
14
+ "#f4b400",
15
+ "#65b045",
16
+ "#e51c23",
17
+ "#e91e63",
18
+ "#9c27b0",
19
+ "#673ab7",
20
+ "#3f51b5",
21
+ "#5677fc",
22
+ "#03a9f4",
23
+ "#00bcd4",
24
+ "#009688",
25
+ "#259b24",
26
+ "#8bc34a",
27
+ "#afb42b",
28
+ "#ff9800",
29
+ "#ff5722",
30
+ "#795548",
31
+ "#607d8b",
32
+ "#880e4f",
33
+ "#827717",
34
+ "#f7981d", // orange
35
+ "#7e3794",
36
+ ];
37
+ var str = key.toString();
38
+ for (var i = 0; i < str.length; i++) {
39
+ hash = str.charCodeAt(i) + ((hash << 5) - hash);
40
+ hash = hash & hash;
41
+ }
42
+ hash = ((hash % colors.length) + colors.length) % colors.length;
43
+ return colors[hash];
44
+ };
45
+ exports.getSelectionColorAtIndex = getSelectionColorAtIndex;
46
+ function parseRGBA(rgbString) {
47
+ var regex = /^rgba?\((\d+),\s*(\d+),\s*(\d+),?\s*([01]?(\.\d+)?)?\)$/;
48
+ var match = rgbString.match(regex);
49
+ if (match) {
50
+ var _a = tslib_1.__read(match.map(Number), 5), r = _a[1], g = _a[2], b = _a[3], a = _a[4];
51
+ return { r: r, g: g, b: b, a: a === undefined || isNaN(a) ? 1 : a };
52
+ }
53
+ return undefined;
54
+ }
55
+ function normalizeColor(color) {
56
+ if (color.startsWith("#")) {
57
+ // Hex to RGB conversion
58
+ var hex = color.slice(1);
59
+ var bigint = parseInt(hex, 16);
60
+ var r = (bigint >> 16) & 255;
61
+ var g = (bigint >> 8) & 255;
62
+ var b = bigint & 255;
63
+ return { r: r, g: g, b: b };
64
+ }
65
+ else if (color.startsWith("rgb")) {
66
+ // RGB string parsing
67
+ var parsedColor = parseRGBA(color);
68
+ if (parsedColor) {
69
+ return parsedColor;
70
+ }
71
+ }
72
+ return null; // Unsupported color format
73
+ }
74
+ var rgbaToArgbHex = function (_a) {
75
+ var r = _a.r, g = _a.g, b = _a.b, _b = _a.a, a = _b === void 0 ? 1 : _b;
76
+ var alpha = Math.round(a * 255);
77
+ var hex = [alpha, r, g, b]
78
+ .map(function (value) {
79
+ var hex = value.toString(16);
80
+ return hex.length === 1 ? "0" + hex : hex;
81
+ })
82
+ .join("");
83
+ return hex;
84
+ };
85
+ exports.rgbaToArgbHex = rgbaToArgbHex;
86
+ var isSameColor = function (colorA, colorB) {
87
+ if (colorA === colorB) {
88
+ return true;
89
+ }
90
+ var normalizedColorA = (0, typeguards_1.isNil)(colorA) ? undefined : normalizeColor(colorA);
91
+ var normalizedColorB = (0, typeguards_1.isNil)(colorB) ? undefined : normalizeColor(colorB);
92
+ if (normalizedColorA && normalizedColorB) {
93
+ return (normalizedColorA.r === normalizedColorB.r &&
94
+ normalizedColorA.g === normalizedColorB.g &&
95
+ normalizedColorA.b === normalizedColorB.b);
96
+ }
97
+ return undefined;
98
+ };
99
+ exports.isSameColor = isSameColor;
100
+ // Returns a `#RRGGBB` hex string, or undefined if the input isn't a recognized
101
+ // color form (rgb()/rgba() function or already-hex). The previous fallback
102
+ // `return color` let CSS fragments like `font-family:"…"` flow through as
103
+ // "colors", which then ended up in cell formatting and broke xlsx export.
104
+ var HEX_COLOR_RE = /^#?[0-9A-Fa-f]{3}([0-9A-Fa-f])?([0-9A-Fa-f]{2})?([0-9A-Fa-f]{2})?$/;
105
+ var colorStringToHex = function (color) {
106
+ if ((0, typeguards_1.isNil)(color)) {
107
+ return undefined;
108
+ }
109
+ var trimmed = color.trim();
110
+ if (!trimmed)
111
+ return undefined;
112
+ if (trimmed.startsWith("rgb")) {
113
+ var rgb = parseRGBA(trimmed);
114
+ return rgb ? (0, exports.rgbToHex)(rgb.r, rgb.g, rgb.b) : undefined;
115
+ }
116
+ if (HEX_COLOR_RE.test(trimmed)) {
117
+ return trimmed.startsWith("#") ? trimmed : "#".concat(trimmed);
118
+ }
119
+ return undefined;
120
+ };
121
+ exports.colorStringToHex = colorStringToHex;
122
+ // Lighten a color
123
+ var lightenColor = function (unit, color) {
124
+ if (unit === void 0) { unit = 0.2; }
125
+ var rgbColor = normalizeColor(color);
126
+ return rgbColor ? shade(unit, rgbColor) : undefined;
127
+ };
128
+ exports.lightenColor = lightenColor;
129
+ var hexToRgb = function (hex) {
130
+ var bigint = parseInt(hex.slice(1), 16);
131
+ var r = (bigint >> 16) & 255;
132
+ var g = (bigint >> 8) & 255;
133
+ var b = bigint & 255;
134
+ return { r: r, g: g, b: b };
135
+ };
136
+ exports.hexToRgb = hexToRgb;
137
+ var rgbToHex = function (r, g, b) {
138
+ var hex = ((r << 16) | (g << 8) | b).toString(16);
139
+ return "#" + ("000000" + hex).slice(-6);
140
+ };
141
+ exports.rgbToHex = rgbToHex;
142
+ var getContrastColor = function (backgroundColor, lightColor, darkColor) {
143
+ var rgbColor = normalizeColor(backgroundColor);
144
+ if (rgbColor) {
145
+ var r = rgbColor.r, g = rgbColor.g, b = rgbColor.b;
146
+ var yiq = (r * 299 + g * 587 + b * 114) / 1000;
147
+ return yiq >= 128 ? lightColor : darkColor;
148
+ }
149
+ return undefined;
150
+ };
151
+ exports.getContrastColor = getContrastColor;
152
+ var shade = function (light, _a) {
153
+ var r = _a.r, g = _a.g, b = _a.b, a = _a.a;
154
+ if (a === 0) {
155
+ return undefined;
156
+ }
157
+ if (light < 0) {
158
+ r = (1 + light) * r;
159
+ g = (1 + light) * g;
160
+ b = (1 + light) * b;
161
+ }
162
+ else {
163
+ r = (1 - light) * r + light * 255;
164
+ g = (1 - light) * g + light * 255;
165
+ b = (1 - light) * b + light * 255;
166
+ }
167
+ return (0, exports.rgbToHex)(r, g, b);
168
+ };
@@ -0,0 +1,2 @@
1
+ export declare const IndexedColors: readonly string[];
2
+ //# sourceMappingURL=colors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"colors.d.ts","sourceRoot":"","sources":["../../colors.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,aAAa,mBAyExB,CAAC"}
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IndexedColors = void 0;
4
+ // Excel indexed colors mapping used for legacy color references
5
+ exports.IndexedColors = Object.freeze([
6
+ // 0-7
7
+ "#000000",
8
+ "#FFFFFF",
9
+ "#FF0000",
10
+ "#00FF00",
11
+ "#0000FF",
12
+ "#FFFF00",
13
+ "#FF00FF",
14
+ "#00FFFF",
15
+ // 8-15
16
+ "#000000",
17
+ "#FFFFFF",
18
+ "#FF0000",
19
+ "#00FF00",
20
+ "#0000FF",
21
+ "#FFFF00",
22
+ "#FF00FF",
23
+ "#00FFFF",
24
+ // 16-23
25
+ "#800000",
26
+ "#008000",
27
+ "#000080",
28
+ "#808000",
29
+ "#800080",
30
+ "#008080",
31
+ "#C0C0C0",
32
+ "#808080",
33
+ // 24-31
34
+ "#9999FF",
35
+ "#993366",
36
+ "#FFFFCC",
37
+ "#CCFFFF",
38
+ "#660066",
39
+ "#FF8080",
40
+ "#0066CC",
41
+ "#CCCCFF",
42
+ // 32-39
43
+ "#000080",
44
+ "#FF00FF",
45
+ "#FFFF00",
46
+ "#00FFFF",
47
+ "#800080",
48
+ "#800000",
49
+ "#008080",
50
+ "#0000FF",
51
+ // 40-47
52
+ "#00CCFF",
53
+ "#CCFFFF",
54
+ "#CCFFCC",
55
+ "#FFFF99",
56
+ "#99CCFF",
57
+ "#FF99CC",
58
+ "#CC99FF",
59
+ "#FFCC99",
60
+ // 48-55
61
+ "#3366FF",
62
+ "#33CCCC",
63
+ "#99CC00",
64
+ "#FFCC00",
65
+ "#FF9900",
66
+ "#FF6600",
67
+ "#666699",
68
+ "#969696",
69
+ // 56-63
70
+ "#003366",
71
+ "#339966",
72
+ "#003300",
73
+ "#333300",
74
+ "#993300",
75
+ "#993366",
76
+ "#333399",
77
+ "#333333",
78
+ ]);
@@ -0,0 +1,49 @@
1
+ import type { BooleanCondition } from "@rowsncolumns/common-types";
2
+ /**
3
+ * Minimal structural shape of a conditional-format rule needed by the
4
+ * predicate/builder below. The full `ConditionalFormatRule` type lives in the
5
+ * `@rowsncolumns/spreadsheet` package and is structurally compatible with
6
+ * this shape.
7
+ */
8
+ export type ConditionalFormatRuleLike = {
9
+ booleanRule?: {
10
+ condition?: BooleanCondition | null;
11
+ } | null;
12
+ };
13
+ /**
14
+ * Whether a CF rule is evaluated via the calculator (formula path) instead of
15
+ * the synchronous `checkBooleanRule` path used in
16
+ * `apps/spreadsheet/hooks/use-conditional-formatting.ts`.
17
+ *
18
+ * Returns `true` for every condition type that `buildConditionalFormatExpression`
19
+ * can express as a single-cell formula: CUSTOM_FORMULA, all NUMBER_/DATE_/TEXT_
20
+ * comparisons, BETWEEN/NOT_BETWEEN, CONTAINS/NOT_CONTAINS, STARTS_WITH/ENDS_WITH,
21
+ * ONE_OF_LIST/ONE_OF_RANGE, BLANK/NOT_BLANK, BOOLEAN, TEXT_IS_EMAIL/TEXT_IS_URL.
22
+ * The calculator stores the per-cell boolean on
23
+ * `cellData.conditionalFormattingResultById[ruleId]`.
24
+ *
25
+ * Returns `false` — leaving the rule on the sync path — for rules that aren't
26
+ * expressible as a single-cell formula:
27
+ * - Aggregate-over-range: gradient/heatmap, TOP/BOTTOM N, DUPLICATE/UNIQUE,
28
+ * NUMBER_ABOVE_AVERAGE / NUMBER_BELOW_AVERAGE — the result depends on
29
+ * other cells in the range, not just the current cell.
30
+ * - Loop-state: NUMBER_GREATER_THAN_PREVIOUS and the other `*_PREVIOUS`
31
+ * variants — compare against the prior row's value held in iteration state.
32
+ * - Calendar-relative dates: DATE_TODAY / DATE_THIS_WEEK / DATE_THIS_MONTH
33
+ * and the surrounding family, plus DATE_IS_VALID. Could be expressed via
34
+ * TODAY()-based formulas if we ever want to migrate them.
35
+ * - Cell error state: ERROR / NOT_ERROR — read directly from the extended
36
+ * value in `getValidationValue`.
37
+ *
38
+ * The consumers (rule create/update/delete enqueueing in spreadsheet-state,
39
+ * `getConditionalFormatFormula` building the expression, `getValidationValue`
40
+ * choosing where to read the per-cell value, and the `isFormulaRule` branch
41
+ * in `use-conditional-formatting.ts`) MUST stay in lockstep with this
42
+ * predicate — if it returns `true`, the calculator owns the result and the
43
+ * sync `checkBooleanRule` path must not run for that rule. Delegating to
44
+ * `buildConditionalFormatExpression` keeps the predicate and the builder from
45
+ * drifting.
46
+ */
47
+ export declare const isConditionalFormatFormulaRule: (rule: ConditionalFormatRuleLike | undefined) => boolean;
48
+ export declare const buildConditionalFormatExpression: (rule: ConditionalFormatRuleLike | undefined, baseCellRef: string, locale?: string) => string | undefined;
49
+ //# sourceMappingURL=conditional-format.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conditional-format.d.ts","sourceRoot":"","sources":["../../conditional-format.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAEjB,MAAM,4BAA4B,CAAC;AAKpC;;;;;GAKG;AACH,MAAM,MAAM,yBAAyB,GAAG;IACtC,WAAW,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,gBAAgB,GAAG,IAAI,CAAA;KAAE,GAAG,IAAI,CAAC;CAC9D,CAAC;AA+DF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,eAAO,MAAM,8BAA8B,GACzC,MAAM,yBAAyB,GAAG,SAAS,YAK5C,CAAC;AAEF,eAAO,MAAM,gCAAgC,GAC3C,MAAM,yBAAyB,GAAG,SAAS,EAC3C,aAAa,MAAM,EACnB,SAAS,MAAM,uBA8HhB,CAAC"}