@colisweb/rescript-toolkit 2.13.2 → 2.13.3

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.13.2",
3
+ "version": "2.13.3",
4
4
  "scripts": {
5
5
  "clean": "rescript clean",
6
6
  "build": "rescript build",
@@ -127,3 +127,68 @@ module ReactAsyncSelectMultiple = {
127
127
  ~loadOptions: string => Promise.Js.t<array<labelOption<'value>>, string>,
128
128
  ) => React.element = "default"
129
129
  }
130
+
131
+ module ReactSelectMultipleCreateInput = {
132
+ module ReactSelect = {
133
+ type components = {"DropDownIndicator": React.element}
134
+
135
+ @module("react-select/creatable") @react.component
136
+ external make: (
137
+ ~components: components,
138
+ ~inputValue: string,
139
+ ~isClearable: option<bool>=?,
140
+ ~isMulti: option<bool>=?,
141
+ ~menuIsOpen: option<bool>=?,
142
+ ~onChange: array<string> => unit,
143
+ ~onInputChange: string => unit,
144
+ ~onKeyDown: ReactEvent.Keyboard.t => unit,
145
+ ~placeholder: option<string>=?,
146
+ ~value: array<string>,
147
+ ~isDisabled: option<bool>=?,
148
+ ~isLoading: option<bool>=?,
149
+ ~className: option<string>=?,
150
+ ) => React.element = "CreatableSelect"
151
+ }
152
+
153
+ @react.component
154
+ let make = (
155
+ ~inputValue: string,
156
+ ~onInputChange: string => unit,
157
+ ~value: array<string>,
158
+ ~onChange: array<string> => unit,
159
+ ~isClearable=true,
160
+ ~placeholder="",
161
+ ~isDisabled=false,
162
+ ~isLoading=false,
163
+ ~className="",
164
+ ) =>
165
+ <ReactSelect
166
+ components={"DropDownIndicator": React.null}
167
+ isMulti=true
168
+ onKeyDown={e => {
169
+ if inputValue === "" {
170
+ ()
171
+ } else {
172
+ switch e->ReactEvent.Keyboard.key {
173
+ | "Enter"
174
+ | "Tab" => {
175
+ onInputChange("")
176
+ onChange(value->Array.concat([inputValue]))
177
+ e->ReactEvent.Keyboard.preventDefault
178
+ }
179
+ | _ => ()
180
+ }
181
+ }
182
+ }}
183
+ menuIsOpen={false}
184
+ inputValue
185
+ isClearable
186
+ onChange
187
+ onInputChange
188
+ placeholder
189
+ value
190
+ isDisabled
191
+ isLoading
192
+ className
193
+ />
194
+ }