@colisweb/rescript-toolkit 4.6.0 → 4.7.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 CHANGED
@@ -39,6 +39,11 @@
39
39
  "defaultMessage": "Volume total",
40
40
  "message": "Volume total"
41
41
  },
42
+ {
43
+ "id": "_2f765479",
44
+ "defaultMessage": "Choisir",
45
+ "message": "Choisir"
46
+ },
42
47
  {
43
48
  "id": "_337be526",
44
49
  "defaultMessage": "Jeudi",
@@ -89,6 +94,11 @@
89
94
  "defaultMessage": "<lat></lat>, <lng></lng>",
90
95
  "message": "<lat></lat>, <lng></lng>"
91
96
  },
97
+ {
98
+ "id": "_7e01b0f2",
99
+ "defaultMessage": "Réinitialiser",
100
+ "message": "Réinitialiser"
101
+ },
92
102
  {
93
103
  "id": "_8f8eb0df",
94
104
  "defaultMessage": "Vendredi",
@@ -184,6 +194,11 @@
184
194
  "defaultMessage": "Doit être un entier positif ou un nombre a virgule",
185
195
  "message": "Doit être un entier positif ou un nombre a virgule"
186
196
  },
197
+ {
198
+ "id": "_e2eadf60",
199
+ "defaultMessage": "Choisissez une date",
200
+ "message": "Choisissez une date"
201
+ },
187
202
  {
188
203
  "id": "_e5c29cb8",
189
204
  "defaultMessage": "(Optionnel)",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@colisweb/rescript-toolkit",
3
- "version": "4.6.0",
3
+ "version": "4.7.0",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "clean": "rescript clean",
@@ -36,7 +36,7 @@
36
36
  "@reach/auto-id": "0.18.0",
37
37
  "@rescript/react": "0.11.0",
38
38
  "autoprefixer": "10.4.14",
39
- "axios": "1.4.0",
39
+ "axios": "0.24.0",
40
40
  "bs-axios": "0.0.43",
41
41
  "case": "1.6.3",
42
42
  "click-outside-hook": "1.1.0",
@@ -721,4 +721,105 @@ module Make = (StateLenses: Config) => {
721
721
  </>}
722
722
  />
723
723
  }
724
+
725
+ module DatePicker = {
726
+ module Picker = {
727
+ @react.component
728
+ let make = (~value, ~handleChange, ~containerClassName, ~placeholder) => {
729
+ let (date, setDate) = React.useState((): option<Js.Date.t> => value)
730
+ let intl = useIntl()
731
+
732
+ <div>
733
+ <Toolkit__Ui_PortalDropdown
734
+ buttonClassName="!border-0 w-full !p-0"
735
+ label={switch value {
736
+ | None =>
737
+ <div className={cx(["text-left w-full", containerClassName])}>
738
+ <div className="border p-2 rounded text-neutral-400 font-normal">
739
+ {placeholder->Option.getWithDefault(
740
+ <FormattedMessage defaultMessage={"Choisissez une date"} />,
741
+ )}
742
+ </div>
743
+ </div>
744
+ | Some(date) =>
745
+ <div
746
+ className={cx([
747
+ "border rounded-lg p-2 flex flex-row items-center justify-between gap-6 font-normal text-neutral-700 w-full",
748
+ containerClassName,
749
+ ])}>
750
+ <span>
751
+ <FormattedDate
752
+ value={date} weekday=#long day=#numeric month=#long year=#numeric
753
+ />
754
+ </span>
755
+ <div
756
+ className="border inline-flex items-center justify-center w-8 h-8 rounded border-primary-700 text-primary-700">
757
+ <ReactIcons.FaPencilAlt size={18} />
758
+ </div>
759
+ </div>
760
+ }}>
761
+ {disclosure => {
762
+ <div className="flex flex-col">
763
+ <ReactDayPicker.ReactDayPicker.DayPicker
764
+ className="cw-Datepicker"
765
+ showOutsideDays=true
766
+ locale={intl->Intl.locale}
767
+ months=Toolkit__LocalesHelpers.DatePicker.Fr.months
768
+ weekdaysShort=Toolkit__LocalesHelpers.DatePicker.Fr.weekdaysShort
769
+ firstDayOfWeek=1
770
+ selectedDays=(date->Obj.magic, {from: Js.Nullable.null, to_: Js.Nullable.null})
771
+ onDayClick={(
772
+ (day, _) => {
773
+ setDate(_ => Some(day))
774
+ }
775
+ )->Obj.magic}
776
+ />
777
+ <div className="flex flex-row justify-between">
778
+ <Toolkit__Ui_Button
779
+ type_="button"
780
+ disabled={date->Option.isNone}
781
+ onClick={_ => {
782
+ setDate(_ => None)
783
+ }}>
784
+ <FormattedMessage defaultMessage={"Réinitialiser"} />
785
+ </Toolkit__Ui_Button>
786
+ <Toolkit__Ui_Button
787
+ color=#primary
788
+ type_="button"
789
+ disabled={date->Option.isNone}
790
+ onClick={_ => {
791
+ disclosure.hide()
792
+ handleChange(date)
793
+ }}>
794
+ <FormattedMessage defaultMessage={"Choisir"} />
795
+ </Toolkit__Ui_Button>
796
+ </div>
797
+ </div>
798
+ }}
799
+ </Toolkit__Ui_PortalDropdown>
800
+ </div>
801
+ }
802
+ }
803
+ @react.component
804
+ let make = (~field, ~label=?, ~id, ~isOptional=?, ~containerClassName="", ~placeholder=?) => {
805
+ <Form.Field
806
+ field
807
+ render={({handleChange, value, error}) => <>
808
+ {switch label {
809
+ | None => React.null
810
+ | Some(label) =>
811
+ <Toolkit__Ui_Label
812
+ htmlFor=id
813
+ optionalMessage={isOptional->Option.getWithDefault(false)
814
+ ? <FormattedMessage defaultMessage="(Optionnel)" />
815
+ : React.null}>
816
+ label
817
+ </Toolkit__Ui_Label>
818
+ }}
819
+ <Picker value handleChange containerClassName placeholder />
820
+ <ErrorMessage ?error />
821
+ </>}
822
+ />
823
+ }
824
+ }
724
825
  }
package/src/ui/styles.css CHANGED
@@ -297,4 +297,8 @@ input[type="number"] {
297
297
  @apply opacity-100;
298
298
  }
299
299
 
300
+ .cw-Datepicker.DayPicker .DayPicker-Day.DayPicker-Day--selected {
301
+ @apply !bg-primary-500 !rounded-full text-white;
302
+ }
303
+
300
304
  /* purgecss end ignore */