How to use the @dhis2/d2-ui-core.mapProps function in @dhis2/d2-ui-core

To help you get started, we’ve selected a few @dhis2/d2-ui-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 dhis2 / d2-ui / packages / legend / src / LegendItem.store.js View on Github external
}, {
    name: 'endValue',
    component: TextField,
    props: {
        type: 'number',
    },
    validators: [{
        validator: value => (value !== ''),
        message: 'required',
    }, /* ,{
        validator: value => Number(value) <= Number(legendItemStore.getState().model.startValue) ? false : true,
        message: 'should_be_higher_than_start_value',
    } */],
}, { // Defined in data-table/data-value/Color.component.js
    name: 'color',
    component: mapProps(props => ({
        color: props.value,
        onChange(color) {
            props.onChange(createFakeEvent(color));
        },
    }), ColorPicker),
}];


// Called when a field is changed
export function onFieldChange(fieldName, value) {
    const model = legendItemStore.getState().model;

    model[fieldName] = value;

    legendItemStore.setState({
        ...legendItemStore.getState(),