sws-frontend
Version:
sws frontend project
81 lines • 3.63 kB
JavaScript
;
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __assign = (this && this.__assign) || Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
Object.defineProperty(exports, "__esModule", { value: true });
var React = require("react");
var ReactSelectClass = require("react-select");
// import Creatable = require('react-select');
// import * as ReactSelect from 'react-select';
// import { Option } from 'ReactSelect';
// import ISelectProps = require('react-select');
require("react-select/dist/react-select.css");
var field_1 = require("./field");
// FieldProps & {
// choices: SelectOption[];
// selected: SelectOption[];
// disabled?: boolean;
// multi: boolean;
//
// autoBlur?:boolean; //Blurs the input element after a selection has been made. Handy for lowering the keyboard on mobile devices
// // addLabelText?:string;
// // isOptionUnique?:Function;
// allowCreate?: boolean; // whether to allow creation of new entries
// // newOptionCreator?: Function; // factory to create new options when allowCreate set
//
// handleSelectChange: (val) => void;
// }
require("./choicefield.scss");
// import ReactSelectProps from 'react-select'; //ReactCreatableSelectProps
var ChoiceField = (function (_super) {
__extends(ChoiceField, _super);
function ChoiceField(p) {
var _this = _super.call(this, p) || this;
_this.state = {
selected: p.selected
};
return _this;
}
ChoiceField.prototype.render = function () {
// import * as Select from 'react-select';
var p = this.props;
return React.createElement(field_1.Field, __assign({ name: p.name }, p), p.allowCreate
? React.createElement(ReactSelectClass.Creatable, __assign({ name: p.name, disabled: p.disabled ? p.disabled : false, placeholder: "", multi: p.multi, value: p.multi ? p.selected : p.selected[0], options: p.choices, clearable: false, onChange: p.handleSelectChange }, p))
: React.createElement(ReactSelectClass, __assign({ name: p.name, disabled: p.disabled ? p.disabled : false, placeholder: "", multi: p.multi, value: p.multi ? p.selected : p.selected[0], options: p.choices, clearable: false, onChange: p.handleSelectChange }, p)));
};
ChoiceField.createOption = function (label, value, clearableValue) {
return ({
label: label,
value: value ? value : label,
clearableValue: clearableValue ? clearableValue : true
});
};
ChoiceField.createOptionWithInfo = function (label, value, clearableValue, disabled, color, info) {
return ({
label: label,
value: value ? value : label,
clearableValue: clearableValue ? clearableValue : true,
disabled: disabled,
color: color,
info: info
});
};
return ChoiceField;
}(React.Component));
exports.default = ChoiceField;
//# sourceMappingURL=choicefield.js.map