aberdeen 1.9.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 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 {$, proxy, ref} from 'aberdeen';
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
- $('h3', () => {
38
+ A('h3', () => {
39
39
  // This function reruns whenever the question or the answer changes
40
- $('text=', `${state.question} ↪ ${state.answer || 'Blowing in the wind'}`)
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
- $('input placeholder=Question bind=', ref(state, 'question'))
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
- $('div.row margin-top:1em', () => {
48
- $('button text=- click=', () => state.answer--);
49
- $('input type=number bind=', ref(state, 'answer'))
50
- $('button text=+ click=', () => state.answer++);
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 {$, proxy, onEach, insertCss, peek, unproxy, ref} from "aberdeen";
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
- $('div.row', () => {
88
- $('button text=+ click=', () => items.push(new TodoItem("")));
89
- $('button.outline text="Delete checked" click=', () => {
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
- $('div.row', todoItemStyle, 'create=', grow, 'destroy=', shrink, () => {
104
+ A('div.row', todoItemStyle, 'create=', grow, 'destroy=', shrink, () => {
105
105
  // Conditionally add a class to `div.row`, based on item.done
106
- $({".done": ref(item,'done')});
106
+ A({".done": A.ref(item,'done')});
107
107
 
108
108
  // The checkmark is hidden using CSS
109
- $('div.checkmark text=✅');
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
- $('input placeholder=Label bind=', labelCopy, 'keydown=', e => e.key==='Enter' && save());
120
- $('button.outline text=Cancel click=', () => editing.value = false);
121
- $('button text=Save click=', save);
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
- $('p text=', item.label);
124
+ A('p text=', item.label);
125
125
 
126
126
  // Edit icon, if not done.
127
127
  if (!item.done) {
128
- $('a text=Edit click=', e => {
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
- $('cursor:pointer click=', () => item.done = !item.done);
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",