@unocss/autocomplete 0.32.0 → 0.32.8
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/LICENSE +1 -1
- package/README.md +1 -1
- package/dist/index.cjs +2 -1
- package/dist/index.mjs +3 -2
- package/package.json +4 -5
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2021 Anthony Fu <https://github.com/antfu>
|
|
3
|
+
Copyright (c) 2021-PRESENT Anthony Fu <https://github.com/antfu>
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -163,6 +163,7 @@ function createAutocomplete(uno) {
|
|
|
163
163
|
...a2zd.map((j) => `${i}${j}`)
|
|
164
164
|
]);
|
|
165
165
|
await Promise.all(keys.map((key) => suggest(key).then((i) => i.forEach((j) => matched.add(j)))));
|
|
166
|
+
await Promise.all([...matched].filter((i) => i.match(/^\w+$/) && i.length > 3).map((i) => suggest(`${i}-`).then((i2) => i2.forEach((j) => matched.add(j)))));
|
|
166
167
|
return matched;
|
|
167
168
|
}
|
|
168
169
|
function getParsed(template) {
|
|
@@ -176,7 +177,7 @@ function createAutocomplete(uno) {
|
|
|
176
177
|
if (cache.has(input))
|
|
177
178
|
return cache.get(input);
|
|
178
179
|
const [, processed, , variants] = uno.matchVariants(input);
|
|
179
|
-
const idx = processed ? input.search(processed) : input.length;
|
|
180
|
+
const idx = processed ? input.search(core.escapeRegExp(processed)) : input.length;
|
|
180
181
|
if (idx === -1)
|
|
181
182
|
return [];
|
|
182
183
|
const variantPrefix = input.slice(0, idx);
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { toArray, uniq } from '@unocss/core';
|
|
1
|
+
import { escapeRegExp, toArray, uniq } from '@unocss/core';
|
|
2
2
|
import LRU from 'lru-cache';
|
|
3
3
|
|
|
4
4
|
const shorthands = {
|
|
@@ -155,6 +155,7 @@ function createAutocomplete(uno) {
|
|
|
155
155
|
...a2zd.map((j) => `${i}${j}`)
|
|
156
156
|
]);
|
|
157
157
|
await Promise.all(keys.map((key) => suggest(key).then((i) => i.forEach((j) => matched.add(j)))));
|
|
158
|
+
await Promise.all([...matched].filter((i) => i.match(/^\w+$/) && i.length > 3).map((i) => suggest(`${i}-`).then((i2) => i2.forEach((j) => matched.add(j)))));
|
|
158
159
|
return matched;
|
|
159
160
|
}
|
|
160
161
|
function getParsed(template) {
|
|
@@ -168,7 +169,7 @@ function createAutocomplete(uno) {
|
|
|
168
169
|
if (cache.has(input))
|
|
169
170
|
return cache.get(input);
|
|
170
171
|
const [, processed, , variants] = uno.matchVariants(input);
|
|
171
|
-
const idx = processed ? input.search(processed) : input.length;
|
|
172
|
+
const idx = processed ? input.search(escapeRegExp(processed)) : input.length;
|
|
172
173
|
if (idx === -1)
|
|
173
174
|
return [];
|
|
174
175
|
const variantPrefix = input.slice(0, idx);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unocss/autocomplete",
|
|
3
|
-
"version": "0.32.
|
|
3
|
+
"version": "0.32.8",
|
|
4
4
|
"description": "Autocomplete utils for UnoCSS",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"unocss",
|
|
@@ -32,15 +32,14 @@
|
|
|
32
32
|
],
|
|
33
33
|
"sideEffects": false,
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"lru-cache": "^7.
|
|
35
|
+
"lru-cache": "^7.9.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@types/lru-cache": "^7.6.1",
|
|
39
|
-
"@unocss/core": "0.32.
|
|
39
|
+
"@unocss/core": "0.32.8"
|
|
40
40
|
},
|
|
41
41
|
"scripts": {
|
|
42
42
|
"build": "unbuild",
|
|
43
43
|
"stub": "unbuild --stub"
|
|
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>`, `<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"
|
|
44
|
+
}
|
|
46
45
|
}
|