@colisweb/rescript-toolkit 3.7.0 → 3.7.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.
package/.yarn/install-state.gz
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -290,6 +290,20 @@ module UnitMeasure = {
|
|
|
290
290
|
})
|
|
291
291
|
}
|
|
292
292
|
|
|
293
|
+
module Speed = {
|
|
294
|
+
module Config = Toolkit__Utils_UnitMeasure.Speed
|
|
295
|
+
|
|
296
|
+
module WithUnit = MakeWithUnit({
|
|
297
|
+
include Config
|
|
298
|
+
let errorPrefix = "Speed with unit"
|
|
299
|
+
})
|
|
300
|
+
|
|
301
|
+
module Km_h = Make({
|
|
302
|
+
include Config
|
|
303
|
+
let wrapValue = Config.wrapValue(#km_h)
|
|
304
|
+
})
|
|
305
|
+
}
|
|
306
|
+
|
|
293
307
|
module Volume = {
|
|
294
308
|
module Config = Toolkit__Utils_UnitMeasure.Volume
|
|
295
309
|
|
|
@@ -323,6 +323,18 @@ let optionalPosFloatEnergyCapacityKWh = (intl, value) => {
|
|
|
323
323
|
}
|
|
324
324
|
}
|
|
325
325
|
|
|
326
|
+
let optionalPosFloatSpeedKm_h = (intl, value) => {
|
|
327
|
+
switch value {
|
|
328
|
+
| "" => None
|
|
329
|
+
| v =>
|
|
330
|
+
switch v->Toolkit__Decoders.UnitMeasure.Speed.WithUnit.decodeFromString {
|
|
331
|
+
| Ok(#km_h(_)) => None
|
|
332
|
+
| _ =>
|
|
333
|
+
Some(Intl.formatMessageWithValues(intl, Msg.wrongFormat, {"exemple": "'10 km/h' '0.5 km/h'"}))
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
|
|
326
338
|
let requiredPosFloatWeightG = (intl, value) => {
|
|
327
339
|
switch value {
|
|
328
340
|
| "" => Some(Intl.formatMessage(intl, Msg.requiredValue))
|
|
@@ -180,6 +180,42 @@ module Dimension = {
|
|
|
180
180
|
}
|
|
181
181
|
}
|
|
182
182
|
|
|
183
|
+
module Speed = {
|
|
184
|
+
include Unit({
|
|
185
|
+
@deriving(jsConverter)
|
|
186
|
+
type unitEnum = [
|
|
187
|
+
| @as(`km/h`) #km_h
|
|
188
|
+
]
|
|
189
|
+
})
|
|
190
|
+
|
|
191
|
+
type t = [
|
|
192
|
+
| #km_h(float)
|
|
193
|
+
]
|
|
194
|
+
|
|
195
|
+
let wrapValue = (unit: unitEnum, value: float): t =>
|
|
196
|
+
switch unit {
|
|
197
|
+
| #km_h => #km_h(value)
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
let toValue = value =>
|
|
201
|
+
switch value {
|
|
202
|
+
| #km_h(v) => v
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
let display = (value, ~digits=2, ()) => {
|
|
206
|
+
open Js.Float
|
|
207
|
+
switch value {
|
|
208
|
+
| #km_h(v) => v->toFixedWithPrecision(~digits) ++ " km/h"
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
let toString = value => {
|
|
213
|
+
switch value {
|
|
214
|
+
| #km_h(v) => v->Float.toString ++ " km/h"
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
183
219
|
module Volume = {
|
|
184
220
|
include Unit({
|
|
185
221
|
@deriving(jsConverter)
|