Latest build

old
Javi Velasco 2016-10-22 17:35:55 +02:00
parent 939e713034
commit 2e36de4f67
15 changed files with 79 additions and 16 deletions

View File

@ -54,8 +54,9 @@ var Day = function (_Component) {
value: function dayStyle() { value: function dayStyle() {
if (this.props.day === 1) { if (this.props.day === 1) {
var e = this.props.sundayFirstDayOfWeek ? 0 : 1; var e = this.props.sundayFirstDayOfWeek ? 0 : 1;
var firstDay = _time2.default.getFirstWeekDay(this.props.viewDate) - e;
return { return {
marginLeft: (_time2.default.getFirstWeekDay(this.props.viewDate) - e) * 100 / 7 + '%' marginLeft: (firstDay >= 0 ? firstDay : 6) * 100 / 7 + '%'
}; };
} }
} }

View File

@ -80,6 +80,9 @@ var factory = function factory(Input, DatePickerDialog) {
active: _this.props.active active: _this.props.active
}, _this.handleDismiss = function () { }, _this.handleDismiss = function () {
_this.setState({ active: false }); _this.setState({ active: false });
if (_this.props.onDismiss) {
_this.props.onDismiss();
}
}, _this.handleInputFocus = function (event) { }, _this.handleInputFocus = function (event) {
_events2.default.pauseEvent(event); _events2.default.pauseEvent(event);
_this.setState({ active: true }); _this.setState({ active: true });
@ -114,6 +117,7 @@ var factory = function factory(Input, DatePickerDialog) {
value: function render() { value: function render() {
var _props = this.props; var _props = this.props;
var active = _props.active; var active = _props.active;
var onDismiss = _props.onDismiss;
var autoOk = _props.autoOk; var autoOk = _props.autoOk;
var cancelLabel = _props.cancelLabel; var cancelLabel = _props.cancelLabel;
var inputClassName = _props.inputClassName; var inputClassName = _props.inputClassName;
@ -128,7 +132,7 @@ var factory = function factory(Input, DatePickerDialog) {
var sundayFirstDayOfWeek = _props.sundayFirstDayOfWeek; var sundayFirstDayOfWeek = _props.sundayFirstDayOfWeek;
var value = _props.value; var value = _props.value;
var others = _objectWithoutProperties(_props, ['active', 'autoOk', 'cancelLabel', 'inputClassName', 'inputFormat', 'locale', 'maxDate', 'minDate', 'okLabel', 'onEscKeyDown', 'onOverlayClick', 'readonly', 'sundayFirstDayOfWeek', 'value']); var others = _objectWithoutProperties(_props, ['active', 'onDismiss', 'autoOk', 'cancelLabel', 'inputClassName', 'inputFormat', 'locale', 'maxDate', 'minDate', 'okLabel', 'onEscKeyDown', 'onOverlayClick', 'readonly', 'sundayFirstDayOfWeek', 'value']);
var finalInputFormat = inputFormat || _time2.default.formatDate; var finalInputFormat = inputFormat || _time2.default.formatDate;
var date = Object.prototype.toString.call(value) === '[object Date]' ? value : undefined; var date = Object.prototype.toString.call(value) === '[object Date]' ? value : undefined;
@ -160,8 +164,8 @@ var factory = function factory(Input, DatePickerDialog) {
maxDate: maxDate, maxDate: maxDate,
minDate: minDate, minDate: minDate,
name: this.props.name, name: this.props.name,
okLabel: okLabel,
onDismiss: this.handleDismiss, onDismiss: this.handleDismiss,
okLabel: okLabel,
onEscKeyDown: onEscKeyDown || this.handleDismiss, onEscKeyDown: onEscKeyDown || this.handleDismiss,
onOverlayClick: onOverlayClick || this.handleDismiss, onOverlayClick: onOverlayClick || this.handleDismiss,
onSelect: this.handleSelect, onSelect: this.handleSelect,
@ -193,6 +197,7 @@ var factory = function factory(Input, DatePickerDialog) {
okLabel: _react.PropTypes.string, okLabel: _react.PropTypes.string,
onChange: _react.PropTypes.func, onChange: _react.PropTypes.func,
onClick: _react.PropTypes.func, onClick: _react.PropTypes.func,
onDismiss: _react.PropTypes.func,
onEscKeyDown: _react.PropTypes.func, onEscKeyDown: _react.PropTypes.func,
onKeyPress: _react.PropTypes.func, onKeyPress: _react.PropTypes.func,
onOverlayClick: _react.PropTypes.func, onOverlayClick: _react.PropTypes.func,

View File

@ -134,6 +134,10 @@ interface DatePickerProps extends ReactToolbox.Props {
* Callback to be invoked when the dialog overlay is clicked. * Callback to be invoked when the dialog overlay is clicked.
*/ */
onOverlayClick?: Function; onOverlayClick?: Function;
/**
* The input element will be readonly and look like disabled.
*/
readonly?: boolean;
/** /**
* Classnames object defining the component style. * Classnames object defining the component style.
*/ */

View File

@ -250,7 +250,7 @@ var factory = function factory(Input) {
errored: _react.PropTypes.string, errored: _react.PropTypes.string,
field: _react.PropTypes.string, field: _react.PropTypes.string,
label: _react.PropTypes.string, label: _react.PropTypes.string,
required: _react.PropTypes.bool, required: _react.PropTypes.string,
selected: _react.PropTypes.string, selected: _react.PropTypes.string,
templateValue: _react.PropTypes.string, templateValue: _react.PropTypes.string,
up: _react.PropTypes.string, up: _react.PropTypes.string,

View File

@ -72,13 +72,19 @@ var factory = function factory(FontIcon) {
if (onChange) onChange(value, event); if (onChange) onChange(value, event);
}, _this.handleAutoresize = function () { }, _this.handleAutoresize = function () {
var element = _this.refs.input; var element = _this.refs.input;
// compute the height difference between inner height and outer height var rows = _this.props.rows;
var style = getComputedStyle(element, null);
var heightOffset = style.boxSizing === 'content-box' ? -(parseFloat(style.paddingTop) + parseFloat(style.paddingBottom)) : parseFloat(style.borderTopWidth) + parseFloat(style.borderBottomWidth);
// resize the input to its content size if (typeof rows === 'number' && !isNaN(rows)) {
element.style.height = 'auto'; element.style.height = null;
element.style.height = element.scrollHeight + heightOffset + 'px'; } else {
// compute the height difference between inner height and outer height
var style = getComputedStyle(element, null);
var heightOffset = style.boxSizing === 'content-box' ? -(parseFloat(style.paddingTop) + parseFloat(style.paddingBottom)) : parseFloat(style.borderTopWidth) + parseFloat(style.borderBottomWidth);
// resize the input to its content size
element.style.height = 'auto';
element.style.height = element.scrollHeight + heightOffset + 'px';
}
}, _this.handleKeyPress = function (event) { }, _this.handleKeyPress = function (event) {
// prevent insertion of more characters if we're a multiline input // prevent insertion of more characters if we're a multiline input
// and maxLength exists // and maxLength exists
@ -164,8 +170,10 @@ var factory = function factory(FontIcon) {
var type = _props.type; var type = _props.type;
var value = _props.value; var value = _props.value;
var onKeyPress = _props.onKeyPress; var onKeyPress = _props.onKeyPress;
var _props$rows = _props.rows;
var rows = _props$rows === undefined ? 1 : _props$rows;
var others = _objectWithoutProperties(_props, ['children', 'disabled', 'error', 'floating', 'hint', 'icon', 'name', 'label', 'maxLength', 'multiline', 'required', 'theme', 'type', 'value', 'onKeyPress']); var others = _objectWithoutProperties(_props, ['children', 'disabled', 'error', 'floating', 'hint', 'icon', 'name', 'label', 'maxLength', 'multiline', 'required', 'theme', 'type', 'value', 'onKeyPress', 'rows']);
var length = maxLength && value ? value.length : 0; var length = maxLength && value ? value.length : 0;
var labelClassName = (0, _classnames5.default)(theme.label, _defineProperty({}, theme.fixed, !floating)); var labelClassName = (0, _classnames5.default)(theme.label, _defineProperty({}, theme.fixed, !floating));
@ -189,7 +197,7 @@ var factory = function factory(FontIcon) {
inputElementProps.maxLength = maxLength; inputElementProps.maxLength = maxLength;
inputElementProps.onKeyPress = onKeyPress; inputElementProps.onKeyPress = onKeyPress;
} else { } else {
inputElementProps.rows = 1; inputElementProps.rows = rows;
inputElementProps.onKeyPress = this.handleKeyPress; inputElementProps.onKeyPress = this.handleKeyPress;
} }
@ -211,7 +219,7 @@ var factory = function factory(FontIcon) {
) : null, ) : null,
hint ? _react2.default.createElement( hint ? _react2.default.createElement(
'span', 'span',
{ className: theme.hint }, { hidden: labelText, className: theme.hint },
hint hint
) : null, ) : null,
error ? _react2.default.createElement( error ? _react2.default.createElement(
@ -251,6 +259,7 @@ var factory = function factory(FontIcon) {
onFocus: _react2.default.PropTypes.func, onFocus: _react2.default.PropTypes.func,
onKeyPress: _react2.default.PropTypes.func, onKeyPress: _react2.default.PropTypes.func,
required: _react2.default.PropTypes.bool, required: _react2.default.PropTypes.bool,
rows: _react2.default.PropTypes.number,
theme: _react2.default.PropTypes.shape({ theme: _react2.default.PropTypes.shape({
bar: _react2.default.PropTypes.string, bar: _react2.default.PropTypes.string,
counter: _react2.default.PropTypes.string, counter: _react2.default.PropTypes.string,

View File

@ -46,6 +46,7 @@
color: $input-text-required-color; color: $input-text-required-color;
} }
~ .hint { ~ .hint {
display: block;
opacity: $input-hint-opacity; opacity: $input-hint-opacity;
} }
~ .icon { ~ .icon {
@ -57,6 +58,9 @@
top: $input-focus-label-top; top: $input-focus-label-top;
font-size: $input-label-font-size; font-size: $input-label-font-size;
} }
&.filled ~ .hint {
opacity: 0;
}
} }
&.filled ~ .label.fixed, &.filled ~ .hint { &.filled ~ .label.fixed, &.filled ~ .hint {
display: none; display: none;
@ -87,7 +91,7 @@
line-height: $input-field-font-size; line-height: $input-field-font-size;
color: $input-text-label-color; color: $input-text-label-color;
pointer-events: none; pointer-events: none;
opacity: 0; opacity: $input-hint-opacity;
transition-timing-function: $animation-curve-default; transition-timing-function: $animation-curve-default;
transition-duration: $animation-duration; transition-duration: $animation-duration;
transition-property: opacity; transition-property: opacity;

View File

@ -99,6 +99,7 @@ var ProgressBar = function (_Component) {
var _props = this.props; var _props = this.props;
var className = _props.className; var className = _props.className;
var disabled = _props.disabled;
var max = _props.max; var max = _props.max;
var min = _props.min; var min = _props.min;
var mode = _props.mode; var mode = _props.mode;
@ -112,6 +113,7 @@ var ProgressBar = function (_Component) {
return _react2.default.createElement( return _react2.default.createElement(
'div', 'div',
{ {
disabled: disabled,
'data-react-toolbox': 'progress-bar', 'data-react-toolbox': 'progress-bar',
'aria-valuenow': value, 'aria-valuenow': value,
'aria-valuemin': min, 'aria-valuemin': min,
@ -129,6 +131,7 @@ var ProgressBar = function (_Component) {
ProgressBar.propTypes = { ProgressBar.propTypes = {
buffer: _react.PropTypes.number, buffer: _react.PropTypes.number,
className: _react.PropTypes.string, className: _react.PropTypes.string,
disabled: _react.PropTypes.bool,
max: _react.PropTypes.number, max: _react.PropTypes.number,
min: _react.PropTypes.number, min: _react.PropTypes.number,
mode: _react.PropTypes.oneOf(['determinate', 'indeterminate']), mode: _react.PropTypes.oneOf(['determinate', 'indeterminate']),

View File

@ -1,6 +1,7 @@
$progress-height: .4 * $unit !default; $progress-height: .4 * $unit !default;
$progress-main-color: $color-primary !default; $progress-main-color: $color-primary !default;
$progress-secondary-color: rgba($color-primary-contrast, 0.7) !default; $progress-secondary-color: rgba($color-primary-contrast, 0.7) !default;
$progress-disabled-color: rgba($color-black, 0.26) !default;
$circle-wrapper-width: 60 !default; $circle-wrapper-width: 60 !default;
$circle-radius: 25 !default; $circle-radius: 25 !default;
$scale-ratio: $circle-radius / 20 !default; $scale-ratio: $circle-radius / 20 !default;

View File

@ -42,6 +42,11 @@ interface ProgressBarProps extends ReactToolbox.Props {
* @default 0 * @default 0
*/ */
buffer?: number; buffer?: number;
/**
* If true, component will be disabled.
* @default false
*/
disabled?: boolean;
/** /**
* Maximum value permitted. * Maximum value permitted.
* @default 100 * @default 100

View File

@ -32,11 +32,20 @@
background-color: $progress-main-color; background-color: $progress-main-color;
} }
[disabled] .value {
background-color: $progress-disabled-color;
}
.buffer { .buffer {
background-image: linear-gradient(to right, $progress-secondary-color, $progress-secondary-color), background-image: linear-gradient(to right, $progress-secondary-color, $progress-secondary-color),
linear-gradient(to right, $progress-main-color, $progress-main-color); linear-gradient(to right, $progress-main-color, $progress-main-color);
} }
[disabled] .buffer {
background-image: linear-gradient(to right, $progress-secondary-color, $progress-secondary-color),
linear-gradient(to right, $progress-disabled-color, $progress-disabled-color);
}
.circular { .circular {
position: relative; position: relative;
display: inline-block; display: inline-block;

View File

@ -265,6 +265,7 @@ var factory = function factory(ProgressBar, Input) {
return _react2.default.createElement(Input, { return _react2.default.createElement(Input, {
ref: 'input', ref: 'input',
className: this.props.theme.input, className: this.props.theme.input,
disabled: this.props.disabled,
onFocus: this.handleInputFocus, onFocus: this.handleInputFocus,
onChange: this.handleInputChange, onChange: this.handleInputChange,
onBlur: this.handleInputBlur, onBlur: this.handleInputBlur,
@ -280,12 +281,13 @@ var factory = function factory(ProgressBar, Input) {
var theme = this.props.theme; var theme = this.props.theme;
var knobStyles = { left: this.knobOffset() + '%' }; var knobStyles = { left: this.knobOffset() + '%' };
var className = (0, _classnames3.default)(theme.slider, (_classnames = {}, _defineProperty(_classnames, theme.editable, this.props.editable), _defineProperty(_classnames, theme.pinned, this.props.pinned), _defineProperty(_classnames, theme.pressed, this.state.pressed), _defineProperty(_classnames, theme.ring, this.props.value === this.props.min), _classnames), this.props.className); var className = (0, _classnames3.default)(theme.slider, (_classnames = {}, _defineProperty(_classnames, theme.editable, this.props.editable), _defineProperty(_classnames, theme.disabled, this.props.disabled), _defineProperty(_classnames, theme.pinned, this.props.pinned), _defineProperty(_classnames, theme.pressed, this.state.pressed), _defineProperty(_classnames, theme.ring, this.props.value === this.props.min), _classnames), this.props.className);
return _react2.default.createElement( return _react2.default.createElement(
'div', 'div',
{ {
className: className, className: className,
disabled: this.props.disabled,
'data-react-toolbox': 'slider', 'data-react-toolbox': 'slider',
onBlur: this.handleSliderBlur, onBlur: this.handleSliderBlur,
onFocus: this.handleSliderFocus, onFocus: this.handleSliderFocus,
@ -314,6 +316,7 @@ var factory = function factory(ProgressBar, Input) {
'div', 'div',
{ className: theme.progress }, { className: theme.progress },
_react2.default.createElement(ProgressBar, { _react2.default.createElement(ProgressBar, {
disabled: this.props.disabled,
ref: 'progressbar', ref: 'progressbar',
className: theme.innerprogress, className: theme.innerprogress,
max: this.props.max, max: this.props.max,
@ -334,6 +337,7 @@ var factory = function factory(ProgressBar, Input) {
Slider.propTypes = { Slider.propTypes = {
className: _react.PropTypes.string, className: _react.PropTypes.string,
disabled: _react.PropTypes.bool,
editable: _react.PropTypes.bool, editable: _react.PropTypes.bool,
max: _react.PropTypes.number, max: _react.PropTypes.number,
min: _react.PropTypes.number, min: _react.PropTypes.number,

View File

@ -1,5 +1,6 @@
$slider-main-color: $color-primary !default; $slider-main-color: $color-primary !default;
$slider-main-color-contrast: $color-primary-contrast !default; $slider-main-color-contrast: $color-primary-contrast !default;
$slider-disabled-color: rgba(177, 177, 177, 1) !default;
$slider-snap-color: $color-black !default; $slider-snap-color: $color-black !default;
$slider-knob-size: 3.2 * $unit !default; $slider-knob-size: 3.2 * $unit !default;
$slider-inner-knob-size: 1.2 * $unit !default; $slider-inner-knob-size: 1.2 * $unit !default;

View File

@ -62,6 +62,11 @@ interface SliderProps extends ReactToolbox.Props {
* @default false * @default false
*/ */
editable?: boolean; editable?: boolean;
/**
* If true, component will be disabled.
* @default false
*/
disabled?: boolean;
/** /**
* Maximum value permitted. * Maximum value permitted.
* @default 100 * @default 100

View File

@ -111,6 +111,13 @@
border-radius: 50%; border-radius: 50%;
opacity: .26; opacity: .26;
} }
&[disabled] {
pointer-events: none;
cursor: auto;
.innerknob {
background-color: $slider-disabled-color;
}
}
&.editable { &.editable {
display: flex; display: flex;
flex-direction: row; flex-direction: row;

View File

@ -72,6 +72,9 @@ var factory = function factory(TimePickerDialog, Input) {
active: _this.props.active active: _this.props.active
}, _this.handleDismiss = function () { }, _this.handleDismiss = function () {
_this.setState({ active: false }); _this.setState({ active: false });
if (_this.props.onDismiss) {
_this.props.onDismiss();
}
}, _this.handleInputFocus = function (event) { }, _this.handleInputFocus = function (event) {
_events2.default.pauseEvent(event); _events2.default.pauseEvent(event);
_this.setState({ active: true }); _this.setState({ active: true });
@ -106,6 +109,7 @@ var factory = function factory(TimePickerDialog, Input) {
value: function render() { value: function render() {
var _props = this.props; var _props = this.props;
var active = _props.active; var active = _props.active;
var onDismiss = _props.onDismiss;
var cancelLabel = _props.cancelLabel; var cancelLabel = _props.cancelLabel;
var format = _props.format; var format = _props.format;
var inputClassName = _props.inputClassName; var inputClassName = _props.inputClassName;
@ -115,7 +119,7 @@ var factory = function factory(TimePickerDialog, Input) {
var readonly = _props.readonly; var readonly = _props.readonly;
var value = _props.value; var value = _props.value;
var others = _objectWithoutProperties(_props, ['active', 'cancelLabel', 'format', 'inputClassName', 'okLabel', 'onEscKeyDown', 'onOverlayClick', 'readonly', 'value']); var others = _objectWithoutProperties(_props, ['active', 'onDismiss', 'cancelLabel', 'format', 'inputClassName', 'okLabel', 'onEscKeyDown', 'onOverlayClick', 'readonly', 'value']);
var formattedTime = value ? _time2.default.formatTime(value, format) : ''; var formattedTime = value ? _time2.default.formatTime(value, format) : '';
return _react2.default.createElement( return _react2.default.createElement(
@ -166,6 +170,7 @@ var factory = function factory(TimePickerDialog, Input) {
okLabel: _react.PropTypes.string, okLabel: _react.PropTypes.string,
onChange: _react.PropTypes.func, onChange: _react.PropTypes.func,
onClick: _react.PropTypes.func, onClick: _react.PropTypes.func,
onDismiss: _react.PropTypes.func,
onEscKeyDown: _react.PropTypes.func, onEscKeyDown: _react.PropTypes.func,
onKeyPress: _react.PropTypes.func, onKeyPress: _react.PropTypes.func,
onOverlayClick: _react.PropTypes.func, onOverlayClick: _react.PropTypes.func,