@noxickon/onyx 1.0.4 → 1.1.0

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,5 +1,5 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../chunks/ui-DRaffjpU.js"),m=require("../chunks/query-D4FW3HN6.js"),E=require("../chunks/useAuth-DxoDe3YA.js"),h=require("../chunks/hooks-DB942JYB.js"),u=require("react");function A({adminRole:s="admin",children:r,getCurrentUserQuery:n=m.DEFAULT_GET_CURRENT_USER,options:o={},pollInterval:l=300*1e3}){const{data:a,error:O,loading:f,refetch:e}=h.useQuery(n,{fetchPolicy:"cache-and-network",nextFetchPolicy:"cache-first",errorPolicy:"all",pollInterval:l,...o}),t=!!a?.me,i=a?.me?.role===s;return c.jsxRuntimeExports.jsx(E.OxAuthContext.Provider,{value:{user:a?.me||null,loading:f,error:O??null,isLoggedIn:t,isAdmin:i,refreshUser:e},children:r})}const g=h.gql`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("../chunks/ui-DRRDAnVI.js"),b=require("../chunks/query-CIsrxNi-.js"),O=require("react/jsx-runtime"),R=require("../chunks/useAuth-DxoDe3YA.js"),m=require("../chunks/hooks-UiKjBucd.js"),j=require("@apollo/client"),g=require("react");function L({adminRole:t="ADMIN",children:e,getCurrentUserQuery:a=b.DEFAULT_GET_CURRENT_USER,options:i={},pollInterval:f=300*1e3}){const{data:u,error:o,loading:d,refetch:s}=m.useQuery(a,{fetchPolicy:"cache-and-network",nextFetchPolicy:"cache-first",errorPolicy:"all",pollInterval:f,...i}),r=!!u?.me,l=u?.me?.role===t;return O.jsx(R.OxAuthContext.Provider,{value:{user:u?.me||null,loading:d,error:o??null,isLoggedIn:r,isAdmin:l,refreshUser:s},children:e})}const U=j.gql`
2
2
  query getFeatures {
3
3
  features
4
4
  }
