Skip to content

Commit 6881ed1

Browse files
committed
more build tweaks
1 parent bbcb0c8 commit 6881ed1

File tree

31 files changed

+3959
-2
lines changed

31 files changed

+3959
-2
lines changed

lib/SLDSButton/index.js

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/*
2+
Copyright (c) 2015, salesforce.com, inc. All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
5+
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
6+
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.
7+
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.
8+
9+
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.
10+
*/
11+
12+
'use strict';
13+
14+
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
15+
16+
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; }; })();
17+
18+
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
19+
20+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
21+
22+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
23+
24+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
25+
26+
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; }
27+
28+
var _react = require('react');
29+
30+
var _react2 = _interopRequireDefault(_react);
31+
32+
var _utilsCreateChainedFunction = require('../utils/create-chained-function');
33+
34+
var _utilsCreateChainedFunction2 = _interopRequireDefault(_utilsCreateChainedFunction);
35+
36+
var _lodash = require('lodash');
37+
38+
var classNames = require('classnames');
39+
40+
var Button = (function (_React$Component) {
41+
_inherits(Button, _React$Component);
42+
43+
function Button(props) {
44+
_classCallCheck(this, Button);
45+
46+
_get(Object.getPrototypeOf(Button.prototype), 'constructor', this).call(this, props);
47+
this.state = {};
48+
}
49+
50+
_createClass(Button, [{
51+
key: 'onClick',
52+
value: function onClick(e) {
53+
this.setState({ active: !this.state.active });
54+
}
55+
}, {
56+
key: 'getClassName',
57+
value: function getClassName() {
58+
var _classNames;
59+
60+
return classNames(this.props.className, 'slds-button', (_classNames = {}, _defineProperty(_classNames, 'slds-button--' + this.props.flavor, this.props.flavor), _defineProperty(_classNames, 'slds-is-selected', this.state.active), _classNames));
61+
}
62+
}, {
63+
key: 'render',
64+
value: function render() {
65+
var props = (0, _lodash.omit)('className', this.props);
66+
var click = (0, _utilsCreateChainedFunction2['default'])(this.props.onClick, this.onClick.bind(this));
67+
return _react2['default'].createElement(
68+
'button',
69+
_extends({ className: this.getClassName() }, props, { onClick: click }),
70+
this.props.children
71+
);
72+
}
73+
}]);
74+
75+
return Button;
76+
})(_react2['default'].Component);
77+
78+
module.exports = Button;
Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
/*
2+
Copyright (c) 2015, salesforce.com, inc. All rights reserved.
3+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
4+
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
5+
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.
6+
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.
7+
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.
8+
*/
9+
10+
'use strict';
11+
12+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
13+
14+
var _react = require('react');
15+
16+
var _react2 = _interopRequireDefault(_react);
17+
18+
var _utils = require('../../../utils');
19+
20+
module.exports = _react2['default'].createClass({
21+
displayName: 'exports',
22+
23+
getDefaultProps: function getDefaultProps() {
24+
return {
25+
26+
displayedDate: new Date(),
27+
28+
selectedDate: new Date(),
29+
30+
onSelectDate: function onSelectDate(date) {
31+
console.log('onSelectDate should be defined ', date);
32+
},
33+
34+
onClick: function onClick(index) {
35+
console.log('onClick should be defined ', index);
36+
},
37+
38+
onMoveFocus: function onMoveFocus(delta) {
39+
console.log('onMoveFocus should be defined ', delta);
40+
},
41+
42+
onBlur: function onBlur(relatedTarget) {
43+
console.log('onBlur should be defined ', relatedTarget);
44+
},
45+
46+
onFocus: function onFocus(index, height) {
47+
console.log('onFocus should be defined ', index, height);
48+
},
49+
50+
onCancel: function onCancel() {
51+
console.log('onCancel should be defined');
52+
}
53+
54+
};
55+
},
56+
57+
handleClick: function handleClick(event) {
58+
if (this.props.onSelectDate) {
59+
this.props.onSelectDate(this.props.date);
60+
}
61+
if (event.nativeEvent) {
62+
event.nativeEvent.stopImmediatePropagation();
63+
event.nativeEvent.preventDefault();
64+
}
65+
},
66+
67+
handleToPrevDay: function handleToPrevDay() {
68+
if (this.props.onPrevDay) {
69+
this.props.onPrevDay(this.props.date);
70+
}
71+
},
72+
73+
handleToNextDay: function handleToNextDay() {
74+
if (this.props.onNextDay) {
75+
this.props.onNextDay(this.props.date);
76+
}
77+
},
78+
79+
handleToPrevWeek: function handleToPrevWeek() {
80+
console.log('>>> handleToPrevWeek');
81+
if (this.props.onPrevWeek) {
82+
console.log('>>> this.props.onPrevWeek');
83+
this.props.onPrevWeek(this.props.date);
84+
}
85+
},
86+
87+
handleToNextWeek: function handleToNextWeek() {
88+
console.log('>>> handleToNextWeek');
89+
if (this.props.onNextWeek) {
90+
console.log('>>> this.props.onNextWeek');
91+
this.props.onNextWeek(this.props.date);
92+
}
93+
},
94+
95+
handleKeyDown: function handleKeyDown(event) {
96+
if (event.keyCode) {
97+
if (event.keyCode === _utils.KEYS.ENTER || event.keyCode === _utils.KEYS.SPACE) {
98+
_utils.EventUtil.trapEvent(event);
99+
if (this.props.onSelectDate) {
100+
this.props.onSelectDate(this.props.date);
101+
}
102+
} else if (event.keyCode === _utils.KEYS.ESCAPE) {
103+
_utils.EventUtil.trapEvent(event);
104+
if (this.props.onCancel) {
105+
this.props.onCancel();
106+
}
107+
} else if (event.keyCode === _utils.KEYS.TAB) {
108+
if (!event.shiftKey) {
109+
_utils.EventUtil.trapEvent(event);
110+
if (this.props.onCancel) {
111+
this.props.onCancel();
112+
}
113+
}
114+
} else if (event.keyCode === _utils.KEYS.RIGHT) {
115+
_utils.EventUtil.trapEvent(event);
116+
this.handleToNextDay();
117+
} else if (event.keyCode === _utils.KEYS.LEFT) {
118+
_utils.EventUtil.trapEvent(event);
119+
this.handleToPrevDay();
120+
} else if (event.keyCode === _utils.KEYS.RIGHT) {
121+
_utils.EventUtil.trapEvent(event);
122+
this.handleToNextDay();
123+
} else if (event.keyCode === _utils.KEYS.UP) {
124+
_utils.EventUtil.trapEvent(event);
125+
this.handleToPrevWeek();
126+
} else if (event.keyCode === _utils.KEYS.DOWN) {
127+
_utils.EventUtil.trapEvent(event);
128+
this.handleToNextWeek();
129+
} else {
130+
_utils.EventUtil.trapEvent(event);
131+
}
132+
}
133+
},
134+
135+
setFocus: function setFocus() {
136+
this.getDOMNode().focus();
137+
},
138+
139+
render: function render() {
140+
141+
var isCurrentMonth = _utils.DateUtil.isSameMonth(this.props.date, this.props.displayedDate);
142+
var isToday = _utils.DateUtil.isToday(this.props.date);
143+
var isSelectedDay = _utils.DateUtil.isSameDay(this.props.date, this.props.selectedDate);
144+
var isFirstDayOfMonth = _utils.DateUtil.isFirstDayOfMonth(this.props.date);
145+
146+
return _react2['default'].createElement(
147+
'td',
148+
{ role: 'gridcell',
149+
'aria-disabled': !isCurrentMonth,
150+
'aria-selected': isSelectedDay,
151+
autoFocus: this.props.focused,
152+
tabIndex: isCurrentMonth && isFirstDayOfMonth && this.props.focused ? 0 : -1,
153+
className: (isToday ? ' slds-is-today' : '') + (isCurrentMonth ? '' : ' slds-disabled-text') + (isSelectedDay ? ' slds-is-selected' : ''),
154+
onClick: this.handleClick,
155+
onMouseDown: this.handleClick,
156+
onKeyDown: this.handleKeyDown },
157+
_react2['default'].createElement(
158+
'span',
159+
{ className: 'slds-day' },
160+
this.props.date.getDate()
161+
)
162+
);
163+
},
164+
165+
componentDidUpdate: function componentDidUpdate(prevProps, prevState) {
166+
if (this.props.focused && !prevProps.focused) {
167+
this.setFocus();
168+
}
169+
}
170+
171+
});
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
/*
2+
Copyright (c) 2015, salesforce.com, inc. All rights reserved.
3+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
4+
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
5+
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.
6+
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.
7+
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.
8+
*/
9+
10+
'use strict';
11+
12+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
13+
14+
var _react = require('react');
15+
16+
var _react2 = _interopRequireDefault(_react);
17+
18+
var _SLDSCalendarDayIndex = require('../SLDSCalendarDay/index');
19+
20+
var _SLDSCalendarDayIndex2 = _interopRequireDefault(_SLDSCalendarDayIndex);
21+
22+
var _utils = require('../../../utils');
23+
24+
module.exports = _react2['default'].createClass({
25+
displayName: 'exports',
26+
27+
getDefaultProps: function getDefaultProps() {
28+
return {
29+
displayedDate: new Date(),
30+
selectedDate: new Date()
31+
};
32+
},
33+
34+
handleSelectDate: function handleSelectDate(day) {
35+
if (this.props.onSelectDate) {
36+
this.props.onSelectDate(day);
37+
}
38+
},
39+
40+
handleCancel: function handleCancel() {
41+
if (this.props.onCancel) {
42+
this.props.onCancel();
43+
}
44+
},
45+
46+
handlePrevDay: function handlePrevDay(date) {
47+
if (this.props.onPrevDay) {
48+
this.props.onPrevDay(date);
49+
}
50+
},
51+
52+
handleNextDay: function handleNextDay(date) {
53+
if (this.props.onNextDay) {
54+
this.props.onNextDay(date);
55+
}
56+
},
57+
58+
handlePrevWeek: function handlePrevWeek(date) {
59+
if (this.props.onPrevWeek) {
60+
this.props.onPrevWeek(date);
61+
}
62+
},
63+
64+
handleNextWeek: function handleNextWeek(date) {
65+
if (this.props.onNextWeek) {
66+
this.props.onNextWeek(date);
67+
}
68+
},
69+
70+
render: function render() {
71+
var days = [];
72+
var date = this.props.date;
73+
for (var i = 0; i < 7; i++) {
74+
days.push(_react2['default'].createElement(_SLDSCalendarDayIndex2['default'], {
75+
key: date.toString(),
76+
date: date,
77+
month: this.props.month,
78+
selectedDate: this.props.selectedDate,
79+
onSelectDate: this.handleSelectDate,
80+
displayedDate: this.props.displayedDate,
81+
highlightedDate: this.props.highlightedDate,
82+
focused: _utils.DateUtil.isSameDay(this.props.highlightedDate, date),
83+
onPrevDay: this.handlePrevDay,
84+
onNextDay: this.handleNextDay,
85+
onPrevWeek: this.handlePrevWeek,
86+
onNextWeek: this.handleNextWeek,
87+
onCancel: this.handleCancel }));
88+
date = _utils.DateUtil.addDays(date, 1);
89+
}
90+
91+
return _react2['default'].createElement(
92+
'tr',
93+
{ className: 'week', key: days[0].toString() },
94+
days
95+
);
96+
}
97+
});

0 commit comments

Comments
 (0)