Skip to content

Commit 022b619

Browse files
anikachurilovantarocco
authored andcommitted
utils: add dropdown options generator
* closes inveniosoftware/invenio-app-rdm#2593
1 parent cb1ba08 commit 022b619

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// This file is part of React-Invenio-Forms
2+
// Copyright (C) 2024 CERN.
3+
//
4+
// React-Invenio-Forms is free software; you can redistribute it and/or modify it
5+
// under the terms of the MIT License; see LICENSE file for more details.
6+
7+
import React from "react";
8+
9+
export function dropdownOptionsGenerator(dropdownOptions) {
10+
return dropdownOptions.map((options) => {
11+
return {
12+
key: options.key,
13+
text: options.text,
14+
value: options.key,
15+
content: (
16+
<>
17+
<div>{options.text}</div>
18+
<div>
19+
<small className="text-muted">{options.description}</small>
20+
</div>
21+
</>
22+
),
23+
};
24+
});
25+
}

src/lib/utils/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export { humanReadableBytes } from "./humanReadableBytes";
2+
export { dropdownOptionsGenerator } from "./dropdownOptionsGenerator";

0 commit comments

Comments
 (0)