@cognite/aura 0.3.2 → 0.3.4

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 (143) hide show
  1. package/DESIGN.md +134 -5
  2. package/README.md +24 -3
  3. package/dist/components/index.d.ts +5 -1
  4. package/dist/components/index.js +59 -327
  5. package/dist/components/ui/core/accordion/accordion.js +79 -114
  6. package/dist/components/ui/core/action-toolbar/action-toolbar.js +108 -176
  7. package/dist/components/ui/core/alert/alert.js +158 -206
  8. package/dist/components/ui/core/avatar/avatar.js +64 -90
  9. package/dist/components/ui/core/badge/badge.js +73 -108
  10. package/dist/components/ui/core/banner/banner.js +146 -215
  11. package/dist/components/ui/core/breadcrumb/breadcrumb.js +105 -200
  12. package/dist/components/ui/core/button/button.js +47 -52
  13. package/dist/components/ui/core/button-group/button-group.js +40 -79
  14. package/dist/components/ui/core/calendar/calendar-header.js +63 -0
  15. package/dist/components/ui/core/calendar/calendar-utils.js +39 -0
  16. package/dist/components/ui/core/calendar/calendar.js +68 -0
  17. package/dist/components/ui/core/calendar/constants.d.ts +1 -0
  18. package/dist/components/ui/core/card/card.js +102 -185
  19. package/dist/components/ui/core/chart/chart.js +116 -206
  20. package/dist/components/ui/core/chart/index.js +2 -8
  21. package/dist/components/ui/core/checkbox/checkbox.js +67 -132
  22. package/dist/components/ui/core/checkbox/checkbox.metadata.js +7 -7
  23. package/dist/components/ui/core/code-block/code-block.d.ts +1 -1
  24. package/dist/components/ui/core/code-block/code-block.js +179 -267
  25. package/dist/components/ui/core/collapsible/collapsible.js +29 -49
  26. package/dist/components/ui/core/combobox/combobox.js +41 -0
  27. package/dist/components/ui/core/command/command.js +85 -150
  28. package/dist/components/ui/core/count/count.js +21 -32
  29. package/dist/components/ui/core/data-grid/data-grid-cell.d.ts +10 -0
  30. package/dist/components/ui/core/data-grid/data-grid-header-row.d.ts +13 -0
  31. package/dist/components/ui/core/data-grid/data-grid-row.d.ts +18 -0
  32. package/dist/components/ui/core/data-grid/data-grid.d.ts +43 -0
  33. package/dist/components/ui/core/data-grid/data-grid.fixtures.d.ts +12 -0
  34. package/dist/components/ui/core/data-grid/data-grid.utils.d.ts +9 -0
  35. package/dist/components/ui/core/date-time-pickers/date-picker/date-picker.js +60 -72
  36. package/dist/components/ui/core/date-time-pickers/date-picker/types.d.ts +2 -1
  37. package/dist/components/ui/core/date-time-pickers/date-picker/use-date-picker.js +36 -51
  38. package/dist/components/ui/core/date-time-pickers/date-range-picker/date-range-picker.js +63 -87
  39. package/dist/components/ui/core/date-time-pickers/date-range-picker/types.d.ts +2 -1
  40. package/dist/components/ui/core/date-time-pickers/date-range-picker/use-date-range-picker.js +60 -68
  41. package/dist/components/ui/core/date-time-pickers/date-time-picker/index.d.ts +1 -0
  42. package/dist/components/ui/core/date-time-pickers/date-time-picker/types.d.ts +36 -0
  43. package/dist/components/ui/core/date-time-pickers/date-time-picker/use-date-time-picker.d.ts +3 -0
  44. package/dist/components/ui/core/date-time-pickers/date-time-range-picker/date-time-range-picker.js +118 -174
  45. package/dist/components/ui/core/date-time-pickers/date-time-range-picker/types.d.ts +7 -6
  46. package/dist/components/ui/core/date-time-pickers/date-time-range-picker/use-date-time-range-picker.js +104 -145
  47. package/dist/components/ui/core/date-time-pickers/index.d.ts +3 -1
  48. package/dist/components/ui/core/date-time-pickers/index.js +6 -10
  49. package/dist/components/ui/core/date-time-pickers/shared/am-pm-scroll/am-pm-scroll.d.ts +3 -2
  50. package/dist/components/ui/core/date-time-pickers/shared/am-pm-scroll/am-pm-scroll.js +42 -56
  51. package/dist/components/ui/core/date-time-pickers/shared/constants.d.ts +3 -8
  52. package/dist/components/ui/core/date-time-pickers/shared/date-time-input/date-time-input.js +64 -98
  53. package/dist/components/ui/core/date-time-pickers/shared/date-time-input/range-input-display.js +38 -67
  54. package/dist/components/ui/core/date-time-pickers/shared/hooks/use-popover-state.js +23 -23
  55. package/dist/components/ui/core/date-time-pickers/shared/hooks/use-range-date-state.js +52 -62
  56. package/dist/components/ui/core/date-time-pickers/shared/hooks/use-range-step-manager.js +18 -18
  57. package/dist/components/ui/core/date-time-pickers/shared/hooks/use-single-date-state.js +24 -31
  58. package/dist/components/ui/core/date-time-pickers/shared/hooks/use-time-state.d.ts +3 -3
  59. package/dist/components/ui/core/date-time-pickers/shared/hooks/use-time-state.js +24 -33
  60. package/dist/components/ui/core/date-time-pickers/shared/scroll-cell-classes.js +4 -7
  61. package/dist/components/ui/core/date-time-pickers/shared/shortcuts-panel/shortcuts-panel.d.ts +3 -2
  62. package/dist/components/ui/core/date-time-pickers/shared/shortcuts-panel/shortcuts-panel.js +17 -31
  63. package/dist/components/ui/core/date-time-pickers/shared/time-picker-panel/time-picker-panel.d.ts +3 -2
  64. package/dist/components/ui/core/date-time-pickers/shared/time-picker-panel/time-picker-panel.js +40 -40
  65. package/dist/components/ui/core/date-time-pickers/shared/time-picker-scroll/time-picker-scroll.js +33 -50
  66. package/dist/components/ui/core/date-time-pickers/time-picker/time-picker.js +78 -99
  67. package/dist/components/ui/core/date-time-pickers/time-picker/types.d.ts +5 -4
  68. package/dist/components/ui/core/date-time-pickers/time-picker/use-time-picker.js +41 -63
  69. package/dist/components/ui/core/date-time-pickers/time-range-picker/index.d.ts +1 -0
  70. package/dist/components/ui/core/date-time-pickers/time-range-picker/types.d.ts +40 -0
  71. package/dist/components/ui/core/date-time-pickers/time-range-picker/use-time-range-picker.d.ts +3 -0
  72. package/dist/components/ui/core/date-time-pickers/utils/format-utils.d.ts +1 -0
  73. package/dist/components/ui/core/date-time-pickers/utils/time-utils.d.ts +3 -3
  74. package/dist/components/ui/core/date-time-pickers/utils/time-utils.js +7 -15
  75. package/dist/components/ui/core/dialog/dialog.js +82 -155
  76. package/dist/components/ui/core/dropdown-menu/dropdown-menu.d.ts +2 -2
  77. package/dist/components/ui/core/dropdown-menu/dropdown-menu.js +150 -248
  78. package/dist/components/ui/core/empty-state/empty-state.context.js +5 -8
  79. package/dist/components/ui/core/empty-state/empty-state.js +86 -138
  80. package/dist/components/ui/core/helper-text/helper-text.js +37 -65
  81. package/dist/components/ui/core/hover-card/hover-card.js +54 -80
  82. package/dist/components/ui/core/inline-citation/inline-citation.js +98 -181
  83. package/dist/components/ui/core/input/input.js +12 -27
  84. package/dist/components/ui/core/input-group/input-group.js +76 -173
  85. package/dist/components/ui/core/kbd/kbd.js +20 -36
  86. package/dist/components/ui/core/label/label.js +26 -43
  87. package/dist/components/ui/core/loader/loader.js +80 -117
  88. package/dist/components/ui/core/message/message-response-default-streamdown-controls.js +12 -12
  89. package/dist/components/ui/core/message/message.d.ts +2 -2
  90. package/dist/components/ui/core/message/message.js +316 -542
  91. package/dist/components/ui/core/overflow-list/overflow-list.utils.d.ts +52 -0
  92. package/dist/components/ui/core/pagination/pagination-size-context.js +5 -6
  93. package/dist/components/ui/core/pagination/pagination-teleport.js +86 -106
  94. package/dist/components/ui/core/pagination/pagination-teleport.utils.js +6 -6
  95. package/dist/components/ui/core/pagination/pagination.js +231 -334
  96. package/dist/components/ui/core/popover/popover.js +90 -157
  97. package/dist/components/ui/core/progress/progress.js +36 -61
  98. package/dist/components/ui/core/prompt-input/prompt-input.js +274 -413
  99. package/dist/components/ui/core/radio-group/radio-group.js +58 -113
  100. package/dist/components/ui/core/reasoning/reasoning.js +55 -86
  101. package/dist/components/ui/core/scroll-area/scroll-area.js +41 -71
  102. package/dist/components/ui/core/search/search.js +77 -99
  103. package/dist/components/ui/core/segmented-control/segmented-control.js +110 -167
  104. package/dist/components/ui/core/select/select.js +168 -293
  105. package/dist/components/ui/core/separator/separator.js +13 -23
  106. package/dist/components/ui/core/shimmer/shimmer.d.ts +2 -4
  107. package/dist/components/ui/core/shimmer/shimmer.js +40 -107
  108. package/dist/components/ui/core/skeleton/skeleton.js +13 -18
  109. package/dist/components/ui/core/slider/slider.d.ts +9 -0
  110. package/dist/components/ui/core/slider/slider.js +40 -0
  111. package/dist/components/ui/core/sonner-toast/sonner-toast.js +54 -47
  112. package/dist/components/ui/core/sources/sources.d.ts +5 -1
  113. package/dist/components/ui/core/sources/sources.js +58 -79
  114. package/dist/components/ui/core/switch/switch.js +62 -0
  115. package/dist/components/ui/core/tabs/tabs.js +149 -223
  116. package/dist/components/ui/core/tabs/tabs.utils.js +6 -8
  117. package/dist/components/ui/core/textarea/textarea.js +13 -27
  118. package/dist/components/ui/core/toggle/toggle.js +55 -74
  119. package/dist/components/ui/core/tool/tool.js +127 -163
  120. package/dist/components/ui/core/tooltip/tooltip.js +47 -86
  121. package/dist/components/ui/core/topbar/topbar.js +106 -190
  122. package/dist/eslint/index.js +5 -10
  123. package/dist/eslint/no-overriding-styles.js +178 -237
  124. package/dist/icons/index.d.ts +1 -0
  125. package/dist/icons/index.js +1 -0
  126. package/dist/index.d.ts +1 -1
  127. package/dist/lib/highlight-code.d.ts +9 -0
  128. package/dist/lib/highlight-code.js +42 -0
  129. package/dist/lib/portal-container-context.js +8 -9
  130. package/dist/lib/style-scope.js +6 -6
  131. package/dist/lib/use-controllable-state.js +21 -30
  132. package/dist/lib/utils.d.ts +0 -2
  133. package/dist/lib/utils.js +32 -112
  134. package/dist/styles.css +1 -1
  135. package/dist/styles.source.css +26 -0
  136. package/package.json +42 -8
  137. package/dist/components/ui/core/date-time-pickers/shared/calendar/calendar.js +0 -119
  138. package/dist/components/ui/core/date-time-pickers/shared/calendar-header/calendar-header.js +0 -93
  139. package/dist/components/ui/core/date-time-pickers/shared/constants.js +0 -14
  140. package/dist/components/ui/core/date-time-pickers/utils/calendar-utils.js +0 -52
  141. /package/dist/components/ui/core/{date-time-pickers/shared/calendar-header → calendar}/calendar-header.d.ts +0 -0
  142. /package/dist/components/ui/core/{date-time-pickers/utils → calendar}/calendar-utils.d.ts +0 -0
  143. /package/dist/components/ui/core/{date-time-pickers/shared/calendar → calendar}/calendar.d.ts +0 -0
