@colisweb/rescript-toolkit 4.6.1 → 4.7.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/locale/fr.json +15 -0
- package/package.json +1 -1
- package/src/form/Toolkit__Form.res +130 -0
- package/src/ui/styles.css +4 -0
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
|
@@ -721,4 +721,134 @@ module Make = (StateLenses: Config) => {
|
|
|
721
721
|
</>}
|
|
722
722
|
/>
|
|
723
723
|
}
|
|
724
|
+
|
|
725
|
+
module DatePicker = {
|
|
726
|
+
module Picker = {
|
|
727
|
+
@react.component
|
|
728
|
+
let make = (
|
|
729
|
+
~value,
|
|
730
|
+
~handleChange,
|
|
731
|
+
~containerClassName,
|
|
732
|
+
~placeholder,
|
|
733
|
+
~disabledBefore: option<Js.Date.t>=?,
|
|
734
|
+
) => {
|
|
735
|
+
let (date, setDate) = React.useState((): option<Js.Date.t> => value)
|
|
736
|
+
let intl = useIntl()
|
|
737
|
+
|
|
738
|
+
<div>
|
|
739
|
+
<Toolkit__Ui_PortalDropdown
|
|
740
|
+
buttonClassName="!border-0 w-full !p-0"
|
|
741
|
+
label={switch value {
|
|
742
|
+
| None =>
|
|
743
|
+
<div className={cx(["text-left w-full", containerClassName])}>
|
|
744
|
+
<div className="border p-2 rounded text-neutral-400 font-normal">
|
|
745
|
+
{placeholder->Option.getWithDefault(
|
|
746
|
+
<FormattedMessage defaultMessage={"Choisissez une date"} />,
|
|
747
|
+
)}
|
|
748
|
+
</div>
|
|
749
|
+
</div>
|
|
750
|
+
| Some(date) =>
|
|
751
|
+
<div
|
|
752
|
+
className={cx([
|
|
753
|
+
"border rounded-lg p-2 flex flex-row items-center justify-between gap-6 font-normal text-neutral-700 w-full",
|
|
754
|
+
containerClassName,
|
|
755
|
+
])}>
|
|
756
|
+
<span>
|
|
757
|
+
<FormattedDate
|
|
758
|
+
value={date} weekday=#long day=#numeric month=#long year=#numeric
|
|
759
|
+
/>
|
|
760
|
+
</span>
|
|
761
|
+
<div
|
|
762
|
+
className="border inline-flex items-center justify-center w-8 h-8 rounded border-primary-700 text-primary-700">
|
|
763
|
+
<ReactIcons.FaPencilAlt size={18} />
|
|
764
|
+
</div>
|
|
765
|
+
</div>
|
|
766
|
+
}}>
|
|
767
|
+
{disclosure => {
|
|
768
|
+
<div className="flex flex-col">
|
|
769
|
+
<ReactDayPicker.ReactDayPicker.DayPicker
|
|
770
|
+
className="cw-Datepicker"
|
|
771
|
+
showOutsideDays=true
|
|
772
|
+
modifiers={disabledBefore->Option.mapWithDefault(
|
|
773
|
+
Js.Obj.empty()->Obj.magic,
|
|
774
|
+
disabledBefore => {
|
|
775
|
+
{
|
|
776
|
+
"disabled": {
|
|
777
|
+
"before": disabledBefore,
|
|
778
|
+
},
|
|
779
|
+
}->Obj.magic
|
|
780
|
+
},
|
|
781
|
+
)}
|
|
782
|
+
locale={intl->Intl.locale}
|
|
783
|
+
months=Toolkit__LocalesHelpers.DatePicker.Fr.months
|
|
784
|
+
weekdaysShort=Toolkit__LocalesHelpers.DatePicker.Fr.weekdaysShort
|
|
785
|
+
firstDayOfWeek=1
|
|
786
|
+
selectedDays=(date->Obj.magic, {from: Js.Nullable.null, to_: Js.Nullable.null})
|
|
787
|
+
onDayClick={(
|
|
788
|
+
(day, modifiers) => {
|
|
789
|
+
let disabled: option<bool> = (modifiers->Obj.magic)["disabled"]
|
|
790
|
+
|
|
791
|
+
switch disabled {
|
|
792
|
+
| Some(true) => ()
|
|
793
|
+
| _ => setDate(_ => Some(day))
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
)->Obj.magic}
|
|
797
|
+
/>
|
|
798
|
+
<div className="flex flex-row justify-between">
|
|
799
|
+
<Toolkit__Ui_Button
|
|
800
|
+
type_="button"
|
|
801
|
+
disabled={date->Option.isNone}
|
|
802
|
+
onClick={_ => {
|
|
803
|
+
setDate(_ => None)
|
|
804
|
+
}}>
|
|
805
|
+
<FormattedMessage defaultMessage={"Réinitialiser"} />
|
|
806
|
+
</Toolkit__Ui_Button>
|
|
807
|
+
<Toolkit__Ui_Button
|
|
808
|
+
color=#primary
|
|
809
|
+
type_="button"
|
|
810
|
+
disabled={date->Option.isNone}
|
|
811
|
+
onClick={_ => {
|
|
812
|
+
disclosure.hide()
|
|
813
|
+
handleChange(date)
|
|
814
|
+
}}>
|
|
815
|
+
<FormattedMessage defaultMessage={"Choisir"} />
|
|
816
|
+
</Toolkit__Ui_Button>
|
|
817
|
+
</div>
|
|
818
|
+
</div>
|
|
819
|
+
}}
|
|
820
|
+
</Toolkit__Ui_PortalDropdown>
|
|
821
|
+
</div>
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
@react.component
|
|
825
|
+
let make = (
|
|
826
|
+
~field,
|
|
827
|
+
~label=?,
|
|
828
|
+
~id,
|
|
829
|
+
~isOptional=?,
|
|
830
|
+
~containerClassName="",
|
|
831
|
+
~placeholder=?,
|
|
832
|
+
~disabledBefore=?,
|
|
833
|
+
) => {
|
|
834
|
+
<Form.Field
|
|
835
|
+
field
|
|
836
|
+
render={({handleChange, value, error}) => <>
|
|
837
|
+
{switch label {
|
|
838
|
+
| None => React.null
|
|
839
|
+
| Some(label) =>
|
|
840
|
+
<Toolkit__Ui_Label
|
|
841
|
+
htmlFor=id
|
|
842
|
+
optionalMessage={isOptional->Option.getWithDefault(false)
|
|
843
|
+
? <FormattedMessage defaultMessage="(Optionnel)" />
|
|
844
|
+
: React.null}>
|
|
845
|
+
label
|
|
846
|
+
</Toolkit__Ui_Label>
|
|
847
|
+
}}
|
|
848
|
+
<Picker value handleChange containerClassName placeholder ?disabledBefore />
|
|
849
|
+
<ErrorMessage ?error />
|
|
850
|
+
</>}
|
|
851
|
+
/>
|
|
852
|
+
}
|
|
853
|
+
}
|
|
724
854
|
}
|