update
This commit is contained in:
185
node_modules/daisyui/functions/addPrefix.js
generated
vendored
Normal file
185
node_modules/daisyui/functions/addPrefix.js
generated
vendored
Normal file
@@ -0,0 +1,185 @@
|
||||
const defaultExcludedPrefixes = ["color-", "size-", "radius-", "border", "depth", "noise"]
|
||||
const excludedSelectors = ["prose"]
|
||||
|
||||
const shouldExcludeVariable = (variableName, excludedPrefixes) => {
|
||||
if (variableName.startsWith("tw")) {
|
||||
return true
|
||||
}
|
||||
return excludedPrefixes.some((excludedPrefix) => variableName.startsWith(excludedPrefix))
|
||||
}
|
||||
|
||||
const prefixVariable = (variableName, prefix, excludedPrefixes) => {
|
||||
if (shouldExcludeVariable(variableName, excludedPrefixes)) {
|
||||
return variableName
|
||||
}
|
||||
return `${prefix}${variableName}`
|
||||
}
|
||||
|
||||
const getPrefixedSelector = (selector, prefix) => {
|
||||
if (!selector.startsWith(".")) return selector
|
||||
if (excludedSelectors.includes(selector.slice(1))) return selector
|
||||
return `.${prefix}${selector.slice(1)}`
|
||||
}
|
||||
|
||||
const getPrefixedKey = (key, prefix, excludedPrefixes) => {
|
||||
const prefixAmpDot = prefix ? `&.${prefix}` : ""
|
||||
|
||||
if (!prefix) return key
|
||||
|
||||
if (key.startsWith(".") && excludedSelectors.includes(key.slice(1))) return key
|
||||
|
||||
if (key.startsWith("--")) {
|
||||
const variableName = key.slice(2)
|
||||
return `--${prefixVariable(variableName, prefix, excludedPrefixes)}`
|
||||
}
|
||||
|
||||
if (key.startsWith("@") || key.startsWith("[")) {
|
||||
return key
|
||||
}
|
||||
|
||||
if (key.startsWith("&")) {
|
||||
// If it's a complex selector with :not(), :has(), etc.
|
||||
if (key.match(/:[a-z-]+\(/)) {
|
||||
return key.replace(/\.([\w-]+)/g, (m, cls) =>
|
||||
excludedSelectors.includes(cls) ? `.${cls}` : `.${prefix}${cls}`,
|
||||
)
|
||||
}
|
||||
// For simple &. cases
|
||||
if (key.startsWith("&.")) {
|
||||
if (excludedSelectors.includes(key.slice(2))) return key
|
||||
return `${prefixAmpDot}${key.slice(2)}`
|
||||
}
|
||||
// For other & cases (like &:hover or &:not(...))
|
||||
return key.replace(/\.([\w-]+)/g, (m, cls) =>
|
||||
excludedSelectors.includes(cls) ? `.${cls}` : `.${prefix}${cls}`,
|
||||
)
|
||||
}
|
||||
|
||||
if (key.startsWith(":")) {
|
||||
return key.replace(/\.([\w-]+)/g, (m, cls) =>
|
||||
excludedSelectors.includes(cls) ? `.${cls}` : `.${prefix}${cls}`,
|
||||
)
|
||||
}
|
||||
|
||||
if (
|
||||
key.includes(".") &&
|
||||
!key.includes(" ") &&
|
||||
!key.includes(">") &&
|
||||
!key.includes("+") &&
|
||||
!key.includes("~")
|
||||
) {
|
||||
return key
|
||||
.split(".")
|
||||
.filter(Boolean)
|
||||
.map((part) => (excludedSelectors.includes(part) ? part : prefix + part))
|
||||
.join(".")
|
||||
.replace(/^/, ".")
|
||||
}
|
||||
|
||||
if (key.includes(">") || key.includes("+") || key.includes("~")) {
|
||||
// For comma-separated selectors
|
||||
if (key.includes(",")) {
|
||||
return key
|
||||
.split(/\s*,\s*/)
|
||||
.map((part) => {
|
||||
// Replace class names with prefixed versions for each part
|
||||
return part.replace(/\.([\w-]+)/g, (m, cls) =>
|
||||
excludedSelectors.includes(cls) ? `.${cls}` : `.${prefix}${cls}`,
|
||||
)
|
||||
})
|
||||
.join(", ")
|
||||
}
|
||||
|
||||
// For simple combinators (not comma-separated)
|
||||
let processedKey = key.replace(/\.([\w-]+)/g, (m, cls) =>
|
||||
excludedSelectors.includes(cls) ? `.${cls}` : `.${prefix}${cls}`,
|
||||
)
|
||||
|
||||
// Add a space before combinators at the beginning
|
||||
if (
|
||||
processedKey.startsWith(">") ||
|
||||
processedKey.startsWith("+") ||
|
||||
processedKey.startsWith("~")
|
||||
) {
|
||||
processedKey = ` ${processedKey}`
|
||||
}
|
||||
|
||||
return processedKey
|
||||
}
|
||||
|
||||
if (key.includes(" ")) {
|
||||
return key
|
||||
.split(/\s+/)
|
||||
.map((part) => {
|
||||
if (part.startsWith(".")) {
|
||||
return excludedSelectors.includes(part.slice(1))
|
||||
? part
|
||||
: getPrefixedSelector(part, prefix)
|
||||
}
|
||||
return part
|
||||
})
|
||||
.join(" ")
|
||||
}
|
||||
|
||||
if (key.includes(":")) {
|
||||
const [selector, ...pseudo] = key.split(":")
|
||||
if (selector.startsWith(".")) {
|
||||
return `${excludedSelectors.includes(selector.slice(1)) ? selector : getPrefixedSelector(selector, prefix)}:${pseudo.join(":")}`
|
||||
}
|
||||
return key.replace(/\.([\w-]+)/g, (m, cls) =>
|
||||
excludedSelectors.includes(cls) ? `.${cls}` : `.${prefix}${cls}`,
|
||||
)
|
||||
}
|
||||
|
||||
if (key.startsWith(".")) {
|
||||
return excludedSelectors.includes(key.slice(1)) ? key : getPrefixedSelector(key, prefix)
|
||||
}
|
||||
|
||||
return key
|
||||
}
|
||||
|
||||
const processArrayValue = (value, prefix, excludedPrefixes) => {
|
||||
return value.map((item) => {
|
||||
if (typeof item === "string") {
|
||||
if (item.startsWith(".")) {
|
||||
return excludedSelectors.includes(item.slice(1))
|
||||
? item
|
||||
: prefix
|
||||
? `.${prefix}${item.slice(1)}`
|
||||
: item
|
||||
}
|
||||
return processStringValue(item, prefix, excludedPrefixes)
|
||||
}
|
||||
return item
|
||||
})
|
||||
}
|
||||
|
||||
const processStringValue = (value, prefix, excludedPrefixes) => {
|
||||
if (prefix === 0) return value
|
||||
return value.replace(/var\(--([^)]+)\)/g, (match, variableName) => {
|
||||
if (shouldExcludeVariable(variableName, excludedPrefixes)) {
|
||||
return match
|
||||
}
|
||||
return `var(--${prefix}${variableName})`
|
||||
})
|
||||
}
|
||||
|
||||
const processValue = (value, prefix, excludedPrefixes) => {
|
||||
if (Array.isArray(value)) {
|
||||
return processArrayValue(value, prefix, excludedPrefixes)
|
||||
} else if (typeof value === "object" && value !== null) {
|
||||
return addPrefix(value, prefix, excludedPrefixes)
|
||||
} else if (typeof value === "string") {
|
||||
return processStringValue(value, prefix, excludedPrefixes)
|
||||
} else {
|
||||
return value
|
||||
}
|
||||
}
|
||||
|
||||
export const addPrefix = (obj, prefix, excludedPrefixes = defaultExcludedPrefixes) => {
|
||||
return Object.entries(obj).reduce((result, [key, value]) => {
|
||||
const newKey = getPrefixedKey(key, prefix, excludedPrefixes)
|
||||
result[newKey] = processValue(value, prefix, excludedPrefixes)
|
||||
return result
|
||||
}, {})
|
||||
}
|
||||
11
node_modules/daisyui/functions/plugin.js
generated
vendored
Normal file
11
node_modules/daisyui/functions/plugin.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
export const plugin = {
|
||||
withOptions: (pluginFunction, configFunction = () => ({})) => {
|
||||
const optionsFunction = (options) => {
|
||||
const handler = pluginFunction(options)
|
||||
const config = configFunction(options)
|
||||
return { handler, config }
|
||||
}
|
||||
optionsFunction.__isOptionsFunction = true
|
||||
return optionsFunction
|
||||
},
|
||||
}
|
||||
97
node_modules/daisyui/functions/pluginOptionsHandler.js
generated
vendored
Normal file
97
node_modules/daisyui/functions/pluginOptionsHandler.js
generated
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
import themeOrder from "./themeOrder.js"
|
||||
|
||||
export const pluginOptionsHandler = (() => {
|
||||
let firstRun = true
|
||||
return (options, addBase, themesObject, packageVersion) => {
|
||||
const {
|
||||
logs = true,
|
||||
root = ":root",
|
||||
themes = ["light --default", "dark --prefersdark"],
|
||||
include,
|
||||
exclude,
|
||||
prefix = "",
|
||||
} = options || {}
|
||||
|
||||
if (logs !== false && firstRun) {
|
||||
console.log(
|
||||
`${atob("Lyoh")} ${decodeURIComponent("%F0%9F%8C%BC")} ${atob("ZGFpc3lVSQ==")} ${packageVersion} ${atob("Ki8=")}`,
|
||||
)
|
||||
firstRun = false
|
||||
}
|
||||
|
||||
const applyTheme = (themeName, flags) => {
|
||||
const theme = themesObject[themeName]
|
||||
if (theme) {
|
||||
// Use prefix for theme-controller class name
|
||||
const themeControllerClass = `${prefix}theme-controller`
|
||||
let selector = `${root}:has(input.${themeControllerClass}[value=${themeName}]:checked),[data-theme=${themeName}]`
|
||||
if (flags.includes("--default")) {
|
||||
selector = `:where(${root}),${selector}`
|
||||
}
|
||||
addBase({ [selector]: theme })
|
||||
|
||||
if (flags.includes("--prefersdark")) {
|
||||
// Use :root:not([data-theme]) for dark mode specificity
|
||||
const darkSelector =
|
||||
root === ":root" ? ":root:not([data-theme])" : `${root}:not([data-theme])`
|
||||
addBase({ "@media (prefers-color-scheme: dark)": { [darkSelector]: theme } })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (themes === "all") {
|
||||
if (themesObject["light"]) {
|
||||
applyTheme("light", ["--default"])
|
||||
}
|
||||
|
||||
if (themesObject["dark"]) {
|
||||
const darkSelector =
|
||||
root === ":root" ? ":root:not([data-theme])" : `${root}:not([data-theme])`
|
||||
addBase({ "@media (prefers-color-scheme: dark)": { [darkSelector]: themesObject["dark"] } })
|
||||
}
|
||||
|
||||
themeOrder.forEach((themeName) => {
|
||||
if (themesObject[themeName]) {
|
||||
applyTheme(themeName, [])
|
||||
}
|
||||
})
|
||||
} else if (themes) {
|
||||
const themeArray = Array.isArray(themes) ? themes : [themes]
|
||||
|
||||
// For single theme with --default flag, skip the other applications
|
||||
if (themeArray.length === 1 && themeArray[0].includes("--default")) {
|
||||
const [themeName, ...flags] = themeArray[0].split(" ")
|
||||
applyTheme(themeName, flags)
|
||||
return { include, exclude, prefix }
|
||||
}
|
||||
|
||||
// default theme
|
||||
themeArray.forEach((themeOption) => {
|
||||
const [themeName, ...flags] = themeOption.split(" ")
|
||||
if (flags.includes("--default")) {
|
||||
applyTheme(themeName, ["--default"])
|
||||
}
|
||||
})
|
||||
|
||||
// prefers dark theme
|
||||
themeArray.forEach((themeOption) => {
|
||||
const [themeName, ...flags] = themeOption.split(" ")
|
||||
if (flags.includes("--prefersdark")) {
|
||||
const darkSelector =
|
||||
root === ":root" ? ":root:not([data-theme])" : `${root}:not([data-theme])`
|
||||
addBase({
|
||||
"@media (prefers-color-scheme: dark)": { [darkSelector]: themesObject[themeName] },
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
// other themes
|
||||
themeArray.forEach((themeOption) => {
|
||||
const [themeName] = themeOption.split(" ")
|
||||
applyTheme(themeName, [])
|
||||
})
|
||||
}
|
||||
|
||||
return { include, exclude, prefix }
|
||||
}
|
||||
})()
|
||||
37
node_modules/daisyui/functions/themeOrder.js
generated
vendored
Normal file
37
node_modules/daisyui/functions/themeOrder.js
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
export default [
|
||||
"light",
|
||||
"dark",
|
||||
"cupcake",
|
||||
"bumblebee",
|
||||
"emerald",
|
||||
"corporate",
|
||||
"synthwave",
|
||||
"retro",
|
||||
"cyberpunk",
|
||||
"valentine",
|
||||
"halloween",
|
||||
"garden",
|
||||
"forest",
|
||||
"aqua",
|
||||
"lofi",
|
||||
"pastel",
|
||||
"fantasy",
|
||||
"wireframe",
|
||||
"black",
|
||||
"luxury",
|
||||
"dracula",
|
||||
"cmyk",
|
||||
"autumn",
|
||||
"business",
|
||||
"acid",
|
||||
"lemonade",
|
||||
"night",
|
||||
"coffee",
|
||||
"winter",
|
||||
"dim",
|
||||
"nord",
|
||||
"sunset",
|
||||
"caramellatte",
|
||||
"abyss",
|
||||
"silk",
|
||||
]
|
||||
29
node_modules/daisyui/functions/variables.js
generated
vendored
Normal file
29
node_modules/daisyui/functions/variables.js
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
export default {
|
||||
colors: {
|
||||
"base-100": "var(--color-base-100)",
|
||||
"base-200": "var(--color-base-200)",
|
||||
"base-300": "var(--color-base-300)",
|
||||
"base-content": "var(--color-base-content)",
|
||||
primary: "var(--color-primary)",
|
||||
"primary-content": "var(--color-primary-content)",
|
||||
secondary: "var(--color-secondary)",
|
||||
"secondary-content": "var(--color-secondary-content)",
|
||||
accent: "var(--color-accent)",
|
||||
"accent-content": "var(--color-accent-content)",
|
||||
neutral: "var(--color-neutral)",
|
||||
"neutral-content": "var(--color-neutral-content)",
|
||||
info: "var(--color-info)",
|
||||
"info-content": "var(--color-info-content)",
|
||||
success: "var(--color-success)",
|
||||
"success-content": "var(--color-success-content)",
|
||||
warning: "var(--color-warning)",
|
||||
"warning-content": "var(--color-warning-content)",
|
||||
error: "var(--color-error)",
|
||||
"error-content": "var(--color-error-content)",
|
||||
},
|
||||
borderRadius: {
|
||||
selector: "var(--radius-selector)",
|
||||
field: "var(--radius-field)",
|
||||
box: "var(--radius-box)",
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user