@reekon-tools/boldr-utils 1.6.1 → 1.6.3
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.
|
@@ -249,7 +249,8 @@ export declare enum ColumnType {
|
|
|
249
249
|
SingleSelect = "singleSelect",
|
|
250
250
|
MultiSelect = "multiSelect",
|
|
251
251
|
Angle = "angle",
|
|
252
|
-
ConversionTable = "conversionTable"
|
|
252
|
+
ConversionTable = "conversionTable",
|
|
253
|
+
Instructions = "instructions"
|
|
253
254
|
}
|
|
254
255
|
export interface Formula extends FirestoreDoc, Timestamps {
|
|
255
256
|
expression: string;
|
|
@@ -271,6 +272,11 @@ export interface SelectColumnData {
|
|
|
271
272
|
export interface ConversionTableColumnData {
|
|
272
273
|
conversions: Conversion[];
|
|
273
274
|
}
|
|
275
|
+
export interface InstructionsColumnData {
|
|
276
|
+
text: string;
|
|
277
|
+
textColor: string;
|
|
278
|
+
backgroundColor: string;
|
|
279
|
+
}
|
|
274
280
|
interface ColumnConfigBase {
|
|
275
281
|
id: string;
|
|
276
282
|
name: string;
|
|
@@ -302,6 +308,9 @@ export type ColumnConfig = ColumnConfigBase & ({
|
|
|
302
308
|
} | {
|
|
303
309
|
type: ColumnType.Angle;
|
|
304
310
|
columnData?: undefined;
|
|
311
|
+
} | {
|
|
312
|
+
type: ColumnType.Instructions;
|
|
313
|
+
columnData: InstructionsColumnData;
|
|
305
314
|
});
|
|
306
315
|
export interface Row {
|
|
307
316
|
[key: string]: any;
|
package/dist/types/firestore.js
CHANGED
|
@@ -42,6 +42,7 @@ export var ColumnType;
|
|
|
42
42
|
ColumnType["MultiSelect"] = "multiSelect";
|
|
43
43
|
ColumnType["Angle"] = "angle";
|
|
44
44
|
ColumnType["ConversionTable"] = "conversionTable";
|
|
45
|
+
ColumnType["Instructions"] = "instructions";
|
|
45
46
|
})(ColumnType || (ColumnType = {}));
|
|
46
47
|
export var MeasurementType;
|
|
47
48
|
(function (MeasurementType) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DecimalTolerance, FractionalTolerance, Units } from '../types/firestore.js';
|
|
2
|
+
export declare const roundToT1Values: (value: number, u: Units) => number;
|
|
2
3
|
export declare const convertMicrometers: (micrometers: number | null | undefined, unit: Units, fractionalTolerance: FractionalTolerance, decimalTolerance: DecimalTolerance) => {
|
|
3
4
|
value: string;
|
|
4
5
|
unit: string;
|
|
@@ -1,12 +1,35 @@
|
|
|
1
1
|
import { Units, convertUnitsToReadable, } from '../types/firestore.js';
|
|
2
2
|
import { create, all } from 'mathjs';
|
|
3
3
|
const math = create(all);
|
|
4
|
+
// The T1 rounds differently depending on the selected measurement unit.
|
|
5
|
+
// This function mirrors the rounding behavior implemented on the firmware.
|
|
6
|
+
// The value being rounded is in microns.
|
|
7
|
+
export const roundToT1Values = (value, u) => {
|
|
8
|
+
switch (u) {
|
|
9
|
+
case Units.Millimeters:
|
|
10
|
+
case Units.Centimeters:
|
|
11
|
+
return Math.round(value / 500) * 500;
|
|
12
|
+
case Units.Meters:
|
|
13
|
+
return Math.round(value / 1000) * 1000;
|
|
14
|
+
case Units.Inches:
|
|
15
|
+
return Math.round(value / 508) * 508;
|
|
16
|
+
case Units.Feet:
|
|
17
|
+
return Math.round(value / 304.8) * 304.8;
|
|
18
|
+
case Units.FeetInchesDecimal:
|
|
19
|
+
return Math.round(value / 508) * 508;
|
|
20
|
+
case Units.FractionalInches:
|
|
21
|
+
case Units.FeetInchesFractional:
|
|
22
|
+
return value;
|
|
23
|
+
default:
|
|
24
|
+
return Math.round(value / 500) * 500;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
4
27
|
export const convertMicrometers = (micrometers, unit, fractionalTolerance, decimalTolerance) => {
|
|
5
28
|
if (micrometers == null || isNaN(micrometers)) {
|
|
6
29
|
return { value: 'NaN', unit: '' };
|
|
7
30
|
}
|
|
8
31
|
try {
|
|
9
|
-
const converted = math.unit(micrometers, 'um');
|
|
32
|
+
const converted = math.unit(roundToT1Values(micrometers, unit), 'um');
|
|
10
33
|
let value = 0;
|
|
11
34
|
let displayUnit = '';
|
|
12
35
|
switch (unit) {
|