Initial commit
This commit is contained in:
54
src/Autosearch.tsx
Normal file
54
src/Autosearch.tsx
Normal file
@@ -0,0 +1,54 @@
|
||||
import { Component, ReactNode, createElement } from "react";
|
||||
import { TextStyle, ViewStyle, TextInput, View } from "react-native";
|
||||
|
||||
import { Style, mergeNativeStyles } from "@mendix/pluggable-widgets-tools";
|
||||
|
||||
import { AutosearchProps } from "../typings/AutosearchProps";
|
||||
|
||||
export interface AutosearchStyle extends Style {
|
||||
container: ViewStyle;
|
||||
label: TextStyle;
|
||||
input: ViewStyle;
|
||||
}
|
||||
|
||||
interface State {
|
||||
textboxValue?: string;
|
||||
}
|
||||
|
||||
const defaultStyle: AutosearchStyle = {
|
||||
container: {},
|
||||
label: {
|
||||
color: "#F6BB42"
|
||||
},
|
||||
input: {
|
||||
height: 45,
|
||||
borderBottomWidth: 1,
|
||||
borderBottomColor: '#de712b',
|
||||
}
|
||||
};
|
||||
|
||||
export class Autosearch extends Component<AutosearchProps<AutosearchStyle>, State> {
|
||||
private readonly styles = mergeNativeStyles(defaultStyle, this.props.style);
|
||||
private readonly onChangeHandler = this.onChange.bind(this);
|
||||
constructor(props: AutosearchProps<AutosearchStyle>){
|
||||
super(props)
|
||||
this.state = {
|
||||
textboxValue: '',
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
render(): ReactNode {
|
||||
return (
|
||||
<View style={this.styles.container}>
|
||||
<TextInput style={this.styles.input} value={this.state.textboxValue} onChangeText={this.onChangeHandler} placeholder={'Zoeken...'}></TextInput>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
private onChange(text: string) {
|
||||
this.setState({textboxValue: text});
|
||||
this.props.searchvalue.setValue(text);
|
||||
this.props.onChange?.execute();
|
||||
}
|
||||
}
|
||||
31
src/Autosearch.xml
Normal file
31
src/Autosearch.xml
Normal file
@@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<widget id="incentro.autosearch.Autosearch" pluginWidget="true" needsEntityContext="true" offlineCapable="true"
|
||||
supportedPlatform="Native"
|
||||
xmlns="http://www.mendix.com/widget/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.mendix.com/widget/1.0/ ../node_modules/mendix/custom_widget.xsd">
|
||||
<name>Autosearch</name>
|
||||
<description>Mendix Native textbox with an onchange event for searching values when user input is detected</description>
|
||||
<icon/>
|
||||
<properties>
|
||||
<propertyGroup caption="General">
|
||||
<propertyGroup caption="Data source">
|
||||
<property key="searchvalue" type="attribute">
|
||||
<caption>Search value</caption>
|
||||
<description>The attribute which will hold the search value.</description>
|
||||
<attributeTypes>
|
||||
<attributeType name="String"/>
|
||||
</attributeTypes>
|
||||
</property>
|
||||
</propertyGroup>
|
||||
<propertyGroup caption="Events">
|
||||
<property key="onChange" type="action" required="false">
|
||||
<caption>On change</caption>
|
||||
<description/>
|
||||
</property>
|
||||
</propertyGroup>
|
||||
<propertyGroup caption="Common">
|
||||
<systemProperty key="Name"/>
|
||||
</propertyGroup>
|
||||
</propertyGroup>
|
||||
</properties>
|
||||
</widget>
|
||||
11
src/package.xml
Normal file
11
src/package.xml
Normal file
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<package xmlns="http://www.mendix.com/package/1.0/">
|
||||
<clientModule name="Autosearch" version="1.0.0" xmlns="http://www.mendix.com/clientModule/1.0/">
|
||||
<widgetFiles>
|
||||
<widgetFile path="Autosearch.xml"/>
|
||||
</widgetFiles>
|
||||
<files>
|
||||
<file path="incentro/autosearch"/>
|
||||
</files>
|
||||
</clientModule>
|
||||
</package>
|
||||
Reference in New Issue
Block a user