@dative-gpi/foundation-shared-domain 1.0.191 → 1.0.193-test-unit-formatter
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.
- package/enums/index.ts +1 -0
- package/enums/units.ts +133 -0
- package/models/index.ts +1 -0
- package/models/units/index.ts +3 -0
- package/models/units/unitDetails.ts +18 -0
- package/models/units/unitFamilies.ts +131 -0
- package/models/units/unitsRegistry.ts +351 -0
- package/package.json +2 -2
package/enums/index.ts
CHANGED
package/enums/units.ts
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
export enum UnitPrefix {
|
|
2
|
+
None = "",
|
|
3
|
+
Nano = "n",
|
|
4
|
+
Micro = "µ",
|
|
5
|
+
Milli = "m",
|
|
6
|
+
Kilo = "k",
|
|
7
|
+
Mega = "M",
|
|
8
|
+
Giga = "G",
|
|
9
|
+
Tera = "T",
|
|
10
|
+
Peta = "P"
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export enum UnitFamily {
|
|
14
|
+
Energy = "Energy",
|
|
15
|
+
Power = "Power",
|
|
16
|
+
Volume = "Volume",
|
|
17
|
+
GasVolume = "Gas Volume",
|
|
18
|
+
WaterFlow = "Water Flow",
|
|
19
|
+
GasFlow = "Gas Flow",
|
|
20
|
+
Pressure = "Pressure",
|
|
21
|
+
Temperature = "Temperature",
|
|
22
|
+
Speed = "Speed",
|
|
23
|
+
Distance = "Distance",
|
|
24
|
+
Mass = "Mass",
|
|
25
|
+
MassFlow = "Mass Flow",
|
|
26
|
+
Frequency = "Frequency",
|
|
27
|
+
Voltage = "Voltage",
|
|
28
|
+
Current = "Current",
|
|
29
|
+
Resistance = "Resistance",
|
|
30
|
+
Percentage = "Percentage",
|
|
31
|
+
Capacity = "Capacity",
|
|
32
|
+
SnowProduction = "Snow Production",
|
|
33
|
+
Efficiency = "Efficiency"
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export enum EnergyUnit {
|
|
37
|
+
Wattheure = "Wh",
|
|
38
|
+
Joule = "J",
|
|
39
|
+
Calorie = "cal",
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export enum PowerUnit {
|
|
43
|
+
Watt = "W",
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export enum VolumeUnit {
|
|
47
|
+
Liter = "L",
|
|
48
|
+
CubicMeter = "m3",
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export enum GasVolumeUnit {
|
|
52
|
+
NormalCubicMeter = "Nm3",
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export enum WaterFlowUnit {
|
|
56
|
+
LiterPerSecond = "L/s",
|
|
57
|
+
CubicMeterPerSecond = "m3/s",
|
|
58
|
+
LiterPerMinute = "L/min",
|
|
59
|
+
CubicMeterPerHour = "m3/h",
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export enum GasFlowUnit {
|
|
63
|
+
NormalCubicMeterPerHour = "Nm3/h",
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export enum PressureUnit {
|
|
67
|
+
Pascal = "Pa",
|
|
68
|
+
Bar = "bar",
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export enum TemperatureUnit {
|
|
72
|
+
Celsius = "°C",
|
|
73
|
+
Kelvin = "K",
|
|
74
|
+
Fahrenheit = "°F",
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export enum SpeedUnit {
|
|
78
|
+
MeterPerSecond = "m/s",
|
|
79
|
+
KilometerPerHour = "km/h",
|
|
80
|
+
Knot = "kn",
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export enum DistanceUnit {
|
|
84
|
+
Meter = "m",
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export enum MassUnit {
|
|
88
|
+
Gram = "g",
|
|
89
|
+
Tonne = "t",
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export enum MassFlowUnit {
|
|
93
|
+
GramPerSecond = "g/s",
|
|
94
|
+
TonnePerSecond = "t/s",
|
|
95
|
+
KilogramPerHour = "kg/h",
|
|
96
|
+
TonnePerHour = "t/h",
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export enum FrequencyUnit {
|
|
100
|
+
Hertz = "Hz",
|
|
101
|
+
RevolutionsPerMinute = "rpm",
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export enum VoltageUnit {
|
|
105
|
+
Volt = "V",
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export enum CurrentUnit {
|
|
109
|
+
Ampere = "A",
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export enum ResistanceUnit {
|
|
113
|
+
Ohm = "Ω",
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export enum PercentageUnit {
|
|
117
|
+
Percent = "%",
|
|
118
|
+
RelativeHumidity = "%RH",
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export enum CapacityUnit {
|
|
122
|
+
Person = "pers",
|
|
123
|
+
PersonPerHour = "pers/h",
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export enum SnowProductionUnit {
|
|
127
|
+
CubicMeterSnowPerHour = "m3_neige/h",
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export enum EfficiencyUnit {
|
|
131
|
+
KilowattHourPerCubicMeter = "kWh/m3",
|
|
132
|
+
KilowattHourPerKilogram = "kWh/kg",
|
|
133
|
+
}
|
package/models/index.ts
CHANGED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { UnitFamily } from "@dative-gpi/foundation-shared-domain/enums";
|
|
2
|
+
|
|
3
|
+
export interface UnitDefinition {
|
|
4
|
+
symbol: string;
|
|
5
|
+
family: UnitFamily;
|
|
6
|
+
toPivot: number;
|
|
7
|
+
usesSIPrefixes: boolean;
|
|
8
|
+
specialConversions?: Array<{
|
|
9
|
+
toUnit: string;
|
|
10
|
+
threshold: number;
|
|
11
|
+
}>;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface UnitFamilyDefinition {
|
|
15
|
+
name: string;
|
|
16
|
+
pivotUnit: string;
|
|
17
|
+
customConverter?: (value: number, fromUnit: string, toUnit: string) => number;
|
|
18
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { UnitFamily, TemperatureUnit, EnergyUnit, PowerUnit, VolumeUnit, GasVolumeUnit, WaterFlowUnit, GasFlowUnit, PressureUnit, SpeedUnit, DistanceUnit, MassUnit, MassFlowUnit, FrequencyUnit, VoltageUnit, CurrentUnit, ResistanceUnit, PercentageUnit, CapacityUnit, SnowProductionUnit, EfficiencyUnit } from "@dative-gpi/foundation-shared-domain/enums";
|
|
2
|
+
import type { UnitFamilyDefinition } from "./unitDetails";
|
|
3
|
+
|
|
4
|
+
export const unitFamilies: Record<UnitFamily, UnitFamilyDefinition> = {
|
|
5
|
+
[UnitFamily.Energy]: {
|
|
6
|
+
name: UnitFamily.Energy,
|
|
7
|
+
pivotUnit: EnergyUnit.Joule,
|
|
8
|
+
},
|
|
9
|
+
|
|
10
|
+
[UnitFamily.Temperature]: {
|
|
11
|
+
name: UnitFamily.Temperature,
|
|
12
|
+
pivotUnit: TemperatureUnit.Celsius,
|
|
13
|
+
customConverter: (value: number, fromUnit: string, toUnit: string) => {
|
|
14
|
+
// Celsius <-> Kelvin
|
|
15
|
+
if (fromUnit === TemperatureUnit.Celsius && toUnit === TemperatureUnit.Kelvin) {
|
|
16
|
+
return value + 273.15;
|
|
17
|
+
}
|
|
18
|
+
if (fromUnit === TemperatureUnit.Kelvin && toUnit === TemperatureUnit.Celsius) {
|
|
19
|
+
return value - 273.15;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Celsius <-> Fahrenheit
|
|
23
|
+
if (fromUnit === TemperatureUnit.Celsius && toUnit === TemperatureUnit.Fahrenheit) {
|
|
24
|
+
return (value * 9/5) + 32;
|
|
25
|
+
}
|
|
26
|
+
if (fromUnit === TemperatureUnit.Fahrenheit && toUnit === TemperatureUnit.Celsius) {
|
|
27
|
+
return (value - 32) * 5/9;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Kelvin <-> Fahrenheit
|
|
31
|
+
if (fromUnit === TemperatureUnit.Kelvin && toUnit === TemperatureUnit.Fahrenheit) {
|
|
32
|
+
return (value - 273.15) * 9/5 + 32;
|
|
33
|
+
}
|
|
34
|
+
if (fromUnit === TemperatureUnit.Fahrenheit && toUnit === TemperatureUnit.Kelvin) {
|
|
35
|
+
return (value - 32) * 5/9 + 273.15;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return value;
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
[UnitFamily.Power]: {
|
|
43
|
+
name: UnitFamily.Power,
|
|
44
|
+
pivotUnit: PowerUnit.Watt
|
|
45
|
+
},
|
|
46
|
+
|
|
47
|
+
[UnitFamily.Volume]: {
|
|
48
|
+
name: UnitFamily.Volume,
|
|
49
|
+
pivotUnit: VolumeUnit.Liter
|
|
50
|
+
},
|
|
51
|
+
|
|
52
|
+
[UnitFamily.GasVolume]: {
|
|
53
|
+
name: UnitFamily.GasVolume,
|
|
54
|
+
pivotUnit: GasVolumeUnit.NormalCubicMeter
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
[UnitFamily.WaterFlow]: {
|
|
58
|
+
name: UnitFamily.WaterFlow,
|
|
59
|
+
pivotUnit: WaterFlowUnit.LiterPerSecond
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
[UnitFamily.GasFlow]: {
|
|
63
|
+
name: UnitFamily.GasFlow,
|
|
64
|
+
pivotUnit: GasFlowUnit.NormalCubicMeterPerHour
|
|
65
|
+
},
|
|
66
|
+
|
|
67
|
+
[UnitFamily.Pressure]: {
|
|
68
|
+
name: UnitFamily.Pressure,
|
|
69
|
+
pivotUnit: PressureUnit.Pascal
|
|
70
|
+
},
|
|
71
|
+
|
|
72
|
+
[UnitFamily.Speed]: {
|
|
73
|
+
name: UnitFamily.Speed,
|
|
74
|
+
pivotUnit: SpeedUnit.MeterPerSecond
|
|
75
|
+
},
|
|
76
|
+
|
|
77
|
+
[UnitFamily.Distance]: {
|
|
78
|
+
name: UnitFamily.Distance,
|
|
79
|
+
pivotUnit: DistanceUnit.Meter
|
|
80
|
+
},
|
|
81
|
+
|
|
82
|
+
[UnitFamily.Mass]: {
|
|
83
|
+
name: UnitFamily.Mass,
|
|
84
|
+
pivotUnit: MassUnit.Gram
|
|
85
|
+
},
|
|
86
|
+
|
|
87
|
+
[UnitFamily.MassFlow]: {
|
|
88
|
+
name: UnitFamily.MassFlow,
|
|
89
|
+
pivotUnit: MassFlowUnit.GramPerSecond
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
[UnitFamily.Frequency]: {
|
|
93
|
+
name: UnitFamily.Frequency,
|
|
94
|
+
pivotUnit: FrequencyUnit.Hertz
|
|
95
|
+
},
|
|
96
|
+
|
|
97
|
+
[UnitFamily.Voltage]: {
|
|
98
|
+
name: UnitFamily.Voltage,
|
|
99
|
+
pivotUnit: VoltageUnit.Volt
|
|
100
|
+
},
|
|
101
|
+
|
|
102
|
+
[UnitFamily.Current]: {
|
|
103
|
+
name: UnitFamily.Current,
|
|
104
|
+
pivotUnit: CurrentUnit.Ampere
|
|
105
|
+
},
|
|
106
|
+
|
|
107
|
+
[UnitFamily.Resistance]: {
|
|
108
|
+
name: UnitFamily.Resistance,
|
|
109
|
+
pivotUnit: ResistanceUnit.Ohm
|
|
110
|
+
},
|
|
111
|
+
|
|
112
|
+
[UnitFamily.Percentage]: {
|
|
113
|
+
name: UnitFamily.Percentage,
|
|
114
|
+
pivotUnit: PercentageUnit.Percent
|
|
115
|
+
},
|
|
116
|
+
|
|
117
|
+
[UnitFamily.Capacity]: {
|
|
118
|
+
name: UnitFamily.Capacity,
|
|
119
|
+
pivotUnit: CapacityUnit.Person
|
|
120
|
+
},
|
|
121
|
+
|
|
122
|
+
[UnitFamily.SnowProduction]: {
|
|
123
|
+
name: UnitFamily.SnowProduction,
|
|
124
|
+
pivotUnit: SnowProductionUnit.CubicMeterSnowPerHour
|
|
125
|
+
},
|
|
126
|
+
|
|
127
|
+
[UnitFamily.Efficiency]: {
|
|
128
|
+
name: UnitFamily.Efficiency,
|
|
129
|
+
pivotUnit: EfficiencyUnit.KilowattHourPerCubicMeter
|
|
130
|
+
},
|
|
131
|
+
};
|
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
import { UnitFamily, EnergyUnit, PowerUnit, VolumeUnit, GasVolumeUnit, WaterFlowUnit, GasFlowUnit, PressureUnit, TemperatureUnit, SpeedUnit, DistanceUnit, MassUnit, MassFlowUnit, FrequencyUnit, VoltageUnit, CurrentUnit, ResistanceUnit, PercentageUnit, CapacityUnit, SnowProductionUnit, EfficiencyUnit,
|
|
2
|
+
} from "@dative-gpi/foundation-shared-domain/enums";
|
|
3
|
+
import type { UnitDefinition } from "./unitDetails";
|
|
4
|
+
|
|
5
|
+
export const unitRegistry: Record<string, UnitDefinition> = {
|
|
6
|
+
// =========================
|
|
7
|
+
// ÉNERGIE (pivot: J)
|
|
8
|
+
// =========================
|
|
9
|
+
[EnergyUnit.Joule]: {
|
|
10
|
+
symbol: EnergyUnit.Joule,
|
|
11
|
+
family: UnitFamily.Energy,
|
|
12
|
+
toPivot: 1,
|
|
13
|
+
usesSIPrefixes: true, // kJ, MJ, ...
|
|
14
|
+
},
|
|
15
|
+
|
|
16
|
+
[EnergyUnit.Wattheure]: {
|
|
17
|
+
symbol: EnergyUnit.Wattheure,
|
|
18
|
+
family: UnitFamily.Energy,
|
|
19
|
+
toPivot: 3600, // 1 Wh = 3600 J
|
|
20
|
+
usesSIPrefixes: true, // kWh, MWh, ...
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
[EnergyUnit.Calorie]: {
|
|
24
|
+
symbol: EnergyUnit.Calorie,
|
|
25
|
+
family: UnitFamily.Energy,
|
|
26
|
+
toPivot: 4.184, // 1 cal(th) = 4.184 J
|
|
27
|
+
usesSIPrefixes: true, // kcal, ...
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
// =========================
|
|
31
|
+
// PUISSANCE (pivot: W)
|
|
32
|
+
// =========================
|
|
33
|
+
[PowerUnit.Watt]: {
|
|
34
|
+
symbol: PowerUnit.Watt,
|
|
35
|
+
family: UnitFamily.Power,
|
|
36
|
+
toPivot: 1,
|
|
37
|
+
usesSIPrefixes: true, // kW, MW...
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
// =========================
|
|
41
|
+
// VOLUME (pivot: L)
|
|
42
|
+
// =========================
|
|
43
|
+
[VolumeUnit.Liter]: {
|
|
44
|
+
symbol: VolumeUnit.Liter,
|
|
45
|
+
family: UnitFamily.Volume,
|
|
46
|
+
toPivot: 1,
|
|
47
|
+
usesSIPrefixes: true,
|
|
48
|
+
specialConversions: [
|
|
49
|
+
{ toUnit: VolumeUnit.CubicMeter, threshold: 1000 },
|
|
50
|
+
],
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
[VolumeUnit.CubicMeter]: {
|
|
54
|
+
symbol: VolumeUnit.CubicMeter,
|
|
55
|
+
family: UnitFamily.Volume,
|
|
56
|
+
toPivot: 1000,
|
|
57
|
+
usesSIPrefixes: false,
|
|
58
|
+
// NOTE: si tu veux "0.001 m³ -> 1 L", ça nécessite une règle "< 1"
|
|
59
|
+
// (non supportée par specialConversions aujourd’hui) ou un traitement dans selectBestUnit.
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
// =========================
|
|
63
|
+
// VOLUME GAZ (pivot: Nm³)
|
|
64
|
+
// =========================
|
|
65
|
+
[GasVolumeUnit.NormalCubicMeter]: {
|
|
66
|
+
symbol: GasVolumeUnit.NormalCubicMeter,
|
|
67
|
+
family: UnitFamily.GasVolume,
|
|
68
|
+
toPivot: 1,
|
|
69
|
+
usesSIPrefixes: true,
|
|
70
|
+
},
|
|
71
|
+
|
|
72
|
+
// =========================
|
|
73
|
+
// DÉBIT D’EAU (pivot: L/s)
|
|
74
|
+
// =========================
|
|
75
|
+
[WaterFlowUnit.LiterPerSecond]: {
|
|
76
|
+
symbol: WaterFlowUnit.LiterPerSecond,
|
|
77
|
+
family: UnitFamily.WaterFlow,
|
|
78
|
+
toPivot: 1,
|
|
79
|
+
usesSIPrefixes: true,
|
|
80
|
+
specialConversions: [
|
|
81
|
+
{ toUnit: WaterFlowUnit.CubicMeterPerHour, threshold: 100 },
|
|
82
|
+
],
|
|
83
|
+
},
|
|
84
|
+
|
|
85
|
+
[WaterFlowUnit.LiterPerMinute]: {
|
|
86
|
+
symbol: WaterFlowUnit.LiterPerMinute,
|
|
87
|
+
family: UnitFamily.WaterFlow,
|
|
88
|
+
toPivot: 1 / 60, // 1 L/min = 1/60 L/s
|
|
89
|
+
usesSIPrefixes: false,
|
|
90
|
+
specialConversions: [
|
|
91
|
+
// >= 60 L/min -> 1 L/s (puis éventuellement m³/h)
|
|
92
|
+
{ toUnit: WaterFlowUnit.LiterPerSecond, threshold: 60 },
|
|
93
|
+
],
|
|
94
|
+
},
|
|
95
|
+
|
|
96
|
+
[WaterFlowUnit.CubicMeterPerHour]: {
|
|
97
|
+
symbol: WaterFlowUnit.CubicMeterPerHour,
|
|
98
|
+
family: UnitFamily.WaterFlow,
|
|
99
|
+
toPivot: 1000 / 3600, // 1 m³/h = 1000 L / 3600 s
|
|
100
|
+
usesSIPrefixes: false,
|
|
101
|
+
},
|
|
102
|
+
|
|
103
|
+
[WaterFlowUnit.CubicMeterPerSecond]: {
|
|
104
|
+
symbol: WaterFlowUnit.CubicMeterPerSecond,
|
|
105
|
+
family: UnitFamily.WaterFlow,
|
|
106
|
+
toPivot: 1000, // 1 m³/s = 1000 L/s
|
|
107
|
+
usesSIPrefixes: false,
|
|
108
|
+
},
|
|
109
|
+
|
|
110
|
+
// =========================
|
|
111
|
+
// DÉBIT GAZ (pivot: Nm³/h)
|
|
112
|
+
// =========================
|
|
113
|
+
[GasFlowUnit.NormalCubicMeterPerHour]: {
|
|
114
|
+
symbol: GasFlowUnit.NormalCubicMeterPerHour,
|
|
115
|
+
family: UnitFamily.GasFlow,
|
|
116
|
+
toPivot: 1,
|
|
117
|
+
usesSIPrefixes: true,
|
|
118
|
+
},
|
|
119
|
+
|
|
120
|
+
// =========================
|
|
121
|
+
// PRESSION (pivot: Pa)
|
|
122
|
+
// =========================
|
|
123
|
+
[PressureUnit.Pascal]: {
|
|
124
|
+
symbol: PressureUnit.Pascal,
|
|
125
|
+
family: UnitFamily.Pressure,
|
|
126
|
+
toPivot: 1,
|
|
127
|
+
usesSIPrefixes: true, // kPa, MPa...
|
|
128
|
+
specialConversions: [
|
|
129
|
+
// Affichage métier fréquent: 100000 Pa = 1 bar
|
|
130
|
+
{ toUnit: PressureUnit.Bar, threshold: 100_000 },
|
|
131
|
+
],
|
|
132
|
+
},
|
|
133
|
+
|
|
134
|
+
[PressureUnit.Bar]: {
|
|
135
|
+
symbol: PressureUnit.Bar,
|
|
136
|
+
family: UnitFamily.Pressure,
|
|
137
|
+
toPivot: 100_000, // 1 bar = 100000 Pa
|
|
138
|
+
usesSIPrefixes: true,
|
|
139
|
+
},
|
|
140
|
+
|
|
141
|
+
// =========================
|
|
142
|
+
// TEMPÉRATURE (custom converter dans unitFamilies)
|
|
143
|
+
// =========================
|
|
144
|
+
[TemperatureUnit.Celsius]: {
|
|
145
|
+
symbol: TemperatureUnit.Celsius,
|
|
146
|
+
family: UnitFamily.Temperature,
|
|
147
|
+
toPivot: 1, // ignoré car customConverter
|
|
148
|
+
usesSIPrefixes: false,
|
|
149
|
+
},
|
|
150
|
+
[TemperatureUnit.Kelvin]: {
|
|
151
|
+
symbol: TemperatureUnit.Kelvin,
|
|
152
|
+
family: UnitFamily.Temperature,
|
|
153
|
+
toPivot: 1, // ignoré
|
|
154
|
+
usesSIPrefixes: false,
|
|
155
|
+
},
|
|
156
|
+
[TemperatureUnit.Fahrenheit]: {
|
|
157
|
+
symbol: TemperatureUnit.Fahrenheit,
|
|
158
|
+
family: UnitFamily.Temperature,
|
|
159
|
+
toPivot: 1, // ignoré
|
|
160
|
+
usesSIPrefixes: false,
|
|
161
|
+
},
|
|
162
|
+
|
|
163
|
+
// =========================
|
|
164
|
+
// VITESSE (pivot: m/s)
|
|
165
|
+
// =========================
|
|
166
|
+
[SpeedUnit.MeterPerSecond]: {
|
|
167
|
+
symbol: SpeedUnit.MeterPerSecond,
|
|
168
|
+
family: UnitFamily.Speed,
|
|
169
|
+
toPivot: 1,
|
|
170
|
+
usesSIPrefixes: false,
|
|
171
|
+
specialConversions: [
|
|
172
|
+
// UX: toujours afficher en km/h
|
|
173
|
+
{ toUnit: SpeedUnit.KilometerPerHour, threshold: 0 },
|
|
174
|
+
],
|
|
175
|
+
},
|
|
176
|
+
|
|
177
|
+
[SpeedUnit.KilometerPerHour]: {
|
|
178
|
+
symbol: SpeedUnit.KilometerPerHour,
|
|
179
|
+
family: UnitFamily.Speed,
|
|
180
|
+
toPivot: 1 / 3.6, // 1 km/h = 0.277... m/s
|
|
181
|
+
usesSIPrefixes: false,
|
|
182
|
+
},
|
|
183
|
+
|
|
184
|
+
[SpeedUnit.Knot]: {
|
|
185
|
+
symbol: SpeedUnit.Knot,
|
|
186
|
+
family: UnitFamily.Speed,
|
|
187
|
+
toPivot: 0.514444, // 1 kt = 0.514444 m/s
|
|
188
|
+
usesSIPrefixes: false,
|
|
189
|
+
},
|
|
190
|
+
|
|
191
|
+
// =========================
|
|
192
|
+
// DISTANCE (pivot: m)
|
|
193
|
+
// =========================
|
|
194
|
+
[DistanceUnit.Meter]: {
|
|
195
|
+
symbol: DistanceUnit.Meter,
|
|
196
|
+
family: UnitFamily.Distance,
|
|
197
|
+
toPivot: 1,
|
|
198
|
+
usesSIPrefixes: true, // mm, km (pas de cm/dm car pas dans SI_PREFIXES)
|
|
199
|
+
},
|
|
200
|
+
|
|
201
|
+
// =========================
|
|
202
|
+
// MASSE (pivot: g)
|
|
203
|
+
// =========================
|
|
204
|
+
[MassUnit.Gram]: {
|
|
205
|
+
symbol: MassUnit.Gram,
|
|
206
|
+
family: UnitFamily.Mass,
|
|
207
|
+
toPivot: 1,
|
|
208
|
+
usesSIPrefixes: true,
|
|
209
|
+
specialConversions: [
|
|
210
|
+
// 1 000 000 g = 1 t (affichage plus "métier" que Mg)
|
|
211
|
+
{ toUnit: MassUnit.Tonne, threshold: 1_000_000 },
|
|
212
|
+
],
|
|
213
|
+
},
|
|
214
|
+
|
|
215
|
+
[MassUnit.Tonne]: {
|
|
216
|
+
symbol: MassUnit.Tonne,
|
|
217
|
+
family: UnitFamily.Mass,
|
|
218
|
+
toPivot: 1_000_000, // 1 t = 1 000 000 g
|
|
219
|
+
usesSIPrefixes: false,
|
|
220
|
+
},
|
|
221
|
+
|
|
222
|
+
// =========================
|
|
223
|
+
// DÉBIT MASSIQUE (pivot: g/s)
|
|
224
|
+
// =========================
|
|
225
|
+
[MassFlowUnit.GramPerSecond]: {
|
|
226
|
+
symbol: MassFlowUnit.GramPerSecond,
|
|
227
|
+
family: UnitFamily.MassFlow,
|
|
228
|
+
toPivot: 1,
|
|
229
|
+
usesSIPrefixes: true,
|
|
230
|
+
specialConversions: [
|
|
231
|
+
// 100 000 g/s = 100 kg/s -> bascule t/h (souvent plus lisible)
|
|
232
|
+
{ toUnit: MassFlowUnit.TonnePerHour, threshold: 100_000 },
|
|
233
|
+
],
|
|
234
|
+
},
|
|
235
|
+
|
|
236
|
+
[MassFlowUnit.KilogramPerHour]: {
|
|
237
|
+
symbol: MassFlowUnit.KilogramPerHour,
|
|
238
|
+
family: UnitFamily.MassFlow,
|
|
239
|
+
toPivot: 1000 / 3600, // 1 kg/h = 1000 g / 3600 s
|
|
240
|
+
usesSIPrefixes: false,
|
|
241
|
+
},
|
|
242
|
+
|
|
243
|
+
[MassFlowUnit.TonnePerHour]: {
|
|
244
|
+
symbol: MassFlowUnit.TonnePerHour,
|
|
245
|
+
family: UnitFamily.MassFlow,
|
|
246
|
+
toPivot: 1_000_000 / 3600, // 1 t/h = 1e6 g / 3600 s
|
|
247
|
+
usesSIPrefixes: false,
|
|
248
|
+
},
|
|
249
|
+
|
|
250
|
+
[MassFlowUnit.TonnePerSecond]: {
|
|
251
|
+
symbol: MassFlowUnit.TonnePerSecond,
|
|
252
|
+
family: UnitFamily.MassFlow,
|
|
253
|
+
toPivot: 1_000_000, // 1 t/s = 1e6 g/s
|
|
254
|
+
usesSIPrefixes: false,
|
|
255
|
+
},
|
|
256
|
+
|
|
257
|
+
// =========================
|
|
258
|
+
// FRÉQUENCE (pivot: Hz)
|
|
259
|
+
// =========================
|
|
260
|
+
[FrequencyUnit.Hertz]: {
|
|
261
|
+
symbol: FrequencyUnit.Hertz,
|
|
262
|
+
family: UnitFamily.Frequency,
|
|
263
|
+
toPivot: 1,
|
|
264
|
+
usesSIPrefixes: true,
|
|
265
|
+
},
|
|
266
|
+
|
|
267
|
+
[FrequencyUnit.RevolutionsPerMinute]: {
|
|
268
|
+
symbol: FrequencyUnit.RevolutionsPerMinute,
|
|
269
|
+
family: UnitFamily.Frequency,
|
|
270
|
+
toPivot: 1 / 60, // 1 rpm = 1/60 Hz
|
|
271
|
+
usesSIPrefixes: false,
|
|
272
|
+
},
|
|
273
|
+
|
|
274
|
+
// =========================
|
|
275
|
+
// ÉLECTRICITÉ
|
|
276
|
+
// =========================
|
|
277
|
+
[VoltageUnit.Volt]: {
|
|
278
|
+
symbol: VoltageUnit.Volt,
|
|
279
|
+
family: UnitFamily.Voltage,
|
|
280
|
+
toPivot: 1,
|
|
281
|
+
usesSIPrefixes: true,
|
|
282
|
+
},
|
|
283
|
+
|
|
284
|
+
[CurrentUnit.Ampere]: {
|
|
285
|
+
symbol: CurrentUnit.Ampere,
|
|
286
|
+
family: UnitFamily.Current,
|
|
287
|
+
toPivot: 1,
|
|
288
|
+
usesSIPrefixes: true,
|
|
289
|
+
},
|
|
290
|
+
|
|
291
|
+
[ResistanceUnit.Ohm]: {
|
|
292
|
+
symbol: ResistanceUnit.Ohm,
|
|
293
|
+
family: UnitFamily.Resistance,
|
|
294
|
+
toPivot: 1,
|
|
295
|
+
usesSIPrefixes: true,
|
|
296
|
+
},
|
|
297
|
+
|
|
298
|
+
// =========================
|
|
299
|
+
// UNITÉS À RISQUE DE "FAUSSE CONVERSION"
|
|
300
|
+
// =========================
|
|
301
|
+
// Ces familles contiennent des unités qui ne sont pas dimensionnellement convertibles entre elles,
|
|
302
|
+
// mais le moteur les traitera comme convertibles si on utilise targetUnit entre elles.
|
|
303
|
+
[PercentageUnit.Percent]: {
|
|
304
|
+
symbol: PercentageUnit.Percent,
|
|
305
|
+
family: UnitFamily.Percentage,
|
|
306
|
+
toPivot: 1,
|
|
307
|
+
usesSIPrefixes: false,
|
|
308
|
+
},
|
|
309
|
+
|
|
310
|
+
[PercentageUnit.RelativeHumidity]: {
|
|
311
|
+
symbol: PercentageUnit.RelativeHumidity,
|
|
312
|
+
family: UnitFamily.Percentage,
|
|
313
|
+
toPivot: 1,
|
|
314
|
+
usesSIPrefixes: false,
|
|
315
|
+
},
|
|
316
|
+
|
|
317
|
+
[CapacityUnit.Person]: {
|
|
318
|
+
symbol: CapacityUnit.Person,
|
|
319
|
+
family: UnitFamily.Capacity,
|
|
320
|
+
toPivot: 1,
|
|
321
|
+
usesSIPrefixes: false,
|
|
322
|
+
},
|
|
323
|
+
|
|
324
|
+
[CapacityUnit.PersonPerHour]: {
|
|
325
|
+
symbol: CapacityUnit.PersonPerHour,
|
|
326
|
+
family: UnitFamily.Capacity,
|
|
327
|
+
toPivot: 1,
|
|
328
|
+
usesSIPrefixes: false,
|
|
329
|
+
},
|
|
330
|
+
|
|
331
|
+
[SnowProductionUnit.CubicMeterSnowPerHour]: {
|
|
332
|
+
symbol: SnowProductionUnit.CubicMeterSnowPerHour,
|
|
333
|
+
family: UnitFamily.SnowProduction,
|
|
334
|
+
toPivot: 1,
|
|
335
|
+
usesSIPrefixes: false,
|
|
336
|
+
},
|
|
337
|
+
|
|
338
|
+
[EfficiencyUnit.KilowattHourPerCubicMeter]: {
|
|
339
|
+
symbol: EfficiencyUnit.KilowattHourPerCubicMeter,
|
|
340
|
+
family: UnitFamily.Efficiency,
|
|
341
|
+
toPivot: 1,
|
|
342
|
+
usesSIPrefixes: false,
|
|
343
|
+
},
|
|
344
|
+
|
|
345
|
+
[EfficiencyUnit.KilowattHourPerKilogram]: {
|
|
346
|
+
symbol: EfficiencyUnit.KilowattHourPerKilogram,
|
|
347
|
+
family: UnitFamily.Efficiency,
|
|
348
|
+
toPivot: 1,
|
|
349
|
+
usesSIPrefixes: false,
|
|
350
|
+
},
|
|
351
|
+
};
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"url": "https://github.com/Dative-GPI/foundation-shared-ui.git"
|
|
5
5
|
},
|
|
6
6
|
"sideEffects": false,
|
|
7
|
-
"version": "1.0.
|
|
7
|
+
"version": "1.0.193-test-unit-formatter",
|
|
8
8
|
"description": "",
|
|
9
9
|
"publishConfig": {
|
|
10
10
|
"access": "public"
|
|
@@ -15,5 +15,5 @@
|
|
|
15
15
|
"peerDependencies": {
|
|
16
16
|
"date-fns": "^3.6.0"
|
|
17
17
|
},
|
|
18
|
-
"gitHead": "
|
|
18
|
+
"gitHead": "fc948d90c3e19270003dc7f695459ae96bf1539c"
|
|
19
19
|
}
|