@orion-ds/react 5.4.0 → 5.5.1

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,6 +1,6 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),s=require("react"),J=require("../MissingDependencyError.cjs"),Q=require("../../utils/optionalDeps.cjs"),l=require("./CodeEditor.module.css.cjs"),X=require("../../contexts/ThemeContext.cjs");let A,B,K;if(typeof require<"u")try{A=require("react-syntax-highlighter").Prism;const d=require("react-syntax-highlighter/dist/esm/styles/prism");B=d.oneDark,K=d.oneLight}catch{}if(typeof require<"u")try{const r=require("refractor/all");r.default&&r.default.registered&&r.default.registered("markdown")&&!r.default.languages.markdown?.["quoted-string"]&&r.default.languages.insertBefore("markdown","bold",{"quoted-string":{pattern:/"(?:\\.|[^"\\])*"/,greedy:!0,alias:"string"}})}catch{}const P=s.forwardRef(({value:r="",onChange:d,language:C,readOnly:N=!1,showLineNumbers:S=!0,placeholder:E,minRows:p=10,className:F,"aria-label":T,...q},O)=>{const[R,v]=s.useState(),[V,_]=s.useState(!0),[m,z]=s.useState(0),[u,I]=s.useState([]),x=s.useRef(null),y=s.useRef(null),k=s.useRef(null),D=s.useRef(null),U=s.useRef(null),h=s.useRef(null),f=O||U;s.useEffect(()=>{(async()=>{try{const t=Q.checkComponent("CodeEditor");t instanceof Promise?v(await t):v(t)}catch{v(void 0)}finally{_(!1)}})()},[]),s.useEffect(()=>{if(h.current&&f.current){const{start:e,end:t}=h.current;f.current.setSelectionRange(e,t),h.current=null}}),s.useEffect(()=>{const e=k.current,t=D.current;if(!e||!t)return;const i=()=>{const o=t.clientWidth;if(o<=0)return;e.style.width=`${o}px`;const a=r.split(`
2
- `),g=Math.max(a.length,p),b=[];for(let w=0;w<g;w++){const G=a[w]??"";e.textContent=G||" ",b.push(e.scrollHeight)}I(b)};i();const c=new ResizeObserver(i);return c.observe(t),()=>c.disconnect()},[r,p]),s.useEffect(()=>{const e=i=>{const c=i.target;x.current&&(x.current.scrollTop=c.scrollTop),y.current&&(y.current.scrollTop=c.scrollTop,y.current.scrollLeft=c.scrollLeft)},t=f?.current;if(t)return t.addEventListener("scroll",e),()=>{t.removeEventListener("scroll",e)}},[f]);let L="dark";try{L=X.useThemeContext().theme}catch{}const W=L==="light"?K:B,M=Math.max(r.split(`
3
- `).length,p);if(R)return n.jsx(J.MissingDependencyError,{...R});if(V)return n.jsx("div",{children:"Loading code editor..."});const j=e=>{const t=e.value.substring(0,e.selectionStart);z(t.split(`
4
- `).length-1)},H=e=>{if(e.key==="Tab"){e.preventDefault();const t=e.currentTarget,i=t.selectionStart,c=t.selectionEnd,o=" ";if(i===c){const a=r.substring(0,i)+o+r.substring(c);h.current={start:i+o.length,end:i+o.length},d?.(a)}else if(e.shiftKey){const a=r.lastIndexOf(`
5
- `,i-1)+1,g=r.substring(a).match(/^ {1,2}/)?.[0]??"";if(g.length>0){const b=r.substring(0,a)+r.substring(a+g.length);h.current={start:Math.max(a,i-g.length),end:Math.max(a,c-g.length)},d?.(b)}}else{const a=r.substring(0,i)+o+r.substring(c);h.current={start:i+o.length,end:i+o.length},d?.(a)}}},$=[l.default.wrapper,F].filter(Boolean).join(" ");return C?n.jsxs("div",{className:$,style:{minHeight:`calc(${p} * 1.6em + 2 * var(--spacing-4))`},children:[n.jsx("div",{ref:k,className:l.default.lineMirror,"aria-hidden":"true"}),S&&n.jsx("div",{ref:x,className:l.default.lineNumbers,"aria-hidden":"true",children:Array.from({length:M}).map((e,t)=>n.jsx("div",{className:l.default.lineNumber,style:u[t]!==void 0?{height:`${u[t]}px`}:void 0,children:t+1},t))}),n.jsxs("div",{ref:D,className:l.default.editorArea,children:[n.jsx("div",{className:l.default.lineHighlight,style:{top:u.length>0?`calc(var(--spacing-4) + ${u.slice(0,m).reduce((e,t)=>e+t,0)}px)`:`calc(var(--spacing-4) + ${(m*1.6).toFixed(2)}em)`,...u[m]!==void 0?{height:`${u[m]}px`}:{}},"aria-hidden":"true"}),n.jsx("div",{ref:y,className:l.default.highlightLayer,"aria-hidden":"true",children:n.jsx(A,{language:C,style:W,customStyle:{margin:0,padding:0,background:"transparent",fontSize:"inherit",lineHeight:"inherit",fontFamily:"inherit",whiteSpace:"pre-wrap",wordBreak:"break-word",overflow:"visible"},codeTagProps:{style:{fontFamily:"inherit",background:"transparent",color:"var(--text-primary)",whiteSpace:"pre-wrap",wordBreak:"break-word"}},children:r+`
6
- `})}),n.jsx("textarea",{ref:f,className:l.default.textareaOverlay,value:r,onChange:e=>d?.(e.target.value),onKeyDown:H,onKeyUp:e=>j(e.currentTarget),onMouseUp:e=>j(e.currentTarget),onClick:e=>j(e.currentTarget),placeholder:E,readOnly:N,"aria-label":T||"Code editor",spellCheck:"false",...q})]})]}):n.jsxs("div",{className:$,style:{minHeight:`calc(${p} * 1.6em + 2 * var(--spacing-4))`},children:[n.jsx("div",{ref:k,className:l.default.lineMirror,"aria-hidden":"true"}),S&&n.jsx("div",{ref:x,className:l.default.lineNumbers,"aria-hidden":"true",children:Array.from({length:M}).map((e,t)=>n.jsx("div",{className:l.default.lineNumber,style:u[t]!==void 0?{height:`${u[t]}px`}:void 0,children:t+1},t))}),n.jsx("textarea",{ref:f,className:l.default.textarea,value:r,onChange:e=>d?.(e.target.value),onKeyDown:H,placeholder:E,readOnly:N,"aria-label":T||"Code editor",spellCheck:"false",...q})]})});P.displayName="CodeEditor";exports.CodeEditor=P;
1
+ "use strict";var Z=Object.create;var F=Object.defineProperty;var ee=Object.getOwnPropertyDescriptor;var te=Object.getOwnPropertyNames;var re=Object.getPrototypeOf,ne=Object.prototype.hasOwnProperty;var se=(r,n,d,x)=>{if(n&&typeof n=="object"||typeof n=="function")for(let h of te(n))!ne.call(r,h)&&h!==d&&F(r,h,{get:()=>n[h],enumerable:!(x=ee(n,h))||x.enumerable});return r};var O=(r,n,d)=>(d=r!=null?Z(re(r)):{},se(n||!r||!r.__esModule?F(d,"default",{value:r,enumerable:!0}):d,r));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),i=require("react"),ie=require("../MissingDependencyError.cjs"),ae=require("../../utils/optionalDeps.cjs"),o=require("./CodeEditor.module.css.cjs"),ce=require("../../contexts/ThemeContext.cjs");let k,N,S;Promise.all([import("react-syntax-highlighter"),import("react-syntax-highlighter/dist/esm/styles/prism")]).then(([r,n])=>{k=r.Prism,N=n.oneDark,S=n.oneLight}).catch(()=>{});const V=i.forwardRef(({value:r="",onChange:n,language:d,readOnly:x=!1,showLineNumbers:h=!0,placeholder:D,minRows:y=10,className:_,"aria-label":M,...H},z)=>{const[$,T]=i.useState(),[I,U]=i.useState(!0),[W,E]=i.useState(!1),[b,G]=i.useState(0),[f,J]=i.useState([]),v=i.useRef(null),j=i.useRef(null),w=i.useRef(null),q=i.useRef(null),Q=i.useRef(null),g=i.useRef(null),m=z||Q;i.useEffect(()=>{(async()=>{try{const t=ae.checkComponent("CodeEditor");t instanceof Promise?T(await t):T(t)}catch{T(void 0)}finally{U(!1)}})()},[]),i.useEffect(()=>{if(k&&N&&S){E(!0);return}const e=setTimeout(()=>{E(!0)},0);return()=>clearTimeout(e)},[]),i.useEffect(()=>{if(g.current&&m.current){const{start:e,end:t}=g.current;m.current.setSelectionRange(e,t),g.current=null}}),i.useEffect(()=>{const e=w.current,t=q.current;if(!e||!t)return;const a=()=>{const u=t.clientWidth;if(u<=0)return;e.style.width=`${u}px`;const c=r.split(`
2
+ `),p=Math.max(c.length,y),C=[];for(let R=0;R<p;R++){const Y=c[R]??"";e.textContent=Y||" ",C.push(e.scrollHeight)}J(C)};a();const l=new ResizeObserver(a);return l.observe(t),()=>l.disconnect()},[r,y]),i.useEffect(()=>{const e=a=>{const l=a.target;v.current&&(v.current.scrollTop=l.scrollTop),j.current&&(j.current.scrollTop=l.scrollTop,j.current.scrollLeft=l.scrollLeft)},t=m?.current;if(t)return t.addEventListener("scroll",e),()=>{t.removeEventListener("scroll",e)}},[m]);let A="dark";try{A=ce.useThemeContext().theme}catch{}const X=A==="light"?S:N,K=Math.max(r.split(`
3
+ `).length,y);if($)return s.jsx(ie.MissingDependencyError,{...$});if(I)return s.jsx("div",{children:"Loading code editor..."});if(d&&!W)return s.jsx("div",{children:"Loading code editor..."});const L=e=>{const t=e.value.substring(0,e.selectionStart);G(t.split(`
4
+ `).length-1)},P=e=>{if(e.key==="Tab"){e.preventDefault();const t=e.currentTarget,a=t.selectionStart,l=t.selectionEnd,u=" ";if(a===l){const c=r.substring(0,a)+u+r.substring(l);g.current={start:a+u.length,end:a+u.length},n?.(c)}else if(e.shiftKey){const c=r.lastIndexOf(`
5
+ `,a-1)+1,p=r.substring(c).match(/^ {1,2}/)?.[0]??"";if(p.length>0){const C=r.substring(0,c)+r.substring(c+p.length);g.current={start:Math.max(c,a-p.length),end:Math.max(c,l-p.length)},n?.(C)}}else{const c=r.substring(0,a)+u+r.substring(l);g.current={start:a+u.length,end:a+u.length},n?.(c)}}},B=[o.default.wrapper,_].filter(Boolean).join(" ");return d?s.jsxs("div",{className:B,style:{minHeight:`calc(${y} * 1.6em + 2 * var(--spacing-4))`},children:[s.jsx("div",{ref:w,className:o.default.lineMirror,"aria-hidden":"true"}),h&&s.jsx("div",{ref:v,className:o.default.lineNumbers,"aria-hidden":"true",children:Array.from({length:K}).map((e,t)=>s.jsx("div",{className:o.default.lineNumber,style:f[t]!==void 0?{height:`${f[t]}px`}:void 0,children:t+1},t))}),s.jsxs("div",{ref:q,className:o.default.editorArea,children:[s.jsx("div",{className:o.default.lineHighlight,style:{top:f.length>0?`calc(var(--spacing-4) + ${f.slice(0,b).reduce((e,t)=>e+t,0)}px)`:`calc(var(--spacing-4) + ${(b*1.6).toFixed(2)}em)`,...f[b]!==void 0?{height:`${f[b]}px`}:{}},"aria-hidden":"true"}),s.jsx("div",{ref:j,className:o.default.highlightLayer,"aria-hidden":"true",children:s.jsx(k,{language:d,style:X,customStyle:{margin:0,padding:0,background:"transparent",fontSize:"inherit",lineHeight:"inherit",fontFamily:"inherit",whiteSpace:"pre-wrap",wordBreak:"break-word",overflow:"visible"},codeTagProps:{style:{fontFamily:"inherit",background:"transparent",color:"var(--text-primary)",whiteSpace:"pre-wrap",wordBreak:"break-word"}},children:r+`
6
+ `})}),s.jsx("textarea",{ref:m,className:o.default.textareaOverlay,value:r,onChange:e=>n?.(e.target.value),onKeyDown:P,onKeyUp:e=>L(e.currentTarget),onMouseUp:e=>L(e.currentTarget),onClick:e=>L(e.currentTarget),placeholder:D,readOnly:x,"aria-label":M||"Code editor",spellCheck:"false",...H})]})]}):s.jsxs("div",{className:B,style:{minHeight:`calc(${y} * 1.6em + 2 * var(--spacing-4))`},children:[s.jsx("div",{ref:w,className:o.default.lineMirror,"aria-hidden":"true"}),h&&s.jsx("div",{ref:v,className:o.default.lineNumbers,"aria-hidden":"true",children:Array.from({length:K}).map((e,t)=>s.jsx("div",{className:o.default.lineNumber,style:f[t]!==void 0?{height:`${f[t]}px`}:void 0,children:t+1},t))}),s.jsx("textarea",{ref:m,className:o.default.textarea,value:r,onChange:e=>n?.(e.target.value),onKeyDown:P,placeholder:D,readOnly:x,"aria-label":M||"Code editor",spellCheck:"false",...H})]})});V.displayName="CodeEditor";exports.CodeEditor=V;
@@ -1 +1 @@
1
- {"version":3,"file":"CodeEditor.d.ts","sourceRoot":"","sources":["../../../src/components/CodeEditor/CodeEditor.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAkD,MAAM,OAAO,CAAC;AACvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAmD1D;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,UAAU,6FAgWtB,CAAC"}
1
+ {"version":3,"file":"CodeEditor.d.ts","sourceRoot":"","sources":["../../../src/components/CodeEditor/CodeEditor.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAkD,MAAM,OAAO,CAAC;AACvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AA+B1D;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,UAAU,6FA4XtB,CAAC"}
@@ -1,157 +1,156 @@
1
- import { jsx as s, jsxs as S } from "react/jsx-runtime";
2
- import { forwardRef as X, useState as v, useRef as g, useEffect as k } from "react";
3
- import { MissingDependencyError as Y } from "../MissingDependencyError.mjs";
4
- import { checkComponent as Z } from "../../utils/optionalDeps.mjs";
5
- import a from "./CodeEditor.module.css.mjs";
6
- import { useThemeContext as ee } from "../../contexts/ThemeContext.mjs";
7
- let F, P, V;
8
- if (typeof require < "u")
9
- try {
10
- F = require("react-syntax-highlighter").Prism;
11
- const l = require("react-syntax-highlighter/dist/esm/styles/prism");
12
- P = l.oneDark, V = l.oneLight;
13
- } catch {
14
- }
15
- if (typeof require < "u")
16
- try {
17
- const r = require("refractor/all");
18
- r.default && r.default.registered && r.default.registered("markdown") && !r.default.languages.markdown?.["quoted-string"] && r.default.languages.insertBefore("markdown", "bold", {
19
- "quoted-string": {
20
- pattern: /"(?:\\.|[^"\\])*"/,
21
- greedy: !0,
22
- alias: "string"
23
- }
24
- });
25
- } catch {
26
- }
27
- const te = X(
1
+ import { jsx as i, jsxs as H } from "react/jsx-runtime";
2
+ import { forwardRef as Z, useState as p, useRef as m, useEffect as x } from "react";
3
+ import { MissingDependencyError as ee } from "../MissingDependencyError.mjs";
4
+ import { checkComponent as te } from "../../utils/optionalDeps.mjs";
5
+ import o from "./CodeEditor.module.css.mjs";
6
+ import { useThemeContext as re } from "../../contexts/ThemeContext.mjs";
7
+ let N, w, C;
8
+ Promise.all([
9
+ import("react-syntax-highlighter"),
10
+ import("react-syntax-highlighter/dist/esm/styles/prism")
11
+ ]).then(([r, l]) => {
12
+ N = r.Prism, w = l.oneDark, C = l.oneLight;
13
+ }).catch(() => {
14
+ });
15
+ const ne = Z(
28
16
  ({
29
17
  value: r = "",
30
18
  onChange: l,
31
- language: L,
32
- readOnly: D = !1,
33
- showLineNumbers: E = !0,
34
- placeholder: H,
35
- minRows: m = 10,
36
- className: z,
37
- "aria-label": M,
38
- ...$
39
- }, I) => {
40
- const [q, w] = v(), [O, U] = v(!0), [p, W] = v(0), [d, _] = v([]), y = g(null), x = g(null), N = g(null), A = g(null), G = g(null), h = g(null), u = I || G;
41
- k(() => {
19
+ language: T,
20
+ readOnly: $ = !1,
21
+ showLineNumbers: A = !0,
22
+ placeholder: R,
23
+ minRows: g = 10,
24
+ className: O,
25
+ "aria-label": K,
26
+ ...B
27
+ }, U) => {
28
+ const [P, L] = p(), [W, _] = p(!0), [q, S] = p(!1), [y, G] = p(0), [d, J] = p([]), v = m(null), b = m(null), D = m(null), j = m(null), Q = m(null), h = m(null), u = U || Q;
29
+ x(() => {
42
30
  (async () => {
43
31
  try {
44
- const t = Z("CodeEditor");
45
- t instanceof Promise ? w(await t) : w(t);
32
+ const t = te("CodeEditor");
33
+ t instanceof Promise ? L(await t) : L(t);
46
34
  } catch {
47
- w(void 0);
35
+ L(void 0);
48
36
  } finally {
49
- U(!1);
37
+ _(!1);
50
38
  }
51
39
  })();
52
- }, []), k(() => {
40
+ }, []), x(() => {
41
+ if (N && w && C) {
42
+ S(!0);
43
+ return;
44
+ }
45
+ const e = setTimeout(() => {
46
+ S(!0);
47
+ }, 0);
48
+ return () => clearTimeout(e);
49
+ }, []), x(() => {
53
50
  if (h.current && u.current) {
54
51
  const { start: e, end: t } = h.current;
55
52
  u.current.setSelectionRange(e, t), h.current = null;
56
53
  }
57
- }), k(() => {
58
- const e = N.current, t = A.current;
54
+ }), x(() => {
55
+ const e = D.current, t = j.current;
59
56
  if (!e || !t) return;
60
57
  const n = () => {
61
- const c = t.clientWidth;
62
- if (c <= 0) return;
63
- e.style.width = `${c}px`;
64
- const i = r.split(`
65
- `), f = Math.max(i.length, m), b = [];
66
- for (let T = 0; T < f; T++) {
67
- const Q = i[T] ?? "";
68
- e.textContent = Q || " ", b.push(e.scrollHeight);
58
+ const a = t.clientWidth;
59
+ if (a <= 0) return;
60
+ e.style.width = `${a}px`;
61
+ const s = r.split(`
62
+ `), f = Math.max(s.length, g), k = [];
63
+ for (let M = 0; M < f; M++) {
64
+ const Y = s[M] ?? "";
65
+ e.textContent = Y || " ", k.push(e.scrollHeight);
69
66
  }
70
- _(b);
67
+ J(k);
71
68
  };
72
69
  n();
73
- const o = new ResizeObserver(n);
74
- return o.observe(t), () => o.disconnect();
75
- }, [r, m]), k(() => {
70
+ const c = new ResizeObserver(n);
71
+ return c.observe(t), () => c.disconnect();
72
+ }, [r, g]), x(() => {
76
73
  const e = (n) => {
77
- const o = n.target;
78
- y.current && (y.current.scrollTop = o.scrollTop), x.current && (x.current.scrollTop = o.scrollTop, x.current.scrollLeft = o.scrollLeft);
74
+ const c = n.target;
75
+ v.current && (v.current.scrollTop = c.scrollTop), b.current && (b.current.scrollTop = c.scrollTop, b.current.scrollLeft = c.scrollLeft);
79
76
  }, t = u?.current;
80
77
  if (t)
81
78
  return t.addEventListener("scroll", e), () => {
82
79
  t.removeEventListener("scroll", e);
83
80
  };
84
81
  }, [u]);
85
- let R = "dark";
82
+ let F = "dark";
86
83
  try {
87
- R = ee().theme;
84
+ F = re().theme;
88
85
  } catch {
89
86
  }
90
- const J = R === "light" ? V : P, B = Math.max(r.split(`
91
- `).length, m);
92
- if (q)
93
- return /* @__PURE__ */ s(Y, { ...q });
94
- if (O)
95
- return /* @__PURE__ */ s("div", { children: "Loading code editor..." });
96
- const C = (e) => {
87
+ const X = F === "light" ? C : w, V = Math.max(r.split(`
88
+ `).length, g);
89
+ if (P)
90
+ return /* @__PURE__ */ i(ee, { ...P });
91
+ if (W)
92
+ return /* @__PURE__ */ i("div", { children: "Loading code editor..." });
93
+ if (T && !q)
94
+ return /* @__PURE__ */ i("div", { children: "Loading code editor..." });
95
+ const E = (e) => {
97
96
  const t = e.value.substring(0, e.selectionStart);
98
- W(t.split(`
97
+ G(t.split(`
99
98
  `).length - 1);
100
- }, K = (e) => {
99
+ }, z = (e) => {
101
100
  if (e.key === "Tab") {
102
101
  e.preventDefault();
103
- const t = e.currentTarget, n = t.selectionStart, o = t.selectionEnd, c = " ";
104
- if (n === o) {
105
- const i = r.substring(0, n) + c + r.substring(o);
102
+ const t = e.currentTarget, n = t.selectionStart, c = t.selectionEnd, a = " ";
103
+ if (n === c) {
104
+ const s = r.substring(0, n) + a + r.substring(c);
106
105
  h.current = {
107
- start: n + c.length,
108
- end: n + c.length
109
- }, l?.(i);
106
+ start: n + a.length,
107
+ end: n + a.length
108
+ }, l?.(s);
110
109
  } else if (e.shiftKey) {
111
- const i = r.lastIndexOf(`
112
- `, n - 1) + 1, f = r.substring(i).match(/^ {1,2}/)?.[0] ?? "";
110
+ const s = r.lastIndexOf(`
111
+ `, n - 1) + 1, f = r.substring(s).match(/^ {1,2}/)?.[0] ?? "";
113
112
  if (f.length > 0) {
114
- const b = r.substring(0, i) + r.substring(i + f.length);
113
+ const k = r.substring(0, s) + r.substring(s + f.length);
115
114
  h.current = {
116
- start: Math.max(i, n - f.length),
117
- end: Math.max(i, o - f.length)
118
- }, l?.(b);
115
+ start: Math.max(s, n - f.length),
116
+ end: Math.max(s, c - f.length)
117
+ }, l?.(k);
119
118
  }
120
119
  } else {
121
- const i = r.substring(0, n) + c + r.substring(o);
120
+ const s = r.substring(0, n) + a + r.substring(c);
122
121
  h.current = {
123
- start: n + c.length,
124
- end: n + c.length
125
- }, l?.(i);
122
+ start: n + a.length,
123
+ end: n + a.length
124
+ }, l?.(s);
126
125
  }
127
126
  }
