Skip to content

Commit

Permalink
build
Browse files Browse the repository at this point in the history
  • Loading branch information
ivansfdc committed Feb 12, 2016
1 parent fc79951 commit f19a454
Show file tree
Hide file tree
Showing 13 changed files with 528 additions and 52,883 deletions.
442 changes: 0 additions & 442 deletions dist/demo.css

This file was deleted.

52,400 changes: 0 additions & 52,400 deletions dist/demo.js

This file was deleted.

1 change: 1 addition & 0 deletions lib/SLDSDatepickerSingleSelect/SLDSYearSelector/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ module.exports = _react2.default.createClass({
options: this.getOptions(),
placeholder: 'Year',
checkmark: false,
modal: false,
value: this.props.displayedDate.getFullYear(),
onSelect: this.handleSelect,
className: 'slds-picklist--fluid slds-shrink-none',
Expand Down
55 changes: 35 additions & 20 deletions lib/SLDSDatepickerSingleSelect/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,21 @@ var propTypes = {
*/
value: _react2.default.PropTypes.instanceOf(Date),

strValue: _react2.default.PropTypes.string,

weekDayLabels: _react2.default.PropTypes.array

};
var defaultProps = {
abbrWeekDayLabels: ['S', 'M', 'T', 'W', 'T', 'F', 'S'],
formatter: function formatter(date) {
return date.getMonth() + 1 + '/' + date.getDate() + '/' + date.getFullYear();
if (date) {
return date.getMonth() + 1 + '/' + date.getDate() + '/' + date.getFullYear();
}
},

monthLabels: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
onDateChange: function onDateChange(date) {
onDateChange: function onDateChange(date, strValue) {
console.log('onDateChange should be defined');
},
parser: function parser(str) {
Expand All @@ -97,12 +101,14 @@ module.exports = _react2.default.createClass({
getInitialState: function getInitialState() {
return {
isOpen: false,
value: this.props.value
value: this.props.value,
strValue: this.props.strValue
};
},
handleChange: function handleChange(date) {
this.setState({
value: date,
strValue: this.props.formatter(date),
isOpen: false
});
if (this.props.onDateChange) {
Expand All @@ -127,8 +133,18 @@ module.exports = _react2.default.createClass({
_reactDom2.default.findDOMNode(this.refs.date).focus();
}
},
parseDate: function parseDate(strValue) {
var d = this.props.parser(strValue);
if (Object.prototype.toString.call(d) === "[object Date]") {
if (!isNaN(d.getTime())) {
return d;
}
}
return new Date();
},
popover: function popover() {
if (this.state && this.state.isOpen) {
var date = this.state.strValue ? this.parseDate(this.state.strValue) : this.state.value;
return _react2.default.createElement(
_SLDSPopover2.default,
{ className: 'slds-dropdown', targetElement: this.refs.date, onClose: this.handleClose },
Expand All @@ -142,31 +158,27 @@ module.exports = _react2.default.createClass({
todayLabel: this.props.todayLabel,
relativeYearFrom: this.props.relativeYearFrom,
relativeYearTo: this.props.relativeYearTo,
selectedDate: this.state.value ? this.state.value : new Date() })
selectedDate: date ? date : new Date() })
);
}
return _react2.default.createElement('span', null);
},
handleInputChange: function handleInputChange() {
var string = _reactDom2.default.findDOMNode(this.refs.date).value;
var date = this.props.parser(string);
if (date) {
this.setState({
value: date,
string: string
});
if (this.props.onDateChage) {
this.props.onDateChange(value);
}
} else {
this.setState({
isOpen: false
});
this.setState({
strValue: string
});
if (this.props.onDateChange) {
var d = this.props.parser(string);
this.props.onDateChange(d, string);
}
},
handleKeyDown: function handleKeyDown(event) {
if (event.keyCode) {
if (event.keyCode === _utils.KEYS.ENTER || event.keyCode === _utils.KEYS.SPACE || event.keyCode === _utils.KEYS.DOWN || event.keyCode === _utils.KEYS.UP) {
var isShift = !!event.shiftKey;
if (!isShift && (event.keyCode === _utils.KEYS.ENTER ||
// event.keyCode === KEYS.SPACE ||
event.keyCode === _utils.KEYS.DOWN || event.keyCode === _utils.KEYS.UP)) {
_utils.EventUtil.trapEvent(event);

this.setState({
Expand All @@ -175,6 +187,9 @@ module.exports = _react2.default.createClass({
}
}
},
getInputIcon: function getInputIcon() {
return _react2.default.createElement(_InputIcon2.default, { name: 'event', style: { pointerEvents: 'none' } });
},
render: function render() {
return _react2.default.createElement(
'div',
Expand All @@ -190,14 +205,14 @@ module.exports = _react2.default.createClass({
_react2.default.createElement(
'div',
{ className: 'slds-input-has-icon slds-input-has-icon--right' },
_react2.default.createElement(_InputIcon2.default, { name: 'event' }),
this.getInputIcon(),
_react2.default.createElement('input', {
name: 'date',
ref: 'date',
className: 'slds-input',
type: 'text',
placeholder: this.props.placeholder,
value: this.state.value ? this.props.formatter(this.state.value) : '',
value: this.state.strValue,
onKeyDown: this.handleKeyDown,
onChange: this.handleInputChange,
onClick: this.handleClick,
Expand Down
1 change: 1 addition & 0 deletions lib/SLDSIcon/InputIcon/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ var propTypes = {
isHighlighted: _react2.default.PropTypes.bool,
isSelected: _react2.default.PropTypes.bool,
label: _react2.default.PropTypes.string,
value: _react2.default.PropTypes.string
value: _react2.default.PropTypes.any
};
var defaultProps = {
data: {},
Expand Down
200 changes: 200 additions & 0 deletions lib/SLDSMenuList/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
"use strict";

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

var _react = require("react");

var _react2 = _interopRequireDefault(_react);

var _reactDom = require("react-dom");

var _reactDom2 = _interopRequireDefault(_reactDom);

var _lodash = require("lodash.isequal");

var _lodash2 = _interopRequireDefault(_lodash);

var _utils = require("../utils");

var _SLDSIcon = require("../SLDSIcon");

var _SLDSIcon2 = _interopRequireDefault(_SLDSIcon);

var _List = require("./List");

var _List2 = _interopRequireDefault(_List);

var _ListItemLabel = require("./ListItemLabel");

var _ListItemLabel2 = _interopRequireDefault(_ListItemLabel);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /*
Copyright (c) 2015, salesforce.com, inc. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
Neither the name of salesforce.com, inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

var displayName = "SLDSMenuList";
var propTypes = {
className: _react2.default.PropTypes.string,
/**
* If true, renders checkmark icon on the selected Menu Item.
*/
checkmark: _react2.default.PropTypes.bool,
label: _react2.default.PropTypes.string,
/**
* Custom element that overrides the default Menu Item component.
*/
listItemRenderer: _react2.default.PropTypes.node,
/**
* If true, component renders specifically to work inside Modal.
*/
onClick: _react2.default.PropTypes.func,
onSelect: _react2.default.PropTypes.func,
/**
* Menu item data.
*/
options: _react2.default.PropTypes.array.isRequired
};
var defaultProps = {
checkmark: true
};

/**
* The SLDSMenuPicklist component is a variant of the Ligtning Design System Menu component.
*/

var SLDSMenuPicklist = function (_React$Component) {
_inherits(SLDSMenuPicklist, _React$Component);

function SLDSMenuPicklist(props) {
_classCallCheck(this, SLDSMenuPicklist);

var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(SLDSMenuPicklist).call(this, props));

_this.state = {
highlightedIndex: 0,
isOpen: false,
lastBlurredIndex: -1,
lastBlurredTimeStamp: -1,
selectedIndex: _this.props.selectedIndex,
/* triggerId is the id of the element that triggers the Menu to open.
* Need this for aria-labelledby on <ul> in Menu for accessibility. */
triggerId: _this.props.label ? _this.props.label.replace(/\s+/g, '') + '_Button' : 'Picklist_Button'
};

return _this;
}

_createClass(SLDSMenuPicklist, [{
key: "componentWillUnmount",
value: function componentWillUnmount() {
this.isUnmounting = true;
}
}, {
key: "componentDidUpdate",
value: function componentDidUpdate(prevProps, prevState) {
if (this.state.lastBlurredTimeStamp !== prevState.lastBlurredTimeStamp) {
if (this.state.lastBlurredIndex === this.state.highlightedIndex) {
this.handleClose();
}
}
if (this.state.selectedIndex !== prevState.selectedIndex) {
this.handleClose();
}

if (this.props.selectedIndex !== prevProps.selectedIndex || !(0, _lodash2.default)(this.props.options, prevProps.options)) {
if (this.props.selectedIndex !== this.state.selectedIndex) {
this.handleSelect(this.props.selectedIndex);
}
}
}
}, {
key: "handleSelect",
value: function handleSelect(index) {
this.setState({ selectedIndex: index });
if (this.props.onSelect) {
this.props.onSelect(index);
}
}
}, {
key: "handleClose",
value: function handleClose() {
if (this.props.onCancel) {
this.props.onCancel();
}
}
}, {
key: "handleMouseDown",
value: function handleMouseDown(event) {
_utils.EventUtil.trapImmediate(event);
}
}, {
key: "handleUpdateHighlighted",
value: function handleUpdateHighlighted(nextIndex) {
this.setState({ highlightedIndex: nextIndex });
}
}, {
key: "handleListBlur",
value: function handleListBlur() {
if (this.props.onListBlur) {
this.props.onListBlur();
}
}
}, {
key: "handleCancel",
value: function handleCancel() {
if (this.props.onCancel) {
this.props.onCancel();
}
}
}, {
key: "getListItemRenderer",
value: function getListItemRenderer() {
return this.props.listItemRenderer ? this.props.listItemRenderer : _ListItemLabel2.default;
}
}, {
key: "handleListItemBlur",
value: function handleListItemBlur(index, relatedTarget) {
this.setState({
lastBlurredIndex: index,
lastBlurredTimeStamp: Date.now()
});
}
}, {
key: "render",
value: function render() {
return _react2.default.createElement(_List2.default, {
checkmark: this.props.checkmark,
highlightedIndex: this.state.highlightedIndex,
itemRenderer: this.getListItemRenderer(),
onCancel: this.handleCancel.bind(this),
onListBlur: this.handleListBlur.bind(this),
onListItemBlur: this.handleListItemBlur.bind(this),
onSelect: this.handleSelect.bind(this),
onUpdateHighlighted: this.handleUpdateHighlighted.bind(this),
options: this.props.options,
ref: "list",
selectedIndex: this.state.selectedIndex
});
}
}]);

return SLDSMenuPicklist;
}(_react2.default.Component);

SLDSMenuPicklist.displayName = displayName;
SLDSMenuPicklist.propTypes = propTypes;
SLDSMenuPicklist.defaultProps = defaultProps;

module.exports = SLDSMenuPicklist;
module.exports.ListItemLabel = _ListItemLabel2.default;
9 changes: 2 additions & 7 deletions lib/SLDSMenuPicklist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,11 @@ var _SLDSIcon = require("../SLDSIcon");

var _SLDSIcon2 = _interopRequireDefault(_SLDSIcon);

var _List = require("./List");
var _List = require("../SLDSMenuList/List");

var _List2 = _interopRequireDefault(_List);

var _ListItem = require("./ListItem");

var _ListItem2 = _interopRequireDefault(_ListItem);

var _ListItemLabel = require("./ListItemLabel");
var _ListItemLabel = require("../SLDSMenuList/ListItemLabel");

var _ListItemLabel2 = _interopRequireDefault(_ListItemLabel);

Expand Down Expand Up @@ -367,5 +363,4 @@ SLDSMenuPicklist.propTypes = propTypes;
SLDSMenuPicklist.defaultProps = defaultProps;

module.exports = SLDSMenuPicklist;
module.exports.ListItem = _ListItem2.default;
module.exports.ListItemLabel = _ListItemLabel2.default;
Loading

0 comments on commit f19a454

Please sign in to comment.