@readme/markdown 15.3.0 → 15.4.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/components/TailwindStyle/index.tsx +5 -2
- package/dist/components/TailwindStyle/index.d.ts +3 -1
- package/dist/main.js +10 -6
- package/dist/main.node.js +10 -6
- package/dist/main.node.js.map +1 -1
- package/dist/render-fixture.node.js +10 -6
- package/dist/render-fixture.node.js.map +1 -1
- package/dist/utils/tailwind-compiler.d.ts +13 -1
- package/package.json +1 -1
|
@@ -14,9 +14,11 @@ const traverse = (node: Node, callback: (element: Node) => void) => {
|
|
|
14
14
|
interface Props {
|
|
15
15
|
children: React.ReactNode;
|
|
16
16
|
darkModeDataAttribute?: string | null;
|
|
17
|
+
/** See the matching param on `tailwindCompiler` in `utils/tailwind-compiler.ts`. */
|
|
18
|
+
darkModeRootSelector?: string | null;
|
|
17
19
|
}
|
|
18
20
|
|
|
19
|
-
const TailwindStyle = ({ children, darkModeDataAttribute }: Props) => {
|
|
21
|
+
const TailwindStyle = ({ children, darkModeDataAttribute, darkModeRootSelector }: Props) => {
|
|
20
22
|
const [stylesheet, setStylesheet] = useState('');
|
|
21
23
|
const classesSet = useRef(new Set<string>());
|
|
22
24
|
const ref = useRef<HTMLStyleElement>(null);
|
|
@@ -43,6 +45,7 @@ const TailwindStyle = ({ children, darkModeDataAttribute }: Props) => {
|
|
|
43
45
|
const sheet = await tailwindCompiler(classes, {
|
|
44
46
|
prefix: `.${tailwindPrefix}`,
|
|
45
47
|
darkModeDataAttribute,
|
|
48
|
+
darkModeRootSelector,
|
|
46
49
|
});
|
|
47
50
|
/* @note: don't insert an empty stylesheet */
|
|
48
51
|
if (sheet.css.match(/^@layer utilities;/m)) return;
|
|
@@ -51,7 +54,7 @@ const TailwindStyle = ({ children, darkModeDataAttribute }: Props) => {
|
|
|
51
54
|
};
|
|
52
55
|
|
|
53
56
|
run();
|
|
54
|
-
}, [classes, darkModeDataAttribute]);
|
|
57
|
+
}, [classes, darkModeDataAttribute, darkModeRootSelector]);
|
|
55
58
|
|
|
56
59
|
/*
|
|
57
60
|
* @note: execute once on load
|
|
@@ -2,6 +2,8 @@ import React from 'react';
|
|
|
2
2
|
interface Props {
|
|
3
3
|
children: React.ReactNode;
|
|
4
4
|
darkModeDataAttribute?: string | null;
|
|
5
|
+
/** See the matching param on `tailwindCompiler` in `utils/tailwind-compiler.ts`. */
|
|
6
|
+
darkModeRootSelector?: string | null;
|
|
5
7
|
}
|
|
6
|
-
declare const TailwindStyle: ({ children, darkModeDataAttribute }: Props) => React.JSX.Element;
|
|
8
|
+
declare const TailwindStyle: ({ children, darkModeDataAttribute, darkModeRootSelector }: Props) => React.JSX.Element;
|
|
7
9
|
export default TailwindStyle;
|
package/dist/main.js
CHANGED
|
@@ -12675,7 +12675,7 @@ async function loadStylesheet(id, base) {
|
|
|
12675
12675
|
async function loadModule() {
|
|
12676
12676
|
throw new Error('The browser build does not support plugins or config files.');
|
|
12677
12677
|
}
|
|
12678
|
-
async function createCompiler({ darkModeDataAttribute }) {
|
|
12678
|
+
async function createCompiler({ darkModeDataAttribute, darkModeRootSelector, }) {
|
|
12679
12679
|
let css = `
|
|
12680
12680
|
@layer theme, base, components, utilities;
|
|
12681
12681
|
|
|
@@ -12683,9 +12683,12 @@ async function createCompiler({ darkModeDataAttribute }) {
|
|
|
12683
12683
|
@import "tailwindcss/utilities.css" layer(utilities);
|
|
12684
12684
|
`;
|
|
12685
12685
|
if (darkModeDataAttribute) {
|
|
12686
|
+
// Anchors `dark:` to `darkModeRootSelector`'s own attribute instead of any ancestor's,
|
|
12687
|
+
// when supplied — see the `darkModeRootSelector` param doc below for why there's no default.
|
|
12688
|
+
const root = darkModeRootSelector || '';
|
|
12686
12689
|
css += `
|
|
12687
12690
|
|
|
12688
|
-
@custom-variant dark (&:where([${darkModeDataAttribute}=dark], [${darkModeDataAttribute}=dark] *));`;
|
|
12691
|
+
@custom-variant dark (&:where(${root}[${darkModeDataAttribute}=dark], ${root}[${darkModeDataAttribute}=dark] *));`;
|
|
12689
12692
|
}
|
|
12690
12693
|
return Hu(css, {
|
|
12691
12694
|
base: '/',
|
|
@@ -12693,8 +12696,8 @@ async function createCompiler({ darkModeDataAttribute }) {
|
|
|
12693
12696
|
loadModule,
|
|
12694
12697
|
});
|
|
12695
12698
|
}
|
|
12696
|
-
async function tailwindCompiler(classes, { prefix, darkModeDataAttribute }) {
|
|
12697
|
-
const compiler = await createCompiler({ darkModeDataAttribute });
|
|
12699
|
+
async function tailwindCompiler(classes, { prefix, darkModeDataAttribute, darkModeRootSelector, }) {
|
|
12700
|
+
const compiler = await createCompiler({ darkModeDataAttribute, darkModeRootSelector });
|
|
12698
12701
|
const css = compiler.build(Array.from(classes));
|
|
12699
12702
|
return lib_postcss([postcss_prefix_selector_default()({ prefix })]).process(css, { from: undefined });
|
|
12700
12703
|
}
|
|
@@ -12709,7 +12712,7 @@ const traverse = (node, callback) => {
|
|
|
12709
12712
|
traverse(child, callback);
|
|
12710
12713
|
});
|
|
12711
12714
|
};
|
|
12712
|
-
const TailwindStyle = ({ children, darkModeDataAttribute }) => {
|
|
12715
|
+
const TailwindStyle = ({ children, darkModeDataAttribute, darkModeRootSelector }) => {
|
|
12713
12716
|
const [stylesheet, setStylesheet] = (0,external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.useState)('');
|
|
12714
12717
|
const classesSet = (0,external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.useRef)(new Set());
|
|
12715
12718
|
const ref = (0,external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.useRef)(null);
|
|
@@ -12733,6 +12736,7 @@ const TailwindStyle = ({ children, darkModeDataAttribute }) => {
|
|
|
12733
12736
|
const sheet = await tailwindCompiler(classes, {
|
|
12734
12737
|
prefix: `.${tailwindPrefix}`,
|
|
12735
12738
|
darkModeDataAttribute,
|
|
12739
|
+
darkModeRootSelector,
|
|
12736
12740
|
});
|
|
12737
12741
|
/* @note: don't insert an empty stylesheet */
|
|
12738
12742
|
if (sheet.css.match(/^@layer utilities;/m))
|
|
@@ -12740,7 +12744,7 @@ const TailwindStyle = ({ children, darkModeDataAttribute }) => {
|
|
|
12740
12744
|
setStylesheet(sheet.css);
|
|
12741
12745
|
};
|
|
12742
12746
|
run();
|
|
12743
|
-
}, [classes, darkModeDataAttribute]);
|
|
12747
|
+
}, [classes, darkModeDataAttribute, darkModeRootSelector]);
|
|
12744
12748
|
/*
|
|
12745
12749
|
* @note: execute once on load
|
|
12746
12750
|
*/
|
package/dist/main.node.js
CHANGED
|
@@ -25260,7 +25260,7 @@ async function loadStylesheet(id, base) {
|
|
|
25260
25260
|
async function loadModule() {
|
|
25261
25261
|
throw new Error('The browser build does not support plugins or config files.');
|
|
25262
25262
|
}
|
|
25263
|
-
async function createCompiler({ darkModeDataAttribute }) {
|
|
25263
|
+
async function createCompiler({ darkModeDataAttribute, darkModeRootSelector, }) {
|
|
25264
25264
|
let css = `
|
|
25265
25265
|
@layer theme, base, components, utilities;
|
|
25266
25266
|
|
|
@@ -25268,9 +25268,12 @@ async function createCompiler({ darkModeDataAttribute }) {
|
|
|
25268
25268
|
@import "tailwindcss/utilities.css" layer(utilities);
|
|
25269
25269
|
`;
|
|
25270
25270
|
if (darkModeDataAttribute) {
|
|
25271
|
+
// Anchors `dark:` to `darkModeRootSelector`'s own attribute instead of any ancestor's,
|
|
25272
|
+
// when supplied — see the `darkModeRootSelector` param doc below for why there's no default.
|
|
25273
|
+
const root = darkModeRootSelector || '';
|
|
25271
25274
|
css += `
|
|
25272
25275
|
|
|
25273
|
-
@custom-variant dark (&:where([${darkModeDataAttribute}=dark], [${darkModeDataAttribute}=dark] *));`;
|
|
25276
|
+
@custom-variant dark (&:where(${root}[${darkModeDataAttribute}=dark], ${root}[${darkModeDataAttribute}=dark] *));`;
|
|
25274
25277
|
}
|
|
25275
25278
|
return Hu(css, {
|
|
25276
25279
|
base: '/',
|
|
@@ -25278,8 +25281,8 @@ async function createCompiler({ darkModeDataAttribute }) {
|
|
|
25278
25281
|
loadModule,
|
|
25279
25282
|
});
|
|
25280
25283
|
}
|
|
25281
|
-
async function tailwindCompiler(classes, { prefix, darkModeDataAttribute }) {
|
|
25282
|
-
const compiler = await createCompiler({ darkModeDataAttribute });
|
|
25284
|
+
async function tailwindCompiler(classes, { prefix, darkModeDataAttribute, darkModeRootSelector, }) {
|
|
25285
|
+
const compiler = await createCompiler({ darkModeDataAttribute, darkModeRootSelector });
|
|
25283
25286
|
const css = compiler.build(Array.from(classes));
|
|
25284
25287
|
return lib_postcss([postcss_prefix_selector_default()({ prefix })]).process(css, { from: undefined });
|
|
25285
25288
|
}
|
|
@@ -25294,7 +25297,7 @@ const traverse = (node, callback) => {
|
|
|
25294
25297
|
traverse(child, callback);
|
|
25295
25298
|
});
|
|
25296
25299
|
};
|
|
25297
|
-
const TailwindStyle = ({ children, darkModeDataAttribute }) => {
|
|
25300
|
+
const TailwindStyle = ({ children, darkModeDataAttribute, darkModeRootSelector }) => {
|
|
25298
25301
|
const [stylesheet, setStylesheet] = (0,external_react_.useState)('');
|
|
25299
25302
|
const classesSet = (0,external_react_.useRef)(new Set());
|
|
25300
25303
|
const ref = (0,external_react_.useRef)(null);
|
|
@@ -25318,6 +25321,7 @@ const TailwindStyle = ({ children, darkModeDataAttribute }) => {
|
|
|
25318
25321
|
const sheet = await tailwindCompiler(classes, {
|
|
25319
25322
|
prefix: `.${tailwindPrefix}`,
|
|
25320
25323
|
darkModeDataAttribute,
|
|
25324
|
+
darkModeRootSelector,
|
|
25321
25325
|
});
|
|
25322
25326
|
/* @note: don't insert an empty stylesheet */
|
|
25323
25327
|
if (sheet.css.match(/^@layer utilities;/m))
|
|
@@ -25325,7 +25329,7 @@ const TailwindStyle = ({ children, darkModeDataAttribute }) => {
|
|
|
25325
25329
|
setStylesheet(sheet.css);
|
|
25326
25330
|
};
|
|
25327
25331
|
run();
|
|
25328
|
-
}, [classes, darkModeDataAttribute]);
|
|
25332
|
+
}, [classes, darkModeDataAttribute, darkModeRootSelector]);
|
|
25329
25333
|
/*
|
|
25330
25334
|
* @note: execute once on load
|
|
25331
25335
|
*/
|