How to use the @remirror/core-helpers.isUndefined function in @remirror/core-helpers

To help you get started, we’ve selected a few @remirror/core-helpers 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 ifiokjr / remirror / packages / multishift / src / multishift-utils.ts View on Github external
export const getHighlightedIndexOnOpen = (
  props: Pick, 'items' | 'initialHighlightedIndexes' | 'defaultHighlightedIndexes'>,
  state: MultishiftState,
  offset: number,
  getItemId: GetItemId,
): number[] => {
  const { items, initialHighlightedIndexes, defaultHighlightedIndexes } = props;
  const { selectedItems, highlightedIndexes } = state;

  // initialHighlightedIndexes will give value to highlightedIndex on initial
  // state only.
  if (!isUndefined(initialHighlightedIndexes) && highlightedIndexes.length) {
    return initialHighlightedIndexes;
  }

  if (defaultHighlightedIndexes) {
    return defaultHighlightedIndexes;
  }

  if (selectedItems.length) {
    const idsOfItems = items.map(getItemId);
    const index = selectedItems
      .map(selectedItem => idsOfItems.indexOf(getItemId(selectedItem)))
      .findIndex(isValidIndex);

    if (!isValidIndex(index)) {
      return [];
    }
github ifiokjr / remirror / packages / prosemirror-suggest / src / suggest-utils.ts View on Github external
const isPrefixValid = (
  prefix: string,
  {
    invalidPrefixCharacters,
    validPrefixCharacters,
  }: Pick, 'invalidPrefixCharacters' | 'validPrefixCharacters'>,
) => {
  if (!isUndefined(invalidPrefixCharacters)) {
    const regex = new RegExp(regexToString(invalidPrefixCharacters));
    return !regex.test(prefix);
  }

  {
    const regex = new RegExp(regexToString(validPrefixCharacters));
    return regex.test(prefix);
  }
};
github ifiokjr / remirror / @remirror / ui / src / ui-hsl.ts View on Github external
const createValidAlpha = (value: number | string | undefined): Alpha => {
  const alpha = isString(value)
    ? value.includes('%')
      ? Number(value.replace(/[%\s]+/g, ''))
      : Number(value) * 100
    : value;

  if (isUndefined(alpha)) {
    return createValidPercent(100);
  }

  return createValidPercent(alpha);
};
github ifiokjr / remirror / packages / multishift / src / multishift.ts View on Github external
const getComboBoxProps = (
    { refKey = 'ref' as GRefKey, ref, ...rest }: GetComboBoxPropsOptions = {
      refKey: 'ref' as GRefKey,
    },
  ): GetComboBoxPropsReturn => {
    if (type !== Type.ComboBox) {
      throw new Error('`getComboBoxProps` is only available for the autocomplete dropdown');
    }

    const extra = isUndefined(rest['aria-label']) ? { 'aria-labelledby': labelId } : {};

    return {
      [refKey]: composeRefs(ref as Ref, refs.comboBox),
      role: 'combobox',
      'aria-expanded': isOpen,
      'aria-haspopup': 'listbox',
      'aria-owns': isOpen ? menuId : null,
      ...extra,
      ...rest,
    } as GetComboBoxPropsReturn;
  };
github ifiokjr / remirror / packages / multishift / src / multishift-utils.ts View on Github external
const noUndefined = (fallback: GType, values: Array): GType => {
  for (const value of values) {
    if (!isUndefined(value)) {
      return value;
    }
  }

  return fallback;
};
github ifiokjr / remirror / @remirror / core / src / extension-manager.helpers.ts View on Github external
[MarkGroup.Indentation]: [],
    [MarkGroup.Link]: [],
    [MarkGroup.Code]: [],
  };

  const node: NodeExtensionTags = { [NodeGroup.Block]: [], [NodeGroup.Inline]: [] };

  for (const extension of extensions) {
    if (isNodeExtension(extension)) {
      const group = extension.schema.group as NodeGroup;
      node[group] = isUndefined(node[group])
        ? [extension.name as GNodes]
        : [...node[group], extension.name as GNodes];
    } else if (isMarkExtension(extension)) {
      const group = extension.schema.group as MarkGroup;
      mark[group] = isUndefined(mark[group])
        ? [extension.name as GMarks]
        : [...mark[group], extension.name as GMarks];
    }

    (extension.tags as Tags[]).forEach(tag => {
      general[tag] = isUndefined(general[tag])
        ? [extension.name as GNames]
        : [...general[tag], extension.name as GNames];
    });
  }

  return {
    general,
    mark,
    node,
  } as any;