aberdeen 1.6.0 → 1.7.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/skill/aberdeen.md CHANGED
@@ -1,4 +1,4 @@
1
- [**Aberdeen v1.6.0**](README.md)
1
+ [**Aberdeen v1.7.0**](README.md)
2
2
 
3
3
  ***
4
4
 
@@ -10,7 +10,7 @@
10
10
 
11
11
  ### PromiseProxy
12
12
 
13
- Defined in: [aberdeen.ts:1315](https://github.com/vanviegen/aberdeen/blob/6b79c7fce769810bdcbd326b8ee6ef1c8e1fc011/src/aberdeen.ts#L1315)
13
+ Defined in: [aberdeen.ts:1360](https://github.com/vanviegen/aberdeen/blob/876d65e85fa77c9453fc72e223d2239e9c745656/src/aberdeen.ts#L1360)
14
14
 
15
15
  When `proxy` is called with a Promise, the returned object has this shape.
16
16
 
@@ -26,7 +26,7 @@ When `proxy` is called with a Promise, the returned object has this shape.
26
26
 
27
27
  > **busy**: `boolean`
28
28
 
29
- Defined in: [aberdeen.ts:1319](https://github.com/vanviegen/aberdeen/blob/6b79c7fce769810bdcbd326b8ee6ef1c8e1fc011/src/aberdeen.ts#L1319)
29
+ Defined in: [aberdeen.ts:1364](https://github.com/vanviegen/aberdeen/blob/876d65e85fa77c9453fc72e223d2239e9c745656/src/aberdeen.ts#L1364)
30
30
 
31
31
  True if the promise is still pending, false if it has resolved or rejected.
32
32
 
@@ -34,7 +34,7 @@ True if the promise is still pending, false if it has resolved or rejected.
34
34
 
35
35
  > `optional` **error**: `any`
36
36
 
37
- Defined in: [aberdeen.ts:1327](https://github.com/vanviegen/aberdeen/blob/6b79c7fce769810bdcbd326b8ee6ef1c8e1fc011/src/aberdeen.ts#L1327)
37
+ Defined in: [aberdeen.ts:1372](https://github.com/vanviegen/aberdeen/blob/876d65e85fa77c9453fc72e223d2239e9c745656/src/aberdeen.ts#L1372)
38
38
 
39
39
  If the promise has rejected, this contains the rejection error.
40
40
 
@@ -42,7 +42,7 @@ If the promise has rejected, this contains the rejection error.
42
42
 
43
43
  > `optional` **value**: `T`
44
44
 
45
- Defined in: [aberdeen.ts:1323](https://github.com/vanviegen/aberdeen/blob/6b79c7fce769810bdcbd326b8ee6ef1c8e1fc011/src/aberdeen.ts#L1323)
45
+ Defined in: [aberdeen.ts:1368](https://github.com/vanviegen/aberdeen/blob/876d65e85fa77c9453fc72e223d2239e9c745656/src/aberdeen.ts#L1368)
46
46
 
47
47
  If the promise has resolved, this contains the resolved value.
48
48
 
@@ -52,7 +52,7 @@ If the promise has resolved, this contains the resolved value.
52
52
 
53
53
  > `const` **cssVars**: `Record`\<`string`, `string`\>
54
54
 
55
- Defined in: [aberdeen.ts:1737](https://github.com/vanviegen/aberdeen/blob/6b79c7fce769810bdcbd326b8ee6ef1c8e1fc011/src/aberdeen.ts#L1737)
55
+ Defined in: [aberdeen.ts:1772](https://github.com/vanviegen/aberdeen/blob/876d65e85fa77c9453fc72e223d2239e9c745656/src/aberdeen.ts#L1772)
56
56
 
57
57
  A reactive object containing CSS variable definitions.
58
58
 
@@ -91,7 +91,7 @@ $('div mt:$3'); // Sets margin-top to var(--m3)
91
91
 
92
92
  > `const` **NO\_COPY**: *typeof* [`NO_COPY`](#no_copy)
93
93
 
94
- Defined in: [aberdeen.ts:1701](https://github.com/vanviegen/aberdeen/blob/6b79c7fce769810bdcbd326b8ee6ef1c8e1fc011/src/aberdeen.ts#L1701)
94
+ Defined in: [aberdeen.ts:1736](https://github.com/vanviegen/aberdeen/blob/876d65e85fa77c9453fc72e223d2239e9c745656/src/aberdeen.ts#L1736)
95
95
 
96
96
  A symbol that can be added to an object to prevent it from being cloned by [clone](#clone) or [copy](#copy).
97
97
  This is useful for objects that should be shared by reference. That also mean that their contents won't
@@ -103,7 +103,7 @@ be observed for changes.
103
103
 
104
104
  > **$**(...`args`): `undefined` \| `Element`
105
105
 
106
- Defined in: [aberdeen.ts:2079](https://github.com/vanviegen/aberdeen/blob/6b79c7fce769810bdcbd326b8ee6ef1c8e1fc011/src/aberdeen.ts#L2079)
106
+ Defined in: [aberdeen.ts:2156](https://github.com/vanviegen/aberdeen/blob/876d65e85fa77c9453fc72e223d2239e9c745656/src/aberdeen.ts#L2156)
107
107
 
108
108
  The core function for building reactive user interfaces in Aberdeen. It creates and inserts new DOM elements
109
109
  and sets attributes/properties/event listeners on DOM elements. It does so in a reactive way, meaning that
@@ -117,42 +117,66 @@ changes will be (mostly) undone when the current *scope* is destroyed or will be
117
117
 
118
118
  Any number of arguments can be given. How they're interpreted depends on their types:
119
119
 
120
- - `string`: Strings can be used to create and insert new elements, set classnames for the *current* element, and add text to the current element.
121
- The format of a string is: (**tag** | `.` **class** | **key**=**val** | **key**="**long val**")* ('#' **text** | **key**=)?
122
- So there can be:
123
- - Any number of **tag** element, like `h1` or `div`. These elements are created, added to the *current* element, and become the new *current* element for the rest of this `$` function execution.
124
- - Any number of CSS classes prefixed by `.` characters. These classes will be added to the *current* element. Optionally, CSS classes can be appended to a **tag** without a space. So both `div.myclass` and `div .myclass` are valid and do the same thing.
125
- - Any number of key/value pairs with string values, like `placeholder="Your name"` or `data-id=123`. These will be handled according to the rules specified for `object`, below, but with the caveat that values can only be strings. The quotes around string values are optional, unless the value contains spaces. It's not possible to escape quotes within the value. If you want to do that, or if you have user-provided values, use the `object` syntax (see below) or end your string with `key=` followed by the data as a separate argument (see below).
126
- - The string may end in a '#' followed by text, which will be added as a TextNode to the *current* element. The text ranges til the end of the string, and may contain any characters, including spaces and quotes.
127
- - Alternatively, the string may end in a key followed by an '=' character, in which case the value is expected as a separate argument. The key/value pair is set according to the rules specified for `object` below. This is useful when the value is not a string or contains spaces or user data. Example: `$('button text="Click me" click=', () => alert('Clicked!'))` or `$('input.value=', someUserData, "placeholder=", "Type your stuff")`.
128
- - `function`: When a function (without argument nor a return value) is passed in, it will be reactively executed in its own observer scope, preserving the *current element*. So any `$()` invocations within this function will create DOM elements with our *current* element as parent. If the function reads observable data, and that data is changed later on, the function we re-execute (after side effects, such as DOM modifications through `$`, have been cleaned - see also [clean](#clean)).
129
- - `object`: When an object is passed in, its key-value pairs are used to modify the *current* element in the following ways...
130
- - `{<attrName>: any}`: The common case is setting the value as an HTML attribute named key. So `{placeholder: "Your name"}` would add `placeholder="Your name"` to the current HTML element.
131
- - `{<propName>: boolean}` or `{value: any}` or `{selectedIndex: number}`: If the value is a boolean, or if the key is `value` or `selectedIndex`, it is set on the `current` element as a DOM property instead of an HTML attribute. For example `{checked: true}` would do `el.checked = true` for the *current* element.
132
- - `{".class": boolean}`: If the key starts with a `.` character, its either added to or removed from the *current* element as a CSS class, based on the truthiness of the value. So `{".hidden": hide}` would toggle the `hidden` CSS class.
133
- - `{<eventName>: function}`: If the value is a `function` it is set as an event listener for the event with the name given by the key. For example: `{click: myClickHandler}`.
134
- - `{$<styleProp>: value}`: If the key starts with a `$` character, set a CSS style property with the name of the rest of the key to the given value. Example: `{$backgroundColor: 'red'}`.
135
- - `{create: string}`: Add the value string as a CSS class to the *current* element, *after* the browser has finished doing a layout pass. This behavior only triggers when the scope setting the `create` is the top-level scope being (re-)run. This allows for creation transitions, without triggering the transitions for deeply nested elements being drawn as part of a larger component. The string may also contain multiple dot-separated CSS classes, such as `.fade.grow`.
136
- - `{destroy: string}`: When the *current* element is a top-level element to be removed (due to reactivity cleanup), actual removal from the DOM is delayed by 2 seconds, and in the mean time the value string is added as a CSS class to the element, allowing for a deletion transition. The string may also contain multiple dot-separated CSS classes, such as `.fade.shrink`.
137
- - `{create: function}` and `{destroy: function}`: The function is invoked when the *current* element is the top-level element being created/destroyed. It can be used for more involved creation/deletion animations. In case of `destroy`, the function is responsible for actually removing the element from the DOM (eventually). See `transitions.ts` in the Aberdeen source code for some examples.
138
- - `{bind: <obsValue>}`: Create a two-way binding element between the `value` property of the given observable (proxy) variable, and the *current* input element (`<input>`, `<select>` or `<textarea>`). This is often used together with [ref](#ref), in order to use properties other than `.value`.
139
- - `{<any>: <obsvalue>}`: Create a new observer scope and read the `value` property of the given observable (proxy) variable from within it, and apply the contained value using any of the other rules in this list. Example:
140
- ```typescript
141
- const myColor = proxy('red');
142
- $('p#Test', {$color: myColor, click: () => myColor.value = 'yellow'})
143
- // Clicking the text will cause it to change color without recreating the <p> itself
144
- ```
145
- This is often used together with [ref](#ref), in order to use properties other than `.value`.
146
- - `{text: string|number}`: Add the value as a `TextNode` to the *current* element.
147
- - `{html: string}`: Add the value as HTML to the *current* element. This should only be used in exceptional situations. And of course, beware of XSS.
148
- - `Node`: If a DOM Node (Element or TextNode) is passed in, it is added as a child to the *current* element. If the Node is an Element, it becomes the new *current* element for the rest of this `$` function execution.
120
+ ### String arguments
121
+ Strings can be used to create and insert new elements, set classnames for the *current* element, and add text to the current element.
122
+ The format of a string is: (**tag** | `.` **class** | **key**[=:]**val** | **key**[=:]"**val containing spaces**")* ('#' **text** | **key**[=:])?
123
+
124
+ So a string may consist of any number of...
125
+ - **tag** elements, like `h1` or `div`. These elements are created, added to the *current* element, and become the new *current* element for the rest of this `$` function execution.
126
+ - CSS classes prefixed by `.` characters. These classes will be added to the *current* element. Optionally, CSS classes can be appended to a **tag** without a space. So both `div.myclass` and `div .myclass` are valid and do the same thing.
127
+ - Property key/value pairs, like `type=password`, `placeholder="Your name"` or `data-id=123`. When the value contains spaces, it needs to be quoted with either "double quotes", 'single quotes' or `backticks`. Quotes within quoted values cannot be escaped (see the next rule for a solution). Key/value pairs will be handled according to *Property rules* below, but with the caveat that values can only be strings.
128
+ - CSS key/value pairs using two syntaxes:
129
+ - **Short form** `key:value` (no space after colon): The value ends at the next whitespace. Example: `m:$3 bg:red r:8px`
130
+ - **Long form** `key: value;` (space after colon): The value continues until a semicolon. Example: `box-shadow: 2px 0 6px black; transition: all 0.3s ease;`
131
+
132
+ Both forms support CSS shortcuts (see below). You can mix them: `m:$3 box-shadow: 0 2px 4px rgba(0,0,0,0.2); bg:$cardBg`
133
+ The elements must be separated by spaces, except before a `.cssClass` if it is preceded by either **tag** or another CSS class.
134
+
135
+ And a string may end in...
136
+ - A '#' followed by text, which will be added as a `TextNode` to the *current* element. The text ranges til the end of the string, and may contain any characters, including spaces and quotes.
137
+ - A key followed by an '=' character, in which case the value is expected as a separate argument. The key/value pair is set according to the *Property rules* below. This is useful when the value is not a string or contains spaces or user data. Example: `$('button text="Click me" click=', () => alert('Clicked!'))` or `$('input.value=', someUserData, "placeholder=", "Type your stuff")`. In case the value is a proxied object, its `.value` property will be applied reactively without needing to rerender the parent scope.
138
+ - A key followed by a ':' character (with no value), in which case the value is expected as a separate argument. The value is treated as a CSS value to be set inline on the *current* element. Example: `$('div margin-top:', someValueInPx)`. In case the value is a proxied object, its `.value` property will be applied reactively without needing to rerender the parent scope.
139
+
140
+ ### Function arguments
141
+ When a function (without arguments nor a return value) is passed in, it will be reactively executed in its own observer scope, preserving the *current* element. So any `$()` invocations within this function will add child elements to or set properties on that element. If the function reads observable data, and that data is changed later on, the function we re-execute (after side effects, such as DOM modifications through `$`, have been cleaned - see also [clean](#clean)).
142
+
143
+ ### Object arguments
144
+ When an object is passed in, its key-value pairs are used to modify the *current* element according to the *Property rules* below, *unless* the key starts with a `$` character, in which case that character is stripped of and the key/value pair is treated as a CSS property, subject to the *CSS shortcuts* below. In case a value is a proxied object, its `.value` property will be applied reactively without needing to rerender the parent scope. In most cases, the string notation (`key=` and `key:`) is preferred over this object notation, for readability.
145
+
146
+ ### DOM node arguments
147
+ When a DOM Node (Element or TextNode) is passed in, it is added as a child to the *current* element. If the Node is an Element, it becomes the new *current* element for the rest of this `$` function execution.
148
+
149
+ ### Property rules
150
+ - **Attribute:** The common case is setting the value as an HTML attribute named key. For example `$('input placeholder=Name')` results in `<input placeholder="Name">`.
151
+ - **Event listener:** If the value is a `function` it is set as an event listener for the event with the name given by the key. For example: $('button text=Press! click=', () => alert('Clicked!'))`. The event listener will be removed when the current scope is destroyed.
152
+ - **DOM property:** When the value is a boolean, or the key is `"value"` or `"selectedIndex"`, it is set on the `current` element as a DOM property instead of an HTML attribute. For example `$('checked=', true)` would do `el.checked = true` for the *current* element.
153
+ - **Conditional CSS class:** If the key starts with a `.` character, its either added to or removed from the *current* element as a CSS class, based on the truthiness of the value. So `$('.hidden=', isHidden)` would toggle the `hidden` CSS class. This only works if the `=` is the last character of the string, and the next argument is the value. Its common for the value to be a proxied object, in which case its `.value` is reactively applied without needing to rerender the parent scope.
154
+ - **Create transition:** When the key is `"create"`, the value will be added as a CSS class to the *current* element immediately, and then removed right after the browser has finished doing a layout pass. This behavior only triggers when the scope setting the `create` is the top-level scope being (re-)run. This allows for creation transitions, without triggering the transitions for deeply nested elements being drawn as part of a larger component. The string may also contain multiple dot-separated CSS classes, such as `.fade.grow`. The initial dot is optional. Alternatively, to allow for more complex transitions, the value may be a function that receives the `HTMLElement` being created as its only argument. It is *only* called if this is the top-level element being created in this scope run. See `transitions.ts` in the Aberdeen source code for some examples.
155
+ - **Destroy transition:** When the key is `"destroy"` the value will be used to apply a CSS transition if the *current* element is later on removed from the DOM and is the top-level element to be removed. This happens as follows: actual removal from the DOM is delayed by 2 seconds, and in the mean-time the value string is added as a CSS class to the element, allowing for a deletion transition. The string may also contain multiple dot-separated CSS classes, such as `.fade.shrink`. The initial dot is optional. Alternatively, to allow for more complex transitions, the value may be a function that receives the `HTMLElement` to be removed from the DOM as its only argument. This function may perform any transitions and is then itself responsible for eventually removing the element from the DOM. See `transitions.ts` in the Aberdeen source code for some examples.
156
+ - **Two-way data binding:** When the key is `"bind"` a two-way binding between the `.value` property of the given proxied object, and the *current* input element (`<input>`, `<select>` or `<textarea>`) is created. This is often used together with {@link ref}, in order to use properties other than `.value`.
157
+ - **Text:**: If the key is `"text"`, the value will be appended as a `TextNode` to the *current* element. The same can also be done with the `#` syntax in string arguments, though `text=` allows additional properties to come after in the same string: `$('button text=Hello click=', alert)`.
158
+ - **Unsafe HTML:** When the key is `"html"`, the value will be added as HTML to the *current* element. This should only be used in exceptional situations. Beware of XSS! Never use this with untrusted user data.
159
+
160
+ ### CSS shortcuts
161
+ For conciseness, Aberdeen supports some CSS shortcuts when setting CSS properties.
162
+ | Shortcut | Expands to |
163
+ |----------|------------|
164
+ | `m`, `mt`, `mb`, `ml`, `mr` | `margin`, `margin-top`, `margin-bottom`, `margin-left`, `margin-right` |
165
+ | `mv`, `mh` | Vertical (top+bottom) or horizontal (left+right) margins |
166
+ | `p`, `pt`, `pb`, `pl`, `pr` | `padding`, `padding-top`, `padding-bottom`, `padding-left`, `padding-right` |
167
+ | `pv`, `ph` | Vertical or horizontal padding |
168
+ | `w`, `h` | `width`, `height` |
169
+ | `bg` | `background` |
170
+ | `fg` | `color` |
171
+ | `r` | `border-radius` |
172
+
173
+ Also, when the value is a string starting with `$`, it is treated as a reference to a CSS variable, expanding to `var(--variableName)`. For numeric variable names (which can't be used directly as CSS custom property names), Aberdeen prefixes them with `m`, so `$3` expands to `var(--m3)`. This is primarily intended for use with [setSpacingCssVars](#setspacingcssvars), which initializes spacing variables named `0` through `12` with an exponential spacing scale.
149
174
 
150
175
  #### Returns
151
176
 
152
177
  `undefined` \| `Element`
153
178
 
154
- The most inner DOM element that was created (not counting text nodes nor elements created by content functions),
155
- or undefined if no elements were created.
179
+ The most inner DOM element that was created (not counting text nodes nor elements created by content functions), or the current element if no new element was created. You should normally not need to use the return value - use this function's DOM manipulation abilities instead. One valid use case is when integrating with non-Aberdeen code that requires a reference to a DOM element.
156
180
 
157
181
  #### Examples
158
182
 
@@ -197,13 +221,20 @@ $(() => { // Reactive scope
197
221
  });
198
222
  ```
199
223
 
224
+ ```typescript
225
+ const myColor = proxy('red');
226
+ $('p text="The color is " text=', myColor, 'click=', () => myColor.value = 'yellow')
227
+ // Clicking the text will cause it to change color without recreating the <p> itself
228
+ ```
229
+ This is often used together with [ref](#ref), in order to use properties other than `.value`.
230
+
200
231
  ***
201
232
 
202
233
  ### clean()
203
234
 
204
235
  > **clean**(`cleaner`): `void`
205
236
 
206
- Defined in: [aberdeen.ts:2481](https://github.com/vanviegen/aberdeen/blob/6b79c7fce769810bdcbd326b8ee6ef1c8e1fc011/src/aberdeen.ts#L2481)
237
+ Defined in: [aberdeen.ts:2640](https://github.com/vanviegen/aberdeen/blob/876d65e85fa77c9453fc72e223d2239e9c745656/src/aberdeen.ts#L2640)
207
238
 
208
239
  Registers a cleanup function to be executed just before the current reactive scope
209
240
  is destroyed or redraws.
@@ -258,7 +289,7 @@ setInterval(() => myArray[rnd()] = rnd(), 1000);
258
289
 
259
290
  > **clone**\<`T`\>(`src`): `T`
260
291
 
261
- Defined in: [aberdeen.ts:1845](https://github.com/vanviegen/aberdeen/blob/6b79c7fce769810bdcbd326b8ee6ef1c8e1fc011/src/aberdeen.ts#L1845)
292
+ Defined in: [aberdeen.ts:1893](https://github.com/vanviegen/aberdeen/blob/876d65e85fa77c9453fc72e223d2239e9c745656/src/aberdeen.ts#L1893)
262
293
 
263
294
  Clone an (optionally proxied) object or array.
264
295
 
@@ -292,7 +323,7 @@ A new unproxied array or object (of the same type as `src`), containing a deep c
292
323
 
293
324
  > **copy**\<`T`\>(`dst`, `src`): `boolean`
294
325
 
295
- Defined in: [aberdeen.ts:1490](https://github.com/vanviegen/aberdeen/blob/6b79c7fce769810bdcbd326b8ee6ef1c8e1fc011/src/aberdeen.ts#L1490)
326
+ Defined in: [aberdeen.ts:1535](https://github.com/vanviegen/aberdeen/blob/876d65e85fa77c9453fc72e223d2239e9c745656/src/aberdeen.ts#L1535)
296
327
 
297
328
  Recursively copies properties or array items from `src` to `dst`.
298
329
  It's designed to work efficiently with reactive proxies created by [proxy](#proxy).
@@ -353,7 +384,7 @@ console.log(dest); // proxy({ a: 1, b: { e: 4 } })
353
384
 
354
385
  > **copy**\<`T`\>(`dst`, `dstKey`, `src`): `boolean`
355
386
 
356
- Defined in: [aberdeen.ts:1497](https://github.com/vanviegen/aberdeen/blob/6b79c7fce769810bdcbd326b8ee6ef1c8e1fc011/src/aberdeen.ts#L1497)
387
+ Defined in: [aberdeen.ts:1542](https://github.com/vanviegen/aberdeen/blob/876d65e85fa77c9453fc72e223d2239e9c745656/src/aberdeen.ts#L1542)
357
388
 
358
389
  Like above, but copies `src` into `dst[dstKey]`. This is useful if you're unsure if dst[dstKey]
359
390
  already exists (as the right type of object) or if you don't want to subscribe to dst[dstKey].
@@ -390,7 +421,7 @@ Optional key in `dst` to copy into.
390
421
 
391
422
  > **count**(`proxied`): `ValueRef`\<`number`\>
392
423
 
393
- Defined in: [aberdeen.ts:1012](https://github.com/vanviegen/aberdeen/blob/6b79c7fce769810bdcbd326b8ee6ef1c8e1fc011/src/aberdeen.ts#L1012)
424
+ Defined in: [aberdeen.ts:1057](https://github.com/vanviegen/aberdeen/blob/876d65e85fa77c9453fc72e223d2239e9c745656/src/aberdeen.ts#L1057)
394
425
 
395
426
  Reactively counts the number of properties in an objects.
396
427
 
@@ -435,7 +466,7 @@ items.z = 12;
435
466
 
436
467
  > **darkMode**(): `boolean`
437
468
 
438
- Defined in: [aberdeen.ts:1819](https://github.com/vanviegen/aberdeen/blob/6b79c7fce769810bdcbd326b8ee6ef1c8e1fc011/src/aberdeen.ts#L1819)
469
+ Defined in: [aberdeen.ts:1872](https://github.com/vanviegen/aberdeen/blob/876d65e85fa77c9453fc72e223d2239e9c745656/src/aberdeen.ts#L1872)
439
470
 
440
471
  Returns whether the user's browser prefers a dark color scheme.
441
472
 
@@ -457,14 +488,11 @@ import { darkMode, cssVars, $, mount } from 'aberdeen';
457
488
 
458
489
  // Reactively set colors based on browser preference
459
490
  $(() => {
460
- if (darkMode()) { // Optionally override this with user settings
461
- cssVars.bg = '#1a1a1a';
462
- cssVars.fg = '#e5e5e5';
463
- } else {
464
- cssVars.bg = '#ffffff';
465
- cssVars.fg = '#000000';
466
- }
491
+ cssVars.bg = darkMode() ? '#1a1a1a' : '#ffffff';
492
+ cssVars.fg = darkMode() ? '#e5e5e5' : '#000000';
467
493
  });
494
+
495
+ $('div bg:$bg fg:$fg p:1rem #Colors change based on system dark mode preference');
468
496
  ```
469
497
 
470
498
  ***
@@ -473,7 +501,7 @@ $(() => {
473
501
 
474
502
  > **derive**\<`T`\>(`func`): `ValueRef`\<`T`\>
475
503
 
476
- Defined in: [aberdeen.ts:2533](https://github.com/vanviegen/aberdeen/blob/6b79c7fce769810bdcbd326b8ee6ef1c8e1fc011/src/aberdeen.ts#L2533)
504
+ Defined in: [aberdeen.ts:2692](https://github.com/vanviegen/aberdeen/blob/876d65e85fa77c9453fc72e223d2239e9c745656/src/aberdeen.ts#L2692)
477
505
 
478
506
  Creates a reactive scope that automatically re-executes the provided function
479
507
  whenever any proxied data (created by [proxy](#proxy)) read during its last execution changes, storing
@@ -542,7 +570,7 @@ $('h3', () => {
542
570
 
543
571
  > **dump**\<`T`\>(`data`): `T`
544
572
 
545
- Defined in: [aberdeen.ts:2953](https://github.com/vanviegen/aberdeen/blob/6b79c7fce769810bdcbd326b8ee6ef1c8e1fc011/src/aberdeen.ts#L2953)
573
+ Defined in: [aberdeen.ts:3113](https://github.com/vanviegen/aberdeen/blob/876d65e85fa77c9453fc72e223d2239e9c745656/src/aberdeen.ts#L3113)
546
574
 
547
575
  Renders a live, recursive dump of a proxied data structure (or any value)
548
576
  into the DOM at the current [$](#) insertion point.
@@ -591,115 +619,104 @@ setTimeout(() => { state.user.kids++; state.items.push('c'); }, 2000);
591
619
 
592
620
  ***
593
621
 
594
- ### getParentElement()
595
-
596
- > **getParentElement**(): `Element`
597
-
598
- Defined in: [aberdeen.ts:2439](https://github.com/vanviegen/aberdeen/blob/6b79c7fce769810bdcbd326b8ee6ef1c8e1fc011/src/aberdeen.ts#L2439)
599
-
600
- Gets the parent DOM `Element` where nodes created by [$](#) would currently be inserted.
601
-
602
- This is context-dependent based on the current reactive scope (e.g., inside a [mount](#mount)
603
- call or a [$](#) element's render function).
604
-
605
- **Note:** While this provides access to the DOM element, directly manipulating it outside
606
- of Aberdeen's control is generally discouraged. Prefer reactive updates using [$](#).
607
-
608
- #### Returns
609
-
610
- `Element`
611
-
612
- The current parent `Element` for DOM insertion.
613
-
614
- #### Example
622
+ ### insertCss()
615
623
 
616
- ```typescript
617
- function thirdPartyLibInit(parentElement) {
618
- parentElement.innerHTML = "This element is managed by a <em>third party</em> lib."
619
- }
624
+ > **insertCss**(`style`): `string`
620
625
 
621
- $('div.box', () => {
622
- // Get the div.box element just created
623
- const containerElement = getParentElement();
624
- thirdPartyLibInit(containerElement);
625
- });
626
- ```
626
+ Defined in: [aberdeen.ts:2349](https://github.com/vanviegen/aberdeen/blob/876d65e85fa77c9453fc72e223d2239e9c745656/src/aberdeen.ts#L2349)
627
627
 
628
- ***
628
+ Inserts CSS rules into the document, scoping them with a unique class name.
629
629
 
630
- ### insertCss()
630
+ The `style` parameter can be either:
631
+ - A **concise style string** (for rules applying to the root class).
632
+ - An **object** where keys are selectors (with `&` representing the root class)
633
+ and values are concise style strings or nested objects. When the key does not contain `&`,
634
+ it is treated as a descendant selector. So `{p: "color:red"}` becomes `".AbdStlX p { color: red; }"` with `AbdStlX` being the generated class name.
631
635
 
632
- > **insertCss**(`style`, `global`): `string`
636
+ ### Concise Style Strings
633
637
 
634
- Defined in: [aberdeen.ts:2222](https://github.com/vanviegen/aberdeen/blob/6b79c7fce769810bdcbd326b8ee6ef1c8e1fc011/src/aberdeen.ts#L2222)
638
+ Concise style strings use two syntaxes (same as inline CSS in [$](#)):
639
+ - **Short form** `key:value` (no space after colon): The value ends at the next whitespace.
640
+ Example: `'m:$3 bg:red r:8px'`
641
+ - **Long form** `key: value;` (space after colon): The value continues until a semicolon.
642
+ Example: `'box-shadow: 2px 0 6px black; transition: all 0.3s ease;'`
635
643
 
636
- Inserts CSS rules into the document, scoping them with a unique class name.
644
+ Both forms can be mixed: `'m:$3 box-shadow: 0 2px 4px rgba(0,0,0,0.2); bg:$cardBg'`
637
645
 
638
- Takes a JavaScript object representation of CSS rules. camelCased property keys are
639
- converted to kebab-case (e.g., `fontSize` becomes `font-size`).
646
+ Supports the same CSS shortcuts as [$](#) and CSS variable references with `$` (e.g., `$primary`, `$3`).
640
647
 
641
648
  #### Parameters
642
649
 
643
650
  ##### style
644
651
 
645
- `object`
646
-
647
- An object where keys are CSS selectors (or camelCased properties) and values are
648
- CSS properties or nested rule objects.
649
- - Selectors are usually combined as a descendant-relationship (meaning just a space character) with their parent selector.
650
- - In case a selector contains a `&`, that character will be replaced by the parent selector.
651
- - Selectors will be split on `,` characters, each combining with the parent selector with *or* semantics.
652
- - Selector starting with `'@'` define at-rules like media queries. They may be nested within regular selectors.
653
-
654
- ##### global
652
+ A concise style string or a style object.
655
653
 
656
- `boolean` = `false`
657
-
658
- Deprecated! Use [insertGlobalCss](#insertglobalcss) instead.
654
+ `string` | `object`
659
655
 
660
656
  #### Returns
661
657
 
662
658
  `string`
663
659
 
664
- The unique class name prefix used for scoping (e.g., `.AbdStl1`). Use this
665
- prefix with [$](#) to apply the styles.
660
+ The unique class name prefix used for scoping (e.g., `.AbdStl1`).
661
+ Use this prefix with [$](#) to apply the styles.
666
662
 
667
- #### Example
663
+ #### Examples
668
664
 
669
665
  ```typescript
670
- const scopeClass = insertCss({
671
- color: 'red',
672
- padding: '10px',
673
- '&:hover': { // Use '&' for the root scoped selector
674
- backgroundColor: '#535'
675
- },
676
- '.child-element': { // Nested selector
677
- fontWeight: 'bold'
678
- },
679
- '@media (max-width: 600px)': {
680
- padding: '5px'
666
+ const cardClass = insertCss({
667
+ '&': 'bg:white p:$4 r:8px transition: background-color 0.3s;',
668
+ '&:hover': 'bg:#f5f5f5',
669
+ });
670
+
671
+ $('section', cardClass, () => {
672
+ $('p#Card content');
673
+ });
674
+ ```
675
+
676
+ ```typescript
677
+ const formClass = insertCss({
678
+ '&': 'bg:#0004 p:$3 r:$2',
679
+ button: {
680
+ '&': 'bg:$primary fg:white p:$2 r:4px cursor:pointer',
681
+ '&:hover': 'bg:$primaryHover',
682
+ '&:disabled': 'bg:#ccc cursor:not-allowed',
683
+ '.icon': 'display:inline-block mr:$1',
684
+ '@media (max-width: 600px)': 'p:$1 font-size:14px'
681
685
  }
682
686
  });
683
- // scopeClass might be ".AbdStl1"
684
687
 
685
- // Apply the styles
686
- $(scopeClass, () => { // Add class to the div
687
- $(`#Scoped content`);
688
- $('div.child-element#Child'); // .AbdStl1 .child-element rule applies
688
+ $('form', formClass, () => {
689
+ $('button', () => {
690
+ $('span.icon text=🔥');
691
+ $('#Click Me');
692
+ });
693
+ });
694
+ ```
695
+
696
+ ```typescript
697
+ const badge = insertCss({
698
+ '&::before': 'content: "★"; color:gold mr:$1',
699
+ '&': 'position:relative box-shadow: 0 2px 8px rgba(0,0,0,0.15);'
689
700
  });
701
+
702
+ $(badge + ' span#Product Name');
690
703
  ```
691
704
 
692
705
  ***
693
706
 
694
707
  ### insertGlobalCss()
695
708
 
696
- > **insertGlobalCss**(`style`): `string`
709
+ > **insertGlobalCss**(`style`): `void`
697
710
 
698
- Defined in: [aberdeen.ts:2250](https://github.com/vanviegen/aberdeen/blob/6b79c7fce769810bdcbd326b8ee6ef1c8e1fc011/src/aberdeen.ts#L2250)
711
+ Defined in: [aberdeen.ts:2473](https://github.com/vanviegen/aberdeen/blob/876d65e85fa77c9453fc72e223d2239e9c745656/src/aberdeen.ts#L2473)
699
712
 
700
- Inserts CSS rules globally.
713
+ Inserts CSS rules globally (unscoped).
701
714
 
702
715
  Works exactly like [insertCss](#insertcss), but without prefixing selectors with a unique class name.
716
+ This is useful for global resets, base styles, or styles that need to apply to the entire document.
717
+
718
+ Accepts the same concise style string syntax and CSS shortcuts as [insertCss](#insertcss).
719
+ See [insertCss](#insertcss) for detailed documentation on syntax and shortcuts.
703
720
 
704
721
  #### Parameters
705
722
 
@@ -707,25 +724,43 @@ Works exactly like [insertCss](#insertcss), but without prefixing selectors with
707
724
 
708
725
  `object`
709
726
 
727
+ Object with selectors as keys and concise CSS strings as values.
728
+
710
729
  #### Returns
711
730
 
712
- `string`
731
+ `void`
713
732
 
714
- #### Example
733
+ #### Examples
734
+
735
+ ```typescript
736
+ // Set up global styles using CSS shortcuts
737
+ insertGlobalCss({
738
+ "*": "m:0 p:0 box-sizing:border-box",
739
+ "body": "font-family: system-ui, sans-serif; m:0 p:$3 bg:#434 fg:#d0dafa",
740
+ "a": "text-decoration:none fg:#57f",
741
+ "a:hover": "text-decoration:underline",
742
+ "code": "font-family:monospace bg:#222 fg:#afc p:4px r:3px"
743
+ });
744
+
745
+ $('h2#Title without margins');
746
+ $('a#This is a link');
747
+ $('code#const x = 42;');
748
+ ```
715
749
 
716
750
  ```typescript
717
751
  insertGlobalCss({
718
- '*': {
719
- fontFamily: 'monospace',
720
- m: 0, // Using shortcut for margin
752
+ "html": "font-size:16px",
753
+ "body": "line-height:1.6",
754
+ "h1, h2, h3": "font-weight:600 mt:$4 mb:$2",
755
+ "@media (max-width: 768px)": {
756
+ "html": "font-size:14px",
757
+ "body": "p:$2"
721
758
  },
722
- 'a': {
723
- textDecoration: 'none',
724
- fg: "@primary", // Using foreground shortcut and CSS variable
759
+ "@media (prefers-color-scheme: dark)": {
760
+ "body": "bg:#1a1a1a fg:#e5e5e5",
761
+ "code": "bg:#2a2a2a"
725
762
  }
726
763
  });
727
-
728
- $('a#Styled link');
729
764
  ```
730
765
 
731
766
  ***
@@ -734,7 +769,7 @@ $('a#Styled link');
734
769
 
735
770
  > **invertString**(`input`): `string`
736
771
 
737
- Defined in: [aberdeen.ts:149](https://github.com/vanviegen/aberdeen/blob/6b79c7fce769810bdcbd326b8ee6ef1c8e1fc011/src/aberdeen.ts#L149)
772
+ Defined in: [aberdeen.ts:149](https://github.com/vanviegen/aberdeen/blob/876d65e85fa77c9453fc72e223d2239e9c745656/src/aberdeen.ts#L149)
738
773
 
739
774
  Creates a new string that has the opposite sort order compared to the input string.
740
775
 
@@ -783,7 +818,7 @@ onEach(users, (user) => {
783
818
 
784
819
  > **isEmpty**(`proxied`): `boolean`
785
820
 
786
- Defined in: [aberdeen.ts:956](https://github.com/vanviegen/aberdeen/blob/6b79c7fce769810bdcbd326b8ee6ef1c8e1fc011/src/aberdeen.ts#L956)
821
+ Defined in: [aberdeen.ts:997](https://github.com/vanviegen/aberdeen/blob/876d65e85fa77c9453fc72e223d2239e9c745656/src/aberdeen.ts#L997)
787
822
 
788
823
  Reactively checks if an observable array or object is empty.
789
824
 
@@ -885,7 +920,7 @@ users.u2.active = true;
885
920
 
886
921
  > **map**\<`K`, `IN`, `OUT`\>(`source`, `func`): `Map`\<`K`, `OUT`\>
887
922
 
888
- Defined in: [aberdeen.ts:2640](https://github.com/vanviegen/aberdeen/blob/6b79c7fce769810bdcbd326b8ee6ef1c8e1fc011/src/aberdeen.ts#L2640)
923
+ Defined in: [aberdeen.ts:2800](https://github.com/vanviegen/aberdeen/blob/876d65e85fa77c9453fc72e223d2239e9c745656/src/aberdeen.ts#L2800)
889
924
 
890
925
  When using a Map as `source`.
891
926
 
@@ -921,7 +956,7 @@ When using a Map as `source`.
921
956
 
922
957
  > **map**\<`IN`, `OUT`\>(`source`, `func`): `OUT`[]
923
958
 
924
- Defined in: [aberdeen.ts:2645](https://github.com/vanviegen/aberdeen/blob/6b79c7fce769810bdcbd326b8ee6ef1c8e1fc011/src/aberdeen.ts#L2645)
959
+ Defined in: [aberdeen.ts:2805](https://github.com/vanviegen/aberdeen/blob/876d65e85fa77c9453fc72e223d2239e9c745656/src/aberdeen.ts#L2805)
925
960
 
926
961
  When using an array as `source`.
927
962
 
@@ -953,7 +988,7 @@ When using an array as `source`.
953
988
 
954
989
  > **map**\<`IN`, `IN_KEY`, `OUT`\>(`source`, `func`): `Record`\<`string` \| `symbol`, `OUT`\>
955
990
 
956
- Defined in: [aberdeen.ts:2650](https://github.com/vanviegen/aberdeen/blob/6b79c7fce769810bdcbd326b8ee6ef1c8e1fc011/src/aberdeen.ts#L2650)
991
+ Defined in: [aberdeen.ts:2810](https://github.com/vanviegen/aberdeen/blob/876d65e85fa77c9453fc72e223d2239e9c745656/src/aberdeen.ts#L2810)
957
992
 
958
993
  When using an object as `source`.
959
994
 
@@ -993,13 +1028,11 @@ When using an object as `source`.
993
1028
 
994
1029
  > **merge**\<`T`\>(`dst`, `value`): `boolean`
995
1030
 
996
- Defined in: [aberdeen.ts:1540](https://github.com/vanviegen/aberdeen/blob/6b79c7fce769810bdcbd326b8ee6ef1c8e1fc011/src/aberdeen.ts#L1540)
1031
+ Defined in: [aberdeen.ts:1575](https://github.com/vanviegen/aberdeen/blob/876d65e85fa77c9453fc72e223d2239e9c745656/src/aberdeen.ts#L1575)
997
1032
 
998
1033
  Like [copy](#copy), but uses merge semantics. Properties in `dst` not present in `src` are kept.
999
1034
  `null`/`undefined` in `src` delete properties in `dst`.
1000
1035
 
1001
- When the destination is an object and the source is an array, its keys are used as (sparse) array indices.
1002
-
1003
1036
  ##### Type Parameters
1004
1037
 
1005
1038
  ###### T
@@ -1020,7 +1053,7 @@ When the destination is an object and the source is an array, its keys are used
1020
1053
 
1021
1054
  `boolean`
1022
1055
 
1023
- ##### Examples
1056
+ ##### Example
1024
1057
 
1025
1058
  ```typescript
1026
1059
  const source = { b: { c: 99 }, d: undefined }; // d: undefined will delete
@@ -1031,24 +1064,15 @@ merge(dest, 'c', { z: 7 }); // merge.c doesn't exist yet, so it will just be ass
1031
1064
  console.log(dest); // proxy({ a: 1, b: { c: 99, x: 5, y: 6 }, c: { z: 7 } })
1032
1065
  ```
1033
1066
 
1034
- ```typescript
1035
- const messages = proxy(['msg1', 'msg2', 'msg3']);
1036
- const update = { 1: 'updated msg2' }; // Update using object key as index
1037
- merge(messages, update);
1038
- console.log(messages); // proxy(['msg1', 'updated msg2', 'msg3'])
1039
- ```
1040
-
1041
1067
  #### Call Signature
1042
1068
 
1043
1069
  > **merge**\<`T`\>(`dst`, `dstKey`, `value`): `boolean`
1044
1070
 
1045
- Defined in: [aberdeen.ts:1541](https://github.com/vanviegen/aberdeen/blob/6b79c7fce769810bdcbd326b8ee6ef1c8e1fc011/src/aberdeen.ts#L1541)
1071
+ Defined in: [aberdeen.ts:1576](https://github.com/vanviegen/aberdeen/blob/876d65e85fa77c9453fc72e223d2239e9c745656/src/aberdeen.ts#L1576)
1046
1072
 
1047
1073
  Like [copy](#copy), but uses merge semantics. Properties in `dst` not present in `src` are kept.
1048
1074
  `null`/`undefined` in `src` delete properties in `dst`.
1049
1075
 
1050
- When the destination is an object and the source is an array, its keys are used as (sparse) array indices.
1051
-
1052
1076
  ##### Type Parameters
1053
1077
 
1054
1078
  ###### T
@@ -1073,7 +1097,7 @@ keyof `T`
1073
1097
 
1074
1098
  `boolean`
1075
1099
 
1076
- ##### Examples
1100
+ ##### Example
1077
1101
 
1078
1102
  ```typescript
1079
1103
  const source = { b: { c: 99 }, d: undefined }; // d: undefined will delete
@@ -1084,20 +1108,13 @@ merge(dest, 'c', { z: 7 }); // merge.c doesn't exist yet, so it will just be ass
1084
1108
  console.log(dest); // proxy({ a: 1, b: { c: 99, x: 5, y: 6 }, c: { z: 7 } })
1085
1109
  ```
1086
1110
 
1087
- ```typescript
1088
- const messages = proxy(['msg1', 'msg2', 'msg3']);
1089
- const update = { 1: 'updated msg2' }; // Update using object key as index
1090
- merge(messages, update);
1091
- console.log(messages); // proxy(['msg1', 'updated msg2', 'msg3'])
1092
- ```
1093
-
1094
1111
  ***
1095
1112
 
1096
1113
  ### mount()
1097
1114
 
1098
1115
  > **mount**(`parentElement`, `func`): `void`
1099
1116
 
1100
- Defined in: [aberdeen.ts:2580](https://github.com/vanviegen/aberdeen/blob/6b79c7fce769810bdcbd326b8ee6ef1c8e1fc011/src/aberdeen.ts#L2580)
1117
+ Defined in: [aberdeen.ts:2739](https://github.com/vanviegen/aberdeen/blob/876d65e85fa77c9453fc72e223d2239e9c745656/src/aberdeen.ts#L2739)
1101
1118
 
1102
1119
  Attaches a reactive Aberdeen UI fragment to an existing DOM element. Without the use of
1103
1120
  this function, [$](#) will assume `document.body` as its root.
@@ -1215,7 +1232,7 @@ items.push({ id: 'c', value: 30 });
1215
1232
 
1216
1233
  > **multiMap**\<`IN`, `OUT`\>(`source`, `func`): `OUT`
1217
1234
 
1218
- Defined in: [aberdeen.ts:2730](https://github.com/vanviegen/aberdeen/blob/6b79c7fce769810bdcbd326b8ee6ef1c8e1fc011/src/aberdeen.ts#L2730)
1235
+ Defined in: [aberdeen.ts:2890](https://github.com/vanviegen/aberdeen/blob/876d65e85fa77c9453fc72e223d2239e9c745656/src/aberdeen.ts#L2890)
1219
1236
 
1220
1237
  When using an array as `source`.
1221
1238
 
@@ -1247,7 +1264,7 @@ When using an array as `source`.
1247
1264
 
1248
1265
  > **multiMap**\<`K`, `IN`, `OUT`\>(`source`, `func`): `OUT`
1249
1266
 
1250
- Defined in: [aberdeen.ts:2735](https://github.com/vanviegen/aberdeen/blob/6b79c7fce769810bdcbd326b8ee6ef1c8e1fc011/src/aberdeen.ts#L2735)
1267
+ Defined in: [aberdeen.ts:2895](https://github.com/vanviegen/aberdeen/blob/876d65e85fa77c9453fc72e223d2239e9c745656/src/aberdeen.ts#L2895)
1251
1268
 
1252
1269
  When using an object as `source`.
1253
1270
 
@@ -1283,7 +1300,7 @@ When using an object as `source`.
1283
1300
 
1284
1301
  > **multiMap**\<`K`, `IN`, `OUT`\>(`source`, `func`): `OUT`
1285
1302
 
1286
- Defined in: [aberdeen.ts:2741](https://github.com/vanviegen/aberdeen/blob/6b79c7fce769810bdcbd326b8ee6ef1c8e1fc011/src/aberdeen.ts#L2741)
1303
+ Defined in: [aberdeen.ts:2901](https://github.com/vanviegen/aberdeen/blob/876d65e85fa77c9453fc72e223d2239e9c745656/src/aberdeen.ts#L2901)
1287
1304
 
1288
1305
  When using a Map as `source`.
1289
1306
 
@@ -1387,7 +1404,7 @@ setTimeout(() => config.fontSize = 16, 2000);
1387
1404
 
1388
1405
  > **onEach**\<`K`, `T`\>(`target`, `render`, `makeKey?`): `void`
1389
1406
 
1390
- Defined in: [aberdeen.ts:834](https://github.com/vanviegen/aberdeen/blob/6b79c7fce769810bdcbd326b8ee6ef1c8e1fc011/src/aberdeen.ts#L834)
1407
+ Defined in: [aberdeen.ts:875](https://github.com/vanviegen/aberdeen/blob/876d65e85fa77c9453fc72e223d2239e9c745656/src/aberdeen.ts#L875)
1391
1408
 
1392
1409
  ##### Type Parameters
1393
1410
 
@@ -1421,7 +1438,7 @@ Defined in: [aberdeen.ts:834](https://github.com/vanviegen/aberdeen/blob/6b79c7f
1421
1438
 
1422
1439
  > **onEach**\<`T`\>(`target`, `render`, `makeKey?`): `void`
1423
1440
 
1424
- Defined in: [aberdeen.ts:839](https://github.com/vanviegen/aberdeen/blob/6b79c7fce769810bdcbd326b8ee6ef1c8e1fc011/src/aberdeen.ts#L839)
1441
+ Defined in: [aberdeen.ts:880](https://github.com/vanviegen/aberdeen/blob/876d65e85fa77c9453fc72e223d2239e9c745656/src/aberdeen.ts#L880)
1425
1442
 
1426
1443
  ##### Type Parameters
1427
1444
 
@@ -1451,7 +1468,7 @@ readonly (`undefined` \| `T`)[]
1451
1468
 
1452
1469
  > **onEach**\<`K`, `T`\>(`target`, `render`, `makeKey?`): `void`
1453
1470
 
1454
- Defined in: [aberdeen.ts:844](https://github.com/vanviegen/aberdeen/blob/6b79c7fce769810bdcbd326b8ee6ef1c8e1fc011/src/aberdeen.ts#L844)
1471
+ Defined in: [aberdeen.ts:885](https://github.com/vanviegen/aberdeen/blob/876d65e85fa77c9453fc72e223d2239e9c745656/src/aberdeen.ts#L885)
1455
1472
 
1456
1473
  ##### Type Parameters
1457
1474
 
@@ -1564,7 +1581,7 @@ console.log(usersByTag);
1564
1581
 
1565
1582
  > **partition**\<`OUT_K`, `IN_V`\>(`source`, `func`): `Record`\<`OUT_K`, `Record`\<`number`, `IN_V`\>\>
1566
1583
 
1567
- Defined in: [aberdeen.ts:2805](https://github.com/vanviegen/aberdeen/blob/6b79c7fce769810bdcbd326b8ee6ef1c8e1fc011/src/aberdeen.ts#L2805)
1584
+ Defined in: [aberdeen.ts:2965](https://github.com/vanviegen/aberdeen/blob/876d65e85fa77c9453fc72e223d2239e9c745656/src/aberdeen.ts#L2965)
1568
1585
 
1569
1586
  When using an object as `array`.
1570
1587
 
@@ -1596,7 +1613,7 @@ When using an object as `array`.
1596
1613
 
1597
1614
  > **partition**\<`IN_K`, `OUT_K`, `IN_V`\>(`source`, `func`): `Record`\<`OUT_K`, `Record`\<`IN_K`, `IN_V`\>\>
1598
1615
 
1599
- Defined in: [aberdeen.ts:2810](https://github.com/vanviegen/aberdeen/blob/6b79c7fce769810bdcbd326b8ee6ef1c8e1fc011/src/aberdeen.ts#L2810)
1616
+ Defined in: [aberdeen.ts:2970](https://github.com/vanviegen/aberdeen/blob/876d65e85fa77c9453fc72e223d2239e9c745656/src/aberdeen.ts#L2970)
1600
1617
 
1601
1618
  When using an object as `source`.
1602
1619
 
@@ -1632,7 +1649,7 @@ When using an object as `source`.
1632
1649
 
1633
1650
  > **partition**\<`IN_K`, `OUT_K`, `IN_V`\>(`source`, `func`): `Record`\<`OUT_K`, `Record`\<`IN_K`, `IN_V`\>\>
1634
1651
 
1635
- Defined in: [aberdeen.ts:2819](https://github.com/vanviegen/aberdeen/blob/6b79c7fce769810bdcbd326b8ee6ef1c8e1fc011/src/aberdeen.ts#L2819)
1652
+ Defined in: [aberdeen.ts:2979](https://github.com/vanviegen/aberdeen/blob/876d65e85fa77c9453fc72e223d2239e9c745656/src/aberdeen.ts#L2979)
1636
1653
 
1637
1654
  When using a Map as `source`.
1638
1655
 
@@ -1672,7 +1689,7 @@ When using a Map as `source`.
1672
1689
 
1673
1690
  > **peek**\<`T`, `K`\>(`target`, `key`): `T`\[`K`\]
1674
1691
 
1675
- Defined in: [aberdeen.ts:2621](https://github.com/vanviegen/aberdeen/blob/6b79c7fce769810bdcbd326b8ee6ef1c8e1fc011/src/aberdeen.ts#L2621)
1692
+ Defined in: [aberdeen.ts:2781](https://github.com/vanviegen/aberdeen/blob/876d65e85fa77c9453fc72e223d2239e9c745656/src/aberdeen.ts#L2781)
1676
1693
 
1677
1694
  Executes a function or retrieves a value *without* creating subscriptions in the current reactive scope, and returns its result.
1678
1695
 
@@ -1728,7 +1745,7 @@ data.a = 2; // Triggers console.log (logs "A is 2, B was 3 when A changed.")
1728
1745
 
1729
1746
  > **peek**\<`K`, `V`\>(`target`, `key`): `undefined` \| `V`
1730
1747
 
1731
- Defined in: [aberdeen.ts:2622](https://github.com/vanviegen/aberdeen/blob/6b79c7fce769810bdcbd326b8ee6ef1c8e1fc011/src/aberdeen.ts#L2622)
1748
+ Defined in: [aberdeen.ts:2782](https://github.com/vanviegen/aberdeen/blob/876d65e85fa77c9453fc72e223d2239e9c745656/src/aberdeen.ts#L2782)
1732
1749
 
1733
1750
  Executes a function or retrieves a value *without* creating subscriptions in the current reactive scope, and returns its result.
1734
1751
 
@@ -1784,7 +1801,7 @@ data.a = 2; // Triggers console.log (logs "A is 2, B was 3 when A changed.")
1784
1801
 
1785
1802
  > **peek**\<`T`\>(`target`, `key`): `undefined` \| `T`
1786
1803
 
1787
- Defined in: [aberdeen.ts:2623](https://github.com/vanviegen/aberdeen/blob/6b79c7fce769810bdcbd326b8ee6ef1c8e1fc011/src/aberdeen.ts#L2623)
1804
+ Defined in: [aberdeen.ts:2783](https://github.com/vanviegen/aberdeen/blob/876d65e85fa77c9453fc72e223d2239e9c745656/src/aberdeen.ts#L2783)
1788
1805
 
1789
1806
  Executes a function or retrieves a value *without* creating subscriptions in the current reactive scope, and returns its result.
1790
1807
 
@@ -1836,7 +1853,7 @@ data.a = 2; // Triggers console.log (logs "A is 2, B was 3 when A changed.")
1836
1853
 
1837
1854
  > **peek**\<`T`\>(`target`): `T`
1838
1855
 
1839
- Defined in: [aberdeen.ts:2624](https://github.com/vanviegen/aberdeen/blob/6b79c7fce769810bdcbd326b8ee6ef1c8e1fc011/src/aberdeen.ts#L2624)
1856
+ Defined in: [aberdeen.ts:2784](https://github.com/vanviegen/aberdeen/blob/876d65e85fa77c9453fc72e223d2239e9c745656/src/aberdeen.ts#L2784)
1840
1857
 
1841
1858
  Executes a function or retrieves a value *without* creating subscriptions in the current reactive scope, and returns its result.
1842
1859
 
@@ -1944,7 +1961,7 @@ setTimeout(() => graph.grow(), 4000);
1944
1961
 
1945
1962
  > **proxy**\<`T`\>(`target`): [`PromiseProxy`](#promiseproxy)\<`T`\>
1946
1963
 
1947
- Defined in: [aberdeen.ts:1330](https://github.com/vanviegen/aberdeen/blob/6b79c7fce769810bdcbd326b8ee6ef1c8e1fc011/src/aberdeen.ts#L1330)
1964
+ Defined in: [aberdeen.ts:1375](https://github.com/vanviegen/aberdeen/blob/876d65e85fa77c9453fc72e223d2239e9c745656/src/aberdeen.ts#L1375)
1948
1965
 
1949
1966
  ##### Type Parameters
1950
1967
 
@@ -1966,7 +1983,7 @@ Defined in: [aberdeen.ts:1330](https://github.com/vanviegen/aberdeen/blob/6b79c7
1966
1983
 
1967
1984
  > **proxy**\<`T`\>(`target`): `T` *extends* `number` ? `number` : `T` *extends* `string` ? `string` : `T` *extends* `boolean` ? `boolean` : `T`[]
1968
1985
 
1969
- Defined in: [aberdeen.ts:1331](https://github.com/vanviegen/aberdeen/blob/6b79c7fce769810bdcbd326b8ee6ef1c8e1fc011/src/aberdeen.ts#L1331)
1986
+ Defined in: [aberdeen.ts:1376](https://github.com/vanviegen/aberdeen/blob/876d65e85fa77c9453fc72e223d2239e9c745656/src/aberdeen.ts#L1376)
1970
1987
 
1971
1988
  ##### Type Parameters
1972
1989
 
@@ -1988,7 +2005,7 @@ Defined in: [aberdeen.ts:1331](https://github.com/vanviegen/aberdeen/blob/6b79c7
1988
2005
 
1989
2006
  > **proxy**\<`T`\>(`target`): `T`
1990
2007
 
1991
- Defined in: [aberdeen.ts:1332](https://github.com/vanviegen/aberdeen/blob/6b79c7fce769810bdcbd326b8ee6ef1c8e1fc011/src/aberdeen.ts#L1332)
2008
+ Defined in: [aberdeen.ts:1377](https://github.com/vanviegen/aberdeen/blob/876d65e85fa77c9453fc72e223d2239e9c745656/src/aberdeen.ts#L1377)
1992
2009
 
1993
2010
  ##### Type Parameters
1994
2011
 
@@ -2010,7 +2027,7 @@ Defined in: [aberdeen.ts:1332](https://github.com/vanviegen/aberdeen/blob/6b79c7
2010
2027
 
2011
2028
  > **proxy**\<`T`\>(`target`): `ValueRef`\<`T` *extends* `number` ? `number` : `T` *extends* `string` ? `string` : `T` *extends* `boolean` ? `boolean` : `T`\>
2012
2029
 
2013
- Defined in: [aberdeen.ts:1333](https://github.com/vanviegen/aberdeen/blob/6b79c7fce769810bdcbd326b8ee6ef1c8e1fc011/src/aberdeen.ts#L1333)
2030
+ Defined in: [aberdeen.ts:1378](https://github.com/vanviegen/aberdeen/blob/876d65e85fa77c9453fc72e223d2239e9c745656/src/aberdeen.ts#L1378)
2014
2031
 
2015
2032
  ##### Type Parameters
2016
2033
 
@@ -2034,7 +2051,7 @@ Defined in: [aberdeen.ts:1333](https://github.com/vanviegen/aberdeen/blob/6b79c7
2034
2051
 
2035
2052
  > **ref**\<`T`, `K`\>(`target`, `index`): `ValueRef`\<`T`\[`K`\]\>
2036
2053
 
2037
- Defined in: [aberdeen.ts:1906](https://github.com/vanviegen/aberdeen/blob/6b79c7fce769810bdcbd326b8ee6ef1c8e1fc011/src/aberdeen.ts#L1906)
2054
+ Defined in: [aberdeen.ts:1954](https://github.com/vanviegen/aberdeen/blob/876d65e85fa77c9453fc72e223d2239e9c745656/src/aberdeen.ts#L1954)
2038
2055
 
2039
2056
  Creates a reactive reference (`{ value: T }`-like object) to a specific value
2040
2057
  within a proxied object or array.
@@ -2096,7 +2113,7 @@ $(() => console.log(formData))
2096
2113
 
2097
2114
  > **runQueue**(): `void`
2098
2115
 
2099
- Defined in: [aberdeen.ts:69](https://github.com/vanviegen/aberdeen/blob/6b79c7fce769810bdcbd326b8ee6ef1c8e1fc011/src/aberdeen.ts#L69)
2116
+ Defined in: [aberdeen.ts:69](https://github.com/vanviegen/aberdeen/blob/876d65e85fa77c9453fc72e223d2239e9c745656/src/aberdeen.ts#L69)
2100
2117
 
2101
2118
  Forces the immediate and synchronous execution of all pending reactive updates.
2102
2119
 
@@ -2120,7 +2137,7 @@ by a previous (or the same) `runQueue` call.
2120
2137
  ```typescript
2121
2138
  const data = proxy("before");
2122
2139
 
2123
- $('#'+data);
2140
+ $('#', data);
2124
2141
  console.log(1, document.body.innerHTML); // before
2125
2142
 
2126
2143
  // Make an update that should cause the DOM to change.
@@ -2139,7 +2156,7 @@ console.log(2, document.body.innerHTML); // after
2139
2156
 
2140
2157
  > **setErrorHandler**(`handler?`): `void`
2141
2158
 
2142
- Defined in: [aberdeen.ts:2409](https://github.com/vanviegen/aberdeen/blob/6b79c7fce769810bdcbd326b8ee6ef1c8e1fc011/src/aberdeen.ts#L2409)
2159
+ Defined in: [aberdeen.ts:2596](https://github.com/vanviegen/aberdeen/blob/876d65e85fa77c9453fc72e223d2239e9c745656/src/aberdeen.ts#L2596)
2143
2160
 
2144
2161
  Sets a custom error handler function for errors that occur asynchronously
2145
2162
  within reactive scopes (e.g., during updates triggered by proxy changes in
@@ -2175,7 +2192,7 @@ setErrorHandler(error => {
2175
2192
 
2176
2193
  try {
2177
2194
  // Attempt to show a custom message in the UI
2178
- $('div.error-message#Oops, something went wrong!');
2195
+ $('div#Oops, something went wrong!', errorClass);
2179
2196
  } catch (e) {
2180
2197
  // Ignore errors during error handling itself
2181
2198
  }
@@ -2184,15 +2201,7 @@ setErrorHandler(error => {
2184
2201
  });
2185
2202
 
2186
2203
  // Styling for our custom error message
2187
- insertCss({
2188
- '.error-message': {
2189
- backgroundColor: '#e31f00',
2190
- display: 'inline-block',
2191
- color: 'white',
2192
- borderRadius: '3px',
2193
- padding: '2px 4px',
2194
- }
2195
- }, true); // global style
2204
+ const errorClass = insertCss('background-color:#e31f00 display:inline-block color:white r:3px padding: 2px 4px;');
2196
2205
 
2197
2206
  // Cause an error within a render scope.
2198
2207
  $('div.box', () => {
@@ -2207,9 +2216,9 @@ $('div.box', () => {
2207
2216
 
2208
2217
  > **setSpacingCssVars**(`base`, `unit`): `void`
2209
2218
 
2210
- Defined in: [aberdeen.ts:1759](https://github.com/vanviegen/aberdeen/blob/6b79c7fce769810bdcbd326b8ee6ef1c8e1fc011/src/aberdeen.ts#L1759)
2219
+ Defined in: [aberdeen.ts:1800](https://github.com/vanviegen/aberdeen/blob/876d65e85fa77c9453fc72e223d2239e9c745656/src/aberdeen.ts#L1800)
2211
2220
 
2212
- Initializes `cssVars[1]` through `cssVars[12]` with an exponential spacing scale.
2221
+ Initializes `cssVars[0]` through `cssVars[12]` with an exponential spacing scale.
2213
2222
 
2214
2223
  The scale is calculated as `2^(n-3) * base`, providing values from `0.25 * base` to `512 * base`.
2215
2224
 
@@ -2219,13 +2228,13 @@ The scale is calculated as `2^(n-3) * base`, providing values from `0.25 * base`
2219
2228
 
2220
2229
  `number` = `1`
2221
2230
 
2222
- The base size for the spacing scale (default: 1). If unit is 'rem' or 'em', this is in that unit. If unit is 'px', this is the pixel value.
2231
+ The base size for the spacing scale that will apply to `cssVars[3]`. Every step up the scale will double this, while every step down will halve it. Defaults to 1.
2223
2232
 
2224
2233
  ##### unit
2225
2234
 
2226
2235
  `string` = `'rem'`
2227
2236
 
2228
- The CSS unit to use (default: 'rem'). Can be 'rem', 'em', 'px', or any other valid CSS unit.
2237
+ The CSS unit to use, like 'rem', 'em', or 'px'. Defaults to 'rem'.
2229
2238
 
2230
2239
  #### Returns
2231
2240
 
@@ -2234,6 +2243,7 @@ The CSS unit to use (default: 'rem'). Can be 'rem', 'em', 'px', or any other val
2234
2243
  #### Example
2235
2244
 
2236
2245
  ```javascript
2246
+ import { setSpacingCssVars, cssVars, onEach, $} from 'aberdeen';
2237
2247
  // Use default scale (0.25rem to 512rem)
2238
2248
  setSpacingCssVars();
2239
2249
 
@@ -2242,6 +2252,11 @@ setSpacingCssVars(16, 'px'); // 4px to 8192px
2242
2252
 
2243
2253
  // Use em units
2244
2254
  setSpacingCssVars(1, 'em'); // 0.25em to 512em
2255
+
2256
+ // Show the last generated spacing values
2257
+ onEach(cssVars, (value, key) => {
2258
+ $(`div #${key} → ${value}`)
2259
+ }, (value, key) => parseInt(key)); // Numeric sort
2245
2260
  ```
2246
2261
 
2247
2262
  ***
@@ -2250,12 +2265,13 @@ setSpacingCssVars(1, 'em'); // 0.25em to 512em
2250
2265
 
2251
2266
  > **unmountAll**(): `void`
2252
2267
 
2253
- Defined in: [aberdeen.ts:2590](https://github.com/vanviegen/aberdeen/blob/6b79c7fce769810bdcbd326b8ee6ef1c8e1fc011/src/aberdeen.ts#L2590)
2268
+ Defined in: [aberdeen.ts:2750](https://github.com/vanviegen/aberdeen/blob/876d65e85fa77c9453fc72e223d2239e9c745656/src/aberdeen.ts#L2750)
2254
2269
 
2255
2270
  Removes all Aberdeen-managed DOM nodes and stops all active reactive scopes
2256
2271
  (created by [mount](#mount), [derive](#derive), [$](#) with functions, etc.).
2257
2272
 
2258
- This effectively cleans up the entire Aberdeen application state.
2273
+ This effectively cleans up the entire Aberdeen application state. Aside from in
2274
+ automated tests, there should probably be little reason to call this function.
2259
2275
 
2260
2276
  #### Returns
2261
2277
 
@@ -2267,7 +2283,7 @@ This effectively cleans up the entire Aberdeen application state.
2267
2283
 
2268
2284
  > **unproxy**\<`T`\>(`target`): `T`
2269
2285
 
2270
- Defined in: [aberdeen.ts:1447](https://github.com/vanviegen/aberdeen/blob/6b79c7fce769810bdcbd326b8ee6ef1c8e1fc011/src/aberdeen.ts#L1447)
2286
+ Defined in: [aberdeen.ts:1492](https://github.com/vanviegen/aberdeen/blob/876d65e85fa77c9453fc72e223d2239e9c745656/src/aberdeen.ts#L1492)
2271
2287
 
2272
2288
  Returns the original, underlying data target from a reactive proxy created by [proxy](#proxy).
2273
2289
  If the input `target` is not a proxy, it is returned directly.