@react-email/tailwind 2.0.0-tailwindv4.1 → 2.0.0-tailwindv4.3
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 +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +100 -76
- package/dist/index.mjs +100 -76
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
package/dist/index.mjs
CHANGED
|
@@ -1077,9 +1077,7 @@ function sourceFragment({ source, line, column, baseLine, baseColumn }, extraLin
|
|
|
1077
1077
|
function processLines(start, end) {
|
|
1078
1078
|
return lines.slice(start, end).map((line$1, idx) => String(start + idx + 1).padStart(maxNumLength) + " |" + line$1).join("\n");
|
|
1079
1079
|
}
|
|
1080
|
-
const
|
|
1081
|
-
const precolumns = " ".repeat(Math.max(baseColumn - 1, 0));
|
|
1082
|
-
const lines = (prelines + precolumns + source).split(/\r\n?|\n|\f/);
|
|
1080
|
+
const lines = ("\n".repeat(Math.max(baseLine - 1, 0)) + " ".repeat(Math.max(baseColumn - 1, 0)) + source).split(/\r\n?|\n|\f/);
|
|
1083
1081
|
const startLine = Math.max(1, line - extraLines) - 1;
|
|
1084
1082
|
const endLine = Math.min(line + extraLines, lines.length + 1);
|
|
1085
1083
|
const maxNumLength = Math.max(4, String(endLine).length) + 1;
|
|
@@ -1362,8 +1360,7 @@ function createParser(config) {
|
|
|
1362
1360
|
if (typeof onComment === "function") parser.forEachToken((type, start, end) => {
|
|
1363
1361
|
if (type === Comment) {
|
|
1364
1362
|
const loc = parser.getLocation(start, end);
|
|
1365
|
-
|
|
1366
|
-
onComment(value, loc);
|
|
1363
|
+
onComment(cmpStr(source, end - 2, end, "*/") ? source.slice(start + 2, end - 2) : source.slice(start + 2, end), loc);
|
|
1367
1364
|
}
|
|
1368
1365
|
});
|
|
1369
1366
|
const ast = parser.context[context].call(parser, options);
|
|
@@ -4798,8 +4795,7 @@ function processStructure(name$49, nodeType) {
|
|
|
4798
4795
|
const docs = { type: "\"" + name$49 + "\"" };
|
|
4799
4796
|
for (const key in structure$49) {
|
|
4800
4797
|
if (hasOwnProperty$1.call(structure$49, key) === false) continue;
|
|
4801
|
-
|
|
4802
|
-
docs[key] = genTypesList(fieldTypes, name$49 + "." + key);
|
|
4798
|
+
docs[key] = genTypesList(fields[key] = Array.isArray(structure$49[key]) ? structure$49[key].slice() : [structure$49[key]], name$49 + "." + key);
|
|
4803
4799
|
}
|
|
4804
4800
|
return {
|
|
4805
4801
|
docs,
|
|
@@ -19088,9 +19084,7 @@ function populateParentsForNodeTree(node) {
|
|
|
19088
19084
|
//#endregion
|
|
19089
19085
|
//#region src/utils/css/resolve-all-css-variables.ts
|
|
19090
19086
|
function doSelectorsIntersect(first, second) {
|
|
19091
|
-
|
|
19092
|
-
const secondStringified = generate(second);
|
|
19093
|
-
if (firstStringified === secondStringified) return true;
|
|
19087
|
+
if (generate(first) === generate(second)) return true;
|
|
19094
19088
|
let hasSomeUniversal = false;
|
|
19095
19089
|
const walker = (node) => {
|
|
19096
19090
|
if (hasSomeUniversal) return;
|
|
@@ -19102,12 +19096,6 @@ function doSelectorsIntersect(first, second) {
|
|
|
19102
19096
|
if (hasSomeUniversal) return true;
|
|
19103
19097
|
return false;
|
|
19104
19098
|
}
|
|
19105
|
-
function removeAndRepeatIfEmptyRecursively(node) {
|
|
19106
|
-
if (node.parent) if (node.containedIn && node.containingItem) {
|
|
19107
|
-
node.containedIn.remove(node.containingItem);
|
|
19108
|
-
if (node.containedIn.isEmpty) removeAndRepeatIfEmptyRecursively(node.parent);
|
|
19109
|
-
} else removeAndRepeatIfEmptyRecursively(node.parent);
|
|
19110
|
-
}
|
|
19111
19099
|
function someParent(node, predicate) {
|
|
19112
19100
|
if (node.parent) {
|
|
19113
19101
|
if (predicate(node.parent)) return true;
|
|
@@ -19125,11 +19113,8 @@ function resolveAllCssVariables(node) {
|
|
|
19125
19113
|
if (someParent(declaration, (ancestor) => ancestor.type === "Atrule" && ancestor.name === "layer" && ancestor.prelude !== null && generate(ancestor.prelude).includes("properties"))) return;
|
|
19126
19114
|
if (/--[\S]+/.test(declaration.property)) variableDefinitions.add({
|
|
19127
19115
|
declaration,
|
|
19128
|
-
variableName:
|
|
19129
|
-
definition: generate(declaration.value)
|
|
19130
|
-
remove() {
|
|
19131
|
-
removeAndRepeatIfEmptyRecursively(declaration);
|
|
19132
|
-
}
|
|
19116
|
+
variableName: declaration.property,
|
|
19117
|
+
definition: generate(declaration.value)
|
|
19133
19118
|
});
|
|
19134
19119
|
else {
|
|
19135
19120
|
function parseVariableUsesFrom(node$1) {
|
|
@@ -19146,10 +19131,7 @@ function resolveAllCssVariables(node) {
|
|
|
19146
19131
|
variableName: name$49,
|
|
19147
19132
|
raw: generate(funcNode)
|
|
19148
19133
|
});
|
|
19149
|
-
if (fallback?.includes("var(")) {
|
|
19150
|
-
const parsedFallback = parse(fallback, { context: "value" });
|
|
19151
|
-
parseVariableUsesFrom(parsedFallback);
|
|
19152
|
-
}
|
|
19134
|
+
if (fallback?.includes("var(")) parseVariableUsesFrom(parse(fallback, { context: "value" }));
|
|
19153
19135
|
}
|
|
19154
19136
|
}
|
|
19155
19137
|
});
|
|
@@ -19175,7 +19157,6 @@ function resolveAllCssVariables(node) {
|
|
|
19175
19157
|
}
|
|
19176
19158
|
if (!hasReplaced && use.fallback) use.declaration.value = parse(generate(use.declaration.value).replaceAll(use.raw, use.fallback), { context: "value" });
|
|
19177
19159
|
}
|
|
19178
|
-
for (const definition of variableDefinitions) definition.remove();
|
|
19179
19160
|
}
|
|
19180
19161
|
|
|
19181
19162
|
//#endregion
|
|
@@ -19191,7 +19172,7 @@ function resolveCalcExpressions(node) {
|
|
|
19191
19172
|
func.children.forEach((child, item) => {
|
|
19192
19173
|
const left = item.prev;
|
|
19193
19174
|
const right = item.next;
|
|
19194
|
-
if (left && right && child.type === "Operator" && (left.data.type === "Dimension" || left.data.type === "Number") && (right.data.type === "Dimension" || right.data.type === "Number")) {
|
|
19175
|
+
if (left && right && child.type === "Operator" && (left.data.type === "Dimension" || left.data.type === "Number" || left.data.type === "Percentage") && (right.data.type === "Dimension" || right.data.type === "Number" || right.data.type === "Percentage")) {
|
|
19195
19176
|
if (child.value === "*" || child.value === "/") {
|
|
19196
19177
|
const value = (() => {
|
|
19197
19178
|
if (child.value === "*") return String(Number.parseFloat(left.data.value) * Number.parseFloat(right.data.value));
|
|
@@ -19233,6 +19214,31 @@ function resolveCalcExpressions(node) {
|
|
|
19233
19214
|
};
|
|
19234
19215
|
func.children.remove(left);
|
|
19235
19216
|
func.children.remove(right);
|
|
19217
|
+
} else if (left.data.type === "Percentage" && right.data.type === "Number") {
|
|
19218
|
+
item.data = {
|
|
19219
|
+
type: "Percentage",
|
|
19220
|
+
value
|
|
19221
|
+
};
|
|
19222
|
+
func.children.remove(left);
|
|
19223
|
+
func.children.remove(right);
|
|
19224
|
+
} else if (left.data.type === "Number" && right.data.type === "Percentage") {
|
|
19225
|
+
item.data = {
|
|
19226
|
+
type: "Percentage",
|
|
19227
|
+
value
|
|
19228
|
+
};
|
|
19229
|
+
func.children.remove(left);
|
|
19230
|
+
func.children.remove(right);
|
|
19231
|
+
} else if (left.data.type === "Percentage" && right.data.type === "Percentage") {
|
|
19232
|
+
if (child.value === "/") item.data = {
|
|
19233
|
+
type: "Number",
|
|
19234
|
+
value
|
|
19235
|
+
};
|
|
19236
|
+
else item.data = {
|
|
19237
|
+
type: "Percentage",
|
|
19238
|
+
value
|
|
19239
|
+
};
|
|
19240
|
+
func.children.remove(left);
|
|
19241
|
+
func.children.remove(right);
|
|
19236
19242
|
}
|
|
19237
19243
|
}
|
|
19238
19244
|
}
|
|
@@ -19276,10 +19282,6 @@ function lrgbToRgb(input) {
|
|
|
19276
19282
|
function clamp(value, min, max) {
|
|
19277
19283
|
return Math.min(Math.max(value, min), max);
|
|
19278
19284
|
}
|
|
19279
|
-
function round(value, digits = 1) {
|
|
19280
|
-
const factor = 10 ** digits;
|
|
19281
|
-
return Math.round(value * factor) / factor;
|
|
19282
|
-
}
|
|
19283
19285
|
function oklchToOklab(oklch) {
|
|
19284
19286
|
return {
|
|
19285
19287
|
l: oklch.l,
|
|
@@ -19297,9 +19299,9 @@ function oklchToRgb(oklch) {
|
|
|
19297
19299
|
const g = 255 * lrgbToRgb(LSM_TO_RGB.g[0] * l + LSM_TO_RGB.g[1] * m + LSM_TO_RGB.g[2] * s);
|
|
19298
19300
|
const b = 255 * lrgbToRgb(LSM_TO_RGB.b[0] * l + LSM_TO_RGB.b[1] * m + LSM_TO_RGB.b[2] * s);
|
|
19299
19301
|
return {
|
|
19300
|
-
r:
|
|
19301
|
-
g:
|
|
19302
|
-
b:
|
|
19302
|
+
r: clamp(r, 0, 255).toFixed(0),
|
|
19303
|
+
g: clamp(g, 0, 255).toFixed(0),
|
|
19304
|
+
b: clamp(b, 0, 255).toFixed(0)
|
|
19303
19305
|
};
|
|
19304
19306
|
}
|
|
19305
19307
|
function separteShorthandDeclaration(shorthandToReplace, [start, end]) {
|
|
@@ -19443,48 +19445,47 @@ function sanitizeDeclarations(nodeContainingDeclarations) {
|
|
|
19443
19445
|
enter(hash, hashParentListItem) {
|
|
19444
19446
|
const hex = hash.value.trim();
|
|
19445
19447
|
if (hex.length === 3) {
|
|
19446
|
-
|
|
19447
|
-
const g$1 = Number.parseInt(hex.charAt(1) + hex.charAt(1), 16);
|
|
19448
|
-
const b$1 = Number.parseInt(hex.charAt(2) + hex.charAt(2), 16);
|
|
19449
|
-
hashParentListItem.data = parse(`rgb(${r$1},${g$1},${b$1})`, { context: "value" });
|
|
19448
|
+
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" });
|
|
19450
19449
|
return;
|
|
19451
19450
|
}
|
|
19452
19451
|
if (hex.length === 4) {
|
|
19453
|
-
|
|
19454
|
-
const g$1 = Number.parseInt(hex.charAt(1) + hex.charAt(1), 16);
|
|
19455
|
-
const b$1 = Number.parseInt(hex.charAt(2) + hex.charAt(2), 16);
|
|
19456
|
-
const a$1 = Number.parseInt(hex.charAt(3) + hex.charAt(3), 16) / 255;
|
|
19457
|
-
hashParentListItem.data = parse(`rgb(${r$1},${g$1},${b$1},${a$1.toFixed(1)})`, { context: "value" });
|
|
19452
|
+
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" });
|
|
19458
19453
|
return;
|
|
19459
19454
|
}
|
|
19460
19455
|
if (hex.length === 5) {
|
|
19461
|
-
|
|
19462
|
-
const g$1 = Number.parseInt(hex.charAt(2) + hex.charAt(2), 16);
|
|
19463
|
-
const b$1 = Number.parseInt(hex.charAt(3) + hex.charAt(3), 16);
|
|
19464
|
-
const a$1 = Number.parseInt(hex.charAt(4) + hex.charAt(4), 16) / 255;
|
|
19465
|
-
hashParentListItem.data = parse(`rgb(${r$1},${g$1},${b$1},${a$1.toFixed(1)})`, { context: "value" });
|
|
19456
|
+
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" });
|
|
19466
19457
|
return;
|
|
19467
19458
|
}
|
|
19468
19459
|
if (hex.length === 6) {
|
|
19469
|
-
|
|
19470
|
-
const g$1 = Number.parseInt(hex.slice(2, 4), 16);
|
|
19471
|
-
const b$1 = Number.parseInt(hex.slice(4, 6), 16);
|
|
19472
|
-
hashParentListItem.data = parse(`rgb(${r$1},${g$1},${b$1})`, { context: "value" });
|
|
19460
|
+
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" });
|
|
19473
19461
|
return;
|
|
19474
19462
|
}
|
|
19475
19463
|
if (hex.length === 7) {
|
|
19476
|
-
|
|
19477
|
-
const g$1 = Number.parseInt(hex.slice(2, 4), 16);
|
|
19478
|
-
const b$1 = Number.parseInt(hex.slice(4, 6), 16);
|
|
19479
|
-
const a$1 = Number.parseInt(hex.charAt(6) + hex.charAt(6), 16) / 255;
|
|
19480
|
-
hashParentListItem.data = parse(`rgb(${r$1},${g$1},${b$1},${a$1.toFixed(1)})`, { context: "value" });
|
|
19464
|
+
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" });
|
|
19481
19465
|
return;
|
|
19482
19466
|
}
|
|
19483
|
-
|
|
19484
|
-
|
|
19485
|
-
|
|
19486
|
-
|
|
19487
|
-
|
|
19467
|
+
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" });
|
|
19468
|
+
}
|
|
19469
|
+
});
|
|
19470
|
+
walk(declaration, {
|
|
19471
|
+
visit: "Function",
|
|
19472
|
+
enter(func, parentListItem) {
|
|
19473
|
+
if (func.name === "color-mix") {
|
|
19474
|
+
const originalColor = find(func, (node) => node.type === "Function" && node.name === "rgb");
|
|
19475
|
+
const percentage$1 = find(func, (node) => node.type === "Percentage");
|
|
19476
|
+
if (func.children.last?.type === "Identifier" && func.children.last.name === "transparent" && originalColor && percentage$1) {
|
|
19477
|
+
const alpha = Number.parseFloat(percentage$1.value) / 100;
|
|
19478
|
+
originalColor.children.appendData({
|
|
19479
|
+
type: "Operator",
|
|
19480
|
+
value: ","
|
|
19481
|
+
});
|
|
19482
|
+
originalColor.children.appendData({
|
|
19483
|
+
type: "Number",
|
|
19484
|
+
value: alpha.toString()
|
|
19485
|
+
});
|
|
19486
|
+
parentListItem.data = originalColor;
|
|
19487
|
+
}
|
|
19488
|
+
}
|
|
19488
19489
|
}
|
|
19489
19490
|
});
|
|
19490
19491
|
if (declaration.property === "padding-inline") {
|
|
@@ -19550,10 +19551,7 @@ function sanitizeNonInlinableRules(node) {
|
|
|
19550
19551
|
enter(rule) {
|
|
19551
19552
|
if (!isRuleInlinable(rule)) {
|
|
19552
19553
|
walk(rule.prelude, (node$1) => {
|
|
19553
|
-
if (node$1.type === "ClassSelector")
|
|
19554
|
-
const unescapedClassName = decode$1(node$1.name);
|
|
19555
|
-
node$1.name = sanitizeClassName(unescapedClassName);
|
|
19556
|
-
}
|
|
19554
|
+
if (node$1.type === "ClassSelector") node$1.name = sanitizeClassName(decode$1(node$1.name));
|
|
19557
19555
|
});
|
|
19558
19556
|
walk(rule, {
|
|
19559
19557
|
visit: "Declaration",
|
|
@@ -19592,10 +19590,7 @@ function mapReactTree(value, process) {
|
|
|
19592
19590
|
const newProps = { ...node.props };
|
|
19593
19591
|
if (node.props.children && !isComponent(node)) newProps.children = mapReactTree(node.props.children, process);
|
|
19594
19592
|
const processed = process(React.cloneElement(node, newProps, newProps.children));
|
|
19595
|
-
if (React.isValidElement(processed) && isComponent(processed))
|
|
19596
|
-
const rendered = (typeof processed.type === "object" ? processed.type.render : processed.type)(processed.props);
|
|
19597
|
-
return mapReactTree(rendered, process);
|
|
19598
|
-
}
|
|
19593
|
+
if (React.isValidElement(processed) && isComponent(processed)) return mapReactTree((typeof processed.type === "object" ? processed.type.render : processed.type)(processed.props), process);
|
|
19599
19594
|
return processed;
|
|
19600
19595
|
}
|
|
19601
19596
|
return process(node);
|
|
@@ -19610,8 +19605,8 @@ const fromDashCaseToCamelCase = (text) => {
|
|
|
19610
19605
|
};
|
|
19611
19606
|
|
|
19612
19607
|
//#endregion
|
|
19613
|
-
//#region src/utils/compatibility/
|
|
19614
|
-
function
|
|
19608
|
+
//#region src/utils/compatibility/get-react-property.ts
|
|
19609
|
+
function getReactProperty(prop) {
|
|
19615
19610
|
const modifiedProp = prop.toLowerCase();
|
|
19616
19611
|
if (modifiedProp.startsWith("--")) return modifiedProp;
|
|
19617
19612
|
if (modifiedProp.startsWith("-ms-")) return fromDashCaseToCamelCase(modifiedProp.slice(1));
|
|
@@ -19622,12 +19617,41 @@ function convertCssPropertyToReactProperty(prop) {
|
|
|
19622
19617
|
//#region src/utils/css/make-inline-styles-for.ts
|
|
19623
19618
|
function makeInlineStylesFor(inlinableRules) {
|
|
19624
19619
|
const styles = {};
|
|
19620
|
+
const localVariableDeclarations = /* @__PURE__ */ new Set();
|
|
19625
19621
|
for (const rule of inlinableRules) walk(rule, {
|
|
19626
19622
|
visit: "Declaration",
|
|
19627
19623
|
enter(declaration) {
|
|
19628
|
-
|
|
19624
|
+
if (declaration.property.startsWith("--")) localVariableDeclarations.add(declaration);
|
|
19629
19625
|
}
|
|
19630
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
|
+
}
|
|
19631
19655
|
return styles;
|
|
19632
19656
|
}
|
|
19633
19657
|
|
|
@@ -21455,7 +21479,7 @@ async function setupTailwind(config) {
|
|
|
21455
21479
|
};
|
|
21456
21480
|
throw new Error(`NO-OP: should we implement support for ${resourceHint}?`);
|
|
21457
21481
|
},
|
|
21458
|
-
polyfills:
|
|
21482
|
+
polyfills: 0,
|
|
21459
21483
|
async loadStylesheet(id, base) {
|
|
21460
21484
|
if (id === "tailwindcss") return {
|
|
21461
21485
|
base,
|
|
@@ -21493,7 +21517,7 @@ async function setupTailwind(config) {
|
|
|
21493
21517
|
|
|
21494
21518
|
//#endregion
|
|
21495
21519
|
//#region src/tailwind.tsx
|
|
21496
|
-
const pixelBasedPreset = { theme: {
|
|
21520
|
+
const pixelBasedPreset = { theme: { extend: {
|
|
21497
21521
|
fontSize: {
|
|
21498
21522
|
xs: ["12px", { lineHeight: "16px" }],
|
|
21499
21523
|
sm: ["14px", { lineHeight: "20px" }],
|
|
@@ -21546,7 +21570,7 @@ const pixelBasedPreset = { theme: {
|
|
|
21546
21570
|
80: "320px",
|
|
21547
21571
|
96: "384px"
|
|
21548
21572
|
}
|
|
21549
|
-
} };
|
|
21573
|
+
} } };
|
|
21550
21574
|
function Tailwind({ children, config }) {
|
|
21551
21575
|
const tailwindSetup = useSuspensedPromise(() => setupTailwind(config ?? {}), JSON.stringify(config));
|
|
21552
21576
|
let classesUsed = [];
|