How to use the jsonforms-core.and 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 / default / src / additional / array-renderer.tsx View on Github external
resolveSchema,
  schemaMatches,
  schemaSubPathMatches,
  uiTypeIs,
  update
} from 'jsonforms-core';
import { connect } from 'react-redux';

export const getStyle = (styleName: string) =>
  JsonForms.stylingRegistry.getAsClassName(styleName);

/**
 * Default tester for an array control.
 * @type {RankedTester}
 */
export const arrayTester: RankedTester = rankWith(2, and(
  uiTypeIs('Control'),
  schemaMatches(schema =>
    !_.isEmpty(schema)
    && schema.type === 'array'
    && !_.isEmpty(schema.items)
    && !Array.isArray(schema.items) // we don't care about tuples
  ),
  schemaSubPathMatches('items', schema =>
    schema.type === 'object'
  ))
);

const addNewItem = (dispatch, path: string) => {
  const element = {};
  dispatch(
    update(
github eclipsesource / jsonforms / packages / default / src / additional / categorization-renderer.tsx View on Github external
)
      )
    }
  
);

const isCategorization = (category: Category | Categorization): category is Categorization =>
  category.type === 'Categorization';

/**
 * Default tester for a categorization.
 * @type {RankedTester}
 */
export const categorizationTester: RankedTester = rankWith(
        1,
        and(
            uiTypeIs('Categorization'),
            uischema => {
              const hasCategory = (element: Categorization): boolean => {
                if (_.isEmpty(element.elements)) {
                  return false;
                }

                return element.elements
                    .map(elem => isCategorization(elem) ?
                        hasCategory(elem) :
                        elem.type === 'Category'
                    )
                    .reduce((prev, curr) => prev && curr, true);
              };

              return hasCategory(uischema as Categorization);
github eclipsesource / jsonforms / packages / default / src / additional / tree-renderer.tsx View on Github external
resolveSchema,
  toDataPathSegments,
  uiTypeIs,
  update
} from 'jsonforms-core';
import {connect} from 'react-redux';
import {SyntheticEvent} from "react";

/**
 * Default tester for a master-detail layout.
 * @type {RankedTester}
 */
export const treeMasterDetailTester: RankedTester =
  rankWith(
    2,
    and(
      uiTypeIs('MasterDetailLayout'),
      uischema => {
        const control = uischema as MasterDetailLayout;
        if (control.scope === undefined || control.scope === null) {
          return false;
        }

        return !(control.scope.$ref === undefined || control.scope.$ref === null);
      }
    ));

const isNotTuple = (schema: JsonSchema) => !Array.isArray(schema.items);

export interface TreeMasterDetailState extends ControlState {
  selected: {
    schema: JsonSchema,