feat(web/context): allow custom metadata order

This commit is contained in:
Luke
2022-05-08 13:18:09 +02:00
parent 62d4812f24
commit a784726267
3 changed files with 12 additions and 4 deletions

View File

@@ -17,7 +17,7 @@ debugData<ContextMenuProps>([
{
title: "Example button",
description: "Example button description",
metadata: { ["Value 1"]: "Some value", ["Value 2"]: 300 },
metadata: [{ label: "Value 1", value: 300 }],
},
{
title: "Menu button",

View File

@@ -104,9 +104,14 @@ const Item: React.FC<{
<PopoverBody>
{Array.isArray(option[1].metadata) ? (
option[1].metadata.map(
(metadata: string, index: number) => (
(
metadata: string | { label: string; value: any },
index: number
) => (
<Text key={`context-metadata-${index}`}>
{metadata}
{typeof metadata === "string"
? `${metadata}`
: `${metadata.label}: ${metadata.value}`}
</Text>
)
)

View File

@@ -3,7 +3,10 @@ export interface Option {
title?: string;
description?: string;
arrow?: boolean;
metadata?: string[] | { [key: string]: any };
metadata?:
| string[]
| { [key: string]: any }
| { label: string; value: any }[];
event?: string;
serverEvent?: string;
args?: any;