@colisweb/rescript-toolkit 5.16.8 → 5.17.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@colisweb/rescript-toolkit",
3
- "version": "5.16.8",
3
+ "version": "5.17.1",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "clean": "rescript clean",
@@ -46,6 +46,7 @@ module type MakeWithUnitConfig = {
46
46
  }
47
47
 
48
48
  module MakeWithUnit = (Config: MakeWithUnitConfig) => {
49
+ module Unit = Config.Unit
49
50
  let decodeFromString = (string: string) => {
50
51
  // match a positive int or float followed by it's unit (capturing int/float in group1 and unit in group2)
51
52
  let regexp = %re("/^(\d+(?:\.\d*)?)\s*(\D*)$/")
@@ -4,7 +4,7 @@ type rec state = {list: array<options>}
4
4
  and options = {
5
5
  id: id,
6
6
  isVisible: bool,
7
- title: string,
7
+ title: React.element,
8
8
  content: option<React.element>,
9
9
  closable: bool,
10
10
  variant: variant,
@@ -40,7 +40,7 @@ let show = (~title, ~content=?, ~closable=true, ~variant, ~timeout=5000, ()) =>
40
40
  Show({
41
41
  id,
42
42
  isVisible: true,
43
- title,
43
+ title: title->React.string,
44
44
  content,
45
45
  closable,
46
46
  variant,
@@ -49,6 +49,49 @@ let show = (~title, ~content=?, ~closable=true, ~variant, ~timeout=5000, ()) =>
49
49
  )
50
50
  }
51
51
 
52
+ let success = title => {
53
+ let id: id = Js.Math.random()->Js.Float.toString->Obj.magic
54
+ store.dispatch(
55
+ Show({
56
+ id,
57
+ isVisible: true,
58
+ title,
59
+ content: None,
60
+ closable: true,
61
+ variant: Success,
62
+ timeout: 5000,
63
+ }),
64
+ )
65
+ }
66
+ let warning = title => {
67
+ let id: id = Js.Math.random()->Js.Float.toString->Obj.magic
68
+ store.dispatch(
69
+ Show({
70
+ id,
71
+ isVisible: true,
72
+ title,
73
+ content: None,
74
+ closable: true,
75
+ variant: Warning,
76
+ timeout: 5000,
77
+ }),
78
+ )
79
+ }
80
+ let error = title => {
81
+ let id: id = Js.Math.random()->Js.Float.toString->Obj.magic
82
+ store.dispatch(
83
+ Show({
84
+ id,
85
+ isVisible: true,
86
+ title,
87
+ content: None,
88
+ closable: true,
89
+ variant: Danger,
90
+ timeout: 5000,
91
+ }),
92
+ )
93
+ }
94
+
52
95
  let remove = id => store.dispatch(Remove(id))
53
96
  let hide = id => {
54
97
  store.dispatch(Hide(id))
@@ -117,7 +160,7 @@ module Item = {
117
160
  | Danger => "text-danger-700"
118
161
  },
119
162
  ])}>
120
- {title->React.string}
163
+ {title}
121
164
  </p>
122
165
  </Toast.Title>
123
166
  </div>
@@ -10,6 +10,9 @@ let show: (
10
10
  unit,
11
11
  ) => unit
12
12
 
13
+ let success: React.element => unit
14
+ let error: React.element => unit
15
+ let warning: React.element => unit
13
16
  module Provider: {
14
17
  @react.component
15
18
  let make: unit => React.element
@@ -1,8 +1,15 @@
1
1
  @module("qs") external stringify: Js.t<'a> => string = "stringify"
2
2
 
3
+ type arrayFormat =
4
+ | @as("indices") Indices
5
+ | @as("comma") Comma
6
+ | @as("brackets") Brackets
7
+ | @as("repeat") Repeat
8
+
3
9
  type params = {
4
10
  addQueryPrefix?: bool,
5
11
  serializeDate?: Js.Date.t => string,
12
+ arrayFormat?: arrayFormat,
6
13
  }
7
14
  @obj
8
15
  external makeParams: (