@colisweb/rescript-toolkit 4.12.0 → 4.13.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
@@ -1,4 +1,9 @@
1
1
  [
2
+ {
3
+ "id": "_0475def8",
4
+ "defaultMessage": "Fin",
5
+ "message": "Fin"
6
+ },
2
7
  {
3
8
  "id": "_04eadf92",
4
9
  "defaultMessage": "L'email est invalide.",
@@ -39,11 +44,6 @@
39
44
  "defaultMessage": "Volume total",
40
45
  "message": "Volume total"
41
46
  },
42
- {
43
- "id": "_2f765479",
44
- "defaultMessage": "Choisir",
45
- "message": "Choisir"
46
- },
47
47
  {
48
48
  "id": "_337be526",
49
49
  "defaultMessage": "Jeudi",
@@ -64,6 +64,16 @@
64
64
  "defaultMessage": "Samedi",
65
65
  "message": "Samedi"
66
66
  },
67
+ {
68
+ "id": "_4df46058",
69
+ "defaultMessage": "Semaine {number}",
70
+ "message": "Semaine {number}"
71
+ },
72
+ {
73
+ "id": "_4f2a1035",
74
+ "defaultMessage": "Début",
75
+ "message": "Début"
76
+ },
67
77
  {
68
78
  "id": "_5689ac4d",
69
79
  "defaultMessage": "Masquer le mot de passe",
@@ -74,6 +84,11 @@
74
84
  "defaultMessage": "Non",
75
85
  "message": "Non"
76
86
  },
87
+ {
88
+ "id": "_6a661ab6",
89
+ "defaultMessage": "Aujourd'hui",
90
+ "message": "Aujourd'hui"
91
+ },
77
92
  {
78
93
  "id": "_6ef34790",
79
94
  "defaultMessage": "Une erreur est survenue lors de la recherche",
@@ -94,11 +109,21 @@
94
109
  "defaultMessage": "<lat></lat>, <lng></lng>",
95
110
  "message": "<lat></lat>, <lng></lng>"
96
111
  },
112
+ {
113
+ "id": "_7cd2a589",
114
+ "defaultMessage": "Cette semaine",
115
+ "message": "Cette semaine"
116
+ },
97
117
  {
98
118
  "id": "_7e01b0f2",
99
119
  "defaultMessage": "Réinitialiser",
100
120
  "message": "Réinitialiser"
101
121
  },
122
+ {
123
+ "id": "_7e345c99",
124
+ "defaultMessage": "Ce mois",
125
+ "message": "Ce mois"
126
+ },
102
127
  {
103
128
  "id": "_8f8eb0df",
104
129
  "defaultMessage": "Vendredi",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@colisweb/rescript-toolkit",
3
- "version": "4.12.0",
3
+ "version": "4.13.0",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "clean": "rescript clean",
@@ -28,7 +28,6 @@
28
28
  "license": "MIT",
29
29
  "dependencies": {
30
30
  "@colisweb/bs-react-intl-extractor-bin": "0.12.2",
31
- "@colisweb/react-day-picker": "7.4.16",
32
31
  "@colisweb/restorative": "1.0.0",
33
32
  "@datadog/browser-rum": "4.46.0",
34
33
  "@headlessui/react": "1.7.16",
@@ -53,6 +52,7 @@
53
52
  "react": "18.2.0",
54
53
  "react-big-calendar": "1.5.2",
55
54
  "react-datepicker": "3.8.0",
55
+ "react-day-picker": "8.8.0",
56
56
  "react-dom": "18.2.0",
57
57
  "react-error-boundary": "4.0.10",
58
58
  "react-helmet": "6.1.0",
@@ -638,107 +638,7 @@ module Make = (StateLenses: Config) => {
638
638
  }
639
639
 
640
640
  module DatePicker = {
641
- module Picker = {
642
- @react.component
643
- let make = (
644
- ~value,
645
- ~handleChange,
646
- ~containerClassName,
647
- ~placeholder,
648
- ~disabledBefore: option<Js.Date.t>=?,
649
- ~revalidate,
650
- ) => {
651
- let (date, setDate) = React.useState((): option<Js.Date.t> => value)
652
- let intl = useIntl()
653
-
654
- <div>
655
- <Toolkit__Ui_PortalDropdown
656
- buttonClassName="!border-0 w-full !p-0"
657
- label={switch value {
658
- | None =>
659
- <div className={cx(["text-left w-full", containerClassName])}>
660
- <div className="border p-2 rounded text-neutral-400 font-normal">
661
- {placeholder->Option.getWithDefault(
662
- <FormattedMessage defaultMessage={"Choisissez une date"} />,
663
- )}
664
- </div>
665
- </div>
666
- | Some(date) =>
667
- <div
668
- className={cx([
669
- "border rounded-lg p-2 flex flex-row items-center justify-between gap-6 font-normal text-neutral-700 w-full",
670
- containerClassName,
671
- ])}>
672
- <span>
673
- <FormattedDate
674
- value={date} weekday=#long day=#numeric month=#long year=#numeric
675
- />
676
- </span>
677
- <div
678
- className="border inline-flex items-center justify-center w-8 h-8 rounded border-primary-700 text-primary-700">
679
- <ReactIcons.FaPencilAlt size={18} />
680
- </div>
681
- </div>
682
- }}>
683
- {disclosure => {
684
- <div className="flex flex-col">
685
- <ReactDayPicker.ReactDayPicker.DayPicker
686
- className="cw-Datepicker"
687
- showOutsideDays=true
688
- modifiers={disabledBefore->Option.mapWithDefault(
689
- Js.Obj.empty()->Obj.magic,
690
- disabledBefore => {
691
- {
692
- "disabled": {
693
- "before": disabledBefore,
694
- },
695
- }->Obj.magic
696
- },
697
- )}
698
- locale={intl->Intl.locale}
699
- months=Toolkit__LocalesHelpers.DatePicker.Fr.months
700
- weekdaysShort=Toolkit__LocalesHelpers.DatePicker.Fr.weekdaysShort
701
- firstDayOfWeek=1
702
- selectedDays=(date->Obj.magic, {from: Js.Nullable.null, to_: Js.Nullable.null})
703
- onDayClick={(
704
- (day, modifiers) => {
705
- let disabled: option<bool> = (modifiers->Obj.magic)["disabled"]
706
-
707
- switch disabled {
708
- | Some(true) => ()
709
- | _ => setDate(_ => Some(day))
710
- }
711
- }
712
- )->Obj.magic}
713
- />
714
- <div className="flex flex-row justify-between">
715
- <Toolkit__Ui_Button
716
- type_="button"
717
- disabled={date->Option.isNone}
718
- onClick={_ => {
719
- revalidate()
720
- setDate(_ => None)
721
- }}>
722
- <FormattedMessage defaultMessage={"Réinitialiser"} />
723
- </Toolkit__Ui_Button>
724
- <Toolkit__Ui_Button
725
- color=#primary
726
- type_="button"
727
- disabled={date->Option.isNone}
728
- onClick={_ => {
729
- disclosure.hide()
730
- revalidate()
731
- handleChange(date)
732
- }}>
733
- <FormattedMessage defaultMessage={"Choisir"} />
734
- </Toolkit__Ui_Button>
735
- </div>
736
- </div>
737
- }}
738
- </Toolkit__Ui_PortalDropdown>
739
- </div>
740
- }
741
- }
641
+ open ReactDayPicker
742
642
  @react.component
743
643
  let make = (
744
644
  ~field,
@@ -751,14 +651,7 @@ module Make = (StateLenses: Config) => {
751
651
  ) => {
752
652
  <Field
753
653
  field
754
- render={({handleChange, value, error, state, validate}) => {
755
- let revalidate = () => {
756
- switch state {
757
- | Pristine => ()
758
- | _ => validate()
759
- }
760
- }
761
-
654
+ render={({handleChange, value, error}) => {
762
655
  <>
763
656
  {switch label {
764
657
  | None => React.null
@@ -771,7 +664,39 @@ module Make = (StateLenses: Config) => {
771
664
  label
772
665
  </Toolkit__Ui_Label>
773
666
  }}
774
- <Picker value handleChange containerClassName placeholder ?disabledBefore revalidate />
667
+ <ReactDayPicker.SingleDayPickerInput
668
+ ?value
669
+ onChange={v => handleChange(v)}
670
+ allowEmpty=?isOptional
671
+ buttonClassName="w-full"
672
+ labelClassName={cx([
673
+ "flex flex-row items-center gap-4 font-normal text-neutral-700 w-full",
674
+ containerClassName,
675
+ ])}
676
+ modifiers=?{disabledBefore->Option.map((disabledBefore): ReactDayPicker.modifiers => {
677
+ disabled: [
678
+ ReactDayPicker.Matcher.interval({
679
+ before: disabledBefore,
680
+ }),
681
+ ],
682
+ })}
683
+ placeholder={placeholder->Option.getWithDefault(
684
+ <FormattedMessage defaultMessage="Choisissez une date" />,
685
+ )}
686
+ labelFormatter={date => {
687
+ <>
688
+ <span>
689
+ <FormattedDate
690
+ value={date} weekday=#long day=#numeric month=#long year=#numeric
691
+ />
692
+ </span>
693
+ <div
694
+ className="border inline-flex items-center justify-center w-8 h-8 rounded border-primary-700 text-primary-700">
695
+ <ReactIcons.FaPencilAlt size={18} />
696
+ </div>
697
+ </>
698
+ }}
699
+ />
775
700
  <ErrorMessage ?error />
776
701
  </>
777
702
  }}
@@ -282,7 +282,7 @@ module Make = (Config: RouterConfig) => {
282
282
  "sidenav-link",
283
283
  isActive && !disabledActiveLink ? "bg-primary-100/75 text-neutral-700" : "",
284
284
  ])}
285
- activeClassName="bg-primary-100/75 text-neutral-700"
285
+ activeClassName={disabledActiveLink ? "" : "bg-primary-100/75 text-neutral-700"}
286
286
  onClick={_ => onLinkClick()}>
287
287
  <span className="overflow-hidden flex">
288
288
  {config.icon->Option.mapWithDefault(React.null, icon =>
package/src/ui/styles.css CHANGED
@@ -1,11 +1,10 @@
1
1
  /* purgecss start ignore */
2
+ @import url("./tailwind-init.css");
2
3
  @import url("https://fonts.googleapis.com/css?family=Montserrat:300,400,500,600,700");
3
4
  @import url("https://fonts.googleapis.com/css?family=Open+Sans:300,400,500,600,700");
4
5
  @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");
5
6
  @import url("https://fonts.googleapis.com/css2?family=Fira+Code:wght@300;400;500;600;700&display=swap");
6
- @import url("@colisweb/react-day-picker/lib/style.css");
7
- @tailwind base;
8
- @tailwind components;
7
+ @import url("react-day-picker/dist/style.css");
9
8
 
10
9
  @layer components {
11
10
  .cw-tab-list {
@@ -23,7 +22,6 @@
23
22
  }
24
23
  }
25
24
 
26
- @tailwind utilities;
27
25
  :root {
28
26
  --reach-dialog: 1;
29
27
  }
@@ -43,8 +41,6 @@ body,
43
41
  @apply h-full flex flex-col justify-between;
44
42
  }
45
43
 
46
- /* Reach UI */
47
-
48
44
  /* Animations */
49
45
  @keyframes spin {
50
46
  from {
@@ -65,6 +61,7 @@ select:not([disabled]):not([tabindex="-1"]):focus,
65
61
  textarea:not([disabled]):not([tabindex="-1"]):focus,
66
62
  button:not([disabled]):not([tabindex="-1"]):focus,
67
63
  iframe:not([tabindex="-1"]):focus,
64
+ [tabindex]:not([tabindex="-1"]):focus,
68
65
  [contentEditable="true"]:not([tabindex="-1"]):focus,
69
66
  .focus {
70
67
  outline: none !important;
@@ -88,41 +85,6 @@ iframe:not([tabindex="-1"]):focus,
88
85
  @apply bg-info-500;
89
86
  }
90
87
 
91
- .input-range
92
- .DayPicker-Day--selected:not(.DayPicker-Day--start):not(
93
- .DayPicker-Day--end
94
- ):not(.DayPicker-Day--outside) {
95
- background-color: #f0f8ff !important;
96
- color: #4a90e2;
97
- }
98
-
99
- .input-range .DayPicker-Day {
100
- border-radius: 0 !important;
101
- }
102
-
103
- .input-range .DayPicker-Day--start {
104
- border-top-left-radius: 50% !important;
105
- border-bottom-left-radius: 50% !important;
106
- }
107
-
108
- .input-range .DayPicker-Day--end {
109
- border-top-right-radius: 50% !important;
110
- border-bottom-right-radius: 50% !important;
111
- }
112
-
113
- .input-range .DayPickerInput-Overlay {
114
- width: 580px;
115
- z-index: 31;
116
- }
117
-
118
- .input-range-to .DayPickerInput-Overlay {
119
- margin-left: -198px;
120
- }
121
-
122
- .input-range .DayPickerInput input {
123
- @apply p-2 border rounded-sm cursor-pointer;
124
- }
125
-
126
88
  .react-select__control {
127
89
  @apply border-gray-300 !important;
128
90
  }
@@ -147,26 +109,46 @@ iframe:not([tabindex="-1"]):focus,
147
109
  @apply shadow-none !important;
148
110
  }
149
111
 
150
- .Selectable
151
- .DayPicker-Day--selected:not(.DayPicker-Day--start):not(
152
- .DayPicker-Day--end
153
- ):not(.DayPicker-Day--outside) {
154
- background-color: #f0f8ff !important;
155
- color: #4a90e2;
112
+ .cw-Tabs {
113
+ @apply flex flex-row bg-gray-200 rounded-full h-6 text-sm mb-2;
114
+ }
115
+
116
+ .cw-Tabs [data-selected] {
117
+ background: linear-gradient(270deg, #11a3b6 0%, #27d0dc 100%);
118
+ color: white;
119
+ }
120
+
121
+ .cw-Tabs [data-selected]:hover {
122
+ color: white;
123
+ @apply bg-primary-500;
124
+ }
125
+
126
+ .cw-Tabs [data-reach-tab] {
127
+ @apply flex items-center justify-center w-full py-3 rounded-full font-display;
156
128
  }
157
129
 
158
- .Selectable .DayPicker-Day {
159
- border-radius: 0 !important;
130
+ .cw-Tabs [data-reach-tab]:hover {
131
+ @apply bg-primary-300;
132
+ }
133
+
134
+ .cw-Tabs.cw-Tabs--big {
135
+ @apply h-10 text-xl;
136
+ }
137
+
138
+ .cw-ButtonGroup > button {
139
+ @apply whitespace-nowrap h-full px-3 md:px-4 flex items-center justify-center rounded-3xl py-3;
140
+ }
141
+ .cw-ButtonGroup > button:hover {
142
+ @apply bg-primary-300;
160
143
  }
161
144
 
162
- .Selectable .DayPicker-Day--start {
163
- border-top-left-radius: 50% !important;
164
- border-bottom-left-radius: 50% !important;
145
+ .cw-ButtonGroup > button.selected {
146
+ background: linear-gradient(270deg, #11a3b6 0%, #27d0dc 100%);
147
+ color: white;
165
148
  }
166
149
 
167
- .Selectable .DayPicker-Day--end {
168
- border-top-right-radius: 50% !important;
169
- border-bottom-right-radius: 50% !important;
150
+ .cw-Checkbox > input:checked + .checkmark > * {
151
+ @apply opacity-100;
170
152
  }
171
153
 
172
154
  code {
@@ -203,7 +185,6 @@ code {
203
185
  visibility: visible;
204
186
  opacity: 100%;
205
187
  }
206
-
207
188
  .sidenav.sidenav--closed .sidenav-link .sidenav-link-tooltip:before {
208
189
  content: "";
209
190
  position: absolute;
@@ -220,85 +201,55 @@ input::-webkit-inner-spin-button {
220
201
  margin: 0;
221
202
  }
222
203
 
223
- /* Firefox */
224
- input[type="number"] {
225
- -moz-appearance: textfield;
226
- }
204
+ /* React day picker */
227
205
 
228
- /* Day picker */
229
- .DayPicker .DayPicker-Day {
230
- width: 40px !important;
231
- height: 40px !important;
232
- }
233
- .DayPicker .DayPicker-Day--selected {
234
- border-radius: 0 !important;
235
- }
236
- .DayPicker
237
- .DayPicker-Day--selected:not(.DayPicker-Day--start):not(.DayPicker-Day--end) {
238
- background-color: #e7edf3 !important;
239
- color: #15373a;
240
- }
241
- .DayPicker .DayPicker-Day--selected.DayPicker-Day--start {
242
- border-top-left-radius: 50% !important;
243
- border-bottom-left-radius: 50% !important;
244
- background-color: #15cbe3 !important;
245
- color: #fff;
246
- }
247
- .DayPicker .DayPicker-Day--selected.DayPicker-Day--end {
248
- border-top-right-radius: 50% !important;
249
- border-bottom-right-radius: 50% !important;
250
- background-color: #15cbe3 !important;
251
- color: #fff;
252
- }
253
- .DayPicker .DayPicker-Day--closed {
254
- border-radius: 0 !important;
255
- }
256
- .DayPicker
257
- .DayPicker-Day--closed:not(.DayPicker-Day--start):not(.DayPicker-Day--end) {
258
- background-color: #ff634b !important;
259
- color: #15373a;
260
- }
261
- .DayPicker
262
- .DayPicker-Day--closed.DayPicker-Day--start:not(.DayPicker-Day--end) {
263
- border-top-left-radius: 50% !important;
264
- border-bottom-left-radius: 50% !important;
265
- border-top-right-radius: 0 !important;
266
- border-bottom-right-radius: 0 !important;
267
- background-color: #ff904b !important;
268
- color: #15373a;
269
- }
270
- .DayPicker
271
- .DayPicker-Day--closed.DayPicker-Day--end:not(.DayPicker-Day--start) {
272
- border-top-right-radius: 50% !important;
273
- border-bottom-right-radius: 50% !important;
274
- border-top-left-radius: 0 !important;
275
- border-bottom-left-radius: 0 !important;
276
- background-color: #ff904b !important;
277
- color: #15373a;
278
- }
279
- .DayPicker .DayPicker-Day--closed.DayPicker-Day--start.DayPicker-Day--end {
280
- background-color: #ff904b !important;
281
- color: #15373a;
206
+ .rdp-caption_label {
207
+ @apply text-neutral-700 capitalize;
282
208
  }
283
209
 
284
- .cw-ButtonGroup > button {
285
- @apply whitespace-nowrap h-full px-3 md:px-4 flex items-center justify-center rounded-3xl py-3;
210
+ .rdp-caption_label {
211
+ @apply text-neutral-700;
286
212
  }
287
- .cw-ButtonGroup > button:hover {
288
- @apply bg-primary-300;
213
+ .rdp-day {
214
+ @apply text-neutral-700;
289
215
  }
290
-
291
- .cw-ButtonGroup > button.selected {
292
- background: linear-gradient(270deg, #11a3b6 0%, #27d0dc 100%);
293
- color: white;
216
+ .rdp-day_today {
217
+ @apply text-danger-700;
218
+ }
219
+ .rdp-head_cell {
220
+ @apply text-neutral-600;
221
+ }
222
+ .rdp-day_selected,
223
+ .rdp-day_selected:hover {
224
+ @apply bg-primary-500 text-white;
225
+ }
226
+ .rdp-day_range_middle,
227
+ .rdp-day_range_middle:hover {
228
+ @apply bg-gray-300 text-black;
229
+ }
230
+ .rdp-day_selected.rdp-day_range_start:not(.rdp-day_range_end),
231
+ .rdp-day_range_middle:hover {
232
+ @apply !rounded-tr-none !rounded-br-none;
294
233
  }
295
234
 
296
- .cw-Checkbox > input:checked + .checkmark > * {
297
- @apply opacity-100;
235
+ .rdp-day_closed,
236
+ .rdp-day_closed:hover {
237
+ @apply !bg-[#ff904b] !text-black;
238
+ }
239
+ .rdp-day_closed:not(.rdp-day_range_start):not(.rdp-day_range_end),
240
+ .rdp-day_closed:not(.rdp-day_range_start):not(.rdp-day_range_end):hover {
241
+ @apply !bg-[#ff634b] !text-black !rounded-none;
242
+ }
243
+ .rdp-button[disabled].rdp-day_closed {
244
+ @apply !opacity-100;
245
+ }
246
+ .rdp-button[disabled] {
247
+ @apply cursor-not-allowed;
298
248
  }
299
249
 
300
- .cw-Datepicker.DayPicker .DayPicker-Day.DayPicker-Day--selected {
301
- @apply !bg-primary-500 !rounded-full text-white;
250
+ /* Firefox */
251
+ input[type="number"] {
252
+ -moz-appearance: textfield;
302
253
  }
303
254
 
304
255
  /* purgecss end ignore */
@@ -0,0 +1,3 @@
1
+ @tailwind base;
2
+ @tailwind components;
3
+ @tailwind utilities;