Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
ui-component-library / src / playground / DetailedList / DetailedList.tsx
Size: Mime:
// modules
import React from 'react'
import { EMPTY_ARRAY } from 'exotic'
import { DetailedListProps } from './typings'
import { media } from './deps'
import { wording as fixture } from './fixture'
import {
  renderSpecificationItem as defaultRenderSpecificationItem,
  renderSpecificationWrap as defaultRenderSpecificationWrap,
  renderSpecificationHeading as defaultRenderSpecificationHeading,
  renderSpecificationList as defaultRenderSpecificationList,
} from './renderProps'
import { renderText } from '../../../../config/__todo/atoms/SelectDropDown/wr/_renderProps'

/**
 * @note - this accepts an array of values that may change, it's not pure, it's an observer
 * @see https://mobx.js.org/refguide/observer-component.html
 */
class DetailedList extends React.Component<DetailedListProps> {
  static defaultProps = {
    list: EMPTY_ARRAY,
    wording: fixture,
    renderSpecificationItem: defaultRenderSpecificationItem,
    renderSpecificationWrap: defaultRenderSpecificationWrap,
    renderSpecificationHeading: defaultRenderSpecificationHeading,
    renderSpecificationList: defaultRenderSpecificationList,
  }

  render() {
    const {
      specifications,
      list,
      wording,
      // @todo could take in children/render too
      // render props
      renderSpecificationItem,
      renderSpecificationWrap,
      renderSpecificationHeading,
      renderSpecificationList,
      ...remainingProps
    } = this.props

    const headerText = media.isPhone ? '' : renderSpecificationHeading(this.props)
    const specificationList = renderSpecificationList(this.props)

    // @todo could also just check `nowrap`
    // but if we want to get the attrs passed
    const children = (
      <React.Fragment>
        {headerText}
        {specificationList}
      </React.Fragment>
    )
    const attributes = {
      ...remainingProps,
      children,
    }

    return renderSpecificationWrap(attributes)
  }
}

export { DetailedList }
export default DetailedList