@colisweb/rescript-toolkit 3.1.3 → 3.1.5
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 +0 -0
- package/package.json +1 -1
- package/src/decoders/Toolkit__Decoders.res +14 -0
- package/src/form/Toolkit__FormValidationFunctions.res +13 -0
- package/src/ui/Toolkit__Ui_Card.res +22 -13
- package/src/ui/Toolkit__Ui_Card.resi +1 -0
- package/src/utils/Toolkit__Utils_UnitMeasure.res +36 -0
package/.yarn/install-state.gz
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -304,6 +304,20 @@ module UnitMeasure = {
|
|
|
304
304
|
})
|
|
305
305
|
}
|
|
306
306
|
|
|
307
|
+
module EnergyCapacity = {
|
|
308
|
+
module Config = Toolkit__Utils_UnitMeasure.EnergyCapacity
|
|
309
|
+
|
|
310
|
+
module WithUnit = MakeWithUnit({
|
|
311
|
+
include Config
|
|
312
|
+
let errorPrefix = "EnergyCapacity with unit"
|
|
313
|
+
})
|
|
314
|
+
|
|
315
|
+
module KWh = Make({
|
|
316
|
+
include Config
|
|
317
|
+
let wrapValue = Config.wrapValue(#kWh)
|
|
318
|
+
})
|
|
319
|
+
}
|
|
320
|
+
|
|
307
321
|
module Weight = {
|
|
308
322
|
module Config = Toolkit__Utils_UnitMeasure.Weight
|
|
309
323
|
|
|
@@ -288,6 +288,19 @@ let optionalPosFloatWeightKg = (intl, value) => {
|
|
|
288
288
|
}
|
|
289
289
|
}
|
|
290
290
|
}
|
|
291
|
+
|
|
292
|
+
let optionalPosFloatEnergyCapacityKWh = (intl, value) => {
|
|
293
|
+
switch value {
|
|
294
|
+
| "" => None
|
|
295
|
+
| v =>
|
|
296
|
+
switch v->Toolkit__Decoders.UnitMeasure.EnergyCapacity.WithUnit.decodeFromString {
|
|
297
|
+
| Ok(#kWh(_)) => None
|
|
298
|
+
| _ =>
|
|
299
|
+
Some(Intl.formatMessageWithValues(intl, Msg.wrongFormat, {"exemple": "'10 kWh' '0.5 kWh'"}))
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
|
|
291
304
|
let requiredPosFloatWeightG = (intl, value) => {
|
|
292
305
|
switch value {
|
|
293
306
|
| "" => Some(Intl.formatMessage(intl, Msg.requiredValue))
|
|
@@ -12,6 +12,7 @@ module Header = {
|
|
|
12
12
|
~action: option<action>=?,
|
|
13
13
|
~actionDisabled: option<bool>=?,
|
|
14
14
|
~containerClassName="",
|
|
15
|
+
~buttonTestId="",
|
|
15
16
|
) =>
|
|
16
17
|
<div className={cx(["flex flex-row items-center mb-4", containerClassName])}>
|
|
17
18
|
<div
|
|
@@ -21,17 +22,20 @@ module Header = {
|
|
|
21
22
|
])}>
|
|
22
23
|
children
|
|
23
24
|
</div>
|
|
24
|
-
{action->Option.mapWithDefault(React.null, ({label, event}) =>
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
25
|
+
{action->Option.mapWithDefault(React.null, ({label, event}) => {
|
|
26
|
+
let btn =
|
|
27
|
+
<Toolkit__Ui_Button
|
|
28
|
+
variant=#pill
|
|
29
|
+
size=#xs
|
|
30
|
+
color=#info
|
|
31
|
+
onClick={_ => event()}
|
|
32
|
+
disabled={actionDisabled->Option.getWithDefault(false)}
|
|
33
|
+
className="flex-shrink-0 ml-4">
|
|
34
|
+
label
|
|
35
|
+
</Toolkit__Ui_Button>
|
|
36
|
+
|
|
37
|
+
React.cloneElement(btn, {"data-testid": cx(["card-header-button", buttonTestId])})
|
|
38
|
+
})}
|
|
35
39
|
</div>
|
|
36
40
|
}
|
|
37
41
|
|
|
@@ -44,7 +48,9 @@ module Body = {
|
|
|
44
48
|
module FixedBody = {
|
|
45
49
|
@react.component
|
|
46
50
|
let make = (~className="", ~children=React.null) =>
|
|
47
|
-
<Body>
|
|
51
|
+
<Body>
|
|
52
|
+
<div className={cx([className, "overflow-y-auto h-full"])}> children </div>
|
|
53
|
+
</Body>
|
|
48
54
|
}
|
|
49
55
|
|
|
50
56
|
module Message = {
|
|
@@ -66,7 +72,10 @@ module Message = {
|
|
|
66
72
|
| #error => "text-danger-600 bg-danger-50"
|
|
67
73
|
}
|
|
68
74
|
|
|
69
|
-
<div className={cx([className, "px-6 py-4 flex", color])}>
|
|
75
|
+
<div className={cx([className, "px-6 py-4 flex", color])}>
|
|
76
|
+
icon
|
|
77
|
+
<div> children </div>
|
|
78
|
+
</div>
|
|
70
79
|
}
|
|
71
80
|
}
|
|
72
81
|
|
|
@@ -216,6 +216,42 @@ module Volume = {
|
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
218
|
|
|
219
|
+
module EnergyCapacity = {
|
|
220
|
+
include Unit({
|
|
221
|
+
@deriving(jsConverter)
|
|
222
|
+
type unitEnum = [
|
|
223
|
+
| @as(`kWh`) #kWh
|
|
224
|
+
]
|
|
225
|
+
})
|
|
226
|
+
|
|
227
|
+
type t = [
|
|
228
|
+
| #kWh(float)
|
|
229
|
+
]
|
|
230
|
+
|
|
231
|
+
let wrapValue = (unit: unitEnum, value: float): t =>
|
|
232
|
+
switch unit {
|
|
233
|
+
| #kWh => #kWh(value)
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
let toValue = value =>
|
|
237
|
+
switch value {
|
|
238
|
+
| #kWh(value) => value
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
let display = (value, ~digits=2, ()) => {
|
|
242
|
+
open Js.Float
|
|
243
|
+
switch value {
|
|
244
|
+
| #kWh(v) => v->toFixedWithPrecision(~digits) ++ ` kWh`
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
let toString = value => {
|
|
249
|
+
switch value {
|
|
250
|
+
| #kWh(v) => v->Float.toString ++ ` kWh`
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
219
255
|
module Currency = {
|
|
220
256
|
include Unit({
|
|
221
257
|
@deriving(jsConverter)
|