How to use the @instructure/console/macro.error function in @instructure/console

To help you get started, we’ve selected a few @instructure/console examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github instructure / instructure-ui / packages / ui-tabs / src / components / Tabs / index.js View on Github external
setSelected (index) {
    let selectedIndex

    // Check index boundary
    error(this.isValidIndex(index), `[Tabs] Invalid tab index: '${index}'.`)

    const handleChange = () => {
      if (typeof selectedIndex !== 'undefined' && typeof this.props.onChange === 'function') {
        this.props.onChange(index, selectedIndex)
      }
    }

    if (typeof this.props.selectedIndex === 'undefined') {
      this.setState((state, props) => {
        selectedIndex = state.selectedIndex

        if (index !== selectedIndex) {
          handleChange()
          return { selectedIndex: index, focus: true }
        } else {
          return state
github instructure / instructure-ui / packages / ui-forms / src / Select / index.js View on Github external
constructor (props) {
    super(props)
    const options = parseOptions(props.children)

    error(
      !(props.allowCustom && props.multiple),
      `[Select] The 'allowCustom' and 'multiple' props are mutually exclusive.`
    )

    this.state = { options }
  }
github instructure / instructure-ui / packages / ui-alerts / src / Alert / index.js View on Github external
initLiveRegion (liveRegion) {
    error(
      liveRegion.getAttribute('role') === 'alert',
      `[Alert] live region must have role='alert' set on page load in order to announce content`
    )

    if (liveRegion) {
      liveRegion.setAttribute('aria-live', this.props.liveRegionPoliteness)
      liveRegion.setAttribute('aria-relevant', 'additions text')
      liveRegion.setAttribute('aria-atomic', this.props.isLiveRegionAtomic)
    }
  }
github instructure / instructure-ui / packages / ui-a11y / src / FocusRegion.js View on Github external
blur () {
    error(!this._active, `[FocusRegion] Cannot call '.blur()' on a region that is currently active.`)
    this._keyboardFocusRegion.blur()
  }
}
github instructure / instructure-ui / packages / ui-a11y / src / Dialog / index.js View on Github external
focus () {
    if (!this.props.open || !this.contentElement) {
      error(false, '[Dialog] Can\'t focus a Dialog that isn\'t open.')
      return
    }

    if (this._focusRegion) {
      FocusRegionManager.focusRegion(this.contentElement, this._focusRegion.id)
    }
  }
github instructure / instructure-ui / packages / ui-forms / src / DateInput / DatePicker / index.js View on Github external
_validateDateProp (dateStr, fallbackDateStr, propName, locale, timezone) {
    const parsedDate = this._parseDate(dateStr, locale, timezone)
    const isEmpty = !dateStr
    const isValid = parsedDate.isValid()

    error(isEmpty || isValid, `[DatePicker] Unexpected date format received for '${propName}' prop: '${dateStr}'.`)

    return (isEmpty || !isValid) ? fallbackDateStr : dateStr
  }
github instructure / instructure-ui / packages / ui-themeable / src / ThemeRegistry.js View on Github external
function getRegisteredTheme (themeKey, defaultTheme = {}) {
  if (!themeKey) return defaultTheme

  const theme = getRegistry().themes[themeKey]
  if (theme) {
    return theme
  } else {
    if (themeKey !== DEFAULT_THEME_KEY) {
      error(theme, `[themeable] Could not find theme: '${themeKey}' in the registry.`)
    }
    return defaultTheme
  }
}
github instructure / instructure-ui / packages / ui-themeable / src / ThemeRegistry.js View on Github external
function generateTheme (themeKey, overrides) {
  const registry = getRegistry()

  error((registry.registered.length > 0), '[themeable] No themes have been registered. ' +
    'Import a theme from @instructure/ui-themes or register a custom theme with registerTheme ' +
    '(see @instructure/ui-themeable).'
  )

  const components = getRegisteredComponents(themeKey)
  const theme = {}

  const variables = mergeWithDefaultThemeVariables(themeKey, overrides)

  if (isEmpty(variables)) {
    return
  }

  Object.getOwnPropertySymbols(components)
    .forEach((componentKey) => {
      theme[componentKey] = components[componentKey](variables)
github instructure / instructure-ui / packages / ui-calendar / src / Calendar / index.js View on Github external
renderDays () {
    const children = Children.toArray(this.props.children)
    const { length } = children
    const role = this.role === 'listbox' ? 'presentation' : null

    error(
      length === Calendar.DAY_COUNT,
      `[Calendar] should have exactly ${Calendar.DAY_COUNT} children. ${length} provided.`
    )

    return children.reduce((days, day, i) => {
      const index = Math.floor(i / 7)

      if (!days[index]) days.push([])

      days[index].push(day)
      return days
    }, []).map((row) => (

@instructure/console

A babel macro made by Instructure Inc.

MIT
Latest version published 5 days ago

Package Health Score

87 / 100
Full package analysis

Similar packages