Skip to content

Commit

Permalink
New Data New bind
Browse files Browse the repository at this point in the history
dd-model -> bind
  • Loading branch information
eirikb committed Oct 6, 2021
1 parent bb23017 commit cc1581b
Show file tree
Hide file tree
Showing 10 changed files with 13,144 additions and 104 deletions.
2 changes: 1 addition & 1 deletion examples/dd-model/app.tsx → examples/bind/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const view = (
<div>
<div>Hello, {don(path().hello)}</div>
<div>
<input type="text" dd-model="hello" />
<input type="text" bind="hello" />
</div>
</div>
);
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion examples/pathifier-on/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const view = (
<button id="desc" onClick={() => (data.desc = !data.desc)}>
Toggle desc
</button>
<input type="text" placeholder="filter" dd-model="filter" />
<input type="text" placeholder="filter" bind="filter" />

<ul>
{don(path().users)
Expand Down
13,092 changes: 13,065 additions & 27 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@
"typescript": "^4.3.2"
},
"dependencies": {
"@eirikb/data": "^5.0.1"
"@eirikb/data": "^5.1.0"
}
}
7 changes: 3 additions & 4 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ Output:

### Automatic binding

[app.tsx](./examples/dd-model/app.tsx):
[app.tsx](./examples/bind/app.tsx):
```tsx
interface Data {
hello: string;
Expand All @@ -320,14 +320,14 @@ const view = (
<div>
<div>Hello, {don(path().hello)}</div>
<div>
<input type="text" dd-model="hello" />
<input type="text" bind="hello" />
</div>
</div>
);
```
Output:

![dd-model](readme/img/dd-model.gif)
![bind](readme/img/bind.gif)

## Pathifier

Expand Down Expand Up @@ -503,4 +503,3 @@ const view = (
init(document.body, view);
```


4 changes: 2 additions & 2 deletions readme/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,10 @@ ${await run('data-attributes', async ({ snapshot, page }) => {
### Automatic binding
${readCode('dd-model/app.tsx')}
${readCode('bind/app.tsx')}
Output:
${await run('dd-model', async ({ snapshot, page }) => {
${await run('bind', async ({ snapshot, page }) => {
await snapshot(1);
await page.click('input', { clickCount: 3 });
for (const c of 'there'.split('')) {
Expand Down
2 changes: 1 addition & 1 deletion src/dd-props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default (

if (props) {
const propsAsAny = props as any;
const model = propsAsAny['dd-model'];
const model = propsAsAny['bind'];
if (model) {
onChange((value: any) => data.set(model, value));
let ref: string = '';
Expand Down
6 changes: 3 additions & 3 deletions test/godmode.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ test('godMode 2', async t => {
init(
element,
<div>
{don('users.$.*').map(user => (
{don('users.$.*').map<any>((user: any) => (
<b>{user.name}</b>
))}
</div>
Expand All @@ -67,7 +67,7 @@ test('godMode 3', async t => {
init(
element,
<div>
{don('users.$.*').map(user => (
{don('users.$.*').map((user: any) => (
<b>{user.name}</b>
))}
</div>
Expand All @@ -88,7 +88,7 @@ test('godMode 4', async t => {
init(
element,
<div>
{don('users.$.*').map(user => (
{don('users.$.*').map((user: any) => (
<b>{user.name}</b>
))}
</div>
Expand Down
Loading

0 comments on commit cc1581b

Please sign in to comment.