128
- }, j = [a.wrapper, z].filter(Boolean).join(" ");
129
- return L ? /* @__PURE__ */ S(
127
+ }, I = [o.wrapper, O].filter(Boolean).join(" ");
128
+ return T ? /* @__PURE__ */ H(
130
129
  "div",
131
130
  {
132
- className: j,
131
+ className: I,
133
132
  style: {
134
- minHeight: `calc(${m} * 1.6em + 2 * var(--spacing-4))`
133
+ minHeight: `calc(${g} * 1.6em + 2 * var(--spacing-4))`
135
134
  },
136
135
  children: [
137
- /* @__PURE__ */ s(
136
+ /* @__PURE__ */ i(
138
137
  "div",
139
138
  {
140
- ref: N,
141
- className: a.lineMirror,
139
+ ref: D,
140
+ className: o.lineMirror,
142
141
  "aria-hidden": "true"
143
142
  }
144
143
  ),
145
- E && /* @__PURE__ */ s(
144
+ A && /* @__PURE__ */ i(
146
145
  "div",
147
146
  {
148
- ref: y,
149
- className: a.lineNumbers,
147
+ ref: v,
148
+ className: o.lineNumbers,
150
149
  "aria-hidden": "true",
151
- children: Array.from({ length: B }).map((e, t) => /* @__PURE__ */ s(
150
+ children: Array.from({ length: V }).map((e, t) => /* @__PURE__ */ i(
152
151
  "div",
153
152
  {
154
- className: a.lineNumber,
153
+ className: o.lineNumber,
155
154
  style: d[t] !== void 0 ? { height: `${d[t]}px` } : void 0,
156
155
  children: t + 1
157
156
  },
@@ -159,29 +158,29 @@ const te = X(
159
158
  ))
160
159
  }
161
160
  ),
162
- /* @__PURE__ */ S("div", { ref: A, className: a.editorArea, children: [
163
- /* @__PURE__ */ s(
161
+ /* @__PURE__ */ H("div", { ref: j, className: o.editorArea, children: [
162
+ /* @__PURE__ */ i(
164
163
  "div",
165
164
  {
166
- className: a.lineHighlight,
165
+ className: o.lineHighlight,
167
166
  style: {
168
- top: d.length > 0 ? `calc(var(--spacing-4) + ${d.slice(0, p).reduce((e, t) => e + t, 0)}px)` : `calc(var(--spacing-4) + ${(p * 1.6).toFixed(2)}em)`,
169
- ...d[p] !== void 0 ? { height: `${d[p]}px` } : {}
167
+ top: d.length > 0 ? `calc(var(--spacing-4) + ${d.slice(0, y).reduce((e, t) => e + t, 0)}px)` : `calc(var(--spacing-4) + ${(y * 1.6).toFixed(2)}em)`,
168
+ ...d[y] !== void 0 ? { height: `${d[y]}px` } : {}
170
169
  },
171
170
  "aria-hidden": "true"
172
171
  }
173
172
  ),
174
- /* @__PURE__ */ s(
173
+ /* @__PURE__ */ i(
175
174
  "div",
176
175
  {
177
- ref: x,
178
- className: a.highlightLayer,
176
+ ref: b,
177
+ className: o.highlightLayer,
179
178
  "aria-hidden": "true",
180
- children: /* @__PURE__ */ s(
181
- F,
179
+ children: /* @__PURE__ */ i(
180
+ N,
182
181
  {
183
- language: L,
184
- style: J,
182
+ language: T,
183
+ style: X,
185
184
  customStyle: {
186
185
  margin: 0,
187
186
  padding: 0,
@@ -208,44 +207,44 @@ const te = X(
208
207
  )
209
208
  }
210
209
  ),
211
- /* @__PURE__ */ s(
210
+ /* @__PURE__ */ i(
212
211
  "textarea",
213
212
  {
214
213
  ref: u,
215
- className: a.textareaOverlay,
214
+ className: o.textareaOverlay,
216
215
  value: r,
217
216
  onChange: (e) => l?.(e.target.value),
218
- onKeyDown: K,
219
- onKeyUp: (e) => C(e.currentTarget),
220
- onMouseUp: (e) => C(e.currentTarget),
221
- onClick: (e) => C(e.currentTarget),
222
- placeholder: H,
223
- readOnly: D,
224
- "aria-label": M || "Code editor",
217
+ onKeyDown: z,
218
+ onKeyUp: (e) => E(e.currentTarget),
219
+ onMouseUp: (e) => E(e.currentTarget),
220
+ onClick: (e) => E(e.currentTarget),
221
+ placeholder: R,
222
+ readOnly: $,
223
+ "aria-label": K || "Code editor",
225
224
  spellCheck: "false",
226
- ...$
225
+ ...B
227
226
  }
228
227
  )
229
228
  ] })
230
229
  ]
231
230
  }
232
- ) : /* @__PURE__ */ S(
231
+ ) : /* @__PURE__ */ H(
233
232
  "div",
234
233
  {
235
- className: j,
236
- style: { minHeight: `calc(${m} * 1.6em + 2 * var(--spacing-4))` },
234
+ className: I,
235
+ style: { minHeight: `calc(${g} * 1.6em + 2 * var(--spacing-4))` },
237
236
  children: [
238
- /* @__PURE__ */ s("div", { ref: N, className: a.lineMirror, "aria-hidden": "true" }),
239
- E && /* @__PURE__ */ s(
237
+ /* @__PURE__ */ i("div", { ref: D, className: o.lineMirror, "aria-hidden": "true" }),
238
+ A && /* @__PURE__ */ i(
240
239
  "div",
241
240
  {
242
- ref: y,
243
- className: a.lineNumbers,
241
+ ref: v,
242
+ className: o.lineNumbers,
244
243
  "aria-hidden": "true",
245
- children: Array.from({ length: B }).map((e, t) => /* @__PURE__ */ s(
244
+ children: Array.from({ length: V }).map((e, t) => /* @__PURE__ */ i(
246
245
  "div",
247
246
  {
248
- className: a.lineNumber,
247
+ className: o.lineNumber,
249
248
  style: d[t] !== void 0 ? { height: `${d[t]}px` } : void 0,
250
249
  children: t + 1
251
250
  },
@@ -253,19 +252,19 @@ const te = X(
253
252
  ))
254
253
  }
255
254
  ),
256
- /* @__PURE__ */ s(
255
+ /* @__PURE__ */ i(
257
256
  "textarea",
258
257
  {
259
258
  ref: u,
260
- className: a.textarea,
259
+ className: o.textarea,
261
260
  value: r,
262
261
  onChange: (e) => l?.(e.target.value),
263
- onKeyDown: K,
264
- placeholder: H,
265
- readOnly: D,
266
- "aria-label": M || "Code editor",
262
+ onKeyDown: z,
263
+ placeholder: R,
264
+ readOnly: $,
265
+ "aria-label": K || "Code editor",
267
266
  spellCheck: "false",
268
- ...$
267
+ ...B
269
268
  }
270
269
  )
271
270
  ]
@@ -273,7 +272,7 @@ const te = X(
273
272
  );
274
273
  }
275
274
  );
276
- te.displayName = "CodeEditor";
275
+ ne.displayName = "CodeEditor";
277
276
  export {
278
- te as CodeEditor
277
+ ne as CodeEditor
279
278
  };
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("react/jsx-runtime"),t=require("react"),S=require("../hooks/useTheme.cjs"),i=require("../utils/fonts.cjs"),O=require("../components/FontLoader/FontLoader.cjs"),h={theme:"light",brand:"orion",setTheme:()=>{},setBrand:()=>{},toggleTheme:()=>{},isDark:!1,isLight:!0},p=t.createContext(h);function P(){return typeof window>"u"?!0:getComputedStyle(document.documentElement).getPropertyValue("--orion-react-styles-loaded").trim()==="1"}function x({children:o,defaultTheme:r,defaultBrand:d,options:T,disableFontWarnings:c=!1,disableAutoFontLoading:g=!1,disableCSSWarnings:u=!1}){const v={...T,...r!==void 0&&{defaultTheme:r},...d!==void 0&&{defaultBrand:d}},n=S.useTheme(v),l=t.useRef(new Set),a=t.useRef(!1);return t.useEffect(()=>{if(u||typeof window>"u"||!(process.env.NODE_ENV==="development"||window.location.hostname==="localhost"))return;const s=setTimeout(()=>{!a.current&&!P()&&(a.current=!0,console.warn(`[Orion] Component styles not detected!
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("react/jsx-runtime"),t=require("react"),S=require("../hooks/useTheme.cjs"),i=require("../utils/fonts.cjs"),O=require("../components/FontLoader/FontLoader.cjs"),h={theme:"light",brand:"orion",setTheme:()=>{},setBrand:()=>{},toggleTheme:()=>{},isDark:!1,isLight:!0},p=t.createContext(h);function P(){return typeof window>"u"?!0:getComputedStyle(document.documentElement).getPropertyValue("--orion-react-styles-loaded").trim()==="1"}function x({children:o,defaultTheme:r,defaultBrand:d,options:T,disableFontWarnings:c=!1,disableAutoFontLoading:v=!1,disableCSSWarnings:u=!1}){const g={...T,...r!==void 0&&{defaultTheme:r},...d!==void 0&&{defaultBrand:d}},n=S.useTheme(g),a=t.useRef(new Set),m=t.useRef(!1);return t.useEffect(()=>{if(u||typeof window>"u"||!(process.env.NODE_ENV==="development"||window.location.hostname==="localhost"))return;const s=setTimeout(()=>{!m.current&&!P()&&(m.current=!0,console.warn(`[Orion] Component styles not detected!
2
2
 
3
3
  You must import the component CSS file:
4
4
 
@@ -6,7 +6,7 @@ You must import the component CSS file:
6
6
 
7
7
  Add this import in your app entry file. It includes both design tokens and component styles.
8
8
 
9
- To disable this warning, set disableCSSWarnings={true} on ThemeProvider.`))},100);return()=>clearTimeout(s)},[u]),t.useEffect(()=>{if(c||typeof window>"u"||!(process.env.NODE_ENV==="development"||typeof window<"u"&&window.location.hostname==="localhost"))return;const s=setTimeout(()=>{const{brand:e}=n,m=i.getMissingFonts(e);if(m.length>0&&!l.current.has(e)){l.current.add(e);const w=i.BRAND_FONTS[e].join(", ");console.warn(`[Orion] Missing fonts for "${e}" brand: ${m.join(", ")}
9
+ To disable this warning, set disableCSSWarnings={true} on ThemeProvider.`))},100);return()=>clearTimeout(s)},[u]),t.useEffect(()=>{if(c||typeof window>"u"||!(process.env.NODE_ENV==="development"||typeof window<"u"&&window.location.hostname==="localhost"))return;const s=setTimeout(()=>{const{brand:e}=n,l=i.getMissingFonts(e);if(l.length>0&&!a.current.has(e)){a.current.add(e);const w=i.BRAND_FONTS[e].join(", ");console.warn(`[Orion] Missing fonts for "${e}" brand: ${l.join(", ")}
10
10
 
11
11
  The "${e}" brand requires these fonts: ${w}
12
12
 
@@ -24,14 +24,16 @@ Option 2: Add Google Fonts to your HTML <head>
24
24
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
25
25
  <link href="${i.GOOGLE_FONTS_URL}" rel="stylesheet">
26
26
 
27
- To disable this warning, set disableFontWarnings={true} on ThemeProvider.`)}},1e3);return()=>clearTimeout(s)},[n.brand,c,n]),f.jsxs(p.Provider,{value:n,children:[!g&&f.jsx(O.FontLoader,{}),o]})}function C(){const o=t.useContext(p);return process.env.NODE_ENV==="development"&&typeof window<"u"&&o===h&&console.warn(`⚠️ [Orion] useThemeContext() called outside <ThemeProvider>. Using SSR defaults.
27
+ To disable this warning, set disableFontWarnings={true} on ThemeProvider.`)}},1e3);return()=>clearTimeout(s)},[n.brand,c,n]),f.jsxs(p.Provider,{value:n,children:[!v&&f.jsx(O.FontLoader,{}),o]})}function C(){const o=t.useContext(p);if(o===h&&process.env.NODE_ENV==="development")throw new Error(`useThemeContext must be used within a <ThemeProvider> component.
28
28
 
29
- For full theme functionality, wrap your app with <ThemeProvider>:
29
+ Wrap your app at the root:
30
30
 
31
- export default function App() {
32
- return (
33
- <ThemeProvider>
34
- <YourComponents />
35
- </ThemeProvider>
36
- );
37
- }`),o}exports.ThemeProvider=x;exports.useThemeContext=C;
31
+ import { ThemeProvider } from '@orion-ds/react';
32
+
33
+ export default function App() {
34
+ return (
35
+ <ThemeProvider>
36
+ <YourComponents />
37
+ </ThemeProvider>
38
+ );
39
+ }`);return o}exports.ThemeProvider=x;exports.useThemeContext=C;
@@ -55,13 +55,16 @@ export declare function ThemeProvider({ children, defaultTheme, defaultBrand, op
55
55
  *
56
56
  * ⚠️ IMPORTANT: Must be used inside a ThemeProvider for full functionality
57
57
  *
58
- * Returns SSR-safe defaults if used outside ThemeProvider (instead of throwing).
59
- * In development, a warning is logged if context is accessed outside the provider.
58
+ * **Development**: Throws a clear error if used outside ThemeProvider
59
+ * (helps catch integration mistakes early)
60
+ *
61
+ * **Production**: Returns SSR-safe defaults if used outside ThemeProvider
62
+ * (maintains compatibility during Next.js static prerendering)
60
63
  *
61
64
  * @example
62
65
  * ```tsx
63
66
  * function MyComponent() {
64
- * const { theme, brand, setTheme, setBrand } = useTheme();
67
+ * const { theme, brand, setTheme, setBrand } = useThemeContext();
65
68
  * // Components automatically inherit theme/brand from <html> attributes
66
69
  * // DO NOT pass brand prop to components - it's applied globally!
67
70
  * }
@@ -1 +1 @@
1
- {"version":3,"file":"ThemeContext.d.ts","sourceRoot":"","sources":["../../src/contexts/ThemeContext.tsx"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,EAKL,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AACf,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,cAAc,EACpB,MAAM,mBAAmB,CAAC;AAoC3B;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,QAAQ,EAAE,SAAS,CAAC;IAEpB;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAEhC;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,GAAG,KAAK,GAAG,UAAU,GAAG,QAAQ,GAAG,OAAO,CAAC;IAEjE;;;OAGG;IACH,OAAO,CAAC,EAAE,eAAe,CAAC;IAE1B;;;OAGG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAE9B;;;;;OAKG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;IAEjC;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,EAC5B,QAAQ,EACR,YAAY,EACZ,YAAY,EACZ,OAAO,EACP,mBAA2B,EAC3B,sBAA8B,EAC9B,kBAA0B,GAC3B,EAAE,kBAAkB,2CA2FpB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,eAAe,IAAI,cAAc,CAsBhD"}
1
+ {"version":3,"file":"ThemeContext.d.ts","sourceRoot":"","sources":["../../src/contexts/ThemeContext.tsx"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,EAKL,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AACf,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,cAAc,EACpB,MAAM,mBAAmB,CAAC;AAoC3B;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,QAAQ,EAAE,SAAS,CAAC;IAEpB;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAEhC;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,GAAG,KAAK,GAAG,UAAU,GAAG,QAAQ,GAAG,OAAO,CAAC;IAEjE;;;OAGG;IACH,OAAO,CAAC,EAAE,eAAe,CAAC;IAE1B;;;OAGG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAE9B;;;;;OAKG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;IAEjC;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,EAC5B,QAAQ,EACR,YAAY,EACZ,YAAY,EACZ,OAAO,EACP,mBAA2B,EAC3B,sBAA8B,EAC9B,kBAA0B,GAC3B,EAAE,kBAAkB,2CA2FpB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,eAAe,IAAI,cAAc,CAyBhD"}
@@ -1,8 +1,8 @@
1
1
  import { jsxs as y, jsx as S } from "react/jsx-runtime";
2
- import { useRef as a, useEffect as u, useContext as O, createContext as x } from "react";
2
+ import { useRef as u, useEffect as l, useContext as O, createContext as x } from "react";
3
3
  import { useTheme as C } from "../hooks/useTheme.mjs";
4
- import { getMissingFonts as F, BRAND_FONTS as P, GOOGLE_FONTS_URL as D } from "../utils/fonts.mjs";
5
- import { FontLoader as E } from "../components/FontLoader/FontLoader.mjs";
4
+ import { getMissingFonts as E, BRAND_FONTS as P, GOOGLE_FONTS_URL as D } from "../utils/fonts.mjs";
5
+ import { FontLoader as F } from "../components/FontLoader/FontLoader.mjs";
6
6
  const f = {
7
7
  theme: "light",
8
8
  brand: "orion",
@@ -18,7 +18,7 @@ const f = {
18
18
  function L() {
19
19
  return typeof window > "u" ? !0 : getComputedStyle(document.documentElement).getPropertyValue("--orion-react-styles-loaded").trim() === "1";
20
20
  }
21
- function A({
21
+ function R({
22
22
  children: o,
23
23
  defaultTheme: n,
24
24
  defaultBrand: s,
@@ -27,15 +27,15 @@ function A({
27
27
  disableAutoFontLoading: T = !1,
28
28
  disableCSSWarnings: d = !1
29
29
  }) {
30
- const g = {
30
+ const v = {
31
31
  ...h,
32
32
  ...n !== void 0 && { defaultTheme: n },
33
33
  ...s !== void 0 && { defaultBrand: s }
34
- }, t = C(g), c = a(/* @__PURE__ */ new Set()), m = a(!1);
35
- return u(() => {
34
+ }, t = C(v), m = u(/* @__PURE__ */ new Set()), c = u(!1);
35
+ return l(() => {
36
36
  if (d || typeof window > "u" || !(process.env.NODE_ENV === "development" || window.location.hostname === "localhost")) return;
37
37
  const r = setTimeout(() => {
38
- !m.current && !L() && (m.current = !0, console.warn(
38
+ !c.current && !L() && (c.current = !0, console.warn(
39
39
  `[Orion] Component styles not detected!
40
40
 
41
41
  You must import the component CSS file:
@@ -48,15 +48,15 @@ To disable this warning, set disableCSSWarnings={true} on ThemeProvider.`
48
48
  ));
49
49
  }, 100);
50
50
  return () => clearTimeout(r);
51
- }, [d]), u(() => {
51
+ }, [d]), l(() => {
52
52
  if (i || typeof window > "u" || !(process.env.NODE_ENV === "development" || typeof window < "u" && window.location.hostname === "localhost")) return;
53
53
  const r = setTimeout(() => {
54
- const { brand: e } = t, l = F(e);
55
- if (l.length > 0 && !c.current.has(e)) {
56
- c.current.add(e);
54
+ const { brand: e } = t, a = E(e);
55
+ if (a.length > 0 && !m.current.has(e)) {
56
+ m.current.add(e);
57
57
  const w = P[e].join(", ");
58
58
  console.warn(
59
- `[Orion] Missing fonts for "${e}" brand: ${l.join(", ")}
59
+ `[Orion] Missing fonts for "${e}" brand: ${a.join(", ")}
60
60
 
61
61
  The "${e}" brand requires these fonts: ${w}
62
62
 
@@ -80,27 +80,31 @@ To disable this warning, set disableFontWarnings={true} on ThemeProvider.`
80
80
  }, 1e3);
81
81
  return () => clearTimeout(r);
82
82
  }, [t.brand, i, t]), /* @__PURE__ */ y(p.Provider, { value: t, children: [
83
- !T && /* @__PURE__ */ S(E, {}),
83
+ !T && /* @__PURE__ */ S(F, {}),
84
84
  o
85
85
  ] });
86
86
  }
87
87
  function $() {
88
88
  const o = O(p);
89
- return process.env.NODE_ENV === "development" && typeof window < "u" && o === f && console.warn(
90
- `⚠️ [Orion] useThemeContext() called outside <ThemeProvider>. Using SSR defaults.
89
+ if (o === f && process.env.NODE_ENV === "development")
90
+ throw new Error(
91
+ `useThemeContext must be used within a <ThemeProvider> component.
91
92
 
92
- For full theme functionality, wrap your app with <ThemeProvider>:
93
+ Wrap your app at the root:
93
94
 
94
- export default function App() {
95
- return (
96
- <ThemeProvider>
97
- <YourComponents />
98
- </ThemeProvider>
99
- );
100
- }`
101
- ), o;
95
+ import { ThemeProvider } from '@orion-ds/react';
96
+
97
+ export default function App() {
98
+ return (
99
+ <ThemeProvider>
100
+ <YourComponents />
101
+ </ThemeProvider>
102
+ );
103
+ }`
104
+ );
105
+ return o;
102
106
  }
103
107
  export {
104
- A as ThemeProvider,
108
+ R as ThemeProvider,
105
109
  $ as useThemeContext
106
110
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orion-ds/react",
3
- "version": "5.4.0",
3
+ "version": "5.5.1",
4
4
  "type": "module",
5
5
  "description": "Orion Design System - React component library with 40+ AI-ready components and 9 templates",
6
6
  "author": "Orion Design System Team",