haya-select 1.0.47 → 1.0.48
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/select/index.jsx +15 -19
package/package.json
CHANGED
package/src/select/index.jsx
CHANGED
|
@@ -147,29 +147,25 @@ export default memo(shapeComponent(class HayaSelect extends ShapeComponent {
|
|
|
147
147
|
if ("values" in this.props && typeof this.props.values != "undefined") {
|
|
148
148
|
if (Array.isArray(this.props.options) && this.props.values) {
|
|
149
149
|
return this.p.values.map((value) => this.p.options.find((option) => option.value == value))
|
|
150
|
-
} else if (this.s.loadedOptions
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
let foundOption = this.s.loadedOptions.find((option) => option.value == value)
|
|
150
|
+
} else if (this.s.loadedOptions && this.props.values) {
|
|
151
|
+
return this.p.values.map((value) => {
|
|
152
|
+
let foundOption = this.s.loadedOptions.find((option) => option.value == value)
|
|
154
153
|
|
|
155
|
-
|
|
156
|
-
|
|
154
|
+
if (!foundOption) {
|
|
155
|
+
foundOption = this.s.currentOptions.find((option) => option.value == value)
|
|
157
156
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
}
|
|
157
|
+
if (!foundOption) {
|
|
158
|
+
console.error(
|
|
159
|
+
`Couldn't find option: ${value} in loadedOptions or state currentOptions`,
|
|
160
|
+
{stateLoadedOptions: this.s.loadedOptions, stateCurrentOptions: this.s.currentOptions, propsOptions: this.props.options}
|
|
161
|
+
)
|
|
164
162
|
}
|
|
163
|
+
}
|
|
165
164
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
} else {
|
|
171
|
-
this.setCurrentFromGivenValues()
|
|
172
|
-
}
|
|
165
|
+
return foundOption
|
|
166
|
+
})
|
|
167
|
+
} else if (this.props.options == "function" && this.props.values) {
|
|
168
|
+
this.setCurrentFromGivenValues()
|
|
173
169
|
} else if (this.props.values) {
|
|
174
170
|
return this.p.values.map((value) => ({value}))
|
|
175
171
|
}
|