How to use the @superset-ui/core.isRequired function in @superset-ui/core

To help you get started, we’ve selected a few @superset-ui/core 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 apache-superset / superset-ui / packages / superset-ui-number-format / src / formatters / D3NumberFormatter.js View on Github external
  constructor(configOrFormatString = isRequired('configOrFormatString')) {
    const config = isString(configOrFormatString)
      ? { id: configOrFormatString }
      : configOrFormatString;

    let formatFunc;
    let isInvalid = false;

    const { id, label, description } = config;

    try {
      formatFunc = d3Format(id);
    } catch (e) {
      formatFunc = () => `Invalid format: ${id}`;
      isInvalid = true;
    }
github apache-superset / superset-ui / packages / superset-ui-chart / src / models / ChartPlugin.ts View on Github external
register() {
    const { key = isRequired('config.key') } = this.config;
    getChartMetadataRegistry().registerValue(key, this.metadata);
    getChartComponentRegistry().registerLoader(key, this.loadChart);
    getChartControlPanelRegistry().registerValue(key, this.controlPanel);
    getChartTransformPropsRegistry().registerLoader(key, this.loadTransformProps);
    if (this.loadBuildQuery) {
      getChartBuildQueryRegistry().registerLoader(key, this.loadBuildQuery);
    }

    return this;
  }
github apache-superset / superset-ui / packages / superset-ui-time-format / src / TimeFormatter.ts View on Github external
constructor(config: {
    id: string;
    label?: string;
    description?: string;
    formatFunc: TimeFormatFunction;
    useLocalTime?: boolean;
  }) {
    super((value: Date | null | undefined) => this.format(value));

    const {
      id = isRequired('config.id'),
      label,
      description = '',
      formatFunc = isRequired('config.formatFunc'),
      useLocalTime = false,
    } = config;

    this.id = id;
    this.label = label || id;
    this.description = description;
    this.formatFunc = formatFunc;
    this.useLocalTime = useLocalTime;
  }
github apache-superset / superset-ui / packages / superset-ui-number-format / src / NumberFormatter.ts View on Github external
constructor(config: NumberFormatterConfig) {
    super((value: number) => this.format(value));

    const {
      id = isRequired('config.id'),
      label,
      description = '',
      formatFunc = isRequired('config.formatFunc'),
      isInvalid = false,
    } = config;
    this.id = id;
    this.label = label || id;
    this.description = description;
    this.formatFunc = formatFunc;
    this.isInvalid = isInvalid;
  }
github apache-superset / superset-ui / packages / superset-ui-time-format / src / TimeFormatter.ts View on Github external
constructor(config: {
    id: string;
    label?: string;
    description?: string;
    formatFunc: TimeFormatFunction;
    useLocalTime?: boolean;
  }) {
    super((value: Date | null | undefined) => this.format(value));

    const {
      id = isRequired('config.id'),
      label,
      description = '',
      formatFunc = isRequired('config.formatFunc'),
      useLocalTime = false,
    } = config;

    this.id = id;
    this.label = label || id;
    this.description = description;
    this.formatFunc = formatFunc;
    this.useLocalTime = useLocalTime;
  }
github apache-superset / superset-ui / packages / superset-ui-number-format / src / NumberFormatter.ts View on Github external
constructor(config: NumberFormatterConfig) {
    super((value: number) => this.format(value));

    const {
      id = isRequired('config.id'),
      label,
      description = '',
      formatFunc = isRequired('config.formatFunc'),
      isInvalid = false,
    } = config;
    this.id = id;
    this.label = label || id;
    this.description = description;
    this.formatFunc = formatFunc;
    this.isInvalid = isInvalid;
  }
github apache-superset / superset-ui / packages / superset-ui-chart / src / models / ChartPlugin.ts View on Github external
unregister() {
    const { key = isRequired('config.key') } = this.config;
    getChartMetadataRegistry().remove(key);
    getChartComponentRegistry().remove(key);
    getChartControlPanelRegistry().remove(key);
    getChartTransformPropsRegistry().remove(key);
    getChartBuildQueryRegistry().remove(key);

    return this;
  }
github apache-superset / superset-ui / packages / superset-ui-number-format / src / factories / createD3NumberFormatter.ts View on Github external
export default function createD3NumberFormatter(config: {
  description?: string;
  formatString: string;
  label?: string;
  locale?: FormatLocaleDefinition;
}) {
  const { description, formatString = isRequired('config.formatString'), label, locale } = config;

  let formatFunc: NumberFormatFunction;
  let isInvalid = false;

  try {
    formatFunc =
      typeof locale === 'undefined'
        ? d3Format(formatString)
        : formatLocale(locale).format(formatString);
  } catch (e) {
    formatFunc = value => `${value} (Invalid format: ${formatString})`;
    isInvalid = true;
  }

  return new NumberFormatter({
    description,
github apache-superset / superset-ui / packages / superset-ui-time-format / src / factories / createD3TimeFormatter.ts View on Github external
export default function createD3TimeFormatter(config: {
  description?: string;
  formatString: string;
  label?: string;
  locale?: TimeLocaleDefinition;
  useLocalTime?: boolean;
}) {
  const {
    description,
    formatString = isRequired('formatString'),
    label,
    locale,
    useLocalTime = false,
  } = config;

  const id = useLocalTime ? `${LOCAL_PREFIX}${formatString}` : formatString;
  let formatFunc;

  if (typeof locale === 'undefined') {
    const format = useLocalTime ? timeFormat : utcFormat;
    formatFunc = format(formatString);
  } else {
    const localeObject = timeFormatLocale(locale);
    formatFunc = useLocalTime
      ? localeObject.format(formatString)
      : localeObject.utcFormat(formatString);
github apache-superset / superset-ui / packages / superset-ui-chart / src / models / ChartPlugin.ts View on Github external
register() {
    const { key = isRequired('config.key') } = this.config;
    getChartMetadataRegistry().registerValue(key, this.metadata);
    getChartBuildQueryRegistry().registerLoader(key, this.loadBuildQuery);
    getChartComponentRegistry().registerLoader(key, this.loadChart);
    getChartTransformPropsRegistry().registerLoader(key, this.loadTransformProps);

    return this;
  }