@colisweb/rescript-toolkit 5.42.8 → 5.43.0
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/locale/fr.json +0 -5
- package/package.json +1 -1
- package/src/form/Toolkit__Form.res +21 -40
- package/src/hooks/Toolkit__Hooks.res +27 -0
- package/src/vendors/Browser.res +4 -0
- package/src/vendors/Browser.resi +4 -0
package/locale/fr.json
CHANGED
|
@@ -199,11 +199,6 @@
|
|
|
199
199
|
"defaultMessage": "Lundi",
|
|
200
200
|
"message": "Lundi"
|
|
201
201
|
},
|
|
202
|
-
{
|
|
203
|
-
"id": "_a7d9c2dc",
|
|
204
|
-
"defaultMessage": "Format: +33612345678",
|
|
205
|
-
"message": "Format: +33612345678"
|
|
206
|
-
},
|
|
207
202
|
{
|
|
208
203
|
"id": "_a7e73ea4",
|
|
209
204
|
"defaultMessage": "Déconnexion",
|
package/package.json
CHANGED
|
@@ -816,50 +816,31 @@ module Make = (StateLenses: Config) => {
|
|
|
816
816
|
~label,
|
|
817
817
|
~isOptional=false,
|
|
818
818
|
~id,
|
|
819
|
-
~name=?,
|
|
820
|
-
~placeholder=?,
|
|
821
|
-
~autoFocus=?,
|
|
822
|
-
~disabled=?,
|
|
823
|
-
~containerClassName="",
|
|
824
|
-
~isInline=false,
|
|
825
|
-
~inputClassName="",
|
|
826
|
-
~labelClassName="",
|
|
827
|
-
~inputContainerClassName="",
|
|
828
|
-
~autoComplete=?,
|
|
829
|
-
~allowWhiteSpace=false,
|
|
830
819
|
) =>
|
|
831
820
|
<Field
|
|
832
821
|
field
|
|
833
|
-
render={({value, handleChange, validate, error
|
|
834
|
-
let isInvalid = error->Option.isSome
|
|
835
|
-
|
|
836
|
-
let onBlur = _ =>
|
|
837
|
-
switch state {
|
|
838
|
-
| Pristine => ()
|
|
839
|
-
| _ => validate()
|
|
840
|
-
}
|
|
822
|
+
render={({value, handleChange, validate, error}) => {
|
|
841
823
|
<>
|
|
842
|
-
<Toolkit__Ui_Label
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
?
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
</div>
|
|
824
|
+
<Toolkit__Ui_Label
|
|
825
|
+
htmlFor=id
|
|
826
|
+
optionalMessage={isOptional
|
|
827
|
+
? <FormattedMessage defaultMessage="(Optionnel)" />
|
|
828
|
+
: React.null}>
|
|
829
|
+
{label}
|
|
830
|
+
</Toolkit__Ui_Label>
|
|
831
|
+
<ReactPhoneNumberInput
|
|
832
|
+
international
|
|
833
|
+
className={cx([
|
|
834
|
+
"bg-white border rounded",
|
|
835
|
+
error->Option.isSome ? "border-danger-500" : "",
|
|
836
|
+
])}
|
|
837
|
+
id
|
|
838
|
+
value
|
|
839
|
+
countryCallingCodeEditable={false}
|
|
840
|
+
defaultCountry
|
|
841
|
+
onChange={handleChange}
|
|
842
|
+
onBlur={_ => validate()}
|
|
843
|
+
/>
|
|
863
844
|
{error->Option.mapWithDefault(React.null, error => {
|
|
864
845
|
<ErrorMessage error />
|
|
865
846
|
})}
|
|
@@ -451,3 +451,30 @@ let usePromiseV3 = (~debounce=true, fn, deps) => {
|
|
|
451
451
|
|
|
452
452
|
(state, cancel)
|
|
453
453
|
}
|
|
454
|
+
|
|
455
|
+
type scrollPosition = {
|
|
456
|
+
x: float,
|
|
457
|
+
y: float,
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
let useScrollPosition = (~delay=150, ()) => {
|
|
461
|
+
let (scrollPos, setScrollPos) = React.useState(() => {x: 0.0, y: 0.0})
|
|
462
|
+
|
|
463
|
+
React.useEffect(() => {
|
|
464
|
+
let handleScroll = () => {
|
|
465
|
+
setScrollPos(_ => {x: Browser.Window.scrollX, y: Browser.Window.scrollY})
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
let debouncedScroll = Lodash.debounce(handleScroll, delay)
|
|
469
|
+
|
|
470
|
+
Browser.Window.addEventListener("scroll", debouncedScroll)
|
|
471
|
+
|
|
472
|
+
Some(
|
|
473
|
+
() => {
|
|
474
|
+
Browser.Window.removeEventListener("scroll", debouncedScroll)
|
|
475
|
+
},
|
|
476
|
+
)
|
|
477
|
+
}, [delay])
|
|
478
|
+
|
|
479
|
+
scrollPos
|
|
480
|
+
}
|
package/src/vendors/Browser.res
CHANGED
|
@@ -187,6 +187,10 @@ module FormData = {
|
|
|
187
187
|
}
|
|
188
188
|
|
|
189
189
|
module Window = {
|
|
190
|
+
@val
|
|
191
|
+
external scrollX: float = "window.scrollX"
|
|
192
|
+
@val
|
|
193
|
+
external scrollY: float = "window.scrollY"
|
|
190
194
|
@val
|
|
191
195
|
external addEventListener: (string, ReactEvent.Form.t => unit) => unit = "window.addEventListener"
|
|
192
196
|
@val
|
package/src/vendors/Browser.resi
CHANGED
|
@@ -167,6 +167,10 @@ module FormData: {
|
|
|
167
167
|
}
|
|
168
168
|
|
|
169
169
|
module Window: {
|
|
170
|
+
@val
|
|
171
|
+
external scrollX: float = "window.scrollX"
|
|
172
|
+
@val
|
|
173
|
+
external scrollY: float = "window.scrollY"
|
|
170
174
|
@val
|
|
171
175
|
external addEventListener: (string, ReactEvent.Form.t => unit) => unit = "window.addEventListener"
|
|
172
176
|
@val
|