@noxickon/onyx 0.0.3 → 0.0.4-dev.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.
Files changed (40) hide show
  1. package/dist/chunks/Button-D-v4l8ZE.js +20 -0
  2. package/dist/chunks/{Button-BV4_pmoH.js → Button-bARrxYyo.js} +120 -121
  3. package/dist/chunks/Input-CLi1H63d.js +1 -0
  4. package/dist/chunks/{Input-BraK4lDE.js → Input-dfvmdIHi.js} +38 -38
  5. package/dist/chunks/errorHelper--G-SWQzN.js +18 -0
  6. package/dist/chunks/errorHelper-DaP_XxEx.js +1 -0
  7. package/dist/chunks/formatTimestamp-CMxOnPo1.js +12 -0
  8. package/dist/chunks/formatTimestamp-TTsNcy7u.js +1 -0
  9. package/dist/chunks/{index-DnVdNmco.js → useAuth-DDRXztKj.js} +240 -178
  10. package/dist/chunks/{index-DGjVEo0G.js → useAuth-DPnpY3XC.js} +18 -9
  11. package/dist/chunks/{useForm-BAbY8X4X.js → useForm-D4co95Vn.js} +785 -801
  12. package/dist/chunks/useForm-DUviJ7xS.js +18 -0
  13. package/dist/chunks/useQuery-BvCyJMae.js +2065 -0
  14. package/dist/chunks/useQuery-DTNHO7so.js +3 -0
  15. package/dist/context/context.cjs.js +1 -1
  16. package/dist/context/context.es.js +1 -1
  17. package/dist/context.d.ts +1 -0
  18. package/dist/hooks/hooks.cjs.js +6 -6
  19. package/dist/hooks/hooks.es.js +117 -118
  20. package/dist/index.css +1 -1
  21. package/dist/index.d.ts +18 -0
  22. package/dist/layout/layout.cjs.js +1 -1
  23. package/dist/layout/layout.es.js +1 -1
  24. package/dist/onyx.cjs.js +1 -1
  25. package/dist/onyx.es.js +425 -386
  26. package/dist/pages/pages.cjs.js +8 -2
  27. package/dist/pages/pages.es.js +34 -24
  28. package/dist/utils/utils.cjs.js +1 -0
  29. package/dist/utils/utils.es.js +8 -0
  30. package/dist/utils.d.ts +29 -0
  31. package/package.json +31 -26
  32. package/dist/chunks/Button-CU-zvMVL.js +0 -20
  33. package/dist/chunks/Input-C5dK8VSu.js +0 -1
  34. package/dist/chunks/index-Dgwp7JKP.js +0 -601
  35. package/dist/chunks/index-rUH_mzKt.js +0 -2
  36. package/dist/chunks/useAuth-BwjRd05B.js +0 -10
  37. package/dist/chunks/useAuth-CR3bAGqp.js +0 -61
  38. package/dist/chunks/useForm-cxgyAiOs.js +0 -26
  39. package/dist/chunks/useQuery--6GP2-dN.js +0 -2
  40. package/dist/chunks/useQuery-mFRa2XuW.js +0 -1481
