@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.js CHANGED
@@ -34,6 +34,28 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
34
34
  //#endregion
35
35
  let react = require("react");
36
36
  react = __toESM(react);
37
+ let __react_email_body = require("@react-email/body");
38
+ __react_email_body = __toESM(__react_email_body);
39
+ let __react_email_button = require("@react-email/button");
40
+ __react_email_button = __toESM(__react_email_button);
41
+ let __react_email_code_block = require("@react-email/code-block");
42
+ __react_email_code_block = __toESM(__react_email_code_block);
43
+ let __react_email_code_inline = require("@react-email/code-inline");
44
+ __react_email_code_inline = __toESM(__react_email_code_inline);
45
+ let __react_email_container = require("@react-email/container");
46
+ __react_email_container = __toESM(__react_email_container);
47
+ let __react_email_heading = require("@react-email/heading");
48
+ __react_email_heading = __toESM(__react_email_heading);
49
+ let __react_email_hr = require("@react-email/hr");
50
+ __react_email_hr = __toESM(__react_email_hr);
51
+ let __react_email_img = require("@react-email/img");
52
+ __react_email_img = __toESM(__react_email_img);
53
+ let __react_email_link = require("@react-email/link");
54
+ __react_email_link = __toESM(__react_email_link);
55
+ let __react_email_preview = require("@react-email/preview");
56
+ __react_email_preview = __toESM(__react_email_preview);
57
+ let __react_email_text = require("@react-email/text");
58
+ __react_email_text = __toESM(__react_email_text);
37
59
  let tailwindcss = require("tailwindcss");
38
60
  tailwindcss = __toESM(tailwindcss);
39
61
  let react_jsx_runtime = require("react/jsx-runtime");
