import React, { FC, MouseEvent, ReactNode, useEffect, useState } from 'react' import styled, { css } from 'styled-components' import { lookup } from 'fp-ts/lib/Array' import * as O from 'fp-ts/lib/Option' import { pipe } from 'fp-ts/lib/pipeable' import { Colors, FontSizes, getColor, pageSizePadding, Sizes, typographyFont, visible, } from '@monorail/helpers/exports' import { flexFlow } from '@monorail/helpers/flex' import { CssOverridesType } from '@monorail/types' import { ActionsMenu, MenuAction, } from '@monorail/visualComponents/actionsMenu/ActionsMenu' import { ButtonDisplay, ButtonSize, } from '@monorail/visualComponents/buttons/buttonTypes' import { IconButton } from '@monorail/visualComponents/buttons/IconButton' import { Header, HeaderProps } from '@monorail/visualComponents/header/Header' import { Icon } from '@monorail/visualComponents/icon/Icon' import { IconType } from '@monorail/visualComponents/icon/IconType' import { TextArea, TextAreaInput, TextAreaProps, } from '@monorail/visualComponents/inputs/TextArea' import { ScrollAnimation } from '@monorail/visualComponents/layout/ScrollAnimation' import { SimpleListItem } from '@monorail/visualComponents/list/List' import { Text } from '@monorail/visualComponents/typography/Text' type Props = { title?: string headerProps?: Omit header?: () => ReactNode children: () => ReactNode list: () => ReactNode listFooter?: () => ReactNode } export const OutlineList = styled.div` ${flexFlow('column')}; background: ${getColor(Colors.White)}; border-right: 1px solid ${getColor(Colors.Black12a)}; flex: 1; max-width: 256px; min-width: 186px; ` const OutlineContainer = styled.div` ${flexFlow('row')}; flex: 1; overflow: hidden; width: 100%; height: 100%; ` const OutlineContent = styled.div` ${flexFlow('column')}; flex: 1; overflow: hidden; ` const IconButtonContainer = styled.div` ${visible(false)} ` export const LayoutOutline: FC = ({ children, header, headerProps, list, listFooter, title, ...domProps }: Props) => { const renderTitleHeader = (): ReactNode => (
) return ( {pipe( O.fromNullable(header), O.alt(() => pipe( O.fromNullable(title), O.map(t => renderTitleHeader), ), ), O.fold( () => <>, render => render(), ), )} {list()} {listFooter && listFooter()} {children()} ) } export const EmptyListBox = styled.div` align-items: center; justify-content: center; margin: auto; ${flexFlow('row')} ` export const EmptyListBoxInner = styled.div` min-width: 200px; align-items: center; justify-content: center; ${flexFlow('column')} p { text-align: center; } ` export const EmptyListButtonsBox = styled.div` display: flex; ` type EmptyLayoutListProps = { title?: string message?: string actions?: ReactNode } export const EmptyLayoutContainer = styled.div` ${flexFlow('column')}; background: ${getColor(Colors.Grey96)}; flex: 1; height: 100%; overflow: hidden; ` export const EmptyLayoutList = ({ title = 'No Selection', message = 'Select an item on the left or create a new item', actions, }: EmptyLayoutListProps) => ( {title} {message} {actions && {actions}} ) const titleStyle = (disabled?: boolean) => css` max-width: unset; flex: 3; ${TextAreaInput} { ${typographyFont(700, FontSizes.Title1)}; ${disabled && css` border: none; &:hover, &:focus, &:active { border: none; } `} } margin-right: 8px; ` export const LayoutContentWrapper = styled.div` ${flexFlow('column', 'nowrap')} ${pageSizePadding({ paddingTop: 16, paddingBottom: 16 })}; flex: 1; overflow: hidden; ` export const ColumnLayout = styled.div` ${flexFlow('column')} flex: 1; width: 100%; ` export const RowLayout = styled.div` ${flexFlow('row')} flex: 1; width: 100%; justify-items: center; align-items: center; ` const LayoutDetailHeaderContainer = styled.div` ${flexFlow('row')} flex: 0; height: auto; margin-left: -8px; ` type LayoutDetailHeaderProps = TextAreaProps & { actions?: Array containerCssOverrides?: ReturnType } export const LayoutDetailHeader = ({ actions, containerCssOverrides, ...textAreaProps }: LayoutDetailHeaderProps) => (