From 2153f576b85a284ec7a85eef42c778fbf0870c5e Mon Sep 17 00:00:00 2001 From: Kevin Bulteel Date: Sun, 17 Mar 2024 15:55:57 +0100 Subject: [PATCH] fix: small fixes --- packages/@hec.js/ui/lib/src/component.js | 23 +++++++++++++++++++---- packages/@hec.js/ui/lib/src/notify.js | 2 +- packages/@hec.js/ui/lib/src/signal.js | 6 +++++- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/packages/@hec.js/ui/lib/src/component.js b/packages/@hec.js/ui/lib/src/component.js index c7add4b..afbe1be 100644 --- a/packages/@hec.js/ui/lib/src/component.js +++ b/packages/@hec.js/ui/lib/src/component.js @@ -33,7 +33,7 @@ const attributeObserver = new MutationObserver((mutations) => { * @typedef { (name: string, props: T, fn: ComponentConstructor) => void } UIElement */ -/** @type { UIElement } */ +/** @type { UIElement } */ function UIElement(name, props, fn) { components.set(name, async ( @@ -121,11 +121,26 @@ function UIElement(name, props, fn) { emit('::component/' + name); } -/** @type { UIElement } */ +/** + * @template T + * @param { string } name + * @param { T } props + * @param { ComponentConstructor } fn + */ export const component = (name, props, fn) => UIElement(`component/${ name }`, props, fn); -/** @type { UIElement } */ +/** + * @template T + * @param { string } name + * @param { T } props + * @param { ComponentConstructor } fn + */ export const view = (name, props, fn) => UIElement(`view/${ name }`, props, fn); -/** @type { UIElement } */ +/** + * @template T + * @param { string } name + * @param { T } props + * @param { ComponentConstructor } fn + */ export const page = (name, props, fn) => UIElement(`page/${ name }`, props, fn); \ No newline at end of file diff --git a/packages/@hec.js/ui/lib/src/notify.js b/packages/@hec.js/ui/lib/src/notify.js index 3ae26c5..e64b43f 100644 --- a/packages/@hec.js/ui/lib/src/notify.js +++ b/packages/@hec.js/ui/lib/src/notify.js @@ -20,7 +20,7 @@ const intersectionObserver = new IntersectionObserver((entries) => { } } }, { - rootMargin: '256px', + rootMargin: '512px', }); new MutationObserver((mutations) => { diff --git a/packages/@hec.js/ui/lib/src/signal.js b/packages/@hec.js/ui/lib/src/signal.js index e77233d..9ffab79 100644 --- a/packages/@hec.js/ui/lib/src/signal.js +++ b/packages/@hec.js/ui/lib/src/signal.js @@ -112,7 +112,11 @@ export function signal(value = null, options = {}) { value = v; if (storage) { - storage.setItem(options.id, JSON.stringify(value)); + if (v === null || v === undefined) { + storage.removeItem(options.id); + } else { + storage.setItem(options.id, JSON.stringify(value)); + } } for (const subscriber of subscribers) {