@startsimpli/ui 0.4.49 → 0.4.50
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@startsimpli/ui",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.50",
|
|
4
4
|
"description": "Shared UI components package for StartSimpli applications",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"next": "^14.0.0 || ^15.0.0 || ^16.0.0",
|
|
41
41
|
"react": "^18.0.0 || ^19.0.0",
|
|
42
42
|
"react-dom": "^18.0.0 || ^19.0.0",
|
|
43
|
-
"@startsimpli/
|
|
44
|
-
"@startsimpli/
|
|
43
|
+
"@startsimpli/auth": "0.4.29",
|
|
44
|
+
"@startsimpli/api": "0.5.44"
|
|
45
45
|
},
|
|
46
46
|
"peerDependenciesMeta": {
|
|
47
47
|
"@startsimpli/api": {
|
|
@@ -15,10 +15,21 @@ export interface RecordDetailProps {
|
|
|
15
15
|
fields: RecordField[]
|
|
16
16
|
emptyMessage?: string
|
|
17
17
|
className?: string
|
|
18
|
+
/**
|
|
19
|
+
* Show declared fields even when they have no value — the header stays with a
|
|
20
|
+
* muted placeholder — instead of hiding them. Lets a reader tell that a field
|
|
21
|
+
* (e.g. `content`) exists on the record but simply wasn't captured, rather than
|
|
22
|
+
* wondering whether it's missing from the schema. Default false (hide empties).
|
|
23
|
+
*/
|
|
24
|
+
showEmpty?: boolean
|
|
18
25
|
}
|
|
19
26
|
|
|
20
27
|
const URL_RE = /^https?:\/\//i
|
|
21
28
|
|
|
29
|
+
function hasValue(f: RecordField): boolean {
|
|
30
|
+
return f.value != null && String(f.value).trim() !== ''
|
|
31
|
+
}
|
|
32
|
+
|
|
22
33
|
/**
|
|
23
34
|
* Read-optimized view of a record's fields (startsim-768w.17.4). Renders short
|
|
24
35
|
* fields as a compact label/value list (auto-linking urls), long-text fields as
|
|
@@ -27,13 +38,13 @@ const URL_RE = /^https?:\/\//i
|
|
|
27
38
|
* `fields` and this owns the layout, so every Foundry tenant's detail drawer reads
|
|
28
39
|
* the same without duplicating the view.
|
|
29
40
|
*/
|
|
30
|
-
export function RecordDetail({ fields, emptyMessage = 'No details.', className }: RecordDetailProps) {
|
|
31
|
-
const
|
|
32
|
-
const shorts =
|
|
33
|
-
const longs =
|
|
34
|
-
const jsons =
|
|
41
|
+
export function RecordDetail({ fields, emptyMessage = 'No details.', className, showEmpty = false }: RecordDetailProps) {
|
|
42
|
+
const visible = showEmpty ? fields : fields.filter(hasValue)
|
|
43
|
+
const shorts = visible.filter((f) => f.kind !== 'longtext' && f.kind !== 'json')
|
|
44
|
+
const longs = visible.filter((f) => f.kind === 'longtext')
|
|
45
|
+
const jsons = visible.filter((f) => f.kind === 'json')
|
|
35
46
|
|
|
36
|
-
if (
|
|
47
|
+
if (visible.length === 0) {
|
|
37
48
|
return <p className={cn('text-sm text-muted-foreground', className)}>{emptyMessage}</p>
|
|
38
49
|
}
|
|
39
50
|
|
|
@@ -42,12 +53,15 @@ export function RecordDetail({ fields, emptyMessage = 'No details.', className }
|
|
|
42
53
|
{shorts.length > 0 && (
|
|
43
54
|
<dl className="space-y-1.5">
|
|
44
55
|
{shorts.map((f, i) => {
|
|
45
|
-
const
|
|
56
|
+
const empty = !hasValue(f)
|
|
57
|
+
const isUrl = !empty && (f.kind === 'url' || URL_RE.test(f.value))
|
|
46
58
|
return (
|
|
47
59
|
<div key={i} className="flex gap-2 text-sm">
|
|
48
60
|
<dt className="w-28 shrink-0 capitalize text-muted-foreground">{f.label}</dt>
|
|
49
61
|
<dd className="min-w-0 flex-1 break-words">
|
|
50
|
-
{
|
|
62
|
+
{empty ? (
|
|
63
|
+
<span className="text-muted-foreground">—</span>
|
|
64
|
+
) : isUrl ? (
|
|
51
65
|
<a
|
|
52
66
|
href={f.value}
|
|
53
67
|
target="_blank"
|
|
@@ -71,9 +85,13 @@ export function RecordDetail({ fields, emptyMessage = 'No details.', className }
|
|
|
71
85
|
<h4 className="text-xs font-medium uppercase tracking-wide text-muted-foreground">
|
|
72
86
|
{f.label}
|
|
73
87
|
</h4>
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
88
|
+
{hasValue(f) ? (
|
|
89
|
+
<div className="whitespace-pre-wrap text-sm leading-relaxed text-foreground">
|
|
90
|
+
{f.value}
|
|
91
|
+
</div>
|
|
92
|
+
) : (
|
|
93
|
+
<p className="text-sm italic text-muted-foreground">Not captured.</p>
|
|
94
|
+
)}
|
|
77
95
|
</section>
|
|
78
96
|
))}
|
|
79
97
|
|
|
@@ -82,9 +100,13 @@ export function RecordDetail({ fields, emptyMessage = 'No details.', className }
|
|
|
82
100
|
<h4 className="text-xs font-medium uppercase tracking-wide text-muted-foreground">
|
|
83
101
|
{f.label}
|
|
84
102
|
</h4>
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
103
|
+
{hasValue(f) ? (
|
|
104
|
+
<pre className="overflow-x-auto rounded-md bg-muted p-3 text-xs leading-relaxed">
|
|
105
|
+
{f.value}
|
|
106
|
+
</pre>
|
|
107
|
+
) : (
|
|
108
|
+
<p className="text-sm italic text-muted-foreground">Not captured.</p>
|
|
109
|
+
)}
|
|
88
110
|
</section>
|
|
89
111
|
))}
|
|
90
112
|
</div>
|