@elabs-ai/components-flow 4.1.0 → 4.2.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/dist/index.d.ts +5 -1
- package/dist/index.js +15 -10
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
- package/src/__contract__/inspector-panel.contract.test.tsx +49 -0
- package/src/__contract__/legend.contract.test.tsx +49 -0
- package/src/flow-mini-map/flow-mini-map.stories.tsx +17 -0
- package/src/inspector-panel/inspector-panel.tsx +9 -6
- package/src/legend/legend.test.tsx +11 -0
- package/src/legend/legend.tsx +15 -7
package/dist/index.d.ts
CHANGED
|
@@ -762,7 +762,11 @@ interface LegendScaleProps {
|
|
|
762
762
|
kind: "width" | "color";
|
|
763
763
|
/** `[min, max]` of the underlying value the ramp represents. */
|
|
764
764
|
domain: [number, number];
|
|
765
|
-
/**
|
|
765
|
+
/**
|
|
766
|
+
* Formats a domain value for display at a tick.
|
|
767
|
+
* @default the active `LocaleProvider` locale's `formatNumber` (host locale
|
|
768
|
+
* when no provider is mounted) — never a hardcoded `toLocaleString()`.
|
|
769
|
+
*/
|
|
766
770
|
format?: (value: number) => string;
|
|
767
771
|
/**
|
|
768
772
|
* Sample count for `kind: "width"`: `"minmax"` draws a min/max pair of
|
package/dist/index.js
CHANGED
|
@@ -1226,15 +1226,15 @@ function FlowMiniMap({
|
|
|
1226
1226
|
|
|
1227
1227
|
// src/inspector-panel/inspector-panel.tsx
|
|
1228
1228
|
import "react";
|
|
1229
|
-
import { Reveal, useCollapsiblePanel } from "@elabs-ai/components-ui";
|
|
1229
|
+
import { Reveal, useCollapsiblePanel, useLocale } from "@elabs-ai/components-ui";
|
|
1230
1230
|
import { cn as cn7 } from "@elabs-ai/components-ui/lib/cn";
|
|
1231
1231
|
import { jsx as jsx11, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1232
1232
|
var INSPECTOR_PANEL_WIDTH = "18rem";
|
|
1233
1233
|
function InspectorPanel({
|
|
1234
|
-
title
|
|
1234
|
+
title,
|
|
1235
1235
|
children,
|
|
1236
1236
|
onClose,
|
|
1237
|
-
emptyMessage
|
|
1237
|
+
emptyMessage,
|
|
1238
1238
|
hasSelection = true,
|
|
1239
1239
|
selectionKey,
|
|
1240
1240
|
open,
|
|
@@ -1244,6 +1244,9 @@ function InspectorPanel({
|
|
|
1244
1244
|
width = INSPECTOR_PANEL_WIDTH,
|
|
1245
1245
|
className
|
|
1246
1246
|
}) {
|
|
1247
|
+
const { t } = useLocale();
|
|
1248
|
+
const resolvedTitle = title ?? t("flow.inspectorPanel.title");
|
|
1249
|
+
const resolvedEmptyMessage = emptyMessage ?? t("flow.inspectorPanel.emptyMessage");
|
|
1247
1250
|
const panel = useCollapsiblePanel({
|
|
1248
1251
|
side,
|
|
1249
1252
|
open,
|
|
@@ -1272,12 +1275,12 @@ function InspectorPanel({
|
|
|
1272
1275
|
className: cn7(panel.containerClassName, "absolute inset-y-0 flex h-full border-s"),
|
|
1273
1276
|
children: /* @__PURE__ */ jsxs8("div", { className: "flex h-full w-full flex-col bg-card", children: [
|
|
1274
1277
|
/* @__PURE__ */ jsxs8("div", { className: "flex items-center justify-between border-b px-4 py-3", children: [
|
|
1275
|
-
/* @__PURE__ */ jsx11("h3", { className: "text-body font-semibold text-foreground", children:
|
|
1278
|
+
/* @__PURE__ */ jsx11("h3", { className: "text-body font-semibold text-foreground", children: resolvedTitle }),
|
|
1276
1279
|
onClose ? /* @__PURE__ */ jsx11(
|
|
1277
1280
|
"button",
|
|
1278
1281
|
{
|
|
1279
1282
|
type: "button",
|
|
1280
|
-
"aria-label": "
|
|
1283
|
+
"aria-label": t("flow.inspectorPanel.close"),
|
|
1281
1284
|
onClick: onClose,
|
|
1282
1285
|
className: "rounded-sm p-1 text-muted-foreground hover:text-foreground focus-ring",
|
|
1283
1286
|
children: /* @__PURE__ */ jsx11(
|
|
@@ -1308,7 +1311,7 @@ function InspectorPanel({
|
|
|
1308
1311
|
children
|
|
1309
1312
|
},
|
|
1310
1313
|
selectionKey
|
|
1311
|
-
) : /* @__PURE__ */ jsx11("div", { tabIndex: 0, className: "focus-ring flex-1 overflow-y-auto p-4 text-body", children: /* @__PURE__ */ jsx11("p", { className: "text-muted-foreground", children:
|
|
1314
|
+
) : /* @__PURE__ */ jsx11("div", { tabIndex: 0, className: "focus-ring flex-1 overflow-y-auto p-4 text-body", children: /* @__PURE__ */ jsx11("p", { className: "text-muted-foreground", children: resolvedEmptyMessage }) })
|
|
1312
1315
|
] })
|
|
1313
1316
|
}
|
|
1314
1317
|
)
|
|
@@ -1318,6 +1321,7 @@ function InspectorPanel({
|
|
|
1318
1321
|
}
|
|
1319
1322
|
|
|
1320
1323
|
// src/legend/legend.tsx
|
|
1324
|
+
import { useLocale as useLocale2 } from "@elabs-ai/components-ui";
|
|
1321
1325
|
import { cn as cn8 } from "@elabs-ai/components-ui/lib/cn";
|
|
1322
1326
|
|
|
1323
1327
|
// src/flow-weighted-edge/weight-scale.ts
|
|
@@ -1357,7 +1361,6 @@ function computeEdgeWeightScale(edges, opts = {}) {
|
|
|
1357
1361
|
|
|
1358
1362
|
// src/legend/legend.tsx
|
|
1359
1363
|
import { jsx as jsx12, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1360
|
-
var defaultFormat = (value) => value.toLocaleString();
|
|
1361
1364
|
function Legend(props) {
|
|
1362
1365
|
if (props.variant === "scale") {
|
|
1363
1366
|
return /* @__PURE__ */ jsx12(LegendScale, { ...props });
|
|
@@ -1406,13 +1409,15 @@ function scaleKindLabel(kind) {
|
|
|
1406
1409
|
function LegendScale({
|
|
1407
1410
|
kind,
|
|
1408
1411
|
domain,
|
|
1409
|
-
format
|
|
1412
|
+
format,
|
|
1410
1413
|
ticks = "minmax",
|
|
1411
1414
|
title,
|
|
1412
1415
|
className
|
|
1413
1416
|
}) {
|
|
1417
|
+
const { formatNumber } = useLocale2();
|
|
1418
|
+
const format_ = format ?? formatNumber;
|
|
1414
1419
|
const [min, max] = domain;
|
|
1415
|
-
const ariaLabel = `Edge ${scaleKindLabel(kind)} scale, ${
|
|
1420
|
+
const ariaLabel = `Edge ${scaleKindLabel(kind)} scale, ${format_(min)} to ${format_(max)}, minimum to maximum`;
|
|
1416
1421
|
return /* @__PURE__ */ jsxs9(
|
|
1417
1422
|
"div",
|
|
1418
1423
|
{
|
|
@@ -1426,7 +1431,7 @@ function LegendScale({
|
|
|
1426
1431
|
tabIndex: 0,
|
|
1427
1432
|
children: [
|
|
1428
1433
|
title ? /* @__PURE__ */ jsx12("div", { className: "text-body font-medium text-foreground", children: title }) : null,
|
|
1429
|
-
kind === "width" ? /* @__PURE__ */ jsx12(LegendScaleWidth, { domain, format, ticks }) : /* @__PURE__ */ jsx12(LegendScaleColor, { domain, format })
|
|
1434
|
+
kind === "width" ? /* @__PURE__ */ jsx12(LegendScaleWidth, { domain, format: format_, ticks }) : /* @__PURE__ */ jsx12(LegendScaleColor, { domain, format: format_ })
|
|
1430
1435
|
]
|
|
1431
1436
|
}
|
|
1432
1437
|
);
|