@nr1e/qwik-ui 0.1.0 → 0.1.1

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.
@@ -3,10 +3,20 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const jsxRuntime = require("@builder.io/qwik/jsx-runtime");
4
4
  const qwik = require("@builder.io/qwik");
5
5
  const AutoDismiss = qwik.component$((props) => {
6
- if (props?.visible && !props.visible.value) return null;
6
+ const visible = qwik.useSignal(props?.visible?.value ?? false);
7
+ if (!visible.value) return null;
8
+ qwik.useTask$(async ({ track }) => {
9
+ track(() => visible.value);
10
+ if (props?.visible) {
11
+ props.visible.value = visible.value;
12
+ }
13
+ if (!visible.value && props?.onDismiss$) {
14
+ props.onDismiss$();
15
+ }
16
+ });
7
17
  qwik.useVisibleTask$(({ cleanup }) => {
8
18
  const id = setTimeout(() => {
9
- if (props?.visible) props.visible.value = false;
19
+ visible.value = false;
10
20
  }, 6e3);
11
21
  cleanup(() => clearTimeout(id));
12
22
  });
@@ -1,10 +1,20 @@
1
1
  import { jsx } from "@builder.io/qwik/jsx-runtime";
2
- import { component$, useVisibleTask$, Slot } from "@builder.io/qwik";
2
+ import { component$, useSignal, useTask$, useVisibleTask$, Slot } from "@builder.io/qwik";
3
3
  const AutoDismiss = component$((props) => {
4
- if (props?.visible && !props.visible.value) return null;
4
+ const visible = useSignal(props?.visible?.value ?? false);
5
+ if (!visible.value) return null;
6
+ useTask$(async ({ track }) => {
7
+ track(() => visible.value);
8
+ if (props?.visible) {
9
+ props.visible.value = visible.value;
10
+ }
11
+ if (!visible.value && props?.onDismiss$) {
12
+ props.onDismiss$();
13
+ }
14
+ });
5
15
  useVisibleTask$(({ cleanup }) => {
6
16
  const id = setTimeout(() => {
7
- if (props?.visible) props.visible.value = false;
17
+ visible.value = false;
8
18
  }, 6e3);
9
19
  cleanup(() => clearTimeout(id));
10
20
  });
@@ -1,6 +1,7 @@
1
- import { Signal } from '@builder.io/qwik';
1
+ import { QRL, Signal } from '@builder.io/qwik';
2
2
  export interface AutoDismissProps {
3
3
  class?: string;
4
4
  visible?: Signal<boolean>;
5
+ onDismiss$?: QRL<() => void>;
5
6
  }
6
7
  export declare const AutoDismiss: import("@builder.io/qwik").Component<AutoDismissProps | undefined>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nr1e/qwik-ui",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "NR1E Qwik UI Library",
5
5
  "author": "NR1E, Inc.",
6
6
  "publishConfig": {