Skip to content

Commit d4096c6

Browse files
committed
expose all plugin internals
1 parent 21256d3 commit d4096c6

File tree

3 files changed

+25
-13
lines changed

3 files changed

+25
-13
lines changed

packages/ui/package.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,16 @@
4040
"import": "./dist/esm/hooks/*/index.mjs",
4141
"require": "./dist/cjs/hooks/*/index.cjs"
4242
},
43-
"./tailwind": {
44-
"types": "./dist/types/tailwind/index.d.ts",
45-
"import": "./dist/esm/tailwind/index.mjs",
46-
"require": "./dist/cjs/tailwind/index.cjs"
47-
},
4843
"./tailwind/*": {
4944
"types": "./dist/types/tailwind/*.d.ts",
5045
"import": "./dist/esm/tailwind/*.mjs",
5146
"require": "./dist/cjs/tailwind/*.cjs"
5247
},
48+
"./tailwind": {
49+
"types": "./dist/types/tailwind/index.d.ts",
50+
"import": "./dist/esm/tailwind/index.mjs",
51+
"require": "./dist/cjs/tailwind/index.cjs"
52+
},
5353
"./package.json": "./package.json"
5454
},
5555
"main": "dist/cjs/index.cjs",

packages/ui/src/tailwind/config.ts

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { theme } from "./theme";
2+
import type { PluginOptions } from "./types";
3+
import { resolveClassList, resolvePrefix } from "./utils";
4+
5+
import type { Config } from "tailwindcss";
6+
7+
export function getConfig(options: PluginOptions = {}): Partial<Config> {
8+
return {
9+
safelist: getSafelist(options),
10+
theme: {
11+
extend: theme,
12+
},
13+
};
14+
}
15+
16+
export function getSafelist(options: PluginOptions = {}): Config["safelist"] {
17+
return resolvePrefix(resolveClassList(options.components), options.prefix, options.separator);
18+
}

packages/ui/src/tailwind/index.ts

+2-8
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11
import plugin from "tailwindcss/plugin";
2-
import { theme } from "./theme";
2+
import { getConfig } from "./config";
33
import { PluginOptions } from "./types";
4-
import { resolveClassList, resolvePrefix } from "./utils";
54

65
export default plugin.withOptions<PluginOptions>(
76
// plugin
87
() => () => {},
98
// config
10-
({ prefix, separator, components } = {}) => ({
11-
safelist: resolvePrefix(resolveClassList(components), prefix, separator),
12-
theme: {
13-
extend: theme,
14-
},
15-
}),
9+
(options) => getConfig(options),
1610
);

0 commit comments

Comments
 (0)