@react-email/tailwind 2.0.0-tailwindv4.3 → 2.0.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.d.mts +15 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.d.ts +15 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +276 -157
- package/dist/index.mjs +262 -157
- package/dist/index.mjs.map +1 -1
- package/package.json +51 -8
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
import * as React$1 from "react";
|
|
2
2
|
import React from "react";
|
|
3
|
+
import { Body } from "@react-email/body";
|
|
4
|
+
import { Button } from "@react-email/button";
|
|
5
|
+
import { CodeBlock } from "@react-email/code-block";
|
|
6
|
+
import { CodeInline } from "@react-email/code-inline";
|
|
7
|
+
import { Container } from "@react-email/container";
|
|
8
|
+
import { Heading } from "@react-email/heading";
|
|
9
|
+
import { Hr } from "@react-email/hr";
|
|
10
|
+
import { Img } from "@react-email/img";
|
|
11
|
+
import { Link } from "@react-email/link";
|
|
12
|
+
import { Preview } from "@react-email/preview";
|
|
13
|
+
import { Text } from "@react-email/text";
|
|
3
14
|
import { compile } from "tailwindcss";
|
|
4
15
|
import { jsx } from "react/jsx-runtime";
|
|
5
16
|
|
|
@@ -19014,21 +19025,6 @@ const { version } = {
|
|
|
19014
19025
|
//#region ../../node_modules/.pnpm/css-tree@3.1.0/node_modules/css-tree/lib/index.js
|
|
19015
19026
|
const { tokenize, parse, generate, lexer, createLexer, walk, find, findLast, findAll, toPlainObject, fromPlainObject, fork } = syntax_default;
|
|
19016
19027
|
|
|
19017
|
-
//#endregion
|
|
19018
|
-
//#region src/hooks/use-suspended-promise.ts
|
|
19019
|
-
const promiseStates = /* @__PURE__ */ new Map();
|
|
19020
|
-
function useSuspensedPromise(promiseFn, key) {
|
|
19021
|
-
const previousState = promiseStates.get(key);
|
|
19022
|
-
if (previousState) {
|
|
19023
|
-
if ("error" in previousState) throw previousState.error;
|
|
19024
|
-
if ("result" in previousState) return previousState.result;
|
|
19025
|
-
throw previousState.promise;
|
|
19026
|
-
}
|
|
19027
|
-
const state = { promise: promiseFn().then((result) => state.result = result).catch((error) => state.error = error) };
|
|
19028
|
-
promiseStates.set(key, state);
|
|
19029
|
-
throw state.promise;
|
|
19030
|
-
}
|
|
19031
|
-
|
|
19032
19028
|
//#endregion
|
|
19033
19029
|
//#region src/utils/css/is-rule-inlinable.ts
|
|
19034
19030
|
function isRuleInlinable(rule) {
|
|
@@ -19065,20 +19061,112 @@ function extractRulesPerClass(root, classes) {
|
|
|
19065
19061
|
}
|
|
19066
19062
|
|
|
19067
19063
|
//#endregion
|
|
19068
|
-
//#region src/utils/css/
|
|
19069
|
-
function
|
|
19070
|
-
const
|
|
19064
|
+
//#region src/utils/css/get-custom-properties.ts
|
|
19065
|
+
function getCustomProperties(node) {
|
|
19066
|
+
const customProperties = /* @__PURE__ */ new Map();
|
|
19071
19067
|
walk(node, {
|
|
19072
|
-
|
|
19073
|
-
|
|
19074
|
-
|
|
19075
|
-
|
|
19076
|
-
|
|
19077
|
-
|
|
19078
|
-
|
|
19079
|
-
|
|
19068
|
+
visit: "Atrule",
|
|
19069
|
+
enter(atrule) {
|
|
19070
|
+
if (atrule.name === "property" && atrule.prelude) {
|
|
19071
|
+
const prelude = generate(atrule.prelude);
|
|
19072
|
+
if (prelude.startsWith("--")) {
|
|
19073
|
+
let syntax;
|
|
19074
|
+
let inherits;
|
|
19075
|
+
let initialValue;
|
|
19076
|
+
walk(atrule, {
|
|
19077
|
+
visit: "Declaration",
|
|
19078
|
+
enter(declaration) {
|
|
19079
|
+
if (declaration.property === "syntax") syntax = declaration;
|
|
19080
|
+
if (declaration.property === "inherits") inherits = declaration;
|
|
19081
|
+
if (declaration.property === "initial-value") initialValue = declaration;
|
|
19082
|
+
}
|
|
19083
|
+
});
|
|
19084
|
+
customProperties.set(prelude, {
|
|
19085
|
+
syntax,
|
|
19086
|
+
inherits,
|
|
19087
|
+
initialValue
|
|
19088
|
+
});
|
|
19089
|
+
}
|
|
19090
|
+
}
|
|
19091
|
+
}
|
|
19092
|
+
});
|
|
19093
|
+
return customProperties;
|
|
19094
|
+
}
|
|
19095
|
+
|
|
19096
|
+
//#endregion
|
|
19097
|
+
//#region src/utils/text/from-dash-case-to-camel-case.ts
|
|
19098
|
+
const fromDashCaseToCamelCase = (text) => {
|
|
19099
|
+
return text.replace(/-(\w|$)/g, (_, p1) => p1.toUpperCase());
|
|
19100
|
+
};
|
|
19101
|
+
|
|
19102
|
+
//#endregion
|
|
19103
|
+
//#region src/utils/compatibility/get-react-property.ts
|
|
19104
|
+
function getReactProperty(prop) {
|
|
19105
|
+
const modifiedProp = prop.toLowerCase();
|
|
19106
|
+
if (modifiedProp.startsWith("--")) return modifiedProp;
|
|
19107
|
+
if (modifiedProp.startsWith("-ms-")) return fromDashCaseToCamelCase(modifiedProp.slice(1));
|
|
19108
|
+
return fromDashCaseToCamelCase(modifiedProp);
|
|
19109
|
+
}
|
|
19110
|
+
|
|
19111
|
+
//#endregion
|
|
19112
|
+
//#region src/utils/css/unwrap-value.ts
|
|
19113
|
+
function unwrapValue(value) {
|
|
19114
|
+
if (value.type === "Value" && value.children.size === 1) return value.children.first ?? value;
|
|
19115
|
+
return value;
|
|
19116
|
+
}
|
|
19117
|
+
|
|
19118
|
+
//#endregion
|
|
19119
|
+
//#region src/utils/css/make-inline-styles-for.ts
|
|
19120
|
+
function makeInlineStylesFor(inlinableRules, customProperties) {
|
|
19121
|
+
const styles = {};
|
|
19122
|
+
const localVariableDeclarations = /* @__PURE__ */ new Map();
|
|
19123
|
+
for (const rule of inlinableRules) walk(rule, {
|
|
19124
|
+
visit: "Declaration",
|
|
19125
|
+
enter(declaration) {
|
|
19126
|
+
if (declaration.property.startsWith("--")) localVariableDeclarations.set(declaration.property, declaration);
|
|
19080
19127
|
}
|
|
19081
19128
|
});
|
|
19129
|
+
for (const rule of inlinableRules) {
|
|
19130
|
+
walk(rule, {
|
|
19131
|
+
visit: "Function",
|
|
19132
|
+
enter(func, funcParentListItem) {
|
|
19133
|
+
if (func.name === "var") {
|
|
19134
|
+
let variableName;
|
|
19135
|
+
walk(func, {
|
|
19136
|
+
visit: "Identifier",
|
|
19137
|
+
enter(identifier) {
|
|
19138
|
+
variableName = identifier.name;
|
|
19139
|
+
return this.break;
|
|
19140
|
+
}
|
|
19141
|
+
});
|
|
19142
|
+
if (variableName) {
|
|
19143
|
+
const definition = localVariableDeclarations.get(variableName);
|
|
19144
|
+
if (definition) funcParentListItem.data = unwrapValue(definition.value);
|
|
19145
|
+
else {
|
|
19146
|
+
const customProperty = customProperties.get(variableName);
|
|
19147
|
+
if (customProperty?.initialValue) funcParentListItem.data = unwrapValue(customProperty.initialValue.value);
|
|
19148
|
+
}
|
|
19149
|
+
}
|
|
19150
|
+
}
|
|
19151
|
+
}
|
|
19152
|
+
});
|
|
19153
|
+
walk(rule, {
|
|
19154
|
+
visit: "Declaration",
|
|
19155
|
+
enter(declaration) {
|
|
19156
|
+
if (declaration.property.startsWith("--")) return;
|
|
19157
|
+
styles[getReactProperty(declaration.property)] = generate(declaration.value) + (declaration.important ? "!important" : "");
|
|
19158
|
+
}
|
|
19159
|
+
});
|
|
19160
|
+
}
|
|
19161
|
+
return styles;
|
|
19162
|
+
}
|
|
19163
|
+
|
|
19164
|
+
//#endregion
|
|
19165
|
+
//#region src/inline-styles.ts
|
|
19166
|
+
function inlineStyles(styleSheet, classes) {
|
|
19167
|
+
const { inlinable: inlinableRules } = extractRulesPerClass(styleSheet, classes);
|
|
19168
|
+
const customProperties = getCustomProperties(styleSheet);
|
|
19169
|
+
return makeInlineStylesFor(Array.from(inlinableRules.values()), customProperties);
|
|
19082
19170
|
}
|
|
19083
19171
|
|
|
19084
19172
|
//#endregion
|
|
@@ -19086,70 +19174,74 @@ function populateParentsForNodeTree(node) {
|
|
|
19086
19174
|
function doSelectorsIntersect(first, second) {
|
|
19087
19175
|
if (generate(first) === generate(second)) return true;
|
|
19088
19176
|
let hasSomeUniversal = false;
|
|
19089
|
-
const walker = (node) => {
|
|
19177
|
+
const walker = (node, _parentListItem, parentList) => {
|
|
19090
19178
|
if (hasSomeUniversal) return;
|
|
19091
19179
|
if (node.type === "PseudoClassSelector" && node.name === "root") hasSomeUniversal = true;
|
|
19092
|
-
if (node.type === "TypeSelector" && node.name === "*" &&
|
|
19180
|
+
if (node.type === "TypeSelector" && node.name === "*" && parentList.size === 1) hasSomeUniversal = true;
|
|
19093
19181
|
};
|
|
19094
19182
|
walk(first, walker);
|
|
19095
19183
|
walk(second, walker);
|
|
19096
19184
|
if (hasSomeUniversal) return true;
|
|
19097
19185
|
return false;
|
|
19098
19186
|
}
|
|
19099
|
-
function someParent(node, predicate) {
|
|
19100
|
-
if (node.parent) {
|
|
19101
|
-
if (predicate(node.parent)) return true;
|
|
19102
|
-
return someParent(node.parent, predicate);
|
|
19103
|
-
}
|
|
19104
|
-
return false;
|
|
19105
|
-
}
|
|
19106
19187
|
function resolveAllCssVariables(node) {
|
|
19107
|
-
populateParentsForNodeTree(node);
|
|
19108
19188
|
const variableDefinitions = /* @__PURE__ */ new Set();
|
|
19109
19189
|
const variableUses = /* @__PURE__ */ new Set();
|
|
19190
|
+
const path = [];
|
|
19110
19191
|
walk(node, {
|
|
19111
|
-
|
|
19112
|
-
|
|
19113
|
-
|
|
19114
|
-
|
|
19115
|
-
|
|
19116
|
-
|
|
19117
|
-
|
|
19118
|
-
|
|
19119
|
-
|
|
19120
|
-
|
|
19121
|
-
|
|
19122
|
-
|
|
19123
|
-
|
|
19124
|
-
|
|
19125
|
-
|
|
19126
|
-
|
|
19127
|
-
|
|
19128
|
-
|
|
19129
|
-
|
|
19130
|
-
|
|
19131
|
-
|
|
19132
|
-
|
|
19133
|
-
|
|
19134
|
-
|
|
19192
|
+
leave() {
|
|
19193
|
+
path.shift();
|
|
19194
|
+
},
|
|
19195
|
+
enter(node$1) {
|
|
19196
|
+
if (node$1.type === "Declaration") {
|
|
19197
|
+
const declaration = node$1;
|
|
19198
|
+
if (path.some((ancestor) => ancestor.type === "Atrule" && ancestor.name === "layer" && ancestor.prelude !== null && generate(ancestor.prelude).includes("properties"))) {
|
|
19199
|
+
path.unshift(node$1);
|
|
19200
|
+
return;
|
|
19201
|
+
}
|
|
19202
|
+
if (/--[\S]+/.test(declaration.property)) variableDefinitions.add({
|
|
19203
|
+
declaration,
|
|
19204
|
+
path: [...path],
|
|
19205
|
+
variableName: declaration.property,
|
|
19206
|
+
definition: generate(declaration.value)
|
|
19207
|
+
});
|
|
19208
|
+
else {
|
|
19209
|
+
function parseVariableUsesFrom(node$2) {
|
|
19210
|
+
walk(node$2, {
|
|
19211
|
+
visit: "Function",
|
|
19212
|
+
enter(funcNode) {
|
|
19213
|
+
if (funcNode.name === "var") {
|
|
19214
|
+
const children = funcNode.children.toArray();
|
|
19215
|
+
const name$49 = generate(children[0]);
|
|
19216
|
+
const fallback = children[2] ? generate(children[2]) : void 0;
|
|
19217
|
+
variableUses.add({
|
|
19218
|
+
declaration,
|
|
19219
|
+
path: [...path],
|
|
19220
|
+
fallback,
|
|
19221
|
+
variableName: name$49,
|
|
19222
|
+
raw: generate(funcNode)
|
|
19223
|
+
});
|
|
19224
|
+
if (fallback?.includes("var(")) parseVariableUsesFrom(parse(fallback, { context: "value" }));
|
|
19225
|
+
}
|
|
19135
19226
|
}
|
|
19136
|
-
}
|
|
19137
|
-
}
|
|
19227
|
+
});
|
|
19228
|
+
}
|
|
19229
|
+
parseVariableUsesFrom(declaration.value);
|
|
19138
19230
|
}
|
|
19139
|
-
parseVariableUsesFrom(declaration.value);
|
|
19140
19231
|
}
|
|
19232
|
+
path.unshift(node$1);
|
|
19141
19233
|
}
|
|
19142
19234
|
});
|
|
19143
19235
|
for (const use of variableUses) {
|
|
19144
19236
|
let hasReplaced = false;
|
|
19145
19237
|
for (const definition of variableDefinitions) {
|
|
19146
19238
|
if (use.variableName !== definition.variableName) continue;
|
|
19147
|
-
if (use.
|
|
19239
|
+
if (use.path[0]?.type === "Block" && use.path[1]?.type === "Atrule" && use.path[2]?.type === "Block" && use.path[3]?.type === "Rule" && definition.path[0].type === "Block" && definition.path[1].type === "Rule" && doSelectorsIntersect(use.path[3].prelude, definition.path[1].prelude)) {
|
|
19148
19240
|
use.declaration.value = parse(generate(use.declaration.value).replaceAll(use.raw, definition.definition), { context: "value" });
|
|
19149
19241
|
hasReplaced = true;
|
|
19150
19242
|
break;
|
|
19151
19243
|
}
|
|
19152
|
-
if (use.
|
|
19244
|
+
if (use.path[0]?.type === "Block" && use.path[1]?.type === "Rule" && definition.path[0]?.type === "Block" && definition.path[1]?.type === "Rule" && doSelectorsIntersect(use.path[1].prelude, definition.path[1].prelude)) {
|
|
19153
19245
|
use.declaration.value = parse(generate(use.declaration.value).replaceAll(use.raw, definition.definition), { context: "value" });
|
|
19154
19246
|
hasReplaced = true;
|
|
19155
19247
|
break;
|
|
@@ -19251,6 +19343,44 @@ function resolveCalcExpressions(node) {
|
|
|
19251
19343
|
|
|
19252
19344
|
//#endregion
|
|
19253
19345
|
//#region src/utils/css/sanitize-declarations.ts
|
|
19346
|
+
function rgbNode(r, g, b, alpha) {
|
|
19347
|
+
const children = new List();
|
|
19348
|
+
children.appendData({
|
|
19349
|
+
type: "Number",
|
|
19350
|
+
value: r.toFixed(0)
|
|
19351
|
+
});
|
|
19352
|
+
children.appendData({
|
|
19353
|
+
type: "Operator",
|
|
19354
|
+
value: ","
|
|
19355
|
+
});
|
|
19356
|
+
children.appendData({
|
|
19357
|
+
type: "Number",
|
|
19358
|
+
value: g.toFixed(0)
|
|
19359
|
+
});
|
|
19360
|
+
children.appendData({
|
|
19361
|
+
type: "Operator",
|
|
19362
|
+
value: ","
|
|
19363
|
+
});
|
|
19364
|
+
children.appendData({
|
|
19365
|
+
type: "Number",
|
|
19366
|
+
value: b.toFixed(0)
|
|
19367
|
+
});
|
|
19368
|
+
if (alpha !== 1 && alpha !== void 0) {
|
|
19369
|
+
children.appendData({
|
|
19370
|
+
type: "Operator",
|
|
19371
|
+
value: ","
|
|
19372
|
+
});
|
|
19373
|
+
children.appendData({
|
|
19374
|
+
type: "Number",
|
|
19375
|
+
value: alpha.toString()
|
|
19376
|
+
});
|
|
19377
|
+
}
|
|
19378
|
+
return {
|
|
19379
|
+
type: "Function",
|
|
19380
|
+
name: "rgb",
|
|
19381
|
+
children
|
|
19382
|
+
};
|
|
19383
|
+
}
|
|
19254
19384
|
const LAB_TO_LMS = {
|
|
19255
19385
|
l: [.3963377773761749, .2158037573099136],
|
|
19256
19386
|
m: [-.1055613458156586, -.0638541728258133],
|
|
@@ -19299,9 +19429,9 @@ function oklchToRgb(oklch) {
|
|
|
19299
19429
|
const g = 255 * lrgbToRgb(LSM_TO_RGB.g[0] * l + LSM_TO_RGB.g[1] * m + LSM_TO_RGB.g[2] * s);
|
|
19300
19430
|
const b = 255 * lrgbToRgb(LSM_TO_RGB.b[0] * l + LSM_TO_RGB.b[1] * m + LSM_TO_RGB.b[2] * s);
|
|
19301
19431
|
return {
|
|
19302
|
-
r: clamp(r, 0, 255)
|
|
19303
|
-
g: clamp(g, 0, 255)
|
|
19304
|
-
b: clamp(b, 0, 255)
|
|
19432
|
+
r: clamp(r, 0, 255),
|
|
19433
|
+
g: clamp(g, 0, 255),
|
|
19434
|
+
b: clamp(b, 0, 255)
|
|
19305
19435
|
};
|
|
19306
19436
|
}
|
|
19307
19437
|
function separteShorthandDeclaration(shorthandToReplace, [start, end]) {
|
|
@@ -19342,6 +19472,7 @@ function sanitizeDeclarations(nodeContainingDeclarations) {
|
|
|
19342
19472
|
walk(nodeContainingDeclarations, {
|
|
19343
19473
|
visit: "Declaration",
|
|
19344
19474
|
enter(declaration, item, list) {
|
|
19475
|
+
if (declaration.value.type === "Raw") declaration.value = parse(declaration.value.value, { context: "value" });
|
|
19345
19476
|
if (/border-radius\s*:\s*calc\s*\(\s*infinity\s*\*\s*1px\s*\)/i.test(generate(declaration))) declaration.value = parse("9999px", { context: "value" });
|
|
19346
19477
|
walk(declaration, {
|
|
19347
19478
|
visit: "Function",
|
|
@@ -19391,8 +19522,7 @@ function sanitizeDeclarations(nodeContainingDeclarations) {
|
|
|
19391
19522
|
c,
|
|
19392
19523
|
h
|
|
19393
19524
|
});
|
|
19394
|
-
|
|
19395
|
-
funcParentListItem.data = parse(`rgb(${rgb.r},${rgb.g},${rgb.b}${alphaString})`, { context: "value" });
|
|
19525
|
+
funcParentListItem.data = rgbNode(rgb.r, rgb.g, rgb.b, a);
|
|
19396
19526
|
}
|
|
19397
19527
|
if (func.name === "rgb") {
|
|
19398
19528
|
let r;
|
|
@@ -19435,8 +19565,8 @@ function sanitizeDeclarations(nodeContainingDeclarations) {
|
|
|
19435
19565
|
}
|
|
19436
19566
|
}
|
|
19437
19567
|
if (r === void 0 || g === void 0 || b === void 0) throw new Error("Could not determine the parameters of an rgb() function.", { cause: declaration });
|
|
19438
|
-
if (a === void 0 || a === 1) funcParentListItem.data =
|
|
19439
|
-
else funcParentListItem.data =
|
|
19568
|
+
if (a === void 0 || a === 1) funcParentListItem.data = rgbNode(r, g, b);
|
|
19569
|
+
else funcParentListItem.data = rgbNode(r, g, b, a);
|
|
19440
19570
|
}
|
|
19441
19571
|
}
|
|
19442
19572
|
});
|
|
@@ -19445,45 +19575,42 @@ function sanitizeDeclarations(nodeContainingDeclarations) {
|
|
|
19445
19575
|
enter(hash, hashParentListItem) {
|
|
19446
19576
|
const hex = hash.value.trim();
|
|
19447
19577
|
if (hex.length === 3) {
|
|
19448
|
-
hashParentListItem.data =
|
|
19578
|
+
hashParentListItem.data = rgbNode(Number.parseInt(hex.charAt(0) + hex.charAt(0), 16), Number.parseInt(hex.charAt(1) + hex.charAt(1), 16), Number.parseInt(hex.charAt(2) + hex.charAt(2), 16));
|
|
19449
19579
|
return;
|
|
19450
19580
|
}
|
|
19451
19581
|
if (hex.length === 4) {
|
|
19452
|
-
hashParentListItem.data =
|
|
19582
|
+
hashParentListItem.data = rgbNode(Number.parseInt(hex.charAt(0) + hex.charAt(0), 16), Number.parseInt(hex.charAt(1) + hex.charAt(1), 16), Number.parseInt(hex.charAt(2) + hex.charAt(2), 16), Number.parseInt(hex.charAt(3) + hex.charAt(3), 16) / 255);
|
|
19453
19583
|
return;
|
|
19454
19584
|
}
|
|
19455
19585
|
if (hex.length === 5) {
|
|
19456
|
-
hashParentListItem.data =
|
|
19586
|
+
hashParentListItem.data = rgbNode(Number.parseInt(hex.slice(0, 2), 16), Number.parseInt(hex.charAt(2) + hex.charAt(2), 16), Number.parseInt(hex.charAt(3) + hex.charAt(3), 16), Number.parseInt(hex.charAt(4) + hex.charAt(4), 16) / 255);
|
|
19457
19587
|
return;
|
|
19458
19588
|
}
|
|
19459
19589
|
if (hex.length === 6) {
|
|
19460
|
-
hashParentListItem.data =
|
|
19590
|
+
hashParentListItem.data = rgbNode(Number.parseInt(hex.slice(0, 2), 16), Number.parseInt(hex.slice(2, 4), 16), Number.parseInt(hex.slice(4, 6), 16));
|
|
19461
19591
|
return;
|
|
19462
19592
|
}
|
|
19463
19593
|
if (hex.length === 7) {
|
|
19464
|
-
hashParentListItem.data =
|
|
19594
|
+
hashParentListItem.data = rgbNode(Number.parseInt(hex.slice(0, 2), 16), Number.parseInt(hex.slice(2, 4), 16), Number.parseInt(hex.slice(4, 6), 16), Number.parseInt(hex.charAt(6) + hex.charAt(6), 16) / 255);
|
|
19465
19595
|
return;
|
|
19466
19596
|
}
|
|
19467
|
-
hashParentListItem.data =
|
|
19597
|
+
hashParentListItem.data = rgbNode(Number.parseInt(hex.slice(0, 2), 16), Number.parseInt(hex.slice(2, 4), 16), Number.parseInt(hex.slice(4, 6), 16), Number.parseInt(hex.slice(6, 8), 16) / 255);
|
|
19468
19598
|
}
|
|
19469
19599
|
});
|
|
19470
19600
|
walk(declaration, {
|
|
19471
19601
|
visit: "Function",
|
|
19472
19602
|
enter(func, parentListItem) {
|
|
19473
19603
|
if (func.name === "color-mix") {
|
|
19474
|
-
const
|
|
19475
|
-
const
|
|
19476
|
-
|
|
19477
|
-
|
|
19478
|
-
|
|
19604
|
+
const children = func.children.toArray();
|
|
19605
|
+
const color = children[3];
|
|
19606
|
+
const opacity = children[4];
|
|
19607
|
+
if (func.children.last?.type === "Identifier" && func.children.last.name === "transparent" && color?.type === "Function" && color?.name === "rgb" && opacity) {
|
|
19608
|
+
color.children.appendData({
|
|
19479
19609
|
type: "Operator",
|
|
19480
19610
|
value: ","
|
|
19481
19611
|
});
|
|
19482
|
-
|
|
19483
|
-
|
|
19484
|
-
value: alpha.toString()
|
|
19485
|
-
});
|
|
19486
|
-
parentListItem.data = originalColor;
|
|
19612
|
+
color.children.appendData(opacity);
|
|
19613
|
+
parentListItem.data = color;
|
|
19487
19614
|
}
|
|
19488
19615
|
}
|
|
19489
19616
|
}
|
|
@@ -19508,6 +19635,29 @@ function sanitizeDeclarations(nodeContainingDeclarations) {
|
|
|
19508
19635
|
});
|
|
19509
19636
|
}
|
|
19510
19637
|
|
|
19638
|
+
//#endregion
|
|
19639
|
+
//#region src/sanitize-stylesheet.ts
|
|
19640
|
+
function sanitizeStyleSheet(styleSheet) {
|
|
19641
|
+
resolveAllCssVariables(styleSheet);
|
|
19642
|
+
resolveCalcExpressions(styleSheet);
|
|
19643
|
+
sanitizeDeclarations(styleSheet);
|
|
19644
|
+
}
|
|
19645
|
+
|
|
19646
|
+
//#endregion
|
|
19647
|
+
//#region src/hooks/use-suspended-promise.ts
|
|
19648
|
+
const promiseStates = /* @__PURE__ */ new Map();
|
|
19649
|
+
function useSuspensedPromise(promiseFn, key) {
|
|
19650
|
+
const previousState = promiseStates.get(key);
|
|
19651
|
+
if (previousState) {
|
|
19652
|
+
if ("error" in previousState) throw previousState.error;
|
|
19653
|
+
if ("result" in previousState) return previousState.result;
|
|
19654
|
+
throw previousState.promise;
|
|
19655
|
+
}
|
|
19656
|
+
const state = { promise: promiseFn().then((result) => state.result = result).catch((error) => state.error = error) };
|
|
19657
|
+
promiseStates.set(key, state);
|
|
19658
|
+
throw state.promise;
|
|
19659
|
+
}
|
|
19660
|
+
|
|
19511
19661
|
//#endregion
|
|
19512
19662
|
//#region src/utils/compatibility/sanitize-class-name.ts
|
|
19513
19663
|
const digitToNameMap = {
|
|
@@ -19566,8 +19716,21 @@ function sanitizeNonInlinableRules(node) {
|
|
|
19566
19716
|
|
|
19567
19717
|
//#endregion
|
|
19568
19718
|
//#region src/utils/react/is-component.ts
|
|
19719
|
+
const componentsToTreatAsElements = [
|
|
19720
|
+
Body,
|
|
19721
|
+
Button,
|
|
19722
|
+
CodeBlock,
|
|
19723
|
+
CodeInline,
|
|
19724
|
+
Container,
|
|
19725
|
+
Heading,
|
|
19726
|
+
Hr,
|
|
19727
|
+
Img,
|
|
19728
|
+
Link,
|
|
19729
|
+
Preview,
|
|
19730
|
+
Text
|
|
19731
|
+
];
|
|
19569
19732
|
const isComponent = (element) => {
|
|
19570
|
-
return (typeof element.type === "function" || element.type.render !== void 0) && element.type
|
|
19733
|
+
return (typeof element.type === "function" || element.type.render !== void 0) && !componentsToTreatAsElements.includes(element.type);
|
|
19571
19734
|
};
|
|
19572
19735
|
|
|
19573
19736
|
//#endregion
|
|
@@ -19598,66 +19761,9 @@ function mapReactTree(value, process) {
|
|
|
19598
19761
|
return mapped && mapped.length === 1 ? mapped[0] : mapped;
|
|
19599
19762
|
}
|
|
19600
19763
|
|
|
19601
|
-
//#endregion
|
|
19602
|
-
//#region src/utils/text/from-dash-case-to-camel-case.ts
|
|
19603
|
-
const fromDashCaseToCamelCase = (text) => {
|
|
19604
|
-
return text.replace(/-(\w|$)/g, (_, p1) => p1.toUpperCase());
|
|
19605
|
-
};
|
|
19606
|
-
|
|
19607
|
-
//#endregion
|
|
19608
|
-
//#region src/utils/compatibility/get-react-property.ts
|
|
19609
|
-
function getReactProperty(prop) {
|
|
19610
|
-
const modifiedProp = prop.toLowerCase();
|
|
19611
|
-
if (modifiedProp.startsWith("--")) return modifiedProp;
|
|
19612
|
-
if (modifiedProp.startsWith("-ms-")) return fromDashCaseToCamelCase(modifiedProp.slice(1));
|
|
19613
|
-
return fromDashCaseToCamelCase(modifiedProp);
|
|
19614
|
-
}
|
|
19615
|
-
|
|
19616
|
-
//#endregion
|
|
19617
|
-
//#region src/utils/css/make-inline-styles-for.ts
|
|
19618
|
-
function makeInlineStylesFor(inlinableRules) {
|
|
19619
|
-
const styles = {};
|
|
19620
|
-
const localVariableDeclarations = /* @__PURE__ */ new Set();
|
|
19621
|
-
for (const rule of inlinableRules) walk(rule, {
|
|
19622
|
-
visit: "Declaration",
|
|
19623
|
-
enter(declaration) {
|
|
19624
|
-
if (declaration.property.startsWith("--")) localVariableDeclarations.add(declaration);
|
|
19625
|
-
}
|
|
19626
|
-
});
|
|
19627
|
-
for (const rule of inlinableRules) {
|
|
19628
|
-
walk(rule, {
|
|
19629
|
-
visit: "Function",
|
|
19630
|
-
enter(func, funcParentListItem) {
|
|
19631
|
-
if (func.name === "var") {
|
|
19632
|
-
let variableName;
|
|
19633
|
-
walk(func, {
|
|
19634
|
-
visit: "Identifier",
|
|
19635
|
-
enter(identifier) {
|
|
19636
|
-
variableName = identifier.name;
|
|
19637
|
-
return this.break;
|
|
19638
|
-
}
|
|
19639
|
-
});
|
|
19640
|
-
if (variableName) {
|
|
19641
|
-
const definition = Array.from(localVariableDeclarations).find((declaration) => variableName === declaration.property);
|
|
19642
|
-
if (definition) funcParentListItem.data = definition.value;
|
|
19643
|
-
}
|
|
19644
|
-
}
|
|
19645
|
-
}
|
|
19646
|
-
});
|
|
19647
|
-
walk(rule, {
|
|
19648
|
-
visit: "Declaration",
|
|
19649
|
-
enter(declaration) {
|
|
19650
|
-
if (declaration.property.startsWith("--")) return;
|
|
19651
|
-
styles[getReactProperty(declaration.property)] = generate(declaration.value) + (declaration.important ? "!important" : "");
|
|
19652
|
-
}
|
|
19653
|
-
});
|
|
19654
|
-
}
|
|
19655
|
-
return styles;
|
|
19656
|
-
}
|
|
19657
|
-
|
|
19658
19764
|
//#endregion
|
|
19659
19765
|
//#region src/utils/tailwindcss/clone-element-with-inlined-styles.ts
|
|
19660
|
-
function cloneElementWithInlinedStyles(element, inlinableRules, nonInlinableRules) {
|
|
19766
|
+
function cloneElementWithInlinedStyles(element, inlinableRules, nonInlinableRules, customProperties) {
|
|
19661
19767
|
const propsToOverwrite = {};
|
|
19662
19768
|
if (element.props.className && !isComponent(element)) {
|
|
19663
19769
|
const classes = element.props.className.trim().split(/\s+/);
|
|
@@ -19669,7 +19775,7 @@ function cloneElementWithInlinedStyles(element, inlinableRules, nonInlinableRule
|
|
|
19669
19775
|
else residualClasses.push(className);
|
|
19670
19776
|
}
|
|
19671
19777
|
propsToOverwrite.style = {
|
|
19672
|
-
...makeInlineStylesFor(rules),
|
|
19778
|
+
...makeInlineStylesFor(rules, customProperties),
|
|
19673
19779
|
...element.props.style
|
|
19674
19780
|
};
|
|
19675
19781
|
if (residualClasses.length > 0) propsToOverwrite.className = residualClasses.map((className) => {
|
|
@@ -21572,7 +21678,7 @@ const pixelBasedPreset = { theme: { extend: {
|
|
|
21572
21678
|
}
|
|
21573
21679
|
} } };
|
|
21574
21680
|
function Tailwind({ children, config }) {
|
|
21575
|
-
const tailwindSetup = useSuspensedPromise(() => setupTailwind(config ?? {}), JSON.stringify(config));
|
|
21681
|
+
const tailwindSetup = useSuspensedPromise(() => setupTailwind(config ?? {}), JSON.stringify(config, (_key, value) => typeof value === "function" ? value.toString() : value));
|
|
21576
21682
|
let classesUsed = [];
|
|
21577
21683
|
let mappedChildren = mapReactTree(children, (node) => {
|
|
21578
21684
|
if (React$1.isValidElement(node)) {
|
|
@@ -21585,20 +21691,19 @@ function Tailwind({ children, config }) {
|
|
|
21585
21691
|
return node;
|
|
21586
21692
|
});
|
|
21587
21693
|
const styleSheet = tailwindSetup.getStyleSheet();
|
|
21588
|
-
|
|
21589
|
-
resolveCalcExpressions(styleSheet);
|
|
21590
|
-
sanitizeDeclarations(styleSheet);
|
|
21694
|
+
sanitizeStyleSheet(styleSheet);
|
|
21591
21695
|
const { inlinable: inlinableRules, nonInlinable: nonInlinableRules } = extractRulesPerClass(styleSheet, classesUsed);
|
|
21592
|
-
|
|
21696
|
+
const customProperties = getCustomProperties(styleSheet);
|
|
21593
21697
|
const nonInlineStyles = {
|
|
21594
21698
|
type: "StyleSheet",
|
|
21595
|
-
children: new List().fromArray(nonInlinableRules.values()
|
|
21699
|
+
children: new List().fromArray(Array.from(nonInlinableRules.values()))
|
|
21596
21700
|
};
|
|
21701
|
+
sanitizeNonInlinableRules(nonInlineStyles);
|
|
21597
21702
|
const hasNonInlineStylesToApply = nonInlinableRules.size > 0;
|
|
21598
21703
|
let appliedNonInlineStyles = false;
|
|
21599
21704
|
mappedChildren = mapReactTree(mappedChildren, (node) => {
|
|
21600
21705
|
if (React$1.isValidElement(node)) {
|
|
21601
|
-
const elementWithInlinedStyles = cloneElementWithInlinedStyles(node, inlinableRules, nonInlinableRules);
|
|
21706
|
+
const elementWithInlinedStyles = cloneElementWithInlinedStyles(node, inlinableRules, nonInlinableRules, customProperties);
|
|
21602
21707
|
if (elementWithInlinedStyles.type === "head") {
|
|
21603
21708
|
appliedNonInlineStyles = true;
|
|
21604
21709
|
const styleElement = /* @__PURE__ */ jsx("style", { children: generate(nonInlineStyles) });
|
|
@@ -21608,7 +21713,7 @@ function Tailwind({ children, config }) {
|
|
|
21608
21713
|
}
|
|
21609
21714
|
return node;
|
|
21610
21715
|
});
|
|
21611
|
-
if (hasNonInlineStylesToApply && !appliedNonInlineStyles) throw new Error(`You are trying to use the following Tailwind classes that cannot be inlined: ${nonInlinableRules.keys()
|
|
21716
|
+
if (hasNonInlineStylesToApply && !appliedNonInlineStyles) throw new Error(`You are trying to use the following Tailwind classes that cannot be inlined: ${Array.from(nonInlinableRules.keys()).join(" ")}.
|
|
21612
21717
|
For the media queries to work properly on rendering, they need to be added into a <style> tag inside of a <head> tag,
|
|
21613
21718
|
the Tailwind component tried finding a <head> element but just wasn't able to find it.
|
|
21614
21719
|
|
|
@@ -21621,5 +21726,5 @@ please file a bug https://github.com/resend/react-email/issues/new?assignees=&la
|
|
|
21621
21726
|
}
|
|
21622
21727
|
|
|
21623
21728
|
//#endregion
|
|
21624
|
-
export { Tailwind, pixelBasedPreset };
|
|
21729
|
+
export { Tailwind, inlineStyles, pixelBasedPreset, sanitizeStyleSheet, setupTailwind };
|
|
21625
21730
|
//# sourceMappingURL=index.mjs.map
|