haya-select 1.0.47 → 1.0.49
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 +28 -24
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
|
}
|
|
@@ -577,7 +573,7 @@ export default memo(shapeComponent(class HayaSelect extends ShapeComponent {
|
|
|
577
573
|
const {optionsContainerRef} = this.tt
|
|
578
574
|
const {optionsAbsolute} = this.p
|
|
579
575
|
const {selectContainerLayout, loadedOptions, endOfSelectLayout, optionsContainerLayout, optionsPlacement, optionsVisibility} = this.s
|
|
580
|
-
let top
|
|
576
|
+
let left, top
|
|
581
577
|
|
|
582
578
|
const style = this.stylingFor("optionsContainer", {
|
|
583
579
|
position: "absolute",
|
|
@@ -597,22 +593,30 @@ export default memo(shapeComponent(class HayaSelect extends ShapeComponent {
|
|
|
597
593
|
} else if (optionsPlacement == "below") {
|
|
598
594
|
if (Platform.OS == "web") {
|
|
599
595
|
// onLayout top value is sometimes negative so use browser JS to get it instead
|
|
600
|
-
top = digg(this.tt.endOfSelectRef.current.getBoundingClientRect(), "top")
|
|
596
|
+
top = digg(this.tt.endOfSelectRef.current.getBoundingClientRect(), "top") + document.documentElement.scrollTop + 2
|
|
597
|
+
|
|
598
|
+
// onLayout left values doesn't always update when changed
|
|
599
|
+
left = digg(this.tt.endOfSelectRef.current.getBoundingClientRect(), "left") + document.documentElement.scrollLeft + 2
|
|
601
600
|
} else {
|
|
601
|
+
left = this.s.endOfSelectLayout.left
|
|
602
602
|
top = selectContainerLayout.top
|
|
603
603
|
}
|
|
604
604
|
|
|
605
|
-
style.left =
|
|
605
|
+
style.left = left
|
|
606
606
|
style.top = top - 2
|
|
607
607
|
} else if (optionsPlacement == "above") {
|
|
608
608
|
if (Platform.OS == "web") {
|
|
609
609
|
// onLayout top value is sometimes negative so use browser JS to get it instead
|
|
610
|
-
top = digg(this.tt.selectContainerRef.current.getBoundingClientRect(), "top")
|
|
610
|
+
top = digg(this.tt.selectContainerRef.current.getBoundingClientRect(), "top") + document.documentElement.scrollTop - 1
|
|
611
|
+
|
|
612
|
+
// onLayout left values doesn't always update when changed
|
|
613
|
+
left = digg(this.tt.selectContainerRef.current.getBoundingClientRect(), "left") + document.documentElement.scrollLeft - 1
|
|
611
614
|
} else {
|
|
615
|
+
left = endOfSelectLayout.left
|
|
612
616
|
top = selectContainerLayout.top
|
|
613
617
|
}
|
|
614
618
|
|
|
615
|
-
style.left =
|
|
619
|
+
style.left = left
|
|
616
620
|
style.top = top - optionsContainerLayout.height + 1
|
|
617
621
|
} else {
|
|
618
622
|
throw new Error(`Unkonwn options placement: ${optionsPlacement}`)
|