@trebco/treb 23.6.5 → 25.0.0-rc2

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 (217) hide show
  1. package/.eslintignore +8 -0
  2. package/.eslintrc.js +164 -0
  3. package/README-shadow-DOM.md +88 -0
  4. package/README.md +37 -130
  5. package/api-config.json +29 -0
  6. package/api-generator/api-generator-types.ts +82 -0
  7. package/api-generator/api-generator.ts +1172 -0
  8. package/api-generator/package.json +3 -0
  9. package/build/treb-spreadsheet.mjs +14 -0
  10. package/{treb.d.ts → build/treb.d.ts} +323 -271
  11. package/esbuild-custom-element.mjs +336 -0
  12. package/esbuild.js +305 -0
  13. package/package.json +49 -14
  14. package/treb-base-types/package.json +5 -0
  15. package/treb-base-types/src/api_types.ts +36 -0
  16. package/treb-base-types/src/area.ts +583 -0
  17. package/treb-base-types/src/basic_types.ts +45 -0
  18. package/treb-base-types/src/cell.ts +612 -0
  19. package/treb-base-types/src/cells.ts +1066 -0
  20. package/treb-base-types/src/color.ts +124 -0
  21. package/treb-base-types/src/import.ts +71 -0
  22. package/treb-base-types/src/index-standalone.ts +29 -0
  23. package/treb-base-types/src/index.ts +42 -0
  24. package/treb-base-types/src/layout.ts +47 -0
  25. package/treb-base-types/src/localization.ts +187 -0
  26. package/treb-base-types/src/rectangle.ts +145 -0
  27. package/treb-base-types/src/render_text.ts +72 -0
  28. package/treb-base-types/src/style.ts +545 -0
  29. package/treb-base-types/src/table.ts +109 -0
  30. package/treb-base-types/src/text_part.ts +54 -0
  31. package/treb-base-types/src/theme.ts +608 -0
  32. package/treb-base-types/src/union.ts +152 -0
  33. package/treb-base-types/src/value-type.ts +164 -0
  34. package/treb-base-types/style/resizable.css +59 -0
  35. package/treb-calculator/modern.tsconfig.json +11 -0
  36. package/treb-calculator/package.json +5 -0
  37. package/treb-calculator/src/calculator.ts +2546 -0
  38. package/treb-calculator/src/complex-math.ts +558 -0
  39. package/treb-calculator/src/dag/array-vertex.ts +198 -0
  40. package/treb-calculator/src/dag/graph.ts +951 -0
  41. package/treb-calculator/src/dag/leaf_vertex.ts +118 -0
  42. package/treb-calculator/src/dag/spreadsheet_vertex.ts +327 -0
  43. package/treb-calculator/src/dag/spreadsheet_vertex_base.ts +44 -0
  44. package/treb-calculator/src/dag/vertex.ts +352 -0
  45. package/treb-calculator/src/descriptors.ts +162 -0
  46. package/treb-calculator/src/expression-calculator.ts +1069 -0
  47. package/treb-calculator/src/function-error.ts +103 -0
  48. package/treb-calculator/src/function-library.ts +103 -0
  49. package/treb-calculator/src/functions/base-functions.ts +1214 -0
  50. package/treb-calculator/src/functions/checkbox.ts +164 -0
  51. package/treb-calculator/src/functions/complex-functions.ts +253 -0
  52. package/treb-calculator/src/functions/finance-functions.ts +399 -0
  53. package/treb-calculator/src/functions/information-functions.ts +102 -0
  54. package/treb-calculator/src/functions/matrix-functions.ts +182 -0
  55. package/treb-calculator/src/functions/sparkline.ts +335 -0
  56. package/treb-calculator/src/functions/statistics-functions.ts +350 -0
  57. package/treb-calculator/src/functions/text-functions.ts +298 -0
  58. package/treb-calculator/src/index.ts +27 -0
  59. package/treb-calculator/src/notifier-types.ts +59 -0
  60. package/treb-calculator/src/primitives.ts +428 -0
  61. package/treb-calculator/src/utilities.ts +305 -0
  62. package/treb-charts/package.json +5 -0
  63. package/treb-charts/src/chart-functions.ts +156 -0
  64. package/treb-charts/src/chart-types.ts +230 -0
  65. package/treb-charts/src/chart.ts +1288 -0
  66. package/treb-charts/src/index.ts +24 -0
  67. package/treb-charts/src/main.ts +37 -0
  68. package/treb-charts/src/rectangle.ts +52 -0
  69. package/treb-charts/src/renderer.ts +1841 -0
  70. package/treb-charts/src/util.ts +122 -0
  71. package/treb-charts/style/charts.scss +221 -0
  72. package/treb-charts/style/old-charts.scss +250 -0
  73. package/treb-embed/markup/layout.html +137 -0
  74. package/treb-embed/markup/toolbar.html +175 -0
  75. package/treb-embed/modern.tsconfig.json +25 -0
  76. package/treb-embed/src/custom-element/content-types.d.ts +18 -0
  77. package/treb-embed/src/custom-element/global.d.ts +11 -0
  78. package/treb-embed/src/custom-element/spreadsheet-constructor.ts +1228 -0
  79. package/treb-embed/src/custom-element/treb-global.ts +44 -0
  80. package/treb-embed/src/custom-element/treb-spreadsheet-element.ts +52 -0
  81. package/treb-embed/src/embedded-spreadsheet.ts +5358 -0
  82. package/treb-embed/src/index.ts +16 -0
  83. package/treb-embed/src/language-model.ts +41 -0
  84. package/treb-embed/src/options.ts +298 -0
  85. package/treb-embed/src/progress-dialog.ts +228 -0
  86. package/treb-embed/src/selection-state.ts +16 -0
  87. package/treb-embed/src/spinner.ts +42 -0
  88. package/treb-embed/src/toolbar-message.ts +96 -0
  89. package/treb-embed/src/types.ts +167 -0
  90. package/treb-embed/style/autocomplete.scss +103 -0
  91. package/treb-embed/style/dark-theme.scss +114 -0
  92. package/treb-embed/style/defaults.scss +36 -0
  93. package/treb-embed/style/dialog.scss +181 -0
  94. package/treb-embed/style/dropdown-select.scss +101 -0
  95. package/treb-embed/style/formula-bar.scss +193 -0
  96. package/treb-embed/style/grid.scss +374 -0
  97. package/treb-embed/style/layout.scss +424 -0
  98. package/treb-embed/style/mouse-mask.scss +67 -0
  99. package/treb-embed/style/note.scss +92 -0
  100. package/treb-embed/style/overlay-editor.scss +102 -0
  101. package/treb-embed/style/spinner.scss +92 -0
  102. package/treb-embed/style/tab-bar.scss +228 -0
  103. package/treb-embed/style/table.scss +80 -0
  104. package/treb-embed/style/theme-defaults.scss +444 -0
  105. package/treb-embed/style/toolbar.scss +416 -0
  106. package/treb-embed/style/tooltip.scss +68 -0
  107. package/treb-embed/style/treb-icons.scss +130 -0
  108. package/treb-embed/style/treb-spreadsheet-element.scss +20 -0
  109. package/treb-embed/style/z-index.scss +43 -0
  110. package/treb-export/docs/charts.md +68 -0
  111. package/treb-export/modern.tsconfig.json +19 -0
  112. package/treb-export/package.json +4 -0
  113. package/treb-export/src/address-type.ts +77 -0
  114. package/treb-export/src/base-template.ts +22 -0
  115. package/treb-export/src/column-width.ts +85 -0
  116. package/treb-export/src/drawing2/chart-template-components2.ts +389 -0
  117. package/treb-export/src/drawing2/chart2.ts +282 -0
  118. package/treb-export/src/drawing2/column-chart-template2.ts +521 -0
  119. package/treb-export/src/drawing2/donut-chart-template2.ts +296 -0
  120. package/treb-export/src/drawing2/drawing2.ts +355 -0
  121. package/treb-export/src/drawing2/embedded-image.ts +71 -0
  122. package/treb-export/src/drawing2/scatter-chart-template2.ts +555 -0
  123. package/treb-export/src/export-worker/export-worker.ts +99 -0
  124. package/treb-export/src/export-worker/index-modern.ts +22 -0
  125. package/treb-export/src/export2.ts +2204 -0
  126. package/treb-export/src/import2.ts +882 -0
  127. package/treb-export/src/relationship.ts +36 -0
  128. package/treb-export/src/shared-strings2.ts +128 -0
  129. package/treb-export/src/template-2.ts +22 -0
  130. package/treb-export/src/unescape_xml.ts +47 -0
  131. package/treb-export/src/workbook-sheet2.ts +182 -0
  132. package/treb-export/src/workbook-style2.ts +1285 -0
  133. package/treb-export/src/workbook-theme2.ts +88 -0
  134. package/treb-export/src/workbook2.ts +491 -0
  135. package/treb-export/src/xml-utils.ts +201 -0
  136. package/treb-export/template/base/[Content_Types].xml +2 -0
  137. package/treb-export/template/base/_rels/.rels +2 -0
  138. package/treb-export/template/base/docProps/app.xml +2 -0
  139. package/treb-export/template/base/docProps/core.xml +12 -0
  140. package/treb-export/template/base/xl/_rels/workbook.xml.rels +2 -0
  141. package/treb-export/template/base/xl/sharedStrings.xml +2 -0
  142. package/treb-export/template/base/xl/styles.xml +2 -0
  143. package/treb-export/template/base/xl/theme/theme1.xml +2 -0
  144. package/treb-export/template/base/xl/workbook.xml +2 -0
  145. package/treb-export/template/base/xl/worksheets/sheet1.xml +2 -0
  146. package/treb-export/template/base.xlsx +0 -0
  147. package/treb-format/package.json +8 -0
  148. package/treb-format/src/format.test.ts +213 -0
  149. package/treb-format/src/format.ts +942 -0
  150. package/treb-format/src/format_cache.ts +199 -0
  151. package/treb-format/src/format_parser.ts +723 -0
  152. package/treb-format/src/index.ts +25 -0
  153. package/treb-format/src/number_format_section.ts +100 -0
  154. package/treb-format/src/value_parser.ts +337 -0
  155. package/treb-grid/package.json +5 -0
  156. package/treb-grid/src/editors/autocomplete.ts +394 -0
  157. package/treb-grid/src/editors/autocomplete_matcher.ts +260 -0
  158. package/treb-grid/src/editors/formula_bar.ts +473 -0
  159. package/treb-grid/src/editors/formula_editor_base.ts +910 -0
  160. package/treb-grid/src/editors/overlay_editor.ts +511 -0
  161. package/treb-grid/src/index.ts +37 -0
  162. package/treb-grid/src/layout/base_layout.ts +2618 -0
  163. package/treb-grid/src/layout/grid_layout.ts +299 -0
  164. package/treb-grid/src/layout/rectangle_cache.ts +86 -0
  165. package/treb-grid/src/render/selection-renderer.ts +414 -0
  166. package/treb-grid/src/render/svg_header_overlay.ts +93 -0
  167. package/treb-grid/src/render/svg_selection_block.ts +187 -0
  168. package/treb-grid/src/render/tile_renderer.ts +2122 -0
  169. package/treb-grid/src/types/annotation.ts +216 -0
  170. package/treb-grid/src/types/border_constants.ts +34 -0
  171. package/treb-grid/src/types/clipboard_data.ts +31 -0
  172. package/treb-grid/src/types/data_model.ts +334 -0
  173. package/treb-grid/src/types/drag_mask.ts +81 -0
  174. package/treb-grid/src/types/grid.ts +7743 -0
  175. package/treb-grid/src/types/grid_base.ts +3644 -0
  176. package/treb-grid/src/types/grid_command.ts +470 -0
  177. package/treb-grid/src/types/grid_events.ts +124 -0
  178. package/treb-grid/src/types/grid_options.ts +97 -0
  179. package/treb-grid/src/types/grid_selection.ts +60 -0
  180. package/treb-grid/src/types/named_range.ts +369 -0
  181. package/treb-grid/src/types/scale-control.ts +202 -0
  182. package/treb-grid/src/types/serialize_options.ts +72 -0
  183. package/treb-grid/src/types/set_range_options.ts +52 -0
  184. package/treb-grid/src/types/sheet.ts +3099 -0
  185. package/treb-grid/src/types/sheet_types.ts +95 -0
  186. package/treb-grid/src/types/tab_bar.ts +464 -0
  187. package/treb-grid/src/types/tile.ts +59 -0
  188. package/treb-grid/src/types/update_flags.ts +75 -0
  189. package/treb-grid/src/util/dom_utilities.ts +44 -0
  190. package/treb-grid/src/util/fontmetrics2.ts +179 -0
  191. package/treb-grid/src/util/ua.ts +104 -0
  192. package/treb-logo.svg +18 -0
  193. package/treb-parser/package.json +5 -0
  194. package/treb-parser/src/csv-parser.ts +122 -0
  195. package/treb-parser/src/index.ts +25 -0
  196. package/treb-parser/src/md-parser.ts +526 -0
  197. package/treb-parser/src/parser-types.ts +397 -0
  198. package/treb-parser/src/parser.test.ts +298 -0
  199. package/treb-parser/src/parser.ts +2673 -0
  200. package/treb-utils/package.json +5 -0
  201. package/treb-utils/src/dispatch.ts +57 -0
  202. package/treb-utils/src/event_source.ts +147 -0
  203. package/treb-utils/src/ievent_source.ts +33 -0
  204. package/treb-utils/src/index.ts +31 -0
  205. package/treb-utils/src/measurement.ts +174 -0
  206. package/treb-utils/src/resizable.ts +160 -0
  207. package/treb-utils/src/scale.ts +137 -0
  208. package/treb-utils/src/serialize_html.ts +124 -0
  209. package/treb-utils/src/template.ts +70 -0
  210. package/treb-utils/src/validate_uri.ts +61 -0
  211. package/tsconfig.json +10 -0
  212. package/tsproject.json +30 -0
  213. package/util/license-plugin-esbuild.js +86 -0
  214. package/util/list-css-vars.sh +46 -0
  215. package/README-esm.md +0 -37
  216. package/treb-bundle.css +0 -2
  217. package/treb-bundle.mjs +0 -15
