@colisweb/rescript-toolkit 5.25.0 → 5.26.1

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@colisweb/rescript-toolkit",
3
- "version": "5.25.0",
3
+ "version": "5.26.1",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "clean": "rescript clean",
@@ -714,4 +714,46 @@ module Make = (StateLenses: Config) => {
714
714
  />
715
715
  }
716
716
  }
717
+
718
+ module Phone = {
719
+ @react.component
720
+ let make = (
721
+ ~field,
722
+ ~international=true,
723
+ ~defaultCountry="FR",
724
+ ~label,
725
+ ~isOptional=false,
726
+ ~id,
727
+ ) =>
728
+ <Field
729
+ field
730
+ render={({value, handleChange, validate, error}) => {
731
+ <>
732
+ <Toolkit__Ui_Label
733
+ htmlFor=id
734
+ optionalMessage={isOptional
735
+ ? <FormattedMessage defaultMessage="(Optionnel)" />
736
+ : React.null}>
737
+ {label}
738
+ </Toolkit__Ui_Label>
739
+ <ReactPhoneNumberInput
740
+ international
741
+ className={cx([
742
+ "bg-white border rounded",
743
+ error->Option.isSome ? "border-danger-500" : "",
744
+ ])}
745
+ id
746
+ value
747
+ countryCallingCodeEditable={false}
748
+ defaultCountry
749
+ onChange={handleChange}
750
+ onBlur={_ => validate()}
751
+ />
752
+ {error->Option.mapWithDefault(React.null, error => {
753
+ <ErrorMessage error />
754
+ })}
755
+ </>
756
+ }}
757
+ />
758
+ }
717
759
  }
package/src/ui/styles.css CHANGED
@@ -6,6 +6,7 @@
6
6
  @import url("https://fonts.googleapis.com/css2?family=Roboto+Mono:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;1,100;1,200;1,300;1,400;1,500;1,600;1,700&display=swap");
7
7
  @import url("https://fonts.googleapis.com/css2?family=Fira+Code:wght@300;400;500;600;700&display=swap");
8
8
  @import url("react-day-picker/dist/style.css");
9
+ @import url("react-phone-number-input/style.css");
9
10
 
10
11
  @layer components {
11
12
  .cw-tab-list {
@@ -32,6 +33,8 @@
32
33
 
33
34
  :root {
34
35
  --reach-dialog: 1;
36
+ --PhoneInputCountrySelectArrow-width: 0.5em;
37
+ --PhoneInputCountryFlag-height: 0.85em;
35
38
  }
36
39
 
37
40
  body {
@@ -259,4 +262,15 @@ input[type="number"] {
259
262
  -moz-appearance: textfield;
260
263
  }
261
264
 
265
+ .PhoneInputCountry {
266
+ @apply pr-2 m-2 border-r;
267
+ }
268
+
269
+ .PhoneInputInput {
270
+ @apply rounded-r py-2;
271
+ }
272
+ .PhoneInputCountrySelectArrow {
273
+ @apply relative -top-px ml-2 text-neutral-600;
274
+ }
275
+
262
276
  /* purgecss end ignore */
@@ -7,6 +7,8 @@ external make: (
7
7
  ~defaultCountry: string=?,
8
8
  ~onChange: string => unit=?,
9
9
  ~onBlur: 'a => unit=?,
10
+ ~className: string=?,
11
+ ~id: string=?,
10
12
  ) => React.element = "default"
11
13
 
12
14
  @module("react-phone-number-input")