styled-components
Version:
CSS for the <Component> Age. Style components your way with speed, strong typing, and flexibility.
3 lines (2 loc) • 14.4 kB
JavaScript
;Object.defineProperty(exports,"__esModule",{value:!0});var e=require("css-to-react-native"),t=require("postcss"),r=require("tslib"),n=require("@emotion/unitless"),o=require("react");function s(e){return e&&e.__esModule?e:{default:e}}var a=/*#__PURE__*/s(e),i=/*#__PURE__*/s(n),c=/*#__PURE__*/s(o),u=Object.freeze([]),l=Object.freeze({}),p="production"!==process.env.NODE_ENV?{1:"Cannot create styled-component for component: %s.\n\n",2:"Can't collect styles once you've consumed a `ServerStyleSheet`'s styles! `ServerStyleSheet` is a one off instance for each server-side render cycle.\n\n- Are you trying to reuse it across renders?\n- Are you accidentally calling collectStyles twice?\n\n",3:"Streaming SSR is only supported in a Node.js environment; Please do not try to call this method in the browser.\n\n",4:"The `StyleSheetManager` expects a valid target or sheet prop!\n\n- Does this error occur on the client and is your target falsy?\n- Does this error occur on the server and is the sheet falsy?\n\n",5:"The clone method cannot be used on the client!\n\n- Are you running in a client-like environment on the server?\n- Are you trying to run SSR on the client?\n\n",6:"Trying to insert a new style tag, but the given Node is unmounted!\n\n- Are you using a custom target that isn't mounted?\n- Does your document not have a valid head element?\n- Have you accidentally removed a style tag manually?\n\n",7:'ThemeProvider: Please return an object from your "theme" prop function, e.g.\n\n```js\ntheme={() => ({})}\n```\n\n',8:'ThemeProvider: Please make your "theme" prop an object.\n\n',9:"Missing document `<head>`\n\n",10:"Cannot find a StyleSheet instance. Usually this happens if there are multiple copies of styled-components loaded at once. Check out this issue for how to troubleshoot and fix the common cases where this situation can happen: https://github.com/styled-components/styled-components/issues/1941#issuecomment-417862021\n\n",11:"_This error was replaced with a dev-time warning, it will be deleted for v4 final._ [createGlobalStyle] received children which will not be rendered. Please use the component without passing children elements.\n\n",12:"It seems you are interpolating a keyframe declaration (%s) into an untagged string. This was supported in styled-components v3, but is not longer supported in v4 as keyframes are now injected on-demand. Please wrap your string in the css\\`\\` helper which ensures the styles are injected correctly. See https://www.styled-components.com/docs/api#css\n\n",13:"%s is not a styled component and cannot be referred to via component selector. See https://www.styled-components.com/docs/advanced#referring-to-other-components for more details.\n\n",14:'ThemeProvider: "theme" prop is required.\n\n',15:"A stylis plugin has been supplied that is not named. We need a name for each plugin to be able to prevent styling collisions between different stylis configurations within the same app. Before you pass your plugin to `<StyleSheetManager stylisPlugins={[]}>`, please make sure each plugin is uniquely-named, e.g.\n\n```js\nObject.defineProperty(importedPlugin, 'name', { value: 'some-unique-name' });\n```\n\n",16:"Reached the limit of how many styled components may be created at group %s.\nYou may only create up to 1,073,741,824 components. If you're creating components dynamically,\nas for instance in your render method then you may be running into this limitation.\n\n",17:"CSSStyleSheet could not be found on HTMLStyleElement.\nHas styled-components' style tag been unmounted or altered by another script?\n",18:"ThemeProvider: Please make sure your useTheme hook is within a `<ThemeProvider>`"}:{};function d(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];for(var r=e[0],n=[],o=1,s=e.length;o<s;o+=1)n.push(e[o]);return n.forEach(function(e){r=r.replace(/%[a-z]/,e)}),r}function f(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return"production"===process.env.NODE_ENV?new Error("An error occurred. See https://github.com/styled-components/styled-components/blob/main/packages/styled-components/src/utils/errors.md#".concat(e," for more information.").concat(t.length>0?" Args: ".concat(t.join(", ")):"")):new Error(d.apply(void 0,r.__spreadArray([p[e]],t,!1)).trim())}function y(e,t){return null==t||"boolean"==typeof t||""===t?"":"number"!=typeof t||0===t||e in i.default||e.startsWith("--")?String(t).trim():"".concat(t,"px")}function h(e){return"production"!==process.env.NODE_ENV&&"string"==typeof e&&e||e.displayName||e.name||"Component"}var m=function(e){return e>="A"&&e<="Z"};function v(e){for(var t="",r=0;r<e.length;r++){var n=e[r];if(1===r&&"-"===n&&"-"===e[0])return e;m(n)?t+="-"+n.toLowerCase():t+=n}return t.startsWith("ms-")?"-"+t:t}function g(e){return"function"==typeof e}var S=Symbol.for("sc-keyframes");function _(e){return"object"==typeof e&&null!==e&&S in e}function w(e){return null!==e&&"object"==typeof e&&e.constructor.name===Object.name&&!("props"in e&&e.$$typeof)}function E(e){return"object"==typeof e&&"styledComponentId"in e}var b=function(e){return null==e||!1===e||""===e},P=function(e){var t=[];for(var n in e){var o=e[n];e.hasOwnProperty(n)&&!b(o)&&(Array.isArray(o)&&o.isCss||g(o)?t.push("".concat(v(n),":"),o,";"):w(o)?t.push.apply(t,r.__spreadArray(r.__spreadArray(["".concat(n," {")],P(o),!1),["}"],!1)):t.push("".concat(v(n),": ").concat(y(n,o),";")))}return t};function A(e,t,r,n,o){if(void 0===o&&(o=[]),"string"==typeof e)return e&&o.push(e),o;if(b(e))return o;if(E(e))return o.push(".".concat(e.styledComponentId)),o;if(g(e)){if(!g(a=e)||a.prototype&&a.prototype.isReactComponent||!t)return o.push(e),o;var s=e(t);return"production"===process.env.NODE_ENV||"object"!=typeof s||Array.isArray(s)||_(s)||w(s)||null===s||console.error("".concat(h(e)," is not a styled component and cannot be referred to via component selector. See https://www.styled-components.com/docs/advanced#referring-to-other-components for more details.")),A(s,t,r,n,o)}var a;if(_(e))return r?(e.inject(r,n),o.push(e.getName(n))):o.push(e),o;if(w(e)){for(var i=P(e),c=0;c<i.length;c++)o.push(i[c]);return o}if(!Array.isArray(e))return o.push(e.toString()),o;for(c=0;c<e.length;c++)A(e[c],t,r,n,o);return o}function C(e,t){for(var r=[e[0]],n=0,o=t.length;n<o;n+=1)r.push(t[n],e[n+1]);return r}var D=function(e){return Object.assign(e,{isCss:!0})};function N(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];if(g(e)||w(e))return D(A(C(u,r.__spreadArray([e],t,!0))));var o=e;return 0===t.length&&1===o.length&&"string"==typeof o[0]?A(o):D(A(C(o,t)))}function T(e,t,n){if(void 0===n&&(n=l),!t)throw f(1,t);var o=function(o){for(var s=[],a=1;a<arguments.length;a++)s[a-1]=arguments[a];return e(t,n,N.apply(void 0,r.__spreadArray([o],s,!1)))};return o.attrs=function(o){return T(e,t,r.__assign(r.__assign({},n),{attrs:Array.prototype.concat(n.attrs,o).filter(Boolean)}))},o.withConfig=function(o){return T(e,t,r.__assign(r.__assign({},n),o))},o}"undefined"!=typeof process&&void 0!==process.env&&(process.env.REACT_APP_SC_ATTR||process),Boolean("boolean"==typeof SC_DISABLE_SPEEDY?SC_DISABLE_SPEEDY:"undefined"!=typeof process&&void 0!==process.env&&void 0!==process.env.REACT_APP_SC_DISABLE_SPEEDY&&""!==process.env.REACT_APP_SC_DISABLE_SPEEDY?"false"!==process.env.REACT_APP_SC_DISABLE_SPEEDY&&process.env.REACT_APP_SC_DISABLE_SPEEDY:"undefined"!=typeof process&&void 0!==process.env&&void 0!==process.env.SC_DISABLE_SPEEDY&&""!==process.env.SC_DISABLE_SPEEDY?"false"!==process.env.SC_DISABLE_SPEEDY&&process.env.SC_DISABLE_SPEEDY:"production"!==process.env.NODE_ENV);var O,j=c.default.createContext(void 0),x=j.Consumer;function I(e,t,r){return void 0===r&&(r=l),e.theme!==r.theme&&e.theme||t||r.theme}var V="function"==typeof Symbol&&Symbol.for,B=V?Symbol.for("react.memo"):60115,L=V?Symbol.for("react.forward_ref"):60112,$={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},R={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},k={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},F=((O={})[L]={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},O[B]=k,O);function Y(e){return("type"in(t=e)&&t.type.$$typeof)===B?k:"$$typeof"in e?F[e.$$typeof]:$;var t}var M=Object.defineProperty,q=Object.getOwnPropertyNames,W=Object.getOwnPropertySymbols,z=Object.getOwnPropertyDescriptor,H=Object.getPrototypeOf,G=Object.prototype;function K(e,t,r){if("string"!=typeof t){if(G){var n=H(t);n&&n!==G&&K(e,n,r)}var o=q(t);W&&(o=o.concat(W(t)));for(var s=Y(e),a=Y(t),i=0;i<o.length;++i){var c=o[i];if(!(c in R||r&&r[c]||a&&c in a||s&&c in s)){var u=z(t,c);try{M(e,c,u)}catch(e){}}}}return e}var U=/(a)(d)/gi,Z=function(e){return String.fromCharCode(e+(e>25?39:97))};function J(e,t){return e.join(t||"")}var Q=["fit-content","min-content","max-content"],X={};function ee(e,t,r){if(void 0===r&&(r=!1),!r&&!w(e)&&!Array.isArray(e))return t;if(Array.isArray(t))for(var n=0;n<t.length;n++)e[n]=ee(e[n],t[n]);else if(w(t))for(var n in t)e[n]=ee(e[n],t[n]);return e}var te,re,ne=require("react-native"),oe=(te=ne.StyleSheet,re=function(){function e(e){this.rules=e}return e.prototype.generateStyleObject=function(e){var r=J(A(this.rules,e)),n=function(e){var t,r="";for(t=Math.abs(e);t>52;t=t/52|0)r=Z(t%52)+r;return(Z(t%52)+r).replace(U,"$1-$2")}(function(e,t){for(var r=t.length;r;)e=33*e^t.charCodeAt(--r);return e}(5381,r)>>>0);if(!X[n]){var o=void 0;try{o=t.parse(r)}catch(e){return"production"!==process.env.NODE_ENV&&console.warn("[styled-components/native] Failed to parse CSS: ".concat(e instanceof Error?e.message:e)),X[n]={},X[n]}var s=[];o.each(function(e){if("decl"===e.type){if(Q.includes(e.value))return void("production"!==process.env.NODE_ENV&&console.warn('[styled-components/native] The value "'.concat(e.value,'" for property "').concat(e.prop,'" is not supported in React Native and will be ignored.')));s.push([e.prop,e.value])}else"production"!==process.env.NODE_ENV&&"comment"!==e.type&&console.warn("Node of type ".concat(e.type," not supported as an inline style"))});var i=a.default(s,["borderWidth","borderColor"]),c=te.create({generated:i});X[n]=c.generated}return X[n]},e}(),function(e,t,n){var s=E(e),a=e,i=t.displayName,p=void 0===i?function(e){return function(e){return"string"==typeof e&&("production"===process.env.NODE_ENV||e.charAt(0)===e.charAt(0).toLowerCase())}(e)?"styled.".concat(e):"Styled(".concat(h(e),")")}(e):i,d=t.attrs,f=void 0===d?u:d,y=s&&a.attrs?a.attrs.concat(f).filter(Boolean):f,m=t.shouldForwardProp;if(s&&a.shouldForwardProp){var v=a.shouldForwardProp;if(t.shouldForwardProp){var S=t.shouldForwardProp;m=function(e,t){return v(e,t)&&S(e,t)}}else m=v}var _=function(e,t){return function(e,t,n){var s=e.attrs,a=e.inlineStyle,i=e.defaultProps,u=e.shouldForwardProp,p=e.target,d=c.default.useContext?c.default.useContext(j):void 0,f=function(e,t,n){void 0===e&&(e=l);var o=r.__assign(r.__assign({},t),{theme:e}),s={};return n.forEach(function(e){var t,r=g(e)?e(o):e;for(t in r)o[t]=s[t]=r[t]}),[o,s]}(I(t,d,i)||l,t,s),y=f[1],h=a.generateStyleObject(f[0]),m=n,v=y.as||t.as||p,S=y!==t?r.__assign(r.__assign({},t),y):t,_={};for(var w in S)"$"!==w[0]&&"as"!==w&&("forwardedAs"===w?_.as=S[w]:u&&!u(w,v)||(_[w]=S[w]));return _.style=c.default.useMemo?c.default.useMemo(function(){return g(t.style)?function(e){return[h].concat(t.style(e))}:t.style?[h].concat(t.style):h},[t.style,h]):g(t.style)?function(e){return[h].concat(t.style(e))}:t.style?[h].concat(t.style):h,n&&(_.ref=m),o.createElement(v,_)}(w,e,t)};_.displayName=p;var w=c.default.forwardRef(_);return w.attrs=y,w.inlineStyle=new re(s?a.inlineStyle.rules.concat(n):n),w.displayName=p,w.shouldForwardProp=m,w.styledComponentId=!0,w.target=s?a.target:e,Object.defineProperty(w,"defaultProps",{get:function(){return this._foldedDefaultProps},set:function(e){this._foldedDefaultProps=s?function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];for(var n=0,o=t;n<o.length;n++)ee(e,o[n],!0);return e}({},a.defaultProps,e):e}}),K(w,e,{attrs:!0,inlineStyle:!0,displayName:!0,shouldForwardProp:!0,target:!0}),w}),se=function(e){return T(oe,e)};["ActivityIndicator","Button","DatePickerIOS","DrawerLayoutAndroid","FlatList","Image","ImageBackground","KeyboardAvoidingView","Modal","Pressable","ProgressBarAndroid","ProgressViewIOS","RefreshControl","SafeAreaView","ScrollView","SectionList","Slider","Switch","Text","TextInput","TouchableHighlight","TouchableOpacity","View","VirtualizedList"].forEach(function(e){return Object.defineProperty(se,e,{enumerable:!0,configurable:!1,get:function(){if(e in ne&&ne[e])return se(ne[e]);throw new Error("".concat(e," is not available in the currently-installed version of react-native"))}})}),exports.ThemeConsumer=x,exports.ThemeContext=j,exports.ThemeProvider=function(e){var t=c.default.useContext(j),n=c.default.useMemo(function(){return function(e,t){if(!e)throw f(14);if(g(e)){var n=e(t);if("production"!==process.env.NODE_ENV&&(null===n||Array.isArray(n)||"object"!=typeof n))throw f(7);return n}if(Array.isArray(e)||"object"!=typeof e)throw f(8);return t?r.__assign(r.__assign({},t),e):e}(e.theme,t)},[e.theme,t]);return e.children?c.default.createElement(j.Provider,{value:n},e.children):null},exports.css=N,exports.default=se,exports.isStyledComponent=E,exports.styled=se,exports.toStyleSheet=function(e){var r=J(A(e)),n=t.parse(r),o=[];n.each(function(e){"decl"===e.type?o.push([e.prop,e.value]):"production"!==process.env.NODE_ENV&&"comment"!==e.type&&console.warn("Node of type ".concat(e.type," not supported as an inline style"))});var s=a.default(o,["borderWidth","borderColor"]);return ne.StyleSheet.create({style:s}).style},exports.useTheme=function(){var e=c.default.useContext(j);if(!e)throw f(18);return e},exports.withTheme=function(e){var t=c.default.forwardRef(function(t,n){var o=I(t,c.default.useContext(j),e.defaultProps);return"production"!==process.env.NODE_ENV&&void 0===o&&console.warn('[withTheme] You are not using a ThemeProvider nor passing a theme prop or a theme in defaultProps in component class "'.concat(h(e),'"')),c.default.createElement(e,r.__assign(r.__assign({},t),{theme:o,ref:n}))});return t.displayName="WithTheme(".concat(h(e),")"),K(t,e)};
//# sourceMappingURL=styled-components.native.cjs.js.map