@espressif/dashboard-ui-components 1.5.0 → 1.6.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.
- package/.claude/rules/dashboard-ui-consumption.md +31 -0
- package/.cursor/rules/dashboard-ui-consumption.mdc +31 -0
- package/CHANGELOG.md +110 -0
- package/README.md +1 -0
- package/dist/{chunk-WR54R7J6.js → chunk-HYSNJBDF.js} +1 -1
- package/dist/{chunk-X7LDLZBT.js → chunk-IYMCZTJ5.js} +688 -40
- package/dist/common/index.js +2 -2
- package/dist/components/index.d.ts +109 -4
- package/dist/components/index.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/package.json +1 -1
- package/src/styles/colors.css +3 -2
|
@@ -3,7 +3,7 @@ import { FieldLabelRow, fieldHintClassName, Button, inputLabelClassName, Input,
|
|
|
3
3
|
import { getStrictContext, buttonVariants, Separator, CollapsibleContent, Collapsible, CollapsibleTrigger, useIsMobile, useControlledState, Button as Button$1, Skeleton, Avatar, AvatarFallback } from './chunk-OKB2WTX7.js';
|
|
4
4
|
import { cn, resolveColor, isPresetColor } from './chunk-VU4CZ76T.js';
|
|
5
5
|
import { __commonJS, __toESM } from './chunk-TRTQSARU.js';
|
|
6
|
-
import { ChevronDown, ChevronUp, Check, Upload, X, RefreshCw, LoaderCircle, Triangle, Info, MinusIcon, ArrowLeft, ArrowRight, Search, ClockIcon, Crown, ShieldCheck, Tag as Tag$1, ChevronRight, CircleAlert, Eye, EyeOff, Circle, FileCheck, CheckCheck, TriangleAlert, CircleX, Menu, ChevronsUpDown, ChevronLeftIcon, ChevronRightIcon, ChevronDownIcon, CalendarIcon, CalendarRangeIcon, CheckIcon, ChevronLeft, Columns2, ChevronsRight, ChevronsLeft,
|
|
6
|
+
import { ChevronDown, ChevronUp, Check, Upload, X, RefreshCw, LoaderCircle, Triangle, Info, MinusIcon, ArrowLeft, ArrowRight, Search, ClockIcon, Crown, ShieldCheck, Tag as Tag$1, ChevronRight, CircleAlert, Eye, EyeOff, Circle, Braces, FileCheck, CheckCheck, TriangleAlert, CircleX, Menu, ChevronsUpDown, ChevronLeftIcon, ChevronRightIcon, ChevronDownIcon, CalendarIcon, CalendarRangeIcon, CheckIcon, XIcon, ChevronLeft, Columns2, ChevronsRight, ChevronsLeft, MoveLeft, CircleIcon, Bolt, Plus, Trash2, Clock, XCircle, CheckCircle2 } from 'lucide-react';
|
|
7
7
|
import * as React10 from 'react';
|
|
8
8
|
import React10__default, { forwardRef, useMemo, isValidElement, useRef, useState, useCallback, useLayoutEffect, useEffect, useId, Fragment as Fragment$1, Children, cloneElement, createElement } from 'react';
|
|
9
9
|
import { Switch as Switch$1, ToggleGroup as ToggleGroup$1, Dialog as Dialog$1, Accordion as Accordion$1 } from 'radix-ui';
|
|
@@ -24,7 +24,7 @@ import Autoplay from 'embla-carousel-autoplay';
|
|
|
24
24
|
import useEmblaCarousel from 'embla-carousel-react';
|
|
25
25
|
import { Command as Command$1 } from 'cmdk';
|
|
26
26
|
import { getDefaultClassNames, DayPicker } from 'react-day-picker';
|
|
27
|
-
import { format, endOfMonth, startOfMonth,
|
|
27
|
+
import { format, sub, endOfMonth, startOfMonth, endOfDay, startOfDay, endOfYear, startOfYear, endOfWeek, startOfWeek, isValid, parse, set } from 'date-fns';
|
|
28
28
|
import { useReactTable, getPaginationRowModel, getCoreRowModel, flexRender } from '@tanstack/react-table';
|
|
29
29
|
import { PreviewCard as PreviewCard$1 } from '@base-ui-components/react/preview-card';
|
|
30
30
|
import { startCase } from 'lodash-es';
|
|
@@ -52331,6 +52331,12 @@ var stateVisuals = {
|
|
|
52331
52331
|
titleClass: "text-success",
|
|
52332
52332
|
descriptionClass: "text-success/80"
|
|
52333
52333
|
},
|
|
52334
|
+
warning: {
|
|
52335
|
+
avatarColor: "warning",
|
|
52336
|
+
endIconClass: "text-warning",
|
|
52337
|
+
titleClass: "text-warning",
|
|
52338
|
+
descriptionClass: "text-warning/80"
|
|
52339
|
+
},
|
|
52334
52340
|
error: {
|
|
52335
52341
|
avatarColor: "error",
|
|
52336
52342
|
endIconClass: "text-error",
|
|
@@ -52352,6 +52358,7 @@ var stateVisuals = {
|
|
|
52352
52358
|
};
|
|
52353
52359
|
var stateSurfaceCssVar = {
|
|
52354
52360
|
success: "--color-success",
|
|
52361
|
+
warning: "--color-warning",
|
|
52355
52362
|
error: "--color-error",
|
|
52356
52363
|
in_progress: "--color-primary",
|
|
52357
52364
|
not_started: "--color-gray"
|
|
@@ -52464,6 +52471,8 @@ function StatusEndIndicator({
|
|
|
52464
52471
|
switch (state) {
|
|
52465
52472
|
case "success":
|
|
52466
52473
|
return /* @__PURE__ */ jsx(CheckCircle2, { className: cls, "aria-hidden": true });
|
|
52474
|
+
case "warning":
|
|
52475
|
+
return /* @__PURE__ */ jsx(TriangleAlert, { className: cls, "aria-hidden": true });
|
|
52467
52476
|
case "error":
|
|
52468
52477
|
return /* @__PURE__ */ jsx(XCircle, { className: cls, "aria-hidden": true });
|
|
52469
52478
|
case "in_progress":
|
|
@@ -52782,15 +52791,15 @@ var Spinner = React10.forwardRef(function Spinner2({
|
|
|
52782
52791
|
"aria-labelledby": ariaLabelledby,
|
|
52783
52792
|
...rest
|
|
52784
52793
|
}, ref) {
|
|
52785
|
-
const
|
|
52794
|
+
const resolved2 = color != null ? resolveColor(color, "text") : void 0;
|
|
52786
52795
|
const ariaLabelResolved = ariaLabelledby != null ? void 0 : ariaLabel !== void 0 ? ariaLabel : "Loading";
|
|
52787
52796
|
return /* @__PURE__ */ jsx(
|
|
52788
52797
|
LoaderCircle,
|
|
52789
52798
|
{
|
|
52790
52799
|
ref,
|
|
52791
52800
|
...rest,
|
|
52792
|
-
className: cn("animate-spin",
|
|
52793
|
-
style: { ...
|
|
52801
|
+
className: cn("animate-spin", resolved2?.className, className),
|
|
52802
|
+
style: { ...resolved2?.style, ...style },
|
|
52794
52803
|
size: size ?? "1em",
|
|
52795
52804
|
"aria-label": ariaLabelResolved,
|
|
52796
52805
|
"aria-labelledby": ariaLabelledby
|
|
@@ -56284,6 +56293,7 @@ function DateTimePicker(props) {
|
|
|
56284
56293
|
}
|
|
56285
56294
|
DateTimePicker.displayName = "DateTimePicker";
|
|
56286
56295
|
var PRESET_IDS = [
|
|
56296
|
+
// Calendar periods
|
|
56287
56297
|
"today",
|
|
56288
56298
|
"yesterday",
|
|
56289
56299
|
"this-week",
|
|
@@ -56292,10 +56302,16 @@ var PRESET_IDS = [
|
|
|
56292
56302
|
"last-month",
|
|
56293
56303
|
"this-year",
|
|
56294
56304
|
"last-year",
|
|
56305
|
+
// Trailing ranges, shortest first. A rolling preset (ends now) precedes
|
|
56306
|
+
// the day-snapped preset of the same length.
|
|
56307
|
+
"last-1-hour",
|
|
56308
|
+
"last-24-hours",
|
|
56295
56309
|
"last-1-day",
|
|
56310
|
+
"past-7-days",
|
|
56296
56311
|
"last-7-days",
|
|
56297
56312
|
"last-14-days",
|
|
56298
56313
|
"last-15-days",
|
|
56314
|
+
"past-30-days",
|
|
56299
56315
|
"last-30-days",
|
|
56300
56316
|
"last-4-weeks",
|
|
56301
56317
|
"last-90-days",
|
|
@@ -56313,10 +56329,14 @@ var PRESET_LABELS = {
|
|
|
56313
56329
|
"last-month": "Last month",
|
|
56314
56330
|
"this-year": "This year",
|
|
56315
56331
|
"last-year": "Last year",
|
|
56332
|
+
"last-1-hour": "Last 1 hour",
|
|
56333
|
+
"last-24-hours": "Last 24 hours",
|
|
56316
56334
|
"last-1-day": "Last 1 day",
|
|
56335
|
+
"past-7-days": "Past 7 days",
|
|
56317
56336
|
"last-7-days": "Last 7 days",
|
|
56318
56337
|
"last-14-days": "Last 14 days",
|
|
56319
56338
|
"last-15-days": "Last 15 days",
|
|
56339
|
+
"past-30-days": "Past 30 days",
|
|
56320
56340
|
"last-30-days": "Last 30 days",
|
|
56321
56341
|
"last-4-weeks": "Last 4 weeks",
|
|
56322
56342
|
"last-90-days": "Last 90 days",
|
|
@@ -56325,6 +56345,12 @@ var PRESET_LABELS = {
|
|
|
56325
56345
|
"last-1-year": "Last 1 year",
|
|
56326
56346
|
"last-5-years": "Last 5 years"
|
|
56327
56347
|
};
|
|
56348
|
+
var ROLLING_PRESET_IDS = [
|
|
56349
|
+
"last-1-hour",
|
|
56350
|
+
"last-24-hours",
|
|
56351
|
+
"past-7-days",
|
|
56352
|
+
"past-30-days"
|
|
56353
|
+
];
|
|
56328
56354
|
function computeDateRange(id) {
|
|
56329
56355
|
const now = /* @__PURE__ */ new Date();
|
|
56330
56356
|
switch (id) {
|
|
@@ -56401,6 +56427,14 @@ function computeDateRange(id) {
|
|
|
56401
56427
|
return { startDate: startOfMonth(sub(now, { years: 1 })), endDate: endOfMonth(now) };
|
|
56402
56428
|
case "last-5-years":
|
|
56403
56429
|
return { startDate: startOfMonth(sub(now, { years: 5 })), endDate: endOfMonth(now) };
|
|
56430
|
+
case "last-1-hour":
|
|
56431
|
+
return { startDate: sub(now, { hours: 1 }), endDate: now };
|
|
56432
|
+
case "last-24-hours":
|
|
56433
|
+
return { startDate: sub(now, { hours: 24 }), endDate: now };
|
|
56434
|
+
case "past-7-days":
|
|
56435
|
+
return { startDate: sub(now, { days: 7 }), endDate: now };
|
|
56436
|
+
case "past-30-days":
|
|
56437
|
+
return { startDate: sub(now, { days: 30 }), endDate: now };
|
|
56404
56438
|
}
|
|
56405
56439
|
}
|
|
56406
56440
|
var DEFAULT_DATE_FORMAT = "dd MMM yyyy";
|
|
@@ -56436,6 +56470,9 @@ function DateRangePicker({
|
|
|
56436
56470
|
selectedPresetId,
|
|
56437
56471
|
selectedStartDate,
|
|
56438
56472
|
selectedEndDate,
|
|
56473
|
+
clearable = false,
|
|
56474
|
+
clearLabel = "Clear",
|
|
56475
|
+
onClear,
|
|
56439
56476
|
trigger,
|
|
56440
56477
|
placeholder = "Select date range",
|
|
56441
56478
|
label,
|
|
@@ -56577,7 +56614,12 @@ function DateRangePicker({
|
|
|
56577
56614
|
if (lockEndToToday) return;
|
|
56578
56615
|
setEndInputValue(draftRange.endDate ? format(draftRange.endDate, dateFormat) : "");
|
|
56579
56616
|
};
|
|
56617
|
+
const handleClear = () => {
|
|
56618
|
+
onClear?.();
|
|
56619
|
+
handleOpenChange(false);
|
|
56620
|
+
};
|
|
56580
56621
|
const displayValue = selectedPresetId ? resolveLabel(selectedPresetId) : "";
|
|
56622
|
+
const hasSelection = !!(selectedPresetId || selectedStartDate);
|
|
56581
56623
|
const inputTrigger = /* @__PURE__ */ jsx(
|
|
56582
56624
|
Input,
|
|
56583
56625
|
{
|
|
@@ -56673,6 +56715,22 @@ function DateRangePicker({
|
|
|
56673
56715
|
]
|
|
56674
56716
|
}
|
|
56675
56717
|
)
|
|
56718
|
+
] }),
|
|
56719
|
+
clearable && hasSelection && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
56720
|
+
/* @__PURE__ */ jsx("div", { className: "mx-1 my-1 h-px bg-border" }),
|
|
56721
|
+
/* @__PURE__ */ jsxs(
|
|
56722
|
+
"button",
|
|
56723
|
+
{
|
|
56724
|
+
type: "button",
|
|
56725
|
+
onClick: handleClear,
|
|
56726
|
+
onMouseEnter: () => setShowCalendar(false),
|
|
56727
|
+
className: "flex w-full items-center justify-between gap-6 px-3 py-1.5 text-left text-sm text-muted-foreground hover:bg-accent",
|
|
56728
|
+
children: [
|
|
56729
|
+
clearLabel,
|
|
56730
|
+
/* @__PURE__ */ jsx(XIcon, { className: "size-4 shrink-0" })
|
|
56731
|
+
]
|
|
56732
|
+
}
|
|
56733
|
+
)
|
|
56676
56734
|
] })
|
|
56677
56735
|
] }),
|
|
56678
56736
|
allowCustom && showCalendar && /* @__PURE__ */ jsx(
|
|
@@ -57451,17 +57509,21 @@ function DataTable({
|
|
|
57451
57509
|
() => enableRowSelection ? [selectColumn, ...columns] : columns,
|
|
57452
57510
|
[enableRowSelection, selectColumn, columns]
|
|
57453
57511
|
);
|
|
57512
|
+
const pagination = useMemo(() => ({ pageIndex: 0, pageSize }), [pageSize]);
|
|
57454
57513
|
const table = useReactTable({
|
|
57455
57514
|
data: data2,
|
|
57456
57515
|
columns: tableColumns,
|
|
57457
57516
|
state: {
|
|
57458
57517
|
columnVisibility,
|
|
57459
|
-
pagination
|
|
57460
|
-
pageIndex: 0,
|
|
57461
|
-
pageSize
|
|
57462
|
-
},
|
|
57518
|
+
pagination,
|
|
57463
57519
|
...rowSelection !== void 0 && { rowSelection }
|
|
57464
57520
|
},
|
|
57521
|
+
// With `manualPagination` unset, TanStack resets pageIndex (an internal
|
|
57522
|
+
// setState + re-render) whenever `data` changes identity. pageIndex is pinned
|
|
57523
|
+
// to 0 here, so that reset is a no-op; with consumers that pass a fresh array
|
|
57524
|
+
// each render (`data?.items ?? []`) it can loop into "Maximum update depth
|
|
57525
|
+
// exceeded".
|
|
57526
|
+
autoResetPageIndex: false,
|
|
57465
57527
|
onColumnVisibilityChange: setColumnVisibility,
|
|
57466
57528
|
enableRowSelection,
|
|
57467
57529
|
enableMultiRowSelection,
|
|
@@ -57851,8 +57913,8 @@ function DeviceIcon({ type, size = 18, color, fallback: Fallback, className }) {
|
|
|
57851
57913
|
const Matched = matchDevice(type);
|
|
57852
57914
|
const Icon2 = Matched ?? Fallback;
|
|
57853
57915
|
if (!Icon2) return null;
|
|
57854
|
-
const
|
|
57855
|
-
return /* @__PURE__ */ jsx("span", { className: cn("inline-flex",
|
|
57916
|
+
const resolved2 = color ? resolveColor(color, "text") : void 0;
|
|
57917
|
+
return /* @__PURE__ */ jsx("span", { className: cn("inline-flex", resolved2?.className, className), style: resolved2?.style, children: /* @__PURE__ */ jsx(Icon2, { size }) });
|
|
57856
57918
|
}
|
|
57857
57919
|
var userTypeBadgeRegistry = {
|
|
57858
57920
|
admin: {
|
|
@@ -60029,6 +60091,8 @@ function getHighlighter() {
|
|
|
60029
60091
|
function normalizeLang(lang) {
|
|
60030
60092
|
return LANG_ALIASES[lang.toLowerCase()] ?? lang;
|
|
60031
60093
|
}
|
|
60094
|
+
|
|
60095
|
+
// src/core/animate-ui/primitives/animate/escape-html.ts
|
|
60032
60096
|
function escapeHtml(input) {
|
|
60033
60097
|
return input.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
60034
60098
|
}
|
|
@@ -60156,6 +60220,33 @@ function CodeBlock({
|
|
|
60156
60220
|
}
|
|
60157
60221
|
);
|
|
60158
60222
|
}
|
|
60223
|
+
function CodeHeader({ icon: Icon2, fileName, copyContent, copyLabel = "Copy", actions }) {
|
|
60224
|
+
const copyButton = copyContent !== void 0 && /* @__PURE__ */ jsx(
|
|
60225
|
+
CopyButton,
|
|
60226
|
+
{
|
|
60227
|
+
content: copyContent,
|
|
60228
|
+
size: "sm",
|
|
60229
|
+
variant: "ghost",
|
|
60230
|
+
"aria-label": copyLabel,
|
|
60231
|
+
title: copyLabel,
|
|
60232
|
+
className: cn(actions == null && "ml-auto", "w-auto h-auto p-2 -mr-2")
|
|
60233
|
+
}
|
|
60234
|
+
);
|
|
60235
|
+
return /* @__PURE__ */ jsxs(
|
|
60236
|
+
"div",
|
|
60237
|
+
{
|
|
60238
|
+
className: "shrink-0 gap-x-2 border-b border-border/75 dark:border-border/50 text-sm flex text-muted-foreground items-center px-4 w-full h-10 font-medium",
|
|
60239
|
+
children: [
|
|
60240
|
+
Icon2 && /* @__PURE__ */ jsx(Icon2, { className: "size-4" }),
|
|
60241
|
+
fileName,
|
|
60242
|
+
actions != null ? /* @__PURE__ */ jsxs("div", { className: "ml-auto flex items-center gap-1", children: [
|
|
60243
|
+
actions,
|
|
60244
|
+
copyButton
|
|
60245
|
+
] }) : copyButton
|
|
60246
|
+
]
|
|
60247
|
+
}
|
|
60248
|
+
);
|
|
60249
|
+
}
|
|
60159
60250
|
function Code({
|
|
60160
60251
|
className,
|
|
60161
60252
|
code,
|
|
@@ -60182,23 +60273,12 @@ function Code({
|
|
|
60182
60273
|
style: { height: height2, ...style },
|
|
60183
60274
|
...props,
|
|
60184
60275
|
children: [
|
|
60185
|
-
showHeader && /* @__PURE__ */
|
|
60186
|
-
|
|
60276
|
+
showHeader && /* @__PURE__ */ jsx(
|
|
60277
|
+
CodeHeader,
|
|
60187
60278
|
{
|
|
60188
|
-
|
|
60189
|
-
|
|
60190
|
-
|
|
60191
|
-
fileName,
|
|
60192
|
-
showCopyButton && /* @__PURE__ */ jsx(
|
|
60193
|
-
CopyButton,
|
|
60194
|
-
{
|
|
60195
|
-
content: code,
|
|
60196
|
-
size: "sm",
|
|
60197
|
-
variant: "ghost",
|
|
60198
|
-
className: "ml-auto w-auto h-auto p-2 -mr-2"
|
|
60199
|
-
}
|
|
60200
|
-
)
|
|
60201
|
-
]
|
|
60279
|
+
icon: Icon2,
|
|
60280
|
+
fileName,
|
|
60281
|
+
copyContent: showCopyButton ? code : void 0
|
|
60202
60282
|
}
|
|
60203
60283
|
),
|
|
60204
60284
|
lang && /* @__PURE__ */ jsx(
|
|
@@ -61017,14 +61097,79 @@ function DynamicList({
|
|
|
61017
61097
|
);
|
|
61018
61098
|
}) });
|
|
61019
61099
|
}
|
|
61100
|
+
function KeyValueManagerField({
|
|
61101
|
+
field,
|
|
61102
|
+
label,
|
|
61103
|
+
value: value2,
|
|
61104
|
+
meta,
|
|
61105
|
+
error,
|
|
61106
|
+
errorMessage,
|
|
61107
|
+
selectPlaceholder,
|
|
61108
|
+
onChange
|
|
61109
|
+
}) {
|
|
61110
|
+
const errorContent = error ? errorMessage : void 0;
|
|
61111
|
+
if (meta?.options) {
|
|
61112
|
+
return (
|
|
61113
|
+
// Remounted when cleared: a Radix Select can't show its placeholder again once it held a value.
|
|
61114
|
+
/* @__PURE__ */ jsxs(
|
|
61115
|
+
Select,
|
|
61116
|
+
{
|
|
61117
|
+
value: value2 || void 0,
|
|
61118
|
+
onValueChange: onChange,
|
|
61119
|
+
children: [
|
|
61120
|
+
/* @__PURE__ */ jsx(
|
|
61121
|
+
SelectTrigger,
|
|
61122
|
+
{
|
|
61123
|
+
label,
|
|
61124
|
+
size: "sm",
|
|
61125
|
+
error,
|
|
61126
|
+
errorContent,
|
|
61127
|
+
children: /* @__PURE__ */ jsx(SelectValue, { placeholder: selectPlaceholder })
|
|
61128
|
+
}
|
|
61129
|
+
),
|
|
61130
|
+
/* @__PURE__ */ jsx(SelectContent, { children: meta.options.map((option) => /* @__PURE__ */ jsx(SelectItem, { value: option, children: option }, option)) })
|
|
61131
|
+
]
|
|
61132
|
+
},
|
|
61133
|
+
value2 ? "selected" : "empty"
|
|
61134
|
+
)
|
|
61135
|
+
);
|
|
61136
|
+
}
|
|
61137
|
+
if (field === "key") {
|
|
61138
|
+
return /* @__PURE__ */ jsx(
|
|
61139
|
+
Input,
|
|
61140
|
+
{
|
|
61141
|
+
label,
|
|
61142
|
+
value: value2,
|
|
61143
|
+
charLimit: meta?.maxLength,
|
|
61144
|
+
error,
|
|
61145
|
+
size: "sm",
|
|
61146
|
+
errorContent,
|
|
61147
|
+
onChange: (e) => onChange(e.target.value)
|
|
61148
|
+
}
|
|
61149
|
+
);
|
|
61150
|
+
}
|
|
61151
|
+
return /* @__PURE__ */ jsx(
|
|
61152
|
+
Textarea,
|
|
61153
|
+
{
|
|
61154
|
+
label,
|
|
61155
|
+
value: value2,
|
|
61156
|
+
charLimit: meta?.maxLength,
|
|
61157
|
+
error,
|
|
61158
|
+
errorContent,
|
|
61159
|
+
onChange: (e) => onChange(e.target.value),
|
|
61160
|
+
size: "sm"
|
|
61161
|
+
}
|
|
61162
|
+
);
|
|
61163
|
+
}
|
|
61020
61164
|
|
|
61021
61165
|
// src/components/key-value-manager/key-value-manager.utils.ts
|
|
61022
61166
|
function validateField(value2, meta) {
|
|
61023
61167
|
if (!value2.trim()) return false;
|
|
61024
61168
|
if (meta?.maxLength != null && value2.length > meta.maxLength) return false;
|
|
61169
|
+
if (meta?.options && !meta.options.includes(value2)) return false;
|
|
61025
61170
|
if (meta?.regex) {
|
|
61026
61171
|
try {
|
|
61027
|
-
if (!new RegExp(meta.regex).test(value2)) return false;
|
|
61172
|
+
if (!new RegExp(meta.regex, meta.regexFlags).test(value2)) return false;
|
|
61028
61173
|
} catch {
|
|
61029
61174
|
}
|
|
61030
61175
|
}
|
|
@@ -61113,27 +61258,29 @@ function KeyValueManagerAddPopover({
|
|
|
61113
61258
|
) }),
|
|
61114
61259
|
/* @__PURE__ */ jsxs(PopoverContent, { align: "end", className: "w-80 space-y-4", children: [
|
|
61115
61260
|
/* @__PURE__ */ jsx(
|
|
61116
|
-
|
|
61261
|
+
KeyValueManagerField,
|
|
61117
61262
|
{
|
|
61263
|
+
field: "key",
|
|
61118
61264
|
label: labels.keyLabel,
|
|
61119
61265
|
value: draftKey,
|
|
61120
|
-
|
|
61266
|
+
meta: meta?.key,
|
|
61121
61267
|
error: keyError,
|
|
61122
|
-
|
|
61123
|
-
|
|
61124
|
-
onChange: (
|
|
61268
|
+
errorMessage: labels.keyErrorMessage,
|
|
61269
|
+
selectPlaceholder: labels.selectPlaceholder,
|
|
61270
|
+
onChange: (value2) => handleFieldChange("key", value2)
|
|
61125
61271
|
}
|
|
61126
61272
|
),
|
|
61127
61273
|
/* @__PURE__ */ jsx(
|
|
61128
|
-
|
|
61274
|
+
KeyValueManagerField,
|
|
61129
61275
|
{
|
|
61276
|
+
field: "value",
|
|
61130
61277
|
label: labels.valueLabel,
|
|
61131
61278
|
value: draftValue,
|
|
61132
|
-
|
|
61279
|
+
meta: meta?.value,
|
|
61133
61280
|
error: valueError,
|
|
61134
|
-
|
|
61135
|
-
|
|
61136
|
-
|
|
61281
|
+
errorMessage: labels.valueErrorMessage,
|
|
61282
|
+
selectPlaceholder: labels.selectPlaceholder,
|
|
61283
|
+
onChange: (value2) => handleFieldChange("value", value2)
|
|
61137
61284
|
}
|
|
61138
61285
|
),
|
|
61139
61286
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
@@ -61296,7 +61443,8 @@ var STATIC_DEFAULT_LABELS = {
|
|
|
61296
61443
|
valueLabel: "Value",
|
|
61297
61444
|
actionLabel: "Action",
|
|
61298
61445
|
emptyItems: "No items",
|
|
61299
|
-
emptySearch: "No matches"
|
|
61446
|
+
emptySearch: "No matches",
|
|
61447
|
+
selectPlaceholder: "Select"
|
|
61300
61448
|
};
|
|
61301
61449
|
function resolveKeyValueManagerLabels(labels) {
|
|
61302
61450
|
const merged = { ...STATIC_DEFAULT_LABELS, ...labels };
|
|
@@ -68108,6 +68256,506 @@ var SimpleInfoCard = React10.forwardRef(
|
|
|
68108
68256
|
}
|
|
68109
68257
|
);
|
|
68110
68258
|
SimpleInfoCard.displayName = "SimpleInfoCard";
|
|
68259
|
+
|
|
68260
|
+
// src/components/code-editor/code-editor.utils.ts
|
|
68261
|
+
function getLineStart(value2, pos) {
|
|
68262
|
+
return value2.lastIndexOf("\n", pos - 1) + 1;
|
|
68263
|
+
}
|
|
68264
|
+
function getLineEnd(value2, pos) {
|
|
68265
|
+
const next = value2.indexOf("\n", pos);
|
|
68266
|
+
return next === -1 ? value2.length : next;
|
|
68267
|
+
}
|
|
68268
|
+
function getLineIndent(value2, pos) {
|
|
68269
|
+
const lineStart = getLineStart(value2, pos);
|
|
68270
|
+
return /^[ \t]*/.exec(value2.slice(lineStart, pos))[0];
|
|
68271
|
+
}
|
|
68272
|
+
function isMultiLineSelection(value2, start, end) {
|
|
68273
|
+
return value2.slice(start, end).includes("\n");
|
|
68274
|
+
}
|
|
68275
|
+
function getSelectedLineStarts(value2, start, end) {
|
|
68276
|
+
const lastPos = end > start && value2[end - 1] === "\n" ? end - 1 : end;
|
|
68277
|
+
const starts = [getLineStart(value2, start)];
|
|
68278
|
+
for (let i = value2.indexOf("\n", starts[0]); i !== -1 && i < lastPos; i = value2.indexOf("\n", i + 1)) {
|
|
68279
|
+
starts.push(i + 1);
|
|
68280
|
+
}
|
|
68281
|
+
return starts;
|
|
68282
|
+
}
|
|
68283
|
+
function insertTab(value2, start, end, tabSize) {
|
|
68284
|
+
const column = start - getLineStart(value2, start);
|
|
68285
|
+
const text2 = " ".repeat(tabSize - column % tabSize);
|
|
68286
|
+
const caret = start + text2.length;
|
|
68287
|
+
return { start, end, text: text2, selectionStart: caret, selectionEnd: caret };
|
|
68288
|
+
}
|
|
68289
|
+
function indentLines(value2, start, end, tabSize) {
|
|
68290
|
+
const lineStarts = getSelectedLineStarts(value2, start, end);
|
|
68291
|
+
const blockStart = lineStarts[0];
|
|
68292
|
+
const blockEnd = getLineEnd(value2, lineStarts[lineStarts.length - 1]);
|
|
68293
|
+
const indent = " ".repeat(tabSize);
|
|
68294
|
+
const added = lineStarts.map(
|
|
68295
|
+
(lineStart) => lineStart === getLineEnd(value2, lineStart) ? 0 : tabSize
|
|
68296
|
+
);
|
|
68297
|
+
const lines = value2.slice(blockStart, blockEnd).split("\n");
|
|
68298
|
+
const text2 = lines.map((line, i) => added[i] ? indent + line : line).join("\n");
|
|
68299
|
+
const mapOffset = (pos, keepAtLineStart) => {
|
|
68300
|
+
let shift = 0;
|
|
68301
|
+
lineStarts.forEach((lineStart, i) => {
|
|
68302
|
+
if (lineStart < pos || lineStart === pos && !keepAtLineStart) shift += added[i];
|
|
68303
|
+
});
|
|
68304
|
+
return pos + shift;
|
|
68305
|
+
};
|
|
68306
|
+
return {
|
|
68307
|
+
start: blockStart,
|
|
68308
|
+
end: blockEnd,
|
|
68309
|
+
text: text2,
|
|
68310
|
+
// A selection starting at column 0 keeps starting there, so the new indentation is selected too.
|
|
68311
|
+
selectionStart: mapOffset(start, true),
|
|
68312
|
+
selectionEnd: mapOffset(end, false)
|
|
68313
|
+
};
|
|
68314
|
+
}
|
|
68315
|
+
function outdentLines(value2, start, end, tabSize) {
|
|
68316
|
+
const lineStarts = getSelectedLineStarts(value2, start, end);
|
|
68317
|
+
const blockStart = lineStarts[0];
|
|
68318
|
+
const blockEnd = getLineEnd(value2, lineStarts[lineStarts.length - 1]);
|
|
68319
|
+
const lines = value2.slice(blockStart, blockEnd).split("\n");
|
|
68320
|
+
const removed = lines.map(
|
|
68321
|
+
(line) => line.startsWith(" ") ? 1 : Math.min(tabSize, /^ */.exec(line)[0].length)
|
|
68322
|
+
);
|
|
68323
|
+
const text2 = lines.map((line, i) => line.slice(removed[i])).join("\n");
|
|
68324
|
+
const mapOffset = (pos) => {
|
|
68325
|
+
let shift = 0;
|
|
68326
|
+
lineStarts.forEach((lineStart, i) => {
|
|
68327
|
+
if (lineStart <= pos) shift += Math.min(removed[i], pos - lineStart);
|
|
68328
|
+
});
|
|
68329
|
+
return pos - shift;
|
|
68330
|
+
};
|
|
68331
|
+
return {
|
|
68332
|
+
start: blockStart,
|
|
68333
|
+
end: blockEnd,
|
|
68334
|
+
text: text2,
|
|
68335
|
+
selectionStart: mapOffset(start),
|
|
68336
|
+
selectionEnd: mapOffset(end)
|
|
68337
|
+
};
|
|
68338
|
+
}
|
|
68339
|
+
function insertNewline(value2, start, end) {
|
|
68340
|
+
const text2 = "\n" + getLineIndent(value2, start);
|
|
68341
|
+
const caret = start + text2.length;
|
|
68342
|
+
return { start, end, text: text2, selectionStart: caret, selectionEnd: caret };
|
|
68343
|
+
}
|
|
68344
|
+
function applyTextEdit(value2, edit) {
|
|
68345
|
+
return value2.slice(0, edit.start) + edit.text + value2.slice(edit.end);
|
|
68346
|
+
}
|
|
68347
|
+
function formatJson(value2, tabSize) {
|
|
68348
|
+
return JSON.stringify(JSON.parse(value2), null, tabSize);
|
|
68349
|
+
}
|
|
68350
|
+
function getBuiltInFormatter(lang) {
|
|
68351
|
+
return lang.toLowerCase() === "json" ? formatJson : void 0;
|
|
68352
|
+
}
|
|
68353
|
+
function applyEdit(el, edit) {
|
|
68354
|
+
const current = el.value;
|
|
68355
|
+
const expected = applyTextEdit(current, edit);
|
|
68356
|
+
if (expected === current) {
|
|
68357
|
+
el.setSelectionRange(edit.selectionStart, edit.selectionEnd);
|
|
68358
|
+
return;
|
|
68359
|
+
}
|
|
68360
|
+
if (el.ownerDocument.activeElement !== el) el.focus({ preventScroll: true });
|
|
68361
|
+
el.setSelectionRange(edit.start, edit.end);
|
|
68362
|
+
let applied = false;
|
|
68363
|
+
try {
|
|
68364
|
+
applied = typeof document.execCommand === "function" && document.execCommand(edit.text ? "insertText" : "delete", false, edit.text);
|
|
68365
|
+
} catch {
|
|
68366
|
+
applied = false;
|
|
68367
|
+
}
|
|
68368
|
+
if (!applied || el.value !== expected) {
|
|
68369
|
+
if (el.value !== current) el.value = current;
|
|
68370
|
+
el.setRangeText(edit.text, edit.start, edit.end, "end");
|
|
68371
|
+
el.dispatchEvent(new Event("input", { bubbles: true }));
|
|
68372
|
+
}
|
|
68373
|
+
el.setSelectionRange(edit.selectionStart, edit.selectionEnd);
|
|
68374
|
+
}
|
|
68375
|
+
function useCodeEditorKeys({ tabSize, onKeyDown, onBlur }) {
|
|
68376
|
+
const tabReleasedRef = React10.useRef(false);
|
|
68377
|
+
const handleKeyDown = React10.useCallback(
|
|
68378
|
+
(event) => {
|
|
68379
|
+
onKeyDown?.(event);
|
|
68380
|
+
if (event.defaultPrevented) return;
|
|
68381
|
+
if (event.nativeEvent.isComposing || event.keyCode === 229) return;
|
|
68382
|
+
const el = event.currentTarget;
|
|
68383
|
+
if (el.readOnly || el.disabled) return;
|
|
68384
|
+
if (event.key === "Escape") {
|
|
68385
|
+
tabReleasedRef.current = true;
|
|
68386
|
+
return;
|
|
68387
|
+
}
|
|
68388
|
+
if (event.key === "Shift") return;
|
|
68389
|
+
const released = tabReleasedRef.current;
|
|
68390
|
+
tabReleasedRef.current = false;
|
|
68391
|
+
const { value: value2, selectionStart: start, selectionEnd: end } = el;
|
|
68392
|
+
if (event.key === "Tab") {
|
|
68393
|
+
if (released || event.altKey || event.ctrlKey || event.metaKey) return;
|
|
68394
|
+
event.preventDefault();
|
|
68395
|
+
if (event.shiftKey) {
|
|
68396
|
+
applyEdit(el, outdentLines(value2, start, end, tabSize));
|
|
68397
|
+
} else if (isMultiLineSelection(value2, start, end)) {
|
|
68398
|
+
applyEdit(el, indentLines(value2, start, end, tabSize));
|
|
68399
|
+
} else {
|
|
68400
|
+
applyEdit(el, insertTab(value2, start, end, tabSize));
|
|
68401
|
+
}
|
|
68402
|
+
return;
|
|
68403
|
+
}
|
|
68404
|
+
if (event.key === "Enter" && !event.shiftKey && !event.altKey && !event.ctrlKey && !event.metaKey) {
|
|
68405
|
+
event.preventDefault();
|
|
68406
|
+
applyEdit(el, insertNewline(value2, start, end));
|
|
68407
|
+
}
|
|
68408
|
+
},
|
|
68409
|
+
[onKeyDown, tabSize]
|
|
68410
|
+
);
|
|
68411
|
+
const handleBlur = React10.useCallback(
|
|
68412
|
+
(event) => {
|
|
68413
|
+
tabReleasedRef.current = false;
|
|
68414
|
+
onBlur?.(event);
|
|
68415
|
+
},
|
|
68416
|
+
[onBlur]
|
|
68417
|
+
);
|
|
68418
|
+
return { onKeyDown: handleKeyDown, onBlur: handleBlur };
|
|
68419
|
+
}
|
|
68420
|
+
var DEFAULT_CODE_EDITOR_THEMES = {
|
|
68421
|
+
light: "everforest-light",
|
|
68422
|
+
dark: "everforest-dark"
|
|
68423
|
+
};
|
|
68424
|
+
var PLAIN_LANGS = /* @__PURE__ */ new Set(["text", "plaintext", "txt", "plain"]);
|
|
68425
|
+
var TRAILING_LINE = "\u200B";
|
|
68426
|
+
var transformer = {
|
|
68427
|
+
// Shiki makes its `<pre>` focusable; this one sits in an `aria-hidden` layer.
|
|
68428
|
+
pre(node) {
|
|
68429
|
+
delete node.properties.tabindex;
|
|
68430
|
+
},
|
|
68431
|
+
code(node) {
|
|
68432
|
+
node.children.push({ type: "text", value: TRAILING_LINE });
|
|
68433
|
+
}
|
|
68434
|
+
};
|
|
68435
|
+
function plainHtml(value2) {
|
|
68436
|
+
return `<pre><code>${escapeHtml(value2)}${TRAILING_LINE}</code></pre>`;
|
|
68437
|
+
}
|
|
68438
|
+
var warned = /* @__PURE__ */ new Set();
|
|
68439
|
+
function warnOnce(key2, message, error) {
|
|
68440
|
+
if (warned.has(key2)) return;
|
|
68441
|
+
warned.add(key2);
|
|
68442
|
+
console.warn(`[dashboard-ui-components] ${message}`, ...error ? [error] : []);
|
|
68443
|
+
}
|
|
68444
|
+
var resolved = /* @__PURE__ */ new WeakMap();
|
|
68445
|
+
function useHighlightedHtml(value2, { lang, theme, themes, maxHighlightLength }) {
|
|
68446
|
+
const [highlighter, setHighlighter] = React10.useState(() => {
|
|
68447
|
+
const promise = getHighlighter();
|
|
68448
|
+
return resolved.get(promise) ?? null;
|
|
68449
|
+
});
|
|
68450
|
+
React10.useEffect(() => {
|
|
68451
|
+
if (highlighter) return;
|
|
68452
|
+
let active2 = true;
|
|
68453
|
+
const promise = getHighlighter();
|
|
68454
|
+
promise.then(
|
|
68455
|
+
(loaded) => {
|
|
68456
|
+
resolved.set(promise, loaded);
|
|
68457
|
+
if (active2) setHighlighter(loaded);
|
|
68458
|
+
},
|
|
68459
|
+
(error) => warnOnce("load", "Syntax highlighter failed to load; showing plain text.", error)
|
|
68460
|
+
);
|
|
68461
|
+
return () => {
|
|
68462
|
+
active2 = false;
|
|
68463
|
+
};
|
|
68464
|
+
}, [highlighter]);
|
|
68465
|
+
const deferredValue = React10.useDeferredValue(value2);
|
|
68466
|
+
const { light, dark } = themes;
|
|
68467
|
+
return React10.useMemo(() => {
|
|
68468
|
+
if (!highlighter || deferredValue.length > maxHighlightLength) {
|
|
68469
|
+
return plainHtml(deferredValue);
|
|
68470
|
+
}
|
|
68471
|
+
const normalizedLang = normalizeLang(lang);
|
|
68472
|
+
if (!PLAIN_LANGS.has(normalizedLang) && !highlighter.getLoadedLanguages().includes(normalizedLang)) {
|
|
68473
|
+
warnOnce(
|
|
68474
|
+
`lang:${lang}`,
|
|
68475
|
+
`Falling back to plain text for lang="${lang}"; not in the curated Shiki bundle.`
|
|
68476
|
+
);
|
|
68477
|
+
return plainHtml(deferredValue);
|
|
68478
|
+
}
|
|
68479
|
+
try {
|
|
68480
|
+
return highlighter.codeToHtml(deferredValue, {
|
|
68481
|
+
lang: normalizedLang,
|
|
68482
|
+
themes: { light, dark },
|
|
68483
|
+
defaultColor: theme,
|
|
68484
|
+
transformers: [transformer]
|
|
68485
|
+
});
|
|
68486
|
+
} catch (error) {
|
|
68487
|
+
warnOnce(
|
|
68488
|
+
`theme:${light}:${dark}:${lang}`,
|
|
68489
|
+
`Falling back to plain text for themes "${light}" / "${dark}" with lang="${lang}".`,
|
|
68490
|
+
error
|
|
68491
|
+
);
|
|
68492
|
+
return plainHtml(deferredValue);
|
|
68493
|
+
}
|
|
68494
|
+
}, [highlighter, deferredValue, lang, theme, light, dark, maxHighlightLength]);
|
|
68495
|
+
}
|
|
68496
|
+
var layerClassName = "col-start-1 row-start-1 m-0 box-border border-0 p-4 font-mono text-[16px] leading-normal tracking-normal [font-variant-ligatures:none] md:text-[13px]";
|
|
68497
|
+
var highlightClassName = "[&_pre]:m-0 [&_pre]:p-0 [&_pre]:!bg-transparent [&_pre]:[font:inherit] [&_pre]:[white-space:inherit] [&_pre]:[overflow-wrap:inherit] [&_code]:[font:inherit]";
|
|
68498
|
+
function observeValueWrites(node, onWrite) {
|
|
68499
|
+
const own = Object.getOwnPropertyDescriptor(node, "value");
|
|
68500
|
+
const base = own ?? Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype, "value");
|
|
68501
|
+
if (!base?.get || !base.set || own && !own.configurable) return () => {
|
|
68502
|
+
};
|
|
68503
|
+
const { get, set: set2 } = base;
|
|
68504
|
+
Object.defineProperty(node, "value", {
|
|
68505
|
+
configurable: true,
|
|
68506
|
+
enumerable: base.enumerable,
|
|
68507
|
+
get() {
|
|
68508
|
+
return get.call(this);
|
|
68509
|
+
},
|
|
68510
|
+
set(next) {
|
|
68511
|
+
set2.call(this, next);
|
|
68512
|
+
onWrite(get.call(this));
|
|
68513
|
+
}
|
|
68514
|
+
});
|
|
68515
|
+
const form = node.form;
|
|
68516
|
+
const handleReset = () => setTimeout(() => onWrite(node.value));
|
|
68517
|
+
form?.addEventListener("reset", handleReset);
|
|
68518
|
+
return () => {
|
|
68519
|
+
form?.removeEventListener("reset", handleReset);
|
|
68520
|
+
if (own) Object.defineProperty(node, "value", own);
|
|
68521
|
+
else delete node.value;
|
|
68522
|
+
};
|
|
68523
|
+
}
|
|
68524
|
+
function hasContent(node) {
|
|
68525
|
+
return node != null && node !== false && node !== "";
|
|
68526
|
+
}
|
|
68527
|
+
function toCssSize(size) {
|
|
68528
|
+
return typeof size === "number" ? `${size}px` : size;
|
|
68529
|
+
}
|
|
68530
|
+
var CodeEditor = React10.forwardRef(
|
|
68531
|
+
({
|
|
68532
|
+
className,
|
|
68533
|
+
style,
|
|
68534
|
+
lang = "json",
|
|
68535
|
+
theme = "light",
|
|
68536
|
+
themes = DEFAULT_CODE_EDITOR_THEMES,
|
|
68537
|
+
hideHeader = false,
|
|
68538
|
+
fileName,
|
|
68539
|
+
icon,
|
|
68540
|
+
copyButton = true,
|
|
68541
|
+
formatButton,
|
|
68542
|
+
formatter,
|
|
68543
|
+
onFormatError,
|
|
68544
|
+
formatLabel = "Format",
|
|
68545
|
+
copyLabel,
|
|
68546
|
+
headerActions,
|
|
68547
|
+
label,
|
|
68548
|
+
required,
|
|
68549
|
+
hintContent,
|
|
68550
|
+
error,
|
|
68551
|
+
errorContent,
|
|
68552
|
+
minHeight,
|
|
68553
|
+
maxHeight,
|
|
68554
|
+
wrap = false,
|
|
68555
|
+
tabSize = 2,
|
|
68556
|
+
maxHighlightLength = 1e4,
|
|
68557
|
+
id,
|
|
68558
|
+
value: value2,
|
|
68559
|
+
defaultValue,
|
|
68560
|
+
onChange,
|
|
68561
|
+
onKeyDown,
|
|
68562
|
+
onBlur,
|
|
68563
|
+
onScroll,
|
|
68564
|
+
disabled,
|
|
68565
|
+
readOnly,
|
|
68566
|
+
"aria-describedby": ariaDescribedBy,
|
|
68567
|
+
...textareaProps
|
|
68568
|
+
}, forwardedRef) => {
|
|
68569
|
+
const autoId = React10.useId();
|
|
68570
|
+
const textareaId = id || autoId;
|
|
68571
|
+
const errorId = `${textareaId}-error`;
|
|
68572
|
+
const hasError = error || !!errorContent;
|
|
68573
|
+
const isControlled = value2 !== void 0;
|
|
68574
|
+
const [innerValue, setInnerValue] = React10.useState(
|
|
68575
|
+
() => defaultValue == null ? "" : String(defaultValue)
|
|
68576
|
+
);
|
|
68577
|
+
const currentValue = isControlled ? String(value2 ?? "") : innerValue;
|
|
68578
|
+
const html = useHighlightedHtml(currentValue, {
|
|
68579
|
+
lang,
|
|
68580
|
+
theme,
|
|
68581
|
+
themes,
|
|
68582
|
+
maxHighlightLength
|
|
68583
|
+
});
|
|
68584
|
+
const keys = useCodeEditorKeys({ tabSize, onKeyDown, onBlur });
|
|
68585
|
+
const textareaRef = React10.useRef(null);
|
|
68586
|
+
const stopObservingRef = React10.useRef(void 0);
|
|
68587
|
+
const setTextareaRef = React10.useCallback(
|
|
68588
|
+
(node) => {
|
|
68589
|
+
textareaRef.current = node;
|
|
68590
|
+
stopObservingRef.current?.();
|
|
68591
|
+
stopObservingRef.current = void 0;
|
|
68592
|
+
if (node && !isControlled) {
|
|
68593
|
+
stopObservingRef.current = observeValueWrites(node, setInnerValue);
|
|
68594
|
+
setInnerValue(node.value);
|
|
68595
|
+
}
|
|
68596
|
+
if (typeof forwardedRef === "function") forwardedRef(node);
|
|
68597
|
+
else if (forwardedRef) forwardedRef.current = node;
|
|
68598
|
+
},
|
|
68599
|
+
[forwardedRef, isControlled]
|
|
68600
|
+
);
|
|
68601
|
+
const handleChange = (event) => {
|
|
68602
|
+
if (!isControlled) setInnerValue(event.target.value);
|
|
68603
|
+
onChange?.(event);
|
|
68604
|
+
};
|
|
68605
|
+
const handleScroll = (event) => {
|
|
68606
|
+
const el = event.currentTarget;
|
|
68607
|
+
if (el.scrollTop !== 0) el.scrollTop = 0;
|
|
68608
|
+
if (el.scrollLeft !== 0) el.scrollLeft = 0;
|
|
68609
|
+
onScroll?.(event);
|
|
68610
|
+
};
|
|
68611
|
+
const builtInFormatter = getBuiltInFormatter(lang);
|
|
68612
|
+
const format6 = formatter ?? (builtInFormatter && ((v) => builtInFormatter(v, tabSize)));
|
|
68613
|
+
const showFormatButton = formatButton !== false && format6 !== void 0;
|
|
68614
|
+
const handleFormat = () => {
|
|
68615
|
+
const el = textareaRef.current;
|
|
68616
|
+
if (!el || !format6) return;
|
|
68617
|
+
let formatted;
|
|
68618
|
+
try {
|
|
68619
|
+
formatted = format6(el.value);
|
|
68620
|
+
} catch (formatError) {
|
|
68621
|
+
onFormatError?.(formatError);
|
|
68622
|
+
return;
|
|
68623
|
+
}
|
|
68624
|
+
applyEdit(el, {
|
|
68625
|
+
start: 0,
|
|
68626
|
+
end: el.value.length,
|
|
68627
|
+
text: formatted,
|
|
68628
|
+
selectionStart: 0,
|
|
68629
|
+
selectionEnd: 0
|
|
68630
|
+
});
|
|
68631
|
+
};
|
|
68632
|
+
const describedBy = [ariaDescribedBy, errorContent ? errorId : void 0].filter(Boolean).join(" ") || void 0;
|
|
68633
|
+
const wrapClassName = wrap ? "whitespace-pre-wrap [overflow-wrap:anywhere]" : "whitespace-pre [overflow-wrap:normal]";
|
|
68634
|
+
const showHeader = !hideHeader && (hasContent(fileName) || copyButton || showFormatButton || hasContent(headerActions));
|
|
68635
|
+
const actions = hasContent(headerActions) || showFormatButton ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
68636
|
+
headerActions,
|
|
68637
|
+
showFormatButton && /* @__PURE__ */ jsx(
|
|
68638
|
+
"button",
|
|
68639
|
+
{
|
|
68640
|
+
type: "button",
|
|
68641
|
+
"data-slot": "code-editor-format",
|
|
68642
|
+
"aria-label": formatLabel,
|
|
68643
|
+
title: formatLabel,
|
|
68644
|
+
disabled: disabled || readOnly || currentValue.trim() === "",
|
|
68645
|
+
onClick: handleFormat,
|
|
68646
|
+
className: cn(buttonVariants$1({ variant: "ghost", size: "sm" }), "w-auto h-auto p-2"),
|
|
68647
|
+
children: /* @__PURE__ */ jsx(Braces, {})
|
|
68648
|
+
}
|
|
68649
|
+
)
|
|
68650
|
+
] }) : void 0;
|
|
68651
|
+
const editor = /* @__PURE__ */ jsxs(
|
|
68652
|
+
"div",
|
|
68653
|
+
{
|
|
68654
|
+
"data-slot": "code-editor",
|
|
68655
|
+
"data-disabled": disabled ? "" : void 0,
|
|
68656
|
+
className: cn(
|
|
68657
|
+
"relative flex flex-col overflow-hidden rounded-lg border bg-background ring-offset-background transition-[box-shadow,border-color] duration-200 ease-in-out",
|
|
68658
|
+
"has-[textarea:focus-visible]:ring-2 has-[textarea:focus-visible]:ring-ring has-[textarea:focus-visible]:ring-offset-2",
|
|
68659
|
+
hasError && "border-destructive has-[textarea:focus-visible]:ring-destructive",
|
|
68660
|
+
className
|
|
68661
|
+
),
|
|
68662
|
+
style,
|
|
68663
|
+
children: [
|
|
68664
|
+
showHeader && /* @__PURE__ */ jsx(
|
|
68665
|
+
CodeHeader,
|
|
68666
|
+
{
|
|
68667
|
+
icon,
|
|
68668
|
+
fileName,
|
|
68669
|
+
actions,
|
|
68670
|
+
copyContent: copyButton ? currentValue : void 0,
|
|
68671
|
+
copyLabel
|
|
68672
|
+
}
|
|
68673
|
+
),
|
|
68674
|
+
/* @__PURE__ */ jsx(
|
|
68675
|
+
"div",
|
|
68676
|
+
{
|
|
68677
|
+
className: cn(
|
|
68678
|
+
"relative min-h-0 flex-1 overflow-auto bg-accent/10",
|
|
68679
|
+
disabled && "cursor-not-allowed opacity-50"
|
|
68680
|
+
),
|
|
68681
|
+
style: { maxHeight: toCssSize(maxHeight) },
|
|
68682
|
+
children: /* @__PURE__ */ jsxs(
|
|
68683
|
+
"div",
|
|
68684
|
+
{
|
|
68685
|
+
className: cn("grid", wrap ? "w-full grid-cols-[minmax(0,1fr)]" : "w-max min-w-full"),
|
|
68686
|
+
style: { minHeight: toCssSize(minHeight), tabSize },
|
|
68687
|
+
children: [
|
|
68688
|
+
/* @__PURE__ */ jsxs("div", { "aria-hidden": true, className: cn(layerClassName, wrapClassName, "invisible"), children: [
|
|
68689
|
+
currentValue,
|
|
68690
|
+
"\u200B"
|
|
68691
|
+
] }),
|
|
68692
|
+
/* @__PURE__ */ jsx(
|
|
68693
|
+
"div",
|
|
68694
|
+
{
|
|
68695
|
+
"aria-hidden": true,
|
|
68696
|
+
className: cn(layerClassName, wrapClassName, highlightClassName, "pointer-events-none"),
|
|
68697
|
+
dangerouslySetInnerHTML: { __html: html }
|
|
68698
|
+
}
|
|
68699
|
+
),
|
|
68700
|
+
/* @__PURE__ */ jsx(
|
|
68701
|
+
"textarea",
|
|
68702
|
+
{
|
|
68703
|
+
id: textareaId,
|
|
68704
|
+
ref: setTextareaRef,
|
|
68705
|
+
value: value2,
|
|
68706
|
+
defaultValue,
|
|
68707
|
+
disabled,
|
|
68708
|
+
readOnly,
|
|
68709
|
+
required,
|
|
68710
|
+
wrap: wrap ? "soft" : "off",
|
|
68711
|
+
spellCheck: false,
|
|
68712
|
+
autoCapitalize: "off",
|
|
68713
|
+
autoComplete: "off",
|
|
68714
|
+
autoCorrect: "off",
|
|
68715
|
+
translate: "no",
|
|
68716
|
+
"data-gramm": "false",
|
|
68717
|
+
"aria-invalid": hasError || void 0,
|
|
68718
|
+
"aria-describedby": describedBy,
|
|
68719
|
+
...textareaProps,
|
|
68720
|
+
onChange: handleChange,
|
|
68721
|
+
onKeyDown: keys.onKeyDown,
|
|
68722
|
+
onBlur: keys.onBlur,
|
|
68723
|
+
onScroll: handleScroll,
|
|
68724
|
+
style: { tabSize },
|
|
68725
|
+
className: cn(
|
|
68726
|
+
layerClassName,
|
|
68727
|
+
wrapClassName,
|
|
68728
|
+
"relative z-10 h-full w-full resize-none overflow-hidden bg-transparent text-transparent caret-foreground outline-none [-webkit-text-fill-color:transparent]",
|
|
68729
|
+
"placeholder:text-muted-foreground placeholder:[-webkit-text-fill-color:var(--color-muted-foreground)] selection:bg-primary/20",
|
|
68730
|
+
"disabled:cursor-not-allowed read-only:cursor-default"
|
|
68731
|
+
)
|
|
68732
|
+
}
|
|
68733
|
+
)
|
|
68734
|
+
]
|
|
68735
|
+
}
|
|
68736
|
+
)
|
|
68737
|
+
}
|
|
68738
|
+
)
|
|
68739
|
+
]
|
|
68740
|
+
}
|
|
68741
|
+
);
|
|
68742
|
+
if (label == null && hintContent == null && errorContent == null) return editor;
|
|
68743
|
+
return /* @__PURE__ */ jsxs("div", { className: "space-y-2 flex-1", children: [
|
|
68744
|
+
label != null ? /* @__PURE__ */ jsx(
|
|
68745
|
+
FieldLabelRow,
|
|
68746
|
+
{
|
|
68747
|
+
htmlFor: textareaId,
|
|
68748
|
+
label,
|
|
68749
|
+
required,
|
|
68750
|
+
hintContent
|
|
68751
|
+
}
|
|
68752
|
+
) : hintContent != null && /* @__PURE__ */ jsx("span", { className: fieldHintClassName, children: hintContent }),
|
|
68753
|
+
editor,
|
|
68754
|
+
errorContent != null && /* @__PURE__ */ jsx("div", { id: errorId, className: "text-sm text-destructive", children: errorContent })
|
|
68755
|
+
] });
|
|
68756
|
+
}
|
|
68757
|
+
);
|
|
68758
|
+
CodeEditor.displayName = "CodeEditor";
|
|
68111
68759
|
var maxWidthClasses = {
|
|
68112
68760
|
sm: "max-w-2xl",
|
|
68113
68761
|
md: "max-w-4xl",
|
|
@@ -68288,4 +68936,4 @@ lottie-react/build/index.es.js:
|
|
|
68288
68936
|
(*! goToAndStop must be relative to the start of the current segment *)
|
|
68289
68937
|
*/
|
|
68290
68938
|
|
|
68291
|
-
export { Accordion3 as Accordion, AdvancedSearchBox, Alert, AnimatedCard, AnimatedRainmakerLogo, AreaChart, AsyncCombobox, AsyncMultiSelect, BarChart, BasicDetailsCard, CHART_CATEGORY_COLORS, CHART_SERIES_COLORS, Calendar, CalendarDayButton, Carousel2 as Carousel, ChartContainer, ChartLegend, ChartLegendContent, ChartStyle, ChartTooltip, ChartTooltipContent, Checkbox2 as Checkbox, CircularProgress, Code, CollapsibleCard, ComposedChart, ConfirmationDialog, ContentContainer, CopiableText, DEFAULT_CHART_SERIES_COLORS, DEFAULT_PAGE_SIZE_OPTIONS, DataTable, DatePicker, DateRangePicker, DateTimePicker, DeviceIcon, Dialog2 as Dialog, DialogClose2 as DialogClose, DialogContent2 as DialogContent, DialogDescription2 as DialogDescription, DialogFooter2 as DialogFooter, DialogHeader2 as DialogHeader, DialogTitle2 as DialogTitle, DialogTrigger2 as DialogTrigger, DonutChart, DynamicList, FileInput, FileUpload, Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, FullSizeError, FullscreenDialog, IconAvatar, IconTextActionCard, Illustration, InlineError, InputOTP, InputOTPSeparator, KeyValueManager, LineChart, ListDetails, LottieAnimationContainer, MarkdownContent, MonospaceContent, NavBar, OverflowBadgeList, PRESET_IDS, PRESET_LABELS, PageContainer, PageContainerSkeleton, Pagination, PopCollectionItem, PreviewCard2 as PreviewCard, PreviewCardBackdrop2 as PreviewCardBackdrop, PreviewCardPanel, PreviewCardTrigger2 as PreviewCardTrigger, ProgressBar, RadioGroup3 as RadioGroup, RequirementList, ScrollableSections, SearchBox, SectionCard, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, SelectableCardList, SimpleCard, SimpleClickableCard, SimpleInfoCard, SimpleList, SimplePaginatedList, SimplifiedDate, Spinner, StatCard, StatusBadge, StatusCardList, Switch2 as Switch, TYPOGRAPHY_VARIANTS, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, TableSkeleton, Tabs2 as Tabs, TabsContent2 as TabsContent, TabsContents2 as TabsContents, TabsList2 as TabsList, TabsTrigger2 as TabsTrigger, Tag, TagInput, Textarea, TimePicker, Toast, Toaster, TogglableItemsList, ToggleGroup2 as ToggleGroup, ToggleGroupItem2 as ToggleGroupItem, TransferList, TreemapChart, Typography, UserTypeBadge, VerificationInProgress, VerticalStepper, animatedCardAnimations, animatedCardTypeKeys, buildSeriesChartConfig, computeDateRange, getChartSeriesColor, illustrationRegistry, illustrationsById, no_data_card_default, parseSvgViewBoxAspectRatio, statusBadgeSizeVariants, toast, typographyDefaultElement, typographyVariantClasses, useFormField, userTypeBadgeRegistry, userTypeBadgeSizeVariants, userTypeBadgeUserTypes };
|
|
68939
|
+
export { Accordion3 as Accordion, AdvancedSearchBox, Alert, AnimatedCard, AnimatedRainmakerLogo, AreaChart, AsyncCombobox, AsyncMultiSelect, BarChart, BasicDetailsCard, CHART_CATEGORY_COLORS, CHART_SERIES_COLORS, Calendar, CalendarDayButton, Carousel2 as Carousel, ChartContainer, ChartLegend, ChartLegendContent, ChartStyle, ChartTooltip, ChartTooltipContent, Checkbox2 as Checkbox, CircularProgress, Code, CodeEditor, CollapsibleCard, ComposedChart, ConfirmationDialog, ContentContainer, CopiableText, DEFAULT_CHART_SERIES_COLORS, DEFAULT_PAGE_SIZE_OPTIONS, DataTable, DatePicker, DateRangePicker, DateTimePicker, DeviceIcon, Dialog2 as Dialog, DialogClose2 as DialogClose, DialogContent2 as DialogContent, DialogDescription2 as DialogDescription, DialogFooter2 as DialogFooter, DialogHeader2 as DialogHeader, DialogTitle2 as DialogTitle, DialogTrigger2 as DialogTrigger, DonutChart, DynamicList, FileInput, FileUpload, Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, FullSizeError, FullscreenDialog, IconAvatar, IconTextActionCard, Illustration, InlineError, InputOTP, InputOTPSeparator, KeyValueManager, LineChart, ListDetails, LottieAnimationContainer, MarkdownContent, MonospaceContent, NavBar, OverflowBadgeList, PRESET_IDS, PRESET_LABELS, PageContainer, PageContainerSkeleton, Pagination, PopCollectionItem, PreviewCard2 as PreviewCard, PreviewCardBackdrop2 as PreviewCardBackdrop, PreviewCardPanel, PreviewCardTrigger2 as PreviewCardTrigger, ProgressBar, ROLLING_PRESET_IDS, RadioGroup3 as RadioGroup, RequirementList, ScrollableSections, SearchBox, SectionCard, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, SelectableCardList, SimpleCard, SimpleClickableCard, SimpleInfoCard, SimpleList, SimplePaginatedList, SimplifiedDate, Spinner, StatCard, StatusBadge, StatusCardList, Switch2 as Switch, TYPOGRAPHY_VARIANTS, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, TableSkeleton, Tabs2 as Tabs, TabsContent2 as TabsContent, TabsContents2 as TabsContents, TabsList2 as TabsList, TabsTrigger2 as TabsTrigger, Tag, TagInput, Textarea, TimePicker, Toast, Toaster, TogglableItemsList, ToggleGroup2 as ToggleGroup, ToggleGroupItem2 as ToggleGroupItem, TransferList, TreemapChart, Typography, UserTypeBadge, VerificationInProgress, VerticalStepper, animatedCardAnimations, animatedCardTypeKeys, buildSeriesChartConfig, computeDateRange, getChartSeriesColor, illustrationRegistry, illustrationsById, no_data_card_default, parseSvgViewBoxAspectRatio, statusBadgeSizeVariants, toast, typographyDefaultElement, typographyVariantClasses, useFormField, userTypeBadgeRegistry, userTypeBadgeSizeVariants, userTypeBadgeUserTypes };
|