How to use the @jsonforms/core.rankWith function in @jsonforms/core

To help you get started, we’ve selected a few @jsonforms/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 eclipsesource / jsonforms / packages / material / src / controls / MaterialAnyOfStringOrEnumControl.tsx View on Github external
// idea: map to type,enum and check that all types are string and at least one item is of type enum,
  const enumSchema = findEnumSchema(schemas);
  const stringSchema = findTextSchema(schemas);
  const remainingSchemas = schemas.filter(
    s => s !== enumSchema || s !== stringSchema
  );
  const wrongType = remainingSchemas.find(s => s.type && s.type !== 'string');
  return enumSchema && stringSchema && !wrongType;
};
const simpleAnyOf = and(
  uiTypeIs('Control'),
  schemaMatches(
    schema => schema.hasOwnProperty('anyOf') && hasEnumAndText(schema.anyOf)
  )
);
export const materialAnyOfStringOrEnumControlTester: RankedTester = rankWith(
  5,
  simpleAnyOf
);
export default withJsonFormsControlProps(MaterialAnyOfStringOrEnumControl);
github eclipsesource / jsonforms / packages / angular-material / src / other / table.renderer.ts View on Github external
getValidColumnProps = (scopedSchema: JsonSchema) => {
    if (scopedSchema.type === 'object') {
      return Object.keys(scopedSchema.properties).filter(prop => {
        const types = deriveTypes(scopedSchema.properties[prop]);
        if (types.length > 1) {
          return false;
        }
        return this.columnsToIgnore.indexOf(types[0]) === -1;
      });
    }
    // primitives
    return [''];
  };
}
export const TableRendererTester: RankedTester = rankWith(
  3,
  or(isObjectArrayControl, isPrimitiveArrayControl)
);

interface ColumnDescription {
  property: string;
  header: string;
  props: OwnPropsOfRenderer;
}

const controlWithoutLabel = (scope: string): ControlElement => ({
  type: 'Control',
  scope: scope,
  label: false
});
github eclipsesource / jsonforms / packages / material / src / cells / MaterialNumberFormatCell.tsx View on Github external
isNumberFormatControl,
  RankedTester,
  rankWith,
  WithClassname
} from '@jsonforms/core';
import { withJsonFormsCellProps } from '@jsonforms/react';
import { MuiInputNumberFormat } from '../mui-controls/MuiInputNumberFormat';

export const MaterialNumberFormatCell = (
  props: CellProps & WithClassname & Formatted
) => ;
/**
 * Default tester for text-based/string controls.
 * @type {RankedTester}
 */
export const materialNumberFormatCellTester: RankedTester = rankWith(
  4,
  isNumberFormatControl
);

export default withJsonFormsCellProps(MaterialNumberFormatCell);
github eclipsesource / jsonforms / packages / vanilla / src / cells / TimeCell.tsx View on Github external
<input value="{data" type="time"> handleChange(path, ev.target.value)}
      className={className}
      id={id}
      disabled={!enabled}
      autoFocus={uischema.options &amp;&amp; uischema.options.focus}
    /&gt;
  );
};
/**
 * Default tester for date controls.
 * @type {RankedTester}
 */
export const timeCellTester: RankedTester = rankWith(2, isTimeControl);

export default withJsonFormsCellProps(TimeCell);
github eclipsesource / jsonforms / packages / angular-material / src / controls / range.renderer.ts View on Github external
max: number;
  multipleOf: number;

  constructor(ngRedux: NgRedux) {
    super(ngRedux);
  }
  getEventValue = (event: any) =&gt; Number(event.value);
  mapAdditionalProps() {
    if (this.scopedSchema) {
      this.min = this.scopedSchema.minimum;
      this.max = this.scopedSchema.maximum;
      this.multipleOf = this.scopedSchema.multipleOf || 1;
    }
  }
}
export const RangeControlRendererTester: RankedTester = rankWith(
  4,
  isRangeControl
);
github eclipsesource / jsonforms / packages / angular-material / src / other / object.renderer.ts View on Github external
props.schema,
      undefined,
      props.path,
      'Group'
    );
    if (isEmpty(props.path)) {
      this.detailUiSchema.type = 'VerticalLayout';
    } else {
      (this.detailUiSchema as GroupLayout).label = startCase(props.path);
    }
    if (!this.isEnabled()) {
      setReadonly(this.detailUiSchema);
    }
  }
}
export const ObjectControlRendererTester: RankedTester = rankWith(
  2,
  isObjectControl
);
github eclipsesource / jsonforms / packages / material / src / fields / MaterialSliderField.tsx View on Github external
onChange={ev =&gt; handleChange(path, Number(ev.currentTarget.value))}
      className={className}
      id={id}
      disabled={!enabled}
      autoFocus={uischema.options &amp;&amp; uischema.options.focus}
      inputProps={config}
      endAdornment={<label style="{{marginLeft:">{data || scopedSchema.default}</label>}
    /&gt;
  );
};

/**
 * Matrial tester for slider controls.
 * @type {RankedTester}
 */
export const materialSliderFieldTester: RankedTester = rankWith(4, isRangeControl);
export default connectToJsonForms(
  mapStateToFieldProps,
  mapDispatchToFieldProps
)(MaterialSliderField);
github eclipsesource / jsonforms / packages / material / src / additional / MaterialListWithDetailRenderer.tsx View on Github external
renderers={renderers}
              visible={visible}
              schema={schema}
              uischema={foundUISchema}
              path={composePaths(path, `${selectedIndex}`)}
            /&gt;
          ) : (
            No Selection
          )}
        
      
    
  );
};

export const materialListWithDetailTester: RankedTester = rankWith(
  4,
  and(uiTypeIs('ListWithDetail'), isObjectArray)
);

export default withJsonFormsArrayLayoutProps(MaterialListWithDetailRenderer);
github eclipsesource / jsonforms / packages / vanilla / src / complex / array / index.ts View on Github external
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  THE SOFTWARE.
*/
import {
  isObjectArrayWithNesting,
  RankedTester,
  rankWith
} from '@jsonforms/core';
import ArrayControlRenderer from './ArrayControlRenderer';
import { ArrayControl } from './ArrayControl';

export { ArrayControl, ArrayControlRenderer };

export const arrayControlTester: RankedTester = rankWith(
  2,
  isObjectArrayWithNesting
);

export default ArrayControlRenderer;