Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | 6x 6x 6x 7x 6x 7x 6x 6x 6x 46x 46x 46x 46x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x | import _ from 'lodash'; import React from 'react'; import PropTypes from 'prop-types'; import { getFirst, StandardProps } from '../../util/component-types'; import { lucidClassNames } from '../../util/style-helpers'; import LoadingIndicator from '../LoadingIndicator/LoadingIndicator'; import OverlayWrapper, { OverlayWrapperMessage, } from '../OverlayWrapper/OverlayWrapper'; const cx = lucidClassNames.bind('&-EmptyStateWrapper'); const { any, bool, node, string } = PropTypes; export interface IEmptyStateWrapperBodyProps extends StandardProps {} const EmptyStateWrapperBody = (_props: IEmptyStateWrapperBodyProps): null => null; export interface IEmptyStateWrapperTitleProps extends StandardProps {} const EmptyStateWrapperTitle = (_props: IEmptyStateWrapperTitleProps): null => null; export interface IEmptyStateWrapperProps extends StandardProps { /** *Child Element* The element to display in the body of the overlay. */ Body?: React.ReactNode; /** *Child Element* The element to display in the title of the overlay. */ Title?: React.ReactNode | string; /** Controls the visibility of the \`EmptyMessage\`. */ isEmpty: boolean; /** Controls the visibility of the \`LoadingMessage\`. */ isLoading: boolean; /** Position the `EmptyMessage` and `LoadingMessage` near the top of the container. */ anchorMessage: boolean; } const nonPassthroughs = [ 'className', 'children', 'isEmpty', 'isLoading', 'anchorMessage', 'Body', 'Title', 'initialState', 'callbackId', ]; const defaultProps = { isEmpty: false, isLoading: false, anchorMessage: false, }; export const EmptyStateWrapper = ( props: IEmptyStateWrapperProps ): React.ReactElement => { const { children, className, isEmpty, isLoading, anchorMessage, ...passThroughs } = props; const emptyMessageBodyProp = _.get( getFirst(props, EmptyStateWrapperBody), 'props' ); const emptyMessageTitleProp = _.get( getFirst(props, EmptyStateWrapperTitle), 'props', { children: 'You have no data.' } ); return isLoading ? ( <LoadingIndicator className={cx('&', className)} isLoading {..._.omit(passThroughs, nonPassthroughs)} anchorMessage={anchorMessage} > {children} </LoadingIndicator> ) : ( <OverlayWrapper className={cx('&', className)} hasOverlay={false} isVisible={isEmpty} anchorMessage={anchorMessage} {..._.omit(passThroughs, nonPassthroughs)} > <OverlayWrapperMessage className={cx('&-message-container')}> <div className={cx('&-message-header')} /> <div className={cx('&-message-contents')}> <header {...emptyMessageTitleProp} className={cx('&-message-title', emptyMessageTitleProp.className)} /> {emptyMessageBodyProp && <div {...emptyMessageBodyProp} />} </div> </OverlayWrapperMessage> {children} </OverlayWrapper> ); }; EmptyStateWrapper._isPrivate = true; EmptyStateWrapper.peek = { description: `A wrapper which can display either a \`LoadingIndicator\` or \`OverlayWrapper\`.`, categories: ['utility'], madeFrom: ['LoadingIndicator', 'OverlayWrapper'], }; EmptyStateWrapper.displayName = 'EmptyStateWrapper'; EmptyStateWrapper.defaultProps = defaultProps; EmptyStateWrapper.propTypes = { /** Class names that are appended to the defaults. */ className: string, /** Any valid React children. */ children: node, /** Controls the visibility of the \`EmptyMessage\`. */ isEmpty: bool, /** Controls the visibility of the \`LoadingMessage\`. */ isLoading: bool, /** Position the \`EmptyMessage\` and \`LoadingMessage\` near the top of the container. */ anchorMessage: bool, /** * Child Element* The element to display in the body of the overlay. */ Body: any, /** * Child Element* The element to display in the title of the overlay. */ Title: any, }; EmptyStateWrapperBody.displayName = 'EmptyStateWrapper.Body'; EmptyStateWrapper.Body = EmptyStateWrapperBody; EmptyStateWrapperBody.peek = { description: `Body content for the message to display when there is no data.`, }; EmptyStateWrapperBody.propName = 'Body'; EmptyStateWrapperTitle.displayName = 'EmptyStateWrapper.Title'; EmptyStateWrapper.Title = EmptyStateWrapperTitle; EmptyStateWrapperTitle.peek = { description: `Title text for the message to display when there is no data.`, }; EmptyStateWrapperTitle.propName = 'Title'; export default EmptyStateWrapper; |