Skip to content

Commit 9a142eb

Browse files
committed
fix: 🎨 setup autocomplete
1 parent 2506a12 commit 9a142eb

21 files changed

+303
-4
lines changed

packages/utilities/useDomLocation/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
"node": ">=10"
1212
},
1313
"scripts": {
14-
"start": "tsdx watch",
15-
"build": "tsdx build",
14+
"start": "npx tsdx watch",
15+
"build": "npx tsdx build",
1616
"test": "tsdx test --passWithNoTests",
1717
"lint": "tsdx lint",
1818
"prepare": "tsdx build",

packages/utilities/useDomLocation/src/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ export function useDomLocation({
2525
};
2626

2727
const onMutation = (): void => {
28+
console.log('Mute Me Buddy 🧎🏽‍♂️🧎🏽‍♂️🧎🏽‍♂️🧎🏽‍♂️');
29+
2830
setLastUpdateTime(new Date());
2931
if (useMendixNav) {
3032
const mxWindow = window.mx.ui.getContentForm();
@@ -88,7 +90,7 @@ export function useDomLocation({
8890
subtree: true,
8991
});
9092
lastScrollTopRef.current = observer;
91-
window.onpopstate = function() {
93+
window.onpopstate = function () {
9294
onMutation();
9395
};
9496
};

packages/web-widgets/auto-complete-widget/src/Autocompletewidget.tsx

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,39 @@ import { AutocompletewidgetContainerProps } from "../typings/AutocompletewidgetP
66
import "./ui/Autocompletewidget.css";
77

88
export default class Autocompletewidget extends Component<AutocompletewidgetContainerProps> {
9+
click = (object: any) => {
10+
console.log(`object`, object);
11+
12+
this.props.volatileDate?.setValue(JSON.stringify(object));
13+
};
914
render(): ReactNode {
10-
return <HelloWorldSample sampleText={this.props.sampleText ? this.props.sampleText : "World"} />;
15+
console.log(`this.props`, this.props);
16+
17+
if (this.props.dataSourceOptions.status === "available") {
18+
console.log(
19+
this.props.dataSourceOptions.items?.map(item => {
20+
console.log(`item`, this.props.titleAttr(item));
21+
})
22+
);
23+
return (
24+
<div>
25+
{this.props.dataSourceOptions.items?.map(item => {
26+
return (
27+
<div>
28+
<span onClick={() => this.click(this.props.titleAttr(item).value)}>
29+
{this.props.titleAttr(item).value}
30+
</span>
31+
</div>
32+
);
33+
})}
34+
</div>
35+
);
36+
} else {
37+
return <HelloWorldSample sampleText={this.props.sampleText ? this.props.sampleText : "World"} />;
38+
}
1139
}
1240
}
41+
42+
// call change on each select
43+
44+
// On Close of drop down

packages/web-widgets/auto-complete-widget/src/Autocompletewidget.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,17 @@
2323
<attributeType name="String"/>
2424
</attributeTypes>
2525
</property>
26+
<property key="volatileDate" type="attribute" required="false" onChange="onClick">
27+
<caption>Editable date</caption>
28+
<description>This attribute is used when a user clicks on a date in the calendar</description>
29+
<attributeTypes>
30+
<attributeType name="String"/>
31+
</attributeTypes>
32+
</property>
33+
<property key="onClick" type="action">
34+
<caption>On click</caption>
35+
<description>This action will not be called when secondary buttons are used.</description>
36+
</property>
2637
</propertyGroup>
2738
</properties>
2839
</widget>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/**
2+
* This file was generated from Autocompletewidget.xml
3+
* WARNING: All changes made to this file will be overwritten
4+
* @author Mendix UI Content Team
5+
*/
6+
import { CSSProperties } from "react";
7+
import { ActionValue, EditableValue, ListValue, ListAttributeValue } from "mendix";
8+
9+
export interface AutocompletewidgetContainerProps {
10+
name: string;
11+
class: string;
12+
style?: CSSProperties;
13+
tabIndex?: number;
14+
sampleText: string;
15+
dataSourceOptions: ListValue;
16+
titleAttr: ListAttributeValue<string>;
17+
volatileDate?: EditableValue<string>;
18+
onClick?: ActionValue;
19+
}
20+
21+
export interface AutocompletewidgetPreviewProps {
22+
class: string;
23+
style: string;
24+
sampleText: string;
25+
dataSourceOptions: {} | null;
26+
titleAttr: string;
27+
volatileDate: string;
28+
onClick: {} | null;
29+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const base = require("@mendix/pluggable-widgets-tools/configs/eslint.ts.base.json");
2+
3+
module.exports = {
4+
...base
5+
};
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
* text=auto
2+
*.ts text eol=lf
3+
*.tsx text eol=lf
4+
*.js text eol=lf
5+
*.jsx text eol=lf
6+
*.css text eol=lf
7+
*.scss text eol=lf
8+
*.json text eol=lf
9+
*.xml text eol=lf
10+
*.md text eol=lf
11+
*.gitattributes eol=lf
12+
*.gitignore eol=lf
13+
*.png binary
14+
*.jpg binary
15+
*.gif binary
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
dist/
2+
node_modules/
3+
tests/testProject/
4+
*.log
5+
.env
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
tests/testProject/
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
The Apache License v2.0
2+
3+
Copyright 2020 Mendix Technology BV
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.

0 commit comments

Comments
 (0)