haya-select 1.0.57 → 1.0.59

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": "haya-select",
3
- "version": "1.0.57",
3
+ "version": "1.0.59",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -13,7 +13,8 @@
13
13
  "debounce": "^2.1.0",
14
14
  "diggerize": "^1.0.4",
15
15
  "fetching-object": "^1.0.1",
16
- "set-state-compare": "^1.0.45"
16
+ "react-native-render-html": "^6.3.4",
17
+ "set-state-compare": "^1.0.52"
17
18
  },
18
19
  "peerDependencies": {
19
20
  "conjointment": ">= 0.1.4",
@@ -88,6 +88,7 @@ export default memo(shapeComponent(class HayaSelect extends ShapeComponent {
88
88
  currentOptions: () => this.defaultCurrentOptions(),
89
89
  selectContainerLayout: null,
90
90
  endOfSelectLayout: null,
91
+ height: null,
91
92
  loadedOptions: () => this.defaultLoadedOptions(),
92
93
  opened: false,
93
94
  optionsContainerLayout: null,
@@ -212,7 +213,6 @@ export default memo(shapeComponent(class HayaSelect extends ShapeComponent {
212
213
  const {opened, optionsPlacement} = this.s
213
214
  const currentOptions = this.getCurrentOptions()
214
215
  const selectContainerStyleActual = this.stylingFor("selectContainer", {
215
- display: "flex",
216
216
  flexDirection: "row",
217
217
  alignItems: "center",
218
218
  backgroundColor: "#fff",
@@ -226,6 +226,9 @@ export default memo(shapeComponent(class HayaSelect extends ShapeComponent {
226
226
  })
227
227
 
228
228
  if (opened) {
229
+ // Prevent select from changing size once the content is replaced with search text once opened
230
+ selectContainerStyleActual.height = this.s.height
231
+
229
232
  if (optionsPlacement == "above") {
230
233
  selectContainerStyleActual.borderTopLeftRadius = 0
231
234
  selectContainerStyleActual.borderTopRightRadius = 0
@@ -246,7 +249,7 @@ export default memo(shapeComponent(class HayaSelect extends ShapeComponent {
246
249
  const chevronStyle = this.stylingFor("chevron", {fontSize: 24})
247
250
 
248
251
  if (opened) {
249
- chevronStyle.marginBottom = -9
252
+ chevronStyle.marginBottom = -15
250
253
  } else {
251
254
  chevronStyle.marginTop = -9
252
255
  }
@@ -272,7 +275,7 @@ export default memo(shapeComponent(class HayaSelect extends ShapeComponent {
272
275
  >
273
276
  <View
274
277
  dataSet={{class: "current-selected"}}
275
- style={this.stylingFor("currentSelected", {width: "calc(100% - 27px)", flexWrap: "wrap"})}
278
+ style={this.stylingFor("currentSelected", {width: "calc(100% - 25px)", flexWrap: "wrap"})}
276
279
  >
277
280
  {opened &&
278
281
  <TextInput
@@ -328,7 +331,7 @@ export default memo(shapeComponent(class HayaSelect extends ShapeComponent {
328
331
  value={digg(currentOption, "value")}
329
332
  />
330
333
  }
331
- {this.presentOption(currentOption)}
334
+ {this.presentOption(currentOption, "current")}
332
335
  </>
333
336
  }
334
337
  </View>
@@ -339,11 +342,9 @@ export default memo(shapeComponent(class HayaSelect extends ShapeComponent {
339
342
  <View
340
343
  className="chevron-container"
341
344
  style={this.stylingFor("chevronContainer", {
342
- display: "flex",
343
345
  alignItems: "center",
344
346
  justifyContent: "center",
345
347
  height: "100%",
346
- marginRight: 8,
347
348
  marginLeft: "auto"
348
349
  })}
349
350
  >
@@ -460,6 +461,7 @@ export default memo(shapeComponent(class HayaSelect extends ShapeComponent {
460
461
 
461
462
  closeOptions() {
462
463
  this.setState({
464
+ height: null,
463
465
  loadedOptions: undefined,
464
466
  opened: false,
465
467
  optionsContainerLayout: null
@@ -478,6 +480,7 @@ export default memo(shapeComponent(class HayaSelect extends ShapeComponent {
478
480
  this.callOptionsPositionAboveIfOutsideScreen = true
479
481
  this.setState(
480
482
  {
483
+ height: this.s.selectContainerLayout.height,
481
484
  opened: true,
482
485
  scrollLeft: Platform.OS == "web" ? document.documentElement.scrollLeft : null,
483
486
  scrollTop: Platform.OS == "web" ? document.documentElement.scrollTop : null,
@@ -751,11 +754,11 @@ export default memo(shapeComponent(class HayaSelect extends ShapeComponent {
751
754
  }
752
755
  }
753
756
 
754
- presentOption = (currentValue) => {
757
+ presentOption = (option, mode) => {
755
758
  const {toggleOptions} = this.props || {}
756
759
  const toggled = this.getToggled()
757
- const icon = this.iconForOption(currentValue)
758
- const toggleValue = toggled[currentValue.value]
760
+ const icon = this.iconForOption(option)
761
+ const toggleValue = toggled[option.value]
759
762
  const toggleOption = toggleOptions?.find((toggleOptionI) => toggleOptionI.value == toggleValue)
760
763
 
761
764
  return (
@@ -764,27 +767,35 @@ export default memo(shapeComponent(class HayaSelect extends ShapeComponent {
764
767
  class: "option-presentation",
765
768
  toggleIcon: toggleOption?.icon,
766
769
  toggleValue: toggleOption?.value,
767
- value: currentValue.value
770
+ value: option.value
768
771
  }}
772
+ style={{flexDirection: "row"}}
769
773
  >
770
- {toggleOptions && !(currentValue.value in toggled) &&
771
- <View dataSet={{class: "toggle-icon-placeholder"}} style={{width: 25}} />
772
- }
773
- {toggleOptions && (currentValue.value in toggled) &&
774
- <FontAwesomeIcon dataSet={{class: "toggle-icon"}} name={icon} style={{width: 25}} />
775
- }
776
- {currentValue.content}
777
- {!currentValue.content &&
778
- <Text dataSet={{class: "option-presentation-text"}} style={this.stylingFor("optionPresentationText", {whiteSpace: "nowrap"})}>
779
- {currentValue.text}
780
- </Text>
781
- }
782
- {("html" in currentValue) && Platform.OS != "web" &&
783
- <RenderHtml source={{html: digg(currentValue, "html")}} />
774
+ {toggleOptions && !(option.value in toggled) &&
775
+ <View dataSet={{class: "toggle-icon-placeholder"}} style={{width: 20}} />
784
776
  }
785
- {("html" in currentValue) && Platform.OS == "web" &&
786
- <div dangerouslySetInnerHTML={{__html: digg(currentValue, "html")}} />
777
+ {toggleOptions && (option.value in toggled) &&
778
+ <View style={{alignItems: "center", justifyContent: "center", width: 20}}>
779
+ <FontAwesomeIcon dataSet={{class: "toggle-icon"}} name={icon} />
780
+ </View>
787
781
  }
782
+ {(() => {
783
+ if (mode == "current" && option.currentContent) {
784
+ return option.currentContent()
785
+ } else if (option.content) {
786
+ return option.content()
787
+ } else if ("html" in option && Platform.OS != "web") {
788
+ return <RenderHtml source={{html: digg(option, "html")}} />
789
+ } else if ("html" in option && Platform.OS == "web") {
790
+ return <div dangerouslySetInnerHTML={{__html: digg(option, "html")}} />
791
+ } else {
792
+ return (
793
+ <Text dataSet={{class: "option-presentation-text"}} style={this.stylingFor("optionPresentationText", {flex: 1, whiteSpace: "nowrap"})}>
794
+ {option.text}
795
+ </Text>
796
+ )
797
+ }
798
+ })()}
788
799
  </View>
789
800
  )
790
801
  }
@@ -795,8 +806,6 @@ export default memo(shapeComponent(class HayaSelect extends ShapeComponent {
795
806
  const currentValues = currentOptions?.map((currentOption) => currentOption.value)
796
807
  const stateValues = this.s.currentOptions?.map((currentOption) => currentOption.value)
797
808
 
798
- console.log("setCurrentFromGivenValues", {stateValues})
799
-
800
809
  if (anythingDifferent(currentValues, stateValues)) {
801
810
  this.setState({currentOptions})
802
811
  }
@@ -59,7 +59,7 @@ export default memo(shapeComponent(class Option extends ShapeComponent {
59
59
  onPointerOut={this.tt.onPointerOut}
60
60
  style={style}
61
61
  >
62
- {this.props.presentOption(option)}
62
+ {this.props.presentOption(option, "option")}
63
63
  </View>
64
64
  )
65
65
  }