@colisweb/rescript-toolkit 3.1.2 → 3.1.4
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/playground/PlaygroundComponents.res +1 -0
- package/playground/components/Playground_CopyWrapper.res +17 -0
- package/src/decoders/Toolkit__Decoders.res +14 -0
- package/src/form/Toolkit__FormValidationFunctions.res +13 -0
- package/src/ui/Toolkit__Ui_CopyWrapper.res +1 -1
- package/src/ui/Toolkit__Ui_CopyWrapper.resi +7 -0
- package/src/utils/Toolkit__Utils_UnitMeasure.res +36 -0
package/.yarn/install-state.gz
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -35,6 +35,7 @@ let components: array<(string, module(Config))> = [
|
|
|
35
35
|
("Form", module(Playground_Form)),
|
|
36
36
|
("Combobox", module(Playground_Combobox)),
|
|
37
37
|
("IconButton", module(Playground_IconButton)),
|
|
38
|
+
("CopyWrapper", module(Playground_CopyWrapper)),
|
|
38
39
|
]
|
|
39
40
|
|
|
40
41
|
module List = {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
@module("@root/src/ui/Toolkit__Ui_CopyWrapper.resi?raw")
|
|
2
|
+
external resi: string = "default"
|
|
3
|
+
|
|
4
|
+
@module("@root/playground/components/Playground_CopyWrapper.res?raw")
|
|
5
|
+
external codeExample: string = "default"
|
|
6
|
+
|
|
7
|
+
@react.component
|
|
8
|
+
let make = () => {
|
|
9
|
+
<ReactIntl.IntlProvider>
|
|
10
|
+
<Toolkit__Ui_Snackbar.Provider />
|
|
11
|
+
<div className="flex flex-col gap-8">
|
|
12
|
+
<Toolkit__Ui_CopyWrapper textToCopy={"some content"} intl={PlaygroundLocales.intl}>
|
|
13
|
+
{"some content"->React.string}
|
|
14
|
+
</Toolkit__Ui_CopyWrapper>
|
|
15
|
+
</div>
|
|
16
|
+
</ReactIntl.IntlProvider>
|
|
17
|
+
}
|
|
@@ -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))
|
|
@@ -18,7 +18,7 @@ let make = (~children, ~textToCopy, ~className="", ~intl) => {
|
|
|
18
18
|
<div className={cx(["rounded-md border border-info-500 bg-info-50", className])}>
|
|
19
19
|
<div className="relative w-full">
|
|
20
20
|
<div
|
|
21
|
-
className="absolute -right-2 top-1 p-1 bg-info-50 text-info-500"
|
|
21
|
+
className="absolute -right-2 top-1 p-1 bg-info-50 text-info-500 cursor-pointer hover:bg-info-400 hover:text-white rounded active:bg-info-500"
|
|
22
22
|
onClick={_ => {
|
|
23
23
|
ref1Clipboard.copy()
|
|
24
24
|
}}>
|
|
@@ -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)
|