react-email 6.7.0 → 6.8.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/CHANGELOG.md +11 -0
- package/dist/_virtual/_rolldown/runtime.cjs +23 -0
- package/dist/cli/index.mjs +3 -2
- package/dist/components/body/body.cjs +39 -0
- package/dist/components/body/body.d.cts +7 -0
- package/dist/components/body/body.d.mts +7 -0
- package/dist/components/body/body.mjs +37 -0
- package/dist/components/body/index.d.cts +1 -0
- package/dist/components/body/index.d.mts +1 -0
- package/dist/components/body/margin-properties.cjs +30 -0
- package/dist/components/body/margin-properties.mjs +29 -0
- package/dist/components/button/button.cjs +64 -0
- package/dist/components/button/button.d.cts +13 -0
- package/dist/components/button/button.d.mts +13 -0
- package/dist/components/button/button.mjs +62 -0
- package/dist/components/button/index.d.cts +1 -0
- package/dist/components/button/index.d.mts +1 -0
- package/dist/components/button/utils/parse-padding.cjs +90 -0
- package/dist/components/button/utils/parse-padding.mjs +90 -0
- package/dist/components/button/utils/px-to-pt.cjs +4 -0
- package/dist/components/button/utils/px-to-pt.mjs +4 -0
- package/dist/components/code-block/code-block.cjs +79 -0
- package/dist/components/code-block/code-block.d.cts +20 -0
- package/dist/components/code-block/code-block.d.mts +20 -0
- package/dist/components/code-block/code-block.mjs +77 -0
- package/dist/components/code-block/index.d.cts +3 -0
- package/dist/components/code-block/index.d.mts +3 -0
- package/dist/components/code-block/languages-available.d.cts +4 -0
- package/dist/components/code-block/languages-available.d.mts +4 -0
- package/dist/components/code-block/prism.cjs +14564 -0
- package/dist/components/code-block/prism.mjs +14562 -0
- package/dist/components/code-block/themes.cjs +2578 -0
- package/dist/components/code-block/themes.d.cts +4877 -0
- package/dist/components/code-block/themes.d.mts +4877 -0
- package/dist/components/code-block/themes.mjs +2541 -0
- package/dist/components/code-inline/code-inline.cjs +43 -0
- package/dist/components/code-inline/code-inline.d.cts +12 -0
- package/dist/components/code-inline/code-inline.d.mts +12 -0
- package/dist/components/code-inline/code-inline.mjs +41 -0
- package/dist/components/code-inline/index.d.cts +1 -0
- package/dist/components/code-inline/index.d.mts +1 -0
- package/dist/components/column/column.cjs +19 -0
- package/dist/components/column/column.d.cts +7 -0
- package/dist/components/column/column.d.mts +7 -0
- package/dist/components/column/column.mjs +17 -0
- package/dist/components/column/index.d.cts +1 -0
- package/dist/components/column/index.d.mts +1 -0
- package/dist/components/container/container.cjs +42 -0
- package/dist/components/container/container.d.cts +7 -0
- package/dist/components/container/container.d.mts +7 -0
- package/dist/components/container/container.mjs +40 -0
- package/dist/components/container/index.d.cts +1 -0
- package/dist/components/container/index.d.mts +1 -0
- package/dist/components/element-marker.cjs +8 -0
- package/dist/components/element-marker.mjs +7 -0
- package/dist/components/font/font.cjs +22 -0
- package/dist/components/font/font.d.cts +26 -0
- package/dist/components/font/font.d.mts +26 -0
- package/dist/components/font/font.mjs +21 -0
- package/dist/components/font/index.d.cts +1 -0
- package/dist/components/font/index.d.mts +1 -0
- package/dist/components/head/head.cjs +20 -0
- package/dist/components/head/head.d.cts +7 -0
- package/dist/components/head/head.d.mts +7 -0
- package/dist/components/head/head.mjs +18 -0
- package/dist/components/head/index.d.cts +1 -0
- package/dist/components/head/index.d.mts +1 -0
- package/dist/components/heading/heading.cjs +30 -0
- package/dist/components/heading/heading.d.cts +22 -0
- package/dist/components/heading/heading.d.mts +22 -0
- package/dist/components/heading/heading.mjs +28 -0
- package/dist/components/heading/index.d.cts +1 -0
- package/dist/components/heading/index.d.mts +1 -0
- package/dist/components/heading/utils/as.d.cts +16 -0
- package/dist/components/heading/utils/as.d.mts +16 -0
- package/dist/components/heading/utils/spaces.cjs +24 -0
- package/dist/components/heading/utils/spaces.d.cts +14 -0
- package/dist/components/heading/utils/spaces.d.mts +14 -0
- package/dist/components/heading/utils/spaces.mjs +24 -0
- package/dist/components/hr/hr.cjs +21 -0
- package/dist/components/hr/hr.d.cts +7 -0
- package/dist/components/hr/hr.d.mts +7 -0
- package/dist/components/hr/hr.mjs +19 -0
- package/dist/components/hr/index.d.cts +1 -0
- package/dist/components/hr/index.d.mts +1 -0
- package/dist/components/html/html.cjs +15 -0
- package/dist/components/html/html.d.cts +7 -0
- package/dist/components/html/html.d.mts +7 -0
- package/dist/components/html/html.mjs +13 -0
- package/dist/components/html/index.d.cts +1 -0
- package/dist/components/html/index.d.mts +1 -0
- package/dist/components/img/img.cjs +25 -0
- package/dist/components/img/img.d.cts +7 -0
- package/dist/components/img/img.d.mts +7 -0
- package/dist/components/img/img.mjs +23 -0
- package/dist/components/img/index.d.cts +1 -0
- package/dist/components/img/index.d.mts +1 -0
- package/dist/components/index.d.cts +24 -0
- package/dist/components/index.d.mts +24 -0
- package/dist/components/link/index.d.cts +1 -0
- package/dist/components/link/index.d.mts +1 -0
- package/dist/components/link/link.cjs +21 -0
- package/dist/components/link/link.d.cts +7 -0
- package/dist/components/link/link.d.mts +7 -0
- package/dist/components/link/link.mjs +19 -0
- package/dist/components/markdown/index.d.cts +1 -0
- package/dist/components/markdown/index.d.mts +1 -0
- package/dist/components/markdown/markdown.cjs +101 -0
- package/dist/components/markdown/markdown.d.cts +16 -0
- package/dist/components/markdown/markdown.d.mts +16 -0
- package/dist/components/markdown/markdown.mjs +99 -0
- package/dist/components/markdown/styles.cjs +92 -0
- package/dist/components/markdown/styles.d.cts +31 -0
- package/dist/components/markdown/styles.d.mts +31 -0
- package/dist/components/markdown/styles.mjs +92 -0
- package/dist/components/markdown/utils/parse-css-in-js-to-inline-css.cjs +60 -0
- package/dist/components/markdown/utils/parse-css-in-js-to-inline-css.mjs +60 -0
- package/dist/components/preview/index.d.cts +1 -0
- package/dist/components/preview/index.d.mts +1 -0
- package/dist/components/preview/preview.cjs +34 -0
- package/dist/components/preview/preview.d.cts +21 -0
- package/dist/components/preview/preview.d.mts +21 -0
- package/dist/components/preview/preview.mjs +31 -0
- package/dist/components/row/index.d.cts +1 -0
- package/dist/components/row/index.d.mts +1 -0
- package/dist/components/row/row.cjs +30 -0
- package/dist/components/row/row.d.cts +11 -0
- package/dist/components/row/row.d.mts +11 -0
- package/dist/components/row/row.mjs +28 -0
- package/dist/components/section/index.d.cts +1 -0
- package/dist/components/section/index.d.mts +1 -0
- package/dist/components/section/section.cjs +36 -0
- package/dist/components/section/section.d.cts +7 -0
- package/dist/components/section/section.d.mts +7 -0
- package/dist/components/section/section.mjs +34 -0
- package/dist/components/tailwind/hooks/use-suspended-promise.cjs +15 -0
- package/dist/components/tailwind/hooks/use-suspended-promise.mjs +15 -0
- package/dist/components/tailwind/index.d.cts +4 -0
- package/dist/components/tailwind/index.d.mts +4 -0
- package/dist/components/tailwind/inline-styles.cjs +11 -0
- package/dist/components/tailwind/inline-styles.d.cts +6 -0
- package/dist/components/tailwind/inline-styles.d.mts +6 -0
- package/dist/components/tailwind/inline-styles.mjs +11 -0
- package/dist/components/tailwind/sanitize-stylesheet.cjs +11 -0
- package/dist/components/tailwind/sanitize-stylesheet.d.cts +6 -0
- package/dist/components/tailwind/sanitize-stylesheet.d.mts +6 -0
- package/dist/components/tailwind/sanitize-stylesheet.mjs +11 -0
- package/dist/components/tailwind/tailwind.cjs +120 -0
- package/dist/components/tailwind/tailwind.d.cts +25 -0
- package/dist/components/tailwind/tailwind.d.mts +25 -0
- package/dist/components/tailwind/tailwind.mjs +117 -0
- package/dist/components/tailwind/utils/compatibility/get-react-property.cjs +10 -0
- package/dist/components/tailwind/utils/compatibility/get-react-property.mjs +10 -0
- package/dist/components/tailwind/utils/compatibility/sanitize-class-name.cjs +26 -0
- package/dist/components/tailwind/utils/compatibility/sanitize-class-name.mjs +26 -0
- package/dist/components/tailwind/utils/css/downlevel-for-email-clients.cjs +126 -0
- package/dist/components/tailwind/utils/css/downlevel-for-email-clients.mjs +125 -0
- package/dist/components/tailwind/utils/css/extract-rules-per-class.cjs +45 -0
- package/dist/components/tailwind/utils/css/extract-rules-per-class.mjs +44 -0
- package/dist/components/tailwind/utils/css/get-custom-properties.cjs +35 -0
- package/dist/components/tailwind/utils/css/get-custom-properties.mjs +34 -0
- package/dist/components/tailwind/utils/css/is-part-inlinable.cjs +10 -0
- package/dist/components/tailwind/utils/css/is-part-inlinable.mjs +9 -0
- package/dist/components/tailwind/utils/css/is-rule-inlinable.cjs +10 -0
- package/dist/components/tailwind/utils/css/is-rule-inlinable.mjs +9 -0
- package/dist/components/tailwind/utils/css/make-inline-styles-for.cjs +52 -0
- package/dist/components/tailwind/utils/css/make-inline-styles-for.mjs +51 -0
- package/dist/components/tailwind/utils/css/resolve-all-css-variables.cjs +89 -0
- package/dist/components/tailwind/utils/css/resolve-all-css-variables.mjs +88 -0
- package/dist/components/tailwind/utils/css/resolve-calc-expressions.cjs +92 -0
- package/dist/components/tailwind/utils/css/resolve-calc-expressions.mjs +91 -0
- package/dist/components/tailwind/utils/css/sanitize-declarations.cjs +310 -0
- package/dist/components/tailwind/utils/css/sanitize-declarations.mjs +309 -0
- package/dist/components/tailwind/utils/css/sanitize-non-inlinable-rules.cjs +46 -0
- package/dist/components/tailwind/utils/css/sanitize-non-inlinable-rules.mjs +45 -0
- package/dist/components/tailwind/utils/css/split-mixed-rule.cjs +41 -0
- package/dist/components/tailwind/utils/css/split-mixed-rule.mjs +40 -0
- package/dist/components/tailwind/utils/css/strip-empty-tailwind-vars.cjs +52 -0
- package/dist/components/tailwind/utils/css/strip-empty-tailwind-vars.mjs +51 -0
- package/dist/components/tailwind/utils/css/unwrap-value.cjs +7 -0
- package/dist/components/tailwind/utils/css/unwrap-value.mjs +7 -0
- package/dist/components/tailwind/utils/react/is-component.cjs +7 -0
- package/dist/components/tailwind/utils/react/is-component.mjs +7 -0
- package/dist/components/tailwind/utils/react/map-react-tree.cjs +32 -0
- package/dist/components/tailwind/utils/react/map-react-tree.mjs +30 -0
- package/dist/components/tailwind/utils/tailwindcss/clone-element-with-inlined-styles.cjs +37 -0
- package/dist/components/tailwind/utils/tailwindcss/clone-element-with-inlined-styles.mjs +35 -0
- package/dist/components/tailwind/utils/tailwindcss/setup-tailwind.cjs +77 -0
- package/dist/components/tailwind/utils/tailwindcss/setup-tailwind.d.cts +19 -0
- package/dist/components/tailwind/utils/tailwindcss/setup-tailwind.d.mts +19 -0
- package/dist/components/tailwind/utils/tailwindcss/setup-tailwind.mjs +76 -0
- package/dist/components/tailwind/utils/tailwindcss/tailwind-stylesheets/index.cjs +901 -0
- package/dist/components/tailwind/utils/tailwindcss/tailwind-stylesheets/index.mjs +901 -0
- package/dist/components/tailwind/utils/tailwindcss/tailwind-stylesheets/preflight.cjs +398 -0
- package/dist/components/tailwind/utils/tailwindcss/tailwind-stylesheets/preflight.mjs +398 -0
- package/dist/components/tailwind/utils/tailwindcss/tailwind-stylesheets/theme.cjs +467 -0
- package/dist/components/tailwind/utils/tailwindcss/tailwind-stylesheets/theme.mjs +467 -0
- package/dist/components/tailwind/utils/tailwindcss/tailwind-stylesheets/utilities.cjs +6 -0
- package/dist/components/tailwind/utils/tailwindcss/tailwind-stylesheets/utilities.mjs +6 -0
- package/dist/components/tailwind/utils/text/from-dash-case-to-camel-case.cjs +6 -0
- package/dist/components/tailwind/utils/text/from-dash-case-to-camel-case.mjs +6 -0
- package/dist/components/text/index.d.cts +1 -0
- package/dist/components/text/index.d.mts +1 -0
- package/dist/components/text/text.cjs +43 -0
- package/dist/components/text/text.d.cts +7 -0
- package/dist/components/text/text.d.mts +7 -0
- package/dist/components/text/text.mjs +41 -0
- package/dist/components/text/utils/compute-margins.cjs +62 -0
- package/dist/components/text/utils/compute-margins.mjs +62 -0
- package/dist/index.cjs +85 -40759
- package/dist/index.d.cts +24 -5132
- package/dist/index.d.mts +24 -5132
- package/dist/index.mjs +23 -40676
- package/package.json +5 -4
- package/src/components/body/body.tsx +2 -0
- package/src/components/button/button.tsx +2 -0
- package/src/components/code-block/code-block.tsx +2 -0
- package/src/components/code-inline/code-inline.tsx +2 -0
- package/src/components/column/column.tsx +2 -0
- package/src/components/container/container.tsx +2 -0
- package/src/components/element-marker.ts +5 -0
- package/src/components/heading/heading.tsx +2 -0
- package/src/components/hr/hr.tsx +2 -0
- package/src/components/img/img.tsx +2 -0
- package/src/components/link/link.tsx +2 -0
- package/src/components/preview/preview.tsx +2 -0
- package/src/components/row/row.tsx +2 -0
- package/src/components/section/section.tsx +2 -0
- package/src/components/tailwind/utils/react/is-component.ts +2 -32
- package/src/components/text/text.tsx +2 -0
- package/tsdown.config.ts +31 -34
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { isComponent } from "./is-component.mjs";
|
|
2
|
+
import React from "react";
|
|
3
|
+
//#region src/components/tailwind/utils/react/map-react-tree.ts
|
|
4
|
+
/**
|
|
5
|
+
* A function made for deep mapping a React tree from a node, even through its components.
|
|
6
|
+
* For all the components it finds, it renders them by directly calling them. This has a few issues
|
|
7
|
+
* with hooks, and the only solution is `renderAsync` here, which will probably be done in the future.
|
|
8
|
+
*
|
|
9
|
+
* @param process - The callback that will be called every time a new element has been reached.
|
|
10
|
+
*
|
|
11
|
+
* For components, this is going to be called, most of the time, two times. This is because the best
|
|
12
|
+
* approach is to process *both* before rendering the components (i.e. on the props.children of a component element)
|
|
13
|
+
* and after rendering them because the children themselves might have been modified in the component's
|
|
14
|
+
* rendering.
|
|
15
|
+
*/
|
|
16
|
+
function mapReactTree(value, process) {
|
|
17
|
+
const mapped = React.Children.map(value, (node) => {
|
|
18
|
+
if (React.isValidElement(node)) {
|
|
19
|
+
const newProps = { ...node.props };
|
|
20
|
+
if (node.props.children && !isComponent(node)) newProps.children = mapReactTree(node.props.children, process);
|
|
21
|
+
const processed = process(React.cloneElement(node, newProps, newProps.children));
|
|
22
|
+
if (React.isValidElement(processed) && isComponent(processed)) return mapReactTree((typeof processed.type === "object" ? processed.type.render : processed.type)(processed.props), process);
|
|
23
|
+
return processed;
|
|
24
|
+
}
|
|
25
|
+
return process(node);
|
|
26
|
+
});
|
|
27
|
+
return mapped && mapped.length === 1 ? mapped[0] : mapped;
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
export { mapReactTree };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
const require_runtime = require("../../../../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
const require_make_inline_styles_for = require("../css/make-inline-styles-for.cjs");
|
|
3
|
+
const require_sanitize_class_name = require("../compatibility/sanitize-class-name.cjs");
|
|
4
|
+
const require_is_component = require("../react/is-component.cjs");
|
|
5
|
+
let react = require("react");
|
|
6
|
+
react = require_runtime.__toESM(react, 1);
|
|
7
|
+
//#region src/components/tailwind/utils/tailwindcss/clone-element-with-inlined-styles.ts
|
|
8
|
+
function cloneElementWithInlinedStyles(element, inlinableRules, nonInlinableRules, customProperties) {
|
|
9
|
+
const propsToOverwrite = {};
|
|
10
|
+
if (element.props.className && !require_is_component.isComponent(element)) {
|
|
11
|
+
const classes = element.props.className.trim().split(/\s+/);
|
|
12
|
+
const residualClasses = [];
|
|
13
|
+
const rules = [];
|
|
14
|
+
for (const className of classes) {
|
|
15
|
+
const classRules = inlinableRules.get(className);
|
|
16
|
+
if (classRules) rules.push(...classRules);
|
|
17
|
+
if (nonInlinableRules.has(className)) residualClasses.push(className);
|
|
18
|
+
else if (!classRules) residualClasses.push(className);
|
|
19
|
+
}
|
|
20
|
+
propsToOverwrite.style = {
|
|
21
|
+
...require_make_inline_styles_for.makeInlineStylesFor(rules, customProperties),
|
|
22
|
+
...element.props.style
|
|
23
|
+
};
|
|
24
|
+
if (residualClasses.length > 0) propsToOverwrite.className = residualClasses.map((className) => {
|
|
25
|
+
if (nonInlinableRules.has(className)) return require_sanitize_class_name.sanitizeClassName(className);
|
|
26
|
+
return className;
|
|
27
|
+
}).join(" ");
|
|
28
|
+
else propsToOverwrite.className = void 0;
|
|
29
|
+
}
|
|
30
|
+
const newProps = {
|
|
31
|
+
...element.props,
|
|
32
|
+
...propsToOverwrite
|
|
33
|
+
};
|
|
34
|
+
return react.default.cloneElement(element, newProps, newProps.children);
|
|
35
|
+
}
|
|
36
|
+
//#endregion
|
|
37
|
+
exports.cloneElementWithInlinedStyles = cloneElementWithInlinedStyles;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { makeInlineStylesFor } from "../css/make-inline-styles-for.mjs";
|
|
2
|
+
import { sanitizeClassName } from "../compatibility/sanitize-class-name.mjs";
|
|
3
|
+
import { isComponent } from "../react/is-component.mjs";
|
|
4
|
+
import React from "react";
|
|
5
|
+
//#region src/components/tailwind/utils/tailwindcss/clone-element-with-inlined-styles.ts
|
|
6
|
+
function cloneElementWithInlinedStyles(element, inlinableRules, nonInlinableRules, customProperties) {
|
|
7
|
+
const propsToOverwrite = {};
|
|
8
|
+
if (element.props.className && !isComponent(element)) {
|
|
9
|
+
const classes = element.props.className.trim().split(/\s+/);
|
|
10
|
+
const residualClasses = [];
|
|
11
|
+
const rules = [];
|
|
12
|
+
for (const className of classes) {
|
|
13
|
+
const classRules = inlinableRules.get(className);
|
|
14
|
+
if (classRules) rules.push(...classRules);
|
|
15
|
+
if (nonInlinableRules.has(className)) residualClasses.push(className);
|
|
16
|
+
else if (!classRules) residualClasses.push(className);
|
|
17
|
+
}
|
|
18
|
+
propsToOverwrite.style = {
|
|
19
|
+
...makeInlineStylesFor(rules, customProperties),
|
|
20
|
+
...element.props.style
|
|
21
|
+
};
|
|
22
|
+
if (residualClasses.length > 0) propsToOverwrite.className = residualClasses.map((className) => {
|
|
23
|
+
if (nonInlinableRules.has(className)) return sanitizeClassName(className);
|
|
24
|
+
return className;
|
|
25
|
+
}).join(" ");
|
|
26
|
+
else propsToOverwrite.className = void 0;
|
|
27
|
+
}
|
|
28
|
+
const newProps = {
|
|
29
|
+
...element.props,
|
|
30
|
+
...propsToOverwrite
|
|
31
|
+
};
|
|
32
|
+
return React.cloneElement(element, newProps, newProps.children);
|
|
33
|
+
}
|
|
34
|
+
//#endregion
|
|
35
|
+
export { cloneElementWithInlinedStyles };
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
require("../../../../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
const require_index = require("./tailwind-stylesheets/index.cjs");
|
|
3
|
+
const require_preflight = require("./tailwind-stylesheets/preflight.cjs");
|
|
4
|
+
const require_theme = require("./tailwind-stylesheets/theme.cjs");
|
|
5
|
+
const require_utilities = require("./tailwind-stylesheets/utilities.cjs");
|
|
6
|
+
let css_tree = require("css-tree");
|
|
7
|
+
let tailwindcss = require("tailwindcss");
|
|
8
|
+
//#region src/components/tailwind/utils/tailwindcss/setup-tailwind.ts
|
|
9
|
+
const SETUP_TAILWIND_KEYS = new Set(["config", "cssConfigs"]);
|
|
10
|
+
async function setupTailwind(props = {}) {
|
|
11
|
+
const stray = Object.keys(props).filter((k) => !SETUP_TAILWIND_KEYS.has(k));
|
|
12
|
+
if (stray.length > 0) throw new Error(`setupTailwind now takes { config, cssConfigs } — received unexpected keys: ${stray.join(", ")}. If you used to call setupTailwind(config), wrap it: setupTailwind({ config }).`);
|
|
13
|
+
const { config, cssConfigs } = props;
|
|
14
|
+
const baseCss = `
|
|
15
|
+
@layer theme, base, components, utilities;
|
|
16
|
+
@import "tailwindcss/theme.css" layer(theme);
|
|
17
|
+
@import "tailwindcss/utilities.css" layer(utilities);
|
|
18
|
+
${cssConfigs?.theme ? "@import \"custom-theme.css\" layer(theme);" : ""}
|
|
19
|
+
${cssConfigs?.utility ? "@import \"custom-utilities.css\" layer(utilities);" : ""}
|
|
20
|
+
@config;
|
|
21
|
+
`;
|
|
22
|
+
const compiler = await (0, tailwindcss.compile)(baseCss, {
|
|
23
|
+
async loadModule(id, base, resourceHint) {
|
|
24
|
+
if (resourceHint === "config") return {
|
|
25
|
+
path: id,
|
|
26
|
+
base,
|
|
27
|
+
module: config ?? {}
|
|
28
|
+
};
|
|
29
|
+
throw new Error(`NO-OP: should we implement support for ${resourceHint}?`);
|
|
30
|
+
},
|
|
31
|
+
polyfills: 0,
|
|
32
|
+
async loadStylesheet(id, base) {
|
|
33
|
+
if (id === "tailwindcss") return {
|
|
34
|
+
base,
|
|
35
|
+
path: "tailwindcss/index.css",
|
|
36
|
+
content: require_index.default
|
|
37
|
+
};
|
|
38
|
+
if (id === "tailwindcss/preflight.css") return {
|
|
39
|
+
base,
|
|
40
|
+
path: id,
|
|
41
|
+
content: require_preflight.default
|
|
42
|
+
};
|
|
43
|
+
if (id === "tailwindcss/theme.css") return {
|
|
44
|
+
base,
|
|
45
|
+
path: id,
|
|
46
|
+
content: require_theme.default
|
|
47
|
+
};
|
|
48
|
+
if (id === "tailwindcss/utilities.css") return {
|
|
49
|
+
base,
|
|
50
|
+
path: id,
|
|
51
|
+
content: require_utilities.default
|
|
52
|
+
};
|
|
53
|
+
if (id === "custom-theme.css") return {
|
|
54
|
+
base,
|
|
55
|
+
path: id,
|
|
56
|
+
content: cssConfigs?.theme ?? ""
|
|
57
|
+
};
|
|
58
|
+
if (id === "custom-utilities.css") return {
|
|
59
|
+
base,
|
|
60
|
+
path: id,
|
|
61
|
+
content: cssConfigs?.utility ?? ""
|
|
62
|
+
};
|
|
63
|
+
throw new Error("stylesheet not supported, you can only import the ones from tailwindcss");
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
let css$4 = baseCss;
|
|
67
|
+
return {
|
|
68
|
+
addUtilities: function addUtilities(candidates) {
|
|
69
|
+
css$4 = compiler.build(candidates);
|
|
70
|
+
},
|
|
71
|
+
getStyleSheet: function getCss() {
|
|
72
|
+
return (0, css_tree.parse)(css$4);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
//#endregion
|
|
77
|
+
exports.setupTailwind = setupTailwind;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { TailwindConfig } from "../../tailwind.cjs";
|
|
2
|
+
import { StyleSheet } from "css-tree";
|
|
3
|
+
|
|
4
|
+
//#region src/components/tailwind/utils/tailwindcss/setup-tailwind.d.ts
|
|
5
|
+
type TailwindSetup = Awaited<ReturnType<typeof setupTailwind>>;
|
|
6
|
+
interface CSSConfigs {
|
|
7
|
+
theme?: string;
|
|
8
|
+
utility?: string;
|
|
9
|
+
}
|
|
10
|
+
interface SetupTailwindProps {
|
|
11
|
+
config?: TailwindConfig;
|
|
12
|
+
cssConfigs?: CSSConfigs;
|
|
13
|
+
}
|
|
14
|
+
declare function setupTailwind(props?: SetupTailwindProps): Promise<{
|
|
15
|
+
addUtilities: (candidates: string[]) => void;
|
|
16
|
+
getStyleSheet: () => StyleSheet;
|
|
17
|
+
}>;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { TailwindSetup, setupTailwind };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { TailwindConfig } from "../../tailwind.mjs";
|
|
2
|
+
import { StyleSheet } from "css-tree";
|
|
3
|
+
|
|
4
|
+
//#region src/components/tailwind/utils/tailwindcss/setup-tailwind.d.ts
|
|
5
|
+
type TailwindSetup = Awaited<ReturnType<typeof setupTailwind>>;
|
|
6
|
+
interface CSSConfigs {
|
|
7
|
+
theme?: string;
|
|
8
|
+
utility?: string;
|
|
9
|
+
}
|
|
10
|
+
interface SetupTailwindProps {
|
|
11
|
+
config?: TailwindConfig;
|
|
12
|
+
cssConfigs?: CSSConfigs;
|
|
13
|
+
}
|
|
14
|
+
declare function setupTailwind(props?: SetupTailwindProps): Promise<{
|
|
15
|
+
addUtilities: (candidates: string[]) => void;
|
|
16
|
+
getStyleSheet: () => StyleSheet;
|
|
17
|
+
}>;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { TailwindSetup, setupTailwind };
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import css from "./tailwind-stylesheets/index.mjs";
|
|
2
|
+
import css$1 from "./tailwind-stylesheets/preflight.mjs";
|
|
3
|
+
import css$2 from "./tailwind-stylesheets/theme.mjs";
|
|
4
|
+
import css$3 from "./tailwind-stylesheets/utilities.mjs";
|
|
5
|
+
import { parse } from "css-tree/dist/csstree.esm";
|
|
6
|
+
import { compile } from "tailwindcss";
|
|
7
|
+
//#region src/components/tailwind/utils/tailwindcss/setup-tailwind.ts
|
|
8
|
+
const SETUP_TAILWIND_KEYS = new Set(["config", "cssConfigs"]);
|
|
9
|
+
async function setupTailwind(props = {}) {
|
|
10
|
+
const stray = Object.keys(props).filter((k) => !SETUP_TAILWIND_KEYS.has(k));
|
|
11
|
+
if (stray.length > 0) throw new Error(`setupTailwind now takes { config, cssConfigs } — received unexpected keys: ${stray.join(", ")}. If you used to call setupTailwind(config), wrap it: setupTailwind({ config }).`);
|
|
12
|
+
const { config, cssConfigs } = props;
|
|
13
|
+
const baseCss = `
|
|
14
|
+
@layer theme, base, components, utilities;
|
|
15
|
+
@import "tailwindcss/theme.css" layer(theme);
|
|
16
|
+
@import "tailwindcss/utilities.css" layer(utilities);
|
|
17
|
+
${cssConfigs?.theme ? "@import \"custom-theme.css\" layer(theme);" : ""}
|
|
18
|
+
${cssConfigs?.utility ? "@import \"custom-utilities.css\" layer(utilities);" : ""}
|
|
19
|
+
@config;
|
|
20
|
+
`;
|
|
21
|
+
const compiler = await compile(baseCss, {
|
|
22
|
+
async loadModule(id, base, resourceHint) {
|
|
23
|
+
if (resourceHint === "config") return {
|
|
24
|
+
path: id,
|
|
25
|
+
base,
|
|
26
|
+
module: config ?? {}
|
|
27
|
+
};
|
|
28
|
+
throw new Error(`NO-OP: should we implement support for ${resourceHint}?`);
|
|
29
|
+
},
|
|
30
|
+
polyfills: 0,
|
|
31
|
+
async loadStylesheet(id, base) {
|
|
32
|
+
if (id === "tailwindcss") return {
|
|
33
|
+
base,
|
|
34
|
+
path: "tailwindcss/index.css",
|
|
35
|
+
content: css
|
|
36
|
+
};
|
|
37
|
+
if (id === "tailwindcss/preflight.css") return {
|
|
38
|
+
base,
|
|
39
|
+
path: id,
|
|
40
|
+
content: css$1
|
|
41
|
+
};
|
|
42
|
+
if (id === "tailwindcss/theme.css") return {
|
|
43
|
+
base,
|
|
44
|
+
path: id,
|
|
45
|
+
content: css$2
|
|
46
|
+
};
|
|
47
|
+
if (id === "tailwindcss/utilities.css") return {
|
|
48
|
+
base,
|
|
49
|
+
path: id,
|
|
50
|
+
content: css$3
|
|
51
|
+
};
|
|
52
|
+
if (id === "custom-theme.css") return {
|
|
53
|
+
base,
|
|
54
|
+
path: id,
|
|
55
|
+
content: cssConfigs?.theme ?? ""
|
|
56
|
+
};
|
|
57
|
+
if (id === "custom-utilities.css") return {
|
|
58
|
+
base,
|
|
59
|
+
path: id,
|
|
60
|
+
content: cssConfigs?.utility ?? ""
|
|
61
|
+
};
|
|
62
|
+
throw new Error("stylesheet not supported, you can only import the ones from tailwindcss");
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
let css$4 = baseCss;
|
|
66
|
+
return {
|
|
67
|
+
addUtilities: function addUtilities(candidates) {
|
|
68
|
+
css$4 = compiler.build(candidates);
|
|
69
|
+
},
|
|
70
|
+
getStyleSheet: function getCss() {
|
|
71
|
+
return parse(css$4);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
//#endregion
|
|
76
|
+
export { setupTailwind };
|