@colisweb/rescript-toolkit 5.25.0 → 5.26.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@colisweb/rescript-toolkit",
3
- "version": "5.25.0",
3
+ "version": "5.26.0",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "clean": "rescript clean",
@@ -714,4 +714,41 @@ 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
+ value
742
+ countryCallingCodeEditable={false}
743
+ defaultCountry
744
+ onChange={handleChange}
745
+ onBlur={_ => validate()}
746
+ />
747
+ {error->Option.mapWithDefault(React.null, error => {
748
+ <ErrorMessage error />
749
+ })}
750
+ </>
751
+ }}
752
+ />
753
+ }
717
754
  }
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 {
@@ -259,4 +260,16 @@ input[type="number"] {
259
260
  -moz-appearance: textfield;
260
261
  }
261
262
 
263
+ .PhoneInput {
264
+ @apply bg-white border rounded;
265
+ }
266
+
267
+ .PhoneInputCountry {
268
+ @apply px-2 m-2 border-r;
269
+ }
270
+
271
+ .PhoneInputInput {
272
+ @apply rounded-r py-2;
273
+ }
274
+
262
275
  /* purgecss end ignore */