@@ -0,0 +1 @@
1
+ "use strict";const e=require("./jsx-runtime-CITbqOLs.js"),p=require("react"),x=require("./Button-D-v4l8ZE.js"),F=require("./isObject-BDHKUJKN.js"),N=({children:n,className:r,disabled:s=!1,htmlFor:t,required:l=!1})=>e.jsxRuntimeExports.jsxs("label",{id:`${t}-label`,className:x.twMerge("block text-sm font-medium text-neutral-300",s&&"cursor-not-allowed text-neutral-500",r),htmlFor:t,children:[n,l&&e.jsxRuntimeExports.jsx("span",{className:"ml-1 text-rose-400",children:"*"})]}),I=({children:n,className:r,disabled:s=!1,id:t})=>e.jsxRuntimeExports.jsx("p",{id:t,className:x.twMerge("text-xs text-neutral-400",s&&"text-neutral-500",r),children:n}),f=({children:n,className:r,icon:s="mdiAlertCircleOutline",id:t})=>n?e.jsxRuntimeExports.jsxs("div",{id:t,className:x.twMerge("flex max-w-full items-center gap-1 text-xs text-rose-400",r),role:"alert",children:[s?e.jsxRuntimeExports.jsx(x.OxIcon,{className:"flex-shrink-0",icon:s,size:.8}):null,e.jsxRuntimeExports.jsx("p",{className:"min-w-0 break-words",children:n})]}):null,S=({children:n,className:r,fullWidth:s=!1,noValidate:t=!0,...l})=>e.jsxRuntimeExports.jsx("form",{className:x.twMerge(s&&"w-full",r),noValidate:t,...l,children:n}),G=({className:n,description:r,disabled:s=!1,error:t=!1,errorMessage:l,icon:a="",iconPosition:c="left",id:y,label:j,name:L,onChange:v,placeholder:$="Input placeholder...",readOnly:M=!1,required:h=!1,showMaxLength:k=!1,type:q="text",value:i,...g})=>{const C=p.useId(),[z,E]=p.useState(typeof i=="string"?i.length:0),m=y||C,R=`${m}-input`,w=`${m}-description`,d=`${m}-error`,O=g.maxLength,b=t&&typeof l=="string",A=t&&F.isObject(l);p.useEffect(()=>{typeof i=="string"&&E(i.length)},[i]);const B=u=>{const o=u.target.value.length;E(o),v?.(u)},D=e.jsxRuntimeExports.jsxs("div",{className:"relative flex w-full items-center",children:[a!==""&&c==="left"?e.jsxRuntimeExports.jsx("div",{className:"absolute left-3 flex items-center",children:e.jsxRuntimeExports.jsx(x.OxIcon,{icon:a,size:.8})}):null,e.jsxRuntimeExports.jsx("input",{id:R,"aria-describedby":[r?w:"",b?d:""].filter(Boolean).join(" ")||void 0,"aria-invalid":t,"aria-required":h,className:x.twMerge("flex h-10 w-full rounded-lg bg-transparent px-2 py-2 text-sm text-white","default-outset-focus","placeholder:text-muted-foreground placeholder:text-neutral-500","default-disabled",a&&(c==="left"?"pl-10":"pr-10"),t?"default-error-border":"default-border",n),disabled:s,name:L,placeholder:$,readOnly:M,type:q,value:i,onChange:B,...g}),a!==""&&c==="right"?e.jsxRuntimeExports.jsx("div",{className:"absolute right-3 flex items-center",children:e.jsxRuntimeExports.jsx(x.OxIcon,{icon:a,size:.8})}):null]});return e.jsxRuntimeExports.jsxs("div",{className:"flex w-full flex-col gap-1",children:[j?e.jsxRuntimeExports.jsx(N,{disabled:s,htmlFor:R,required:h,children:j}):null,D,k&&typeof O=="number"?e.jsxRuntimeExports.jsxs("div",{className:"pointer-events-none mt-1 text-right text-xs text-neutral-400",children:[z,"/",O]}):null,r?e.jsxRuntimeExports.jsx(I,{id:w,disabled:s,children:r}):null,b?e.jsxRuntimeExports.jsx(f,{id:d,children:l}):null,A&&Array.isArray(l)?e.jsxRuntimeExports.jsx("div",{className:"mt-1 space-y-1",children:l.map((u,o)=>e.jsxRuntimeExports.jsx(f,{id:`${d}-${o}`,children:u},o))}):null]})};exports.OxDescription=I;exports.OxErrorMessage=f;exports.OxForm=S;exports.OxInput=G;exports.OxLabel=N;
@@ -1,6 +1,6 @@
1
1
  import { j as e } from "./jsx-runtime--oOP9f8K.js";
2
- import { useId as S, useState as q, useEffect as C } from "react";
3
- import { t as x, a as p } from "./Button-BV4_pmoH.js";
2
+ import { useId as R, useState as S, useEffect as q } from "react";
3
+ import { t as x, a as m } from "./Button-bARrxYyo.js";
4
4
  import { i as G } from "./isObject-vmP43YLW.js";
