UNPKG

20 kBJavaScriptView Raw
1module.exports =
2/******/ (function(modules) { // webpackBootstrap
3/******/ // The module cache
4/******/ var installedModules = {};
5
6/******/ // The require function
7/******/ function __webpack_require__(moduleId) {
8
9/******/ // Check if module is in cache
10/******/ if(installedModules[moduleId])
11/******/ return installedModules[moduleId].exports;
12
13/******/ // Create a new module (and put it into the cache)
14/******/ var module = installedModules[moduleId] = {
15/******/ exports: {},
16/******/ id: moduleId,
17/******/ loaded: false
18/******/ };
19
20/******/ // Execute the module function
21/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
22
23/******/ // Flag the module as loaded
24/******/ module.loaded = true;
25
26/******/ // Return the exports of the module
27/******/ return module.exports;
28/******/ }
29
30
31/******/ // expose the modules object (__webpack_modules__)
32/******/ __webpack_require__.m = modules;
33
34/******/ // expose the module cache
35/******/ __webpack_require__.c = installedModules;
36
37/******/ // __webpack_public_path__
38/******/ __webpack_require__.p = "/";
39
40/******/ // Load entry module and return exports
41/******/ return __webpack_require__(0);
42/******/ })
43/************************************************************************/
44/******/ ([
45/* 0 */
46/***/ function(module, exports, __webpack_require__) {
47
48 "use strict";
49
50 var React = __webpack_require__(1);
51 var ReactDOM = __webpack_require__(2);
52 var _ = __webpack_require__(3);
53 var cx = __webpack_require__(4);
54
55 var api = __webpack_require__(5);
56 var Result = __webpack_require__(7);
57
58 module.exports = React.createClass({
59 displayName: "exports",
60
61 getInitialState: function getInitialState() {
62 return {
63 x: 0,
64 y: 0,
65 mouseX: 0,
66 mouseY: 0,
67 show: false,
68 searchPredicate: "",
69
70 source: null,
71 dataset: null,
72 searchBy: "name",
73 imageBy: "name",
74 showRemove: false,
75 placeholder: null,
76 callback: null
77 };
78 },
79 componentWillMount: function componentWillMount() {
80 __webpack_require__(8);
81 },
82 componentDidMount: function componentDidMount() {
83 window.addEventListener("click", this.handleOutsideClick, false);
84 window.addEventListener("mousemove", this.handleMouseMove, false);
85 api.on("show", this.handleShow);
86 },
87 componentWillUnmount: function componentWillUnmount() {
88 window.removeEventListener("click", this.handleOutsideClick, false);
89 window.removeEventListener("mousemove", this.handleMouseMove, false);
90 api.off("show");
91 },
92 handleSearchChange: function handleSearchChange(event) {
93 this.setState({ searchPredicate: event.target.value.toLowerCase() });
94 },
95 handleSelect: function handleSelect(item) {
96 if (this.state.callback) this.state.callback(item);
97 this.hide();
98 },
99 handleShow: function handleShow(source, dataset, searchBy, imageBy, showRemove, placeholder, callback) {
100 this.setState({
101 x: this.state.mouseX,
102 y: this.state.mouseY,
103 show: true,
104 source: source,
105 dataset: dataset,
106 searchBy: searchBy,
107 imageBy: imageBy,
108 showRemove: showRemove,
109 placeholder: placeholder,
110 callback: callback,
111 searchPredicate: ""
112 });
113 },
114 handleOutsideClick: function handleOutsideClick(event) {
115 if (!this.state.show) return;
116 if (this.refs.main.contains(event.target)) return;
117 if (this.state.source.contains(event.target)) return;
118 this.hide();
119 },
120 handleMouseMove: function handleMouseMove(event) {
121 this.setState({
122 mouseX: event.pageX,
123 mouseY: event.pageY
124 });
125 },
126 hide: function hide() {
127 this.setState({
128 show: false
129 });
130 },
131 render: function render() {
132 var _this = this;
133
134 // Filter results by search criteria
135 var results = _.sortBy(_.filter(this.state.dataset, function (item) {
136 var criteria = item[_this.state.searchBy];
137 if (typeof criteria === "function") criteria = criteria();
138
139 return _.startsWith(_.toLower(criteria), _this.state.searchPredicate);
140 }), this.state.searchBy);
141 var className = cx("component-searchableModal", { show: this.state.show });
142
143 return React.createElement(
144 "div",
145 { ref: "main", className: className, style: { left: this.state.x, top: this.state.y } },
146 React.createElement("input", {
147 type: "text",
148 value: this.state.searchPredicate,
149 onChange: this.handleSearchChange,
150 placeholder: this.state.placeholder || "Search..."
151 }),
152 results.length ? React.createElement(
153 "div",
154 { className: "results" },
155 this.state.showRemove ? React.createElement(Result, {
156 data: null,
157 image: __webpack_require__(12),
158 label: "Remove",
159 key: -1,
160 onSelect: this.handleSelect
161 }) : null,
162 results.map(function (result, index) {
163 var label = result[_this.state.searchBy];
164 if (typeof label === "function") label = label.bind(result)();
165
166 var image = _this.state.imageBy ? result[_this.state.imageBy] : null;
167 if (typeof image === "function") image = image.bind(result)();
168
169 return React.createElement(Result, {
170 data: result,
171 label: label,
172 image: image,
173 key: index,
174 onSelect: _this.handleSelect
175 });
176 })
177 ) : React.createElement(
178 "div",
179 { className: "resultsEmptyState" },
180 "No results."
181 )
182 );
183 }
184 });
185 module.exports.api = api;
186
187/***/ },
188/* 1 */
189/***/ function(module, exports) {
190
191 module.exports = require("react");
192
193/***/ },
194/* 2 */
195/***/ function(module, exports) {
196
197 module.exports = require("react-dom");
198
199/***/ },
200/* 3 */
201/***/ function(module, exports) {
202
203 module.exports = require("lodash");
204
205/***/ },
206/* 4 */
207/***/ function(module, exports) {
208
209 module.exports = require("classnames");
210
211/***/ },
212/* 5 */
213/***/ function(module, exports, __webpack_require__) {
214
215 "use strict";
216
217 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; }; }();
218
219 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
220
221 var Events = __webpack_require__(6);
222
223 var SearchableModalApi = function () {
224 function SearchableModalApi() {
225 _classCallCheck(this, SearchableModalApi);
226 }
227
228 _createClass(SearchableModalApi, [{
229 key: "show",
230 value: function show(source, dataset, searchBy, imageBy, showRemove, placeholder, callback) {
231 this.trigger("show", source, dataset, searchBy, imageBy, showRemove, placeholder, callback);
232 }
233 }]);
234
235 return SearchableModalApi;
236 }();
237
238 var api = new SearchableModalApi();
239 Events.createEmitter(api);
240 module.exports = api;
241
242/***/ },
243/* 6 */
244/***/ function(module, exports) {
245
246 module.exports = require("ampersand-events");
247
248/***/ },
249/* 7 */
250/***/ function(module, exports, __webpack_require__) {
251
252 "use strict";
253
254 var React = __webpack_require__(1);
255
256 module.exports = React.createClass({
257 displayName: "exports",
258
259 propTypes: {
260 onSelect: React.PropTypes.func.isRequired,
261
262 data: React.PropTypes.any,
263 image: React.PropTypes.string,
264 label: React.PropTypes.string
265 },
266 handleClick: function handleClick() {
267 this.props.onSelect(this.props.data);
268 },
269 render: function render() {
270 return React.createElement(
271 "div",
272 { className: "result", onClick: this.handleClick },
273 this.props.image ? React.createElement("img", { src: this.props.image }) : null,
274 this.props.label ? React.createElement(
275 "div",
276 { className: "label" },
277 this.props.label
278 ) : null
279 );
280 }
281 });
282
283/***/ },
284/* 8 */
285/***/ function(module, exports, __webpack_require__) {
286
287 // style-loader: Adds some css to the DOM by adding a <style> tag
288
289 // load the styles
290 var content = __webpack_require__(9);
291 if(typeof content === 'string') content = [[module.id, content, '']];
292 // add the styles to the DOM
293 var update = __webpack_require__(11)(content, {});
294 if(content.locals) module.exports = content.locals;
295 // Hot Module Replacement
296 if(false) {
297 // When the styles change, update the <style> tags
298 if(!content.locals) {
299 module.hot.accept("!!./../../node_modules/css-loader/index.js!./../../node_modules/sass-loader/index.js!./style.scss", function() {
300 var newContent = require("!!./../../node_modules/css-loader/index.js!./../../node_modules/sass-loader/index.js!./style.scss");
301 if(typeof newContent === 'string') newContent = [[module.id, newContent, '']];
302 update(newContent);
303 });
304 }
305 // When the module is disposed, remove the <style> tags
306 module.hot.dispose(function() { update(); });
307 }
308
309/***/ },
310/* 9 */
311/***/ function(module, exports, __webpack_require__) {
312
313 exports = module.exports = __webpack_require__(10)();
314 // imports
315
316
317 // module
318 exports.push([module.id, ".component-searchableModal {\n width: 275px;\n height: 300px;\n overflow: hidden;\n position: absolute;\n z-index: 4000;\n pointer-events: none;\n background-color: white;\n color: #14083f;\n font-size: 10px;\n letter-spacing: 0.05em;\n opacity: 0;\n transition: opacity 0.05s;\n box-shadow: 0px 0px 5px 4px rgba(0, 0, 0, 0.25); }\n .component-searchableModal.show {\n opacity: 1;\n pointer-events: initial; }\n .component-searchableModal input {\n width: calc(100% - 16px);\n font-size: 14px;\n font-family: inherit;\n color: inherit;\n padding: 10px 8px;\n border: none;\n border-bottom: 1px solid rgba(20, 8, 63, 0.25);\n outline: 0; }\n .component-searchableModal .results {\n height: 262px;\n overflow-y: scroll; }\n .component-searchableModal .resultsEmptyState {\n width: 100%;\n margin-top: 25px;\n text-align: center;\n color: rgba(20, 8, 63, 0.5); }\n .component-searchableModal .result {\n cursor: pointer;\n display: block;\n overflow: hidden;\n padding: 6px;\n height: 26px; }\n .component-searchableModal .result:hover {\n background-color: #1c155b;\n color: white; }\n .component-searchableModal .result .label {\n width: calc(100% - 48px);\n font-size: 11px;\n text-overflow: ellipsis;\n overflow: hidden;\n white-space: nowrap;\n display: inline-block;\n vertical-align: top;\n height: 26px;\n line-height: 26px;\n margin: 0 10px; }\n .component-searchableModal .result img {\n width: 26px;\n height: 26px;\n border-radius: 5px; }\n", ""]);
319
320 // exports
321
322
323/***/ },
324/* 10 */
325/***/ function(module, exports) {
326
327 /*
328 MIT License http://www.opensource.org/licenses/mit-license.php
329 Author Tobias Koppers @sokra
330 */
331 // css base code, injected by the css-loader
332 module.exports = function() {
333 var list = [];
334
335 // return the list of modules as css string
336 list.toString = function toString() {
337 var result = [];
338 for(var i = 0; i < this.length; i++) {
339 var item = this[i];
340 if(item[2]) {
341 result.push("@media " + item[2] + "{" + item[1] + "}");
342 } else {
343 result.push(item[1]);
344 }
345 }
346 return result.join("");
347 };
348
349 // import a list of modules into the list
350 list.i = function(modules, mediaQuery) {
351 if(typeof modules === "string")
352 modules = [[null, modules, ""]];
353 var alreadyImportedModules = {};
354 for(var i = 0; i < this.length; i++) {
355 var id = this[i][0];
356 if(typeof id === "number")
357 alreadyImportedModules[id] = true;
358 }
359 for(i = 0; i < modules.length; i++) {
360 var item = modules[i];
361 // skip already imported module
362 // this implementation is not 100% perfect for weird media query combinations
363 // when a module is imported multiple times with different media queries.
364 // I hope this will never occur (Hey this way we have smaller bundles)
365 if(typeof item[0] !== "number" || !alreadyImportedModules[item[0]]) {
366 if(mediaQuery && !item[2]) {
367 item[2] = mediaQuery;
368 } else if(mediaQuery) {
369 item[2] = "(" + item[2] + ") and (" + mediaQuery + ")";
370 }
371 list.push(item);
372 }
373 }
374 };
375 return list;
376 };
377
378
379/***/ },
380/* 11 */
381/***/ function(module, exports, __webpack_require__) {
382
383 /*
384 MIT License http://www.opensource.org/licenses/mit-license.php
385 Author Tobias Koppers @sokra
386 */
387 var stylesInDom = {},
388 memoize = function(fn) {
389 var memo;
390 return function () {
391 if (typeof memo === "undefined") memo = fn.apply(this, arguments);
392 return memo;
393 };
394 },
395 isOldIE = memoize(function() {
396 return /msie [6-9]\b/.test(window.navigator.userAgent.toLowerCase());
397 }),
398 getHeadElement = memoize(function () {
399 return document.head || document.getElementsByTagName("head")[0];
400 }),
401 singletonElement = null,
402 singletonCounter = 0,
403 styleElementsInsertedAtTop = [];
404
405 module.exports = function(list, options) {
406 if(false) {
407 if(typeof document !== "object") throw new Error("The style-loader cannot be used in a non-browser environment");
408 }
409
410 options = options || {};
411 // Force single-tag solution on IE6-9, which has a hard limit on the # of <style>
412 // tags it will allow on a page
413 if (typeof options.singleton === "undefined") options.singleton = isOldIE();
414
415 // By default, add <style> tags to the bottom of <head>.
416 if (typeof options.insertAt === "undefined") options.insertAt = "bottom";
417
418 var styles = listToStyles(list);
419 addStylesToDom(styles, options);
420
421 return function update(newList) {
422 var mayRemove = [];
423 for(var i = 0; i < styles.length; i++) {
424 var item = styles[i];
425 var domStyle = stylesInDom[item.id];
426 domStyle.refs--;
427 mayRemove.push(domStyle);
428 }
429 if(newList) {
430 var newStyles = listToStyles(newList);
431 addStylesToDom(newStyles, options);
432 }
433 for(var i = 0; i < mayRemove.length; i++) {
434 var domStyle = mayRemove[i];
435 if(domStyle.refs === 0) {
436 for(var j = 0; j < domStyle.parts.length; j++)
437 domStyle.parts[j]();
438 delete stylesInDom[domStyle.id];
439 }
440 }
441 };
442 }
443
444 function addStylesToDom(styles, options) {
445 for(var i = 0; i < styles.length; i++) {
446 var item = styles[i];
447 var domStyle = stylesInDom[item.id];
448 if(domStyle) {
449 domStyle.refs++;
450 for(var j = 0; j < domStyle.parts.length; j++) {
451 domStyle.parts[j](item.parts[j]);
452 }
453 for(; j < item.parts.length; j++) {
454 domStyle.parts.push(addStyle(item.parts[j], options));
455 }
456 } else {
457 var parts = [];
458 for(var j = 0; j < item.parts.length; j++) {
459 parts.push(addStyle(item.parts[j], options));
460 }
461 stylesInDom[item.id] = {id: item.id, refs: 1, parts: parts};
462 }
463 }
464 }
465
466 function listToStyles(list) {
467 var styles = [];
468 var newStyles = {};
469 for(var i = 0; i < list.length; i++) {
470 var item = list[i];
471 var id = item[0];
472 var css = item[1];
473 var media = item[2];
474 var sourceMap = item[3];
475 var part = {css: css, media: media, sourceMap: sourceMap};
476 if(!newStyles[id])
477 styles.push(newStyles[id] = {id: id, parts: [part]});
478 else
479 newStyles[id].parts.push(part);
480 }
481 return styles;
482 }
483
484 function insertStyleElement(options, styleElement) {
485 var head = getHeadElement();
486 var lastStyleElementInsertedAtTop = styleElementsInsertedAtTop[styleElementsInsertedAtTop.length - 1];
487 if (options.insertAt === "top") {
488 if(!lastStyleElementInsertedAtTop) {
489 head.insertBefore(styleElement, head.firstChild);
490 } else if(lastStyleElementInsertedAtTop.nextSibling) {
491 head.insertBefore(styleElement, lastStyleElementInsertedAtTop.nextSibling);
492 } else {
493 head.appendChild(styleElement);
494 }
495 styleElementsInsertedAtTop.push(styleElement);
496 } else if (options.insertAt === "bottom") {
497 head.appendChild(styleElement);
498 } else {
499 throw new Error("Invalid value for parameter 'insertAt'. Must be 'top' or 'bottom'.");
500 }
501 }
502
503 function removeStyleElement(styleElement) {
504 styleElement.parentNode.removeChild(styleElement);
505 var idx = styleElementsInsertedAtTop.indexOf(styleElement);
506 if(idx >= 0) {
507 styleElementsInsertedAtTop.splice(idx, 1);
508 }
509 }
510
511 function createStyleElement(options) {
512 var styleElement = document.createElement("style");
513 styleElement.type = "text/css";
514 insertStyleElement(options, styleElement);
515 return styleElement;
516 }
517
518 function createLinkElement(options) {
519 var linkElement = document.createElement("link");
520 linkElement.rel = "stylesheet";
521 insertStyleElement(options, linkElement);
522 return linkElement;
523 }
524
525 function addStyle(obj, options) {
526 var styleElement, update, remove;
527
528 if (options.singleton) {
529 var styleIndex = singletonCounter++;
530 styleElement = singletonElement || (singletonElement = createStyleElement(options));
531 update = applyToSingletonTag.bind(null, styleElement, styleIndex, false);
532 remove = applyToSingletonTag.bind(null, styleElement, styleIndex, true);
533 } else if(obj.sourceMap &&
534 typeof URL === "function" &&
535 typeof URL.createObjectURL === "function" &&
536 typeof URL.revokeObjectURL === "function" &&
537 typeof Blob === "function" &&
538 typeof btoa === "function") {
539 styleElement = createLinkElement(options);
540 update = updateLink.bind(null, styleElement);
541 remove = function() {
542 removeStyleElement(styleElement);
543 if(styleElement.href)
544 URL.revokeObjectURL(styleElement.href);
545 };
546 } else {
547 styleElement = createStyleElement(options);
548 update = applyToTag.bind(null, styleElement);
549 remove = function() {
550 removeStyleElement(styleElement);
551 };
552 }
553
554 update(obj);
555
556 return function updateStyle(newObj) {
557 if(newObj) {
558 if(newObj.css === obj.css && newObj.media === obj.media && newObj.sourceMap === obj.sourceMap)
559 return;
560 update(obj = newObj);
561 } else {
562 remove();
563 }
564 };
565 }
566
567 var replaceText = (function () {
568 var textStore = [];
569
570 return function (index, replacement) {
571 textStore[index] = replacement;
572 return textStore.filter(Boolean).join('\n');
573 };
574 })();
575
576 function applyToSingletonTag(styleElement, index, remove, obj) {
577 var css = remove ? "" : obj.css;
578
579 if (styleElement.styleSheet) {
580 styleElement.styleSheet.cssText = replaceText(index, css);
581 } else {
582 var cssNode = document.createTextNode(css);
583 var childNodes = styleElement.childNodes;
584 if (childNodes[index]) styleElement.removeChild(childNodes[index]);
585 if (childNodes.length) {
586 styleElement.insertBefore(cssNode, childNodes[index]);
587 } else {
588 styleElement.appendChild(cssNode);
589 }
590 }
591 }
592
593 function applyToTag(styleElement, obj) {
594 var css = obj.css;
595 var media = obj.media;
596
597 if(media) {
598 styleElement.setAttribute("media", media)
599 }
600
601 if(styleElement.styleSheet) {
602 styleElement.styleSheet.cssText = css;
603 } else {
604 while(styleElement.firstChild) {
605 styleElement.removeChild(styleElement.firstChild);
606 }
607 styleElement.appendChild(document.createTextNode(css));
608 }
609 }
610
611 function updateLink(linkElement, obj) {
612 var css = obj.css;
613 var sourceMap = obj.sourceMap;
614
615 if(sourceMap) {
616 // http://stackoverflow.com/a/26603875
617 css += "\n/*# sourceMappingURL=data:application/json;base64," + btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))) + " */";
618 }
619
620 var blob = new Blob([css], { type: "text/css" });
621
622 var oldSrc = linkElement.href;
623
624 linkElement.href = URL.createObjectURL(blob);
625
626 if(oldSrc)
627 URL.revokeObjectURL(oldSrc);
628 }
629
630
631/***/ },
632/* 12 */
633/***/ function(module, exports, __webpack_require__) {
634
635 module.exports = __webpack_require__.p + "960a01c4f59fa6d466d4ea4ce1d30ae0.svg";
636
637/***/ }
638/******/ ]);
\No newline at end of file