Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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(
path,
)
}
);
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);
}
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,
data: any,