@epilot/zenith-react 0.2.0-next.0 → 0.2.0-next.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.
Files changed (131) hide show
  1. package/dist/components/accordion/accordion.js +57 -48
  2. package/dist/components/accordion/accordion.js.map +1 -1
  3. package/dist/components/alert-dialog/alert-dialog.js +120 -92
  4. package/dist/components/alert-dialog/alert-dialog.js.map +1 -1
  5. package/dist/components/avatar/avatar-group.js +38 -35
  6. package/dist/components/avatar/avatar-group.js.map +1 -1
  7. package/dist/components/avatar/avatar.js +78 -71
  8. package/dist/components/avatar/avatar.js.map +1 -1
  9. package/dist/components/badge/badge.js +60 -55
  10. package/dist/components/badge/badge.js.map +1 -1
  11. package/dist/components/breadcrumb/breadcrumb.js +99 -54
  12. package/dist/components/breadcrumb/breadcrumb.js.map +1 -1
  13. package/dist/components/button/button.js +87 -77
  14. package/dist/components/button/button.js.map +1 -1
  15. package/dist/components/button-group/button-group.js +36 -32
  16. package/dist/components/button-group/button-group.js.map +1 -1
  17. package/dist/components/callout/callout.js +105 -98
  18. package/dist/components/callout/callout.js.map +1 -1
  19. package/dist/components/card/card.js +62 -52
  20. package/dist/components/card/card.js.map +1 -1
  21. package/dist/components/checkbox/checkbox.js +22 -19
  22. package/dist/components/checkbox/checkbox.js.map +1 -1
  23. package/dist/components/code-block/code-block.js +135 -123
  24. package/dist/components/code-block/code-block.js.map +1 -1
  25. package/dist/components/code-editor/code-editor.js +276 -260
  26. package/dist/components/code-editor/code-editor.js.map +1 -1
  27. package/dist/components/collapsible-sidebar/collapsible-sidebar.js +62 -56
  28. package/dist/components/collapsible-sidebar/collapsible-sidebar.js.map +1 -1
  29. package/dist/components/command/command.js +116 -105
  30. package/dist/components/command/command.js.map +1 -1
  31. package/dist/components/data-table/data-table-body.js +38 -34
  32. package/dist/components/data-table/data-table-body.js.map +1 -1
  33. package/dist/components/data-table/data-table-column-header.js +30 -26
  34. package/dist/components/data-table/data-table-column-header.js.map +1 -1
  35. package/dist/components/data-table/data-table-column-order.js +79 -73
  36. package/dist/components/data-table/data-table-column-order.js.map +1 -1
  37. package/dist/components/data-table/data-table-column-visibility.js +25 -22
  38. package/dist/components/data-table/data-table-column-visibility.js.map +1 -1
  39. package/dist/components/data-table/data-table-content.js +47 -44
  40. package/dist/components/data-table/data-table-content.js.map +1 -1
  41. package/dist/components/data-table/data-table-error.js +36 -32
  42. package/dist/components/data-table/data-table-error.js.map +1 -1
  43. package/dist/components/data-table/data-table-footer.js +10 -8
  44. package/dist/components/data-table/data-table-footer.js.map +1 -1
  45. package/dist/components/data-table/data-table-header-draggable.js +40 -36
  46. package/dist/components/data-table/data-table-header-draggable.js.map +1 -1
  47. package/dist/components/data-table/data-table-loading.js +21 -18
  48. package/dist/components/data-table/data-table-loading.js.map +1 -1
  49. package/dist/components/data-table/data-table-resize-handle.js +13 -11
  50. package/dist/components/data-table/data-table-resize-handle.js.map +1 -1
  51. package/dist/components/data-table/data-table-row.js +47 -44
  52. package/dist/components/data-table/data-table-row.js.map +1 -1
  53. package/dist/components/data-table/data-table-toolbar.js +9 -7
  54. package/dist/components/data-table/data-table-toolbar.js.map +1 -1
  55. package/dist/components/data-table/data-table.js +48 -46
  56. package/dist/components/data-table/data-table.js.map +1 -1
  57. package/dist/components/date-range-picker/date-range-picker.js +173 -164
  58. package/dist/components/date-range-picker/date-range-picker.js.map +1 -1
  59. package/dist/components/date-range-picker/range-calendar.js +36 -34
  60. package/dist/components/date-range-picker/range-calendar.js.map +1 -1
  61. package/dist/components/date-time-picker/calendar.js +290 -272
  62. package/dist/components/date-time-picker/calendar.js.map +1 -1
  63. package/dist/components/date-time-picker/date-time-picker-input.js +22 -20
  64. package/dist/components/date-time-picker/date-time-picker-input.js.map +1 -1
  65. package/dist/components/date-time-picker/date-time-picker-panel.js +126 -120
  66. package/dist/components/date-time-picker/date-time-picker-panel.js.map +1 -1
  67. package/dist/components/date-time-picker/date-time-picker.js +42 -40
  68. package/dist/components/date-time-picker/date-time-picker.js.map +1 -1
  69. package/dist/components/date-time-picker/time-picker.js +95 -87
  70. package/dist/components/date-time-picker/time-picker.js.map +1 -1
  71. package/dist/components/dialog/dialog.js +115 -95
  72. package/dist/components/dialog/dialog.js.map +1 -1
  73. package/dist/components/drawer/drawer.js +144 -109
  74. package/dist/components/drawer/drawer.js.map +1 -1
  75. package/dist/components/dropdown-menu/dropdown-menu.js +141 -112
  76. package/dist/components/dropdown-menu/dropdown-menu.js.map +1 -1
  77. package/dist/components/field/field-combobox.js +196 -176
  78. package/dist/components/field/field-combobox.js.map +1 -1
  79. package/dist/components/field/field.js +137 -126
  80. package/dist/components/field/field.js.map +1 -1
  81. package/dist/components/list/list.js +237 -219
  82. package/dist/components/list/list.js.map +1 -1
  83. package/dist/components/option-card/option-card.js +129 -116
  84. package/dist/components/option-card/option-card.js.map +1 -1
  85. package/dist/components/pill/pill.js +55 -51
  86. package/dist/components/pill/pill.js.map +1 -1
  87. package/dist/components/popover/popover.js +53 -36
  88. package/dist/components/popover/popover.js.map +1 -1
  89. package/dist/components/radio/radio.js +38 -34
  90. package/dist/components/radio/radio.js.map +1 -1
  91. package/dist/components/scroll-area/scroll-area.js +38 -35
  92. package/dist/components/scroll-area/scroll-area.js.map +1 -1
  93. package/dist/components/scroll-overflow/scroll-overflow.js +166 -151
  94. package/dist/components/scroll-overflow/scroll-overflow.js.map +1 -1
  95. package/dist/components/segmented-control/segmented-control.js +93 -85
  96. package/dist/components/segmented-control/segmented-control.js.map +1 -1
  97. package/dist/components/select/select.js +149 -128
  98. package/dist/components/select/select.js.map +1 -1
  99. package/dist/components/separator/separator.js +19 -16
  100. package/dist/components/separator/separator.js.map +1 -1
  101. package/dist/components/skeleton/skeleton.js +34 -30
  102. package/dist/components/skeleton/skeleton.js.map +1 -1
  103. package/dist/components/spinner/spinner.js +22 -17
  104. package/dist/components/spinner/spinner.js.map +1 -1
  105. package/dist/components/surface/surface.js +25 -22
  106. package/dist/components/surface/surface.js.map +1 -1
  107. package/dist/components/switch/switch.js +66 -57
  108. package/dist/components/switch/switch.js.map +1 -1
  109. package/dist/components/table/table-pagination.js +139 -129
  110. package/dist/components/table/table-pagination.js.map +1 -1
  111. package/dist/components/table/table.js +104 -90
  112. package/dist/components/table/table.js.map +1 -1
  113. package/dist/components/tabs/tabs.js +206 -128
  114. package/dist/components/tabs/tabs.js.map +1 -1
  115. package/dist/components/toast/toast.js +112 -100
  116. package/dist/components/toast/toast.js.map +1 -1
  117. package/dist/components/toggle/toggle.js +32 -30
  118. package/dist/components/toggle/toggle.js.map +1 -1
  119. package/dist/components/tooltip/tooltip.js +59 -46
  120. package/dist/components/tooltip/tooltip.js.map +1 -1
  121. package/dist/index.d.ts +12 -0
  122. package/dist/lib/clear-button.js +18 -17
  123. package/dist/lib/clear-button.js.map +1 -1
  124. package/dist/styles/host-reset.js +47 -0
  125. package/dist/styles/host-reset.js.map +1 -0
  126. package/dist/styles/overlay-layer.js +5 -0
  127. package/dist/styles/overlay-layer.js.map +1 -0
  128. package/dist/tokens.json +1 -1
  129. package/package.json +8 -7
  130. package/scripts/migration-diagnostics.mjs +42 -7
  131. package/scripts/migration-sweep.mjs +9 -1
