@unocss/preset-attributify 0.49.8 → 0.50.1

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.cjs CHANGED
@@ -9,9 +9,10 @@ const variantAttributify = (options = {}) => {
9
9
  const prefix = options.prefix ?? "un-";
10
10
  const prefixedOnly = options.prefixedOnly ?? false;
11
11
  const trueToNonValued = options.trueToNonValued ?? false;
12
+ let variantsValueRE;
12
13
  return {
13
14
  name: "attributify",
14
- match(input) {
15
+ match(input, { generator }) {
15
16
  const match = core.isAttributifySelector(input);
16
17
  if (!match)
17
18
  return;
@@ -24,8 +25,19 @@ const variantAttributify = (options = {}) => {
24
25
  const [, variants = "", body = content] = content.match(variantsRE) || [];
25
26
  if (body === "~" || trueToNonValued && body === "true" || !body)
26
27
  return `${variants}${name}`;
27
- else
28
- return `${variants}${name}-${body}`;
28
+ if (variantsValueRE == null) {
29
+ const separators = generator?.config?.separators?.join("|");
30
+ if (separators)
31
+ variantsValueRE = new RegExp(`^(.*\\](?:${separators}))(\\[[^\\]]+?\\])$`);
32
+ else
33
+ variantsValueRE = false;
34
+ }
35
+ if (variantsValueRE) {
36
+ const [, bodyVariant, bracketValue] = content.match(variantsValueRE) || [];
37
+ if (bracketValue)
38
+ return `${bodyVariant}${variants}${name}-${bracketValue}`;
39
+ }
40
+ return `${variants}${name}-${body}`;
29
41
  }
30
42
  };
31
43
  };
@@ -117,7 +129,7 @@ const strippedPrefixes = [
117
129
  ":"
118
130
  ];
119
131
  const splitterRE = /[\s'"`;]+/g;
120
- const elementRE = /<[^>\s]*\s((?:'.*?'|".*?"|`.*?`|\{.*?\}|[^>]*?)*)/gs;
132
+ const elementRE = /<[^>\s]*\s((?:'.*?'|".*?"|`.*?`|\{.*?\}|[^>]*?)*)/g;
121
133
  const valuedAttributeRE = /([?]|(?!\d|-{2}|-\d)[a-zA-Z0-9\u00A0-\uFFFF-_:!%-.]+)=?(?:["]([^"]*)["]|[']([^']*)[']|[{]([^}]*)[}])?/gms;
122
134
  const defaultIgnoreAttributes = ["placeholder", "fill", "opacity"];
123
135
  const extractorAttributify = (options) => {
package/dist/index.mjs CHANGED
@@ -5,9 +5,10 @@ const variantAttributify = (options = {}) => {
5
5
  const prefix = options.prefix ?? "un-";
6
6
  const prefixedOnly = options.prefixedOnly ?? false;
7
7
  const trueToNonValued = options.trueToNonValued ?? false;
8
+ let variantsValueRE;
8
9
  return {
9
10
  name: "attributify",
10
- match(input) {
11
+ match(input, { generator }) {
11
12
  const match = isAttributifySelector(input);
12
13
  if (!match)
13
14
  return;
@@ -20,8 +21,19 @@ const variantAttributify = (options = {}) => {
20
21
  const [, variants = "", body = content] = content.match(variantsRE) || [];
21
22
  if (body === "~" || trueToNonValued && body === "true" || !body)
22
23
  return `${variants}${name}`;
23
- else
24
- return `${variants}${name}-${body}`;
24
+ if (variantsValueRE == null) {
25
+ const separators = generator?.config?.separators?.join("|");
26
+ if (separators)
27
+ variantsValueRE = new RegExp(`^(.*\\](?:${separators}))(\\[[^\\]]+?\\])$`);
28
+ else
29
+ variantsValueRE = false;
30
+ }
31
+ if (variantsValueRE) {
32
+ const [, bodyVariant, bracketValue] = content.match(variantsValueRE) || [];
33
+ if (bracketValue)
34
+ return `${bodyVariant}${variants}${name}-${bracketValue}`;
35
+ }
36
+ return `${variants}${name}-${body}`;
25
37
  }
26
38
  };
27
39
  };
@@ -113,7 +125,7 @@ const strippedPrefixes = [
113
125
  ":"
114
126
  ];
115
127
  const splitterRE = /[\s'"`;]+/g;
116
- const elementRE = /<[^>\s]*\s((?:'.*?'|".*?"|`.*?`|\{.*?\}|[^>]*?)*)/gs;
128
+ const elementRE = /<[^>\s]*\s((?:'.*?'|".*?"|`.*?`|\{.*?\}|[^>]*?)*)/g;
117
129
  const valuedAttributeRE = /([?]|(?!\d|-{2}|-\d)[a-zA-Z0-9\u00A0-\uFFFF-_:!%-.]+)=?(?:["]([^"]*)["]|[']([^']*)[']|[{]([^}]*)[}])?/gms;
118
130
  const defaultIgnoreAttributes = ["placeholder", "fill", "opacity"];
119
131
  const extractorAttributify = (options) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unocss/preset-attributify",
3
- "version": "0.49.8",
3
+ "version": "0.50.1",
4
4
  "description": "Attributify preset for UnoCSS",
5
5
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
6
6
  "license": "MIT",
@@ -33,7 +33,7 @@
33
33
  "dist"
34
34
  ],
35
35
  "dependencies": {
36
- "@unocss/core": "0.49.8"
36
+ "@unocss/core": "0.50.1"
37
37
  },
38
38
  "scripts": {
39
39
  "build": "unbuild",