@unocss/core 0.28.1 → 0.29.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.
package/dist/index.cjs CHANGED
@@ -350,13 +350,14 @@ function resolveConfig(userConfig = {}, defaults = {}) {
350
350
  preprocess: mergePresets("preprocess"),
351
351
  postprocess: mergePresets("postprocess"),
352
352
  preflights: mergePresets("preflights"),
353
+ autocomplete: mergePresets("autocomplete"),
353
354
  variants: mergePresets("variants").map(normalizeVariant),
354
355
  shortcuts: resolveShortcuts(mergePresets("shortcuts")),
355
356
  extractors
356
357
  };
357
358
  }
358
359
 
359
- const version = "0.28.1";
360
+ const version = "0.29.0";
360
361
 
361
362
  class UnoGenerator {
362
363
  constructor(userConfig = {}, defaults = {}) {
@@ -552,15 +553,13 @@ class UnoGenerator {
552
553
  continue;
553
554
  if (typeof handler === "string")
554
555
  handler = { matcher: handler };
555
- if (handler) {
556
- processed = handler.matcher;
557
- if (Array.isArray(handler.parent))
558
- this.parentOrders.set(handler.parent[0], handler.parent[1]);
559
- handlers.push(handler);
560
- usedVariants.add(v);
561
- applied = true;
562
- break;
563
- }
556
+ processed = handler.matcher;
557
+ if (Array.isArray(handler.parent))
558
+ this.parentOrders.set(handler.parent[0], handler.parent[1]);
559
+ handlers.push(handler);
560
+ usedVariants.add(v);
561
+ applied = true;
562
+ break;
564
563
  }
565
564
  if (!applied)
566
565
  break;
package/dist/index.d.ts CHANGED
@@ -220,6 +220,10 @@ interface RuleMeta {
220
220
  * Fine tune sort
221
221
  */
222
222
  sort?: number;
223
+ /**
224
+ * Templates to provide autocomplete suggestions
225
+ */
226
+ autocomplete?: AutoCompleteTemplate | AutoCompleteTemplate[];
223
227
  /**
224
228
  * Internal rules will only be matched for shortcuts but not the user code.
225
229
  * @default false
@@ -347,7 +351,13 @@ interface ConfigBase<Theme extends {} = {}> {
347
351
  * Custom functions to extend the theme object
348
352
  */
349
353
  extendTheme?: Arrayable<ThemeExtender<Theme>>;
354
+ /**
355
+ * Custom function for auto complete
356
+ */
357
+ autocomplete?: (AutoCompleteFunction | AutoCompleteTemplate)[];
350
358
  }
359
+ declare type AutoCompleteTemplate = string;
360
+ declare type AutoCompleteFunction = (input: string) => Awaitable<string[]>;
351
361
  interface Preset<Theme extends {} = {}> extends ConfigBase<Theme> {
352
362
  name: string;
353
363
  enforce?: 'pre' | 'post';
@@ -544,4 +554,4 @@ declare const extractorSplit: Extractor;
544
554
 
545
555
  declare const extractorSvelte: Extractor;
546
556
 
547
- export { ArgumentType, Arrayable, Awaitable, BetterMap, BlocklistRule, CONTROL_SHORTCUT_NO_MERGE, CSSColorValue, CSSEntries, CSSObject, CSSValues, ConfigBase, DeepPartial, DynamicMatcher, DynamicRule, DynamicShortcut, DynamicShortcutMatcher, Extractor, ExtractorContext, FilterPattern, FlatObjectTuple, GenerateOptions, GenerateResult, GeneratorOptions, ParsedColorValue, ParsedUtil, PartialByKeys, PluginOptions, Postprocessor, Preflight, PreflightContext, Preprocessor, Preset, PresetOptions, RGBAColorValue, RawUtil, RequiredByKey, ResolvedConfig, RestArgs, Rule, RuleContext, RuleMeta, Shift, Shortcut, SourceCodeTransformer, SourceMap, StaticRule, StaticShortcut, StaticShortcutMap, StringifiedUtil, ThemeExtender, TransformResult, TwoKeyMap, UnoGenerator, UnocssPluginContext, UserConfig, UserConfigDefaults, UserOnlyOptions, UserShortcuts, UtilObject, ValueHandler, ValueHandlerCallback, Variant, VariantContext, VariantFunction, VariantHandler, VariantMatchedResult, VariantObject, attributifyRE, clearIdenticalEntries, clone, createGenerator, createValueHandler, e, entriesToCss, escapeRegExp, escapeSelector, expandVariantGroup, extractorSplit, extractorSvelte, hasScopePlaceholder, isAttributifySelector, isObject, isRawUtil, isStaticRule, isStaticShortcut, isValidSelector, mergeDeep, mergeSet, normalizeCSSEntries, normalizeCSSValues, normalizeVariant, notNull, regexClassGroup, regexScopePlaceholder, toArray, uniq, validateFilterRE, warnOnce, withLayer };
557
+ export { ArgumentType, Arrayable, AutoCompleteFunction, AutoCompleteTemplate, Awaitable, BetterMap, BlocklistRule, CONTROL_SHORTCUT_NO_MERGE, CSSColorValue, CSSEntries, CSSObject, CSSValues, ConfigBase, DeepPartial, DynamicMatcher, DynamicRule, DynamicShortcut, DynamicShortcutMatcher, Extractor, ExtractorContext, FilterPattern, FlatObjectTuple, GenerateOptions, GenerateResult, GeneratorOptions, ParsedColorValue, ParsedUtil, PartialByKeys, PluginOptions, Postprocessor, Preflight, PreflightContext, Preprocessor, Preset, PresetOptions, RGBAColorValue, RawUtil, RequiredByKey, ResolvedConfig, RestArgs, Rule, RuleContext, RuleMeta, Shift, Shortcut, SourceCodeTransformer, SourceMap, StaticRule, StaticShortcut, StaticShortcutMap, StringifiedUtil, ThemeExtender, TransformResult, TwoKeyMap, UnoGenerator, UnocssPluginContext, UserConfig, UserConfigDefaults, UserOnlyOptions, UserShortcuts, UtilObject, ValueHandler, ValueHandlerCallback, Variant, VariantContext, VariantFunction, VariantHandler, VariantMatchedResult, VariantObject, attributifyRE, clearIdenticalEntries, clone, createGenerator, createValueHandler, e, entriesToCss, escapeRegExp, escapeSelector, expandVariantGroup, extractorSplit, extractorSvelte, hasScopePlaceholder, isAttributifySelector, isObject, isRawUtil, isStaticRule, isStaticShortcut, isValidSelector, mergeDeep, mergeSet, normalizeCSSEntries, normalizeCSSValues, normalizeVariant, notNull, regexClassGroup, regexScopePlaceholder, toArray, uniq, validateFilterRE, warnOnce, withLayer };
package/dist/index.mjs CHANGED
@@ -346,13 +346,14 @@ function resolveConfig(userConfig = {}, defaults = {}) {
346
346
  preprocess: mergePresets("preprocess"),
347
347
  postprocess: mergePresets("postprocess"),
348
348
  preflights: mergePresets("preflights"),
349
+ autocomplete: mergePresets("autocomplete"),
349
350
  variants: mergePresets("variants").map(normalizeVariant),
350
351
  shortcuts: resolveShortcuts(mergePresets("shortcuts")),
351
352
  extractors
352
353
  };
353
354
  }
354
355
 
355
- const version = "0.28.1";
356
+ const version = "0.29.0";
356
357
 
357
358
  class UnoGenerator {
358
359
  constructor(userConfig = {}, defaults = {}) {
@@ -548,15 +549,13 @@ class UnoGenerator {
548
549
  continue;
549
550
  if (typeof handler === "string")
550
551
  handler = { matcher: handler };
551
- if (handler) {
552
- processed = handler.matcher;
553
- if (Array.isArray(handler.parent))
554
- this.parentOrders.set(handler.parent[0], handler.parent[1]);
555
- handlers.push(handler);
556
- usedVariants.add(v);
557
- applied = true;
558
- break;
559
- }
552
+ processed = handler.matcher;
553
+ if (Array.isArray(handler.parent))
554
+ this.parentOrders.set(handler.parent[0], handler.parent[1]);
555
+ handlers.push(handler);
556
+ usedVariants.add(v);
557
+ applied = true;
558
+ break;
560
559
  }
561
560
  if (!applied)
562
561
  break;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unocss/core",
3
- "version": "0.28.1",
3
+ "version": "0.29.0",
4
4
  "description": "The instant on-demand Atomic CSS engine.",
5
5
  "keywords": [
6
6
  "unocss",