ripple 0.2.144 → 0.2.145
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/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Ripple is an elegant TypeScript UI framework",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Dominic Gannaway",
|
|
6
|
-
"version": "0.2.
|
|
6
|
+
"version": "0.2.145",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"module": "src/runtime/index-client.js",
|
|
9
9
|
"main": "src/runtime/index-client.js",
|
|
@@ -81,6 +81,6 @@
|
|
|
81
81
|
"typescript": "^5.9.2"
|
|
82
82
|
},
|
|
83
83
|
"peerDependencies": {
|
|
84
|
-
"ripple": "0.2.
|
|
84
|
+
"ripple": "0.2.145"
|
|
85
85
|
}
|
|
86
86
|
}
|
|
@@ -1,10 +1,18 @@
|
|
|
1
|
-
/** @import {
|
|
1
|
+
/** @import { Tracked } from '#client' */
|
|
2
2
|
|
|
3
3
|
import { effect, render } from './blocks.js';
|
|
4
4
|
import { on } from './events.js';
|
|
5
|
-
import {
|
|
5
|
+
import { get, set, tick, untrack } from './runtime.js';
|
|
6
6
|
import { is_array, is_tracked_object } from './utils.js';
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* @param {string} name
|
|
10
|
+
* @returns {TypeError}
|
|
11
|
+
*/
|
|
12
|
+
function not_tracked_type_error(name) {
|
|
13
|
+
return new TypeError(`${name} argument is not a tracked object`);
|
|
14
|
+
}
|
|
15
|
+
|
|
8
16
|
/**
|
|
9
17
|
* Resize observer singleton.
|
|
10
18
|
* One listener per element only!
|
|
@@ -145,10 +153,9 @@ function select_option(select, value, mounting = false) {
|
|
|
145
153
|
*/
|
|
146
154
|
export function bindValue(maybe_tracked) {
|
|
147
155
|
if (!is_tracked_object(maybe_tracked)) {
|
|
148
|
-
throw
|
|
156
|
+
throw not_tracked_type_error('bindValue()');
|
|
149
157
|
}
|
|
150
158
|
|
|
151
|
-
var block = /** @type {Block} */ (active_block);
|
|
152
159
|
var tracked = /** @type {Tracked} */ (maybe_tracked);
|
|
153
160
|
|
|
154
161
|
return (node) => {
|
|
@@ -246,10 +253,9 @@ export function bindValue(maybe_tracked) {
|
|
|
246
253
|
*/
|
|
247
254
|
export function bindChecked(maybe_tracked) {
|
|
248
255
|
if (!is_tracked_object(maybe_tracked)) {
|
|
249
|
-
throw
|
|
256
|
+
throw not_tracked_type_error('bindChecked()');
|
|
250
257
|
}
|
|
251
258
|
|
|
252
|
-
const block = /** @type {any} */ (active_block);
|
|
253
259
|
const tracked = /** @type {Tracked} */ (maybe_tracked);
|
|
254
260
|
|
|
255
261
|
return (input) => {
|
|
@@ -267,12 +273,9 @@ export function bindChecked(maybe_tracked) {
|
|
|
267
273
|
*/
|
|
268
274
|
function bind_element_size(maybe_tracked, type) {
|
|
269
275
|
if (!is_tracked_object(maybe_tracked)) {
|
|
270
|
-
throw
|
|
271
|
-
`bind${type.charAt(0).toUpperCase() + type.slice(1)}() argument is not a tracked object`,
|
|
272
|
-
);
|
|
276
|
+
throw not_tracked_type_error(`bind${type.charAt(0).toUpperCase() + type.slice(1)}()`);
|
|
273
277
|
}
|
|
274
278
|
|
|
275
|
-
var block = /** @type {any} */ (active_block);
|
|
276
279
|
var tracked = /** @type {Tracked<any>} */ (maybe_tracked);
|
|
277
280
|
|
|
278
281
|
return (/** @type {HTMLElement} */ element) => {
|
|
@@ -325,12 +328,9 @@ export function bindOffsetHeight(maybe_tracked) {
|
|
|
325
328
|
*/
|
|
326
329
|
function bind_element_rect(maybe_tracked, type) {
|
|
327
330
|
if (!is_tracked_object(maybe_tracked)) {
|
|
328
|
-
throw
|
|
329
|
-
`bind${type.charAt(0).toUpperCase() + type.slice(1)}() argument is not a tracked object`,
|
|
330
|
-
);
|
|
331
|
+
throw not_tracked_type_error(`bind${type.charAt(0).toUpperCase() + type.slice(1)}()`);
|
|
331
332
|
}
|
|
332
333
|
|
|
333
|
-
var block = /** @type {any} */ (active_block);
|
|
334
334
|
var tracked = /** @type {Tracked<any>} */ (maybe_tracked);
|
|
335
335
|
var observer =
|
|
336
336
|
type === 'contentRect' || type === 'contentBoxSize'
|
|
@@ -388,12 +388,9 @@ export function bindDevicePixelContentBoxSize(maybe_tracked) {
|
|
|
388
388
|
*/
|
|
389
389
|
export function bind_content_editable(maybe_tracked, property) {
|
|
390
390
|
if (!is_tracked_object(maybe_tracked)) {
|
|
391
|
-
throw
|
|
392
|
-
`bind${property.charAt(0).toUpperCase() + property.slice(1)}() argument is not a tracked object`,
|
|
393
|
-
);
|
|
391
|
+
throw not_tracked_type_error(`bind${property.charAt(0).toUpperCase() + property.slice(1)}()`);
|
|
394
392
|
}
|
|
395
393
|
|
|
396
|
-
const block = /** @type {any} */ (active_block);
|
|
397
394
|
const tracked = /** @type {Tracked} */ (maybe_tracked);
|
|
398
395
|
|
|
399
396
|
return (element) => {
|
|
@@ -443,3 +440,21 @@ export function bindInnerText(maybe_tracked) {
|
|
|
443
440
|
export function bindTextContent(maybe_tracked) {
|
|
444
441
|
return bind_content_editable(maybe_tracked, 'textContent');
|
|
445
442
|
}
|
|
443
|
+
|
|
444
|
+
/**
|
|
445
|
+
* Syntactic sugar for binding a HTMLElement with {ref fn}
|
|
446
|
+
* @param {unknown} maybe_tracked
|
|
447
|
+
* @returns {(node: HTMLElement) => void}
|
|
448
|
+
*/
|
|
449
|
+
export function bindNode(maybe_tracked) {
|
|
450
|
+
if (!is_tracked_object(maybe_tracked)) {
|
|
451
|
+
throw not_tracked_type_error('bindNode()');
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
const tracked = /** @type {Tracked} */ (maybe_tracked);
|
|
455
|
+
|
|
456
|
+
/** @param {HTMLElement} node */
|
|
457
|
+
return (node) => {
|
|
458
|
+
set(tracked, node);
|
|
459
|
+
};
|
|
460
|
+
}
|
package/types/index.d.ts
CHANGED
|
@@ -287,3 +287,5 @@ export declare function bindInnerHTML<V>(tracked: Tracked<V>): (node: HTMLElemen
|
|
|
287
287
|
export declare function bindInnerText<V>(tracked: Tracked<V>): (node: HTMLElement) => void;
|
|
288
288
|
|
|
289
289
|
export declare function bindTextContent<V>(tracked: Tracked<V>): (node: HTMLElement) => void;
|
|
290
|
+
|
|
291
|
+
export declare function bindNode<V>(tracked: Tracked<V>): (node: HTMLElement) => void;
|