@asteby/metacore-runtime-react 18.7.0 → 18.9.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 +23 -0
- package/dist/dynamic-columns.d.ts.map +1 -1
- package/dist/dynamic-columns.js +44 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/org-runtime-provider.d.ts +13 -0
- package/dist/org-runtime-provider.d.ts.map +1 -0
- package/dist/org-runtime-provider.js +6 -0
- package/package.json +1 -1
- package/src/dynamic-columns.tsx +69 -0
- package/src/index.ts +2 -0
- package/src/org-runtime-provider.tsx +42 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# @asteby/metacore-runtime-react
|
|
2
2
|
|
|
3
|
+
## 18.9.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 5becc8e: Add a `reference` display type for SAP-style polymorphic source-document columns.
|
|
8
|
+
|
|
9
|
+
A column declared `display: "reference"` (e.g. `inventory_movements.source_id`,
|
|
10
|
+
whose target document varies by a `source_kind` discriminator) now renders a
|
|
11
|
+
navigable chip resolved by the backend. The new `ReferenceCell` reads the
|
|
12
|
+
resolved sibling `row[<key w/o _id>] = { value, label, kind, table }`: it shows
|
|
13
|
+
the `label` when present, else a short id (first 8 chars of the value), and —
|
|
14
|
+
when the sibling carries a target `table` and `value` — wraps the chip in a
|
|
15
|
+
plain `<a href="/m/<table>/<value>">` so the host router navigates to the source
|
|
16
|
+
document. Mirrors `RelationCell`'s chip look (subtle tint, dark-mode aware) and
|
|
17
|
+
is domain-agnostic: any polymorphic FK carrying the `reference` renderer works
|
|
18
|
+
without per-addon code.
|
|
19
|
+
|
|
20
|
+
## 18.8.0
|
|
21
|
+
|
|
22
|
+
### Minor Changes
|
|
23
|
+
|
|
24
|
+
- 266e3da: Add `OrgRuntimeProvider` (+ export `CurrencyContext`/`TimeZoneContext`/`useCurrency`/`useTimeZone`) so host apps can feed the org's display config (timezone, currency, image-url resolver) to EVERY nested renderer from one place. Standalone surfaces like the full-page detail view — which mount `DynamicRelations`/`DynamicTable` outside the record dialog — previously had no provider, so money fell back to USD and datetimes to the browser zone. Wrap the authenticated app root once for app-wide org consistency.
|
|
25
|
+
|
|
3
26
|
## 18.7.0
|
|
4
27
|
|
|
5
28
|
### Minor Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dynamic-columns.d.ts","sourceRoot":"","sources":["../src/dynamic-columns.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAAU,KAAK,MAAM,EAAE,MAAM,UAAU,CAAA;AAgC9C,OAAO,KAAK,EAAiB,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAE9D,OAAO,KAAK,EAER,iBAAiB,EACpB,MAAM,wBAAwB,CAAA;AAE/B,qEAAqE;AACrE,MAAM,WAAW,qBAAqB;IAClC;;;;OAIG;IACH,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAA;IACtC;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;CACtB;AA0BD;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAAI,KAAK,gBAAgB,EAAE,cAAc,MAAM,KAAG,MACzB,CAAA;AAoErD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,0BAA0B,GAAI,QAAQ,GAAG,EAAE,KAAK,GAAG,KAAG,OAMlE,CAAA;AAqKD;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,GAAI,KAAK,IAAI,CAAC,gBAAgB,EAAE,KAAK,CAAC,KAAG,MAGnE,CAAA;AAED,6EAA6E;AAC7E,eAAO,MAAM,eAAe,2DAA4D,CAAA;AAExF;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,cAAc,CAC1B,KAAK,EAAE,OAAO,EACd,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,MAA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,EACd,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,MAAM,EAAE,MAAM,EACd,QAAQ,CAAC,EAAE,MAAM,GAClB;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CA6C5C;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,GAAI,KAAK,gBAAgB,EAAE,KAAK,GAAG,KAAG,MAWtE,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,GAAI,KAAK,gBAAgB,EAAE,KAAK,GAAG,KAAG,MAOtE,CAAA;AAsID;;;;GAIG;AACH,wBAAgB,4BAA4B,CACxC,OAAO,GAAE,qBAA0B,GACpC,iBAAiB,CAinBnB;AAED;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,EAAE,iBACL,CAAA"}
|
package/dist/dynamic-columns.js
CHANGED
|
@@ -340,6 +340,42 @@ const RelationCell = ({ col, row, getImageUrl }) => {
|
|
|
340
340
|
const chipStyles = relationChipStyles(display, { isDark });
|
|
341
341
|
return (_jsxs("span", { className: "inline-flex max-w-[220px] items-center gap-1.5 rounded-md px-2 py-0.5 text-sm font-medium", style: chipStyles, title: display, children: [image && (_jsx(RelationThumbnail, { src: image, alt: display, getImageUrl: getImageUrl, size: 18 })), _jsx("span", { className: "truncate", children: display })] }));
|
|
342
342
|
};
|
|
343
|
+
/**
|
|
344
|
+
* Renders a SAP-style polymorphic source-document reference as a navigable
|
|
345
|
+
* chip. Reads the backend-resolved sibling `row[<key w/o _id>] =
|
|
346
|
+
* { value, label, kind, table }` (see `relationKeyFor`) — the discriminator
|
|
347
|
+
* (`source_kind`) selects the target model and the backend stamps the resolved
|
|
348
|
+
* SQL `table` so the cell can link to `/m/<table>/<value>` (the host router
|
|
349
|
+
* handles `/m/:model/:id`). Shows the resolved `label` when present, else a
|
|
350
|
+
* short id (first 8 chars of the value). Domain-agnostic: any polymorphic FK
|
|
351
|
+
* (`source_id`, `document_id`, …) carrying `display: "reference"` works without
|
|
352
|
+
* per-addon code. Mirrors `RelationCell`'s chip look (subtle tint, dark-mode
|
|
353
|
+
* aware) so references read consistently next to plain relations.
|
|
354
|
+
*/
|
|
355
|
+
const ReferenceCell = ({ col, row }) => {
|
|
356
|
+
const isDark = useIsDarkTheme();
|
|
357
|
+
const sibling = getNestedValue(row, relationKeyFor(col));
|
|
358
|
+
const value = (sibling && typeof sibling === 'object' ? sibling.value : undefined) ??
|
|
359
|
+
getNestedValue(row, col.key);
|
|
360
|
+
if (value === undefined || value === null || value === '' || isNilUuid(value)) {
|
|
361
|
+
return _jsx(EmptyCell, {});
|
|
362
|
+
}
|
|
363
|
+
const label = sibling && typeof sibling === 'object' ? sibling.label : undefined;
|
|
364
|
+
const kind = sibling && typeof sibling === 'object' ? sibling.kind : undefined;
|
|
365
|
+
const table = sibling && typeof sibling === 'object' ? sibling.table : undefined;
|
|
366
|
+
const displayText = label !== undefined && label !== null && label !== ''
|
|
367
|
+
? String(label)
|
|
368
|
+
: `${String(value).slice(0, 8)}`;
|
|
369
|
+
// Tint keyed on the discriminator (when present) so e.g. sale/transfer/
|
|
370
|
+
// adjustment chips read as visually distinct families; falls back to the
|
|
371
|
+
// display text. Same subtle relation-chip look + dark-mode handling.
|
|
372
|
+
const chipStyles = relationChipStyles(String(kind || displayText), { isDark });
|
|
373
|
+
const className = 'inline-flex max-w-[220px] items-center gap-1 rounded-md px-2 py-0.5 text-sm font-medium';
|
|
374
|
+
if (table && value) {
|
|
375
|
+
return (_jsx("a", { href: `/m/${table}/${value}`, onClick: (e) => e.stopPropagation(), className: `${className} hover:underline`, style: chipStyles, title: displayText, children: _jsx("span", { className: "truncate", children: displayText }) }));
|
|
376
|
+
}
|
|
377
|
+
return (_jsx("span", { className: className, style: chipStyles, title: displayText, children: _jsx("span", { className: "truncate", children: displayText }) }));
|
|
378
|
+
};
|
|
343
379
|
/**
|
|
344
380
|
* Generic avatar-style cell: round/rounded photo (or initials fallback) +
|
|
345
381
|
* primary name + optional subtitle. Backs the `avatar`/`search` columns as
|
|
@@ -444,6 +480,14 @@ export function makeDefaultGetDynamicColumns(helpers = {}) {
|
|
|
444
480
|
// `in_progress` reads as "In Progress" instead of raw.
|
|
445
481
|
return (_jsx(Badge, { variant: "outline", className: "border-0", style: styles, children: humanizeToken(sv) }));
|
|
446
482
|
}
|
|
483
|
+
// Polymorphic source-document reference (SAP-style). Reads
|
|
484
|
+
// the backend-resolved `{ value, label, kind, table }`
|
|
485
|
+
// sibling and renders a navigable `/m/<table>/<value>` chip.
|
|
486
|
+
// Checked before the relation branch so a polymorphic FK
|
|
487
|
+
// carrying a `ref` still routes here.
|
|
488
|
+
if (renderAs === 'reference') {
|
|
489
|
+
return _jsx(ReferenceCell, { col: col, row: row.original });
|
|
490
|
+
}
|
|
447
491
|
// Resolved FK relation chip. Triggers on an explicit
|
|
448
492
|
// `cellStyle: 'relation'` or on any column carrying a `ref`
|
|
449
493
|
// (a belongs_to FK) that isn't being rendered as an
|
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,8 @@ export * from './addon-loader';
|
|
|
8
8
|
export { AddonLayoutProvider, useAddonLayout, useAddonLayoutControl, useDeclareAddonLayout, type AddonLayout, type AddonLayoutProviderProps, } from './addon-layout-context';
|
|
9
9
|
export * from './slot';
|
|
10
10
|
export * from './capability-gate';
|
|
11
|
+
export * from './org-runtime-context';
|
|
12
|
+
export * from './org-runtime-provider';
|
|
11
13
|
export * from './navigation-builder';
|
|
12
14
|
export * from './i18n-provider';
|
|
13
15
|
export * from './api-context';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,cAAc,SAAS,CAAA;AACvB,cAAc,mBAAmB,CAAA;AACjC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,gBAAgB,CAAA;AAC9B,OAAO,EACH,qBAAqB,EACrB,KAAK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,EACnB,KAAK,mBAAmB,GAC3B,MAAM,4BAA4B,CAAA;AACnC,OAAO,EACH,sBAAsB,EACtB,uBAAuB,GAC1B,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EACH,kBAAkB,EAClB,aAAa,EACb,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,sBAAsB,EAC3B,KAAK,wBAAwB,GAChC,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EACH,kBAAkB,EAClB,kBAAkB,EAClB,qBAAqB,EACrB,KAAK,eAAe,GACvB,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -13,6 +13,8 @@ export * from './addon-loader';
|
|
|
13
13
|
export { AddonLayoutProvider, useAddonLayout, useAddonLayoutControl, useDeclareAddonLayout, } from './addon-layout-context';
|
|
14
14
|
export * from './slot';
|
|
15
15
|
export * from './capability-gate';
|
|
16
|
+
export * from './org-runtime-context';
|
|
17
|
+
export * from './org-runtime-provider';
|
|
16
18
|
export * from './navigation-builder';
|
|
17
19
|
export * from './i18n-provider';
|
|
18
20
|
export * from './api-context';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { type GetImageUrl } from './image-url-context';
|
|
3
|
+
export interface OrgRuntimeProviderProps {
|
|
4
|
+
/** Org IANA timezone (e.g. `America/Mexico_City`). */
|
|
5
|
+
timeZone?: string;
|
|
6
|
+
/** Org ISO-4217 currency (e.g. `MXN`). */
|
|
7
|
+
currency?: string;
|
|
8
|
+
/** Resolver turning a stored path into a fetchable URL. Defaults to identity. */
|
|
9
|
+
getImageUrl?: GetImageUrl;
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
}
|
|
12
|
+
export declare function OrgRuntimeProvider({ timeZone, currency, getImageUrl, children, }: OrgRuntimeProviderProps): import("react").JSX.Element;
|
|
13
|
+
//# sourceMappingURL=org-runtime-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"org-runtime-provider.d.ts","sourceRoot":"","sources":["../src/org-runtime-provider.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtC,OAAO,EAGL,KAAK,WAAW,EACjB,MAAM,qBAAqB,CAAA;AAG5B,MAAM,WAAW,uBAAuB;IACtC,sDAAsD;IACtD,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,0CAA0C;IAC1C,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,iFAAiF;IACjF,WAAW,CAAC,EAAE,WAAW,CAAA;IACzB,QAAQ,EAAE,SAAS,CAAA;CACpB;AAED,wBAAgB,kBAAkB,CAAC,EACjC,QAAQ,EACR,QAAQ,EACR,WAA8B,EAC9B,QAAQ,GACT,EAAE,uBAAuB,+BAUzB"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { ImageUrlContext, identityImageUrl, } from './image-url-context';
|
|
3
|
+
import { CurrencyContext, TimeZoneContext } from './org-runtime-context';
|
|
4
|
+
export function OrgRuntimeProvider({ timeZone, currency, getImageUrl = identityImageUrl, children, }) {
|
|
5
|
+
return (_jsx(ImageUrlContext.Provider, { value: getImageUrl, children: _jsx(TimeZoneContext.Provider, { value: timeZone, children: _jsx(CurrencyContext.Provider, { value: currency, children: children }) }) }));
|
|
6
|
+
}
|
package/package.json
CHANGED
package/src/dynamic-columns.tsx
CHANGED
|
@@ -509,6 +509,66 @@ const RelationCell: React.FC<{
|
|
|
509
509
|
)
|
|
510
510
|
}
|
|
511
511
|
|
|
512
|
+
/**
|
|
513
|
+
* Renders a SAP-style polymorphic source-document reference as a navigable
|
|
514
|
+
* chip. Reads the backend-resolved sibling `row[<key w/o _id>] =
|
|
515
|
+
* { value, label, kind, table }` (see `relationKeyFor`) — the discriminator
|
|
516
|
+
* (`source_kind`) selects the target model and the backend stamps the resolved
|
|
517
|
+
* SQL `table` so the cell can link to `/m/<table>/<value>` (the host router
|
|
518
|
+
* handles `/m/:model/:id`). Shows the resolved `label` when present, else a
|
|
519
|
+
* short id (first 8 chars of the value). Domain-agnostic: any polymorphic FK
|
|
520
|
+
* (`source_id`, `document_id`, …) carrying `display: "reference"` works without
|
|
521
|
+
* per-addon code. Mirrors `RelationCell`'s chip look (subtle tint, dark-mode
|
|
522
|
+
* aware) so references read consistently next to plain relations.
|
|
523
|
+
*/
|
|
524
|
+
const ReferenceCell: React.FC<{
|
|
525
|
+
col: ColumnDefinition
|
|
526
|
+
row: any
|
|
527
|
+
}> = ({ col, row }) => {
|
|
528
|
+
const isDark = useIsDarkTheme()
|
|
529
|
+
const sibling = getNestedValue(row, relationKeyFor(col))
|
|
530
|
+
const value =
|
|
531
|
+
(sibling && typeof sibling === 'object' ? sibling.value : undefined) ??
|
|
532
|
+
getNestedValue(row, col.key)
|
|
533
|
+
if (value === undefined || value === null || value === '' || isNilUuid(value)) {
|
|
534
|
+
return <EmptyCell />
|
|
535
|
+
}
|
|
536
|
+
const label =
|
|
537
|
+
sibling && typeof sibling === 'object' ? sibling.label : undefined
|
|
538
|
+
const kind =
|
|
539
|
+
sibling && typeof sibling === 'object' ? sibling.kind : undefined
|
|
540
|
+
const table =
|
|
541
|
+
sibling && typeof sibling === 'object' ? sibling.table : undefined
|
|
542
|
+
const displayText =
|
|
543
|
+
label !== undefined && label !== null && label !== ''
|
|
544
|
+
? String(label)
|
|
545
|
+
: `${String(value).slice(0, 8)}`
|
|
546
|
+
// Tint keyed on the discriminator (when present) so e.g. sale/transfer/
|
|
547
|
+
// adjustment chips read as visually distinct families; falls back to the
|
|
548
|
+
// display text. Same subtle relation-chip look + dark-mode handling.
|
|
549
|
+
const chipStyles = relationChipStyles(String(kind || displayText), { isDark })
|
|
550
|
+
const className =
|
|
551
|
+
'inline-flex max-w-[220px] items-center gap-1 rounded-md px-2 py-0.5 text-sm font-medium'
|
|
552
|
+
if (table && value) {
|
|
553
|
+
return (
|
|
554
|
+
<a
|
|
555
|
+
href={`/m/${table}/${value}`}
|
|
556
|
+
onClick={(e) => e.stopPropagation()}
|
|
557
|
+
className={`${className} hover:underline`}
|
|
558
|
+
style={chipStyles}
|
|
559
|
+
title={displayText}
|
|
560
|
+
>
|
|
561
|
+
<span className="truncate">{displayText}</span>
|
|
562
|
+
</a>
|
|
563
|
+
)
|
|
564
|
+
}
|
|
565
|
+
return (
|
|
566
|
+
<span className={className} style={chipStyles} title={displayText}>
|
|
567
|
+
<span className="truncate">{displayText}</span>
|
|
568
|
+
</span>
|
|
569
|
+
)
|
|
570
|
+
}
|
|
571
|
+
|
|
512
572
|
/**
|
|
513
573
|
* Generic avatar-style cell: round/rounded photo (or initials fallback) +
|
|
514
574
|
* primary name + optional subtitle. Backs the `avatar`/`search` columns as
|
|
@@ -682,6 +742,15 @@ export function makeDefaultGetDynamicColumns(
|
|
|
682
742
|
)
|
|
683
743
|
}
|
|
684
744
|
|
|
745
|
+
// Polymorphic source-document reference (SAP-style). Reads
|
|
746
|
+
// the backend-resolved `{ value, label, kind, table }`
|
|
747
|
+
// sibling and renders a navigable `/m/<table>/<value>` chip.
|
|
748
|
+
// Checked before the relation branch so a polymorphic FK
|
|
749
|
+
// carrying a `ref` still routes here.
|
|
750
|
+
if (renderAs === 'reference') {
|
|
751
|
+
return <ReferenceCell col={col} row={row.original} />
|
|
752
|
+
}
|
|
753
|
+
|
|
685
754
|
// Resolved FK relation chip. Triggers on an explicit
|
|
686
755
|
// `cellStyle: 'relation'` or on any column carrying a `ref`
|
|
687
756
|
// (a belongs_to FK) that isn't being rendered as an
|
package/src/index.ts
CHANGED
|
@@ -28,6 +28,8 @@ export {
|
|
|
28
28
|
} from './addon-layout-context'
|
|
29
29
|
export * from './slot'
|
|
30
30
|
export * from './capability-gate'
|
|
31
|
+
export * from './org-runtime-context'
|
|
32
|
+
export * from './org-runtime-provider'
|
|
31
33
|
export * from './navigation-builder'
|
|
32
34
|
export * from './i18n-provider'
|
|
33
35
|
export * from './api-context'
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// OrgRuntimeProvider — one place to feed the org's display config (timezone,
|
|
2
|
+
// currency, image-url resolver) to EVERY nested SDK renderer: dynamic tables,
|
|
3
|
+
// relation tables, record dialogs and field cells all read these via context.
|
|
4
|
+
// The record dialog provides them locally, but standalone surfaces (the
|
|
5
|
+
// full-page detail view, any table mounted outside a dialog) had no provider,
|
|
6
|
+
// so money fell back to USD and datetimes to the browser zone. Wrap the
|
|
7
|
+
// authenticated app root once and the whole app becomes org-consistent.
|
|
8
|
+
import { type ReactNode } from 'react'
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
ImageUrlContext,
|
|
12
|
+
identityImageUrl,
|
|
13
|
+
type GetImageUrl,
|
|
14
|
+
} from './image-url-context'
|
|
15
|
+
import { CurrencyContext, TimeZoneContext } from './org-runtime-context'
|
|
16
|
+
|
|
17
|
+
export interface OrgRuntimeProviderProps {
|
|
18
|
+
/** Org IANA timezone (e.g. `America/Mexico_City`). */
|
|
19
|
+
timeZone?: string
|
|
20
|
+
/** Org ISO-4217 currency (e.g. `MXN`). */
|
|
21
|
+
currency?: string
|
|
22
|
+
/** Resolver turning a stored path into a fetchable URL. Defaults to identity. */
|
|
23
|
+
getImageUrl?: GetImageUrl
|
|
24
|
+
children: ReactNode
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function OrgRuntimeProvider({
|
|
28
|
+
timeZone,
|
|
29
|
+
currency,
|
|
30
|
+
getImageUrl = identityImageUrl,
|
|
31
|
+
children,
|
|
32
|
+
}: OrgRuntimeProviderProps) {
|
|
33
|
+
return (
|
|
34
|
+
<ImageUrlContext.Provider value={getImageUrl}>
|
|
35
|
+
<TimeZoneContext.Provider value={timeZone}>
|
|
36
|
+
<CurrencyContext.Provider value={currency}>
|
|
37
|
+
{children}
|
|
38
|
+
</CurrencyContext.Provider>
|
|
39
|
+
</TimeZoneContext.Provider>
|
|
40
|
+
</ImageUrlContext.Provider>
|
|
41
|
+
)
|
|
42
|
+
}
|