@nr1e/qwik-ui 1.0.0 → 1.0.2

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.
@@ -59,6 +59,7 @@ const DropUpButtonSelector = qwik.component$((props) => {
59
59
  });
60
60
  const DropUp = qwik.component$((props) => {
61
61
  const open = qwik.useSignal(props?.open?.value ?? false);
62
+ const dropdownRef = qwik.useSignal();
62
63
  qwik.useTask$(({ track }) => {
63
64
  track(() => props?.open?.value);
64
65
  if (props?.open?.value && props.open.value !== open.value) {
@@ -71,7 +72,24 @@ const DropUp = qwik.component$((props) => {
71
72
  props.open.value = open.value;
72
73
  }
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
+ }));
74
91
  return /* @__PURE__ */ jsxRuntime.jsx("div", {
92
+ ref: dropdownRef,
75
93
  class: `dropdown dropdown-top ${open.value ? "dropdown-open" : "dropdown-close"} ${props?.class ?? ""}`,
76
94
  onClick$: () => {
77
95
  open.value = !open.value;
@@ -1,5 +1,5 @@
1
1
  import { jsx } from "@builder.io/qwik/jsx-runtime";
2
- import { component$, Slot, useSignal, useTask$ } from "@builder.io/qwik";
2
+ import { component$, Slot, useSignal, useTask$, useOnDocument, $ } from "@builder.io/qwik";
3
3
  import { Link } from "@builder.io/qwik-city";
4
4
  const DropUpButton = component$((props) => {
5
5
  return /* @__PURE__ */ jsx("li", {
@@ -57,6 +57,7 @@ const DropUpButtonSelector = component$((props) => {
57
57
  });
58
58
  const DropUp = component$((props) => {
59
59
  const open = useSignal(props?.open?.value ?? false);
60
+ const dropdownRef = useSignal();
60
61
  useTask$(({ track }) => {
61
62
  track(() => props?.open?.value);
62
63
  if (props?.open?.value && props.open.value !== open.value) {
@@ -69,7 +70,24 @@ const DropUp = component$((props) => {
69
70
  props.open.value = open.value;
70
71
  }
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
+ }));
72
89
  return /* @__PURE__ */ jsx("div", {
90
+ ref: dropdownRef,
73
91
  class: `dropdown dropdown-top ${open.value ? "dropdown-open" : "dropdown-close"} ${props?.class ?? ""}`,
74
92
  onClick$: () => {
75
93
  open.value = !open.value;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("@builder.io/qwik/jsx-runtime");
4
+ const qwik = require("@builder.io/qwik");
5
+ const lang = require("@nr1e/commons/lang");
6
+ const FormatDateTime = qwik.component$((props) => {
7
+ const date = qwik.useSignal(null);
8
+ if (!props.date) return null;
9
+ qwik.useVisibleTask$(() => {
10
+ if (props.date) {
11
+ let timeZone = props.timeZone;
12
+ if (!props.timeZone) {
13
+ timeZone = localStorage.getItem("timezone");
14
+ if (!timeZone || timeZone === "auto") {
15
+ timeZone = null;
16
+ }
17
+ }
18
+ date.value = lang.formatTimeZoneDateTimeReadable(props.date, timeZone ?? void 0, props.locale ?? void 0);
19
+ }
20
+ });
21
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {
22
+ children: date.value
23
+ });
24
+ });
25
+ exports.FormatDateTime = FormatDateTime;
@@ -0,0 +1,25 @@
1
+ import { jsx, Fragment } from "@builder.io/qwik/jsx-runtime";
2
+ import { component$, useSignal, useVisibleTask$ } from "@builder.io/qwik";
3
+ import { formatTimeZoneDateTimeReadable } from "@nr1e/commons/lang";
4
+ const FormatDateTime = component$((props) => {
5
+ const date = useSignal(null);
6
+ if (!props.date) return null;
7
+ useVisibleTask$(() => {
8
+ if (props.date) {
9
+ let timeZone = props.timeZone;
10
+ if (!props.timeZone) {
11
+ timeZone = localStorage.getItem("timezone");
12
+ if (!timeZone || timeZone === "auto") {
13
+ timeZone = null;
14
+ }
15
+ }
16
+ date.value = formatTimeZoneDateTimeReadable(props.date, timeZone ?? void 0, props.locale ?? void 0);
17
+ }
18
+ });
19
+ return /* @__PURE__ */ jsx(Fragment, {
20
+ children: date.value
21
+ });
22
+ });
23
+ export {
24
+ FormatDateTime
25
+ };
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("@builder.io/qwik/jsx-runtime");
4
+ const qwik = require("@builder.io/qwik");
5
+ const lang = require("@nr1e/commons/lang");
6
+ const FormatDate = qwik.component$((props) => {
7
+ const date = qwik.useSignal(null);
8
+ if (!props.date) return null;
9
+ qwik.useVisibleTask$(() => {
10
+ if (props.date) {
11
+ let timeZone = props.timeZone;
12
+ if (!props.timeZone) {
13
+ timeZone = localStorage.getItem("timezone");
14
+ if (!timeZone || timeZone === "auto") {
15
+ timeZone = null;
16
+ }
17
+ }
18
+ date.value = lang.formatTimeZoneDateShort(props.date, timeZone ?? void 0, props.locale ?? void 0);
19
+ }
20
+ });
21
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {
22
+ children: date.value
23
+ });
24
+ });
25
+ exports.FormatDate = FormatDate;
@@ -0,0 +1,25 @@
1
+ import { jsx, Fragment } from "@builder.io/qwik/jsx-runtime";
2
+ import { component$, useSignal, useVisibleTask$ } from "@builder.io/qwik";
3
+ import { formatTimeZoneDateShort } from "@nr1e/commons/lang";
4
+ const FormatDate = component$((props) => {
5
+ const date = useSignal(null);
6
+ if (!props.date) return null;
7
+ useVisibleTask$(() => {
8
+ if (props.date) {
9
+ let timeZone = props.timeZone;
10
+ if (!props.timeZone) {
11
+ timeZone = localStorage.getItem("timezone");
12
+ if (!timeZone || timeZone === "auto") {
13
+ timeZone = null;
14
+ }
15
+ }
16
+ date.value = formatTimeZoneDateShort(props.date, timeZone ?? void 0, props.locale ?? void 0);
17
+ }
18
+ });
19
+ return /* @__PURE__ */ jsx(Fragment, {
20
+ children: date.value
21
+ });
22
+ });
23
+ export {
24
+ FormatDate
25
+ };
@@ -10,6 +10,8 @@ const checkboxField = require("./components/checkbox-field.qwik.cjs");
10
10
  const dialog = require("./components/dialog.qwik.cjs");
11
11
  const dock = require("./components/dock.qwik.cjs");
12
12
  const fixedCenterBottom = require("./components/fixed-center-bottom.qwik.cjs");
13
+ const formatDate = require("./components/format-date.qwik.cjs");
14
+ const formatDateTime = require("./components/format-date-time.qwik.cjs");
13
15
  const dropUp = require("./components/drop-up.qwik.cjs");
14
16
  const googleSignInButton = require("./components/google-sign-in-button.qwik.cjs");
15
17
  const gtm = require("./components/gtm.qwik.cjs");
@@ -34,6 +36,8 @@ exports.DockButton = dock.DockButton;
34
36
  exports.DockLabel = dock.DockLabel;
35
37
  exports.DockLink = dock.DockLink;
36
38
  exports.FixedCenterBottom = fixedCenterBottom.FixedCenterBottom;
39
+ exports.FormatDate = formatDate.FormatDate;
40
+ exports.FormatDateTime = formatDateTime.FormatDateTime;
37
41
  exports.DropUp = dropUp.DropUp;
38
42
  exports.DropUpButton = dropUp.DropUpButton;
39
43
  exports.DropUpButtonSelector = dropUp.DropUpButtonSelector;
@@ -8,6 +8,8 @@ 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 { FormatDate } from "./components/format-date.qwik.mjs";
12
+ import { FormatDateTime } from "./components/format-date-time.qwik.mjs";
11
13
  import { DropUp, DropUpButton, DropUpButtonSelector, DropUpLink, DropUpSubmenu } from "./components/drop-up.qwik.mjs";
12
14
  import { GoogleSignInButton } from "./components/google-sign-in-button.qwik.mjs";
13
15
  import { GtmBody, GtmHead } from "./components/gtm.qwik.mjs";
@@ -38,6 +40,8 @@ export {
38
40
  DropUpLink,
39
41
  DropUpSubmenu,
40
42
  FixedCenterBottom,
43
+ FormatDate,
44
+ FormatDateTime,
41
45
  GoogleSignInButton,
42
46
  GtmBody,
43
47
  GtmHead,
@@ -0,0 +1,6 @@
1
+ export interface FormatDateTimeProps {
2
+ timeZone?: string | null;
3
+ locale?: string | null;
4
+ date: Date | string | null;
5
+ }
6
+ export declare const FormatDateTime: import("@builder.io/qwik").Component<FormatDateTimeProps>;
@@ -0,0 +1,6 @@
1
+ export interface FormatDateProps {
2
+ timeZone?: string | null;
3
+ locale?: string | null;
4
+ date: Date | string | null;
5
+ }
6
+ export declare const FormatDate: import("@builder.io/qwik").Component<FormatDateProps>;
@@ -8,6 +8,8 @@ export * from './components/checkbox-field';
8
8
  export * from './components/dialog';
9
9
  export * from './components/dock';
10
10
  export * from './components/fixed-center-bottom';
11
+ export * from './components/format-date';
12
+ export * from './components/format-date-time';
11
13
  export * from './components/drop-up';
12
14
  export * from './components/google-sign-in-button';
13
15
  export * from './components/gtm';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nr1e/qwik-ui",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "NR1E Qwik UI Library",
5
5
  "author": "NR1E, Inc.",
6
6
  "publishConfig": {
@@ -36,7 +36,8 @@
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.24"
39
+ "@nr1e/qwik-icons": "0.0.25",
40
+ "@nr1e/commons": "0.4.3"
40
41
  },
41
42
  "devDependencies": {
42
43
  "@builder.io/qwik": "1.19.0",