aberdeen 1.8.0 → 1.10.0
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/README.md +29 -29
- package/dist/aberdeen.d.ts +194 -149
- package/dist/aberdeen.js +43 -7
- package/dist/aberdeen.js.map +3 -3
- package/dist/route.d.ts +2 -2
- package/dist/route.js +24 -24
- package/dist/route.js.map +3 -3
- package/dist-min/aberdeen.js +8 -8
- package/dist-min/aberdeen.js.map +3 -3
- package/dist-min/route.js +2 -2
- package/dist-min/route.js.map +3 -3
- package/package.json +1 -1
- package/skill/SKILL.md +245 -245
- package/skill/aberdeen.md +2306 -248
- package/skill/dispatcher.md +6 -6
- package/skill/prediction.md +3 -3
- package/skill/route.md +19 -19
- package/skill/transitions.md +3 -3
- package/src/aberdeen.ts +241 -189
- package/src/route.ts +26 -26
package/README.md
CHANGED
|
@@ -30,24 +30,24 @@ Aberdeen wraps your state in ES6 `Proxy` objects for fine-grained property acces
|
|
|
30
30
|
First, let's start with the obligatory reactive counter example. If you're reading this on [the official website](https://aberdeenjs.org) you should see a working demo below the code, and an 'edit' button in the top-right corner of the code, to play around.
|
|
31
31
|
|
|
32
32
|
```javascript
|
|
33
|
-
import
|
|
33
|
+
import A from 'aberdeen';
|
|
34
34
|
|
|
35
35
|
// Define some state as a proxied (observable) object
|
|
36
|
-
const state = proxy({question: "How many roads must a man walk down?", answer: 42});
|
|
36
|
+
const state = A.proxy({question: "How many roads must a man walk down?", answer: 42});
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
A('h3', () => {
|
|
39
39
|
// This function reruns whenever the question or the answer changes
|
|
40
|
-
|
|
40
|
+
A('text=', `${state.question} ↪ ${state.answer || 'Blowing in the wind'}`)
|
|
41
41
|
});
|
|
42
42
|
|
|
43
43
|
// Two-way bind state.question to an <input>
|
|
44
|
-
|
|
44
|
+
A('input placeholder=Question bind=', A.ref(state, 'question'))
|
|
45
45
|
|
|
46
46
|
// Allow state.answer to be modified using both an <input> and buttons
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
A('div.row margin-top:1em', () => {
|
|
48
|
+
A('button text=- click=', () => state.answer--);
|
|
49
|
+
A('input type=number bind=', A.ref(state, 'answer'))
|
|
50
|
+
A('button text=+ click=', () => state.answer++);
|
|
51
51
|
});
|
|
52
52
|
```
|
|
53
53
|
|
|
@@ -63,7 +63,7 @@ Okay, next up is a somewhat more complex app - a todo-list with the following be
|
|
|
63
63
|
Pfew.. now let's look at the code:
|
|
64
64
|
|
|
65
65
|
```typescript
|
|
66
|
-
import
|
|
66
|
+
import A from "aberdeen";
|
|
67
67
|
import {grow, shrink} from "aberdeen/transitions";
|
|
68
68
|
|
|
69
69
|
// We'll use a simple class to store our data.
|
|
@@ -74,19 +74,19 @@ class TodoItem {
|
|
|
74
74
|
|
|
75
75
|
// The top-level user interface.
|
|
76
76
|
function drawMain() {
|
|
77
|
-
// Add some initial items. We'll wrap a proxy() around it!
|
|
78
|
-
let items: TodoItem[] = proxy([
|
|
77
|
+
// Add some initial items. We'll wrap a A.proxy() around it!
|
|
78
|
+
let items: TodoItem[] = A.proxy([
|
|
79
79
|
new TodoItem('Make todo-list demo', true),
|
|
80
80
|
new TodoItem('Learn Aberdeen', false),
|
|
81
81
|
]);
|
|
82
82
|
|
|
83
83
|
// Draw the list, ordered by label.
|
|
84
|
-
onEach(items, drawItem, item => item.label);
|
|
84
|
+
A.onEach(items, drawItem, item => item.label);
|
|
85
85
|
|
|
86
86
|
// Add item and delete checked buttons.
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
87
|
+
A('div.row', () => {
|
|
88
|
+
A('button text=+ click=', () => items.push(new TodoItem("")));
|
|
89
|
+
A('button.outline text="Delete checked" click=', () => {
|
|
90
90
|
for(let idx in items) {
|
|
91
91
|
if (items[idx].done) delete items[idx];
|
|
92
92
|
}
|
|
@@ -97,48 +97,48 @@ function drawMain() {
|
|
|
97
97
|
// Called for each todo list item.
|
|
98
98
|
function drawItem(item) {
|
|
99
99
|
// Items without a label open in editing state.
|
|
100
|
-
// Note that we're creating this proxy outside the `div.row` scope
|
|
100
|
+
// Note that we're creating this A.proxy outside the `div.row` scope
|
|
101
101
|
// create below, so that it will persist when that state reruns.
|
|
102
|
-
let editing: {value: boolean} = proxy(item.label == '');
|
|
102
|
+
let editing: {value: boolean} = A.proxy(item.label == '');
|
|
103
103
|
|
|
104
|
-
|
|
104
|
+
A('div.row', todoItemStyle, 'create=', grow, 'destroy=', shrink, () => {
|
|
105
105
|
// Conditionally add a class to `div.row`, based on item.done
|
|
106
|
-
|
|
106
|
+
A({".done": A.ref(item,'done')});
|
|
107
107
|
|
|
108
108
|
// The checkmark is hidden using CSS
|
|
109
|
-
|
|
109
|
+
A('div.checkmark text=✅');
|
|
110
110
|
|
|
111
111
|
if (editing.value) {
|
|
112
112
|
// Proxied string to hold label while being edited.
|
|
113
|
-
const labelCopy = proxy(item.label);
|
|
113
|
+
const labelCopy = A.proxy(item.label);
|
|
114
114
|
function save() {
|
|
115
115
|
editing.value = false;
|
|
116
116
|
item.label = labelCopy.value;
|
|
117
117
|
}
|
|
118
118
|
// Label <input>. Save using enter or button.
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
119
|
+
A('input placeholder=Label bind=', labelCopy, 'keydown=', e => e.key==='Enter' && save());
|
|
120
|
+
A('button.outline text=Cancel click=', () => editing.value = false);
|
|
121
|
+
A('button text=Save click=', save);
|
|
122
122
|
} else {
|
|
123
123
|
// Label as text.
|
|
124
|
-
|
|
124
|
+
A('p text=', item.label);
|
|
125
125
|
|
|
126
126
|
// Edit icon, if not done.
|
|
127
127
|
if (!item.done) {
|
|
128
|
-
|
|
128
|
+
A('a text=Edit click=', e => {
|
|
129
129
|
editing.value = true;
|
|
130
130
|
e.stopPropagation(); // We don't want to toggle as well.
|
|
131
131
|
});
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
// Clicking a row toggles done.
|
|
135
|
-
|
|
135
|
+
A('cursor:pointer click=', () => item.done = !item.done);
|
|
136
136
|
}
|
|
137
137
|
});
|
|
138
138
|
}
|
|
139
139
|
|
|
140
140
|
// Insert some component-local CSS, specific for this demo.
|
|
141
|
-
const todoItemStyle = insertCss({
|
|
141
|
+
const todoItemStyle = A.insertCss({
|
|
142
142
|
"&": "mb:0.5rem",
|
|
143
143
|
".checkmark": "opacity:0.2",
|
|
144
144
|
"&.done": "text-decoration:line-through",
|