@nr1e/qwik-ui 0.0.16 → 0.0.18
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/lib/components/dialog.qwik.cjs +20 -2
- package/lib/components/dialog.qwik.mjs +21 -3
- package/lib/components/text-field.qwik.cjs +5 -2
- package/lib/components/text-field.qwik.mjs +5 -2
- package/lib-types/components/dialog.d.ts +3 -1
- package/lib-types/components/text-field.d.ts +1 -0
- package/package.json +1 -1
|
@@ -8,15 +8,33 @@ const alertInfo = require("./alert-info.qwik.cjs");
|
|
|
8
8
|
const alertWarning = require("./alert-warning.qwik.cjs");
|
|
9
9
|
const alertSuccess = require("./alert-success.qwik.cjs");
|
|
10
10
|
const Dialog = qwik.component$((props) => {
|
|
11
|
+
const internalOpen = qwik.useSignal(props.open.value);
|
|
12
|
+
const dialog = qwik.useSignal();
|
|
13
|
+
qwik.useTask$(({ track }) => {
|
|
14
|
+
track(() => props.open.value);
|
|
15
|
+
if (!props.open.value && internalOpen.value) {
|
|
16
|
+
if (props.onClose$ && dialog.value) {
|
|
17
|
+
props.onClose$(dialog.value);
|
|
18
|
+
}
|
|
19
|
+
internalOpen.value = false;
|
|
20
|
+
}
|
|
21
|
+
if (props.open.value && !internalOpen.value) {
|
|
22
|
+
if (props.onOpen$ && dialog.value) {
|
|
23
|
+
props.onOpen$(dialog.value);
|
|
24
|
+
}
|
|
25
|
+
internalOpen.value = true;
|
|
26
|
+
}
|
|
27
|
+
});
|
|
11
28
|
qwik.useOnDocument("keydown", qwik.$((event) => {
|
|
12
29
|
if (event.key === "Escape") {
|
|
13
30
|
props.open.value = false;
|
|
14
31
|
}
|
|
15
32
|
}));
|
|
16
33
|
return /* @__PURE__ */ jsxRuntime.jsx("dialog", {
|
|
34
|
+
ref: dialog,
|
|
17
35
|
class: `modal ${props.class}`,
|
|
18
36
|
id: props.id,
|
|
19
|
-
open:
|
|
37
|
+
open: internalOpen.value,
|
|
20
38
|
children: /* @__PURE__ */ jsxRuntime.jsxs("div", {
|
|
21
39
|
class: "modal-box",
|
|
22
40
|
children: [
|
|
@@ -57,7 +75,7 @@ const Dialog = qwik.component$((props) => {
|
|
|
57
75
|
]
|
|
58
76
|
}),
|
|
59
77
|
/* @__PURE__ */ jsxRuntime.jsx("div", {
|
|
60
|
-
class: "modal-action",
|
|
78
|
+
class: "modal-action mt-2",
|
|
61
79
|
children: /* @__PURE__ */ jsxRuntime.jsx(qwik.Slot, {
|
|
62
80
|
name: "action"
|
|
63
81
|
})
|
|
@@ -1,20 +1,38 @@
|
|
|
1
1
|
import { jsx, jsxs } from "@builder.io/qwik/jsx-runtime";
|
|
2
|
-
import { component$, useOnDocument, $, Slot } from "@builder.io/qwik";
|
|
2
|
+
import { component$, useSignal, useTask$, useOnDocument, $, Slot } from "@builder.io/qwik";
|
|
3
3
|
import { MdiClose } from "../qwik-icons/lib/components/icons/mdi-close.qwik.qwik.mjs";
|
|
4
4
|
import { AlertError } from "./alert-error.qwik.mjs";
|
|
5
5
|
import { AlertInfo } from "./alert-info.qwik.mjs";
|
|
6
6
|
import { AlertWarning } from "./alert-warning.qwik.mjs";
|
|
7
7
|
import { AlertSuccess } from "./alert-success.qwik.mjs";
|
|
8
8
|
const Dialog = component$((props) => {
|
|
9
|
+
const internalOpen = useSignal(props.open.value);
|
|
10
|
+
const dialog = useSignal();
|
|
11
|
+
useTask$(({ track }) => {
|
|
12
|
+
track(() => props.open.value);
|
|
13
|
+
if (!props.open.value && internalOpen.value) {
|
|
14
|
+
if (props.onClose$ && dialog.value) {
|
|
15
|
+
props.onClose$(dialog.value);
|
|
16
|
+
}
|
|
17
|
+
internalOpen.value = false;
|
|
18
|
+
}
|
|
19
|
+
if (props.open.value && !internalOpen.value) {
|
|
20
|
+
if (props.onOpen$ && dialog.value) {
|
|
21
|
+
props.onOpen$(dialog.value);
|
|
22
|
+
}
|
|
23
|
+
internalOpen.value = true;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
9
26
|
useOnDocument("keydown", $((event) => {
|
|
10
27
|
if (event.key === "Escape") {
|
|
11
28
|
props.open.value = false;
|
|
12
29
|
}
|
|
13
30
|
}));
|
|
14
31
|
return /* @__PURE__ */ jsx("dialog", {
|
|
32
|
+
ref: dialog,
|
|
15
33
|
class: `modal ${props.class}`,
|
|
16
34
|
id: props.id,
|
|
17
|
-
open:
|
|
35
|
+
open: internalOpen.value,
|
|
18
36
|
children: /* @__PURE__ */ jsxs("div", {
|
|
19
37
|
class: "modal-box",
|
|
20
38
|
children: [
|
|
@@ -55,7 +73,7 @@ const Dialog = component$((props) => {
|
|
|
55
73
|
]
|
|
56
74
|
}),
|
|
57
75
|
/* @__PURE__ */ jsx("div", {
|
|
58
|
-
class: "modal-action",
|
|
76
|
+
class: "modal-action mt-2",
|
|
59
77
|
children: /* @__PURE__ */ jsx(Slot, {
|
|
60
78
|
name: "action"
|
|
61
79
|
})
|
|
@@ -25,11 +25,14 @@ const TextField = qwik.component$((props) => {
|
|
|
25
25
|
}),
|
|
26
26
|
/* @__PURE__ */ jsxRuntime.jsx("input", {
|
|
27
27
|
type: "text",
|
|
28
|
+
...props.id && {
|
|
29
|
+
id: props.id
|
|
30
|
+
},
|
|
28
31
|
...props.name && {
|
|
29
32
|
name: props.name
|
|
30
33
|
},
|
|
31
|
-
...props.
|
|
32
|
-
|
|
34
|
+
...props.value && {
|
|
35
|
+
value: props.value
|
|
33
36
|
},
|
|
34
37
|
class: "placeholder:opacity-50",
|
|
35
38
|
placeholder: props.placeholder,
|
|
@@ -23,11 +23,14 @@ const TextField = component$((props) => {
|
|
|
23
23
|
}),
|
|
24
24
|
/* @__PURE__ */ jsx("input", {
|
|
25
25
|
type: "text",
|
|
26
|
+
...props.id && {
|
|
27
|
+
id: props.id
|
|
28
|
+
},
|
|
26
29
|
...props.name && {
|
|
27
30
|
name: props.name
|
|
28
31
|
},
|
|
29
|
-
...props.
|
|
30
|
-
|
|
32
|
+
...props.value && {
|
|
33
|
+
value: props.value
|
|
31
34
|
},
|
|
32
35
|
class: "placeholder:opacity-50",
|
|
33
36
|
placeholder: props.placeholder,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Signal } from '@builder.io/qwik';
|
|
1
|
+
import { QRL, Signal } from '@builder.io/qwik';
|
|
2
2
|
export interface DialogProps {
|
|
3
3
|
id?: string;
|
|
4
4
|
open: Signal<boolean>;
|
|
@@ -9,5 +9,7 @@ export interface DialogProps {
|
|
|
9
9
|
infoMessage?: string;
|
|
10
10
|
successMessage?: string;
|
|
11
11
|
warningMessage?: string;
|
|
12
|
+
onClose$?: QRL<(e: HTMLDialogElement) => void>;
|
|
13
|
+
onOpen$?: QRL<(e: HTMLDialogElement) => void>;
|
|
12
14
|
}
|
|
13
15
|
export declare const Dialog: import("@builder.io/qwik").Component<DialogProps>;
|