@orion-ds/react 5.0.0 → 5.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.
Files changed (40) hide show
  1. package/README.md +48 -4
  2. package/dist/client.cjs +1 -1
  3. package/dist/client.mjs +143 -139
  4. package/dist/components/Button/Button.module.css +1 -1
  5. package/dist/components/Button/Button.module.css.cjs +1 -1
  6. package/dist/components/Button/Button.module.css.mjs +28 -28
  7. package/dist/components/Calendar/Calendar.cjs +1 -1
  8. package/dist/components/Calendar/Calendar.d.ts.map +1 -1
  9. package/dist/components/Calendar/Calendar.mjs +105 -86
  10. package/dist/components/Chart/Chart.cjs +1 -1
  11. package/dist/components/Chart/Chart.d.ts +2 -3
  12. package/dist/components/Chart/Chart.d.ts.map +1 -1
  13. package/dist/components/Chart/Chart.mjs +124 -71
  14. package/dist/components/Chat/components/ChatMarkdown.cjs +1 -1
  15. package/dist/components/Chat/components/ChatMarkdown.d.ts.map +1 -1
  16. package/dist/components/Chat/components/ChatMarkdown.mjs +32 -17
  17. package/dist/components/CodeEditor/CodeEditor.cjs +6 -6
  18. package/dist/components/CodeEditor/CodeEditor.d.ts.map +1 -1
  19. package/dist/components/CodeEditor/CodeEditor.mjs +118 -99
  20. package/dist/components/CollapsibleFolder/CollapsibleFolder.cjs +1 -1
  21. package/dist/components/CollapsibleFolder/CollapsibleFolder.d.ts.map +1 -1
  22. package/dist/components/CollapsibleFolder/CollapsibleFolder.mjs +123 -105
  23. package/dist/components/DatePicker/DatePicker.cjs +1 -1
  24. package/dist/components/DatePicker/DatePicker.d.ts.map +1 -1
  25. package/dist/components/DatePicker/DatePicker.mjs +70 -52
  26. package/dist/components/MissingDependencyError.cjs +1 -0
  27. package/dist/components/MissingDependencyError.d.ts +5 -0
  28. package/dist/components/MissingDependencyError.d.ts.map +1 -0
  29. package/dist/components/MissingDependencyError.mjs +140 -0
  30. package/dist/index.cjs +1 -1
  31. package/dist/index.mjs +143 -139
  32. package/dist/styles.css +111 -3
  33. package/dist/theme.css +110 -2
  34. package/dist/utils/index.d.ts +1 -0
  35. package/dist/utils/index.d.ts.map +1 -1
  36. package/dist/utils/optionalDeps.cjs +1 -0
  37. package/dist/utils/optionalDeps.d.ts +63 -0
  38. package/dist/utils/optionalDeps.d.ts.map +1 -0
  39. package/dist/utils/optionalDeps.mjs +55 -0
  40. package/package.json +2 -1
@@ -1,103 +1,156 @@
1
- import { jsx as t, jsxs as C } from "react/jsx-runtime";
2
- import { useContext as v, createContext as j } from "react";
3
- import { Legend as I, Tooltip as K, ResponsiveContainer as T } from "recharts";
4
- import { useResolvedChartColors as B } from "./useResolvedChartColors.mjs";
1
+ import { jsx as e, jsxs as h } from "react/jsx-runtime";
2
+ import { useContext as y, createContext as K } from "react";
3
+ import { useResolvedChartColors as R } from "./useResolvedChartColors.mjs";
4
+ import { MissingDependencyError as C } from "../MissingDependencyError.mjs";
5
5
  import o from "./Chart.module.css.mjs";