5
- `,p=u.createContext(void 0);function D({children:s,enableDevMode:r=!1,getFeaturesQuery:n=g,options:o={},pollInterval:l=300*1e3}){const{data:a,error:O,loading:f,refetch:e}=h.useQuery(n,{fetchPolicy:"cache-and-network",nextFetchPolicy:"cache-first",errorPolicy:"all",pollInterval:l,skip:r,...o}),t=a?.features||{},i=d=>r?!0:t[d]??!1;return c.jsxRuntimeExports.jsx(p.Provider,{value:{features:t,isEnabled:i,loading:f,error:O??null,refreshFeatures:e,enableDevMode:r},children:s})}function F(){const s=u.useContext(p);if(!s)throw new Error("useOxFeature must be used within an OxFeatureProvider");return s}const P=({children:s,className:r,fallback:n=null,name:o})=>{const{isEnabled:l}=F();return l(o)?c.jsxRuntimeExports.jsx("div",{className:c.cn("contents",r),children:s}):n?c.jsxRuntimeExports.jsx("div",{className:c.cn("contents",r),children:n}):null},v=u.createContext(null),R=({children:s,maxDialogs:r=3})=>{const[n,o]=u.useState([]);u.useEffect(()=>(n.some(t=>t.isOpen)?document.body.classList.add("overflow-hidden"):document.body.classList.remove("overflow-hidden"),()=>{document.body.classList.remove("overflow-hidden")}),[n]);const l=u.useCallback(()=>{let e=null;o(t=>{const i=t.filter(x=>x.isOpen),d=h.head(i);return d?(e=d.id,t.map(x=>x.id===d.id?{...x,isOpen:!1}:x)):t}),e&&setTimeout(()=>{o(t=>h.reject(t,i=>i.id===e))},200)},[]),a=u.useCallback((e,t)=>{const i=h.uniqueId(),d={id:i,content:e,isOpen:!0,options:t};return o(x=>[d,...x].slice(0,r)),i},[r]),O=u.useCallback(()=>{o(e=>e.map(t=>({...t,isOpen:!1}))),setTimeout(()=>{o([])},200)},[]),f=Object.assign((e,t)=>a(e,t),{open:a,dismiss:l,dismissAll:O});return c.jsxRuntimeExports.jsxs(v.Provider,{value:f,children:[s,n.map(e=>c.jsxRuntimeExports.jsx(c.OxDialog,{isOpen:e.isOpen,onClose:l,...e.options,children:e.content},e.id))]})},T=()=>{const s=u.useContext(v);if(!s)throw new Error("useOxDialog must be used within a DialogProvider");return s};exports.DEFAULT_GET_CURRENT_USER=m.DEFAULT_GET_CURRENT_USER;exports.OxAuthContext=E.OxAuthContext;exports.useOxAuth=E.useOxAuth;exports.DEFAULT_GET_FEATURES=g;exports.OxAuthProvider=A;exports.OxDialogProvider=R;exports.OxFeatureFlag=P;exports.OxFeatureProvider=D;exports.useOxDialog=T;exports.useOxFeature=F;
5
+ `,w=g.createContext(void 0);function N({children:t,enableDevMode:e=!1,getFeaturesQuery:a=U,options:i={},pollInterval:f=300*1e3}){const{data:u,error:o,loading:d,refetch:s}=m.useQuery(a,{fetchPolicy:"cache-and-network",nextFetchPolicy:"cache-first",errorPolicy:"all",pollInterval:f,skip:e,...i}),r=u?.features||{},l=_=>e?!0:r[_]??!1;return O.jsx(w.Provider,{value:{features:r,isEnabled:l,loading:d,error:o??null,refreshFeatures:s,enableDevMode:e},children:t})}function C(){const t=g.useContext(w);if(!t)throw new Error("useOxFeature must be used within an OxFeatureProvider");return t}const k=t=>{const e=m.compilerRuntimeExports.c(8),{children:a,className:i,fallback:f,name:u}=t,o=f===void 0?null:f,{isEnabled:d}=C();if(!d(u)){let l;return e[0]!==i||e[1]!==o?(l=o?O.jsx("div",{className:T.cn("contents",i),children:o}):null,e[0]=i,e[1]=o,e[2]=l):l=e[2],l}let s;e[3]!==i?(s=T.cn("contents",i),e[3]=i,e[4]=s):s=e[4];let r;return e[5]!==a||e[6]!==s?(r=O.jsx("div",{className:s,children:a}),e[5]=a,e[6]=s,e[7]=r):r=e[7],r},S=g.createContext(null),G=t=>{const e=m.compilerRuntimeExports.c(17),{children:a,maxDialogs:i}=t,f=i===void 0?3:i;let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=[],e[0]=u):u=e[0];const[o,d]=g.useState(u);let s,r;e[1]!==o?(s=()=>(o.some(I)?document.body.classList.add("overflow-hidden"):document.body.classList.remove("overflow-hidden"),Q),r=[o],e[1]=o,e[2]=s,e[3]=r):(s=e[2],r=e[3]),g.useEffect(s,r);let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{let c=null;d(n=>{const h=n.filter($),p=m.head(h);return p?(c=p.id,n.map(E=>E.id===p.id?{...E,isOpen:!1}:E)):n}),c&&setTimeout(()=>{d(n=>m.reject(n,h=>h.id===c))},200)},e[4]=l):l=e[4];const _=l;let D;e[5]!==f?(D=(c,n)=>{const h=m.uniqueId(),p={id:h,content:c,isOpen:!0,options:n};return d(E=>[p,...E].slice(0,f)),h},e[5]=f,e[6]=D):D=e[6];const F=D;let v;e[7]===Symbol.for("react.memo_cache_sentinel")?(v=()=>{d(B),setTimeout(()=>{d([])},200)},e[7]=v):v=e[7];const q=v;let y;e[8]!==F?(y=Object.assign((c,n)=>F(c,n),{open:F,dismiss:_,dismissAll:q}),e[8]=F,e[9]=y):y=e[9];const P=y;let x;if(e[10]!==o){let c;e[12]===Symbol.for("react.memo_cache_sentinel")?(c=n=>O.jsx(T.OxDialog,{isOpen:n.isOpen,onClose:_,...n.options,children:n.content},n.id),e[12]=c):c=e[12],x=o.map(c),e[10]=o,e[11]=x}else x=e[11];let A;return e[13]!==a||e[14]!==P||e[15]!==x?(A=O.jsxs(S.Provider,{value:P,children:[a,x]}),e[13]=a,e[14]=P,e[15]=x,e[16]=A):A=e[16],A};function I(t){return t.isOpen}function Q(){document.body.classList.remove("overflow-hidden")}function $(t){return t.isOpen}function z(t){return{...t,isOpen:!1}}function B(t){return t.map(z)}const H=()=>{const t=g.useContext(S);if(!t)throw new Error("useOxDialog must be used within a DialogProvider");return t};exports.DEFAULT_GET_CURRENT_USER=b.DEFAULT_GET_CURRENT_USER;exports.OxAuthContext=R.OxAuthContext;exports.useOxAuth=R.useOxAuth;exports.DEFAULT_GET_FEATURES=U;exports.OxAuthProvider=L;exports.OxDialogProvider=G;exports.OxFeatureFlag=k;exports.OxFeatureProvider=N;exports.useOxDialog=H;exports.useOxFeature=C;
@@ -1,156 +1,190 @@
1
- import { _ as d, $ as h, o as D } from "../chunks/ui-CWzo2o31.js";
2
- import { D as E } from "../chunks/query-v272k9Fk.js";
3
- import { O as F } from "../chunks/useAuth-BFgXzu6Q.js";
4
- import { u as H } from "../chunks/useAuth-BFgXzu6Q.js";
5
- import { v as p, n as P, w as y, r as j, k as A } from "../chunks/hooks-BswtWYGK.js";
6
- import { createContext as O, useContext as g, useState as C, useEffect as T, useCallback as x } from "react";
7
- function S({
8
- adminRole: t = "admin",
9
- children: o,
10
- getCurrentUserQuery: n = E,
11
- options: r = {},
12
- pollInterval: c = 300 * 1e3
1
+ import { a0 as F, p as U } from "../chunks/ui-DGkJW_Fa.js";
2
+ import { D as k } from "../chunks/query-D2S9cFBP.js";
3
+ import { jsx as g, jsxs as N } from "react/jsx-runtime";
4
+ import { O as R } from "../chunks/useAuth-BFgXzu6Q.js";
5
+ import { u as fe } from "../chunks/useAuth-BFgXzu6Q.js";
6
+ import { w as P, d as b, x as j, r as I, n as q } from "../chunks/hooks-CUNBk2tZ.js";
7
+ import { gql as G } from "@apollo/client";
8
+ import { createContext as A, useContext as T, useState as $, useEffect as Q } from "react";
9
+ function re({
10
+ adminRole: t = "ADMIN",
11
+ children: e,
12
+ getCurrentUserQuery: u = k,
13
+ options: i = {},
14
+ pollInterval: m = 300 * 1e3
13
15
  }) {
14
- const { data: l, error: f, loading: m, refetch: e } = p(
15
- n,
16
- {
17
- fetchPolicy: "cache-and-network",
18
- nextFetchPolicy: "cache-first",
19
- errorPolicy: "all",
20
- pollInterval: c,
21
- ...r
22
- }
23
- ), s = !!l?.me, i = l?.me?.role === t;
24
- return /* @__PURE__ */ d.jsx(
25
- F.Provider,
26
- {
27
- value: {
28
- user: l?.me || null,
29
- loading: m,
30
- error: f ?? null,
31
- isLoggedIn: s,
32
- isAdmin: i,
33
- refreshUser: e
34
- },
35
- children: o
36
- }
37
- );
16
+ const {
17
+ data: a,
18
+ error: o,
19
+ loading: f,
20
+ refetch: s
21
+ } = P(u, {
22
+ fetchPolicy: "cache-and-network",
23
+ nextFetchPolicy: "cache-first",
24
+ errorPolicy: "all",
25
+ pollInterval: m,
26
+ ...i
27
+ }), r = !!a?.me, l = a?.me?.role === t;
28
+ return /* @__PURE__ */ g(R.Provider, { value: {
29
+ user: a?.me || null,
30
+ loading: f,
31
+ error: o ?? null,
32
+ isLoggedIn: r,
33
+ isAdmin: l,
34
+ refreshUser: s
35
+ }, children: e });
38
36
  }
39
- const b = P`
37
+ const z = G`
40
38
  query getFeatures {
41
39
  features
42
40
  }
43
- `, v = O(void 0);
44
- function G({
41
+ `, C = A(void 0);
42
+ function ne({
45
43
  children: t,
46
- enableDevMode: o = !1,
47
- getFeaturesQuery: n = b,
48
- options: r = {},
49
- pollInterval: c = 300 * 1e3
44
+ enableDevMode: e = !1,
45
+ getFeaturesQuery: u = z,
46
+ options: i = {},
47
+ pollInterval: m = 300 * 1e3
50
48
  }) {
51
- const { data: l, error: f, loading: m, refetch: e } = p(n, {
49
+ const {
50
+ data: a,
51
+ error: o,
52
+ loading: f,
53
+ refetch: s
54
+ } = P(u, {
52
55
  fetchPolicy: "cache-and-network",
53
56
  nextFetchPolicy: "cache-first",
54
57
  errorPolicy: "all",
55
- pollInterval: c,
56
- skip: o,
57
- ...r
58
- }), s = l?.features || {}, i = (a) => o ? !0 : s[a] ?? !1;
59
- return /* @__PURE__ */ d.jsx(
60
- v.Provider,
61
- {
62
- value: {
63
- features: s,
64
- isEnabled: i,
65
- loading: m,
66
- error: f ?? null,
67
- refreshFeatures: e,
68
- enableDevMode: o
69
- },
70
- children: t
71
- }
72
- );
58
+ pollInterval: m,
59
+ skip: e,
60
+ ...i
61
+ }), r = a?.features || {}, l = (O) => e ? !0 : r[O] ?? !1;
62
+ return /* @__PURE__ */ g(C.Provider, { value: {
63
+ features: r,
64
+ isEnabled: l,
65
+ loading: f,
66
+ error: o ?? null,
67
+ refreshFeatures: s,
68
+ enableDevMode: e
69
+ }, children: t });
73
70
  }
74
- function L() {
75
- const t = g(v);
71
+ function B() {
72
+ const t = T(C);
76
73
  if (!t)
77
74
  throw new Error("useOxFeature must be used within an OxFeatureProvider");
78
75
  return t;
79
76
  }
80
- const N = ({
81
- children: t,
82
- className: o,
83
- fallback: n = null,
84
- name: r
85
- }) => {
86
- const { isEnabled: c } = L();
87
- return c(r) ? /* @__PURE__ */ d.jsx("div", { className: h("contents", o), children: t }) : n ? /* @__PURE__ */ d.jsx("div", { className: h("contents", o), children: n }) : null;
88
- }, w = O(null), Q = ({ children: t, maxDialogs: o = 3 }) => {
89
- const [n, r] = C([]);
90
- T(() => (n.some((s) => s.isOpen) ? document.body.classList.add("overflow-hidden") : document.body.classList.remove("overflow-hidden"), () => {
91
- document.body.classList.remove("overflow-hidden");
92
- }), [n]);
93
- const c = x(() => {
94
- let e = null;
95
- r((s) => {
96
- const i = s.filter((u) => u.isOpen), a = y(i);
97
- return a ? (e = a.id, s.map(
98
- (u) => u.id === a.id ? { ...u, isOpen: !1 } : u
99
- )) : s;
100
- }), e && setTimeout(() => {
101
- r((s) => j(s, (i) => i.id === e));
77
+ const ie = (t) => {
78
+ const e = b.c(8), {
79
+ children: u,
80
+ className: i,
81
+ fallback: m,
82
+ name: a
83
+ } = t, o = m === void 0 ? null : m, {
84
+ isEnabled: f
85
+ } = B();
86
+ if (!f(a)) {
87
+ let l;
88
+ return e[0] !== i || e[1] !== o ? (l = o ? /* @__PURE__ */ g("div", { className: F("contents", i), children: o }) : null, e[0] = i, e[1] = o, e[2] = l) : l = e[2], l;
89
+ }
90
+ let s;
91
+ e[3] !== i ? (s = F("contents", i), e[3] = i, e[4] = s) : s = e[4];
92
+ let r;
93
+ return e[5] !== u || e[6] !== s ? (r = /* @__PURE__ */ g("div", { className: s, children: u }), e[5] = u, e[6] = s, e[7] = r) : r = e[7], r;
94
+ }, S = A(null), le = (t) => {
95
+ const e = b.c(17), {
96
+ children: u,
97
+ maxDialogs: i
98
+ } = t, m = i === void 0 ? 3 : i;
99
+ let a;
100
+ e[0] === Symbol.for("react.memo_cache_sentinel") ? (a = [], e[0] = a) : a = e[0];
101
+ const [o, f] = $(a);
102
+ let s, r;
103
+ e[1] !== o ? (s = () => (o.some(H) ? document.body.classList.add("overflow-hidden") : document.body.classList.remove("overflow-hidden"), J), r = [o], e[1] = o, e[2] = s, e[3] = r) : (s = e[2], r = e[3]), Q(s, r);
104
+ let l;
105
+ e[4] === Symbol.for("react.memo_cache_sentinel") ? (l = () => {
106
+ let c = null;
107
+ f((n) => {
108
+ const h = n.filter(K), p = j(h);
109
+ return p ? (c = p.id, n.map((x) => x.id === p.id ? {
110
+ ...x,
111
+ isOpen: !1
112
+ } : x)) : n;
113
+ }), c && setTimeout(() => {
114
+ f((n) => I(n, (h) => h.id === c));
102
115
  }, 200);
103
- }, []), l = x(
104
- (e, s) => {
105
- const i = A(), a = {
106
- id: i,
107
- content: e,
108
- isOpen: !0,
109
- options: s
110
- };
111
- return r((u) => [a, ...u].slice(0, o)), i;
112
- },
113
- [o]
114
- ), f = x(() => {
115
- r((e) => e.map((s) => ({ ...s, isOpen: !1 }))), setTimeout(() => {
116
- r([]);
116
+ }, e[4] = l) : l = e[4];
117
+ const O = l;
118
+ let D;
119
+ e[5] !== m ? (D = (c, n) => {
120
+ const h = q(), p = {
121
+ id: h,
122
+ content: c,
123
+ isOpen: !0,
124
+ options: n
125
+ };
126
+ return f((x) => [p, ...x].slice(0, m)), h;
127
+ }, e[5] = m, e[6] = D) : D = e[6];
128
+ const _ = D;
129
+ let v;
130
+ e[7] === Symbol.for("react.memo_cache_sentinel") ? (v = () => {
131
+ f(W), setTimeout(() => {
132
+ f([]);
117
133
  }, 200);
118
- }, []), m = Object.assign(
119
- (e, s) => l(e, s),
120
- {
121
- open: l,
122
- dismiss: c,
123
- dismissAll: f
124
- }
125
- );
126
- return /* @__PURE__ */ d.jsxs(w.Provider, { value: m, children: [
127
- t,
128
- n.map((e) => /* @__PURE__ */ d.jsx(
129
- D,
130
- {
131
- isOpen: e.isOpen,
132
- onClose: c,
133
- ...e.options,
134
- children: e.content
135
- },
136
- e.id
137
- ))
138
- ] });
139
- }, $ = () => {
140
- const t = g(w);
134
+ }, e[7] = v) : v = e[7];
135
+ const L = v;
136
+ let y;
137
+ e[8] !== _ ? (y = Object.assign((c, n) => _(c, n), {
138
+ open: _,
139
+ dismiss: O,
140
+ dismissAll: L
141
+ }), e[8] = _, e[9] = y) : y = e[9];
142
+ const E = y;
143
+ let d;
144
+ if (e[10] !== o) {
145
+ let c;
146
+ e[12] === Symbol.for("react.memo_cache_sentinel") ? (c = (n) => /* @__PURE__ */ g(U, { isOpen: n.isOpen, onClose: O, ...n.options, children: n.content }, n.id), e[12] = c) : c = e[12], d = o.map(c), e[10] = o, e[11] = d;
147
+ } else
148
+ d = e[11];
149
+ let w;
150
+ return e[13] !== u || e[14] !== E || e[15] !== d ? (w = /* @__PURE__ */ N(S.Provider, { value: E, children: [
151
+ u,
152
+ d
153
+ ] }), e[13] = u, e[14] = E, e[15] = d, e[16] = w) : w = e[16], w;
154
+ };
155
+ function H(t) {
156
+ return t.isOpen;
157
+ }
158
+ function J() {
159
+ document.body.classList.remove("overflow-hidden");
160
+ }
161
+ function K(t) {
162
+ return t.isOpen;
163
+ }
164
+ function V(t) {
165
+ return {
166
+ ...t,
167
+ isOpen: !1
168
+ };
169
+ }
170
+ function W(t) {
171
+ return t.map(V);
172
+ }
173
+ const ce = () => {
174
+ const t = T(S);
141
175
  if (!t)
142
176
  throw new Error("useOxDialog must be used within a DialogProvider");
143
177
  return t;
144
178
  };
145
179
  export {
146
- E as DEFAULT_GET_CURRENT_USER,
147
- b as DEFAULT_GET_FEATURES,
148
- F as OxAuthContext,
149
- S as OxAuthProvider,
150
- Q as OxDialogProvider,
151
- N as OxFeatureFlag,
152
- G as OxFeatureProvider,
153
- H as useOxAuth,
154
- $ as useOxDialog,
155
- L as useOxFeature
180
+ k as DEFAULT_GET_CURRENT_USER,
181
+ z as DEFAULT_GET_FEATURES,
182
+ R as OxAuthContext,
183
+ re as OxAuthProvider,
184
+ le as OxDialogProvider,
185
+ ie as OxFeatureFlag,
186
+ ne as OxFeatureProvider,
187
+ fe as useOxAuth,
188
+ ce as useOxDialog,
189
+ B as useOxFeature
156
190
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../chunks/hooks-DB942JYB.js");exports.handleRules=e.handleRules;exports.useControllableState=e.useControllableState;exports.useFileUpload=e.useFileUpload;exports.useFilter=e.useFilter;exports.useFocus=e.useFocus;exports.useForm=e.useForm;exports.useFormState=e.useFormState;exports.useKeyboard=e.useKeyboard;exports.useOverflowDetection=e.useOverflowDetection;exports.validator=e.validator;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../chunks/hooks-UiKjBucd.js");exports.handleRules=e.handleRules;exports.useControllableState=e.useControllableState;exports.useFileUpload=e.useFileUpload;exports.useFilter=e.useFilter;exports.useFocus=e.useFocus;exports.useForm=e.useForm;exports.useFormState=e.useFormState;exports.useKeyboard=e.useKeyboard;exports.useOverflowDetection=e.useOverflowDetection;exports.validator=e.validator;
@@ -1,4 +1,4 @@
1
- import { y as a, f as o, A as l, B as t, g as u, l as r, x as F, h as d, j as i, z as f } from "../chunks/hooks-BswtWYGK.js";
1
+ import { z as a, h as o, B as l, C as t, j as u, q as r, y as F, k as d, l as i, A as m } from "../chunks/hooks-CUNBk2tZ.js";
2
2
  export {
3
3
  a as handleRules,
4
4
  o as useControllableState,
@@ -9,5 +9,5 @@ export {
9
9
  F as useFormState,
10
10
  d as useKeyboard,
11
11
  i as useOverflowDetection,
12
- f as validator
12
+ m as validator
13
13
  };