@standardbeagle/edit-db 0.4.448 → 0.4.450
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/empty-value.d.ts +0 -7
- package/dist/components/m2m-panel.d.ts +3 -3
- package/dist/components/row-actions.d.ts +3 -2
- package/dist/data-edit.d.ts +11 -0
- package/dist/edit-db.css +1 -1
- package/dist/editor.es.js +7264 -7169
- package/dist/editor.umd.cjs +34 -34
- package/dist/lib/format-value-render.test.d.ts +1 -0
- package/dist/lib/format-value.d.ts +53 -0
- package/dist/lib/format-value.test.d.ts +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { Column } from '../types/schema';
|
|
3
|
+
/**
|
|
4
|
+
* Per-column display formatting for grid/detail cells.
|
|
5
|
+
*
|
|
6
|
+
* Raw DB values — especially SQL Server datetimes like
|
|
7
|
+
* `2026-05-11T22:17:47.7636626` — are unreadable. This formats values into
|
|
8
|
+
* concise, locale-aware forms, driven by a `display-format` column metadata key
|
|
9
|
+
* with a sensible default inferred from the column type when none is set.
|
|
10
|
+
*
|
|
11
|
+
* Supported `display-format` values:
|
|
12
|
+
* date — locale date (e.g. "May 11, 2026")
|
|
13
|
+
* datetime — locale date + time (e.g. "May 11, 2026, 10:17 PM")
|
|
14
|
+
* time — locale time (e.g. "10:17 PM")
|
|
15
|
+
* relative — humanized relative time (e.g. "4 hours ago"), hover shows exact
|
|
16
|
+
* number — grouped locale number (e.g. "1,234,567")
|
|
17
|
+
* percent — locale percent (0.42 -> "42%")
|
|
18
|
+
* raw — no formatting (escape hatch)
|
|
19
|
+
*
|
|
20
|
+
* Any formatted cell keeps the exact value in a `title` so hovering reveals the
|
|
21
|
+
* precise underlying data.
|
|
22
|
+
*/
|
|
23
|
+
export declare const DISPLAY_FORMAT_KEY = "display-format";
|
|
24
|
+
/**
|
|
25
|
+
* Secondary, context-specific format template (used by compact surfaces like FK
|
|
26
|
+
* preview popovers). When a column doesn't set it, formatting falls back to the
|
|
27
|
+
* main `display-format`, so the preview matches the grid by default.
|
|
28
|
+
*/
|
|
29
|
+
export declare const DISPLAY_FORMAT_PREVIEW_KEY = "display-format-preview";
|
|
30
|
+
export type DisplayFormat = 'date' | 'datetime' | 'time' | 'relative' | 'number' | 'percent' | 'raw';
|
|
31
|
+
/** Options for {@link formatColumnValue}. */
|
|
32
|
+
export interface FormatOptions {
|
|
33
|
+
/**
|
|
34
|
+
* Metadata key to read the format from before falling back to the main
|
|
35
|
+
* `display-format`. Lets a context override the template while defaulting to
|
|
36
|
+
* the main one when the column doesn't set the override key.
|
|
37
|
+
*/
|
|
38
|
+
formatKey?: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Resolve the effective format: an explicit override key wins, then the main
|
|
42
|
+
* `display-format` metadata, else inferred from the column type. Passing
|
|
43
|
+
* `formatKey` lets a context default to the main template when its own is unset.
|
|
44
|
+
*/
|
|
45
|
+
export declare function resolveDisplayFormat(column: Column, formatKey?: string): DisplayFormat | null;
|
|
46
|
+
/** "4 hours ago" / "in 3 days" via Intl.RelativeTimeFormat. */
|
|
47
|
+
export declare function formatRelative(date: Date, now?: Date): string;
|
|
48
|
+
/**
|
|
49
|
+
* Format a scalar value for display, given its column. Returns a muted
|
|
50
|
+
* placeholder for null/empty, a locale-formatted node for known formats (with a
|
|
51
|
+
* `title` revealing the exact value), or the plain string otherwise.
|
|
52
|
+
*/
|
|
53
|
+
export declare function formatColumnValue(value: unknown, column: Column, options?: FormatOptions): ReactNode;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|