@colisweb/rescript-toolkit 2.66.0 → 2.66.2

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.66.0",
3
+ "version": "2.66.2",
4
4
  "scripts": {
5
5
  "clean": "rescript clean",
6
6
  "build": "rescript build -with-deps",
@@ -133,9 +133,13 @@ module ReactAsyncSelectMultiple = {
133
133
  }
134
134
 
135
135
  module ReactSelectMultipleCreateInput = {
136
+ type labelOption<'value> = {
137
+ label: string,
138
+ value: 'value,
139
+ }
136
140
  module ReactSelect = {
137
- type components = {"DropDownIndicator": React.element}
138
-
141
+ type components = {"DropdownIndicator": React.element}
142
+ type labeledValue = {value: string, label: string}
139
143
  @module("react-select/creatable") @react.component
140
144
  external make: (
141
145
  ~components: components,
@@ -143,11 +147,11 @@ module ReactSelectMultipleCreateInput = {
143
147
  ~isClearable: option<bool>=?,
144
148
  ~isMulti: option<bool>=?,
145
149
  ~menuIsOpen: option<bool>=?,
146
- ~onChange: array<string> => unit,
150
+ ~onChange: array<labelOption<'a>> => unit,
147
151
  ~onInputChange: string => unit,
148
152
  ~onKeyDown: ReactEvent.Keyboard.t => unit,
149
153
  ~placeholder: option<string>=?,
150
- ~value: array<string>,
154
+ ~value: array<labelOption<'a>>,
151
155
  ~isDisabled: option<bool>=?,
152
156
  ~isLoading: option<bool>=?,
153
157
  ~className: option<string>=?,
@@ -157,8 +161,6 @@ module ReactSelectMultipleCreateInput = {
157
161
 
158
162
  @react.component
159
163
  let make = (
160
- ~inputValue: string,
161
- ~onInputChange: string => unit,
162
164
  ~value: array<string>,
163
165
  ~onChange: array<string> => unit,
164
166
  ~isClearable=true,
@@ -168,8 +170,11 @@ module ReactSelectMultipleCreateInput = {
168
170
  ~className: option<string>=?,
169
171
  ~id: option<string>=?,
170
172
  ) => {
173
+ let (inputValue, onInputChange) = React.useState(() => "")
174
+ let onInputChange = v => onInputChange(_ => v)
175
+
171
176
  <ReactSelect
172
- components={"DropDownIndicator": React.null}
177
+ components={"DropdownIndicator": React.null}
173
178
  isMulti=true
174
179
  onKeyDown={e => {
175
180
  if inputValue === "" {
@@ -190,10 +195,10 @@ module ReactSelectMultipleCreateInput = {
190
195
  menuIsOpen={false}
191
196
  inputValue
192
197
  isClearable
193
- onChange
198
+ onChange={values => onChange(values->Array.map(({label}) => label))}
194
199
  onInputChange
195
200
  placeholder
196
- value
201
+ value={value->Array.mapWithIndex((i, v) => {label: v, value: v ++ i->Js.Int.toString})}
197
202
  isDisabled
198
203
  isLoading
199
204
  ?className