@asteby/metacore-runtime-react 50.2.0 → 51.0.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/CHANGELOG.md +13 -0
- package/README.md +26 -0
- package/dist/activity-timeline.d.ts.map +1 -1
- package/dist/activity-timeline.js +4 -2
- package/dist/audit-info.d.ts.map +1 -1
- package/dist/audit-info.js +3 -2
- package/dist/dialogs/dynamic-record.d.ts.map +1 -1
- package/dist/dialogs/dynamic-record.js +8 -5
- package/dist/dynamic-columns.d.ts +6 -0
- package/dist/dynamic-columns.d.ts.map +1 -1
- package/dist/dynamic-columns.js +30 -7
- package/dist/dynamic-kanban.js +6 -5
- package/dist/dynamic-table.d.ts.map +1 -1
- package/dist/dynamic-table.js +6 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/org-runtime-context.d.ts +38 -0
- package/dist/org-runtime-context.d.ts.map +1 -1
- package/dist/org-runtime-context.js +18 -0
- package/dist/org-runtime-provider.d.ts +14 -1
- package/dist/org-runtime-provider.d.ts.map +1 -1
- package/dist/org-runtime-provider.js +3 -3
- package/dist/record-history.d.ts.map +1 -1
- package/dist/record-history.js +3 -1
- package/dist/widgets/widget-card.d.ts +7 -2
- package/dist/widgets/widget-card.d.ts.map +1 -1
- package/dist/widgets/widget-card.js +6 -3
- package/package.json +3 -3
- package/src/__tests__/org-runtime-number-locale-system-actor.test.tsx +80 -0
- package/src/activity-timeline.tsx +4 -2
- package/src/audit-info.tsx +3 -2
- package/src/dialogs/dynamic-record.tsx +8 -5
- package/src/dynamic-columns.tsx +54 -6
- package/src/dynamic-kanban.tsx +6 -5
- package/src/dynamic-table.tsx +6 -4
- package/src/index.ts +1 -0
- package/src/org-runtime-context.ts +56 -0
- package/src/org-runtime-provider.tsx +29 -3
- package/src/record-history.tsx +3 -1
- package/src/widgets/widget-card.tsx +26 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// OrgRuntimeProvider — one place to feed the org's display config (timezone,
|
|
2
|
-
// currency, image-url resolver) to EVERY nested SDK renderer: dynamic tables,
|
|
2
|
+
// currency, number locale, image-url resolver) to EVERY nested SDK renderer: dynamic tables,
|
|
3
3
|
// relation tables, record dialogs and field cells all read these via context.
|
|
4
4
|
// The record dialog provides them locally, but standalone surfaces (the
|
|
5
5
|
// full-page detail view, any table mounted outside a dialog) had no provider,
|
|
@@ -12,7 +12,15 @@ import {
|
|
|
12
12
|
identityImageUrl,
|
|
13
13
|
type GetImageUrl,
|
|
14
14
|
} from './image-url-context'
|
|
15
|
-
import {
|
|
15
|
+
import {
|
|
16
|
+
CurrencyContext,
|
|
17
|
+
NumberLocalesContext,
|
|
18
|
+
SystemActorContext,
|
|
19
|
+
TaxRateContext,
|
|
20
|
+
TimeZoneContext,
|
|
21
|
+
type NumberLocales,
|
|
22
|
+
type SystemActor,
|
|
23
|
+
} from './org-runtime-context'
|
|
16
24
|
|
|
17
25
|
export interface OrgRuntimeProviderProps {
|
|
18
26
|
/** Org IANA timezone (e.g. `America/Mexico_City`). */
|
|
@@ -21,6 +29,18 @@ export interface OrgRuntimeProviderProps {
|
|
|
21
29
|
currency?: string
|
|
22
30
|
/** Org default tax rate as a fraction (e.g. `0.16`) for document lines. */
|
|
23
31
|
taxRate?: number
|
|
32
|
+
/**
|
|
33
|
+
* Number-locale overrides by UI language, e.g. `{ es: 'es-MX' }` so a
|
|
34
|
+
* Spanish UI formats numbers and money as Mexico does (11,461.50). Applies
|
|
35
|
+
* to table cells and footers, kanban cards and lane totals, and the record
|
|
36
|
+
* dialog. Omit to format with the UI language as-is.
|
|
37
|
+
*/
|
|
38
|
+
numberLocales?: NumberLocales
|
|
39
|
+
/**
|
|
40
|
+
* Presentation of the system actor (name + avatar) wherever a record shows
|
|
41
|
+
* who created/changed it and nobody did — e.g. `{ name: 'Gobi' }`.
|
|
42
|
+
*/
|
|
43
|
+
systemActor?: SystemActor
|
|
24
44
|
/** Resolver turning a stored path into a fetchable URL. Defaults to identity. */
|
|
25
45
|
getImageUrl?: GetImageUrl
|
|
26
46
|
children: ReactNode
|
|
@@ -30,6 +50,8 @@ export function OrgRuntimeProvider({
|
|
|
30
50
|
timeZone,
|
|
31
51
|
currency,
|
|
32
52
|
taxRate,
|
|
53
|
+
numberLocales,
|
|
54
|
+
systemActor,
|
|
33
55
|
getImageUrl = identityImageUrl,
|
|
34
56
|
children,
|
|
35
57
|
}: OrgRuntimeProviderProps) {
|
|
@@ -38,7 +60,11 @@ export function OrgRuntimeProvider({
|
|
|
38
60
|
<TimeZoneContext.Provider value={timeZone}>
|
|
39
61
|
<CurrencyContext.Provider value={currency}>
|
|
40
62
|
<TaxRateContext.Provider value={taxRate}>
|
|
41
|
-
{
|
|
63
|
+
<NumberLocalesContext.Provider value={numberLocales}>
|
|
64
|
+
<SystemActorContext.Provider value={systemActor}>
|
|
65
|
+
{children}
|
|
66
|
+
</SystemActorContext.Provider>
|
|
67
|
+
</NumberLocalesContext.Provider>
|
|
42
68
|
</TaxRateContext.Provider>
|
|
43
69
|
</CurrencyContext.Provider>
|
|
44
70
|
</TimeZoneContext.Provider>
|
package/src/record-history.tsx
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
import * as React from 'react'
|
|
14
|
+
import { useSystemActor } from './org-runtime-context'
|
|
14
15
|
import { formatDistanceToNow } from 'date-fns'
|
|
15
16
|
import { es, enUS } from 'date-fns/locale'
|
|
16
17
|
import { ChevronDown, ChevronRight, Clock, ExternalLink } from 'lucide-react'
|
|
@@ -124,6 +125,7 @@ export const RecordHistory: React.FC<RecordHistoryProps> = ({
|
|
|
124
125
|
const dateLocale = locale === 'en' ? enUS : es
|
|
125
126
|
|
|
126
127
|
// Sort: most recent first
|
|
128
|
+
const systemName = useSystemActor()?.name || 'Sistema'
|
|
127
129
|
const sorted = React.useMemo(
|
|
128
130
|
() => [...events].sort((a, b) => new Date(b.occurred_at).getTime() - new Date(a.occurred_at).getTime()),
|
|
129
131
|
[events],
|
|
@@ -164,7 +166,7 @@ export const RecordHistory: React.FC<RecordHistoryProps> = ({
|
|
|
164
166
|
{sorted.map((event) => {
|
|
165
167
|
const isOpen = openIds.has(event.id)
|
|
166
168
|
const dotColor = actionDotColor(event.action)
|
|
167
|
-
const actor = event.actor_label || event.actor_id ||
|
|
169
|
+
const actor = event.actor_label || event.actor_id || systemName
|
|
168
170
|
const timeAgo = (() => {
|
|
169
171
|
try {
|
|
170
172
|
return formatDistanceToNow(new Date(event.occurred_at), { addSuffix: true, locale: dateLocale })
|
|
@@ -114,12 +114,35 @@ export function WidgetEmpty({ message }: { message: string }) {
|
|
|
114
114
|
)
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
/**
|
|
118
|
-
|
|
117
|
+
/**
|
|
118
|
+
* Per-widget error state — isolated so a broken widget never tumbles the grid.
|
|
119
|
+
* Pass `onRetry` to offer a retry (e.g. the widget query's `refetch`).
|
|
120
|
+
*/
|
|
121
|
+
export function WidgetError({
|
|
122
|
+
message,
|
|
123
|
+
onRetry,
|
|
124
|
+
retryLabel = 'Reintentar',
|
|
125
|
+
}: {
|
|
126
|
+
message: string
|
|
127
|
+
onRetry?: () => void
|
|
128
|
+
retryLabel?: string
|
|
129
|
+
}) {
|
|
119
130
|
return (
|
|
120
|
-
<div
|
|
131
|
+
<div
|
|
132
|
+
role="alert"
|
|
133
|
+
className="flex flex-1 flex-wrap items-center justify-center gap-2 py-6 text-center text-xs text-destructive"
|
|
134
|
+
>
|
|
121
135
|
<DynamicIcon name="TriangleAlert" className="size-4" />
|
|
122
136
|
<span>{message}</span>
|
|
137
|
+
{onRetry && (
|
|
138
|
+
<button
|
|
139
|
+
type="button"
|
|
140
|
+
onClick={onRetry}
|
|
141
|
+
className="rounded-md border px-2 py-0.5 font-medium text-foreground hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
|
|
142
|
+
>
|
|
143
|
+
{retryLabel}
|
|
144
|
+
</button>
|
|
145
|
+
)}
|
|
123
146
|
</div>
|
|
124
147
|
)
|
|
125
148
|
}
|