@colisweb/rescript-toolkit 2.26.0 → 2.28.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": "2.26.0",
3
+ "version": "2.28.0",
4
4
  "scripts": {
5
5
  "clean": "rescript clean",
6
6
  "build": "rescript build",
@@ -40,4 +40,4 @@ let make = (~worker: Msw.worker, ~children) => {
40
40
  </React.Suspense>
41
41
  }
42
42
 
43
- let defaul = make
43
+ let default = make
@@ -0,0 +1,4 @@
1
+ // @react.component
2
+ // let make: (~worker: Msw.worker, ~children: React.element) => React.element
3
+
4
+ let default: {"children": React.element, "worker": Msw.worker} => React.element
package/src/mock/index.md CHANGED
@@ -10,7 +10,36 @@ Install the package
10
10
  yarn add msw --dev
11
11
  ```
12
12
 
13
- Define the mock
13
+ ### Wrap the App for dev only
14
+
15
+ ```js
16
+ import React from "react";
17
+ import ReactDOM from "react-dom";
18
+ import "@colisweb/rescript-toolkit/src/ui/styles.css";
19
+ import { make as App } from "../lib/es6_global/src/App.bs";
20
+ import { make as Spinner } from "@colisweb/rescript-toolkit/lib/es6_global/src/ui/Toolkit__Ui_SpinnerFullScreen.bs.js";
21
+ import { make as AppWithMock } from "@colisweb/rescript-toolkit/lib/es6_global/src/mock/AppWithMock.bs";
22
+
23
+ const root = ReactDOM.createRoot(document.getElementById("root"));
24
+
25
+ if (import.meta.env.DEV) {
26
+ import("../lib/es6_global/mocks/Mock.bs").then(({ worker }) => {
27
+ root.render(
28
+ <AppWithMock worker={worker}>
29
+ <App />
30
+ </AppWithMock>
31
+ );
32
+ });
33
+ } else {
34
+ root.render(
35
+ <React.Suspense fallback={<Spinner />}>
36
+ <App />
37
+ </React.Suspense>
38
+ );
39
+ }
40
+ ```
41
+
42
+ ### Define the mock
14
43
 
15
44
  ```rescript
16
45
  /* Mock_Page_X.res */
@@ -4,6 +4,13 @@ module String = {
4
4
 
5
5
  @ocaml.doc(" TODO: remove ")
6
6
  let join = joinNonEmty
7
+
8
+ let includes = (str1, str2) => {
9
+ str1
10
+ ->Js.String2.toLowerCase
11
+ ->Js.String2.normalizeByForm("NFD")
12
+ ->Js.String2.includes(str2->Js.String2.toLowerCase->Js.String2.normalizeByForm("NFD"))
13
+ }
7
14
  }
8
15
 
9
16
  module Option = {
@@ -8,6 +8,19 @@ Utililties functions for primitives types :
8
8
 
9
9
  ## API
10
10
 
11
+ ### String
12
+
13
+ #### includes
14
+
15
+ Check if the string is included by setting both strings to lowercase and using `normalize("NFD")`.
16
+
17
+ ```rescript
18
+ let search = "aurelie"
19
+ let data = "Aurélie
20
+
21
+ data->Primitives.String.includes(search) // true
22
+ ```
23
+
11
24
  ### Option
12
25
 
13
26
  ```rescript
@@ -65,6 +65,9 @@ module SwrConfig = {
65
65
 
66
66
  @send
67
67
  external mutate: (t, 'key, 'data, bool) => unit = "mutate"
68
+
69
+ @module("swr") @react.component
70
+ external make: (~value: fetcherOptions=?, ~children: React.element) => React.element = "SWRConfig"
68
71
  }
69
72
 
70
73
  @module("swr")
@@ -1,2 +0,0 @@
1
- @react.component
2
- let make: (~worker: Msw.worker, ~children: React.element) => React.element