daisyui 2.6.4 → 2.9.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "daisyui",
3
- "version": "2.6.4",
3
+ "version": "2.9.0",
4
4
  "description": "daisyUI - Tailwind CSS Components",
5
5
  "author": "Pouya Saadeghi",
6
6
  "license": "MIT",
package/src/index.js CHANGED
@@ -1,3 +1,6 @@
1
+ const postcssJs = require("postcss-js")
2
+ const postcssPrefix = require('./lib/postcss-prefixer')
3
+
1
4
  const daisyuiInfo = require("../package.json");
2
5
  const colors = require("./colors/index");
3
6
  const utilities = require("../dist/utilities");
@@ -6,12 +9,12 @@ const unstyled = require("../dist/unstyled");
6
9
  const unstyledRtl = require("../dist/unstyled.rtl");
7
10
  const styled = require("../dist/styled");
8
11
  const styledRtl = require("../dist/styled.rtl");
9
- let utilitiesUnstyled = require("../dist/utilities-unstyled");
10
- let utilitiesStyled = require("../dist/utilities-styled");
12
+ const utilitiesUnstyled = require("../dist/utilities-unstyled");
13
+ const utilitiesStyled = require("../dist/utilities-styled");
11
14
  const themes = require("./colors/themes");
12
15
  const colorFunctions = require("./colors/functions");
13
16
 
14
- const mainFunction = ({ addBase, addComponents, addUtilities, config }) => {
17
+ const mainFunction = ({ addBase, addComponents, addUtilities, config, postcss }) => {
15
18
  let diasyuiIncludedItems = [];
16
19
  let logs = false;
17
20
  if (config("daisyui.logs") != false) {
@@ -64,21 +67,17 @@ const mainFunction = ({ addBase, addComponents, addUtilities, config }) => {
64
67
 
65
68
  // add prefix to class names if specified
66
69
  const prefix = config("daisyui.prefix")
67
- let postcssJs, postcssPrefix
70
+ let postcssJsProcess
68
71
  if (prefix) {
69
72
  try {
70
- postcssJs = require("postcss-js")
71
- postcssPrefix = require('./lib/postcss-prefixer')
73
+ postcssJsProcess = postcssJs.sync(postcssPrefix({ prefix, ignore: [] }))
72
74
  } catch (error) {
73
75
  logs && console.error(`Error occurred and prevent applying the "prefix" option:`, error)
74
76
  }
75
77
  }
76
- const shouldApplyPrefix = prefix && postcssPrefix && postcssJs
78
+ const shouldApplyPrefix = prefix && postcssJsProcess;
77
79
  if (shouldApplyPrefix) {
78
- file = postcssJs.sync(postcssPrefix({
79
- prefix: prefix,
80
- ignore: []
81
- }))(file)
80
+ file = postcssJsProcess(file)
82
81
  }
83
82
 
84
83
  addComponents(file);
@@ -91,20 +90,18 @@ const mainFunction = ({ addBase, addComponents, addUtilities, config }) => {
91
90
  // inject @utilities style needed by components
92
91
  if (config("daisyui.utils") != false) {
93
92
  addComponents(utilities, { variants: ["responsive"] });
93
+
94
+ let toAdd = utilitiesUnstyled // shadow clone here to avoid mutate the original
94
95
  if (shouldApplyPrefix) {
95
- utilitiesUnstyled = postcssJs.sync(postcssPrefix({
96
- prefix: prefix,
97
- ignore: []
98
- }))(utilitiesUnstyled)
96
+ toAdd = postcssJsProcess(toAdd);
99
97
  }
100
- addComponents(utilitiesUnstyled, { variants: ["responsive"] });
98
+ addComponents(toAdd, { variants: ["responsive"] });
99
+
100
+ toAdd = utilitiesStyled
101
101
  if (shouldApplyPrefix) {
102
- utilitiesStyled = postcssJs.sync(postcssPrefix({
103
- prefix: prefix,
104
- ignore: []
105
- }))(utilitiesStyled)
102
+ toAdd = postcssJsProcess(toAdd);
106
103
  }
107
- addComponents(utilitiesStyled, { variants: ["responsive"] });
104
+ addComponents(toAdd, { variants: ["responsive"] });
108
105
  diasyuiIncludedItems.push("utilities");
109
106
  }
110
107
  if (logs) {