Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// 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);
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
});
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);
<input value="{data" type="time"> handleChange(path, ev.target.value)}
className={className}
id={id}
disabled={!enabled}
autoFocus={uischema.options && uischema.options.focus}
/>
);
};
/**
* Default tester for date controls.
* @type {RankedTester}
*/
export const timeCellTester: RankedTester = rankWith(2, isTimeControl);
export default withJsonFormsCellProps(TimeCell);
max: number;
multipleOf: number;
constructor(ngRedux: NgRedux) {
super(ngRedux);
}
getEventValue = (event: any) => 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
);
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
);
onChange={ev => handleChange(path, Number(ev.currentTarget.value))}
className={className}
id={id}
disabled={!enabled}
autoFocus={uischema.options && uischema.options.focus}
inputProps={config}
endAdornment={<label style="{{marginLeft:">{data || scopedSchema.default}</label>}
/>
);
};
/**
* Matrial tester for slider controls.
* @type {RankedTester}
*/
export const materialSliderFieldTester: RankedTester = rankWith(4, isRangeControl);
export default connectToJsonForms(
mapStateToFieldProps,
mapDispatchToFieldProps
)(MaterialSliderField);
renderers={renderers}
visible={visible}
schema={schema}
uischema={foundUISchema}
path={composePaths(path, `${selectedIndex}`)}
/>
) : (
No Selection
)}
);
};
export const materialListWithDetailTester: RankedTester = rankWith(
4,
and(uiTypeIs('ListWithDetail'), isObjectArray)
);
export default withJsonFormsArrayLayoutProps(MaterialListWithDetailRenderer);
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;