@vinicunca/unocss-preset 1.22.0 → 1.24.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.
@@ -14,15 +14,13 @@ function getBrandPreflight(options) {
14
14
  lightVars.push(`--akar-brand-${brandName}: ${colorValue[500]};`);
15
15
  darkVars.push(`--akar-brand-${brandName}: ${colorValue[400]};`);
16
16
  });
17
- const lightStr = lightVars.join("\n ");
18
- const darkStr = darkVars.join("\n ");
19
17
  return compressCSS(`
20
18
  :root {
21
- ${lightStr}
19
+ ${lightVars.join("\n ")}
22
20
  }
23
21
 
24
22
  .dark {
25
- ${darkStr}
23
+ ${darkVars.join("\n ")}
26
24
  }
27
25
  `);
28
26
  }
@@ -65,8 +65,7 @@ function toRem(value, config) {
65
65
  * The result of this value is used to calculate the min and max values in rem when the viewport are extended.
66
66
  */
67
67
  function calculateRelativeSize({ originalViewPortMin, originalMinSize, originalMaxSize, originalViewPortMax, newViewPortSize }) {
68
- const slope = (originalMaxSize - originalMinSize) / (originalViewPortMax - originalViewPortMin);
69
- return slope * (newViewPortSize - originalViewPortMin) + originalMinSize;
68
+ return (originalMaxSize - originalMinSize) / (originalViewPortMax - originalViewPortMin) * (newViewPortSize - originalViewPortMin) + originalMinSize;
70
69
  }
71
70
  /**
72
71
  * Returns the min and max values in rem for the given match.
@@ -150,12 +149,11 @@ function getIntersection({ min, slope, minWidth }) {
150
149
  * @returns The slope value as a percentage for use in the 'clamp' function.
151
150
  */
152
151
  function getSlopePercentage({ min, max, config }) {
153
- const slope = getSlope({
152
+ return getSlope({
154
153
  min,
155
154
  max,
156
155
  config
157
- });
158
- return slope * 100;
156
+ }) * 100;
159
157
  }
160
158
  /**
161
159
  * Generates a CSS 'clamp' function value for fluid.
@@ -168,14 +166,13 @@ function getSlopePercentage({ min, max, config }) {
168
166
  * @returns A string representing the CSS 'clamp' function.
169
167
  */
170
168
  function getClamp({ min, max, config }) {
171
- const slope = getSlope({
172
- min,
173
- max,
174
- config
175
- });
176
169
  const intersection = getIntersection({
177
170
  min,
178
- slope,
171
+ slope: getSlope({
172
+ min,
173
+ max,
174
+ config
175
+ }),
179
176
  minWidth: getRemMinWidth(config)
180
177
  });
181
178
  const slopePercentage = getSlopePercentage({
@@ -306,9 +303,7 @@ function buildMultiplePropertiesRule({ match, config, properties }) {
306
303
  return { ...selectors };
307
304
  }
308
305
  function buildRule({ name, properties, config }) {
309
- const regexPattersNumericValues = `^${name}${REGEX_PATTERNS_NUMERIC_VALUES}`;
310
- const regexPattersRangeValues = `^${name}${REGEX_PATTERNS_RANGE_VALUES}`;
311
- const regexPattern = `${regexPattersNumericValues}|${regexPattersRangeValues}`;
306
+ const regexPattern = `${`^${name}${REGEX_PATTERNS_NUMERIC_VALUES}`}|${`^${name}${REGEX_PATTERNS_RANGE_VALUES}`}`;
312
307
  const regex = new RegExp(regexPattern);
313
308
  if (Array.isArray(properties)) return [[regex, (match) => buildMultiplePropertiesRule({
314
309
  match,
package/dist/index.js CHANGED
@@ -614,12 +614,11 @@ const DEFAULT_PRESET_OPTIONS = {
614
614
  //#endregion
615
615
  //#region src/presets/akar/akar.theme.ts
616
616
  function getAkarTheme(brands = {}) {
617
- const brandTheme = Object.entries(brands).reduce((acc, [brandKey, brandValue]) => {
617
+ return Object.entries(brands).reduce((acc, [brandKey, brandValue]) => {
618
618
  acc[brandKey] = theme.colors[brandValue];
619
619
  if (isObjectType(acc[brandKey])) acc[brandKey].DEFAULT = `var(--akar-brand-${brandKey})`;
620
620
  return acc;
621
621
  }, {});
622
- return brandTheme;
623
622
  }
624
623
 
625
624
  //#endregion
@@ -634,8 +633,7 @@ async function resolveOptions(options) {
634
633
  const presets = await resolvePresets(optionsWithDefault);
635
634
  const transformers = await resolveTransformers(optionsWithDefault);
636
635
  const { theme: themeExtend, shortcuts, safelist } = resolveExtend(optionsWithDefault);
637
- const resolvedTheme = resolveTheme(optionsWithDefault);
638
- const theme_ = mergeDeep(themeExtend, resolvedTheme);
636
+ const theme_ = mergeDeep(themeExtend, resolveTheme(optionsWithDefault));
639
637
  return {
640
638
  ...optionsWithDefault,
641
639
  theme: { ...theme_ },
@@ -665,11 +663,11 @@ async function resolvePresets(options) {
665
663
  typography: import("@unocss/preset-typography").then((mod) => mod.presetTypography),
666
664
  wind3: import("unocss").then((m) => m.presetWind3),
667
665
  wind4: import("unocss").then((m) => m.presetWind4),
668
- scrollbar: import("./scrollbar-DGguyrXf.js").then((mod) => mod.presetScrollbar),
666
+ scrollbar: import("./scrollbar-CeS4p1zr.js").then((mod) => mod.presetScrollbar),
669
667
  magicCss: import("./magic-css-BxO5zv5z.js").then((mod) => mod.presetMagicss),
670
668
  animation: import("./animation-KZDlcVMl.js").then((mod) => mod.presetAnimation),
671
- fluid: import("./fluid-7LHAeN3X.js").then((mod) => mod.presetFluid),
672
- akar: import("./akar-CcA2NVpg.js").then((mod) => mod.presetAkar)
669
+ fluid: import("./fluid-Ne2qtSnB.js").then((mod) => mod.presetFluid),
670
+ akar: import("./akar-DZp5UN-l.js").then((mod) => mod.presetAkar)
673
671
  };
674
672
  for (const [key, preset] of Object.entries(presetMap)) {
675
673
  const option = options[key];
@@ -702,11 +700,10 @@ function resolveExtend(options) {
702
700
  const shortcuts_ = [];
703
701
  let { animation = {}, keyframes = {} } = options.theme.extend ?? {};
704
702
  const safelist = [];
705
- const enableAkar = Boolean(options.akar);
706
703
  /**
707
704
  * If akar is enabled we want to safelist all default animations
708
705
  */
709
- if (enableAkar) {
706
+ if (Boolean(options.akar)) {
710
707
  animation = mergeDeep(animation, DEFAULT_AKAR_OPTIONS.animation ?? {});
711
708
  keyframes = mergeDeep(keyframes, DEFAULT_AKAR_OPTIONS.keyframes ?? {});
712
709
  let akarAnimation = DEFAULT_AKAR_OPTIONS.animation ?? {};
@@ -716,8 +713,7 @@ function resolveExtend(options) {
716
713
  akarKeyframes = mergeDeep(akarKeyframes, options.akar.keyframes ?? {});
717
714
  }
718
715
  const animationKeys = Object.keys(akarAnimation);
719
- const keyframesKeys = Object.keys(akarKeyframes);
720
- keyframesKeys.forEach((frameKey) => {
716
+ Object.keys(akarKeyframes).forEach((frameKey) => {
721
717
  if (!animationKeys.includes(frameKey)) safelist.push(`animate-${frameKey}`);
722
718
  });
723
719
  }
@@ -28,8 +28,7 @@ function presetScrollbar(option) {
28
28
  };
29
29
  function resolveVar(name) {
30
30
  const prefix = config.varPrefix;
31
- const prefixStr = prefix ? `${prefix}-` : "";
32
- return `--${prefixStr}scrollbar-${name}`;
31
+ return `--${prefix ? `${prefix}-` : ""}scrollbar-${name}`;
33
32
  }
34
33
  const variantsRE = /^(scrollbar(-track|-thumb)?):.+$/;
35
34
  return {
@@ -105,8 +104,7 @@ function presetScrollbar(option) {
105
104
  numberVarRegex,
106
105
  ([_, type, value, unit]) => {
107
106
  const val = unit ? value + unit : config.numberToUnit(Number.parseInt(value));
108
- const vars = customRules[type].map((v) => resolveVar(v));
109
- return vars.reduce((acc, v) => {
107
+ return customRules[type].map((v) => resolveVar(v)).reduce((acc, v) => {
110
108
  acc[v] = val;
111
109
  return acc;
112
110
  }, {});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vinicunca/unocss-preset",
3
3
  "type": "module",
4
- "version": "1.22.0",
4
+ "version": "1.24.0",
5
5
  "description": "Opinionated UnoCSS preset",
6
6
  "author": "praburangki<https://github.com/praburangki>",
7
7
  "license": "MIT",
@@ -42,23 +42,23 @@
42
42
  ],
43
43
  "peerDependencies": {
44
44
  "@vinicunca/perkakas": "^1.7.1",
45
- "unocss": "66.5.0"
45
+ "unocss": "66.5.2"
46
46
  },
47
47
  "publishConfig": {
48
48
  "registry": "https://registry.npmjs.org/"
49
49
  },
50
50
  "dependencies": {
51
- "@unocss/core": "66.5.0",
52
- "@unocss/preset-icons": "66.5.0",
53
- "@unocss/preset-mini": "66.5.0",
54
- "@unocss/preset-typography": "66.5.0",
55
- "@unocss/preset-web-fonts": "66.5.0",
56
- "@unocss/preset-wind4": "66.5.0",
57
- "@unocss/transformer-directives": "66.5.0",
58
- "@unocss/transformer-variant-group": "66.5.0",
51
+ "@unocss/core": "66.5.2",
52
+ "@unocss/preset-icons": "66.5.2",
53
+ "@unocss/preset-mini": "66.5.2",
54
+ "@unocss/preset-typography": "66.5.2",
55
+ "@unocss/preset-web-fonts": "66.5.2",
56
+ "@unocss/preset-wind4": "66.5.2",
57
+ "@unocss/transformer-directives": "66.5.2",
58
+ "@unocss/transformer-variant-group": "66.5.2",
59
59
  "defu": "^6.1.4",
60
60
  "postcss": "^8.5.6",
61
- "postcss-js": "^4.0.1"
61
+ "postcss-js": "^5.0.1"
62
62
  },
63
63
  "scripts": {
64
64
  "build": "tsdown",