UNPKG

@darwino/darwino-react

Version:

A set of Javascript classes and utilities

50 lines (44 loc) 1.35 kB
/* * (c) Copyright Darwino Inc. 2014-2017. */ import React, { Component } from "react"; import { EmptyDataFetcher, ArrayDataFetcher, JSArrayDataFetcher } from '@darwino/darwino'; import BasePicker from './BasePicker'; /* * Base class for a value picker class */ class BaseValuePicker extends BasePicker { constructor(props, context) { super(props, context); // Shortcut for an array of values // Should this be shared with cursor list? if (this.props.dataFetcher) { this.dataFetcher = this.props.dataFetcher; } else if (this.props.dataLoader) { this.dataFetcher = new ArrayDataFetcher({ dataLoader: this.props.dataLoader }); } else if (this.props.values) { if (this.props.values.then) { this.dataFetcher = new JSArrayDataFetcher({ values: [] }); this.props.values.then(json => { this.dataFetcher._array = json; this.dataFetcher.onDataLoaded(); }); } else { this.dataFetcher = new JSArrayDataFetcher({ values: this.props.values }); } } else { this.dataFetcher = new EmptyDataFetcher(); } this.dataFetcher.onDataLoaded = () => { this.forceUpdate(); }; this.dataFetcher.init(); } } export default BaseValuePicker; //# sourceMappingURL=BaseValuePicker.js.map