-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.bundle.js
5485 lines (4477 loc) · 175 KB
/
server.bundle.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ exports: {},
/******/ id: moduleId,
/******/ loaded: false
/******/ };
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ // Flag the module as loaded
/******/ module.loaded = true;
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/ // Load entry module and return exports
/******/ return __webpack_require__(0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
var _express = __webpack_require__(1);
var _express2 = _interopRequireDefault(_express);
var _path = __webpack_require__(2);
var _path2 = _interopRequireDefault(_path);
var _compression = __webpack_require__(3);
var _compression2 = _interopRequireDefault(_compression);
var _morgan = __webpack_require__(4);
var _morgan2 = _interopRequireDefault(_morgan);
var _react = __webpack_require__(5);
var _react2 = _interopRequireDefault(_react);
var _server = __webpack_require__(6);
var _reactRouter = __webpack_require__(7);
var _routes = __webpack_require__(8);
var _routes2 = _interopRequireDefault(_routes);
var _configureStore = __webpack_require__(38);
var _configureStore2 = _interopRequireDefault(_configureStore);
var _reactRedux = __webpack_require__(11);
var _getMuiTheme = __webpack_require__(44);
var _getMuiTheme2 = _interopRequireDefault(_getMuiTheme);
var _MuiThemeProvider = __webpack_require__(101);
var _MuiThemeProvider2 = _interopRequireDefault(_MuiThemeProvider);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
process.env.NODE_ENV = 'production';
var app = (0, _express2.default)();
app.set('views', _path2.default.join(__dirname, 'public'));
app.set('view engine', 'ejs');
// serve our static stuff like index.css
app.use(_express2.default.static(_path2.default.join(__dirname, 'public')));
//This tells express to log via morgan and morgan to log in the "combined" pre-defined format
app.use((0, _morgan2.default)('combined'));
app.use((0, _compression2.default)());
// send all requests to index.html so browserHistory works
var routes = _routes2.default;
app.get('*', function (req, res) {
(0, _reactRouter.match)({ routes: routes, location: req.url }, function (err, redirect, props) {
if (err) {
res.status(500).send(err.message);
} else if (redirect) {
res.redirect(redirect.pathname + redirect.search);
} else if (props) {
// Compile an initial state
var preloadedState = { authentication: 'Admin' };
// Create a new Redux store instance
var store = (0, _configureStore2.default)(preloadedState);
global.navigator = {
userAgent: req.headers['user-agent']
};
console.log('>>>>>>>> navigator.userAgent');
console.log(navigator.userAgent);
var muiTheme = (0, _getMuiTheme2.default)({ userAgent: req.headers['user-agent'] });
// hey we made it!
var appHtml = (0, _server.renderToString)(_react2.default.createElement(
_MuiThemeProvider2.default,
{ muiTheme: muiTheme },
_react2.default.createElement(
_reactRedux.Provider,
{ store: store },
_react2.default.createElement(_reactRouter.RouterContext, props)
)
));
var fs = __webpack_require__(102);
fs.writeFile("RenderedReact.txt", appHtml, function (err) {
if (err) {
return console.log(err);
}
console.log("The file was saved!");
});
res.send(renderFullPage(appHtml, store.getState()));
} else {
res.status(404).send('Not Found');
}
});
});
function renderFullPage(html, preloadedState) {
return '\n <!doctype html>\n <html>\n <head>\n <title>Child Care Online Services</title>\n </head>\n <body>\n <div id="app">' + html + '</div>\n <script>\n window.__PRELOADED_STATE__ = ' + JSON.stringify(preloadedState) + '\n </script>\n <script src="login.js"></script>\n </body>\n </html>\n ';
}
var PORT = process.env.PORT || 8080;
process.env.NODE_ENV = 'production';
app.listen(PORT, function () {
console.log('process.env.NODE_ENV', process.env.NODE_ENV);
console.log('Production Express server running at localhost:' + PORT);
});
/***/ },
/* 1 */
/***/ function(module, exports) {
module.exports = require("express");
/***/ },
/* 2 */
/***/ function(module, exports) {
module.exports = require("path");
/***/ },
/* 3 */
/***/ function(module, exports) {
module.exports = require("compression");
/***/ },
/* 4 */
/***/ function(module, exports) {
module.exports = require("morgan");
/***/ },
/* 5 */
/***/ function(module, exports) {
module.exports = require("react");
/***/ },
/* 6 */
/***/ function(module, exports) {
module.exports = require("react-dom/server");
/***/ },
/* 7 */
/***/ function(module, exports) {
module.exports = require("react-router");
/***/ },
/* 8 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
var _react = __webpack_require__(5);
var _react2 = _interopRequireDefault(_react);
var _reactRouter = __webpack_require__(7);
var _App = __webpack_require__(9);
var _App2 = _interopRequireDefault(_App);
var _LoginContainer = __webpack_require__(10);
var _LoginContainer2 = _interopRequireDefault(_LoginContainer);
var _Dashboard = __webpack_require__(37);
var _Dashboard2 = _interopRequireDefault(_Dashboard);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
module.exports = _react2.default.createElement(
_reactRouter.Route,
{ path: '/', component: _App2.default },
_react2.default.createElement(_reactRouter.IndexRoute, { component: _LoginContainer2.default }),
_react2.default.createElement(_reactRouter.Route, { path: '/app', component: _Dashboard2.default })
);
/***/ },
/* 9 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
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 = __webpack_require__(5);
var _react2 = _interopRequireDefault(_react);
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; }
var App = function (_React$Component) {
_inherits(App, _React$Component);
function App() {
_classCallCheck(this, App);
return _possibleConstructorReturn(this, Object.getPrototypeOf(App).apply(this, arguments));
}
_createClass(App, [{
key: 'render',
value: function render() {
return _react2.default.createElement(
'div',
null,
_react2.default.createElement(
'h2',
null,
'This Home page act as ROOT Component.'
),
this.props.children
);
}
}]);
return App;
}(_react2.default.Component);
exports.default = App;
/***/ },
/* 10 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _reactRedux = __webpack_require__(11);
var _actions = __webpack_require__(12);
var _Login = __webpack_require__(14);
var _Login2 = _interopRequireDefault(_Login);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var mapStateToProps = function mapStateToProps(state) {
console.log(state);
return {
loggedInUser: state.authentication
};
};
var mapDispatchToProps = function mapDispatchToProps(dispatch) {
return {
onLoginClick: function onLoginClick(as) {
dispatch((0, _actions.loginAction)(as));
},
loginAsyncAction: function loginAsyncAction() {
dispatch((0, _actions.loginAsyncAction)());
}
};
};
var LoginContainer = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(_Login2.default);
exports.default = LoginContainer;
/***/ },
/* 11 */
/***/ function(module, exports) {
module.exports = require("react-redux");
/***/ },
/* 12 */
/***/ function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.loginAsyncAction = exports.loginAction = undefined;
var _constants = __webpack_require__(13);
var CONST = _interopRequireWildcard(_constants);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
var loginAction = exports.loginAction = function loginAction(loginAs) {
return {
type: CONST.LOGIN,
loginAs: loginAs
};
};
var loginAsyncAction = exports.loginAsyncAction = function loginAsyncAction() {
return function (dispatch) {
setTimeout(function () {
// Yay! Can invoke sync or async actions with `dispatch`
dispatch(loginAction("Async Admin"));
}, 1000);
};
};
/***/ },
/* 13 */
/***/ function(module, exports) {
module.exports = require("constants");
/***/ },
/* 14 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
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 = __webpack_require__(5);
var _react2 = _interopRequireDefault(_react);
var _FlatButton = __webpack_require__(15);
var _FlatButton2 = _interopRequireDefault(_FlatButton);
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; }
var Login = function (_React$Component) {
_inherits(Login, _React$Component);
function Login(props) {
_classCallCheck(this, Login);
return _possibleConstructorReturn(this, Object.getPrototypeOf(Login).call(this, props));
}
_createClass(Login, [{
key: 'render',
value: function render() {
var _this2 = this;
return _react2.default.createElement(
'div',
null,
_react2.default.createElement(
'h3',
null,
'Login Component. . . '
),
_react2.default.createElement(
'div',
null,
_react2.default.createElement(_FlatButton2.default, { onClick: function onClick() {
return _this2.props.onLoginClick("Admin");
}, label: 'Login As Admin', primary: true })
),
_react2.default.createElement(
'h4',
null,
'Loggen in As ',
this.props.loggedInUser
)
);
}
}]);
return Login;
}(_react2.default.Component);
exports.default = Login;
/***/ },
/* 15 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = undefined;
var _FlatButton = __webpack_require__(16);
var _FlatButton2 = _interopRequireDefault(_FlatButton);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.default = _FlatButton2.default;
/***/ },
/* 16 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
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; };
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 _simpleAssign = __webpack_require__(17);
var _simpleAssign2 = _interopRequireDefault(_simpleAssign);
var _react = __webpack_require__(5);
var _react2 = _interopRequireDefault(_react);
var _transitions = __webpack_require__(18);
var _transitions2 = _interopRequireDefault(_transitions);
var _childUtils = __webpack_require__(19);
var _colorManipulator = __webpack_require__(21);
var _EnhancedButton = __webpack_require__(22);
var _EnhancedButton2 = _interopRequireDefault(_EnhancedButton);
var _FlatButtonLabel = __webpack_require__(36);
var _FlatButtonLabel2 = _interopRequireDefault(_FlatButtonLabel);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
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; }
function validateLabel(props, propName, componentName) {
if (!props.children && !props.label && !props.icon) {
return new Error('Required prop label or children or icon was not specified in ' + componentName + '.');
}
}
var FlatButton = function (_Component) {
_inherits(FlatButton, _Component);
function FlatButton() {
var _Object$getPrototypeO;
var _temp, _this, _ret;
_classCallCheck(this, FlatButton);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_Object$getPrototypeO = Object.getPrototypeOf(FlatButton)).call.apply(_Object$getPrototypeO, [this].concat(args))), _this), _this.state = {
hovered: false,
isKeyboardFocused: false,
touch: false
}, _this.handleKeyboardFocus = function (event, isKeyboardFocused) {
_this.setState({ isKeyboardFocused: isKeyboardFocused });
_this.props.onKeyboardFocus(event, isKeyboardFocused);
}, _this.handleMouseEnter = function (event) {
// Cancel hover styles for touch devices
if (!_this.state.touch) _this.setState({ hovered: true });
_this.props.onMouseEnter(event);
}, _this.handleMouseLeave = function (event) {
_this.setState({ hovered: false });
_this.props.onMouseLeave(event);
}, _this.handleTouchStart = function (event) {
_this.setState({ touch: true });
_this.props.onTouchStart(event);
}, _temp), _possibleConstructorReturn(_this, _ret);
}
_createClass(FlatButton, [{
key: 'render',
value: function render() {
var _props = this.props;
var children = _props.children;
var disabled = _props.disabled;
var hoverColor = _props.hoverColor;
var backgroundColor = _props.backgroundColor;
var icon = _props.icon;
var label = _props.label;
var labelStyle = _props.labelStyle;
var labelPosition = _props.labelPosition;
var linkButton = _props.linkButton;
var primary = _props.primary;
var rippleColor = _props.rippleColor;
var secondary = _props.secondary;
var style = _props.style;
var other = _objectWithoutProperties(_props, ['children', 'disabled', 'hoverColor', 'backgroundColor', 'icon', 'label', 'labelStyle', 'labelPosition', 'linkButton', 'primary', 'rippleColor', 'secondary', 'style']);
var _context$muiTheme = this.context.muiTheme;
var _context$muiTheme$but = _context$muiTheme.button;
var buttonHeight = _context$muiTheme$but.height;
var buttonMinWidth = _context$muiTheme$but.minWidth;
var buttonTextTransform = _context$muiTheme$but.textTransform;
var _context$muiTheme$fla = _context$muiTheme.flatButton;
var buttonFilterColor = _context$muiTheme$fla.buttonFilterColor;
var buttonColor = _context$muiTheme$fla.color;
var disabledTextColor = _context$muiTheme$fla.disabledTextColor;
var fontSize = _context$muiTheme$fla.fontSize;
var fontWeight = _context$muiTheme$fla.fontWeight;
var primaryTextColor = _context$muiTheme$fla.primaryTextColor;
var secondaryTextColor = _context$muiTheme$fla.secondaryTextColor;
var textColor = _context$muiTheme$fla.textColor;
var _context$muiTheme$fla2 = _context$muiTheme$fla.textTransform;
var textTransform = _context$muiTheme$fla2 === undefined ? buttonTextTransform || 'uppercase' : _context$muiTheme$fla2;
var defaultTextColor = disabled ? disabledTextColor : primary ? primaryTextColor : secondary ? secondaryTextColor : textColor;
var defaultHoverColor = (0, _colorManipulator.fade)(buttonFilterColor, 0.2);
var defaultRippleColor = buttonFilterColor;
var buttonHoverColor = hoverColor || defaultHoverColor;
var buttonRippleColor = rippleColor || defaultRippleColor;
var buttonBackgroundColor = backgroundColor || buttonColor;
var hovered = (this.state.hovered || this.state.isKeyboardFocused) && !disabled;
var mergedRootStyles = (0, _simpleAssign2.default)({}, {
height: buttonHeight,
lineHeight: buttonHeight + 'px',
minWidth: buttonMinWidth,
color: defaultTextColor,
transition: _transitions2.default.easeOut(),
borderRadius: 2,
userSelect: 'none',
position: 'relative',
overflow: 'hidden',
backgroundColor: hovered ? buttonHoverColor : buttonBackgroundColor,
padding: 0,
margin: 0,
textAlign: 'center'
}, style);
var iconCloned = void 0;
var labelStyleIcon = {};
if (icon) {
iconCloned = _react2.default.cloneElement(icon, {
color: mergedRootStyles.color,
style: {
verticalAlign: 'middle',
marginLeft: label && labelPosition !== 'before' ? 12 : 0,
marginRight: label && labelPosition === 'before' ? 12 : 0
}
});
if (labelPosition === 'before') {
labelStyleIcon.paddingRight = 8;
} else {
labelStyleIcon.paddingLeft = 8;
}
}
var mergedLabelStyles = (0, _simpleAssign2.default)({
letterSpacing: 0,
textTransform: textTransform,
fontWeight: fontWeight,
fontSize: fontSize
}, labelStyleIcon, labelStyle);
var labelElement = label ? _react2.default.createElement(_FlatButtonLabel2.default, { label: label, style: mergedLabelStyles }) : undefined;
// Place label before or after children.
var childrenFragment = labelPosition === 'before' ? {
labelElement: labelElement,
iconCloned: iconCloned,
children: children
} : {
children: children,
iconCloned: iconCloned,
labelElement: labelElement
};
var enhancedButtonChildren = (0, _childUtils.createChildFragment)(childrenFragment);
return _react2.default.createElement(
_EnhancedButton2.default,
_extends({}, other, {
disabled: disabled,
focusRippleColor: buttonRippleColor,
focusRippleOpacity: 0.3,
linkButton: linkButton,
onKeyboardFocus: this.handleKeyboardFocus,
onMouseLeave: this.handleMouseLeave,
onMouseEnter: this.handleMouseEnter,
onTouchStart: this.handleTouchStart,
style: mergedRootStyles,
touchRippleColor: buttonRippleColor,
touchRippleOpacity: 0.3
}),
enhancedButtonChildren
);
}
}]);
return FlatButton;
}(_react.Component);
FlatButton.muiName = 'FlatButton';
FlatButton.propTypes = {
/**
* Color of button when mouse is not hovering over it.
*/
backgroundColor: _react.PropTypes.string,
/**
* This is what will be displayed inside the button.
* If a label is specified, the text within the label prop will
* be displayed. Otherwise, the component will expect children
* which will then be displayed. (In our example,
* we are nesting an `<input type="file" />` and a `span`
* that acts as our label to be displayed.) This only
* applies to flat and raised buttons.
*/
children: _react.PropTypes.node,
/**
* Disables the button if set to true.
*/
disabled: _react.PropTypes.bool,
/**
* Color of button when mouse hovers over.
*/
hoverColor: _react.PropTypes.string,
/**
* URL to link to when button clicked if `linkButton` is set to true.
*/
href: _react.PropTypes.string,
/**
* Use this property to display an icon.
*/
icon: _react.PropTypes.node,
/**
* Label for the button.
*/
label: validateLabel,
/**
* Place label before or after the passed children.
*/
labelPosition: _react.PropTypes.oneOf(['before', 'after']),
/**
* Override the inline-styles of the button's label element.
*/
labelStyle: _react.PropTypes.object,
/**
* Enables use of `href` property to provide a URL to link to if set to true.
*/
linkButton: _react.PropTypes.bool,
/**
* Callback function fired when the element is focused or blurred by the keyboard.
*
* @param {object} event `focus` or `blur` event targeting the element.
* @param {boolean} isKeyboardFocused Indicates whether the element is focused.
*/
onKeyboardFocus: _react.PropTypes.func,
/**
* Callback function fired when the mouse enters the element.
*
* @param {object} event `mouseenter` event targeting the element.
*/
onMouseEnter: _react.PropTypes.func,
/**
* Callback function fired when the mouse leaves the element.
*
* @param {object} event `mouseleave` event targeting the element.
*/
onMouseLeave: _react.PropTypes.func,
/**
* Callback function fired when the element is touched.
*
* @param {object} event `touchstart` event targeting the element.
*/
onTouchStart: _react.PropTypes.func,
/**
* If true, colors button according to
* primaryTextColor from the Theme.
*/
primary: _react.PropTypes.bool,
/**
* Color for the ripple after button is clicked.
*/
rippleColor: _react.PropTypes.string,
/**
* If true, colors button according to secondaryTextColor from the theme.
* The primary prop has precendent if set to true.
*/
secondary: _react.PropTypes.bool,
/**
* Override the inline-styles of the root element.
*/
style: _react.PropTypes.object
};
FlatButton.defaultProps = {
disabled: false,
labelStyle: {},
labelPosition: 'after',
onKeyboardFocus: function onKeyboardFocus() {},
onMouseEnter: function onMouseEnter() {},
onMouseLeave: function onMouseLeave() {},
onTouchStart: function onTouchStart() {},
primary: false,
secondary: false
};
FlatButton.contextTypes = {
muiTheme: _react.PropTypes.object.isRequired
};
exports.default = FlatButton;
/***/ },
/* 17 */
/***/ function(module, exports) {
module.exports = require("simple-assign");
/***/ },
/* 18 */
/***/ function(module, exports) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = {
easeOutFunction: 'cubic-bezier(0.23, 1, 0.32, 1)',
easeInOutFunction: 'cubic-bezier(0.445, 0.05, 0.55, 0.95)',
easeOut: function easeOut(duration, property, delay, easeFunction) {
easeFunction = easeFunction || this.easeOutFunction;
if (property && Object.prototype.toString.call(property) === '[object Array]') {
var transitions = '';
for (var i = 0; i < property.length; i++) {
if (transitions) transitions += ',';
transitions += this.create(duration, property[i], delay, easeFunction);
}
return transitions;
} else {
return this.create(duration, property, delay, easeFunction);
}
},
create: function create(duration, property, delay, easeFunction) {
duration = duration || '450ms';
property = property || 'all';
delay = delay || '0ms';
easeFunction = easeFunction || 'linear';
return property + ' ' + duration + ' ' + easeFunction + ' ' + delay;
}
};
/***/ },
/* 19 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.createChildFragment = createChildFragment;
exports.extendChildren = extendChildren;
var _react = __webpack_require__(5);
var _react2 = _interopRequireDefault(_react);
var _reactAddonsCreateFragment = __webpack_require__(20);
var _reactAddonsCreateFragment2 = _interopRequireDefault(_reactAddonsCreateFragment);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function createChildFragment(fragments) {
var newFragments = {};
var validChildrenCount = 0;
var firstKey = void 0;
// Only create non-empty key fragments
for (var key in fragments) {
var currentChild = fragments[key];
if (currentChild) {
if (validChildrenCount === 0) firstKey = key;
newFragments[key] = currentChild;
validChildrenCount++;
}
}
if (validChildrenCount === 0) return undefined;
if (validChildrenCount === 1) return newFragments[firstKey];
return (0, _reactAddonsCreateFragment2.default)(newFragments);
}
function extendChildren(children, extendedProps, extendedChildren) {
return _react2.default.isValidElement(children) ? _react2.default.Children.map(children, function (child) {
var newProps = typeof extendedProps === 'function' ? extendedProps(child) : extendedProps;
var newChildren = typeof extendedChildren === 'function' ? extendedChildren(child) : extendedChildren ? extendedChildren : child.props.children;
return _react2.default.cloneElement(child, newProps, newChildren);
}) : children;
}
/***/ },
/* 20 */
/***/ function(module, exports) {
module.exports = require("react-addons-create-fragment");
/***/ },
/* 21 */
/***/ function(module, exports) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.convertColorToString = convertColorToString;
exports.convertHexToRGB = convertHexToRGB;
exports.decomposeColor = decomposeColor;
exports.getContrastRatio = getContrastRatio;
exports.getLuminance = getLuminance;
exports.emphasize = emphasize;
exports.fade = fade;
exports.darken = darken;
exports.lighten = lighten;
/**
* Returns a number whose value is limited to the given range.
*
* @param {number} value The value to be clamped
* @param {number} min The lower boundary of the output range
* @param {number} max The upper boundary of the output range
* @returns {number} A number in the range [min, max]
*/
function clamp(value, min, max) {
if (value < min) {
return min;
}
if (value > max) {
return max;
}
return value;
}
/**
* Converts a color object with type and values to a string.
*
* @param {object} color - Decomposed color
* @param {string} color.type - One of, 'rgb', 'rgba', 'hsl', 'hsla'
* @param {array} color.values - [n,n,n] or [n,n,n,n]
* @returns {string} A CSS color string
*/
function convertColorToString(color) {
var type = color.type;
var values = color.values;
if (type.indexOf('rgb') > -1) {
// Only convert the first 3 values to int (i.e. not alpha)
for (var i = 0; i < 3; i++) {
values[i] = parseInt(values[i]);
}
}
var colorString = void 0;
if (type.indexOf('hsl') > -1) {
colorString = color.type + '(' + values[0] + ', ' + values[1] + '%, ' + values[2] + '%';
} else {
colorString = color.type + '(' + values[0] + ', ' + values[1] + ', ' + values[2];
}
if (values.length === 4) {
colorString += ', ' + color.values[3] + ')';
} else {
colorString += ')';
}
return colorString;
}
/**
* Converts a color from CSS hex format to CSS rgb format.
*
* @param {string} color - Hex color, i.e. #nnn or #nnnnnn
* @returns {string} A CSS rgb color string
*/
function convertHexToRGB(color) {
if (color.length === 4) {
var extendedColor = '#';
for (var i = 1; i < color.length; i++) {
extendedColor += color.charAt(i) + color.charAt(i);
}
color = extendedColor;
}
var values = {
r: parseInt(color.substr(1, 2), 16),
g: parseInt(color.substr(3, 2), 16),
b: parseInt(color.substr(5, 2), 16)
};
return 'rgb(' + values.r + ', ' + values.g + ', ' + values.b + ')';
}
/**
* Returns an object with the type and values of a color.
*
* Note: Does not support rgb % values.
*
* @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla()
* @returns {{type: string, values: number[]}} A MUI color object