diff --git a/src/lib/utils/dropdownOptionsGenerator.js b/src/lib/utils/dropdownOptionsGenerator.js new file mode 100644 index 00000000..c719fac9 --- /dev/null +++ b/src/lib/utils/dropdownOptionsGenerator.js @@ -0,0 +1,25 @@ +// This file is part of React-Invenio-Forms +// Copyright (C) 2024 CERN. +// +// React-Invenio-Forms is free software; you can redistribute it and/or modify it +// under the terms of the MIT License; see LICENSE file for more details. + +import React from "react"; + +export function dropdownOptionsGenerator(dropdownOptions) { + return dropdownOptions.map((options) => { + return { + key: options.key, + text: options.text, + value: options.key, + content: ( + <> +
{options.text}
+
+ {options.description} +
+ + ), + }; + }); +} diff --git a/src/lib/utils/index.js b/src/lib/utils/index.js index 1d5cc688..9f213050 100644 --- a/src/lib/utils/index.js +++ b/src/lib/utils/index.js @@ -1 +1,2 @@ export { humanReadableBytes } from "./humanReadableBytes"; +export { dropdownOptionsGenerator } from "./dropdownOptionsGenerator";