@linaria/react 4.1.4 → 4.2.0
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/dist/index.js +132 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +99 -0
- package/dist/index.mjs.map +1 -0
- package/dist/processors/styled.js +274 -0
- package/dist/processors/styled.js.map +1 -0
- package/dist/processors/styled.mjs +260 -0
- package/dist/processors/styled.mjs.map +1 -0
- package/package.json +23 -15
- package/processors/styled.js +1 -1
- package/types/processors/styled.d.ts +6 -3
- package/esm/index.js +0 -2
- package/esm/index.js.map +0 -1
- package/esm/processors/styled.js +0 -205
- package/esm/processors/styled.js.map +0 -1
- package/esm/styled.js +0 -130
- package/esm/styled.js.map +0 -1
- package/lib/index.js +0 -11
- package/lib/index.js.map +0 -1
- package/lib/processors/styled.js +0 -216
- package/lib/processors/styled.js.map +0 -1
- package/lib/styled.js +0 -143
- package/lib/styled.js.map +0 -1
package/dist/index.js
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
|
|
26
|
+
// src/index.ts
|
|
27
|
+
var src_exports = {};
|
|
28
|
+
__export(src_exports, {
|
|
29
|
+
styled: () => styled_default
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(src_exports);
|
|
32
|
+
|
|
33
|
+
// src/styled.ts
|
|
34
|
+
var import_is_prop_valid = __toESM(require("@emotion/is-prop-valid"));
|
|
35
|
+
var import_react = __toESM(require("react"));
|
|
36
|
+
var import_core = require("@linaria/core");
|
|
37
|
+
var isCapital = (ch) => ch.toUpperCase() === ch;
|
|
38
|
+
var filterKey = (keys) => (key) => keys.indexOf(key) === -1;
|
|
39
|
+
var omit = (obj, keys) => {
|
|
40
|
+
const res = {};
|
|
41
|
+
Object.keys(obj).filter(filterKey(keys)).forEach((key) => {
|
|
42
|
+
res[key] = obj[key];
|
|
43
|
+
});
|
|
44
|
+
return res;
|
|
45
|
+
};
|
|
46
|
+
function filterProps(component, props, omitKeys) {
|
|
47
|
+
const filteredProps = omit(props, omitKeys);
|
|
48
|
+
if (typeof component === "string" && component.indexOf("-") === -1 && !isCapital(component[0])) {
|
|
49
|
+
Object.keys(filteredProps).forEach((key) => {
|
|
50
|
+
if (!(0, import_is_prop_valid.default)(key)) {
|
|
51
|
+
delete filteredProps[key];
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
return filteredProps;
|
|
56
|
+
}
|
|
57
|
+
var warnIfInvalid = (value, componentName) => {
|
|
58
|
+
if (process.env.NODE_ENV !== "production") {
|
|
59
|
+
if (typeof value === "string" || typeof value === "number" && isFinite(value)) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const stringified = typeof value === "object" ? JSON.stringify(value) : String(value);
|
|
63
|
+
console.warn(
|
|
64
|
+
`An interpolation evaluated to '${stringified}' in the component '${componentName}', which is probably a mistake. You should explicitly cast or transform the value to a string.`
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
function styled(tag) {
|
|
69
|
+
return (options) => {
|
|
70
|
+
if (process.env.NODE_ENV !== "production") {
|
|
71
|
+
if (Array.isArray(options)) {
|
|
72
|
+
throw new Error(
|
|
73
|
+
'Using the "styled" tag in runtime is not supported. Make sure you have set up the Babel plugin correctly. See https://github.com/callstack/linaria#setup'
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
const render = (props, ref) => {
|
|
78
|
+
const { as: component = tag, class: className } = props;
|
|
79
|
+
const filteredProps = filterProps(component, props, [
|
|
80
|
+
"as",
|
|
81
|
+
"class"
|
|
82
|
+
]);
|
|
83
|
+
filteredProps.ref = ref;
|
|
84
|
+
filteredProps.className = options.atomic ? (0, import_core.cx)(options.class, filteredProps.className || className) : (0, import_core.cx)(filteredProps.className || className, options.class);
|
|
85
|
+
const { vars } = options;
|
|
86
|
+
if (vars) {
|
|
87
|
+
const style = {};
|
|
88
|
+
for (const name in vars) {
|
|
89
|
+
const variable = vars[name];
|
|
90
|
+
const result = variable[0];
|
|
91
|
+
const unit = variable[1] || "";
|
|
92
|
+
const value = typeof result === "function" ? result(props) : result;
|
|
93
|
+
warnIfInvalid(value, options.name);
|
|
94
|
+
style[`--${name}`] = `${value}${unit}`;
|
|
95
|
+
}
|
|
96
|
+
const ownStyle = filteredProps.style || {};
|
|
97
|
+
const keys = Object.keys(ownStyle);
|
|
98
|
+
if (keys.length > 0) {
|
|
99
|
+
keys.forEach((key) => {
|
|
100
|
+
style[key] = ownStyle[key];
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
filteredProps.style = style;
|
|
104
|
+
}
|
|
105
|
+
if (tag.__linaria && tag !== component) {
|
|
106
|
+
filteredProps.as = component;
|
|
107
|
+
return import_react.default.createElement(tag, filteredProps);
|
|
108
|
+
}
|
|
109
|
+
return import_react.default.createElement(component, filteredProps);
|
|
110
|
+
};
|
|
111
|
+
const Result = import_react.default.forwardRef ? import_react.default.forwardRef(render) : (props) => {
|
|
112
|
+
const rest = omit(props, ["innerRef"]);
|
|
113
|
+
return render(rest, props.innerRef);
|
|
114
|
+
};
|
|
115
|
+
Result.displayName = options.name;
|
|
116
|
+
Result.__linaria = {
|
|
117
|
+
className: options.class,
|
|
118
|
+
extends: tag
|
|
119
|
+
};
|
|
120
|
+
return Result;
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
var styled_default = process.env.NODE_ENV !== "production" ? new Proxy(styled, {
|
|
124
|
+
get(o, prop) {
|
|
125
|
+
return o(prop);
|
|
126
|
+
}
|
|
127
|
+
}) : styled;
|
|
128
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
129
|
+
0 && (module.exports = {
|
|
130
|
+
styled
|
|
131
|
+
});
|
|
132
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/styled.ts"],"sourcesContent":["export { default as styled } from './styled';\nexport type { StyledJSXIntrinsics, Styled } from './styled';\nexport type { CSSProperties } from '@linaria/core';\nexport type { StyledMeta } from '@linaria/tags';\n","/* eslint-disable @typescript-eslint/no-explicit-any */\n/**\n * This file contains an runtime version of `styled` component. Responsibilities of the component are:\n * - returns ReactElement based on HTML tag used with `styled` or custom React Component\n * - injects classNames for the returned component\n * - injects CSS variables used to define dynamic styles based on props\n */\nimport validAttr from '@emotion/is-prop-valid';\nimport React from 'react';\n\nimport { cx } from '@linaria/core';\nimport type { CSSProperties } from '@linaria/core';\nimport type { StyledMeta } from '@linaria/tags';\n\nexport type NoInfer<A> = [A][A extends any ? 0 : never];\n\ntype Component<TProps> =\n | ((props: TProps) => unknown)\n | { new (props: TProps): unknown };\n\ntype Has<T, TObj> = [T] extends [TObj] ? T : T & TObj;\n\ntype Options = {\n name: string;\n class: string;\n atomic?: boolean;\n vars?: {\n [key: string]: [\n string | number | ((props: unknown) => string | number),\n string | void\n ];\n };\n};\n\nconst isCapital = (ch: string): boolean => ch.toUpperCase() === ch;\nconst filterKey =\n <TExclude extends keyof any>(keys: TExclude[]) =>\n <TAll extends keyof any>(key: TAll): key is Exclude<TAll, TExclude> =>\n keys.indexOf(key as any) === -1;\n\nexport const omit = <T extends Record<string, unknown>, TKeys extends keyof T>(\n obj: T,\n keys: TKeys[]\n): Omit<T, TKeys> => {\n const res = {} as Omit<T, TKeys>;\n Object.keys(obj)\n .filter(filterKey(keys))\n .forEach((key) => {\n res[key] = obj[key];\n });\n\n return res;\n};\n\nfunction filterProps<T extends Record<string, unknown>, TKeys extends keyof T>(\n component: string | unknown,\n props: T,\n omitKeys: TKeys[]\n): Partial<Omit<T, TKeys>> {\n const filteredProps = omit(props, omitKeys) as Partial<T>;\n\n // Check if it's an HTML tag and not a custom element\n if (\n typeof component === 'string' &&\n component.indexOf('-') === -1 &&\n !isCapital(component[0])\n ) {\n Object.keys(filteredProps).forEach((key) => {\n if (!validAttr(key)) {\n // Don't pass through invalid attributes to HTML elements\n delete filteredProps[key];\n }\n });\n }\n\n return filteredProps;\n}\n\nconst warnIfInvalid = (value: unknown, componentName: string) => {\n if (process.env.NODE_ENV !== 'production') {\n if (\n typeof value === 'string' ||\n // eslint-disable-next-line no-self-compare,no-restricted-globals\n (typeof value === 'number' && isFinite(value))\n ) {\n return;\n }\n\n const stringified =\n typeof value === 'object' ? JSON.stringify(value) : String(value);\n\n // eslint-disable-next-line no-console\n console.warn(\n `An interpolation evaluated to '${stringified}' in the component '${componentName}', which is probably a mistake. You should explicitly cast or transform the value to a string.`\n );\n }\n};\n\ninterface IProps {\n className?: string;\n style?: Record<string, string>;\n [props: string]: unknown;\n}\n\n// Property-based interpolation is allowed only if `style` property exists\nfunction styled<\n TProps extends Has<TMustHave, { style?: React.CSSProperties }>,\n TMustHave extends { style?: React.CSSProperties },\n TConstructor extends Component<TProps>\n>(\n componentWithStyle: TConstructor & Component<TProps>\n): ComponentStyledTagWithInterpolation<TProps, TConstructor>;\n// If styled wraps custom component, that component should have className property\nfunction styled<\n TProps extends Has<TMustHave, { className?: string }>,\n TMustHave extends { className?: string },\n TConstructor extends Component<TProps>\n>(\n componentWithoutStyle: TConstructor & Component<TProps>\n): ComponentStyledTagWithoutInterpolation<TConstructor>;\nfunction styled<TName extends keyof JSX.IntrinsicElements>(\n tag: TName\n): HtmlStyledTag<TName>;\nfunction styled(\n component: 'The target component should have a className prop'\n): never;\nfunction styled(tag: any): any {\n return (options: Options) => {\n if (process.env.NODE_ENV !== 'production') {\n if (Array.isArray(options)) {\n // We received a strings array since it's used as a tag\n throw new Error(\n 'Using the \"styled\" tag in runtime is not supported. Make sure you have set up the Babel plugin correctly. See https://github.com/callstack/linaria#setup'\n );\n }\n }\n\n const render = (props: any, ref: any) => {\n const { as: component = tag, class: className } = props;\n const filteredProps: IProps = filterProps(component, props, [\n 'as',\n 'class',\n ]);\n\n filteredProps.ref = ref;\n filteredProps.className = options.atomic\n ? cx(options.class, filteredProps.className || className)\n : cx(filteredProps.className || className, options.class);\n\n const { vars } = options;\n\n if (vars) {\n const style: { [key: string]: string } = {};\n\n // eslint-disable-next-line guard-for-in,no-restricted-syntax\n for (const name in vars) {\n const variable = vars[name];\n const result = variable[0];\n const unit = variable[1] || '';\n const value = typeof result === 'function' ? result(props) : result;\n\n warnIfInvalid(value, options.name);\n\n style[`--${name}`] = `${value}${unit}`;\n }\n\n const ownStyle = filteredProps.style || {};\n const keys = Object.keys(ownStyle);\n if (keys.length > 0) {\n keys.forEach((key) => {\n style[key] = ownStyle[key];\n });\n }\n\n filteredProps.style = style;\n }\n\n if ((tag as any).__linaria && tag !== component) {\n // If the underlying tag is a styled component, forward the `as` prop\n // Otherwise the styles from the underlying component will be ignored\n filteredProps.as = component;\n\n return React.createElement(tag, filteredProps);\n }\n return React.createElement(component, filteredProps);\n };\n\n const Result = React.forwardRef\n ? React.forwardRef(render)\n : // React.forwardRef won't available on older React versions and in Preact\n // Fallback to a innerRef prop in that case\n (props: any) => {\n const rest = omit(props, ['innerRef']);\n return render(rest, props.innerRef);\n };\n\n (Result as any).displayName = options.name;\n\n // These properties will be read by the babel plugin for interpolation\n (Result as any).__linaria = {\n className: options.class,\n extends: tag,\n };\n\n return Result;\n };\n}\n\ntype StyledComponent<T> = StyledMeta &\n ([T] extends [React.FunctionComponent<any>]\n ? T\n : React.FunctionComponent<T & { as?: React.ElementType }>);\n\ntype StaticPlaceholder = string | number | CSSProperties | StyledMeta;\n\ntype HtmlStyledTag<TName extends keyof JSX.IntrinsicElements> = <\n TAdditionalProps = Record<string, unknown>\n>(\n strings: TemplateStringsArray,\n ...exprs: Array<\n | StaticPlaceholder\n | ((\n // Without Omit here TS tries to infer TAdditionalProps\n // from a component passed for interpolation\n props: JSX.IntrinsicElements[TName] & Omit<TAdditionalProps, never>\n ) => string | number)\n >\n) => StyledComponent<JSX.IntrinsicElements[TName] & TAdditionalProps>;\n\ntype ComponentStyledTagWithoutInterpolation<TOrigCmp> = (\n strings: TemplateStringsArray,\n ...exprs: Array<\n | StaticPlaceholder\n | ((props: 'The target component should have a style prop') => never)\n >\n) => StyledMeta & TOrigCmp;\n\n// eslint-disable-next-line @typescript-eslint/ban-types\ntype ComponentStyledTagWithInterpolation<TTrgProps, TOrigCmp> = <OwnProps = {}>(\n strings: TemplateStringsArray,\n ...exprs: Array<\n | StaticPlaceholder\n | ((props: NoInfer<OwnProps & TTrgProps>) => string | number)\n >\n) => keyof OwnProps extends never\n ? StyledMeta & TOrigCmp\n : StyledComponent<OwnProps & TTrgProps>;\n\nexport type StyledJSXIntrinsics = {\n readonly [P in keyof JSX.IntrinsicElements]: HtmlStyledTag<P>;\n};\n\nexport type Styled = typeof styled & StyledJSXIntrinsics;\n\nexport default (process.env.NODE_ENV !== 'production'\n ? new Proxy(styled, {\n get(o, prop: keyof JSX.IntrinsicElements) {\n return o(prop);\n },\n })\n : styled) as Styled;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACOA,2BAAsB;AACtB,mBAAkB;AAElB,kBAAmB;AAwBnB,IAAM,YAAY,CAAC,OAAwB,GAAG,YAAY,MAAM;AAChE,IAAM,YACJ,CAA6B,SAC7B,CAAyB,QACvB,KAAK,QAAQ,GAAU,MAAM;AAE1B,IAAM,OAAO,CAClB,KACA,SACmB;AACnB,QAAM,MAAM,CAAC;AACb,SAAO,KAAK,GAAG,EACZ,OAAO,UAAU,IAAI,CAAC,EACtB,QAAQ,CAAC,QAAQ;AAChB,QAAI,OAAO,IAAI;AAAA,EACjB,CAAC;AAEH,SAAO;AACT;AAEA,SAAS,YACP,WACA,OACA,UACyB;AACzB,QAAM,gBAAgB,KAAK,OAAO,QAAQ;AAG1C,MACE,OAAO,cAAc,YACrB,UAAU,QAAQ,GAAG,MAAM,MAC3B,CAAC,UAAU,UAAU,EAAE,GACvB;AACA,WAAO,KAAK,aAAa,EAAE,QAAQ,CAAC,QAAQ;AAC1C,UAAI,KAAC,qBAAAA,SAAU,GAAG,GAAG;AAEnB,eAAO,cAAc;AAAA,MACvB;AAAA,IACF,CAAC;AAAA,EACH;AAEA,SAAO;AACT;AAEA,IAAM,gBAAgB,CAAC,OAAgB,kBAA0B;AAC/D,MAAI,QAAQ,IAAI,aAAa,cAAc;AACzC,QACE,OAAO,UAAU,YAEhB,OAAO,UAAU,YAAY,SAAS,KAAK,GAC5C;AACA;AAAA,IACF;AAEA,UAAM,cACJ,OAAO,UAAU,WAAW,KAAK,UAAU,KAAK,IAAI,OAAO,KAAK;AAGlE,YAAQ;AAAA,MACN,kCAAkC,kCAAkC;AAAA,IACtE;AAAA,EACF;AACF;AA8BA,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QAAM,aACjB,aAAAA,QAAM,WAAW,MAAM,IAGvB,CAAC,UAAe;AACd,YAAM,OAAO,KAAK,OAAO,CAAC,UAAU,CAAC;AACrC,aAAO,OAAO,MAAM,MAAM,QAAQ;AAAA,IACpC;AAEJ,IAAC,OAAe,cAAc,QAAQ;AAGtC,IAAC,OAAe,YAAY;AAAA,MAC1B,WAAW,QAAQ;AAAA,MACnB,SAAS;AAAA,IACX;AAEA,WAAO;AAAA,EACT;AACF;AAgDA,IAAO,iBAAS,QAAQ,IAAI,aAAa,eACrC,IAAI,MAAM,QAAQ;AAAA,EAChB,IAAI,GAAG,MAAmC;AACxC,WAAO,EAAE,IAAI;AAAA,EACf;AACF,CAAC,IACD;","names":["validAttr","React"]}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
// src/styled.ts
|
|
2
|
+
import validAttr from "@emotion/is-prop-valid";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { cx } from "@linaria/core";
|
|
5
|
+
var isCapital = (ch) => ch.toUpperCase() === ch;
|
|
6
|
+
var filterKey = (keys) => (key) => keys.indexOf(key) === -1;
|
|
7
|
+
var omit = (obj, keys) => {
|
|
8
|
+
const res = {};
|
|
9
|
+
Object.keys(obj).filter(filterKey(keys)).forEach((key) => {
|
|
10
|
+
res[key] = obj[key];
|
|
11
|
+
});
|
|
12
|
+
return res;
|
|
13
|
+
};
|
|
14
|
+
function filterProps(component, props, omitKeys) {
|
|
15
|
+
const filteredProps = omit(props, omitKeys);
|
|
16
|
+
if (typeof component === "string" && component.indexOf("-") === -1 && !isCapital(component[0])) {
|
|
17
|
+
Object.keys(filteredProps).forEach((key) => {
|
|
18
|
+
if (!validAttr(key)) {
|
|
19
|
+
delete filteredProps[key];
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
return filteredProps;
|
|
24
|
+
}
|
|
25
|
+
var warnIfInvalid = (value, componentName) => {
|
|
26
|
+
if (process.env.NODE_ENV !== "production") {
|
|
27
|
+
if (typeof value === "string" || typeof value === "number" && isFinite(value)) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const stringified = typeof value === "object" ? JSON.stringify(value) : String(value);
|
|
31
|
+
console.warn(
|
|
32
|
+
`An interpolation evaluated to '${stringified}' in the component '${componentName}', which is probably a mistake. You should explicitly cast or transform the value to a string.`
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
function styled(tag) {
|
|
37
|
+
return (options) => {
|
|
38
|
+
if (process.env.NODE_ENV !== "production") {
|
|
39
|
+
if (Array.isArray(options)) {
|
|
40
|
+
throw new Error(
|
|
41
|
+
'Using the "styled" tag in runtime is not supported. Make sure you have set up the Babel plugin correctly. See https://github.com/callstack/linaria#setup'
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
const render = (props, ref) => {
|
|
46
|
+
const { as: component = tag, class: className } = props;
|
|
47
|
+
const filteredProps = filterProps(component, props, [
|
|
48
|
+
"as",
|
|
49
|
+
"class"
|
|
50
|
+
]);
|
|
51
|
+
filteredProps.ref = ref;
|
|
52
|
+
filteredProps.className = options.atomic ? cx(options.class, filteredProps.className || className) : cx(filteredProps.className || className, options.class);
|
|
53
|
+
const { vars } = options;
|
|
54
|
+
if (vars) {
|
|
55
|
+
const style = {};
|
|
56
|
+
for (const name in vars) {
|
|
57
|
+
const variable = vars[name];
|
|
58
|
+
const result = variable[0];
|
|
59
|
+
const unit = variable[1] || "";
|
|
60
|
+
const value = typeof result === "function" ? result(props) : result;
|
|
61
|
+
warnIfInvalid(value, options.name);
|
|
62
|
+
style[`--${name}`] = `${value}${unit}`;
|
|
63
|
+
}
|
|
64
|
+
const ownStyle = filteredProps.style || {};
|
|
65
|
+
const keys = Object.keys(ownStyle);
|
|
66
|
+
if (keys.length > 0) {
|
|
67
|
+
keys.forEach((key) => {
|
|
68
|
+
style[key] = ownStyle[key];
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
filteredProps.style = style;
|
|
72
|
+
}
|
|
73
|
+
if (tag.__linaria && tag !== component) {
|
|
74
|
+
filteredProps.as = component;
|
|
75
|
+
return React.createElement(tag, filteredProps);
|
|
76
|
+
}
|
|
77
|
+
return React.createElement(component, filteredProps);
|
|
78
|
+
};
|
|
79
|
+
const Result = React.forwardRef ? React.forwardRef(render) : (props) => {
|
|
80
|
+
const rest = omit(props, ["innerRef"]);
|
|
81
|
+
return render(rest, props.innerRef);
|
|
82
|
+
};
|
|
83
|
+
Result.displayName = options.name;
|
|
84
|
+
Result.__linaria = {
|
|
85
|
+
className: options.class,
|
|
86
|
+
extends: tag
|
|
87
|
+
};
|
|
88
|
+
return Result;
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
var styled_default = process.env.NODE_ENV !== "production" ? new Proxy(styled, {
|
|
92
|
+
get(o, prop) {
|
|
93
|
+
return o(prop);
|
|
94
|
+
}
|
|
95
|
+
}) : styled;
|
|
96
|
+
export {
|
|
97
|
+
styled_default as styled
|
|
98
|
+
};
|
|
99
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/styled.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/**\n * This file contains an runtime version of `styled` component. Responsibilities of the component are:\n * - returns ReactElement based on HTML tag used with `styled` or custom React Component\n * - injects classNames for the returned component\n * - injects CSS variables used to define dynamic styles based on props\n */\nimport validAttr from '@emotion/is-prop-valid';\nimport React from 'react';\n\nimport { cx } from '@linaria/core';\nimport type { CSSProperties } from '@linaria/core';\nimport type { StyledMeta } from '@linaria/tags';\n\nexport type NoInfer<A> = [A][A extends any ? 0 : never];\n\ntype Component<TProps> =\n | ((props: TProps) => unknown)\n | { new (props: TProps): unknown };\n\ntype Has<T, TObj> = [T] extends [TObj] ? T : T & TObj;\n\ntype Options = {\n name: string;\n class: string;\n atomic?: boolean;\n vars?: {\n [key: string]: [\n string | number | ((props: unknown) => string | number),\n string | void\n ];\n };\n};\n\nconst isCapital = (ch: string): boolean => ch.toUpperCase() === ch;\nconst filterKey =\n <TExclude extends keyof any>(keys: TExclude[]) =>\n <TAll extends keyof any>(key: TAll): key is Exclude<TAll, TExclude> =>\n keys.indexOf(key as any) === -1;\n\nexport const omit = <T extends Record<string, unknown>, TKeys extends keyof T>(\n obj: T,\n keys: TKeys[]\n): Omit<T, TKeys> => {\n const res = {} as Omit<T, TKeys>;\n Object.keys(obj)\n .filter(filterKey(keys))\n .forEach((key) => {\n res[key] = obj[key];\n });\n\n return res;\n};\n\nfunction filterProps<T extends Record<string, unknown>, TKeys extends keyof T>(\n component: string | unknown,\n props: T,\n omitKeys: TKeys[]\n): Partial<Omit<T, TKeys>> {\n const filteredProps = omit(props, omitKeys) as Partial<T>;\n\n // Check if it's an HTML tag and not a custom element\n if (\n typeof component === 'string' &&\n component.indexOf('-') === -1 &&\n !isCapital(component[0])\n ) {\n Object.keys(filteredProps).forEach((key) => {\n if (!validAttr(key)) {\n // Don't pass through invalid attributes to HTML elements\n delete filteredProps[key];\n }\n });\n }\n\n return filteredProps;\n}\n\nconst warnIfInvalid = (value: unknown, componentName: string) => {\n if (process.env.NODE_ENV !== 'production') {\n if (\n typeof value === 'string' ||\n // eslint-disable-next-line no-self-compare,no-restricted-globals\n (typeof value === 'number' && isFinite(value))\n ) {\n return;\n }\n\n const stringified =\n typeof value === 'object' ? JSON.stringify(value) : String(value);\n\n // eslint-disable-next-line no-console\n console.warn(\n `An interpolation evaluated to '${stringified}' in the component '${componentName}', which is probably a mistake. You should explicitly cast or transform the value to a string.`\n );\n }\n};\n\ninterface IProps {\n className?: string;\n style?: Record<string, string>;\n [props: string]: unknown;\n}\n\n// Property-based interpolation is allowed only if `style` property exists\nfunction styled<\n TProps extends Has<TMustHave, { style?: React.CSSProperties }>,\n TMustHave extends { style?: React.CSSProperties },\n TConstructor extends Component<TProps>\n>(\n componentWithStyle: TConstructor & Component<TProps>\n): ComponentStyledTagWithInterpolation<TProps, TConstructor>;\n// If styled wraps custom component, that component should have className property\nfunction styled<\n TProps extends Has<TMustHave, { className?: string }>,\n TMustHave extends { className?: string },\n TConstructor extends Component<TProps>\n>(\n componentWithoutStyle: TConstructor & Component<TProps>\n): ComponentStyledTagWithoutInterpolation<TConstructor>;\nfunction styled<TName extends keyof JSX.IntrinsicElements>(\n tag: TName\n): HtmlStyledTag<TName>;\nfunction styled(\n component: 'The target component should have a className prop'\n): never;\nfunction styled(tag: any): any {\n return (options: Options) => {\n if (process.env.NODE_ENV !== 'production') {\n if (Array.isArray(options)) {\n // We received a strings array since it's used as a tag\n throw new Error(\n 'Using the \"styled\" tag in runtime is not supported. Make sure you have set up the Babel plugin correctly. See https://github.com/callstack/linaria#setup'\n );\n }\n }\n\n const render = (props: any, ref: any) => {\n const { as: component = tag, class: className } = props;\n const filteredProps: IProps = filterProps(component, props, [\n 'as',\n 'class',\n ]);\n\n filteredProps.ref = ref;\n filteredProps.className = options.atomic\n ? cx(options.class, filteredProps.className || className)\n : cx(filteredProps.className || className, options.class);\n\n const { vars } = options;\n\n if (vars) {\n const style: { [key: string]: string } = {};\n\n // eslint-disable-next-line guard-for-in,no-restricted-syntax\n for (const name in vars) {\n const variable = vars[name];\n const result = variable[0];\n const unit = variable[1] || '';\n const value = typeof result === 'function' ? result(props) : result;\n\n warnIfInvalid(value, options.name);\n\n style[`--${name}`] = `${value}${unit}`;\n }\n\n const ownStyle = filteredProps.style || {};\n const keys = Object.keys(ownStyle);\n if (keys.length > 0) {\n keys.forEach((key) => {\n style[key] = ownStyle[key];\n });\n }\n\n filteredProps.style = style;\n }\n\n if ((tag as any).__linaria && tag !== component) {\n // If the underlying tag is a styled component, forward the `as` prop\n // Otherwise the styles from the underlying component will be ignored\n filteredProps.as = component;\n\n return React.createElement(tag, filteredProps);\n }\n return React.createElement(component, filteredProps);\n };\n\n const Result = React.forwardRef\n ? React.forwardRef(render)\n : // React.forwardRef won't available on older React versions and in Preact\n // Fallback to a innerRef prop in that case\n (props: any) => {\n const rest = omit(props, ['innerRef']);\n return render(rest, props.innerRef);\n };\n\n (Result as any).displayName = options.name;\n\n // These properties will be read by the babel plugin for interpolation\n (Result as any).__linaria = {\n className: options.class,\n extends: tag,\n };\n\n return Result;\n };\n}\n\ntype StyledComponent<T> = StyledMeta &\n ([T] extends [React.FunctionComponent<any>]\n ? T\n : React.FunctionComponent<T & { as?: React.ElementType }>);\n\ntype StaticPlaceholder = string | number | CSSProperties | StyledMeta;\n\ntype HtmlStyledTag<TName extends keyof JSX.IntrinsicElements> = <\n TAdditionalProps = Record<string, unknown>\n>(\n strings: TemplateStringsArray,\n ...exprs: Array<\n | StaticPlaceholder\n | ((\n // Without Omit here TS tries to infer TAdditionalProps\n // from a component passed for interpolation\n props: JSX.IntrinsicElements[TName] & Omit<TAdditionalProps, never>\n ) => string | number)\n >\n) => StyledComponent<JSX.IntrinsicElements[TName] & TAdditionalProps>;\n\ntype ComponentStyledTagWithoutInterpolation<TOrigCmp> = (\n strings: TemplateStringsArray,\n ...exprs: Array<\n | StaticPlaceholder\n | ((props: 'The target component should have a style prop') => never)\n >\n) => StyledMeta & TOrigCmp;\n\n// eslint-disable-next-line @typescript-eslint/ban-types\ntype ComponentStyledTagWithInterpolation<TTrgProps, TOrigCmp> = <OwnProps = {}>(\n strings: TemplateStringsArray,\n ...exprs: Array<\n | StaticPlaceholder\n | ((props: NoInfer<OwnProps & TTrgProps>) => string | number)\n >\n) => keyof OwnProps extends never\n ? StyledMeta & TOrigCmp\n : StyledComponent<OwnProps & TTrgProps>;\n\nexport type StyledJSXIntrinsics = {\n readonly [P in keyof JSX.IntrinsicElements]: HtmlStyledTag<P>;\n};\n\nexport type Styled = typeof styled & StyledJSXIntrinsics;\n\nexport default (process.env.NODE_ENV !== 'production'\n ? new Proxy(styled, {\n get(o, prop: keyof JSX.IntrinsicElements) {\n return o(prop);\n },\n })\n : styled) as Styled;\n"],"mappings":";AAOA,OAAO,eAAe;AACtB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,WAAO;AAAA,EACT;AACF;AAgDA,IAAO,iBAAS,QAAQ,IAAI,aAAa,eACrC,IAAI,MAAM,QAAQ;AAAA,EAChB,IAAI,GAAG,MAAmC;AACxC,WAAO,EAAE,IAAI;AAAA,EACf;AACF,CAAC,IACD;","names":[]}
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var __publicField = (obj, key, value) => {
|
|
21
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
22
|
+
return value;
|
|
23
|
+
};
|
|
24
|
+
var __accessCheck = (obj, member, msg) => {
|
|
25
|
+
if (!member.has(obj))
|
|
26
|
+
throw TypeError("Cannot " + msg);
|
|
27
|
+
};
|
|
28
|
+
var __privateGet = (obj, member, getter) => {
|
|
29
|
+
__accessCheck(obj, member, "read from private field");
|
|
30
|
+
return getter ? getter.call(obj) : member.get(obj);
|
|
31
|
+
};
|
|
32
|
+
var __privateAdd = (obj, member, value) => {
|
|
33
|
+
if (member.has(obj))
|
|
34
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
35
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
36
|
+
};
|
|
37
|
+
var __privateSet = (obj, member, value, setter) => {
|
|
38
|
+
__accessCheck(obj, member, "write to private field");
|
|
39
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
40
|
+
return value;
|
|
41
|
+
};
|
|
42
|
+
var __privateWrapper = (obj, member, setter, getter) => ({
|
|
43
|
+
set _(value) {
|
|
44
|
+
__privateSet(obj, member, value, setter);
|
|
45
|
+
},
|
|
46
|
+
get _() {
|
|
47
|
+
return __privateGet(obj, member, getter);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
// src/processors/styled.ts
|
|
52
|
+
var styled_exports = {};
|
|
53
|
+
__export(styled_exports, {
|
|
54
|
+
default: () => StyledProcessor
|
|
55
|
+
});
|
|
56
|
+
module.exports = __toCommonJS(styled_exports);
|
|
57
|
+
var import_tags = require("@linaria/tags");
|
|
58
|
+
var import_utils = require("@linaria/utils");
|
|
59
|
+
var isNotNull = (x) => x !== null;
|
|
60
|
+
var singleQuotedStringLiteral = (value) => ({
|
|
61
|
+
type: "StringLiteral",
|
|
62
|
+
value,
|
|
63
|
+
extra: {
|
|
64
|
+
rawValue: value,
|
|
65
|
+
raw: `'${value}'`
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
var _variableIdx, _variablesCache;
|
|
69
|
+
var StyledProcessor = class extends import_tags.TaggedTemplateProcessor {
|
|
70
|
+
constructor(params, ...args) {
|
|
71
|
+
(0, import_tags.validateParams)(
|
|
72
|
+
params,
|
|
73
|
+
["tag", ["call", "member"], ["template", "call"]],
|
|
74
|
+
"Invalid usage of `styled` tag"
|
|
75
|
+
);
|
|
76
|
+
const [tag, tagOp, template] = params;
|
|
77
|
+
if (template[0] === "call") {
|
|
78
|
+
throw import_tags.TaggedTemplateProcessor.SKIP;
|
|
79
|
+
}
|
|
80
|
+
super([tag, template], ...args);
|
|
81
|
+
__publicField(this, "component");
|
|
82
|
+
__privateAdd(this, _variableIdx, 0);
|
|
83
|
+
__privateAdd(this, _variablesCache, /* @__PURE__ */ new Map());
|
|
84
|
+
let component;
|
|
85
|
+
if (tagOp[0] === "call" && tagOp.length === 2) {
|
|
86
|
+
const value = tagOp[1];
|
|
87
|
+
if (value.kind === import_tags.ValueType.FUNCTION) {
|
|
88
|
+
component = "FunctionalComponent";
|
|
89
|
+
} else {
|
|
90
|
+
component = {
|
|
91
|
+
node: value.ex,
|
|
92
|
+
source: value.source
|
|
93
|
+
};
|
|
94
|
+
this.dependencies.push(value);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if (tagOp[0] === "member") {
|
|
98
|
+
[, component] = tagOp;
|
|
99
|
+
}
|
|
100
|
+
if (!component) {
|
|
101
|
+
throw new Error("Invalid usage of `styled` tag");
|
|
102
|
+
}
|
|
103
|
+
this.component = component;
|
|
104
|
+
}
|
|
105
|
+
addInterpolation(node, precedingCss, source, unit = "") {
|
|
106
|
+
const id = this.getVariableId(source, unit, precedingCss);
|
|
107
|
+
this.interpolations.push({
|
|
108
|
+
id,
|
|
109
|
+
node,
|
|
110
|
+
source,
|
|
111
|
+
unit
|
|
112
|
+
});
|
|
113
|
+
return id;
|
|
114
|
+
}
|
|
115
|
+
doEvaltimeReplacement() {
|
|
116
|
+
this.replacer(this.value, false);
|
|
117
|
+
}
|
|
118
|
+
doRuntimeReplacement() {
|
|
119
|
+
const t = this.astService;
|
|
120
|
+
const props = this.getProps();
|
|
121
|
+
this.replacer(
|
|
122
|
+
t.callExpression(this.tagExpression, [this.getTagComponentProps(props)]),
|
|
123
|
+
true
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
extractRules(valueCache, cssText, loc) {
|
|
127
|
+
const rules = {};
|
|
128
|
+
let selector = `.${this.className}`;
|
|
129
|
+
let value = typeof this.component === "string" ? null : valueCache.get(this.component.node.name);
|
|
130
|
+
while ((0, import_tags.hasMeta)(value)) {
|
|
131
|
+
selector += `.${value.__linaria.className}`;
|
|
132
|
+
value = value.__linaria.extends;
|
|
133
|
+
}
|
|
134
|
+
rules[selector] = {
|
|
135
|
+
cssText,
|
|
136
|
+
className: this.className,
|
|
137
|
+
displayName: this.displayName,
|
|
138
|
+
start: (loc == null ? void 0 : loc.start) ?? null
|
|
139
|
+
};
|
|
140
|
+
return rules;
|
|
141
|
+
}
|
|
142
|
+
get asSelector() {
|
|
143
|
+
return `.${this.className}`;
|
|
144
|
+
}
|
|
145
|
+
get tagExpressionArgument() {
|
|
146
|
+
const t = this.astService;
|
|
147
|
+
if (typeof this.component === "string") {
|
|
148
|
+
if (this.component === "FunctionalComponent") {
|
|
149
|
+
return t.arrowFunctionExpression([], t.blockStatement([]));
|
|
150
|
+
}
|
|
151
|
+
return singleQuotedStringLiteral(this.component);
|
|
152
|
+
}
|
|
153
|
+
return t.callExpression(t.identifier(this.component.node.name), []);
|
|
154
|
+
}
|
|
155
|
+
get tagExpression() {
|
|
156
|
+
const t = this.astService;
|
|
157
|
+
return t.callExpression(this.tag, [this.tagExpressionArgument]);
|
|
158
|
+
}
|
|
159
|
+
get value() {
|
|
160
|
+
const t = this.astService;
|
|
161
|
+
const extendsNode = typeof this.component === "string" ? null : this.component.node.name;
|
|
162
|
+
return t.objectExpression([
|
|
163
|
+
t.objectProperty(
|
|
164
|
+
t.stringLiteral("displayName"),
|
|
165
|
+
t.stringLiteral(this.displayName)
|
|
166
|
+
),
|
|
167
|
+
t.objectProperty(
|
|
168
|
+
t.stringLiteral("__linaria"),
|
|
169
|
+
t.objectExpression([
|
|
170
|
+
t.objectProperty(
|
|
171
|
+
t.stringLiteral("className"),
|
|
172
|
+
t.stringLiteral(this.className)
|
|
173
|
+
),
|
|
174
|
+
t.objectProperty(
|
|
175
|
+
t.stringLiteral("extends"),
|
|
176
|
+
extendsNode ? t.callExpression(t.identifier(extendsNode), []) : t.nullLiteral()
|
|
177
|
+
)
|
|
178
|
+
])
|
|
179
|
+
)
|
|
180
|
+
]);
|
|
181
|
+
}
|
|
182
|
+
toString() {
|
|
183
|
+
const res = (arg) => `${this.tagSourceCode()}(${arg})\`\u2026\``;
|
|
184
|
+
if (typeof this.component === "string") {
|
|
185
|
+
if (this.component === "FunctionalComponent") {
|
|
186
|
+
return res("() => {\u2026}");
|
|
187
|
+
}
|
|
188
|
+
return res(`'${this.component}'`);
|
|
189
|
+
}
|
|
190
|
+
return res(this.component.source);
|
|
191
|
+
}
|
|
192
|
+
getCustomVariableId(source, unit, precedingCss) {
|
|
193
|
+
const context = this.getVariableContext(source, unit, precedingCss);
|
|
194
|
+
const customSlugFn = this.options.variableNameSlug;
|
|
195
|
+
if (!customSlugFn) {
|
|
196
|
+
return void 0;
|
|
197
|
+
}
|
|
198
|
+
return typeof customSlugFn === "function" ? customSlugFn(context) : (0, import_tags.buildSlug)(customSlugFn, context);
|
|
199
|
+
}
|
|
200
|
+
getProps() {
|
|
201
|
+
const propsObj = {
|
|
202
|
+
name: this.displayName,
|
|
203
|
+
class: this.className
|
|
204
|
+
};
|
|
205
|
+
if (this.interpolations.length) {
|
|
206
|
+
propsObj.vars = {};
|
|
207
|
+
this.interpolations.forEach(({ id, unit, node }) => {
|
|
208
|
+
const items = [this.astService.callExpression(node, [])];
|
|
209
|
+
if (unit) {
|
|
210
|
+
items.push(this.astService.stringLiteral(unit));
|
|
211
|
+
}
|
|
212
|
+
propsObj.vars[id] = items;
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
return propsObj;
|
|
216
|
+
}
|
|
217
|
+
getTagComponentProps(props) {
|
|
218
|
+
const t = this.astService;
|
|
219
|
+
const propExpressions = Object.entries(props).map(([key, value]) => {
|
|
220
|
+
if (!value) {
|
|
221
|
+
return null;
|
|
222
|
+
}
|
|
223
|
+
const keyNode = t.identifier(key);
|
|
224
|
+
if (typeof value === "string") {
|
|
225
|
+
return t.objectProperty(keyNode, t.stringLiteral(value));
|
|
226
|
+
}
|
|
227
|
+
if (typeof value === "boolean") {
|
|
228
|
+
return t.objectProperty(keyNode, t.booleanLiteral(value));
|
|
229
|
+
}
|
|
230
|
+
const vars = Object.entries(value).map(([propName, propValue]) => {
|
|
231
|
+
return t.objectProperty(
|
|
232
|
+
t.stringLiteral(propName),
|
|
233
|
+
t.arrayExpression(propValue)
|
|
234
|
+
);
|
|
235
|
+
});
|
|
236
|
+
return t.objectProperty(keyNode, t.objectExpression(vars));
|
|
237
|
+
}).filter(isNotNull);
|
|
238
|
+
return t.objectExpression(propExpressions);
|
|
239
|
+
}
|
|
240
|
+
getVariableContext(source, unit, precedingCss) {
|
|
241
|
+
const getIndex = () => {
|
|
242
|
+
return __privateWrapper(this, _variableIdx)._++;
|
|
243
|
+
};
|
|
244
|
+
return {
|
|
245
|
+
componentName: this.displayName,
|
|
246
|
+
componentSlug: this.slug,
|
|
247
|
+
get index() {
|
|
248
|
+
return getIndex();
|
|
249
|
+
},
|
|
250
|
+
precedingCss,
|
|
251
|
+
processor: this.constructor.name,
|
|
252
|
+
source,
|
|
253
|
+
unit,
|
|
254
|
+
valueSlug: (0, import_utils.slugify)(source + unit)
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
getVariableId(source, unit, precedingCss) {
|
|
258
|
+
const value = source + unit;
|
|
259
|
+
if (!__privateGet(this, _variablesCache).has(value)) {
|
|
260
|
+
const id = this.getCustomVariableId(source, unit, precedingCss);
|
|
261
|
+
if (id) {
|
|
262
|
+
return (0, import_tags.toValidCSSIdentifier)(id);
|
|
263
|
+
}
|
|
264
|
+
const context = this.getVariableContext(source, unit, precedingCss);
|
|
265
|
+
__privateGet(this, _variablesCache).set(value, `${this.slug}-${context.index}`);
|
|
266
|
+
}
|
|
267
|
+
return __privateGet(this, _variablesCache).get(value);
|
|
268
|
+
}
|
|
269
|
+
};
|
|
270
|
+
_variableIdx = new WeakMap();
|
|
271
|
+
_variablesCache = new WeakMap();
|
|
272
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
273
|
+
0 && (module.exports = {});
|
|
274
|
+
//# sourceMappingURL=styled.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/processors/styled.ts"],"sourcesContent":["import type {\n CallExpression,\n Expression,\n ObjectExpression,\n SourceLocation,\n StringLiteral,\n} from '@babel/types';\n\nimport type {\n Params,\n Rules,\n TailProcessorParams,\n ValueCache,\n WrappedNode,\n} from '@linaria/tags';\nimport {\n buildSlug,\n hasMeta,\n TaggedTemplateProcessor,\n validateParams,\n ValueType,\n toValidCSSIdentifier,\n} from '@linaria/tags';\nimport type { IVariableContext } from '@linaria/utils';\nimport { slugify } from '@linaria/utils';\n\nconst isNotNull = <T>(x: T | null): x is T => x !== null;\n\nexport interface IProps {\n atomic?: boolean;\n class?: string;\n name: string;\n vars?: Record<string, Expression[]>;\n}\n\nconst singleQuotedStringLiteral = (value: string): StringLiteral => ({\n type: 'StringLiteral',\n value,\n extra: {\n rawValue: value,\n raw: `'${value}'`,\n },\n});\n\nexport default class StyledProcessor extends TaggedTemplateProcessor {\n public component: WrappedNode;\n\n #variableIdx = 0;\n\n #variablesCache = new Map<string, string>();\n\n constructor(params: Params, ...args: TailProcessorParams) {\n validateParams(\n params,\n ['tag', ['call', 'member'], ['template', 'call']],\n 'Invalid usage of `styled` tag'\n );\n\n const [tag, tagOp, template] = params;\n\n if (template[0] === 'call') {\n // It is already transformed styled-literal. Skip it.\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw TaggedTemplateProcessor.SKIP;\n }\n\n super([tag, template], ...args);\n\n let component: WrappedNode | undefined;\n if (tagOp[0] === 'call' && tagOp.length === 2) {\n const value = tagOp[1];\n if (value.kind === ValueType.FUNCTION) {\n component = 'FunctionalComponent';\n } else {\n component = {\n node: value.ex,\n source: value.source,\n };\n\n this.dependencies.push(value);\n }\n }\n\n if (tagOp[0] === 'member') {\n [, component] = tagOp;\n }\n\n if (!component) {\n throw new Error('Invalid usage of `styled` tag');\n }\n\n this.component = component;\n }\n\n public override addInterpolation(\n node: Expression,\n precedingCss: string,\n source: string,\n unit = ''\n ): string {\n const id = this.getVariableId(source, unit, precedingCss);\n\n this.interpolations.push({\n id,\n node,\n source,\n unit,\n });\n\n return id;\n }\n\n public override doEvaltimeReplacement(): void {\n this.replacer(this.value, false);\n }\n\n public override doRuntimeReplacement(): void {\n const t = this.astService;\n\n const props = this.getProps();\n\n this.replacer(\n t.callExpression(this.tagExpression, [this.getTagComponentProps(props)]),\n true\n );\n }\n\n public override extractRules(\n valueCache: ValueCache,\n cssText: string,\n loc?: SourceLocation | null\n ): Rules {\n const rules: Rules = {};\n\n let selector = `.${this.className}`;\n\n // If `styled` wraps another component and not a primitive,\n // get its class name to create a more specific selector\n // it'll ensure that styles are overridden properly\n let value =\n typeof this.component === 'string'\n ? null\n : valueCache.get(this.component.node.name);\n while (hasMeta(value)) {\n selector += `.${value.__linaria.className}`;\n value = value.__linaria.extends;\n }\n\n rules[selector] = {\n cssText,\n className: this.className,\n displayName: this.displayName,\n start: loc?.start ?? null,\n };\n\n return rules;\n }\n\n public override get asSelector(): string {\n return `.${this.className}`;\n }\n\n protected get tagExpressionArgument(): Expression {\n const t = this.astService;\n if (typeof this.component === 'string') {\n if (this.component === 'FunctionalComponent') {\n return t.arrowFunctionExpression([], t.blockStatement([]));\n }\n\n return singleQuotedStringLiteral(this.component);\n }\n\n return t.callExpression(t.identifier(this.component.node.name), []);\n }\n\n protected get tagExpression(): CallExpression {\n const t = this.astService;\n return t.callExpression(this.tag, [this.tagExpressionArgument]);\n }\n\n public override get value(): ObjectExpression {\n const t = this.astService;\n const extendsNode =\n typeof this.component === 'string' ? null : this.component.node.name;\n\n return t.objectExpression([\n t.objectProperty(\n t.stringLiteral('displayName'),\n t.stringLiteral(this.displayName)\n ),\n t.objectProperty(\n t.stringLiteral('__linaria'),\n t.objectExpression([\n t.objectProperty(\n t.stringLiteral('className'),\n t.stringLiteral(this.className)\n ),\n t.objectProperty(\n t.stringLiteral('extends'),\n extendsNode\n ? t.callExpression(t.identifier(extendsNode), [])\n : t.nullLiteral()\n ),\n ])\n ),\n ]);\n }\n\n public override toString(): string {\n const res = (arg: string) => `${this.tagSourceCode()}(${arg})\\`…\\``;\n\n if (typeof this.component === 'string') {\n if (this.component === 'FunctionalComponent') {\n return res('() => {…}');\n }\n\n return res(`'${this.component}'`);\n }\n\n return res(this.component.source);\n }\n\n protected getCustomVariableId(\n source: string,\n unit: string,\n precedingCss: string\n ) {\n const context = this.getVariableContext(source, unit, precedingCss);\n const customSlugFn = this.options.variableNameSlug;\n if (!customSlugFn) {\n return undefined;\n }\n\n return typeof customSlugFn === 'function'\n ? customSlugFn(context)\n : buildSlug(customSlugFn, context);\n }\n\n protected getProps(): IProps {\n const propsObj: IProps = {\n name: this.displayName,\n class: this.className,\n };\n\n // If we found any interpolations, also pass them, so they can be applied\n if (this.interpolations.length) {\n propsObj.vars = {};\n this.interpolations.forEach(({ id, unit, node }) => {\n const items: Expression[] = [this.astService.callExpression(node, [])];\n\n if (unit) {\n items.push(this.astService.stringLiteral(unit));\n }\n\n propsObj.vars![id] = items;\n });\n }\n\n return propsObj;\n }\n\n protected getTagComponentProps(props: IProps): ObjectExpression {\n const t = this.astService;\n\n const propExpressions = Object.entries(props)\n .map(([key, value]: [key: string, value: IProps[keyof IProps]]) => {\n if (!value) {\n return null;\n }\n\n const keyNode = t.identifier(key);\n\n if (typeof value === 'string') {\n return t.objectProperty(keyNode, t.stringLiteral(value));\n }\n\n if (typeof value === 'boolean') {\n return t.objectProperty(keyNode, t.booleanLiteral(value));\n }\n\n const vars = Object.entries(value).map(([propName, propValue]) => {\n return t.objectProperty(\n t.stringLiteral(propName),\n t.arrayExpression(propValue)\n );\n });\n\n return t.objectProperty(keyNode, t.objectExpression(vars));\n })\n .filter(isNotNull);\n\n return t.objectExpression(propExpressions);\n }\n\n protected getVariableContext(\n source: string,\n unit: string,\n precedingCss: string\n ): IVariableContext {\n const getIndex = () => {\n // eslint-disable-next-line no-plusplus\n return this.#variableIdx++;\n };\n\n return {\n componentName: this.displayName,\n componentSlug: this.slug,\n get index() {\n return getIndex();\n },\n precedingCss,\n processor: this.constructor.name,\n source,\n unit,\n valueSlug: slugify(source + unit),\n };\n }\n\n protected getVariableId(\n source: string,\n unit: string,\n precedingCss: string\n ): string {\n const value = source + unit;\n if (!this.#variablesCache.has(value)) {\n const id = this.getCustomVariableId(source, unit, precedingCss);\n if (id) {\n return toValidCSSIdentifier(id);\n }\n\n const context = this.getVariableContext(source, unit, precedingCss);\n\n // make the variable unique to this styled component\n this.#variablesCache.set(value, `${this.slug}-${context.index}`);\n }\n\n return this.#variablesCache.get(value)!;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAeA,kBAOO;AAEP,mBAAwB;AAExB,IAAM,YAAY,CAAI,MAAwB,MAAM;AASpD,IAAM,4BAA4B,CAAC,WAAkC;AAAA,EACnE,MAAM;AAAA,EACN;AAAA,EACA,OAAO;AAAA,IACL,UAAU;AAAA,IACV,KAAK,IAAI;AAAA,EACX;AACF;AA1CA;AA4CA,IAAqB,kBAArB,cAA6C,oCAAwB;AAAA,EAOnE,YAAY,WAAmB,MAA2B;AACxD;AAAA,MACE;AAAA,MACA,CAAC,OAAO,CAAC,QAAQ,QAAQ,GAAG,CAAC,YAAY,MAAM,CAAC;AAAA,MAChD;AAAA,IACF;AAEA,UAAM,CAAC,KAAK,OAAO,QAAQ,IAAI;AAE/B,QAAI,SAAS,OAAO,QAAQ;AAG1B,YAAM,oCAAwB;AAAA,IAChC;AAEA,UAAM,CAAC,KAAK,QAAQ,GAAG,GAAG,IAAI;AArBhC,wBAAO;AAEP,qCAAe;AAEf,wCAAkB,oBAAI,IAAoB;AAmBxC,QAAI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