@react-email/tailwind 2.0.0-canary.0 → 2.0.0-canary.1
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.d.mts +11 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.d.ts +11 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +84 -73
- package/dist/index.mjs +81 -73
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React$1 from "react";
|
|
2
2
|
import { Config } from "tailwindcss";
|
|
3
|
+
import { StyleSheet } from "css-tree";
|
|
3
4
|
|
|
4
5
|
//#region src/tailwind.d.ts
|
|
5
6
|
type TailwindConfig = Omit<Config, 'content'>;
|
|
@@ -13,10 +14,19 @@ interface EmailElementProps {
|
|
|
13
14
|
style?: React$1.CSSProperties;
|
|
14
15
|
}
|
|
15
16
|
declare const pixelBasedPreset: TailwindConfig;
|
|
17
|
+
declare function sanitizeStyleSheet(styleSheet: StyleSheet): void;
|
|
18
|
+
declare function inlineStyles(styleSheet: StyleSheet, classes: string[]): Record<string, string>;
|
|
16
19
|
declare function Tailwind({
|
|
17
20
|
children,
|
|
18
21
|
config
|
|
19
22
|
}: TailwindProps): React$1.ReactNode;
|
|
20
23
|
//#endregion
|
|
21
|
-
|
|
24
|
+
//#region src/utils/tailwindcss/setup-tailwind.d.ts
|
|
25
|
+
type TailwindSetup = Awaited<ReturnType<typeof setupTailwind>>;
|
|
26
|
+
declare function setupTailwind(config: TailwindConfig): Promise<{
|
|
27
|
+
addUtilities: (candidates: string[]) => void;
|
|
28
|
+
getStyleSheet: () => StyleSheet;
|
|
29
|
+
}>;
|
|
30
|
+
//#endregion
|
|
31
|
+
export { EmailElementProps, Tailwind, TailwindConfig, TailwindProps, TailwindSetup, inlineStyles, pixelBasedPreset, sanitizeStyleSheet, setupTailwind };
|
|
22
32
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/tailwind.tsx"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/tailwind.tsx","../src/utils/tailwindcss/setup-tailwind.ts"],"sourcesContent":[],"mappings":";;;;;KAqBY,cAAA,GAAiB,KAAK;UAEjB,aAAA;EAFL,QAAA,EAGA,OAAA,CAAM,SAHQ;EAAA,MAAA,CAAA,EAIf,cAJe;;AAAG,UAOZ,iBAAA,CAPY;EAAI,QAAA,CAAA,EAQpB,OAAA,CAAM,SARc;EAEhB,SAAA,CAAA,EAAA,MAAa;EAAA,KAAA,CAAA,EAQpB,OAAA,CAAM,aARc;;AAEnB,cASE,gBATF,EASoB,cATpB;AAAc,iBAoET,kBAAA,CApES,UAAA,EAoEsB,UApEtB,CAAA,EAAA,IAAA;AAGR,iBAuED,YAAA,CAvEkB,UAAA,EAwEpB,UAxEoB,EAAA,OAAA,EAAA,MAAA,EAAA,CAAA,EA0E/B,MA1E+B,CAAA,MAAA,EAAA,MAAA,CAAA;AAAA,iBAwFlB,QAAA,CAxFkB;EAAA,QAAA;EAAA;AAAA,CAAA,EAwFa,aAxFb,CAAA,EAwF0B,OAAA,CAAA,SAxF1B;;;KCpBtB,aAAA,GAAgB,QAAQ,kBAAkB;iBAEhC,aAAA,SAAsB,iBAAc;;EDW9C,aAAA,EAAA,GAAc,GCyDC,UDzDD;CAAA,CAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { StyleSheet } from "css-tree";
|
|
1
2
|
import * as React from "react";
|
|
2
3
|
import { Config } from "tailwindcss";
|
|
3
4
|
|
|
@@ -13,10 +14,19 @@ interface EmailElementProps {
|
|
|
13
14
|
style?: React.CSSProperties;
|
|
14
15
|
}
|
|
15
16
|
declare const pixelBasedPreset: TailwindConfig;
|
|
17
|
+
declare function sanitizeStyleSheet(styleSheet: StyleSheet): void;
|
|
18
|
+
declare function inlineStyles(styleSheet: StyleSheet, classes: string[]): Record<string, string>;
|
|
16
19
|
declare function Tailwind({
|
|
17
20
|
children,
|
|
18
21
|
config
|
|
19
22
|
}: TailwindProps): React.ReactNode;
|
|
20
23
|
//#endregion
|
|
21
|
-
|
|
24
|
+
//#region src/utils/tailwindcss/setup-tailwind.d.ts
|
|
25
|
+
type TailwindSetup = Awaited<ReturnType<typeof setupTailwind>>;
|
|
26
|
+
declare function setupTailwind(config: TailwindConfig): Promise<{
|
|
27
|
+
addUtilities: (candidates: string[]) => void;
|
|
28
|
+
getStyleSheet: () => StyleSheet;
|
|
29
|
+
}>;
|
|
30
|
+
//#endregion
|
|
31
|
+
export { EmailElementProps, Tailwind, TailwindConfig, TailwindProps, TailwindSetup, inlineStyles, pixelBasedPreset, sanitizeStyleSheet, setupTailwind };
|
|
22
32
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/tailwind.tsx"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/tailwind.tsx","../src/utils/tailwindcss/setup-tailwind.ts"],"sourcesContent":[],"mappings":";;;;;KAqBY,cAAA,GAAiB,KAAK;UAEjB,aAAA;EAFL,QAAA,EAGA,KAAA,CAAM,SAHQ;EAAA,MAAA,CAAA,EAIf,cAJe;;AAAG,UAOZ,iBAAA,CAPY;EAAI,QAAA,CAAA,EAQpB,KAAA,CAAM,SARc;EAEhB,SAAA,CAAA,EAAA,MAAa;EAAA,KAAA,CAAA,EAQpB,KAAA,CAAM,aARc;;AAEnB,cASE,gBATF,EASoB,cATpB;AAAc,iBAoET,kBAAA,CApES,UAAA,EAoEsB,UApEtB,CAAA,EAAA,IAAA;AAGR,iBAuED,YAAA,CAvEkB,UAAA,EAwEpB,UAxEoB,EAAA,OAAA,EAAA,MAAA,EAAA,CAAA,EA0E/B,MA1E+B,CAAA,MAAA,EAAA,MAAA,CAAA;AAAA,iBAwFlB,QAAA,CAxFkB;EAAA,QAAA;EAAA;AAAA,CAAA,EAwFa,aAxFb,CAAA,EAwF0B,KAAA,CAAA,SAxF1B;;;KCpBtB,aAAA,GAAgB,QAAQ,kBAAkB;iBAEhC,aAAA,SAAsB,iBAAc;;EDW9C,aAAA,EAAA,GAAc,GCyDC,UDzDD;CAAA,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -19121,6 +19121,74 @@ function getCustomProperties(node) {
|
|
|
19121
19121
|
return customProperties;
|
|
19122
19122
|
}
|
|
19123
19123
|
|
|
19124
|
+
//#endregion
|
|
19125
|
+
//#region src/utils/text/from-dash-case-to-camel-case.ts
|
|
19126
|
+
const fromDashCaseToCamelCase = (text) => {
|
|
19127
|
+
return text.replace(/-(\w|$)/g, (_, p1) => p1.toUpperCase());
|
|
19128
|
+
};
|
|
19129
|
+
|
|
19130
|
+
//#endregion
|
|
19131
|
+
//#region src/utils/compatibility/get-react-property.ts
|
|
19132
|
+
function getReactProperty(prop) {
|
|
19133
|
+
const modifiedProp = prop.toLowerCase();
|
|
19134
|
+
if (modifiedProp.startsWith("--")) return modifiedProp;
|
|
19135
|
+
if (modifiedProp.startsWith("-ms-")) return fromDashCaseToCamelCase(modifiedProp.slice(1));
|
|
19136
|
+
return fromDashCaseToCamelCase(modifiedProp);
|
|
19137
|
+
}
|
|
19138
|
+
|
|
19139
|
+
//#endregion
|
|
19140
|
+
//#region src/utils/css/unwrap-value.ts
|
|
19141
|
+
function unwrapValue(value) {
|
|
19142
|
+
if (value.type === "Value" && value.children.size === 1) return value.children.first ?? value;
|
|
19143
|
+
return value;
|
|
19144
|
+
}
|
|
19145
|
+
|
|
19146
|
+
//#endregion
|
|
19147
|
+
//#region src/utils/css/make-inline-styles-for.ts
|
|
19148
|
+
function makeInlineStylesFor(inlinableRules, customProperties) {
|
|
19149
|
+
const styles = {};
|
|
19150
|
+
const localVariableDeclarations = /* @__PURE__ */ new Map();
|
|
19151
|
+
for (const rule of inlinableRules) walk(rule, {
|
|
19152
|
+
visit: "Declaration",
|
|
19153
|
+
enter(declaration) {
|
|
19154
|
+
if (declaration.property.startsWith("--")) localVariableDeclarations.set(declaration.property, declaration);
|
|
19155
|
+
}
|
|
19156
|
+
});
|
|
19157
|
+
for (const rule of inlinableRules) {
|
|
19158
|
+
walk(rule, {
|
|
19159
|
+
visit: "Function",
|
|
19160
|
+
enter(func, funcParentListItem) {
|
|
19161
|
+
if (func.name === "var") {
|
|
19162
|
+
let variableName;
|
|
19163
|
+
walk(func, {
|
|
19164
|
+
visit: "Identifier",
|
|
19165
|
+
enter(identifier) {
|
|
19166
|
+
variableName = identifier.name;
|
|
19167
|
+
return this.break;
|
|
19168
|
+
}
|
|
19169
|
+
});
|
|
19170
|
+
if (variableName) {
|
|
19171
|
+
const definition = localVariableDeclarations.get(variableName);
|
|
19172
|
+
if (definition) funcParentListItem.data = unwrapValue(definition.value);
|
|
19173
|
+
else {
|
|
19174
|
+
const customProperty = customProperties.get(variableName);
|
|
19175
|
+
if (customProperty?.initialValue) funcParentListItem.data = unwrapValue(customProperty.initialValue.value);
|
|
19176
|
+
}
|
|
19177
|
+
}
|
|
19178
|
+
}
|
|
19179
|
+
}
|
|
19180
|
+
});
|
|
19181
|
+
walk(rule, {
|
|
19182
|
+
visit: "Declaration",
|
|
19183
|
+
enter(declaration) {
|
|
19184
|
+
if (declaration.property.startsWith("--")) return;
|
|
19185
|
+
styles[getReactProperty(declaration.property)] = generate(declaration.value) + (declaration.important ? "!important" : "");
|
|
19186
|
+
}
|
|
19187
|
+
});
|
|
19188
|
+
}
|
|
19189
|
+
return styles;
|
|
19190
|
+
}
|
|
19191
|
+
|
|
19124
19192
|
//#endregion
|
|
19125
19193
|
//#region src/utils/css/resolve-all-css-variables.ts
|
|
19126
19194
|
function doSelectorsIntersect(first, second) {
|
|
@@ -19690,74 +19758,6 @@ function mapReactTree(value, process) {
|
|
|
19690
19758
|
return mapped && mapped.length === 1 ? mapped[0] : mapped;
|
|
19691
19759
|
}
|
|
19692
19760
|
|
|
19693
|
-
//#endregion
|
|
19694
|
-
//#region src/utils/text/from-dash-case-to-camel-case.ts
|
|
19695
|
-
const fromDashCaseToCamelCase = (text) => {
|
|
19696
|
-
return text.replace(/-(\w|$)/g, (_, p1) => p1.toUpperCase());
|
|
19697
|
-
};
|
|
19698
|
-
|
|
19699
|
-
//#endregion
|
|
19700
|
-
//#region src/utils/compatibility/get-react-property.ts
|
|
19701
|
-
function getReactProperty(prop) {
|
|
19702
|
-
const modifiedProp = prop.toLowerCase();
|
|
19703
|
-
if (modifiedProp.startsWith("--")) return modifiedProp;
|
|
19704
|
-
if (modifiedProp.startsWith("-ms-")) return fromDashCaseToCamelCase(modifiedProp.slice(1));
|
|
19705
|
-
return fromDashCaseToCamelCase(modifiedProp);
|
|
19706
|
-
}
|
|
19707
|
-
|
|
19708
|
-
//#endregion
|
|
19709
|
-
//#region src/utils/css/unwrap-value.ts
|
|
19710
|
-
function unwrapValue(value) {
|
|
19711
|
-
if (value.type === "Value" && value.children.size === 1) return value.children.first ?? value;
|
|
19712
|
-
return value;
|
|
19713
|
-
}
|
|
19714
|
-
|
|
19715
|
-
//#endregion
|
|
19716
|
-
//#region src/utils/css/make-inline-styles-for.ts
|
|
19717
|
-
function makeInlineStylesFor(inlinableRules, customProperties) {
|
|
19718
|
-
const styles = {};
|
|
19719
|
-
const localVariableDeclarations = /* @__PURE__ */ new Map();
|
|
19720
|
-
for (const rule of inlinableRules) walk(rule, {
|
|
19721
|
-
visit: "Declaration",
|
|
19722
|
-
enter(declaration) {
|
|
19723
|
-
if (declaration.property.startsWith("--")) localVariableDeclarations.set(declaration.property, declaration);
|
|
19724
|
-
}
|
|
19725
|
-
});
|
|
19726
|
-
for (const rule of inlinableRules) {
|
|
19727
|
-
walk(rule, {
|
|
19728
|
-
visit: "Function",
|
|
19729
|
-
enter(func, funcParentListItem) {
|
|
19730
|
-
if (func.name === "var") {
|
|
19731
|
-
let variableName;
|
|
19732
|
-
walk(func, {
|
|
19733
|
-
visit: "Identifier",
|
|
19734
|
-
enter(identifier) {
|
|
19735
|
-
variableName = identifier.name;
|
|
19736
|
-
return this.break;
|
|
19737
|
-
}
|
|
19738
|
-
});
|
|
19739
|
-
if (variableName) {
|
|
19740
|
-
const definition = localVariableDeclarations.get(variableName);
|
|
19741
|
-
if (definition) funcParentListItem.data = unwrapValue(definition.value);
|
|
19742
|
-
else {
|
|
19743
|
-
const customProperty = customProperties.get(variableName);
|
|
19744
|
-
if (customProperty?.initialValue) funcParentListItem.data = unwrapValue(customProperty.initialValue.value);
|
|
19745
|
-
}
|
|
19746
|
-
}
|
|
19747
|
-
}
|
|
19748
|
-
}
|
|
19749
|
-
});
|
|
19750
|
-
walk(rule, {
|
|
19751
|
-
visit: "Declaration",
|
|
19752
|
-
enter(declaration) {
|
|
19753
|
-
if (declaration.property.startsWith("--")) return;
|
|
19754
|
-
styles[getReactProperty(declaration.property)] = generate(declaration.value) + (declaration.important ? "!important" : "");
|
|
19755
|
-
}
|
|
19756
|
-
});
|
|
19757
|
-
}
|
|
19758
|
-
return styles;
|
|
19759
|
-
}
|
|
19760
|
-
|
|
19761
19761
|
//#endregion
|
|
19762
19762
|
//#region src/utils/tailwindcss/clone-element-with-inlined-styles.ts
|
|
19763
19763
|
function cloneElementWithInlinedStyles(element, inlinableRules, nonInlinableRules, customProperties) {
|
|
@@ -21674,6 +21674,16 @@ const pixelBasedPreset = { theme: { extend: {
|
|
|
21674
21674
|
96: "384px"
|
|
21675
21675
|
}
|
|
21676
21676
|
} } };
|
|
21677
|
+
function sanitizeStyleSheet(styleSheet) {
|
|
21678
|
+
resolveAllCssVariables(styleSheet);
|
|
21679
|
+
resolveCalcExpressions(styleSheet);
|
|
21680
|
+
sanitizeDeclarations(styleSheet);
|
|
21681
|
+
}
|
|
21682
|
+
function inlineStyles(styleSheet, classes) {
|
|
21683
|
+
const { inlinable: inlinableRules } = extractRulesPerClass(styleSheet, classes);
|
|
21684
|
+
const customProperties = getCustomProperties(styleSheet);
|
|
21685
|
+
return makeInlineStylesFor(Array.from(inlinableRules.values()), customProperties);
|
|
21686
|
+
}
|
|
21677
21687
|
function Tailwind({ children, config }) {
|
|
21678
21688
|
const tailwindSetup = useSuspensedPromise(() => setupTailwind(config ?? {}), JSON.stringify(config, (_key, value) => typeof value === "function" ? value.toString() : value));
|
|
21679
21689
|
let classesUsed = [];
|
|
@@ -21688,16 +21698,14 @@ function Tailwind({ children, config }) {
|
|
|
21688
21698
|
return node;
|
|
21689
21699
|
});
|
|
21690
21700
|
const styleSheet = tailwindSetup.getStyleSheet();
|
|
21691
|
-
|
|
21692
|
-
resolveCalcExpressions(styleSheet);
|
|
21693
|
-
sanitizeDeclarations(styleSheet);
|
|
21701
|
+
sanitizeStyleSheet(styleSheet);
|
|
21694
21702
|
const { inlinable: inlinableRules, nonInlinable: nonInlinableRules } = extractRulesPerClass(styleSheet, classesUsed);
|
|
21695
|
-
sanitizeNonInlinableRules(styleSheet);
|
|
21696
21703
|
const customProperties = getCustomProperties(styleSheet);
|
|
21697
21704
|
const nonInlineStyles = {
|
|
21698
21705
|
type: "StyleSheet",
|
|
21699
21706
|
children: new List().fromArray(Array.from(nonInlinableRules.values()))
|
|
21700
21707
|
};
|
|
21708
|
+
sanitizeNonInlinableRules(nonInlineStyles);
|
|
21701
21709
|
const hasNonInlineStylesToApply = nonInlinableRules.size > 0;
|
|
21702
21710
|
let appliedNonInlineStyles = false;
|
|
21703
21711
|
mappedChildren = mapReactTree(mappedChildren, (node) => {
|
|
@@ -21726,4 +21734,7 @@ please file a bug https://github.com/resend/react-email/issues/new?assignees=&la
|
|
|
21726
21734
|
|
|
21727
21735
|
//#endregion
|
|
21728
21736
|
exports.Tailwind = Tailwind;
|
|
21729
|
-
exports.
|
|
21737
|
+
exports.inlineStyles = inlineStyles;
|
|
21738
|
+
exports.pixelBasedPreset = pixelBasedPreset;
|
|
21739
|
+
exports.sanitizeStyleSheet = sanitizeStyleSheet;
|
|
21740
|
+
exports.setupTailwind = setupTailwind;
|
package/dist/index.mjs
CHANGED
|
@@ -19108,6 +19108,74 @@ function getCustomProperties(node) {
|
|
|
19108
19108
|
return customProperties;
|
|
19109
19109
|
}
|
|
19110
19110
|
|
|
19111
|
+
//#endregion
|
|
19112
|
+
//#region src/utils/text/from-dash-case-to-camel-case.ts
|
|
19113
|
+
const fromDashCaseToCamelCase = (text) => {
|
|
19114
|
+
return text.replace(/-(\w|$)/g, (_, p1) => p1.toUpperCase());
|
|
19115
|
+
};
|
|
19116
|
+
|
|
19117
|
+
//#endregion
|
|
19118
|
+
//#region src/utils/compatibility/get-react-property.ts
|
|
19119
|
+
function getReactProperty(prop) {
|
|
19120
|
+
const modifiedProp = prop.toLowerCase();
|
|
19121
|
+
if (modifiedProp.startsWith("--")) return modifiedProp;
|
|
19122
|
+
if (modifiedProp.startsWith("-ms-")) return fromDashCaseToCamelCase(modifiedProp.slice(1));
|
|
19123
|
+
return fromDashCaseToCamelCase(modifiedProp);
|
|
19124
|
+
}
|
|
19125
|
+
|
|
19126
|
+
//#endregion
|
|
19127
|
+
//#region src/utils/css/unwrap-value.ts
|
|
19128
|
+
function unwrapValue(value) {
|
|
19129
|
+
if (value.type === "Value" && value.children.size === 1) return value.children.first ?? value;
|
|
19130
|
+
return value;
|
|
19131
|
+
}
|
|
19132
|
+
|
|
19133
|
+
//#endregion
|
|
19134
|
+
//#region src/utils/css/make-inline-styles-for.ts
|
|
19135
|
+
function makeInlineStylesFor(inlinableRules, customProperties) {
|
|
19136
|
+
const styles = {};
|
|
19137
|
+
const localVariableDeclarations = /* @__PURE__ */ new Map();
|
|
19138
|
+
for (const rule of inlinableRules) walk(rule, {
|
|
19139
|
+
visit: "Declaration",
|
|
19140
|
+
enter(declaration) {
|
|
19141
|
+
if (declaration.property.startsWith("--")) localVariableDeclarations.set(declaration.property, declaration);
|
|
19142
|
+
}
|
|
19143
|
+
});
|
|
19144
|
+
for (const rule of inlinableRules) {
|
|
19145
|
+
walk(rule, {
|
|
19146
|
+
visit: "Function",
|
|
19147
|
+
enter(func, funcParentListItem) {
|
|
19148
|
+
if (func.name === "var") {
|
|
19149
|
+
let variableName;
|
|
19150
|
+
walk(func, {
|
|
19151
|
+
visit: "Identifier",
|
|
19152
|
+
enter(identifier) {
|
|
19153
|
+
variableName = identifier.name;
|
|
19154
|
+
return this.break;
|
|
19155
|
+
}
|
|
19156
|
+
});
|
|
19157
|
+
if (variableName) {
|
|
19158
|
+
const definition = localVariableDeclarations.get(variableName);
|
|
19159
|
+
if (definition) funcParentListItem.data = unwrapValue(definition.value);
|
|
19160
|
+
else {
|
|
19161
|
+
const customProperty = customProperties.get(variableName);
|
|
19162
|
+
if (customProperty?.initialValue) funcParentListItem.data = unwrapValue(customProperty.initialValue.value);
|
|
19163
|
+
}
|
|
19164
|
+
}
|
|
19165
|
+
}
|
|
19166
|
+
}
|
|
19167
|
+
});
|
|
19168
|
+
walk(rule, {
|
|
19169
|
+
visit: "Declaration",
|
|
19170
|
+
enter(declaration) {
|
|
19171
|
+
if (declaration.property.startsWith("--")) return;
|
|
19172
|
+
styles[getReactProperty(declaration.property)] = generate(declaration.value) + (declaration.important ? "!important" : "");
|
|
19173
|
+
}
|
|
19174
|
+
});
|
|
19175
|
+
}
|
|
19176
|
+
return styles;
|
|
19177
|
+
}
|
|
19178
|
+
|
|
19111
19179
|
//#endregion
|
|
19112
19180
|
//#region src/utils/css/resolve-all-css-variables.ts
|
|
19113
19181
|
function doSelectorsIntersect(first, second) {
|
|
@@ -19677,74 +19745,6 @@ function mapReactTree(value, process) {
|
|
|
19677
19745
|
return mapped && mapped.length === 1 ? mapped[0] : mapped;
|
|
19678
19746
|
}
|
|
19679
19747
|
|
|
19680
|
-
//#endregion
|
|
19681
|
-
//#region src/utils/text/from-dash-case-to-camel-case.ts
|
|
19682
|
-
const fromDashCaseToCamelCase = (text) => {
|
|
19683
|
-
return text.replace(/-(\w|$)/g, (_, p1) => p1.toUpperCase());
|
|
19684
|
-
};
|
|
19685
|
-
|
|
19686
|
-
//#endregion
|
|
19687
|
-
//#region src/utils/compatibility/get-react-property.ts
|
|
19688
|
-
function getReactProperty(prop) {
|
|
19689
|
-
const modifiedProp = prop.toLowerCase();
|
|
19690
|
-
if (modifiedProp.startsWith("--")) return modifiedProp;
|
|
19691
|
-
if (modifiedProp.startsWith("-ms-")) return fromDashCaseToCamelCase(modifiedProp.slice(1));
|
|
19692
|
-
return fromDashCaseToCamelCase(modifiedProp);
|
|
19693
|
-
}
|
|
19694
|
-
|
|
19695
|
-
//#endregion
|
|
19696
|
-
//#region src/utils/css/unwrap-value.ts
|
|
19697
|
-
function unwrapValue(value) {
|
|
19698
|
-
if (value.type === "Value" && value.children.size === 1) return value.children.first ?? value;
|
|
19699
|
-
return value;
|
|
19700
|
-
}
|
|
19701
|
-
|
|
19702
|
-
//#endregion
|
|
19703
|
-
//#region src/utils/css/make-inline-styles-for.ts
|
|
19704
|
-
function makeInlineStylesFor(inlinableRules, customProperties) {
|
|
19705
|
-
const styles = {};
|
|
19706
|
-
const localVariableDeclarations = /* @__PURE__ */ new Map();
|
|
19707
|
-
for (const rule of inlinableRules) walk(rule, {
|
|
19708
|
-
visit: "Declaration",
|
|
19709
|
-
enter(declaration) {
|
|
19710
|
-
if (declaration.property.startsWith("--")) localVariableDeclarations.set(declaration.property, declaration);
|
|
19711
|
-
}
|
|
19712
|
-
});
|
|
19713
|
-
for (const rule of inlinableRules) {
|
|
19714
|
-
walk(rule, {
|
|
19715
|
-
visit: "Function",
|
|
19716
|
-
enter(func, funcParentListItem) {
|
|
19717
|
-
if (func.name === "var") {
|
|
19718
|
-
let variableName;
|
|
19719
|
-
walk(func, {
|
|
19720
|
-
visit: "Identifier",
|
|
19721
|
-
enter(identifier) {
|
|
19722
|
-
variableName = identifier.name;
|
|
19723
|
-
return this.break;
|
|
19724
|
-
}
|
|
19725
|
-
});
|
|
19726
|
-
if (variableName) {
|
|
19727
|
-
const definition = localVariableDeclarations.get(variableName);
|
|
19728
|
-
if (definition) funcParentListItem.data = unwrapValue(definition.value);
|
|
19729
|
-
else {
|
|
19730
|
-
const customProperty = customProperties.get(variableName);
|
|
19731
|
-
if (customProperty?.initialValue) funcParentListItem.data = unwrapValue(customProperty.initialValue.value);
|
|
19732
|
-
}
|
|
19733
|
-
}
|
|
19734
|
-
}
|
|
19735
|
-
}
|
|
19736
|
-
});
|
|
19737
|
-
walk(rule, {
|
|
19738
|
-
visit: "Declaration",
|
|
19739
|
-
enter(declaration) {
|
|
19740
|
-
if (declaration.property.startsWith("--")) return;
|
|
19741
|
-
styles[getReactProperty(declaration.property)] = generate(declaration.value) + (declaration.important ? "!important" : "");
|
|
19742
|
-
}
|
|
19743
|
-
});
|
|
19744
|
-
}
|
|
19745
|
-
return styles;
|
|
19746
|
-
}
|
|
19747
|
-
|
|
19748
19748
|
//#endregion
|
|
19749
19749
|
//#region src/utils/tailwindcss/clone-element-with-inlined-styles.ts
|
|
19750
19750
|
function cloneElementWithInlinedStyles(element, inlinableRules, nonInlinableRules, customProperties) {
|
|
@@ -21661,6 +21661,16 @@ const pixelBasedPreset = { theme: { extend: {
|
|
|
21661
21661
|
96: "384px"
|
|
21662
21662
|
}
|
|
21663
21663
|
} } };
|
|
21664
|
+
function sanitizeStyleSheet(styleSheet) {
|
|
21665
|
+
resolveAllCssVariables(styleSheet);
|
|
21666
|
+
resolveCalcExpressions(styleSheet);
|
|
21667
|
+
sanitizeDeclarations(styleSheet);
|
|
21668
|
+
}
|
|
21669
|
+
function inlineStyles(styleSheet, classes) {
|
|
21670
|
+
const { inlinable: inlinableRules } = extractRulesPerClass(styleSheet, classes);
|
|
21671
|
+
const customProperties = getCustomProperties(styleSheet);
|
|
21672
|
+
return makeInlineStylesFor(Array.from(inlinableRules.values()), customProperties);
|
|
21673
|
+
}
|
|
21664
21674
|
function Tailwind({ children, config }) {
|
|
21665
21675
|
const tailwindSetup = useSuspensedPromise(() => setupTailwind(config ?? {}), JSON.stringify(config, (_key, value) => typeof value === "function" ? value.toString() : value));
|
|
21666
21676
|
let classesUsed = [];
|
|
@@ -21675,16 +21685,14 @@ function Tailwind({ children, config }) {
|
|
|
21675
21685
|
return node;
|
|
21676
21686
|
});
|
|
21677
21687
|
const styleSheet = tailwindSetup.getStyleSheet();
|
|
21678
|
-
|
|
21679
|
-
resolveCalcExpressions(styleSheet);
|
|
21680
|
-
sanitizeDeclarations(styleSheet);
|
|
21688
|
+
sanitizeStyleSheet(styleSheet);
|
|
21681
21689
|
const { inlinable: inlinableRules, nonInlinable: nonInlinableRules } = extractRulesPerClass(styleSheet, classesUsed);
|
|
21682
|
-
sanitizeNonInlinableRules(styleSheet);
|
|
21683
21690
|
const customProperties = getCustomProperties(styleSheet);
|
|
21684
21691
|
const nonInlineStyles = {
|
|
21685
21692
|
type: "StyleSheet",
|
|
21686
21693
|
children: new List().fromArray(Array.from(nonInlinableRules.values()))
|
|
21687
21694
|
};
|
|
21695
|
+
sanitizeNonInlinableRules(nonInlineStyles);
|
|
21688
21696
|
const hasNonInlineStylesToApply = nonInlinableRules.size > 0;
|
|
21689
21697
|
let appliedNonInlineStyles = false;
|
|
21690
21698
|
mappedChildren = mapReactTree(mappedChildren, (node) => {
|
|
@@ -21712,5 +21720,5 @@ please file a bug https://github.com/resend/react-email/issues/new?assignees=&la
|
|
|
21712
21720
|
}
|
|
21713
21721
|
|
|
21714
21722
|
//#endregion
|
|
21715
|
-
export { Tailwind, pixelBasedPreset };
|
|
21723
|
+
export { Tailwind, inlineStyles, pixelBasedPreset, sanitizeStyleSheet, setupTailwind };
|
|
21716
21724
|
//# sourceMappingURL=index.mjs.map
|