@colisweb/rescript-toolkit 2.66.1 → 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 +1 -1
- package/src/vendors/BsReactSelect.res +24 -20
package/package.json
CHANGED
|
@@ -133,21 +133,25 @@ 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 = {"
|
|
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,
|
|
142
|
-
~inputValue: string
|
|
146
|
+
~inputValue: string,
|
|
143
147
|
~isClearable: option<bool>=?,
|
|
144
148
|
~isMulti: option<bool>=?,
|
|
145
149
|
~menuIsOpen: option<bool>=?,
|
|
146
|
-
~onChange: array<
|
|
147
|
-
~onInputChange: string => unit
|
|
150
|
+
~onChange: array<labelOption<'a>> => unit,
|
|
151
|
+
~onInputChange: string => unit,
|
|
148
152
|
~onKeyDown: ReactEvent.Keyboard.t => unit,
|
|
149
153
|
~placeholder: option<string>=?,
|
|
150
|
-
~value: array<
|
|
154
|
+
~value: array<labelOption<'a>>,
|
|
151
155
|
~isDisabled: option<bool>=?,
|
|
152
156
|
~isLoading: option<bool>=?,
|
|
153
157
|
~className: option<string>=?,
|
|
@@ -157,10 +161,8 @@ module ReactSelectMultipleCreateInput = {
|
|
|
157
161
|
|
|
158
162
|
@react.component
|
|
159
163
|
let make = (
|
|
160
|
-
~inputValue: option<string>=?,
|
|
161
|
-
~onInputChange: option<string => unit>=?,
|
|
162
164
|
~value: array<string>,
|
|
163
|
-
~onChange:
|
|
165
|
+
~onChange: array<string> => unit,
|
|
164
166
|
~isClearable=true,
|
|
165
167
|
~placeholder="",
|
|
166
168
|
~isDisabled=false,
|
|
@@ -168,19 +170,21 @@ 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={"
|
|
177
|
+
components={"DropdownIndicator": React.null}
|
|
173
178
|
isMulti=true
|
|
174
179
|
onKeyDown={e => {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
| Some(inputValue) =>
|
|
180
|
+
if inputValue === "" {
|
|
181
|
+
()
|
|
182
|
+
} else {
|
|
179
183
|
switch e->ReactEvent.Keyboard.key {
|
|
180
184
|
| "Enter"
|
|
181
185
|
| "Tab" => {
|
|
182
|
-
onInputChange
|
|
183
|
-
onChange
|
|
186
|
+
onInputChange("")
|
|
187
|
+
onChange(value->Array.concat([inputValue]))
|
|
184
188
|
e->ReactEvent.Keyboard.preventDefault
|
|
185
189
|
}
|
|
186
190
|
|
|
@@ -189,12 +193,12 @@ module ReactSelectMultipleCreateInput = {
|
|
|
189
193
|
}
|
|
190
194
|
}}
|
|
191
195
|
menuIsOpen={false}
|
|
192
|
-
|
|
196
|
+
inputValue
|
|
193
197
|
isClearable
|
|
194
|
-
|
|
195
|
-
|
|
198
|
+
onChange={values => onChange(values->Array.map(({label}) => label))}
|
|
199
|
+
onInputChange
|
|
196
200
|
placeholder
|
|
197
|
-
value
|
|
201
|
+
value={value->Array.mapWithIndex((i, v) => {label: v, value: v ++ i->Js.Int.toString})}
|
|
198
202
|
isDisabled
|
|
199
203
|
isLoading
|
|
200
204
|
?className
|