@unocss/transformer-directives 0.63.1 → 0.63.3
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/dist/index.mjs +7 -5
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { expandVariantGroup, notNull, regexScopePlaceholder, toArray, cssIdRE } from '@unocss/core';
|
|
2
|
-
import { transformThemeString, hasThemeFn, hasIconFn } from '@unocss/rule-utils';
|
|
2
|
+
import { transformThemeFn, transformThemeString, hasThemeFn, hasIconFn } from '@unocss/rule-utils';
|
|
3
3
|
import { generate, parse, clone, List, walk } from 'css-tree';
|
|
4
4
|
|
|
5
5
|
async function handleApply(ctx, node) {
|
|
@@ -90,7 +90,7 @@ function removeComments(value) {
|
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
async function transformIconString(uno, icon, color) {
|
|
93
|
-
const presetIcons = uno.userConfig.presets?.flat()?.
|
|
93
|
+
const presetIcons = uno.userConfig.presets?.flat()?.find((i) => i.name === "@unocss/preset-icons");
|
|
94
94
|
if (!presetIcons) {
|
|
95
95
|
console.warn("@unocss/preset-icons not found, icon() directive will be keep as-is");
|
|
96
96
|
return;
|
|
@@ -99,7 +99,6 @@ async function transformIconString(uno, icon, color) {
|
|
|
99
99
|
scale = 1,
|
|
100
100
|
prefix = "i-",
|
|
101
101
|
collections: customCollections,
|
|
102
|
-
extraProperties = {},
|
|
103
102
|
customizations = {},
|
|
104
103
|
autoInstall = false,
|
|
105
104
|
collectionsNodeResolvePath,
|
|
@@ -116,7 +115,6 @@ async function transformIconString(uno, icon, color) {
|
|
|
116
115
|
warn: void 0,
|
|
117
116
|
customizations: {
|
|
118
117
|
...customizations,
|
|
119
|
-
additionalProps: { ...extraProperties },
|
|
120
118
|
trimCustomSvg: true,
|
|
121
119
|
async iconCustomizer(collection, icon2, props) {
|
|
122
120
|
await customizations.iconCustomizer?.(collection, icon2, props);
|
|
@@ -156,7 +154,11 @@ async function handleFunction({ code, uno, options }, node) {
|
|
|
156
154
|
const params = node.children.toArray().filter((i) => i.type === "String").map((i) => i.value);
|
|
157
155
|
if (params.length === 0)
|
|
158
156
|
throw new Error("icon() expects at least one argument");
|
|
159
|
-
|
|
157
|
+
let [icon, color] = params;
|
|
158
|
+
if (color) {
|
|
159
|
+
color = encodeURIComponent(transformThemeFn(color, uno.config.theme, throwOnMissing));
|
|
160
|
+
}
|
|
161
|
+
const value = await transformIconString(uno, icon, color);
|
|
160
162
|
if (value)
|
|
161
163
|
code.overwrite(node.loc.start.offset, node.loc.end.offset, value);
|
|
162
164
|
break;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unocss/transformer-directives",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.63.
|
|
4
|
+
"version": "0.63.3",
|
|
5
5
|
"description": "UnoCSS transformer for `@apply` directive",
|
|
6
6
|
"author": "hannoeru <me@hanlee.co>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"css-tree": "^3.0.0",
|
|
36
|
-
"@unocss/rule-utils": "0.63.
|
|
37
|
-
"@unocss/core": "0.63.
|
|
36
|
+
"@unocss/rule-utils": "0.63.3",
|
|
37
|
+
"@unocss/core": "0.63.3"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"magic-string": "^0.30.11"
|