6
- const h = j({}), D = ({
7
- config: n,
8
- children: e,
9
- className: s,
10
- style: l,
11
- ...a
6
+ let b, L, x, p = null;
7
+ try {
8
+ const t = require("recharts");
9
+ b = t.ResponsiveContainer, L = t.Tooltip, x = t.Legend;
10
+ } catch (t) {
11
+ p = t instanceof Error ? t : new Error("recharts not found");
12
+ }
13
+ const u = K({}), U = ({
14
+ config: t,
15
+ children: n,
16
+ className: a,
17
+ style: r,
18
+ ...s
12
19
  }) => {
13
- const { resolvedConfig: i, resolvedColorVars: r } = B(n), c = [o.container, s].filter(Boolean).join(" ");
14
- return /* @__PURE__ */ t(h.Provider, { value: i, children: /* @__PURE__ */ t(
20
+ if (p)
21
+ return /* @__PURE__ */ e(
22
+ C,
23
+ {
24
+ available: !1,
25
+ componentName: "Chart",
26
+ depName: "recharts",
27
+ installCommand: "npm install recharts",
28
+ pnpmCommand: "pnpm add recharts",
29
+ docsUrl: "https://docs.orion-ds.dev/components/chart"
30
+ }
31
+ );
32
+ const { resolvedConfig: l, resolvedColorVars: i } = R(t), c = [o.container, a].filter(Boolean).join(" ");
33
+ return /* @__PURE__ */ e(u.Provider, { value: l, children: /* @__PURE__ */ e(
15
34
  "div",
16
35
  {
17
36
  role: "figure",
18
37
  className: c,
19
- style: { ...r, ...l },
20
- ...a,
21
- children: /* @__PURE__ */ t(T, { width: "100%", height: "100%", children: e })
38
+ style: { ...i, ...r },
39
+ ...s,
40
+ children: /* @__PURE__ */ e(b, { width: "100%", height: "100%", children: n })
22
41
  }
23
42
  ) });
24
43
  };
25
- D.displayName = "ChartContainer";
26
- const G = ({
27
- active: n,
28
- payload: e,
29
- label: s,
30
- indicator: l = "dot",
31
- hideLabel: a = !1,
32
- hideIndicator: i = !1,
33
- labelFormatter: r,
44
+ U.displayName = "ChartContainer";
45
+ const B = ({
46
+ active: t,
47
+ payload: n,
48
+ label: a,
49
+ indicator: r = "dot",
50
+ hideLabel: s = !1,
51
+ hideIndicator: l = !1,
52
+ labelFormatter: i,
34
53
  formatter: c,
35
- className: m
54
+ className: f
36
55
  }) => {
37
- const N = v(h);
38
- if (!n || !e?.length) return null;
39
- const y = [o.tooltip, m].filter(Boolean).join(" "), f = r ? r(String(s)) : s, L = {
56
+ if (p)
57
+ return /* @__PURE__ */ e(
58
+ C,
59
+ {
60
+ available: !1,
61
+ componentName: "Chart",
62
+ depName: "recharts",
63
+ installCommand: "npm install recharts",
64
+ pnpmCommand: "pnpm add recharts",
65
+ docsUrl: "https://docs.orion-ds.dev/components/chart"
66
+ }
67
+ );
68
+ const j = y(u);
69
+ if (!t || !n?.length) return null;
70
+ const I = [o.tooltip, f].filter(Boolean).join(" "), v = i ? i(String(a)) : a, T = {
40
71
  dot: o.tooltipDot,
41
72
  line: o.tooltipLine,
42
73
  dashed: o.tooltipDashed
43
- }[l];
44
- return /* @__PURE__ */ C("div", { className: y, children: [
45
- !a && f && /* @__PURE__ */ t("div", { className: o.tooltipLabel, children: f }),
46
- /* @__PURE__ */ t("div", { className: o.tooltipItems, children: e.map((d) => {
47
- const p = String(d.dataKey || d.name), g = N[p], x = g?.label || p, b = c ? c(d.value, p) : String(d.value), u = d.color || g?.color;
48
- return /* @__PURE__ */ C("div", { className: o.tooltipItem, children: [
49
- !i && /* @__PURE__ */ t(
74
+ }[r];
75
+ return /* @__PURE__ */ h("div", { className: I, children: [
76
+ !s && v && /* @__PURE__ */ e("div", { className: o.tooltipLabel, children: v }),
77
+ /* @__PURE__ */ e("div", { className: o.tooltipItems, children: n.map((d) => {
78
+ const m = String(d.dataKey || d.name), g = j[m], D = g?.label || m, E = c ? c(d.value, m) : String(d.value), N = d.color || g?.color;
79
+ return /* @__PURE__ */ h("div", { className: o.tooltipItem, children: [
80
+ !l && /* @__PURE__ */ e(
50
81
  "span",
51
82
  {
52
- className: L,
53
- style: { backgroundColor: u, borderColor: u }
83
+ className: T,
84
+ style: { backgroundColor: N, borderColor: N }
54
85
  }
55
86
  ),
56
- /* @__PURE__ */ t("span", { className: o.tooltipName, children: x }),
57
- /* @__PURE__ */ t("span", { className: o.tooltipValue, children: b })
58
- ] }, p);
87
+ /* @__PURE__ */ e("span", { className: o.tooltipName, children: D }),
88
+ /* @__PURE__ */ e("span", { className: o.tooltipValue, children: E })
89
+ ] }, m);
59
90
  }) })
60
91
  ] });
61
92
  };
62
- G.displayName = "ChartTooltipContent";
63
- const S = ({
64
- payload: n,
65
- className: e
93
+ B.displayName = "ChartTooltipContent";
94
+ const G = ({
95
+ payload: t,
96
+ className: n
66
97
  }) => {
67
- const s = v(h);
68
- if (!n?.length) return null;
69
- const l = [o.legend, e].filter(Boolean).join(" ");
70
- return /* @__PURE__ */ t("div", { className: l, children: n.map((a) => {
71
- const i = a.dataKey || a.value, r = s[i], c = r?.label || i, m = a.color || r?.color;
72
- return /* @__PURE__ */ C("div", { className: o.legendItem, children: [
73
- /* @__PURE__ */ t(
98
+ if (p)
99
+ return /* @__PURE__ */ e(
100
+ C,
101
+ {
102
+ available: !1,
103
+ componentName: "Chart",
104
+ depName: "recharts",
105
+ installCommand: "npm install recharts",
106
+ pnpmCommand: "pnpm add recharts",
107
+ docsUrl: "https://docs.orion-ds.dev/components/chart"
108
+ }
109
+ );
110
+ const a = y(u);
111
+ if (!t?.length) return null;
112
+ const r = [o.legend, n].filter(Boolean).join(" ");
113
+ return /* @__PURE__ */ e("div", { className: r, children: t.map((s) => {
114
+ const l = s.dataKey || s.value, i = a[l], c = i?.label || l, f = s.color || i?.color;
115
+ return /* @__PURE__ */ h("div", { className: o.legendItem, children: [
116
+ /* @__PURE__ */ e(
74
117
  "span",
75
118
  {
76
119
  className: o.legendDot,
77
- style: { backgroundColor: m }
120
+ style: { backgroundColor: f }
78
121
  }
79
122
  ),
80
- /* @__PURE__ */ t("span", { children: c })
81
- ] }, i);
123
+ /* @__PURE__ */ e("span", { children: c })
124
+ ] }, l);
82
125
  }) });
83
126
  };
84
- S.displayName = "ChartLegendContent";
85
- const V = ({
86
- id: n,
87
- color: e,
88
- startOpacity: s = 0.4,
89
- endOpacity: l = 0.05
90
- }) => /* @__PURE__ */ C("linearGradient", { id: n, x1: "0", y1: "0", x2: "0", y2: "1", children: [
91
- /* @__PURE__ */ t("stop", { offset: "5%", stopColor: e, stopOpacity: s }),
92
- /* @__PURE__ */ t("stop", { offset: "95%", stopColor: e, stopOpacity: l })
127
+ G.displayName = "ChartLegendContent";
128
+ const S = ({
129
+ id: t,
130
+ color: n,
131
+ startOpacity: a = 0.4,
132
+ endOpacity: r = 0.05
133
+ }) => p ? /* @__PURE__ */ e(
134
+ C,
135
+ {
136
+ available: !1,
137
+ componentName: "Chart",
138
+ depName: "recharts",
139
+ installCommand: "npm install recharts",
140
+ pnpmCommand: "pnpm add recharts",
141
+ docsUrl: "https://docs.orion-ds.dev/components/chart"
142
+ }
143
+ ) : /* @__PURE__ */ h("linearGradient", { id: t, x1: "0", y1: "0", x2: "0", y2: "1", children: [
144
+ /* @__PURE__ */ e("stop", { offset: "5%", stopColor: n, stopOpacity: a }),
145
+ /* @__PURE__ */ e("stop", { offset: "95%", stopColor: n, stopOpacity: r })
93
146
  ] });
94
- V.displayName = "ChartGradient";
95
- const q = K, z = I;
147
+ S.displayName = "ChartGradient";
148
+ const M = L || null, P = x || null;
96
149
  export {
97
- D as ChartContainer,
98
- V as ChartGradient,
99
- z as ChartLegend,
100
- S as ChartLegendContent,
101
- q as ChartTooltip,
102
- G as ChartTooltipContent
150
+ U as ChartContainer,
151
+ S as ChartGradient,
152
+ P as ChartLegend,
153
+ G as ChartLegendContent,
154
+ M as ChartTooltip,
155
+ B as ChartTooltipContent
103
156
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),d=require("react-markdown"),u=require("remark-gfm"),m=require("./ChatCodeBlock.cjs"),g=require("../Chat.module.css.cjs"),o=({content:s,className:c,...i})=>r.jsx("div",{className:[g.default.markdown,c].filter(Boolean).join(" "),...i,children:r.jsx(d,{remarkPlugins:[u],components:{code({className:e,children:t,...a}){const n=/language-(\w+)/.exec(e||"");if(!n)return r.jsx("code",{className:e,...a,children:t});const l=String(t).replace(/\n$/,"");return r.jsx(m.ChatCodeBlock,{code:l,language:n[1]})},pre({children:e}){return r.jsx(r.Fragment,{children:e})},a({href:e,children:t,...a}){const n=e?.startsWith("http");return r.jsx("a",{href:e,target:n?"_blank":void 0,rel:n?"noopener noreferrer":void 0,...a,children:t})}},children:s})});o.displayName="ChatMarkdown";exports.ChatMarkdown=o;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),k=require("./ChatCodeBlock.cjs"),p=require("../../MissingDependencyError.cjs"),g=require("../Chat.module.css.cjs");let s,c,i=null;try{s=require("react-markdown"),c=require("remark-gfm")}catch(a){i=a instanceof Error?a:new Error("react-markdown or remark-gfm not found")}const d=({content:a,className:m,...l})=>i?r.jsx(p.MissingDependencyError,{available:!1,componentName:"Chat",depName:["react-markdown","remark-gfm"],installCommand:"npm install react-markdown remark-gfm",pnpmCommand:"pnpm add react-markdown remark-gfm",docsUrl:"https://docs.orion-ds.dev/components/chat"}):r.jsx("div",{className:[g.default.markdown,m].filter(Boolean).join(" "),...l,children:r.jsx(s,{remarkPlugins:[c],components:{code({className:e,children:t,...o}){const n=/language-(\w+)/.exec(e||"");if(!n)return r.jsx("code",{className:e,...o,children:t});const u=String(t).replace(/\n$/,"");return r.jsx(k.ChatCodeBlock,{code:u,language:n[1]})},pre({children:e}){return r.jsx(r.Fragment,{children:e})},a({href:e,children:t,...o}){const n=e?.startsWith("http");return r.jsx("a",{href:e,target:n?"_blank":void 0,rel:n?"noopener noreferrer":void 0,...o,children:t})}},children:a})});d.displayName="ChatMarkdown";exports.ChatMarkdown=d;
@@ -1 +1 @@
1
- {"version":3,"file":"ChatMarkdown.d.ts","sourceRoot":"","sources":["../../../../src/components/Chat/components/ChatMarkdown.tsx"],"names":[],"mappings":"AAEA;;;;;GAKG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAIvD,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAyDpD,CAAC"}
1
+ {"version":3,"file":"ChatMarkdown.d.ts","sourceRoot":"","sources":["../../../../src/components/Chat/components/ChatMarkdown.tsx"],"names":[],"mappings":"AAEA;;;;;GAKG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAiBvD,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAuEpD,CAAC"}
@@ -1,33 +1,48 @@
1
- import { jsx as e, Fragment as c } from "react/jsx-runtime";
2
- import l from "react-markdown";
3
- import d from "remark-gfm";
4
- import { ChatCodeBlock as p } from "./ChatCodeBlock.mjs";
1
+ import { jsx as e, Fragment as p } from "react/jsx-runtime";
2
+ import { ChatCodeBlock as k } from "./ChatCodeBlock.mjs";
3
+ import { MissingDependencyError as f } from "../../MissingDependencyError.mjs";
5
4
  import g from "../Chat.module.css.mjs";
6
- const f = ({
5
+ let m, c, i = null;
6
+ try {
7
+ m = require("react-markdown"), c = require("remark-gfm");
8
+ } catch (a) {
9
+ i = a instanceof Error ? a : new Error("react-markdown or remark-gfm not found");
10
+ }
11
+ const u = ({
7
12
  content: a,
8
- className: i,
9
- ...m
10
- }) => /* @__PURE__ */ e(
13
+ className: s,
14
+ ...l
15
+ }) => i ? /* @__PURE__ */ e(
16
+ f,
17
+ {
18
+ available: !1,
19
+ componentName: "Chat",
20
+ depName: ["react-markdown", "remark-gfm"],
21
+ installCommand: "npm install react-markdown remark-gfm",
22
+ pnpmCommand: "pnpm add react-markdown remark-gfm",
23
+ docsUrl: "https://docs.orion-ds.dev/components/chat"
24
+ }
25
+ ) : /* @__PURE__ */ e(
11
26
  "div",
12
27
  {
13
- className: [g.markdown, i].filter(Boolean).join(" "),
14
- ...m,
28
+ className: [g.markdown, s].filter(Boolean).join(" "),
29
+ ...l,
15
30
  children: /* @__PURE__ */ e(
16
- l,
31
+ m,
17
32
  {
18
- remarkPlugins: [d],
33
+ remarkPlugins: [c],
19
34
  components: {
20
35
  // Custom code block rendering
21
36
  code({ className: r, children: o, ...t }) {
22
37
  const n = /language-(\w+)/.exec(r || "");
23
38
  if (!n)
24
39
  return /* @__PURE__ */ e("code", { className: r, ...t, children: o });
25
- const s = String(o).replace(/\n$/, "");
26
- return /* @__PURE__ */ e(p, { code: s, language: n[1] });
40
+ const d = String(o).replace(/\n$/, "");
41
+ return /* @__PURE__ */ e(k, { code: d, language: n[1] });
27
42
  },
28
43
  // Custom pre rendering (remove wrapper for code blocks)
29
44
  pre({ children: r }) {
30
- return /* @__PURE__ */ e(c, { children: r });
45
+ return /* @__PURE__ */ e(p, { children: r });
31
46
  },
32
47
  // Custom link rendering (open in new tab)
33
48
  a({ href: r, children: o, ...t }) {
@@ -49,7 +64,7 @@ const f = ({
49
64
  )
50
65
  }
51
66
  );
52
- f.displayName = "ChatMarkdown";
67
+ u.displayName = "ChatMarkdown";
53
68
  export {
54
- f as ChatMarkdown
69
+ u as ChatMarkdown
55
70
  };
@@ -1,6 +1,6 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),i=require("react"),_=require("react-syntax-highlighter"),$=require("react-syntax-highlighter/dist/esm/styles/prism"),l=require("./CodeEditor.module.css.cjs"),z=require("../../contexts/ThemeContext.cjs");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 A=i.forwardRef(({value:r="",onChange:g,language:j,readOnly:T=!1,showLineNumbers:k=!0,placeholder:C,minRows:m=10,className:B,"aria-label":S,...R},D)=>{const p=i.useRef(null),x=i.useRef(null),v=i.useRef(null),E=i.useRef(null),K=i.useRef(null),u=i.useRef(null),h=D||K,[y,F]=i.useState(0),[d,O]=i.useState([]);let q="dark";try{q=z.useThemeContext().theme}catch{}const P=q==="light"?$.oneLight:$.oneDark,L=Math.max(r.split(`
2
- `).length,m);i.useEffect(()=>{if(u.current&&h.current){const{start:e,end:t}=u.current;h.current.setSelectionRange(e,t),u.current=null}}),i.useEffect(()=>{const e=v.current,t=E.current;if(!e||!t)return;const n=()=>{const o=t.clientWidth;if(o<=0)return;e.style.width=`${o}px`;const a=r.split(`
3
- `),f=Math.max(a.length,m),b=[];for(let N=0;N<f;N++){const V=a[N]??"";e.textContent=V||" ",b.push(e.scrollHeight)}O(b)};n();const c=new ResizeObserver(n);return c.observe(t),()=>c.disconnect()},[r,m]),i.useEffect(()=>{const e=n=>{const c=n.target;p.current&&(p.current.scrollTop=c.scrollTop),x.current&&(x.current.scrollTop=c.scrollTop,x.current.scrollLeft=c.scrollLeft)},t=h?.current;if(t)return t.addEventListener("scroll",e),()=>{t.removeEventListener("scroll",e)}},[h]);const w=e=>{const t=e.value.substring(0,e.selectionStart);F(t.split(`
4
- `).length-1)},H=e=>{if(e.key==="Tab"){e.preventDefault();const t=e.currentTarget,n=t.selectionStart,c=t.selectionEnd,o=" ";if(n===c){const a=r.substring(0,n)+o+r.substring(c);u.current={start:n+o.length,end:n+o.length},g?.(a)}else if(e.shiftKey){const a=r.lastIndexOf(`
5
- `,n-1)+1,f=r.substring(a).match(/^ {1,2}/)?.[0]??"";if(f.length>0){const b=r.substring(0,a)+r.substring(a+f.length);u.current={start:Math.max(a,n-f.length),end:Math.max(a,c-f.length)},g?.(b)}}else{const a=r.substring(0,n)+o+r.substring(c);u.current={start:n+o.length,end:n+o.length},g?.(a)}}},M=[l.default.wrapper,B].filter(Boolean).join(" ");return j?s.jsxs("div",{className:M,style:{minHeight:`calc(${m} * 1.6em + 2 * var(--spacing-4))`},children:[s.jsx("div",{ref:v,className:l.default.lineMirror,"aria-hidden":"true"}),k&&s.jsx("div",{ref:p,className:l.default.lineNumbers,"aria-hidden":"true",children:Array.from({length:L}).map((e,t)=>s.jsx("div",{className:l.default.lineNumber,style:d[t]!==void 0?{height:`${d[t]}px`}:void 0,children:t+1},t))}),s.jsxs("div",{ref:E,className:l.default.editorArea,children:[s.jsx("div",{className:l.default.lineHighlight,style:{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)`,...d[y]!==void 0?{height:`${d[y]}px`}:{}},"aria-hidden":"true"}),s.jsx("div",{ref:x,className:l.default.highlightLayer,"aria-hidden":"true",children:s.jsx(_.Prism,{language:j,style:P,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:h,className:l.default.textareaOverlay,value:r,onChange:e=>g?.(e.target.value),onKeyDown:H,onKeyUp:e=>w(e.currentTarget),onMouseUp:e=>w(e.currentTarget),onClick:e=>w(e.currentTarget),placeholder:C,readOnly:T,"aria-label":S||"Code editor",spellCheck:"false",...R})]})]}):s.jsxs("div",{className:M,style:{minHeight:`calc(${m} * 1.6em + 2 * var(--spacing-4))`},children:[s.jsx("div",{ref:v,className:l.default.lineMirror,"aria-hidden":"true"}),k&&s.jsx("div",{ref:p,className:l.default.lineNumbers,"aria-hidden":"true",children:Array.from({length:L}).map((e,t)=>s.jsx("div",{className:l.default.lineNumber,style:d[t]!==void 0?{height:`${d[t]}px`}:void 0,children:t+1},t))}),s.jsx("textarea",{ref:h,className:l.default.textarea,value:r,onChange:e=>g?.(e.target.value),onKeyDown:H,placeholder:C,readOnly:T,"aria-label":S||"Code editor",spellCheck:"false",...R})]})});A.displayName="CodeEditor";exports.CodeEditor=A;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),i=require("react"),W=require("../MissingDependencyError.cjs"),l=require("./CodeEditor.module.css.cjs"),I=require("../../contexts/ThemeContext.cjs");let D,$,A,B=null;try{D=require("react-syntax-highlighter").Prism;const d=require("react-syntax-highlighter/dist/esm/styles/prism");$=d.oneDark,A=d.oneLight}catch(r){B=r instanceof Error?r:new Error("react-syntax-highlighter not found")}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 K=i.forwardRef(({value:r="",onChange:d,language:j,readOnly:C=!1,showLineNumbers:k=!0,placeholder:E,minRows:m=10,className:F,"aria-label":S,...T},O)=>{if(B)return n.jsx(W.MissingDependencyError,{available:!1,componentName:"CodeEditor",depName:"react-syntax-highlighter",installCommand:"npm install react-syntax-highlighter",pnpmCommand:"pnpm add react-syntax-highlighter",docsUrl:"https://docs.orion-ds.dev/components/code-editor"});const p=i.useRef(null),x=i.useRef(null),v=i.useRef(null),R=i.useRef(null),P=i.useRef(null),h=i.useRef(null),g=O||P,[y,U]=i.useState(0),[u,V]=i.useState([]);let q="dark";try{q=I.useThemeContext().theme}catch{}const _=q==="light"?A:$,L=Math.max(r.split(`
2
+ `).length,m);i.useEffect(()=>{if(h.current&&g.current){const{start:e,end:t}=h.current;g.current.setSelectionRange(e,t),h.current=null}}),i.useEffect(()=>{const e=v.current,t=R.current;if(!e||!t)return;const s=()=>{const c=t.clientWidth;if(c<=0)return;e.style.width=`${c}px`;const a=r.split(`
3
+ `),f=Math.max(a.length,m),b=[];for(let w=0;w<f;w++){const z=a[w]??"";e.textContent=z||" ",b.push(e.scrollHeight)}V(b)};s();const o=new ResizeObserver(s);return o.observe(t),()=>o.disconnect()},[r,m]),i.useEffect(()=>{const e=s=>{const o=s.target;p.current&&(p.current.scrollTop=o.scrollTop),x.current&&(x.current.scrollTop=o.scrollTop,x.current.scrollLeft=o.scrollLeft)},t=g?.current;if(t)return t.addEventListener("scroll",e),()=>{t.removeEventListener("scroll",e)}},[g]);const N=e=>{const t=e.value.substring(0,e.selectionStart);U(t.split(`
4
+ `).length-1)},M=e=>{if(e.key==="Tab"){e.preventDefault();const t=e.currentTarget,s=t.selectionStart,o=t.selectionEnd,c=" ";if(s===o){const a=r.substring(0,s)+c+r.substring(o);h.current={start:s+c.length,end:s+c.length},d?.(a)}else if(e.shiftKey){const a=r.lastIndexOf(`
5
+ `,s-1)+1,f=r.substring(a).match(/^ {1,2}/)?.[0]??"";if(f.length>0){const b=r.substring(0,a)+r.substring(a+f.length);h.current={start:Math.max(a,s-f.length),end:Math.max(a,o-f.length)},d?.(b)}}else{const a=r.substring(0,s)+c+r.substring(o);h.current={start:s+c.length,end:s+c.length},d?.(a)}}},H=[l.default.wrapper,F].filter(Boolean).join(" ");return j?n.jsxs("div",{className:H,style:{minHeight:`calc(${m} * 1.6em + 2 * var(--spacing-4))`},children:[n.jsx("div",{ref:v,className:l.default.lineMirror,"aria-hidden":"true"}),k&&n.jsx("div",{ref:p,className:l.default.lineNumbers,"aria-hidden":"true",children:Array.from({length:L}).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:R,className:l.default.editorArea,children:[n.jsx("div",{className:l.default.lineHighlight,style:{top:u.length>0?`calc(var(--spacing-4) + ${u.slice(0,y).reduce((e,t)=>e+t,0)}px)`:`calc(var(--spacing-4) + ${(y*1.6).toFixed(2)}em)`,...u[y]!==void 0?{height:`${u[y]}px`}:{}},"aria-hidden":"true"}),n.jsx("div",{ref:x,className:l.default.highlightLayer,"aria-hidden":"true",children:n.jsx(D,{language:j,style:_,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:g,className:l.default.textareaOverlay,value:r,onChange:e=>d?.(e.target.value),onKeyDown:M,onKeyUp:e=>N(e.currentTarget),onMouseUp:e=>N(e.currentTarget),onClick:e=>N(e.currentTarget),placeholder:E,readOnly:C,"aria-label":S||"Code editor",spellCheck:"false",...T})]})]}):n.jsxs("div",{className:H,style:{minHeight:`calc(${m} * 1.6em + 2 * var(--spacing-4))`},children:[n.jsx("div",{ref:v,className:l.default.lineMirror,"aria-hidden":"true"}),k&&n.jsx("div",{ref:p,className:l.default.lineNumbers,"aria-hidden":"true",children:Array.from({length:L}).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:g,className:l.default.textarea,value:r,onChange:e=>d?.(e.target.value),onKeyDown:M,placeholder:E,readOnly:C,"aria-label":S||"Code editor",spellCheck:"false",...T})]})});K.displayName="CodeEditor";exports.CodeEditor=K;
@@ -1 +1 @@
1
- {"version":3,"file":"CodeEditor.d.ts","sourceRoot":"","sources":["../../../src/components/CodeEditor/CodeEditor.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAkD,MAAM,OAAO,CAAC;AAMvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AA2B1D;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,UAAU,6FAgUtB,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;AA4C1D;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,UAAU,6FA8UtB,CAAC"}