statebus 7.0.9 → 7.0.10
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/client-library.js +27 -8
- package/package.json +1 -1
package/client-library.js
CHANGED
|
@@ -784,7 +784,9 @@
|
|
|
784
784
|
// This one is for react v17+.
|
|
785
785
|
function make_fixed_textbox (tagname) {
|
|
786
786
|
// `tagname` can be either "input" or "textarea"
|
|
787
|
-
|
|
787
|
+
|
|
788
|
+
// Create a special component
|
|
789
|
+
var component = createReactClass({
|
|
788
790
|
getInitialState: function() {
|
|
789
791
|
return {value: this.props.value}
|
|
790
792
|
},
|
|
@@ -796,17 +798,34 @@
|
|
|
796
798
|
if (this.props.value)
|
|
797
799
|
this.setState({value: e.target.value})
|
|
798
800
|
},
|
|
801
|
+
onInput: function(e) {
|
|
802
|
+
this.props.onInput && this.props.onInput(e)
|
|
803
|
+
if (this.props.value)
|
|
804
|
+
this.setState({value: e.target.value})
|
|
805
|
+
},
|
|
799
806
|
render: function() {
|
|
800
|
-
var new_props = {
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
+
var new_props = {
|
|
808
|
+
...this.props,
|
|
809
|
+
ref: this.props.forwarded_ref // We had to rename ref
|
|
810
|
+
}
|
|
811
|
+
delete new_props.forwarded_ref // Delete the old name
|
|
812
|
+
|
|
813
|
+
// Now replace any onChange or onInput with our wrapper handlers
|
|
814
|
+
if (new_props.hasOwnProperty('onChange'))
|
|
815
|
+
new_props.onChange = this.onChange
|
|
816
|
+
if (new_props.hasOwnProperty('onInput'))
|
|
817
|
+
new_props.onInput = this.onInput
|
|
818
|
+
|
|
807
819
|
return React.createElement(tagname, new_props)
|
|
808
820
|
}
|
|
809
821
|
})
|
|
822
|
+
|
|
823
|
+
// But react components don't pass through the `ref` prop by default,
|
|
824
|
+
// so we have to do that with this special function and rename it to
|
|
825
|
+
// forwarded_ref temporarily:
|
|
826
|
+
return React.forwardRef((props, ref) => {
|
|
827
|
+
return React.createElement(component, {...props, forwarded_ref: ref})
|
|
828
|
+
})
|
|
810
829
|
}
|
|
811
830
|
|
|
812
831
|
// We create special functions for INPUT and TEXTAREA, because they
|