@@ -19016,21 +19038,6 @@ const { version } = {
19016
19038
  //#region ../../node_modules/.pnpm/css-tree@3.1.0/node_modules/css-tree/lib/index.js
19017
19039
  const { tokenize, parse, generate, lexer, createLexer, walk, find, findLast, findAll, toPlainObject, fromPlainObject, fork } = syntax_default;
19018
19040
 
19019
- //#endregion
19020
- //#region src/hooks/use-suspended-promise.ts
19021
- const promiseStates = /* @__PURE__ */ new Map();
19022
- function useSuspensedPromise(promiseFn, key) {
19023
- const previousState = promiseStates.get(key);
19024
- if (previousState) {
19025
- if ("error" in previousState) throw previousState.error;
19026
- if ("result" in previousState) return previousState.result;
19027
- throw previousState.promise;
19028
- }
19029
- const state = { promise: promiseFn().then((result) => state.result = result).catch((error) => state.error = error) };
19030
- promiseStates.set(key, state);
19031
- throw state.promise;
19032
- }
19033
-
19034
19041
  //#endregion
19035
19042
  //#region src/utils/css/is-rule-inlinable.ts
19036
19043
  function isRuleInlinable(rule) {
@@ -19067,20 +19074,112 @@ function extractRulesPerClass(root, classes) {
19067
19074
  }
19068
19075
 
19069
19076
  //#endregion
19070
- //#region src/utils/css/populate-parents-for-node-tree.ts
19071
- function populateParentsForNodeTree(node) {
19072
- const parentPath = [];
19077
+ //#region src/utils/css/get-custom-properties.ts
19078
+ function getCustomProperties(node) {
19079
+ const customProperties = /* @__PURE__ */ new Map();
19073
19080
  walk(node, {
19074
- enter(child, parentListItem, parentList) {
19075
- child.parent = parentPath[parentPath.length - 1];
19076
- child.containingItem = parentListItem;
19077
- child.containedIn = parentList;
19078
- parentPath.push(child);
19079
- },
19080
- leave() {
19081
- parentPath.pop();
19081
+ visit: "Atrule",
19082
+ enter(atrule) {
19083
+ if (atrule.name === "property" && atrule.prelude) {
19084
+ const prelude = generate(atrule.prelude);
19085
+ if (prelude.startsWith("--")) {
19086
+ let syntax;
19087
+ let inherits;
19088
+ let initialValue;
19089
+ walk(atrule, {
19090
+ visit: "Declaration",
19091
+ enter(declaration) {
19092
+ if (declaration.property === "syntax") syntax = declaration;
19093
+ if (declaration.property === "inherits") inherits = declaration;
19094
+ if (declaration.property === "initial-value") initialValue = declaration;
19095
+ }
19096
+ });
19097
+ customProperties.set(prelude, {
19098
+ syntax,
19099
+ inherits,
19100
+ initialValue
19101
+ });
19102
+ }
19103
+ }
19104
+ }
19105
+ });
19106
+ return customProperties;
19107
+ }
19108
+
19109
+ //#endregion
19110
+ //#region src/utils/text/from-dash-case-to-camel-case.ts
19111
+ const fromDashCaseToCamelCase = (text) => {
19112
+ return text.replace(/-(\w|$)/g, (_, p1) => p1.toUpperCase());
19113
+ };
19114
+
19115
+ //#endregion
19116
+ //#region src/utils/compatibility/get-react-property.ts
19117
+ function getReactProperty(prop) {
19118
+ const modifiedProp = prop.toLowerCase();
19119
+ if (modifiedProp.startsWith("--")) return modifiedProp;
19120
+ if (modifiedProp.startsWith("-ms-")) return fromDashCaseToCamelCase(modifiedProp.slice(1));
19121
+ return fromDashCaseToCamelCase(modifiedProp);
19122
+ }
19123
+
19124
+ //#endregion
19125
+ //#region src/utils/css/unwrap-value.ts
19126
+ function unwrapValue(value) {
19127
+ if (value.type === "Value" && value.children.size === 1) return value.children.first ?? value;
19128
+ return value;
19129
+ }
19130
+
19131
+ //#endregion
19132
+ //#region src/utils/css/make-inline-styles-for.ts
19133
+ function makeInlineStylesFor(inlinableRules, customProperties) {
19134
+ const styles = {};
19135
+ const localVariableDeclarations = /* @__PURE__ */ new Map();
19136
+ for (const rule of inlinableRules) walk(rule, {
19137
+ visit: "Declaration",
19138
+ enter(declaration) {
19139
+ if (declaration.property.startsWith("--")) localVariableDeclarations.set(declaration.property, declaration);
19082
19140
  }
19083
19141
  });
19142
+ for (const rule of inlinableRules) {
19143
+ walk(rule, {
19144
+ visit: "Function",
19145
+ enter(func, funcParentListItem) {
19146
+ if (func.name === "var") {
19147
+ let variableName;
19148
+ walk(func, {
19149
+ visit: "Identifier",
19150
+ enter(identifier) {
19151
+ variableName = identifier.name;
19152
+ return this.break;
19153
+ }
19154
+ });
19155
+ if (variableName) {
19156
+ const definition = localVariableDeclarations.get(variableName);
19157
+ if (definition) funcParentListItem.data = unwrapValue(definition.value);
19158
+ else {
19159
+ const customProperty = customProperties.get(variableName);
19160
+ if (customProperty?.initialValue) funcParentListItem.data = unwrapValue(customProperty.initialValue.value);
19161
+ }
19162
+ }
19163
+ }
19164
+ }
19165
+ });
19166
+ walk(rule, {
19167
+ visit: "Declaration",
19168
+ enter(declaration) {
19169
+ if (declaration.property.startsWith("--")) return;
19170
+ styles[getReactProperty(declaration.property)] = generate(declaration.value) + (declaration.important ? "!important" : "");
19171
+ }
19172
+ });
19173
+ }
19174
+ return styles;
19175
+ }
19176
+
19177
+ //#endregion
19178
+ //#region src/inline-styles.ts
19179
+ function inlineStyles(styleSheet, classes) {
19180
+ const { inlinable: inlinableRules } = extractRulesPerClass(styleSheet, classes);
19181
+ const customProperties = getCustomProperties(styleSheet);
19182
+ return makeInlineStylesFor(Array.from(inlinableRules.values()), customProperties);
19084
19183
  }
19085
19184
 
19086
19185
  //#endregion
@@ -19088,70 +19187,74 @@ function populateParentsForNodeTree(node) {
19088
19187
  function doSelectorsIntersect(first, second) {
19089
19188
  if (generate(first) === generate(second)) return true;
19090
19189
  let hasSomeUniversal = false;
19091
- const walker = (node) => {
19190
+ const walker = (node, _parentListItem, parentList) => {
19092
19191
  if (hasSomeUniversal) return;
19093
19192
  if (node.type === "PseudoClassSelector" && node.name === "root") hasSomeUniversal = true;
19094
- if (node.type === "TypeSelector" && node.name === "*" && node.containedIn?.size === 1) hasSomeUniversal = true;
19193
+ if (node.type === "TypeSelector" && node.name === "*" && parentList.size === 1) hasSomeUniversal = true;
19095
19194
  };
19096
19195
  walk(first, walker);
19097
19196
  walk(second, walker);
19098
19197
  if (hasSomeUniversal) return true;
19099
19198
  return false;
19100
19199
  }
19101
- function someParent(node, predicate) {
19102
- if (node.parent) {
19103
- if (predicate(node.parent)) return true;
19104
- return someParent(node.parent, predicate);
19105
- }
19106
- return false;
19107
- }
19108
19200
  function resolveAllCssVariables(node) {
19109
- populateParentsForNodeTree(node);
19110
19201
  const variableDefinitions = /* @__PURE__ */ new Set();
19111
19202
  const variableUses = /* @__PURE__ */ new Set();
19203
+ const path = [];
19112
19204
  walk(node, {
19113
- visit: "Declaration",
19114
- enter(declaration) {
19115
- if (someParent(declaration, (ancestor) => ancestor.type === "Atrule" && ancestor.name === "layer" && ancestor.prelude !== null && generate(ancestor.prelude).includes("properties"))) return;
19116
- if (/--[\S]+/.test(declaration.property)) variableDefinitions.add({
19117
- declaration,
19118
- variableName: declaration.property,
19119
- definition: generate(declaration.value)
19120
- });
19121
- else {
19122
- function parseVariableUsesFrom(node$1) {
19123
- walk(node$1, {
19124
- visit: "Function",
19125
- enter(funcNode) {
19126
- if (funcNode.name === "var") {
19127
- const children = funcNode.children.toArray();
19128
- const name$49 = generate(children[0]);
19129
- const fallback = children[2] ? generate(children[2]) : void 0;
19130
- variableUses.add({
19131
- declaration,
19132
- fallback,
19133
- variableName: name$49,
19134
- raw: generate(funcNode)
19135
- });
19136
- if (fallback?.includes("var(")) parseVariableUsesFrom(parse(fallback, { context: "value" }));
19205
+ leave() {
19206
+ path.shift();
19207
+ },
19208
+ enter(node$1) {
19209
+ if (node$1.type === "Declaration") {
19210
+ const declaration = node$1;
19211
+ if (path.some((ancestor) => ancestor.type === "Atrule" && ancestor.name === "layer" && ancestor.prelude !== null && generate(ancestor.prelude).includes("properties"))) {
19212
+ path.unshift(node$1);
19213
+ return;
19214
+ }
19215
+ if (/--[\S]+/.test(declaration.property)) variableDefinitions.add({
19216
+ declaration,
19217
+ path: [...path],
19218
+ variableName: declaration.property,
19219
+ definition: generate(declaration.value)
19220
+ });
19221
+ else {
19222
+ function parseVariableUsesFrom(node$2) {
19223
+ walk(node$2, {
19224
+ visit: "Function",
19225
+ enter(funcNode) {
19226
+ if (funcNode.name === "var") {
19227
+ const children = funcNode.children.toArray();
19228
+ const name$49 = generate(children[0]);
19229
+ const fallback = children[2] ? generate(children[2]) : void 0;
19230
+ variableUses.add({
19231
+ declaration,
19232
+ path: [...path],
19233
+ fallback,
19234
+ variableName: name$49,
19235
+ raw: generate(funcNode)
19236
+ });
19237
+ if (fallback?.includes("var(")) parseVariableUsesFrom(parse(fallback, { context: "value" }));
19238
+ }
19137
19239
  }
19138
- }
19139
- });
19240
+ });
19241
+ }
19242
+ parseVariableUsesFrom(declaration.value);
19140
19243
  }
19141
- parseVariableUsesFrom(declaration.value);
19142
19244
  }
19245
+ path.unshift(node$1);
19143
19246
  }
19144
19247
  });
19145
19248
  for (const use of variableUses) {
19146
19249
  let hasReplaced = false;
19147
19250
  for (const definition of variableDefinitions) {
19148
19251
  if (use.variableName !== definition.variableName) continue;
19149
- if (use.declaration.parent?.type === "Block" && use.declaration.parent?.parent?.type === "Atrule" && use.declaration.parent.parent?.parent?.type === "Block" && use.declaration.parent.parent?.parent?.parent?.type === "Rule" && definition.declaration.parent?.type === "Block" && definition.declaration.parent?.parent?.type === "Rule" && doSelectorsIntersect(use.declaration.parent.parent.parent.parent.prelude, definition.declaration.parent.parent.prelude)) {
19252
+ 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)) {
19150
19253
  use.declaration.value = parse(generate(use.declaration.value).replaceAll(use.raw, definition.definition), { context: "value" });
19151
19254
  hasReplaced = true;
19152
19255
  break;
19153
19256
  }
19154
- if (use.declaration.parent?.type === "Block" && use.declaration.parent?.parent?.type === "Rule" && definition.declaration.parent?.type === "Block" && definition.declaration.parent?.parent?.type === "Rule" && doSelectorsIntersect(use.declaration.parent.parent.prelude, definition.declaration.parent.parent.prelude)) {
19257
+ 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)) {
19155
19258
  use.declaration.value = parse(generate(use.declaration.value).replaceAll(use.raw, definition.definition), { context: "value" });
19156
19259
  hasReplaced = true;
19157
19260
  break;
@@ -19253,6 +19356,44 @@ function resolveCalcExpressions(node) {
19253
19356
 
19254
19357
  //#endregion
19255
19358
  //#region src/utils/css/sanitize-declarations.ts
19359
+ function rgbNode(r, g, b, alpha) {
19360
+ const children = new List();
19361
+ children.appendData({
19362
+ type: "Number",
19363
+ value: r.toFixed(0)
19364
+ });
19365
+ children.appendData({
19366
+ type: "Operator",
19367
+ value: ","
19368
+ });
19369
+ children.appendData({
19370
+ type: "Number",
19371
+ value: g.toFixed(0)
19372
+ });
19373
+ children.appendData({
19374
+ type: "Operator",
19375
+ value: ","
19376
+ });
19377
+ children.appendData({
19378
+ type: "Number",
19379
+ value: b.toFixed(0)
19380
+ });
19381
+ if (alpha !== 1 && alpha !== void 0) {
19382
+ children.appendData({
19383
+ type: "Operator",
19384
+ value: ","
19385
+ });
19386
+ children.appendData({
19387
+ type: "Number",
19388
+ value: alpha.toString()
19389
+ });
19390
+ }
19391
+ return {
19392
+ type: "Function",
19393
+ name: "rgb",
19394
+ children
19395
+ };
19396
+ }
19256
19397
  const LAB_TO_LMS = {
19257
19398
  l: [.3963377773761749, .2158037573099136],
19258
19399
  m: [-.1055613458156586, -.0638541728258133],
@@ -19301,9 +19442,9 @@ function oklchToRgb(oklch) {
19301
19442
  const g = 255 * lrgbToRgb(LSM_TO_RGB.g[0] * l + LSM_TO_RGB.g[1] * m + LSM_TO_RGB.g[2] * s);
19302
19443
  const b = 255 * lrgbToRgb(LSM_TO_RGB.b[0] * l + LSM_TO_RGB.b[1] * m + LSM_TO_RGB.b[2] * s);
19303
19444
  return {
19304
- r: clamp(r, 0, 255).toFixed(0),
19305
- g: clamp(g, 0, 255).toFixed(0),
19306
- b: clamp(b, 0, 255).toFixed(0)
19445
+ r: clamp(r, 0, 255),
19446
+ g: clamp(g, 0, 255),
19447
+ b: clamp(b, 0, 255)
19307
19448
  };
19308
19449
  }
19309
19450
  function separteShorthandDeclaration(shorthandToReplace, [start, end]) {
@@ -19344,6 +19485,7 @@ function sanitizeDeclarations(nodeContainingDeclarations) {
19344
19485
  walk(nodeContainingDeclarations, {
19345
19486
  visit: "Declaration",
19346
19487
  enter(declaration, item, list) {
19488
+ if (declaration.value.type === "Raw") declaration.value = parse(declaration.value.value, { context: "value" });
19347
19489
  if (/border-radius\s*:\s*calc\s*\(\s*infinity\s*\*\s*1px\s*\)/i.test(generate(declaration))) declaration.value = parse("9999px", { context: "value" });
19348
19490
  walk(declaration, {
19349
19491
  visit: "Function",
@@ -19393,8 +19535,7 @@ function sanitizeDeclarations(nodeContainingDeclarations) {
19393
19535
  c,
19394
19536
  h
19395
19537
  });
19396
- const alphaString = a !== void 0 ? `,${a}` : "";
19397
- funcParentListItem.data = parse(`rgb(${rgb.r},${rgb.g},${rgb.b}${alphaString})`, { context: "value" });
19538
+ funcParentListItem.data = rgbNode(rgb.r, rgb.g, rgb.b, a);
19398
19539
  }
19399
19540
  if (func.name === "rgb") {
19400
19541
  let r;
@@ -19437,8 +19578,8 @@ function sanitizeDeclarations(nodeContainingDeclarations) {
19437
19578
  }
19438
19579
  }
19439
19580
  if (r === void 0 || g === void 0 || b === void 0) throw new Error("Could not determine the parameters of an rgb() function.", { cause: declaration });
19440
- if (a === void 0 || a === 1) funcParentListItem.data = parse(`rgb(${r},${g},${b})`, { context: "value" });
19441
- else funcParentListItem.data = parse(`rgb(${r},${g},${b},${a})`, { context: "value" });
19581
+ if (a === void 0 || a === 1) funcParentListItem.data = rgbNode(r, g, b);
19582
+ else funcParentListItem.data = rgbNode(r, g, b, a);
19442
19583
  }
19443
19584
  }
19444
19585
  });
@@ -19447,45 +19588,42 @@ function sanitizeDeclarations(nodeContainingDeclarations) {
19447
19588
  enter(hash, hashParentListItem) {
19448
19589
  const hex = hash.value.trim();
19449
19590
  if (hex.length === 3) {
19450
- hashParentListItem.data = parse(`rgb(${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)})`, { context: "value" });
19591
+ 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));
19451
19592
  return;
19452
19593
  }
19453
19594
  if (hex.length === 4) {
19454
- hashParentListItem.data = parse(`rgb(${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).toFixed(1)})`, { context: "value" });
19595
+ 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);
19455
19596
  return;
19456
19597
  }
19457
19598
  if (hex.length === 5) {
19458
- hashParentListItem.data = parse(`rgb(${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).toFixed(1)})`, { context: "value" });
19599
+ 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);
19459
19600
  return;
19460
19601
  }
19461
19602
  if (hex.length === 6) {
19462
- hashParentListItem.data = parse(`rgb(${Number.parseInt(hex.slice(0, 2), 16)},${Number.parseInt(hex.slice(2, 4), 16)},${Number.parseInt(hex.slice(4, 6), 16)})`, { context: "value" });
19603
+ hashParentListItem.data = rgbNode(Number.parseInt(hex.slice(0, 2), 16), Number.parseInt(hex.slice(2, 4), 16), Number.parseInt(hex.slice(4, 6), 16));
19463
19604
  return;
19464
19605
  }
19465
19606
  if (hex.length === 7) {
19466
- hashParentListItem.data = parse(`rgb(${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).toFixed(1)})`, { context: "value" });
19607
+ 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);
19467
19608
  return;
19468
19609
  }
19469
- hashParentListItem.data = parse(`rgb(${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).toFixed(1)})`, { context: "value" });
19610
+ 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);
19470
19611
  }
19471
19612
  });
19472
19613
  walk(declaration, {
19473
19614
  visit: "Function",
19474
19615
  enter(func, parentListItem) {
19475
19616
  if (func.name === "color-mix") {
19476
- const originalColor = find(func, (node) => node.type === "Function" && node.name === "rgb");
19477
- const percentage$1 = find(func, (node) => node.type === "Percentage");
19478
- if (func.children.last?.type === "Identifier" && func.children.last.name === "transparent" && originalColor && percentage$1) {
19479
- const alpha = Number.parseFloat(percentage$1.value) / 100;
19480
- originalColor.children.appendData({
19617
+ const children = func.children.toArray();
19618
+ const color = children[3];
19619
+ const opacity = children[4];
19620
+ if (func.children.last?.type === "Identifier" && func.children.last.name === "transparent" && color?.type === "Function" && color?.name === "rgb" && opacity) {
19621
+ color.children.appendData({
19481
19622
  type: "Operator",
19482
19623
  value: ","
19483
19624
  });
19484
- originalColor.children.appendData({
19485
- type: "Number",
19486
- value: alpha.toString()
19487
- });
19488
- parentListItem.data = originalColor;
19625
+ color.children.appendData(opacity);
19626
+ parentListItem.data = color;
19489
19627
  }
19490
19628
  }
19491
19629
  }
@@ -19510,6 +19648,29 @@ function sanitizeDeclarations(nodeContainingDeclarations) {
19510
19648
  });
19511
19649
  }
19512
19650
 
19651
+ //#endregion
19652
+ //#region src/sanitize-stylesheet.ts
19653
+ function sanitizeStyleSheet(styleSheet) {
19654
+ resolveAllCssVariables(styleSheet);
19655
+ resolveCalcExpressions(styleSheet);
19656
+ sanitizeDeclarations(styleSheet);
19657
+ }
19658
+
19659
+ //#endregion
19660
+ //#region src/hooks/use-suspended-promise.ts
19661
+ const promiseStates = /* @__PURE__ */ new Map();
19662
+ function useSuspensedPromise(promiseFn, key) {
19663
+ const previousState = promiseStates.get(key);
19664
+ if (previousState) {
19665
+ if ("error" in previousState) throw previousState.error;
19666
+ if ("result" in previousState) return previousState.result;
19667
+ throw previousState.promise;
19668
+ }
19669
+ const state = { promise: promiseFn().then((result) => state.result = result).catch((error) => state.error = error) };
19670
+ promiseStates.set(key, state);
19671
+ throw state.promise;
19672
+ }
19673
+
19513
19674
  //#endregion
19514
19675
  //#region src/utils/compatibility/sanitize-class-name.ts
19515
19676
  const digitToNameMap = {
@@ -19568,8 +19729,21 @@ function sanitizeNonInlinableRules(node) {
19568
19729
 
19569
19730
  //#endregion
19570
19731
  //#region src/utils/react/is-component.ts
19732
+ const componentsToTreatAsElements = [
19733
+ __react_email_body.Body,
19734
+ __react_email_button.Button,
19735
+ __react_email_code_block.CodeBlock,
19736
+ __react_email_code_inline.CodeInline,
19737
+ __react_email_container.Container,
19738
+ __react_email_heading.Heading,
19739
+ __react_email_hr.Hr,
19740
+ __react_email_img.Img,
19741
+ __react_email_link.Link,
19742
+ __react_email_preview.Preview,
19743
+ __react_email_text.Text
19744
+ ];
19571
19745
  const isComponent = (element) => {
19572
- return (typeof element.type === "function" || element.type.render !== void 0) && element.type.tailwindTreatAsElement !== true;
19746
+ return (typeof element.type === "function" || element.type.render !== void 0) && !componentsToTreatAsElements.includes(element.type);
19573
19747
  };
19574
19748
 
19575
19749
  //#endregion
@@ -19600,66 +19774,9 @@ function mapReactTree(value, process) {
19600
19774
  return mapped && mapped.length === 1 ? mapped[0] : mapped;
19601
19775
  }
19602
19776
 
19603
- //#endregion
19604
- //#region src/utils/text/from-dash-case-to-camel-case.ts
19605
- const fromDashCaseToCamelCase = (text) => {
19606
- return text.replace(/-(\w|$)/g, (_, p1) => p1.toUpperCase());
19607
- };
19608
-
19609
- //#endregion
19610
- //#region src/utils/compatibility/get-react-property.ts
19611
- function getReactProperty(prop) {
19612
- const modifiedProp = prop.toLowerCase();
19613
- if (modifiedProp.startsWith("--")) return modifiedProp;
19614
- if (modifiedProp.startsWith("-ms-")) return fromDashCaseToCamelCase(modifiedProp.slice(1));
19615
- return fromDashCaseToCamelCase(modifiedProp);
19616
- }
19617
-
19618
- //#endregion
19619
- //#region src/utils/css/make-inline-styles-for.ts
19620
- function makeInlineStylesFor(inlinableRules) {
19621
- const styles = {};
19622
- const localVariableDeclarations = /* @__PURE__ */ new Set();
19623
- for (const rule of inlinableRules) walk(rule, {
19624
- visit: "Declaration",
19625
- enter(declaration) {
19626
- if (declaration.property.startsWith("--")) localVariableDeclarations.add(declaration);
19627
- }
19628
- });
19629
- for (const rule of inlinableRules) {
19630
- walk(rule, {
19631
- visit: "Function",
19632
- enter(func, funcParentListItem) {
19633
- if (func.name === "var") {
19634
- let variableName;
19635
- walk(func, {
19636
- visit: "Identifier",
19637
- enter(identifier) {
19638
- variableName = identifier.name;
19639
- return this.break;
19640
- }
19641
- });
19642
- if (variableName) {
19643
- const definition = Array.from(localVariableDeclarations).find((declaration) => variableName === declaration.property);
19644
- if (definition) funcParentListItem.data = definition.value;
19645
- }
19646
- }
19647
- }
19648
- });
19649
- walk(rule, {
19650
- visit: "Declaration",
19651
- enter(declaration) {
19652
- if (declaration.property.startsWith("--")) return;
19653
- styles[getReactProperty(declaration.property)] = generate(declaration.value) + (declaration.important ? "!important" : "");
19654
- }
19655
- });
19656
- }
19657
- return styles;
19658
- }
19659
-
19660
19777
  //#endregion
19661
19778
  //#region src/utils/tailwindcss/clone-element-with-inlined-styles.ts
19662
- function cloneElementWithInlinedStyles(element, inlinableRules, nonInlinableRules) {
19779
+ function cloneElementWithInlinedStyles(element, inlinableRules, nonInlinableRules, customProperties) {
19663
19780
  const propsToOverwrite = {};
19664
19781
  if (element.props.className && !isComponent(element)) {
19665
19782
  const classes = element.props.className.trim().split(/\s+/);
@@ -19671,7 +19788,7 @@ function cloneElementWithInlinedStyles(element, inlinableRules, nonInlinableRule
19671
19788
  else residualClasses.push(className);
19672
19789
  }
19673
19790
  propsToOverwrite.style = {
19674
- ...makeInlineStylesFor(rules),
19791
+ ...makeInlineStylesFor(rules, customProperties),
19675
19792
  ...element.props.style
19676
19793
  };
19677
19794
  if (residualClasses.length > 0) propsToOverwrite.className = residualClasses.map((className) => {
@@ -21574,7 +21691,7 @@ const pixelBasedPreset = { theme: { extend: {
21574
21691
  }
21575
21692
  } } };
21576
21693
  function Tailwind({ children, config }) {
21577
- const tailwindSetup = useSuspensedPromise(() => setupTailwind(config ?? {}), JSON.stringify(config));
21694
+ const tailwindSetup = useSuspensedPromise(() => setupTailwind(config ?? {}), JSON.stringify(config, (_key, value) => typeof value === "function" ? value.toString() : value));
21578
21695
  let classesUsed = [];
21579
21696
  let mappedChildren = mapReactTree(children, (node) => {
21580
21697
  if (react.isValidElement(node)) {
@@ -21587,20 +21704,19 @@ function Tailwind({ children, config }) {
21587
21704
  return node;
21588
21705
  });
21589
21706
  const styleSheet = tailwindSetup.getStyleSheet();
21590
- resolveAllCssVariables(styleSheet);
21591
- resolveCalcExpressions(styleSheet);
21592
- sanitizeDeclarations(styleSheet);
21707
+ sanitizeStyleSheet(styleSheet);
21593
21708
  const { inlinable: inlinableRules, nonInlinable: nonInlinableRules } = extractRulesPerClass(styleSheet, classesUsed);
21594
- sanitizeNonInlinableRules(styleSheet);
21709
+ const customProperties = getCustomProperties(styleSheet);
21595
21710
  const nonInlineStyles = {
21596
21711
  type: "StyleSheet",
21597
- children: new List().fromArray(nonInlinableRules.values().toArray())
21712
+ children: new List().fromArray(Array.from(nonInlinableRules.values()))
21598
21713
  };
21714
+ sanitizeNonInlinableRules(nonInlineStyles);
21599
21715
  const hasNonInlineStylesToApply = nonInlinableRules.size > 0;
21600
21716
  let appliedNonInlineStyles = false;
21601
21717
  mappedChildren = mapReactTree(mappedChildren, (node) => {
21602
21718
  if (react.isValidElement(node)) {
21603
- const elementWithInlinedStyles = cloneElementWithInlinedStyles(node, inlinableRules, nonInlinableRules);
21719
+ const elementWithInlinedStyles = cloneElementWithInlinedStyles(node, inlinableRules, nonInlinableRules, customProperties);
21604
21720
  if (elementWithInlinedStyles.type === "head") {
21605
21721
  appliedNonInlineStyles = true;
21606
21722
  const styleElement = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("style", { children: generate(nonInlineStyles) });
@@ -21610,7 +21726,7 @@ function Tailwind({ children, config }) {
21610
21726
  }
21611
21727
  return node;
21612
21728
  });
21613
- if (hasNonInlineStylesToApply && !appliedNonInlineStyles) throw new Error(`You are trying to use the following Tailwind classes that cannot be inlined: ${nonInlinableRules.keys().toArray().join(" ")}.
21729
+ if (hasNonInlineStylesToApply && !appliedNonInlineStyles) throw new Error(`You are trying to use the following Tailwind classes that cannot be inlined: ${Array.from(nonInlinableRules.keys()).join(" ")}.
21614
21730
  For the media queries to work properly on rendering, they need to be added into a <style> tag inside of a <head> tag,
21615
21731
  the Tailwind component tried finding a <head> element but just wasn't able to find it.
21616
21732
 
@@ -21624,4 +21740,7 @@ please file a bug https://github.com/resend/react-email/issues/new?assignees=&la
21624
21740
 
21625
21741
  //#endregion
21626
21742
  exports.Tailwind = Tailwind;
21627
- exports.pixelBasedPreset = pixelBasedPreset;
21743
+ exports.inlineStyles = inlineStyles;
21744
+ exports.pixelBasedPreset = pixelBasedPreset;
21745
+ exports.sanitizeStyleSheet = sanitizeStyleSheet;
21746
+ exports.setupTailwind = setupTailwind;