1 | (function (global, factory) {
|
2 | typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('react'), require('glamor')) :
|
3 | typeof define === 'function' && define.amd ? define(['react', 'glamor'], factory) :
|
4 | (global.glamorous = factory(global.React,global.Glamor));
|
5 | }(this, (function (React,glamor) { 'use strict';
|
6 |
|
7 | React = React && React.hasOwnProperty('default') ? React['default'] : React;
|
8 |
|
9 | var htmlTagNames = [
|
10 | "a",
|
11 | "abbr",
|
12 | "acronym",
|
13 | "address",
|
14 | "applet",
|
15 | "area",
|
16 | "article",
|
17 | "aside",
|
18 | "audio",
|
19 | "b",
|
20 | "base",
|
21 | "basefont",
|
22 | "bdi",
|
23 | "bdo",
|
24 | "bgsound",
|
25 | "big",
|
26 | "blink",
|
27 | "blockquote",
|
28 | "body",
|
29 | "br",
|
30 | "button",
|
31 | "canvas",
|
32 | "caption",
|
33 | "center",
|
34 | "cite",
|
35 | "code",
|
36 | "col",
|
37 | "colgroup",
|
38 | "command",
|
39 | "content",
|
40 | "data",
|
41 | "datalist",
|
42 | "dd",
|
43 | "del",
|
44 | "details",
|
45 | "dfn",
|
46 | "dialog",
|
47 | "dir",
|
48 | "div",
|
49 | "dl",
|
50 | "dt",
|
51 | "element",
|
52 | "em",
|
53 | "embed",
|
54 | "fieldset",
|
55 | "figcaption",
|
56 | "figure",
|
57 | "font",
|
58 | "footer",
|
59 | "form",
|
60 | "frame",
|
61 | "frameset",
|
62 | "h1",
|
63 | "h2",
|
64 | "h3",
|
65 | "h4",
|
66 | "h5",
|
67 | "h6",
|
68 | "head",
|
69 | "header",
|
70 | "hgroup",
|
71 | "hr",
|
72 | "html",
|
73 | "i",
|
74 | "iframe",
|
75 | "image",
|
76 | "img",
|
77 | "input",
|
78 | "ins",
|
79 | "isindex",
|
80 | "kbd",
|
81 | "keygen",
|
82 | "label",
|
83 | "legend",
|
84 | "li",
|
85 | "link",
|
86 | "listing",
|
87 | "main",
|
88 | "map",
|
89 | "mark",
|
90 | "marquee",
|
91 | "math",
|
92 | "menu",
|
93 | "menuitem",
|
94 | "meta",
|
95 | "meter",
|
96 | "multicol",
|
97 | "nav",
|
98 | "nextid",
|
99 | "nobr",
|
100 | "noembed",
|
101 | "noframes",
|
102 | "noscript",
|
103 | "object",
|
104 | "ol",
|
105 | "optgroup",
|
106 | "option",
|
107 | "output",
|
108 | "p",
|
109 | "param",
|
110 | "picture",
|
111 | "plaintext",
|
112 | "pre",
|
113 | "progress",
|
114 | "q",
|
115 | "rb",
|
116 | "rbc",
|
117 | "rp",
|
118 | "rt",
|
119 | "rtc",
|
120 | "ruby",
|
121 | "s",
|
122 | "samp",
|
123 | "script",
|
124 | "section",
|
125 | "select",
|
126 | "shadow",
|
127 | "slot",
|
128 | "small",
|
129 | "source",
|
130 | "spacer",
|
131 | "span",
|
132 | "strike",
|
133 | "strong",
|
134 | "style",
|
135 | "sub",
|
136 | "summary",
|
137 | "sup",
|
138 | "svg",
|
139 | "table",
|
140 | "tbody",
|
141 | "td",
|
142 | "template",
|
143 | "textarea",
|
144 | "tfoot",
|
145 | "th",
|
146 | "thead",
|
147 | "time",
|
148 | "title",
|
149 | "tr",
|
150 | "track",
|
151 | "tt",
|
152 | "u",
|
153 | "ul",
|
154 | "var",
|
155 | "video",
|
156 | "wbr",
|
157 | "xmp"
|
158 | ]
|
159 | ;
|
160 |
|
161 | var svgTagNames = [
|
162 | "a",
|
163 | "altGlyph",
|
164 | "altGlyphDef",
|
165 | "altGlyphItem",
|
166 | "animate",
|
167 | "animateColor",
|
168 | "animateMotion",
|
169 | "animateTransform",
|
170 | "animation",
|
171 | "audio",
|
172 | "canvas",
|
173 | "circle",
|
174 | "clipPath",
|
175 | "color-profile",
|
176 | "cursor",
|
177 | "defs",
|
178 | "desc",
|
179 | "discard",
|
180 | "ellipse",
|
181 | "feBlend",
|
182 | "feColorMatrix",
|
183 | "feComponentTransfer",
|
184 | "feComposite",
|
185 | "feConvolveMatrix",
|
186 | "feDiffuseLighting",
|
187 | "feDisplacementMap",
|
188 | "feDistantLight",
|
189 | "feDropShadow",
|
190 | "feFlood",
|
191 | "feFuncA",
|
192 | "feFuncB",
|
193 | "feFuncG",
|
194 | "feFuncR",
|
195 | "feGaussianBlur",
|
196 | "feImage",
|
197 | "feMerge",
|
198 | "feMergeNode",
|
199 | "feMorphology",
|
200 | "feOffset",
|
201 | "fePointLight",
|
202 | "feSpecularLighting",
|
203 | "feSpotLight",
|
204 | "feTile",
|
205 | "feTurbulence",
|
206 | "filter",
|
207 | "font",
|
208 | "font-face",
|
209 | "font-face-format",
|
210 | "font-face-name",
|
211 | "font-face-src",
|
212 | "font-face-uri",
|
213 | "foreignObject",
|
214 | "g",
|
215 | "glyph",
|
216 | "glyphRef",
|
217 | "handler",
|
218 | "hatch",
|
219 | "hatchpath",
|
220 | "hkern",
|
221 | "iframe",
|
222 | "image",
|
223 | "line",
|
224 | "linearGradient",
|
225 | "listener",
|
226 | "marker",
|
227 | "mask",
|
228 | "mesh",
|
229 | "meshgradient",
|
230 | "meshpatch",
|
231 | "meshrow",
|
232 | "metadata",
|
233 | "missing-glyph",
|
234 | "mpath",
|
235 | "path",
|
236 | "pattern",
|
237 | "polygon",
|
238 | "polyline",
|
239 | "prefetch",
|
240 | "radialGradient",
|
241 | "rect",
|
242 | "script",
|
243 | "set",
|
244 | "solidColor",
|
245 | "solidcolor",
|
246 | "stop",
|
247 | "style",
|
248 | "svg",
|
249 | "switch",
|
250 | "symbol",
|
251 | "tbreak",
|
252 | "text",
|
253 | "textArea",
|
254 | "textPath",
|
255 | "title",
|
256 | "tref",
|
257 | "tspan",
|
258 | "unknown",
|
259 | "use",
|
260 | "video",
|
261 | "view",
|
262 | "vkern"
|
263 | ]
|
264 | ;
|
265 |
|
266 | var domElements = htmlTagNames.concat(svgTagNames).filter(function (tag, index, array) {
|
267 | return array.indexOf(tag) === index;
|
268 | });
|
269 |
|
270 | var CHANNEL = '__glamorous__';
|
271 |
|
272 | var isPreact = false;
|
273 |
|
274 | var _PropTypes = void 0;
|
275 |
|
276 |
|
277 | if (isPreact) {
|
278 | if (!React.PropTypes) {
|
279 | _PropTypes = function PropTypes() {
|
280 | return _PropTypes;
|
281 | };
|
282 |
|
283 | ['array', 'bool', 'func', 'number', 'object', 'string', 'symbol', 'any', 'arrayOf', 'element', 'instanceOf', 'node', 'objectOf', 'oneOf', 'oneOfType', 'shape', 'exact'].forEach(function (type) {
|
284 | _PropTypes[type] = _PropTypes;
|
285 | });
|
286 | }
|
287 |
|
288 |
|
289 | if (!React.Children) {
|
290 | var Children = {
|
291 | map: function map(children, fn, ctx) {
|
292 | if (children == null) {
|
293 | return null;
|
294 | }
|
295 | children = Children.toArray(children);
|
296 | if (ctx && ctx !== children) {
|
297 | fn = fn.bind(ctx);
|
298 | }
|
299 | return children.map(fn);
|
300 | },
|
301 | forEach: function forEach(children, fn, ctx) {
|
302 | if (children == null) {
|
303 | return null;
|
304 | }
|
305 | children = Children.toArray(children);
|
306 | if (ctx && ctx !== children) {
|
307 | fn = fn.bind(ctx);
|
308 | }
|
309 | children.forEach(fn);
|
310 | },
|
311 | count: function count(children) {
|
312 | return children && children.length || 0;
|
313 | },
|
314 | only: function only(children) {
|
315 | children = Children.toArray(children);
|
316 | if (children.length !== 1) {
|
317 | throw new Error('Children.only() expects only one child.');
|
318 | }
|
319 | return children[0];
|
320 | },
|
321 | toArray: function toArray(children) {
|
322 | if (children == null) {
|
323 | return [];
|
324 | }
|
325 | return [].concat(children);
|
326 | }
|
327 | };
|
328 | React.Children = Children;
|
329 | }
|
330 |
|
331 | } else if (parseFloat(React.version.slice(0, 4)) >= 15.5) {
|
332 |
|
333 | try {
|
334 | _PropTypes = (typeof window !== 'undefined' ? window : global).PropTypes;
|
335 |
|
336 | } catch (error) {
|
337 |
|
338 | }
|
339 | }
|
340 |
|
341 | _PropTypes = _PropTypes || React.PropTypes;
|
342 |
|
343 |
|
344 |
|
345 |
|
346 |
|
347 |
|
348 |
|
349 |
|
350 | var classCallCheck = function (instance, Constructor) {
|
351 | if (!(instance instanceof Constructor)) {
|
352 | throw new TypeError("Cannot call a class as a function");
|
353 | }
|
354 | };
|
355 |
|
356 | var _extends = Object.assign || function (target) {
|
357 | for (var i = 1; i < arguments.length; i++) {
|
358 | var source = arguments[i];
|
359 |
|
360 | for (var key in source) {
|
361 | if (Object.prototype.hasOwnProperty.call(source, key)) {
|
362 | target[key] = source[key];
|
363 | }
|
364 | }
|
365 | }
|
366 |
|
367 | return target;
|
368 | };
|
369 |
|
370 | var inherits = function (subClass, superClass) {
|
371 | if (typeof superClass !== "function" && superClass !== null) {
|
372 | throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
|
373 | }
|
374 |
|
375 | subClass.prototype = Object.create(superClass && superClass.prototype, {
|
376 | constructor: {
|
377 | value: subClass,
|
378 | enumerable: false,
|
379 | writable: true,
|
380 | configurable: true
|
381 | }
|
382 | });
|
383 | if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
|
384 | };
|
385 |
|
386 | var objectWithoutProperties = function (obj, keys) {
|
387 | var target = {};
|
388 |
|
389 | for (var i in obj) {
|
390 | if (keys.indexOf(i) >= 0) continue;
|
391 | if (!Object.prototype.hasOwnProperty.call(obj, i)) continue;
|
392 | target[i] = obj[i];
|
393 | }
|
394 |
|
395 | return target;
|
396 | };
|
397 |
|
398 | var possibleConstructorReturn = function (self, call) {
|
399 | if (!self) {
|
400 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
401 | }
|
402 |
|
403 | return call && (typeof call === "object" || typeof call === "function") ? call : self;
|
404 | };
|
405 |
|
406 | function generateWarningMessage(Comp) {
|
407 | var componentName = Comp.displayName || Comp.name || 'FunctionComponent';
|
408 |
|
409 | return 'glamorous warning: Expected component called "' + componentName + '" which uses withTheme to be within a ThemeProvider but none was found.';
|
410 | }
|
411 |
|
412 | function withTheme(ComponentToTheme) {
|
413 | var _defaultContextTypes;
|
414 |
|
415 | var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
416 | _ref$noWarn = _ref.noWarn,
|
417 | noWarn = _ref$noWarn === undefined ? false : _ref$noWarn,
|
418 | _ref$createElement = _ref.createElement,
|
419 | createElement = _ref$createElement === undefined ? true : _ref$createElement;
|
420 |
|
421 | var ThemedComponent = function (_React$Component) {
|
422 | inherits(ThemedComponent, _React$Component);
|
423 |
|
424 | function ThemedComponent() {
|
425 | var _temp, _this, _ret;
|
426 |
|
427 | classCallCheck(this, ThemedComponent);
|
428 |
|
429 | for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
430 | args[_key] = arguments[_key];
|
431 | }
|
432 |
|
433 | return _ret = (_temp = (_this = possibleConstructorReturn(this, _React$Component.call.apply(_React$Component, [this].concat(args))), _this), _this.warned = noWarn, _this.state = { theme: {} }, _this.setTheme = function (theme) {
|
434 | return _this.setState({ theme: theme });
|
435 | }, _temp), possibleConstructorReturn(_this, _ret);
|
436 | }
|
437 |
|
438 |
|
439 | ThemedComponent.prototype.componentWillMount = function componentWillMount() {
|
440 | if (!this.context[CHANNEL]) {
|
441 | if ('development' !== 'production' && !this.warned) {
|
442 | this.warned = true;
|
443 |
|
444 | console.warn(generateWarningMessage(ComponentToTheme));
|
445 | }
|
446 | }
|
447 | var theme = this.props.theme;
|
448 |
|
449 | if (this.context[CHANNEL]) {
|
450 |
|
451 |
|
452 | this.setTheme(theme ? theme : this.context[CHANNEL].getState());
|
453 | } else {
|
454 | this.setTheme(theme || {});
|
455 | }
|
456 | };
|
457 |
|
458 | ThemedComponent.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
|
459 | if (this.props.theme !== nextProps.theme) {
|
460 | this.setTheme(nextProps.theme);
|
461 | }
|
462 | };
|
463 |
|
464 | ThemedComponent.prototype.componentDidMount = function componentDidMount() {
|
465 | if (this.context[CHANNEL] && !this.props.theme) {
|
466 |
|
467 | this.subscriptionId = this.context[CHANNEL].subscribe(this.setTheme);
|
468 | }
|
469 | };
|
470 |
|
471 | ThemedComponent.prototype.componentWillUnmount = function componentWillUnmount() {
|
472 |
|
473 | this.subscriptionId && this.context[CHANNEL].unsubscribe(this.subscriptionId);
|
474 | };
|
475 |
|
476 | ThemedComponent.prototype.render = function render() {
|
477 | if (createElement) {
|
478 | return React.createElement(ComponentToTheme, _extends({}, this.props, this.state));
|
479 | } else {
|
480 |
|
481 |
|
482 |
|
483 |
|
484 |
|
485 | return ComponentToTheme.call(this, _extends({}, this.props, this.state), this.context);
|
486 | }
|
487 | };
|
488 |
|
489 | return ThemedComponent;
|
490 | }(React.Component);
|
491 |
|
492 | ThemedComponent.propTypes = {
|
493 | theme: _PropTypes.object
|
494 | };
|
495 |
|
496 |
|
497 | var defaultContextTypes = (_defaultContextTypes = {}, _defaultContextTypes[CHANNEL] = _PropTypes.object, _defaultContextTypes);
|
498 |
|
499 | var userDefinedContextTypes = null;
|
500 |
|
501 |
|
502 |
|
503 | Object.defineProperty(ThemedComponent, 'contextTypes', {
|
504 | enumerable: true,
|
505 | configurable: true,
|
506 | set: function set$$1(value) {
|
507 | userDefinedContextTypes = value;
|
508 | },
|
509 | get: function get$$1() {
|
510 |
|
511 |
|
512 | if (userDefinedContextTypes) {
|
513 | return _extends({}, defaultContextTypes, userDefinedContextTypes);
|
514 | }
|
515 | return defaultContextTypes;
|
516 | }
|
517 | });
|
518 |
|
519 | return ThemedComponent;
|
520 | }
|
521 |
|
522 | var isFunction_1 = isFunction;
|
523 |
|
524 | var toString = Object.prototype.toString;
|
525 |
|
526 | function isFunction (fn) {
|
527 | var string = toString.call(fn);
|
528 | return string === '[object Function]' ||
|
529 | (typeof fn === 'function' && string !== '[object RegExp]') ||
|
530 | (typeof window !== 'undefined' &&
|
531 |
|
532 | (fn === window.setTimeout ||
|
533 | fn === window.alert ||
|
534 | fn === window.confirm ||
|
535 | fn === window.prompt))
|
536 | }
|
537 |
|
538 |
|
539 |
|
540 |
|
541 |
|
542 |
|
543 |
|
544 |
|
545 | var isobject = function isObject(val) {
|
546 | return val != null && typeof val === 'object' && Array.isArray(val) === false;
|
547 | };
|
548 |
|
549 | function isObjectObject(o) {
|
550 | return isobject(o) === true
|
551 | && Object.prototype.toString.call(o) === '[object Object]';
|
552 | }
|
553 |
|
554 | var isPlainObject = function isPlainObject(o) {
|
555 | var ctor,prot;
|
556 |
|
557 | if (isObjectObject(o) === false) return false;
|
558 |
|
559 |
|
560 | ctor = o.constructor;
|
561 | if (typeof ctor !== 'function') return false;
|
562 |
|
563 |
|
564 | prot = ctor.prototype;
|
565 | if (isObjectObject(prot) === false) return false;
|
566 |
|
567 |
|
568 | if (prot.hasOwnProperty('isPrototypeOf') === false) {
|
569 | return false;
|
570 | }
|
571 |
|
572 |
|
573 | return true;
|
574 | };
|
575 |
|
576 | function createBroadcast (initialState) {
|
577 | var listeners = {};
|
578 | var id = 1;
|
579 | var _state = initialState;
|
580 |
|
581 | function getState () {
|
582 | return _state
|
583 | }
|
584 |
|
585 | function setState (state) {
|
586 | _state = state;
|
587 | var keys = Object.keys(listeners);
|
588 | var i = 0;
|
589 | var len = keys.length;
|
590 | for (; i < len; i++) {
|
591 |
|
592 | if (listeners[keys[i]]) { listeners[keys[i]](state); }
|
593 | }
|
594 | }
|
595 |
|
596 |
|
597 | function subscribe (listener) {
|
598 | if (typeof listener !== 'function') {
|
599 | throw new Error('listener must be a function.')
|
600 | }
|
601 | var currentId = id;
|
602 | listeners[currentId] = listener;
|
603 | id += 1;
|
604 | return currentId
|
605 | }
|
606 |
|
607 |
|
608 | function unsubscribe (id) {
|
609 | listeners[id] = undefined;
|
610 | }
|
611 |
|
612 | return { getState: getState, setState: setState, subscribe: subscribe, unsubscribe: unsubscribe }
|
613 | }
|
614 |
|
615 | var _ThemeProvider$childC, _ThemeProvider$contex;
|
616 |
|
617 |
|
618 |
|
619 |
|
620 |
|
621 |
|
622 |
|
623 |
|
624 |
|
625 |
|
626 | var ThemeProvider = function (_React$Component) {
|
627 | inherits(ThemeProvider, _React$Component);
|
628 |
|
629 | function ThemeProvider() {
|
630 | var _temp, _this, _ret;
|
631 |
|
632 | classCallCheck(this, ThemeProvider);
|
633 |
|
634 | for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
635 | args[_key] = arguments[_key];
|
636 | }
|
637 |
|
638 | return _ret = (_temp = (_this = possibleConstructorReturn(this, _React$Component.call.apply(_React$Component, [this].concat(args))), _this), _this.setOuterTheme = function (theme) {
|
639 | _this.outerTheme = theme;
|
640 | if (_this.broadcast !== undefined) {
|
641 | _this.publishTheme();
|
642 | }
|
643 | }, _temp), possibleConstructorReturn(_this, _ret);
|
644 | }
|
645 |
|
646 |
|
647 | ThemeProvider.prototype.getTheme = function getTheme(passedTheme) {
|
648 | var theme = passedTheme || this.props.theme;
|
649 | if (isFunction_1(theme)) {
|
650 | var mergedTheme = theme(this.outerTheme);
|
651 | if (!isPlainObject(mergedTheme)) {
|
652 | throw new Error('[ThemeProvider] Please return an object from your theme function, ' + 'i.e. theme={() => ({})}!');
|
653 | }
|
654 | return mergedTheme;
|
655 | }
|
656 | return _extends({}, this.outerTheme, theme);
|
657 | };
|
658 |
|
659 | ThemeProvider.prototype.getChildContext = function getChildContext() {
|
660 | var _ref;
|
661 |
|
662 | return _ref = {}, _ref[CHANNEL] = this.broadcast, _ref;
|
663 | };
|
664 |
|
665 | ThemeProvider.prototype.publishTheme = function publishTheme(theme) {
|
666 | this.broadcast.setState(this.getTheme(theme));
|
667 | };
|
668 |
|
669 | ThemeProvider.prototype.componentDidMount = function componentDidMount() {
|
670 |
|
671 | if (this.context[CHANNEL]) {
|
672 | this.subscriptionId = this.context[CHANNEL].subscribe(this.setOuterTheme);
|
673 | }
|
674 | };
|
675 |
|
676 | ThemeProvider.prototype.componentWillMount = function componentWillMount() {
|
677 |
|
678 | if (this.context[CHANNEL]) {
|
679 | this.setOuterTheme(this.context[CHANNEL].getState());
|
680 | }
|
681 | this.broadcast = createBroadcast(this.getTheme(this.props.theme));
|
682 | };
|
683 |
|
684 | ThemeProvider.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
|
685 | if (this.props.theme !== nextProps.theme) {
|
686 | this.publishTheme(nextProps.theme);
|
687 | }
|
688 | };
|
689 |
|
690 | ThemeProvider.prototype.componentWillUnmount = function componentWillUnmount() {
|
691 | this.subscriptionId && this.context[CHANNEL].unsubscribe(this.subscriptionId);
|
692 | };
|
693 |
|
694 | ThemeProvider.prototype.render = function render() {
|
695 | return this.props.children ? React.Children.only(this.props.children) : null;
|
696 | };
|
697 |
|
698 | return ThemeProvider;
|
699 | }(React.Component);
|
700 |
|
701 | ThemeProvider.childContextTypes = (_ThemeProvider$childC = {}, _ThemeProvider$childC[CHANNEL] = _PropTypes.object.isRequired, _ThemeProvider$childC);
|
702 |
|
703 | ThemeProvider.contextTypes = (_ThemeProvider$contex = {}, _ThemeProvider$contex[CHANNEL] = _PropTypes.object, _ThemeProvider$contex);
|
704 |
|
705 | ThemeProvider.propTypes = {
|
706 | theme: _PropTypes.oneOfType([_PropTypes.object, _PropTypes.func]).isRequired,
|
707 | children: _PropTypes.node
|
708 | };
|
709 |
|
710 |
|
711 |
|
712 |
|
713 |
|
714 |
|
715 |
|
716 |
|
717 |
|
718 |
|
719 |
|
720 |
|
721 | function extractGlamorStyles(className) {
|
722 | var glamorlessClassName = [];
|
723 | var glamorStyles = [];
|
724 | className.toString().split(' ').forEach(function (name) {
|
725 | if (glamor.styleSheet.registered[name.substring(4)] === undefined) {
|
726 | glamorlessClassName.push(name);
|
727 | } else {
|
728 | var style = buildGlamorSrcFromClassName(name);
|
729 | glamorStyles.push(style);
|
730 | }
|
731 | });
|
732 |
|
733 | return { glamorlessClassName: glamorlessClassName, glamorStyles: glamorStyles };
|
734 | }
|
735 |
|
736 |
|
737 |
|
738 |
|
739 |
|
740 |
|
741 |
|
742 |
|
743 |
|
744 |
|
745 |
|
746 |
|
747 |
|
748 | function buildGlamorSrcFromClassName(className) {
|
749 | var _ref;
|
750 |
|
751 | return _ref = {}, _ref['data-' + className] = '', _ref;
|
752 | }
|
753 |
|
754 | function getGlamorClassName(_ref2) {
|
755 | var styles = _ref2.styles,
|
756 | props = _ref2.props,
|
757 | cssOverrides = _ref2.cssOverrides,
|
758 | cssProp = _ref2.cssProp,
|
759 | context = _ref2.context,
|
760 | displayName = _ref2.displayName;
|
761 |
|
762 | var _handleStyles = handleStyles([].concat(styles, [props.className, cssOverrides, cssProp]), props, context),
|
763 | mappedArgs = _handleStyles.mappedArgs,
|
764 | nonGlamorClassNames = _handleStyles.nonGlamorClassNames;
|
765 |
|
766 |
|
767 |
|
768 | var devRules = { label: displayName };
|
769 | var glamorClassName = glamor.css.apply(undefined, [devRules].concat(mappedArgs)).toString();
|
770 | var extras = nonGlamorClassNames.join(' ').trim();
|
771 | return (glamorClassName + ' ' + extras).trim();
|
772 | }
|
773 |
|
774 |
|
775 |
|
776 |
|
777 | function handleStyles(styles, props, context) {
|
778 | var current = void 0;
|
779 | var mappedArgs = [];
|
780 | var nonGlamorClassNames = [];
|
781 | for (var i = 0; i < styles.length; i++) {
|
782 | current = styles[i];
|
783 | while (typeof current === 'function') {
|
784 | current = current(props, context);
|
785 | }
|
786 | if (typeof current === 'string') {
|
787 | var _extractGlamorStyles = extractGlamorStyles(current),
|
788 | glamorStyles = _extractGlamorStyles.glamorStyles,
|
789 | glamorlessClassName = _extractGlamorStyles.glamorlessClassName;
|
790 |
|
791 | mappedArgs.push.apply(mappedArgs, glamorStyles);
|
792 | nonGlamorClassNames.push.apply(nonGlamorClassNames, glamorlessClassName);
|
793 | } else if (Array.isArray(current)) {
|
794 | var recursed = handleStyles(current, props, context);
|
795 | mappedArgs.push.apply(mappedArgs, recursed.mappedArgs);
|
796 | nonGlamorClassNames.push.apply(nonGlamorClassNames, recursed.nonGlamorClassNames);
|
797 | } else {
|
798 | mappedArgs.push(current);
|
799 | }
|
800 | }
|
801 | return { mappedArgs: mappedArgs, nonGlamorClassNames: nonGlamorClassNames };
|
802 | }
|
803 |
|
804 |
|
805 |
|
806 |
|
807 |
|
808 |
|
809 | function createGlamorous(splitProps) {
|
810 | return glamorous;
|
811 |
|
812 | |
813 |
|
814 |
|
815 |
|
816 |
|
817 |
|
818 |
|
819 |
|
820 |
|
821 |
|
822 |
|
823 | function glamorous(comp) {
|
824 | var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
825 | var rootEl = config.rootEl,
|
826 | displayName = config.displayName,
|
827 | shouldClassNameUpdate = config.shouldClassNameUpdate,
|
828 | _config$filterProps = config.filterProps,
|
829 | filterProps = _config$filterProps === undefined ? [] : _config$filterProps,
|
830 | _config$forwardProps = config.forwardProps,
|
831 | forwardProps = _config$forwardProps === undefined ? [] : _config$forwardProps,
|
832 | _config$propsAreCssOv = config.propsAreCssOverrides,
|
833 | propsAreCssOverrides = _config$propsAreCssOv === undefined ? comp.propsAreCssOverrides : _config$propsAreCssOv,
|
834 | basePropsToApply = config.withProps;
|
835 |
|
836 | Object.assign(glamorousComponentFactory, { withConfig: withConfig });
|
837 | return glamorousComponentFactory;
|
838 |
|
839 | function withConfig(newConfig) {
|
840 | return glamorous(comp, _extends({}, config, newConfig));
|
841 | }
|
842 |
|
843 | |
844 |
|
845 |
|
846 |
|
847 |
|
848 |
|
849 |
|
850 |
|
851 | function glamorousComponentFactory() {
|
852 | for (var _len = arguments.length, styles = Array(_len), _key = 0; _key < _len; _key++) {
|
853 | styles[_key] = arguments[_key];
|
854 | }
|
855 |
|
856 | |
857 |
|
858 |
|
859 |
|
860 |
|
861 | var GlamorousComponent = withTheme(function (props, context) {
|
862 | props = getPropsToApply(GlamorousComponent.propsToApply, {}, props, context);
|
863 | var updateClassName = shouldUpdate(props, context, this.previous);
|
864 |
|
865 | if (shouldClassNameUpdate) {
|
866 | this.previous = { props: props, context: context };
|
867 | }
|
868 |
|
869 | var _splitProps = splitProps(props, GlamorousComponent),
|
870 | toForward = _splitProps.toForward,
|
871 | cssOverrides = _splitProps.cssOverrides,
|
872 | cssProp = _splitProps.cssProp;
|
873 |
|
874 |
|
875 |
|
876 |
|
877 | this.className = updateClassName ? getGlamorClassName({
|
878 | styles: GlamorousComponent.styles,
|
879 | props: props,
|
880 | cssOverrides: cssOverrides,
|
881 | cssProp: cssProp,
|
882 | context: context,
|
883 | displayName: GlamorousComponent.displayName
|
884 | }) : this.className;
|
885 |
|
886 | return React.createElement(GlamorousComponent.comp, _extends({
|
887 |
|
888 | ref: 'innerRef' in toForward ? undefined : props.innerRef
|
889 | }, toForward, {
|
890 | className: this.className
|
891 | }));
|
892 | }, { noWarn: true, createElement: false });
|
893 |
|
894 | GlamorousComponent.propTypes = {
|
895 |
|
896 |
|
897 | className: _PropTypes.oneOfType([_PropTypes.string, _PropTypes.object]),
|
898 | cssOverrides: _PropTypes.object,
|
899 | innerRef: _PropTypes.oneOfType([_PropTypes.func, _PropTypes.object]),
|
900 | glam: _PropTypes.object
|
901 | };
|
902 |
|
903 | function shouldUpdate(props, context, previous) {
|
904 |
|
905 |
|
906 |
|
907 | if (!shouldClassNameUpdate) {
|
908 | return true;
|
909 | }
|
910 | var update = true;
|
911 | if (previous) {
|
912 | if (!shouldClassNameUpdate(previous.props, props, previous.context, context)) {
|
913 | update = false;
|
914 | }
|
915 | }
|
916 |
|
917 | return update;
|
918 | }
|
919 |
|
920 | Object.assign(GlamorousComponent, getGlamorousComponentMetadata({
|
921 | comp: comp,
|
922 | styles: styles,
|
923 | rootEl: rootEl,
|
924 | filterProps: filterProps,
|
925 | forwardProps: forwardProps,
|
926 | displayName: displayName,
|
927 | propsToApply: basePropsToApply
|
928 | }), {
|
929 | isGlamorousComponent: true,
|
930 | propsAreCssOverrides: propsAreCssOverrides,
|
931 | withComponent: function (newComp) {
|
932 | var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
933 | var fwp = GlamorousComponent.forwardProps,
|
934 | flp = GlamorousComponent.filterProps,
|
935 | componentProperties = objectWithoutProperties(GlamorousComponent, ['forwardProps', 'filterProps']);
|
936 |
|
937 | return glamorous(_extends({}, componentProperties, {
|
938 | comp: newComp,
|
939 | rootEl: getRootEl(newComp)
|
940 | }), _extends({
|
941 |
|
942 | forwardProps: fwp,
|
943 | filterProps: flp
|
944 | }, options))();
|
945 | },
|
946 | withProps: function () {
|
947 | for (var _len2 = arguments.length, propsToApply = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
948 | propsToApply[_key2] = arguments[_key2];
|
949 | }
|
950 |
|
951 | return glamorous(GlamorousComponent, { withProps: propsToApply })();
|
952 | },
|
953 | withConfig: withConfig
|
954 | });
|
955 | return GlamorousComponent;
|
956 | }
|
957 | }
|
958 |
|
959 | function getGlamorousComponentMetadata(_ref) {
|
960 | var comp = _ref.comp,
|
961 | styles = _ref.styles,
|
962 | rootEl = _ref.rootEl,
|
963 | filterProps = _ref.filterProps,
|
964 | forwardProps = _ref.forwardProps,
|
965 | displayName = _ref.displayName,
|
966 | basePropsToApply = _ref.propsToApply;
|
967 |
|
968 | var componentsComp = comp.comp ? comp.comp : comp;
|
969 | var propsToApply = comp.propsToApply ? [].concat(comp.propsToApply, arrayify(basePropsToApply)) : arrayify(basePropsToApply);
|
970 | return {
|
971 |
|
972 | styles: when(comp.styles, styles),
|
973 |
|
974 |
|
975 |
|
976 |
|
977 | comp: componentsComp,
|
978 | rootEl: rootEl || getRootEl(comp),
|
979 |
|
980 |
|
981 | forwardProps: when(comp.forwardProps, forwardProps),
|
982 | filterProps: when(comp.filterProps, filterProps),
|
983 |
|
984 |
|
985 | displayName: displayName || 'glamorous(' + getDisplayName(comp) + ')',
|
986 |
|
987 | propsToApply: propsToApply
|
988 | };
|
989 | }
|
990 | }
|
991 |
|
992 |
|
993 |
|
994 |
|
995 |
|
996 |
|
997 |
|
998 |
|
999 |
|
1000 |
|
1001 |
|
1002 |
|
1003 | function getPropsToApply(propsToApply, accumulator, props, context) {
|
1004 |
|
1005 |
|
1006 | propsToApply.forEach(function (propsToApplyItem) {
|
1007 | if (typeof propsToApplyItem === 'function') {
|
1008 | return Object.assign(accumulator, propsToApplyItem(Object.assign({}, accumulator, props), context));
|
1009 | } else if (Array.isArray(propsToApplyItem)) {
|
1010 | return Object.assign(accumulator, getPropsToApply(propsToApplyItem, accumulator, props, context));
|
1011 | }
|
1012 | return Object.assign(accumulator, propsToApplyItem);
|
1013 | });
|
1014 |
|
1015 | return Object.assign(accumulator, props);
|
1016 | }
|
1017 |
|
1018 | function arrayify() {
|
1019 | var x = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
1020 |
|
1021 | return Array.isArray(x) ? x : [x];
|
1022 | }
|
1023 |
|
1024 | function when(comp, prop) {
|
1025 | return comp ? comp.concat(prop) : prop;
|
1026 | }
|
1027 |
|
1028 | function getRootEl(comp) {
|
1029 | return comp.rootEl ? comp.rootEl : comp.comp || comp;
|
1030 | }
|
1031 |
|
1032 | function getDisplayName(comp) {
|
1033 | return typeof comp === 'string' ? comp : comp.displayName || comp.name || 'unknown';
|
1034 | }
|
1035 |
|
1036 |
|
1037 |
|
1038 |
|
1039 |
|
1040 | function memoize (fn, options) {
|
1041 | var cache = options && options.cache
|
1042 | ? options.cache
|
1043 | : cacheDefault;
|
1044 |
|
1045 | var serializer = options && options.serializer
|
1046 | ? options.serializer
|
1047 | : serializerDefault;
|
1048 |
|
1049 | var strategy = options && options.strategy
|
1050 | ? options.strategy
|
1051 | : strategyDefault;
|
1052 |
|
1053 | return strategy(fn, {
|
1054 | cache: cache,
|
1055 | serializer: serializer
|
1056 | })
|
1057 | }
|
1058 |
|
1059 |
|
1060 |
|
1061 |
|
1062 |
|
1063 | function isPrimitive (value) {
|
1064 | return value == null || typeof value === 'number' || typeof value === 'boolean'
|
1065 | }
|
1066 |
|
1067 | function monadic (fn, cache, serializer, arg) {
|
1068 | var cacheKey = isPrimitive(arg) ? arg : serializer(arg);
|
1069 |
|
1070 | var computedValue = cache.get(cacheKey);
|
1071 | if (typeof computedValue === 'undefined') {
|
1072 | computedValue = fn.call(this, arg);
|
1073 | cache.set(cacheKey, computedValue);
|
1074 | }
|
1075 |
|
1076 | return computedValue
|
1077 | }
|
1078 |
|
1079 | function variadic (fn, cache, serializer) {
|
1080 | var args = Array.prototype.slice.call(arguments, 3);
|
1081 | var cacheKey = serializer(args);
|
1082 |
|
1083 | var computedValue = cache.get(cacheKey);
|
1084 | if (typeof computedValue === 'undefined') {
|
1085 | computedValue = fn.apply(this, args);
|
1086 | cache.set(cacheKey, computedValue);
|
1087 | }
|
1088 |
|
1089 | return computedValue
|
1090 | }
|
1091 |
|
1092 | function assemble (fn, context, strategy, cache, serialize) {
|
1093 | return strategy.bind(
|
1094 | context,
|
1095 | fn,
|
1096 | cache,
|
1097 | serialize
|
1098 | )
|
1099 | }
|
1100 |
|
1101 | function strategyDefault (fn, options) {
|
1102 | var strategy = fn.length === 1 ? monadic : variadic;
|
1103 |
|
1104 | return assemble(
|
1105 | fn,
|
1106 | this,
|
1107 | strategy,
|
1108 | options.cache.create(),
|
1109 | options.serializer
|
1110 | )
|
1111 | }
|
1112 |
|
1113 | function strategyVariadic (fn, options) {
|
1114 | var strategy = variadic;
|
1115 |
|
1116 | return assemble(
|
1117 | fn,
|
1118 | this,
|
1119 | strategy,
|
1120 | options.cache.create(),
|
1121 | options.serializer
|
1122 | )
|
1123 | }
|
1124 |
|
1125 | function strategyMonadic (fn, options) {
|
1126 | var strategy = monadic;
|
1127 |
|
1128 | return assemble(
|
1129 | fn,
|
1130 | this,
|
1131 | strategy,
|
1132 | options.cache.create(),
|
1133 | options.serializer
|
1134 | )
|
1135 | }
|
1136 |
|
1137 |
|
1138 |
|
1139 |
|
1140 |
|
1141 | function serializerDefault () {
|
1142 | return JSON.stringify(arguments)
|
1143 | }
|
1144 |
|
1145 |
|
1146 |
|
1147 |
|
1148 |
|
1149 | function ObjectWithoutPrototypeCache () {
|
1150 | this.cache = Object.create(null);
|
1151 | }
|
1152 |
|
1153 | ObjectWithoutPrototypeCache.prototype.has = function (key) {
|
1154 | return (key in this.cache)
|
1155 | };
|
1156 |
|
1157 | ObjectWithoutPrototypeCache.prototype.get = function (key) {
|
1158 | return this.cache[key]
|
1159 | };
|
1160 |
|
1161 | ObjectWithoutPrototypeCache.prototype.set = function (key, value) {
|
1162 | this.cache[key] = value;
|
1163 | };
|
1164 |
|
1165 | var cacheDefault = {
|
1166 | create: function create () {
|
1167 | return new ObjectWithoutPrototypeCache()
|
1168 | }
|
1169 | };
|
1170 |
|
1171 |
|
1172 |
|
1173 |
|
1174 |
|
1175 | var src = memoize;
|
1176 | var strategies = {
|
1177 | variadic: strategyVariadic,
|
1178 | monadic: strategyMonadic
|
1179 | };
|
1180 | src.strategies = strategies;
|
1181 |
|
1182 | function unwrapExports (x) {
|
1183 | return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x.default : x;
|
1184 | }
|
1185 |
|
1186 | function createCommonjsModule(fn, module) {
|
1187 | return module = { exports: {} }, fn(module, module.exports), module.exports;
|
1188 | }
|
1189 |
|
1190 | function getCjsExportFromNamespace (n) {
|
1191 | return n && n.default || n;
|
1192 | }
|
1193 |
|
1194 | var a = ["coords","download","href","name","rel","shape","target","type","onClick"];
|
1195 | var abbr = ["title"];
|
1196 | var applet = ["alt","height","name","width"];
|
1197 | var area = ["alt","coords","download","href","rel","shape","target","type"];
|
1198 | var audio = ["controls","loop","muted","preload","src"];
|
1199 | var base = ["href","target"];
|
1200 | var basefont = ["size"];
|
1201 | var bdo = ["dir"];
|
1202 | var blockquote = ["cite"];
|
1203 | var button = ["disabled","form","name","type","value"];
|
1204 | var canvas = ["height","width"];
|
1205 | var col = ["span","width"];
|
1206 | var colgroup = ["span","width"];
|
1207 | var data = ["value"];
|
1208 | var del = ["cite"];
|
1209 | var details = ["open"];
|
1210 | var dfn = ["title"];
|
1211 | var dialog = ["open"];
|
1212 | var embed = ["height","src","type","width"];
|
1213 | var fieldset = ["disabled","form","name"];
|
1214 | var font = ["size"];
|
1215 | var form = ["accept","action","method","name","target","onChange","onInput","onInvalid","onSubmit"];
|
1216 | var frame = ["name","scrolling","src"];
|
1217 | var frameset = ["cols","rows"];
|
1218 | var head = ["profile"];
|
1219 | var hr = ["size","width"];
|
1220 | var html = ["manifest"];
|
1221 | var iframe = ["height","name","sandbox","scrolling","src","width"];
|
1222 | var img = ["alt","height","name","sizes","src","width"];
|
1223 | var input = ["accept","alt","autoCapitalize","autoCorrect","autoSave","checked","defaultChecked","defaultValue","disabled","form","height","list","max","min","multiple","name","onChange","pattern","placeholder","required","results","size","src","step","title","type","value","width"];
|
1224 | var ins = ["cite"];
|
1225 | var keygen = ["challenge","disabled","form","name"];
|
1226 | var label = ["form"];
|
1227 | var li = ["type","value"];
|
1228 | var link = ["color","href","integrity","media","nonce","rel","scope","sizes","target","title","type"];
|
1229 | var map = ["name"];
|
1230 | var meta = ["content","name"];
|
1231 | var meter = ["high","low","max","min","optimum","value"];
|
1232 | var object = ["data","form","height","name","type","width"];
|
1233 | var ol = ["reversed","start","type"];
|
1234 | var optgroup = ["disabled","label"];
|
1235 | var option = ["disabled","label","selected","value"];
|
1236 | var output = ["form","name"];
|
1237 | var param = ["name","type","value"];
|
1238 | var pre = ["width"];
|
1239 | var progress = ["max","value"];
|
1240 | var q = ["cite"];
|
1241 | var script = ["async","defer","integrity","nonce","src","type"];
|
1242 | var select = ["defaultValue","disabled","form","multiple","name","onChange","required","size","value"];
|
1243 | var slot = ["name"];
|
1244 | var source = ["media","sizes","src","type"];
|
1245 | var style = ["media","nonce","title","type"];
|
1246 | var table = ["summary","width"];
|
1247 | var td = ["headers","height","scope","width"];
|
1248 | var textarea = ["autoCapitalize","autoCorrect","cols","defaultValue","disabled","form","name","onChange","placeholder","required","rows","value","wrap"];
|
1249 | var th = ["headers","height","scope","width"];
|
1250 | var track = ["default","kind","label","src"];
|
1251 | var ul = ["type"];
|
1252 | var video = ["controls","height","loop","muted","playsInline","poster","preload","src","width"];
|
1253 | var svg = ["accentHeight","accumulate","additive","alignmentBaseline","allowReorder","alphabetic","amplitude","arabicForm","ascent","attributeName","attributeType","autoReverse","azimuth","baseFrequency","baseProfile","baselineShift","bbox","begin","bias","by","calcMode","capHeight","clip","clipPath","clipPathUnits","clipRule","color","colorInterpolation","colorInterpolationFilters","colorProfile","colorRendering","contentScriptType","contentStyleType","cursor","cx","cy","d","decelerate","descent","diffuseConstant","direction","display","divisor","dominantBaseline","dur","dx","dy","edgeMode","elevation","enableBackground","end","exponent","externalResourcesRequired","fill","fillOpacity","fillRule","filter","filterRes","filterUnits","floodColor","floodOpacity","focusable","fontFamily","fontSize","fontSizeAdjust","fontStretch","fontStyle","fontVariant","fontWeight","format","from","fx","fy","g1","g2","glyphName","glyphOrientationHorizontal","glyphOrientationVertical","glyphRef","gradientTransform","gradientUnits","hanging","height","horizAdvX","horizOriginX","ideographic","imageRendering","in","in2","intercept","k","k1","k2","k3","k4","kernelMatrix","kernelUnitLength","kerning","keyPoints","keySplines","keyTimes","lengthAdjust","letterSpacing","lightingColor","limitingConeAngle","local","markerEnd","markerHeight","markerMid","markerStart","markerUnits","markerWidth","mask","maskContentUnits","maskUnits","mathematical","mode","numOctaves","offset","opacity","operator","order","orient","orientation","origin","overflow","overlinePosition","overlineThickness","paintOrder","panose1","pathLength","patternContentUnits","patternTransform","patternUnits","pointerEvents","points","pointsAtX","pointsAtY","pointsAtZ","preserveAlpha","preserveAspectRatio","primitiveUnits","r","radius","refX","refY","renderingIntent","repeatCount","repeatDur","requiredExtensions","requiredFeatures","restart","result","rotate","rx","ry","scale","seed","shapeRendering","slope","spacing","specularConstant","specularExponent","speed","spreadMethod","startOffset","stdDeviation","stemh","stemv","stitchTiles","stopColor","stopOpacity","strikethroughPosition","strikethroughThickness","string","stroke","strokeDasharray","strokeDashoffset","strokeLinecap","strokeLinejoin","strokeMiterlimit","strokeOpacity","strokeWidth","surfaceScale","systemLanguage","tableValues","targetX","targetY","textAnchor","textDecoration","textLength","textRendering","to","transform","u1","u2","underlinePosition","underlineThickness","unicode","unicodeBidi","unicodeRange","unitsPerEm","vAlphabetic","vHanging","vIdeographic","vMathematical","values","vectorEffect","version","vertAdvY","vertOriginX","vertOriginY","viewBox","viewTarget","visibility","width","widths","wordSpacing","writingMode","x","x1","x2","xChannelSelector","xHeight","xlinkActuate","xlinkArcrole","xlinkHref","xlinkRole","xlinkShow","xlinkTitle","xlinkType","xmlBase","xmlLang","xmlSpace","xmlns","xmlnsXlink","y","y1","y2","yChannelSelector","z","zoomAndPan"];
|
1254 | var elements = {"html":["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","math","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rb","rp","rt","rtc","ruby","s","samp","script","section","select","slot","small","source","span","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr"],"svg":["a","altGlyph","altGlyphDef","altGlyphItem","animate","animateColor","animateMotion","animateTransform","circle","clipPath","color-profile","cursor","defs","desc","ellipse","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","font","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignObject","g","glyph","glyphRef","hkern","image","line","linearGradient","marker","mask","metadata","missing-glyph","mpath","path","pattern","polygon","polyline","radialGradient","rect","script","set","stop","style","svg","switch","symbol","text","textPath","title","tref","tspan","use","view","vkern"]};
|
1255 | var reactHtmlAttributes = {
|
1256 | a: a,
|
1257 | abbr: abbr,
|
1258 | applet: applet,
|
1259 | area: area,
|
1260 | audio: audio,
|
1261 | base: base,
|
1262 | basefont: basefont,
|
1263 | bdo: bdo,
|
1264 | blockquote: blockquote,
|
1265 | button: button,
|
1266 | canvas: canvas,
|
1267 | col: col,
|
1268 | colgroup: colgroup,
|
1269 | data: data,
|
1270 | del: del,
|
1271 | details: details,
|
1272 | dfn: dfn,
|
1273 | dialog: dialog,
|
1274 | embed: embed,
|
1275 | fieldset: fieldset,
|
1276 | font: font,
|
1277 | form: form,
|
1278 | frame: frame,
|
1279 | frameset: frameset,
|
1280 | head: head,
|
1281 | hr: hr,
|
1282 | html: html,
|
1283 | iframe: iframe,
|
1284 | img: img,
|
1285 | input: input,
|
1286 | ins: ins,
|
1287 | keygen: keygen,
|
1288 | label: label,
|
1289 | li: li,
|
1290 | link: link,
|
1291 | map: map,
|
1292 | meta: meta,
|
1293 | meter: meter,
|
1294 | object: object,
|
1295 | ol: ol,
|
1296 | optgroup: optgroup,
|
1297 | option: option,
|
1298 | output: output,
|
1299 | param: param,
|
1300 | pre: pre,
|
1301 | progress: progress,
|
1302 | q: q,
|
1303 | script: script,
|
1304 | select: select,
|
1305 | slot: slot,
|
1306 | source: source,
|
1307 | style: style,
|
1308 | table: table,
|
1309 | td: td,
|
1310 | textarea: textarea,
|
1311 | th: th,
|
1312 | track: track,
|
1313 | ul: ul,
|
1314 | video: video,
|
1315 | svg: svg,
|
1316 | elements: elements,
|
1317 | "*": ["about","acceptCharset","accessKey","allowFullScreen","allowTransparency","autoComplete","autoFocus","autoPlay","capture","cellPadding","cellSpacing","charSet","classID","className","colSpan","contentEditable","contextMenu","crossOrigin","dangerouslySetInnerHTML","datatype","dateTime","dir","draggable","encType","formAction","formEncType","formMethod","formNoValidate","formTarget","frameBorder","hidden","hrefLang","htmlFor","httpEquiv","icon","id","inlist","inputMode","is","itemID","itemProp","itemRef","itemScope","itemType","keyParams","keyType","lang","marginHeight","marginWidth","maxLength","mediaGroup","minLength","noValidate","prefix","property","radioGroup","readOnly","resource","role","rowSpan","scoped","seamless","security","spellCheck","srcDoc","srcLang","srcSet","style","suppressContentEditableWarning","tabIndex","title","typeof","unselectable","useMap","vocab","wmode"]
|
1318 | };
|
1319 |
|
1320 | var reactHtmlAttributes$1 = Object.freeze({
|
1321 | a: a,
|
1322 | abbr: abbr,
|
1323 | applet: applet,
|
1324 | area: area,
|
1325 | audio: audio,
|
1326 | base: base,
|
1327 | basefont: basefont,
|
1328 | bdo: bdo,
|
1329 | blockquote: blockquote,
|
1330 | button: button,
|
1331 | canvas: canvas,
|
1332 | col: col,
|
1333 | colgroup: colgroup,
|
1334 | data: data,
|
1335 | del: del,
|
1336 | details: details,
|
1337 | dfn: dfn,
|
1338 | dialog: dialog,
|
1339 | embed: embed,
|
1340 | fieldset: fieldset,
|
1341 | font: font,
|
1342 | form: form,
|
1343 | frame: frame,
|
1344 | frameset: frameset,
|
1345 | head: head,
|
1346 | hr: hr,
|
1347 | html: html,
|
1348 | iframe: iframe,
|
1349 | img: img,
|
1350 | input: input,
|
1351 | ins: ins,
|
1352 | keygen: keygen,
|
1353 | label: label,
|
1354 | li: li,
|
1355 | link: link,
|
1356 | map: map,
|
1357 | meta: meta,
|
1358 | meter: meter,
|
1359 | object: object,
|
1360 | ol: ol,
|
1361 | optgroup: optgroup,
|
1362 | option: option,
|
1363 | output: output,
|
1364 | param: param,
|
1365 | pre: pre,
|
1366 | progress: progress,
|
1367 | q: q,
|
1368 | script: script,
|
1369 | select: select,
|
1370 | slot: slot,
|
1371 | source: source,
|
1372 | style: style,
|
1373 | table: table,
|
1374 | td: td,
|
1375 | textarea: textarea,
|
1376 | th: th,
|
1377 | track: track,
|
1378 | ul: ul,
|
1379 | video: video,
|
1380 | svg: svg,
|
1381 | elements: elements,
|
1382 | default: reactHtmlAttributes
|
1383 | });
|
1384 |
|
1385 | var reactHtmlAttributes$2 = getCjsExportFromNamespace(reactHtmlAttributes$1)
|
1386 |
|
1387 | var dist = createCommonjsModule(function (module, exports) {
|
1388 |
|
1389 | Object.defineProperty(exports, "__esModule", {
|
1390 | value: true
|
1391 | });
|
1392 |
|
1393 |
|
1394 | exports.default = reactHtmlAttributes$2;
|
1395 |
|
1396 | module.exports = reactHtmlAttributes$2;
|
1397 | });
|
1398 |
|
1399 | var reactHTMLAttributes = unwrapExports(dist);
|
1400 |
|
1401 |
|
1402 |
|
1403 |
|
1404 |
|
1405 |
|
1406 |
|
1407 |
|
1408 | var reactProps = ['children', 'dangerouslySetInnerHTML', 'key', 'ref', 'autoFocus', 'defaultValue', 'valueLink', 'defaultChecked', 'checkedLink', 'innerHTML', 'suppressContentEditableWarning', 'onFocusIn', 'onFocusOut', 'className',
|
1409 |
|
1410 |
|
1411 | 'onCopy', 'onCut', 'onPaste', 'onCompositionEnd', 'onCompositionStart', 'onCompositionUpdate', 'onKeyDown', 'onKeyPress', 'onKeyUp', 'onFocus', 'onBlur', 'onChange', 'onInput', 'onInvalid', 'onSubmit', 'onClick', 'onContextMenu', 'onDoubleClick', 'onDrag', 'onDragEnd', 'onDragEnter', 'onDragExit', 'onDragLeave', 'onDragOver', 'onDragStart', 'onDrop', 'onMouseDown', 'onMouseEnter', 'onMouseLeave', 'onMouseMove', 'onMouseOut', 'onMouseOver', 'onMouseUp', 'onSelect', 'onTouchCancel', 'onTouchEnd', 'onTouchMove', 'onTouchStart', 'onScroll', 'onWheel', 'onAbort', 'onCanPlay', 'onCanPlayThrough', 'onDurationChange', 'onEmptied', 'onEncrypted', 'onEnded', 'onError', 'onLoadedData', 'onLoadedMetadata', 'onLoadStart', 'onPause', 'onPlay', 'onPlaying', 'onProgress', 'onRateChange', 'onSeeked', 'onSeeking', 'onStalled', 'onSuspend', 'onTimeUpdate', 'onVolumeChange', 'onWaiting', 'onLoad', 'onAnimationStart', 'onAnimationEnd', 'onAnimationIteration', 'onTransitionEnd', 'onCopyCapture', 'onCutCapture', 'onPasteCapture', 'onCompositionEndCapture', 'onCompositionStartCapture', 'onCompositionUpdateCapture', 'onKeyDownCapture', 'onKeyPressCapture', 'onKeyUpCapture', 'onFocusCapture', 'onBlurCapture', 'onChangeCapture', 'onInputCapture', 'onSubmitCapture', 'onClickCapture', 'onContextMenuCapture', 'onDoubleClickCapture', 'onDragCapture', 'onDragEndCapture', 'onDragEnterCapture', 'onDragExitCapture', 'onDragLeaveCapture', 'onDragOverCapture', 'onDragStartCapture', 'onDropCapture', 'onMouseDownCapture', 'onMouseEnterCapture', 'onMouseLeaveCapture', 'onMouseMoveCapture', 'onMouseOutCapture', 'onMouseOverCapture', 'onMouseUpCapture', 'onSelectCapture', 'onTouchCancelCapture', 'onTouchEndCapture', 'onTouchMoveCapture', 'onTouchStartCapture', 'onScrollCapture', 'onWheelCapture', 'onAbortCapture', 'onCanPlayCapture', 'onCanPlayThroughCapture', 'onDurationChangeCapture', 'onEmptiedCapture', 'onEncryptedCapture', 'onEndedCapture', 'onErrorCapture', 'onLoadedDataCapture', 'onLoadedMetadataCapture', 'onLoadStartCapture', 'onPauseCapture', 'onPlayCapture', 'onPlayingCapture', 'onProgressCapture', 'onRateChangeCapture', 'onSeekedCapture', 'onSeekingCapture', 'onStalledCapture', 'onSuspendCapture', 'onTimeUpdateCapture', 'onVolumeChangeCapture', 'onWaitingCapture', 'onLoadCapture', 'onAnimationStartCapture', 'onAnimationEndCapture', 'onAnimationIterationCapture', 'onTransitionEndCapture'];
|
1412 |
|
1413 | if (isPreact) {
|
1414 | reactProps.push('autocomplete', 'autofocus', 'class', 'for', 'onDblClick', 'onSearch', 'slot', 'srcset');
|
1415 | }
|
1416 |
|
1417 |
|
1418 |
|
1419 | var globalReactHtmlProps = reactHTMLAttributes['*'];
|
1420 | var supportedSVGTagNames = reactHTMLAttributes.elements.svg;
|
1421 | var supportedHtmlTagNames = reactHTMLAttributes.elements.html;
|
1422 |
|
1423 |
|
1424 |
|
1425 |
|
1426 | var cssProps = ['color', 'height', 'width'];
|
1427 |
|
1428 |
|
1429 | var ATTRIBUTE_NAME_START_CHAR =
|
1430 |
|
1431 | ':A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD';
|
1432 |
|
1433 | var ATTRIBUTE_NAME_CHAR = ATTRIBUTE_NAME_START_CHAR + '\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040';
|
1434 | var isCustomAttribute = RegExp.prototype.test.bind(new RegExp('^(data|aria)-[' + ATTRIBUTE_NAME_CHAR + ']*$'));
|
1435 |
|
1436 | var isSvgTag = function (tagName) {
|
1437 | return (
|
1438 |
|
1439 |
|
1440 |
|
1441 |
|
1442 |
|
1443 | tagName === 'svg' || supportedHtmlTagNames.indexOf(tagName) === -1 && supportedSVGTagNames.indexOf(tagName) !== -1
|
1444 | );
|
1445 | };
|
1446 | var isHtmlProp = function (name, tagName) {
|
1447 | var elementAttributes = void 0;
|
1448 |
|
1449 | if (isSvgTag(tagName)) {
|
1450 |
|
1451 | elementAttributes = reactHTMLAttributes.svg;
|
1452 | } else {
|
1453 | elementAttributes = reactHTMLAttributes[tagName] || [];
|
1454 | }
|
1455 |
|
1456 | return globalReactHtmlProps.indexOf(name) !== -1 || elementAttributes.indexOf(name) !== -1;
|
1457 | };
|
1458 | var isCssProp = function (name) {
|
1459 | return cssProps.indexOf(name) !== -1;
|
1460 | };
|
1461 | var isReactProp = function (name) {
|
1462 | return reactProps.indexOf(name) !== -1;
|
1463 | };
|
1464 |
|
1465 |
|
1466 | var shouldForwardProperty = function (tagName, name) {
|
1467 | return typeof tagName !== 'string' || (isHtmlProp(name, tagName) || isReactProp(name) || isCustomAttribute(name.toLowerCase())) && (!isCssProp(name) || isSvgTag(tagName));
|
1468 | };
|
1469 |
|
1470 | var shouldForwardProperty$1 = src(shouldForwardProperty);
|
1471 |
|
1472 |
|
1473 | function splitProps(_ref, _ref2) {
|
1474 | var propsAreCssOverrides = _ref2.propsAreCssOverrides,
|
1475 | rootEl = _ref2.rootEl,
|
1476 | filterProps = _ref2.filterProps,
|
1477 | forwardProps = _ref2.forwardProps;
|
1478 | var cssProp = _ref.css,
|
1479 | innerRef = _ref.innerRef,
|
1480 | theme = _ref.theme,
|
1481 | className = _ref.className,
|
1482 | glam = _ref.glam,
|
1483 | rest = objectWithoutProperties(_ref, ['css', 'innerRef', 'theme', 'className', 'glam']);
|
1484 |
|
1485 |
|
1486 | if (innerRef !== undefined && forwardProps.indexOf('innerRef') !== -1) {
|
1487 | rest.innerRef = innerRef;
|
1488 | }
|
1489 | var returnValue = { toForward: {}, cssProp: cssProp, cssOverrides: {} };
|
1490 | if (!propsAreCssOverrides) {
|
1491 | if (typeof rootEl !== 'string' && filterProps.length === 0) {
|
1492 |
|
1493 |
|
1494 | returnValue.toForward = rest;
|
1495 | return returnValue;
|
1496 | }
|
1497 | }
|
1498 | return Object.keys(rest).reduce(function (split, propName) {
|
1499 | if (filterProps.indexOf(propName) !== -1) {
|
1500 | return split;
|
1501 | } else if (forwardProps.indexOf(propName) !== -1 || shouldForwardProperty$1(rootEl, propName)) {
|
1502 | split.toForward[propName] = rest[propName];
|
1503 | } else if (propsAreCssOverrides) {
|
1504 | split.cssOverrides[propName] = rest[propName];
|
1505 | }
|
1506 | return split;
|
1507 | }, returnValue);
|
1508 | }
|
1509 |
|
1510 | var glamorous = createGlamorous(splitProps);
|
1511 |
|
1512 |
|
1513 |
|
1514 |
|
1515 |
|
1516 |
|
1517 |
|
1518 |
|
1519 |
|
1520 |
|
1521 | Object.assign(glamorous, domElements.reduce(function (getters, tag) {
|
1522 |
|
1523 |
|
1524 | getters[tag] = glamorous(tag);
|
1525 | return getters;
|
1526 | }, {}));
|
1527 |
|
1528 |
|
1529 |
|
1530 |
|
1531 |
|
1532 |
|
1533 |
|
1534 |
|
1535 |
|
1536 |
|
1537 |
|
1538 | Object.assign(glamorous, domElements.reduce(function (comps, tag) {
|
1539 | var capitalTag = capitalize(tag);
|
1540 | comps[capitalTag] = glamorous[tag]();
|
1541 | comps[capitalTag].displayName = 'glamorous.' + capitalTag;
|
1542 | comps[capitalTag].propsAreCssOverrides = true;
|
1543 | return comps;
|
1544 | }, {}));
|
1545 |
|
1546 | function capitalize(s) {
|
1547 | return s.slice(0, 1).toUpperCase() + s.slice(1);
|
1548 | }
|
1549 |
|
1550 |
|
1551 |
|
1552 |
|
1553 |
|
1554 |
|
1555 | glamorous.default = glamorous;
|
1556 |
|
1557 |
|
1558 | var glamorousStar = Object.freeze({
|
1559 | default: glamorous,
|
1560 | ThemeProvider: ThemeProvider,
|
1561 | withTheme: withTheme
|
1562 | });
|
1563 |
|
1564 |
|
1565 |
|
1566 | var glamorous$1 = glamorous;
|
1567 |
|
1568 | Object.assign(glamorous$1, Object.keys(glamorousStar).reduce(function (e, prop) {
|
1569 | if (prop !== 'default') {
|
1570 |
|
1571 | e[prop] = glamorousStar[prop];
|
1572 | }
|
1573 | return e;
|
1574 | }, {}));
|
1575 |
|
1576 |
|
1577 |
|
1578 | return glamorous$1;
|
1579 |
|
1580 | })));
|
1581 |
|