@nextui-org/theme 0.0.0-dev-v2-20230326015909 → 0.0.0-dev-v2-20230326024632
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/plugin.d.ts +15 -3
- package/dist/plugin.js +20 -10
- package/dist/plugin.mjs +20 -10
- package/package.json +1 -1
package/dist/plugin.d.ts
CHANGED
|
@@ -14,12 +14,24 @@ interface ColorsWithScheme<T> extends Colors {
|
|
|
14
14
|
[SCHEME]?: T;
|
|
15
15
|
}
|
|
16
16
|
type SchemerFn<T> = (colors: Colors) => ColorsWithScheme<T>;
|
|
17
|
+
type DefaultTheme = "light" | "dark";
|
|
17
18
|
type ConfigObject = Record<string, ColorsWithScheme<"light" | "dark">>;
|
|
18
19
|
type ConfigFunction = ({ light, dark, }: {
|
|
19
20
|
light: SchemerFn<"light">;
|
|
20
21
|
dark: SchemerFn<"dark">;
|
|
21
22
|
}) => ConfigObject;
|
|
22
|
-
|
|
23
|
+
type NextUIConfig = {
|
|
24
|
+
/**
|
|
25
|
+
* The theme definitions.
|
|
26
|
+
*/
|
|
27
|
+
themes?: ConfigObject | ConfigFunction;
|
|
28
|
+
/**
|
|
29
|
+
* The default theme to use.
|
|
30
|
+
* @default "light"
|
|
31
|
+
*/
|
|
32
|
+
defaultTheme?: DefaultTheme;
|
|
33
|
+
};
|
|
34
|
+
declare const resolveConfig: (config: ConfigObject | ConfigFunction | undefined, defaultTheme: DefaultTheme) => {
|
|
23
35
|
variants: {
|
|
24
36
|
name: string;
|
|
25
37
|
definition: string[];
|
|
@@ -30,9 +42,9 @@ declare const resolveConfig: (config?: ConfigObject | ConfigFunction) => {
|
|
|
30
42
|
opacityVariable: string;
|
|
31
43
|
}) => string>;
|
|
32
44
|
};
|
|
33
|
-
declare const nextui: (config?:
|
|
45
|
+
declare const nextui: (config?: NextUIConfig) => {
|
|
34
46
|
handler: tailwindcss_types_config.PluginCreator;
|
|
35
47
|
config?: Partial<tailwindcss.Config> | undefined;
|
|
36
48
|
};
|
|
37
49
|
|
|
38
|
-
export { Colors, ColorsWithScheme, ConfigFunction, ConfigObject, nextui, resolveConfig };
|
|
50
|
+
export { Colors, ColorsWithScheme, ConfigFunction, ConfigObject, DefaultTheme, NextUIConfig, nextui, resolveConfig };
|
package/dist/plugin.js
CHANGED
|
@@ -460,7 +460,7 @@ var light = (colors2) => {
|
|
|
460
460
|
...colors2
|
|
461
461
|
};
|
|
462
462
|
};
|
|
463
|
-
var resolveConfig = (config = {}) => {
|
|
463
|
+
var resolveConfig = (config = {}, defaultTheme) => {
|
|
464
464
|
const resolved = {
|
|
465
465
|
variants: [],
|
|
466
466
|
utilities: {},
|
|
@@ -468,7 +468,10 @@ var resolveConfig = (config = {}) => {
|
|
|
468
468
|
};
|
|
469
469
|
const configObject = typeof config === "function" ? config({ dark, light }) : config;
|
|
470
470
|
(0, import_lodash.default)(configObject, (colors2, themeName) => {
|
|
471
|
-
|
|
471
|
+
let cssSelector = `.${themeName},.theme-${themeName},[data-theme="${themeName}"]`;
|
|
472
|
+
if (themeName === defaultTheme) {
|
|
473
|
+
cssSelector = `:root,${cssSelector}`;
|
|
474
|
+
}
|
|
472
475
|
resolved.utilities[cssSelector] = colors2[SCHEME] ? {
|
|
473
476
|
"color-scheme": colors2[SCHEME]
|
|
474
477
|
} : {};
|
|
@@ -509,8 +512,8 @@ var resolveConfig = (config = {}) => {
|
|
|
509
512
|
});
|
|
510
513
|
return resolved;
|
|
511
514
|
};
|
|
512
|
-
var corePlugin = (config = {}) => {
|
|
513
|
-
const resolved = resolveConfig(config);
|
|
515
|
+
var corePlugin = (config = {}, defaultTheme) => {
|
|
516
|
+
const resolved = resolveConfig(config, defaultTheme);
|
|
514
517
|
return (0, import_plugin.default)(
|
|
515
518
|
({ addBase, addUtilities, addVariant }) => {
|
|
516
519
|
addBase({
|
|
@@ -550,13 +553,20 @@ var corePlugin = (config = {}) => {
|
|
|
550
553
|
);
|
|
551
554
|
};
|
|
552
555
|
var nextui = (config = {}) => {
|
|
553
|
-
const userLightColors = (0, import_lodash2.default)(config, "light", {});
|
|
554
|
-
const userDarkColors = (0, import_lodash2.default)(config, "dark", {});
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
556
|
+
const userLightColors = (0, import_lodash2.default)(config.themes, "light", {});
|
|
557
|
+
const userDarkColors = (0, import_lodash2.default)(config.themes, "dark", {});
|
|
558
|
+
const defaultTheme = config.defaultTheme || "light";
|
|
559
|
+
return corePlugin(
|
|
560
|
+
{
|
|
561
|
+
light: (0, import_deepmerge.default)(semanticColors.light, userLightColors),
|
|
562
|
+
dark: (0, import_deepmerge.default)(semanticColors.dark, userDarkColors)
|
|
563
|
+
},
|
|
564
|
+
defaultTheme
|
|
565
|
+
);
|
|
559
566
|
};
|
|
567
|
+
nextui({
|
|
568
|
+
defaultTheme: "light"
|
|
569
|
+
});
|
|
560
570
|
// Annotate the CommonJS export names for ESM import in node:
|
|
561
571
|
0 && (module.exports = {
|
|
562
572
|
nextui,
|
package/dist/plugin.mjs
CHANGED
|
@@ -48,7 +48,7 @@ var light = (colors) => {
|
|
|
48
48
|
...colors
|
|
49
49
|
};
|
|
50
50
|
};
|
|
51
|
-
var resolveConfig = (config = {}) => {
|
|
51
|
+
var resolveConfig = (config = {}, defaultTheme) => {
|
|
52
52
|
const resolved = {
|
|
53
53
|
variants: [],
|
|
54
54
|
utilities: {},
|
|
@@ -56,7 +56,10 @@ var resolveConfig = (config = {}) => {
|
|
|
56
56
|
};
|
|
57
57
|
const configObject = typeof config === "function" ? config({ dark, light }) : config;
|
|
58
58
|
forEach(configObject, (colors, themeName) => {
|
|
59
|
-
|
|
59
|
+
let cssSelector = `.${themeName},.theme-${themeName},[data-theme="${themeName}"]`;
|
|
60
|
+
if (themeName === defaultTheme) {
|
|
61
|
+
cssSelector = `:root,${cssSelector}`;
|
|
62
|
+
}
|
|
60
63
|
resolved.utilities[cssSelector] = colors[SCHEME] ? {
|
|
61
64
|
"color-scheme": colors[SCHEME]
|
|
62
65
|
} : {};
|
|
@@ -97,8 +100,8 @@ var resolveConfig = (config = {}) => {
|
|
|
97
100
|
});
|
|
98
101
|
return resolved;
|
|
99
102
|
};
|
|
100
|
-
var corePlugin = (config = {}) => {
|
|
101
|
-
const resolved = resolveConfig(config);
|
|
103
|
+
var corePlugin = (config = {}, defaultTheme) => {
|
|
104
|
+
const resolved = resolveConfig(config, defaultTheme);
|
|
102
105
|
return plugin(
|
|
103
106
|
({ addBase, addUtilities, addVariant }) => {
|
|
104
107
|
addBase({
|
|
@@ -138,13 +141,20 @@ var corePlugin = (config = {}) => {
|
|
|
138
141
|
);
|
|
139
142
|
};
|
|
140
143
|
var nextui = (config = {}) => {
|
|
141
|
-
const userLightColors = get(config, "light", {});
|
|
142
|
-
const userDarkColors = get(config, "dark", {});
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
144
|
+
const userLightColors = get(config.themes, "light", {});
|
|
145
|
+
const userDarkColors = get(config.themes, "dark", {});
|
|
146
|
+
const defaultTheme = config.defaultTheme || "light";
|
|
147
|
+
return corePlugin(
|
|
148
|
+
{
|
|
149
|
+
light: deepMerge(semanticColors.light, userLightColors),
|
|
150
|
+
dark: deepMerge(semanticColors.dark, userDarkColors)
|
|
151
|
+
},
|
|
152
|
+
defaultTheme
|
|
153
|
+
);
|
|
147
154
|
};
|
|
155
|
+
nextui({
|
|
156
|
+
defaultTheme: "light"
|
|
157
|
+
});
|
|
148
158
|
export {
|
|
149
159
|
nextui,
|
|
150
160
|
resolveConfig
|