@react-email/tailwind 2.0.4 → 2.0.5
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 +71 -2
- package/dist/index.mjs +71 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -19034,6 +19034,21 @@ const { version } = {
|
|
|
19034
19034
|
]
|
|
19035
19035
|
};
|
|
19036
19036
|
|
|
19037
|
+
//#endregion
|
|
19038
|
+
//#region ../../node_modules/.pnpm/css-tree@3.1.0/node_modules/css-tree/lib/utils/clone.js
|
|
19039
|
+
function clone(node) {
|
|
19040
|
+
const result = {};
|
|
19041
|
+
for (const key of Object.keys(node)) {
|
|
19042
|
+
let value = node[key];
|
|
19043
|
+
if (value) {
|
|
19044
|
+
if (Array.isArray(value) || value instanceof List) value = value.map(clone);
|
|
19045
|
+
else if (value.constructor === Object) value = clone(value);
|
|
19046
|
+
}
|
|
19047
|
+
result[key] = value;
|
|
19048
|
+
}
|
|
19049
|
+
return result;
|
|
19050
|
+
}
|
|
19051
|
+
|
|
19037
19052
|
//#endregion
|
|
19038
19053
|
//#region ../../node_modules/.pnpm/css-tree@3.1.0/node_modules/css-tree/lib/index.js
|
|
19039
19054
|
const { tokenize, parse, generate, lexer, createLexer, walk, find, findLast, findAll, toPlainObject, fromPlainObject, fork } = syntax_default;
|
|
@@ -19046,6 +19061,52 @@ function isRuleInlinable(rule) {
|
|
|
19046
19061
|
return !hasAtRuleInside && !hasPseudoSelector;
|
|
19047
19062
|
}
|
|
19048
19063
|
|
|
19064
|
+
//#endregion
|
|
19065
|
+
//#region src/utils/css/is-part-inlinable.ts
|
|
19066
|
+
function isPartInlinable(part) {
|
|
19067
|
+
const hasAtRuleInside = find(part, (node) => node.type === "Atrule") !== null;
|
|
19068
|
+
const hasPseudoSelector = find(part, (node) => node.type === "PseudoClassSelector" || node.type === "PseudoElementSelector") !== null;
|
|
19069
|
+
return !hasAtRuleInside && !hasPseudoSelector;
|
|
19070
|
+
}
|
|
19071
|
+
|
|
19072
|
+
//#endregion
|
|
19073
|
+
//#region src/utils/css/split-mixed-rule.ts
|
|
19074
|
+
/**
|
|
19075
|
+
* Split a rule into inlinable and non-inlinable parts. Caller must only pass rules
|
|
19076
|
+
* for which isRuleInlinable(rule) is false. Returns clones so the original stylesheet is never mutated.
|
|
19077
|
+
*
|
|
19078
|
+
* @returns inlinablePart: rule with only inlinable block children, or null if none.
|
|
19079
|
+
* nonInlinablePart: rule with only non-inlinable block children, or null if none.
|
|
19080
|
+
*/
|
|
19081
|
+
function splitMixedRule(rule) {
|
|
19082
|
+
if (rule.prelude !== null && find(rule.prelude, (node) => node.type === "PseudoClassSelector" || node.type === "PseudoElementSelector") !== null) return {
|
|
19083
|
+
inlinablePart: null,
|
|
19084
|
+
nonInlinablePart: clone(rule)
|
|
19085
|
+
};
|
|
19086
|
+
const ruleCloneInlinable = clone(rule);
|
|
19087
|
+
const ruleCloneNonInlinable = clone(rule);
|
|
19088
|
+
const inlinableParts = [];
|
|
19089
|
+
const nonInlinableParts = [];
|
|
19090
|
+
for (const part of ruleCloneInlinable.block.children.toArray()) if (isPartInlinable(part)) inlinableParts.push(part);
|
|
19091
|
+
else nonInlinableParts.push(part);
|
|
19092
|
+
return {
|
|
19093
|
+
inlinablePart: inlinableParts.length > 0 ? {
|
|
19094
|
+
...ruleCloneInlinable,
|
|
19095
|
+
block: {
|
|
19096
|
+
type: "Block",
|
|
19097
|
+
children: new List().fromArray(inlinableParts)
|
|
19098
|
+
}
|
|
19099
|
+
} : null,
|
|
19100
|
+
nonInlinablePart: nonInlinableParts.length > 0 ? {
|
|
19101
|
+
...ruleCloneNonInlinable,
|
|
19102
|
+
block: {
|
|
19103
|
+
type: "Block",
|
|
19104
|
+
children: new List().fromArray(nonInlinableParts)
|
|
19105
|
+
}
|
|
19106
|
+
} : null
|
|
19107
|
+
};
|
|
19108
|
+
}
|
|
19109
|
+
|
|
19049
19110
|
//#endregion
|
|
19050
19111
|
//#region src/utils/css/extract-rules-per-class.ts
|
|
19051
19112
|
function extractRulesPerClass(root, classes) {
|
|
@@ -19064,7 +19125,14 @@ function extractRulesPerClass(root, classes) {
|
|
|
19064
19125
|
});
|
|
19065
19126
|
if (isRuleInlinable(rule)) {
|
|
19066
19127
|
for (const className of selectorClasses) if (classSet.has(className)) inlinableRules.set(className, rule);
|
|
19067
|
-
} else
|
|
19128
|
+
} else {
|
|
19129
|
+
const { inlinablePart, nonInlinablePart } = splitMixedRule(rule);
|
|
19130
|
+
for (const className of selectorClasses) {
|
|
19131
|
+
if (!classSet.has(className)) continue;
|
|
19132
|
+
if (inlinablePart) inlinableRules.set(className, inlinablePart);
|
|
19133
|
+
if (nonInlinablePart) nonInlinableRules.set(className, nonInlinablePart);
|
|
19134
|
+
}
|
|
19135
|
+
}
|
|
19068
19136
|
}
|
|
19069
19137
|
});
|
|
19070
19138
|
return {
|
|
@@ -19785,7 +19853,8 @@ function cloneElementWithInlinedStyles(element, inlinableRules, nonInlinableRule
|
|
|
19785
19853
|
for (const className of classes) {
|
|
19786
19854
|
const rule = inlinableRules.get(className);
|
|
19787
19855
|
if (rule) rules.push(rule);
|
|
19788
|
-
|
|
19856
|
+
if (nonInlinableRules.has(className)) residualClasses.push(className);
|
|
19857
|
+
else if (!rule) residualClasses.push(className);
|
|
19789
19858
|
}
|
|
19790
19859
|
propsToOverwrite.style = {
|
|
19791
19860
|
...makeInlineStylesFor(rules, customProperties),
|
package/dist/index.mjs
CHANGED
|
@@ -19021,6 +19021,21 @@ const { version } = {
|
|
|
19021
19021
|
]
|
|
19022
19022
|
};
|
|
19023
19023
|
|
|
19024
|
+
//#endregion
|
|
19025
|
+
//#region ../../node_modules/.pnpm/css-tree@3.1.0/node_modules/css-tree/lib/utils/clone.js
|
|
19026
|
+
function clone(node) {
|
|
19027
|
+
const result = {};
|
|
19028
|
+
for (const key of Object.keys(node)) {
|
|
19029
|
+
let value = node[key];
|
|
19030
|
+
if (value) {
|
|
19031
|
+
if (Array.isArray(value) || value instanceof List) value = value.map(clone);
|
|
19032
|
+
else if (value.constructor === Object) value = clone(value);
|
|
19033
|
+
}
|
|
19034
|
+
result[key] = value;
|
|
19035
|
+
}
|
|
19036
|
+
return result;
|
|
19037
|
+
}
|
|
19038
|
+
|
|
19024
19039
|
//#endregion
|
|
19025
19040
|
//#region ../../node_modules/.pnpm/css-tree@3.1.0/node_modules/css-tree/lib/index.js
|
|
19026
19041
|
const { tokenize, parse, generate, lexer, createLexer, walk, find, findLast, findAll, toPlainObject, fromPlainObject, fork } = syntax_default;
|
|
@@ -19033,6 +19048,52 @@ function isRuleInlinable(rule) {
|
|
|
19033
19048
|
return !hasAtRuleInside && !hasPseudoSelector;
|
|
19034
19049
|
}
|
|
19035
19050
|
|
|
19051
|
+
//#endregion
|
|
19052
|
+
//#region src/utils/css/is-part-inlinable.ts
|
|
19053
|
+
function isPartInlinable(part) {
|
|
19054
|
+
const hasAtRuleInside = find(part, (node) => node.type === "Atrule") !== null;
|
|
19055
|
+
const hasPseudoSelector = find(part, (node) => node.type === "PseudoClassSelector" || node.type === "PseudoElementSelector") !== null;
|
|
19056
|
+
return !hasAtRuleInside && !hasPseudoSelector;
|
|
19057
|
+
}
|
|
19058
|
+
|
|
19059
|
+
//#endregion
|
|
19060
|
+
//#region src/utils/css/split-mixed-rule.ts
|
|
19061
|
+
/**
|
|
19062
|
+
* Split a rule into inlinable and non-inlinable parts. Caller must only pass rules
|
|
19063
|
+
* for which isRuleInlinable(rule) is false. Returns clones so the original stylesheet is never mutated.
|
|
19064
|
+
*
|
|
19065
|
+
* @returns inlinablePart: rule with only inlinable block children, or null if none.
|
|
19066
|
+
* nonInlinablePart: rule with only non-inlinable block children, or null if none.
|
|
19067
|
+
*/
|
|
19068
|
+
function splitMixedRule(rule) {
|
|
19069
|
+
if (rule.prelude !== null && find(rule.prelude, (node) => node.type === "PseudoClassSelector" || node.type === "PseudoElementSelector") !== null) return {
|
|
19070
|
+
inlinablePart: null,
|
|
19071
|
+
nonInlinablePart: clone(rule)
|
|
19072
|
+
};
|
|
19073
|
+
const ruleCloneInlinable = clone(rule);
|
|
19074
|
+
const ruleCloneNonInlinable = clone(rule);
|
|
19075
|
+
const inlinableParts = [];
|
|
19076
|
+
const nonInlinableParts = [];
|
|
19077
|
+
for (const part of ruleCloneInlinable.block.children.toArray()) if (isPartInlinable(part)) inlinableParts.push(part);
|
|
19078
|
+
else nonInlinableParts.push(part);
|
|
19079
|
+
return {
|
|
19080
|
+
inlinablePart: inlinableParts.length > 0 ? {
|
|
19081
|
+
...ruleCloneInlinable,
|
|
19082
|
+
block: {
|
|
19083
|
+
type: "Block",
|
|
19084
|
+
children: new List().fromArray(inlinableParts)
|
|
19085
|
+
}
|
|
19086
|
+
} : null,
|
|
19087
|
+
nonInlinablePart: nonInlinableParts.length > 0 ? {
|
|
19088
|
+
...ruleCloneNonInlinable,
|
|
19089
|
+
block: {
|
|
19090
|
+
type: "Block",
|
|
19091
|
+
children: new List().fromArray(nonInlinableParts)
|
|
19092
|
+
}
|
|
19093
|
+
} : null
|
|
19094
|
+
};
|
|
19095
|
+
}
|
|
19096
|
+
|
|
19036
19097
|
//#endregion
|
|
19037
19098
|
//#region src/utils/css/extract-rules-per-class.ts
|
|
19038
19099
|
function extractRulesPerClass(root, classes) {
|
|
@@ -19051,7 +19112,14 @@ function extractRulesPerClass(root, classes) {
|
|
|
19051
19112
|
});
|
|
19052
19113
|
if (isRuleInlinable(rule)) {
|
|
19053
19114
|
for (const className of selectorClasses) if (classSet.has(className)) inlinableRules.set(className, rule);
|
|
19054
|
-
} else
|
|
19115
|
+
} else {
|
|
19116
|
+
const { inlinablePart, nonInlinablePart } = splitMixedRule(rule);
|
|
19117
|
+
for (const className of selectorClasses) {
|
|
19118
|
+
if (!classSet.has(className)) continue;
|
|
19119
|
+
if (inlinablePart) inlinableRules.set(className, inlinablePart);
|
|
19120
|
+
if (nonInlinablePart) nonInlinableRules.set(className, nonInlinablePart);
|
|
19121
|
+
}
|
|
19122
|
+
}
|
|
19055
19123
|
}
|
|
19056
19124
|
});
|
|
19057
19125
|
return {
|
|
@@ -19772,7 +19840,8 @@ function cloneElementWithInlinedStyles(element, inlinableRules, nonInlinableRule
|
|
|
19772
19840
|
for (const className of classes) {
|
|
19773
19841
|
const rule = inlinableRules.get(className);
|
|
19774
19842
|
if (rule) rules.push(rule);
|
|
19775
|
-
|
|
19843
|
+
if (nonInlinableRules.has(className)) residualClasses.push(className);
|
|
19844
|
+
else if (!rule) residualClasses.push(className);
|
|
19776
19845
|
}
|
|
19777
19846
|
propsToOverwrite.style = {
|
|
19778
19847
|
...makeInlineStylesFor(rules, customProperties),
|