Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
* startInEdit - Either a function or a value that will be evaluated as truthy or not
* If a function is used, it's passed the formData and expects a boolean return value
* volatileData - If this is truthy, the component pattern changes slightly so only completely new
* data can be entered, but not edited.
* This is useful for bank account information.
* reviewTitle - The title shown on the review card. Defaults to ui:title
* editTitle - The title shown on the edit card. Defaults to ui:title
* itemName - The name of the set of data in the card. This shows up on the "New X" button if
* volatileData is set to true.
*/
export default class ReviewCardField extends React.Component {
static defaultProps = {
uiSchema: {},
errorSchema: {},
idSchema: {},
registry: getDefaultRegistry(),
required: false,
disabled: false,
readonly: false,
};
constructor(props) {
super(props);
// Throw an error if there’s no viewComponent (should be React component)
if (
typeof get('ui:options.viewComponent', this.props.uiSchema) !== 'function'
) {
throw new Error(
`No viewComponent found in uiSchema for ReviewCardField ${
this.props.idSchema.$id
}.`,
import get from '../../../../platform/utilities/data/get';
import omit from '../../../../platform/utilities/data/omit';
/**
* Displays a review card if the information inside is valid.
*
* For use on a schema of type 'object' or 'array'.
* Intended to wrap objects or arrays to avoid duplicate functionality here.
*/
export default class ReviewCardField extends React.Component {
static defaultProps = {
uiSchema: {},
errorSchema: {},
idSchema: {},
registry: getDefaultRegistry(),
required: false,
disabled: false,
readonly: false,
}
constructor(props) {
super(props);
// Throw an error if there’s no viewComponent (should be React component)
if (typeof get('ui:options.viewComponent', this.props.uiSchema) !== 'function') {
throw new Error(`No viewComponent found in uiSchema for ReviewCardField ${this.props.idSchema.$id}.`);
}
const acceptedTypes = ['object', 'array'];
if (!acceptedTypes.includes(this.props.schema.type)) {
* startInEdit - Either a function or a value that will be evaluated as truthy or not
* If a function is used, it's passed the formData and expects a boolean return value
* volatileData - If this is truthy, the component pattern changes slightly so only completely new
* data can be entered, but not edited.
* This is useful for bank account information.
* reviewTitle - The title shown on the review card. Defaults to ui:title
* editTitle - The title shown on the edit card. Defaults to ui:title
* itemName - The name of the set of data in the card. This shows up on the "New X" button if
* volatileData is set to true.
*/
export default class ReviewCardField extends React.Component {
static defaultProps = {
uiSchema: {},
errorSchema: {},
idSchema: {},
registry: getDefaultRegistry(),
required: false,
disabled: false,
readonly: false,
};
constructor(props) {
super(props);
// Throw an error if there’s no viewComponent (should be React component)
if (
typeof get('ui:options.viewComponent', this.props.uiSchema) !== 'function'
) {
throw new Error(
`No viewComponent found in uiSchema for ReviewCardField ${
this.props.idSchema.$id
}.`,
orderProperties,
shouldRender,
getDefaultRegistry,
} from '@department-of-veterans-affairs/react-jsonschema-form/lib/utils';
/*
* This is largely copied from the react-jsonschema-form library,
* but with the way descriptions are used changed
*/
class ObjectField extends React.Component {
static defaultProps = {
uiSchema: {},
errorSchema: {},
idSchema: {},
registry: getDefaultRegistry(),
required: false,
disabled: false,
readonly: false,
}
constructor() {
super();
this.isRequired = this.isRequired.bind(this);
this.orderAndFilterProperties = _.flow(
properties => orderProperties(properties, _.get('ui:order', this.props.uiSchema)),
_.groupBy((item) => {
const expandUnderField = _.get([item, 'ui:options', 'expandUnder'], this.props.uiSchema);
return expandUnderField || item;
}),
_.values
);
orderProperties,
shouldRender,
getDefaultRegistry,
} from '@department-of-veterans-affairs/react-jsonschema-form/lib/utils';
/*
* This is largely copied from the react-jsonschema-form library,
* but with the way descriptions are used changed
*/
class ObjectField extends React.Component {
static defaultProps = {
uiSchema: {},
errorSchema: {},
idSchema: {},
registry: getDefaultRegistry(),
required: false,
disabled: false,
readonly: false,
};
constructor() {
super();
this.isRequired = this.isRequired.bind(this);
this.orderAndFilterProperties = _.flow(
properties =>
orderProperties(properties, _.get('ui:order', this.props.uiSchema)),
_.groupBy(item => {
const expandUnderField = _.get(
[item, 'ui:options', 'expandUnder'],
this.props.uiSchema,
);
const fields = Array.from(
block.querySelectorAll('.form-checkbox,.schemaform-field-template'),
);
if (fields.length) {
fields[0].classList.add('schemaform-first-field');
}
});
}
}
class ObjectField extends React.Component {
static defaultProps = {
uiSchema: {},
errorSchema: {},
idSchema: {},
registry: getDefaultRegistry(),
required: false,
disabled: false,
readonly: false,
};
constructor(props) {
super(props);
this.state = this.getStateFromProps(props);
this.onPropertyChange = this.onPropertyChange.bind(this);
this.onPropertyBlur = this.onPropertyBlur.bind(this);
this.isRequired = this.isRequired.bind(this);
this.SchemaField = pureWithDeepEquals(
this.props.registry.fields.SchemaField,
);
this.orderedProperties = this.orderAndFilterProperties(
props.schema,