@nextui-org/theme 0.0.0-dev-v2-20231104194339 → 0.0.0-dev-v2-20231105140217

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.
@@ -37,13 +37,14 @@ import mapKeys from "lodash.mapkeys";
37
37
  import kebabCase from "lodash.kebabcase";
38
38
  import deepMerge from "deepmerge";
39
39
  var DEFAULT_PREFIX = "nextui";
40
+ var parsedColorsCache = {};
40
41
  var resolveConfig = (themes = {}, defaultTheme, prefix) => {
41
42
  const resolved = {
42
43
  variants: [],
43
44
  utilities: {},
44
45
  colors: {}
45
46
  };
46
- forEach(themes, ({ extend, layout, colors }, themeName) => {
47
+ for (const [themeName, { extend, layout, colors }] of Object.entries(themes)) {
47
48
  let cssSelector = `.${themeName},[data-theme="${themeName}"]`;
48
49
  const scheme = themeName === "light" || themeName === "dark" ? themeName : extend;
49
50
  if (themeName === defaultTheme) {
@@ -58,11 +59,13 @@ var resolveConfig = (themes = {}, defaultTheme, prefix) => {
58
59
  name: themeName,
59
60
  definition: [`&.${themeName}`, `&[data-theme='${themeName}']`]
60
61
  });
61
- forEach(flatColors, (colorValue, colorName) => {
62
+ for (const [colorName, colorValue] of Object.entries(flatColors)) {
62
63
  if (!colorValue)
63
64
  return;
64
65
  try {
65
- const [h, s, l, defaultAlphaValue] = Color(colorValue).hsl().round().array();
66
+ const parsedColor = parsedColorsCache[colorValue] || Color(colorValue).hsl().round().array();
67
+ parsedColorsCache[colorValue] = parsedColor;
68
+ const [h, s, l, defaultAlphaValue] = parsedColor;
66
69
  const nextuiColorVariable = `--${prefix}-${colorName}`;
67
70
  const nextuiOpacityVariable = `--${prefix}-${colorName}-opacity`;
68
71
  resolved.utilities[cssSelector][nextuiColorVariable] = `${h} ${s}% ${l}%`;
@@ -81,32 +84,31 @@ var resolveConfig = (themes = {}, defaultTheme, prefix) => {
81
84
  } catch (error) {
82
85
  console.log("error", error == null ? void 0 : error.message);
83
86
  }
84
- });
85
- forEach(flatLayout, (value, key) => {
87
+ }
88
+ for (const [key, value] of Object.entries(flatLayout)) {
86
89
  if (!value)
87
90
  return;
91
+ const layoutVariablePrefix = `--${prefix}-${key}`;
88
92
  if (typeof value === "object") {
89
- forEach(value, (v, k) => {
90
- const layoutVariable = `--${prefix}-${key}-${k}`;
91
- resolved.utilities[cssSelector][layoutVariable] = v;
92
- });
93
- } else if (key === "spacing-unit") {
94
- const layoutVariable = `--${prefix}-${key}`;
95
- resolved.utilities[cssSelector][layoutVariable] = value;
96
- const spacingScale = generateSpacingScale(Number(value));
97
- forEach(spacingScale, (v, k) => {
98
- const layoutVariable2 = `--${prefix}-${key}-${k}`;
99
- resolved.utilities[cssSelector][layoutVariable2] = v;
100
- });
93
+ for (const [nestedKey, nestedValue] of Object.entries(value)) {
94
+ const nestedLayoutVariable = `${layoutVariablePrefix}-${nestedKey}`;
95
+ resolved.utilities[cssSelector][nestedLayoutVariable] = nestedValue;
96
+ }
101
97
  } else {
102
- const layoutVariable = `--${prefix}-${key}`;
103
- if (layoutVariable.includes("opacity") && typeof value === "number") {
104
- value = value.toString().replace(/^0\./, ".");
98
+ if (key === "spacing-unit") {
99
+ resolved.utilities[cssSelector][layoutVariablePrefix] = value;
100
+ const spacingScale = generateSpacingScale(Number(value));
101
+ for (const [scaleKey, scaleValue] of Object.entries(spacingScale)) {
102
+ const spacingVariable = `${layoutVariablePrefix}-${scaleKey}`;
103
+ resolved.utilities[cssSelector][spacingVariable] = scaleValue;
104
+ }
105
+ } else {
106
+ const formattedValue = layoutVariablePrefix.includes("opacity") && typeof value === "number" ? value.toString().replace(/^0\./, ".") : value;
107
+ resolved.utilities[cssSelector][layoutVariablePrefix] = formattedValue;
105
108
  }
106
- resolved.utilities[cssSelector][layoutVariable] = value;
107
109
  }
108
- });
109
- });
110
+ }
111
+ }
110
112
  return resolved;
111
113
  };
112
114
  var corePlugin = (themes = {}, defaultTheme, prefix, addCommonColors) => {
@@ -136,8 +138,8 @@ var corePlugin = (themes = {}, defaultTheme, prefix, addCommonColors) => {
136
138
  ...baseStyles(prefix)
137
139
  }
138
140
  });
139
- addUtilities({ ...resolved.utilities, ...utilities });
140
- resolved.variants.forEach((variant) => {
141
+ addUtilities({ ...resolved == null ? void 0 : resolved.utilities, ...utilities });
142
+ resolved == null ? void 0 : resolved.variants.forEach((variant) => {
141
143
  addVariant(variant.name, variant.definition);
142
144
  });
143
145
  },
@@ -146,7 +148,7 @@ var corePlugin = (themes = {}, defaultTheme, prefix, addCommonColors) => {
146
148
  extend: {
147
149
  colors: {
148
150
  ...addCommonColors ? commonColors : {},
149
- ...resolved.colors
151
+ ...resolved == null ? void 0 : resolved.colors
150
152
  },
151
153
  scale: {
152
154
  "80": "0.8",
package/dist/index.js CHANGED
@@ -8492,13 +8492,14 @@ var darkLayout = {
8492
8492
 
8493
8493
  // src/plugin.ts
8494
8494
  var DEFAULT_PREFIX = "nextui";
8495
+ var parsedColorsCache = {};
8495
8496
  var resolveConfig = (themes = {}, defaultTheme, prefix) => {
8496
8497
  const resolved = {
8497
8498
  variants: [],
8498
8499
  utilities: {},
8499
8500
  colors: {}
8500
8501
  };
8501
- (0, import_lodash3.default)(themes, ({ extend, layout, colors: colors2 }, themeName) => {
8502
+ for (const [themeName, { extend, layout, colors: colors2 }] of Object.entries(themes)) {
8502
8503
  let cssSelector = `.${themeName},[data-theme="${themeName}"]`;
8503
8504
  const scheme = themeName === "light" || themeName === "dark" ? themeName : extend;
8504
8505
  if (themeName === defaultTheme) {
@@ -8513,11 +8514,13 @@ var resolveConfig = (themes = {}, defaultTheme, prefix) => {
8513
8514
  name: themeName,
8514
8515
  definition: [`&.${themeName}`, `&[data-theme='${themeName}']`]
8515
8516
  });
8516
- (0, import_lodash3.default)(flatColors, (colorValue, colorName) => {
8517
+ for (const [colorName, colorValue] of Object.entries(flatColors)) {
8517
8518
  if (!colorValue)
8518
8519
  return;
8519
8520
  try {
8520
- const [h, s, l, defaultAlphaValue] = (0, import_color.default)(colorValue).hsl().round().array();
8521
+ const parsedColor = parsedColorsCache[colorValue] || (0, import_color.default)(colorValue).hsl().round().array();
8522
+ parsedColorsCache[colorValue] = parsedColor;
8523
+ const [h, s, l, defaultAlphaValue] = parsedColor;
8521
8524
  const nextuiColorVariable = `--${prefix}-${colorName}`;
8522
8525
  const nextuiOpacityVariable = `--${prefix}-${colorName}-opacity`;
8523
8526
  resolved.utilities[cssSelector][nextuiColorVariable] = `${h} ${s}% ${l}%`;
@@ -8536,32 +8539,31 @@ var resolveConfig = (themes = {}, defaultTheme, prefix) => {
8536
8539
  } catch (error) {
8537
8540
  console.log("error", error == null ? void 0 : error.message);
8538
8541
  }
8539
- });
8540
- (0, import_lodash3.default)(flatLayout, (value, key) => {
8542
+ }
8543
+ for (const [key, value] of Object.entries(flatLayout)) {
8541
8544
  if (!value)
8542
8545
  return;
8546
+ const layoutVariablePrefix = `--${prefix}-${key}`;
8543
8547
  if (typeof value === "object") {
8544
- (0, import_lodash3.default)(value, (v, k) => {
8545
- const layoutVariable = `--${prefix}-${key}-${k}`;
8546
- resolved.utilities[cssSelector][layoutVariable] = v;
8547
- });
8548
- } else if (key === "spacing-unit") {
8549
- const layoutVariable = `--${prefix}-${key}`;
8550
- resolved.utilities[cssSelector][layoutVariable] = value;
8551
- const spacingScale = generateSpacingScale(Number(value));
8552
- (0, import_lodash3.default)(spacingScale, (v, k) => {
8553
- const layoutVariable2 = `--${prefix}-${key}-${k}`;
8554
- resolved.utilities[cssSelector][layoutVariable2] = v;
8555
- });
8548
+ for (const [nestedKey, nestedValue] of Object.entries(value)) {
8549
+ const nestedLayoutVariable = `${layoutVariablePrefix}-${nestedKey}`;
8550
+ resolved.utilities[cssSelector][nestedLayoutVariable] = nestedValue;
8551
+ }
8556
8552
  } else {
8557
- const layoutVariable = `--${prefix}-${key}`;
8558
- if (layoutVariable.includes("opacity") && typeof value === "number") {
8559
- value = value.toString().replace(/^0\./, ".");
8553
+ if (key === "spacing-unit") {
8554
+ resolved.utilities[cssSelector][layoutVariablePrefix] = value;
8555
+ const spacingScale = generateSpacingScale(Number(value));
8556
+ for (const [scaleKey, scaleValue] of Object.entries(spacingScale)) {
8557
+ const spacingVariable = `${layoutVariablePrefix}-${scaleKey}`;
8558
+ resolved.utilities[cssSelector][spacingVariable] = scaleValue;
8559
+ }
8560
+ } else {
8561
+ const formattedValue = layoutVariablePrefix.includes("opacity") && typeof value === "number" ? value.toString().replace(/^0\./, ".") : value;
8562
+ resolved.utilities[cssSelector][layoutVariablePrefix] = formattedValue;
8560
8563
  }
8561
- resolved.utilities[cssSelector][layoutVariable] = value;
8562
8564
  }
8563
- });
8564
- });
8565
+ }
8566
+ }
8565
8567
  return resolved;
8566
8568
  };
8567
8569
  var corePlugin = (themes = {}, defaultTheme, prefix, addCommonColors) => {
@@ -8591,8 +8593,8 @@ var corePlugin = (themes = {}, defaultTheme, prefix, addCommonColors) => {
8591
8593
  ...baseStyles(prefix)
8592
8594
  }
8593
8595
  });
8594
- addUtilities({ ...resolved.utilities, ...utilities });
8595
- resolved.variants.forEach((variant) => {
8596
+ addUtilities({ ...resolved == null ? void 0 : resolved.utilities, ...utilities });
8597
+ resolved == null ? void 0 : resolved.variants.forEach((variant) => {
8596
8598
  addVariant(variant.name, variant.definition);
8597
8599
  });
8598
8600
  },
@@ -8601,7 +8603,7 @@ var corePlugin = (themes = {}, defaultTheme, prefix, addCommonColors) => {
8601
8603
  extend: {
8602
8604
  colors: {
8603
8605
  ...addCommonColors ? commonColors : {},
8604
- ...resolved.colors
8606
+ ...resolved == null ? void 0 : resolved.colors
8605
8607
  },
8606
8608
  scale: {
8607
8609
  "80": "0.8",
package/dist/index.mjs CHANGED
@@ -130,7 +130,7 @@ import {
130
130
  } from "./chunk-WBUVHAJX.mjs";
131
131
  import {
132
132
  nextui
133
- } from "./chunk-6XG3Y4GM.mjs";
133
+ } from "./chunk-5QVKTCUZ.mjs";
134
134
  import "./chunk-S7W5DQP2.mjs";
135
135
  import "./chunk-DI2L75XK.mjs";
136
136
  import "./chunk-4Z22WXZX.mjs";
package/dist/plugin.js CHANGED
@@ -711,13 +711,14 @@ var baseStyles = (prefix) => ({
711
711
 
712
712
  // src/plugin.ts
713
713
  var DEFAULT_PREFIX = "nextui";
714
+ var parsedColorsCache = {};
714
715
  var resolveConfig = (themes = {}, defaultTheme, prefix) => {
715
716
  const resolved = {
716
717
  variants: [],
717
718
  utilities: {},
718
719
  colors: {}
719
720
  };
720
- (0, import_lodash3.default)(themes, ({ extend, layout, colors: colors2 }, themeName) => {
721
+ for (const [themeName, { extend, layout, colors: colors2 }] of Object.entries(themes)) {
721
722
  let cssSelector = `.${themeName},[data-theme="${themeName}"]`;
722
723
  const scheme = themeName === "light" || themeName === "dark" ? themeName : extend;
723
724
  if (themeName === defaultTheme) {
@@ -732,11 +733,13 @@ var resolveConfig = (themes = {}, defaultTheme, prefix) => {
732
733
  name: themeName,
733
734
  definition: [`&.${themeName}`, `&[data-theme='${themeName}']`]
734
735
  });
735
- (0, import_lodash3.default)(flatColors, (colorValue, colorName) => {
736
+ for (const [colorName, colorValue] of Object.entries(flatColors)) {
736
737
  if (!colorValue)
737
738
  return;
738
739
  try {
739
- const [h, s, l, defaultAlphaValue] = (0, import_color.default)(colorValue).hsl().round().array();
740
+ const parsedColor = parsedColorsCache[colorValue] || (0, import_color.default)(colorValue).hsl().round().array();
741
+ parsedColorsCache[colorValue] = parsedColor;
742
+ const [h, s, l, defaultAlphaValue] = parsedColor;
740
743
  const nextuiColorVariable = `--${prefix}-${colorName}`;
741
744
  const nextuiOpacityVariable = `--${prefix}-${colorName}-opacity`;
742
745
  resolved.utilities[cssSelector][nextuiColorVariable] = `${h} ${s}% ${l}%`;
@@ -755,32 +758,31 @@ var resolveConfig = (themes = {}, defaultTheme, prefix) => {
755
758
  } catch (error) {
756
759
  console.log("error", error == null ? void 0 : error.message);
757
760
  }
758
- });
759
- (0, import_lodash3.default)(flatLayout, (value, key) => {
761
+ }
762
+ for (const [key, value] of Object.entries(flatLayout)) {
760
763
  if (!value)
761
764
  return;
765
+ const layoutVariablePrefix = `--${prefix}-${key}`;
762
766
  if (typeof value === "object") {
763
- (0, import_lodash3.default)(value, (v, k) => {
764
- const layoutVariable = `--${prefix}-${key}-${k}`;
765
- resolved.utilities[cssSelector][layoutVariable] = v;
766
- });
767
- } else if (key === "spacing-unit") {
768
- const layoutVariable = `--${prefix}-${key}`;
769
- resolved.utilities[cssSelector][layoutVariable] = value;
770
- const spacingScale = generateSpacingScale(Number(value));
771
- (0, import_lodash3.default)(spacingScale, (v, k) => {
772
- const layoutVariable2 = `--${prefix}-${key}-${k}`;
773
- resolved.utilities[cssSelector][layoutVariable2] = v;
774
- });
767
+ for (const [nestedKey, nestedValue] of Object.entries(value)) {
768
+ const nestedLayoutVariable = `${layoutVariablePrefix}-${nestedKey}`;
769
+ resolved.utilities[cssSelector][nestedLayoutVariable] = nestedValue;
770
+ }
775
771
  } else {
776
- const layoutVariable = `--${prefix}-${key}`;
777
- if (layoutVariable.includes("opacity") && typeof value === "number") {
778
- value = value.toString().replace(/^0\./, ".");
772
+ if (key === "spacing-unit") {
773
+ resolved.utilities[cssSelector][layoutVariablePrefix] = value;
774
+ const spacingScale = generateSpacingScale(Number(value));
775
+ for (const [scaleKey, scaleValue] of Object.entries(spacingScale)) {
776
+ const spacingVariable = `${layoutVariablePrefix}-${scaleKey}`;
777
+ resolved.utilities[cssSelector][spacingVariable] = scaleValue;
778
+ }
779
+ } else {
780
+ const formattedValue = layoutVariablePrefix.includes("opacity") && typeof value === "number" ? value.toString().replace(/^0\./, ".") : value;
781
+ resolved.utilities[cssSelector][layoutVariablePrefix] = formattedValue;
779
782
  }
780
- resolved.utilities[cssSelector][layoutVariable] = value;
781
783
  }
782
- });
783
- });
784
+ }
785
+ }
784
786
  return resolved;
785
787
  };
786
788
  var corePlugin = (themes = {}, defaultTheme, prefix, addCommonColors) => {
@@ -810,8 +812,8 @@ var corePlugin = (themes = {}, defaultTheme, prefix, addCommonColors) => {
810
812
  ...baseStyles(prefix)
811
813
  }
812
814
  });
813
- addUtilities({ ...resolved.utilities, ...utilities });
814
- resolved.variants.forEach((variant) => {
815
+ addUtilities({ ...resolved == null ? void 0 : resolved.utilities, ...utilities });
816
+ resolved == null ? void 0 : resolved.variants.forEach((variant) => {
815
817
  addVariant(variant.name, variant.definition);
816
818
  });
817
819
  },
@@ -820,7 +822,7 @@ var corePlugin = (themes = {}, defaultTheme, prefix, addCommonColors) => {
820
822
  extend: {
821
823
  colors: {
822
824
  ...addCommonColors ? commonColors : {},
823
- ...resolved.colors
825
+ ...resolved == null ? void 0 : resolved.colors
824
826
  },
825
827
  scale: {
826
828
  "80": "0.8",
package/dist/plugin.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  nextui
3
- } from "./chunk-6XG3Y4GM.mjs";
3
+ } from "./chunk-5QVKTCUZ.mjs";
4
4
  import "./chunk-S7W5DQP2.mjs";
5
5
  import "./chunk-DI2L75XK.mjs";
6
6
  import "./chunk-4Z22WXZX.mjs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nextui-org/theme",
3
- "version": "0.0.0-dev-v2-20231104194339",
3
+ "version": "0.0.0-dev-v2-20231105140217",
4
4
  "description": "The default theme for NextUI components",
5
5
  "keywords": [
6
6
  "theme",