@react-email/tailwind 2.0.0-tailwindv4.4 → 2.0.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 +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 +244 -157
- package/dist/index.mjs +240 -157
- package/dist/index.mjs.map +1 -1
- package/package.json +16 -15
package/dist/index.mjs
CHANGED
|
@@ -10,6 +10,7 @@ import { Hr } from "@react-email/hr";
|
|
|
10
10
|
import { Img } from "@react-email/img";
|
|
11
11
|
import { Link } from "@react-email/link";
|
|
12
12
|
import { Preview } from "@react-email/preview";
|
|
13
|
+
import { Text } from "@react-email/text";
|
|
13
14
|
import { compile } from "tailwindcss";
|
|
14
15
|
import { jsx } from "react/jsx-runtime";
|
|
15
16
|
|
|
@@ -19024,21 +19025,6 @@ const { version } = {
|
|
|
19024
19025
|
//#region ../../node_modules/.pnpm/css-tree@3.1.0/node_modules/css-tree/lib/index.js
|
|
19025
19026
|
const { tokenize, parse, generate, lexer, createLexer, walk, find, findLast, findAll, toPlainObject, fromPlainObject, fork } = syntax_default;
|
|
19026
19027
|
|
|
19027
|
-
//#endregion
|
|
19028
|
-
//#region src/hooks/use-suspended-promise.ts
|
|
19029
|
-
const promiseStates = /* @__PURE__ */ new Map();
|
|
19030
|
-
function useSuspensedPromise(promiseFn, key) {
|
|
19031
|
-
const previousState = promiseStates.get(key);
|
|
19032
|
-
if (previousState) {
|
|
19033
|
-
if ("error" in previousState) throw previousState.error;
|
|
19034
|
-
if ("result" in previousState) return previousState.result;
|
|
19035
|
-
throw previousState.promise;
|
|
19036
|
-
}
|
|
19037
|
-
const state = { promise: promiseFn().then((result) => state.result = result).catch((error) => state.error = error) };
|
|
19038
|
-
promiseStates.set(key, state);
|
|
19039
|
-
throw state.promise;
|
|
19040
|
-
}
|
|
19041
|
-
|
|
19042
19028
|
//#endregion
|
|
19043
19029
|
//#region src/utils/css/is-rule-inlinable.ts
|
|
19044
19030
|
function isRuleInlinable(rule) {
|
|
@@ -19075,20 +19061,112 @@ function extractRulesPerClass(root, classes) {
|
|
|
19075
19061
|
}
|
|
19076
19062
|
|
|
19077
19063
|
//#endregion
|
|
19078
|
-
//#region src/utils/css/
|
|
19079
|
-
function
|
|
19080
|
-
const
|
|
19064
|
+
//#region src/utils/css/get-custom-properties.ts
|
|
19065
|
+
function getCustomProperties(node) {
|
|
19066
|
+
const customProperties = /* @__PURE__ */ new Map();
|
|
19081
19067
|
walk(node, {
|
|
19082
|
-
|
|
19083
|
-
|
|
19084
|
-
|
|
19085
|
-
|
|
19086
|
-
|
|
19087
|
-
|
|
19088
|
-
|
|
19089
|
-
|
|
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);
|
|
19090
19127
|
}
|
|
19091
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);
|
|
19092
19170
|
}
|
|
19093
19171
|
|
|
19094
19172
|
//#endregion
|
|
@@ -19096,70 +19174,74 @@ function populateParentsForNodeTree(node) {
|
|
|
19096
19174
|
function doSelectorsIntersect(first, second) {
|
|
19097
19175
|
if (generate(first) === generate(second)) return true;
|
|
19098
19176
|
let hasSomeUniversal = false;
|
|
19099
|
-
const walker = (node) => {
|
|
19177
|
+
const walker = (node, _parentListItem, parentList) => {
|
|
19100
19178
|
if (hasSomeUniversal) return;
|
|
19101
19179
|
if (node.type === "PseudoClassSelector" && node.name === "root") hasSomeUniversal = true;
|
|
19102
|
-
if (node.type === "TypeSelector" && node.name === "*" &&
|
|
19180
|
+
if (node.type === "TypeSelector" && node.name === "*" && parentList.size === 1) hasSomeUniversal = true;
|
|
19103
19181
|
};
|
|
19104
19182
|
walk(first, walker);
|
|
19105
19183
|
walk(second, walker);
|
|
19106
19184
|
if (hasSomeUniversal) return true;
|
|
19107
19185
|
return false;
|
|
19108
19186
|
}
|
|
19109
|
-
function someParent(node, predicate) {
|
|
19110
|
-
if (node.parent) {
|
|
19111
|
-
if (predicate(node.parent)) return true;
|
|
19112
|
-
return someParent(node.parent, predicate);
|
|
19113
|
-
}
|
|
19114
|
-
return false;
|
|
19115
|
-
}
|
|
19116
19187
|
function resolveAllCssVariables(node) {
|
|
19117
|
-
populateParentsForNodeTree(node);
|
|
19118
19188
|
const variableDefinitions = /* @__PURE__ */ new Set();
|
|
19119
19189
|
const variableUses = /* @__PURE__ */ new Set();
|
|
19190
|
+
const path = [];
|
|
19120
19191
|
walk(node, {
|
|
19121
|
-
|
|
19122
|
-
|
|
19123
|
-
|
|
19124
|
-
|
|
19125
|
-
|
|
19126
|
-
|
|
19127
|
-
|
|
19128
|
-
|
|
19129
|
-
|
|
19130
|
-
|
|
19131
|
-
|
|
19132
|
-
|
|
19133
|
-
|
|
19134
|
-
|
|
19135
|
-
|
|
19136
|
-
|
|
19137
|
-
|
|
19138
|
-
|
|
19139
|
-
|
|
19140
|
-
|
|
19141
|
-
|
|
19142
|
-
|
|
19143
|
-
|
|
19144
|
-
|
|
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
|
+
}
|
|
19145
19226
|
}
|
|
19146
|
-
}
|
|
19147
|
-
}
|
|
19227
|
+
});
|
|
19228
|
+
}
|
|
19229
|
+
parseVariableUsesFrom(declaration.value);
|
|
19148
19230
|
}
|
|
19149
|
-
parseVariableUsesFrom(declaration.value);
|
|
19150
19231
|
}
|
|
19232
|
+
path.unshift(node$1);
|
|
19151
19233
|
}
|
|
19152
19234
|
});
|
|
19153
19235
|
for (const use of variableUses) {
|
|
19154
19236
|
let hasReplaced = false;
|
|
19155
19237
|
for (const definition of variableDefinitions) {
|
|
19156
19238
|
if (use.variableName !== definition.variableName) continue;
|
|
19157
|
-
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)) {
|
|
19158
19240
|
use.declaration.value = parse(generate(use.declaration.value).replaceAll(use.raw, definition.definition), { context: "value" });
|
|
19159
19241
|
hasReplaced = true;
|
|
19160
19242
|
break;
|
|
19161
19243
|
}
|
|
19162
|
-
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)) {
|
|
19163
19245
|
use.declaration.value = parse(generate(use.declaration.value).replaceAll(use.raw, definition.definition), { context: "value" });
|
|
19164
19246
|
hasReplaced = true;
|
|
19165
19247
|
break;
|
|
@@ -19261,6 +19343,44 @@ function resolveCalcExpressions(node) {
|
|
|
19261
19343
|
|
|
19262
19344
|
//#endregion
|
|
19263
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
|
+
}
|
|
19264
19384
|
const LAB_TO_LMS = {
|
|
19265
19385
|
l: [.3963377773761749, .2158037573099136],
|
|
19266
19386
|
m: [-.1055613458156586, -.0638541728258133],
|
|
@@ -19309,9 +19429,9 @@ function oklchToRgb(oklch) {
|
|
|
19309
19429
|
const g = 255 * lrgbToRgb(LSM_TO_RGB.g[0] * l + LSM_TO_RGB.g[1] * m + LSM_TO_RGB.g[2] * s);
|
|
19310
19430
|
const b = 255 * lrgbToRgb(LSM_TO_RGB.b[0] * l + LSM_TO_RGB.b[1] * m + LSM_TO_RGB.b[2] * s);
|
|
19311
19431
|
return {
|
|
19312
|
-
r: clamp(r, 0, 255)
|
|
19313
|
-
g: clamp(g, 0, 255)
|
|
19314
|
-
b: clamp(b, 0, 255)
|
|
19432
|
+
r: clamp(r, 0, 255),
|
|
19433
|
+
g: clamp(g, 0, 255),
|
|
19434
|
+
b: clamp(b, 0, 255)
|
|
19315
19435
|
};
|
|
19316
19436
|
}
|
|
19317
19437
|
function separteShorthandDeclaration(shorthandToReplace, [start, end]) {
|
|
@@ -19352,6 +19472,7 @@ function sanitizeDeclarations(nodeContainingDeclarations) {
|
|
|
19352
19472
|
walk(nodeContainingDeclarations, {
|
|
19353
19473
|
visit: "Declaration",
|
|
19354
19474
|
enter(declaration, item, list) {
|
|
19475
|
+
if (declaration.value.type === "Raw") declaration.value = parse(declaration.value.value, { context: "value" });
|
|
19355
19476
|
if (/border-radius\s*:\s*calc\s*\(\s*infinity\s*\*\s*1px\s*\)/i.test(generate(declaration))) declaration.value = parse("9999px", { context: "value" });
|
|
19356
19477
|
walk(declaration, {
|
|
19357
19478
|
visit: "Function",
|
|
@@ -19401,8 +19522,7 @@ function sanitizeDeclarations(nodeContainingDeclarations) {
|
|
|
19401
19522
|
c,
|
|
19402
19523
|
h
|
|
19403
19524
|
});
|
|
19404
|
-
|
|
19405
|
-
funcParentListItem.data = parse(`rgb(${rgb.r},${rgb.g},${rgb.b}${alphaString})`, { context: "value" });
|
|
19525
|
+
funcParentListItem.data = rgbNode(rgb.r, rgb.g, rgb.b, a);
|
|
19406
19526
|
}
|
|
19407
19527
|
if (func.name === "rgb") {
|
|
19408
19528
|
let r;
|
|
@@ -19445,8 +19565,8 @@ function sanitizeDeclarations(nodeContainingDeclarations) {
|
|
|
19445
19565
|
}
|
|
19446
19566
|
}
|
|
19447
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 });
|
|
19448
|
-
if (a === void 0 || a === 1) funcParentListItem.data =
|
|
19449
|
-
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);
|
|
19450
19570
|
}
|
|
19451
19571
|
}
|
|
19452
19572
|
});
|
|
@@ -19455,45 +19575,42 @@ function sanitizeDeclarations(nodeContainingDeclarations) {
|
|
|
19455
19575
|
enter(hash, hashParentListItem) {
|
|
19456
19576
|
const hex = hash.value.trim();
|
|
19457
19577
|
if (hex.length === 3) {
|
|
19458
|
-
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));
|
|
19459
19579
|
return;
|
|
19460
19580
|
}
|
|
19461
19581
|
if (hex.length === 4) {
|
|
19462
|
-
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);
|
|
19463
19583
|
return;
|
|
19464
19584
|
}
|
|
19465
19585
|
if (hex.length === 5) {
|
|
19466
|
-
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);
|
|
19467
19587
|
return;
|
|
19468
19588
|
}
|
|
19469
19589
|
if (hex.length === 6) {
|
|
19470
|
-
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));
|
|
19471
19591
|
return;
|
|
19472
19592
|
}
|
|
19473
19593
|
if (hex.length === 7) {
|
|
19474
|
-
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);
|
|
19475
19595
|
return;
|
|
19476
19596
|
}
|
|
19477
|
-
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);
|
|
19478
19598
|
}
|
|
19479
19599
|
});
|
|
19480
19600
|
walk(declaration, {
|
|
19481
19601
|
visit: "Function",
|
|
19482
19602
|
enter(func, parentListItem) {
|
|
19483
19603
|
if (func.name === "color-mix") {
|
|
19484
|
-
const
|
|
19485
|
-
const
|
|
19486
|
-
|
|
19487
|
-
|
|
19488
|
-
|
|
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({
|
|
19489
19609
|
type: "Operator",
|
|
19490
19610
|
value: ","
|
|
19491
19611
|
});
|
|
19492
|
-
|
|
19493
|
-
|
|
19494
|
-
value: alpha.toString()
|
|
19495
|
-
});
|
|
19496
|
-
parentListItem.data = originalColor;
|
|
19612
|
+
color.children.appendData(opacity);
|
|
19613
|
+
parentListItem.data = color;
|
|
19497
19614
|
}
|
|
19498
19615
|
}
|
|
19499
19616
|
}
|
|
@@ -19518,6 +19635,29 @@ function sanitizeDeclarations(nodeContainingDeclarations) {
|
|
|
19518
19635
|
});
|
|
19519
19636
|
}
|
|
19520
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
|
+
|
|
19521
19661
|
//#endregion
|
|
19522
19662
|
//#region src/utils/compatibility/sanitize-class-name.ts
|
|
19523
19663
|
const digitToNameMap = {
|
|
@@ -19586,7 +19726,8 @@ const componentsToTreatAsElements = [
|
|
|
19586
19726
|
Hr,
|
|
19587
19727
|
Img,
|
|
19588
19728
|
Link,
|
|
19589
|
-
Preview
|
|
19729
|
+
Preview,
|
|
19730
|
+
Text
|
|
19590
19731
|
];
|
|
19591
19732
|
const isComponent = (element) => {
|
|
19592
19733
|
return (typeof element.type === "function" || element.type.render !== void 0) && !componentsToTreatAsElements.includes(element.type);
|
|
@@ -19620,66 +19761,9 @@ function mapReactTree(value, process) {
|
|
|
19620
19761
|
return mapped && mapped.length === 1 ? mapped[0] : mapped;
|
|
19621
19762
|
}
|
|
19622
19763
|
|
|
19623
|
-
//#endregion
|
|
19624
|
-
//#region src/utils/text/from-dash-case-to-camel-case.ts
|
|
19625
|
-
const fromDashCaseToCamelCase = (text) => {
|
|
19626
|
-
return text.replace(/-(\w|$)/g, (_, p1) => p1.toUpperCase());
|
|
19627
|
-
};
|
|
19628
|
-
|
|
19629
|
-
//#endregion
|
|
19630
|
-
//#region src/utils/compatibility/get-react-property.ts
|
|
19631
|
-
function getReactProperty(prop) {
|
|
19632
|
-
const modifiedProp = prop.toLowerCase();
|
|
19633
|
-
if (modifiedProp.startsWith("--")) return modifiedProp;
|
|
19634
|
-
if (modifiedProp.startsWith("-ms-")) return fromDashCaseToCamelCase(modifiedProp.slice(1));
|
|
19635
|
-
return fromDashCaseToCamelCase(modifiedProp);
|
|
19636
|
-
}
|
|
19637
|
-
|
|
19638
|
-
//#endregion
|
|
19639
|
-
//#region src/utils/css/make-inline-styles-for.ts
|
|
19640
|
-
function makeInlineStylesFor(inlinableRules) {
|
|
19641
|
-
const styles = {};
|
|
19642
|
-
const localVariableDeclarations = /* @__PURE__ */ new Set();
|
|
19643
|
-
for (const rule of inlinableRules) walk(rule, {
|
|
19644
|
-
visit: "Declaration",
|
|
19645
|
-
enter(declaration) {
|
|
19646
|
-
if (declaration.property.startsWith("--")) localVariableDeclarations.add(declaration);
|
|
19647
|
-
}
|
|
19648
|
-
});
|
|
19649
|
-
for (const rule of inlinableRules) {
|
|
19650
|
-
walk(rule, {
|
|
19651
|
-
visit: "Function",
|
|
19652
|
-
enter(func, funcParentListItem) {
|
|
19653
|
-
if (func.name === "var") {
|
|
19654
|
-
let variableName;
|
|
19655
|
-
walk(func, {
|
|
19656
|
-
visit: "Identifier",
|
|
19657
|
-
enter(identifier) {
|
|
19658
|
-
variableName = identifier.name;
|
|
19659
|
-
return this.break;
|
|
19660
|
-
}
|
|
19661
|
-
});
|
|
19662
|
-
if (variableName) {
|
|
19663
|
-
const definition = Array.from(localVariableDeclarations).find((declaration) => variableName === declaration.property);
|
|
19664
|
-
if (definition) funcParentListItem.data = definition.value;
|
|
19665
|
-
}
|
|
19666
|
-
}
|
|
19667
|
-
}
|
|
19668
|
-
});
|
|
19669
|
-
walk(rule, {
|
|
19670
|
-
visit: "Declaration",
|
|
19671
|
-
enter(declaration) {
|
|
19672
|
-
if (declaration.property.startsWith("--")) return;
|
|
19673
|
-
styles[getReactProperty(declaration.property)] = generate(declaration.value) + (declaration.important ? "!important" : "");
|
|
19674
|
-
}
|
|
19675
|
-
});
|
|
19676
|
-
}
|
|
19677
|
-
return styles;
|
|
19678
|
-
}
|
|
19679
|
-
|
|
19680
19764
|
//#endregion
|
|
19681
19765
|
//#region src/utils/tailwindcss/clone-element-with-inlined-styles.ts
|
|
19682
|
-
function cloneElementWithInlinedStyles(element, inlinableRules, nonInlinableRules) {
|
|
19766
|
+
function cloneElementWithInlinedStyles(element, inlinableRules, nonInlinableRules, customProperties) {
|
|
19683
19767
|
const propsToOverwrite = {};
|
|
19684
19768
|
if (element.props.className && !isComponent(element)) {
|
|
19685
19769
|
const classes = element.props.className.trim().split(/\s+/);
|
|
@@ -19691,7 +19775,7 @@ function cloneElementWithInlinedStyles(element, inlinableRules, nonInlinableRule
|
|
|
19691
19775
|
else residualClasses.push(className);
|
|
19692
19776
|
}
|
|
19693
19777
|
propsToOverwrite.style = {
|
|
19694
|
-
...makeInlineStylesFor(rules),
|
|
19778
|
+
...makeInlineStylesFor(rules, customProperties),
|
|
19695
19779
|
...element.props.style
|
|
19696
19780
|
};
|
|
19697
19781
|
if (residualClasses.length > 0) propsToOverwrite.className = residualClasses.map((className) => {
|
|
@@ -21594,7 +21678,7 @@ const pixelBasedPreset = { theme: { extend: {
|
|
|
21594
21678
|
}
|
|
21595
21679
|
} } };
|
|
21596
21680
|
function Tailwind({ children, config }) {
|
|
21597
|
-
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));
|
|
21598
21682
|
let classesUsed = [];
|
|
21599
21683
|
let mappedChildren = mapReactTree(children, (node) => {
|
|
21600
21684
|
if (React$1.isValidElement(node)) {
|
|
@@ -21607,20 +21691,19 @@ function Tailwind({ children, config }) {
|
|
|
21607
21691
|
return node;
|
|
21608
21692
|
});
|
|
21609
21693
|
const styleSheet = tailwindSetup.getStyleSheet();
|
|
21610
|
-
|
|
21611
|
-
resolveCalcExpressions(styleSheet);
|
|
21612
|
-
sanitizeDeclarations(styleSheet);
|
|
21694
|
+
sanitizeStyleSheet(styleSheet);
|
|
21613
21695
|
const { inlinable: inlinableRules, nonInlinable: nonInlinableRules } = extractRulesPerClass(styleSheet, classesUsed);
|
|
21614
|
-
|
|
21696
|
+
const customProperties = getCustomProperties(styleSheet);
|
|
21615
21697
|
const nonInlineStyles = {
|
|
21616
21698
|
type: "StyleSheet",
|
|
21617
|
-
children: new List().fromArray(nonInlinableRules.values()
|
|
21699
|
+
children: new List().fromArray(Array.from(nonInlinableRules.values()))
|
|
21618
21700
|
};
|
|
21701
|
+
sanitizeNonInlinableRules(nonInlineStyles);
|
|
21619
21702
|
const hasNonInlineStylesToApply = nonInlinableRules.size > 0;
|
|
21620
21703
|
let appliedNonInlineStyles = false;
|
|
21621
21704
|
mappedChildren = mapReactTree(mappedChildren, (node) => {
|
|
21622
21705
|
if (React$1.isValidElement(node)) {
|
|
21623
|
-
const elementWithInlinedStyles = cloneElementWithInlinedStyles(node, inlinableRules, nonInlinableRules);
|
|
21706
|
+
const elementWithInlinedStyles = cloneElementWithInlinedStyles(node, inlinableRules, nonInlinableRules, customProperties);
|
|
21624
21707
|
if (elementWithInlinedStyles.type === "head") {
|
|
21625
21708
|
appliedNonInlineStyles = true;
|
|
21626
21709
|
const styleElement = /* @__PURE__ */ jsx("style", { children: generate(nonInlineStyles) });
|
|
@@ -21630,7 +21713,7 @@ function Tailwind({ children, config }) {
|
|
|
21630
21713
|
}
|
|
21631
21714
|
return node;
|
|
21632
21715
|
});
|
|
21633
|
-
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(" ")}.
|
|
21634
21717
|
For the media queries to work properly on rendering, they need to be added into a <style> tag inside of a <head> tag,
|
|
21635
21718
|
the Tailwind component tried finding a <head> element but just wasn't able to find it.
|
|
21636
21719
|
|
|
@@ -21643,5 +21726,5 @@ please file a bug https://github.com/resend/react-email/issues/new?assignees=&la
|
|
|
21643
21726
|
}
|
|
21644
21727
|
|
|
21645
21728
|
//#endregion
|
|
21646
|
-
export { Tailwind, pixelBasedPreset };
|
|
21729
|
+
export { Tailwind, inlineStyles, pixelBasedPreset, sanitizeStyleSheet, setupTailwind };
|
|
21647
21730
|
//# sourceMappingURL=index.mjs.map
|