@fibery/views 17.0.4 → 18.0.2

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 (236) hide show
  1. package/lib/index.js +17 -0
  2. package/lib/jest.config.d.ts +2 -0
  3. package/lib/jest.config.js +33 -0
  4. package/lib/src/field-utils/avatar.d.ts +20 -0
  5. package/lib/src/field-utils/avatar.js +42 -0
  6. package/lib/src/field-utils/back-references.d.ts +15 -0
  7. package/lib/src/field-utils/back-references.js +21 -0
  8. package/lib/src/field-utils/comments.d.ts +60 -0
  9. package/lib/src/field-utils/comments.js +46 -0
  10. package/lib/src/field-utils/date-time.d.ts +14 -0
  11. package/lib/src/field-utils/date-time.js +56 -0
  12. package/lib/src/field-utils/enum-value.d.ts +13 -0
  13. package/lib/src/field-utils/enum-value.js +29 -0
  14. package/lib/src/field-utils/file.d.ts +4 -0
  15. package/lib/src/field-utils/file.js +18 -0
  16. package/lib/src/field-utils/icon.d.ts +10 -0
  17. package/lib/src/field-utils/icon.js +26 -0
  18. package/lib/src/field-utils/number.d.ts +31 -0
  19. package/lib/src/field-utils/number.js +91 -0
  20. package/lib/src/field-utils/reference-collection.d.ts +18 -0
  21. package/lib/src/field-utils/reference-collection.js +45 -0
  22. package/lib/src/field-utils/reference.d.ts +7 -0
  23. package/lib/src/field-utils/reference.js +57 -0
  24. package/lib/src/field-utils/relation-view.d.ts +2 -0
  25. package/lib/src/field-utils/relation-view.js +12 -0
  26. package/lib/src/field-utils/rich-text.d.ts +12 -0
  27. package/lib/src/field-utils/rich-text.js +27 -0
  28. package/lib/src/field-utils/text.d.ts +35 -0
  29. package/lib/src/field-utils/text.js +40 -0
  30. package/lib/src/field-utils/user-active.d.ts +8 -0
  31. package/lib/src/field-utils/user-active.js +28 -0
  32. package/lib/src/field-utils/user-role.d.ts +6 -0
  33. package/lib/src/field-utils/user-role.js +25 -0
  34. package/lib/src/field-utils/workflow.d.ts +15 -0
  35. package/lib/src/field-utils/workflow.js +56 -0
  36. package/lib/src/index.d.ts +16 -0
  37. package/lib/src/index.js +258 -0
  38. package/lib/src/private/board.d.ts +11 -0
  39. package/lib/src/private/board.js +326 -0
  40. package/lib/src/private/calendar.d.ts +10 -0
  41. package/lib/src/private/calendar.js +122 -0
  42. package/lib/src/private/feed.d.ts +10 -0
  43. package/lib/src/private/feed.js +119 -0
  44. package/lib/src/private/form.d.ts +3 -0
  45. package/lib/src/private/form.js +61 -0
  46. package/lib/src/private/map.d.ts +10 -0
  47. package/lib/src/private/map.js +119 -0
  48. package/lib/src/private/smart-folder.d.ts +23 -0
  49. package/lib/src/private/smart-folder.js +274 -0
  50. package/lib/src/private/test-data/garbage-test.d.ts +649 -0
  51. package/lib/src/private/test-data/garbage-test.js +520 -0
  52. package/lib/src/private/test-data/kanban.d.ts +1123 -0
  53. package/lib/src/private/test-data/kanban.js +1203 -0
  54. package/lib/src/private/test-data/tasks.d.ts +3216 -0
  55. package/lib/src/private/test-data/tasks.js +2731 -0
  56. package/lib/src/private/timeline.d.ts +10 -0
  57. package/lib/src/private/timeline.js +323 -0
  58. package/lib/src/private/units.d.ts +6 -0
  59. package/lib/src/private/units.js +144 -0
  60. package/lib/src/private/utils.d.ts +17 -0
  61. package/lib/src/private/utils.js +267 -0
  62. package/lib/src/tsfixme.d.ts +1 -0
  63. package/lib/src/tsfixme.js +2 -0
  64. package/lib/src/unit-definitions/avatar-collection.d.ts +2 -0
  65. package/lib/src/unit-definitions/avatar-collection.js +53 -0
  66. package/lib/src/unit-definitions/avatar-input.d.ts +2 -0
  67. package/lib/src/unit-definitions/avatar-input.js +12 -0
  68. package/lib/src/unit-definitions/avatar.d.ts +2 -0
  69. package/lib/src/unit-definitions/avatar.js +80 -0
  70. package/lib/src/unit-definitions/back-references-list.d.ts +2 -0
  71. package/lib/src/unit-definitions/back-references-list.js +38 -0
  72. package/lib/src/unit-definitions/bool-checkbox.d.ts +2 -0
  73. package/lib/src/unit-definitions/bool-checkbox.js +25 -0
  74. package/lib/src/unit-definitions/bool.d.ts +2 -0
  75. package/lib/src/unit-definitions/bool.js +22 -0
  76. package/lib/src/unit-definitions/collection-count.d.ts +2 -0
  77. package/lib/src/unit-definitions/collection-count.js +32 -0
  78. package/lib/src/unit-definitions/color-input.d.ts +2 -0
  79. package/lib/src/unit-definitions/color-input.js +21 -0
  80. package/lib/src/unit-definitions/comments-list.d.ts +2 -0
  81. package/lib/src/unit-definitions/comments-list.js +25 -0
  82. package/lib/src/unit-definitions/date-range-combobox.d.ts +2 -0
  83. package/lib/src/unit-definitions/date-range-combobox.js +22 -0
  84. package/lib/src/unit-definitions/date-range.d.ts +2 -0
  85. package/lib/src/unit-definitions/date-range.js +22 -0
  86. package/lib/src/unit-definitions/date-time-combobox.d.ts +2 -0
  87. package/lib/src/unit-definitions/date-time-combobox.js +22 -0
  88. package/lib/src/unit-definitions/date.d.ts +2 -0
  89. package/lib/src/unit-definitions/date.js +22 -0
  90. package/lib/src/unit-definitions/email-input.d.ts +2 -0
  91. package/lib/src/unit-definitions/email-input.js +12 -0
  92. package/lib/src/unit-definitions/email.d.ts +2 -0
  93. package/lib/src/unit-definitions/email.js +17 -0
  94. package/lib/src/unit-definitions/emoji.d.ts +2 -0
  95. package/lib/src/unit-definitions/emoji.js +17 -0
  96. package/lib/src/unit-definitions/file-collection-count.d.ts +2 -0
  97. package/lib/src/unit-definitions/file-collection-count.js +30 -0
  98. package/lib/src/unit-definitions/file-compact-collection.d.ts +2 -0
  99. package/lib/src/unit-definitions/file-compact-collection.js +30 -0
  100. package/lib/src/unit-definitions/file-compact-reference.d.ts +2 -0
  101. package/lib/src/unit-definitions/file-compact-reference.js +36 -0
  102. package/lib/src/unit-definitions/file-reference.d.ts +2 -0
  103. package/lib/src/unit-definitions/file-reference.js +26 -0
  104. package/lib/src/unit-definitions/files-gallery.d.ts +2 -0
  105. package/lib/src/unit-definitions/files-gallery.js +30 -0
  106. package/lib/src/unit-definitions/files-l-list-item.d.ts +2 -0
  107. package/lib/src/unit-definitions/files-l-list-item.js +26 -0
  108. package/lib/src/unit-definitions/files-l-list.d.ts +2 -0
  109. package/lib/src/unit-definitions/files-l-list.js +30 -0
  110. package/lib/src/unit-definitions/files-list-item.d.ts +2 -0
  111. package/lib/src/unit-definitions/files-list-item.js +26 -0
  112. package/lib/src/unit-definitions/files-list.d.ts +2 -0
  113. package/lib/src/unit-definitions/files-list.js +30 -0
  114. package/lib/src/unit-definitions/geometry-preview.d.ts +2 -0
  115. package/lib/src/unit-definitions/geometry-preview.js +17 -0
  116. package/lib/src/unit-definitions/icon-button.d.ts +2 -0
  117. package/lib/src/unit-definitions/icon-button.js +29 -0
  118. package/lib/src/unit-definitions/icon-input.d.ts +2 -0
  119. package/lib/src/unit-definitions/icon-input.js +12 -0
  120. package/lib/src/unit-definitions/id.d.ts +2 -0
  121. package/lib/src/unit-definitions/id.js +29 -0
  122. package/lib/src/unit-definitions/index.d.ts +27 -0
  123. package/lib/src/unit-definitions/index.js +57 -0
  124. package/lib/src/unit-definitions/json-input.d.ts +2 -0
  125. package/lib/src/unit-definitions/json-input.js +21 -0
  126. package/lib/src/unit-definitions/location-input.d.ts +2 -0
  127. package/lib/src/unit-definitions/location-input.js +18 -0
  128. package/lib/src/unit-definitions/location.d.ts +2 -0
  129. package/lib/src/unit-definitions/location.js +17 -0
  130. package/lib/src/unit-definitions/not-found.d.ts +2 -0
  131. package/lib/src/unit-definitions/not-found.js +24 -0
  132. package/lib/src/unit-definitions/number-input.d.ts +2 -0
  133. package/lib/src/unit-definitions/number-input.js +22 -0
  134. package/lib/src/unit-definitions/number.d.ts +2 -0
  135. package/lib/src/unit-definitions/number.js +27 -0
  136. package/lib/src/unit-definitions/phone-input.d.ts +2 -0
  137. package/lib/src/unit-definitions/phone-input.js +12 -0
  138. package/lib/src/unit-definitions/phone.d.ts +2 -0
  139. package/lib/src/unit-definitions/phone.js +12 -0
  140. package/lib/src/unit-definitions/progress-bar.d.ts +2 -0
  141. package/lib/src/unit-definitions/progress-bar.js +32 -0
  142. package/lib/src/unit-definitions/reference-collection-combobox.d.ts +2 -0
  143. package/lib/src/unit-definitions/reference-collection-combobox.js +21 -0
  144. package/lib/src/unit-definitions/reference-collection-list.d.ts +2 -0
  145. package/lib/src/unit-definitions/reference-collection-list.js +22 -0
  146. package/lib/src/unit-definitions/reference-collection-view.d.ts +2 -0
  147. package/lib/src/unit-definitions/reference-collection-view.js +19 -0
  148. package/lib/src/unit-definitions/reference-collection.d.ts +2 -0
  149. package/lib/src/unit-definitions/reference-collection.js +27 -0
  150. package/lib/src/unit-definitions/reference-combobox.d.ts +2 -0
  151. package/lib/src/unit-definitions/reference-combobox.js +21 -0
  152. package/lib/src/unit-definitions/reference-icon.d.ts +2 -0
  153. package/lib/src/unit-definitions/reference-icon.js +12 -0
  154. package/lib/src/unit-definitions/reference.d.ts +2 -0
  155. package/lib/src/unit-definitions/reference.js +49 -0
  156. package/lib/src/unit-definitions/rich-text-document.d.ts +2 -0
  157. package/lib/src/unit-definitions/rich-text-document.js +22 -0
  158. package/lib/src/unit-definitions/rich-text-snippet.d.ts +2 -0
  159. package/lib/src/unit-definitions/rich-text-snippet.js +39 -0
  160. package/lib/src/unit-definitions/single-location-preview.d.ts +2 -0
  161. package/lib/src/unit-definitions/single-location-preview.js +17 -0
  162. package/lib/src/unit-definitions/text-input.d.ts +2 -0
  163. package/lib/src/unit-definitions/text-input.js +22 -0
  164. package/lib/src/unit-definitions/text.d.ts +2 -0
  165. package/lib/src/unit-definitions/text.js +22 -0
  166. package/lib/src/unit-definitions/title-input.d.ts +2 -0
  167. package/lib/src/unit-definitions/title-input.js +16 -0
  168. package/lib/src/unit-definitions/title.d.ts +2 -0
  169. package/lib/src/unit-definitions/title.js +34 -0
  170. package/lib/src/unit-definitions/type-badge-abbr.d.ts +2 -0
  171. package/lib/src/unit-definitions/type-badge-abbr.js +25 -0
  172. package/lib/src/unit-definitions/type-badge.d.ts +2 -0
  173. package/lib/src/unit-definitions/type-badge.js +25 -0
  174. package/lib/src/unit-definitions/type-icon.d.ts +2 -0
  175. package/lib/src/unit-definitions/type-icon.js +25 -0
  176. package/lib/src/unit-definitions/url-input.d.ts +2 -0
  177. package/lib/src/unit-definitions/url-input.js +12 -0
  178. package/lib/src/unit-definitions/url.d.ts +2 -0
  179. package/lib/src/unit-definitions/url.js +17 -0
  180. package/lib/src/unit-definitions/user-button.d.ts +2 -0
  181. package/lib/src/unit-definitions/user-button.js +23 -0
  182. package/lib/src/unit-definitions/user-role-input.d.ts +2 -0
  183. package/lib/src/unit-definitions/user-role-input.js +12 -0
  184. package/lib/src/unit-definitions/user-role.d.ts +2 -0
  185. package/lib/src/unit-definitions/user-role.js +29 -0
  186. package/lib/src/unit-utils/access.d.ts +9 -0
  187. package/lib/src/unit-utils/access.js +14 -0
  188. package/lib/src/unit-utils/can-edit-field.d.ts +6 -0
  189. package/lib/src/unit-utils/can-edit-field.js +8 -0
  190. package/lib/src/unit-utils/common.d.ts +14 -0
  191. package/lib/src/unit-utils/common.js +43 -0
  192. package/lib/src/unit-utils/decimal.d.ts +42 -0
  193. package/lib/src/unit-utils/decimal.js +414 -0
  194. package/lib/src/unit-utils/dynamic-keys.d.ts +7 -0
  195. package/lib/src/unit-utils/dynamic-keys.js +13 -0
  196. package/lib/src/unit-utils/enums.d.ts +27 -0
  197. package/lib/src/unit-utils/enums.js +69 -0
  198. package/lib/src/unit-utils/formatters.d.ts +50 -0
  199. package/lib/src/unit-utils/formatters.js +163 -0
  200. package/lib/src/unit-utils/get-export-value.d.ts +45 -0
  201. package/lib/src/unit-utils/get-export-value.js +83 -0
  202. package/lib/src/unit-utils/get-field-label.d.ts +6 -0
  203. package/lib/src/unit-utils/get-field-label.js +10 -0
  204. package/lib/src/unit-utils/get-unmatched-unit-label.d.ts +2 -0
  205. package/lib/src/unit-utils/get-unmatched-unit-label.js +9 -0
  206. package/lib/src/unit-utils/schema.d.ts +4 -0
  207. package/lib/src/unit-utils/schema.js +12 -0
  208. package/lib/src/units/board.d.ts +43 -0
  209. package/lib/src/units/board.js +51 -0
  210. package/lib/src/units/canvas/all-units-data-definitions.d.ts +18 -0
  211. package/lib/src/units/canvas/all-units-data-definitions.js +40 -0
  212. package/lib/src/units/canvas/index.d.ts +42 -0
  213. package/lib/src/units/canvas/index.js +48 -0
  214. package/lib/src/units/canvas/type-badge-abbr.d.ts +36 -0
  215. package/lib/src/units/canvas/type-badge-abbr.js +11 -0
  216. package/lib/src/units/canvas/type-badge.d.ts +36 -0
  217. package/lib/src/units/canvas/type-badge.js +11 -0
  218. package/lib/src/units/default.d.ts +43 -0
  219. package/lib/src/units/default.js +51 -0
  220. package/lib/src/units/gallery.d.ts +3 -0
  221. package/lib/src/units/gallery.js +18 -0
  222. package/lib/src/units/gantt.d.ts +44 -0
  223. package/lib/src/units/gantt.js +59 -0
  224. package/lib/src/units/get-unit-definitions-for-view-type.d.ts +2 -0
  225. package/lib/src/units/get-unit-definitions-for-view-type.js +64 -0
  226. package/lib/src/units/grid.d.ts +42 -0
  227. package/lib/src/units/grid.js +67 -0
  228. package/lib/src/units/list.d.ts +43 -0
  229. package/lib/src/units/list.js +49 -0
  230. package/lib/src/units/make-factory.d.ts +50 -0
  231. package/lib/src/units/make-factory.js +245 -0
  232. package/lib/src/units/types.d.ts +73 -0
  233. package/lib/src/units/types.js +2 -0
  234. package/package.json +42 -52
  235. package/lib/views.js +0 -1813
  236. /package/{index.js → lib/index.d.ts} +0 -0
