@konstructio/ui 0.1.4 → 0.1.6

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.
@@ -1,25 +1,30 @@
1
- import { useEffect as s, useState as l } from "react";
2
- var u = "https://gravatar.com/avatar", c = (r) => Array.from(new Uint8Array(r)).map((t) => t.toString(16).padStart(2, "0")).join(""), i = async (r, t) => {
3
- const a = globalThis.crypto?.subtle;
4
- if (!a) return null;
5
- const e = new TextEncoder().encode(r.trim().toLowerCase()), n = c(await a.digest("SHA-256", e));
6
- return `${u}/${n}?d=404&s=${t}`;
7
- }, f = (r, t) => {
8
- const [a, e] = l(null);
9
- return s(() => {
1
+ import { useEffect as c, useState as v } from "react";
2
+ var d = "https://gravatar.com/avatar", o = /* @__PURE__ */ new Map(), l = (r, t) => `${r.trim().toLowerCase()}|${t}`, f = (r) => Array.from(new Uint8Array(r)).map((t) => t.toString(16).padStart(2, "0")).join(""), h = async (r, t) => {
3
+ const n = globalThis.crypto?.subtle;
4
+ if (!n) return null;
5
+ const e = new TextEncoder().encode(r.trim().toLowerCase()), a = f(await n.digest("SHA-256", e));
6
+ return `${d}/${a}?d=404&s=${t}`;
7
+ }, p = (r, t) => {
8
+ const [n, e] = v(() => r ? o.get(l(r, t)) ?? null : null);
9
+ return c(() => {
10
10
  if (!r) {
11
11
  e(null);
12
12
  return;
13
13
  }
14
- let n = !1;
15
- return i(r, t).then((o) => {
16
- n || e(o);
14
+ const a = l(r, t);
15
+ if (o.has(a)) {
16
+ e(o.get(a) ?? null);
17
+ return;
18
+ }
19
+ let s = !1;
20
+ return h(r, t).then((u) => {
21
+ o.set(a, u), s || e(u);
17
22
  }), () => {
18
- n = !0;
23
+ s = !0;
19
24
  };
20
- }, [r, t]), a;
25
+ }, [r, t]), n;
21
26
  };
22
27
  export {
23
- i as buildGravatarUrl,
24
- f as useGravatarUrl
28
+ h as buildGravatarUrl,
29
+ p as useGravatarUrl
25
30
  };
@@ -1,29 +1,29 @@
1
1
  import { t as x } from "../../x-C8O1IsaM.js";
2
2
  import { LoaderIcon as D } from "../../assets/icons/components/Loader.js";
3
- import { t as u } from "../../utils-DnIJruo0.js";
3
+ import { t as c } from "../../utils-DnIJruo0.js";
4
4
  import { badgeVariants as V, buttonDismissVariants as j } from "./Badge.variants.js";
5
5
  import { t as f } from "../../dist-CK8FUUUn.js";
6
6
  import { useEffect as E, useRef as L, useState as P } from "react";
7
7
  import { jsx as s, jsxs as p } from "react/jsx-runtime";
8
- var q = ({ className: b, dismissible: v = !1, isSelectable: g = !0, label: i, leftIcon: n, loading: o = !1, rightIcon: l, size: m, variant: c, onClick: e, onDismiss: h }) => {
9
- const d = L(null), [r, N] = P("visible"), y = (a) => {
10
- a.stopPropagation(), h?.(), N("hidden");
8
+ var q = ({ className: b, dismissible: g = !1, isSelectable: h = !0, label: i, leftIcon: n, loading: o = !1, rightIcon: l, size: m, variant: d, onClick: e, onDismiss: v }) => {
9
+ const u = L(null), [r, N] = P("visible"), y = (a) => {
10
+ a.stopPropagation(), v?.(), N("hidden");
11
11
  };
12
12
  return E(() => {
13
13
  if (r !== "hidden") return;
14
- const a = new AbortController(), t = d.current;
14
+ const a = new AbortController(), t = u.current;
15
15
  return t?.addEventListener("animationend", (w) => {
16
16
  w.target === t && (t.style.setProperty("display", "none"), t.remove());
17
17
  }, { signal: a.signal }), () => a.abort();
18
18
  }, [r]), /* @__PURE__ */ p("span", {
19
- ref: d,
20
- className: u(V({
21
- variant: c,
19
+ ref: u,
20
+ className: c(V({
21
+ variant: d,
22
22
  size: m,
23
23
  className: b
24
24
  }), {
25
- "select-none": !g,
26
- "cursor-pointer tap-target outline-none focus-visible:ring-1 focus-visible:ring-aurora-500 active:scale-95 motion-reduce:active:scale-100": e
25
+ "select-none": !h,
26
+ "cursor-pointer tap-target outline-none focus-visible:ring-1 focus-visible:ring-aurora-500 pointer-coarse:motion-safe:active:scale-95": e
27
27
  }),
28
28
  role: e ? "button" : void 0,
29
29
  onClick: e,
@@ -42,11 +42,11 @@ var q = ({ className: b, dismissible: v = !1, isSelectable: g = !0, label: i, le
42
42
  children: n
43
43
  }) : null,
44
44
  i,
45
- v ? /* @__PURE__ */ p("button", {
45
+ g ? /* @__PURE__ */ p("button", {
46
46
  type: "button",
47
- className: u(j({
47
+ className: c(j({
48
48
  size: m,
49
- variant: c
49
+ variant: d
50
50
  })),
51
51
  onClick: y,
52
52
  "aria-label": "Dismiss",
@@ -1,30 +1,31 @@
1
- import { t as x } from "../../dist-CK8FUUUn.js";
2
- import { t as b } from "../../utils-DnIJruo0.js";
3
- import { buttonVariants as l } from "./Button.variants.js";
4
- import { forwardRef as v } from "react";
5
- import { jsx as B } from "react/jsx-runtime";
6
- var N = v(({ appearance: r, asChild: o = !1, className: n, disabled: t = !1, shape: a, size: e, theme: m, variant: s, version: p, ...f }, u) => {
7
- const i = o ? x : "button", c = o && t ? {
1
+ import { t as b } from "../../dist-CK8FUUUn.js";
2
+ import { t as l } from "../../utils-DnIJruo0.js";
3
+ import { buttonVariants as v } from "./Button.variants.js";
4
+ import { forwardRef as B } from "react";
5
+ import { jsx as N } from "react/jsx-runtime";
6
+ var j = B(({ appearance: r, asChild: o = !1, className: e, disabled: t = !1, pressEffect: n = !0, shape: a, size: m, theme: s, variant: p, version: f, ...u }, i) => {
7
+ const c = o ? b : "button", x = o && t ? {
8
8
  "aria-disabled": !0,
9
9
  tabIndex: -1
10
10
  } : { disabled: t };
11
- return /* @__PURE__ */ B(i, {
12
- ref: u,
13
- "data-theme": m,
14
- className: b(l({
11
+ return /* @__PURE__ */ N(c, {
12
+ ref: i,
13
+ "data-theme": s,
14
+ className: l(v({
15
15
  appearance: r,
16
- className: n,
16
+ className: e,
17
17
  disabled: t,
18
+ pressEffect: n,
18
19
  shape: a,
19
- size: e,
20
- variant: s,
21
- version: p
20
+ size: m,
21
+ variant: p,
22
+ version: f
22
23
  }), o && t && "pointer-events-none"),
23
- ...c,
24
- ...f
24
+ ...x,
25
+ ...u
25
26
  });
26
27
  });
27
- N.displayName = "KonstructButton";
28
+ j.displayName = "KonstructButton";
28
29
  export {
29
- N as Button
30
+ j as Button
30
31
  };
@@ -20,8 +20,6 @@ var a = r([
20
20
  "rounded",
21
21
  "transition-[color,background-color,border-color,transform]",
22
22
  "duration-150",
23
- "active:scale-[0.97]",
24
- "motion-reduce:active:scale-100",
25
23
  "whitespace-nowrap",
26
24
  "h-10",
27
25
  "pointer-coarse:min-h-11",
@@ -41,6 +39,10 @@ var a = r([
41
39
  "kubefirst:text-white"
42
40
  ], {
43
41
  variants: {
42
+ pressEffect: {
43
+ true: "pointer-coarse:motion-safe:active:scale-[0.97]",
44
+ false: ""
45
+ },
44
46
  variant: {
45
47
  primary: "",
46
48
  secondary: ["bg-white"],
@@ -322,6 +324,7 @@ var a = r([
322
324
  }
323
325
  ],
324
326
  defaultVariants: {
327
+ pressEffect: !0,
325
328
  variant: "primary",
326
329
  version: "default",
327
330
  disabled: !1,
@@ -9,8 +9,7 @@ var t = e([
9
9
  "focus-visible:outline-2",
10
10
  "focus-visible:outline-offset-2",
11
11
  "focus-visible:outline-aurora-500",
12
- "active:scale-90",
13
- "motion-reduce:active:scale-100",
12
+ "pointer-coarse:motion-safe:active:scale-90",
14
13
  "border",
15
14
  "rounded",
16
15
  "w-5",
@@ -6,22 +6,22 @@ import { t as k } from "../../../../chevron-right-D4OkgIIT.js";
6
6
  import '../../../../style.css';/* empty css */
7
7
  import { useState as g } from "react";
8
8
  import { jsx as a } from "react/jsx-runtime";
9
- var v = ({ className: o, showOutsideDays: n = !0, animate: l = !0, arrowClassName: s, monthsClassName: d, defaultSelected: i, onSelect: m, ...c }) => {
10
- const [u, x] = g(() => i), b = (e) => {
9
+ var w = ({ className: o, showOutsideDays: n = !0, animate: l = !0, arrowClassName: s, monthsClassName: d, defaultSelected: i, onSelect: m, ...u }) => {
10
+ const [c, x] = g(() => i), b = (e) => {
11
11
  e && (x(e), m?.(e));
12
12
  };
13
13
  return /* @__PURE__ */ a(f, {
14
14
  className: t(h({ className: o })),
15
15
  animate: l,
16
16
  mode: "single",
17
- selected: u,
17
+ selected: c,
18
18
  onSelect: b,
19
19
  showOutsideDays: n,
20
20
  role: "dialog",
21
21
  "aria-label": "Datepicker",
22
22
  classNames: {
23
23
  chevron: t("cursor-pointer", "text-slate-500", "w-5", "h-5", "text-slate-500", "w-4", "h-4", "dark:text-metal-200"),
24
- day_button: t("h-7.5", "aria-selected:opacity-100", "font-semibold", "hover:rounded-full", "cursor-pointer", "tap-target", "rounded-full", "w-7.5", "pointer-coarse:size-10", "active:scale-90", "motion-reduce:active:scale-100", "transition-transform"),
24
+ day_button: t("h-7.5", "aria-selected:opacity-100", "font-semibold", "hover:rounded-full", "cursor-pointer", "tap-target", "rounded-full", "w-7.5", "pointer-coarse:size-10", "pointer-coarse:motion-safe:active:scale-90", "transition-transform"),
25
25
  day: "text-center text-sm leading-5",
26
26
  month_caption: t("text-slate-700", "font-semibold", "text-sm", "pl-1", "h-8", "flex", "items-center", "dark:text-white"),
27
27
  months: t("flex", "flex-col", "relative", "px-5", "py-4", "rounded-lg", "shadow-md", "px-6", "py-4", "w-[307px]", "justify-center", "items-center", "border", "border-transparent", "dark:bg-metal-800", "dark:border-metal-700", d),
@@ -42,10 +42,10 @@ var v = ({ className: o, showOutsideDays: n = !0, animate: l = !0, arrowClassNam
42
42
  className: t(e),
43
43
  ...r
44
44
  }) },
45
- ...c
45
+ ...u
46
46
  });
47
47
  };
48
- v.displayName = "DatePickerContent";
48
+ w.displayName = "DatePickerContent";
49
49
  export {
50
- v as DatePickerContent
50
+ w as DatePickerContent
51
51
  };