How to use the uniforms.joinName function in uniforms

To help you get started, we’ve selected a few uniforms 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 vazco / uniforms / packages / uniforms-bridge-simple-schema / src / SimpleSchemaBridge.ts View on Github external
getInitialValue(name, props: any = {}) {
    const field = this.getField(name);

    if (field.type === Array) {
      const item = this.getInitialValue(joinName(name, '0'));
      const items = Math.max(props.initialCount || 0, field.minCount || 0);

      return Array.from({ length: items }, () => item);
    }

    if (field.type === Object) {
      return {};
    }

    return field.defaultValue;
  }
github vazco / uniforms / packages / uniforms-bridge-graphql / src / GraphQLBridge.ts View on Github external
getField(name, returnExtracted = true) {
    return joinName(null, name).reduce((definition, next, index, array) => {
      if (next === '$' || next === '' + parseInt(next, 10)) {
        invariant(
          definition.type instanceof graphql.GraphQLList,
          'Field not found in schema: "%s"',
          name,
        );
        definition = { type: extractFromNonNull(definition.type.ofType) };
      } else if (definition.type && definition.type._fields) {
        definition = definition.type._fields[next];
      } else {
        definition = definition[next];
      }

      invariant(definition, 'Field not found in schema: "%s"', name);

      const isLast = array.length - 1 === index;
github vazco / uniforms / packages / uniforms-bootstrap3 / src / ListItemField.tsx View on Github external
Children.map(props.children, child =>
        React.cloneElement(child, {
          className: 'col-xs-11',
          name: joinName(props.name, child.props.name),
          label: null,
        }),
      )
github vazco / uniforms / packages / uniforms-semantic / src / ListField.tsx View on Github external
Children.map(children, child =>
            React.cloneElement(child, {
              key: index,
              label: null,
              name: joinName(
                name,
                child.props.name && child.props.name.replace('$', index),
              ),
            }),
          ),
github vazco / uniforms / packages / uniforms-bridge-graphql / src / GraphQLBridge.ts View on Github external
getInitialValue(name, props: any = {}) {
    const type = this.getType(name);

    if (type === Array) {
      const item = this.getInitialValue(joinName(name, '0'));
      const items = props.initialCount || 0;

      return Array.from({ length: items }, () => item);
    }

    if (type === Object) {
      return {};
    }

    const defaultValue = this.getField(name).defaultValue;

    return defaultValue === undefined
      ? this.extras[name] && this.extras[name].initialValue
      : defaultValue;
  }