@@ -1,271 +1,183 @@
1
- import { jsxs as L, jsx as r } from "react/jsx-runtime";
2
- import { createContext as F, forwardRef as w, useState as x, useMemo as D, useEffect as O, useContext as H } from "react";
3
- import { IconCheck as K, IconCopy as V, IconSelector as $, IconDownload as q } from "@tabler/icons-react";
4
- import { isStorybookTestEnv as v, highlightCode as M, cn as f } from "../../../../lib/utils.js";
5
- import { Button as S } from "../button/button.js";
6
- const I = F({
7
- code: "",
8
- copyText: "",
9
- isCollapsed: !1,
10
- setIsCollapsed: () => {
11
- },
12
- lineCount: 0
13
- }), P = (e) => e.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;").replaceAll("'", "&#39;"), E = 14, N = 8e3, W = 400, G = 16384;
14
- function J(e) {
15
- const t = e.split(`
16
- `);
17
- let n = !1, o = t.slice(0, E).join(`
18
- `);
19
- t.length > E && (n = !0), o.length > N && (o = o.slice(0, N), n = !0);
20
- const a = o.length === 0 ? " " : o;
21
- return n ? `${a}
22
- …` : a;
1
+ import { cn as e, isStorybookTestEnv as t } from "../../../../lib/utils.js";
2
+ import { Button as n } from "../button/button.js";
3
+ import { highlightCode as r } from "../../../../lib/highlight-code.js";
4
+ import { createContext as i, forwardRef as a, useContext as o, useEffect as s, useMemo as c, useState as l } from "react";
5
+ import { IconCheck as u, IconCopy as d, IconDownload as f, IconSelector as p } from "@tabler/icons-react";
6
+ import { jsx as m, jsxs as h } from "react/jsx-runtime";
7
+ //#region libs/aura/src/components/ui/core/code-block/code-block.tsx
8
+ var g = i({
9
+ code: "",
10
+ copyText: "",
11
+ isCollapsed: !1,
12
+ setIsCollapsed: () => void 0,
13
+ lineCount: 0
14
+ }), _ = (e) => e.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll("\"", "&quot;").replaceAll("'", "&#39;"), v = 14, y = 8e3, b = 400, x = 16384, S = 1;
15
+ function C(e) {
16
+ let t = e.split("\n"), n = !1, r = t.slice(0, v).join("\n");
17
+ t.length > v && (n = !0), r.length > y && (r = r.slice(0, y), n = !0);
18
+ let i = r.length === 0 ? " " : r;
19
+ return n ? `${i}\n…` : i;
23
20
  }
24
- function Q(e) {
25
- return e.split(`
26
- `).length > E || e.length > N;
21
+ function w(e) {
22
+ return e.split("\n").length > v || e.length > y;
27
23
  }
28
- function Y(e, t) {
29
- return t > W || e.length > G;
24
+ function T(e, t) {
25
+ return t > b || e.length > x;
30
26
  }
31
- function Z(e) {
32
- return `<pre><code>${P(e)}</code></pre>`;
27
+ function E(e) {
28
+ return `<pre><code>${_(e)}</code></pre>`;
33
29
  }
34
- const ee = "min(60vh, 32rem)", oe = "dark:hidden [&>pre]:m-0 [&>pre]:min-h-10 [&>pre]:bg-card-background [&>pre]:p-2 [&>pre]:text-secondary-foreground [&>pre]:leading-[18px] [&>pre]:tracking-[-0.08px] [&>pre]:text-sm [&_code]:font-mono [&_code]:text-sm [&>pre]:overflow-x-auto", te = "hidden dark:block [&>pre]:m-0 [&>pre]:min-h-10 [&>pre]:bg-card-background [&>pre]:p-2 [&>pre]:text-secondary-foreground [&>pre]:leading-[18px] [&>pre]:tracking-[-0.08px] [&>pre]:text-sm [&_code]:font-mono [&_code]:text-sm [&>pre]:overflow-x-auto", ne = w(
35
- ({
36
- code: e,
37
- copyText: t,
38
- language: n,
39
- showLineNumbers: o = !1,
40
- collapsed: a = !1,
41
- className: h,
42
- children: i,
43
- style: C,
44
- ...k
45
- }, b) => {
46
- const [d, p] = x(""), [c, _] = x(""), [l, R] = x(a), s = e.length === 0 ? " " : e, y = e.split(`
47
- `).length, A = t ?? e, T = D(
48
- () => v ? `<pre><code>${P(s)}</code></pre>` : "",
49
- [s]
50
- );
51
- O(() => {
52
- if (v) return;
53
- let g = !1;
54
- const B = (u) => {
55
- if (!g) {
56
- const m = Z(u);
57
- p(m), _(m);
58
- }
59
- };
60
- if (l && Q(s)) {
61
- const u = J(s);
62
- return M(u, n, o).then(([m, j]) => {
63
- g || (p(m), _(j));
64
- }).catch((m) => {
65
- console.error("Failed to highlight code:", m), B(u);
66
- }), () => {
67
- g = !0;
68
- };
69
- }
70
- return !l && Y(s, y) ? (queueMicrotask(() => {
71
- B(s);
72
- }), () => {
73
- g = !0;
74
- }) : (M(s, n, o).then(([u, m]) => {
75
- g || (p(u), _(m));
76
- }).catch((u) => {
77
- console.error("Failed to highlight code:", u), B(s);
78
- }), () => {
79
- g = !0;
80
- });
81
- }, [s, n, o, l, y]);
82
- const z = D(
83
- () => ({
84
- code: e,
85
- copyText: A,
86
- isCollapsed: l,
87
- setIsCollapsed: R,
88
- lineCount: y
89
- }),
90
- [e, A, l, y]
91
- ), U = /* @__PURE__ */ L("div", { className: "relative", children: [
92
- /* @__PURE__ */ r(
93
- "div",
94
- {
95
- className: f(
96
- oe,
97
- l && "max-h-26 overflow-y-hidden"
98
- ),
99
- dangerouslySetInnerHTML: {
100
- __html: v ? T : d
101
- }
102
- }
103
- ),
104
- /* @__PURE__ */ r(
105
- "div",
106
- {
107
- className: f(
108
- te,
109
- l && "max-h-26 overflow-y-hidden"
110
- ),
111
- dangerouslySetInnerHTML: {
112
- __html: v ? T : c
113
- }
114
- }
115
- ),
116
- l && /* @__PURE__ */ r("div", { className: "pointer-events-none absolute bottom-0 left-0 right-0 h-3/4 bg-linear-to-b from-transparent via-card-background/70 to-card-background" })
117
- ] }), X = i != null ? /* @__PURE__ */ r(
118
- "div",
119
- {
120
- "data-slot": "code-block-actions",
121
- className: f(
122
- /* Sibling of scroll inner: pinned while code scrolls; even inset from top/right (scrollbar gutter on inner) */
123
- "pointer-events-none absolute top-5 right-5 z-20 flex items-center gap-1 bg-transparent p-0 shadow-none ring-0 outline-none",
124
- "opacity-0 transition-opacity",
125
- "group-hover/code-block:pointer-events-auto group-hover/code-block:opacity-100",
126
- "group-focus-within/code-block:pointer-events-auto group-focus-within/code-block:opacity-100",
127
- v && "pointer-events-auto opacity-100"
128
- ),
129
- children: i
130
- }
131
- ) : null;
132
- return /* @__PURE__ */ r(I.Provider, { value: z, children: /* @__PURE__ */ L(
133
- "div",
134
- {
135
- ref: b,
136
- "data-slot": "code-block",
137
- className: f(
138
- "group/code-block relative w-full rounded-xl bg-background text-foreground",
139
- l ? "overflow-hidden" : (
140
- /* Expanded: flex + clip so actions overlay without a reserved top row */
141
- "flex min-h-0 max-h-[min(60vh,_32rem)] flex-col overflow-hidden"
142
- ),
143
- h
144
- ),
145
- style: {
146
- ...l ? {} : {
147
- maxHeight: ee,
148
- minHeight: 0
149
- },
150
- ...C
151
- },
152
- ...k,
153
- children: [
154
- /* @__PURE__ */ r(
155
- "div",
156
- {
157
- className: f(
158
- /* Match <pre> card tone so transparent actions are not over root bg-background */
159
- "relative min-h-0 bg-card-background",
160
- !l && "min-h-0 flex-1 overflow-x-auto overflow-y-auto [scrollbar-gutter:stable]"
161
- ),
162
- children: U
163
- }
164
- ),
165
- X
166
- ]
167
- }
168
- ) });
169
- }
170
- );
171
- ne.displayName = "CodeBlock";
172
- const re = w(
173
- ({ onCopy: e, onError: t, timeout: n = 2e3, children: o, className: a, ...h }, i) => {
174
- const [C, k] = x(!1), { copyText: b } = H(I), d = async () => {
175
- if (typeof window > "u" || !navigator?.clipboard?.writeText) {
176
- t?.(new Error("Clipboard API not available"));
177
- return;
178
- }
179
- try {
180
- await navigator.clipboard.writeText(b), k(!0), e?.(), setTimeout(() => k(!1), n);
181
- } catch (c) {
182
- console.warn("Clipboard write failed:", c), t?.(
183
- c instanceof Error ? c : new Error("Clipboard write failed")
184
- );
185
- }
186
- }, p = C ? K : V;
187
- return /* @__PURE__ */ r(
188
- S,
189
- {
190
- ref: i,
191
- "data-slot": "code-block-copy-button",
192
- className: f("shrink-0", a),
193
- onClick: d,
194
- size: "icon-sm",
195
- variant: "secondary",
196
- ...h,
197
- children: o ?? /* @__PURE__ */ r(p, { size: 14 })
198
- }
199
- );
200
- }
201
- );
202
- re.displayName = "CodeBlockCopyButton";
203
- const le = w(
204
- ({ children: e, className: t, ...n }, o) => {
205
- const { isCollapsed: a, setIsCollapsed: h, lineCount: i } = H(I);
206
- return i <= 1 ? null : /* @__PURE__ */ r(
207
- S,
208
- {
209
- ref: o,
210
- "data-slot": "code-block-collapse-button",
211
- className: f("shrink-0", t),
212
- onClick: () => h(!a),
213
- size: "icon-sm",
214
- variant: "secondary",
215
- ...n,
216
- children: e ?? /* @__PURE__ */ r($, { size: 14 })
217
- }
218
- );
219
- }
220
- );
221
- le.displayName = "CodeBlockCollapseButton";
222
- const ae = w(
223
- ({
224
- fileName: e = "code.txt",
225
- mimeType: t = "text/plain;charset=utf-8",
226
- onDownload: n,
227
- onError: o,
228
- children: a,
229
- className: h,
230
- ...i
231
- }, C) => {
232
- const { code: k } = H(I), b = () => {
233
- if (typeof window > "u" || typeof document > "u") {
234
- o?.(new Error("Download not available"));
235
- return;
236
- }
237
- try {
238
- const d = new Blob([k], { type: t }), p = URL.createObjectURL(d), c = document.createElement("a");
239
- c.href = p, c.download = e, c.rel = "noopener", c.click(), URL.revokeObjectURL(p), n?.();
240
- } catch (d) {
241
- o?.(
242
- d instanceof Error ? d : new Error("Download failed")
243
- );
244
- }
245
- };
246
- return /* @__PURE__ */ r(
247
- S,
248
- {
249
- ref: C,
250
- "data-slot": "code-block-download-button",
251
- className: f("shrink-0", h),
252
- onClick: b,
253
- size: "icon-sm",
254
- variant: "secondary",
255
- ...i,
256
- children: a ?? /* @__PURE__ */ r(q, { size: 14 })
257
- }
258
- );
259
- }
260
- );
261
- ae.displayName = "CodeBlockDownloadButton";
262
- export {
263
- ne as CodeBlock,
264
- le as CodeBlockCollapseButton,
265
- re as CodeBlockCopyButton,
266
- ae as CodeBlockDownloadButton,
267
- J as getCollapsedPreviewDisplay,
268
- Q as isContentLargerThanPreview,
269
- Z as plainPreMarkup,
270
- Y as shouldUsePlainTextInsteadOfShiki
271
- };
30
+ var D = "min(60vh, 32rem)", O = "dark:hidden [&>pre]:m-0 [&>pre]:min-h-10 [&>pre]:bg-card-background [&>pre]:p-2 [&>pre]:text-secondary-foreground [&>pre]:leading-[18px] [&>pre]:tracking-[-0.08px] [&>pre]:text-sm [&_code]:font-mono [&_code]:text-sm [&>pre]:overflow-x-auto", k = "hidden dark:block [&>pre]:m-0 [&>pre]:min-h-10 [&>pre]:bg-card-background [&>pre]:p-2 [&>pre]:text-secondary-foreground [&>pre]:leading-[18px] [&>pre]:tracking-[-0.08px] [&>pre]:text-sm [&_code]:font-mono [&_code]:text-sm [&>pre]:overflow-x-auto", A = a(({ code: n, copyText: i, language: a, showLineNumbers: o = !1, collapsed: u = !1, className: d, children: f, style: p, ...v }, y) => {
31
+ let [b, x] = l(""), [A, j] = l(""), [M, N] = l(u), P = n.length === 0 ? " " : n, F = n.split("\n").length, I = M && F > S, L = i ?? n, R = c(() => t ? `<pre><code>${_(P)}</code></pre>` : "", [P]);
32
+ s(() => {
33
+ if (t) return;
34
+ let e = !1, n = (t) => {
35
+ if (!e) {
36
+ let e = E(t);
37
+ x(e), j(e);
38
+ }
39
+ };
40
+ if (M && w(P)) {
41
+ let t = C(P);
42
+ return r(t, a, o).then(([t, n]) => {
43
+ e || (x(t), j(n));
44
+ }).catch((e) => {
45
+ console.error("Failed to highlight code:", e), n(t);
46
+ }), () => {
47
+ e = !0;
48
+ };
49
+ }
50
+ return !M && T(P, F) ? (queueMicrotask(() => {
51
+ n(P);
52
+ }), () => {
53
+ e = !0;
54
+ }) : (r(P, a, o).then(([t, n]) => {
55
+ e || (x(t), j(n));
56
+ }).catch((e) => {
57
+ console.error("Failed to highlight code:", e), n(P);
58
+ }), () => {
59
+ e = !0;
60
+ });
61
+ }, [
62
+ P,
63
+ a,
64
+ o,
65
+ M,
66
+ F
67
+ ]);
68
+ let z = c(() => ({
69
+ code: n,
70
+ copyText: L,
71
+ isCollapsed: M,
72
+ setIsCollapsed: N,
73
+ lineCount: F
74
+ }), [
75
+ n,
76
+ L,
77
+ M,
78
+ F
79
+ ]), B = /* @__PURE__ */ h("div", {
80
+ className: "relative",
81
+ children: [
82
+ /* @__PURE__ */ m("div", {
83
+ className: e(O, I && "max-h-26 overflow-y-hidden"),
84
+ dangerouslySetInnerHTML: { __html: t ? R : b }
85
+ }),
86
+ /* @__PURE__ */ m("div", {
87
+ className: e(k, I && "max-h-26 overflow-y-hidden"),
88
+ dangerouslySetInnerHTML: { __html: t ? R : A }
89
+ }),
90
+ I && /* @__PURE__ */ m("div", { className: "pointer-events-none absolute bottom-0 left-0 right-0 h-3/4 bg-linear-to-b from-transparent via-card-background/70 to-card-background" })
91
+ ]
92
+ }), V = f == null ? null : /* @__PURE__ */ m("div", {
93
+ "data-slot": "code-block-actions",
94
+ className: e("pointer-events-none absolute top-5 right-5 z-20 flex items-center gap-1 bg-transparent p-0 shadow-none ring-0 outline-none", "opacity-0 transition-opacity", "group-hover/code-block:pointer-events-auto group-hover/code-block:opacity-100", "group-focus-within/code-block:pointer-events-auto group-focus-within/code-block:opacity-100", t && "pointer-events-auto opacity-100"),
95
+ children: f
96
+ });
97
+ return /* @__PURE__ */ m(g.Provider, {
98
+ value: z,
99
+ children: /* @__PURE__ */ h("div", {
100
+ ref: y,
101
+ "data-slot": "code-block",
102
+ className: e("group/code-block relative w-full rounded-xl bg-background text-foreground", I ? "overflow-hidden" : "flex min-h-0 max-h-[min(60vh,_32rem)] flex-col overflow-hidden", d),
103
+ style: {
104
+ ...I ? {} : {
105
+ maxHeight: D,
106
+ minHeight: 0
107
+ },
108
+ ...p
109
+ },
110
+ ...v,
111
+ children: [/* @__PURE__ */ m("div", {
112
+ className: e("relative min-h-0 bg-card-background", !I && "min-h-0 flex-1 overflow-x-auto overflow-y-auto [scrollbar-gutter:stable]"),
113
+ children: B
114
+ }), V]
115
+ })
116
+ });
117
+ });
118
+ A.displayName = "CodeBlock";
119
+ var j = a(({ onCopy: t, onError: r, timeout: i = 2e3, children: a, className: s, ...c }, f) => {
120
+ let [p, h] = l(!1), { copyText: _ } = o(g), v = async () => {
121
+ if (typeof window > "u" || !navigator?.clipboard?.writeText) {
122
+ r?.(/* @__PURE__ */ Error("Clipboard API not available"));
123
+ return;
124
+ }
125
+ try {
126
+ await navigator.clipboard.writeText(_), h(!0), t?.(), setTimeout(() => h(!1), i);
127
+ } catch (e) {
128
+ console.warn("Clipboard write failed:", e), r?.(e instanceof Error ? e : /* @__PURE__ */ Error("Clipboard write failed"));
129
+ }
130
+ }, y = p ? u : d;
131
+ return /* @__PURE__ */ m(n, {
132
+ ref: f,
133
+ "data-slot": "code-block-copy-button",
134
+ className: e("shrink-0", s),
135
+ onClick: v,
136
+ size: "icon-sm",
137
+ variant: "secondary",
138
+ ...c,
139
+ children: a ?? /* @__PURE__ */ m(y, { size: 14 })
140
+ });
141
+ });
142
+ j.displayName = "CodeBlockCopyButton";
143
+ var M = a(({ children: t, className: r, ...i }, a) => {
144
+ let { isCollapsed: s, setIsCollapsed: c, lineCount: l } = o(g);
145
+ return l <= S ? null : /* @__PURE__ */ m(n, {
146
+ ref: a,
147
+ "data-slot": "code-block-collapse-button",
148
+ className: e("shrink-0", r),
149
+ onClick: () => c(!s),
150
+ size: "icon-sm",
151
+ variant: "secondary",
152
+ ...i,
153
+ children: t ?? /* @__PURE__ */ m(p, { size: 14 })
154
+ });
155
+ });
156
+ M.displayName = "CodeBlockCollapseButton";
157
+ var N = a(({ fileName: t = "code.txt", mimeType: r = "text/plain;charset=utf-8", onDownload: i, onError: a, children: s, className: c, ...l }, u) => {
158
+ let { code: d } = o(g);
159
+ return /* @__PURE__ */ m(n, {
160
+ ref: u,
161
+ "data-slot": "code-block-download-button",
162
+ className: e("shrink-0", c),
163
+ onClick: () => {
164
+ if (typeof window > "u" || typeof document > "u") {
165
+ a?.(/* @__PURE__ */ Error("Download not available"));
166
+ return;
167
+ }
168
+ try {
169
+ let e = new Blob([d], { type: r }), n = URL.createObjectURL(e), a = document.createElement("a");
170
+ a.href = n, a.download = t, a.rel = "noopener", a.click(), URL.revokeObjectURL(n), i?.();
171
+ } catch (e) {
172
+ a?.(e instanceof Error ? e : /* @__PURE__ */ Error("Download failed"));
173
+ }
174
+ },
175
+ size: "icon-sm",
176
+ variant: "secondary",
177
+ ...l,
178
+ children: s ?? /* @__PURE__ */ m(f, { size: 14 })
179
+ });
180
+ });
181
+ N.displayName = "CodeBlockDownloadButton";
182
+ //#endregion
183
+ export { A as CodeBlock, M as CodeBlockCollapseButton, j as CodeBlockCopyButton, N as CodeBlockDownloadButton, C as getCollapsedPreviewDisplay, w as isContentLargerThanPreview, E as plainPreMarkup, T as shouldUsePlainTextInsteadOfShiki };
@@ -1,50 +1,30 @@
1
- import { jsx as a } from "react/jsx-runtime";
1
+ import { cn as e } from "../../../../lib/utils.js";
2
2
  import { forwardRef as t } from "react";
3
- import { Collapsible as n } from "@base-ui/react/collapsible";
4
- import { cn as i } from "../../../../lib/utils.js";
5
- const s = t(({ className: l, ...o }, e) => /* @__PURE__ */ a(
6
- n.Root,
7
- {
8
- ref: e,
9
- "data-slot": "collapsible",
10
- className: i(
11
- "w-full min-w-0 rounded-md box-border *:max-w-full",
12
- l
13
- ),
14
- ...o
15
- }
16
- ));
17
- s.displayName = "Collapsible";
18
- const d = t(({ className: l, children: o, ...e }, r) => /* @__PURE__ */ a(
19
- n.Trigger,
20
- {
21
- ref: r,
22
- "data-slot": "collapsible-trigger",
23
- className: i(
24
- "group/collapsible-trigger rounded-lg text-sm font-medium leading-5 text-foreground overflow-hidden",
25
- l
26
- ),
27
- ...e,
28
- children: o
29
- }
30
- ));
31
- d.displayName = "CollapsibleTrigger";
32
- const m = t(({ className: l, keepMounted: o = !0, ...e }, r) => /* @__PURE__ */ a(
33
- n.Panel,
34
- {
35
- ref: r,
36
- "data-slot": "collapsible-content",
37
- className: i(
38
- "hidden data-open:block border-none outline-none text-secondary-foreground text-sm font-normal leading-5 tracking-tight w-full min-w-0 overflow-x-hidden box-border *:max-w-full *:box-border",
39
- l
40
- ),
41
- keepMounted: o,
42
- ...e
43
- }
44
- ));
45
- m.displayName = "CollapsibleContent";
46
- export {
47
- s as Collapsible,
48
- m as CollapsibleContent,
49
- d as CollapsibleTrigger
50
- };
3
+ import { jsx as n } from "react/jsx-runtime";
4
+ import { Collapsible as r } from "@base-ui/react/collapsible";
5
+ //#region libs/aura/src/components/ui/core/collapsible/collapsible.tsx
6
+ var i = t(({ className: t, ...i }, a) => /* @__PURE__ */ n(r.Root, {
7
+ ref: a,
8
+ "data-slot": "collapsible",
9
+ className: e("w-full min-w-0 rounded-md box-border *:max-w-full", t),
10
+ ...i
11
+ }));
12
+ i.displayName = "Collapsible";
13
+ var a = t(({ className: t, children: i, ...a }, o) => /* @__PURE__ */ n(r.Trigger, {
14
+ ref: o,
15
+ "data-slot": "collapsible-trigger",
16
+ className: e("group/collapsible-trigger rounded-lg text-sm font-medium leading-5 text-foreground overflow-hidden", t),
17
+ ...a,
18
+ children: i
19
+ }));
20
+ a.displayName = "CollapsibleTrigger";
21
+ var o = t(({ className: t, keepMounted: i = !0, ...a }, o) => /* @__PURE__ */ n(r.Panel, {
22
+ ref: o,
23
+ "data-slot": "collapsible-content",
24
+ className: e("hidden data-open:block border-none outline-none text-secondary-foreground text-sm font-normal leading-5 tracking-tight w-full min-w-0 overflow-x-hidden box-border *:max-w-full *:box-border", t),
25
+ keepMounted: i,
26
+ ...a
27
+ }));
28
+ o.displayName = "CollapsibleContent";
29
+ //#endregion
30
+ export { i as Collapsible, o as CollapsibleContent, a as CollapsibleTrigger };
@@ -0,0 +1,41 @@
1
+ import { cn as e } from "../../../../lib/utils.js";
2
+ import { Button as t } from "../button/button.js";
3
+ import { Command as n, CommandEmpty as r, CommandGroup as i, CommandInput as a, CommandItem as o, CommandList as s } from "../command/command.js";
4
+ import { Popover as c, PopoverContent as l, PopoverTrigger as u } from "../popover/popover.js";
5
+ import { forwardRef as d, useState as f } from "react";
6
+ import { IconCaretUpDown as p, IconCheck as m } from "@tabler/icons-react";
7
+ import { jsx as h, jsxs as g } from "react/jsx-runtime";
8
+ //#region libs/aura/src/components/ui/core/combobox/combobox.tsx
9
+ var _ = d(({ options: d, value: _, onValueChange: v, placeholder: y = "Select option...", searchPlaceholder: b = "Search...", emptyText: x = "No option found.", className: S, ...C }, w) => {
10
+ let [T, E] = f(!1), [D, O] = f(_ ?? ""), k = _ !== void 0, A = k ? _ : D, j = (e) => {
11
+ let t = e === A ? "" : e;
12
+ k || O(t), v?.(t), E(!1);
13
+ };
14
+ return /* @__PURE__ */ h("div", {
15
+ "data-slot": "combobox",
16
+ children: /* @__PURE__ */ g(c, {
17
+ open: T,
18
+ onOpenChange: E,
19
+ children: [/* @__PURE__ */ h(u, { render: /* @__PURE__ */ g(t, {
20
+ ref: w,
21
+ "data-slot": "combobox-trigger",
22
+ variant: "outline",
23
+ role: "combobox",
24
+ "aria-expanded": T,
25
+ className: e("w-50 justify-between", S),
26
+ ...C,
27
+ children: [A ? d.find((e) => e.value === A)?.label : y, /* @__PURE__ */ h(p, { className: "ml-2 h-4 w-4 shrink-0 opacity-50" })]
28
+ }) }), /* @__PURE__ */ h(l, {
29
+ className: e("w-50 p-0", S),
30
+ children: /* @__PURE__ */ g(n, { children: [/* @__PURE__ */ h(a, { placeholder: b }), /* @__PURE__ */ g(s, { children: [/* @__PURE__ */ h(r, { children: x }), /* @__PURE__ */ h(i, { children: d.map((t) => /* @__PURE__ */ g(o, {
31
+ value: t.value,
32
+ onSelect: j,
33
+ children: [/* @__PURE__ */ h(m, { className: e("mr-2 h-4 w-4", A === t.value ? "opacity-100" : "opacity-0") }), t.label]
34
+ }, t.value)) })] })] })
35
+ })]
36
+ })
37
+ });
38
+ });
39
+ _.displayName = "Combobox";
40
+ //#endregion
41
+ export { _ as Combobox };