@jsudc/react 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +228 -2
- package/dist/calendar/CalendarRenderer.d.ts +11 -0
- package/dist/calendar/CalendarRenderer.js +343 -0
- package/dist/calendar/CalendarRenderer.js.map +1 -0
- package/dist/calendar/EventBlock.d.ts +16 -0
- package/dist/calendar/EventBlock.js +57 -0
- package/dist/calendar/EventBlock.js.map +1 -0
- package/dist/calendar/EventDetail.d.ts +20 -0
- package/dist/calendar/EventDetail.js +186 -0
- package/dist/calendar/EventDetail.js.map +1 -0
- package/dist/calendar/MonthGrid.d.ts +19 -0
- package/dist/calendar/MonthGrid.js +120 -0
- package/dist/calendar/MonthGrid.js.map +1 -0
- package/dist/calendar/TimeGrid.d.ts +24 -0
- package/dist/calendar/TimeGrid.js +330 -0
- package/dist/calendar/TimeGrid.js.map +1 -0
- package/dist/calendar/model.d.ts +97 -0
- package/dist/calendar/model.js +279 -0
- package/dist/calendar/model.js.map +1 -0
- package/dist/cards/CardRenderer.d.ts +24 -0
- package/dist/cards/CardRenderer.js +274 -0
- package/dist/cards/CardRenderer.js.map +1 -0
- package/dist/cards/cardModel.d.ts +48 -0
- package/dist/cards/cardModel.js +86 -0
- package/dist/cards/cardModel.js.map +1 -0
- package/dist/chart/ChartRenderer.d.ts +16 -0
- package/dist/chart/ChartRenderer.js +529 -0
- package/dist/chart/ChartRenderer.js.map +1 -0
- package/dist/chart/ChartWindowControl.d.ts +13 -0
- package/dist/chart/ChartWindowControl.js +99 -0
- package/dist/chart/ChartWindowControl.js.map +1 -0
- package/dist/chart/model.d.ts +45 -0
- package/dist/chart/model.js +179 -0
- package/dist/chart/model.js.map +1 -0
- package/dist/chart/useChartWindow.d.ts +18 -0
- package/dist/chart/useChartWindow.js +70 -0
- package/dist/chart/useChartWindow.js.map +1 -0
- package/dist/chart/window.d.ts +50 -0
- package/dist/chart/window.js +130 -0
- package/dist/chart/window.js.map +1 -0
- package/dist/components/ui/button.d.ts +21 -0
- package/dist/components/ui/button.js +30 -0
- package/dist/components/ui/button.js.map +1 -0
- package/dist/components/ui/checkbox.d.ts +2 -0
- package/dist/components/ui/checkbox.js +23 -0
- package/dist/components/ui/checkbox.js.map +1 -0
- package/dist/components/ui/dialog.d.ts +14 -0
- package/dist/components/ui/dialog.js +52 -0
- package/dist/components/ui/dialog.js.map +1 -0
- package/dist/components/ui/dropdown-menu.d.ts +12 -0
- package/dist/components/ui/dropdown-menu.js +35 -0
- package/dist/components/ui/dropdown-menu.js.map +1 -0
- package/dist/components/ui/input.d.ts +4 -0
- package/dist/components/ui/input.js +24 -0
- package/dist/components/ui/input.js.map +1 -0
- package/dist/components/ui/misc.d.ts +6 -0
- package/dist/components/ui/misc.js +24 -0
- package/dist/components/ui/misc.js.map +1 -0
- package/dist/components/ui/popover.d.ts +6 -0
- package/dist/components/ui/popover.js +21 -0
- package/dist/components/ui/popover.js.map +1 -0
- package/dist/components/ui/segmented.d.ts +18 -0
- package/dist/components/ui/segmented.js +35 -0
- package/dist/components/ui/segmented.js.map +1 -0
- package/dist/components/ui/select.d.ts +14 -0
- package/dist/components/ui/select.js +39 -0
- package/dist/components/ui/select.js.map +1 -0
- package/dist/components/ui/toast.d.ts +14 -0
- package/dist/components/ui/toast.js +72 -0
- package/dist/components/ui/toast.js.map +1 -0
- package/dist/components/ui/tooltip.d.ts +9 -0
- package/dist/components/ui/tooltip.js +19 -0
- package/dist/components/ui/tooltip.js.map +1 -0
- package/dist/data-view/DocTab.d.ts +8 -0
- package/dist/data-view/DocTab.js +26 -0
- package/dist/data-view/DocTab.js.map +1 -0
- package/dist/data-view/FilePreview.d.ts +10 -0
- package/dist/data-view/FilePreview.js +71 -0
- package/dist/data-view/FilePreview.js.map +1 -0
- package/dist/data-view/FilterBuilder.d.ts +26 -0
- package/dist/data-view/FilterBuilder.js +350 -0
- package/dist/data-view/FilterBuilder.js.map +1 -0
- package/dist/data-view/FilterChips.d.ts +12 -0
- package/dist/data-view/FilterChips.js +295 -0
- package/dist/data-view/FilterChips.js.map +1 -0
- package/dist/data-view/FolderBar.d.ts +5 -0
- package/dist/data-view/FolderBar.js +46 -0
- package/dist/data-view/FolderBar.js.map +1 -0
- package/dist/data-view/FolderEntry.d.ts +13 -0
- package/dist/data-view/FolderEntry.js +37 -0
- package/dist/data-view/FolderEntry.js.map +1 -0
- package/dist/data-view/Freshness.d.ts +18 -0
- package/dist/data-view/Freshness.js +86 -0
- package/dist/data-view/Freshness.js.map +1 -0
- package/dist/data-view/SearchBox.d.ts +7 -0
- package/dist/data-view/SearchBox.js +65 -0
- package/dist/data-view/SearchBox.js.map +1 -0
- package/dist/data-view/SourceTab.d.ts +9 -0
- package/dist/data-view/SourceTab.js +103 -0
- package/dist/data-view/SourceTab.js.map +1 -0
- package/dist/data-view/UdcDataView.d.ts +8 -0
- package/dist/data-view/UdcDataView.js +366 -0
- package/dist/data-view/UdcDataView.js.map +1 -0
- package/dist/data-view/compose.d.ts +24 -0
- package/dist/data-view/compose.js +86 -0
- package/dist/data-view/compose.js.map +1 -0
- package/dist/data-view/folder.d.ts +13 -0
- package/dist/data-view/folder.js +52 -0
- package/dist/data-view/folder.js.map +1 -0
- package/dist/data-view/liveView.d.ts +20 -0
- package/dist/data-view/liveView.js +67 -0
- package/dist/data-view/liveView.js.map +1 -0
- package/dist/data-view/urlState.d.ts +44 -0
- package/dist/data-view/urlState.js +139 -0
- package/dist/data-view/urlState.js.map +1 -0
- package/dist/data-view/useDataViewState.d.ts +36 -0
- package/dist/data-view/useDataViewState.js +69 -0
- package/dist/data-view/useDataViewState.js.map +1 -0
- package/dist/i18n/i18n.d.ts +71 -0
- package/dist/i18n/i18n.js +151 -0
- package/dist/i18n/i18n.js.map +1 -0
- package/dist/i18n/translations.d.ts +16 -0
- package/dist/i18n/translations.js +959 -0
- package/dist/i18n/translations.js.map +1 -0
- package/dist/icons/lucide.generated.d.ts +2 -0
- package/dist/icons/lucide.generated.js +32 -0
- package/dist/icons/lucide.generated.js.map +1 -0
- package/dist/icons/resolve.d.ts +9 -0
- package/dist/icons/resolve.js +25 -0
- package/dist/icons/resolve.js.map +1 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.js +28 -0
- package/dist/kanban/CardDetailDialog.d.ts +17 -0
- package/dist/kanban/CardDetailDialog.js +52 -0
- package/dist/kanban/CardDetailDialog.js.map +1 -0
- package/dist/kanban/KanbanBoardSwitcher.d.ts +6 -0
- package/dist/kanban/KanbanBoardSwitcher.js +27 -0
- package/dist/kanban/KanbanBoardSwitcher.js.map +1 -0
- package/dist/kanban/KanbanCard.d.ts +21 -0
- package/dist/kanban/KanbanCard.js +188 -0
- package/dist/kanban/KanbanCard.js.map +1 -0
- package/dist/kanban/KanbanColumn.d.ts +30 -0
- package/dist/kanban/KanbanColumn.js +227 -0
- package/dist/kanban/KanbanColumn.js.map +1 -0
- package/dist/kanban/KanbanRenderer.d.ts +3 -0
- package/dist/kanban/KanbanRenderer.js +472 -0
- package/dist/kanban/KanbanRenderer.js.map +1 -0
- package/dist/kanban/model.d.ts +89 -0
- package/dist/kanban/model.js +159 -0
- package/dist/kanban/model.js.map +1 -0
- package/dist/kanban/persist.d.ts +27 -0
- package/dist/kanban/persist.js +54 -0
- package/dist/kanban/persist.js.map +1 -0
- package/dist/kanban/useKanbanBoard.d.ts +21 -0
- package/dist/kanban/useKanbanBoard.js +47 -0
- package/dist/kanban/useKanbanBoard.js.map +1 -0
- package/dist/lib/theme.d.ts +11 -0
- package/dist/lib/theme.js +43 -0
- package/dist/lib/theme.js.map +1 -0
- package/dist/lib/utils.d.ts +9 -0
- package/dist/lib/utils.js +29 -0
- package/dist/lib/utils.js.map +1 -0
- package/dist/map/MapRenderer.d.ts +13 -0
- package/dist/map/MapRenderer.js +405 -0
- package/dist/map/MapRenderer.js.map +1 -0
- package/dist/map/model.d.ts +68 -0
- package/dist/map/model.js +140 -0
- package/dist/map/model.js.map +1 -0
- package/dist/renderers/AllRowsStatus.d.ts +8 -0
- package/dist/renderers/AllRowsStatus.js +34 -0
- package/dist/renderers/AllRowsStatus.js.map +1 -0
- package/dist/renderers/registry.d.ts +21 -0
- package/dist/renderers/registry.js +103 -0
- package/dist/renderers/registry.js.map +1 -0
- package/dist/renderers/types.d.ts +83 -0
- package/dist/renderers/types.js +8 -0
- package/dist/renderers/types.js.map +1 -0
- package/dist/schema-editor/ColumnHeaderMenu.d.ts +11 -0
- package/dist/schema-editor/ColumnHeaderMenu.js +74 -0
- package/dist/schema-editor/ColumnHeaderMenu.js.map +1 -0
- package/dist/schema-editor/DeleteFieldDialog.d.ts +8 -0
- package/dist/schema-editor/DeleteFieldDialog.js +79 -0
- package/dist/schema-editor/DeleteFieldDialog.js.map +1 -0
- package/dist/schema-editor/FieldFormDialog.d.ts +22 -0
- package/dist/schema-editor/FieldFormDialog.js +313 -0
- package/dist/schema-editor/FieldFormDialog.js.map +1 -0
- package/dist/schema-editor/TagInput.d.ts +9 -0
- package/dist/schema-editor/TagInput.js +46 -0
- package/dist/schema-editor/TagInput.js.map +1 -0
- package/dist/schema-editor/fieldForm.d.ts +52 -0
- package/dist/schema-editor/fieldForm.js +131 -0
- package/dist/schema-editor/fieldForm.js.map +1 -0
- package/dist/schema-editor/useSchemaEditor.d.ts +15 -0
- package/dist/schema-editor/useSchemaEditor.js +87 -0
- package/dist/schema-editor/useSchemaEditor.js.map +1 -0
- package/dist/styles.css +2 -0
- package/dist/table/CellEditor.d.ts +31 -0
- package/dist/table/CellEditor.js +144 -0
- package/dist/table/CellEditor.js.map +1 -0
- package/dist/table/Pager.d.ts +8 -0
- package/dist/table/Pager.js +90 -0
- package/dist/table/Pager.js.map +1 -0
- package/dist/table/TableRenderer.d.ts +27 -0
- package/dist/table/TableRenderer.js +458 -0
- package/dist/table/TableRenderer.js.map +1 -0
- package/dist/table/cells.d.ts +38 -0
- package/dist/table/cells.js +218 -0
- package/dist/table/cells.js.map +1 -0
- package/dist/table/sparkline.d.ts +31 -0
- package/dist/table/sparkline.js +105 -0
- package/dist/table/sparkline.js.map +1 -0
- package/dist/table/states.d.ts +10 -0
- package/dist/table/states.js +71 -0
- package/dist/table/states.js.map +1 -0
- package/dist/table/style.d.ts +15 -0
- package/dist/table/style.js +53 -0
- package/dist/table/style.js.map +1 -0
- package/dist/table/transforms.d.ts +17 -0
- package/dist/table/transforms.js +95 -0
- package/dist/table/transforms.js.map +1 -0
- package/dist/table/useInfiniteSentinel.d.ts +8 -0
- package/dist/table/useInfiniteSentinel.js +34 -0
- package/dist/table/useInfiniteSentinel.js.map +1 -0
- package/dist/time/timezone.d.ts +27 -0
- package/dist/time/timezone.js +69 -0
- package/dist/time/timezone.js.map +1 -0
- package/dist/time/zoned.d.ts +65 -0
- package/dist/time/zoned.js +208 -0
- package/dist/time/zoned.js.map +1 -0
- package/dist/tokens.css +454 -0
- package/dist/tree/TreeNode.d.ts +9 -0
- package/dist/tree/TreeNode.js +291 -0
- package/dist/tree/TreeNode.js.map +1 -0
- package/dist/tree/TreeRenderer.d.ts +54 -0
- package/dist/tree/TreeRenderer.js +446 -0
- package/dist/tree/TreeRenderer.js.map +1 -0
- package/dist/tree/expand.d.ts +31 -0
- package/dist/tree/expand.js +80 -0
- package/dist/tree/expand.js.map +1 -0
- package/dist/tree/model.d.ts +108 -0
- package/dist/tree/model.js +294 -0
- package/dist/tree/model.js.map +1 -0
- package/dist/udc/hooks.d.ts +644 -0
- package/dist/udc/hooks.js +353 -0
- package/dist/udc/hooks.js.map +1 -0
- package/dist/udc/keys.d.ts +19 -0
- package/dist/udc/keys.js +30 -0
- package/dist/udc/keys.js.map +1 -0
- package/dist/udc/provider.d.ts +14 -0
- package/dist/udc/provider.js +36 -0
- package/dist/udc/provider.js.map +1 -0
- package/package.json +113 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.js","names":[],"sources":["../../src/map/model.ts"],"sourcesContent":["import type { ColumnColor, LatLng, MapOptions, MapRegion, Row, RowColorConfig } from \"@jsudc/core\";\nimport { resolveRowColor } from \"../table/style\";\n\n/** One row on the map. */\nexport interface MapMarker {\n id: string;\n lat: number;\n lng: number;\n radius: number;\n tone: ColumnColor;\n /** Degrees clockwise from north for an `airplane` icon; `null` draws the circle. */\n rotation: number | null;\n /** The positions it has flown, oldest first (`trail`); empty without one. */\n trail: LatLng[];\n row: Row;\n}\n\n/** More rows than this and a trail is drawn only for the hovered and the selected marker. */\nexport const TRAILS_FOR_ALL_MAX = 300;\n\n/** A finite number from a number or a numeric string (a decimal may arrive as either). */\nexport function toNumber(v: unknown): number | null {\n const n = typeof v === \"number\" ? v : typeof v === \"string\" && v.trim() !== \"\" ? Number(v) : NaN;\n return Number.isFinite(n) ? n : null;\n}\n\n/** `[lat, lng]` of a row, or `null` when either is missing or out of range. */\nexport function coordsOf(row: Record<string, unknown>, opts: MapOptions): LatLng | null {\n const lat = toNumber(row[opts.lat_field]);\n const lng = toNumber(row[opts.lng_field]);\n if (lat === null || lng === null) return null;\n if (Math.abs(lat) > 90 || Math.abs(lng) > 180) return null;\n return [lat, lng];\n}\n\n/** `radius_min + value * radius_scale`, at most `radius_max`; `radius_min` without a usable value. */\nexport function markerRadius(row: Record<string, unknown>, opts: MapOptions): number {\n const v = opts.radius_field ? toNumber(row[opts.radius_field]) : null;\n if (v === null || v <= 0) return opts.radius_min;\n return Math.min(opts.radius_max, opts.radius_min + v * opts.radius_scale);\n}\n\n/** The colour of the first `row_color` rule the row matches, else the accent. */\nexport function markerTone(\n row: Record<string, unknown>,\n cfg: RowColorConfig | undefined,\n): ColumnColor {\n const color = resolveRowColor(row, cfg)?.color;\n return color && color !== \"default\" ? color : \"accent\";\n}\n\n/**\n * The turn of a row's aeroplane, `[0, 360)`: `rotate_field` of an\n * `icon: airplane` map. `null` (a circle) for the circle icon or a row\n * without a usable value — a missing track is not north.\n */\nexport function rotationOf(row: Record<string, unknown>, opts: MapOptions): number | null {\n if (opts.icon !== \"airplane\") return null;\n if (!opts.rotate_field) return 0;\n const v = toNumber(row[opts.rotate_field]);\n return v === null ? null : ((v % 360) + 360) % 360;\n}\n\nconst numbers = (v: unknown): (number | null)[] => (Array.isArray(v) ? v.map(toNumber) : []);\n\n/**\n * The trail of a row: its lat and lng histories paired from the newest end\n * (both are appended together), pairs out of range dropped, the last\n * `max_points`, oldest first. Empty without a `trail` block.\n */\nexport function trailOf(row: Record<string, unknown>, opts: MapOptions): LatLng[] {\n const trail = opts.trail;\n if (!trail) return [];\n const lats = numbers(row[trail.lat_history_field]);\n const lngs = numbers(row[trail.lng_history_field]);\n const n = Math.min(lats.length, lngs.length);\n const out: LatLng[] = [];\n for (let i = 0; i < n; i++) {\n const lat = lats[lats.length - n + i];\n const lng = lngs[lngs.length - n + i];\n if (lat == null || lng == null || Math.abs(lat) > 90 || Math.abs(lng) > 180) continue;\n out.push([lat, lng]);\n }\n return out.slice(-trail.max_points);\n}\n\n/**\n * The markers whose trail is drawn: all of them up to `TRAILS_FOR_ALL_MAX`,\n * above it only the hovered and the selected one. A trail needs two points.\n */\nexport function trailMarkers(\n markers: readonly MapMarker[],\n hovered: string | null,\n selected: string | null,\n): MapMarker[] {\n const drawn = markers.filter((m) => m.trail.length >= 2);\n if (markers.length <= TRAILS_FOR_ALL_MAX) return drawn;\n return drawn.filter((m) => m.id === hovered || m.id === selected);\n}\n\n/**\n * An aeroplane seen from above, nose up (north), in a 24×24 box: filled\n * with `currentColor`, so the tone's CSS colour paints it.\n */\nexport const AIRPLANE_PATH =\n \"M12 1.5 L13.5 9 L22.5 13 L22.5 14.5 L13.5 13.5 L13 18.5 L16 20.5 L16 21.5 L12 20.5 L8 21.5 L8 20.5 L11 18.5 L10.5 13.5 L1.5 14.5 L1.5 13 L10.5 9 Z\";\n\n/** The inner HTML of an aeroplane marker: turned by CSS, sized by `icon_size`. */\nexport function airplaneHtml(rotation: number, size: number): string {\n return (\n `<div class=\"udc-map-plane-glyph\" style=\"width:${size}px;height:${size}px;transform:rotate(${rotation}deg)\">` +\n `<svg viewBox=\"0 0 24 24\" width=\"${size}\" height=\"${size}\" aria-hidden=\"true\">` +\n `<path d=\"${AIRPLANE_PATH}\"/></svg></div>`\n );\n}\n\n/**\n * The rows that can be placed, biggest first: drawn in that order, a small\n * marker sits on top of a large one around it and stays clickable.\n */\nexport function toMarkers(\n rows: readonly Row[],\n opts: MapOptions,\n rowColor: RowColorConfig | undefined,\n): MapMarker[] {\n const out: MapMarker[] = [];\n for (const row of rows) {\n const at = coordsOf(row, opts);\n if (!at) continue;\n out.push({\n id: row.__meta.id,\n lat: at[0],\n lng: at[1],\n radius: markerRadius(row, opts),\n tone: markerTone(row, rowColor),\n rotation: rotationOf(row, opts),\n trail: trailOf(row, opts),\n row,\n });\n }\n return out.sort((a, b) => b.radius - a.radius);\n}\n\n/** `[[south, west], [north, east]]` around every marker; `null` for none. */\nexport function boundsOf(\n markers: readonly Pick<MapMarker, \"lat\" | \"lng\">[],\n): [LatLng, LatLng] | null {\n if (markers.length === 0) return null;\n let s = 90;\n let w = 180;\n let n = -90;\n let e = -180;\n for (const m of markers) {\n s = Math.min(s, m.lat);\n n = Math.max(n, m.lat);\n w = Math.min(w, m.lng);\n e = Math.max(e, m.lng);\n }\n return [\n [s, w],\n [n, e],\n ];\n}\n\nexport function regionById(opts: MapOptions, id: string | null): MapRegion | undefined {\n return id === null ? undefined : opts.regions?.find((r) => r.id === id);\n}\n\n/** Where the map opens: the default region, else `center` / `zoom` (the world when there is no center). */\nexport function initialView(opts: MapOptions): {\n center: LatLng;\n zoom: number;\n region: string | null;\n} {\n const region = regionById(opts, opts.default_region ?? null);\n if (region) return { center: region.center, zoom: region.zoom, region: region.id };\n return { center: opts.center ?? [20, 0], zoom: opts.zoom, region: null };\n}\n\n/**\n * The region a view is in: the one whose centre and zoom it shows (after a\n * fly-to, or on open), else none — a pan or a zoom by hand leaves every\n * region button unpressed.\n */\nexport function regionAt(\n opts: MapOptions,\n center: LatLng,\n zoom: number,\n tolerance = 0.01,\n): string | null {\n const found = opts.regions?.find(\n (r) =>\n r.zoom === zoom &&\n Math.abs(r.center[0] - center[0]) <= tolerance &&\n Math.abs(r.center[1] - center[1]) <= tolerance,\n );\n return found?.id ?? null;\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { UdcAllRowsResult } from "../udc/hooks";
|
|
2
|
+
/**
|
|
3
|
+
* What a renderer over `useUdcAllRows` shows above its content: a thin bar
|
|
4
|
+
* filling while the pages load, and a notice when the cap cut the rows short.
|
|
5
|
+
*/
|
|
6
|
+
export declare function AllRowsStatus({ result }: {
|
|
7
|
+
result: UdcAllRowsResult;
|
|
8
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { useI18n } from "../i18n/i18n.js";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
// src/renderers/AllRowsStatus.tsx
|
|
4
|
+
/**
|
|
5
|
+
* What a renderer over `useUdcAllRows` shows above its content: a thin bar
|
|
6
|
+
* filling while the pages load, and a notice when the cap cut the rows short.
|
|
7
|
+
*/
|
|
8
|
+
function AllRowsStatus({ result }) {
|
|
9
|
+
const { t, intlLocale } = useI18n();
|
|
10
|
+
const fmt = (n) => new Intl.NumberFormat(intlLocale).format(n);
|
|
11
|
+
const { progress } = result;
|
|
12
|
+
const pct = progress?.total ? Math.min(100, progress.loaded / progress.total * 100) : null;
|
|
13
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [result.isFetching ? /* @__PURE__ */ jsx("div", {
|
|
14
|
+
className: "pointer-events-none relative z-30 h-0",
|
|
15
|
+
"data-testid": "all-rows-progress",
|
|
16
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
17
|
+
className: "h-0.5 w-full overflow-hidden bg-primary/15",
|
|
18
|
+
children: pct === null ? /* @__PURE__ */ jsx("div", { className: "h-full w-1/3 animate-[shimmer_1s_linear_infinite] bg-primary/70" }) : /* @__PURE__ */ jsx("div", {
|
|
19
|
+
className: "h-full bg-primary/70 transition-[width]",
|
|
20
|
+
style: { width: `${pct}%` }
|
|
21
|
+
})
|
|
22
|
+
})
|
|
23
|
+
}) : null, result.capped && result.total !== null ? /* @__PURE__ */ jsx("div", {
|
|
24
|
+
"data-testid": "all-rows-capped",
|
|
25
|
+
className: "border-b border-border bg-sem-warning-bg px-4 py-1.5 text-xs text-sem-warning",
|
|
26
|
+
children: t("APP", "CAPPED", {
|
|
27
|
+
shown: fmt(result.rows.length),
|
|
28
|
+
total: fmt(result.total)
|
|
29
|
+
})
|
|
30
|
+
}) : null] });
|
|
31
|
+
}
|
|
32
|
+
export { AllRowsStatus };
|
|
33
|
+
|
|
34
|
+
//# sourceMappingURL=AllRowsStatus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AllRowsStatus.js","names":["_Fragment"],"sources":["../../src/renderers/AllRowsStatus.tsx"],"sourcesContent":["import { useI18n } from \"../i18n/i18n\";\nimport type { UdcAllRowsResult } from \"../udc/hooks\";\n\n/**\n * What a renderer over `useUdcAllRows` shows above its content: a thin bar\n * filling while the pages load, and a notice when the cap cut the rows short.\n */\nexport function AllRowsStatus({ result }: { result: UdcAllRowsResult }) {\n const { t, intlLocale } = useI18n();\n const fmt = (n: number) => new Intl.NumberFormat(intlLocale).format(n);\n const { progress } = result;\n const pct = progress?.total ? Math.min(100, (progress.loaded / progress.total) * 100) : null;\n return (\n <>\n {result.isFetching ? (\n <div className=\"pointer-events-none relative z-30 h-0\" data-testid=\"all-rows-progress\">\n <div className=\"h-0.5 w-full overflow-hidden bg-primary/15\">\n {pct === null ? (\n <div className=\"h-full w-1/3 animate-[shimmer_1s_linear_infinite] bg-primary/70\" />\n ) : (\n <div\n className=\"h-full bg-primary/70 transition-[width]\"\n style={{ width: `${pct}%` }}\n />\n )}\n </div>\n </div>\n ) : null}\n {result.capped && result.total !== null ? (\n <div\n data-testid=\"all-rows-capped\"\n className=\"border-b border-border bg-sem-warning-bg px-4 py-1.5 text-xs text-sem-warning\"\n >\n {t(\"APP\", \"CAPPED\", { shown: fmt(result.rows.length), total: fmt(result.total) })}\n </div>\n ) : null}\n </>\n );\n}\n"],"mappings":";;;;;;;AAOA,SAAgB,cAAc,EAAE,UAAwC;CACtE,MAAM,EAAE,GAAG,eAAe,QAAQ;CAClC,MAAM,OAAO,MAAc,IAAI,KAAK,aAAa,UAAU,CAAC,CAAC,OAAO,CAAC;CACrE,MAAM,EAAE,aAAa;CACrB,MAAM,MAAM,UAAU,QAAQ,KAAK,IAAI,KAAM,SAAS,SAAS,SAAS,QAAS,GAAG,IAAI;CACxF,OACE,qBAAAA,UAAA,EAAA,UAAA,CACG,OAAO,aACN,oBAAC,OAAD;EAAK,WAAU;EAAwC,eAAY;EACjE,UAAA,oBAAC,OAAD;GAAK,WAAU;GACZ,UAAA,QAAQ,OACP,oBAAC,OAAD,EAAK,WAAU,kEAAmE,CAAA,IAElF,oBAAC,OAAD;IACE,WAAU;IACV,OAAO,EAAE,OAAO,GAAG,IAAI,GAAG;GAC3B,CAAA;EAEA,CAAA;CACF,CAAA,IACH,MACH,OAAO,UAAU,OAAO,UAAU,OACjC,oBAAC,OAAD;EACE,eAAY;EACZ,WAAU;EAET,UAAA,EAAE,OAAO,UAAU;GAAE,OAAO,IAAI,OAAO,KAAK,MAAM;GAAG,OAAO,IAAI,OAAO,KAAK;EAAE,CAAC;CAC7E,CAAA,IACH,IACJ,EAAA,CAAA;AAEN"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { RendererName } from "@jsudc/core";
|
|
2
|
+
import type { RendererEntry } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Renderer name → its component and tab. `<UdcDataView>` shows a tab for
|
|
5
|
+
* every name in `available_renderers`; a name with no entry here is drawn
|
|
6
|
+
* disabled. A new renderer is one more entry.
|
|
7
|
+
*/
|
|
8
|
+
export declare const RENDERERS: Partial<Record<RendererName, RendererEntry>>;
|
|
9
|
+
export declare function rendererEntry(name: string): RendererEntry | undefined;
|
|
10
|
+
export interface RendererTab {
|
|
11
|
+
name: string;
|
|
12
|
+
entry: RendererEntry | undefined;
|
|
13
|
+
}
|
|
14
|
+
/** The tabs of a view: every available renderer, in view order, with its entry when one exists. */
|
|
15
|
+
export declare function rendererTabs(available: readonly string[]): RendererTab[];
|
|
16
|
+
/**
|
|
17
|
+
* The tab to draw: the requested one when it is available and has a
|
|
18
|
+
* component, else the view's default, else the first available one with a
|
|
19
|
+
* component, else `table`.
|
|
20
|
+
*/
|
|
21
|
+
export declare function resolveTab(requested: string, available: readonly string[], fallback: string): string;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { CalendarRenderer } from "../calendar/CalendarRenderer.js";
|
|
2
|
+
import { CardRenderer } from "../cards/CardRenderer.js";
|
|
3
|
+
import { ChartRenderer } from "../chart/ChartRenderer.js";
|
|
4
|
+
import { KanbanBoardSwitcher } from "../kanban/KanbanBoardSwitcher.js";
|
|
5
|
+
import { KanbanRenderer } from "../kanban/KanbanRenderer.js";
|
|
6
|
+
import { MapRenderer } from "../map/MapRenderer.js";
|
|
7
|
+
import { TableRenderer } from "../table/TableRenderer.js";
|
|
8
|
+
import { TreeRenderer } from "../tree/TreeRenderer.js";
|
|
9
|
+
import { jsx } from "react/jsx-runtime";
|
|
10
|
+
import { CalendarDays, ChartLine, Kanban, LayoutGrid, ListTree, MapPinned, Table2 } from "lucide-react";
|
|
11
|
+
// src/renderers/registry.tsx
|
|
12
|
+
function TableTab(props) {
|
|
13
|
+
return /* @__PURE__ */ jsx(TableRenderer, { ...props });
|
|
14
|
+
}
|
|
15
|
+
function CardsTab(props) {
|
|
16
|
+
return /* @__PURE__ */ jsx(CardRenderer, { ...props });
|
|
17
|
+
}
|
|
18
|
+
/** The calendar of a kanban collection keeps the board switcher: it shows the board's tickets. */
|
|
19
|
+
function CalendarToolbar(props) {
|
|
20
|
+
return props.describe.view.kanban_options ? /* @__PURE__ */ jsx(KanbanBoardSwitcher, { ...props }) : null;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Renderer name → its component and tab. `<UdcDataView>` shows a tab for
|
|
24
|
+
* every name in `available_renderers`; a name with no entry here is drawn
|
|
25
|
+
* disabled. A new renderer is one more entry.
|
|
26
|
+
*/
|
|
27
|
+
var RENDERERS = {
|
|
28
|
+
table: {
|
|
29
|
+
component: TableTab,
|
|
30
|
+
icon: Table2,
|
|
31
|
+
labelKey: "TAB_TABLE",
|
|
32
|
+
paging: true,
|
|
33
|
+
editMode: true
|
|
34
|
+
},
|
|
35
|
+
cards: {
|
|
36
|
+
component: CardsTab,
|
|
37
|
+
icon: LayoutGrid,
|
|
38
|
+
labelKey: "TAB_CARDS",
|
|
39
|
+
paging: true,
|
|
40
|
+
editMode: false
|
|
41
|
+
},
|
|
42
|
+
kanban: {
|
|
43
|
+
component: KanbanRenderer,
|
|
44
|
+
icon: Kanban,
|
|
45
|
+
labelKey: "TAB_KANBAN",
|
|
46
|
+
paging: false,
|
|
47
|
+
editMode: false,
|
|
48
|
+
toolbar: KanbanBoardSwitcher
|
|
49
|
+
},
|
|
50
|
+
calendar: {
|
|
51
|
+
component: CalendarRenderer,
|
|
52
|
+
icon: CalendarDays,
|
|
53
|
+
labelKey: "TAB_CALENDAR",
|
|
54
|
+
paging: false,
|
|
55
|
+
editMode: false,
|
|
56
|
+
toolbar: CalendarToolbar
|
|
57
|
+
},
|
|
58
|
+
tree: {
|
|
59
|
+
component: TreeRenderer,
|
|
60
|
+
icon: ListTree,
|
|
61
|
+
labelKey: "TAB_TREE",
|
|
62
|
+
paging: false,
|
|
63
|
+
editMode: false
|
|
64
|
+
},
|
|
65
|
+
map: {
|
|
66
|
+
component: MapRenderer,
|
|
67
|
+
icon: MapPinned,
|
|
68
|
+
labelKey: "TAB_MAP",
|
|
69
|
+
paging: false,
|
|
70
|
+
editMode: false
|
|
71
|
+
},
|
|
72
|
+
chart: {
|
|
73
|
+
component: ChartRenderer,
|
|
74
|
+
icon: ChartLine,
|
|
75
|
+
labelKey: "TAB_CHART",
|
|
76
|
+
paging: false,
|
|
77
|
+
editMode: false
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
function rendererEntry(name) {
|
|
81
|
+
return Object.hasOwn(RENDERERS, name) ? RENDERERS[name] : void 0;
|
|
82
|
+
}
|
|
83
|
+
/** The tabs of a view: every available renderer, in view order, with its entry when one exists. */
|
|
84
|
+
function rendererTabs(available) {
|
|
85
|
+
return available.map((name) => ({
|
|
86
|
+
name,
|
|
87
|
+
entry: rendererEntry(name)
|
|
88
|
+
}));
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* The tab to draw: the requested one when it is available and has a
|
|
92
|
+
* component, else the view's default, else the first available one with a
|
|
93
|
+
* component, else `table`.
|
|
94
|
+
*/
|
|
95
|
+
function resolveTab(requested, available, fallback) {
|
|
96
|
+
const usable = (n) => available.includes(n) && rendererEntry(n) !== void 0;
|
|
97
|
+
if (usable(requested)) return requested;
|
|
98
|
+
if (usable(fallback)) return fallback;
|
|
99
|
+
return available.find(usable) ?? "table";
|
|
100
|
+
}
|
|
101
|
+
export { RENDERERS, rendererEntry, rendererTabs, resolveTab };
|
|
102
|
+
|
|
103
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","names":[],"sources":["../../src/renderers/registry.tsx"],"sourcesContent":["import type { DescribeResponse, RendererName } from \"@jsudc/core\";\nimport {\n CalendarDays,\n ChartLine,\n Kanban,\n LayoutGrid,\n ListTree,\n MapPinned,\n Table2,\n} from \"lucide-react\";\nimport { CalendarRenderer } from \"../calendar/CalendarRenderer\";\nimport { CardRenderer } from \"../cards/CardRenderer\";\nimport { ChartRenderer } from \"../chart/ChartRenderer\";\nimport { KanbanBoardSwitcher } from \"../kanban/KanbanBoardSwitcher\";\nimport { KanbanRenderer } from \"../kanban/KanbanRenderer\";\nimport { MapRenderer } from \"../map/MapRenderer\";\nimport { TableRenderer } from \"../table/TableRenderer\";\nimport { TreeRenderer } from \"../tree/TreeRenderer\";\nimport type { RendererEntry, RendererProps } from \"./types\";\n\nfunction TableTab(props: RendererProps) {\n return <TableRenderer {...props} />;\n}\n\nfunction CardsTab(props: RendererProps) {\n return <CardRenderer {...props} />;\n}\n\n/** The calendar of a kanban collection keeps the board switcher: it shows the board's tickets. */\nfunction CalendarToolbar(props: { collection: string; describe: DescribeResponse }) {\n return props.describe.view.kanban_options ? <KanbanBoardSwitcher {...props} /> : null;\n}\n\n/**\n * Renderer name → its component and tab. `<UdcDataView>` shows a tab for\n * every name in `available_renderers`; a name with no entry here is drawn\n * disabled. A new renderer is one more entry.\n */\nexport const RENDERERS: Partial<Record<RendererName, RendererEntry>> = {\n table: { component: TableTab, icon: Table2, labelKey: \"TAB_TABLE\", paging: true, editMode: true },\n cards: {\n component: CardsTab,\n icon: LayoutGrid,\n labelKey: \"TAB_CARDS\",\n paging: true,\n editMode: false,\n },\n kanban: {\n component: KanbanRenderer,\n icon: Kanban,\n labelKey: \"TAB_KANBAN\",\n paging: false,\n editMode: false,\n toolbar: KanbanBoardSwitcher,\n },\n calendar: {\n component: CalendarRenderer,\n icon: CalendarDays,\n labelKey: \"TAB_CALENDAR\",\n paging: false,\n editMode: false,\n toolbar: CalendarToolbar,\n },\n tree: {\n component: TreeRenderer,\n icon: ListTree,\n labelKey: \"TAB_TREE\",\n paging: false,\n editMode: false,\n },\n map: {\n component: MapRenderer,\n icon: MapPinned,\n labelKey: \"TAB_MAP\",\n paging: false,\n editMode: false,\n },\n // The window control is drawn by the data view: it also follows the other tabs once picked.\n chart: {\n component: ChartRenderer,\n icon: ChartLine,\n labelKey: \"TAB_CHART\",\n paging: false,\n editMode: false,\n },\n};\n\nexport function rendererEntry(name: string): RendererEntry | undefined {\n return Object.hasOwn(RENDERERS, name) ? RENDERERS[name as RendererName] : undefined;\n}\n\nexport interface RendererTab {\n name: string;\n entry: RendererEntry | undefined;\n}\n\n/** The tabs of a view: every available renderer, in view order, with its entry when one exists. */\nexport function rendererTabs(available: readonly string[]): RendererTab[] {\n return available.map((name) => ({ name, entry: rendererEntry(name) }));\n}\n\n/**\n * The tab to draw: the requested one when it is available and has a\n * component, else the view's default, else the first available one with a\n * component, else `table`.\n */\nexport function resolveTab(\n requested: string,\n available: readonly string[],\n fallback: string,\n): string {\n const usable = (n: string) => available.includes(n) && rendererEntry(n) !== undefined;\n if (usable(requested)) return requested;\n if (usable(fallback)) return fallback;\n return available.find(usable) ?? \"table\";\n}\n"],"mappings":";;;;;;;;;;;AAoBA,SAAS,SAAS,OAAsB;CACtC,OAAO,oBAAC,eAAD,EAAe,GAAI,MAAQ,CAAA;AACpC;AAEA,SAAS,SAAS,OAAsB;CACtC,OAAO,oBAAC,cAAD,EAAc,GAAI,MAAQ,CAAA;AACnC;;AAGA,SAAS,gBAAgB,OAA2D;CAClF,OAAO,MAAM,SAAS,KAAK,iBAAiB,oBAAC,qBAAD,EAAqB,GAAI,MAAQ,CAAA,IAAI;AACnF;;;;;;AAOA,IAAa,YAA0D;CACrE,OAAO;EAAE,WAAW;EAAU,MAAM;EAAQ,UAAU;EAAa,QAAQ;EAAM,UAAU;CAAK;CAChG,OAAO;EACL,WAAW;EACX,MAAM;EACN,UAAU;EACV,QAAQ;EACR,UAAU;CACZ;CACA,QAAQ;EACN,WAAW;EACX,MAAM;EACN,UAAU;EACV,QAAQ;EACR,UAAU;EACV,SAAS;CACX;CACA,UAAU;EACR,WAAW;EACX,MAAM;EACN,UAAU;EACV,QAAQ;EACR,UAAU;EACV,SAAS;CACX;CACA,MAAM;EACJ,WAAW;EACX,MAAM;EACN,UAAU;EACV,QAAQ;EACR,UAAU;CACZ;CACA,KAAK;EACH,WAAW;EACX,MAAM;EACN,UAAU;EACV,QAAQ;EACR,UAAU;CACZ;CAEA,OAAO;EACL,WAAW;EACX,MAAM;EACN,UAAU;EACV,QAAQ;EACR,UAAU;CACZ;AACF;AAEA,SAAgB,cAAc,MAAyC;CACrE,OAAO,OAAO,OAAO,WAAW,IAAI,IAAI,UAAU,QAAwB,KAAA;AAC5E;;AAQA,SAAgB,aAAa,WAA6C;CACxE,OAAO,UAAU,KAAK,UAAU;EAAE;EAAM,OAAO,cAAc,IAAI;CAAE,EAAE;AACvE;;;;;;AAOA,SAAgB,WACd,WACA,WACA,UACQ;CACR,MAAM,UAAU,MAAc,UAAU,SAAS,CAAC,KAAK,cAAc,CAAC,MAAM,KAAA;CAC5E,IAAI,OAAO,SAAS,GAAG,OAAO;CAC9B,IAAI,OAAO,QAAQ,GAAG,OAAO;CAC7B,OAAO,UAAU,KAAK,MAAM,KAAK;AACnC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { DescribeResponse, FilterNode, FolderOptions, Row, SortKey } from "@jsudc/core";
|
|
2
|
+
import type { LucideIcon } from "lucide-react";
|
|
3
|
+
import type { ComponentType } from "react";
|
|
4
|
+
import type { ChartWindowState } from "../chart/useChartWindow";
|
|
5
|
+
import type { SchemaAction } from "../schema-editor/fieldForm";
|
|
6
|
+
import type { UdcCollectionResult } from "../udc/hooks";
|
|
7
|
+
import type { PagingMode } from "../udc/keys";
|
|
8
|
+
/** The row count a renderer that loads its own rows reports to the toolbar. */
|
|
9
|
+
export interface RendererCount {
|
|
10
|
+
shown: number;
|
|
11
|
+
total: number | null;
|
|
12
|
+
/**
|
|
13
|
+
* `nodes`: the toolbar reads "N nodes" (the tree), `map`: "N on map of M"
|
|
14
|
+
* (rows without a position are not drawn), `chart`: "N points in window of
|
|
15
|
+
* M" (M counts the filter without the window), instead of "Showing N of M".
|
|
16
|
+
*/
|
|
17
|
+
unit?: "nodes" | "map" | "chart";
|
|
18
|
+
/** A source serving a fetched copy (http_api): when it was fetched, and whether it is stale. */
|
|
19
|
+
fetchedAt?: string | null;
|
|
20
|
+
stale?: boolean;
|
|
21
|
+
}
|
|
22
|
+
/** A folder-shaped collection (`folder_options`): what a folder row or a file row does on click. */
|
|
23
|
+
export interface FolderNav {
|
|
24
|
+
options: FolderOptions;
|
|
25
|
+
/** Open a folder by its path (`""`: the root). */
|
|
26
|
+
open: (path: string) => void;
|
|
27
|
+
/** Preview a file row; absent when the view has no preview. */
|
|
28
|
+
openFile?: ((row: Row) => void) | undefined;
|
|
29
|
+
}
|
|
30
|
+
/** Is `row` a folder of `nav`'s listing (the `..` row included)? */
|
|
31
|
+
export declare function isFolderRow(row: Row, nav: FolderNav): boolean;
|
|
32
|
+
/** What `<UdcDataView>` hands every renderer; each takes the parts it uses. */
|
|
33
|
+
export interface RendererProps {
|
|
34
|
+
collection: string;
|
|
35
|
+
/** `describe` with soft-deleted fields already gone. */
|
|
36
|
+
describe: DescribeResponse;
|
|
37
|
+
/** The data view's paged list; loaded only for a renderer with `paging`. */
|
|
38
|
+
data: UdcCollectionResult;
|
|
39
|
+
/** Search, chips and filter tree, composed. */
|
|
40
|
+
filter: FilterNode | undefined;
|
|
41
|
+
/** Chips and filter tree without the search: for a renderer that searches what it loaded. */
|
|
42
|
+
baseFilter: FilterNode | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* The chart window, when the view has one and it applies (on the chart tab,
|
|
45
|
+
* or on any tab once the URL picked it): already ANDed into `filter` and
|
|
46
|
+
* `baseFilter`.
|
|
47
|
+
*/
|
|
48
|
+
chartWindow?: ChartWindowState | undefined;
|
|
49
|
+
/** `filter` without the chart window: what "of M" counts. */
|
|
50
|
+
unwindowedFilter?: FilterNode | undefined;
|
|
51
|
+
/** The search box, as typed. */
|
|
52
|
+
search: string;
|
|
53
|
+
sort: SortKey[];
|
|
54
|
+
onSort: (field: string, multi: boolean) => void;
|
|
55
|
+
mode: PagingMode;
|
|
56
|
+
page: number;
|
|
57
|
+
limit: number;
|
|
58
|
+
onPage: (page: number) => void;
|
|
59
|
+
filtered: boolean;
|
|
60
|
+
onClearFilters: () => void;
|
|
61
|
+
resetKey: string;
|
|
62
|
+
/** Set when the schema may be edited and the renderer has `editMode`. */
|
|
63
|
+
onSchemaAction?: ((a: SchemaAction) => void) | undefined;
|
|
64
|
+
/** For a renderer without `paging`: the count the toolbar shows. */
|
|
65
|
+
onCount: (count: RendererCount | null) => void;
|
|
66
|
+
/** Set when the view has `folder_options`. */
|
|
67
|
+
folder?: FolderNav | undefined;
|
|
68
|
+
}
|
|
69
|
+
export interface RendererEntry {
|
|
70
|
+
component: ComponentType<RendererProps>;
|
|
71
|
+
icon: LucideIcon;
|
|
72
|
+
/** `APP.<labelKey>` is the tab label. */
|
|
73
|
+
labelKey: string;
|
|
74
|
+
/** Reads the data view's paged list: the paging toggle shows, the list loads. */
|
|
75
|
+
paging: boolean;
|
|
76
|
+
/** Offers the schema editor (column menus, add column). */
|
|
77
|
+
editMode: boolean;
|
|
78
|
+
/** Extra controls in the toolbar while this tab is open. */
|
|
79
|
+
toolbar?: ComponentType<{
|
|
80
|
+
collection: string;
|
|
81
|
+
describe: DescribeResponse;
|
|
82
|
+
}>;
|
|
83
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../src/renderers/types.ts"],"sourcesContent":["import type { DescribeResponse, FilterNode, FolderOptions, Row, SortKey } from \"@jsudc/core\";\nimport type { LucideIcon } from \"lucide-react\";\nimport type { ComponentType } from \"react\";\nimport type { ChartWindowState } from \"../chart/useChartWindow\";\nimport type { SchemaAction } from \"../schema-editor/fieldForm\";\nimport type { UdcCollectionResult } from \"../udc/hooks\";\nimport type { PagingMode } from \"../udc/keys\";\n\n/** The row count a renderer that loads its own rows reports to the toolbar. */\nexport interface RendererCount {\n shown: number;\n total: number | null;\n /**\n * `nodes`: the toolbar reads \"N nodes\" (the tree), `map`: \"N on map of M\"\n * (rows without a position are not drawn), `chart`: \"N points in window of\n * M\" (M counts the filter without the window), instead of \"Showing N of M\".\n */\n unit?: \"nodes\" | \"map\" | \"chart\";\n /** A source serving a fetched copy (http_api): when it was fetched, and whether it is stale. */\n fetchedAt?: string | null;\n stale?: boolean;\n}\n\n/** A folder-shaped collection (`folder_options`): what a folder row or a file row does on click. */\nexport interface FolderNav {\n options: FolderOptions;\n /** Open a folder by its path (`\"\"`: the root). */\n open: (path: string) => void;\n /** Preview a file row; absent when the view has no preview. */\n openFile?: ((row: Row) => void) | undefined;\n}\n\n/** Is `row` a folder of `nav`'s listing (the `..` row included)? */\nexport function isFolderRow(row: Row, nav: FolderNav): boolean {\n return row[nav.options.kind_field] === nav.options.dir_value;\n}\n\n/** What `<UdcDataView>` hands every renderer; each takes the parts it uses. */\nexport interface RendererProps {\n collection: string;\n /** `describe` with soft-deleted fields already gone. */\n describe: DescribeResponse;\n /** The data view's paged list; loaded only for a renderer with `paging`. */\n data: UdcCollectionResult;\n /** Search, chips and filter tree, composed. */\n filter: FilterNode | undefined;\n /** Chips and filter tree without the search: for a renderer that searches what it loaded. */\n baseFilter: FilterNode | undefined;\n /**\n * The chart window, when the view has one and it applies (on the chart tab,\n * or on any tab once the URL picked it): already ANDed into `filter` and\n * `baseFilter`.\n */\n chartWindow?: ChartWindowState | undefined;\n /** `filter` without the chart window: what \"of M\" counts. */\n unwindowedFilter?: FilterNode | undefined;\n /** The search box, as typed. */\n search: string;\n sort: SortKey[];\n onSort: (field: string, multi: boolean) => void;\n mode: PagingMode;\n page: number;\n limit: number;\n onPage: (page: number) => void;\n filtered: boolean;\n onClearFilters: () => void;\n resetKey: string;\n /** Set when the schema may be edited and the renderer has `editMode`. */\n onSchemaAction?: ((a: SchemaAction) => void) | undefined;\n /** For a renderer without `paging`: the count the toolbar shows. */\n onCount: (count: RendererCount | null) => void;\n /** Set when the view has `folder_options`. */\n folder?: FolderNav | undefined;\n}\n\nexport interface RendererEntry {\n component: ComponentType<RendererProps>;\n icon: LucideIcon;\n /** `APP.<labelKey>` is the tab label. */\n labelKey: string;\n /** Reads the data view's paged list: the paging toggle shows, the list loads. */\n paging: boolean;\n /** Offers the schema editor (column menus, add column). */\n editMode: boolean;\n /** Extra controls in the toolbar while this tab is open. */\n toolbar?: ComponentType<{ collection: string; describe: DescribeResponse }>;\n}\n"],"mappings":";;AAiCA,SAAgB,YAAY,KAAU,KAAyB;CAC7D,OAAO,IAAI,IAAI,QAAQ,gBAAgB,IAAI,QAAQ;AACrD"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { SchemaAction } from "./fieldForm";
|
|
2
|
+
/**
|
|
3
|
+
* The kebab on a column header: add a column before or after this one, edit
|
|
4
|
+
* it, delete it. The trigger shows on header hover, on focus and while open.
|
|
5
|
+
*/
|
|
6
|
+
export declare function ColumnHeaderMenu({ field, label, onAction, className, }: {
|
|
7
|
+
field: string;
|
|
8
|
+
label: string;
|
|
9
|
+
onAction: (a: SchemaAction) => void;
|
|
10
|
+
className?: string;
|
|
11
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger } from "../components/ui/dropdown-menu.js";
|
|
2
|
+
import { useI18n } from "../i18n/i18n.js";
|
|
3
|
+
import { cn } from "../lib/utils.js";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { ArrowLeftToLine, ArrowRightToLine, EllipsisVertical, Pencil, Trash2 } from "lucide-react";
|
|
6
|
+
// src/schema-editor/ColumnHeaderMenu.tsx
|
|
7
|
+
/**
|
|
8
|
+
* The kebab on a column header: add a column before or after this one, edit
|
|
9
|
+
* it, delete it. The trigger shows on header hover, on focus and while open.
|
|
10
|
+
*/
|
|
11
|
+
function ColumnHeaderMenu({ field, label, onAction, className }) {
|
|
12
|
+
const { t } = useI18n();
|
|
13
|
+
return /* @__PURE__ */ jsxs(DropdownMenu, {
|
|
14
|
+
modal: false,
|
|
15
|
+
children: [/* @__PURE__ */ jsx(DropdownMenuTrigger, {
|
|
16
|
+
"data-testid": `col-menu-${field}`,
|
|
17
|
+
"aria-label": t("APP", "COL_MENU", { label }),
|
|
18
|
+
className: cn("grid size-6 shrink-0 place-items-center rounded-md text-muted-foreground outline-none transition-[opacity,background-color,color]", "opacity-0 group-hover/th:opacity-100 focus-visible:opacity-100 data-[state=open]:opacity-100", "hover:bg-border/70 hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring data-[state=open]:bg-border/70 data-[state=open]:text-foreground", className),
|
|
19
|
+
children: /* @__PURE__ */ jsx(EllipsisVertical, { className: "size-3.5" })
|
|
20
|
+
}), /* @__PURE__ */ jsxs(DropdownMenuContent, {
|
|
21
|
+
"data-testid": "col-menu",
|
|
22
|
+
align: "end",
|
|
23
|
+
children: [
|
|
24
|
+
/* @__PURE__ */ jsx(DropdownMenuLabel, {
|
|
25
|
+
className: "truncate",
|
|
26
|
+
children: label
|
|
27
|
+
}),
|
|
28
|
+
/* @__PURE__ */ jsxs(DropdownMenuItem, {
|
|
29
|
+
"data-testid": "col-menu-add-before",
|
|
30
|
+
onSelect: () => onAction({
|
|
31
|
+
kind: "add",
|
|
32
|
+
position: {
|
|
33
|
+
where: "before",
|
|
34
|
+
anchor: field
|
|
35
|
+
}
|
|
36
|
+
}),
|
|
37
|
+
children: [/* @__PURE__ */ jsx(ArrowLeftToLine, {}), t("APP", "COL_ADD_BEFORE")]
|
|
38
|
+
}),
|
|
39
|
+
/* @__PURE__ */ jsxs(DropdownMenuItem, {
|
|
40
|
+
"data-testid": "col-menu-add-after",
|
|
41
|
+
onSelect: () => onAction({
|
|
42
|
+
kind: "add",
|
|
43
|
+
position: {
|
|
44
|
+
where: "after",
|
|
45
|
+
anchor: field
|
|
46
|
+
}
|
|
47
|
+
}),
|
|
48
|
+
children: [/* @__PURE__ */ jsx(ArrowRightToLine, {}), t("APP", "COL_ADD_AFTER")]
|
|
49
|
+
}),
|
|
50
|
+
/* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
|
|
51
|
+
/* @__PURE__ */ jsxs(DropdownMenuItem, {
|
|
52
|
+
"data-testid": "col-menu-edit",
|
|
53
|
+
onSelect: () => onAction({
|
|
54
|
+
kind: "edit",
|
|
55
|
+
field
|
|
56
|
+
}),
|
|
57
|
+
children: [/* @__PURE__ */ jsx(Pencil, {}), t("APP", "COL_EDIT")]
|
|
58
|
+
}),
|
|
59
|
+
/* @__PURE__ */ jsxs(DropdownMenuItem, {
|
|
60
|
+
"data-testid": "col-menu-delete",
|
|
61
|
+
tone: "danger",
|
|
62
|
+
onSelect: () => onAction({
|
|
63
|
+
kind: "delete",
|
|
64
|
+
field
|
|
65
|
+
}),
|
|
66
|
+
children: [/* @__PURE__ */ jsx(Trash2, {}), t("APP", "COL_DELETE")]
|
|
67
|
+
})
|
|
68
|
+
]
|
|
69
|
+
})]
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
export { ColumnHeaderMenu };
|
|
73
|
+
|
|
74
|
+
//# sourceMappingURL=ColumnHeaderMenu.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColumnHeaderMenu.js","names":[],"sources":["../../src/schema-editor/ColumnHeaderMenu.tsx"],"sourcesContent":["import { ArrowLeftToLine, ArrowRightToLine, EllipsisVertical, Pencil, Trash2 } from \"lucide-react\";\nimport {\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuLabel,\n DropdownMenuSeparator,\n DropdownMenuTrigger,\n} from \"../components/ui/dropdown-menu\";\nimport { useI18n } from \"../i18n/i18n\";\nimport { cn } from \"../lib/utils\";\nimport type { SchemaAction } from \"./fieldForm\";\n\n/**\n * The kebab on a column header: add a column before or after this one, edit\n * it, delete it. The trigger shows on header hover, on focus and while open.\n */\nexport function ColumnHeaderMenu({\n field,\n label,\n onAction,\n className,\n}: {\n field: string;\n label: string;\n onAction: (a: SchemaAction) => void;\n className?: string;\n}) {\n const { t } = useI18n();\n return (\n <DropdownMenu modal={false}>\n <DropdownMenuTrigger\n data-testid={`col-menu-${field}`}\n aria-label={t(\"APP\", \"COL_MENU\", { label })}\n className={cn(\n \"grid size-6 shrink-0 place-items-center rounded-md text-muted-foreground outline-none transition-[opacity,background-color,color]\",\n \"opacity-0 group-hover/th:opacity-100 focus-visible:opacity-100 data-[state=open]:opacity-100\",\n \"hover:bg-border/70 hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring data-[state=open]:bg-border/70 data-[state=open]:text-foreground\",\n className,\n )}\n >\n <EllipsisVertical className=\"size-3.5\" />\n </DropdownMenuTrigger>\n <DropdownMenuContent data-testid=\"col-menu\" align=\"end\">\n <DropdownMenuLabel className=\"truncate\">{label}</DropdownMenuLabel>\n <DropdownMenuItem\n data-testid=\"col-menu-add-before\"\n onSelect={() => onAction({ kind: \"add\", position: { where: \"before\", anchor: field } })}\n >\n <ArrowLeftToLine />\n {t(\"APP\", \"COL_ADD_BEFORE\")}\n </DropdownMenuItem>\n <DropdownMenuItem\n data-testid=\"col-menu-add-after\"\n onSelect={() => onAction({ kind: \"add\", position: { where: \"after\", anchor: field } })}\n >\n <ArrowRightToLine />\n {t(\"APP\", \"COL_ADD_AFTER\")}\n </DropdownMenuItem>\n <DropdownMenuSeparator />\n <DropdownMenuItem\n data-testid=\"col-menu-edit\"\n onSelect={() => onAction({ kind: \"edit\", field })}\n >\n <Pencil />\n {t(\"APP\", \"COL_EDIT\")}\n </DropdownMenuItem>\n <DropdownMenuItem\n data-testid=\"col-menu-delete\"\n tone=\"danger\"\n onSelect={() => onAction({ kind: \"delete\", field })}\n >\n <Trash2 />\n {t(\"APP\", \"COL_DELETE\")}\n </DropdownMenuItem>\n </DropdownMenuContent>\n </DropdownMenu>\n );\n}\n"],"mappings":";;;;;;;;;;AAiBA,SAAgB,iBAAiB,EAC/B,OACA,OACA,UACA,aAMC;CACD,MAAM,EAAE,MAAM,QAAQ;CACtB,OACE,qBAAC,cAAD;EAAc,OAAO;EAArB,UAAA,CACE,oBAAC,qBAAD;GACE,eAAa,YAAY;GACzB,cAAY,EAAE,OAAO,YAAY,EAAE,MAAM,CAAC;GAC1C,WAAW,GACT,qIACA,gGACA,0JACA,SACF;GAEA,UAAA,oBAAC,kBAAD,EAAkB,WAAU,WAAY,CAAA;EACrB,CAAA,GACrB,qBAAC,qBAAD;GAAqB,eAAY;GAAW,OAAM;GAAlD,UAAA;IACE,oBAAC,mBAAD;KAAmB,WAAU;KAAY,UAAA;IAAyB,CAAA;IAClE,qBAAC,kBAAD;KACE,eAAY;KACZ,gBAAgB,SAAS;MAAE,MAAM;MAAO,UAAU;OAAE,OAAO;OAAU,QAAQ;MAAM;KAAE,CAAC;KAFxF,UAAA,CAIE,oBAAC,iBAAD,CAAkB,CAAA,GACjB,EAAE,OAAO,gBAAgB,CACV;;IAClB,qBAAC,kBAAD;KACE,eAAY;KACZ,gBAAgB,SAAS;MAAE,MAAM;MAAO,UAAU;OAAE,OAAO;OAAS,QAAQ;MAAM;KAAE,CAAC;KAFvF,UAAA,CAIE,oBAAC,kBAAD,CAAmB,CAAA,GAClB,EAAE,OAAO,eAAe,CACT;;IAClB,oBAAC,uBAAD,CAAwB,CAAA;IACxB,qBAAC,kBAAD;KACE,eAAY;KACZ,gBAAgB,SAAS;MAAE,MAAM;MAAQ;KAAM,CAAC;KAFlD,UAAA,CAIE,oBAAC,QAAD,CAAS,CAAA,GACR,EAAE,OAAO,UAAU,CACJ;;IAClB,qBAAC,kBAAD;KACE,eAAY;KACZ,MAAK;KACL,gBAAgB,SAAS;MAAE,MAAM;MAAU;KAAM,CAAC;KAHpD,UAAA,CAKE,oBAAC,QAAD,CAAS,CAAA,GACR,EAAE,OAAO,YAAY,CACN;;GACC;EACT,CAAA,CAAA;;AAElB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Confirms a soft delete: the column goes, the data stays. */
|
|
2
|
+
export declare function DeleteFieldDialog({ collection, field, label, onDeleted, onCancel, }: {
|
|
3
|
+
collection: string;
|
|
4
|
+
field: string;
|
|
5
|
+
label: string;
|
|
6
|
+
onDeleted: () => void;
|
|
7
|
+
onCancel: () => void;
|
|
8
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { Button } from "../components/ui/button.js";
|
|
2
|
+
import { DialogBody, DialogContent, DialogFooter } from "../components/ui/dialog.js";
|
|
3
|
+
import { Spinner } from "../components/ui/misc.js";
|
|
4
|
+
import { useI18n } from "../i18n/i18n.js";
|
|
5
|
+
import { useUdcSchema } from "../udc/hooks.js";
|
|
6
|
+
import { useState } from "react";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { AlertTriangle, Trash2 } from "lucide-react";
|
|
9
|
+
import { isUdcError } from "@jsudc/core";
|
|
10
|
+
// src/schema-editor/DeleteFieldDialog.tsx
|
|
11
|
+
/** Confirms a soft delete: the column goes, the data stays. */
|
|
12
|
+
function DeleteFieldDialog({ collection, field, label, onDeleted, onCancel }) {
|
|
13
|
+
const { t } = useI18n();
|
|
14
|
+
const { softDeleteField } = useUdcSchema(collection);
|
|
15
|
+
const [error, setError] = useState(null);
|
|
16
|
+
const pending = softDeleteField.isPending;
|
|
17
|
+
const confirm = async () => {
|
|
18
|
+
setError(null);
|
|
19
|
+
try {
|
|
20
|
+
await softDeleteField.mutateAsync(field);
|
|
21
|
+
onDeleted();
|
|
22
|
+
} catch (err) {
|
|
23
|
+
setError(isUdcError(err) || err instanceof Error ? err.message : String(err));
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
return /* @__PURE__ */ jsxs(DialogContent, {
|
|
27
|
+
role: "alertdialog",
|
|
28
|
+
"data-testid": "delete-field",
|
|
29
|
+
title: t("APP", "DELETE_TITLE", { label }),
|
|
30
|
+
onEscapeKeyDown: (e) => pending && e.preventDefault(),
|
|
31
|
+
onInteractOutside: (e) => pending && e.preventDefault(),
|
|
32
|
+
children: [/* @__PURE__ */ jsxs(DialogBody, {
|
|
33
|
+
className: "flex gap-3",
|
|
34
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
35
|
+
className: "grid size-9 shrink-0 place-items-center rounded-lg bg-sem-danger-bg text-sem-danger",
|
|
36
|
+
children: /* @__PURE__ */ jsx(Trash2, { className: "size-4" })
|
|
37
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
38
|
+
className: "min-w-0 text-[13px] text-muted-foreground",
|
|
39
|
+
children: [
|
|
40
|
+
/* @__PURE__ */ jsx("p", {
|
|
41
|
+
"data-testid": "delete-field-body",
|
|
42
|
+
children: t("APP", "DELETE_BODY")
|
|
43
|
+
}),
|
|
44
|
+
/* @__PURE__ */ jsxs("p", {
|
|
45
|
+
className: "mt-2",
|
|
46
|
+
children: [
|
|
47
|
+
t("APP", "DELETE_FIELD_NAME"),
|
|
48
|
+
" ",
|
|
49
|
+
/* @__PURE__ */ jsx("code", {
|
|
50
|
+
className: "rounded bg-muted px-1 py-0.5 font-mono text-xs text-foreground",
|
|
51
|
+
children: field
|
|
52
|
+
})
|
|
53
|
+
]
|
|
54
|
+
}),
|
|
55
|
+
error ? /* @__PURE__ */ jsxs("p", {
|
|
56
|
+
role: "alert",
|
|
57
|
+
"data-testid": "delete-field-error",
|
|
58
|
+
className: "mt-3 flex items-start gap-1.5 text-sem-danger",
|
|
59
|
+
children: [/* @__PURE__ */ jsx(AlertTriangle, { className: "mt-0.5 size-3.5 shrink-0" }), error]
|
|
60
|
+
}) : null
|
|
61
|
+
]
|
|
62
|
+
})]
|
|
63
|
+
}), /* @__PURE__ */ jsxs(DialogFooter, { children: [/* @__PURE__ */ jsx(Button, {
|
|
64
|
+
variant: "ghost",
|
|
65
|
+
onClick: onCancel,
|
|
66
|
+
disabled: pending,
|
|
67
|
+
children: t("APP", "CANCEL")
|
|
68
|
+
}), /* @__PURE__ */ jsxs(Button, {
|
|
69
|
+
variant: "danger",
|
|
70
|
+
"data-testid": "delete-field-confirm",
|
|
71
|
+
onClick: () => void confirm(),
|
|
72
|
+
disabled: pending,
|
|
73
|
+
children: [pending ? /* @__PURE__ */ jsx(Spinner, {}) : null, t("APP", "DELETE_CONFIRM")]
|
|
74
|
+
})] })]
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
export { DeleteFieldDialog };
|
|
78
|
+
|
|
79
|
+
//# sourceMappingURL=DeleteFieldDialog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DeleteFieldDialog.js","names":[],"sources":["../../src/schema-editor/DeleteFieldDialog.tsx"],"sourcesContent":["import { isUdcError } from \"@jsudc/core\";\nimport { AlertTriangle, Trash2 } from \"lucide-react\";\nimport { useState } from \"react\";\nimport { Button } from \"../components/ui/button\";\nimport { DialogBody, DialogContent, DialogFooter } from \"../components/ui/dialog\";\nimport { Spinner } from \"../components/ui/misc\";\nimport { useI18n } from \"../i18n/i18n\";\nimport { useUdcSchema } from \"../udc/hooks\";\n\n/** Confirms a soft delete: the column goes, the data stays. */\nexport function DeleteFieldDialog({\n collection,\n field,\n label,\n onDeleted,\n onCancel,\n}: {\n collection: string;\n field: string;\n label: string;\n onDeleted: () => void;\n onCancel: () => void;\n}) {\n const { t } = useI18n();\n const { softDeleteField } = useUdcSchema(collection);\n const [error, setError] = useState<string | null>(null);\n const pending = softDeleteField.isPending;\n\n const confirm = async () => {\n setError(null);\n try {\n await softDeleteField.mutateAsync(field);\n onDeleted();\n } catch (err) {\n setError(isUdcError(err) || err instanceof Error ? err.message : String(err));\n }\n };\n\n return (\n <DialogContent\n role=\"alertdialog\"\n data-testid=\"delete-field\"\n title={t(\"APP\", \"DELETE_TITLE\", { label })}\n onEscapeKeyDown={(e) => pending && e.preventDefault()}\n onInteractOutside={(e) => pending && e.preventDefault()}\n >\n <DialogBody className=\"flex gap-3\">\n <span className=\"grid size-9 shrink-0 place-items-center rounded-lg bg-sem-danger-bg text-sem-danger\">\n <Trash2 className=\"size-4\" />\n </span>\n <div className=\"min-w-0 text-[13px] text-muted-foreground\">\n <p data-testid=\"delete-field-body\">{t(\"APP\", \"DELETE_BODY\")}</p>\n <p className=\"mt-2\">\n {t(\"APP\", \"DELETE_FIELD_NAME\")}{\" \"}\n <code className=\"rounded bg-muted px-1 py-0.5 font-mono text-xs text-foreground\">\n {field}\n </code>\n </p>\n {error ? (\n <p\n role=\"alert\"\n data-testid=\"delete-field-error\"\n className=\"mt-3 flex items-start gap-1.5 text-sem-danger\"\n >\n <AlertTriangle className=\"mt-0.5 size-3.5 shrink-0\" />\n {error}\n </p>\n ) : null}\n </div>\n </DialogBody>\n <DialogFooter>\n <Button variant=\"ghost\" onClick={onCancel} disabled={pending}>\n {t(\"APP\", \"CANCEL\")}\n </Button>\n <Button\n variant=\"danger\"\n data-testid=\"delete-field-confirm\"\n onClick={() => void confirm()}\n disabled={pending}\n >\n {pending ? <Spinner /> : null}\n {t(\"APP\", \"DELETE_CONFIRM\")}\n </Button>\n </DialogFooter>\n </DialogContent>\n );\n}\n"],"mappings":";;;;;;;;;;;AAUA,SAAgB,kBAAkB,EAChC,YACA,OACA,OACA,WACA,YAOC;CACD,MAAM,EAAE,MAAM,QAAQ;CACtB,MAAM,EAAE,oBAAoB,aAAa,UAAU;CACnD,MAAM,CAAC,OAAO,YAAY,SAAwB,IAAI;CACtD,MAAM,UAAU,gBAAgB;CAEhC,MAAM,UAAU,YAAY;EAC1B,SAAS,IAAI;EACb,IAAI;GACF,MAAM,gBAAgB,YAAY,KAAK;GACvC,UAAU;EACZ,SAAS,KAAK;GACZ,SAAS,WAAW,GAAG,KAAK,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG,CAAC;EAC9E;CACF;CAEA,OACE,qBAAC,eAAD;EACE,MAAK;EACL,eAAY;EACZ,OAAO,EAAE,OAAO,gBAAgB,EAAE,MAAM,CAAC;EACzC,kBAAkB,MAAM,WAAW,EAAE,eAAe;EACpD,oBAAoB,MAAM,WAAW,EAAE,eAAe;EALxD,UAAA,CAOE,qBAAC,YAAD;GAAY,WAAU;GAAtB,UAAA,CACE,oBAAC,QAAD;IAAM,WAAU;IACd,UAAA,oBAAC,QAAD,EAAQ,WAAU,SAAU,CAAA;GACxB,CAAA,GACN,qBAAC,OAAD;IAAK,WAAU;IAAf,UAAA;KACE,oBAAC,KAAD;MAAG,eAAY;MAAqB,UAAA,EAAE,OAAO,aAAa;KAAK,CAAA;KAC/D,qBAAC,KAAD;MAAG,WAAU;MAAb,UAAA;OACG,EAAE,OAAO,mBAAmB;OAAG;OAChC,oBAAC,QAAD;QAAM,WAAU;QACb,UAAA;OACG,CAAA;MACL;;KACF,QACC,qBAAC,KAAD;MACE,MAAK;MACL,eAAY;MACZ,WAAU;MAHZ,UAAA,CAKE,oBAAC,eAAD,EAAe,WAAU,2BAA4B,CAAA,GACpD,KACA;KACD,CAAA,IAAA;IACD;GACK,CAAA,CAAA;EACZ,CAAA,GAAA,qBAAC,cAAD,EAAA,UAAA,CACE,oBAAC,QAAD;GAAQ,SAAQ;GAAQ,SAAS;GAAU,UAAU;GAClD,UAAA,EAAE,OAAO,QAAQ;EACZ,CAAA,GACR,qBAAC,QAAD;GACE,SAAQ;GACR,eAAY;GACZ,eAAe,KAAK,QAAQ;GAC5B,UAAU;GAJZ,UAAA,CAMG,UAAU,oBAAC,SAAD,CAAU,CAAA,IAAI,MACxB,EAAE,OAAO,gBAAgB,CACpB;EACI,CAAA,CAAA,EAAA,CAAA,CACD;;AAEnB"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type SchemaDoc, type SchemaPosition } from "@jsudc/core";
|
|
2
|
+
export type FieldFormTarget = {
|
|
3
|
+
mode: "add";
|
|
4
|
+
position: SchemaPosition;
|
|
5
|
+
} | {
|
|
6
|
+
mode: "edit";
|
|
7
|
+
field: string;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* The add / edit column form, inside an open `<Dialog>`. Client-side
|
|
11
|
+
* validation runs before anything is sent; what the server still refuses
|
|
12
|
+
* (`validation_error`, `unsupported_op`) is shown inline, and the dialog
|
|
13
|
+
* stays open.
|
|
14
|
+
*/
|
|
15
|
+
export declare function FieldFormDialog({ collection, schema, target, fieldLabel, onSaved, onCancel, }: {
|
|
16
|
+
collection: string;
|
|
17
|
+
schema: SchemaDoc;
|
|
18
|
+
target: FieldFormTarget;
|
|
19
|
+
fieldLabel: (field: string) => string;
|
|
20
|
+
onSaved: (name: string, label: string) => void;
|
|
21
|
+
onCancel: () => void;
|
|
22
|
+
}): import("react").JSX.Element;
|