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