import * as React from 'react';
import {createContainer} from '@workday/canvas-kit-react/common';
import {Menu} from '@workday/canvas-kit-react/menu';
import {ActionBarItem} from './ActionBarItem';
import {ActionBarList} from './ActionBarList';
import {ActionBarOverflowButton} from './ActionBarOverflowButton';
import {useActionBarModel} from './useActionBarModel';
export interface ActionBarProps {
/**
* The contents of the ActionBar. Can be `ActionBar` children or any valid elements.
*/
children: React.ReactNode;
}
/**
* `ActionBar` is a container component that is responsible for creating an {@link ActionBarModel}
* and sharing it with its subcomponents using React context. It does not represent a real element.
*
* ```tsx
* {Child components}
* ```
*
* Alternatively, you may pass in a model using the hoisted model pattern.
*
* ```tsx
* const model = useActionBarModel({
* items: [],
* });
*
* {Child components};
* ```
*/
export const ActionBar = createContainer()({
displayName: 'ActionBar',
modelHook: useActionBarModel,
subComponents: {
/**
* `ActionBar.List` is a {@link Flex} element. It is a container for
* {@link ActionBarItem ActionBar.Item} subcomponents. To render an overflow button for
* ActionBar with overflow behavior `overflowButton` prop with overflow button component as a
* value should be passed.
*
* ```tsx
* // without overflow
* {ActionBar.Items}
*
* // with overflow
* }>
* {ActionBar.Items}
*
* ```
*/
List: ActionBarList,
/**
* `ActionBar.Item` is a `button` element, by default it's a `SecondaryButton` unless an `as`
* prop is passed.
*
* ```tsx
* console.log('first action')}>
* First Action
*
* ```
*/
Item: ActionBarItem,
OverflowButton: ActionBarOverflowButton,
/**
* The overflow menu of the ActionBar component. If there isn't enough room to render all the action
* items, the extra actions that don't fit will be overflowed into this menu.
* @example
*
*
*
* {(item: MyActionItem) => {item.text}}
*
*
*
*/
Menu,
},
})(({children}, _, model) => {
return ;
});