@kwantis-id3/frontend-library 0.1.2 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +3 -0
- package/dist/cjs/index.js +2306 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/components/ThemeContext/ThemeContext.d.ts +18 -0
- package/dist/cjs/types/components/button/Button.d.ts +2 -0
- package/dist/esm/index.js +2306 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/components/ThemeContext/ThemeContext.d.ts +18 -0
- package/dist/esm/types/components/button/Button.d.ts +2 -0
- package/dist/index.d.ts +3 -0
- package/package.json +11 -7
package/dist/cjs/index.js
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
function _mergeNamespaces(n, m) {
|
|
4
|
+
m.forEach(function (e) {
|
|
5
|
+
e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {
|
|
6
|
+
if (k !== 'default' && !(k in n)) {
|
|
7
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
8
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function () { return e[k]; }
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
return Object.freeze(n);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function getDefaultExportFromCjs (x) {
|
|
19
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
20
|
+
}
|
|
21
|
+
|
|
3
22
|
var reactExports = {};
|
|
4
23
|
var react = {
|
|
5
24
|
get exports(){ return reactExports; },
|
|
@@ -2804,8 +2823,2294 @@ function requireReact_development () {
|
|
|
2804
2823
|
}
|
|
2805
2824
|
} (react));
|
|
2806
2825
|
|
|
2826
|
+
var React = /*@__PURE__*/getDefaultExportFromCjs(reactExports);
|
|
2827
|
+
|
|
2828
|
+
var React$1 = /*#__PURE__*/_mergeNamespaces({
|
|
2829
|
+
__proto__: null,
|
|
2830
|
+
default: React
|
|
2831
|
+
}, [reactExports]);
|
|
2832
|
+
|
|
2833
|
+
/*
|
|
2834
|
+
|
|
2835
|
+
Based off glamor's StyleSheet, thanks Sunil ❤️
|
|
2836
|
+
|
|
2837
|
+
high performance StyleSheet for css-in-js systems
|
|
2838
|
+
|
|
2839
|
+
- uses multiple style tags behind the scenes for millions of rules
|
|
2840
|
+
- uses `insertRule` for appending in production for *much* faster performance
|
|
2841
|
+
|
|
2842
|
+
// usage
|
|
2843
|
+
|
|
2844
|
+
import { StyleSheet } from '@emotion/sheet'
|
|
2845
|
+
|
|
2846
|
+
let styleSheet = new StyleSheet({ key: '', container: document.head })
|
|
2847
|
+
|
|
2848
|
+
styleSheet.insert('#box { border: 1px solid red; }')
|
|
2849
|
+
- appends a css rule into the stylesheet
|
|
2850
|
+
|
|
2851
|
+
styleSheet.flush()
|
|
2852
|
+
- empties the stylesheet of all its contents
|
|
2853
|
+
|
|
2854
|
+
*/
|
|
2855
|
+
// $FlowFixMe
|
|
2856
|
+
function sheetForTag(tag) {
|
|
2857
|
+
if (tag.sheet) {
|
|
2858
|
+
// $FlowFixMe
|
|
2859
|
+
return tag.sheet;
|
|
2860
|
+
} // this weirdness brought to you by firefox
|
|
2861
|
+
|
|
2862
|
+
/* istanbul ignore next */
|
|
2863
|
+
|
|
2864
|
+
|
|
2865
|
+
for (var i = 0; i < document.styleSheets.length; i++) {
|
|
2866
|
+
if (document.styleSheets[i].ownerNode === tag) {
|
|
2867
|
+
// $FlowFixMe
|
|
2868
|
+
return document.styleSheets[i];
|
|
2869
|
+
}
|
|
2870
|
+
}
|
|
2871
|
+
}
|
|
2872
|
+
|
|
2873
|
+
function createStyleElement(options) {
|
|
2874
|
+
var tag = document.createElement('style');
|
|
2875
|
+
tag.setAttribute('data-emotion', options.key);
|
|
2876
|
+
|
|
2877
|
+
if (options.nonce !== undefined) {
|
|
2878
|
+
tag.setAttribute('nonce', options.nonce);
|
|
2879
|
+
}
|
|
2880
|
+
|
|
2881
|
+
tag.appendChild(document.createTextNode(''));
|
|
2882
|
+
tag.setAttribute('data-s', '');
|
|
2883
|
+
return tag;
|
|
2884
|
+
}
|
|
2885
|
+
|
|
2886
|
+
var StyleSheet = /*#__PURE__*/function () {
|
|
2887
|
+
// Using Node instead of HTMLElement since container may be a ShadowRoot
|
|
2888
|
+
function StyleSheet(options) {
|
|
2889
|
+
var _this = this;
|
|
2890
|
+
|
|
2891
|
+
this._insertTag = function (tag) {
|
|
2892
|
+
var before;
|
|
2893
|
+
|
|
2894
|
+
if (_this.tags.length === 0) {
|
|
2895
|
+
if (_this.insertionPoint) {
|
|
2896
|
+
before = _this.insertionPoint.nextSibling;
|
|
2897
|
+
} else if (_this.prepend) {
|
|
2898
|
+
before = _this.container.firstChild;
|
|
2899
|
+
} else {
|
|
2900
|
+
before = _this.before;
|
|
2901
|
+
}
|
|
2902
|
+
} else {
|
|
2903
|
+
before = _this.tags[_this.tags.length - 1].nextSibling;
|
|
2904
|
+
}
|
|
2905
|
+
|
|
2906
|
+
_this.container.insertBefore(tag, before);
|
|
2907
|
+
|
|
2908
|
+
_this.tags.push(tag);
|
|
2909
|
+
};
|
|
2910
|
+
|
|
2911
|
+
this.isSpeedy = options.speedy === undefined ? process.env.NODE_ENV === 'production' : options.speedy;
|
|
2912
|
+
this.tags = [];
|
|
2913
|
+
this.ctr = 0;
|
|
2914
|
+
this.nonce = options.nonce; // key is the value of the data-emotion attribute, it's used to identify different sheets
|
|
2915
|
+
|
|
2916
|
+
this.key = options.key;
|
|
2917
|
+
this.container = options.container;
|
|
2918
|
+
this.prepend = options.prepend;
|
|
2919
|
+
this.insertionPoint = options.insertionPoint;
|
|
2920
|
+
this.before = null;
|
|
2921
|
+
}
|
|
2922
|
+
|
|
2923
|
+
var _proto = StyleSheet.prototype;
|
|
2924
|
+
|
|
2925
|
+
_proto.hydrate = function hydrate(nodes) {
|
|
2926
|
+
nodes.forEach(this._insertTag);
|
|
2927
|
+
};
|
|
2928
|
+
|
|
2929
|
+
_proto.insert = function insert(rule) {
|
|
2930
|
+
// the max length is how many rules we have per style tag, it's 65000 in speedy mode
|
|
2931
|
+
// it's 1 in dev because we insert source maps that map a single rule to a location
|
|
2932
|
+
// and you can only have one source map per style tag
|
|
2933
|
+
if (this.ctr % (this.isSpeedy ? 65000 : 1) === 0) {
|
|
2934
|
+
this._insertTag(createStyleElement(this));
|
|
2935
|
+
}
|
|
2936
|
+
|
|
2937
|
+
var tag = this.tags[this.tags.length - 1];
|
|
2938
|
+
|
|
2939
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2940
|
+
var isImportRule = rule.charCodeAt(0) === 64 && rule.charCodeAt(1) === 105;
|
|
2941
|
+
|
|
2942
|
+
if (isImportRule && this._alreadyInsertedOrderInsensitiveRule) {
|
|
2943
|
+
// this would only cause problem in speedy mode
|
|
2944
|
+
// but we don't want enabling speedy to affect the observable behavior
|
|
2945
|
+
// so we report this error at all times
|
|
2946
|
+
console.error("You're attempting to insert the following rule:\n" + rule + '\n\n`@import` rules must be before all other types of rules in a stylesheet but other rules have already been inserted. Please ensure that `@import` rules are before all other rules.');
|
|
2947
|
+
}
|
|
2948
|
+
this._alreadyInsertedOrderInsensitiveRule = this._alreadyInsertedOrderInsensitiveRule || !isImportRule;
|
|
2949
|
+
}
|
|
2950
|
+
|
|
2951
|
+
if (this.isSpeedy) {
|
|
2952
|
+
var sheet = sheetForTag(tag);
|
|
2953
|
+
|
|
2954
|
+
try {
|
|
2955
|
+
// this is the ultrafast version, works across browsers
|
|
2956
|
+
// the big drawback is that the css won't be editable in devtools
|
|
2957
|
+
sheet.insertRule(rule, sheet.cssRules.length);
|
|
2958
|
+
} catch (e) {
|
|
2959
|
+
if (process.env.NODE_ENV !== 'production' && !/:(-moz-placeholder|-moz-focus-inner|-moz-focusring|-ms-input-placeholder|-moz-read-write|-moz-read-only|-ms-clear|-ms-expand|-ms-reveal){/.test(rule)) {
|
|
2960
|
+
console.error("There was a problem inserting the following rule: \"" + rule + "\"", e);
|
|
2961
|
+
}
|
|
2962
|
+
}
|
|
2963
|
+
} else {
|
|
2964
|
+
tag.appendChild(document.createTextNode(rule));
|
|
2965
|
+
}
|
|
2966
|
+
|
|
2967
|
+
this.ctr++;
|
|
2968
|
+
};
|
|
2969
|
+
|
|
2970
|
+
_proto.flush = function flush() {
|
|
2971
|
+
// $FlowFixMe
|
|
2972
|
+
this.tags.forEach(function (tag) {
|
|
2973
|
+
return tag.parentNode && tag.parentNode.removeChild(tag);
|
|
2974
|
+
});
|
|
2975
|
+
this.tags = [];
|
|
2976
|
+
this.ctr = 0;
|
|
2977
|
+
|
|
2978
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2979
|
+
this._alreadyInsertedOrderInsensitiveRule = false;
|
|
2980
|
+
}
|
|
2981
|
+
};
|
|
2982
|
+
|
|
2983
|
+
return StyleSheet;
|
|
2984
|
+
}();
|
|
2985
|
+
|
|
2986
|
+
var MS = '-ms-';
|
|
2987
|
+
var MOZ = '-moz-';
|
|
2988
|
+
var WEBKIT = '-webkit-';
|
|
2989
|
+
|
|
2990
|
+
var COMMENT = 'comm';
|
|
2991
|
+
var RULESET = 'rule';
|
|
2992
|
+
var DECLARATION = 'decl';
|
|
2993
|
+
var IMPORT = '@import';
|
|
2994
|
+
var KEYFRAMES = '@keyframes';
|
|
2995
|
+
|
|
2996
|
+
/**
|
|
2997
|
+
* @param {number}
|
|
2998
|
+
* @return {number}
|
|
2999
|
+
*/
|
|
3000
|
+
var abs = Math.abs;
|
|
3001
|
+
|
|
3002
|
+
/**
|
|
3003
|
+
* @param {number}
|
|
3004
|
+
* @return {string}
|
|
3005
|
+
*/
|
|
3006
|
+
var from = String.fromCharCode;
|
|
3007
|
+
|
|
3008
|
+
/**
|
|
3009
|
+
* @param {object}
|
|
3010
|
+
* @return {object}
|
|
3011
|
+
*/
|
|
3012
|
+
var assign = Object.assign;
|
|
3013
|
+
|
|
3014
|
+
/**
|
|
3015
|
+
* @param {string} value
|
|
3016
|
+
* @param {number} length
|
|
3017
|
+
* @return {number}
|
|
3018
|
+
*/
|
|
3019
|
+
function hash (value, length) {
|
|
3020
|
+
return charat(value, 0) ^ 45 ? (((((((length << 2) ^ charat(value, 0)) << 2) ^ charat(value, 1)) << 2) ^ charat(value, 2)) << 2) ^ charat(value, 3) : 0
|
|
3021
|
+
}
|
|
3022
|
+
|
|
3023
|
+
/**
|
|
3024
|
+
* @param {string} value
|
|
3025
|
+
* @return {string}
|
|
3026
|
+
*/
|
|
3027
|
+
function trim (value) {
|
|
3028
|
+
return value.trim()
|
|
3029
|
+
}
|
|
3030
|
+
|
|
3031
|
+
/**
|
|
3032
|
+
* @param {string} value
|
|
3033
|
+
* @param {RegExp} pattern
|
|
3034
|
+
* @return {string?}
|
|
3035
|
+
*/
|
|
3036
|
+
function match (value, pattern) {
|
|
3037
|
+
return (value = pattern.exec(value)) ? value[0] : value
|
|
3038
|
+
}
|
|
3039
|
+
|
|
3040
|
+
/**
|
|
3041
|
+
* @param {string} value
|
|
3042
|
+
* @param {(string|RegExp)} pattern
|
|
3043
|
+
* @param {string} replacement
|
|
3044
|
+
* @return {string}
|
|
3045
|
+
*/
|
|
3046
|
+
function replace (value, pattern, replacement) {
|
|
3047
|
+
return value.replace(pattern, replacement)
|
|
3048
|
+
}
|
|
3049
|
+
|
|
3050
|
+
/**
|
|
3051
|
+
* @param {string} value
|
|
3052
|
+
* @param {string} search
|
|
3053
|
+
* @return {number}
|
|
3054
|
+
*/
|
|
3055
|
+
function indexof (value, search) {
|
|
3056
|
+
return value.indexOf(search)
|
|
3057
|
+
}
|
|
3058
|
+
|
|
3059
|
+
/**
|
|
3060
|
+
* @param {string} value
|
|
3061
|
+
* @param {number} index
|
|
3062
|
+
* @return {number}
|
|
3063
|
+
*/
|
|
3064
|
+
function charat (value, index) {
|
|
3065
|
+
return value.charCodeAt(index) | 0
|
|
3066
|
+
}
|
|
3067
|
+
|
|
3068
|
+
/**
|
|
3069
|
+
* @param {string} value
|
|
3070
|
+
* @param {number} begin
|
|
3071
|
+
* @param {number} end
|
|
3072
|
+
* @return {string}
|
|
3073
|
+
*/
|
|
3074
|
+
function substr (value, begin, end) {
|
|
3075
|
+
return value.slice(begin, end)
|
|
3076
|
+
}
|
|
3077
|
+
|
|
3078
|
+
/**
|
|
3079
|
+
* @param {string} value
|
|
3080
|
+
* @return {number}
|
|
3081
|
+
*/
|
|
3082
|
+
function strlen (value) {
|
|
3083
|
+
return value.length
|
|
3084
|
+
}
|
|
3085
|
+
|
|
3086
|
+
/**
|
|
3087
|
+
* @param {any[]} value
|
|
3088
|
+
* @return {number}
|
|
3089
|
+
*/
|
|
3090
|
+
function sizeof (value) {
|
|
3091
|
+
return value.length
|
|
3092
|
+
}
|
|
3093
|
+
|
|
3094
|
+
/**
|
|
3095
|
+
* @param {any} value
|
|
3096
|
+
* @param {any[]} array
|
|
3097
|
+
* @return {any}
|
|
3098
|
+
*/
|
|
3099
|
+
function append (value, array) {
|
|
3100
|
+
return array.push(value), value
|
|
3101
|
+
}
|
|
3102
|
+
|
|
3103
|
+
/**
|
|
3104
|
+
* @param {string[]} array
|
|
3105
|
+
* @param {function} callback
|
|
3106
|
+
* @return {string}
|
|
3107
|
+
*/
|
|
3108
|
+
function combine (array, callback) {
|
|
3109
|
+
return array.map(callback).join('')
|
|
3110
|
+
}
|
|
3111
|
+
|
|
3112
|
+
var line = 1;
|
|
3113
|
+
var column = 1;
|
|
3114
|
+
var length = 0;
|
|
3115
|
+
var position = 0;
|
|
3116
|
+
var character = 0;
|
|
3117
|
+
var characters = '';
|
|
3118
|
+
|
|
3119
|
+
/**
|
|
3120
|
+
* @param {string} value
|
|
3121
|
+
* @param {object | null} root
|
|
3122
|
+
* @param {object | null} parent
|
|
3123
|
+
* @param {string} type
|
|
3124
|
+
* @param {string[] | string} props
|
|
3125
|
+
* @param {object[] | string} children
|
|
3126
|
+
* @param {number} length
|
|
3127
|
+
*/
|
|
3128
|
+
function node (value, root, parent, type, props, children, length) {
|
|
3129
|
+
return {value: value, root: root, parent: parent, type: type, props: props, children: children, line: line, column: column, length: length, return: ''}
|
|
3130
|
+
}
|
|
3131
|
+
|
|
3132
|
+
/**
|
|
3133
|
+
* @param {object} root
|
|
3134
|
+
* @param {object} props
|
|
3135
|
+
* @return {object}
|
|
3136
|
+
*/
|
|
3137
|
+
function copy (root, props) {
|
|
3138
|
+
return assign(node('', null, null, '', null, null, 0), root, {length: -root.length}, props)
|
|
3139
|
+
}
|
|
3140
|
+
|
|
3141
|
+
/**
|
|
3142
|
+
* @return {number}
|
|
3143
|
+
*/
|
|
3144
|
+
function char () {
|
|
3145
|
+
return character
|
|
3146
|
+
}
|
|
3147
|
+
|
|
3148
|
+
/**
|
|
3149
|
+
* @return {number}
|
|
3150
|
+
*/
|
|
3151
|
+
function prev () {
|
|
3152
|
+
character = position > 0 ? charat(characters, --position) : 0;
|
|
3153
|
+
|
|
3154
|
+
if (column--, character === 10)
|
|
3155
|
+
column = 1, line--;
|
|
3156
|
+
|
|
3157
|
+
return character
|
|
3158
|
+
}
|
|
3159
|
+
|
|
3160
|
+
/**
|
|
3161
|
+
* @return {number}
|
|
3162
|
+
*/
|
|
3163
|
+
function next () {
|
|
3164
|
+
character = position < length ? charat(characters, position++) : 0;
|
|
3165
|
+
|
|
3166
|
+
if (column++, character === 10)
|
|
3167
|
+
column = 1, line++;
|
|
3168
|
+
|
|
3169
|
+
return character
|
|
3170
|
+
}
|
|
3171
|
+
|
|
3172
|
+
/**
|
|
3173
|
+
* @return {number}
|
|
3174
|
+
*/
|
|
3175
|
+
function peek () {
|
|
3176
|
+
return charat(characters, position)
|
|
3177
|
+
}
|
|
3178
|
+
|
|
3179
|
+
/**
|
|
3180
|
+
* @return {number}
|
|
3181
|
+
*/
|
|
3182
|
+
function caret () {
|
|
3183
|
+
return position
|
|
3184
|
+
}
|
|
3185
|
+
|
|
3186
|
+
/**
|
|
3187
|
+
* @param {number} begin
|
|
3188
|
+
* @param {number} end
|
|
3189
|
+
* @return {string}
|
|
3190
|
+
*/
|
|
3191
|
+
function slice (begin, end) {
|
|
3192
|
+
return substr(characters, begin, end)
|
|
3193
|
+
}
|
|
3194
|
+
|
|
3195
|
+
/**
|
|
3196
|
+
* @param {number} type
|
|
3197
|
+
* @return {number}
|
|
3198
|
+
*/
|
|
3199
|
+
function token (type) {
|
|
3200
|
+
switch (type) {
|
|
3201
|
+
// \0 \t \n \r \s whitespace token
|
|
3202
|
+
case 0: case 9: case 10: case 13: case 32:
|
|
3203
|
+
return 5
|
|
3204
|
+
// ! + , / > @ ~ isolate token
|
|
3205
|
+
case 33: case 43: case 44: case 47: case 62: case 64: case 126:
|
|
3206
|
+
// ; { } breakpoint token
|
|
3207
|
+
case 59: case 123: case 125:
|
|
3208
|
+
return 4
|
|
3209
|
+
// : accompanied token
|
|
3210
|
+
case 58:
|
|
3211
|
+
return 3
|
|
3212
|
+
// " ' ( [ opening delimit token
|
|
3213
|
+
case 34: case 39: case 40: case 91:
|
|
3214
|
+
return 2
|
|
3215
|
+
// ) ] closing delimit token
|
|
3216
|
+
case 41: case 93:
|
|
3217
|
+
return 1
|
|
3218
|
+
}
|
|
3219
|
+
|
|
3220
|
+
return 0
|
|
3221
|
+
}
|
|
3222
|
+
|
|
3223
|
+
/**
|
|
3224
|
+
* @param {string} value
|
|
3225
|
+
* @return {any[]}
|
|
3226
|
+
*/
|
|
3227
|
+
function alloc (value) {
|
|
3228
|
+
return line = column = 1, length = strlen(characters = value), position = 0, []
|
|
3229
|
+
}
|
|
3230
|
+
|
|
3231
|
+
/**
|
|
3232
|
+
* @param {any} value
|
|
3233
|
+
* @return {any}
|
|
3234
|
+
*/
|
|
3235
|
+
function dealloc (value) {
|
|
3236
|
+
return characters = '', value
|
|
3237
|
+
}
|
|
3238
|
+
|
|
3239
|
+
/**
|
|
3240
|
+
* @param {number} type
|
|
3241
|
+
* @return {string}
|
|
3242
|
+
*/
|
|
3243
|
+
function delimit (type) {
|
|
3244
|
+
return trim(slice(position - 1, delimiter(type === 91 ? type + 2 : type === 40 ? type + 1 : type)))
|
|
3245
|
+
}
|
|
3246
|
+
|
|
3247
|
+
/**
|
|
3248
|
+
* @param {number} type
|
|
3249
|
+
* @return {string}
|
|
3250
|
+
*/
|
|
3251
|
+
function whitespace (type) {
|
|
3252
|
+
while (character = peek())
|
|
3253
|
+
if (character < 33)
|
|
3254
|
+
next();
|
|
3255
|
+
else
|
|
3256
|
+
break
|
|
3257
|
+
|
|
3258
|
+
return token(type) > 2 || token(character) > 3 ? '' : ' '
|
|
3259
|
+
}
|
|
3260
|
+
|
|
3261
|
+
/**
|
|
3262
|
+
* @param {number} index
|
|
3263
|
+
* @param {number} count
|
|
3264
|
+
* @return {string}
|
|
3265
|
+
*/
|
|
3266
|
+
function escaping (index, count) {
|
|
3267
|
+
while (--count && next())
|
|
3268
|
+
// not 0-9 A-F a-f
|
|
3269
|
+
if (character < 48 || character > 102 || (character > 57 && character < 65) || (character > 70 && character < 97))
|
|
3270
|
+
break
|
|
3271
|
+
|
|
3272
|
+
return slice(index, caret() + (count < 6 && peek() == 32 && next() == 32))
|
|
3273
|
+
}
|
|
3274
|
+
|
|
3275
|
+
/**
|
|
3276
|
+
* @param {number} type
|
|
3277
|
+
* @return {number}
|
|
3278
|
+
*/
|
|
3279
|
+
function delimiter (type) {
|
|
3280
|
+
while (next())
|
|
3281
|
+
switch (character) {
|
|
3282
|
+
// ] ) " '
|
|
3283
|
+
case type:
|
|
3284
|
+
return position
|
|
3285
|
+
// " '
|
|
3286
|
+
case 34: case 39:
|
|
3287
|
+
if (type !== 34 && type !== 39)
|
|
3288
|
+
delimiter(character);
|
|
3289
|
+
break
|
|
3290
|
+
// (
|
|
3291
|
+
case 40:
|
|
3292
|
+
if (type === 41)
|
|
3293
|
+
delimiter(type);
|
|
3294
|
+
break
|
|
3295
|
+
// \
|
|
3296
|
+
case 92:
|
|
3297
|
+
next();
|
|
3298
|
+
break
|
|
3299
|
+
}
|
|
3300
|
+
|
|
3301
|
+
return position
|
|
3302
|
+
}
|
|
3303
|
+
|
|
3304
|
+
/**
|
|
3305
|
+
* @param {number} type
|
|
3306
|
+
* @param {number} index
|
|
3307
|
+
* @return {number}
|
|
3308
|
+
*/
|
|
3309
|
+
function commenter (type, index) {
|
|
3310
|
+
while (next())
|
|
3311
|
+
// //
|
|
3312
|
+
if (type + character === 47 + 10)
|
|
3313
|
+
break
|
|
3314
|
+
// /*
|
|
3315
|
+
else if (type + character === 42 + 42 && peek() === 47)
|
|
3316
|
+
break
|
|
3317
|
+
|
|
3318
|
+
return '/*' + slice(index, position - 1) + '*' + from(type === 47 ? type : next())
|
|
3319
|
+
}
|
|
3320
|
+
|
|
3321
|
+
/**
|
|
3322
|
+
* @param {number} index
|
|
3323
|
+
* @return {string}
|
|
3324
|
+
*/
|
|
3325
|
+
function identifier (index) {
|
|
3326
|
+
while (!token(peek()))
|
|
3327
|
+
next();
|
|
3328
|
+
|
|
3329
|
+
return slice(index, position)
|
|
3330
|
+
}
|
|
3331
|
+
|
|
3332
|
+
/**
|
|
3333
|
+
* @param {string} value
|
|
3334
|
+
* @return {object[]}
|
|
3335
|
+
*/
|
|
3336
|
+
function compile (value) {
|
|
3337
|
+
return dealloc(parse('', null, null, null, [''], value = alloc(value), 0, [0], value))
|
|
3338
|
+
}
|
|
3339
|
+
|
|
3340
|
+
/**
|
|
3341
|
+
* @param {string} value
|
|
3342
|
+
* @param {object} root
|
|
3343
|
+
* @param {object?} parent
|
|
3344
|
+
* @param {string[]} rule
|
|
3345
|
+
* @param {string[]} rules
|
|
3346
|
+
* @param {string[]} rulesets
|
|
3347
|
+
* @param {number[]} pseudo
|
|
3348
|
+
* @param {number[]} points
|
|
3349
|
+
* @param {string[]} declarations
|
|
3350
|
+
* @return {object}
|
|
3351
|
+
*/
|
|
3352
|
+
function parse (value, root, parent, rule, rules, rulesets, pseudo, points, declarations) {
|
|
3353
|
+
var index = 0;
|
|
3354
|
+
var offset = 0;
|
|
3355
|
+
var length = pseudo;
|
|
3356
|
+
var atrule = 0;
|
|
3357
|
+
var property = 0;
|
|
3358
|
+
var previous = 0;
|
|
3359
|
+
var variable = 1;
|
|
3360
|
+
var scanning = 1;
|
|
3361
|
+
var ampersand = 1;
|
|
3362
|
+
var character = 0;
|
|
3363
|
+
var type = '';
|
|
3364
|
+
var props = rules;
|
|
3365
|
+
var children = rulesets;
|
|
3366
|
+
var reference = rule;
|
|
3367
|
+
var characters = type;
|
|
3368
|
+
|
|
3369
|
+
while (scanning)
|
|
3370
|
+
switch (previous = character, character = next()) {
|
|
3371
|
+
// (
|
|
3372
|
+
case 40:
|
|
3373
|
+
if (previous != 108 && charat(characters, length - 1) == 58) {
|
|
3374
|
+
if (indexof(characters += replace(delimit(character), '&', '&\f'), '&\f') != -1)
|
|
3375
|
+
ampersand = -1;
|
|
3376
|
+
break
|
|
3377
|
+
}
|
|
3378
|
+
// " ' [
|
|
3379
|
+
case 34: case 39: case 91:
|
|
3380
|
+
characters += delimit(character);
|
|
3381
|
+
break
|
|
3382
|
+
// \t \n \r \s
|
|
3383
|
+
case 9: case 10: case 13: case 32:
|
|
3384
|
+
characters += whitespace(previous);
|
|
3385
|
+
break
|
|
3386
|
+
// \
|
|
3387
|
+
case 92:
|
|
3388
|
+
characters += escaping(caret() - 1, 7);
|
|
3389
|
+
continue
|
|
3390
|
+
// /
|
|
3391
|
+
case 47:
|
|
3392
|
+
switch (peek()) {
|
|
3393
|
+
case 42: case 47:
|
|
3394
|
+
append(comment(commenter(next(), caret()), root, parent), declarations);
|
|
3395
|
+
break
|
|
3396
|
+
default:
|
|
3397
|
+
characters += '/';
|
|
3398
|
+
}
|
|
3399
|
+
break
|
|
3400
|
+
// {
|
|
3401
|
+
case 123 * variable:
|
|
3402
|
+
points[index++] = strlen(characters) * ampersand;
|
|
3403
|
+
// } ; \0
|
|
3404
|
+
case 125 * variable: case 59: case 0:
|
|
3405
|
+
switch (character) {
|
|
3406
|
+
// \0 }
|
|
3407
|
+
case 0: case 125: scanning = 0;
|
|
3408
|
+
// ;
|
|
3409
|
+
case 59 + offset:
|
|
3410
|
+
if (property > 0 && (strlen(characters) - length))
|
|
3411
|
+
append(property > 32 ? declaration(characters + ';', rule, parent, length - 1) : declaration(replace(characters, ' ', '') + ';', rule, parent, length - 2), declarations);
|
|
3412
|
+
break
|
|
3413
|
+
// @ ;
|
|
3414
|
+
case 59: characters += ';';
|
|
3415
|
+
// { rule/at-rule
|
|
3416
|
+
default:
|
|
3417
|
+
append(reference = ruleset(characters, root, parent, index, offset, rules, points, type, props = [], children = [], length), rulesets);
|
|
3418
|
+
|
|
3419
|
+
if (character === 123)
|
|
3420
|
+
if (offset === 0)
|
|
3421
|
+
parse(characters, root, reference, reference, props, rulesets, length, points, children);
|
|
3422
|
+
else
|
|
3423
|
+
switch (atrule === 99 && charat(characters, 3) === 110 ? 100 : atrule) {
|
|
3424
|
+
// d m s
|
|
3425
|
+
case 100: case 109: case 115:
|
|
3426
|
+
parse(value, reference, reference, rule && append(ruleset(value, reference, reference, 0, 0, rules, points, type, rules, props = [], length), children), rules, children, length, points, rule ? props : children);
|
|
3427
|
+
break
|
|
3428
|
+
default:
|
|
3429
|
+
parse(characters, reference, reference, reference, [''], children, 0, points, children);
|
|
3430
|
+
}
|
|
3431
|
+
}
|
|
3432
|
+
|
|
3433
|
+
index = offset = property = 0, variable = ampersand = 1, type = characters = '', length = pseudo;
|
|
3434
|
+
break
|
|
3435
|
+
// :
|
|
3436
|
+
case 58:
|
|
3437
|
+
length = 1 + strlen(characters), property = previous;
|
|
3438
|
+
default:
|
|
3439
|
+
if (variable < 1)
|
|
3440
|
+
if (character == 123)
|
|
3441
|
+
--variable;
|
|
3442
|
+
else if (character == 125 && variable++ == 0 && prev() == 125)
|
|
3443
|
+
continue
|
|
3444
|
+
|
|
3445
|
+
switch (characters += from(character), character * variable) {
|
|
3446
|
+
// &
|
|
3447
|
+
case 38:
|
|
3448
|
+
ampersand = offset > 0 ? 1 : (characters += '\f', -1);
|
|
3449
|
+
break
|
|
3450
|
+
// ,
|
|
3451
|
+
case 44:
|
|
3452
|
+
points[index++] = (strlen(characters) - 1) * ampersand, ampersand = 1;
|
|
3453
|
+
break
|
|
3454
|
+
// @
|
|
3455
|
+
case 64:
|
|
3456
|
+
// -
|
|
3457
|
+
if (peek() === 45)
|
|
3458
|
+
characters += delimit(next());
|
|
3459
|
+
|
|
3460
|
+
atrule = peek(), offset = length = strlen(type = characters += identifier(caret())), character++;
|
|
3461
|
+
break
|
|
3462
|
+
// -
|
|
3463
|
+
case 45:
|
|
3464
|
+
if (previous === 45 && strlen(characters) == 2)
|
|
3465
|
+
variable = 0;
|
|
3466
|
+
}
|
|
3467
|
+
}
|
|
3468
|
+
|
|
3469
|
+
return rulesets
|
|
3470
|
+
}
|
|
3471
|
+
|
|
3472
|
+
/**
|
|
3473
|
+
* @param {string} value
|
|
3474
|
+
* @param {object} root
|
|
3475
|
+
* @param {object?} parent
|
|
3476
|
+
* @param {number} index
|
|
3477
|
+
* @param {number} offset
|
|
3478
|
+
* @param {string[]} rules
|
|
3479
|
+
* @param {number[]} points
|
|
3480
|
+
* @param {string} type
|
|
3481
|
+
* @param {string[]} props
|
|
3482
|
+
* @param {string[]} children
|
|
3483
|
+
* @param {number} length
|
|
3484
|
+
* @return {object}
|
|
3485
|
+
*/
|
|
3486
|
+
function ruleset (value, root, parent, index, offset, rules, points, type, props, children, length) {
|
|
3487
|
+
var post = offset - 1;
|
|
3488
|
+
var rule = offset === 0 ? rules : [''];
|
|
3489
|
+
var size = sizeof(rule);
|
|
3490
|
+
|
|
3491
|
+
for (var i = 0, j = 0, k = 0; i < index; ++i)
|
|
3492
|
+
for (var x = 0, y = substr(value, post + 1, post = abs(j = points[i])), z = value; x < size; ++x)
|
|
3493
|
+
if (z = trim(j > 0 ? rule[x] + ' ' + y : replace(y, /&\f/g, rule[x])))
|
|
3494
|
+
props[k++] = z;
|
|
3495
|
+
|
|
3496
|
+
return node(value, root, parent, offset === 0 ? RULESET : type, props, children, length)
|
|
3497
|
+
}
|
|
3498
|
+
|
|
3499
|
+
/**
|
|
3500
|
+
* @param {number} value
|
|
3501
|
+
* @param {object} root
|
|
3502
|
+
* @param {object?} parent
|
|
3503
|
+
* @return {object}
|
|
3504
|
+
*/
|
|
3505
|
+
function comment (value, root, parent) {
|
|
3506
|
+
return node(value, root, parent, COMMENT, from(char()), substr(value, 2, -2), 0)
|
|
3507
|
+
}
|
|
3508
|
+
|
|
3509
|
+
/**
|
|
3510
|
+
* @param {string} value
|
|
3511
|
+
* @param {object} root
|
|
3512
|
+
* @param {object?} parent
|
|
3513
|
+
* @param {number} length
|
|
3514
|
+
* @return {object}
|
|
3515
|
+
*/
|
|
3516
|
+
function declaration (value, root, parent, length) {
|
|
3517
|
+
return node(value, root, parent, DECLARATION, substr(value, 0, length), substr(value, length + 1, -1), length)
|
|
3518
|
+
}
|
|
3519
|
+
|
|
3520
|
+
/**
|
|
3521
|
+
* @param {object[]} children
|
|
3522
|
+
* @param {function} callback
|
|
3523
|
+
* @return {string}
|
|
3524
|
+
*/
|
|
3525
|
+
function serialize (children, callback) {
|
|
3526
|
+
var output = '';
|
|
3527
|
+
var length = sizeof(children);
|
|
3528
|
+
|
|
3529
|
+
for (var i = 0; i < length; i++)
|
|
3530
|
+
output += callback(children[i], i, children, callback) || '';
|
|
3531
|
+
|
|
3532
|
+
return output
|
|
3533
|
+
}
|
|
3534
|
+
|
|
3535
|
+
/**
|
|
3536
|
+
* @param {object} element
|
|
3537
|
+
* @param {number} index
|
|
3538
|
+
* @param {object[]} children
|
|
3539
|
+
* @param {function} callback
|
|
3540
|
+
* @return {string}
|
|
3541
|
+
*/
|
|
3542
|
+
function stringify (element, index, children, callback) {
|
|
3543
|
+
switch (element.type) {
|
|
3544
|
+
case IMPORT: case DECLARATION: return element.return = element.return || element.value
|
|
3545
|
+
case COMMENT: return ''
|
|
3546
|
+
case KEYFRAMES: return element.return = element.value + '{' + serialize(element.children, callback) + '}'
|
|
3547
|
+
case RULESET: element.value = element.props.join(',');
|
|
3548
|
+
}
|
|
3549
|
+
|
|
3550
|
+
return strlen(children = serialize(element.children, callback)) ? element.return = element.value + '{' + children + '}' : ''
|
|
3551
|
+
}
|
|
3552
|
+
|
|
3553
|
+
/**
|
|
3554
|
+
* @param {function[]} collection
|
|
3555
|
+
* @return {function}
|
|
3556
|
+
*/
|
|
3557
|
+
function middleware (collection) {
|
|
3558
|
+
var length = sizeof(collection);
|
|
3559
|
+
|
|
3560
|
+
return function (element, index, children, callback) {
|
|
3561
|
+
var output = '';
|
|
3562
|
+
|
|
3563
|
+
for (var i = 0; i < length; i++)
|
|
3564
|
+
output += collection[i](element, index, children, callback) || '';
|
|
3565
|
+
|
|
3566
|
+
return output
|
|
3567
|
+
}
|
|
3568
|
+
}
|
|
3569
|
+
|
|
3570
|
+
/**
|
|
3571
|
+
* @param {function} callback
|
|
3572
|
+
* @return {function}
|
|
3573
|
+
*/
|
|
3574
|
+
function rulesheet (callback) {
|
|
3575
|
+
return function (element) {
|
|
3576
|
+
if (!element.root)
|
|
3577
|
+
if (element = element.return)
|
|
3578
|
+
callback(element);
|
|
3579
|
+
}
|
|
3580
|
+
}
|
|
3581
|
+
|
|
3582
|
+
var weakMemoize = function weakMemoize(func) {
|
|
3583
|
+
// $FlowFixMe flow doesn't include all non-primitive types as allowed for weakmaps
|
|
3584
|
+
var cache = new WeakMap();
|
|
3585
|
+
return function (arg) {
|
|
3586
|
+
if (cache.has(arg)) {
|
|
3587
|
+
// $FlowFixMe
|
|
3588
|
+
return cache.get(arg);
|
|
3589
|
+
}
|
|
3590
|
+
|
|
3591
|
+
var ret = func(arg);
|
|
3592
|
+
cache.set(arg, ret);
|
|
3593
|
+
return ret;
|
|
3594
|
+
};
|
|
3595
|
+
};
|
|
3596
|
+
|
|
3597
|
+
function memoize(fn) {
|
|
3598
|
+
var cache = Object.create(null);
|
|
3599
|
+
return function (arg) {
|
|
3600
|
+
if (cache[arg] === undefined) cache[arg] = fn(arg);
|
|
3601
|
+
return cache[arg];
|
|
3602
|
+
};
|
|
3603
|
+
}
|
|
3604
|
+
|
|
3605
|
+
var identifierWithPointTracking = function identifierWithPointTracking(begin, points, index) {
|
|
3606
|
+
var previous = 0;
|
|
3607
|
+
var character = 0;
|
|
3608
|
+
|
|
3609
|
+
while (true) {
|
|
3610
|
+
previous = character;
|
|
3611
|
+
character = peek(); // &\f
|
|
3612
|
+
|
|
3613
|
+
if (previous === 38 && character === 12) {
|
|
3614
|
+
points[index] = 1;
|
|
3615
|
+
}
|
|
3616
|
+
|
|
3617
|
+
if (token(character)) {
|
|
3618
|
+
break;
|
|
3619
|
+
}
|
|
3620
|
+
|
|
3621
|
+
next();
|
|
3622
|
+
}
|
|
3623
|
+
|
|
3624
|
+
return slice(begin, position);
|
|
3625
|
+
};
|
|
3626
|
+
|
|
3627
|
+
var toRules = function toRules(parsed, points) {
|
|
3628
|
+
// pretend we've started with a comma
|
|
3629
|
+
var index = -1;
|
|
3630
|
+
var character = 44;
|
|
3631
|
+
|
|
3632
|
+
do {
|
|
3633
|
+
switch (token(character)) {
|
|
3634
|
+
case 0:
|
|
3635
|
+
// &\f
|
|
3636
|
+
if (character === 38 && peek() === 12) {
|
|
3637
|
+
// this is not 100% correct, we don't account for literal sequences here - like for example quoted strings
|
|
3638
|
+
// stylis inserts \f after & to know when & where it should replace this sequence with the context selector
|
|
3639
|
+
// and when it should just concatenate the outer and inner selectors
|
|
3640
|
+
// it's very unlikely for this sequence to actually appear in a different context, so we just leverage this fact here
|
|
3641
|
+
points[index] = 1;
|
|
3642
|
+
}
|
|
3643
|
+
|
|
3644
|
+
parsed[index] += identifierWithPointTracking(position - 1, points, index);
|
|
3645
|
+
break;
|
|
3646
|
+
|
|
3647
|
+
case 2:
|
|
3648
|
+
parsed[index] += delimit(character);
|
|
3649
|
+
break;
|
|
3650
|
+
|
|
3651
|
+
case 4:
|
|
3652
|
+
// comma
|
|
3653
|
+
if (character === 44) {
|
|
3654
|
+
// colon
|
|
3655
|
+
parsed[++index] = peek() === 58 ? '&\f' : '';
|
|
3656
|
+
points[index] = parsed[index].length;
|
|
3657
|
+
break;
|
|
3658
|
+
}
|
|
3659
|
+
|
|
3660
|
+
// fallthrough
|
|
3661
|
+
|
|
3662
|
+
default:
|
|
3663
|
+
parsed[index] += from(character);
|
|
3664
|
+
}
|
|
3665
|
+
} while (character = next());
|
|
3666
|
+
|
|
3667
|
+
return parsed;
|
|
3668
|
+
};
|
|
3669
|
+
|
|
3670
|
+
var getRules = function getRules(value, points) {
|
|
3671
|
+
return dealloc(toRules(alloc(value), points));
|
|
3672
|
+
}; // WeakSet would be more appropriate, but only WeakMap is supported in IE11
|
|
3673
|
+
|
|
3674
|
+
|
|
3675
|
+
var fixedElements = /* #__PURE__ */new WeakMap();
|
|
3676
|
+
var compat = function compat(element) {
|
|
3677
|
+
if (element.type !== 'rule' || !element.parent || // positive .length indicates that this rule contains pseudo
|
|
3678
|
+
// negative .length indicates that this rule has been already prefixed
|
|
3679
|
+
element.length < 1) {
|
|
3680
|
+
return;
|
|
3681
|
+
}
|
|
3682
|
+
|
|
3683
|
+
var value = element.value,
|
|
3684
|
+
parent = element.parent;
|
|
3685
|
+
var isImplicitRule = element.column === parent.column && element.line === parent.line;
|
|
3686
|
+
|
|
3687
|
+
while (parent.type !== 'rule') {
|
|
3688
|
+
parent = parent.parent;
|
|
3689
|
+
if (!parent) return;
|
|
3690
|
+
} // short-circuit for the simplest case
|
|
3691
|
+
|
|
3692
|
+
|
|
3693
|
+
if (element.props.length === 1 && value.charCodeAt(0) !== 58
|
|
3694
|
+
/* colon */
|
|
3695
|
+
&& !fixedElements.get(parent)) {
|
|
3696
|
+
return;
|
|
3697
|
+
} // if this is an implicitly inserted rule (the one eagerly inserted at the each new nested level)
|
|
3698
|
+
// then the props has already been manipulated beforehand as they that array is shared between it and its "rule parent"
|
|
3699
|
+
|
|
3700
|
+
|
|
3701
|
+
if (isImplicitRule) {
|
|
3702
|
+
return;
|
|
3703
|
+
}
|
|
3704
|
+
|
|
3705
|
+
fixedElements.set(element, true);
|
|
3706
|
+
var points = [];
|
|
3707
|
+
var rules = getRules(value, points);
|
|
3708
|
+
var parentRules = parent.props;
|
|
3709
|
+
|
|
3710
|
+
for (var i = 0, k = 0; i < rules.length; i++) {
|
|
3711
|
+
for (var j = 0; j < parentRules.length; j++, k++) {
|
|
3712
|
+
element.props[k] = points[i] ? rules[i].replace(/&\f/g, parentRules[j]) : parentRules[j] + " " + rules[i];
|
|
3713
|
+
}
|
|
3714
|
+
}
|
|
3715
|
+
};
|
|
3716
|
+
var removeLabel = function removeLabel(element) {
|
|
3717
|
+
if (element.type === 'decl') {
|
|
3718
|
+
var value = element.value;
|
|
3719
|
+
|
|
3720
|
+
if ( // charcode for l
|
|
3721
|
+
value.charCodeAt(0) === 108 && // charcode for b
|
|
3722
|
+
value.charCodeAt(2) === 98) {
|
|
3723
|
+
// this ignores label
|
|
3724
|
+
element["return"] = '';
|
|
3725
|
+
element.value = '';
|
|
3726
|
+
}
|
|
3727
|
+
}
|
|
3728
|
+
};
|
|
3729
|
+
var ignoreFlag = 'emotion-disable-server-rendering-unsafe-selector-warning-please-do-not-use-this-the-warning-exists-for-a-reason';
|
|
3730
|
+
|
|
3731
|
+
var isIgnoringComment = function isIgnoringComment(element) {
|
|
3732
|
+
return element.type === 'comm' && element.children.indexOf(ignoreFlag) > -1;
|
|
3733
|
+
};
|
|
3734
|
+
|
|
3735
|
+
var createUnsafeSelectorsAlarm = function createUnsafeSelectorsAlarm(cache) {
|
|
3736
|
+
return function (element, index, children) {
|
|
3737
|
+
if (element.type !== 'rule' || cache.compat) return;
|
|
3738
|
+
var unsafePseudoClasses = element.value.match(/(:first|:nth|:nth-last)-child/g);
|
|
3739
|
+
|
|
3740
|
+
if (unsafePseudoClasses) {
|
|
3741
|
+
var isNested = !!element.parent; // in nested rules comments become children of the "auto-inserted" rule and that's always the `element.parent`
|
|
3742
|
+
//
|
|
3743
|
+
// considering this input:
|
|
3744
|
+
// .a {
|
|
3745
|
+
// .b /* comm */ {}
|
|
3746
|
+
// color: hotpink;
|
|
3747
|
+
// }
|
|
3748
|
+
// we get output corresponding to this:
|
|
3749
|
+
// .a {
|
|
3750
|
+
// & {
|
|
3751
|
+
// /* comm */
|
|
3752
|
+
// color: hotpink;
|
|
3753
|
+
// }
|
|
3754
|
+
// .b {}
|
|
3755
|
+
// }
|
|
3756
|
+
|
|
3757
|
+
var commentContainer = isNested ? element.parent.children : // global rule at the root level
|
|
3758
|
+
children;
|
|
3759
|
+
|
|
3760
|
+
for (var i = commentContainer.length - 1; i >= 0; i--) {
|
|
3761
|
+
var node = commentContainer[i];
|
|
3762
|
+
|
|
3763
|
+
if (node.line < element.line) {
|
|
3764
|
+
break;
|
|
3765
|
+
} // it is quite weird but comments are *usually* put at `column: element.column - 1`
|
|
3766
|
+
// so we seek *from the end* for the node that is earlier than the rule's `element` and check that
|
|
3767
|
+
// this will also match inputs like this:
|
|
3768
|
+
// .a {
|
|
3769
|
+
// /* comm */
|
|
3770
|
+
// .b {}
|
|
3771
|
+
// }
|
|
3772
|
+
//
|
|
3773
|
+
// but that is fine
|
|
3774
|
+
//
|
|
3775
|
+
// it would be the easiest to change the placement of the comment to be the first child of the rule:
|
|
3776
|
+
// .a {
|
|
3777
|
+
// .b { /* comm */ }
|
|
3778
|
+
// }
|
|
3779
|
+
// with such inputs we wouldn't have to search for the comment at all
|
|
3780
|
+
// TODO: consider changing this comment placement in the next major version
|
|
3781
|
+
|
|
3782
|
+
|
|
3783
|
+
if (node.column < element.column) {
|
|
3784
|
+
if (isIgnoringComment(node)) {
|
|
3785
|
+
return;
|
|
3786
|
+
}
|
|
3787
|
+
|
|
3788
|
+
break;
|
|
3789
|
+
}
|
|
3790
|
+
}
|
|
3791
|
+
|
|
3792
|
+
unsafePseudoClasses.forEach(function (unsafePseudoClass) {
|
|
3793
|
+
console.error("The pseudo class \"" + unsafePseudoClass + "\" is potentially unsafe when doing server-side rendering. Try changing it to \"" + unsafePseudoClass.split('-child')[0] + "-of-type\".");
|
|
3794
|
+
});
|
|
3795
|
+
}
|
|
3796
|
+
};
|
|
3797
|
+
};
|
|
3798
|
+
|
|
3799
|
+
var isImportRule = function isImportRule(element) {
|
|
3800
|
+
return element.type.charCodeAt(1) === 105 && element.type.charCodeAt(0) === 64;
|
|
3801
|
+
};
|
|
3802
|
+
|
|
3803
|
+
var isPrependedWithRegularRules = function isPrependedWithRegularRules(index, children) {
|
|
3804
|
+
for (var i = index - 1; i >= 0; i--) {
|
|
3805
|
+
if (!isImportRule(children[i])) {
|
|
3806
|
+
return true;
|
|
3807
|
+
}
|
|
3808
|
+
}
|
|
3809
|
+
|
|
3810
|
+
return false;
|
|
3811
|
+
}; // use this to remove incorrect elements from further processing
|
|
3812
|
+
// so they don't get handed to the `sheet` (or anything else)
|
|
3813
|
+
// as that could potentially lead to additional logs which in turn could be overhelming to the user
|
|
3814
|
+
|
|
3815
|
+
|
|
3816
|
+
var nullifyElement = function nullifyElement(element) {
|
|
3817
|
+
element.type = '';
|
|
3818
|
+
element.value = '';
|
|
3819
|
+
element["return"] = '';
|
|
3820
|
+
element.children = '';
|
|
3821
|
+
element.props = '';
|
|
3822
|
+
};
|
|
3823
|
+
|
|
3824
|
+
var incorrectImportAlarm = function incorrectImportAlarm(element, index, children) {
|
|
3825
|
+
if (!isImportRule(element)) {
|
|
3826
|
+
return;
|
|
3827
|
+
}
|
|
3828
|
+
|
|
3829
|
+
if (element.parent) {
|
|
3830
|
+
console.error("`@import` rules can't be nested inside other rules. Please move it to the top level and put it before regular rules. Keep in mind that they can only be used within global styles.");
|
|
3831
|
+
nullifyElement(element);
|
|
3832
|
+
} else if (isPrependedWithRegularRules(index, children)) {
|
|
3833
|
+
console.error("`@import` rules can't be after other rules. Please put your `@import` rules before your other rules.");
|
|
3834
|
+
nullifyElement(element);
|
|
3835
|
+
}
|
|
3836
|
+
};
|
|
3837
|
+
|
|
3838
|
+
/* eslint-disable no-fallthrough */
|
|
3839
|
+
|
|
3840
|
+
function prefix(value, length) {
|
|
3841
|
+
switch (hash(value, length)) {
|
|
3842
|
+
// color-adjust
|
|
3843
|
+
case 5103:
|
|
3844
|
+
return WEBKIT + 'print-' + value + value;
|
|
3845
|
+
// animation, animation-(delay|direction|duration|fill-mode|iteration-count|name|play-state|timing-function)
|
|
3846
|
+
|
|
3847
|
+
case 5737:
|
|
3848
|
+
case 4201:
|
|
3849
|
+
case 3177:
|
|
3850
|
+
case 3433:
|
|
3851
|
+
case 1641:
|
|
3852
|
+
case 4457:
|
|
3853
|
+
case 2921: // text-decoration, filter, clip-path, backface-visibility, column, box-decoration-break
|
|
3854
|
+
|
|
3855
|
+
case 5572:
|
|
3856
|
+
case 6356:
|
|
3857
|
+
case 5844:
|
|
3858
|
+
case 3191:
|
|
3859
|
+
case 6645:
|
|
3860
|
+
case 3005: // mask, mask-image, mask-(mode|clip|size), mask-(repeat|origin), mask-position, mask-composite,
|
|
3861
|
+
|
|
3862
|
+
case 6391:
|
|
3863
|
+
case 5879:
|
|
3864
|
+
case 5623:
|
|
3865
|
+
case 6135:
|
|
3866
|
+
case 4599:
|
|
3867
|
+
case 4855: // background-clip, columns, column-(count|fill|gap|rule|rule-color|rule-style|rule-width|span|width)
|
|
3868
|
+
|
|
3869
|
+
case 4215:
|
|
3870
|
+
case 6389:
|
|
3871
|
+
case 5109:
|
|
3872
|
+
case 5365:
|
|
3873
|
+
case 5621:
|
|
3874
|
+
case 3829:
|
|
3875
|
+
return WEBKIT + value + value;
|
|
3876
|
+
// appearance, user-select, transform, hyphens, text-size-adjust
|
|
3877
|
+
|
|
3878
|
+
case 5349:
|
|
3879
|
+
case 4246:
|
|
3880
|
+
case 4810:
|
|
3881
|
+
case 6968:
|
|
3882
|
+
case 2756:
|
|
3883
|
+
return WEBKIT + value + MOZ + value + MS + value + value;
|
|
3884
|
+
// flex, flex-direction
|
|
3885
|
+
|
|
3886
|
+
case 6828:
|
|
3887
|
+
case 4268:
|
|
3888
|
+
return WEBKIT + value + MS + value + value;
|
|
3889
|
+
// order
|
|
3890
|
+
|
|
3891
|
+
case 6165:
|
|
3892
|
+
return WEBKIT + value + MS + 'flex-' + value + value;
|
|
3893
|
+
// align-items
|
|
3894
|
+
|
|
3895
|
+
case 5187:
|
|
3896
|
+
return WEBKIT + value + replace(value, /(\w+).+(:[^]+)/, WEBKIT + 'box-$1$2' + MS + 'flex-$1$2') + value;
|
|
3897
|
+
// align-self
|
|
3898
|
+
|
|
3899
|
+
case 5443:
|
|
3900
|
+
return WEBKIT + value + MS + 'flex-item-' + replace(value, /flex-|-self/, '') + value;
|
|
3901
|
+
// align-content
|
|
3902
|
+
|
|
3903
|
+
case 4675:
|
|
3904
|
+
return WEBKIT + value + MS + 'flex-line-pack' + replace(value, /align-content|flex-|-self/, '') + value;
|
|
3905
|
+
// flex-shrink
|
|
3906
|
+
|
|
3907
|
+
case 5548:
|
|
3908
|
+
return WEBKIT + value + MS + replace(value, 'shrink', 'negative') + value;
|
|
3909
|
+
// flex-basis
|
|
3910
|
+
|
|
3911
|
+
case 5292:
|
|
3912
|
+
return WEBKIT + value + MS + replace(value, 'basis', 'preferred-size') + value;
|
|
3913
|
+
// flex-grow
|
|
3914
|
+
|
|
3915
|
+
case 6060:
|
|
3916
|
+
return WEBKIT + 'box-' + replace(value, '-grow', '') + WEBKIT + value + MS + replace(value, 'grow', 'positive') + value;
|
|
3917
|
+
// transition
|
|
3918
|
+
|
|
3919
|
+
case 4554:
|
|
3920
|
+
return WEBKIT + replace(value, /([^-])(transform)/g, '$1' + WEBKIT + '$2') + value;
|
|
3921
|
+
// cursor
|
|
3922
|
+
|
|
3923
|
+
case 6187:
|
|
3924
|
+
return replace(replace(replace(value, /(zoom-|grab)/, WEBKIT + '$1'), /(image-set)/, WEBKIT + '$1'), value, '') + value;
|
|
3925
|
+
// background, background-image
|
|
3926
|
+
|
|
3927
|
+
case 5495:
|
|
3928
|
+
case 3959:
|
|
3929
|
+
return replace(value, /(image-set\([^]*)/, WEBKIT + '$1' + '$`$1');
|
|
3930
|
+
// justify-content
|
|
3931
|
+
|
|
3932
|
+
case 4968:
|
|
3933
|
+
return replace(replace(value, /(.+:)(flex-)?(.*)/, WEBKIT + 'box-pack:$3' + MS + 'flex-pack:$3'), /s.+-b[^;]+/, 'justify') + WEBKIT + value + value;
|
|
3934
|
+
// (margin|padding)-inline-(start|end)
|
|
3935
|
+
|
|
3936
|
+
case 4095:
|
|
3937
|
+
case 3583:
|
|
3938
|
+
case 4068:
|
|
3939
|
+
case 2532:
|
|
3940
|
+
return replace(value, /(.+)-inline(.+)/, WEBKIT + '$1$2') + value;
|
|
3941
|
+
// (min|max)?(width|height|inline-size|block-size)
|
|
3942
|
+
|
|
3943
|
+
case 8116:
|
|
3944
|
+
case 7059:
|
|
3945
|
+
case 5753:
|
|
3946
|
+
case 5535:
|
|
3947
|
+
case 5445:
|
|
3948
|
+
case 5701:
|
|
3949
|
+
case 4933:
|
|
3950
|
+
case 4677:
|
|
3951
|
+
case 5533:
|
|
3952
|
+
case 5789:
|
|
3953
|
+
case 5021:
|
|
3954
|
+
case 4765:
|
|
3955
|
+
// stretch, max-content, min-content, fill-available
|
|
3956
|
+
if (strlen(value) - 1 - length > 6) switch (charat(value, length + 1)) {
|
|
3957
|
+
// (m)ax-content, (m)in-content
|
|
3958
|
+
case 109:
|
|
3959
|
+
// -
|
|
3960
|
+
if (charat(value, length + 4) !== 45) break;
|
|
3961
|
+
// (f)ill-available, (f)it-content
|
|
3962
|
+
|
|
3963
|
+
case 102:
|
|
3964
|
+
return replace(value, /(.+:)(.+)-([^]+)/, '$1' + WEBKIT + '$2-$3' + '$1' + MOZ + (charat(value, length + 3) == 108 ? '$3' : '$2-$3')) + value;
|
|
3965
|
+
// (s)tretch
|
|
3966
|
+
|
|
3967
|
+
case 115:
|
|
3968
|
+
return ~indexof(value, 'stretch') ? prefix(replace(value, 'stretch', 'fill-available'), length) + value : value;
|
|
3969
|
+
}
|
|
3970
|
+
break;
|
|
3971
|
+
// position: sticky
|
|
3972
|
+
|
|
3973
|
+
case 4949:
|
|
3974
|
+
// (s)ticky?
|
|
3975
|
+
if (charat(value, length + 1) !== 115) break;
|
|
3976
|
+
// display: (flex|inline-flex)
|
|
3977
|
+
|
|
3978
|
+
case 6444:
|
|
3979
|
+
switch (charat(value, strlen(value) - 3 - (~indexof(value, '!important') && 10))) {
|
|
3980
|
+
// stic(k)y
|
|
3981
|
+
case 107:
|
|
3982
|
+
return replace(value, ':', ':' + WEBKIT) + value;
|
|
3983
|
+
// (inline-)?fl(e)x
|
|
3984
|
+
|
|
3985
|
+
case 101:
|
|
3986
|
+
return replace(value, /(.+:)([^;!]+)(;|!.+)?/, '$1' + WEBKIT + (charat(value, 14) === 45 ? 'inline-' : '') + 'box$3' + '$1' + WEBKIT + '$2$3' + '$1' + MS + '$2box$3') + value;
|
|
3987
|
+
}
|
|
3988
|
+
|
|
3989
|
+
break;
|
|
3990
|
+
// writing-mode
|
|
3991
|
+
|
|
3992
|
+
case 5936:
|
|
3993
|
+
switch (charat(value, length + 11)) {
|
|
3994
|
+
// vertical-l(r)
|
|
3995
|
+
case 114:
|
|
3996
|
+
return WEBKIT + value + MS + replace(value, /[svh]\w+-[tblr]{2}/, 'tb') + value;
|
|
3997
|
+
// vertical-r(l)
|
|
3998
|
+
|
|
3999
|
+
case 108:
|
|
4000
|
+
return WEBKIT + value + MS + replace(value, /[svh]\w+-[tblr]{2}/, 'tb-rl') + value;
|
|
4001
|
+
// horizontal(-)tb
|
|
4002
|
+
|
|
4003
|
+
case 45:
|
|
4004
|
+
return WEBKIT + value + MS + replace(value, /[svh]\w+-[tblr]{2}/, 'lr') + value;
|
|
4005
|
+
}
|
|
4006
|
+
|
|
4007
|
+
return WEBKIT + value + MS + value + value;
|
|
4008
|
+
}
|
|
4009
|
+
|
|
4010
|
+
return value;
|
|
4011
|
+
}
|
|
4012
|
+
|
|
4013
|
+
var prefixer = function prefixer(element, index, children, callback) {
|
|
4014
|
+
if (element.length > -1) if (!element["return"]) switch (element.type) {
|
|
4015
|
+
case DECLARATION:
|
|
4016
|
+
element["return"] = prefix(element.value, element.length);
|
|
4017
|
+
break;
|
|
4018
|
+
|
|
4019
|
+
case KEYFRAMES:
|
|
4020
|
+
return serialize([copy(element, {
|
|
4021
|
+
value: replace(element.value, '@', '@' + WEBKIT)
|
|
4022
|
+
})], callback);
|
|
4023
|
+
|
|
4024
|
+
case RULESET:
|
|
4025
|
+
if (element.length) return combine(element.props, function (value) {
|
|
4026
|
+
switch (match(value, /(::plac\w+|:read-\w+)/)) {
|
|
4027
|
+
// :read-(only|write)
|
|
4028
|
+
case ':read-only':
|
|
4029
|
+
case ':read-write':
|
|
4030
|
+
return serialize([copy(element, {
|
|
4031
|
+
props: [replace(value, /:(read-\w+)/, ':' + MOZ + '$1')]
|
|
4032
|
+
})], callback);
|
|
4033
|
+
// :placeholder
|
|
4034
|
+
|
|
4035
|
+
case '::placeholder':
|
|
4036
|
+
return serialize([copy(element, {
|
|
4037
|
+
props: [replace(value, /:(plac\w+)/, ':' + WEBKIT + 'input-$1')]
|
|
4038
|
+
}), copy(element, {
|
|
4039
|
+
props: [replace(value, /:(plac\w+)/, ':' + MOZ + '$1')]
|
|
4040
|
+
}), copy(element, {
|
|
4041
|
+
props: [replace(value, /:(plac\w+)/, MS + 'input-$1')]
|
|
4042
|
+
})], callback);
|
|
4043
|
+
}
|
|
4044
|
+
|
|
4045
|
+
return '';
|
|
4046
|
+
});
|
|
4047
|
+
}
|
|
4048
|
+
};
|
|
4049
|
+
|
|
4050
|
+
var isBrowser$4 = typeof document !== 'undefined';
|
|
4051
|
+
var getServerStylisCache = isBrowser$4 ? undefined : weakMemoize(function () {
|
|
4052
|
+
return memoize(function () {
|
|
4053
|
+
var cache = {};
|
|
4054
|
+
return function (name) {
|
|
4055
|
+
return cache[name];
|
|
4056
|
+
};
|
|
4057
|
+
});
|
|
4058
|
+
});
|
|
4059
|
+
var defaultStylisPlugins = [prefixer];
|
|
4060
|
+
|
|
4061
|
+
var createCache = function createCache(options) {
|
|
4062
|
+
var key = options.key;
|
|
4063
|
+
|
|
4064
|
+
if (process.env.NODE_ENV !== 'production' && !key) {
|
|
4065
|
+
throw new Error("You have to configure `key` for your cache. Please make sure it's unique (and not equal to 'css') as it's used for linking styles to your cache.\n" + "If multiple caches share the same key they might \"fight\" for each other's style elements.");
|
|
4066
|
+
}
|
|
4067
|
+
|
|
4068
|
+
if (isBrowser$4 && key === 'css') {
|
|
4069
|
+
var ssrStyles = document.querySelectorAll("style[data-emotion]:not([data-s])"); // get SSRed styles out of the way of React's hydration
|
|
4070
|
+
// document.head is a safe place to move them to(though note document.head is not necessarily the last place they will be)
|
|
4071
|
+
// note this very very intentionally targets all style elements regardless of the key to ensure
|
|
4072
|
+
// that creating a cache works inside of render of a React component
|
|
4073
|
+
|
|
4074
|
+
Array.prototype.forEach.call(ssrStyles, function (node) {
|
|
4075
|
+
// we want to only move elements which have a space in the data-emotion attribute value
|
|
4076
|
+
// because that indicates that it is an Emotion 11 server-side rendered style elements
|
|
4077
|
+
// while we will already ignore Emotion 11 client-side inserted styles because of the :not([data-s]) part in the selector
|
|
4078
|
+
// Emotion 10 client-side inserted styles did not have data-s (but importantly did not have a space in their data-emotion attributes)
|
|
4079
|
+
// so checking for the space ensures that loading Emotion 11 after Emotion 10 has inserted some styles
|
|
4080
|
+
// will not result in the Emotion 10 styles being destroyed
|
|
4081
|
+
var dataEmotionAttribute = node.getAttribute('data-emotion');
|
|
4082
|
+
|
|
4083
|
+
if (dataEmotionAttribute.indexOf(' ') === -1) {
|
|
4084
|
+
return;
|
|
4085
|
+
}
|
|
4086
|
+
document.head.appendChild(node);
|
|
4087
|
+
node.setAttribute('data-s', '');
|
|
4088
|
+
});
|
|
4089
|
+
}
|
|
4090
|
+
|
|
4091
|
+
var stylisPlugins = options.stylisPlugins || defaultStylisPlugins;
|
|
4092
|
+
|
|
4093
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4094
|
+
// $FlowFixMe
|
|
4095
|
+
if (/[^a-z-]/.test(key)) {
|
|
4096
|
+
throw new Error("Emotion key must only contain lower case alphabetical characters and - but \"" + key + "\" was passed");
|
|
4097
|
+
}
|
|
4098
|
+
}
|
|
4099
|
+
|
|
4100
|
+
var inserted = {};
|
|
4101
|
+
var container;
|
|
4102
|
+
var nodesToHydrate = [];
|
|
4103
|
+
|
|
4104
|
+
if (isBrowser$4) {
|
|
4105
|
+
container = options.container || document.head;
|
|
4106
|
+
Array.prototype.forEach.call( // this means we will ignore elements which don't have a space in them which
|
|
4107
|
+
// means that the style elements we're looking at are only Emotion 11 server-rendered style elements
|
|
4108
|
+
document.querySelectorAll("style[data-emotion^=\"" + key + " \"]"), function (node) {
|
|
4109
|
+
var attrib = node.getAttribute("data-emotion").split(' '); // $FlowFixMe
|
|
4110
|
+
|
|
4111
|
+
for (var i = 1; i < attrib.length; i++) {
|
|
4112
|
+
inserted[attrib[i]] = true;
|
|
4113
|
+
}
|
|
4114
|
+
|
|
4115
|
+
nodesToHydrate.push(node);
|
|
4116
|
+
});
|
|
4117
|
+
}
|
|
4118
|
+
|
|
4119
|
+
var _insert;
|
|
4120
|
+
|
|
4121
|
+
var omnipresentPlugins = [compat, removeLabel];
|
|
4122
|
+
|
|
4123
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4124
|
+
omnipresentPlugins.push(createUnsafeSelectorsAlarm({
|
|
4125
|
+
get compat() {
|
|
4126
|
+
return cache.compat;
|
|
4127
|
+
}
|
|
4128
|
+
|
|
4129
|
+
}), incorrectImportAlarm);
|
|
4130
|
+
}
|
|
4131
|
+
|
|
4132
|
+
if (isBrowser$4) {
|
|
4133
|
+
var currentSheet;
|
|
4134
|
+
var finalizingPlugins = [stringify, process.env.NODE_ENV !== 'production' ? function (element) {
|
|
4135
|
+
if (!element.root) {
|
|
4136
|
+
if (element["return"]) {
|
|
4137
|
+
currentSheet.insert(element["return"]);
|
|
4138
|
+
} else if (element.value && element.type !== COMMENT) {
|
|
4139
|
+
// insert empty rule in non-production environments
|
|
4140
|
+
// so @emotion/jest can grab `key` from the (JS)DOM for caches without any rules inserted yet
|
|
4141
|
+
currentSheet.insert(element.value + "{}");
|
|
4142
|
+
}
|
|
4143
|
+
}
|
|
4144
|
+
} : rulesheet(function (rule) {
|
|
4145
|
+
currentSheet.insert(rule);
|
|
4146
|
+
})];
|
|
4147
|
+
var serializer = middleware(omnipresentPlugins.concat(stylisPlugins, finalizingPlugins));
|
|
4148
|
+
|
|
4149
|
+
var stylis = function stylis(styles) {
|
|
4150
|
+
return serialize(compile(styles), serializer);
|
|
4151
|
+
};
|
|
4152
|
+
|
|
4153
|
+
_insert = function insert(selector, serialized, sheet, shouldCache) {
|
|
4154
|
+
currentSheet = sheet;
|
|
4155
|
+
|
|
4156
|
+
if (process.env.NODE_ENV !== 'production' && serialized.map !== undefined) {
|
|
4157
|
+
currentSheet = {
|
|
4158
|
+
insert: function insert(rule) {
|
|
4159
|
+
sheet.insert(rule + serialized.map);
|
|
4160
|
+
}
|
|
4161
|
+
};
|
|
4162
|
+
}
|
|
4163
|
+
|
|
4164
|
+
stylis(selector ? selector + "{" + serialized.styles + "}" : serialized.styles);
|
|
4165
|
+
|
|
4166
|
+
if (shouldCache) {
|
|
4167
|
+
cache.inserted[serialized.name] = true;
|
|
4168
|
+
}
|
|
4169
|
+
};
|
|
4170
|
+
} else {
|
|
4171
|
+
var _finalizingPlugins = [stringify];
|
|
4172
|
+
|
|
4173
|
+
var _serializer = middleware(omnipresentPlugins.concat(stylisPlugins, _finalizingPlugins));
|
|
4174
|
+
|
|
4175
|
+
var _stylis = function _stylis(styles) {
|
|
4176
|
+
return serialize(compile(styles), _serializer);
|
|
4177
|
+
}; // $FlowFixMe
|
|
4178
|
+
|
|
4179
|
+
|
|
4180
|
+
var serverStylisCache = getServerStylisCache(stylisPlugins)(key);
|
|
4181
|
+
|
|
4182
|
+
var getRules = function getRules(selector, serialized) {
|
|
4183
|
+
var name = serialized.name;
|
|
4184
|
+
|
|
4185
|
+
if (serverStylisCache[name] === undefined) {
|
|
4186
|
+
serverStylisCache[name] = _stylis(selector ? selector + "{" + serialized.styles + "}" : serialized.styles);
|
|
4187
|
+
}
|
|
4188
|
+
|
|
4189
|
+
return serverStylisCache[name];
|
|
4190
|
+
};
|
|
4191
|
+
|
|
4192
|
+
_insert = function _insert(selector, serialized, sheet, shouldCache) {
|
|
4193
|
+
var name = serialized.name;
|
|
4194
|
+
var rules = getRules(selector, serialized);
|
|
4195
|
+
|
|
4196
|
+
if (cache.compat === undefined) {
|
|
4197
|
+
// in regular mode, we don't set the styles on the inserted cache
|
|
4198
|
+
// since we don't need to and that would be wasting memory
|
|
4199
|
+
// we return them so that they are rendered in a style tag
|
|
4200
|
+
if (shouldCache) {
|
|
4201
|
+
cache.inserted[name] = true;
|
|
4202
|
+
}
|
|
4203
|
+
|
|
4204
|
+
if ( // using === development instead of !== production
|
|
4205
|
+
// because if people do ssr in tests, the source maps showing up would be annoying
|
|
4206
|
+
process.env.NODE_ENV === 'development' && serialized.map !== undefined) {
|
|
4207
|
+
return rules + serialized.map;
|
|
4208
|
+
}
|
|
4209
|
+
|
|
4210
|
+
return rules;
|
|
4211
|
+
} else {
|
|
4212
|
+
// in compat mode, we put the styles on the inserted cache so
|
|
4213
|
+
// that emotion-server can pull out the styles
|
|
4214
|
+
// except when we don't want to cache it which was in Global but now
|
|
4215
|
+
// is nowhere but we don't want to do a major right now
|
|
4216
|
+
// and just in case we're going to leave the case here
|
|
4217
|
+
// it's also not affecting client side bundle size
|
|
4218
|
+
// so it's really not a big deal
|
|
4219
|
+
if (shouldCache) {
|
|
4220
|
+
cache.inserted[name] = rules;
|
|
4221
|
+
} else {
|
|
4222
|
+
return rules;
|
|
4223
|
+
}
|
|
4224
|
+
}
|
|
4225
|
+
};
|
|
4226
|
+
}
|
|
4227
|
+
|
|
4228
|
+
var cache = {
|
|
4229
|
+
key: key,
|
|
4230
|
+
sheet: new StyleSheet({
|
|
4231
|
+
key: key,
|
|
4232
|
+
container: container,
|
|
4233
|
+
nonce: options.nonce,
|
|
4234
|
+
speedy: options.speedy,
|
|
4235
|
+
prepend: options.prepend,
|
|
4236
|
+
insertionPoint: options.insertionPoint
|
|
4237
|
+
}),
|
|
4238
|
+
nonce: options.nonce,
|
|
4239
|
+
inserted: inserted,
|
|
4240
|
+
registered: {},
|
|
4241
|
+
insert: _insert
|
|
4242
|
+
};
|
|
4243
|
+
cache.sheet.hydrate(nodesToHydrate);
|
|
4244
|
+
return cache;
|
|
4245
|
+
};
|
|
4246
|
+
|
|
4247
|
+
function _extends() {
|
|
4248
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
4249
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
4250
|
+
var source = arguments[i];
|
|
4251
|
+
for (var key in source) {
|
|
4252
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
4253
|
+
target[key] = source[key];
|
|
4254
|
+
}
|
|
4255
|
+
}
|
|
4256
|
+
}
|
|
4257
|
+
return target;
|
|
4258
|
+
};
|
|
4259
|
+
return _extends.apply(this, arguments);
|
|
4260
|
+
}
|
|
4261
|
+
|
|
4262
|
+
var isBrowser$3 = typeof document !== 'undefined';
|
|
4263
|
+
function getRegisteredStyles(registered, registeredStyles, classNames) {
|
|
4264
|
+
var rawClassName = '';
|
|
4265
|
+
classNames.split(' ').forEach(function (className) {
|
|
4266
|
+
if (registered[className] !== undefined) {
|
|
4267
|
+
registeredStyles.push(registered[className] + ";");
|
|
4268
|
+
} else {
|
|
4269
|
+
rawClassName += className + " ";
|
|
4270
|
+
}
|
|
4271
|
+
});
|
|
4272
|
+
return rawClassName;
|
|
4273
|
+
}
|
|
4274
|
+
var registerStyles = function registerStyles(cache, serialized, isStringTag) {
|
|
4275
|
+
var className = cache.key + "-" + serialized.name;
|
|
4276
|
+
|
|
4277
|
+
if ( // we only need to add the styles to the registered cache if the
|
|
4278
|
+
// class name could be used further down
|
|
4279
|
+
// the tree but if it's a string tag, we know it won't
|
|
4280
|
+
// so we don't have to add it to registered cache.
|
|
4281
|
+
// this improves memory usage since we can avoid storing the whole style string
|
|
4282
|
+
(isStringTag === false || // we need to always store it if we're in compat mode and
|
|
4283
|
+
// in node since emotion-server relies on whether a style is in
|
|
4284
|
+
// the registered cache to know whether a style is global or not
|
|
4285
|
+
// also, note that this check will be dead code eliminated in the browser
|
|
4286
|
+
isBrowser$3 === false && cache.compat !== undefined) && cache.registered[className] === undefined) {
|
|
4287
|
+
cache.registered[className] = serialized.styles;
|
|
4288
|
+
}
|
|
4289
|
+
};
|
|
4290
|
+
var insertStyles = function insertStyles(cache, serialized, isStringTag) {
|
|
4291
|
+
registerStyles(cache, serialized, isStringTag);
|
|
4292
|
+
var className = cache.key + "-" + serialized.name;
|
|
4293
|
+
|
|
4294
|
+
if (cache.inserted[serialized.name] === undefined) {
|
|
4295
|
+
var stylesForSSR = '';
|
|
4296
|
+
var current = serialized;
|
|
4297
|
+
|
|
4298
|
+
do {
|
|
4299
|
+
var maybeStyles = cache.insert(serialized === current ? "." + className : '', current, cache.sheet, true);
|
|
4300
|
+
|
|
4301
|
+
if (!isBrowser$3 && maybeStyles !== undefined) {
|
|
4302
|
+
stylesForSSR += maybeStyles;
|
|
4303
|
+
}
|
|
4304
|
+
|
|
4305
|
+
current = current.next;
|
|
4306
|
+
} while (current !== undefined);
|
|
4307
|
+
|
|
4308
|
+
if (!isBrowser$3 && stylesForSSR.length !== 0) {
|
|
4309
|
+
return stylesForSSR;
|
|
4310
|
+
}
|
|
4311
|
+
}
|
|
4312
|
+
};
|
|
4313
|
+
|
|
4314
|
+
/* eslint-disable */
|
|
4315
|
+
// Inspired by https://github.com/garycourt/murmurhash-js
|
|
4316
|
+
// Ported from https://github.com/aappleby/smhasher/blob/61a0530f28277f2e850bfc39600ce61d02b518de/src/MurmurHash2.cpp#L37-L86
|
|
4317
|
+
function murmur2(str) {
|
|
4318
|
+
// 'm' and 'r' are mixing constants generated offline.
|
|
4319
|
+
// They're not really 'magic', they just happen to work well.
|
|
4320
|
+
// const m = 0x5bd1e995;
|
|
4321
|
+
// const r = 24;
|
|
4322
|
+
// Initialize the hash
|
|
4323
|
+
var h = 0; // Mix 4 bytes at a time into the hash
|
|
4324
|
+
|
|
4325
|
+
var k,
|
|
4326
|
+
i = 0,
|
|
4327
|
+
len = str.length;
|
|
4328
|
+
|
|
4329
|
+
for (; len >= 4; ++i, len -= 4) {
|
|
4330
|
+
k = str.charCodeAt(i) & 0xff | (str.charCodeAt(++i) & 0xff) << 8 | (str.charCodeAt(++i) & 0xff) << 16 | (str.charCodeAt(++i) & 0xff) << 24;
|
|
4331
|
+
k =
|
|
4332
|
+
/* Math.imul(k, m): */
|
|
4333
|
+
(k & 0xffff) * 0x5bd1e995 + ((k >>> 16) * 0xe995 << 16);
|
|
4334
|
+
k ^=
|
|
4335
|
+
/* k >>> r: */
|
|
4336
|
+
k >>> 24;
|
|
4337
|
+
h =
|
|
4338
|
+
/* Math.imul(k, m): */
|
|
4339
|
+
(k & 0xffff) * 0x5bd1e995 + ((k >>> 16) * 0xe995 << 16) ^
|
|
4340
|
+
/* Math.imul(h, m): */
|
|
4341
|
+
(h & 0xffff) * 0x5bd1e995 + ((h >>> 16) * 0xe995 << 16);
|
|
4342
|
+
} // Handle the last few bytes of the input array
|
|
4343
|
+
|
|
4344
|
+
|
|
4345
|
+
switch (len) {
|
|
4346
|
+
case 3:
|
|
4347
|
+
h ^= (str.charCodeAt(i + 2) & 0xff) << 16;
|
|
4348
|
+
|
|
4349
|
+
case 2:
|
|
4350
|
+
h ^= (str.charCodeAt(i + 1) & 0xff) << 8;
|
|
4351
|
+
|
|
4352
|
+
case 1:
|
|
4353
|
+
h ^= str.charCodeAt(i) & 0xff;
|
|
4354
|
+
h =
|
|
4355
|
+
/* Math.imul(h, m): */
|
|
4356
|
+
(h & 0xffff) * 0x5bd1e995 + ((h >>> 16) * 0xe995 << 16);
|
|
4357
|
+
} // Do a few final mixes of the hash to ensure the last few
|
|
4358
|
+
// bytes are well-incorporated.
|
|
4359
|
+
|
|
4360
|
+
|
|
4361
|
+
h ^= h >>> 13;
|
|
4362
|
+
h =
|
|
4363
|
+
/* Math.imul(h, m): */
|
|
4364
|
+
(h & 0xffff) * 0x5bd1e995 + ((h >>> 16) * 0xe995 << 16);
|
|
4365
|
+
return ((h ^ h >>> 15) >>> 0).toString(36);
|
|
4366
|
+
}
|
|
4367
|
+
|
|
4368
|
+
var unitlessKeys = {
|
|
4369
|
+
animationIterationCount: 1,
|
|
4370
|
+
borderImageOutset: 1,
|
|
4371
|
+
borderImageSlice: 1,
|
|
4372
|
+
borderImageWidth: 1,
|
|
4373
|
+
boxFlex: 1,
|
|
4374
|
+
boxFlexGroup: 1,
|
|
4375
|
+
boxOrdinalGroup: 1,
|
|
4376
|
+
columnCount: 1,
|
|
4377
|
+
columns: 1,
|
|
4378
|
+
flex: 1,
|
|
4379
|
+
flexGrow: 1,
|
|
4380
|
+
flexPositive: 1,
|
|
4381
|
+
flexShrink: 1,
|
|
4382
|
+
flexNegative: 1,
|
|
4383
|
+
flexOrder: 1,
|
|
4384
|
+
gridRow: 1,
|
|
4385
|
+
gridRowEnd: 1,
|
|
4386
|
+
gridRowSpan: 1,
|
|
4387
|
+
gridRowStart: 1,
|
|
4388
|
+
gridColumn: 1,
|
|
4389
|
+
gridColumnEnd: 1,
|
|
4390
|
+
gridColumnSpan: 1,
|
|
4391
|
+
gridColumnStart: 1,
|
|
4392
|
+
msGridRow: 1,
|
|
4393
|
+
msGridRowSpan: 1,
|
|
4394
|
+
msGridColumn: 1,
|
|
4395
|
+
msGridColumnSpan: 1,
|
|
4396
|
+
fontWeight: 1,
|
|
4397
|
+
lineHeight: 1,
|
|
4398
|
+
opacity: 1,
|
|
4399
|
+
order: 1,
|
|
4400
|
+
orphans: 1,
|
|
4401
|
+
tabSize: 1,
|
|
4402
|
+
widows: 1,
|
|
4403
|
+
zIndex: 1,
|
|
4404
|
+
zoom: 1,
|
|
4405
|
+
WebkitLineClamp: 1,
|
|
4406
|
+
// SVG-related properties
|
|
4407
|
+
fillOpacity: 1,
|
|
4408
|
+
floodOpacity: 1,
|
|
4409
|
+
stopOpacity: 1,
|
|
4410
|
+
strokeDasharray: 1,
|
|
4411
|
+
strokeDashoffset: 1,
|
|
4412
|
+
strokeMiterlimit: 1,
|
|
4413
|
+
strokeOpacity: 1,
|
|
4414
|
+
strokeWidth: 1
|
|
4415
|
+
};
|
|
4416
|
+
|
|
4417
|
+
var ILLEGAL_ESCAPE_SEQUENCE_ERROR$1 = "You have illegal escape sequence in your template literal, most likely inside content's property value.\nBecause you write your CSS inside a JavaScript string you actually have to do double escaping, so for example \"content: '\\00d7';\" should become \"content: '\\\\00d7';\".\nYou can read more about this here:\nhttps://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#ES2018_revision_of_illegal_escape_sequences";
|
|
4418
|
+
var UNDEFINED_AS_OBJECT_KEY_ERROR = "You have passed in falsy value as style object's key (can happen when in example you pass unexported component as computed key).";
|
|
4419
|
+
var hyphenateRegex = /[A-Z]|^ms/g;
|
|
4420
|
+
var animationRegex = /_EMO_([^_]+?)_([^]*?)_EMO_/g;
|
|
4421
|
+
|
|
4422
|
+
var isCustomProperty = function isCustomProperty(property) {
|
|
4423
|
+
return property.charCodeAt(1) === 45;
|
|
4424
|
+
};
|
|
4425
|
+
|
|
4426
|
+
var isProcessableValue = function isProcessableValue(value) {
|
|
4427
|
+
return value != null && typeof value !== 'boolean';
|
|
4428
|
+
};
|
|
4429
|
+
|
|
4430
|
+
var processStyleName = /* #__PURE__ */memoize(function (styleName) {
|
|
4431
|
+
return isCustomProperty(styleName) ? styleName : styleName.replace(hyphenateRegex, '-$&').toLowerCase();
|
|
4432
|
+
});
|
|
4433
|
+
|
|
4434
|
+
var processStyleValue = function processStyleValue(key, value) {
|
|
4435
|
+
switch (key) {
|
|
4436
|
+
case 'animation':
|
|
4437
|
+
case 'animationName':
|
|
4438
|
+
{
|
|
4439
|
+
if (typeof value === 'string') {
|
|
4440
|
+
return value.replace(animationRegex, function (match, p1, p2) {
|
|
4441
|
+
cursor = {
|
|
4442
|
+
name: p1,
|
|
4443
|
+
styles: p2,
|
|
4444
|
+
next: cursor
|
|
4445
|
+
};
|
|
4446
|
+
return p1;
|
|
4447
|
+
});
|
|
4448
|
+
}
|
|
4449
|
+
}
|
|
4450
|
+
}
|
|
4451
|
+
|
|
4452
|
+
if (unitlessKeys[key] !== 1 && !isCustomProperty(key) && typeof value === 'number' && value !== 0) {
|
|
4453
|
+
return value + 'px';
|
|
4454
|
+
}
|
|
4455
|
+
|
|
4456
|
+
return value;
|
|
4457
|
+
};
|
|
4458
|
+
|
|
4459
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4460
|
+
var contentValuePattern = /(var|attr|counters?|url|element|(((repeating-)?(linear|radial))|conic)-gradient)\(|(no-)?(open|close)-quote/;
|
|
4461
|
+
var contentValues = ['normal', 'none', 'initial', 'inherit', 'unset'];
|
|
4462
|
+
var oldProcessStyleValue = processStyleValue;
|
|
4463
|
+
var msPattern = /^-ms-/;
|
|
4464
|
+
var hyphenPattern = /-(.)/g;
|
|
4465
|
+
var hyphenatedCache = {};
|
|
4466
|
+
|
|
4467
|
+
processStyleValue = function processStyleValue(key, value) {
|
|
4468
|
+
if (key === 'content') {
|
|
4469
|
+
if (typeof value !== 'string' || contentValues.indexOf(value) === -1 && !contentValuePattern.test(value) && (value.charAt(0) !== value.charAt(value.length - 1) || value.charAt(0) !== '"' && value.charAt(0) !== "'")) {
|
|
4470
|
+
throw new Error("You seem to be using a value for 'content' without quotes, try replacing it with `content: '\"" + value + "\"'`");
|
|
4471
|
+
}
|
|
4472
|
+
}
|
|
4473
|
+
|
|
4474
|
+
var processed = oldProcessStyleValue(key, value);
|
|
4475
|
+
|
|
4476
|
+
if (processed !== '' && !isCustomProperty(key) && key.indexOf('-') !== -1 && hyphenatedCache[key] === undefined) {
|
|
4477
|
+
hyphenatedCache[key] = true;
|
|
4478
|
+
console.error("Using kebab-case for css properties in objects is not supported. Did you mean " + key.replace(msPattern, 'ms-').replace(hyphenPattern, function (str, _char) {
|
|
4479
|
+
return _char.toUpperCase();
|
|
4480
|
+
}) + "?");
|
|
4481
|
+
}
|
|
4482
|
+
|
|
4483
|
+
return processed;
|
|
4484
|
+
};
|
|
4485
|
+
}
|
|
4486
|
+
|
|
4487
|
+
var noComponentSelectorMessage = 'Component selectors can only be used in conjunction with ' + '@emotion/babel-plugin, the swc Emotion plugin, or another Emotion-aware ' + 'compiler transform.';
|
|
4488
|
+
|
|
4489
|
+
function handleInterpolation(mergedProps, registered, interpolation) {
|
|
4490
|
+
if (interpolation == null) {
|
|
4491
|
+
return '';
|
|
4492
|
+
}
|
|
4493
|
+
|
|
4494
|
+
if (interpolation.__emotion_styles !== undefined) {
|
|
4495
|
+
if (process.env.NODE_ENV !== 'production' && interpolation.toString() === 'NO_COMPONENT_SELECTOR') {
|
|
4496
|
+
throw new Error(noComponentSelectorMessage);
|
|
4497
|
+
}
|
|
4498
|
+
|
|
4499
|
+
return interpolation;
|
|
4500
|
+
}
|
|
4501
|
+
|
|
4502
|
+
switch (typeof interpolation) {
|
|
4503
|
+
case 'boolean':
|
|
4504
|
+
{
|
|
4505
|
+
return '';
|
|
4506
|
+
}
|
|
4507
|
+
|
|
4508
|
+
case 'object':
|
|
4509
|
+
{
|
|
4510
|
+
if (interpolation.anim === 1) {
|
|
4511
|
+
cursor = {
|
|
4512
|
+
name: interpolation.name,
|
|
4513
|
+
styles: interpolation.styles,
|
|
4514
|
+
next: cursor
|
|
4515
|
+
};
|
|
4516
|
+
return interpolation.name;
|
|
4517
|
+
}
|
|
4518
|
+
|
|
4519
|
+
if (interpolation.styles !== undefined) {
|
|
4520
|
+
var next = interpolation.next;
|
|
4521
|
+
|
|
4522
|
+
if (next !== undefined) {
|
|
4523
|
+
// not the most efficient thing ever but this is a pretty rare case
|
|
4524
|
+
// and there will be very few iterations of this generally
|
|
4525
|
+
while (next !== undefined) {
|
|
4526
|
+
cursor = {
|
|
4527
|
+
name: next.name,
|
|
4528
|
+
styles: next.styles,
|
|
4529
|
+
next: cursor
|
|
4530
|
+
};
|
|
4531
|
+
next = next.next;
|
|
4532
|
+
}
|
|
4533
|
+
}
|
|
4534
|
+
|
|
4535
|
+
var styles = interpolation.styles + ";";
|
|
4536
|
+
|
|
4537
|
+
if (process.env.NODE_ENV !== 'production' && interpolation.map !== undefined) {
|
|
4538
|
+
styles += interpolation.map;
|
|
4539
|
+
}
|
|
4540
|
+
|
|
4541
|
+
return styles;
|
|
4542
|
+
}
|
|
4543
|
+
|
|
4544
|
+
return createStringFromObject(mergedProps, registered, interpolation);
|
|
4545
|
+
}
|
|
4546
|
+
|
|
4547
|
+
case 'function':
|
|
4548
|
+
{
|
|
4549
|
+
if (mergedProps !== undefined) {
|
|
4550
|
+
var previousCursor = cursor;
|
|
4551
|
+
var result = interpolation(mergedProps);
|
|
4552
|
+
cursor = previousCursor;
|
|
4553
|
+
return handleInterpolation(mergedProps, registered, result);
|
|
4554
|
+
} else if (process.env.NODE_ENV !== 'production') {
|
|
4555
|
+
console.error('Functions that are interpolated in css calls will be stringified.\n' + 'If you want to have a css call based on props, create a function that returns a css call like this\n' + 'let dynamicStyle = (props) => css`color: ${props.color}`\n' + 'It can be called directly with props or interpolated in a styled call like this\n' + "let SomeComponent = styled('div')`${dynamicStyle}`");
|
|
4556
|
+
}
|
|
4557
|
+
|
|
4558
|
+
break;
|
|
4559
|
+
}
|
|
4560
|
+
|
|
4561
|
+
case 'string':
|
|
4562
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4563
|
+
var matched = [];
|
|
4564
|
+
var replaced = interpolation.replace(animationRegex, function (match, p1, p2) {
|
|
4565
|
+
var fakeVarName = "animation" + matched.length;
|
|
4566
|
+
matched.push("const " + fakeVarName + " = keyframes`" + p2.replace(/^@keyframes animation-\w+/, '') + "`");
|
|
4567
|
+
return "${" + fakeVarName + "}";
|
|
4568
|
+
});
|
|
4569
|
+
|
|
4570
|
+
if (matched.length) {
|
|
4571
|
+
console.error('`keyframes` output got interpolated into plain string, please wrap it with `css`.\n\n' + 'Instead of doing this:\n\n' + [].concat(matched, ["`" + replaced + "`"]).join('\n') + '\n\nYou should wrap it with `css` like this:\n\n' + ("css`" + replaced + "`"));
|
|
4572
|
+
}
|
|
4573
|
+
}
|
|
4574
|
+
|
|
4575
|
+
break;
|
|
4576
|
+
} // finalize string values (regular strings and functions interpolated into css calls)
|
|
4577
|
+
|
|
4578
|
+
|
|
4579
|
+
if (registered == null) {
|
|
4580
|
+
return interpolation;
|
|
4581
|
+
}
|
|
4582
|
+
|
|
4583
|
+
var cached = registered[interpolation];
|
|
4584
|
+
return cached !== undefined ? cached : interpolation;
|
|
4585
|
+
}
|
|
4586
|
+
|
|
4587
|
+
function createStringFromObject(mergedProps, registered, obj) {
|
|
4588
|
+
var string = '';
|
|
4589
|
+
|
|
4590
|
+
if (Array.isArray(obj)) {
|
|
4591
|
+
for (var i = 0; i < obj.length; i++) {
|
|
4592
|
+
string += handleInterpolation(mergedProps, registered, obj[i]) + ";";
|
|
4593
|
+
}
|
|
4594
|
+
} else {
|
|
4595
|
+
for (var _key in obj) {
|
|
4596
|
+
var value = obj[_key];
|
|
4597
|
+
|
|
4598
|
+
if (typeof value !== 'object') {
|
|
4599
|
+
if (registered != null && registered[value] !== undefined) {
|
|
4600
|
+
string += _key + "{" + registered[value] + "}";
|
|
4601
|
+
} else if (isProcessableValue(value)) {
|
|
4602
|
+
string += processStyleName(_key) + ":" + processStyleValue(_key, value) + ";";
|
|
4603
|
+
}
|
|
4604
|
+
} else {
|
|
4605
|
+
if (_key === 'NO_COMPONENT_SELECTOR' && process.env.NODE_ENV !== 'production') {
|
|
4606
|
+
throw new Error(noComponentSelectorMessage);
|
|
4607
|
+
}
|
|
4608
|
+
|
|
4609
|
+
if (Array.isArray(value) && typeof value[0] === 'string' && (registered == null || registered[value[0]] === undefined)) {
|
|
4610
|
+
for (var _i = 0; _i < value.length; _i++) {
|
|
4611
|
+
if (isProcessableValue(value[_i])) {
|
|
4612
|
+
string += processStyleName(_key) + ":" + processStyleValue(_key, value[_i]) + ";";
|
|
4613
|
+
}
|
|
4614
|
+
}
|
|
4615
|
+
} else {
|
|
4616
|
+
var interpolated = handleInterpolation(mergedProps, registered, value);
|
|
4617
|
+
|
|
4618
|
+
switch (_key) {
|
|
4619
|
+
case 'animation':
|
|
4620
|
+
case 'animationName':
|
|
4621
|
+
{
|
|
4622
|
+
string += processStyleName(_key) + ":" + interpolated + ";";
|
|
4623
|
+
break;
|
|
4624
|
+
}
|
|
4625
|
+
|
|
4626
|
+
default:
|
|
4627
|
+
{
|
|
4628
|
+
if (process.env.NODE_ENV !== 'production' && _key === 'undefined') {
|
|
4629
|
+
console.error(UNDEFINED_AS_OBJECT_KEY_ERROR);
|
|
4630
|
+
}
|
|
4631
|
+
|
|
4632
|
+
string += _key + "{" + interpolated + "}";
|
|
4633
|
+
}
|
|
4634
|
+
}
|
|
4635
|
+
}
|
|
4636
|
+
}
|
|
4637
|
+
}
|
|
4638
|
+
}
|
|
4639
|
+
|
|
4640
|
+
return string;
|
|
4641
|
+
}
|
|
4642
|
+
|
|
4643
|
+
var labelPattern = /label:\s*([^\s;\n{]+)\s*(;|$)/g;
|
|
4644
|
+
var sourceMapPattern;
|
|
4645
|
+
|
|
4646
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4647
|
+
sourceMapPattern = /\/\*#\ssourceMappingURL=data:application\/json;\S+\s+\*\//g;
|
|
4648
|
+
} // this is the cursor for keyframes
|
|
4649
|
+
// keyframes are stored on the SerializedStyles object as a linked list
|
|
4650
|
+
|
|
4651
|
+
|
|
4652
|
+
var cursor;
|
|
4653
|
+
var serializeStyles = function serializeStyles(args, registered, mergedProps) {
|
|
4654
|
+
if (args.length === 1 && typeof args[0] === 'object' && args[0] !== null && args[0].styles !== undefined) {
|
|
4655
|
+
return args[0];
|
|
4656
|
+
}
|
|
4657
|
+
|
|
4658
|
+
var stringMode = true;
|
|
4659
|
+
var styles = '';
|
|
4660
|
+
cursor = undefined;
|
|
4661
|
+
var strings = args[0];
|
|
4662
|
+
|
|
4663
|
+
if (strings == null || strings.raw === undefined) {
|
|
4664
|
+
stringMode = false;
|
|
4665
|
+
styles += handleInterpolation(mergedProps, registered, strings);
|
|
4666
|
+
} else {
|
|
4667
|
+
if (process.env.NODE_ENV !== 'production' && strings[0] === undefined) {
|
|
4668
|
+
console.error(ILLEGAL_ESCAPE_SEQUENCE_ERROR$1);
|
|
4669
|
+
}
|
|
4670
|
+
|
|
4671
|
+
styles += strings[0];
|
|
4672
|
+
} // we start at 1 since we've already handled the first arg
|
|
4673
|
+
|
|
4674
|
+
|
|
4675
|
+
for (var i = 1; i < args.length; i++) {
|
|
4676
|
+
styles += handleInterpolation(mergedProps, registered, args[i]);
|
|
4677
|
+
|
|
4678
|
+
if (stringMode) {
|
|
4679
|
+
if (process.env.NODE_ENV !== 'production' && strings[i] === undefined) {
|
|
4680
|
+
console.error(ILLEGAL_ESCAPE_SEQUENCE_ERROR$1);
|
|
4681
|
+
}
|
|
4682
|
+
|
|
4683
|
+
styles += strings[i];
|
|
4684
|
+
}
|
|
4685
|
+
}
|
|
4686
|
+
|
|
4687
|
+
var sourceMap;
|
|
4688
|
+
|
|
4689
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4690
|
+
styles = styles.replace(sourceMapPattern, function (match) {
|
|
4691
|
+
sourceMap = match;
|
|
4692
|
+
return '';
|
|
4693
|
+
});
|
|
4694
|
+
} // using a global regex with .exec is stateful so lastIndex has to be reset each time
|
|
4695
|
+
|
|
4696
|
+
|
|
4697
|
+
labelPattern.lastIndex = 0;
|
|
4698
|
+
var identifierName = '';
|
|
4699
|
+
var match; // https://esbench.com/bench/5b809c2cf2949800a0f61fb5
|
|
4700
|
+
|
|
4701
|
+
while ((match = labelPattern.exec(styles)) !== null) {
|
|
4702
|
+
identifierName += '-' + // $FlowFixMe we know it's not null
|
|
4703
|
+
match[1];
|
|
4704
|
+
}
|
|
4705
|
+
|
|
4706
|
+
var name = murmur2(styles) + identifierName;
|
|
4707
|
+
|
|
4708
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4709
|
+
// $FlowFixMe SerializedStyles type doesn't have toString property (and we don't want to add it)
|
|
4710
|
+
return {
|
|
4711
|
+
name: name,
|
|
4712
|
+
styles: styles,
|
|
4713
|
+
map: sourceMap,
|
|
4714
|
+
next: cursor,
|
|
4715
|
+
toString: function toString() {
|
|
4716
|
+
return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop).";
|
|
4717
|
+
}
|
|
4718
|
+
};
|
|
4719
|
+
}
|
|
4720
|
+
|
|
4721
|
+
return {
|
|
4722
|
+
name: name,
|
|
4723
|
+
styles: styles,
|
|
4724
|
+
next: cursor
|
|
4725
|
+
};
|
|
4726
|
+
};
|
|
4727
|
+
|
|
4728
|
+
var isBrowser$2 = typeof document !== 'undefined';
|
|
4729
|
+
|
|
4730
|
+
var syncFallback = function syncFallback(create) {
|
|
4731
|
+
return create();
|
|
4732
|
+
};
|
|
4733
|
+
|
|
4734
|
+
var useInsertionEffect = React$1['useInsertion' + 'Effect'] ? React$1['useInsertion' + 'Effect'] : false;
|
|
4735
|
+
var useInsertionEffectAlwaysWithSyncFallback = !isBrowser$2 ? syncFallback : useInsertionEffect || syncFallback;
|
|
4736
|
+
|
|
4737
|
+
var isBrowser$1 = typeof document !== 'undefined';
|
|
4738
|
+
var hasOwnProperty = {}.hasOwnProperty;
|
|
4739
|
+
|
|
4740
|
+
var EmotionCacheContext = /* #__PURE__ */reactExports.createContext( // we're doing this to avoid preconstruct's dead code elimination in this one case
|
|
4741
|
+
// because this module is primarily intended for the browser and node
|
|
4742
|
+
// but it's also required in react native and similar environments sometimes
|
|
4743
|
+
// and we could have a special build just for that
|
|
4744
|
+
// but this is much easier and the native packages
|
|
4745
|
+
// might use a different theme context in the future anyway
|
|
4746
|
+
typeof HTMLElement !== 'undefined' ? /* #__PURE__ */createCache({
|
|
4747
|
+
key: 'css'
|
|
4748
|
+
}) : null);
|
|
4749
|
+
|
|
4750
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4751
|
+
EmotionCacheContext.displayName = 'EmotionCacheContext';
|
|
4752
|
+
}
|
|
4753
|
+
|
|
4754
|
+
EmotionCacheContext.Provider;
|
|
4755
|
+
|
|
4756
|
+
var withEmotionCache = function withEmotionCache(func) {
|
|
4757
|
+
// $FlowFixMe
|
|
4758
|
+
return /*#__PURE__*/reactExports.forwardRef(function (props, ref) {
|
|
4759
|
+
// the cache will never be null in the browser
|
|
4760
|
+
var cache = reactExports.useContext(EmotionCacheContext);
|
|
4761
|
+
return func(props, cache, ref);
|
|
4762
|
+
});
|
|
4763
|
+
};
|
|
4764
|
+
|
|
4765
|
+
if (!isBrowser$1) {
|
|
4766
|
+
withEmotionCache = function withEmotionCache(func) {
|
|
4767
|
+
return function (props) {
|
|
4768
|
+
var cache = reactExports.useContext(EmotionCacheContext);
|
|
4769
|
+
|
|
4770
|
+
if (cache === null) {
|
|
4771
|
+
// yes, we're potentially creating this on every render
|
|
4772
|
+
// it doesn't actually matter though since it's only on the server
|
|
4773
|
+
// so there will only every be a single render
|
|
4774
|
+
// that could change in the future because of suspense and etc. but for now,
|
|
4775
|
+
// this works and i don't want to optimise for a future thing that we aren't sure about
|
|
4776
|
+
cache = createCache({
|
|
4777
|
+
key: 'css'
|
|
4778
|
+
});
|
|
4779
|
+
return /*#__PURE__*/reactExports.createElement(EmotionCacheContext.Provider, {
|
|
4780
|
+
value: cache
|
|
4781
|
+
}, func(props, cache));
|
|
4782
|
+
} else {
|
|
4783
|
+
return func(props, cache);
|
|
4784
|
+
}
|
|
4785
|
+
};
|
|
4786
|
+
};
|
|
4787
|
+
}
|
|
4788
|
+
|
|
4789
|
+
var ThemeContext = /* #__PURE__ */reactExports.createContext({});
|
|
4790
|
+
|
|
4791
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4792
|
+
ThemeContext.displayName = 'EmotionThemeContext';
|
|
4793
|
+
}
|
|
4794
|
+
|
|
4795
|
+
var useTheme = function useTheme() {
|
|
4796
|
+
return reactExports.useContext(ThemeContext);
|
|
4797
|
+
};
|
|
4798
|
+
|
|
4799
|
+
var typePropName = '__EMOTION_TYPE_PLEASE_DO_NOT_USE__';
|
|
4800
|
+
var labelPropName = '__EMOTION_LABEL_PLEASE_DO_NOT_USE__';
|
|
4801
|
+
|
|
4802
|
+
var Insertion$1 = function Insertion(_ref) {
|
|
4803
|
+
var cache = _ref.cache,
|
|
4804
|
+
serialized = _ref.serialized,
|
|
4805
|
+
isStringTag = _ref.isStringTag;
|
|
4806
|
+
registerStyles(cache, serialized, isStringTag);
|
|
4807
|
+
var rules = useInsertionEffectAlwaysWithSyncFallback(function () {
|
|
4808
|
+
return insertStyles(cache, serialized, isStringTag);
|
|
4809
|
+
});
|
|
4810
|
+
|
|
4811
|
+
if (!isBrowser$1 && rules !== undefined) {
|
|
4812
|
+
var _ref2;
|
|
4813
|
+
|
|
4814
|
+
var serializedNames = serialized.name;
|
|
4815
|
+
var next = serialized.next;
|
|
4816
|
+
|
|
4817
|
+
while (next !== undefined) {
|
|
4818
|
+
serializedNames += ' ' + next.name;
|
|
4819
|
+
next = next.next;
|
|
4820
|
+
}
|
|
4821
|
+
|
|
4822
|
+
return /*#__PURE__*/reactExports.createElement("style", (_ref2 = {}, _ref2["data-emotion"] = cache.key + " " + serializedNames, _ref2.dangerouslySetInnerHTML = {
|
|
4823
|
+
__html: rules
|
|
4824
|
+
}, _ref2.nonce = cache.sheet.nonce, _ref2));
|
|
4825
|
+
}
|
|
4826
|
+
|
|
4827
|
+
return null;
|
|
4828
|
+
};
|
|
4829
|
+
|
|
4830
|
+
var Emotion = /* #__PURE__ */withEmotionCache(function (props, cache, ref) {
|
|
4831
|
+
var cssProp = props.css; // so that using `css` from `emotion` and passing the result to the css prop works
|
|
4832
|
+
// not passing the registered cache to serializeStyles because it would
|
|
4833
|
+
// make certain babel optimisations not possible
|
|
4834
|
+
|
|
4835
|
+
if (typeof cssProp === 'string' && cache.registered[cssProp] !== undefined) {
|
|
4836
|
+
cssProp = cache.registered[cssProp];
|
|
4837
|
+
}
|
|
4838
|
+
|
|
4839
|
+
var WrappedComponent = props[typePropName];
|
|
4840
|
+
var registeredStyles = [cssProp];
|
|
4841
|
+
var className = '';
|
|
4842
|
+
|
|
4843
|
+
if (typeof props.className === 'string') {
|
|
4844
|
+
className = getRegisteredStyles(cache.registered, registeredStyles, props.className);
|
|
4845
|
+
} else if (props.className != null) {
|
|
4846
|
+
className = props.className + " ";
|
|
4847
|
+
}
|
|
4848
|
+
|
|
4849
|
+
var serialized = serializeStyles(registeredStyles, undefined, reactExports.useContext(ThemeContext));
|
|
4850
|
+
|
|
4851
|
+
if (process.env.NODE_ENV !== 'production' && serialized.name.indexOf('-') === -1) {
|
|
4852
|
+
var labelFromStack = props[labelPropName];
|
|
4853
|
+
|
|
4854
|
+
if (labelFromStack) {
|
|
4855
|
+
serialized = serializeStyles([serialized, 'label:' + labelFromStack + ';']);
|
|
4856
|
+
}
|
|
4857
|
+
}
|
|
4858
|
+
|
|
4859
|
+
className += cache.key + "-" + serialized.name;
|
|
4860
|
+
var newProps = {};
|
|
4861
|
+
|
|
4862
|
+
for (var key in props) {
|
|
4863
|
+
if (hasOwnProperty.call(props, key) && key !== 'css' && key !== typePropName && (process.env.NODE_ENV === 'production' || key !== labelPropName)) {
|
|
4864
|
+
newProps[key] = props[key];
|
|
4865
|
+
}
|
|
4866
|
+
}
|
|
4867
|
+
|
|
4868
|
+
newProps.ref = ref;
|
|
4869
|
+
newProps.className = className;
|
|
4870
|
+
return /*#__PURE__*/reactExports.createElement(reactExports.Fragment, null, /*#__PURE__*/reactExports.createElement(Insertion$1, {
|
|
4871
|
+
cache: cache,
|
|
4872
|
+
serialized: serialized,
|
|
4873
|
+
isStringTag: typeof WrappedComponent === 'string'
|
|
4874
|
+
}), /*#__PURE__*/reactExports.createElement(WrappedComponent, newProps));
|
|
4875
|
+
});
|
|
4876
|
+
|
|
4877
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4878
|
+
Emotion.displayName = 'EmotionCssPropInternal';
|
|
4879
|
+
}
|
|
4880
|
+
|
|
4881
|
+
const defaultThemeColors = {
|
|
4882
|
+
primary: "#00739D",
|
|
4883
|
+
secondary: "#01A982",
|
|
4884
|
+
tertiary: "#FFC20A",
|
|
4885
|
+
textPrimary: "#333333",
|
|
4886
|
+
textSecondary: "#666666",
|
|
4887
|
+
textTertiary: "#999999",
|
|
4888
|
+
statusOk: "#01A982",
|
|
4889
|
+
statusWarning: "#FFC20A",
|
|
4890
|
+
statusCritical: "#FF4040",
|
|
4891
|
+
statusNeutral: "#CCCCCC",
|
|
4892
|
+
};
|
|
4893
|
+
React.createContext(defaultThemeColors);
|
|
4894
|
+
const isEmpty = (obj) => {
|
|
4895
|
+
return Object.keys(obj).length === 0;
|
|
4896
|
+
};
|
|
4897
|
+
const useKwantisThemeContext = () => {
|
|
4898
|
+
const contextTheme = useTheme();
|
|
4899
|
+
return isEmpty(contextTheme) ? defaultThemeColors : contextTheme;
|
|
4900
|
+
};
|
|
4901
|
+
|
|
4902
|
+
var reactPropsRegex = /^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|abbr|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|download|draggable|encType|enterKeyHint|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|translate|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|incremental|fallback|inert|itemProp|itemScope|itemType|itemID|itemRef|on|option|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|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|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|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|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/; // https://esbench.com/bench/5bfee68a4cd7e6009ef61d23
|
|
4903
|
+
|
|
4904
|
+
var isPropValid = /* #__PURE__ */memoize(function (prop) {
|
|
4905
|
+
return reactPropsRegex.test(prop) || prop.charCodeAt(0) === 111
|
|
4906
|
+
/* o */
|
|
4907
|
+
&& prop.charCodeAt(1) === 110
|
|
4908
|
+
/* n */
|
|
4909
|
+
&& prop.charCodeAt(2) < 91;
|
|
4910
|
+
}
|
|
4911
|
+
/* Z+1 */
|
|
4912
|
+
);
|
|
4913
|
+
|
|
4914
|
+
var testOmitPropsOnStringTag = isPropValid;
|
|
4915
|
+
|
|
4916
|
+
var testOmitPropsOnComponent = function testOmitPropsOnComponent(key) {
|
|
4917
|
+
return key !== 'theme';
|
|
4918
|
+
};
|
|
4919
|
+
|
|
4920
|
+
var getDefaultShouldForwardProp = function getDefaultShouldForwardProp(tag) {
|
|
4921
|
+
return typeof tag === 'string' && // 96 is one less than the char code
|
|
4922
|
+
// for "a" so this is checking that
|
|
4923
|
+
// it's a lowercase character
|
|
4924
|
+
tag.charCodeAt(0) > 96 ? testOmitPropsOnStringTag : testOmitPropsOnComponent;
|
|
4925
|
+
};
|
|
4926
|
+
var composeShouldForwardProps = function composeShouldForwardProps(tag, options, isReal) {
|
|
4927
|
+
var shouldForwardProp;
|
|
4928
|
+
|
|
4929
|
+
if (options) {
|
|
4930
|
+
var optionsShouldForwardProp = options.shouldForwardProp;
|
|
4931
|
+
shouldForwardProp = tag.__emotion_forwardProp && optionsShouldForwardProp ? function (propName) {
|
|
4932
|
+
return tag.__emotion_forwardProp(propName) && optionsShouldForwardProp(propName);
|
|
4933
|
+
} : optionsShouldForwardProp;
|
|
4934
|
+
}
|
|
4935
|
+
|
|
4936
|
+
if (typeof shouldForwardProp !== 'function' && isReal) {
|
|
4937
|
+
shouldForwardProp = tag.__emotion_forwardProp;
|
|
4938
|
+
}
|
|
4939
|
+
|
|
4940
|
+
return shouldForwardProp;
|
|
4941
|
+
};
|
|
4942
|
+
|
|
4943
|
+
var ILLEGAL_ESCAPE_SEQUENCE_ERROR = "You have illegal escape sequence in your template literal, most likely inside content's property value.\nBecause you write your CSS inside a JavaScript string you actually have to do double escaping, so for example \"content: '\\00d7';\" should become \"content: '\\\\00d7';\".\nYou can read more about this here:\nhttps://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#ES2018_revision_of_illegal_escape_sequences";
|
|
4944
|
+
var isBrowser = typeof document !== 'undefined';
|
|
4945
|
+
|
|
4946
|
+
var Insertion = function Insertion(_ref) {
|
|
4947
|
+
var cache = _ref.cache,
|
|
4948
|
+
serialized = _ref.serialized,
|
|
4949
|
+
isStringTag = _ref.isStringTag;
|
|
4950
|
+
registerStyles(cache, serialized, isStringTag);
|
|
4951
|
+
var rules = useInsertionEffectAlwaysWithSyncFallback(function () {
|
|
4952
|
+
return insertStyles(cache, serialized, isStringTag);
|
|
4953
|
+
});
|
|
4954
|
+
|
|
4955
|
+
if (!isBrowser && rules !== undefined) {
|
|
4956
|
+
var _ref2;
|
|
4957
|
+
|
|
4958
|
+
var serializedNames = serialized.name;
|
|
4959
|
+
var next = serialized.next;
|
|
4960
|
+
|
|
4961
|
+
while (next !== undefined) {
|
|
4962
|
+
serializedNames += ' ' + next.name;
|
|
4963
|
+
next = next.next;
|
|
4964
|
+
}
|
|
4965
|
+
|
|
4966
|
+
return /*#__PURE__*/reactExports.createElement("style", (_ref2 = {}, _ref2["data-emotion"] = cache.key + " " + serializedNames, _ref2.dangerouslySetInnerHTML = {
|
|
4967
|
+
__html: rules
|
|
4968
|
+
}, _ref2.nonce = cache.sheet.nonce, _ref2));
|
|
4969
|
+
}
|
|
4970
|
+
|
|
4971
|
+
return null;
|
|
4972
|
+
};
|
|
4973
|
+
|
|
4974
|
+
var createStyled = function createStyled(tag, options) {
|
|
4975
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4976
|
+
if (tag === undefined) {
|
|
4977
|
+
throw new Error('You are trying to create a styled element with an undefined component.\nYou may have forgotten to import it.');
|
|
4978
|
+
}
|
|
4979
|
+
}
|
|
4980
|
+
|
|
4981
|
+
var isReal = tag.__emotion_real === tag;
|
|
4982
|
+
var baseTag = isReal && tag.__emotion_base || tag;
|
|
4983
|
+
var identifierName;
|
|
4984
|
+
var targetClassName;
|
|
4985
|
+
|
|
4986
|
+
if (options !== undefined) {
|
|
4987
|
+
identifierName = options.label;
|
|
4988
|
+
targetClassName = options.target;
|
|
4989
|
+
}
|
|
4990
|
+
|
|
4991
|
+
var shouldForwardProp = composeShouldForwardProps(tag, options, isReal);
|
|
4992
|
+
var defaultShouldForwardProp = shouldForwardProp || getDefaultShouldForwardProp(baseTag);
|
|
4993
|
+
var shouldUseAs = !defaultShouldForwardProp('as');
|
|
4994
|
+
return function () {
|
|
4995
|
+
var args = arguments;
|
|
4996
|
+
var styles = isReal && tag.__emotion_styles !== undefined ? tag.__emotion_styles.slice(0) : [];
|
|
4997
|
+
|
|
4998
|
+
if (identifierName !== undefined) {
|
|
4999
|
+
styles.push("label:" + identifierName + ";");
|
|
5000
|
+
}
|
|
5001
|
+
|
|
5002
|
+
if (args[0] == null || args[0].raw === undefined) {
|
|
5003
|
+
styles.push.apply(styles, args);
|
|
5004
|
+
} else {
|
|
5005
|
+
if (process.env.NODE_ENV !== 'production' && args[0][0] === undefined) {
|
|
5006
|
+
console.error(ILLEGAL_ESCAPE_SEQUENCE_ERROR);
|
|
5007
|
+
}
|
|
5008
|
+
|
|
5009
|
+
styles.push(args[0][0]);
|
|
5010
|
+
var len = args.length;
|
|
5011
|
+
var i = 1;
|
|
5012
|
+
|
|
5013
|
+
for (; i < len; i++) {
|
|
5014
|
+
if (process.env.NODE_ENV !== 'production' && args[0][i] === undefined) {
|
|
5015
|
+
console.error(ILLEGAL_ESCAPE_SEQUENCE_ERROR);
|
|
5016
|
+
}
|
|
5017
|
+
|
|
5018
|
+
styles.push(args[i], args[0][i]);
|
|
5019
|
+
}
|
|
5020
|
+
} // $FlowFixMe: we need to cast StatelessFunctionalComponent to our PrivateStyledComponent class
|
|
5021
|
+
|
|
5022
|
+
|
|
5023
|
+
var Styled = withEmotionCache(function (props, cache, ref) {
|
|
5024
|
+
var FinalTag = shouldUseAs && props.as || baseTag;
|
|
5025
|
+
var className = '';
|
|
5026
|
+
var classInterpolations = [];
|
|
5027
|
+
var mergedProps = props;
|
|
5028
|
+
|
|
5029
|
+
if (props.theme == null) {
|
|
5030
|
+
mergedProps = {};
|
|
5031
|
+
|
|
5032
|
+
for (var key in props) {
|
|
5033
|
+
mergedProps[key] = props[key];
|
|
5034
|
+
}
|
|
5035
|
+
|
|
5036
|
+
mergedProps.theme = reactExports.useContext(ThemeContext);
|
|
5037
|
+
}
|
|
5038
|
+
|
|
5039
|
+
if (typeof props.className === 'string') {
|
|
5040
|
+
className = getRegisteredStyles(cache.registered, classInterpolations, props.className);
|
|
5041
|
+
} else if (props.className != null) {
|
|
5042
|
+
className = props.className + " ";
|
|
5043
|
+
}
|
|
5044
|
+
|
|
5045
|
+
var serialized = serializeStyles(styles.concat(classInterpolations), cache.registered, mergedProps);
|
|
5046
|
+
className += cache.key + "-" + serialized.name;
|
|
5047
|
+
|
|
5048
|
+
if (targetClassName !== undefined) {
|
|
5049
|
+
className += " " + targetClassName;
|
|
5050
|
+
}
|
|
5051
|
+
|
|
5052
|
+
var finalShouldForwardProp = shouldUseAs && shouldForwardProp === undefined ? getDefaultShouldForwardProp(FinalTag) : defaultShouldForwardProp;
|
|
5053
|
+
var newProps = {};
|
|
5054
|
+
|
|
5055
|
+
for (var _key in props) {
|
|
5056
|
+
if (shouldUseAs && _key === 'as') continue;
|
|
5057
|
+
|
|
5058
|
+
if ( // $FlowFixMe
|
|
5059
|
+
finalShouldForwardProp(_key)) {
|
|
5060
|
+
newProps[_key] = props[_key];
|
|
5061
|
+
}
|
|
5062
|
+
}
|
|
5063
|
+
|
|
5064
|
+
newProps.className = className;
|
|
5065
|
+
newProps.ref = ref;
|
|
5066
|
+
return /*#__PURE__*/reactExports.createElement(reactExports.Fragment, null, /*#__PURE__*/reactExports.createElement(Insertion, {
|
|
5067
|
+
cache: cache,
|
|
5068
|
+
serialized: serialized,
|
|
5069
|
+
isStringTag: typeof FinalTag === 'string'
|
|
5070
|
+
}), /*#__PURE__*/reactExports.createElement(FinalTag, newProps));
|
|
5071
|
+
});
|
|
5072
|
+
Styled.displayName = identifierName !== undefined ? identifierName : "Styled(" + (typeof baseTag === 'string' ? baseTag : baseTag.displayName || baseTag.name || 'Component') + ")";
|
|
5073
|
+
Styled.defaultProps = tag.defaultProps;
|
|
5074
|
+
Styled.__emotion_real = Styled;
|
|
5075
|
+
Styled.__emotion_base = baseTag;
|
|
5076
|
+
Styled.__emotion_styles = styles;
|
|
5077
|
+
Styled.__emotion_forwardProp = shouldForwardProp;
|
|
5078
|
+
Object.defineProperty(Styled, 'toString', {
|
|
5079
|
+
value: function value() {
|
|
5080
|
+
if (targetClassName === undefined && process.env.NODE_ENV !== 'production') {
|
|
5081
|
+
return 'NO_COMPONENT_SELECTOR';
|
|
5082
|
+
} // $FlowFixMe: coerce undefined to string
|
|
5083
|
+
|
|
5084
|
+
|
|
5085
|
+
return "." + targetClassName;
|
|
5086
|
+
}
|
|
5087
|
+
});
|
|
5088
|
+
|
|
5089
|
+
Styled.withComponent = function (nextTag, nextOptions) {
|
|
5090
|
+
return createStyled(nextTag, _extends({}, options, nextOptions, {
|
|
5091
|
+
shouldForwardProp: composeShouldForwardProps(Styled, nextOptions, true)
|
|
5092
|
+
})).apply(void 0, styles);
|
|
5093
|
+
};
|
|
5094
|
+
|
|
5095
|
+
return Styled;
|
|
5096
|
+
};
|
|
5097
|
+
};
|
|
5098
|
+
|
|
5099
|
+
var tags = ['a', 'abbr', 'address', 'area', 'article', 'aside', 'audio', 'b', 'base', 'bdi', 'bdo', 'big', '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', 'marquee', 'menu', 'menuitem', 'meta', 'meter', 'nav', 'noscript', 'object', 'ol', 'optgroup', 'option', 'output', 'p', 'param', 'picture', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'script', 'section', 'select', 'small', 'source', 'span', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'textarea', 'tfoot', 'th', 'thead', 'time', 'title', 'tr', 'track', 'u', 'ul', 'var', 'video', 'wbr', // SVG
|
|
5100
|
+
'circle', 'clipPath', 'defs', 'ellipse', 'foreignObject', 'g', 'image', 'line', 'linearGradient', 'mask', 'path', 'pattern', 'polygon', 'polyline', 'radialGradient', 'rect', 'stop', 'svg', 'text', 'tspan'];
|
|
5101
|
+
|
|
5102
|
+
var newStyled = createStyled.bind();
|
|
5103
|
+
tags.forEach(function (tagName) {
|
|
5104
|
+
// $FlowFixMe: we can ignore this because its exposed type is defined by the CreateStyled type
|
|
5105
|
+
newStyled[tagName] = newStyled(tagName);
|
|
5106
|
+
});
|
|
5107
|
+
|
|
2807
5108
|
const Button = (props) => {
|
|
2808
|
-
|
|
5109
|
+
const colors = useKwantisThemeContext();
|
|
5110
|
+
const Button = newStyled.button `
|
|
5111
|
+
background-color: ${colors[props.color || "primary"]};
|
|
5112
|
+
`;
|
|
5113
|
+
return reactExports.createElement(Button, null, props.label);
|
|
2809
5114
|
};
|
|
2810
5115
|
|
|
2811
5116
|
exports.Button = Button;
|