@@ -1,62 +1,64 @@
1
- import { jsxs as j, jsx as n } from "react/jsx-runtime";
2
- import * as t from "react";
1
+ import { jsxs as Y, jsx as n } from "react/jsx-runtime";
2
+ import * as r from "react";
3
3
  import { mergeClasses as m, SLOT_ATTR as c, shorthands as l } from "@epilot/zenith-runtime/v1";
4
- import { makeZenithStyles as it } from "../../styles/make-styles.js";
5
- import { leadingXs as le, spacingElement2 as k, surfaceField as oe, spacingElement05 as ze, info11 as nt, warning11 as lt, error11 as at, infoUi as st, warningUi as ct, errorUi as De, grayA12 as _, spacingElement3 as ie, grayA8 as ne, grayA2 as We, accentA5 as dt, fontWeightNormal as ut, trackingNormal as ft, textXs as ht, fontMono as gt, grayA3 as Re, focusRing as mt, surfaceRadiusField as pt, borderField as vt, borderWidthField as bt } from "../../tokens/index.js";
6
- import { Button as yt } from "../button/button.js";
7
- import { applyIndent as kt } from "./indent.js";
8
- import { highlightCode as xt, splitTokenLines as St } from "../../lib/code-highlight.js";
9
- import { useCodeTokenRenderer as wt } from "../../lib/code-tokens.js";
10
- import { severityByLine as Ct, visibleDiagnostics as zt, lineIndexAt as Wt, caretAfterRewrite as Rt, gutterDigits as $t } from "../../lib/code-lines.js";
11
- const Dt = 2e3, ae = "--zenith-code-gutter", $e = {
4
+ import { makeZenithStyles as lt } from "../../styles/make-styles.js";
5
+ import { boxModel as p, nativeControl as at } from "../../styles/host-reset.js";
6
+ import { leadingXs as ae, spacingElement2 as x, surfaceField as ie, spacingElement05 as We, info11 as st, warning11 as ct, error11 as dt, infoUi as ut, warningUi as ft, errorUi as Te, grayA12 as j, spacingElement3 as ne, grayA8 as le, grayA2 as Re, fontMono as Ie, accentA5 as ht, fontWeightNormal as gt, trackingNormal as mt, textXs as pt, grayA3 as $e, focusRing as vt, surfaceRadiusField as bt, borderField as yt, borderWidthField as kt } from "../../tokens/index.js";
7
+ import { Button as xt } from "../button/button.js";
8
+ import { applyIndent as St } from "./indent.js";
9
+ import { highlightCode as wt, splitTokenLines as Ct } from "../../lib/code-highlight.js";
10
+ import { useCodeTokenRenderer as zt } from "../../lib/code-tokens.js";
11
+ import { severityByLine as Wt, visibleDiagnostics as Rt, lineIndexAt as $t, caretAfterRewrite as Dt, gutterDigits as Tt } from "../../lib/code-lines.js";
12
+ const It = 2e3, se = "--zenith-code-gutter", De = {
12
13
  ...l.margin(0),
13
14
  ...l.borderWidth(0),
14
15
  ...l.borderStyle("none"),
15
- ...l.padding(k),
16
- fontFamily: gt,
17
- fontSize: ht,
18
- lineHeight: le,
19
- letterSpacing: ft,
20
- fontWeight: ut,
16
+ ...l.padding(x),
17
+ fontFamily: Ie,
18
+ fontSize: pt,
19
+ lineHeight: ae,
20
+ letterSpacing: mt,
21
+ fontWeight: gt,
21
22
  textIndent: 0,
22
23
  boxSizing: "border-box",
23
24
  // A classic, space-consuming scrollbar narrows the textarea's content box but not the layer's,
24
25
  // which moves where wrapped lines break. Reserving the gutter on both keeps one content width.
25
26
  // Platforms with overlay scrollbars never had the problem.
26
27
  scrollbarGutter: "stable"
27
- }, y = {
28
- error: { rule: De, number: at },
29
- warning: { rule: ct, number: lt },
30
- info: { rule: st, number: nt }
31
- }, Tt = it({
28
+ }, k = {
29
+ error: { rule: Te, number: dt },
30
+ warning: { rule: ft, number: ct },
31
+ info: { rule: ut, number: st }
32
+ }, Mt = lt({
32
33
  root: {
34
+ ...p,
33
35
  display: "flex",
34
36
  flexDirection: "column",
35
37
  minWidth: 0,
36
38
  position: "relative",
37
- backgroundColor: oe,
38
- ...l.borderWidth(bt),
39
+ backgroundColor: ie,
40
+ ...l.borderWidth(kt),
39
41
  ...l.borderStyle("solid"),
40
- ...l.borderColor(vt),
41
- borderRadius: pt,
42
+ ...l.borderColor(yt),
43
+ borderRadius: bt,
42
44
  // Declared before the state rules below so those win by source order, per AGENTS.md rule 2.
43
45
  "&:focus-within": {
44
46
  outlineWidth: "2px",
45
47
  outlineStyle: "solid",
46
48
  outlineOffset: "-1px",
47
- outlineColor: mt
49
+ outlineColor: vt
48
50
  },
49
51
  "&[data-invalid]": {
50
- ...l.borderColor(De)
52
+ ...l.borderColor(Te)
51
53
  },
52
54
  "&[data-disabled]": {
53
- backgroundColor: Re
55
+ backgroundColor: $e
54
56
  }
55
57
  },
56
58
  // Repaint the opaque gutter when the surrounding field is disabled.
57
59
  rootDisabledGutter: {
58
60
  [`&[data-disabled] [${c}='code-editor-line-number']`]: {
59
- backgroundColor: Re
61
+ backgroundColor: $e
60
62
  }
61
63
  },
62
64
  // focus-within would keep the overlay visible throughout the editing session.
@@ -65,7 +67,7 @@ const Dt = 2e3, ae = "--zenith-code-gutter", $e = {
65
67
  },
66
68
  // The textarea defines the box; this decorative layer stretches without measurement.
67
69
  highlight: {
68
- ...$e,
70
+ ...De,
69
71
  position: "absolute",
70
72
  top: 0,
71
73
  right: 0,
@@ -76,7 +78,7 @@ const Dt = 2e3, ae = "--zenith-code-gutter", $e = {
76
78
  // Paint only: it must never take a click, a caret or a selection away from the control.
77
79
  pointerEvents: "none",
78
80
  userSelect: "none",
79
- color: _,
81
+ color: j,
80
82
  "&[data-composing]": {
81
83
  // Provisional IME text lives in the textarea, so the layer would be showing stale colours
82
84
  // over it. Declared after the base so it wins by source order.
@@ -85,30 +87,32 @@ const Dt = 2e3, ae = "--zenith-code-gutter", $e = {
85
87
  },
86
88
  /** With a gutter, the left padding moves into the number cell so the cell can pin flush. */
87
89
  highlightGutter: {
90
+ ...p,
88
91
  paddingLeft: 0
89
92
  },
90
93
  textarea: {
91
- ...$e,
94
+ ...at,
95
+ ...De,
92
96
  position: "relative",
93
97
  width: "100%",
94
98
  minWidth: 0,
95
99
  backgroundColor: "transparent",
96
100
  // The glyphs come from the layer beneath; only the caret is painted here.
97
101
  color: "transparent",
98
- caretColor: _,
102
+ caretColor: j,
99
103
  overflowX: "auto",
100
104
  overflowY: "auto",
101
105
  // The root paints the ring for the whole surface; a second one on the control would double it.
102
106
  outlineStyle: "none",
103
107
  "::placeholder": {
104
- color: ne,
108
+ color: le,
105
109
  // Placeholders are the textarea's own paint, so they need a real colour despite the above.
106
- WebkitTextFillColor: ne
110
+ WebkitTextFillColor: le
107
111
  },
108
112
  "::selection": {
109
113
  // An alpha tint, so highlighted glyphs stay legible through the selection band instead of
110
114
  // being covered by it — transparent text under an opaque selection is invisible text.
111
- backgroundColor: dt
115
+ backgroundColor: ht
112
116
  },
113
117
  ":disabled": {
114
118
  cursor: "not-allowed"
@@ -116,12 +120,13 @@ const Dt = 2e3, ae = "--zenith-code-gutter", $e = {
116
120
  "&[data-composing]": {
117
121
  // Reveal what the IME is composing. Without this the author types blind through a CJK
118
122
  // composition, which is the one way this technique can fail outright.
119
- color: _
123
+ color: j
120
124
  }
121
125
  },
122
126
  // Keep textarea glyphs aligned with the highlighted rows.
123
127
  textareaGutter: {
124
- paddingLeft: `calc(${k} + var(${ae}) + ${ie})`
128
+ ...p,
129
+ paddingLeft: `calc(${x} + var(${se}) + ${ne})`
125
130
  },
126
131
  // Unsupported browsers fall back to the native rows height.
127
132
  autoSize: {
@@ -147,44 +152,53 @@ const Dt = 2e3, ae = "--zenith-code-gutter", $e = {
147
152
  whiteSpace: "pre-wrap",
148
153
  overflowWrap: "break-word"
149
154
  },
155
+ // The UA gives `<code>` its own monospace family and size, so the pre's metrics would not reach
156
+ // the rows without this.
157
+ code: {
158
+ fontFamily: Ie,
159
+ fontSize: "1em"
160
+ },
150
161
  // Width constraints below require a block formatting context.
151
162
  codeRows: {
152
163
  display: "block"
153
164
  },
154
165
  // Give the sticky gutter and active-line band the full width of unwrapped code.
155
166
  codeNoWrap: {
167
+ ...p,
156
168
  width: "max-content",
157
169
  minWidth: "100%"
158
170
  },
159
171
  line: {
172
+ ...p,
160
173
  display: "flex",
161
174
  width: "100%"
162
175
  },
163
176
  /** The band under the caret's line. See `caretLine` in the component for when it is on. */
164
177
  lineActive: {
165
- backgroundImage: `linear-gradient(${We}, ${We})`
178
+ backgroundImage: `linear-gradient(${Re}, ${Re})`
166
179
  },
167
180
  lineNumber: {
168
181
  userSelect: "none",
169
182
  textAlign: "right",
170
183
  flexGrow: 0,
171
184
  flexShrink: 0,
172
- color: ne,
185
+ color: le,
173
186
  boxSizing: "border-box",
174
- width: `calc(var(${ae}) + ${k} + ${ie})`,
175
- paddingLeft: k,
176
- paddingRight: ie,
187
+ width: `calc(var(${se}) + ${x} + ${ne})`,
188
+ paddingLeft: x,
189
+ paddingRight: ne,
177
190
  // Pinned, so a long line scrolled sideways does not take the numbers with it. Opaque, because
178
191
  // scrolled code passes underneath.
179
192
  position: "sticky",
180
193
  left: 0,
181
- backgroundColor: oe
194
+ backgroundColor: ie
182
195
  },
183
196
  /** The caret's line number, lifted out of the gutter's grey. */
184
197
  lineNumberActive: {
185
- color: _
198
+ color: j
186
199
  },
187
200
  lineContent: {
201
+ ...p,
188
202
  minWidth: 0,
189
203
  flexGrow: 1,
190
204
  flexShrink: 1,
@@ -197,33 +211,33 @@ const Dt = 2e3, ae = "--zenith-code-gutter", $e = {
197
211
  diagnosticError: {
198
212
  textDecorationLine: "underline",
199
213
  textDecorationStyle: "wavy",
200
- textDecorationColor: y.error.rule,
214
+ textDecorationColor: k.error.rule,
201
215
  textDecorationSkipInk: "none",
202
216
  textUnderlineOffset: "0.2em"
203
217
  },
204
218
  diagnosticWarning: {
205
219
  textDecorationLine: "underline",
206
220
  textDecorationStyle: "wavy",
207
- textDecorationColor: y.warning.rule,
221
+ textDecorationColor: k.warning.rule,
208
222
  textDecorationSkipInk: "none",
209
223
  textUnderlineOffset: "0.2em"
210
224
  },
211
225
  diagnosticInfo: {
212
226
  textDecorationLine: "underline",
213
227
  textDecorationStyle: "wavy",
214
- textDecorationColor: y.info.rule,
228
+ textDecorationColor: k.info.rule,
215
229
  textDecorationSkipInk: "none",
216
230
  textUnderlineOffset: "0.2em"
217
231
  },
218
- numberError: { color: y.error.number },
219
- numberWarning: { color: y.warning.number },
220
- numberInfo: { color: y.info.number },
232
+ numberError: { color: k.error.number },
233
+ numberWarning: { color: k.warning.number },
234
+ numberInfo: { color: k.info.number },
221
235
  format: {
222
236
  position: "absolute",
223
- top: ze,
224
- right: ze,
237
+ top: We,
238
+ right: We,
225
239
  zIndex: 1,
226
- backgroundColor: oe,
240
+ backgroundColor: ie,
227
241
  opacity: 0,
228
242
  transitionProperty: "opacity",
229
243
  transitionDuration: "120ms",
@@ -238,6 +252,7 @@ const Dt = 2e3, ae = "--zenith-code-gutter", $e = {
238
252
  "&[data-format-state='pending']": { opacity: 1 }
239
253
  },
240
254
  srOnly: {
255
+ ...p,
241
256
  position: "absolute",
242
257
  width: "1px",
243
258
  height: "1px",
@@ -248,7 +263,7 @@ const Dt = 2e3, ae = "--zenith-code-gutter", $e = {
248
263
  clip: "rect(0, 0, 0, 0)",
249
264
  whiteSpace: "nowrap"
250
265
  }
251
- }), It = (se) => /* @__PURE__ */ j(
266
+ }), Nt = (ce) => /* @__PURE__ */ Y(
252
267
  "svg",
253
268
  {
254
269
  xmlns: "http://www.w3.org/2000/svg",
@@ -260,7 +275,7 @@ const Dt = 2e3, ae = "--zenith-code-gutter", $e = {
260
275
  strokeLinejoin: "round",
261
276
  "aria-hidden": "true",
262
277
  focusable: "false",
263
- ...se,
278
+ ...ce,
264
279
  children: [
265
280
  /* @__PURE__ */ n("path", { d: "M4 5h16" }),
266
281
  /* @__PURE__ */ n("path", { d: "M9 10h11" }),
@@ -268,262 +283,263 @@ const Dt = 2e3, ae = "--zenith-code-gutter", $e = {
268
283
  /* @__PURE__ */ n("path", { d: "M4 20h16" })
269
284
  ]
270
285
  }
271
- ), Ot = t.forwardRef(function({
272
- value: ce,
273
- defaultValue: Te,
274
- onValueChange: z,
275
- onChange: W,
276
- onKeyDown: R,
277
- onBlur: $,
278
- onFocus: D,
279
- onSelect: T,
280
- onScroll: I,
286
+ ), jt = r.forwardRef(function({
287
+ value: de,
288
+ defaultValue: Me,
289
+ onValueChange: W,
290
+ onChange: R,
291
+ onKeyDown: $,
292
+ onBlur: D,
293
+ onFocus: T,
294
+ onSelect: I,
295
+ onScroll: M,
281
296
  onCompositionStart: N,
282
- onCompositionEnd: M,
283
- language: Y,
284
- wrap: A = !1,
285
- resize: Ie,
286
- indentWithTab: de = !1,
287
- indentSize: E = 2,
288
- invalid: ue = !1,
297
+ onCompositionEnd: A,
298
+ language: P,
299
+ wrap: E = !1,
300
+ resize: Ne,
301
+ indentWithTab: ue = !1,
302
+ indentSize: L = 2,
303
+ invalid: fe = !1,
289
304
  readOnly: u = !1,
290
305
  disabled: f = !1,
291
- showLineNumbers: p = !1,
292
- diagnostics: L,
306
+ showLineNumbers: v = !1,
307
+ diagnostics: G,
293
308
  onFormat: d,
294
309
  onFormatError: h,
295
- formatLabel: Ne = "Format code",
296
- formattedLabel: fe = "Formatted",
297
- formatErrorLabel: P = "Formatting failed",
298
- autoSize: F = !1,
299
- maxRows: he,
300
- rows: ge,
301
- className: Me,
302
- style: me,
303
- spellCheck: Ae = !1,
304
- autoComplete: Ee = "off",
305
- autoCorrect: Le = "off",
306
- autoCapitalize: Ge = "off",
307
- dir: Ke = "ltr",
308
- ...Z
309
- }, x) {
310
- const r = Tt(), pe = `${t.useId()}-diagnostics`, q = ce !== void 0, [Ue, Be] = t.useState(Te ?? ""), a = q ? ce : Ue, ve = wt(), be = t.useRef(null), [ye, ke] = t.useState(!1), G = t.useRef(null), He = t.useCallback(
310
+ formatLabel: Ae = "Format code",
311
+ formattedLabel: he = "Formatted",
312
+ formatErrorLabel: F = "Formatting failed",
313
+ autoSize: Z = !1,
314
+ maxRows: ge,
315
+ rows: me,
316
+ className: Ee,
317
+ style: pe,
318
+ spellCheck: Le = !1,
319
+ autoComplete: Ge = "off",
320
+ autoCorrect: Ke = "off",
321
+ autoCapitalize: Ue = "off",
322
+ dir: Be = "ltr",
323
+ ...q
324
+ }, S) {
325
+ const t = Mt(), ve = `${r.useId()}-diagnostics`, J = de !== void 0, [He, Oe] = r.useState(Me ?? ""), a = J ? de : He, be = zt(), ye = r.useRef(null), [ke, xe] = r.useState(!1), K = r.useRef(null), Xe = r.useCallback(
311
326
  (e) => {
312
- G.current = e, typeof x == "function" ? x(e) : x && (x.current = e);
327
+ K.current = e, typeof S == "function" ? S(e) : S && (S.current = e);
313
328
  },
314
- [x]
315
- ), S = t.useRef(!1), v = t.useCallback(
329
+ [S]
330
+ ), w = r.useRef(!1), b = r.useCallback(
316
331
  (e) => {
317
- q || Be(e), z == null || z(e);
332
+ J || Oe(e), W == null || W(e);
318
333
  },
319
- [q, z]
320
- ), w = t.useMemo(() => a.split(`
321
- `).length, [a]), xe = t.useMemo(
322
- () => Ct(L, w),
323
- [L, w]
324
- ), J = t.useMemo(
325
- () => zt(L, w),
326
- [L, w]
327
- ), g = p || xe.size > 0, [Oe, Q] = t.useState(null), K = t.useCallback(() => {
334
+ [J, W]
335
+ ), C = r.useMemo(() => a.split(`
336
+ `).length, [a]), Se = r.useMemo(
337
+ () => Wt(G, C),
338
+ [G, C]
339
+ ), Q = r.useMemo(
340
+ () => Rt(G, C),
341
+ [G, C]
342
+ ), g = v || Se.size > 0, [_e, V] = r.useState(null), U = r.useCallback(() => {
328
343
  if (!g) return;
329
- const e = G.current;
344
+ const e = K.current;
330
345
  if (e !== null) {
331
346
  if (e.selectionStart !== e.selectionEnd) {
332
- Q(null);
347
+ V(null);
333
348
  return;
334
349
  }
335
- Q(Wt(e.value, e.selectionStart ?? 0));
350
+ V($t(e.value, e.selectionStart ?? 0));
336
351
  }
337
- }, [g]), Xe = t.useCallback(
352
+ }, [g]), je = r.useCallback(
338
353
  (e) => {
339
- v(e.target.value), W == null || W(e);
354
+ b(e.target.value), R == null || R(e);
340
355
  },
341
- [v, W]
342
- ), _e = t.useCallback(
356
+ [b, R]
357
+ ), Ye = r.useCallback(
343
358
  (e) => {
344
- K(), T == null || T(e);
359
+ U(), I == null || I(e);
345
360
  },
346
- [T, K]
347
- ), je = t.useCallback(
361
+ [I, U]
362
+ ), Pe = r.useCallback(
348
363
  (e) => {
349
- K(), D == null || D(e);
364
+ U(), T == null || T(e);
350
365
  },
351
- [D, K]
352
- ), U = t.useRef(!1), [B, V] = t.useState(!1), [Ye, Se] = t.useState(""), b = t.useRef(null);
353
- t.useEffect(
366
+ [T, U]
367
+ ), B = r.useRef(!1), [H, ee] = r.useState(!1), [Fe, we] = r.useState(""), y = r.useRef(null);
368
+ r.useEffect(
354
369
  () => () => {
355
- b.current !== null && clearTimeout(b.current);
370
+ y.current !== null && clearTimeout(y.current);
356
371
  },
357
372
  []
358
373
  );
359
- const H = t.useCallback((e) => {
360
- Se(e), b.current !== null && clearTimeout(b.current), b.current = setTimeout(() => {
361
- b.current = null, Se("");
362
- }, Dt);
363
- }, []), ee = t.useCallback(async () => {
374
+ const O = r.useCallback((e) => {
375
+ we(e), y.current !== null && clearTimeout(y.current), y.current = setTimeout(() => {
376
+ y.current = null, we("");
377
+ }, It);
378
+ }, []), te = r.useCallback(async () => {
364
379
  if (d === void 0 || u || f) return;
365
- const e = G.current;
366
- if (e === null || U.current) return;
380
+ const e = K.current;
381
+ if (e === null || B.current) return;
367
382
  const o = e.value;
368
- U.current = !0, V(!0);
383
+ B.current = !0, ee(!0);
369
384
  let i;
370
385
  try {
371
386
  i = await d(o);
372
- } catch (X) {
373
- U.current = !1, V(!1), H(P), h == null || h(X ?? new Error("Formatting failed"));
387
+ } catch (_) {
388
+ B.current = !1, ee(!1), O(F), h == null || h(_ ?? new Error("Formatting failed"));
374
389
  return;
375
390
  }
376
- U.current = !1, V(!1);
377
- const s = G.current;
391
+ B.current = !1, ee(!1);
392
+ const s = K.current;
378
393
  if (s !== null) {
379
394
  if (s.value !== o) {
380
- H(P), h == null || h(
395
+ O(F), h == null || h(
381
396
  new Error("Formatting discarded: the value changed while formatting")
382
397
  );
383
398
  return;
384
399
  }
385
400
  if (i !== o) {
386
- const X = Rt(o, i, s.selectionStart ?? 0);
387
- s.value = i, s.setSelectionRange(X, X), v(i);
401
+ const _ = Dt(o, i, s.selectionStart ?? 0);
402
+ s.value = i, s.setSelectionRange(_, _), b(i);
388
403
  }
389
- H(fe);
404
+ O(he);
390
405
  }
391
406
  }, [
392
- H,
393
- v,
407
+ O,
408
+ b,
394
409
  f,
395
- P,
396
- fe,
410
+ F,
411
+ he,
397
412
  d,
398
413
  h,
399
414
  u
400
- ]), Pe = t.useCallback(
415
+ ]), Ze = r.useCallback(
401
416
  (e) => {
402
- if (R == null || R(e), e.defaultPrevented || u || f) return;
417
+ if ($ == null || $(e), e.defaultPrevented || u || f) return;
403
418
  if (d !== void 0 && e.altKey && e.shiftKey && !e.ctrlKey && !e.metaKey && (e.code === "KeyF" || e.key.toLowerCase() === "f")) {
404
- e.preventDefault(), S.current = !1, ee();
419
+ e.preventDefault(), w.current = !1, te();
405
420
  return;
406
421
  }
407
- if (!de) return;
422
+ if (!ue) return;
408
423
  if (e.key === "Escape") {
409
- S.current = !0;
424
+ w.current = !0;
410
425
  return;
411
426
  }
412
427
  if (e.key !== "Tab") {
413
- S.current = !1;
428
+ w.current = !1;
414
429
  return;
415
430
  }
416
- if (S.current || e.ctrlKey || e.metaKey || e.altKey)
431
+ if (w.current || e.ctrlKey || e.metaKey || e.altKey)
417
432
  return;
418
- const o = e.currentTarget, i = kt(
433
+ const o = e.currentTarget, i = St(
419
434
  {
420
435
  value: o.value,
421
436
  selectionStart: o.selectionStart ?? 0,
422
437
  selectionEnd: o.selectionEnd ?? 0
423
438
  },
424
- { outdent: e.shiftKey, indentSize: E }
439
+ { outdent: e.shiftKey, indentSize: L }
425
440
  );
426
- i.value === o.value && i.selectionStart === o.selectionStart && i.selectionEnd === o.selectionEnd || (e.preventDefault(), o.value = i.value, o.setSelectionRange(i.selectionStart, i.selectionEnd), v(i.value));
441
+ i.value === o.value && i.selectionStart === o.selectionStart && i.selectionEnd === o.selectionEnd || (e.preventDefault(), o.value = i.value, o.setSelectionRange(i.selectionStart, i.selectionEnd), b(i.value));
427
442
  },
428
443
  [
429
- v,
444
+ b,
430
445
  f,
431
- E,
432
- de,
446
+ L,
447
+ ue,
433
448
  d,
434
- R,
449
+ $,
435
450
  u,
436
- ee
451
+ te
437
452
  ]
438
- ), Fe = t.useCallback(
453
+ ), qe = r.useCallback(
439
454
  (e) => {
440
- S.current = !1, Q(null), $ == null || $(e);
455
+ w.current = !1, V(null), D == null || D(e);
441
456
  },
442
- [$]
443
- ), Ze = t.useCallback(
457
+ [D]
458
+ ), Je = r.useCallback(
444
459
  (e) => {
445
- const o = be.current;
446
- o !== null && (o.scrollTop = e.currentTarget.scrollTop, o.scrollLeft = e.currentTarget.scrollLeft), I == null || I(e);
460
+ const o = ye.current;
461
+ o !== null && (o.scrollTop = e.currentTarget.scrollTop, o.scrollLeft = e.currentTarget.scrollLeft), M == null || M(e);
447
462
  },
448
- [I]
449
- ), qe = t.useCallback(
463
+ [M]
464
+ ), Qe = r.useCallback(
450
465
  (e) => {
451
- ke(!0), N == null || N(e);
466
+ xe(!0), N == null || N(e);
452
467
  },
453
468
  [N]
454
- ), Je = t.useCallback(
469
+ ), Ve = r.useCallback(
455
470
  (e) => {
456
- ke(!1), M == null || M(e);
471
+ xe(!1), A == null || A(e);
457
472
  },
458
- [M]
459
- ), te = g ? a : a.endsWith(`
460
- `) ? `${a} ` : a, C = t.useMemo(
461
- () => xt(te, Y),
462
- [te, Y]
463
- ), O = t.useMemo(
473
+ [A]
474
+ ), re = g ? a : a.endsWith(`
475
+ `) ? `${a} ` : a, z = r.useMemo(
476
+ () => wt(re, P),
477
+ [re, P]
478
+ ), X = r.useMemo(
464
479
  () => g ? a.split(`
465
480
  `) : null,
466
481
  [a, g]
467
- ), we = t.useMemo(
468
- () => g && C !== null ? St(C) : null,
469
- [C, g]
470
- ), Ce = A ? r.wrap : r.noWrap, re = Ie ?? (F ? "none" : "vertical"), Qe = re === "vertical" ? r.resizeVertical : re === "horizontal" ? r.resizeHorizontal : re === "both" ? r.resizeBoth : r.resizeNone, Ve = F ? {
471
- minHeight: `calc(${ge ?? 3} * ${le} + ${k} * 2)`,
472
- maxHeight: he === void 0 ? void 0 : `calc(${he} * ${le} + ${k} * 2)`
473
- } : void 0, et = p ? {
474
- [ae]: `${$t(w)}ch`,
475
- ...me
476
- } : me, tt = J.length === 0 ? Z["aria-describedby"] : [Z["aria-describedby"], pe].filter(Boolean).join(" "), rt = {
477
- error: r.diagnosticError,
478
- warning: r.diagnosticWarning,
479
- info: r.diagnosticInfo
480
- }, ot = {
481
- error: r.numberError,
482
- warning: r.numberWarning,
483
- info: r.numberInfo
482
+ ), Ce = r.useMemo(
483
+ () => g && z !== null ? Ct(z) : null,
484
+ [z, g]
485
+ ), ze = E ? t.wrap : t.noWrap, oe = Ne ?? (Z ? "none" : "vertical"), et = oe === "vertical" ? t.resizeVertical : oe === "horizontal" ? t.resizeHorizontal : oe === "both" ? t.resizeBoth : t.resizeNone, tt = Z ? {
486
+ minHeight: `calc(${me ?? 3} * ${ae} + ${x} * 2)`,
487
+ maxHeight: ge === void 0 ? void 0 : `calc(${ge} * ${ae} + ${x} * 2)`
488
+ } : void 0, rt = v ? {
489
+ [se]: `${Tt(C)}ch`,
490
+ ...pe
491
+ } : pe, ot = Q.length === 0 ? q["aria-describedby"] : [q["aria-describedby"], ve].filter(Boolean).join(" "), it = {
492
+ error: t.diagnosticError,
493
+ warning: t.diagnosticWarning,
494
+ info: t.diagnosticInfo
495
+ }, nt = {
496
+ error: t.numberError,
497
+ warning: t.numberWarning,
498
+ info: t.numberInfo
484
499
  };
485
- return /* @__PURE__ */ j(
500
+ return /* @__PURE__ */ Y(
486
501
  "div",
487
502
  {
488
503
  "data-slot": "code-editor",
489
504
  [c]: "code-editor",
490
- "data-language": Y,
491
- "data-invalid": ue || void 0,
505
+ "data-language": P,
506
+ "data-invalid": fe || void 0,
492
507
  "data-disabled": f || void 0,
493
508
  "data-readonly": u || void 0,
494
- "data-formatting": B || void 0,
509
+ "data-formatting": H || void 0,
495
510
  className: m(
496
- r.root,
497
- p ? r.rootDisabledGutter : void 0,
498
- d === void 0 ? void 0 : r.rootFormatReveal,
499
- Me
511
+ t.root,
512
+ v ? t.rootDisabledGutter : void 0,
513
+ d === void 0 ? void 0 : t.rootFormatReveal,
514
+ Ee
500
515
  ),
501
- style: et,
516
+ style: rt,
502
517
  children: [
503
518
  /* @__PURE__ */ n(
504
519
  "pre",
505
520
  {
506
- ref: be,
521
+ ref: ye,
507
522
  "aria-hidden": "true",
508
523
  "data-slot": "code-editor-highlight",
509
524
  [c]: "code-editor-highlight",
510
- "data-composing": ye || void 0,
525
+ "data-composing": ke || void 0,
511
526
  className: m(
512
- r.highlight,
513
- p ? r.highlightGutter : void 0,
514
- Ce
527
+ t.highlight,
528
+ v ? t.highlightGutter : void 0,
529
+ ze
515
530
  ),
516
- style: { tabSize: E },
531
+ style: { tabSize: L },
517
532
  children: /* @__PURE__ */ n(
518
533
  "code",
519
534
  {
520
535
  className: m(
521
- O === null ? void 0 : r.codeRows,
522
- O !== null && !A ? r.codeNoWrap : void 0
536
+ t.code,
537
+ X === null ? void 0 : t.codeRows,
538
+ X !== null && !E ? t.codeNoWrap : void 0
523
539
  ),
524
- children: O === null ? C === null ? te : ve(C) : O.map((e, o) => {
525
- const i = xe.get(o + 1), s = Oe === o;
526
- return /* @__PURE__ */ j(
540
+ children: X === null ? z === null ? re : be(z) : X.map((e, o) => {
541
+ const i = Se.get(o + 1), s = _e === o;
542
+ return /* @__PURE__ */ Y(
527
543
  "span",
528
544
  {
529
545
  "data-slot": "code-editor-line",
@@ -532,38 +548,38 @@ const Dt = 2e3, ae = "--zenith-code-gutter", $e = {
532
548
  "data-active": s || void 0,
533
549
  "data-severity": i,
534
550
  className: m(
535
- r.line,
536
- s ? r.lineActive : void 0
551
+ t.line,
552
+ s ? t.lineActive : void 0
537
553
  ),
538
554
  children: [
539
- p ? /* @__PURE__ */ n(
555
+ v ? /* @__PURE__ */ n(
540
556
  "span",
541
557
  {
542
558
  "data-slot": "code-editor-line-number",
543
559
  [c]: "code-editor-line-number",
544
560
  className: m(
545
- r.lineNumber,
546
- s ? r.lineNumberActive : void 0,
547
- i === void 0 ? void 0 : ot[i]
561
+ t.lineNumber,
562
+ s ? t.lineNumberActive : void 0,
563
+ i === void 0 ? void 0 : nt[i]
548
564
  ),
549
565
  children: o + 1
550
566
  }
551
567
  ) : null,
552
- /* @__PURE__ */ j(
568
+ /* @__PURE__ */ Y(
553
569
  "span",
554
570
  {
555
571
  "data-slot": "code-editor-line-content",
556
572
  [c]: "code-editor-line-content",
557
573
  className: m(
558
- r.lineContent,
559
- A ? r.lineContentWrap : void 0
574
+ t.lineContent,
575
+ E ? t.lineContentWrap : void 0
560
576
  ),
561
577
  children: [
562
578
  /* @__PURE__ */ n(
563
579
  "span",
564
580
  {
565
- className: i === void 0 ? void 0 : rt[i],
566
- children: we === null ? e : ve(we[o] ?? [])
581
+ className: i === void 0 ? void 0 : it[i],
582
+ children: Ce === null ? e : be(Ce[o] ?? [])
567
583
  }
568
584
  ),
569
585
  `
@@ -583,67 +599,67 @@ const Dt = 2e3, ae = "--zenith-code-gutter", $e = {
583
599
  /* @__PURE__ */ n(
584
600
  "textarea",
585
601
  {
586
- ...Z,
587
- ref: He,
602
+ ...q,
603
+ ref: Xe,
588
604
  "data-slot": "code-editor-input",
589
605
  [c]: "code-editor-input",
590
606
  value: a,
591
- rows: ge,
592
- onChange: Xe,
593
- onKeyDown: Pe,
594
- onFocus: je,
595
- onBlur: Fe,
596
- onSelect: _e,
597
- onScroll: Ze,
598
- onCompositionStart: qe,
599
- onCompositionEnd: Je,
600
- "data-composing": ye || void 0,
607
+ rows: me,
608
+ onChange: je,
609
+ onKeyDown: Ze,
610
+ onFocus: Pe,
611
+ onBlur: qe,
612
+ onSelect: Ye,
613
+ onScroll: Je,
614
+ onCompositionStart: Qe,
615
+ onCompositionEnd: Ve,
616
+ "data-composing": ke || void 0,
601
617
  readOnly: u,
602
618
  disabled: f,
603
- "aria-invalid": ue || void 0,
604
- "aria-describedby": tt,
605
- "aria-busy": B || void 0,
606
- spellCheck: Ae,
607
- autoComplete: Ee,
608
- autoCorrect: Le,
609
- autoCapitalize: Ge,
610
- dir: Ke,
611
- wrap: A ? "soft" : "off",
612
- style: { tabSize: E, ...Ve },
619
+ "aria-invalid": fe || void 0,
620
+ "aria-describedby": ot,
621
+ "aria-busy": H || void 0,
622
+ spellCheck: Le,
623
+ autoComplete: Ge,
624
+ autoCorrect: Ke,
625
+ autoCapitalize: Ue,
626
+ dir: Be,
627
+ wrap: E ? "soft" : "off",
628
+ style: { tabSize: L, ...tt },
613
629
  className: m(
614
- r.textarea,
615
- p ? r.textareaGutter : void 0,
616
- F ? r.autoSize : void 0,
617
- Ce,
618
- Qe
630
+ t.textarea,
631
+ v ? t.textareaGutter : void 0,
632
+ Z ? t.autoSize : void 0,
633
+ ze,
634
+ et
619
635
  )
620
636
  }
621
637
  ),
622
638
  d === void 0 ? null : /* @__PURE__ */ n(
623
- yt,
639
+ xt,
624
640
  {
625
641
  type: "button",
626
642
  variant: "ghost",
627
643
  size: "icon-sm",
628
- "data-format-state": B ? "pending" : "idle",
629
- "aria-label": Ne,
630
- disabled: f || u || B,
631
- className: r.format,
644
+ "data-format-state": H ? "pending" : "idle",
645
+ "aria-label": Ae,
646
+ disabled: f || u || H,
647
+ className: t.format,
632
648
  onMouseDown: (e) => e.preventDefault(),
633
649
  onClick: () => {
634
- ee();
650
+ te();
635
651
  },
636
- children: /* @__PURE__ */ n(It, {})
652
+ children: /* @__PURE__ */ n(Nt, {})
637
653
  }
638
654
  ),
639
- J.length === 0 ? null : /* @__PURE__ */ n(
655
+ Q.length === 0 ? null : /* @__PURE__ */ n(
640
656
  "ul",
641
657
  {
642
- id: pe,
658
+ id: ve,
643
659
  "data-slot": "code-editor-diagnostics",
644
660
  [c]: "code-editor-diagnostics",
645
- className: r.srOnly,
646
- children: J.map((e, o) => /* @__PURE__ */ n("li", { children: `${e.severity ?? "error"}, line ${e.line}${e.column === void 0 ? "" : `, column ${e.column}`}: ${e.message}` }, o))
661
+ className: t.srOnly,
662
+ children: Q.map((e, o) => /* @__PURE__ */ n("li", { children: `${e.severity ?? "error"}, line ${e.line}${e.column === void 0 ? "" : `, column ${e.column}`}: ${e.message}` }, o))
647
663
  }
648
664
  ),
649
665
  d === void 0 ? null : /* @__PURE__ */ n(
@@ -653,8 +669,8 @@ const Dt = 2e3, ae = "--zenith-code-gutter", $e = {
653
669
  "aria-live": "polite",
654
670
  "data-slot": "code-editor-format-status",
655
671
  [c]: "code-editor-format-status",
656
- className: r.srOnly,
657
- children: Ye
672
+ className: t.srOnly,
673
+ children: Fe
658
674
  }
659
675
  )
660
676
  ]
@@ -662,6 +678,6 @@ const Dt = 2e3, ae = "--zenith-code-gutter", $e = {
662
678
  );
663
679
  });
664
680
  export {
665
- Ot as CodeEditor
681
+ jt as CodeEditor
666
682
  };
667
683
  //# sourceMappingURL=code-editor.js.map