@jsudc/react 0.3.1 → 0.5.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/README.md +1137 -22
- package/dist/actions/RowActionsMenu.d.ts +45 -0
- package/dist/actions/RowActionsMenu.js +161 -0
- package/dist/actions/RowActionsMenu.js.map +1 -0
- package/dist/actions/bulk.d.ts +81 -0
- package/dist/actions/bulk.js +54 -0
- package/dist/actions/bulk.js.map +1 -0
- package/dist/actions/row.d.ts +50 -0
- package/dist/actions/row.js +34 -0
- package/dist/actions/row.js.map +1 -0
- package/dist/actions/useRowActionRunner.d.ts +26 -0
- package/dist/actions/useRowActionRunner.js +198 -0
- package/dist/actions/useRowActionRunner.js.map +1 -0
- package/dist/calendar/CalendarRenderer.js +5 -4
- package/dist/calendar/CalendarRenderer.js.map +1 -1
- package/dist/calendar/EventDetail.js +1 -1
- package/dist/calendar.js +1 -1
- package/dist/cards/CardRenderer.d.ts +8 -1
- package/dist/cards/CardRenderer.js +179 -110
- package/dist/cards/CardRenderer.js.map +1 -1
- package/dist/cells/registry.d.ts +60 -0
- package/dist/cells/registry.js +47 -0
- package/dist/cells/registry.js.map +1 -0
- package/dist/chart/ChartRenderer.js +6 -4
- package/dist/chart/ChartRenderer.js.map +1 -1
- package/dist/chart/ChartWindowControl.js +2 -2
- package/dist/components/ui/checkbox.js +1 -1
- package/dist/components/ui/dialog.js +4 -3
- package/dist/components/ui/dialog.js.map +1 -1
- package/dist/components/ui/dropdown-menu.js +2 -1
- package/dist/components/ui/dropdown-menu.js.map +1 -1
- package/dist/components/ui/popover.js +2 -1
- package/dist/components/ui/popover.js.map +1 -1
- package/dist/components/ui/select.js +2 -1
- package/dist/components/ui/select.js.map +1 -1
- package/dist/components/ui/toast.js +3 -2
- package/dist/components/ui/toast.js.map +1 -1
- package/dist/components/ui/tooltip.js +2 -1
- package/dist/components/ui/tooltip.js.map +1 -1
- package/dist/data-view/BulkBar.d.ts +36 -0
- package/dist/data-view/BulkBar.js +239 -0
- package/dist/data-view/BulkBar.js.map +1 -0
- package/dist/data-view/FilePreview.js +1 -1
- package/dist/data-view/FilterBuilder.js +2 -2
- package/dist/data-view/FilterChips.js +2 -2
- package/dist/data-view/Freshness.js +1 -1
- package/dist/data-view/LiveIndicator.d.ts +10 -0
- package/dist/data-view/LiveIndicator.js +33 -0
- package/dist/data-view/LiveIndicator.js.map +1 -0
- package/dist/data-view/SearchBox.js +1 -1
- package/dist/data-view/UdcDataView.d.ts +110 -1
- package/dist/data-view/UdcDataView.js +237 -90
- package/dist/data-view/UdcDataView.js.map +1 -1
- package/dist/data-view/useDataViewState.d.ts +8 -0
- package/dist/data-view/useDataViewState.js +2 -1
- package/dist/data-view/useDataViewState.js.map +1 -1
- package/dist/headless.d.ts +9 -0
- package/dist/headless.js +12 -2
- package/dist/i18n/translations.js +136 -0
- package/dist/i18n/translations.js.map +1 -1
- package/dist/index.d.ts +15 -4
- package/dist/index.js +17 -4
- package/dist/kanban/KanbanCard.js +1 -1
- package/dist/kanban/KanbanColumn.js +1 -1
- package/dist/kanban/KanbanRenderer.js +6 -5
- package/dist/kanban/KanbanRenderer.js.map +1 -1
- package/dist/lib/scope.d.ts +8 -0
- package/dist/lib/scope.js +12 -0
- package/dist/lib/scope.js.map +1 -0
- package/dist/lookup/LookupCombobox.js +1 -1
- package/dist/lookup/batch.js +1 -1
- package/dist/lookup/options.js +4 -1
- package/dist/lookup/options.js.map +1 -1
- package/dist/lookup/useUdcLookup.js +9 -3
- package/dist/lookup/useUdcLookup.js.map +1 -1
- package/dist/map/MapRenderer.js +4 -3
- package/dist/map/MapRenderer.js.map +1 -1
- package/dist/renderers/types.d.ts +44 -1
- package/dist/renderers/types.js.map +1 -1
- package/dist/rows/useRowActivation.d.ts +91 -0
- package/dist/rows/useRowActivation.js +257 -0
- package/dist/rows/useRowActivation.js.map +1 -0
- package/dist/rows/useRowSelection.d.ts +92 -0
- package/dist/rows/useRowSelection.js +156 -0
- package/dist/rows/useRowSelection.js.map +1 -0
- package/dist/schema-editor/DeleteFieldDialog.js +2 -2
- package/dist/schema-editor/FieldFormDialog.js +2 -2
- package/dist/schema-editor/TagInput.js +1 -1
- package/dist/styles.css +1 -1
- package/dist/styles.scoped.css +2 -0
- package/dist/table/CellEditor.js +2 -1
- package/dist/table/CellEditor.js.map +1 -1
- package/dist/table/SelectCheckbox.d.ts +15 -0
- package/dist/table/SelectCheckbox.js +37 -0
- package/dist/table/SelectCheckbox.js.map +1 -0
- package/dist/table/TableRenderer.d.ts +15 -1
- package/dist/table/TableRenderer.js +305 -114
- package/dist/table/TableRenderer.js.map +1 -1
- package/dist/table/cells.d.ts +13 -2
- package/dist/table/cells.js +15 -2
- package/dist/table/cells.js.map +1 -1
- package/dist/table/index.d.ts +1 -0
- package/dist/table/states.d.ts +6 -0
- package/dist/table/states.js +14 -1
- package/dist/table/states.js.map +1 -1
- package/dist/table/useRowWindow.d.ts +82 -0
- package/dist/table/useRowWindow.js +182 -0
- package/dist/table/useRowWindow.js.map +1 -0
- package/dist/table.js.map +1 -1
- package/dist/tree/TreeNode.js +1 -1
- package/dist/tree/TreeRenderer.d.ts +2 -0
- package/dist/tree/TreeRenderer.js +16 -10
- package/dist/tree/TreeRenderer.js.map +1 -1
- package/dist/udc/changeFeed.d.ts +94 -0
- package/dist/udc/changeFeed.js +250 -0
- package/dist/udc/changeFeed.js.map +1 -0
- package/dist/udc/changes.d.ts +34 -0
- package/dist/udc/changes.js +79 -0
- package/dist/udc/changes.js.map +1 -0
- package/dist/udc/client.d.ts +15 -1
- package/dist/udc/client.js +34 -10
- package/dist/udc/client.js.map +1 -1
- package/dist/udc/hooks.d.ts +94 -16
- package/dist/udc/hooks.js +113 -10
- package/dist/udc/hooks.js.map +1 -1
- package/dist/udc/keys.d.ts +2 -0
- package/dist/udc/keys.js.map +1 -1
- package/dist/udc/listCache.d.ts +11 -0
- package/dist/udc/listCache.js +38 -0
- package/dist/udc/listCache.js.map +1 -0
- package/dist/udc/provider.d.ts +21 -3
- package/dist/udc/provider.js +23 -2
- package/dist/udc/provider.js.map +1 -1
- package/dist/udc/unauthenticated.d.ts +4 -0
- package/dist/udc/unauthenticated.js +17 -0
- package/dist/udc/unauthenticated.js.map +1 -0
- package/dist/ui-kit/types.d.ts +14 -0
- package/dist/ui-kit/ui.d.ts +1 -0
- package/dist/ui.js +2 -1
- package/dist/url-state/adapters.d.ts +23 -0
- package/dist/url-state/adapters.js +57 -0
- package/dist/url-state/adapters.js.map +1 -0
- package/dist/url-state/index.d.ts +1 -0
- package/package.json +6 -4
|
@@ -8,8 +8,8 @@ import { isoInZone } from "../time/zoned.js";
|
|
|
8
8
|
import { useUdcAllRows, useUdcCollection } from "../udc/hooks.js";
|
|
9
9
|
import { useUiKit } from "../ui-kit/context.js";
|
|
10
10
|
import { axisFrames, barSize, cartesianData, formatAxisValue, formatTimeTick, maxPointsFor, seriesColor, timeTicks } from "./model.js";
|
|
11
|
-
import { useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
12
11
|
import { chartXKind, foldSlices } from "@jsudc/core";
|
|
12
|
+
import { useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
13
13
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
14
14
|
import { Area, AreaChart, Bar, BarChart, CartesianGrid, Cell, Line, LineChart, Pie, PieChart, Rectangle, Tooltip, XAxis, YAxis } from "recharts";
|
|
15
15
|
// src/chart/ChartRenderer.tsx
|
|
@@ -27,7 +27,7 @@ function ChartRenderer(props) {
|
|
|
27
27
|
opts
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
|
-
function ChartTab({ collection, describe, filter, unwindowedFilter, chartWindow, filtered, onClearFilters, onCount, opts }) {
|
|
30
|
+
function ChartTab({ collection, describe, filter, listSearch, unwindowedFilter, chartWindow, filtered, onClearFilters, onCount, opts }) {
|
|
31
31
|
const { Skeleton } = useUiKit();
|
|
32
32
|
const { schema, capabilities, view } = describe;
|
|
33
33
|
const xKind = chartXKind(opts, schema);
|
|
@@ -41,7 +41,8 @@ function ChartTab({ collection, describe, filter, unwindowedFilter, chartWindow,
|
|
|
41
41
|
sort,
|
|
42
42
|
capabilities,
|
|
43
43
|
max: opts.max_rows,
|
|
44
|
-
refetchInterval: view.refresh_interval_ms
|
|
44
|
+
refetchInterval: view.refresh_interval_ms,
|
|
45
|
+
search: listSearch
|
|
45
46
|
});
|
|
46
47
|
const outside = useUdcCollection({
|
|
47
48
|
collection,
|
|
@@ -49,7 +50,8 @@ function ChartTab({ collection, describe, filter, unwindowedFilter, chartWindow,
|
|
|
49
50
|
mode: "pages",
|
|
50
51
|
pageLimit: 1,
|
|
51
52
|
enabled: chartWindow !== void 0,
|
|
52
|
-
capabilities
|
|
53
|
+
capabilities,
|
|
54
|
+
search: listSearch
|
|
53
55
|
});
|
|
54
56
|
const windowed = chartWindow !== void 0;
|
|
55
57
|
const windowTotal = windowed ? outside.total : null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChartRenderer.js","names":[],"sources":["../../src/chart/ChartRenderer.tsx"],"sourcesContent":["import {\n type ChartOptions,\n type ColumnConfig,\n chartXKind,\n type DescribeResponse,\n foldSlices,\n type PieSlice,\n type Row,\n} from \"@jsudc/core\";\nimport { type ReactNode, useEffect, useLayoutEffect, useMemo, useRef, useState } from \"react\";\nimport {\n Area,\n AreaChart,\n Bar,\n BarChart,\n type BarShapeProps,\n CartesianGrid,\n Cell,\n Line,\n LineChart,\n Pie,\n PieChart,\n type PieLabelRenderProps,\n Rectangle,\n Tooltip,\n XAxis,\n YAxis,\n} from \"recharts\";\nimport { tableSection, useI18n } from \"../i18n/i18n.js\";\nimport { cn, humanize } from \"../lib/utils.js\";\nimport { AllRowsStatus } from \"../renderers/AllRowsStatus.js\";\nimport type { RendererProps } from \"../renderers/types.js\";\nimport { CellValue } from \"../table/cells.js\";\nimport { EmptyState, ErrorState } from \"../table/states.js\";\nimport { isoInZone } from \"../time/zoned.js\";\nimport { useUdcAllRows, useUdcCollection } from \"../udc/hooks.js\";\nimport { useUiKit } from \"../ui-kit/context.js\";\nimport {\n axisFrames,\n barSize,\n CHART_SLOTS,\n type ChartPoint,\n COUNT_KEY,\n cartesianData,\n formatAxisValue,\n formatTimeTick,\n maxPointsFor,\n seriesColor,\n timeTicks,\n X_KEY,\n} from \"./model.js\";\n\n/** The `chart` tab: the rows of the filter (and the window) drawn as `chart_options` says. */\nexport function ChartRenderer(props: RendererProps) {\n const opts = props.describe.view.chart_options;\n const { t } = useI18n();\n if (!opts) {\n return (\n <div\n className=\"udc:p-8 udc:text-center udc:text-sm udc:text-muted-foreground\"\n data-testid=\"chart-missing\"\n >\n {t(\"APP\", \"CHART_NO_OPTIONS\")}\n </div>\n );\n }\n return <ChartTab {...props} opts={opts} />;\n}\n\nfunction ChartTab({\n collection,\n describe,\n filter,\n unwindowedFilter,\n chartWindow,\n filtered,\n onClearFilters,\n onCount,\n opts,\n}: RendererProps & { opts: ChartOptions }) {\n const { Skeleton } = useUiKit();\n const { schema, capabilities, view } = describe;\n const xKind = chartXKind(opts, schema);\n // Pages in x order, so a cut by max_rows keeps the start of the window; a pie keeps its biggest.\n const sort =\n opts.type === \"pie\"\n ? [{ field: opts.value_field ?? \"\", dir: \"desc\" as const }]\n : xKind === \"time\" && opts.x_field\n ? [{ field: opts.x_field }]\n : [];\n const q = useUdcAllRows({\n collection,\n filter,\n sort,\n capabilities,\n max: opts.max_rows,\n refetchInterval: view.refresh_interval_ms,\n });\n // \"N points in window of M\": M counts the filter without the window (one row asked for).\n const outside = useUdcCollection({\n collection,\n filter: unwindowedFilter,\n mode: \"pages\",\n pageLimit: 1,\n enabled: chartWindow !== undefined,\n capabilities,\n });\n\n const windowed = chartWindow !== undefined;\n const windowTotal = windowed ? outside.total : null;\n useEffect(() => {\n if (q.total === null) {\n onCount(null);\n return;\n }\n onCount({\n shown: q.total,\n total: windowTotal ?? q.total,\n ...(windowed ? { unit: \"chart\" as const } : {}),\n fetchedAt: q.fetchedAt,\n stale: q.stale,\n });\n }, [onCount, q.total, windowTotal, windowed, q.fetchedAt, q.stale]);\n useEffect(() => () => onCount(null), [onCount]);\n\n if (q.error && q.rows.length === 0) {\n return <ErrorState error={q.error} onRetry={() => void q.refetch()} />;\n }\n const firstLoad = q.isLoading && q.rows.length === 0;\n const empty = !firstLoad && !q.isFetching && q.rows.length === 0;\n return (\n <div\n className=\"udc-chart udc:flex udc:min-h-0 udc:flex-1 udc:flex-col udc:overflow-auto\"\n data-testid=\"chart-tab\"\n >\n <AllRowsStatus result={q} />\n {firstLoad ? (\n <div className=\"udc:p-6\">\n <Skeleton\n className=\"udc:w-full\"\n style={{ height: opts.height_px }}\n data-testid=\"chart-loading\"\n />\n </div>\n ) : empty ? (\n <EmptyState filtered={filtered} onClear={onClearFilters} body={opts.empty_label} />\n ) : (\n <ChartView\n collection={collection}\n describe={describe}\n rows={q.rows}\n opts={opts}\n range={chartWindow?.range}\n timeZone={chartWindow?.timeZone}\n />\n )}\n </div>\n );\n}\n\n/** The width of an element, followed as it resizes (jsdom has no layout: 720 there). */\nfunction useWidth<T extends HTMLElement>(): [React.RefObject<T | null>, number] {\n const ref = useRef<T>(null);\n const [width, setWidth] = useState(0);\n useLayoutEffect(() => {\n const el = ref.current;\n if (!el) return;\n setWidth(el.clientWidth);\n const obs = new ResizeObserver((entries) => {\n const w = entries[0]?.contentRect.width;\n if (w) setWidth(Math.floor(w));\n });\n obs.observe(el);\n return () => obs.disconnect();\n }, []);\n return [ref, width > 0 ? width : 720];\n}\n\nconst MARGIN = { top: 12, right: 12, bottom: 4, left: 4 };\nconst Y_AXIS_WIDTH = 56;\nconst AXIS_TICK = { fontSize: 11, fill: \"var(--muted-foreground)\" };\n\nexport interface ChartViewProps {\n collection: string;\n describe: DescribeResponse;\n rows: readonly Row[];\n opts: ChartOptions;\n /** The window, when there is one: the time axis spans it. */\n range?: [number | null, number | null] | undefined;\n /** The header's zone (the time axis and the tooltip read in it); the browser's without one. */\n timeZone?: string | undefined;\n}\n\n/** The chart over rows already loaded: cartesian or pie. Exported for the unit tests. */\nexport function ChartView(props: ChartViewProps) {\n return props.opts.type === \"pie\" ? <PieView {...props} /> : <CartesianView {...props} />;\n}\n\n/** `view.columns`' block for `field`, or a bare one: tooltips format as the table does. */\nfunction columnOf(describe: DescribeResponse, field: string): ColumnConfig {\n return describe.view.columns.find((c) => c.field === field) ?? { field };\n}\n\nfunction useFieldLabel(collection: string) {\n const { tMaybe } = useI18n();\n const section = tableSection(collection);\n return (field: string, label?: string) => tMaybe(section, field) ?? label ?? humanize(field);\n}\n\nfunction CartesianView({ collection, describe, rows, opts, range, timeZone }: ChartViewProps) {\n const { intlLocale } = useI18n();\n const zone = timeZone ?? Intl.DateTimeFormat().resolvedOptions().timeZone;\n const fieldLabel = useFieldLabel(collection);\n const [ref, width] = useWidth<HTMLDivElement>();\n const [hidden, setHidden] = useState<ReadonlySet<string>>(new Set());\n const xKind = chartXKind(opts, describe.schema);\n const sides = ([\"left\", \"right\"] as const).filter((side) =>\n opts.series.some((s) => s.axis === side),\n );\n const plotWidth = width - MARGIN.left - MARGIN.right - sides.length * Y_AXIS_WIDTH;\n const { points, bucket } = useMemo(\n () => cartesianData(rows, opts, xKind, maxPointsFor(plotWidth)),\n [rows, opts, xKind, plotWidth],\n );\n const frames = axisFrames(points, opts, hidden);\n\n // The time axis spans the window when there is one, else the rows.\n const xs = points.map((p) => p[X_KEY]).filter((x): x is number => typeof x === \"number\");\n const from = range?.[0] ?? (xs.length ? Math.min(...xs) : 0);\n const to = range?.[1] ?? (xs.length ? Math.max(...xs) : 0);\n const ticks =\n xKind === \"time\" ? timeTicks(from, to, zone, Math.max(3, Math.floor(plotWidth / 110))) : [];\n\n const toggle = (field: string) =>\n setHidden((h) => {\n const next = new Set(h);\n if (!next.delete(field)) next.add(field);\n return next;\n });\n\n const timeBar = barSize(plotWidth, points.length);\n const series = opts.series.map((s, i) => {\n const common = {\n dataKey: s.field,\n name: fieldLabel(s.field, s.label),\n yAxisId: s.axis,\n hide: hidden.has(s.field),\n isAnimationActive: false,\n };\n const color = seriesColor(s, i);\n if (opts.type === \"bar\") {\n return (\n <Bar\n key={s.field}\n {...common}\n fill={color}\n stackId={s.stack}\n radius={s.stack ? 0 : [2, 2, 0, 0]}\n // A number axis has no bands: recharts sizes a bar by the closest two instants (two\n // quakes a minute apart leave it 0.4 px wide), so a time bar is drawn at a fixed width.\n shape={\n xKind === \"time\"\n ? (p: BarShapeProps) => (\n <Rectangle\n {...p}\n x={p.x + p.width / 2 - timeBar / 2}\n width={timeBar}\n // A ring of the surface keeps two close instants apart.\n stroke=\"var(--surface)\"\n strokeWidth={1}\n radius={s.stack ? 0 : [2, 2, 0, 0]}\n />\n )\n : undefined\n }\n />\n );\n }\n if (opts.type === \"area\") {\n return (\n <Area\n key={s.field}\n {...common}\n type=\"monotone\"\n stroke={color}\n strokeWidth={2}\n fill={color}\n fillOpacity={0.16}\n stackId={s.stack}\n dot={false}\n activeDot={{ r: 4, strokeWidth: 2, stroke: \"var(--surface)\" }}\n />\n );\n }\n return (\n <Line\n key={s.field}\n {...common}\n type=\"monotone\"\n stroke={color}\n strokeWidth={2}\n dot={false}\n activeDot={{ r: 4, strokeWidth: 2, stroke: \"var(--surface)\" }}\n />\n );\n });\n\n const Chart = opts.type === \"bar\" ? BarChart : opts.type === \"area\" ? AreaChart : LineChart;\n const frameAttr = (side: \"left\" | \"right\") => frames[side]?.domain.join(\",\") ?? undefined;\n\n return (\n <div\n ref={ref}\n className=\"udc:px-4 udc:pt-4 udc:pb-2\"\n data-testid=\"chart\"\n data-type={opts.type}\n data-x-kind={xKind}\n data-points={points.length}\n data-bucket={bucket}\n data-tz={zone}\n data-from={range?.[0] != null ? isoInZone(range[0], zone, true) : undefined}\n data-to={range?.[1] != null ? isoInZone(range[1], zone, true) : undefined}\n data-left-domain={frameAttr(\"left\")}\n data-right-domain={frameAttr(\"right\")}\n >\n <Chart\n width={width - 32}\n height={opts.height_px}\n data={points}\n margin={MARGIN}\n barCategoryGap=\"10%\"\n >\n <CartesianGrid vertical={false} stroke=\"var(--border)\" />\n <XAxis\n dataKey={X_KEY}\n type={xKind === \"time\" ? \"number\" : \"category\"}\n scale={xKind === \"time\" ? \"time\" : \"auto\"}\n domain={xKind === \"time\" ? [from, to] : undefined}\n ticks={xKind === \"time\" ? ticks : undefined}\n tickFormatter={(v: number | string) =>\n xKind === \"time\" && typeof v === \"number\"\n ? formatTimeTick(v, ticks, intlLocale, zone)\n : String(v)\n }\n allowDataOverflow={xKind === \"time\"}\n tick={AXIS_TICK}\n tickLine={false}\n axisLine={{ stroke: \"var(--border-strong)\" }}\n minTickGap={8}\n />\n {sides.map((side) => (\n <YAxis\n key={side}\n yAxisId={side}\n orientation={side}\n width={Y_AXIS_WIDTH}\n domain={frames[side]?.domain ?? [\"auto\", \"auto\"]}\n ticks={frames[side]?.ticks}\n allowDataOverflow\n tickFormatter={(v: number) => formatAxisValue(v, opts.y_axis[side].format, intlLocale)}\n tick={AXIS_TICK}\n tickLine={false}\n axisLine={false}\n />\n ))}\n <Tooltip\n isAnimationActive={false}\n cursor={{ stroke: \"var(--border-strong)\", fill: \"var(--hover)\" }}\n content={(p) => (\n <SeriesTooltip\n active={p.active === true}\n point={p.payload?.[0]?.payload as ChartPoint | undefined}\n describe={describe}\n opts={opts}\n hidden={hidden}\n fieldLabel={fieldLabel}\n bucket={bucket}\n />\n )}\n />\n {series}\n </Chart>\n {/* One series needs no legend: the tab and the axis name it. */}\n {opts.legend && opts.series.length > 1 ? (\n <ul\n className=\"udc:mt-1 udc:flex udc:flex-wrap udc:items-center udc:justify-center udc:gap-x-4 udc:gap-y-1\"\n data-testid=\"chart-legend\"\n >\n {opts.series.map((s, i) => {\n const off = hidden.has(s.field);\n return (\n <li key={s.field}>\n <button\n type=\"button\"\n data-testid=\"chart-legend-item\"\n data-field={s.field}\n data-axis={s.axis}\n data-hidden={off}\n aria-pressed={!off}\n onClick={() => toggle(s.field)}\n className={cn(\n \"udc:inline-flex udc:items-center udc:gap-1.5 udc:rounded-sm udc:px-1.5 udc:py-0.5 udc:text-xs udc:text-foreground udc:hover:bg-hover\",\n off && \"udc:text-muted-foreground udc:line-through\",\n )}\n >\n <span\n className={cn(\n \"udc:inline-block udc:h-0.5 udc:w-3.5 udc:rounded-full\",\n opts.type !== \"line\" && \"udc:h-2.5 udc:w-2.5 udc:rounded-sm\",\n off && \"udc:opacity-30\",\n )}\n style={{ background: seriesColor(s, i) }}\n />\n {fieldLabel(s.field, s.label)}\n {sides.length > 1 ? (\n <span className=\"udc:text-muted-foreground\">\n {s.axis === \"left\" ? \"◂\" : \"▸\"}\n </span>\n ) : null}\n </button>\n </li>\n );\n })}\n </ul>\n ) : null}\n </div>\n );\n}\n\nfunction TooltipBox({ children, testId }: { children: ReactNode; testId: string }) {\n return (\n <div\n data-testid={testId}\n className=\"udc:min-w-40 udc:rounded-md udc:border udc:border-border udc:bg-surface-raised udc:px-3 udc:py-2 udc:text-xs udc:text-foreground udc:shadow-md\"\n >\n {children}\n </div>\n );\n}\n\n/** One point: its x as the table shows it, then every visible series' value, formatted the same way. */\nfunction SeriesTooltip({\n active,\n point,\n describe,\n opts,\n hidden,\n fieldLabel,\n bucket,\n}: {\n active: boolean;\n point: ChartPoint | undefined;\n describe: DescribeResponse;\n opts: ChartOptions;\n hidden: ReadonlySet<string>;\n fieldLabel: (field: string, label?: string) => string;\n bucket: number;\n}) {\n const { t, locale, intlLocale } = useI18n();\n if (!active || !point) return null;\n const x = opts.x_field ?? \"\";\n const xValue = point[X_KEY];\n const count = Number(point[COUNT_KEY] ?? 1);\n return (\n <TooltipBox testId=\"chart-tooltip\">\n <div\n className=\"udc:mb-1.5 udc:font-medium udc:text-muted-foreground\"\n data-testid=\"chart-tooltip-x\"\n >\n <CellValue\n value={typeof xValue === \"number\" ? new Date(xValue).toISOString() : xValue}\n column={columnOf(describe, x)}\n def={describe.schema.fields[x]}\n locale={locale}\n intlLocale={intlLocale}\n />\n </div>\n <table className=\"udc:w-full\">\n <tbody>\n {opts.series.map((s, i) =>\n hidden.has(s.field) ? null : (\n <tr key={s.field} data-testid=\"chart-tooltip-row\" data-field={s.field}>\n <td className=\"udc:pr-3\">\n <span className=\"udc:inline-flex udc:items-center udc:gap-1.5\">\n <span\n className=\"udc:inline-block udc:size-2 udc:rounded-full\"\n style={{ background: seriesColor(s, i) }}\n />\n {fieldLabel(s.field, s.label)}\n </span>\n </td>\n <td\n className=\"udc:text-right udc:font-medium udc:tabular-nums\"\n data-testid=\"chart-tooltip-value\"\n >\n <CellValue\n value={point[s.field]}\n column={columnOf(describe, s.field)}\n def={describe.schema.fields[s.field]}\n locale={locale}\n intlLocale={intlLocale}\n />\n </td>\n </tr>\n ),\n )}\n </tbody>\n </table>\n {count > 1 ? (\n <div className=\"udc:mt-1.5 udc:text-[11px] udc:text-muted-foreground\">\n {t(\"APP\", bucket > 1 ? \"CHART_BUCKET_ROWS\" : \"CHART_MERGED_ROWS\", { count })}\n </div>\n ) : null}\n </TooltipBox>\n );\n}\n\nconst OTHER_COLOR = \"var(--sem-muted)\";\n\nfunction PieView({ collection, describe, rows, opts }: ChartViewProps) {\n const { t, locale, intlLocale } = useI18n();\n const fieldLabel = useFieldLabel(collection);\n const [ref, width] = useWidth<HTMLDivElement>();\n const category = opts.category_field ?? \"\";\n const value = opts.value_field ?? \"\";\n const slices = useMemo(\n () => foldSlices(rows, category, value, opts.max_slices),\n [rows, category, value, opts.max_slices],\n );\n const sum = slices.reduce((s, x) => s + x.value, 0);\n const pct = (v: number) =>\n new Intl.NumberFormat(intlLocale, { style: \"percent\", maximumFractionDigits: 1 }).format(\n sum > 0 ? v / sum : 0,\n );\n const nameOf = (s: PieSlice) => (s.other ? t(\"APP\", \"CHART_OTHER\") : s.category || \"—\");\n const colorOf = (s: PieSlice, i: number) =>\n s.other ? OTHER_COLOR : `var(--chart-${(i % CHART_SLOTS) + 1})`;\n const data = slices.map((s, i) => ({ ...s, name: nameOf(s), fill: colorOf(s, i) }));\n const radius = Math.max(60, Math.min(opts.height_px / 2 - 40, width / 4));\n\n if (slices.length === 0) {\n return <EmptyState filtered={false} onClear={() => {}} body={opts.empty_label} />;\n }\n return (\n <div\n ref={ref}\n className=\"udc:flex udc:flex-wrap udc:items-center udc:justify-center udc:gap-6 udc:px-4 udc:pt-4 udc:pb-2\"\n data-testid=\"chart\"\n data-type=\"pie\"\n data-slices={slices.length}\n data-other={slices.some((s) => s.other)}\n >\n <PieChart width={Math.min(width - 32, radius * 2 + 360)} height={opts.height_px}>\n <Pie\n data={data}\n dataKey=\"value\"\n nameKey=\"name\"\n innerRadius={radius * 0.55}\n outerRadius={radius}\n paddingAngle={1}\n stroke=\"var(--surface)\"\n strokeWidth={2}\n isAnimationActive={false}\n // Labels wear the text ink, not the slice's colour; the slice beside them says which.\n label={(e: PieLabelRenderProps) => (\n <text\n x={e.x}\n y={e.y}\n textAnchor={e.textAnchor}\n dominantBaseline=\"central\"\n fill=\"var(--muted-foreground)\"\n fontSize={11}\n data-testid=\"chart-slice-label\"\n >\n {`${e.name ?? \"\"} ${pct(Number(e.value ?? 0))}`}\n </text>\n )}\n labelLine={false}\n >\n {data.map((s) => (\n <Cell\n key={s.other ? \"__other\" : s.category}\n fill={s.fill}\n data-testid=\"chart-slice\"\n data-other={s.other === true}\n />\n ))}\n </Pie>\n <Tooltip\n isAnimationActive={false}\n content={(p) => {\n const s = p.payload?.[0]?.payload as (PieSlice & { name: string }) | undefined;\n if (!p.active || !s) return null;\n return (\n <TooltipBox testId=\"chart-tooltip\">\n <div className=\"udc:mb-1 udc:font-medium\">{s.name}</div>\n <div className=\"udc:flex udc:justify-between udc:gap-4\">\n <span className=\"udc:text-muted-foreground\">{fieldLabel(value)}</span>\n <span\n className=\"udc:font-medium udc:tabular-nums\"\n data-testid=\"chart-tooltip-value\"\n >\n <CellValue\n value={s.value}\n column={columnOf(describe, value)}\n def={describe.schema.fields[value]}\n locale={locale}\n intlLocale={intlLocale}\n />{\" \"}\n · {pct(s.value)}\n </span>\n </div>\n {s.other ? (\n <div className=\"udc:mt-1 udc:text-[11px] udc:text-muted-foreground\">\n {t(\"APP\", \"CHART_OTHER_COUNT\", { count: s.count })}\n </div>\n ) : null}\n </TooltipBox>\n );\n }}\n />\n </PieChart>\n {opts.legend ? (\n <ul className=\"udc:grid udc:gap-1 udc:text-xs\" data-testid=\"chart-legend\">\n {data.map((s) => (\n <li\n key={s.other ? \"__other\" : s.category}\n className=\"udc:flex udc:items-center udc:gap-2\"\n data-testid=\"chart-legend-item\"\n >\n <span\n className=\"udc:inline-block udc:size-2.5 udc:rounded-sm\"\n style={{ background: s.fill }}\n />\n <span className=\"udc:min-w-0 udc:truncate\">{s.name}</span>\n <span className=\"udc:ml-auto udc:pl-3 udc:text-muted-foreground udc:tabular-nums\">\n {pct(s.value)}\n </span>\n </li>\n ))}\n </ul>\n ) : null}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAqDA,SAAgB,cAAc,OAAsB;CAClD,MAAM,OAAO,MAAM,SAAS,KAAK;CACjC,MAAM,EAAE,MAAM,QAAQ;CACtB,IAAI,CAAC,MACH,OACE,oBAAC,OAAD;EACE,WAAU;EACV,eAAY;EAEX,UAAA,EAAE,OAAO,kBAAkB;CACzB,CAAA;CAGT,OAAO,oBAAC,UAAD;EAAU,GAAI;EAAa;CAAO,CAAA;AAC3C;AAEA,SAAS,SAAS,EAChB,YACA,UACA,QACA,kBACA,aACA,UACA,gBACA,SACA,QACyC;CACzC,MAAM,EAAE,aAAa,SAAS;CAC9B,MAAM,EAAE,QAAQ,cAAc,SAAS;CACvC,MAAM,QAAQ,WAAW,MAAM,MAAM;CAErC,MAAM,OACJ,KAAK,SAAS,QACV,CAAC;EAAE,OAAO,KAAK,eAAe;EAAI,KAAK;CAAgB,CAAC,IACxD,UAAU,UAAU,KAAK,UACvB,CAAC,EAAE,OAAO,KAAK,QAAQ,CAAC,IACxB,CAAC;CACT,MAAM,IAAI,cAAc;EACtB;EACA;EACA;EACA;E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,QAAD;MAAM,WAAU;MACb,UAAA,IAAI,EAAE,KAAK;KACR,CAAA;IACJ;GAZG,GAAA,EAAE,QAAQ,YAAY,EAAE,QAY3B,CACL;EACC,CAAA,IACF,IACD;;AAET"}
|
|
1
|
+
{"version":3,"file":"ChartRenderer.js","names":[],"sources":["../../src/chart/ChartRenderer.tsx"],"sourcesContent":["import {\n type ChartOptions,\n type ColumnConfig,\n chartXKind,\n type DescribeResponse,\n foldSlices,\n type PieSlice,\n type Row,\n} from \"@jsudc/core\";\nimport { type ReactNode, useEffect, useLayoutEffect, useMemo, useRef, useState } from \"react\";\nimport {\n Area,\n AreaChart,\n Bar,\n BarChart,\n type BarShapeProps,\n CartesianGrid,\n Cell,\n Line,\n LineChart,\n Pie,\n PieChart,\n type PieLabelRenderProps,\n Rectangle,\n Tooltip,\n XAxis,\n YAxis,\n} from \"recharts\";\nimport { tableSection, useI18n } from \"../i18n/i18n.js\";\nimport { cn, humanize } from \"../lib/utils.js\";\nimport { AllRowsStatus } from \"../renderers/AllRowsStatus.js\";\nimport type { RendererProps } from \"../renderers/types.js\";\nimport { CellValue } from \"../table/cells.js\";\nimport { EmptyState, ErrorState } from \"../table/states.js\";\nimport { isoInZone } from \"../time/zoned.js\";\nimport { useUdcAllRows, useUdcCollection } from \"../udc/hooks.js\";\nimport { useUiKit } from \"../ui-kit/context.js\";\nimport {\n axisFrames,\n barSize,\n CHART_SLOTS,\n type ChartPoint,\n COUNT_KEY,\n cartesianData,\n formatAxisValue,\n formatTimeTick,\n maxPointsFor,\n seriesColor,\n timeTicks,\n X_KEY,\n} from \"./model.js\";\n\n/** The `chart` tab: the rows of the filter (and the window) drawn as `chart_options` says. */\nexport function ChartRenderer(props: RendererProps) {\n const opts = props.describe.view.chart_options;\n const { t } = useI18n();\n if (!opts) {\n return (\n <div\n className=\"udc:p-8 udc:text-center udc:text-sm udc:text-muted-foreground\"\n data-testid=\"chart-missing\"\n >\n {t(\"APP\", \"CHART_NO_OPTIONS\")}\n </div>\n );\n }\n return <ChartTab {...props} opts={opts} />;\n}\n\nfunction ChartTab({\n collection,\n describe,\n filter,\n listSearch,\n unwindowedFilter,\n chartWindow,\n filtered,\n onClearFilters,\n onCount,\n opts,\n}: RendererProps & { opts: ChartOptions }) {\n const { Skeleton } = useUiKit();\n const { schema, capabilities, view } = describe;\n const xKind = chartXKind(opts, schema);\n // Pages in x order, so a cut by max_rows keeps the start of the window; a pie keeps its biggest.\n const sort =\n opts.type === \"pie\"\n ? [{ field: opts.value_field ?? \"\", dir: \"desc\" as const }]\n : xKind === \"time\" && opts.x_field\n ? [{ field: opts.x_field }]\n : [];\n const q = useUdcAllRows({\n collection,\n filter,\n sort,\n capabilities,\n max: opts.max_rows,\n refetchInterval: view.refresh_interval_ms,\n search: listSearch,\n });\n // \"N points in window of M\": M counts the filter without the window (one row asked for).\n const outside = useUdcCollection({\n collection,\n filter: unwindowedFilter,\n mode: \"pages\",\n pageLimit: 1,\n enabled: chartWindow !== undefined,\n capabilities,\n search: listSearch,\n });\n\n const windowed = chartWindow !== undefined;\n const windowTotal = windowed ? outside.total : null;\n useEffect(() => {\n if (q.total === null) {\n onCount(null);\n return;\n }\n onCount({\n shown: q.total,\n total: windowTotal ?? q.total,\n ...(windowed ? { unit: \"chart\" as const } : {}),\n fetchedAt: q.fetchedAt,\n stale: q.stale,\n });\n }, [onCount, q.total, windowTotal, windowed, q.fetchedAt, q.stale]);\n useEffect(() => () => onCount(null), [onCount]);\n\n if (q.error && q.rows.length === 0) {\n return <ErrorState error={q.error} onRetry={() => void q.refetch()} />;\n }\n const firstLoad = q.isLoading && q.rows.length === 0;\n const empty = !firstLoad && !q.isFetching && q.rows.length === 0;\n return (\n <div\n className=\"udc-chart udc:flex udc:min-h-0 udc:flex-1 udc:flex-col udc:overflow-auto\"\n data-testid=\"chart-tab\"\n >\n <AllRowsStatus result={q} />\n {firstLoad ? (\n <div className=\"udc:p-6\">\n <Skeleton\n className=\"udc:w-full\"\n style={{ height: opts.height_px }}\n data-testid=\"chart-loading\"\n />\n </div>\n ) : empty ? (\n <EmptyState filtered={filtered} onClear={onClearFilters} body={opts.empty_label} />\n ) : (\n <ChartView\n collection={collection}\n describe={describe}\n rows={q.rows}\n opts={opts}\n range={chartWindow?.range}\n timeZone={chartWindow?.timeZone}\n />\n )}\n </div>\n );\n}\n\n/** The width of an element, followed as it resizes (jsdom has no layout: 720 there). */\nfunction useWidth<T extends HTMLElement>(): [React.RefObject<T | null>, number] {\n const ref = useRef<T>(null);\n const [width, setWidth] = useState(0);\n useLayoutEffect(() => {\n const el = ref.current;\n if (!el) return;\n setWidth(el.clientWidth);\n const obs = new ResizeObserver((entries) => {\n const w = entries[0]?.contentRect.width;\n if (w) setWidth(Math.floor(w));\n });\n obs.observe(el);\n return () => obs.disconnect();\n }, []);\n return [ref, width > 0 ? width : 720];\n}\n\nconst MARGIN = { top: 12, right: 12, bottom: 4, left: 4 };\nconst Y_AXIS_WIDTH = 56;\nconst AXIS_TICK = { fontSize: 11, fill: \"var(--muted-foreground)\" };\n\nexport interface ChartViewProps {\n collection: string;\n describe: DescribeResponse;\n rows: readonly Row[];\n opts: ChartOptions;\n /** The window, when there is one: the time axis spans it. */\n range?: [number | null, number | null] | undefined;\n /** The header's zone (the time axis and the tooltip read in it); the browser's without one. */\n timeZone?: string | undefined;\n}\n\n/** The chart over rows already loaded: cartesian or pie. Exported for the unit tests. */\nexport function ChartView(props: ChartViewProps) {\n return props.opts.type === \"pie\" ? <PieView {...props} /> : <CartesianView {...props} />;\n}\n\n/** `view.columns`' block for `field`, or a bare one: tooltips format as the table does. */\nfunction columnOf(describe: DescribeResponse, field: string): ColumnConfig {\n return describe.view.columns.find((c) => c.field === field) ?? { field };\n}\n\nfunction useFieldLabel(collection: string) {\n const { tMaybe } = useI18n();\n const section = tableSection(collection);\n return (field: string, label?: string) => tMaybe(section, field) ?? label ?? humanize(field);\n}\n\nfunction CartesianView({ collection, describe, rows, opts, range, timeZone }: ChartViewProps) {\n const { intlLocale } = useI18n();\n const zone = timeZone ?? Intl.DateTimeFormat().resolvedOptions().timeZone;\n const fieldLabel = useFieldLabel(collection);\n const [ref, width] = useWidth<HTMLDivElement>();\n const [hidden, setHidden] = useState<ReadonlySet<string>>(new Set());\n const xKind = chartXKind(opts, describe.schema);\n const sides = ([\"left\", \"right\"] as const).filter((side) =>\n opts.series.some((s) => s.axis === side),\n );\n const plotWidth = width - MARGIN.left - MARGIN.right - sides.length * Y_AXIS_WIDTH;\n const { points, bucket } = useMemo(\n () => cartesianData(rows, opts, xKind, maxPointsFor(plotWidth)),\n [rows, opts, xKind, plotWidth],\n );\n const frames = axisFrames(points, opts, hidden);\n\n // The time axis spans the window when there is one, else the rows.\n const xs = points.map((p) => p[X_KEY]).filter((x): x is number => typeof x === \"number\");\n const from = range?.[0] ?? (xs.length ? Math.min(...xs) : 0);\n const to = range?.[1] ?? (xs.length ? Math.max(...xs) : 0);\n const ticks =\n xKind === \"time\" ? timeTicks(from, to, zone, Math.max(3, Math.floor(plotWidth / 110))) : [];\n\n const toggle = (field: string) =>\n setHidden((h) => {\n const next = new Set(h);\n if (!next.delete(field)) next.add(field);\n return next;\n });\n\n const timeBar = barSize(plotWidth, points.length);\n const series = opts.series.map((s, i) => {\n const common = {\n dataKey: s.field,\n name: fieldLabel(s.field, s.label),\n yAxisId: s.axis,\n hide: hidden.has(s.field),\n isAnimationActive: false,\n };\n const color = seriesColor(s, i);\n if (opts.type === \"bar\") {\n return (\n <Bar\n key={s.field}\n {...common}\n fill={color}\n stackId={s.stack}\n radius={s.stack ? 0 : [2, 2, 0, 0]}\n // A number axis has no bands: recharts sizes a bar by the closest two instants (two\n // quakes a minute apart leave it 0.4 px wide), so a time bar is drawn at a fixed width.\n shape={\n xKind === \"time\"\n ? (p: BarShapeProps) => (\n <Rectangle\n {...p}\n x={p.x + p.width / 2 - timeBar / 2}\n width={timeBar}\n // A ring of the surface keeps two close instants apart.\n stroke=\"var(--surface)\"\n strokeWidth={1}\n radius={s.stack ? 0 : [2, 2, 0, 0]}\n />\n )\n : undefined\n }\n />\n );\n }\n if (opts.type === \"area\") {\n return (\n <Area\n key={s.field}\n {...common}\n type=\"monotone\"\n stroke={color}\n strokeWidth={2}\n fill={color}\n fillOpacity={0.16}\n stackId={s.stack}\n dot={false}\n activeDot={{ r: 4, strokeWidth: 2, stroke: \"var(--surface)\" }}\n />\n );\n }\n return (\n <Line\n key={s.field}\n {...common}\n type=\"monotone\"\n stroke={color}\n strokeWidth={2}\n dot={false}\n activeDot={{ r: 4, strokeWidth: 2, stroke: \"var(--surface)\" }}\n />\n );\n });\n\n const Chart = opts.type === \"bar\" ? BarChart : opts.type === \"area\" ? AreaChart : LineChart;\n const frameAttr = (side: \"left\" | \"right\") => frames[side]?.domain.join(\",\") ?? undefined;\n\n return (\n <div\n ref={ref}\n className=\"udc:px-4 udc:pt-4 udc:pb-2\"\n data-testid=\"chart\"\n data-type={opts.type}\n data-x-kind={xKind}\n data-points={points.length}\n data-bucket={bucket}\n data-tz={zone}\n data-from={range?.[0] != null ? isoInZone(range[0], zone, true) : undefined}\n data-to={range?.[1] != null ? isoInZone(range[1], zone, true) : undefined}\n data-left-domain={frameAttr(\"left\")}\n data-right-domain={frameAttr(\"right\")}\n >\n <Chart\n width={width - 32}\n height={opts.height_px}\n data={points}\n margin={MARGIN}\n barCategoryGap=\"10%\"\n >\n <CartesianGrid vertical={false} stroke=\"var(--border)\" />\n <XAxis\n dataKey={X_KEY}\n type={xKind === \"time\" ? \"number\" : \"category\"}\n scale={xKind === \"time\" ? \"time\" : \"auto\"}\n domain={xKind === \"time\" ? [from, to] : undefined}\n ticks={xKind === \"time\" ? ticks : undefined}\n tickFormatter={(v: number | string) =>\n xKind === \"time\" && typeof v === \"number\"\n ? formatTimeTick(v, ticks, intlLocale, zone)\n : String(v)\n }\n allowDataOverflow={xKind === \"time\"}\n tick={AXIS_TICK}\n tickLine={false}\n axisLine={{ stroke: \"var(--border-strong)\" }}\n minTickGap={8}\n />\n {sides.map((side) => (\n <YAxis\n key={side}\n yAxisId={side}\n orientation={side}\n width={Y_AXIS_WIDTH}\n domain={frames[side]?.domain ?? [\"auto\", \"auto\"]}\n ticks={frames[side]?.ticks}\n allowDataOverflow\n tickFormatter={(v: number) => formatAxisValue(v, opts.y_axis[side].format, intlLocale)}\n tick={AXIS_TICK}\n tickLine={false}\n axisLine={false}\n />\n ))}\n <Tooltip\n isAnimationActive={false}\n cursor={{ stroke: \"var(--border-strong)\", fill: \"var(--hover)\" }}\n content={(p) => (\n <SeriesTooltip\n active={p.active === true}\n point={p.payload?.[0]?.payload as ChartPoint | undefined}\n describe={describe}\n opts={opts}\n hidden={hidden}\n fieldLabel={fieldLabel}\n bucket={bucket}\n />\n )}\n />\n {series}\n </Chart>\n {/* One series needs no legend: the tab and the axis name it. */}\n {opts.legend && opts.series.length > 1 ? (\n <ul\n className=\"udc:mt-1 udc:flex udc:flex-wrap udc:items-center udc:justify-center udc:gap-x-4 udc:gap-y-1\"\n data-testid=\"chart-legend\"\n >\n {opts.series.map((s, i) => {\n const off = hidden.has(s.field);\n return (\n <li key={s.field}>\n <button\n type=\"button\"\n data-testid=\"chart-legend-item\"\n data-field={s.field}\n data-axis={s.axis}\n data-hidden={off}\n aria-pressed={!off}\n onClick={() => toggle(s.field)}\n className={cn(\n \"udc:inline-flex udc:items-center udc:gap-1.5 udc:rounded-sm udc:px-1.5 udc:py-0.5 udc:text-xs udc:text-foreground udc:hover:bg-hover\",\n off && \"udc:text-muted-foreground udc:line-through\",\n )}\n >\n <span\n className={cn(\n \"udc:inline-block udc:h-0.5 udc:w-3.5 udc:rounded-full\",\n opts.type !== \"line\" && \"udc:h-2.5 udc:w-2.5 udc:rounded-sm\",\n off && \"udc:opacity-30\",\n )}\n style={{ background: seriesColor(s, i) }}\n />\n {fieldLabel(s.field, s.label)}\n {sides.length > 1 ? (\n <span className=\"udc:text-muted-foreground\">\n {s.axis === \"left\" ? \"◂\" : \"▸\"}\n </span>\n ) : null}\n </button>\n </li>\n );\n })}\n </ul>\n ) : null}\n </div>\n );\n}\n\nfunction TooltipBox({ children, testId }: { children: ReactNode; testId: string }) {\n return (\n <div\n data-testid={testId}\n className=\"udc:min-w-40 udc:rounded-md udc:border udc:border-border udc:bg-surface-raised udc:px-3 udc:py-2 udc:text-xs udc:text-foreground udc:shadow-md\"\n >\n {children}\n </div>\n );\n}\n\n/** One point: its x as the table shows it, then every visible series' value, formatted the same way. */\nfunction SeriesTooltip({\n active,\n point,\n describe,\n opts,\n hidden,\n fieldLabel,\n bucket,\n}: {\n active: boolean;\n point: ChartPoint | undefined;\n describe: DescribeResponse;\n opts: ChartOptions;\n hidden: ReadonlySet<string>;\n fieldLabel: (field: string, label?: string) => string;\n bucket: number;\n}) {\n const { t, locale, intlLocale } = useI18n();\n if (!active || !point) return null;\n const x = opts.x_field ?? \"\";\n const xValue = point[X_KEY];\n const count = Number(point[COUNT_KEY] ?? 1);\n return (\n <TooltipBox testId=\"chart-tooltip\">\n <div\n className=\"udc:mb-1.5 udc:font-medium udc:text-muted-foreground\"\n data-testid=\"chart-tooltip-x\"\n >\n <CellValue\n value={typeof xValue === \"number\" ? new Date(xValue).toISOString() : xValue}\n column={columnOf(describe, x)}\n def={describe.schema.fields[x]}\n locale={locale}\n intlLocale={intlLocale}\n />\n </div>\n <table className=\"udc:w-full\">\n <tbody>\n {opts.series.map((s, i) =>\n hidden.has(s.field) ? null : (\n <tr key={s.field} data-testid=\"chart-tooltip-row\" data-field={s.field}>\n <td className=\"udc:pr-3\">\n <span className=\"udc:inline-flex udc:items-center udc:gap-1.5\">\n <span\n className=\"udc:inline-block udc:size-2 udc:rounded-full\"\n style={{ background: seriesColor(s, i) }}\n />\n {fieldLabel(s.field, s.label)}\n </span>\n </td>\n <td\n className=\"udc:text-right udc:font-medium udc:tabular-nums\"\n data-testid=\"chart-tooltip-value\"\n >\n <CellValue\n value={point[s.field]}\n column={columnOf(describe, s.field)}\n def={describe.schema.fields[s.field]}\n locale={locale}\n intlLocale={intlLocale}\n />\n </td>\n </tr>\n ),\n )}\n </tbody>\n </table>\n {count > 1 ? (\n <div className=\"udc:mt-1.5 udc:text-[11px] udc:text-muted-foreground\">\n {t(\"APP\", bucket > 1 ? \"CHART_BUCKET_ROWS\" : \"CHART_MERGED_ROWS\", { count })}\n </div>\n ) : null}\n </TooltipBox>\n );\n}\n\nconst OTHER_COLOR = \"var(--sem-muted)\";\n\nfunction PieView({ collection, describe, rows, opts }: ChartViewProps) {\n const { t, locale, intlLocale } = useI18n();\n const fieldLabel = useFieldLabel(collection);\n const [ref, width] = useWidth<HTMLDivElement>();\n const category = opts.category_field ?? \"\";\n const value = opts.value_field ?? \"\";\n const slices = useMemo(\n () => foldSlices(rows, category, value, opts.max_slices),\n [rows, category, value, opts.max_slices],\n );\n const sum = slices.reduce((s, x) => s + x.value, 0);\n const pct = (v: number) =>\n new Intl.NumberFormat(intlLocale, { style: \"percent\", maximumFractionDigits: 1 }).format(\n sum > 0 ? v / sum : 0,\n );\n const nameOf = (s: PieSlice) => (s.other ? t(\"APP\", \"CHART_OTHER\") : s.category || \"—\");\n const colorOf = (s: PieSlice, i: number) =>\n s.other ? OTHER_COLOR : `var(--chart-${(i % CHART_SLOTS) + 1})`;\n const data = slices.map((s, i) => ({ ...s, name: nameOf(s), fill: colorOf(s, i) }));\n const radius = Math.max(60, Math.min(opts.height_px / 2 - 40, width / 4));\n\n if (slices.length === 0) {\n return <EmptyState filtered={false} onClear={() => {}} body={opts.empty_label} />;\n }\n return (\n <div\n ref={ref}\n className=\"udc:flex udc:flex-wrap udc:items-center udc:justify-center udc:gap-6 udc:px-4 udc:pt-4 udc:pb-2\"\n data-testid=\"chart\"\n data-type=\"pie\"\n data-slices={slices.length}\n data-other={slices.some((s) => s.other)}\n >\n <PieChart width={Math.min(width - 32, radius * 2 + 360)} height={opts.height_px}>\n <Pie\n data={data}\n dataKey=\"value\"\n nameKey=\"name\"\n innerRadius={radius * 0.55}\n outerRadius={radius}\n paddingAngle={1}\n stroke=\"var(--surface)\"\n strokeWidth={2}\n isAnimationActive={false}\n // Labels wear the text ink, not the slice's colour; the slice beside them says which.\n label={(e: PieLabelRenderProps) => (\n <text\n x={e.x}\n y={e.y}\n textAnchor={e.textAnchor}\n dominantBaseline=\"central\"\n fill=\"var(--muted-foreground)\"\n fontSize={11}\n data-testid=\"chart-slice-label\"\n >\n {`${e.name ?? \"\"} ${pct(Number(e.value ?? 0))}`}\n </text>\n )}\n labelLine={false}\n >\n {data.map((s) => (\n <Cell\n key={s.other ? \"__other\" : s.category}\n fill={s.fill}\n data-testid=\"chart-slice\"\n data-other={s.other === true}\n />\n ))}\n </Pie>\n <Tooltip\n isAnimationActive={false}\n content={(p) => {\n const s = p.payload?.[0]?.payload as (PieSlice & { name: string }) | undefined;\n if (!p.active || !s) return null;\n return (\n <TooltipBox testId=\"chart-tooltip\">\n <div className=\"udc:mb-1 udc:font-medium\">{s.name}</div>\n <div className=\"udc:flex udc:justify-between udc:gap-4\">\n <span className=\"udc:text-muted-foreground\">{fieldLabel(value)}</span>\n <span\n className=\"udc:font-medium udc:tabular-nums\"\n data-testid=\"chart-tooltip-value\"\n >\n <CellValue\n value={s.value}\n column={columnOf(describe, value)}\n def={describe.schema.fields[value]}\n locale={locale}\n intlLocale={intlLocale}\n />{\" \"}\n · {pct(s.value)}\n </span>\n </div>\n {s.other ? (\n <div className=\"udc:mt-1 udc:text-[11px] udc:text-muted-foreground\">\n {t(\"APP\", \"CHART_OTHER_COUNT\", { count: s.count })}\n </div>\n ) : null}\n </TooltipBox>\n );\n }}\n />\n </PieChart>\n {opts.legend ? (\n <ul className=\"udc:grid udc:gap-1 udc:text-xs\" data-testid=\"chart-legend\">\n {data.map((s) => (\n <li\n key={s.other ? \"__other\" : s.category}\n className=\"udc:flex udc:items-center udc:gap-2\"\n data-testid=\"chart-legend-item\"\n >\n <span\n className=\"udc:inline-block udc:size-2.5 udc:rounded-sm\"\n style={{ background: s.fill }}\n />\n <span className=\"udc:min-w-0 udc:truncate\">{s.name}</span>\n <span className=\"udc:ml-auto udc:pl-3 udc:text-muted-foreground udc:tabular-nums\">\n {pct(s.value)}\n </span>\n </li>\n ))}\n </ul>\n ) : null}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAqDA,SAAgB,cAAc,OAAsB;CAClD,MAAM,OAAO,MAAM,SAAS,KAAK;CACjC,MAAM,EAAE,MAAM,QAAQ;CACtB,IAAI,CAAC,MACH,OACE,oBAAC,OAAD;EACE,WAAU;EACV,eAAY;EAEX,UAAA,EAAE,OAAO,kBAAkB;CACzB,CAAA;CAGT,OAAO,oBAAC,UAAD;EAAU,GAAI;EAAa;CAAO,CAAA;AAC3C;AAEA,SAAS,SAAS,EAChB,YACA,UACA,QACA,YACA,kBACA,aACA,UACA,gBACA,SACA,QACyC;CACzC,MAAM,EAAE,aAAa,SAAS;CAC9B,MAAM,EAAE,QAAQ,cAAc,SAAS;CACvC,MAAM,QAAQ,WAAW,MAAM,MAAM;CAErC,MAAM,OACJ,KAAK,SAAS,QACV,CAAC;EAAE,OAAO,KAAK,eAAe;EAAI,KAAK;CAAgB,CAAC,IACxD,UAAU,UAAU,KAAK,UACvB,CAAC,EAAE,OAAO,KAAK,QAAQ,CAAC,IACxB,CAAC;CACT,MAAM,IAAI,cAAc;EACtB;EACA;EACA;EACA;EACA,KAAK,KAAK;EACV,iBAAiB,KAAK;EACtB,QAAQ;CACV,CAAC;CAED,MAAM,UAAU,iBAAiB;EAC/B;EACA,QAAQ;EACR,MAAM;EACN,WAAW;EACX,SAAS,gBAAgB,KAAA;EACzB;EACA,QAAQ;CACV,CAAC;CAED,MAAM,WAAW,gBAAgB,KAAA;CACjC,MAAM,cAAc,WAAW,QAAQ,QAAQ;CAC/C,gBAAgB;EACd,IAAI,EAAE,UAAU,MAAM;GACpB,QAAQ,IAAI;GACZ;EACF;EACA,QAAQ;GACN,OAAO,EAAE;GACT,OAAO,eAAe,EAAE;GACxB,GAAI,WAAW,EAAE,MAAM,QAAiB,IAAI,C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AD;QAAK,WAAU;QAA4B,UAAA,EAAE;OAAU,CAAA;OACvD,qBAAC,OAAD;QAAK,WAAU;QAAf,UAAA,CACE,oBAAC,QAAD;SAAM,WAAU;SAA6B,UAAA,WAAW,KAAK;QAAQ,CAAA,GACrE,qBAAC,QAAD;SACE,WAAU;SACV,eAAY;SAFd,UAAA;UAIE,oBAAC,WAAD;WACE,OAAO,EAAE;WACT,QAAQ,SAAS,UAAU,KAAK;WAChC,KAAK,SAAS,OAAO,OAAO;WACpB;WACI;UACb,CAAA;UAAE;UAAI;UACJ,IAAI,EAAE,KAAK;SACV;QACH,CAAA,CAAA;;OACJ,EAAE,QACD,oBAAC,OAAD;QAAK,WAAU;QACZ,UAAA,EAAE,OAAO,qBAAqB,EAAE,OAAO,EAAE,MAAM,CAAC;OAC9C,CAAA,IACH;MACM;;IAEhB;GACD,CAAA,CACO;EACT,CAAA,GAAA,KAAK,SACJ,oBAAC,MAAD;GAAI,WAAU;GAAiC,eAAY;GACxD,UAAA,KAAK,KAAK,MACT,qBAAC,MAAD;IAEE,WAAU;IACV,eAAY;IAHd,UAAA;KAKE,oBAAC,QAAD;MACE,WAAU;MACV,OAAO,EAAE,YAAY,EAAE,KAAK;KAC7B,CAAA;KACD,oBAAC,QAAD;MAAM,WAAU;MAA4B,UAAA,EAAE;KAAW,CAAA;KACzD,oBAAC,QAAD;MAAM,WAAU;MACb,UAAA,IAAI,EAAE,KAAK;KACR,CAAA;IACJ;GAZG,GAAA,EAAE,QAAQ,YAAY,EAAE,QAY3B,CACL;EACC,CAAA,IACF,IACD;;AAET"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { useI18n } from "../i18n/i18n.js";
|
|
2
2
|
import { useUiKit } from "../ui-kit/context.js";
|
|
3
3
|
import { wallOf } from "./window.js";
|
|
4
|
-
import { X } from "lucide-react";
|
|
5
|
-
import { useId } from "react";
|
|
6
4
|
import { parseWindowPreset } from "@jsudc/core";
|
|
5
|
+
import { useId } from "react";
|
|
6
|
+
import { X } from "lucide-react";
|
|
7
7
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
8
|
// src/chart/ChartWindowControl.tsx
|
|
9
9
|
var CUSTOM = "custom";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { cn } from "../../lib/utils.js";
|
|
2
|
-
import { Check, Minus } from "lucide-react";
|
|
3
2
|
import { forwardRef } from "react";
|
|
3
|
+
import { Check, Minus } from "lucide-react";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
5
|
import { Checkbox } from "radix-ui";
|
|
6
6
|
// src/components/ui/checkbox.tsx
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { UDC_SCOPE_CLASS } from "../../lib/scope.js";
|
|
1
2
|
import { cn } from "../../lib/utils.js";
|
|
2
|
-
import { X } from "lucide-react";
|
|
3
3
|
import { forwardRef } from "react";
|
|
4
|
+
import { X } from "lucide-react";
|
|
4
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
6
|
import { Dialog } from "radix-ui";
|
|
6
7
|
// src/components/ui/dialog.tsx
|
|
@@ -9,9 +10,9 @@ var DialogTrigger = Dialog.Trigger;
|
|
|
9
10
|
var DialogClose = Dialog.Close;
|
|
10
11
|
/** A centred Radix dialog over a dimmed backdrop, with a title row and a close button. */
|
|
11
12
|
var DialogContent = forwardRef(function DialogContent({ className, title, description, children, ...props }, ref) {
|
|
12
|
-
return /* @__PURE__ */ jsxs(Dialog.Portal, { children: [/* @__PURE__ */ jsx(Dialog.Overlay, { className: "udc:fixed udc:inset-0 udc:z-50 udc:bg-black/35 udc:data-[state=open]:animate-[overlay-in_140ms_ease-out] udc:dark:bg-black/55" }), /* @__PURE__ */ jsxs(Dialog.Content, {
|
|
13
|
+
return /* @__PURE__ */ jsxs(Dialog.Portal, { children: [/* @__PURE__ */ jsx(Dialog.Overlay, { className: cn(UDC_SCOPE_CLASS, "udc:fixed udc:inset-0 udc:z-50 udc:bg-black/35 udc:data-[state=open]:animate-[overlay-in_140ms_ease-out] udc:dark:bg-black/55") }), /* @__PURE__ */ jsxs(Dialog.Content, {
|
|
13
14
|
ref,
|
|
14
|
-
className: cn("udc:fixed udc:top-[12vh] udc:left-1/2 udc:z-50 udc:flex udc:max-h-[80vh] udc:w-[calc(100vw-2rem)] udc:max-w-md udc:-translate-x-1/2 udc:flex-col udc:rounded-xl udc:border udc:border-border udc:bg-surface-raised udc:text-foreground udc:shadow-2xl udc:shadow-black/15 udc:outline-none", "udc:data-[state=open]:animate-in udc:dark:shadow-black/50", className),
|
|
15
|
+
className: cn(UDC_SCOPE_CLASS, "udc:fixed udc:top-[12vh] udc:left-1/2 udc:z-50 udc:flex udc:max-h-[80vh] udc:w-[calc(100vw-2rem)] udc:max-w-md udc:-translate-x-1/2 udc:flex-col udc:rounded-xl udc:border udc:border-border udc:bg-surface-raised udc:text-foreground udc:shadow-2xl udc:shadow-black/15 udc:outline-none", "udc:data-[state=open]:animate-in udc:dark:shadow-black/50", className),
|
|
15
16
|
...description ? {} : { "aria-describedby": void 0 },
|
|
16
17
|
...props,
|
|
17
18
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialog.js","names":["Dialog","D"],"sources":["../../../src/components/ui/dialog.tsx"],"sourcesContent":["import { X } from \"lucide-react\";\nimport { Dialog as D } from \"radix-ui\";\nimport { type ComponentProps, forwardRef, type ReactNode } from \"react\";\nimport { cn } from \"../../lib/utils.js\";\n\nexport const Dialog = D.Root;\nexport const DialogTrigger = D.Trigger;\nexport const DialogClose = D.Close;\n\n/** A centred Radix dialog over a dimmed backdrop, with a title row and a close button. */\nexport const DialogContent = forwardRef<\n HTMLDivElement,\n // The HTML `title` attribute is dropped: here it is the heading, any node.\n Omit<ComponentProps<typeof D.Content>, \"title\"> & { title: ReactNode; description?: ReactNode }\n>(function DialogContent({ className, title, description, children, ...props }, ref) {\n return (\n <D.Portal>\n <D.Overlay
|
|
1
|
+
{"version":3,"file":"dialog.js","names":["Dialog","D"],"sources":["../../../src/components/ui/dialog.tsx"],"sourcesContent":["import { X } from \"lucide-react\";\nimport { Dialog as D } from \"radix-ui\";\nimport { type ComponentProps, forwardRef, type ReactNode } from \"react\";\nimport { UDC_SCOPE_CLASS } from \"../../lib/scope.js\";\nimport { cn } from \"../../lib/utils.js\";\n\nexport const Dialog = D.Root;\nexport const DialogTrigger = D.Trigger;\nexport const DialogClose = D.Close;\n\n/** A centred Radix dialog over a dimmed backdrop, with a title row and a close button. */\nexport const DialogContent = forwardRef<\n HTMLDivElement,\n // The HTML `title` attribute is dropped: here it is the heading, any node.\n Omit<ComponentProps<typeof D.Content>, \"title\"> & { title: ReactNode; description?: ReactNode }\n>(function DialogContent({ className, title, description, children, ...props }, ref) {\n return (\n <D.Portal>\n <D.Overlay\n className={cn(\n UDC_SCOPE_CLASS,\n \"udc:fixed udc:inset-0 udc:z-50 udc:bg-black/35 udc:data-[state=open]:animate-[overlay-in_140ms_ease-out] udc:dark:bg-black/55\",\n )}\n />\n <D.Content\n ref={ref}\n className={cn(\n UDC_SCOPE_CLASS,\n \"udc:fixed udc:top-[12vh] udc:left-1/2 udc:z-50 udc:flex udc:max-h-[80vh] udc:w-[calc(100vw-2rem)] udc:max-w-md udc:-translate-x-1/2 udc:flex-col udc:rounded-xl udc:border udc:border-border udc:bg-surface-raised udc:text-foreground udc:shadow-2xl udc:shadow-black/15 udc:outline-none\",\n \"udc:data-[state=open]:animate-in udc:dark:shadow-black/50\",\n className,\n )}\n {...(description ? {} : { \"aria-describedby\": undefined })}\n {...props}\n >\n <div className=\"udc:flex udc:items-start udc:gap-3 udc:px-5 udc:pt-4 udc:pb-3\">\n <div className=\"udc:min-w-0 udc:flex-1\">\n <D.Title className=\"udc:text-[15px] udc:font-semibold udc:tracking-tight\">\n {title}\n </D.Title>\n {description ? (\n <D.Description className=\"udc:mt-1 udc:text-[13px] udc:text-muted-foreground\">\n {description}\n </D.Description>\n ) : null}\n </div>\n <D.Close\n aria-label=\"Close\"\n className=\"udc:-mr-1.5 udc:rounded-md udc:p-1 udc:text-muted-foreground udc:outline-none udc:hover:bg-hover udc:hover:text-foreground udc:focus-visible:ring-2 udc:focus-visible:ring-ring\"\n >\n <X className=\"udc:size-4\" />\n </D.Close>\n </div>\n {children}\n </D.Content>\n </D.Portal>\n );\n});\n\n/** The scrolling middle of a dialog. */\nexport function DialogBody({ className, ...props }: ComponentProps<\"div\">) {\n return (\n <div\n className={cn(\"udc-scroll-thin udc:min-h-0 udc:overflow-y-auto udc:px-5 udc:pb-4\", className)}\n {...props}\n />\n );\n}\n\n/** The button row at the bottom of a dialog. */\nexport function DialogFooter({ className, ...props }: ComponentProps<\"div\">) {\n return (\n <div\n className={cn(\n \"udc:flex udc:items-center udc:justify-end udc:gap-2 udc:rounded-b-xl udc:border-t udc:border-border udc:bg-muted/50 udc:px-5 udc:py-3\",\n className,\n )}\n {...props}\n />\n );\n}\n"],"mappings":";;;;;;;AAMA,IAAaA,WAASC,OAAE;AACxB,IAAa,gBAAgBA,OAAE;AAC/B,IAAa,cAAcA,OAAE;;AAG7B,IAAa,gBAAgB,WAI3B,SAAS,cAAc,EAAE,WAAW,OAAO,aAAa,UAAU,GAAG,SAAS,KAAK;CACnF,OACE,qBAACA,OAAE,QAAH,EAAA,UAAA,CACE,oBAACA,OAAE,SAAH,EACE,WAAW,GACT,iBACA,+HACF,EACD,CAAA,GACD,qBAACA,OAAE,SAAH;EACO;EACL,WAAW,GACT,iBACA,8RACA,6DACA,SACF;EACA,GAAK,cAAc,CAAC,IAAI,EAAE,oBAAoB,KAAA,EAAU;EACxD,GAAI;EATN,UAAA,CAWE,qBAAC,OAAD;GAAK,WAAU;GAAf,UAAA,CACE,qBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACE,oBAACA,OAAE,OAAH;KAAS,WAAU;KAChB,UAAA;IACM,CAAA,GACR,cACC,oBAACA,OAAE,aAAH;KAAe,WAAU;KACtB,UAAA;IACY,CAAA,IACb,IACD;GACL,CAAA,GAAA,oBAACA,OAAE,OAAH;IACE,cAAW;IACX,WAAU;IAEV,UAAA,oBAAC,GAAD,EAAG,WAAU,aAAc,CAAA;GACpB,CAAA,CACN;EACJ,CAAA,GAAA,QACQ;CACH,CAAA,CAAA,EAAA,CAAA;AAEd,CAAC;;AAGD,SAAgB,WAAW,EAAE,WAAW,GAAG,SAAgC;CACzE,OACE,oBAAC,OAAD;EACE,WAAW,GAAG,qEAAqE,SAAS;EAC5F,GAAI;CACL,CAAA;AAEL;;AAGA,SAAgB,aAAa,EAAE,WAAW,GAAG,SAAgC;CAC3E,OACE,oBAAC,OAAD;EACE,WAAW,GACT,yIACA,SACF;EACA,GAAI;CACL,CAAA;AAEL"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { UDC_SCOPE_CLASS } from "../../lib/scope.js";
|
|
1
2
|
import { cn } from "../../lib/utils.js";
|
|
2
3
|
import { forwardRef } from "react";
|
|
3
4
|
import { jsx } from "react/jsx-runtime";
|
|
@@ -10,7 +11,7 @@ var DropdownMenuContent = forwardRef(function DropdownMenuContent({ className, a
|
|
|
10
11
|
ref,
|
|
11
12
|
align,
|
|
12
13
|
sideOffset,
|
|
13
|
-
className: cn("udc:z-50 udc:min-w-48 udc:rounded-lg udc:border udc:border-border udc:bg-surface-raised udc:p-1 udc:text-foreground udc:shadow-lg udc:shadow-black/5 udc:outline-none", "udc:data-[state=open]:animate-in udc:dark:shadow-black/40", className),
|
|
14
|
+
className: cn(UDC_SCOPE_CLASS, "udc:z-50 udc:min-w-48 udc:rounded-lg udc:border udc:border-border udc:bg-surface-raised udc:p-1 udc:text-foreground udc:shadow-lg udc:shadow-black/5 udc:outline-none", "udc:data-[state=open]:animate-in udc:dark:shadow-black/40", className),
|
|
14
15
|
...props
|
|
15
16
|
}) });
|
|
16
17
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dropdown-menu.js","names":["DropdownMenu","M"],"sources":["../../../src/components/ui/dropdown-menu.tsx"],"sourcesContent":["import { DropdownMenu as M } from \"radix-ui\";\nimport { type ComponentProps, forwardRef } from \"react\";\nimport { cn } from \"../../lib/utils.js\";\n\nexport const DropdownMenu = M.Root;\nexport const DropdownMenuTrigger = M.Trigger;\n\nexport const DropdownMenuContent = forwardRef<HTMLDivElement, ComponentProps<typeof M.Content>>(\n function DropdownMenuContent({ className, align = \"end\", sideOffset = 4, ...props }, ref) {\n return (\n <M.Portal>\n <M.Content\n ref={ref}\n align={align}\n sideOffset={sideOffset}\n className={cn(\n \"udc:z-50 udc:min-w-48 udc:rounded-lg udc:border udc:border-border udc:bg-surface-raised udc:p-1 udc:text-foreground udc:shadow-lg udc:shadow-black/5 udc:outline-none\",\n \"udc:data-[state=open]:animate-in udc:dark:shadow-black/40\",\n className,\n )}\n {...props}\n />\n </M.Portal>\n );\n },\n);\n\nexport const DropdownMenuItem = forwardRef<\n HTMLDivElement,\n ComponentProps<typeof M.Item> & { tone?: \"default\" | \"danger\" }\n>(function DropdownMenuItem({ className, tone = \"default\", ...props }, ref) {\n return (\n <M.Item\n ref={ref}\n className={cn(\n \"udc:flex udc:h-8 udc:cursor-default udc:select-none udc:items-center udc:gap-2 udc:rounded-md udc:px-2 udc:text-[13px] udc:outline-none udc:[&_svg]:size-4 udc:[&_svg]:shrink-0\",\n tone === \"danger\"\n ? \"udc:text-sem-danger udc:data-[highlighted]:bg-sem-danger-bg\"\n : \"udc:data-[highlighted]:bg-hover udc:[&_svg]:text-muted-foreground\",\n \"udc:data-[disabled]:pointer-events-none udc:data-[disabled]:opacity-50\",\n className,\n )}\n {...props}\n />\n );\n});\n\nexport function DropdownMenuSeparator({ className }: { className?: string }) {\n return <M.Separator className={cn(\"udc:my-1 udc:h-px udc:bg-border\", className)} />;\n}\n\nexport function DropdownMenuLabel({ className, ...props }: ComponentProps<typeof M.Label>) {\n return (\n <M.Label\n className={cn(\n \"udc:px-2 udc:pt-1.5 udc:pb-1 udc:text-[11px] udc:font-medium udc:text-muted-foreground\",\n className,\n )}\n {...props}\n />\n );\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"dropdown-menu.js","names":["DropdownMenu","M"],"sources":["../../../src/components/ui/dropdown-menu.tsx"],"sourcesContent":["import { DropdownMenu as M } from \"radix-ui\";\nimport { type ComponentProps, forwardRef } from \"react\";\nimport { UDC_SCOPE_CLASS } from \"../../lib/scope.js\";\nimport { cn } from \"../../lib/utils.js\";\n\nexport const DropdownMenu = M.Root;\nexport const DropdownMenuTrigger = M.Trigger;\n\nexport const DropdownMenuContent = forwardRef<HTMLDivElement, ComponentProps<typeof M.Content>>(\n function DropdownMenuContent({ className, align = \"end\", sideOffset = 4, ...props }, ref) {\n return (\n <M.Portal>\n <M.Content\n ref={ref}\n align={align}\n sideOffset={sideOffset}\n className={cn(\n UDC_SCOPE_CLASS,\n \"udc:z-50 udc:min-w-48 udc:rounded-lg udc:border udc:border-border udc:bg-surface-raised udc:p-1 udc:text-foreground udc:shadow-lg udc:shadow-black/5 udc:outline-none\",\n \"udc:data-[state=open]:animate-in udc:dark:shadow-black/40\",\n className,\n )}\n {...props}\n />\n </M.Portal>\n );\n },\n);\n\nexport const DropdownMenuItem = forwardRef<\n HTMLDivElement,\n ComponentProps<typeof M.Item> & { tone?: \"default\" | \"danger\" }\n>(function DropdownMenuItem({ className, tone = \"default\", ...props }, ref) {\n return (\n <M.Item\n ref={ref}\n className={cn(\n \"udc:flex udc:h-8 udc:cursor-default udc:select-none udc:items-center udc:gap-2 udc:rounded-md udc:px-2 udc:text-[13px] udc:outline-none udc:[&_svg]:size-4 udc:[&_svg]:shrink-0\",\n tone === \"danger\"\n ? \"udc:text-sem-danger udc:data-[highlighted]:bg-sem-danger-bg\"\n : \"udc:data-[highlighted]:bg-hover udc:[&_svg]:text-muted-foreground\",\n \"udc:data-[disabled]:pointer-events-none udc:data-[disabled]:opacity-50\",\n className,\n )}\n {...props}\n />\n );\n});\n\nexport function DropdownMenuSeparator({ className }: { className?: string }) {\n return <M.Separator className={cn(\"udc:my-1 udc:h-px udc:bg-border\", className)} />;\n}\n\nexport function DropdownMenuLabel({ className, ...props }: ComponentProps<typeof M.Label>) {\n return (\n <M.Label\n className={cn(\n \"udc:px-2 udc:pt-1.5 udc:pb-1 udc:text-[11px] udc:font-medium udc:text-muted-foreground\",\n className,\n )}\n {...props}\n />\n );\n}\n"],"mappings":";;;;;;AAKA,IAAaA,iBAAeC,aAAE;AAC9B,IAAa,sBAAsBA,aAAE;AAErC,IAAa,sBAAsB,WACjC,SAAS,oBAAoB,EAAE,WAAW,QAAQ,OAAO,aAAa,GAAG,GAAG,SAAS,KAAK;CACxF,OACE,oBAACA,aAAE,QAAH,EAAA,UACE,oBAACA,aAAE,SAAH;EACO;EACE;EACK;EACZ,WAAW,GACT,iBACA,yKACA,6DACA,SACF;EACA,GAAI;CACL,CAAA,EACO,CAAA;AAEd,CACF;AAEA,IAAa,mBAAmB,WAG9B,SAAS,iBAAiB,EAAE,WAAW,OAAO,WAAW,GAAG,SAAS,KAAK;CAC1E,OACE,oBAACA,aAAE,MAAH;EACO;EACL,WAAW,GACT,mLACA,SAAS,WACL,gEACA,qEACJ,0EACA,SACF;EACA,GAAI;CACL,CAAA;AAEL,CAAC;AAED,SAAgB,sBAAsB,EAAE,aAAqC;CAC3E,OAAO,oBAACA,aAAE,WAAH,EAAa,WAAW,GAAG,mCAAmC,SAAS,EAAI,CAAA;AACpF;AAEA,SAAgB,kBAAkB,EAAE,WAAW,GAAG,SAAyC;CACzF,OACE,oBAACA,aAAE,OAAH;EACE,WAAW,GACT,0FACA,SACF;EACA,GAAI;CACL,CAAA;AAEL"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { UDC_SCOPE_CLASS } from "../../lib/scope.js";
|
|
1
2
|
import { cn } from "../../lib/utils.js";
|
|
2
3
|
import { forwardRef } from "react";
|
|
3
4
|
import { jsx } from "react/jsx-runtime";
|
|
@@ -12,7 +13,7 @@ var PopoverContent = forwardRef(function PopoverContent({ className, align = "st
|
|
|
12
13
|
ref,
|
|
13
14
|
align,
|
|
14
15
|
sideOffset,
|
|
15
|
-
className: cn("udc:z-50 udc:rounded-lg udc:border udc:border-border udc:bg-surface-raised udc:p-3 udc:text-foreground udc:shadow-lg udc:shadow-black/5 udc:outline-none", "udc:data-[state=open]:animate-in udc:dark:shadow-black/40", className),
|
|
16
|
+
className: cn(UDC_SCOPE_CLASS, "udc:z-50 udc:rounded-lg udc:border udc:border-border udc:bg-surface-raised udc:p-3 udc:text-foreground udc:shadow-lg udc:shadow-black/5 udc:outline-none", "udc:data-[state=open]:animate-in udc:dark:shadow-black/40", className),
|
|
16
17
|
...props
|
|
17
18
|
}) });
|
|
18
19
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"popover.js","names":["Popover","P"],"sources":["../../../src/components/ui/popover.tsx"],"sourcesContent":["import { Popover as P } from \"radix-ui\";\nimport { type ComponentProps, forwardRef } from \"react\";\nimport { cn } from \"../../lib/utils.js\";\n\nexport const Popover = P.Root;\nexport const PopoverTrigger = P.Trigger;\nexport const PopoverClose = P.Close;\nexport const PopoverAnchor = P.Anchor;\n\nexport const PopoverContent = forwardRef<HTMLDivElement, ComponentProps<typeof P.Content>>(\n function PopoverContent({ className, align = \"start\", sideOffset = 6, ...props }, ref) {\n return (\n <P.Portal>\n <P.Content\n ref={ref}\n align={align}\n sideOffset={sideOffset}\n className={cn(\n \"udc:z-50 udc:rounded-lg udc:border udc:border-border udc:bg-surface-raised udc:p-3 udc:text-foreground udc:shadow-lg udc:shadow-black/5 udc:outline-none\",\n \"udc:data-[state=open]:animate-in udc:dark:shadow-black/40\",\n className,\n )}\n {...props}\n />\n </P.Portal>\n );\n },\n);\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"popover.js","names":["Popover","P"],"sources":["../../../src/components/ui/popover.tsx"],"sourcesContent":["import { Popover as P } from \"radix-ui\";\nimport { type ComponentProps, forwardRef } from \"react\";\nimport { UDC_SCOPE_CLASS } from \"../../lib/scope.js\";\nimport { cn } from \"../../lib/utils.js\";\n\nexport const Popover = P.Root;\nexport const PopoverTrigger = P.Trigger;\nexport const PopoverClose = P.Close;\nexport const PopoverAnchor = P.Anchor;\n\nexport const PopoverContent = forwardRef<HTMLDivElement, ComponentProps<typeof P.Content>>(\n function PopoverContent({ className, align = \"start\", sideOffset = 6, ...props }, ref) {\n return (\n <P.Portal>\n <P.Content\n ref={ref}\n align={align}\n sideOffset={sideOffset}\n className={cn(\n UDC_SCOPE_CLASS,\n \"udc:z-50 udc:rounded-lg udc:border udc:border-border udc:bg-surface-raised udc:p-3 udc:text-foreground udc:shadow-lg udc:shadow-black/5 udc:outline-none\",\n \"udc:data-[state=open]:animate-in udc:dark:shadow-black/40\",\n className,\n )}\n {...props}\n />\n </P.Portal>\n );\n },\n);\n"],"mappings":";;;;;;AAKA,IAAaA,YAAUC,QAAE;AACzB,IAAa,iBAAiBA,QAAE;AAChC,IAAa,eAAeA,QAAE;AAC9B,IAAa,gBAAgBA,QAAE;AAE/B,IAAa,iBAAiB,WAC5B,SAAS,eAAe,EAAE,WAAW,QAAQ,SAAS,aAAa,GAAG,GAAG,SAAS,KAAK;CACrF,OACE,oBAACA,QAAE,QAAH,EAAA,UACE,oBAACA,QAAE,SAAH;EACO;EACE;EACK;EACZ,WAAW,GACT,iBACA,4JACA,6DACA,SACF;EACA,GAAI;CACL,CAAA,EACO,CAAA;AAEd,CACF"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { UDC_SCOPE_CLASS } from "../../lib/scope.js";
|
|
1
2
|
import { cn } from "../../lib/utils.js";
|
|
2
3
|
import { Check, ChevronDown } from "lucide-react";
|
|
3
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -19,7 +20,7 @@ function Select$1({ value, onValueChange, options, placeholder, className, "aria
|
|
|
19
20
|
}), /* @__PURE__ */ jsx(Select.Portal, { children: /* @__PURE__ */ jsx(Select.Content, {
|
|
20
21
|
position: "popper",
|
|
21
22
|
sideOffset: 4,
|
|
22
|
-
className:
|
|
23
|
+
className: `${UDC_SCOPE_CLASS} udc:z-[60] udc:max-h-72 udc:min-w-[var(--radix-select-trigger-width)] udc:overflow-hidden udc:rounded-lg udc:border udc:border-border udc:bg-surface-raised udc:shadow-lg udc:shadow-black/5 udc:data-[state=open]:animate-in udc:dark:shadow-black/40`,
|
|
23
24
|
children: /* @__PURE__ */ jsx(Select.Viewport, {
|
|
24
25
|
className: "udc-scroll-thin udc:p-1",
|
|
25
26
|
children: options.map((o) => /* @__PURE__ */ jsxs(Select.Item, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select.js","names":["Select","S"],"sources":["../../../src/components/ui/select.tsx"],"sourcesContent":["import { Check, ChevronDown } from \"lucide-react\";\nimport { Select as S } from \"radix-ui\";\nimport { cn } from \"../../lib/utils.js\";\nimport type { SelectOption } from \"../../ui-kit/types.js\";\n\nexport type { SelectOption };\n\n/** A Radix select with the input look. `value` must not be \"\" (Radix reserves it). */\nexport function Select({\n value,\n onValueChange,\n options,\n placeholder,\n className,\n \"aria-label\": ariaLabel,\n \"data-testid\": testId,\n}: {\n value: string | undefined;\n onValueChange: (v: string) => void;\n options: readonly SelectOption[];\n placeholder?: string;\n className?: string;\n \"aria-label\"?: string;\n \"data-testid\"?: string;\n}) {\n return (\n <S.Root {...(value ? { value } : {})} onValueChange={onValueChange}>\n <S.Trigger\n aria-label={ariaLabel}\n data-testid={testId}\n className={cn(\n \"udc:inline-flex udc:h-8 udc:w-full udc:min-w-0 udc:items-center udc:justify-between udc:gap-1 udc:rounded-md udc:border udc:border-input udc:bg-surface udc:px-2.5 udc:text-left udc:text-[13px] udc:shadow-xs\",\n \"udc:focus-visible:border-ring udc:focus-visible:outline-none udc:focus-visible:ring-3 udc:focus-visible:ring-ring/20\",\n \"udc:data-[placeholder]:text-muted-foreground\",\n className,\n )}\n >\n <span className=\"udc:truncate\">\n <S.Value placeholder={placeholder} />\n </span>\n <S.Icon>\n <ChevronDown className=\"udc:size-3.5 udc:opacity-60\" />\n </S.Icon>\n </S.Trigger>\n <S.Portal>\n <S.Content\n position=\"popper\"\n sideOffset={4}\n className
|
|
1
|
+
{"version":3,"file":"select.js","names":["Select","S"],"sources":["../../../src/components/ui/select.tsx"],"sourcesContent":["import { Check, ChevronDown } from \"lucide-react\";\nimport { Select as S } from \"radix-ui\";\nimport { UDC_SCOPE_CLASS } from \"../../lib/scope.js\";\nimport { cn } from \"../../lib/utils.js\";\nimport type { SelectOption } from \"../../ui-kit/types.js\";\n\nexport type { SelectOption };\n\n/** A Radix select with the input look. `value` must not be \"\" (Radix reserves it). */\nexport function Select({\n value,\n onValueChange,\n options,\n placeholder,\n className,\n \"aria-label\": ariaLabel,\n \"data-testid\": testId,\n}: {\n value: string | undefined;\n onValueChange: (v: string) => void;\n options: readonly SelectOption[];\n placeholder?: string;\n className?: string;\n \"aria-label\"?: string;\n \"data-testid\"?: string;\n}) {\n return (\n <S.Root {...(value ? { value } : {})} onValueChange={onValueChange}>\n <S.Trigger\n aria-label={ariaLabel}\n data-testid={testId}\n className={cn(\n \"udc:inline-flex udc:h-8 udc:w-full udc:min-w-0 udc:items-center udc:justify-between udc:gap-1 udc:rounded-md udc:border udc:border-input udc:bg-surface udc:px-2.5 udc:text-left udc:text-[13px] udc:shadow-xs\",\n \"udc:focus-visible:border-ring udc:focus-visible:outline-none udc:focus-visible:ring-3 udc:focus-visible:ring-ring/20\",\n \"udc:data-[placeholder]:text-muted-foreground\",\n className,\n )}\n >\n <span className=\"udc:truncate\">\n <S.Value placeholder={placeholder} />\n </span>\n <S.Icon>\n <ChevronDown className=\"udc:size-3.5 udc:opacity-60\" />\n </S.Icon>\n </S.Trigger>\n <S.Portal>\n <S.Content\n position=\"popper\"\n sideOffset={4}\n className={`${UDC_SCOPE_CLASS} udc:z-[60] udc:max-h-72 udc:min-w-[var(--radix-select-trigger-width)] udc:overflow-hidden udc:rounded-lg udc:border udc:border-border udc:bg-surface-raised udc:shadow-lg udc:shadow-black/5 udc:data-[state=open]:animate-in udc:dark:shadow-black/40`}\n >\n <S.Viewport className=\"udc-scroll-thin udc:p-1\">\n {options.map((o) => (\n <S.Item\n key={o.value}\n value={o.value}\n className=\"udc:relative udc:flex udc:h-7 udc:cursor-default udc:select-none udc:items-center udc:rounded-md udc:pr-2 udc:pl-7 udc:text-[13px] udc:outline-none udc:data-[highlighted]:bg-hover udc:data-[state=checked]:font-medium\"\n >\n <S.ItemIndicator className=\"udc:absolute udc:left-2 udc:inline-flex\">\n <Check className=\"udc:size-3.5 udc:text-primary\" />\n </S.ItemIndicator>\n <S.ItemText>{o.label}</S.ItemText>\n </S.Item>\n ))}\n </S.Viewport>\n </S.Content>\n </S.Portal>\n </S.Root>\n );\n}\n"],"mappings":";;;;;;;AASA,SAAgBA,SAAO,EACrB,OACA,eACA,SACA,aACA,WACA,cAAc,WACd,eAAe,UASd;CACD,OACE,qBAACC,OAAE,MAAH;EAAQ,GAAK,QAAQ,EAAE,MAAM,IAAI,CAAC;EAAmB;EAArD,UAAA,CACE,qBAACA,OAAE,SAAH;GACE,cAAY;GACZ,eAAa;GACb,WAAW,GACT,kNACA,wHACA,gDACA,SACF;GARF,UAAA,CAUE,oBAAC,QAAD;IAAM,WAAU;IACd,UAAA,oBAACA,OAAE,OAAH,EAAsB,YAAc,CAAA;GAChC,CAAA,GACN,oBAACA,OAAE,MAAH,EAAA,UACE,oBAAC,aAAD,EAAa,WAAU,8BAA+B,CAAA,EAChD,CAAA,CACC;EACX,CAAA,GAAA,oBAACA,OAAE,QAAH,EAAA,UACE,oBAACA,OAAE,SAAH;GACE,UAAS;GACT,YAAY;GACZ,WAAW,GAAG,gBAAgB;GAE9B,UAAA,oBAACA,OAAE,UAAH;IAAY,WAAU;IACnB,UAAA,QAAQ,KAAK,MACZ,qBAACA,OAAE,MAAH;KAEE,OAAO,EAAE;KACT,WAAU;KAHZ,UAAA,CAKE,oBAACA,OAAE,eAAH;MAAiB,WAAU;MACzB,UAAA,oBAAC,OAAD,EAAO,WAAU,gCAAiC,CAAA;KACnC,CAAA,GACjB,oBAACA,OAAE,UAAH,EAAA,UAAa,EAAE,MAAkB,CAAA,CAC3B;IARD,GAAA,EAAE,KAQD,CACT;GACS,CAAA;EACH,CAAA,EACH,CAAA,CACJ;;AAEZ"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { UDC_SCOPE_CLASS } from "../../lib/scope.js";
|
|
1
2
|
import { cn } from "../../lib/utils.js";
|
|
2
|
-
import { AlertTriangle, CheckCircle2, Info, X } from "lucide-react";
|
|
3
3
|
import { createContext, useCallback, useContext, useMemo, useState } from "react";
|
|
4
|
+
import { AlertTriangle, CheckCircle2, Info, X } from "lucide-react";
|
|
4
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
6
|
import { Toast } from "radix-ui";
|
|
6
7
|
// src/components/ui/toast.tsx
|
|
@@ -57,7 +58,7 @@ function Toaster({ children }) {
|
|
|
57
58
|
})
|
|
58
59
|
]
|
|
59
60
|
}, t.id)),
|
|
60
|
-
/* @__PURE__ */ jsx(Toast.Viewport, { className:
|
|
61
|
+
/* @__PURE__ */ jsx(Toast.Viewport, { className: `${UDC_SCOPE_CLASS} udc:fixed udc:right-0 udc:bottom-0 udc:z-[100] udc:m-0 udc:flex udc:w-[380px] udc:max-w-[100vw] udc:list-none udc:flex-col udc:gap-2 udc:p-4 udc:outline-none` })
|
|
61
62
|
]
|
|
62
63
|
})
|
|
63
64
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toast.js","names":["T"],"sources":["../../../src/components/ui/toast.tsx"],"sourcesContent":["import { AlertTriangle, CheckCircle2, Info, X } from \"lucide-react\";\nimport { Toast as T } from \"radix-ui\";\nimport { createContext, type ReactNode, useCallback, useContext, useMemo, useState } from \"react\";\nimport { cn } from \"../../lib/utils.js\";\nimport type { ToastInput, ToastVariant } from \"../../ui-kit/types.js\";\n\nexport type { ToastInput, ToastVariant };\n\ninterface ToastItem extends ToastInput {\n id: number;\n}\n\nconst ToastContext = createContext<((t: ToastInput) => void) | null>(null);\n\nconst ICON: Record<ToastVariant, ReactNode> = {\n info: <Info className=\"udc:size-4 udc:text-sem-info\" />,\n success: <CheckCircle2 className=\"udc:size-4 udc:text-sem-success\" />,\n warning: <AlertTriangle className=\"udc:size-4 udc:text-sem-warning\" />,\n danger: <AlertTriangle className=\"udc:size-4 udc:text-sem-danger\" />,\n};\n\nlet nextId = 1;\n\n/** Radix toasts, stacked bottom-right. `useToast()` returns the function that shows one. */\nexport function Toaster({ children }: { children: ReactNode }) {\n const [items, setItems] = useState<ToastItem[]>([]);\n const show = useCallback((t: ToastInput) => {\n const id = nextId++;\n setItems((prev) => [...prev.slice(-3), { ...t, id }]);\n }, []);\n const remove = (id: number) => setItems((prev) => prev.filter((t) => t.id !== id));\n\n return (\n <ToastContext.Provider value={show}>\n <T.Provider swipeDirection=\"right\" duration={6000}>\n {children}\n {items.map((t) => (\n <T.Root\n key={t.id}\n data-testid=\"toast\"\n data-variant={t.variant ?? \"info\"}\n onOpenChange={(open) => !open && remove(t.id)}\n className={cn(\n \"udc:grid udc:grid-cols-[auto_1fr_auto] udc:items-start udc:gap-3 udc:rounded-lg udc:border udc:border-border udc:bg-surface-raised udc:p-3 udc:pr-2 udc:shadow-lg udc:shadow-black/10 udc:dark:shadow-black/40\",\n \"udc:data-[state=open]:animate-in udc:data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)]\",\n )}\n >\n <span className=\"udc:mt-0.5\">{ICON[t.variant ?? \"info\"]}</span>\n <div className=\"udc:min-w-0\">\n <T.Title className=\"udc:text-[13px] udc:font-semibold\">{t.title}</T.Title>\n {t.description ? (\n <T.Description className=\"udc:mt-0.5 udc:text-xs udc:text-muted-foreground\">\n {t.description}\n </T.Description>\n ) : null}\n </div>\n <T.Close\n aria-label=\"Close\"\n className=\"udc:rounded-sm udc:p-1 udc:text-muted-foreground udc:hover:bg-hover udc:hover:text-foreground\"\n >\n <X className=\"udc:size-3.5\" />\n </T.Close>\n </T.Root>\n ))}\n <T.Viewport
|
|
1
|
+
{"version":3,"file":"toast.js","names":["T"],"sources":["../../../src/components/ui/toast.tsx"],"sourcesContent":["import { AlertTriangle, CheckCircle2, Info, X } from \"lucide-react\";\nimport { Toast as T } from \"radix-ui\";\nimport { createContext, type ReactNode, useCallback, useContext, useMemo, useState } from \"react\";\nimport { UDC_SCOPE_CLASS } from \"../../lib/scope.js\";\nimport { cn } from \"../../lib/utils.js\";\nimport type { ToastInput, ToastVariant } from \"../../ui-kit/types.js\";\n\nexport type { ToastInput, ToastVariant };\n\ninterface ToastItem extends ToastInput {\n id: number;\n}\n\nconst ToastContext = createContext<((t: ToastInput) => void) | null>(null);\n\nconst ICON: Record<ToastVariant, ReactNode> = {\n info: <Info className=\"udc:size-4 udc:text-sem-info\" />,\n success: <CheckCircle2 className=\"udc:size-4 udc:text-sem-success\" />,\n warning: <AlertTriangle className=\"udc:size-4 udc:text-sem-warning\" />,\n danger: <AlertTriangle className=\"udc:size-4 udc:text-sem-danger\" />,\n};\n\nlet nextId = 1;\n\n/** Radix toasts, stacked bottom-right. `useToast()` returns the function that shows one. */\nexport function Toaster({ children }: { children: ReactNode }) {\n const [items, setItems] = useState<ToastItem[]>([]);\n const show = useCallback((t: ToastInput) => {\n const id = nextId++;\n setItems((prev) => [...prev.slice(-3), { ...t, id }]);\n }, []);\n const remove = (id: number) => setItems((prev) => prev.filter((t) => t.id !== id));\n\n return (\n <ToastContext.Provider value={show}>\n <T.Provider swipeDirection=\"right\" duration={6000}>\n {children}\n {items.map((t) => (\n <T.Root\n key={t.id}\n data-testid=\"toast\"\n data-variant={t.variant ?? \"info\"}\n onOpenChange={(open) => !open && remove(t.id)}\n className={cn(\n \"udc:grid udc:grid-cols-[auto_1fr_auto] udc:items-start udc:gap-3 udc:rounded-lg udc:border udc:border-border udc:bg-surface-raised udc:p-3 udc:pr-2 udc:shadow-lg udc:shadow-black/10 udc:dark:shadow-black/40\",\n \"udc:data-[state=open]:animate-in udc:data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)]\",\n )}\n >\n <span className=\"udc:mt-0.5\">{ICON[t.variant ?? \"info\"]}</span>\n <div className=\"udc:min-w-0\">\n <T.Title className=\"udc:text-[13px] udc:font-semibold\">{t.title}</T.Title>\n {t.description ? (\n <T.Description className=\"udc:mt-0.5 udc:text-xs udc:text-muted-foreground\">\n {t.description}\n </T.Description>\n ) : null}\n </div>\n <T.Close\n aria-label=\"Close\"\n className=\"udc:rounded-sm udc:p-1 udc:text-muted-foreground udc:hover:bg-hover udc:hover:text-foreground\"\n >\n <X className=\"udc:size-3.5\" />\n </T.Close>\n </T.Root>\n ))}\n <T.Viewport\n className={`${UDC_SCOPE_CLASS} udc:fixed udc:right-0 udc:bottom-0 udc:z-[100] udc:m-0 udc:flex udc:w-[380px] udc:max-w-[100vw] udc:list-none udc:flex-col udc:gap-2 udc:p-4 udc:outline-none`}\n />\n </T.Provider>\n </ToastContext.Provider>\n );\n}\n\nexport function useToast() {\n const show = useContext(ToastContext);\n if (!show) throw new Error(\"useToast needs a <Toaster> above it\");\n return useMemo(() => ({ toast: show }), [show]);\n}\n"],"mappings":";;;;;;;AAaA,IAAM,eAAe,cAAgD,IAAI;AAEzE,IAAM,OAAwC;CAC5C,MAAM,oBAAC,MAAD,EAAM,WAAU,+BAAgC,CAAA;CACtD,SAAS,oBAAC,cAAD,EAAc,WAAU,kCAAmC,CAAA;CACpE,SAAS,oBAAC,eAAD,EAAe,WAAU,kCAAmC,CAAA;CACrE,QAAQ,oBAAC,eAAD,EAAe,WAAU,iCAAkC,CAAA;AACrE;AAEA,IAAI,SAAS;;AAGb,SAAgB,QAAQ,EAAE,YAAqC;CAC7D,MAAM,CAAC,OAAO,YAAY,SAAsB,CAAC,CAAC;CAClD,MAAM,OAAO,aAAa,MAAkB;EAC1C,MAAM,KAAK;EACX,UAAU,SAAS,CAAC,GAAG,KAAK,MAAM,EAAE,GAAG;GAAE,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ip } from "radix-ui";
|
|
3
4
|
// src/components/ui/tooltip.tsx
|
|
@@ -10,7 +11,7 @@ function Tip({ label, children, side = "bottom" }) {
|
|
|
10
11
|
}), /* @__PURE__ */ jsx(Tooltip.Portal, { children: /* @__PURE__ */ jsx(Tooltip.Content, {
|
|
11
12
|
side,
|
|
12
13
|
sideOffset: 6,
|
|
13
|
-
className:
|
|
14
|
+
className: `${UDC_SCOPE_CLASS} udc:z-50 udc:rounded-md udc:bg-foreground udc:px-2 udc:py-1 udc:text-xs udc:font-medium udc:text-background udc:shadow-md udc:data-[state=delayed-open]:animate-in`,
|
|
14
15
|
children: label
|
|
15
16
|
}) })] });
|
|
16
17
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tooltip.js","names":["T"],"sources":["../../../src/components/ui/tooltip.tsx"],"sourcesContent":["import { Tooltip as T } from \"radix-ui\";\nimport type { ReactNode } from \"react\";\n\nexport const TooltipProvider = T.Provider;\n\n/** A hover / focus label for an icon button. */\nexport function Tip({\n label,\n children,\n side = \"bottom\",\n}: {\n label: ReactNode;\n children: ReactNode;\n side?: \"top\" | \"bottom\" | \"left\" | \"right\";\n}) {\n return (\n <T.Root>\n <T.Trigger asChild>{children}</T.Trigger>\n <T.Portal>\n <T.Content\n side={side}\n sideOffset={6}\n className
|
|
1
|
+
{"version":3,"file":"tooltip.js","names":["T"],"sources":["../../../src/components/ui/tooltip.tsx"],"sourcesContent":["import { Tooltip as T } from \"radix-ui\";\nimport type { ReactNode } from \"react\";\nimport { UDC_SCOPE_CLASS } from \"../../lib/scope.js\";\n\nexport const TooltipProvider = T.Provider;\n\n/** A hover / focus label for an icon button. */\nexport function Tip({\n label,\n children,\n side = \"bottom\",\n}: {\n label: ReactNode;\n children: ReactNode;\n side?: \"top\" | \"bottom\" | \"left\" | \"right\";\n}) {\n return (\n <T.Root>\n <T.Trigger asChild>{children}</T.Trigger>\n <T.Portal>\n <T.Content\n side={side}\n sideOffset={6}\n className={`${UDC_SCOPE_CLASS} udc:z-50 udc:rounded-md udc:bg-foreground udc:px-2 udc:py-1 udc:text-xs udc:font-medium udc:text-background udc:shadow-md udc:data-[state=delayed-open]:animate-in`}\n >\n {label}\n </T.Content>\n </T.Portal>\n </T.Root>\n );\n}\n"],"mappings":";;;;AAIA,IAAa,kBAAkBA,QAAE;;AAGjC,SAAgB,IAAI,EAClB,OACA,UACA,OAAO,YAKN;CACD,OACE,qBAACA,QAAE,MAAH,EAAA,UAAA,CACE,oBAACA,QAAE,SAAH;EAAW,SAAA;EAAS;CAAoB,CAAA,GACxC,oBAACA,QAAE,QAAH,EAAA,UACE,oBAACA,QAAE,SAAH;EACQ;EACN,YAAY;EACZ,WAAW,GAAG,gBAAgB;EAE7B,UAAA;CACQ,CAAA,EACH,CAAA,CACJ,EAAA,CAAA;AAEZ"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type ActionDef, type FilterNode } from "@jsudc/core";
|
|
2
|
+
import { type LucideIcon } from "lucide-react";
|
|
3
|
+
import { type BulkActionHandlers } from "../actions/bulk.js";
|
|
4
|
+
import type { RowSelection } from "../rows/useRowSelection.js";
|
|
5
|
+
export interface BulkBarProps {
|
|
6
|
+
collection: string;
|
|
7
|
+
/** The collection's i18n section (`TBL_<COLLECTION>`). */
|
|
8
|
+
section: string;
|
|
9
|
+
/** `view.bulk_actions`; none: the bar only counts and clears. */
|
|
10
|
+
defs: readonly ActionDef[];
|
|
11
|
+
selection: RowSelection;
|
|
12
|
+
/** The list's filter, composed: what "all that match" sends. */
|
|
13
|
+
filter: FilterNode | undefined;
|
|
14
|
+
/** More rows match than are loaded: "select all that match" is worth offering. */
|
|
15
|
+
moreThanLoaded: boolean;
|
|
16
|
+
/** The list's total; `null` when the source does not count. */
|
|
17
|
+
total: number | null;
|
|
18
|
+
/** The view's own handlers (`UdcDataView actions`), before the provider's. */
|
|
19
|
+
handlers?: BulkActionHandlers | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* `false`: "select all that match" is not offered, and a short hint says
|
|
22
|
+
* why. `UdcDataView` sets it while the source answers the search (0.5.0):
|
|
23
|
+
* `mutate_many` by filter cannot carry the search text, so it could not
|
|
24
|
+
* name the same set. Default `true`.
|
|
25
|
+
*/
|
|
26
|
+
allMatching?: boolean | undefined;
|
|
27
|
+
}
|
|
28
|
+
/** A def's `icon` (`lucide:<name>` or a bare name), or none when the name is not known. */
|
|
29
|
+
export declare function actionIcon(name: string | undefined): LucideIcon | null;
|
|
30
|
+
/**
|
|
31
|
+
* The bar over the list while rows are selected: the count (or "all
|
|
32
|
+
* matching"), the offer to select every row that matches, one button per
|
|
33
|
+
* `view.bulk_actions` entry, and a clear button. Runs an action through the
|
|
34
|
+
* host's handler for its `kind`, else on the server (`planBulkAction`).
|
|
35
|
+
*/
|
|
36
|
+
export declare function BulkBar({ collection, section, defs, selection, filter, moreThanLoaded, total, handlers, allMatching, }: BulkBarProps): import("react").JSX.Element;
|