@@ -0,0 +1,414 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /* eslint-disable */
4
+ const EXP_LIMIT = 9e15;
5
+ // The limit on the value of `precision`, and on the value of the first argument to `toFixed`.
6
+ const MAX_DIGITS = 1e9;
7
+ // The minimum exponent value, beneath which underflow to zero occurs.
8
+ // JavaScript numbers: -324 (5e-324)
9
+ const minE = -EXP_LIMIT;
10
+ // The maximum exponent value, above which overflow to Infinity occurs.
11
+ // JavaScript numbers: 308 (1.7976931348623157e+308)
12
+ const maxE = EXP_LIMIT;
13
+ const decimalError = "[DecimalError] ";
14
+ const invalidArgument = decimalError + "Invalid argument: ";
15
+ const mathpow = Math.pow;
16
+ const isDecimalRegex = /^-?(\d+(\.\d*)?|\.\d+)$/i;
17
+ const BASE = 1e7;
18
+ const LOG_BASE = 7;
19
+ function checkInt32(i, min, max) {
20
+ if (i !== ~~i || i < min || i > max) {
21
+ throw Error(invalidArgument + i);
22
+ }
23
+ }
24
+ const isNeg = (decimal) => {
25
+ return decimal.s < 0;
26
+ };
27
+ const isZero = (decimal) => {
28
+ return Boolean(decimal.d) && decimal.d?.[0] === 0;
29
+ };
30
+ const isFinite = (decimal) => {
31
+ return Boolean(decimal.d);
32
+ };
33
+ // ±Infinity, NaN.
34
+ function nonFiniteToString(x) {
35
+ // Unsigned.
36
+ return String((x.s * x.s) / 0);
37
+ }
38
+ function getZeroString(k) {
39
+ let zs = "";
40
+ for (let i = k; i--;) {
41
+ zs += "0";
42
+ }
43
+ return zs;
44
+ }
45
+ function digitsToString(d) {
46
+ let str = "";
47
+ let w = d[0];
48
+ const indexOfLastWord = d.length - 1;
49
+ if (indexOfLastWord > 0) {
50
+ str += w;
51
+ let i;
52
+ for (i = 1; i < indexOfLastWord; i++) {
53
+ const ws = String(d[i]);
54
+ const k = LOG_BASE - ws.length;
55
+ if (k) {
56
+ str += getZeroString(k);
57
+ }
58
+ str += ws;
59
+ }
60
+ w = d[i];
61
+ const ws = String(w);
62
+ const k = LOG_BASE - ws.length;
63
+ if (k) {
64
+ str += getZeroString(k);
65
+ }
66
+ }
67
+ else if (w === 0) {
68
+ return "0";
69
+ }
70
+ // Remove trailing zeros of last w.
71
+ for (; w % 10 === 0;) {
72
+ w /= 10;
73
+ }
74
+ return str + w;
75
+ }
76
+ function finiteToString(x, sd) {
77
+ if (!isFinite(x)) {
78
+ return nonFiniteToString(x);
79
+ }
80
+ let k;
81
+ const e = x.e;
82
+ let str = digitsToString(x.d);
83
+ const len = str.length;
84
+ if (e < 0) {
85
+ str = "0." + getZeroString(-e - 1) + str;
86
+ if (sd && (k = sd - len) > 0) {
87
+ str += getZeroString(k);
88
+ }
89
+ }
90
+ else if (e >= len) {
91
+ str += getZeroString(e + 1 - len);
92
+ if (sd && (k = sd - e - 1) > 0) {
93
+ str = str + "." + getZeroString(k);
94
+ }
95
+ }
96
+ else {
97
+ if ((k = e + 1) < len) {
98
+ str = str.slice(0, k) + "." + str.slice(k);
99
+ }
100
+ if (sd && (k = sd - len) > 0) {
101
+ if (e + 1 === len) {
102
+ str += ".";
103
+ }
104
+ str += getZeroString(k);
105
+ }
106
+ }
107
+ return str;
108
+ }
109
+ /*
110
+ * Round `x` to `sd` significant digits using rounding mode `rm`.
111
+ * Check for over/under-flow.
112
+ */
113
+ function finalise(x, sd, rm) {
114
+ let digits;
115
+ let i;
116
+ let j;
117
+ let k;
118
+ let rd;
119
+ let roundUp;
120
+ let w;
121
+ let xd;
122
+ let xdi;
123
+ // Don't round if sd is null or undefined.
124
+ out: if (sd != null) {
125
+ xd = x.d;
126
+ // Infinity/NaN.
127
+ if (!xd) {
128
+ return x;
129
+ }
130
+ // rd: the rounding digit, i.e. the digit after the digit that may be rounded up.
131
+ // w: the word of xd containing rd, a base 1e7 number.
132
+ // xdi: the index of w within xd.
133
+ // digits: the number of digits of w.
134
+ // i: what would be the index of rd within w if all the numbers were 7 digits long (i.e. if
135
+ // they had leading zeros)
136
+ // j: if > 0, the actual index of rd within w (if < 0, rd is a leading zero).
137
+ // Get the length of the first word of the digits array xd.
138
+ for (digits = 1, k = xd[0]; k >= 10; k /= 10) {
139
+ digits++;
140
+ }
141
+ i = sd - digits;
142
+ // Is the rounding digit in the first word of xd?
143
+ if (i < 0) {
144
+ i += LOG_BASE;
145
+ j = sd;
146
+ w = xd[(xdi = 0)];
147
+ // Get the rounding digit at index j of w.
148
+ rd = (w / mathpow(10, digits - j - 1)) % 10 | 0;
149
+ }
150
+ else {
151
+ xdi = Math.ceil((i + 1) / LOG_BASE);
152
+ k = xd.length;
153
+ if (xdi >= k) {
154
+ break out;
155
+ }
156
+ else {
157
+ w = k = xd[xdi];
158
+ // Get the number of digits of w.
159
+ for (digits = 1; k >= 10; k /= 10) {
160
+ digits++;
161
+ }
162
+ // Get the index of rd within w.
163
+ i %= LOG_BASE;
164
+ // Get the index of rd within w, adjusted for leading zeros.
165
+ // The number of leading zeros of w is given by LOG_BASE - digits.
166
+ j = i - LOG_BASE + digits;
167
+ // Get the rounding digit at index j of w.
168
+ rd = j < 0 ? 0 : (w / mathpow(10, digits - j - 1)) % 10 | 0;
169
+ }
170
+ }
171
+ // Are there any non-zero digits after the rounding digit?
172
+ const isTruncated = sd < 0 || xd[xdi + 1] !== undefined || (j < 0 ? w : w % mathpow(10, digits - j - 1));
173
+ // The expression `w % mathpow(10, digits - j - 1)` returns all the digits of w to the right
174
+ // of the digit at (left-to-right) index j, e.g. if w is 908714 and j is 2, the expression
175
+ // will give 714.
176
+ roundUp =
177
+ rm < 4
178
+ ? (rd || isTruncated) && (rm == 0 || rm == (x.s < 0 ? 3 : 2))
179
+ : rd > 5 ||
180
+ (rd == 5 &&
181
+ (rm == 4 ||
182
+ isTruncated ||
183
+ (rm == 6 &&
184
+ // Check whether the digit to the left of the rounding digit is odd.
185
+ (i > 0 ? (j > 0 ? w / mathpow(10, digits - j) : 0) : xd[xdi - 1]) % 10 & 1) ||
186
+ rm == (x.s < 0 ? 8 : 7)));
187
+ if (sd < 1 || !xd[0]) {
188
+ xd.length = 0;
189
+ if (roundUp) {
190
+ // Convert sd to decimal places.
191
+ sd -= x.e + 1;
192
+ // 1, 0.1, 0.01, 0.001, 0.0001 etc.
193
+ xd[0] = mathpow(10, (LOG_BASE - (sd % LOG_BASE)) % LOG_BASE);
194
+ x.e = -sd || 0;
195
+ }
196
+ else {
197
+ // Zero.
198
+ xd[0] = x.e = 0;
199
+ }
200
+ return x;
201
+ }
202
+ // Remove excess digits.
203
+ if (i == 0) {
204
+ xd.length = xdi;
205
+ k = 1;
206
+ xdi--;
207
+ }
208
+ else {
209
+ xd.length = xdi + 1;
210
+ k = mathpow(10, LOG_BASE - i);
211
+ // E.g. 56700 becomes 56000 if 7 is the rounding digit.
212
+ // j > 0 means i > number of leading zeros of w.
213
+ xd[xdi] = j > 0 ? ((w / mathpow(10, digits - j)) % mathpow(10, j) | 0) * k : 0;
214
+ }
215
+ if (roundUp) {
216
+ for (;;) {
217
+ // Is the digit to be rounded up in the first word of xd?
218
+ if (xdi == 0) {
219
+ // i will be the length of xd[0] before k is added.
220
+ for (i = 1, j = xd[0]; j >= 10; j /= 10) {
221
+ i++;
222
+ }
223
+ j = xd[0] += k;
224
+ for (k = 1; j >= 10; j /= 10) {
225
+ k++;
226
+ }
227
+ // if i != k the length has increased.
228
+ if (i != k) {
229
+ x.e++;
230
+ if (xd[0] == BASE) {
231
+ xd[0] = 1;
232
+ }
233
+ }
234
+ break;
235
+ }
236
+ else {
237
+ xd[xdi] += k;
238
+ if (xd[xdi] != BASE) {
239
+ break;
240
+ }
241
+ xd[xdi--] = 0;
242
+ k = 1;
243
+ }
244
+ }
245
+ }
246
+ // Remove trailing zeros.
247
+ for (i = xd.length; xd[--i] === 0;) {
248
+ xd.pop();
249
+ }
250
+ }
251
+ return x;
252
+ }
253
+ function toFixedHelper(decimal, decimalPlaces, roundingMode) {
254
+ if (decimalPlaces === undefined) {
255
+ throw new Error("number of decimal places must be specified");
256
+ }
257
+ checkInt32(decimalPlaces, 0, MAX_DIGITS);
258
+ if (roundingMode === undefined) {
259
+ throw new Error("rounding strategy must be specified");
260
+ }
261
+ else {
262
+ checkInt32(roundingMode, 0, 8);
263
+ }
264
+ const rounded = finalise(new Decimal(decimal), decimalPlaces + decimal.e + 1, roundingMode);
265
+ const str = finiteToString(rounded, decimalPlaces + rounded.e + 1);
266
+ return isNeg(decimal) && !isZero(decimal) ? "-" + str : str;
267
+ }
268
+ function parseDecimal(x, str) {
269
+ let e = str.indexOf(".");
270
+ // Decimal point?
271
+ if (e > -1) {
272
+ str = str.replace(".", "");
273
+ }
274
+ if (e < 0) {
275
+ // Integer.
276
+ e = str.length;
277
+ }
278
+ let i;
279
+ // Determine leading zeros.
280
+ for (i = 0; str.charCodeAt(i) === 48; i++) { }
281
+ let len;
282
+ // Determine trailing zeros.
283
+ for (len = str.length; str.charCodeAt(len - 1) === 48; --len) { }
284
+ str = str.slice(i, len);
285
+ if (str) {
286
+ len -= i;
287
+ x.e = e = e - i - 1;
288
+ x.d = [];
289
+ // Transform base
290
+ // e is the base 10 exponent.
291
+ // i is where to slice str to get the first word of the digits array.
292
+ i = (e + 1) % LOG_BASE;
293
+ if (e < 0) {
294
+ i += LOG_BASE;
295
+ }
296
+ if (i < len) {
297
+ if (i) {
298
+ x.d.push(Number(str.slice(0, i)));
299
+ }
300
+ for (len -= LOG_BASE; i < len;) {
301
+ x.d.push(Number(str.slice(i, (i += LOG_BASE))));
302
+ }
303
+ str = str.slice(i);
304
+ i = LOG_BASE - str.length;
305
+ }
306
+ else {
307
+ i -= len;
308
+ }
309
+ for (; i--;) {
310
+ str += "0";
311
+ }
312
+ x.d.push(Number(str));
313
+ // Overflow?
314
+ if (x.e > maxE) {
315
+ // Infinity.
316
+ x.e = NaN;
317
+ x.d = null;
318
+ // Underflow?
319
+ }
320
+ else if (x.e < minE) {
321
+ // Zero.
322
+ x.e = 0;
323
+ x.d = [0];
324
+ }
325
+ }
326
+ else {
327
+ // Zero.
328
+ x.e = 0;
329
+ x.d = [0];
330
+ }
331
+ return x;
332
+ }
333
+ /*
334
+ * The Decimal class for arbitrary-precision decimal arithmetic.
335
+ *
336
+ * ROUND_UP 0 Away from zero.
337
+ * ROUND_DOWN 1 Towards zero.
338
+ * ROUND_CEIL 2 Towards +Infinity.
339
+ * ROUND_FLOOR 3 Towards -Infinity.
340
+ * ROUND_HALF_UP 4 Towards nearest neighbour. If equidistant, up.
341
+ * ROUND_HALF_DOWN 5 Towards nearest neighbour. If equidistant, down.
342
+ * ROUND_HALF_EVEN 6 Towards nearest neighbour. If equidistant, towards even neighbour.
343
+ * ROUND_HALF_CEIL 7 Towards nearest neighbour. If equidistant, towards +Infinity.
344
+ * ROUND_HALF_FLOOR 8 Towards nearest neighbour. If equidistant, towards -Infinity.
345
+ */
346
+ class Decimal {
347
+ static ROUND_UP = 0;
348
+ static ROUND_DOWN = 1;
349
+ static ROUND_CEIL = 2;
350
+ static ROUND_FLOOR = 3;
351
+ static ROUND_HALF_UP = 4;
352
+ static ROUND_HALF_DOWN = 5;
353
+ static ROUND_HALF_EVEN = 6;
354
+ static ROUND_HALF_CEIL = 7;
355
+ static ROUND_HALF_FLOOR = 8;
356
+ s = 0;
357
+ e = 0;
358
+ d = null;
359
+ /**
360
+ * Create a new Decimal instance.
361
+ * @param v A numeric string or Decimal instance
362
+ */
363
+ constructor(v) {
364
+ // Duplicate.
365
+ if (v instanceof Decimal) {
366
+ this.s = v.s;
367
+ this.e = v.e;
368
+ this.d = v.d ? v.d.slice() : v.d;
369
+ return;
370
+ }
371
+ if (typeof v !== "string") {
372
+ throw Error(invalidArgument + v);
373
+ }
374
+ // Minus sign?
375
+ if (v.charCodeAt(0) === 45) {
376
+ v = v.slice(1);
377
+ this.s = -1;
378
+ }
379
+ else {
380
+ this.s = 1;
381
+ }
382
+ if (!isDecimalRegex.test(v)) {
383
+ throw new Error("String value is not Decimal");
384
+ }
385
+ parseDecimal(this, v);
386
+ }
387
+ /**
388
+ * Return a string representing the value of this Decimal in normal (fixed-point) notation to
389
+ * `dp` fixed decimal places and rounded using rounding mode `rm`.
390
+ *
391
+ * As with JavaScript numbers, (-0).toFixed(0) is '0', but e.g. (-0.00001).toFixed(0) is '-0'.
392
+ *
393
+ * @param dp Decimal places. Integer, 0 to MAX_DIGITS inclusive.
394
+ * @param rm Rounding mode. Integer, 0 to 8 inclusive.
395
+ *
396
+ * @example
397
+ * (-0).toFixed(0) is '0', but (-0.1).toFixed(0) is '-0'.
398
+ * (-0).toFixed(1) is '0.0', but (-0.01).toFixed(1) is '-0.0'.
399
+ * (-0).toFixed(3) is '0.000'.
400
+ * (-0.5).toFixed(0) is '-0'.
401
+ */
402
+ toFixed(dp, rm) {
403
+ return toFixedHelper(this, dp, rm);
404
+ }
405
+ /**
406
+ * Test whether a string value is a valid decimal.
407
+ * @param value The string to test
408
+ * @returns true if the value is a valid decimal string
409
+ */
410
+ static isDecimal(value) {
411
+ return isDecimalRegex.test(value);
412
+ }
413
+ }
414
+ exports.default = Decimal;
@@ -0,0 +1,7 @@
1
+ export declare const isUserActiveDynamicKeyPrefix = "is-user-active";
2
+ export declare const isFinalStateDynamicKeyPrefix = "is-final-state";
3
+ export declare const colorCodingKeyPrefix = "color-coding";
4
+ export declare const hasAccessToSecretKeyPrefix = "has-access-to-secret";
5
+ export declare const collectionCountKeyPrefix = "collection-count";
6
+ export declare const accessCheckKeyKeyPrefix = "access/check";
7
+ export declare const makeDynamicKey: (prefix: string, key?: string) => string;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.makeDynamicKey = exports.accessCheckKeyKeyPrefix = exports.collectionCountKeyPrefix = exports.hasAccessToSecretKeyPrefix = exports.colorCodingKeyPrefix = exports.isFinalStateDynamicKeyPrefix = exports.isUserActiveDynamicKeyPrefix = void 0;
4
+ exports.isUserActiveDynamicKeyPrefix = "is-user-active";
5
+ exports.isFinalStateDynamicKeyPrefix = "is-final-state";
6
+ exports.colorCodingKeyPrefix = "color-coding";
7
+ exports.hasAccessToSecretKeyPrefix = "has-access-to-secret";
8
+ exports.collectionCountKeyPrefix = "collection-count";
9
+ exports.accessCheckKeyKeyPrefix = "access/check";
10
+ const makeDynamicKey = (prefix, key) => {
11
+ return `?${prefix}${key === undefined ? "" : `_${key}`}`;
12
+ };
13
+ exports.makeDynamicKey = makeDynamicKey;
@@ -0,0 +1,27 @@
1
+ import { TypeObject } from "@fibery/schema";
2
+ import { FieldExpression } from "@fibery/expression-utils";
3
+ import type { Select } from "@fibery/expression-utils/src/types";
4
+ export declare const getEnumIconColorQuery: ({ typeObject, contextPath, }: {
5
+ typeObject: TypeObject;
6
+ contextPath?: FieldExpression;
7
+ }) => Select;
8
+ export declare function getEnumIconSelect(typeObject: TypeObject): {
9
+ "enum/icon": string[];
10
+ } | {
11
+ "enum/icon"?: undefined;
12
+ };
13
+ export declare const getEnumsRequest: (enumTypeObject: TypeObject) => {
14
+ query: {
15
+ "q/from": string;
16
+ "q/select": {
17
+ "workflow/Final"?: string | undefined;
18
+ "workflow/Type"?: string | undefined;
19
+ "fibery/id": string;
20
+ "enum/name": string;
21
+ "fibery/rank": string;
22
+ };
23
+ "q/limit": string;
24
+ "q/order-by": (string | string[])[][];
25
+ };
26
+ params: {};
27
+ };
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getEnumsRequest = exports.getEnumIconColorQuery = void 0;
4
+ exports.getEnumIconSelect = getEnumIconSelect;
5
+ const select_1 = require("@fibery/query-utils/src/select");
6
+ const enum_value_1 = require("../field-utils/enum-value");
7
+ const access_1 = require("./access");
8
+ const getWorkflowQuery = ({ typeObject }) => {
9
+ if (!typeObject.isEnum) {
10
+ return null;
11
+ }
12
+ return typeObject.nameParts.namespace === "workflow"
13
+ ? {
14
+ "workflow/Final": "workflow/Final",
15
+ "workflow/Type": "workflow/Type",
16
+ }
17
+ : null;
18
+ };
19
+ const getEnumIconColorQuery = ({ typeObject, contextPath = [], }) => {
20
+ if (!typeObject.isEnum) {
21
+ return {};
22
+ }
23
+ const select = {
24
+ "?accessToIcon": ["q/access?", [...contextPath, "enum/icon"]],
25
+ };
26
+ if (Object.hasOwn(typeObject.fieldObjectsByName, "enum/color")) {
27
+ select["enum/color"] = "enum/color";
28
+ }
29
+ if (Object.hasOwn(typeObject.fieldObjectsByName, "enum/icon")) {
30
+ select["enum/icon"] = "enum/icon";
31
+ }
32
+ return select;
33
+ };
34
+ exports.getEnumIconColorQuery = getEnumIconColorQuery;
35
+ const getEnumNumberFieldQuery = (typeObject) => {
36
+ const fieldObject = (0, enum_value_1.getNumberFieldObject)(typeObject);
37
+ if (!fieldObject) {
38
+ return null;
39
+ }
40
+ return (0, select_1.toSelectMapClause)([fieldObject.name]);
41
+ };
42
+ function getEnumIconSelect(typeObject) {
43
+ if (typeObject.isEnum) {
44
+ return {
45
+ "enum/icon": ["enum/icon"],
46
+ };
47
+ }
48
+ return {};
49
+ }
50
+ const getEnumsRequest = (enumTypeObject) => {
51
+ return {
52
+ query: {
53
+ "q/from": enumTypeObject.name,
54
+ "q/select": {
55
+ "fibery/id": "fibery/id",
56
+ "enum/name": "enum/name",
57
+ "fibery/rank": "fibery/rank",
58
+ ...(0, access_1.generateAccessCheckQueryExpression)({ typeObject: enumTypeObject }),
59
+ ...(0, exports.getEnumIconColorQuery)({ typeObject: enumTypeObject }),
60
+ ...getWorkflowQuery({ typeObject: enumTypeObject }),
61
+ ...getEnumNumberFieldQuery(enumTypeObject),
62
+ },
63
+ "q/limit": "q/no-limit",
64
+ "q/order-by": [[["fibery/rank"], "q/asc"]],
65
+ },
66
+ params: {},
67
+ };
68
+ };
69
+ exports.getEnumsRequest = getEnumsRequest;
@@ -0,0 +1,50 @@
1
+ import { FieldObject } from "@fibery/schema";
2
+ import { NumberDisplaySettings } from "../field-utils/number";
3
+ export declare const defaultLocale = "en-US";
4
+ export declare const defaultDateFormat = "MMM D, YYYY";
5
+ export declare const defaultDateTimeFormat = "MMM D, YYYY HH:mm";
6
+ export declare const defaultTimeFormat = "HH:mm";
7
+ export declare const formatArbitraryNumber: (value: number, displaySettings?: NumberDisplaySettings, options?: Intl.NumberFormatOptions) => string;
8
+ export declare const formatNumber: (useGrouping: boolean, precision: number, value: number, displaySettings?: NumberDisplaySettings) => string;
9
+ export declare const formatCurrency: (currency: string, useGrouping: boolean, precision: number, value: number | string, displaySettings?: NumberDisplaySettings) => string;
10
+ export declare const formatPercent: (useGrouping: boolean, precision: number, value: number | string, displaySettings?: NumberDisplaySettings) => string;
11
+ export declare const formatNumberWithoutUnit: ({ value, format, displaySettings, currencyCode, precision, useThousandSeparator, }: {
12
+ value: string;
13
+ format?: string;
14
+ displaySettings?: NumberDisplaySettings;
15
+ currencyCode: string | null;
16
+ precision: number;
17
+ useThousandSeparator: boolean;
18
+ }) => string;
19
+ export declare const formatNumberWithUnitAsString: ({ value, format, displaySettings, unit, currencyCode, precision, useThousandSeparator, withNumberUnit, }: {
20
+ value: string;
21
+ format?: string;
22
+ displaySettings?: NumberDisplaySettings;
23
+ unit?: string | null;
24
+ currencyCode: string | null;
25
+ precision: number;
26
+ useThousandSeparator: boolean;
27
+ withNumberUnit: boolean;
28
+ }) => string;
29
+ export declare const formatNumberWithUnitAsStringByFieldObject: (fieldObject: FieldObject, value: string, displaySettings?: NumberDisplaySettings) => string;
30
+ export declare const formatDateRange: ({ value, type, format, }: {
31
+ value: {
32
+ start: string;
33
+ end: string;
34
+ };
35
+ type: string;
36
+ format?: string;
37
+ }) => string;
38
+ export declare const formatDateTimeRange: ({ value, type, dateFormat, timeFormat, dateTimeFormat, }: {
39
+ value: {
40
+ start: string;
41
+ end: string;
42
+ };
43
+ type: string;
44
+ dateFormat?: string;
45
+ timeFormat?: string;
46
+ dateTimeFormat?: string;
47
+ }) => string;
48
+ export declare function formatUnitUrl(url: string): {
49
+ host: string;
50
+ };