1
0
Fork 0
freesewing/sites/shared/components/workbench/menus/shared/index.mjs

67 lines
2.1 KiB
JavaScript
Raw Normal View History

2023-09-29 16:01:27 +02:00
// __SDEFILE__ - This file is a dependency for the stand-alone environment
2023-05-29 23:22:26 -05:00
import { MenuItemGroup } from './menu-item.mjs'
2023-05-26 18:16:48 -05:00
import { useTranslation } from 'next-i18next'
2023-05-31 17:42:16 -05:00
/**
* A component for a collapsible sidebar menu in workbench views
* @param {Function} options.updateFunc a function the menu's inputs will use to update their values
* @param {String[]} options.ns namespaces used by this menu
* @param {React.Component} options.Icon the menu's icon
* @param {String} options.name the translation key for the menu's title
* @param {Object} options.config the structure of the menu's options
* @param {Number} options.control the user's control level setting
* @param {Object} options.inputs a map of input components to use, keyed by option name
* @param {Object} options.values a map of value components to use, keyed by option name
* @param {Object} options.currentValues a map of the values of the menu's options
* @param {Object} options.passProps any additional properties to pass the the inputs
* @param {string} language the language to use for the menu
* @param {Object} emojis a map of the emojis to use, keyed by option name
* @param {React.component} Item the component to use for menu items
* @return {[type]} [description]
*/
2023-05-26 18:16:48 -05:00
export const WorkbenchMenu = ({
updateFunc,
2023-05-26 18:16:48 -05:00
ns,
Icon = () => null,
2023-05-26 18:16:48 -05:00
config,
control,
inputs,
values,
currentValues,
passProps = {},
language,
emojis,
Item,
2023-05-26 18:16:48 -05:00
children,
isDesignOptionsGroup,
design,
2023-05-26 18:16:48 -05:00
}) => {
2023-05-31 17:42:16 -05:00
// get translation for the menu
2023-05-29 23:22:26 -05:00
const { t } = useTranslation(ns)
2023-05-26 18:16:48 -05:00
return children ? (
children
) : (
<MenuItemGroup
{...{
collapsible: false,
topLevel: true,
control,
currentValues,
structure: config,
Item,
Icon,
values,
inputs,
passProps,
updateFunc,
emojis,
t,
language,
isDesignOptionsGroup,
design,
}}
/>
2023-05-26 18:16:48 -05:00
)
}