@unocss/autocomplete 0.29.1 → 0.29.2
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/README.md +13 -1
- package/dist/index.cjs +2 -3
- package/dist/index.mjs +2 -3
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -33,7 +33,7 @@ rules: [
|
|
|
33
33
|
The template uses a simle DSL to specify the autocomplete suggestions. The syntax is:
|
|
34
34
|
|
|
35
35
|
- `(...|...)`: logic OR groups. `|` as the separator. Will be used as suggestions when the some of the groups match.
|
|
36
|
-
- `<...>`: built-in short hands. currently supports `<num>`, `<
|
|
36
|
+
- `<...>`: built-in short hands. currently supports `<num>`, `<percent>` and `<directions>`
|
|
37
37
|
- `$...`: theme infering. for example, `$colors` will list all the properties of the `colors` object of the theme.
|
|
38
38
|
|
|
39
39
|
For examples:
|
|
@@ -56,6 +56,18 @@ For examples:
|
|
|
56
56
|
- **Input**: `text-r`
|
|
57
57
|
- **Suggestions**: `text-red`, `text-rose` ...
|
|
58
58
|
|
|
59
|
+
###### Example 4
|
|
60
|
+
|
|
61
|
+
For multiple templates
|
|
62
|
+
|
|
63
|
+
- **Template**: `['(border|b)-<num>', '(border|b)-<directions>-<num>']`
|
|
64
|
+
|
|
65
|
+
- **Input**: `b-`
|
|
66
|
+
- **Suggestions**: `b-x`, `b-y`, `b-1`, `b-2` ...
|
|
67
|
+
|
|
68
|
+
- **Input**: `b-x-`
|
|
69
|
+
- **Suggestions**: `b-x-1`, `b-x-2` ...
|
|
70
|
+
|
|
59
71
|
## License
|
|
60
72
|
|
|
61
73
|
MIT License © 2021-PRESENT [Anthony Fu](https://github.com/antfu)
|
package/dist/index.cjs
CHANGED
|
@@ -11,7 +11,7 @@ const LRU__default = /*#__PURE__*/_interopDefaultLegacy(LRU);
|
|
|
11
11
|
|
|
12
12
|
const shorthands = {
|
|
13
13
|
num: `(${[0, 1, 2, 3, 4, 5, 6, 8, 10, 12, 24, 36].join("|")})`,
|
|
14
|
-
|
|
14
|
+
percent: `(${Array.from({ length: 11 }, (_, i) => i * 10).join("|")})`,
|
|
15
15
|
directions: "(x|y|t|b|l|r|s|e)"
|
|
16
16
|
};
|
|
17
17
|
const ignoredThemeKeys = ["DEFAULT"];
|
|
@@ -41,10 +41,9 @@ function parseAutocomplete(template, theme = {}) {
|
|
|
41
41
|
};
|
|
42
42
|
function handleNonGroup(input) {
|
|
43
43
|
handleRegexMatch(input, /\$([\w\|]+)/g, (m) => {
|
|
44
|
-
const keys = m[1].split("|");
|
|
45
44
|
parts.push({
|
|
46
45
|
type: "theme",
|
|
47
|
-
objects:
|
|
46
|
+
objects: m[1].split("|").map((i) => {
|
|
48
47
|
if (!i || !theme[i])
|
|
49
48
|
throw new Error(`Invalid theme key ${i}`);
|
|
50
49
|
return theme[i];
|
package/dist/index.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import LRU from 'lru-cache';
|
|
|
3
3
|
|
|
4
4
|
const shorthands = {
|
|
5
5
|
num: `(${[0, 1, 2, 3, 4, 5, 6, 8, 10, 12, 24, 36].join("|")})`,
|
|
6
|
-
|
|
6
|
+
percent: `(${Array.from({ length: 11 }, (_, i) => i * 10).join("|")})`,
|
|
7
7
|
directions: "(x|y|t|b|l|r|s|e)"
|
|
8
8
|
};
|
|
9
9
|
const ignoredThemeKeys = ["DEFAULT"];
|
|
@@ -33,10 +33,9 @@ function parseAutocomplete(template, theme = {}) {
|
|
|
33
33
|
};
|
|
34
34
|
function handleNonGroup(input) {
|
|
35
35
|
handleRegexMatch(input, /\$([\w\|]+)/g, (m) => {
|
|
36
|
-
const keys = m[1].split("|");
|
|
37
36
|
parts.push({
|
|
38
37
|
type: "theme",
|
|
39
|
-
objects:
|
|
38
|
+
objects: m[1].split("|").map((i) => {
|
|
40
39
|
if (!i || !theme[i])
|
|
41
40
|
throw new Error(`Invalid theme key ${i}`);
|
|
42
41
|
return theme[i];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unocss/autocomplete",
|
|
3
|
-
"version": "0.29.
|
|
3
|
+
"version": "0.29.2",
|
|
4
4
|
"description": "Autocomplete utils for UnoCSS",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"unocss",
|
|
@@ -36,11 +36,11 @@
|
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@types/lru-cache": "^7.4.0",
|
|
39
|
-
"@unocss/core": "0.29.
|
|
39
|
+
"@unocss/core": "0.29.2"
|
|
40
40
|
},
|
|
41
41
|
"scripts": {
|
|
42
42
|
"build": "unbuild",
|
|
43
43
|
"stub": "unbuild --stub"
|
|
44
44
|
},
|
|
45
|
-
"readme": "# @unocss/autocomplete\n\nAutocomplete utils for UnoCSS. This is embedded in [the playground](https://unocss.antfu.me/) and [the VS Code extension](https://github.com/unocss/unocss/tree/main/packages/vscode).\n\n## Syntax\n\nTo add autocomplete support to your custom rules:\n\n### Static Rules\n\nStatic rules like this will just works without any configuration.\n\n```ts\nrules: [\n ['flex', { display: 'flex' }]\n]\n```\n\n### Dynamic Rules\n\nFor dynamic rules, you can provide an extra `meta` object to the rule and specify the autocomplete template.\n\n```ts\nrules: [\n [\n /^m-(\\d)$/,\n ([, d]) => ({ margin: `${d / 4}rem` }),\n { autocomplete: 'm-<num>' }, // <-- this\n ],\n]\n```\n\nThe template uses a simle DSL to specify the autocomplete suggestions. The syntax is:\n\n- `(...|...)`: logic OR groups. `|` as the separator. Will be used as suggestions when the some of the groups match.\n- `<...>`: built-in short hands. currently supports `<num>`, `<
|
|
45
|
+
"readme": "# @unocss/autocomplete\n\nAutocomplete utils for UnoCSS. This is embedded in [the playground](https://unocss.antfu.me/) and [the VS Code extension](https://github.com/unocss/unocss/tree/main/packages/vscode).\n\n## Syntax\n\nTo add autocomplete support to your custom rules:\n\n### Static Rules\n\nStatic rules like this will just works without any configuration.\n\n```ts\nrules: [\n ['flex', { display: 'flex' }]\n]\n```\n\n### Dynamic Rules\n\nFor dynamic rules, you can provide an extra `meta` object to the rule and specify the autocomplete template.\n\n```ts\nrules: [\n [\n /^m-(\\d)$/,\n ([, d]) => ({ margin: `${d / 4}rem` }),\n { autocomplete: 'm-<num>' }, // <-- this\n ],\n]\n```\n\nThe template uses a simle DSL to specify the autocomplete suggestions. The syntax is:\n\n- `(...|...)`: logic OR groups. `|` as the separator. Will be used as suggestions when the some of the groups match.\n- `<...>`: built-in short hands. currently supports `<num>`, `<percent>` and `<directions>`\n- `$...`: theme infering. for example, `$colors` will list all the properties of the `colors` object of the theme.\n\nFor examples:\n\n###### Example 1\n\n- **Template**: `(border|b)-(solid|dashed|dotted|double|hidden|none)`\n- **Input**: `b-do`\n- **Suggestions**: `b-dashed`, `b-double`\n\n###### Example 2\n\n- **Template**: `m-<num>`\n- **Input**: `m-`\n- **Suggestions**: `m-1`, `m-2`, `m-3` ...\n\n###### Example 3\n\n- **Template**: `text-$colors`\n- **Input**: `text-r`\n- **Suggestions**: `text-red`, `text-rose` ...\n\n###### Example 4\n\nFor multiple templates\n\n- **Template**: `['(border|b)-<num>', '(border|b)-<directions>-<num>']`\n\n- **Input**: `b-`\n- **Suggestions**: `b-x`, `b-y`, `b-1`, `b-2` ...\n\n- **Input**: `b-x-`\n- **Suggestions**: `b-x-1`, `b-x-2` ...\n\n## License\n\nMIT License © 2021-PRESENT [Anthony Fu](https://github.com/antfu)\n"
|
|
46
46
|
}
|