5
5
  const H = ({
6
6
  children: r,
@@ -35,7 +35,7 @@ const H = ({
35
35
  className: x("text-xs text-neutral-400", s && "text-neutral-500", l),
36
36
  children: r
37
37
  }
38
- ), I = ({
38
+ ), O = ({
39
39
  children: r,
40
40
  className: l,
41
41
  icon: s = "mdiAlertCircleOutline",
@@ -47,7 +47,7 @@ const H = ({
47
47
  className: x("flex max-w-full items-center gap-1 text-xs text-rose-400", l),
48
48
  role: "alert",
49
49
  children: [
50
- s ? /* @__PURE__ */ e.jsx(p, { className: "flex-shrink-0", icon: s, size: 0.8 }) : null,
50
+ s ? /* @__PURE__ */ e.jsx(m, { className: "flex-shrink-0", icon: s, size: 0.8 }) : null,
51
51
  /* @__PURE__ */ e.jsx("p", { className: "min-w-0 break-words", children: r })
52
52
  ]
53
53
  }
@@ -64,75 +64,75 @@ const H = ({
64
64
  error: t = !1,
65
65
  errorMessage: a,
66
66
  icon: i = "",
67
- iconPosition: u = "left",
68
- id: v,
67
+ iconPosition: d = "left",
68
+ id: I,
69
69
  label: h,
70
- name: E,
71
- onChange: o,
70
+ name: v,
71
+ onChange: E,
72
72
  placeholder: L = "Input placeholder...",
73
73
  readOnly: $ = !1,
74
- required: j = !1,
74
+ required: p = !1,
75
75
  showMaxLength: k = !1,
76
- type: z = "text",
76
+ type: C = "text",
77
77
  value: n,
78
- ...g
78
+ ...j
79
79
  }) => {
80
- const A = S(), [B, b] = q(
80
+ const z = R(), [A, g] = S(
81
81
  typeof n == "string" ? n.length : 0
82
- ), f = v || A, N = `${f}-input`, w = `${f}-description`, m = `${f}-error`, y = g.maxLength, O = t && typeof a == "string", D = t && G(a);
83
- C(() => {
84
- typeof n == "string" && b(n.length);
82
+ ), u = I || z, b = `${u}-input`, N = `${u}-description`, f = `${u}-error`, w = j.maxLength, y = t && typeof a == "string", B = t && G(a);
83
+ q(() => {
84
+ typeof n == "string" && g(n.length);
85
85
  }, [n]);
86
- const F = (c) => {
87
- const d = c.target.value.length;
88
- b(d), o == null || o(c);
89
- }, R = /* @__PURE__ */ e.jsxs("div", { className: "relative flex w-full items-center", children: [
90
- i !== "" && u === "left" ? /* @__PURE__ */ e.jsx("div", { className: "absolute left-3 flex items-center", children: /* @__PURE__ */ e.jsx(p, { icon: i, size: 0.8 }) }) : null,
86
+ const D = (c) => {
87
+ const o = c.target.value.length;
88
+ g(o), E?.(c);
89
+ }, F = /* @__PURE__ */ e.jsxs("div", { className: "relative flex w-full items-center", children: [
90
+ i !== "" && d === "left" ? /* @__PURE__ */ e.jsx("div", { className: "absolute left-3 flex items-center", children: /* @__PURE__ */ e.jsx(m, { icon: i, size: 0.8 }) }) : null,
91
91
  /* @__PURE__ */ e.jsx(
92
92
  "input",
93
93
  {
94
- id: N,
95
- "aria-describedby": [l ? w : "", O ? m : ""].filter(Boolean).join(" ") || void 0,
94
+ id: b,
95
+ "aria-describedby": [l ? N : "", y ? f : ""].filter(Boolean).join(" ") || void 0,
96
96
  "aria-invalid": t,
97
- "aria-required": j,
97
+ "aria-required": p,
98
98
  className: x(
99
99
  "flex h-10 w-full rounded-lg bg-transparent px-2 py-2 text-sm text-white",
100
100
  "default-outset-focus",
101
101
  "placeholder:text-muted-foreground placeholder:text-neutral-500",
102
102
  "default-disabled",
103
- i && (u === "left" ? "pl-10" : "pr-10"),
103
+ i && (d === "left" ? "pl-10" : "pr-10"),
104
104
  t ? "default-error-border" : "default-border",
105
105
  r
106
106
  ),
107
107
  disabled: s,
108
- name: E,
108
+ name: v,
109
109
  placeholder: L,
110
110
  readOnly: $,
111
- type: z,
111
+ type: C,
112
112
  value: n,
113
- onChange: F,
114
- ...g
113
+ onChange: D,
114
+ ...j
115
115
  }
116
116
  ),
117
- i !== "" && u === "right" ? /* @__PURE__ */ e.jsx("div", { className: "absolute right-3 flex items-center", children: /* @__PURE__ */ e.jsx(p, { icon: i, size: 0.8 }) }) : null
117
+ i !== "" && d === "right" ? /* @__PURE__ */ e.jsx("div", { className: "absolute right-3 flex items-center", children: /* @__PURE__ */ e.jsx(m, { icon: i, size: 0.8 }) }) : null
118
118
  ] });
119
119
  return /* @__PURE__ */ e.jsxs("div", { className: "flex w-full flex-col gap-1", children: [
120
- h ? /* @__PURE__ */ e.jsx(H, { disabled: s, htmlFor: N, required: j, children: h }) : null,
121
- R,
122
- k && typeof y == "number" ? /* @__PURE__ */ e.jsxs("div", { className: "pointer-events-none mt-1 text-right text-xs text-neutral-400", children: [
123
- B,
120
+ h ? /* @__PURE__ */ e.jsx(H, { disabled: s, htmlFor: b, required: p, children: h }) : null,
121
+ F,
122
+ k && typeof w == "number" ? /* @__PURE__ */ e.jsxs("div", { className: "pointer-events-none mt-1 text-right text-xs text-neutral-400", children: [
123
+ A,
124
124
  "/",
125
- y
125
+ w
126
126
  ] }) : null,
127
- l ? /* @__PURE__ */ e.jsx(J, { id: w, disabled: s, children: l }) : null,
128
- O ? /* @__PURE__ */ e.jsx(I, { id: m, children: a }) : null,
129
- D && Array.isArray(a) ? /* @__PURE__ */ e.jsx("div", { className: "mt-1 space-y-1", children: a.map((c, d) => /* @__PURE__ */ e.jsx(I, { id: `${m}-${d}`, children: c }, d)) }) : null
127
+ l ? /* @__PURE__ */ e.jsx(J, { id: N, disabled: s, children: l }) : null,
128
+ y ? /* @__PURE__ */ e.jsx(O, { id: f, children: a }) : null,
129
+ B && Array.isArray(a) ? /* @__PURE__ */ e.jsx("div", { className: "mt-1 space-y-1", children: a.map((c, o) => /* @__PURE__ */ e.jsx(O, { id: `${f}-${o}`, children: c }, o)) }) : null
130
130
  ] });
131
131
  };
132
132
  export {
133
133
  U as O,
134
134
  V as a,
135
- I as b,
135
+ O as b,
136
136
  H as c,
137
137
  J as d
138
138
  };
@@ -0,0 +1,18 @@
1
+ const n = (a) => a.map((s) => ({
2
+ message: s.message,
3
+ code: s.extensions?.code || "UNKNOWN_ERROR",
4
+ field: s.extensions?.field,
5
+ path: s.path
6
+ })), o = (a, s) => {
7
+ a.forEach((e) => {
8
+ e.field ? s.setError(e.field, e.message) : s.setError("", e.message);
9
+ });
10
+ }, t = (a, s) => {
11
+ const e = n(a);
12
+ o(e, s);
13
+ };
14
+ export {
15
+ n as O,
16
+ o as a,
17
+ t as b
18
+ };
@@ -0,0 +1 @@
1
+ "use strict";const a=r=>r.map(s=>({message:s.message,code:s.extensions?.code||"UNKNOWN_ERROR",field:s.extensions?.field,path:s.path})),o=(r,s)=>{r.forEach(e=>{e.field?s.setError(e.field,e.message):s.setError("",e.message)})},n=(r,s)=>{const e=a(r);o(e,s)};exports.OxHandleFormErrors=o;exports.OxHandleGraphQLFormErrors=n;exports.OxParseGraphQLErrors=a;
@@ -0,0 +1,12 @@
1
+ const f = (n) => {
2
+ const t = Math.floor(((/* @__PURE__ */ new Date()).getTime() - n.getTime()) / (1e3 * 60));
3
+ if (t < 1) return "just now";
4
+ if (t < 60) return `${t}m ago`;
5
+ const o = Math.floor(t / 60);
6
+ if (o < 24) return `${o}h ago`;
7
+ const r = Math.floor(o / 24);
8
+ return r < 7 ? `${r}d ago` : n.toLocaleDateString();
9
+ };
10
+ export {
11
+ f
12
+ };
@@ -0,0 +1 @@
1
+ "use strict";const e=n=>{const t=Math.floor((new Date().getTime()-n.getTime())/(1e3*60));if(t<1)return"just now";if(t<60)return`${t}m ago`;const o=Math.floor(t/60);if(o<24)return`${o}h ago`;const r=Math.floor(o/24);return r<7?`${r}d ago`:n.toLocaleDateString()};exports.formatTimestamp=e;