@itsjonq/controls
Version:
A control panel to develop React UI
43 lines (36 loc) • 1.02 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getFields = getFields;
exports.getField = getField;
exports.getValue = getValue;
var _store = require("./store");
/**
* Retrieves the fields from the store.
* @returns {Array<Object>} Fields from the store.
*/
function getFields() {
return [].concat(_store.store.getState().fields) || [];
}
/**
* Retrieves a single field from the store, based on the prop (key).
* @param {string} prop The prop to find from the store.
* @returns {Object} A field from the store.
*/
function getField(prop) {
if (!prop) return undefined;
return getFields().find(function (f) {
return f.prop === prop;
});
}
/**
* Retrieves the value of a single field from the store, based on the prop (key).
* @param {string} prop The prop to find from the store.
* @returns {any} The value of the field.
*/
function getValue(prop) {
if (!prop) return undefined;
var field = getField(prop);
return field ? field.value : undefined;
}