@@ -0,0 +1,201 @@
1
+ /*
2
+ * This file is part of TREB.
3
+ *
4
+ * TREB is free software: you can redistribute it and/or modify it under the
5
+ * terms of the GNU General Public License as published by the Free Software
6
+ * Foundation, either version 3 of the License, or (at your option) any
7
+ * later version.
8
+ *
9
+ * TREB is distributed in the hope that it will be useful, but WITHOUT ANY
10
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12
+ * details.
13
+ *
14
+ * You should have received a copy of the GNU General Public License along
15
+ * with TREB. If not, see <https://www.gnu.org/licenses/>.
16
+ *
17
+ * Copyright 2022-2023 trebco, llc.
18
+ * info@treb.app
19
+ *
20
+ */
21
+
22
+ import { Unescape } from './unescape_xml';
23
+ import type { X2jOptions } from 'fast-xml-parser';
24
+
25
+ export const XMLTagProcessor = (name: string, value: string): string => Unescape(value);
26
+
27
+ export const XMLOptions: Partial<X2jOptions> = {
28
+ ignoreAttributes: false,
29
+ attributeNamePrefix: '__',
30
+ trimValues: false,
31
+ textNodeName: 'text__',
32
+ tagValueProcessor: XMLTagProcessor,
33
+ ignoreDeclaration: true,
34
+ };
35
+
36
+ /**
37
+ * group attributes under `a$`, and don't add attribute prefixes (should be
38
+ * implicit on that option, but hey).
39
+ */
40
+ export const XMLOptions2: Partial<X2jOptions> = {
41
+ ignoreAttributes: false,
42
+ // attrNodeName: 'a$', // FXP v4
43
+ attributesGroupName: 'a$',
44
+ attributeNamePrefix: '',
45
+ textNodeName: 't$',
46
+ trimValues: false,
47
+ ignoreDeclaration: true,
48
+
49
+ // arrayMode: false, // this was removed in FXP, but false is default anyway
50
+
51
+ isArray: (tagName: string, jPath: string, isLeafNode: boolean, isAttribute: boolean) => {
52
+ return /Relationship$/.test(tagName);
53
+ },
54
+
55
+ tagValueProcessor: XMLTagProcessor,
56
+ };
57
+
58
+ /**
59
+ * some utility functions for working with the xml/json
60
+ * objects we get from fast-xml-parser.
61
+ */
62
+ export class XMLUtils {
63
+
64
+ /**
65
+ * @deprecated
66
+ *
67
+ * use the array version. it will run in approximately the same
68
+ * amount of time for non-array structures, and it's safer in the
69
+ * event you have an array somewhere in the node hierarchy.
70
+ */
71
+ public static FindChild(root: any = {}, path: string) {
72
+ const elements = path.split('/');
73
+ for (const element of elements) {
74
+ root = root[element];
75
+ if (!root) { return undefined; }
76
+ }
77
+ return root;
78
+ }
79
+
80
+ /**
81
+ * the aim of this function is to handle the case where we don't
82
+ * know where the arrays are -- any element in the path could be
83
+ * multiple. for example, the path
84
+ *
85
+ * a/b/c
86
+ *
87
+ * could be reflected in xml as
88
+ *
89
+ * <a>
90
+ * <b>
91
+ * <c/>
92
+ * <c/>
93
+ * </b>
94
+ * </a>
95
+ *
96
+ * or it could be
97
+ *
98
+ * <a>
99
+ * <b>
100
+ * <c/>
101
+ * </b>
102
+ * <b>
103
+ * <c/>
104
+ * </b>
105
+ * </a>
106
+ *
107
+ * in either case we want both "c" elements.
108
+ */
109
+ public static FindAll(root: any = {}, path: string): any[] {
110
+
111
+ const components = path.split('/');
112
+
113
+ // allow proper paths starting with ./
114
+ if (components[0] === '.') {
115
+ components.shift();
116
+ }
117
+
118
+ // don't allow going up the stack (we don't have it)
119
+ if (components[0] === '..') {
120
+ throw new Error(`invalid path (no access to parent)`);
121
+ }
122
+
123
+ // root path would be written like /x/a (I think)
124
+ if (components[0] === '') {
125
+ throw new Error(`invalid path (no access to root)`);
126
+ }
127
+
128
+ // TODO
129
+ if (components[0] === '**') {
130
+ throw new Error('ENOTIMPL');
131
+ }
132
+
133
+ return this.FindAllTail(root, components);
134
+ }
135
+
136
+ /**
137
+ * how hard would it be to support wildcards? ...
138
+ * basically if you see a wildcard, just treat every element as a
139
+ * match -- right?
140
+ */
141
+ public static FindAllTail(root: any, elements: string[]): any[] {
142
+
143
+ if (Array.isArray(root)) {
144
+ return root.reduce((composite, element) => {
145
+ return composite.concat(this.FindAllTail(element, elements));
146
+ }, []);
147
+ }
148
+
149
+ for (let i = 0; i < elements.length; i++) {
150
+ const element = elements[i];
151
+
152
+ // wildcard should be handled here... if element is a wildard,
153
+ // then either continue (single element) or recurse (multiple elements).
154
+ // we need to avoid the attribute and text children.
155
+
156
+ // NOTE we still have some code using the old options type, which
157
+ // maps attributes and text differently... hopefully they won't use
158
+ // wildcards
159
+
160
+ // two loops, really? come on
161
+
162
+ if (element === '*') {
163
+ root = Object.keys(root).
164
+ filter(key => (key !== 'a$' && key !== 't$')).
165
+ map(key => root[key]);
166
+ }
167
+ else {
168
+ root = root[element];
169
+ }
170
+
171
+ if (!root) {
172
+ return []; // no matching element
173
+ }
174
+
175
+ if (Array.isArray(root)) {
176
+
177
+ // if this is the target node, then return the array;
178
+ // otherwise, we need to recurse. also we can check for
179
+ // zero-length array.
180
+
181
+ if (i === elements.length - 1 || root.length === 0) {
182
+ return root;
183
+ }
184
+
185
+ const step = elements.slice(1);
186
+ return root.reduce((composite, element) => {
187
+ return composite.concat(this.FindAllTail(element, step));
188
+ }, []);
189
+
190
+ }
191
+
192
+ }
193
+
194
+ // if we get here, root must be a single element so wrap it up
195
+
196
+ return [root];
197
+
198
+ }
199
+
200
+ }
201
+
@@ -0,0 +1,2 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2
+ <Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/><Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"/><Override PartName="/xl/worksheets/sheet1.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/><Override PartName="/xl/theme/theme1.xml" ContentType="application/vnd.openxmlformats-officedocument.theme+xml"/><Override PartName="/xl/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml"/><Override PartName="/xl/sharedStrings.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml"/><Override PartName="/docProps/core.xml" ContentType="application/vnd.openxmlformats-package.core-properties+xml"/><Override PartName="/docProps/app.xml" ContentType="application/vnd.openxmlformats-officedocument.extended-properties+xml"/></Types>
@@ -0,0 +1,2 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2
+ <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties" Target="docProps/app.xml"/><Relationship Id="rId2" Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" Target="docProps/core.xml"/><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml"/></Relationships>
@@ -0,0 +1,2 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2
+ <Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties" xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes"><Application>Microsoft Excel</Application><DocSecurity>0</DocSecurity><ScaleCrop>false</ScaleCrop><HeadingPairs><vt:vector size="2" baseType="variant"><vt:variant><vt:lpstr>Worksheets</vt:lpstr></vt:variant><vt:variant><vt:i4>1</vt:i4></vt:variant></vt:vector></HeadingPairs><TitlesOfParts><vt:vector size="1" baseType="lpstr"><vt:lpstr>Sheet1</vt:lpstr></vt:vector></TitlesOfParts><Company></Company><LinksUpToDate>false</LinksUpToDate><SharedDoc>false</SharedDoc><HyperlinksChanged>false</HyperlinksChanged><AppVersion>16.0300</AppVersion></Properties>
@@ -0,0 +1,12 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2
+ <cp:coreProperties
3
+ xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties"
4
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
5
+ xmlns:dcterms="http://purl.org/dc/terms/"
6
+ xmlns:dcmitype="http://purl.org/dc/dcmitype/"
7
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
8
+ <dc:creator>TREB</dc:creator>
9
+ <cp:lastModifiedBy>TREB</cp:lastModifiedBy>
10
+ <dcterms:created xsi:type="dcterms:W3CDTF">2019-01-31T16:48:03Z</dcterms:created>
11
+ <dcterms:modified xsi:type="dcterms:W3CDTF">2019-01-31T16:48:28Z</dcterms:modified>
12
+ </cp:coreProperties>
@@ -0,0 +1,2 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2
+ <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/><Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme" Target="theme/theme1.xml"/><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet1.xml"/><Relationship Id="rId4" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings" Target="sharedStrings.xml"/></Relationships>
@@ -0,0 +1,2 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2
+ <sst xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"/>
@@ -0,0 +1,2 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2
+ <styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="x14ac x16r2 xr" xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac" xmlns:x16r2="http://schemas.microsoft.com/office/spreadsheetml/2015/02/main" xmlns:xr="http://schemas.microsoft.com/office/spreadsheetml/2014/revision"><fonts count="1" x14ac:knownFonts="1"><font><sz val="11"/><color theme="1"/><name val="Calibri"/><family val="2"/><scheme val="minor"/></font></fonts><fills count="2"><fill><patternFill patternType="none"/></fill><fill><patternFill patternType="gray125"/></fill></fills><borders count="1"><border><left/><right/><top/><bottom/><diagonal/></border></borders><cellStyleXfs count="1"><xf numFmtId="0" fontId="0" fillId="0" borderId="0"/></cellStyleXfs><cellXfs count="1"><xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0"/></cellXfs><cellStyles count="1"><cellStyle name="Normal" xfId="0" builtinId="0"/></cellStyles><dxfs count="0"/><tableStyles count="0" defaultTableStyle="TableStyleMedium2" defaultPivotStyle="PivotStyleLight16"/><extLst><ext uri="{EB79DEF2-80B8-43e5-95BD-54CBDDF9020C}" xmlns:x14="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main"><x14:slicerStyles defaultSlicerStyle="SlicerStyleLight1"/></ext><ext uri="{9260A510-F301-46a8-8635-F512D64BE5F5}" xmlns:x15="http://schemas.microsoft.com/office/spreadsheetml/2010/11/main"><x15:timelineStyles defaultTimelineStyle="TimeSlicerStyleLight1"/></ext></extLst></styleSheet>
@@ -0,0 +1,2 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2
+ <a:theme xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" name="Office Theme"><a:themeElements><a:clrScheme name="Office"><a:dk1><a:sysClr val="windowText" lastClr="000000"/></a:dk1><a:lt1><a:sysClr val="window" lastClr="FFFFFF"/></a:lt1><a:dk2><a:srgbClr val="44546A"/></a:dk2><a:lt2><a:srgbClr val="E7E6E6"/></a:lt2><a:accent1><a:srgbClr val="4472C4"/></a:accent1><a:accent2><a:srgbClr val="ED7D31"/></a:accent2><a:accent3><a:srgbClr val="A5A5A5"/></a:accent3><a:accent4><a:srgbClr val="FFC000"/></a:accent4><a:accent5><a:srgbClr val="5B9BD5"/></a:accent5><a:accent6><a:srgbClr val="70AD47"/></a:accent6><a:hlink><a:srgbClr val="0563C1"/></a:hlink><a:folHlink><a:srgbClr val="954F72"/></a:folHlink></a:clrScheme><a:fontScheme name="Office"><a:majorFont><a:latin typeface="Calibri Light" panose="020F0302020204030204"/><a:ea typeface=""/><a:cs typeface=""/><a:font script="Jpan" typeface="游ゴシック Light"/><a:font script="Hang" typeface="맑은 고딕"/><a:font script="Hans" typeface="等线 Light"/><a:font script="Hant" typeface="新細明體"/><a:font script="Arab" typeface="Times New Roman"/><a:font script="Hebr" typeface="Times New Roman"/><a:font script="Thai" typeface="Tahoma"/><a:font script="Ethi" typeface="Nyala"/><a:font script="Beng" typeface="Vrinda"/><a:font script="Gujr" typeface="Shruti"/><a:font script="Khmr" typeface="MoolBoran"/><a:font script="Knda" typeface="Tunga"/><a:font script="Guru" typeface="Raavi"/><a:font script="Cans" typeface="Euphemia"/><a:font script="Cher" typeface="Plantagenet Cherokee"/><a:font script="Yiii" typeface="Microsoft Yi Baiti"/><a:font script="Tibt" typeface="Microsoft Himalaya"/><a:font script="Thaa" typeface="MV Boli"/><a:font script="Deva" typeface="Mangal"/><a:font script="Telu" typeface="Gautami"/><a:font script="Taml" typeface="Latha"/><a:font script="Syrc" typeface="Estrangelo Edessa"/><a:font script="Orya" typeface="Kalinga"/><a:font script="Mlym" typeface="Kartika"/><a:font script="Laoo" typeface="DokChampa"/><a:font script="Sinh" typeface="Iskoola Pota"/><a:font script="Mong" typeface="Mongolian Baiti"/><a:font script="Viet" typeface="Times New Roman"/><a:font script="Uigh" typeface="Microsoft Uighur"/><a:font script="Geor" typeface="Sylfaen"/><a:font script="Armn" typeface="Arial"/><a:font script="Bugi" typeface="Leelawadee UI"/><a:font script="Bopo" typeface="Microsoft JhengHei"/><a:font script="Java" typeface="Javanese Text"/><a:font script="Lisu" typeface="Segoe UI"/><a:font script="Mymr" typeface="Myanmar Text"/><a:font script="Nkoo" typeface="Ebrima"/><a:font script="Olck" typeface="Nirmala UI"/><a:font script="Osma" typeface="Ebrima"/><a:font script="Phag" typeface="Phagspa"/><a:font script="Syrn" typeface="Estrangelo Edessa"/><a:font script="Syrj" typeface="Estrangelo Edessa"/><a:font script="Syre" typeface="Estrangelo Edessa"/><a:font script="Sora" typeface="Nirmala UI"/><a:font script="Tale" typeface="Microsoft Tai Le"/><a:font script="Talu" typeface="Microsoft New Tai Lue"/><a:font script="Tfng" typeface="Ebrima"/></a:majorFont><a:minorFont><a:latin typeface="Calibri" panose="020F0502020204030204"/><a:ea typeface=""/><a:cs typeface=""/><a:font script="Jpan" typeface="游ゴシック"/><a:font script="Hang" typeface="맑은 고딕"/><a:font script="Hans" typeface="等线"/><a:font script="Hant" typeface="新細明體"/><a:font script="Arab" typeface="Arial"/><a:font script="Hebr" typeface="Arial"/><a:font script="Thai" typeface="Tahoma"/><a:font script="Ethi" typeface="Nyala"/><a:font script="Beng" typeface="Vrinda"/><a:font script="Gujr" typeface="Shruti"/><a:font script="Khmr" typeface="DaunPenh"/><a:font script="Knda" typeface="Tunga"/><a:font script="Guru" typeface="Raavi"/><a:font script="Cans" typeface="Euphemia"/><a:font script="Cher" typeface="Plantagenet Cherokee"/><a:font script="Yiii" typeface="Microsoft Yi Baiti"/><a:font script="Tibt" typeface="Microsoft Himalaya"/><a:font script="Thaa" typeface="MV Boli"/><a:font script="Deva" typeface="Mangal"/><a:font script="Telu" typeface="Gautami"/><a:font script="Taml" typeface="Latha"/><a:font script="Syrc" typeface="Estrangelo Edessa"/><a:font script="Orya" typeface="Kalinga"/><a:font script="Mlym" typeface="Kartika"/><a:font script="Laoo" typeface="DokChampa"/><a:font script="Sinh" typeface="Iskoola Pota"/><a:font script="Mong" typeface="Mongolian Baiti"/><a:font script="Viet" typeface="Arial"/><a:font script="Uigh" typeface="Microsoft Uighur"/><a:font script="Geor" typeface="Sylfaen"/><a:font script="Armn" typeface="Arial"/><a:font script="Bugi" typeface="Leelawadee UI"/><a:font script="Bopo" typeface="Microsoft JhengHei"/><a:font script="Java" typeface="Javanese Text"/><a:font script="Lisu" typeface="Segoe UI"/><a:font script="Mymr" typeface="Myanmar Text"/><a:font script="Nkoo" typeface="Ebrima"/><a:font script="Olck" typeface="Nirmala UI"/><a:font script="Osma" typeface="Ebrima"/><a:font script="Phag" typeface="Phagspa"/><a:font script="Syrn" typeface="Estrangelo Edessa"/><a:font script="Syrj" typeface="Estrangelo Edessa"/><a:font script="Syre" typeface="Estrangelo Edessa"/><a:font script="Sora" typeface="Nirmala UI"/><a:font script="Tale" typeface="Microsoft Tai Le"/><a:font script="Talu" typeface="Microsoft New Tai Lue"/><a:font script="Tfng" typeface="Ebrima"/></a:minorFont></a:fontScheme><a:fmtScheme name="Office"><a:fillStyleLst><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:lumMod val="110000"/><a:satMod val="105000"/><a:tint val="67000"/></a:schemeClr></a:gs><a:gs pos="50000"><a:schemeClr val="phClr"><a:lumMod val="105000"/><a:satMod val="103000"/><a:tint val="73000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:lumMod val="105000"/><a:satMod val="109000"/><a:tint val="81000"/></a:schemeClr></a:gs></a:gsLst><a:lin ang="5400000" scaled="0"/></a:gradFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:satMod val="103000"/><a:lumMod val="102000"/><a:tint val="94000"/></a:schemeClr></a:gs><a:gs pos="50000"><a:schemeClr val="phClr"><a:satMod val="110000"/><a:lumMod val="100000"/><a:shade val="100000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:lumMod val="99000"/><a:satMod val="120000"/><a:shade val="78000"/></a:schemeClr></a:gs></a:gsLst><a:lin ang="5400000" scaled="0"/></a:gradFill></a:fillStyleLst><a:lnStyleLst><a:ln w="6350" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:prstDash val="solid"/><a:miter lim="800000"/></a:ln><a:ln w="12700" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:prstDash val="solid"/><a:miter lim="800000"/></a:ln><a:ln w="19050" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:prstDash val="solid"/><a:miter lim="800000"/></a:ln></a:lnStyleLst><a:effectStyleLst><a:effectStyle><a:effectLst/></a:effectStyle><a:effectStyle><a:effectLst/></a:effectStyle><a:effectStyle><a:effectLst><a:outerShdw blurRad="57150" dist="19050" dir="5400000" algn="ctr" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="63000"/></a:srgbClr></a:outerShdw></a:effectLst></a:effectStyle></a:effectStyleLst><a:bgFillStyleLst><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:solidFill><a:schemeClr val="phClr"><a:tint val="95000"/><a:satMod val="170000"/></a:schemeClr></a:solidFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="93000"/><a:satMod val="150000"/><a:shade val="98000"/><a:lumMod val="102000"/></a:schemeClr></a:gs><a:gs pos="50000"><a:schemeClr val="phClr"><a:tint val="98000"/><a:satMod val="130000"/><a:shade val="90000"/><a:lumMod val="103000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:shade val="63000"/><a:satMod val="120000"/></a:schemeClr></a:gs></a:gsLst><a:lin ang="5400000" scaled="0"/></a:gradFill></a:bgFillStyleLst></a:fmtScheme></a:themeElements><a:objectDefaults/><a:extraClrSchemeLst/><a:extLst><a:ext uri="{05A4C25C-085E-4340-85A3-A5531E510DB2}"><thm15:themeFamily xmlns:thm15="http://schemas.microsoft.com/office/thememl/2012/main" name="Office Theme" id="{62F939B6-93AF-4DB8-9C6B-D6C7DFDC589F}" vid="{4A3C46E8-61CC-4603-A589-7422A47A8E4A}"/></a:ext></a:extLst></a:theme>
@@ -0,0 +1,2 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2
+ <workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="x15 xr xr6 xr10 xr2" xmlns:x15="http://schemas.microsoft.com/office/spreadsheetml/2010/11/main" xmlns:xr="http://schemas.microsoft.com/office/spreadsheetml/2014/revision" xmlns:xr6="http://schemas.microsoft.com/office/spreadsheetml/2016/revision6" xmlns:xr10="http://schemas.microsoft.com/office/spreadsheetml/2016/revision10" xmlns:xr2="http://schemas.microsoft.com/office/spreadsheetml/2015/revision2"><fileVersion appName="xl" lastEdited="7" lowestEdited="7" rupBuild="21126"/><workbookPr defaultThemeVersion="166925"/><mc:AlternateContent xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"><mc:Choice Requires="x15"><x15ac:absPath url="H:\TREB\treb-export\template\" xmlns:x15ac="http://schemas.microsoft.com/office/spreadsheetml/2010/11/ac"/></mc:Choice></mc:AlternateContent><xr:revisionPtr revIDLastSave="0" documentId="8_{D858F9F7-0D92-4AE4-8A42-480CB359B62D}" xr6:coauthVersionLast="40" xr6:coauthVersionMax="40" xr10:uidLastSave="{00000000-0000-0000-0000-000000000000}"/><bookViews><workbookView xWindow="0" yWindow="0" windowWidth="24570" windowHeight="11130" xr2:uid="{DE4E7D35-492D-40D7-9925-4647F587E1DE}"/></bookViews><sheets><sheet name="Sheet1" sheetId="1" r:id="rId1"/></sheets><calcPr calcId="191029"/><extLst><ext uri="{140A7094-0E35-4892-8432-C4D2E57EDEB5}" xmlns:x15="http://schemas.microsoft.com/office/spreadsheetml/2010/11/main"><x15:workbookPr chartTrackingRefBase="1"/></ext></extLst></workbook>
@@ -0,0 +1,2 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2
+ <worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="x14ac xr xr2 xr3" xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac" xmlns:xr="http://schemas.microsoft.com/office/spreadsheetml/2014/revision" xmlns:xr2="http://schemas.microsoft.com/office/spreadsheetml/2015/revision2" xmlns:xr3="http://schemas.microsoft.com/office/spreadsheetml/2016/revision3" xr:uid="{0D8E5CA2-5C9E-4D4B-94C5-F35C041F39BD}"><dimension ref="A1"/><sheetViews><sheetView tabSelected="1" workbookViewId="0"/></sheetViews><sheetFormatPr defaultRowHeight="15" x14ac:dyDescent="0.25"/><sheetData/><pageMargins left="0.7" right="0.7" top="0.75" bottom="0.75" header="0.3" footer="0.3"/></worksheet>
Binary file
@@ -0,0 +1,8 @@
1
+ {
2
+ "name": "treb-format",
3
+ "version": "16.0.0",
4
+ "main": "src/index.ts",
5
+ "dependencies": {
6
+ "treb-base-types": "file:../treb-base-types"
7
+ }
8
+ }
@@ -0,0 +1,213 @@
1
+ /*
2
+ * This file is part of TREB.
3
+ *
4
+ * TREB is free software: you can redistribute it and/or modify it under the
5
+ * terms of the GNU General Public License as published by the Free Software
6
+ * Foundation, either version 3 of the License, or (at your option) any
7
+ * later version.
8
+ *
9
+ * TREB is distributed in the hope that it will be useful, but WITHOUT ANY
10
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12
+ * details.
13
+ *
14
+ * You should have received a copy of the GNU General Public License along
15
+ * with TREB. If not, see <https://www.gnu.org/licenses/>.
16
+ *
17
+ * Copyright 2022-2023 trebco, llc.
18
+ * info@treb.app
19
+ *
20
+ */
21
+
22
+ import {NumberFormat} from './format';
23
+
24
+ test('integer format: "0"', () => {
25
+ const integer_format = new NumberFormat('0');
26
+ expect(integer_format.Format(0)).toBe('0');
27
+ expect(integer_format.Format(100)).toBe('100');
28
+ expect(integer_format.Format(9.9)).toBe('10');
29
+ expect(integer_format.Format(3.3)).toBe('3');
30
+ });
31
+
32
+ test('decimal format: "0.00"', () => {
33
+ const decimal_format = new NumberFormat('0.00');
34
+ expect(decimal_format.Format(0)).toBe('0.00');
35
+ expect(decimal_format.Format(0.5)).toBe('0.50');
36
+ expect(decimal_format.Format(3.33)).toBe('3.33');
37
+ expect(decimal_format.Format(99.99)).toBe('99.99');
38
+ expect(decimal_format.Format(99.999)).toBe('100.00');
39
+ });
40
+
41
+ test('scaling: #,##0, and #,##0,,', () => {
42
+ const thousands_format = new NumberFormat('#,##0,');
43
+ expect(thousands_format.Format(0)).toBe('0');
44
+ expect(thousands_format.Format(20000)).toBe('20');
45
+ expect(thousands_format.Format(20000000)).toBe('20,000');
46
+
47
+ const millions_format = new NumberFormat('#,##0,,');
48
+ expect(millions_format.Format(0)).toBe('0');
49
+ expect(millions_format.Format(20000)).toBe('0');
50
+ expect(millions_format.Format(20000000)).toBe('20');
51
+ });
52
+
53
+ test('grouping: "#,##0"', () => {
54
+ const grouping_format = new NumberFormat('#,##0');
55
+ expect(grouping_format.Format(0)).toBe('0');
56
+ expect(grouping_format.Format(10000)).toBe('10,000');
57
+ expect(grouping_format.Format(1000)).toBe('1,000');
58
+ expect(grouping_format.Format(999999.9)).toBe('1,000,000');
59
+ });
60
+
61
+ test('digits', () => {
62
+ const digits_format = new NumberFormat('0000');
63
+ expect(digits_format.Format(0)).toBe('0000');
64
+ expect(digits_format.Format(100)).toBe('0100');
65
+ });
66
+
67
+ test('sections', () => {
68
+ const section_format = new NumberFormat('a 0;b 0;c 0;d 0');
69
+ expect(section_format.Format(1)).toBe('a 1');
70
+ expect(section_format.Format(-100)).toBe('b 100');
71
+ expect(section_format.Format(0)).toBe('c 0');
72
+ expect(section_format.Format('x')).toBe('d 0');
73
+ });
74
+
75
+ test('strings', () => {
76
+ const string_format = new NumberFormat('1: @;2: @;3: @;4: @');
77
+ expect(string_format.Format(1)).toBe('1: 1');
78
+ expect(string_format.Format(-1)).toBe('2: -1');
79
+ expect(string_format.Format(0)).toBe('3: 0');
80
+ expect(string_format.Format('test')).toBe('4: test');
81
+ });
82
+
83
+ test('default string', () => {
84
+ const a = new NumberFormat('0;-0;0;@');
85
+ expect(a.Format(100)).toBe('100');
86
+
87
+ const b = new NumberFormat('@');
88
+ expect(b.Format(100)).toBe('100');
89
+
90
+ });
91
+
92
+ test('escape', () => {
93
+ let escape_format = new NumberFormat('\\* 0');
94
+ expect(escape_format.Format(100)).toBe('* 100');
95
+
96
+ escape_format = new NumberFormat('mm/dd/yy \\*');
97
+ expect(escape_format.Format(0)).toBe('12/31/69 *');
98
+
99
+ expect(() => {
100
+ escape_format = new NumberFormat('0 \\');
101
+ }).toThrow();
102
+
103
+ expect(() => {
104
+ escape_format = new NumberFormat('mm/dd/yy \\');
105
+ }).toThrow();
106
+ });
107
+
108
+ test('layout', () => {
109
+ let layout_format = new NumberFormat('$* _(#,##0_);[red]$* (#,##0);$* -_)');
110
+ expect(layout_format.Format(1, 12)).toBe('$ 1 ');
111
+ expect(layout_format.Format(0, 12)).toBe('$ - ');
112
+ expect(layout_format.Format(999999.99, 12)).toBe('$ 1,000,000 ');
113
+ expect(layout_format.Format(-3333, 12)).toBe('$ (3,333)');
114
+
115
+ expect(() => {
116
+ layout_format = new NumberFormat(' *');
117
+ }).toThrow();
118
+
119
+ expect(() => {
120
+ layout_format = new NumberFormat(' _');
121
+ }).toThrow();
122
+
123
+ expect(() => {
124
+ layout_format = new NumberFormat(' * * 0');
125
+ }).toThrow();
126
+
127
+ expect(() => {
128
+ layout_format = new NumberFormat('mm/dd/yy *');
129
+ }).toThrow();
130
+
131
+ expect(() => {
132
+ layout_format = new NumberFormat('mm/dd/yy _');
133
+ }).toThrow();
134
+
135
+ expect(() => {
136
+ layout_format = new NumberFormat('mm/dd/yy * * ');
137
+ }).toThrow();
138
+
139
+ });
140
+
141
+ test('short date', () => {
142
+ const short_date_format = new NumberFormat('mm/dd/yy');
143
+ expect(short_date_format.Format(0)).toBe('12/31/69');
144
+ expect(short_date_format.Format(1)).toBe('01/01/70');
145
+ expect(short_date_format.Format(3456.78)).toBe('06/19/79');
146
+ });
147
+
148
+ test('timestamp', () => {
149
+ const timestamp_format = new NumberFormat('dddd mmmm dd, yyyy hh:mm:ss AM/PM');
150
+ expect(timestamp_format.Format(0)).toBe('Wednesday December 31, 1969 04:00:00 PM');
151
+ expect(timestamp_format.Format(1)).toBe('Thursday January 01, 1970 04:00:00 PM');
152
+ expect(timestamp_format.Format(3456.78)).toBe('Tuesday June 19, 1979 11:43:12 AM');
153
+ });
154
+
155
+ test('short/long day/month', () => {
156
+ const time_format = new NumberFormat('ddd DDD DDDD mmm mmmmm MMM MMMM');
157
+ expect(time_format.Format(0)).toBe('Wed WED WEDNESDAY Dec D DEC DECEMBER');
158
+ expect(time_format.Format(1)).toBe('Thu THU THURSDAY Jan J JAN JANUARY');
159
+ expect(time_format.Format(3456.78)).toBe('Tue TUE TUESDAY Jun J JUN JUNE');
160
+ });
161
+
162
+ test('variable time fields', () => {
163
+ const time_format = new NumberFormat('m d yyyy h:m:s');
164
+ expect(time_format.Format(0)).toBe('12 31 1969 16:0:0');
165
+ expect(time_format.Format(1)).toBe('1 1 1970 16:0:0');
166
+ expect(time_format.Format(3456.78)).toBe('6 19 1979 11:43:12');
167
+ expect(time_format.Format(5591.5008)).toBe('4 23 1985 4:1:9');
168
+ });
169
+
170
+ test('millis', () => {
171
+ const millis_format = new NumberFormat('hh:mm:ss.00');
172
+ expect(millis_format.Format(1.23456)).toBe('21:37:45.98');
173
+ });
174
+
175
+ test('mutation', () => {
176
+ const base_format = new NumberFormat('0');
177
+ expect(base_format.toString()).toBe('0');
178
+
179
+ base_format.IncreaseDecimal();
180
+ expect(base_format.toString()).toBe('0.0');
181
+ base_format.IncreaseDecimal();
182
+ expect(base_format.toString()).toBe('0.00');
183
+ base_format.DecreaseDecimal();
184
+ expect(base_format.toString()).toBe('0.0');
185
+
186
+ base_format.ToggleGrouping();
187
+ expect(base_format.toString()).toBe('#,##0.0');
188
+ base_format.RemoveGrouping();
189
+ expect(base_format.toString()).toBe('0.0');
190
+ base_format.AddGrouping();
191
+ expect(base_format.toString()).toBe('#,##0.0');
192
+ base_format.ToggleGrouping();
193
+ expect(base_format.toString()).toBe('0.0');
194
+ });
195
+
196
+ test('representation', () => {
197
+ let format = new NumberFormat('$* _(#,##0_);[red]$* (#,##0);$* -_;@)');
198
+ expect(format.pattern).toBe('$* _(#,##0_);[red]$* (#,##0);$* -_;@)');
199
+ expect(format.toString()).toBe('$* _(#,##0_);[red]$* (#,##0);$* -_;@)');
200
+ expect(format.date_format).toBe(false);
201
+
202
+ format = new NumberFormat('0,,');
203
+ expect(format.pattern).toBe('0,,');
204
+ expect(format.toString()).toBe('0,,');
205
+ expect(format.date_format).toBe(false);
206
+
207
+ format = new NumberFormat('mmmm dd yyyy');
208
+ expect(format.pattern).toBe('mmmm dd yyyy');
209
+ expect(format.toString()).toBe('mmmm dd yyyy');
210
+ expect(format.date_format).toBe(true);
211
+
212
+ });
213
+