daisyui 4.3.0-alpha.7 → 4.3.0-alpha.8

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/package.json CHANGED
@@ -1,11 +1,10 @@
1
1
  {
2
2
  "name": "daisyui",
3
- "version": "4.3.0-alpha.7",
3
+ "version": "4.3.0-alpha.8",
4
4
  "description": "daisyUI - Tailwind CSS Components",
5
5
  "author": "Pouya Saadeghi",
6
6
  "license": "MIT",
7
7
  "homepage": "https://daisyui.com",
8
- "type": "module",
9
8
  "repository": {
10
9
  "type": "git",
11
10
  "url": "git+https://github.com/saadeghi/daisyui.git"
@@ -33,16 +32,16 @@
33
32
  "ui"
34
33
  ],
35
34
  "main": "src/index.js",
36
- "module": "src/index.js",
35
+ "typings": "src/index.d.ts",
37
36
  "types": "src/index.d.ts",
38
37
  "files": [
39
- "themes.js",
40
38
  "src/lib/**/*.js",
41
- "dist/*.cjs",
39
+ "dist/*.js",
42
40
  "dist/{themes,styled,unstyled,full}.css",
43
41
  "src/index.js",
44
42
  "src/theming/*.js",
45
- "src/**/*.d.ts"
43
+ "src/theming/*.d.ts",
44
+ "src/index.d.ts"
46
45
  ],
47
46
  "engines": {
48
47
  "node": ">=16.9.0"
package/src/index.js CHANGED
@@ -1,22 +1,22 @@
1
1
  // const tailwindColors = require("tailwindcss/colors")
2
2
  // const tailwindPlugin = require("tailwindcss/plugin")
3
- import tailwindPlugin from "./lib/createPlugin"
3
+ const tailwindPlugin = require("./lib/createPlugin")
4
4
 
5
- import { sync } from "postcss-js"
6
- import { magenta, dim, yellow, blue, reset, green } from "picocolors"
7
- import postcssPrefix from "./lib/addPrefix"
5
+ const postcssJs = require("postcss-js")
6
+ const pc = require("picocolors")
7
+ const postcssPrefix = require("./lib/addPrefix")
8
8
 
9
- import { version, funding } from "../package.json"
10
- import utilities from "../dist/utilities.cjs"
11
- import base from "../dist/base.cjs"
12
- import unstyled from "../dist/unstyled.cjs"
13
- import styled from "../dist/styled.cjs"
14
- import utilitiesUnstyled from "../dist/utilities-unstyled.cjs"
15
- import utilitiesStyled from "../dist/utilities-styled.cjs"
16
- import { themes } from "./theming/themes"
17
- import { injectThemes } from "./theming/functions"
18
- import { utilityClasses } from "./lib/utility-classes"
19
- import colorObject from "./theming/index"
9
+ const daisyuiInfo = require("../package.json")
10
+ const utilities = require("../dist/utilities")
11
+ const base = require("../dist/base")
12
+ const unstyled = require("../dist/unstyled")
13
+ const styled = require("../dist/styled")
14
+ const utilitiesUnstyled = require("../dist/utilities-unstyled")
15
+ const utilitiesStyled = require("../dist/utilities-styled")
16
+ const themes = require("./theming/themes")
17
+ const colorFunctions = require("./theming/functions")
18
+ const utilityClasses = require("./lib/utility-classes")
19
+ let colorObject = require("./theming/index")
20
20
 
21
21
  const mainFunction = ({ addBase, addComponents, config }) => {
22
22
  let logs = false
@@ -25,7 +25,7 @@ const mainFunction = ({ addBase, addComponents, config }) => {
25
25
  }
26
26
  if (logs) {
27
27
  console.log()
28
- console.log(`🌼 ${magenta("daisyUI")} ${dim(version)}`)
28
+ console.log(`🌼 ${pc.magenta("daisyUI")} ${pc.dim(daisyuiInfo.version)}`)
29
29
  }
30
30
 
31
31
  // inject @base style
@@ -44,7 +44,7 @@ const mainFunction = ({ addBase, addComponents, config }) => {
44
44
  let postcssJsProcess
45
45
  if (prefix) {
46
46
  try {
47
- postcssJsProcess = sync(postcssPrefix({ prefix, ignore: [] }))
47
+ postcssJsProcess = postcssJs.sync(postcssPrefix({ prefix, ignore: [] }))
48
48
  } catch (error) {
49
49
  logs && console.error(`Error occurred and prevent applying the "prefix" option:`, error)
50
50
  }
@@ -56,7 +56,7 @@ const mainFunction = ({ addBase, addComponents, config }) => {
56
56
 
57
57
  addComponents(file)
58
58
 
59
- const themeInjector = injectThemes(addBase, config, themes)
59
+ const themeInjector = colorFunctions.injectThemes(addBase, config, themes)
60
60
  themeInjector
61
61
 
62
62
  // inject @utilities style needed by components
@@ -79,42 +79,44 @@ const mainFunction = ({ addBase, addComponents, config }) => {
79
79
  if (logs) {
80
80
  if (config("daisyui.styled") == false) {
81
81
  console.log(
82
- `├─ ${yellow("ℹ︎")} ${blue("styled")} ${reset("config is")} ${blue("false")} ${dim(
83
- "\tcomponents won't have design decisions"
84
- )}`
82
+ `├─ ${pc.yellow("ℹ︎")} ${pc.blue("styled")} ${pc.reset("config is")} ${pc.blue(
83
+ "false"
84
+ )} ${pc.dim("\tcomponents won't have design decisions")}`
85
85
  )
86
86
  }
87
87
  if (config("daisyui.utils") == false) {
88
88
  console.log(
89
- `├─ ${yellow("ℹ︎")} ${blue("utils")} ${reset("config is")} ${blue("false")} ${dim(
90
- "\tdaisyUI utility classes are disabled"
91
- )}`
89
+ `├─ ${pc.yellow("ℹ︎")} ${pc.blue("utils")} ${pc.reset("config is")} ${pc.blue(
90
+ "false"
91
+ )} ${pc.dim("\tdaisyUI utility classes are disabled")}`
92
92
  )
93
93
  }
94
94
  if (config("daisyui.prefix") && config("daisyui.prefix") !== "") {
95
95
  console.log(
96
- `├─ ${green("✔︎")} ${blue("prefix")} is enabled${dim(
96
+ `├─ ${pc.green("✔︎")} ${pc.blue("prefix")} is enabled${pc.dim(
97
97
  "\t\tdaisyUI classnames must use"
98
- )} ${blue(config("daisyui.prefix"))} ${dim("prefix")}`
98
+ )} ${pc.blue(config("daisyui.prefix"))} ${pc.dim("prefix")}`
99
99
  )
100
100
  }
101
101
  if (themeInjector.themeOrder.length > 0) {
102
102
  console.log(
103
- `├─ ${green("✔︎")} ${themeInjector.themeOrder.length} ${
103
+ `├─ ${pc.green("✔︎")} ${themeInjector.themeOrder.length} ${
104
104
  themeInjector.themeOrder.length > 1 ? "themes" : "theme"
105
- } added${dim("\t\thttps://daisyui.com/docs/themes")}`
105
+ } added${pc.dim("\t\thttps://daisyui.com/docs/themes")}`
106
106
  )
107
107
  }
108
108
  if (themeInjector.themeOrder.length === 0) {
109
109
  console.log(
110
- `├─ ${yellow("ℹ︎")} All themes are disabled in config${dim(
110
+ `├─ ${pc.yellow("ℹ︎")} All themes are disabled in config${pc.dim(
111
111
  "\t\thttps://daisyui.com/docs/themes"
112
112
  )}`
113
113
  )
114
114
  }
115
115
  let messages = [
116
- `${green("❤︎")} ${reset("Support daisyUI project:")}\t${dim(funding.url)}`,
117
- `${green("★")} ${reset("Star daisyUI on GitHub")}\t${dim(
116
+ `${pc.green("❤︎")} ${pc.reset("Support daisyUI project:")}\t${pc.dim(
117
+ daisyuiInfo.funding.url
118
+ )}`,
119
+ `${pc.green("★")} ${pc.reset("Star daisyUI on GitHub")}\t${pc.dim(
118
120
  "https://github.com/saadeghi/daisyui"
119
121
  )}`,
120
122
  ]
@@ -123,7 +125,7 @@ const mainFunction = ({ addBase, addComponents, config }) => {
123
125
  }
124
126
  }
125
127
 
126
- export default tailwindPlugin(mainFunction, {
128
+ module.exports = tailwindPlugin(mainFunction, {
127
129
  theme: {
128
130
  extend: {
129
131
  colors: {
@@ -1,4 +1,4 @@
1
- import { stringify, parse } from "css-selector-tokenizer"
1
+ const Tokenizer = require("css-selector-tokenizer")
2
2
 
3
3
  function itMatchesOne(arr, term) {
4
4
  return arr.some((i) => term.search(i) >= 0)
@@ -61,7 +61,7 @@ function iterateSelectorNodes(selector, options) {
61
61
  return iterateSelectorNodes(node, options)
62
62
  }
63
63
 
64
- if (itMatchesOne(ignore, stringify(node))) return node
64
+ if (itMatchesOne(ignore, Tokenizer.stringify(node))) return node
65
65
 
66
66
  return prefixNode(node, prefix)
67
67
  }),
@@ -71,7 +71,7 @@ function iterateSelectorNodes(selector, options) {
71
71
  /**
72
72
  * @type {import('postcss').PluginCreator}
73
73
  */
74
- export default (opts = {}) => {
74
+ module.exports = (opts = {}) => {
75
75
  const { prefix, ignore } = {
76
76
  prefix: "",
77
77
  ignore: [],
@@ -92,13 +92,13 @@ export default (opts = {}) => {
92
92
  postcssPlugin: "addprefix",
93
93
  Root(root, postcss) {
94
94
  root.walkRules((rule) => {
95
- const parsed = parse(rule.selector)
95
+ const parsed = Tokenizer.parse(rule.selector)
96
96
  const selector = iterateSelectorNodes(parsed, { prefix, ignore })
97
97
 
98
- rule.selector = stringify(selector)
98
+ rule.selector = Tokenizer.stringify(selector)
99
99
  })
100
100
  },
101
101
  }
102
102
  }
103
103
 
104
- export const postcss = true
104
+ module.exports.postcss = true
@@ -4,7 +4,7 @@
4
4
  // regex for all Tailwind CSS color utilities
5
5
  // (bg|to|via|from|text|ring|fill|caret|stroke|border|divide|accent|shadow|outline|decoration|placeholder|ring-offset)
6
6
 
7
- export const responsiveRegex = [
7
+ module.exports = [
8
8
  {
9
9
  pattern: /.*/,
10
10
  },
@@ -1,4 +1,4 @@
1
- export const utilityClasses = {
1
+ module.exports = {
2
2
  borderRadius: {
3
3
  badge: "var(--rounded-badge, 1.9rem)",
4
4
  btn: "var(--rounded-btn, 0.5rem)",
@@ -1,4 +1,4 @@
1
- export const colorNames = {
1
+ module.exports = {
2
2
  "primary": "--p",
3
3
  "primary-content": "--pc",
4
4
 
@@ -1,214 +1,226 @@
1
- import { colorNames } from "./colorNames"
2
- import { variables, themesOrder } from "./themeDefaults"
1
+ const colorNames = require("./colorNames")
2
+ const themeDefaults = require("./themeDefaults")
3
3
 
4
- import { toGamut, interpolate, wcagContrast } from "culori"
4
+ const { toGamut, interpolate, wcagContrast } = require("culori")
5
5
 
6
- const cutNumber = (number) => (number ? +number.toFixed(6) : 0)
7
- const toGamutOKLCH = toGamut("oklch")
6
+ const cutNumber = (number) => (number ? +number.toFixed(6) : 0);
7
+ const toGamutOKLCH = toGamut("oklch");
8
8
 
9
- export function isDark(color) {
10
- if (wcagContrast(color, "black") < wcagContrast(color, "white")) {
11
- return true
12
- }
13
- return false
14
- }
15
- export function colorObjToString({ l, c, h }) {
16
- return `${cutNumber(l)} ${cutNumber(c)} ${cutNumber(h)}`
17
- }
18
- export function generateForegroundColorFrom(input, percentage = 0.8) {
19
- const result = interpolate([input, isDark(input) ? "white" : "black"], "oklch")(percentage)
20
- return colorObjToString(result)
21
- }
22
- export function generateDarkenColorFrom(input, percentage = 0.07) {
23
- const result = interpolate([input, "black"], "oklch")(percentage)
24
- return colorObjToString(result)
25
- }
26
- export function convertColorFormat(input) {
27
- if (typeof input !== "object" || input === null) {
28
- return input
29
- }
9
+ module.exports = {
10
+ isDark: (color) => {
11
+ if (wcagContrast(color, "black") < wcagContrast(color, "white")) {
12
+ return true
13
+ }
14
+ return false
15
+ },
30
16
 
31
- const resultObj = {}
17
+ colorObjToString: function (input) {
18
+ const { l, c, h } = input
19
+ return `${cutNumber(l)} ${cutNumber(c)} ${cutNumber(h)}`
20
+ },
32
21
 
33
- Object.entries(input).forEach(([rule, value]) => {
34
- if (Object.hasOwn(colorNames, rule)) {
35
- const colorObj = toGamutOKLCH(value)
36
- resultObj[colorNames[rule]] = colorObjToString(colorObj)
37
- } else {
38
- resultObj[rule] = value
39
- }
22
+ generateForegroundColorFrom: function (input, percentage = 0.8) {
23
+ const result = interpolate([input, this.isDark(input) ? "white" : "black"], "oklch")(percentage)
24
+ return this.colorObjToString(result)
25
+ },
40
26
 
41
- // auto generate base colors
42
- if (!Object.hasOwn(input, "base-100")) {
43
- resultObj["--b1"] = "100 0 0"
44
- }
45
- if (!Object.hasOwn(input, "base-200")) {
46
- resultObj["--b2"] = generateDarkenColorFrom(input["base-100"], 0.07)
27
+ generateDarkenColorFrom: function (input, percentage = 0.07) {
28
+ const result = interpolate([input, "black"], "oklch")(percentage)
29
+ return this.colorObjToString(result)
30
+ },
31
+
32
+ convertColorFormat: function (input) {
33
+ if (typeof input !== "object" || input === null) {
34
+ return input
47
35
  }
48
- if (!Object.hasOwn(input, "base-300")) {
49
- if (Object.hasOwn(input, "base-200")) {
50
- resultObj["--b3"] = generateDarkenColorFrom(input["base-200"], 0.07)
36
+
37
+ const resultObj = {}
38
+
39
+ Object.entries(input).forEach(([rule, value]) => {
40
+ if (Object.hasOwn(colorNames,rule)) {
41
+ const colorObj = toGamutOKLCH(value)
42
+ resultObj[colorNames[rule]] = this.colorObjToString(colorObj)
51
43
  } else {
52
- resultObj["--b3"] = generateDarkenColorFrom(input["base-100"], 0.14)
44
+ resultObj[rule] = value
53
45
  }
54
- }
55
46
 
56
- // auto generate state colors
57
- if (!Object.hasOwn(input, "info")) {
58
- resultObj["--in"] = "0.7206 0.191 231.6"
59
- }
60
- if (!Object.hasOwn(input, "success")) {
61
- resultObj["--su"] = "0.7441 0.213 164.75"
62
- }
63
- if (!Object.hasOwn(input, "warning")) {
64
- resultObj["--wa"] = "0.8471 0.199 83.87"
65
- }
66
- if (!Object.hasOwn(input, "error")) {
67
- resultObj["--er"] = "0.7176 0.221 22.18"
68
- }
47
+ // auto generate base colors
48
+ if (!Object.hasOwn(input, "base-100")) {
49
+ resultObj["--b1"] = "100 0 0"
50
+ }
51
+ if (!Object.hasOwn(input, "base-200")) {
52
+ resultObj["--b2"] = this.generateDarkenColorFrom(input["base-100"], 0.07)
53
+ }
54
+ if (!Object.hasOwn(input, "base-300")) {
55
+ if (Object.hasOwn(input, "base-200")) {
56
+ resultObj["--b3"] = this.generateDarkenColorFrom(input["base-200"], 0.07)
57
+ } else {
58
+ resultObj["--b3"] = this.generateDarkenColorFrom(input["base-100"], 0.14)
59
+ }
60
+ }
69
61
 
70
- // auto generate content colors
71
- if (!Object.hasOwn(input, "base-content")) {
72
- resultObj["--bc"] = generateForegroundColorFrom(input["base-100"], 0.8)
73
- }
74
- if (!Object.hasOwn(input, "primary-content")) {
75
- resultObj["--pc"] = generateForegroundColorFrom(input["primary"], 0.8)
76
- }
77
- if (!Object.hasOwn(input, "secondary-content")) {
78
- resultObj["--sc"] = generateForegroundColorFrom(input["secondary"], 0.8)
79
- }
80
- if (!Object.hasOwn(input, "accent-content")) {
81
- resultObj["--ac"] = generateForegroundColorFrom(input["accent"], 0.8)
82
- }
83
- if (!Object.hasOwn(input, "neutral-content")) {
84
- resultObj["--nc"] = generateForegroundColorFrom(input["neutral"], 0.8)
85
- }
86
- if (!Object.hasOwn(input, "info-content")) {
87
- if (Object.hasOwn(input, "info")) {
88
- resultObj["--inc"] = generateForegroundColorFrom(input["info"], 0.8)
89
- } else {
90
- resultObj["--inc"] = "0 0 0"
62
+ // auto generate state colors
63
+
64
+ if (!Object.hasOwn(input, "info")) {
65
+ resultObj["--in"] = "0.7206 0.191 231.6"
91
66
  }
92
- }
93
- if (!Object.hasOwn(input, "success-content")) {
94
- if (Object.hasOwn(input, "success")) {
95
- resultObj["--suc"] = generateForegroundColorFrom(input["success"], 0.8)
96
- } else {
97
- resultObj["--suc"] = "0 0 0"
67
+ if (!Object.hasOwn(input, "success")) {
68
+ resultObj["--su"] = "0.7441 0.213 164.75"
98
69
  }
99
- }
100
- if (!Object.hasOwn(input, "warning-content")) {
101
- if (Object.hasOwn(input, "warning")) {
102
- resultObj["--wac"] = generateForegroundColorFrom(input["warning"], 0.8)
103
- } else {
104
- resultObj["--wac"] = "0 0 0"
70
+ if (!Object.hasOwn(input, "warning")) {
71
+ resultObj["--wa"] = "0.8471 0.199 83.87"
105
72
  }
106
- }
107
- if (!Object.hasOwn(input, "error-content")) {
108
- if (Object.hasOwn(input, "error")) {
109
- resultObj["--erc"] = generateForegroundColorFrom(input["error"], 0.8)
110
- } else {
111
- resultObj["--erc"] = "0 0 0"
73
+ if (!Object.hasOwn(input, "error")) {
74
+ resultObj["--er"] = "0.7176 0.221 22.18"
112
75
  }
113
- }
114
76
 
115
- // add css variables if not exist
116
- Object.entries(variables).forEach(([variable, value]) => {
117
- if (!Object.hasOwn(input, variable)) {
118
- resultObj[variable] = value
77
+ // auto generate content colors
78
+ if (!Object.hasOwn(input, "base-content")) {
79
+ resultObj["--bc"] = this.generateForegroundColorFrom(input["base-100"], 0.8)
80
+ }
81
+ if (!Object.hasOwn(input, "primary-content")) {
82
+ resultObj["--pc"] = this.generateForegroundColorFrom(input["primary"], 0.8)
83
+ }
84
+ if (!Object.hasOwn(input, "secondary-content")) {
85
+ resultObj["--sc"] = this.generateForegroundColorFrom(input["secondary"], 0.8)
86
+ }
87
+ if (!Object.hasOwn(input, "accent-content")) {
88
+ resultObj["--ac"] = this.generateForegroundColorFrom(input["accent"], 0.8)
89
+ }
90
+ if (!Object.hasOwn(input, "neutral-content")) {
91
+ resultObj["--nc"] = this.generateForegroundColorFrom(input["neutral"], 0.8)
92
+ }
93
+ if (!Object.hasOwn(input, "info-content")) {
94
+ if (Object.hasOwn(input, "info")) {
95
+ resultObj["--inc"] = this.generateForegroundColorFrom(input["info"], 0.8)
96
+ } else {
97
+ resultObj["--inc"] = "0 0 0"
98
+ }
99
+ }
100
+ if (!Object.hasOwn(input, "success-content")) {
101
+ if (Object.hasOwn(input, "success")) {
102
+ resultObj["--suc"] = this.generateForegroundColorFrom(input["success"], 0.8)
103
+ } else {
104
+ resultObj["--suc"] = "0 0 0"
105
+ }
106
+ }
107
+ if (!Object.hasOwn(input, "warning-content")) {
108
+ if (Object.hasOwn(input, "warning")) {
109
+ resultObj["--wac"] = this.generateForegroundColorFrom(input["warning"], 0.8)
110
+ } else {
111
+ resultObj["--wac"] = "0 0 0"
112
+ }
113
+ }
114
+ if (!Object.hasOwn(input, "error-content")) {
115
+ if (Object.hasOwn(input, "error")) {
116
+ resultObj["--erc"] = this.generateForegroundColorFrom(input["error"], 0.8)
117
+ } else {
118
+ resultObj["--erc"] = "0 0 0"
119
+ }
119
120
  }
120
- })
121
121
 
122
- // add other custom styles
123
- if (!Object.hasOwn(colorNames, rule)) {
124
- resultObj[rule] = value
125
- }
126
- })
122
+ // add css variables if not exist
123
+ Object.entries(themeDefaults.variables).forEach((item) => {
124
+ const [variable, value] = item
125
+ if (!Object.hasOwn(input, variable)) {
126
+ resultObj[variable] = value
127
+ }
128
+ })
127
129
 
128
- return resultObj
129
- }
130
- export function injectThemes(addBase, config, themes) {
131
- const includedThemesObj = {}
132
- // add default themes
133
- const themeRoot = config("daisyui.themeRoot") ?? ":root"
134
- Object.entries(themes).forEach(([theme, value]) => {
135
- includedThemesObj[theme] = convertColorFormat(value)
136
- })
137
-
138
- // add custom themes
139
- if (Array.isArray(config("daisyui.themes"))) {
140
- config("daisyui.themes").forEach((item) => {
141
- if (typeof item === "object" && item !== null) {
142
- Object.entries(item).forEach(([customThemeName, customThemevalue]) => {
143
- includedThemesObj[customThemeName] = convertColorFormat(customThemevalue)
144
- })
130
+ // add other custom styles
131
+ if (!Object.hasOwn(colorNames,rule)) {
132
+ resultObj[rule] = value
145
133
  }
146
134
  })
147
- }
148
-
149
- let themeOrder = []
150
- if (Array.isArray(config("daisyui.themes"))) {
151
- config("daisyui.themes").forEach((theme) => {
152
- if (typeof theme === "object" && theme !== null) {
153
- Object.keys(theme).forEach((customThemeName) => {
154
- themeOrder.push(customThemeName)
155
- })
156
- } else if (Object.hasOwn(includedThemesObj, theme)) {
157
- themeOrder.push(theme)
158
- }
135
+
136
+ return resultObj
137
+ },
138
+
139
+ injectThemes: function (addBase, config, themes) {
140
+ const includedThemesObj = {}
141
+ // add default themes
142
+ const themeRoot = config("daisyui.themeRoot") ?? ":root"
143
+ Object.entries(themes).forEach(([theme, value]) => {
144
+ includedThemesObj[theme] = this.convertColorFormat(value)
159
145
  })
160
- } else if (config("daisyui.themes") === true) {
161
- themeOrder = themesOrder
162
- } else {
163
- themeOrder = ["light", "dark"]
164
- }
165
-
166
- // inject themes in order
167
- const themesToInject = {}
168
- themeOrder.forEach((themeName, index) => {
169
- if (index === 0) {
170
- // first theme as root
171
- themesToInject[themeRoot] = includedThemesObj[themeName]
172
- } else if (index === 1) {
173
- // auto dark
174
- if (config("daisyui.darkTheme")) {
175
- if (
176
- themeOrder[0] !== config("daisyui.darkTheme") &&
177
- themeOrder.includes(config("daisyui.darkTheme"))
178
- ) {
179
- themesToInject["@media (prefers-color-scheme: dark)"] = {
180
- [themeRoot]: includedThemesObj[`${config("daisyui.darkTheme")}`],
181
- }
146
+
147
+ // add custom themes
148
+ if (Array.isArray(config("daisyui.themes"))) {
149
+ config("daisyui.themes").forEach((item) => {
150
+ if (typeof item === "object" && item !== null) {
151
+ Object.entries(item).forEach(([customThemeName, customThemevalue]) => {
152
+ includedThemesObj[customThemeName] = this.convertColorFormat(customThemevalue)
153
+ })
182
154
  }
183
- } else if (config("daisyui.darkTheme") === false) {
184
- } else {
185
- if (themeOrder[0] !== "dark" && themeOrder.includes("dark")) {
186
- themesToInject["@media (prefers-color-scheme: dark)"] = {
187
- [themeRoot]: includedThemesObj["dark"],
155
+ })
156
+ }
157
+
158
+ let themeOrder = []
159
+ if (Array.isArray(config("daisyui.themes"))) {
160
+ config("daisyui.themes").forEach((theme) => {
161
+ if (typeof theme === "object" && theme !== null) {
162
+ Object.keys(theme).forEach((customThemeName) => {
163
+ themeOrder.push(customThemeName)
164
+ })
165
+ } else if (Object.hasOwn(includedThemesObj, theme)) {
166
+ themeOrder.push(theme)
167
+ }
168
+ })
169
+ } else if (config("daisyui.themes") === true) {
170
+ themeOrder = themeDefaults.themeOrder
171
+ } else {
172
+ themeOrder = ["light", "dark"]
173
+ }
174
+
175
+ // inject themes in order
176
+ const themesToInject = {}
177
+ themeOrder.forEach((themeName, index) => {
178
+ if (index === 0) {
179
+ // first theme as root
180
+ themesToInject[themeRoot] = includedThemesObj[themeName]
181
+ } else if (index === 1) {
182
+ // auto dark
183
+ if (config("daisyui.darkTheme")) {
184
+ if (
185
+ themeOrder[0] !== config("daisyui.darkTheme") &&
186
+ themeOrder.includes(config("daisyui.darkTheme"))
187
+ ) {
188
+ themesToInject["@media (prefers-color-scheme: dark)"] = {
189
+ [themeRoot]: includedThemesObj[`${config("daisyui.darkTheme")}`],
190
+ }
191
+ }
192
+ } else if (config("daisyui.darkTheme") === false) {
193
+ // disables prefers-color-scheme: dark
194
+ } else {
195
+ if (themeOrder[0] !== "dark" && themeOrder.includes("dark")) {
196
+ themesToInject["@media (prefers-color-scheme: dark)"] = {
197
+ [themeRoot]: includedThemesObj["dark"],
198
+ }
188
199
  }
189
200
  }
201
+ // theme 0 with name
202
+ themesToInject["[data-theme=" + themeOrder[0] + "]"] = includedThemesObj[themeOrder[0]]
203
+ themesToInject[
204
+ themeRoot + ":has(input.theme-controller[value=" + themeOrder[0] + "]:checked)"
205
+ ] = includedThemesObj[themeOrder[0]]
206
+ // theme 1 with name
207
+ themesToInject["[data-theme=" + themeOrder[1] + "]"] = includedThemesObj[themeOrder[1]]
208
+ themesToInject[
209
+ themeRoot + ":has(input.theme-controller[value=" + themeOrder[1] + "]:checked)"
210
+ ] = includedThemesObj[themeOrder[1]]
211
+ } else {
212
+ themesToInject["[data-theme=" + themeName + "]"] = includedThemesObj[themeName]
213
+ themesToInject[
214
+ themeRoot + ":has(input.theme-controller[value=" + themeName + "]:checked)"
215
+ ] = includedThemesObj[themeName]
190
216
  }
191
- // theme 0 with name
192
- themesToInject["[data-theme=" + themeOrder[0] + "]"] = includedThemesObj[themeOrder[0]]
193
- themesToInject[
194
- themeRoot + ":has(input.theme-controller[value=" + themeOrder[0] + "]:checked)"
195
- ] = includedThemesObj[themeOrder[0]]
196
- // theme 1 with name
197
- themesToInject["[data-theme=" + themeOrder[1] + "]"] = includedThemesObj[themeOrder[1]]
198
- themesToInject[
199
- themeRoot + ":has(input.theme-controller[value=" + themeOrder[1] + "]:checked)"
200
- ] = includedThemesObj[themeOrder[1]]
201
- } else {
202
- themesToInject["[data-theme=" + themeName + "]"] = includedThemesObj[themeName]
203
- themesToInject[themeRoot + ":has(input.theme-controller[value=" + themeName + "]:checked)"] =
204
- includedThemesObj[themeName]
205
- }
206
- })
217
+ })
207
218
 
208
- addBase(themesToInject)
219
+ addBase(themesToInject)
209
220
 
210
- return {
211
- includedThemesObj,
212
- themeOrder,
213
- }
221
+ return {
222
+ includedThemesObj,
223
+ themeOrder,
224
+ }
225
+ },
214
226
  }
@@ -32,4 +32,4 @@ const colorObject = {
32
32
  "error-content": "var(--fallback-erc,oklch(var(--erc)/<alpha-value>))",
33
33
  }
34
34
 
35
- export default colorObject
35
+ module.exports = colorObject