aberdeen 1.4.0 → 1.4.3

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/src/aberdeen.ts CHANGED
@@ -53,7 +53,7 @@ function queue(runner: QueueRunner) {
53
53
  * ```typescript
54
54
  * const data = proxy("before");
55
55
  *
56
- * $({text: data});
56
+ * $('#'+data);
57
57
  * console.log(1, document.body.innerHTML); // before
58
58
  *
59
59
  * // Make an update that should cause the DOM to change.
@@ -940,9 +940,9 @@ const EMPTY = Symbol("empty");
940
940
  * // Reactively display a message if the items array is empty
941
941
  * $('div', () => {
942
942
  * if (isEmpty(items)) {
943
- * $('p', 'i#No items yet!');
943
+ * $('p i#No items yet!');
944
944
  * } else {
945
- * onEach(items, item=>$('p#'+item));
945
+ * onEach(items, item => $('p#'+item));
946
946
  * }
947
947
  * });
948
948
  *
@@ -995,7 +995,7 @@ export interface ValueRef<T> {
995
995
  * const cnt = count(items);
996
996
  *
997
997
  * // Create a DOM text node for the count:
998
- * $('div', {text: cnt});
998
+ * $('div text=', cnt);
999
999
  * // <div>2</div>
1000
1000
 
1001
1001
  * // Or we can use it in an {@link derive} function:
@@ -1782,17 +1782,10 @@ const refHandler: ProxyHandler<RefTarget> = {
1782
1782
  * const formData = proxy({ color: 'orange', velocity: 42 });
1783
1783
  *
1784
1784
  * // Usage with `bind`
1785
- * $('input', {
1786
- * type: 'text',
1787
- * // Creates a two-way binding between the input's value and formData.username
1788
- * bind: ref(formData, 'color')
1789
- * });
1785
+ * $('input type=text bind=', ref(formData, 'color'));
1790
1786
  *
1791
1787
  * // Usage as a dynamic property, causes a TextNode with just the name to be created and live-updated
1792
- * $('p#Selected color: ', {
1793
- * text: ref(formData, 'color'),
1794
- * $color: ref(formData, 'color')
1795
- * });
1788
+ * $('p text="Selected color: " text=', ref(formData, 'color'), 'color:', ref(formData, 'color'));
1796
1789
  *
1797
1790
  * // Changes are actually stored in formData - this causes logs like `{color: "Blue", velocity 42}`
1798
1791
  * $(() => console.log(formData))
@@ -1926,16 +1919,7 @@ const SPECIAL_PROPS: { [key: string]: (el: Element, value: any) => void } = {
1926
1919
  *
1927
1920
  * @example Create Element
1928
1921
  * ```typescript
1929
- * $('button.secondary.outline#Submit', {
1930
- * disabled: false,
1931
- * click: () => console.log('Clicked!'),
1932
- * $color: 'red'
1933
- * });
1934
- * ```
1935
- *
1936
- * Which can also be written as:
1937
- * ```typescript
1938
- * $('button.secondary.outline text=Submit $color=red disabled=', false, 'click=', () => console.log('Clicked!'));
1922
+ * $('button.secondary.outline text=Submit color:red disabled=', false, 'click=', () => console.log('Clicked!'));
1939
1923
  * ```
1940
1924
  *
1941
1925
  * We want to set `disabled` as a property instead of an attribute, so we must use the `key=` syntax in order to provide
@@ -1943,7 +1927,7 @@ const SPECIAL_PROPS: { [key: string]: (el: Element, value: any) => void } = {
1943
1927
  *
1944
1928
  * @example Create Nested Elements
1945
1929
  * ```typescript
1946
- * let inputElement: Element = $('label#Click me', 'input', {type: 'checkbox'});
1930
+ * let inputElement: Element = $('label text="Click me" input type=checkbox');
1947
1931
  * // You should usually not touch raw DOM elements, unless when integrating
1948
1932
  * // with non-Aberdeen code.
1949
1933
  * console.log('DOM element:', inputElement);
@@ -1955,14 +1939,14 @@ const SPECIAL_PROPS: { [key: string]: (el: Element, value: any) => void } = {
1955
1939
  * $('div', () => { // Outer element
1956
1940
  * // This scope re-renders when state.count changes
1957
1941
  * $(`p#Count is ${state.count}`);
1958
- * $('button#Increment', { click: () => state.count++ });
1942
+ * $('button text=Increment click=', () => state.count++);
1959
1943
  * });
1960
1944
  * ```
1961
1945
  *
1962
1946
  * @example Two-way Binding
1963
1947
  * ```typescript
1964
1948
  * const user = proxy({ name: '' });
1965
- * $('input', { placeholder: 'Name', bind: ref(user, 'name') });
1949
+ * $('input placeholder=Name bind=', ref(user, 'name'));
1966
1950
  * $('h3', () => { // Reactive scope
1967
1951
  * $(`#Hello ${user.name || 'stranger'}`);
1968
1952
  * });
@@ -1971,7 +1955,7 @@ const SPECIAL_PROPS: { [key: string]: (el: Element, value: any) => void } = {
1971
1955
  * @example Conditional Rendering
1972
1956
  * ```typescript
1973
1957
  * const show = proxy(false);
1974
- * $('button', { click: () => show.value = !show.value }, () => $(show.value ? '#Hide' : '#Show'));
1958
+ * $('button click=', () => show.value = !show.value, () => $(show.value ? '#Hide' : '#Show'));
1975
1959
  * $(() => { // Reactive scope
1976
1960
  * if (show.value) {
1977
1961
  * $('p#Details are visible!');
@@ -2095,7 +2079,7 @@ let cssCount = 0;
2095
2079
  * - In case a selector contains a `&`, that character will be replaced by the parent selector.
2096
2080
  * - Selectors will be split on `,` characters, each combining with the parent selector with *or* semantics.
2097
2081
  * - Selector starting with `'@'` define at-rules like media queries. They may be nested within regular selectors.
2098
- * @param global - @deprecated Use {@link insertGlobalCss} instead.
2082
+ * @param global - Deprecated! Use {@link insertGlobalCss} instead.
2099
2083
  * @returns The unique class name prefix used for scoping (e.g., `.AbdStl1`). Use this
2100
2084
  * prefix with {@link $} to apply the styles.
2101
2085
  *
@@ -2374,7 +2358,7 @@ export function getParentElement(): Element {
2374
2358
  * })
2375
2359
  *
2376
2360
  * // Show the sum
2377
- * $('h1', {text: sum});
2361
+ * $('h1 text=', sum);
2378
2362
  *
2379
2363
  * // Make random changes to the array
2380
2364
  * const rnd = () => 0|(Math.random()*20);
@@ -2412,8 +2396,8 @@ export function clean(cleaner: () => void) {
2412
2396
  * // When data.notifications changes, only this inner scope reruns,
2413
2397
  * // leaving the `<p>Welcome, ..</p>` untouched.
2414
2398
  * console.log('Notifications');
2415
- * $('code.notification-badge#' + data.notifications);
2416
- * $('a#Notify!', {click: () => data.notifications++});
2399
+ * $('code.notification-badge text=', data.notifications);
2400
+ * $('a text=Notify! click=', () => data.notifications++);
2417
2401
  * });
2418
2402
  * });
2419
2403
  * ```
@@ -2522,7 +2506,7 @@ export function unmountAll() {
2522
2506
  *
2523
2507
  */
2524
2508
 
2525
- export function peek<T extends object>(target: T, key: keyof T): T[typeof key];
2509
+ export function peek<T extends object, K extends keyof T>(target: T, key: K): T[K];
2526
2510
  export function peek<K,V>(target: Map<K,V>, key: K): V | undefined;
2527
2511
  export function peek<T>(target: T[], key: number): T | undefined;
2528
2512
  export function peek<T>(target: () => T): T;