@colisweb/rescript-toolkit 2.13.5 → 2.13.6
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/package.json
CHANGED
|
@@ -358,6 +358,143 @@ module UnitMeasure = {
|
|
|
358
358
|
let convert = Toolkit__Utils_UnitMeasure.Time.makeH
|
|
359
359
|
})
|
|
360
360
|
}
|
|
361
|
+
|
|
362
|
+
module Currency = {
|
|
363
|
+
module WithUnit = {
|
|
364
|
+
let encoder: Decco.encoder<Toolkit__Utils_UnitMeasure.Currency.t> = value =>
|
|
365
|
+
switch value {
|
|
366
|
+
| #EUR(v) => Js.Json.string(v->Js.Float.toString ++ " EUR")
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
let decoder: Decco.decoder<Toolkit__Utils_UnitMeasure.Currency.t> = json =>
|
|
370
|
+
switch Decco.stringFromJson(json) {
|
|
371
|
+
| Ok(v) =>
|
|
372
|
+
let valueUnitArray = v->Js.String2.split(" ")
|
|
373
|
+
switch (
|
|
374
|
+
valueUnitArray[0]->Belt.Option.flatMap(Belt.Float.fromString),
|
|
375
|
+
valueUnitArray[1],
|
|
376
|
+
) {
|
|
377
|
+
| (Some(v), Some("EUR")) => #EUR(v)->Ok
|
|
378
|
+
| (None, _) => Decco.error("unhandled no value", json)
|
|
379
|
+
| (_, None) => Decco.error("unhandled no unit", json)
|
|
380
|
+
| (_, Some(_)) => Decco.error("unhandled currency unit", json)
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
| Error(_) as err => err
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
let codec: Decco.codec<Toolkit__Utils_UnitMeasure.Currency.t> = (encoder, decoder)
|
|
387
|
+
|
|
388
|
+
@decco
|
|
389
|
+
type t = @decco.codec(codec) Toolkit__Utils_UnitMeasure.Currency.t
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
module type CurrencyConfig = {
|
|
393
|
+
let convert: float => Toolkit__Utils_UnitMeasure.Currency.t
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
module Make = (C: CurrencyConfig) => {
|
|
397
|
+
type currency = Toolkit__Utils_UnitMeasure.Currency.t
|
|
398
|
+
|
|
399
|
+
let encoder: Decco.encoder<Toolkit__Utils_UnitMeasure.Currency.t> = value =>
|
|
400
|
+
switch value {
|
|
401
|
+
| #EUR(v) => Js.Json.string(v->Js.Float.toString ++ " EUR")
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
let decoder: Decco.decoder<Toolkit__Utils_UnitMeasure.Currency.t> = json =>
|
|
405
|
+
switch Decco.floatFromJson(json) {
|
|
406
|
+
| Ok(v) => v->C.convert->Ok
|
|
407
|
+
| Error(_) as err => err
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
let codec: Decco.codec<currency> = (encoder, decoder)
|
|
411
|
+
|
|
412
|
+
let toValue = Toolkit__Utils_UnitMeasure.Currency.toValue
|
|
413
|
+
let display = Toolkit__Utils_UnitMeasure.Currency.toString
|
|
414
|
+
|
|
415
|
+
@decco
|
|
416
|
+
type t = @decco.codec(codec) Toolkit__Utils_UnitMeasure.Currency.t
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
module EUR = Make({
|
|
420
|
+
let convert = Toolkit__Utils_UnitMeasure.Currency.makeEUR
|
|
421
|
+
})
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
module CompositeUnits = {
|
|
425
|
+
module CurrencyPerDistance = {
|
|
426
|
+
module WithUnit = {
|
|
427
|
+
let encoder: Decco.encoder<
|
|
428
|
+
Toolkit__Utils_UnitMeasure.CompositeUnits.CurrencyPerDistance.t,
|
|
429
|
+
> = value =>
|
|
430
|
+
switch value {
|
|
431
|
+
| #EUR_km(v) => Js.Json.string(v->Js.Float.toString ++ " EUR/km")
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
let decoder: Decco.decoder<
|
|
435
|
+
Toolkit__Utils_UnitMeasure.CompositeUnits.CurrencyPerDistance.t,
|
|
436
|
+
> = json =>
|
|
437
|
+
switch Decco.stringFromJson(json) {
|
|
438
|
+
| Ok(v) =>
|
|
439
|
+
let valueUnitArray = v->Js.String2.split(" ")
|
|
440
|
+
switch (
|
|
441
|
+
valueUnitArray[0]->Belt.Option.flatMap(Belt.Float.fromString),
|
|
442
|
+
valueUnitArray[1],
|
|
443
|
+
) {
|
|
444
|
+
| (Some(v), Some("EUR/km")) => #EUR_km(v)->Ok
|
|
445
|
+
| (None, _) => Decco.error("unhandled no value", json)
|
|
446
|
+
| (_, None) => Decco.error("unhandled no unit", json)
|
|
447
|
+
| (_, Some(_)) => Decco.error("unhandled currencyPerDistance unit", json)
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
| Error(_) as err => err
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
let codec: Decco.codec<Toolkit__Utils_UnitMeasure.CompositeUnits.CurrencyPerDistance.t> = (
|
|
454
|
+
encoder,
|
|
455
|
+
decoder,
|
|
456
|
+
)
|
|
457
|
+
|
|
458
|
+
@decco
|
|
459
|
+
type t = @decco.codec(codec) Toolkit__Utils_UnitMeasure.CompositeUnits.CurrencyPerDistance.t
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
module type CurrencyPerDistanceConfig = {
|
|
463
|
+
let convert: float => Toolkit__Utils_UnitMeasure.CompositeUnits.CurrencyPerDistance.t
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
module Make = (C: CurrencyPerDistanceConfig) => {
|
|
467
|
+
type currencyPerDistance = Toolkit__Utils_UnitMeasure.CompositeUnits.CurrencyPerDistance.t
|
|
468
|
+
|
|
469
|
+
let encoder: Decco.encoder<
|
|
470
|
+
Toolkit__Utils_UnitMeasure.CompositeUnits.CurrencyPerDistance.t,
|
|
471
|
+
> = value =>
|
|
472
|
+
switch value {
|
|
473
|
+
| #EUR_km(v) => Js.Json.string(v->Js.Float.toString ++ " EUR/km")
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
let decoder: Decco.decoder<
|
|
477
|
+
Toolkit__Utils_UnitMeasure.CompositeUnits.CurrencyPerDistance.t,
|
|
478
|
+
> = json =>
|
|
479
|
+
switch Decco.floatFromJson(json) {
|
|
480
|
+
| Ok(v) => v->C.convert->Ok
|
|
481
|
+
| Error(_) as err => err
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
let codec: Decco.codec<currencyPerDistance> = (encoder, decoder)
|
|
485
|
+
|
|
486
|
+
let toValue = Toolkit__Utils_UnitMeasure.CompositeUnits.CurrencyPerDistance.toValue
|
|
487
|
+
let display = Toolkit__Utils_UnitMeasure.CompositeUnits.CurrencyPerDistance.toString
|
|
488
|
+
|
|
489
|
+
@decco
|
|
490
|
+
type t = @decco.codec(codec) Toolkit__Utils_UnitMeasure.CompositeUnits.CurrencyPerDistance.t
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
module EUR_km = Make({
|
|
494
|
+
let convert = Toolkit__Utils_UnitMeasure.CompositeUnits.CurrencyPerDistance.makeEUR_km
|
|
495
|
+
})
|
|
496
|
+
}
|
|
497
|
+
}
|
|
361
498
|
}
|
|
362
499
|
|
|
363
500
|
// StringArray
|
|
@@ -64,21 +64,32 @@ let make = (
|
|
|
64
64
|
placeholder=?{searchPlaceholder}
|
|
65
65
|
onChange={event => {
|
|
66
66
|
let target = event->ReactEvent.Form.currentTarget
|
|
67
|
-
|
|
68
|
-
setSearch(_ =>
|
|
67
|
+
// normalize nfd -> replace by re remove split by commponents the accent letters and deletes the accent component only, leaving the un-accented letter
|
|
68
|
+
setSearch(_ =>
|
|
69
|
+
target["value"]
|
|
70
|
+
->Js.String2.toLowerCase
|
|
71
|
+
->Js.String2.normalizeByForm("NFD")
|
|
72
|
+
->Js.String2.replaceByRe(%re("/[\u0300-\u036f]/g"), "")
|
|
73
|
+
)
|
|
69
74
|
}}
|
|
70
75
|
/>
|
|
71
76
|
</div>
|
|
72
77
|
: React.null}
|
|
73
78
|
{options
|
|
74
79
|
->Array.keep(({label}) =>
|
|
75
|
-
|
|
80
|
+
// normalize nfd -> replace by re remove split by commponents the accent letters and deletes the accent component only, leaving the un-accented letter
|
|
81
|
+
search == "" ||
|
|
82
|
+
label
|
|
83
|
+
->Js.String2.toLowerCase
|
|
84
|
+
->Js.String2.normalizeByForm("NFD")
|
|
85
|
+
->Js.String2.replaceByRe(%re("/[\u0300-\u036f]/g"), "")
|
|
86
|
+
->Js.String2.includes(search)
|
|
76
87
|
)
|
|
77
88
|
->Array.map(item => {
|
|
78
89
|
let {itemLabel, label, value} = item
|
|
79
90
|
|
|
80
91
|
<div
|
|
81
|
-
key={label}
|
|
92
|
+
key={`multiselectoption-${label}-${value}`}
|
|
82
93
|
className={cx(["flex flex-row items-center gap-2 mt-3 pt-3 text-left", itemClassName])}>
|
|
83
94
|
<Toolkit__Ui_Checkbox
|
|
84
95
|
value
|
|
@@ -103,3 +103,43 @@ module Dimension = {
|
|
|
103
103
|
let makeM = (value: float) => #m(value)
|
|
104
104
|
let makeKm = (value: float) => #km(value)
|
|
105
105
|
}
|
|
106
|
+
|
|
107
|
+
module Currency = {
|
|
108
|
+
type t = [
|
|
109
|
+
| #EUR(float)
|
|
110
|
+
]
|
|
111
|
+
|
|
112
|
+
let toValue = value =>
|
|
113
|
+
switch value {
|
|
114
|
+
| #EUR(v) => v
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
let toString = value => {
|
|
118
|
+
switch value {
|
|
119
|
+
| #EUR(v) => v->Float.toString ++ " EUR"
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
let makeEUR = (value: float) => #EUR(value)
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
module CompositeUnits = {
|
|
127
|
+
module CurrencyPerDistance = {
|
|
128
|
+
type t = [
|
|
129
|
+
| #EUR_km(float)
|
|
130
|
+
]
|
|
131
|
+
|
|
132
|
+
let toValue = value =>
|
|
133
|
+
switch value {
|
|
134
|
+
| #EUR_km(v) => v
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
let toString = value => {
|
|
138
|
+
switch value {
|
|
139
|
+
| #EUR_km(v) => v->Float.toString ++ " EUR/km"
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
let makeEUR_km = (value: float) => #EUR_km(value)
|
|
144
|
+
}
|
|
145
|
+
}
|
|
@@ -148,7 +148,7 @@ module ReactSelectMultipleCreateInput = {
|
|
|
148
148
|
~isLoading: option<bool>=?,
|
|
149
149
|
~className: option<string>=?,
|
|
150
150
|
~id: option<string>=?,
|
|
151
|
-
) => React.element = "
|
|
151
|
+
) => React.element = "default"
|
|
152
152
|
}
|
|
153
153
|
|
|
154
154
|
@react.component
|
|
@@ -163,7 +163,7 @@ module ReactSelectMultipleCreateInput = {
|
|
|
163
163
|
~isLoading=false,
|
|
164
164
|
~className: option<string>=?,
|
|
165
165
|
~id: option<string>=?,
|
|
166
|
-
) =>
|
|
166
|
+
) => {
|
|
167
167
|
<ReactSelect
|
|
168
168
|
components={"DropDownIndicator": React.null}
|
|
169
169
|
isMulti=true
|
|
@@ -194,4 +194,5 @@ module ReactSelectMultipleCreateInput = {
|
|
|
194
194
|
?className
|
|
195
195
|
?id
|
|
196
196
|
/>
|
|
197
|
+
}
|
|
197
198
|
}
|