@nr1e/qwik-ui 0.1.4 → 1.0.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,24 +3,39 @@ 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 qwikCity = require("@builder.io/qwik-city");
6
- const DropUpItem = qwik.component$((props) => {
7
- const nav = qwikCity.useNavigate();
6
+ const DropUpButton = qwik.component$((props) => {
8
7
  return /* @__PURE__ */ jsxRuntime.jsx("li", {
8
+ class: props.class ?? "",
9
+ children: /* @__PURE__ */ jsxRuntime.jsx("button", {
10
+ class: `text-nowrap ${props?.buttonClass ?? null}`,
11
+ onClick$: async (event) => {
12
+ if (props.loading) {
13
+ props.loading.value = true;
14
+ }
15
+ await props.onClick$(event);
16
+ if (props.loading) {
17
+ props.loading.value = false;
18
+ }
19
+ }
20
+ })
21
+ });
22
+ });
23
+ const DropUpLink = qwik.component$((props) => {
24
+ return /* @__PURE__ */ jsxRuntime.jsx("li", {
25
+ class: props.class ?? "",
9
26
  children: /* @__PURE__ */ jsxRuntime.jsx(qwikCity.Link, {
10
27
  href: props.href,
11
28
  prefetch: props.prefetch,
12
- class: `text-nowrap ${props?.class ?? null}`,
29
+ class: `text-nowrap ${props?.linkClass ?? null}`,
13
30
  onClick$: async (event) => {
31
+ if (props.loading) {
32
+ props.loading.value = true;
33
+ }
14
34
  if (props.onClick$) {
15
35
  await props.onClick$(event);
16
- } else {
17
- if (props.loading) {
18
- props.loading.value = true;
19
- }
20
- await nav(props.href);
21
- if (props.loading) {
22
- props.loading.value = false;
23
- }
36
+ }
37
+ if (props.loading) {
38
+ props.loading.value = false;
24
39
  }
25
40
  },
26
41
  children: /* @__PURE__ */ jsxRuntime.jsx(qwik.Slot, {})
@@ -43,12 +58,47 @@ const DropUpButtonSelector = qwik.component$((props) => {
43
58
  });
44
59
  });
45
60
  const DropUp = qwik.component$((props) => {
61
+ const open = qwik.useSignal(props?.open?.value ?? false);
62
+ const dropdownRef = qwik.useSignal();
63
+ qwik.useTask$(({ track }) => {
64
+ track(() => props?.open?.value);
65
+ if (props?.open?.value && props.open.value !== open.value) {
66
+ open.value = props.open.value;
67
+ }
68
+ });
69
+ qwik.useTask$(({ track }) => {
70
+ track(() => open.value);
71
+ if (props?.open?.value && props?.open?.value !== open.value) {
72
+ props.open.value = open.value;
73
+ }
74
+ });
75
+ qwik.useOnDocument("click", qwik.$((event) => {
76
+ if (open.value && dropdownRef.value && !dropdownRef.value.contains(event.target)) {
77
+ console.log("close");
78
+ open.value = false;
79
+ }
80
+ }));
81
+ qwik.useOnDocument("keydown", qwik.$((event) => {
82
+ if (open.value && event.key === "Escape") {
83
+ event.preventDefault();
84
+ event.stopImmediatePropagation();
85
+ if (document.activeElement instanceof HTMLElement) {
86
+ document.activeElement.blur();
87
+ }
88
+ open.value = false;
89
+ }
90
+ }));
46
91
  return /* @__PURE__ */ jsxRuntime.jsx("div", {
47
- class: `dropdown dropdown-top ${props?.class ?? ""}`,
92
+ ref: dropdownRef,
93
+ class: `dropdown dropdown-top ${open.value ? "dropdown-open" : "dropdown-close"} ${props?.class ?? ""}`,
94
+ onClick$: () => {
95
+ open.value = !open.value;
96
+ },
48
97
  children: /* @__PURE__ */ jsxRuntime.jsx(qwik.Slot, {})
49
98
  });
50
99
  });
51
100
  exports.DropUp = DropUp;
101
+ exports.DropUpButton = DropUpButton;
52
102
  exports.DropUpButtonSelector = DropUpButtonSelector;
53
- exports.DropUpItem = DropUpItem;
103
+ exports.DropUpLink = DropUpLink;
54
104
  exports.DropUpSubmenu = DropUpSubmenu;
@@ -1,24 +1,39 @@
1
1
  import { jsx } from "@builder.io/qwik/jsx-runtime";
2
- import { component$, Slot } from "@builder.io/qwik";
3
- import { useNavigate, Link } from "@builder.io/qwik-city";
4
- const DropUpItem = component$((props) => {
5
- const nav = useNavigate();
2
+ import { component$, Slot, useSignal, useTask$, useOnDocument, $ } from "@builder.io/qwik";
3
+ import { Link } from "@builder.io/qwik-city";
4
+ const DropUpButton = component$((props) => {
6
5
  return /* @__PURE__ */ jsx("li", {
6
+ class: props.class ?? "",
7
+ children: /* @__PURE__ */ jsx("button", {
8
+ class: `text-nowrap ${props?.buttonClass ?? null}`,
9
+ onClick$: async (event) => {
10
+ if (props.loading) {
11
+ props.loading.value = true;
12
+ }
13
+ await props.onClick$(event);
14
+ if (props.loading) {
15
+ props.loading.value = false;
16
+ }
17
+ }
18
+ })
19
+ });
20
+ });
21
+ const DropUpLink = component$((props) => {
22
+ return /* @__PURE__ */ jsx("li", {
23
+ class: props.class ?? "",
7
24
  children: /* @__PURE__ */ jsx(Link, {
8
25
  href: props.href,
9
26
  prefetch: props.prefetch,
10
- class: `text-nowrap ${props?.class ?? null}`,
27
+ class: `text-nowrap ${props?.linkClass ?? null}`,
11
28
  onClick$: async (event) => {
29
+ if (props.loading) {
30
+ props.loading.value = true;
31
+ }
12
32
  if (props.onClick$) {
13
33
  await props.onClick$(event);
14
- } else {
15
- if (props.loading) {
16
- props.loading.value = true;
17
- }
18
- await nav(props.href);
19
- if (props.loading) {
20
- props.loading.value = false;
21
- }
34
+ }
35
+ if (props.loading) {
36
+ props.loading.value = false;
22
37
  }
23
38
  },
24
39
  children: /* @__PURE__ */ jsx(Slot, {})
@@ -41,14 +56,49 @@ const DropUpButtonSelector = component$((props) => {
41
56
  });
42
57
  });
43
58
  const DropUp = component$((props) => {
59
+ const open = useSignal(props?.open?.value ?? false);
60
+ const dropdownRef = useSignal();
61
+ useTask$(({ track }) => {
62
+ track(() => props?.open?.value);
63
+ if (props?.open?.value && props.open.value !== open.value) {
64
+ open.value = props.open.value;
65
+ }
66
+ });
67
+ useTask$(({ track }) => {
68
+ track(() => open.value);
69
+ if (props?.open?.value && props?.open?.value !== open.value) {
70
+ props.open.value = open.value;
71
+ }
72
+ });
73
+ useOnDocument("click", $((event) => {
74
+ if (open.value && dropdownRef.value && !dropdownRef.value.contains(event.target)) {
75
+ console.log("close");
76
+ open.value = false;
77
+ }
78
+ }));
79
+ useOnDocument("keydown", $((event) => {
80
+ if (open.value && event.key === "Escape") {
81
+ event.preventDefault();
82
+ event.stopImmediatePropagation();
83
+ if (document.activeElement instanceof HTMLElement) {
84
+ document.activeElement.blur();
85
+ }
86
+ open.value = false;
87
+ }
88
+ }));
44
89
  return /* @__PURE__ */ jsx("div", {
45
- class: `dropdown dropdown-top ${props?.class ?? ""}`,
90
+ ref: dropdownRef,
91
+ class: `dropdown dropdown-top ${open.value ? "dropdown-open" : "dropdown-close"} ${props?.class ?? ""}`,
92
+ onClick$: () => {
93
+ open.value = !open.value;
94
+ },
46
95
  children: /* @__PURE__ */ jsx(Slot, {})
47
96
  });
48
97
  });
49
98
  export {
50
99
  DropUp,
100
+ DropUpButton,
51
101
  DropUpButtonSelector,
52
- DropUpItem,
102
+ DropUpLink,
53
103
  DropUpSubmenu
54
104
  };
@@ -7,7 +7,7 @@ const MenuButton = qwik.component$((props) => {
7
7
  return /* @__PURE__ */ jsxRuntime.jsx("li", {
8
8
  class: props.class ?? "",
9
9
  children: /* @__PURE__ */ jsxRuntime.jsx("button", {
10
- class: `truncate ${props.selected ? "bg-base-200" : ""} ${props.linkClass ?? ""}`,
10
+ class: `truncate ${props.selected ? "bg-base-200" : ""} ${props.buttonClass ?? ""}`,
11
11
  onClick$: async (event) => {
12
12
  if (props.loading) {
13
13
  props.loading.value = true;
@@ -28,6 +28,7 @@ const MenuLink = qwik.component$((props) => {
28
28
  class: `truncate ${props.selected ? "bg-base-200" : ""} ${props.linkClass ?? ""}`,
29
29
  href: props.href,
30
30
  prefetch: props.prefetch ?? true,
31
+ target: props.target,
31
32
  onClick$: async (event) => {
32
33
  if (props.loading) {
33
34
  props.loading.value = true;
@@ -5,7 +5,7 @@ const MenuButton = component$((props) => {
5
5
  return /* @__PURE__ */ jsx("li", {
6
6
  class: props.class ?? "",
7
7
  children: /* @__PURE__ */ jsx("button", {
8
- class: `truncate ${props.selected ? "bg-base-200" : ""} ${props.linkClass ?? ""}`,
8
+ class: `truncate ${props.selected ? "bg-base-200" : ""} ${props.buttonClass ?? ""}`,
9
9
  onClick$: async (event) => {
10
10
  if (props.loading) {
11
11
  props.loading.value = true;
@@ -26,6 +26,7 @@ const MenuLink = component$((props) => {
26
26
  class: `truncate ${props.selected ? "bg-base-200" : ""} ${props.linkClass ?? ""}`,
27
27
  href: props.href,
28
28
  prefetch: props.prefetch ?? true,
29
+ target: props.target,
29
30
  onClick$: async (event) => {
30
31
  if (props.loading) {
31
32
  props.loading.value = true;
@@ -35,8 +35,9 @@ exports.DockLabel = dock.DockLabel;
35
35
  exports.DockLink = dock.DockLink;
36
36
  exports.FixedCenterBottom = fixedCenterBottom.FixedCenterBottom;
37
37
  exports.DropUp = dropUp.DropUp;
38
+ exports.DropUpButton = dropUp.DropUpButton;
38
39
  exports.DropUpButtonSelector = dropUp.DropUpButtonSelector;
39
- exports.DropUpItem = dropUp.DropUpItem;
40
+ exports.DropUpLink = dropUp.DropUpLink;
40
41
  exports.DropUpSubmenu = dropUp.DropUpSubmenu;
41
42
  exports.GoogleSignInButton = googleSignInButton.GoogleSignInButton;
42
43
  exports.GtmBody = gtm.GtmBody;
@@ -8,7 +8,7 @@ import { CheckboxField } from "./components/checkbox-field.qwik.mjs";
8
8
  import { Dialog } from "./components/dialog.qwik.mjs";
9
9
  import { Dock, DockButton, DockLabel, DockLink } from "./components/dock.qwik.mjs";
10
10
  import { FixedCenterBottom } from "./components/fixed-center-bottom.qwik.mjs";
11
- import { DropUp, DropUpButtonSelector, DropUpItem, DropUpSubmenu } from "./components/drop-up.qwik.mjs";
11
+ import { DropUp, DropUpButton, DropUpButtonSelector, DropUpLink, DropUpSubmenu } from "./components/drop-up.qwik.mjs";
12
12
  import { GoogleSignInButton } from "./components/google-sign-in-button.qwik.mjs";
13
13
  import { GtmBody, GtmHead } from "./components/gtm.qwik.mjs";
14
14
  import { Menu, MenuButton, MenuDivider, MenuGroup, MenuGroupSummary, MenuLink, Submenu } from "./components/menu.qwik.mjs";
@@ -33,8 +33,9 @@ export {
33
33
  DockLabel,
34
34
  DockLink,
35
35
  DropUp,
36
+ DropUpButton,
36
37
  DropUpButtonSelector,
37
- DropUpItem,
38
+ DropUpLink,
38
39
  DropUpSubmenu,
39
40
  FixedCenterBottom,
40
41
  GoogleSignInButton,
@@ -1,22 +1,30 @@
1
1
  import { QRL, Signal } from '@builder.io/qwik';
2
- export interface DropUpItemProps {
3
- href?: string;
2
+ export interface DropUpButtonProps {
3
+ loading?: Signal<boolean>;
4
+ onClick$: QRL<(event: Event) => void>;
5
+ class?: string;
6
+ buttonClass?: string;
7
+ }
8
+ export declare const DropUpButton: import("@builder.io/qwik").Component<DropUpButtonProps>;
9
+ export interface DropUpLinkProps {
10
+ href: string;
4
11
  prefetch?: boolean;
5
- selected?: boolean;
6
12
  loading?: Signal<boolean>;
7
13
  onClick$?: QRL<(event: Event) => void>;
8
14
  class?: string;
15
+ linkClass?: string;
9
16
  }
10
- export declare const DropUpItem: import("@builder.io/qwik").Component<DropUpItemProps>;
17
+ export declare const DropUpLink: import("@builder.io/qwik").Component<DropUpLinkProps>;
11
18
  export interface DropUpSubmenuProps {
12
19
  class?: string;
13
20
  }
14
21
  export declare const DropUpSubmenu: import("@builder.io/qwik").Component<DropUpSubmenuProps | undefined>;
15
- export interface DropUpButtonProps {
22
+ export interface DropUpButtonSelectorProps {
16
23
  class?: string;
17
24
  }
18
- export declare const DropUpButtonSelector: import("@builder.io/qwik").Component<DropUpButtonProps | undefined>;
25
+ export declare const DropUpButtonSelector: import("@builder.io/qwik").Component<DropUpButtonSelectorProps | undefined>;
19
26
  export interface DropUpProps {
20
27
  class?: string;
28
+ open?: Signal<boolean>;
21
29
  }
22
30
  export declare const DropUp: import("@builder.io/qwik").Component<DropUpProps | undefined>;
@@ -4,7 +4,7 @@ export interface MenuButtonProps {
4
4
  loading?: Signal<boolean>;
5
5
  selected?: boolean;
6
6
  onClick$: QRL<(event: Event) => void>;
7
- linkClass?: string;
7
+ buttonClass?: string;
8
8
  }
9
9
  export declare const MenuButton: import("@builder.io/qwik").Component<MenuButtonProps>;
10
10
  export interface MenuLinkProps {
@@ -15,6 +15,7 @@ export interface MenuLinkProps {
15
15
  onClick$?: QRL<(event: Event) => void>;
16
16
  class?: string;
17
17
  linkClass?: string;
18
+ target?: string;
18
19
  }
19
20
  export declare const MenuLink: import("@builder.io/qwik").Component<MenuLinkProps>;
20
21
  export interface MenuGroupSummaryProps {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nr1e/qwik-ui",
3
- "version": "0.1.4",
3
+ "version": "1.0.1",
4
4
  "description": "NR1E Qwik UI Library",
5
5
  "author": "NR1E, Inc.",
6
6
  "publishConfig": {
@@ -36,7 +36,7 @@
36
36
  "peerDependencies": {
37
37
  "@builder.io/qwik-city": "1.19.0",
38
38
  "tailwindcss-animated": "2.0.0",
39
- "@nr1e/qwik-icons": "0.0.20"
39
+ "@nr1e/qwik-icons": "0.0.24"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@builder.io/qwik": "1.19.0",