@teacss/rule-helpers 0.4.7 → 0.5.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/README.md CHANGED
@@ -1,136 +1,46 @@
1
1
  # @teacss/rule-helpers
2
2
 
3
- **Helpers for writing TeaCSS presets and directive transforms.**
3
+ Reusable builders and value parsers for TeaCSS preset authors.
4
4
 
5
- ## Purpose
5
+ This package provides framework-neutral building blocks. The calling preset
6
+ still owns public prefixes, scales, aliases, theme shape, and registration.
6
7
 
7
- This package provides reusable rule builders, TeaCSS value resolvers, CSS value
8
- grammar, theme helpers, and shared constants for preset authors.
8
+ ## Entry points
9
9
 
10
- Preset and directive authors use these helpers to implement behavior consistent
11
- with TeaCSS parsing and value conventions. The package does not choose a
12
- preset's public utility prefixes, theme schema, or vocabulary-specific scales
13
- and aliases, register a preset, or run CSS generation; the calling preset or
14
- integration selects the generic building blocks and owns those public
15
- vocabulary decisions.
16
-
17
- ## Usage
10
+ | Import | Contents |
11
+ | --------------------------------------- | -------------------------------------------------------------------------------- |
12
+ | `@teacss/rule-helpers` | Rule builders, theme helpers, identifiers, arbitrary values, and handler chains. |
13
+ | `@teacss/rule-helpers/value-resolvers` | Theme, keyword, number, time, variable, and opacity resolvers. |
14
+ | `@teacss/rule-helpers/css-syntax` | Top-level CSS value scanning and splitting. |
15
+ | `@teacss/rule-helpers/css-value-syntax` | CSS value validation and numeric-function inference. |
16
+ | `@teacss/rule-helpers/constants` | Shared constants. |
18
17
 
19
18
  ```ts
20
19
  import {
21
- consumeCssIdentifier,
22
20
  createValueHandler,
23
- cssLengthPercentageUnitRESource,
24
- cssLengthUnitRESource,
25
- cssLengthUnits,
26
- decodeArbitraryValue,
27
- decodeCssIdentifier,
28
- getBracket,
29
21
  getOwn,
30
22
  h,
31
- isBareDashedIdentifier,
32
- isCssIdentifier,
33
23
  makeArbitraryValueRule,
34
24
  makeGlobalRules,
35
- makeGlobalValueRule,
36
25
  makeShorthandRules,
37
26
  makeStaticRules,
38
- parseCssColor,
39
27
  routeGlobalKeywordsToExactRules,
40
- transformThemeFn,
41
- valueHandlers,
42
28
  } from "@teacss/rule-helpers";
43
29
  ```
44
30
 
45
- Use these helpers when a preset needs behavior compatible with TeaCSS's standard
46
- value and condition model. Use `makeShorthandRules` for bare shorthand rules
47
- that should emit in TeaCSS's primitives layer by default, e.g.
48
- `makeShorthandRules("outline", DEFAULT_OUTLINE)`.
49
-
50
- Use `makeGlobalRules` for enum rules that also need exact dynamic CSS-wide
51
- keywords. Apply `routeGlobalKeywordsToExactRules` to the flattened preset rules
52
- before appending user rules so broad preset fallbacks cannot shadow those exact
53
- global-keyword rules.
54
-
55
- Use `getOwn(record, key)` for user-controlled maps such as theme values and
56
- static rule tables. It returns explicitly configured own properties—including
57
- names such as `constructor`—while ignoring inherited object properties.
58
-
59
- `cssLengthUnitRESource` and `cssLengthPercentageUnitRESource` are derived from
60
- `cssLengthUnits`; reuse them when several helpers must validate the same modern
61
- CSS length-unit vocabulary.
62
-
63
- Use `makeArbitraryValueRule` for a dynamic fallback that accepts bracket values
64
- and CSS variables. Use `makeGlobalValueRule` when the same fallback must also
65
- accept CSS-wide keywords such as `inherit` and `unset`. Both builders preserve
66
- the supplied matcher, CSS property, and autocomplete metadata; the rule value
67
- must be the matcher's first capture group.
68
-
69
- Use the chainable `h` parser when a value may take several forms. The first
70
- matching handler wins, for example `h.bracket.cssvar.global.positiveInteger(value)`.
71
- `valueHandlers` exposes the same parsers individually. Common CSS value types
72
- include `alpha`, `integer`, `positiveInteger`, `customIdent`, and `url`, alongside
73
- the existing bracket, variable, global-keyword, number, percentage, length, and
74
- time handlers. Use `decodeArbitraryValue` when a helper needs exactly the same
75
- arbitrary-value decoding as `h.bracket` without constructing a handler chain.
76
- Use `isBareDashedIdentifier` when validating a CSS dashed identifier before
77
- wrapping or otherwise interpreting it.
78
-
79
- Import reusable TeaCSS value resolvers from their dedicated subpath:
80
-
81
- ```ts
82
- import {
83
- applyOpacity,
84
- isCssVariableToken,
85
- resolveAlphaValue,
86
- resolveKeyword,
87
- resolveNumber,
88
- resolveThemeVariable,
89
- resolveTime,
90
- } from "@teacss/rule-helpers/value-resolvers";
91
- ```
92
-
93
- Use `resolveThemeVariable` for typed theme groups, `resolveKeyword` for
94
- caller-supplied keyword sets, `resolveTime` and `resolveNumber` for TeaCSS
95
- tokens, `isCssVariableToken` for `$name` syntax, and the opacity helpers for
96
- color modifiers. Theme schemas, variable prefixes, passthrough keys, and
97
- allowed values remain owned by the calling preset.
98
-
99
- Use `isCssIdentifier` to validate a complete CSS identifier,
100
- `consumeCssIdentifier` while scanning a larger value, and
101
- `decodeCssIdentifier` when escaped spellings need a shared identity. These
102
- primitives support non-ASCII names and CSS escapes.
103
-
104
- Import generic top-level CSS value scanners from the dedicated subpath so
105
- presets can share token splitting without loading the rule-authoring entry:
31
+ Use `makeShorthandRules` for bare primitive-layer shorthands,
32
+ `makeGlobalRules` for enumerations with CSS-wide keywords, and
33
+ `routeGlobalKeywordsToExactRules` before appending user rules so broad
34
+ fallbacks cannot shadow exact keyword rules.
106
35
 
107
- ```ts
108
- import {
109
- findClosingParenthesis,
110
- splitTopLevelCommas,
111
- splitTopLevelWhitespace,
112
- } from "@teacss/rule-helpers/css-syntax";
113
- ```
114
-
115
- Import complete CSS value grammar from its separate subpath:
116
-
117
- ```ts
118
- import {
119
- inferNumericFunction,
120
- isCssColorValue,
121
- isCssEasingValue,
122
- isCssLengthValue,
123
- isCssTimeValue,
124
- isValidDropShadowArgument,
125
- } from "@teacss/rule-helpers/css-value-syntax";
126
- ```
36
+ `h` is a first-match handler chain for bracket values, variables, global
37
+ keywords, numbers, percentages, lengths, times, identifiers, colors, and URLs.
38
+ Use `makeArbitraryValueRule` for dynamic bracket and variable fallbacks.
127
39
 
128
- `css-syntax` contains lightweight top-level scanning and splitting primitives.
129
- `css-value-syntax` contains complete validators and numeric type inference. Use
130
- the dedicated grammar subpath when a consumer only needs value validation
131
- without the root rule-authoring API. Resolvers that depend on the complete
132
- grammar stay in `value-resolvers`, keeping the root rule-builder entry light.
40
+ `getOwn(record, key)` reads configured own properties, including names such as
41
+ `constructor`, while ignoring inherited values. Reuse the exported CSS
42
+ identifier and grammar helpers instead of maintaining partial validators.
133
43
 
134
- ## Status
44
+ This package does not choose vocabulary or run generation.
135
45
 
136
- Pre-1.0. Helper behavior is kept framework-neutral and preset-oriented.
46
+ Pre-1.0. Helper behavior remains preset-oriented.
@@ -1,14 +1,13 @@
1
1
  //#region src/constants.d.ts
2
- declare const globalKeywords: readonly ["inherit", "initial", "revert", "revert-layer", "unset"];
3
- declare const cssLengthUnits: readonly ["px", "pt", "pc", "in", "cm", "mm", "q", "rpx", "%", "em", "rem", "ex", "rex", "ch", "rch", "cap", "rcap", "ic", "ric", "lh", "rlh", "vw", "vh", "vi", "vb", "vmin", "vmax", "svw", "svh", "svi", "svb", "svmin", "svmax", "lvw", "lvh", "lvi", "lvb", "lvmin", "lvmax", "dvw", "dvh", "dvi", "dvb", "dvmin", "dvmax", "cqw", "cqh", "cqi", "cqb", "cqmin", "cqmax"];
2
+ export declare const globalKeywords: readonly ["inherit", "initial", "revert", "revert-layer", "unset"];
3
+ export declare const cssLengthUnits: readonly ["px", "pt", "pc", "in", "cm", "mm", "q", "rpx", "%", "em", "rem", "ex", "rex", "ch", "rch", "cap", "rcap", "ic", "ric", "lh", "rlh", "vw", "vh", "vi", "vb", "vmin", "vmax", "svw", "svh", "svi", "svb", "svmin", "svmax", "lvw", "lvh", "lvi", "lvb", "lvmin", "lvmax", "dvw", "dvh", "dvi", "dvb", "dvmin", "dvmax", "cqw", "cqh", "cqi", "cqb", "cqmin", "cqmax"];
4
4
  /** CSS `<length>` units, excluding TeaCSS's spacing-only `rpx` and percentage. */
5
- declare const cssLengthUnitRESource: string;
5
+ export declare const cssLengthUnitRESource: string;
6
6
  /** CSS `<length-percentage>` units from the same canonical unit list. */
7
- declare const cssLengthPercentageUnitRESource: string;
7
+ export declare const cssLengthPercentageUnitRESource: string;
8
8
  /**
9
9
  * CSS Color 4 `<named-color>` set (+ `transparent`), the single source of truth for recognizing a
10
10
  * bare keyword as a color. Case-insensitive — compare against `value.toLowerCase()`.
11
11
  */
12
- declare const cssNamedColors: ReadonlySet<string>;
13
- //#endregion
14
- export { cssLengthPercentageUnitRESource, cssLengthUnitRESource, cssLengthUnits, cssNamedColors, globalKeywords };
12
+ export declare const cssNamedColors: ReadonlySet<string>;
13
+ //#endregion
@@ -1,16 +1,15 @@
1
1
  //#region src/css-syntax.d.ts
2
- interface CssTokenSpan {
2
+ export interface CssTokenSpan {
3
3
  end: number;
4
4
  start: number;
5
5
  value: string;
6
6
  }
7
- declare function splitTopLevelDelimiter(value: string, delimiter: string): string[];
8
- declare function splitTopLevelCommas(value: string): string[];
9
- declare function splitTopLevelWhitespace(value: string): string[];
10
- declare function topLevelWhitespaceSpans(value: string): CssTokenSpan[];
11
- declare function findLastTopLevelDelimiter(value: string, delimiter: string): number;
12
- declare function findFirstTopLevelDelimiter(value: string, delimiter: string): number;
13
- declare function hasTopLevelDelimiter(value: string, delimiter: string): boolean;
14
- declare function findClosingParenthesis(value: string, openIndex: number): number | undefined;
15
- //#endregion
16
- export { CssTokenSpan, findClosingParenthesis, findFirstTopLevelDelimiter, findLastTopLevelDelimiter, hasTopLevelDelimiter, splitTopLevelCommas, splitTopLevelDelimiter, splitTopLevelWhitespace, topLevelWhitespaceSpans };
7
+ export declare function splitTopLevelDelimiter(value: string, delimiter: string): string[];
8
+ export declare function splitTopLevelCommas(value: string): string[];
9
+ export declare function splitTopLevelWhitespace(value: string): string[];
10
+ export declare function topLevelWhitespaceSpans(value: string): CssTokenSpan[];
11
+ export declare function findLastTopLevelDelimiter(value: string, delimiter: string): number;
12
+ export declare function findFirstTopLevelDelimiter(value: string, delimiter: string): number;
13
+ export declare function hasTopLevelDelimiter(value: string, delimiter: string): boolean;
14
+ export declare function findClosingParenthesis(value: string, openIndex: number): number | undefined;
15
+ //#endregion
@@ -1,62 +1,62 @@
1
1
  import { splitTopLevelCommas, splitTopLevelWhitespace } from "./css-syntax.js";
2
2
  //#region src/css-color-syntax.d.ts
3
3
  /** True for a complete standard CSS <color> value or an unresolved substitution. */
4
- declare function isCssColorValue(value: string): boolean;
4
+ export declare function isCssColorValue(value: string): boolean;
5
5
  //#endregion
6
6
  //#region src/css-drop-shadow-syntax.d.ts
7
7
  /** Validate the decoded argument of Filter Effects 1 `drop-shadow()`. */
8
- declare function isValidDropShadowArgument(value: string): boolean;
8
+ export declare function isValidDropShadowArgument(value: string): boolean;
9
9
  //#endregion
10
10
  //#region src/css-numeric-syntax.d.ts
11
- declare const cssNumberRe: RegExp;
12
- declare const nonnegativeCssNumberRe: RegExp;
13
- declare const cssPercentageRe: RegExp;
14
- declare const cssLengthPercentageRe: RegExp;
15
- declare const cssLengthPercentageWithOptionalUnitRe: RegExp;
16
- declare const nonnegativeCssLengthPercentageRe: RegExp;
17
- declare const simpleCssLengthPercentageRe: RegExp;
11
+ export declare const cssNumberRe: RegExp;
12
+ export declare const nonnegativeCssNumberRe: RegExp;
13
+ export declare const cssPercentageRe: RegExp;
14
+ export declare const cssLengthPercentageRe: RegExp;
15
+ export declare const cssLengthPercentageWithOptionalUnitRe: RegExp;
16
+ export declare const nonnegativeCssLengthPercentageRe: RegExp;
17
+ export declare const simpleCssLengthPercentageRe: RegExp;
18
18
  /** True only for an explicit negative numeric literal; math functions keep CSS's computed-value clamping behavior. */
19
- declare function isNegativeNumericLiteral(value: string): boolean;
20
- declare function hasDefiniteNegativeComponent(value: string): boolean;
19
+ export declare function isNegativeNumericLiteral(value: string): boolean;
20
+ export declare function hasDefiniteNegativeComponent(value: string): boolean;
21
21
  type CssBaseDimension = "angle" | "flex" | "frequency" | "length" | "resolution" | "time";
22
22
  interface CssNumericDimension {
23
23
  exponents: Partial<Record<CssBaseDimension | "percent", number>>;
24
24
  percentHint?: "conflict" | "length" | "percent";
25
25
  }
26
26
  type CssNumericType = CssBaseDimension | "length-percentage" | "number" | "percentage" | "unknown" | CssNumericDimension;
27
- declare function inferNumericFunction(value: string, allowedIdents: ReadonlySet<string>, allowAnyIdentifier?: boolean, allowLengthPercentage?: boolean): CssNumericType | undefined;
27
+ export declare function inferNumericFunction(value: string, allowedIdents: ReadonlySet<string>, allowAnyIdentifier?: boolean, allowLengthPercentage?: boolean): CssNumericType | undefined;
28
28
  /** True when a value is a typed CSS angle or a substitution whose type is resolved later. */
29
- declare function isCssAngleValue(value: string): boolean;
29
+ export declare function isCssAngleValue(value: string): boolean;
30
30
  /** True for a CSS angle, unitless zero, or a substitution whose type is resolved later. */
31
- declare function isCssAngleOrZeroValue(value: string): boolean;
31
+ export declare function isCssAngleOrZeroValue(value: string): boolean;
32
32
  /** True for a single CSS number/percentage or a substitution whose type is resolved later. */
33
- declare function isCssNumberOrPercentageValue(value: string): boolean;
33
+ export declare function isCssNumberOrPercentageValue(value: string): boolean;
34
34
  /** True for a single CSS length, unitless zero, or a substitution whose type is resolved later. */
35
- declare function isCssLengthValue(value: string): boolean;
35
+ export declare function isCssLengthValue(value: string): boolean;
36
36
  /** True for a single CSS length-percentage, unitless zero, or a substitution whose type is resolved later. */
37
- declare function isCssLengthPercentageValue(value: string): boolean;
37
+ export declare function isCssLengthPercentageValue(value: string): boolean;
38
38
  /** True for a nonnegative CSS length-percentage, unitless zero, or a substitution resolved later. */
39
- declare function isNonnegativeCssLengthPercentageValue(value: string): boolean;
39
+ export declare function isNonnegativeCssLengthPercentageValue(value: string): boolean;
40
40
  //#endregion
41
41
  //#region src/css-string-syntax.d.ts
42
- declare function isCssString(value: string): boolean;
42
+ export declare function isCssString(value: string): boolean;
43
43
  //#endregion
44
44
  //#region src/css-substitution-syntax.d.ts
45
45
  /** True when a complete value is a syntactically valid unresolved var() or env() substitution. */
46
- declare function isCssVariableSubstitutionValue(value: string): boolean;
46
+ export declare function isCssVariableSubstitutionValue(value: string): boolean;
47
47
  /**
48
48
  * Validate the unresolved value and every complete value reachable by taking
49
49
  * an explicit var() / env() fallback.
50
50
  */
51
- declare function areCssSubstitutionFallbacksValid(value: string, validateValue: (candidate: string) => boolean): boolean;
51
+ export declare function areCssSubstitutionFallbacksValid(value: string, validateValue: (candidate: string) => boolean): boolean;
52
52
  /** True for a syntactically valid CSS Values 5 function that must occupy the entire property value. */
53
- declare function isCssWholeValueFunction(value: string, validateCandidate?: (candidate: string) => boolean): boolean;
53
+ export declare function isCssWholeValueFunction(value: string, validateCandidate?: (candidate: string) => boolean): boolean;
54
54
  //#endregion
55
55
  //#region src/css-timing-syntax.d.ts
56
- declare function isCssTimeValue(value: string): boolean;
57
- declare function isCssEasingValue(value: string): boolean;
56
+ export declare function isCssTimeValue(value: string): boolean;
57
+ export declare function isCssEasingValue(value: string): boolean;
58
58
  //#endregion
59
59
  //#region src/css-value-tokenizer.d.ts
60
- declare function normalizedCssIdentifier(value: string): string;
60
+ export declare function normalizedCssIdentifier(value: string): string;
61
61
  //#endregion
62
- export { areCssSubstitutionFallbacksValid, cssLengthPercentageRe, cssLengthPercentageWithOptionalUnitRe, cssNumberRe, cssPercentageRe, hasDefiniteNegativeComponent, inferNumericFunction, isCssAngleOrZeroValue, isCssAngleValue, isCssColorValue, isCssEasingValue, isCssLengthPercentageValue, isCssLengthValue, isCssNumberOrPercentageValue, isCssString, isCssTimeValue, isCssVariableSubstitutionValue, isCssWholeValueFunction, isNegativeNumericLiteral, isNonnegativeCssLengthPercentageValue, isValidDropShadowArgument, nonnegativeCssLengthPercentageRe, nonnegativeCssNumberRe, normalizedCssIdentifier, simpleCssLengthPercentageRe, splitTopLevelCommas, splitTopLevelWhitespace };
62
+ export { splitTopLevelCommas, splitTopLevelWhitespace };
package/dist/index.d.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  import { cssLengthPercentageUnitRESource, cssLengthUnitRESource, cssLengthUnits, cssNamedColors, globalKeywords } from "./constants.js";
2
2
  import { CSSValueInput, DynamicRule, Rule, RuleMeta, StaticRule } from "@teacss/core";
3
3
  //#region src/arbitrary-value.d.ts
4
- declare function isBareDashedIdentifier(value: string): boolean;
4
+ export declare function isBareDashedIdentifier(value: string): boolean;
5
5
  /** Decode a TeaCSS arbitrary value using the same rules as `h.bracket`. */
6
- declare function decodeArbitraryValue(value: string): string | undefined;
6
+ export declare function decodeArbitraryValue(value: string): string | undefined;
7
7
  //#endregion
8
8
  //#region src/breakpoint-range.d.ts
9
- declare function calcMaxWidthBySize(size: string): string;
9
+ export declare function calcMaxWidthBySize(size: string): string;
10
10
  //#endregion
11
11
  //#region src/colors.d.ts
12
12
  interface CSSColorValue {
@@ -15,17 +15,17 @@ interface CSSColorValue {
15
15
  alpha: string | number | undefined;
16
16
  }
17
17
  type RGBAColorValue = [number, number, number, number] | [number, number, number];
18
- declare const cssColorFunctions: string[];
19
- declare const rectangularColorSpace: string[];
20
- declare const polarColorSpace: string[];
21
- declare const hueInterpolationMethods: string[];
22
- declare const alphaPlaceholders: string[];
23
- declare const alphaPlaceholdersRE: RegExp;
24
- declare function isInterpolatedMethod(type?: string): boolean;
25
- declare function hex2rgba(hex?: string): RGBAColorValue | undefined;
26
- declare function parseCssColor(str?: string): CSSColorValue | undefined;
27
- declare function colorOpacityToString(color: CSSColorValue): string | number;
28
- declare function colorToString(color: CSSColorValue | string, alphaOverride?: string | number): string;
18
+ export declare const cssColorFunctions: string[];
19
+ export declare const rectangularColorSpace: string[];
20
+ export declare const polarColorSpace: string[];
21
+ export declare const hueInterpolationMethods: string[];
22
+ export declare const alphaPlaceholders: string[];
23
+ export declare const alphaPlaceholdersRE: RegExp;
24
+ export declare function isInterpolatedMethod(type?: string): boolean;
25
+ export declare function hex2rgba(hex?: string): RGBAColorValue | undefined;
26
+ export declare function parseCssColor(str?: string): CSSColorValue | undefined;
27
+ export declare function colorOpacityToString(color: CSSColorValue): string | number;
28
+ export declare function colorToString(color: CSSColorValue | string, alphaOverride?: string | number): string;
29
29
  //#endregion
30
30
  //#region src/css-custom-property.d.ts
31
31
  type CSSCustomPropertyName = `--${string}`;
@@ -34,41 +34,41 @@ interface DefinePropertyOptions {
34
34
  inherits?: boolean;
35
35
  initialValue?: string | number;
36
36
  }
37
- declare function defineProperty(property: CSSCustomPropertyName, options?: DefinePropertyOptions): CSSValueInput;
37
+ export declare function defineProperty(property: CSSCustomPropertyName, options?: DefinePropertyOptions): CSSValueInput;
38
38
  //#endregion
39
39
  //#region src/css-identifier.d.ts
40
- declare function isCssWhitespace(character: string | undefined): boolean;
41
- declare function isCssNameStartCharacter(character: string | undefined): boolean;
42
- declare function isCssNameCharacter(character: string | undefined): boolean;
43
- declare function consumeCssEscape(value: string, start: number): number | undefined;
44
- declare function consumeCssName(value: string, start: number): number;
45
- declare function consumeCssIdentifier(value: string, index?: number): number | undefined;
46
- declare function isCssIdentifier(value: string): boolean;
40
+ export declare function isCssWhitespace(character: string | undefined): boolean;
41
+ export declare function isCssNameStartCharacter(character: string | undefined): boolean;
42
+ export declare function isCssNameCharacter(character: string | undefined): boolean;
43
+ export declare function consumeCssEscape(value: string, start: number): number | undefined;
44
+ export declare function consumeCssName(value: string, start: number): number;
45
+ export declare function consumeCssIdentifier(value: string, index?: number): number | undefined;
46
+ export declare function isCssIdentifier(value: string): boolean;
47
47
  /** Decode CSS identifier escapes so equivalent spellings share one identity. */
48
- declare function decodeCssIdentifier(value: string): string;
48
+ export declare function decodeCssIdentifier(value: string): string;
49
49
  //#endregion
50
50
  //#region src/css-value-patterns.d.ts
51
- declare const numberWithUnitRE: RegExp;
52
- declare const numberRE: RegExp;
53
- declare const angleRE: RegExp;
54
- declare const percentRE: RegExp;
55
- declare const lengthRE: RegExp;
56
- declare const unitOnlyMap: Record<string, number>;
57
- declare const unitOnlyRE: RegExp;
58
- declare const bracketTypeRe: RegExp;
51
+ export declare const numberWithUnitRE: RegExp;
52
+ export declare const numberRE: RegExp;
53
+ export declare const angleRE: RegExp;
54
+ export declare const percentRE: RegExp;
55
+ export declare const lengthRE: RegExp;
56
+ export declare const unitOnlyMap: Record<string, number>;
57
+ export declare const unitOnlyRE: RegExp;
58
+ export declare const bracketTypeRe: RegExp;
59
59
  //#endregion
60
60
  //#region src/directive-functions.d.ts
61
- declare function hasThemeFn(str: string): boolean;
62
- declare function hasIconFn(str: string): boolean;
63
- declare function transformThemeFn(code: string, theme: Record<string, any>, throwOnMissing?: boolean): string;
64
- declare function transformThemeString(code: string, theme: Record<string, any>, throwOnMissing?: boolean): string | undefined;
61
+ export declare function hasThemeFn(str: string): boolean;
62
+ export declare function hasIconFn(str: string): boolean;
63
+ export declare function transformThemeFn(code: string, theme: Record<string, any>, throwOnMissing?: boolean): string;
64
+ export declare function transformThemeString(code: string, theme: Record<string, any>, throwOnMissing?: boolean): string | undefined;
65
65
  //#endregion
66
66
  //#region src/dynamic-rule-builders.d.ts
67
67
  type RuleAutocomplete = NonNullable<RuleMeta["autocomplete"]>;
68
68
  /** Create a dynamic fallback whose first capture accepts TeaCSS bracket values and CSS variables. */
69
- declare function makeArbitraryValueRule<Theme extends object = object>(matcher: RegExp, property: string, autocomplete: RuleAutocomplete): DynamicRule<Theme>;
69
+ export declare function makeArbitraryValueRule<Theme extends object = object>(matcher: RegExp, property: string, autocomplete: RuleAutocomplete): DynamicRule<Theme>;
70
70
  /** Create a dynamic fallback whose first capture also accepts CSS-wide global keywords. */
71
- declare function makeGlobalValueRule<Theme extends object = object>(matcher: RegExp, property: string, autocomplete: RuleAutocomplete): DynamicRule<Theme>;
71
+ export declare function makeGlobalValueRule<Theme extends object = object>(matcher: RegExp, property: string, autocomplete: RuleAutocomplete): DynamicRule<Theme>;
72
72
  //#endregion
73
73
  //#region src/static-rule-builders.d.ts
74
74
  type StaticRuleName = readonly string[];
@@ -104,13 +104,13 @@ interface ShorthandRuleOptions extends Omit<RuleMeta, "layer"> {
104
104
  property?: StaticRuleProperty;
105
105
  }
106
106
  /** Create bare shorthand rules that belong in the primitives layer by default. */
107
- declare function makeShorthandRules(names: ShorthandRuleNames, value: ShorthandRuleValue, options?: ShorthandRuleOptions): StaticRule[];
108
- declare function propsToValueMap(arr: readonly StaticRuleValue[], transform?: (key: string) => StaticRuleValueMapEntry, options?: {
107
+ export declare function makeShorthandRules(names: ShorthandRuleNames, value: ShorthandRuleValue, options?: ShorthandRuleOptions): StaticRule[];
108
+ export declare function propsToValueMap(arr: readonly StaticRuleValue[], transform?: (key: string) => StaticRuleValueMapEntry, options?: {
109
109
  as?: "record" | "map";
110
110
  dedupe?: boolean;
111
111
  ignores?: readonly StaticRuleValue[];
112
112
  }): StaticRuleValueMapStore;
113
- declare function hyphenToSpace(arr: readonly StaticRuleValue[], options?: {
113
+ export declare function hyphenToSpace(arr: readonly StaticRuleValue[], options?: {
114
114
  as?: "record" | "map";
115
115
  dedupe?: boolean;
116
116
  ignores?: readonly StaticRuleValue[];
@@ -126,7 +126,7 @@ declare function hyphenToSpace(arr: readonly StaticRuleValue[], options?: {
126
126
  * @param values enum values
127
127
  * @param options `property` (defaults to the first prefix), `valueMap`, `meta`, `bareExclude`
128
128
  */
129
- declare function makeStaticRules(names: StaticRuleNames, values: readonly StaticRuleValue[], options?: StaticRuleOptions): StaticRule[];
129
+ export declare function makeStaticRules(names: StaticRuleNames, values: readonly StaticRuleValue[], options?: StaticRuleOptions): StaticRule[];
130
130
  //#endregion
131
131
  //#region src/global-keyword-rules.d.ts
132
132
  /**
@@ -135,20 +135,20 @@ declare function makeStaticRules(names: StaticRuleNames, values: readonly Static
135
135
  * value-map, metadata, and conflict position without expanding every keyword
136
136
  * into the static rule map.
137
137
  */
138
- declare function makeGlobalRules(names: StaticRuleNames, values: readonly StaticRuleValue[], options?: StaticRuleOptions): Rule[];
138
+ export declare function makeGlobalRules(names: StaticRuleNames, values: readonly StaticRuleValue[], options?: StaticRuleOptions): Rule[];
139
139
  /**
140
140
  * Prevent broad preset fallbacks from shadowing exact global rules at their
141
141
  * property-local conflict position. Apply this before appending user rules so
142
142
  * later user-defined dynamic rules retain their normal priority.
143
143
  */
144
- declare function routeGlobalKeywordsToExactRules<Theme extends object>(rules: readonly Rule<Theme>[]): Rule<Theme>[];
144
+ export declare function routeGlobalKeywordsToExactRules<Theme extends object>(rules: readonly Rule<Theme>[]): Rule<Theme>[];
145
145
  //#endregion
146
146
  //#region src/not-last-child-selector.d.ts
147
- declare function notLastChildSelector(selector: string): string;
147
+ export declare function notLastChildSelector(selector: string): string;
148
148
  //#endregion
149
149
  //#region src/object-access.d.ts
150
150
  /** Read a record entry without exposing inherited Object prototype members. */
151
- declare function getOwn<ObjectType extends object, Key extends keyof ObjectType>(record: ObjectType | null | undefined, key: Key): ObjectType[Key] | undefined;
151
+ export declare function getOwn<ObjectType extends object, Key extends keyof ObjectType>(record: ObjectType | null | undefined, key: Key): ObjectType[Key] | undefined;
152
152
  //#endregion
153
153
  //#region src/value-handler-factory.d.ts
154
154
  type ValueHandlerResult = string | number | undefined;
@@ -160,7 +160,7 @@ type ValueHandler<K extends string, T extends object, Handlers extends Record<K,
160
160
  readonly sequence: readonly K[];
161
161
  };
162
162
  };
163
- declare function createValueHandler<K extends string, T extends object, const Handlers extends Record<K, ValueHandlerCallback<T>> = Record<K, ValueHandlerCallback<T>>>(handlers: Handlers): ValueHandler<K, T, Handlers>;
163
+ export declare function createValueHandler<K extends string, T extends object, const Handlers extends Record<K, ValueHandlerCallback<T>> = Record<K, ValueHandlerCallback<T>>>(handlers: Handlers): ValueHandler<K, T, Handlers>;
164
164
  //#endregion
165
165
  //#region src/standard-value-resolvers.d.ts
166
166
  declare function numberWithUnit(str: string): string | undefined;
@@ -193,7 +193,7 @@ declare function zero(str: string): "0" | undefined;
193
193
  //#endregion
194
194
  //#region src/standard-value-handler.d.ts
195
195
  /** The standard set of value handlers assembled into a chainable handler. */
196
- declare const valueHandlers: Readonly<{
196
+ export declare const valueHandlers: Readonly<{
197
197
  alpha: typeof alpha;
198
198
  auto: typeof auto;
199
199
  bracket: typeof bracket;
@@ -221,7 +221,7 @@ declare const valueHandlers: Readonly<{
221
221
  video: typeof video;
222
222
  zero: typeof zero;
223
223
  }>;
224
- declare const handler: ValueHandler<string, object, Readonly<{
224
+ export declare const handler: ValueHandler<string, object, Readonly<{
225
225
  alpha: typeof alpha;
226
226
  auto: typeof auto;
227
227
  bracket: typeof bracket;
@@ -249,7 +249,7 @@ declare const handler: ValueHandler<string, object, Readonly<{
249
249
  video: typeof video;
250
250
  zero: typeof zero;
251
251
  }>, never>;
252
- declare const h: ValueHandler<string, object, Readonly<{
252
+ export declare const h: ValueHandler<string, object, Readonly<{
253
253
  alpha: typeof alpha;
254
254
  auto: typeof auto;
255
255
  bracket: typeof bracket;
@@ -279,8 +279,8 @@ declare const h: ValueHandler<string, object, Readonly<{
279
279
  }>, never>;
280
280
  //#endregion
281
281
  //#region src/string-components.d.ts
282
- declare function getBracket(str: string, open: string, close: string): string[] | undefined;
283
- declare function getStringComponent(str: string, open: string, close: string, separators: string | string[]): string[] | undefined;
284
- declare function getStringComponents(str: string, separators: string | string[], limit?: number, open?: string, close?: string): string[] | undefined;
282
+ export declare function getBracket(str: string, open: string, close: string): string[] | undefined;
283
+ export declare function getStringComponent(str: string, open: string, close: string, separators: string | string[]): string[] | undefined;
284
+ export declare function getStringComponents(str: string, separators: string | string[], limit?: number, open?: string, close?: string): string[] | undefined;
285
285
  //#endregion
286
- export { type CSSColorValue, type CSSCustomPropertyName, type DefinePropertyOptions, type RGBAColorValue, type ShorthandRuleNames, type ShorthandRuleOptions, type ShorthandRuleValue, type StaticRuleBody, type StaticRuleName, type StaticRuleNames, type StaticRuleOptions, type StaticRulePrefix, type StaticRuleProperty, type StaticRuleValue, type StaticRuleValueMap, type StaticRuleValueMapEntry, type StaticRuleValueMapResolver, type StaticRuleValueMapStore, type ValueHandler, type ValueHandlerCallback, type ValueHandlerResult, alphaPlaceholders, alphaPlaceholdersRE, angleRE, bracketTypeRe, calcMaxWidthBySize, colorOpacityToString, colorToString, consumeCssEscape, consumeCssIdentifier, consumeCssName, createValueHandler, cssColorFunctions, cssLengthPercentageUnitRESource, cssLengthUnitRESource, cssLengthUnits, cssNamedColors, decodeArbitraryValue, decodeCssIdentifier, defineProperty, getBracket, getOwn, getStringComponent, getStringComponents, globalKeywords, h, handler, hasIconFn, hasThemeFn, hex2rgba, hueInterpolationMethods, hyphenToSpace, isBareDashedIdentifier, isCssIdentifier, isCssNameCharacter, isCssNameStartCharacter, isCssWhitespace, isInterpolatedMethod, lengthRE, makeArbitraryValueRule, makeGlobalRules, makeGlobalValueRule, makeShorthandRules, makeStaticRules, notLastChildSelector, numberRE, numberWithUnitRE, parseCssColor, percentRE, polarColorSpace, propsToValueMap, rectangularColorSpace, routeGlobalKeywordsToExactRules, transformThemeFn, transformThemeString, unitOnlyMap, unitOnlyRE, valueHandlers };
286
+ export { type CSSColorValue, type CSSCustomPropertyName, type DefinePropertyOptions, type RGBAColorValue, type ShorthandRuleNames, type ShorthandRuleOptions, type ShorthandRuleValue, type StaticRuleBody, type StaticRuleName, type StaticRuleNames, type StaticRuleOptions, type StaticRulePrefix, type StaticRuleProperty, type StaticRuleValue, type StaticRuleValueMap, type StaticRuleValueMapEntry, type StaticRuleValueMapResolver, type StaticRuleValueMapStore, type ValueHandler, type ValueHandlerCallback, type ValueHandlerResult, cssLengthPercentageUnitRESource, cssLengthUnitRESource, cssLengthUnits, cssNamedColors, globalKeywords };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{cssLengthPercentageUnitRESource as e,cssLengthUnitRESource as t,cssLengthUnits as n,cssNamedColors as r,globalKeywords as i}from"./constants.js";import{a,c as o,i as s,n as c,o as l,r as u,s as d,t as ee}from"./css-identifier-4yDg85cV.js";import{_ as te,a as f,b as ne,d as p,f as m,g as re,h as ie,i as ae,l as oe,m as se,n as h,o as g,p as ce,r as le,s as _,t as v,u as y,v as b,x as ue,y as de}from"./standard-value-handler-DimbUwdo.js";import{LAYER_PRIMITIVES as fe,LAYER_PROPERTIES as pe,escapeRegExp as x,isStaticRule as me,isString as he,symbols as S,toArray as ge}from"@teacss/core";function _e(e){let t=e.match(/^-?\d+\.?\d*/)?.[0]||``,n=e.slice(t.length);if(n===`px`){let r=Number.parseFloat(t)-.1;return Number.isNaN(r)?e:`${r}${n}`}return`calc(${e} - 0.1px)`}function ve(e,t,n){if(e===``)return;let r=e.length,i=0,a=!1,o=0;for(let s=0;s<r;s++)switch(e[s]){case t:a||(a=!0,o=s),i++;break;case n:if(--i,i<0)return;if(i===0)return[e.slice(o,s+1),e.slice(s+1),e.slice(0,o)];break}}function C(e,t,n,r){if(e===``||(he(r)&&(r=[r]),r.length===0))return;let i=e.length,a=0;for(let o=0;o<i;o++)switch(e[o]){case t:a++;break;case n:if(--a<0)return;break;default:for(let t of r){let n=t.length;if(n&&t===e.slice(o,o+n)&&a===0)return o===0||o===i-n?void 0:[e.slice(0,o),e.slice(o+n)]}}if(a===0)return[e,``]}function w(e,t,n,r=`(`,i=`)`){n??=10;let a=[],o=0;for(;e!==``;){if(++o>n)return;let s=C(e,r,i,t);if(!s)return;let[c,l]=s;a.push(c),e=l}if(a.length>0)return a}const T=[`hsl`,`hsla`,`hwb`,`lab`,`lch`,`oklab`,`oklch`,`rgb`,`rgba`],E=[`srgb`,`srgb-linear`,`display-p3`,`display-p3-linear`,`a98-rgb`,`prophoto-rgb`,`rec2020`,`lab`,`oklab`,`xyz`,`xyz-d50`,`xyz-d65`],D=[`hsl`,`hwb`,`lch`,`oklch`],O=[`shorter`,`longer`,`increasing`,`decreasing`],k=[`%alpha`,`<alpha-value>`],A=new RegExp(k.map(e=>x(e)).join(`|`),`g`),j=new Set([...E,...D,...O]);function M(e){if(!e)return!1;let t=-1;for(let n=0;n<=e.length;n++){if(e[n]===`\\`||l(e[n])){t<0&&(t=n);continue}if(t>=0&&j.has(e.slice(t,n).toLowerCase()))return!0;t=-1}return!1}function N(e=``){let t=L(e);if(t!=null){let{components:e,alpha:n}=t;return n==null?e:[...e,n]}}function P(e=``){let t=ye(e);if(t==null||t===!1)return;let{type:n,components:r,alpha:i}=t,a=n.toLowerCase();if(r.length!==0&&!(T.includes(a)&&![1,3].includes(r.length)))return{type:a,components:r.map(e=>typeof e==`string`?e.trim():e),alpha:typeof i==`string`?i.trim():i}}function F(e){let t=e.alpha??1;return typeof t==`string`&&k.includes(t)?1:t}function I(e,t){if(typeof e==`string`)return e.replace(A,`${t??1}`);let{components:n}=e,{alpha:r,type:i}=e;return r=t??r,i=i.toLowerCase(),[`hsla`,`rgba`].includes(i)?`${i}(${n.join(`, `)}${r==null?``:`, ${r}`})`:(r=r==null?``:` / ${r}`,T.includes(i)?`${i}(${n.join(` `)}${r})`:`color(${i} ${n.join(` `)}${r})`)}function ye(e){if(!e)return;let t=L(e);if(t!=null||(t=z(e),t!=null)||(t=xe(e),t!=null)||(t=Ce(e),t!=null)||(t=we(e),t!=null))return t}function L(e){let[,t]=e.match(/^#([\da-f]+)$/i)||[];if(t)switch(t.length){case 3:case 4:{let e=Array.from(t,e=>Number.parseInt(e,16)).map(e=>e<<4|e);return{type:`rgb`,components:e.slice(0,3),alpha:t.length===3?void 0:R(e[3])}}case 6:case 8:{let e=Number.parseInt(t,16);return{type:`rgb`,components:t.length===6?[e>>16&255,e>>8&255,e&255]:[e>>24&255,e>>16&255,e>>8&255],alpha:t.length===6?void 0:R(e&255)}}}}function R(e){return Math.round(e/255*1e4)/1e4}const be={rebeccapurple:[102,51,153,1]};function z(e){let t=p(be,e);if(t!=null)return{type:`rgb`,components:t.slice(0,3),alpha:t[3]}}function xe(e){let t=e.match(/^(rgb|rgba|hsl|hsla)\((.+)\)$/i);if(!t)return;let[,n,r]=t,i=w(r,`,`,5);if(i){if([3,4].includes(i.length))return{type:n,components:i.slice(0,3),alpha:i[3]};if(i.length!==1)return!1}}const Se=RegExp(`^(${T.join(`|`)})\\((.+)\\)$`,`i`);function Ce(e){let t=e.match(Se);if(!t)return;let[,n,r]=t,i=B(`${n} ${r}`);if(i){let{alpha:e,components:[t,...n]}=i;return{type:t,components:n,alpha:e}}}function we(e){let t=e.match(/^color\((.+)\)$/);if(!t)return;let n=B(t[1]);if(n){let{alpha:e,components:[t,...r]}=n;return{type:t,components:r,alpha:e}}}function B(e){let t=w(e,` `);if(!t)return;let n=t.length;if(t[n-2]===`/`)return{components:t.slice(0,n-2),alpha:t[n-1]};if(t[n-2]!=null&&(t[n-2].endsWith(`/`)||t[n-1].startsWith(`/`))){let e=t.splice(n-2);t.push(e.join(` `)),--n}let r=w(t[n-1],`/`,2);if(!r)return;if(r.length===1||r[r.length-1]===``)return{components:t};let i=r.pop();return t[n-1]=r.join(`/`),{components:t,alpha:i}}function Te(e,t={}){let{syntax:n=`*`,inherits:r=!1,initialValue:i}=t,a={[S.shortcutsNoMerge]:!0,[S.noMerge]:!0,[S.variants]:()=>[{parent:``,layer:pe,selector:()=>`@property ${e}`}],syntax:JSON.stringify(n),inherits:r?`true`:`false`};return i!=null&&(a[`initial-value`]=i),a}function V(e){return y(e,`theme`)}function Ee(e){return y(e,`icon`)}function H(e,t,n=!0){if(!V(e))return e;let r=[],i=0,a=0;for(;a<e.length;){let o=oe(e,`theme`,a);if(o===-1)break;let s=De(e,o);if(!s)break;if(a=s.end,!s.valid)continue;if(!s.argument)throw Error(`theme() expect exact one argument, but got 0`);let c=G(s.argument,t,s.fallback===void 0&&n)??(s.fallback===void 0?void 0:H(s.fallback,t,n));c!==void 0&&(r.push(e.slice(i,o),c),i=s.end)}return i===0?e:(r.push(e.slice(i)),r.join(``))}function U(e,t){let n=0,r=-1,i;for(let a=t;a<e.length;a++){let t=e[a];if(i!=null){t===`\\`?a++:t===i&&(i=void 0);continue}if(t===`"`||t===`'`)i=t;else if(t===`(`)n++;else if(t===`)`){if(n===0)return{end:a,separator:r};n--}else t===`,`&&n===0&&r===-1&&(r=a)}return{end:-1,separator:-1}}function W(e,t,n,r){let i=e.slice(n,r).trim();return i?{argument:t,fallback:i,end:r+1,valid:!0}:{argument:t,end:r+1,valid:!0}}function De(e,t){let n=t+6;for(;/\s/.test(e[n]??``);)n++;let r=e[n]===`"`||e[n]===`'`?e[n++]:void 0,i=n;if(r){for(;n<e.length;){let t=e[n];if(t===`\\`){n+=2;continue}if(t===r)break;n++}if(n>=e.length)return;let t=e.slice(i,n);for(n++;/\s/.test(e[n]??``);)n++;if(e[n]===`)`)return{argument:t,end:n+1,valid:!0};if(e[n]!==`,`)return{argument:t,end:Oe(e,n),valid:!1};let a=U(e,n+1);return a.end===-1?void 0:W(e,t,n+1,a.end)}let a=U(e,n);if(a.end!==-1)return a.separator===-1?{argument:e.slice(i,a.end).trim(),end:a.end+1,valid:!0}:W(e,e.slice(i,a.separator).trim(),a.separator+1,a.end)}function Oe(e,t){let n=e.indexOf(`)`,t);return n===-1?e.length:n+1}function G(e,t,n=!0){let r=e.indexOf(`/`),i=r<0?e:e.slice(0,r),a=r<0?void 0:e.slice(r+1),o=i.trim().split(`.`),s=t;for(let e of o){if(typeof s!=`object`||!s){s=void 0;break}s=p(s,e)}if(typeof s==`object`&&s&&(s=p(s,`DEFAULT`)),typeof s==`number`&&Number.isFinite(s)&&a==null)return String(s);if(typeof s==`string`){if(!a)return s;let e=ke(a),t=P(s);return t?I(t,e):`color-mix(in oklab, ${s} ${e}, transparent)`}if(n)throw Error(`theme("${e}") was not found`)}function ke(e){let t=e.trim();return/^\d{1,3}$/.test(t)&&Number(t)<=100?`${Number(t)}%`:t}function K(e){return f(e)??g(e)}function Ae(e){return K(e)??_(e)}function je(e,t,n){return[e,([,e])=>({[t]:K(e)}),{autocomplete:n}]}function Me(e,t,n){return[e,([,e])=>({[t]:Ae(e)}),{autocomplete:n}]}const Ne=new Set(i);function Pe(e,t,n){Object.defineProperty(e,t,{value:n,configurable:!0,enumerable:!0,writable:!0})}function Fe(e,t,n={}){let r=J(typeof e==`string`?[e]:e);if(r.length===0)return[];let{property:i,...a}=n,o=(i??r[0]??``).trim();if(!o)throw Error(`makeShorthandRules requires a non-empty property`);return r.map(e=>[e,{[o]:t},{...a,layer:fe}])}function q(e,t,n={}){let{as:r=`record`,dedupe:i=!0,ignores:a=[]}=n,o=new Set,s=a.length?new Set(a.map(String)):void 0,c=t??(e=>e);if(r===`map`){let t=new Map;for(let n of e){let e=String(n);s?.has(e)||i&&o.has(e)||(o.add(e),t.set(e,c(e)))}return t}let l={};for(let t of e){let e=String(t);if(s?.has(e)||i&&o.has(e))continue;o.add(e);let n=c(e);e===`__proto__`?Pe(l,e,n):l[e]=n}return l}function Ie(e,t={}){return q(e,e=>e.includes(`-`)?e.replaceAll(`-`,` `):e,t)}function J(e){let t=new Set,n=[];for(let r of e)r&&(t.has(r)||(t.add(r),n.push(r)));return n}function Le(e){let t=new Set,n=[];for(let r of e){let e=String(r);t.has(e)||(t.add(e),n.push(e))}return n}function Re(e){if(!e)return()=>void 0;if(typeof e==`function`)return e;if(e instanceof Map)return t=>e.get(t);let t=e;return e=>p(t,e)}function Y(e,t){let n=(e??``).trim(),r=Re(t);return e=>{let t=r(e);if(t!=null&&typeof t!=`string`&&typeof t!=`number`)return t;if(!n)throw Error(`makeStaticRules requires a non-empty property`);return{[n]:t??e}}}function X(e,t,n={}){let{valueMap:r,meta:i}=n,a=typeof e==`string`||e===!1?[e]:e,o=a.includes(!1),s=J(a.filter(e=>typeof e==`string`));if(s.length===0&&!o)return[];let c=Le(t);if(c.length===0)return[];let l=Y(n.property??s[0],r),u=[],d=(e,t)=>u.push(i?[e,l(t),i]:[e,l(t)]);for(let e of s)for(let t of c)d(t?`${e}:${t}`:e,t);if(o){let e=new Set([...Ne,...(n.bareExclude??[]).map(String)]);for(let t of c)!t||e.has(t)||d(t,t)}return u}const ze=i.join(`|`),Z=new Set(i),Q=Symbol.for(`@teacss/rule-helpers/global-rule-name`);function $(e){return e[2]?.[Q]}function Be(e){if(e.flags)return;let t=e.source;if(!t.startsWith(`^`))return;let n=1;for(;n<t.length&&/[A-Za-z0-9_-]/.test(t[n]);)n++;return t[n]===`:`?t.slice(1,n):void 0}function Ve(e,t,n={}){let r=J((typeof e==`string`||e===!1?[e]:e).filter(e=>typeof e==`string`)),i=X(e,t.filter(e=>!Z.has(String(e))),n);if(r.length===0)return i;let a=Y(n.property??r[0],n.valueMap),o=n.meta?.autocomplete,s=typeof o==`string`?[o]:o??[],c=n.meta?.prefix==null?[``]:ge(n.meta.prefix);for(let e of r){let t={...n.meta,autocomplete:[...s,...c.map(t=>`${t}${e}:<globalKeyword>`)],[Q]:e},r=[RegExp(`^${x(e)}:(${ze})$`),([,e])=>a(e),t];i.push(r)}if(n.escapeHatch){let e=(n.property??r[0]??``).trim();if(!e)throw Error(`escapeHatch requires a rule name or property`);for(let t of r){let r={...n.meta,autocomplete:[...s,...c.map(e=>`${e}${t}:[]`)]};i.push([RegExp(`^${x(t)}:(.+)$`),([,t])=>({[e]:f(t)??g(t)}),r])}}return i}function He(e,t){let n=e.lastIndexOf(`:`);return n<=0||!Z.has(e.slice(n+1))?!1:t.has(e.slice(0,n))}function Ue(e){let t=new Set;for(let n of e){let e=$(n);e!=null&&t.add(e)}return t.size===0?[...e]:e.map(e=>{if(me(e)||$(e)!=null)return e;let[n,r,i]=e,a=Be(n);if(a!=null&&!t.has(a))return e;let o=(e,n)=>{if(!He(e[0],t))return r(e,n)};return i==null?[n,o]:[n,o,i]})}function We(e){let t=`>:not(:last-child)`;return e.includes(t)?`:where(${e})`:`:where(${e}${t})`}export{k as alphaPlaceholders,A as alphaPlaceholdersRE,se as angleRE,ie as bracketTypeRe,_e as calcMaxWidthBySize,F as colorOpacityToString,I as colorToString,ee as consumeCssEscape,c as consumeCssIdentifier,u as consumeCssName,ae as createValueHandler,T as cssColorFunctions,e as cssLengthPercentageUnitRESource,t as cssLengthUnitRESource,n as cssLengthUnits,r as cssNamedColors,m as decodeArbitraryValue,s as decodeCssIdentifier,Te as defineProperty,ve as getBracket,p as getOwn,C as getStringComponent,w as getStringComponents,i as globalKeywords,v as h,h as handler,Ee as hasIconFn,V as hasThemeFn,N as hex2rgba,O as hueInterpolationMethods,Ie as hyphenToSpace,ce as isBareDashedIdentifier,a as isCssIdentifier,l as isCssNameCharacter,d as isCssNameStartCharacter,o as isCssWhitespace,M as isInterpolatedMethod,re as lengthRE,je as makeArbitraryValueRule,Ve as makeGlobalRules,Me as makeGlobalValueRule,Fe as makeShorthandRules,X as makeStaticRules,We as notLastChildSelector,te as numberRE,b as numberWithUnitRE,P as parseCssColor,de as percentRE,D as polarColorSpace,q as propsToValueMap,E as rectangularColorSpace,Ue as routeGlobalKeywordsToExactRules,H as transformThemeFn,G as transformThemeString,ne as unitOnlyMap,ue as unitOnlyRE,le as valueHandlers};
1
+ import{cssLengthPercentageUnitRESource as e,cssLengthUnitRESource as t,cssLengthUnits as n,cssNamedColors as r,globalKeywords as i}from"./constants.js";import{a,c as o,i as s,n as c,o as l,r as u,s as d,t as ee}from"./css-identifier-4yDg85cV.js";import{_ as te,a as f,b as ne,d as p,f as m,g as re,h as ie,i as ae,l as oe,m as se,n as h,o as g,p as ce,r as le,s as _,t as v,u as y,v as b,x as ue,y as de}from"./standard-value-handler-YFojajHy.js";import{LAYER_PRIMITIVES as fe,LAYER_PROPERTIES as pe,escapeRegExp as x,isStaticRule as me,isString as he,symbols as S,toArray as ge}from"@teacss/core";function _e(e){let t=e.match(/^-?\d+\.?\d*/)?.[0]||``,n=e.slice(t.length);if(n===`px`){let r=Number.parseFloat(t)-.1;return Number.isNaN(r)?e:`${r}${n}`}return`calc(${e} - 0.1px)`}function ve(e,t,n){if(e===``)return;let r=e.length,i=0,a=!1,o=0;for(let s=0;s<r;s++)switch(e[s]){case t:a||(a=!0,o=s),i++;break;case n:if(--i,i<0)return;if(i===0)return[e.slice(o,s+1),e.slice(s+1),e.slice(0,o)]}}function C(e,t,n,r){if(e===``||(he(r)&&(r=[r]),r.length===0))return;let i=e.length,a=0;for(let o=0;o<i;o++)switch(e[o]){case t:a++;break;case n:if(--a<0)return;break;default:for(let t of r){let n=t.length;if(n&&t===e.slice(o,o+n)&&a===0)return o===0||o===i-n?void 0:[e.slice(0,o),e.slice(o+n)]}}if(a===0)return[e,``]}function w(e,t,n,r=`(`,i=`)`){n??=10;let a=[],o=0;for(;e!==``;){if(++o>n)return;let s=C(e,r,i,t);if(!s)return;let[c,l]=s;a.push(c),e=l}if(a.length>0)return a}const T=[`hsl`,`hsla`,`hwb`,`lab`,`lch`,`oklab`,`oklch`,`rgb`,`rgba`],E=[`srgb`,`srgb-linear`,`display-p3`,`display-p3-linear`,`a98-rgb`,`prophoto-rgb`,`rec2020`,`lab`,`oklab`,`xyz`,`xyz-d50`,`xyz-d65`],D=[`hsl`,`hwb`,`lch`,`oklch`],O=[`shorter`,`longer`,`increasing`,`decreasing`],k=[`%alpha`,`<alpha-value>`],A=new RegExp(k.map(e=>x(e)).join(`|`),`g`),j=new Set([...E,...D,...O]);function M(e){if(!e)return!1;let t=-1;for(let n=0;n<=e.length;n++){if(e[n]===`\\`||l(e[n])){t<0&&(t=n);continue}if(t>=0&&j.has(e.slice(t,n).toLowerCase()))return!0;t=-1}return!1}function N(e=``){let t=L(e);if(t!=null){let{components:e,alpha:n}=t;return n==null?e:[...e,n]}}function P(e=``){let t=ye(e);if(t==null||t===!1)return;let{type:n,components:r,alpha:i}=t,a=n.toLowerCase();if(r.length!==0&&(!T.includes(a)||[1,3].includes(r.length)))return{type:a,components:r.map(e=>typeof e==`string`?e.trim():e),alpha:typeof i==`string`?i.trim():i}}function F(e){let t=e.alpha??1;return typeof t==`string`&&k.includes(t)?1:t}function I(e,t){if(typeof e==`string`)return e.replace(A,`${t??1}`);let{components:n}=e,{alpha:r,type:i}=e;return r=t??r,i=i.toLowerCase(),[`hsla`,`rgba`].includes(i)?`${i}(${n.join(`, `)}${r==null?``:`, ${r}`})`:(r=r==null?``:` / ${r}`,T.includes(i)?`${i}(${n.join(` `)}${r})`:`color(${i} ${n.join(` `)}${r})`)}function ye(e){if(!e)return;let t=L(e);if(t!=null||(t=z(e),t!=null)||(t=xe(e),t!=null)||(t=Ce(e),t!=null)||(t=we(e),t!=null))return t}function L(e){let[,t]=e.match(/^#([\da-f]+)$/i)||[];if(t)switch(t.length){case 3:case 4:{let e=Array.from(t,e=>Number.parseInt(e,16)).map(e=>e<<4|e);return{type:`rgb`,components:e.slice(0,3),alpha:t.length===3?void 0:R(e[3])}}case 6:case 8:{let e=Number.parseInt(t,16);return{type:`rgb`,components:t.length===6?[e>>16&255,e>>8&255,e&255]:[e>>24&255,e>>16&255,e>>8&255],alpha:t.length===6?void 0:R(e&255)}}}}function R(e){return Math.round(e/255*1e4)/1e4}const be={rebeccapurple:[102,51,153,1]};function z(e){let t=p(be,e);if(t!=null)return{type:`rgb`,components:t.slice(0,3),alpha:t[3]}}function xe(e){let t=e.match(/^(rgb|rgba|hsl|hsla)\((.+)\)$/i);if(!t)return;let[,n,r]=t,i=w(r,`,`,5);if(i){if([3,4].includes(i.length))return{type:n,components:i.slice(0,3),alpha:i[3]};if(i.length!==1)return!1}}const Se=RegExp(`^(${T.join(`|`)})\\((.+)\\)$`,`i`);function Ce(e){let t=e.match(Se);if(!t)return;let[,n,r]=t,i=B(`${n} ${r}`);if(i){let{alpha:e,components:[t,...n]}=i;return{type:t,components:n,alpha:e}}}function we(e){let t=e.match(/^color\((.+)\)$/);if(!t)return;let n=B(t[1]);if(n){let{alpha:e,components:[t,...r]}=n;return{type:t,components:r,alpha:e}}}function B(e){let t=w(e,` `);if(!t)return;let n=t.length;if(t[n-2]===`/`)return{components:t.slice(0,n-2),alpha:t[n-1]};if(t[n-2]!=null&&(t[n-2].endsWith(`/`)||t[n-1].startsWith(`/`))){let e=t.splice(n-2);t.push(e.join(` `)),--n}let r=w(t[n-1],`/`,2);if(!r)return;if(r.length===1||r[r.length-1]===``)return{components:t};let i=r.pop();return t[n-1]=r.join(`/`),{components:t,alpha:i}}function Te(e,t={}){let{syntax:n=`*`,inherits:r=!1,initialValue:i}=t,a={[S.shortcutsNoMerge]:!0,[S.noMerge]:!0,[S.variants]:()=>[{parent:``,layer:pe,selector:()=>`@property ${e}`}],syntax:JSON.stringify(n),inherits:r?`true`:`false`};return i!=null&&(a[`initial-value`]=i),a}function V(e){return y(e,`theme`)}function Ee(e){return y(e,`icon`)}function H(e,t,n=!0){if(!V(e))return e;let r=[],i=0,a=0;for(;a<e.length;){let o=oe(e,`theme`,a);if(o===-1)break;let s=De(e,o);if(!s)break;if(a=s.end,!s.valid)continue;if(!s.argument)throw Error(`theme() expect exact one argument, but got 0`);let c=G(s.argument,t,s.fallback===void 0&&n)??(s.fallback===void 0?void 0:H(s.fallback,t,n));c!==void 0&&(r.push(e.slice(i,o),c),i=s.end)}return i===0?e:(r.push(e.slice(i)),r.join(``))}function U(e,t){let n=0,r=-1,i;for(let a=t;a<e.length;a++){let t=e[a];if(i!=null){t===`\\`?a++:t===i&&(i=void 0);continue}if(t===`"`||t===`'`)i=t;else if(t===`(`)n++;else if(t===`)`){if(n===0)return{end:a,separator:r};n--}else t===`,`&&n===0&&r===-1&&(r=a)}return{end:-1,separator:-1}}function W(e,t,n,r){let i=e.slice(n,r).trim();return i?{argument:t,fallback:i,end:r+1,valid:!0}:{argument:t,end:r+1,valid:!0}}function De(e,t){let n=t+6;for(;/\s/.test(e[n]??``);)n++;let r=e[n]===`"`||e[n]===`'`?e[n++]:void 0,i=n;if(r){for(;n<e.length;){let t=e[n];if(t===`\\`){n+=2;continue}if(t===r)break;n++}if(n>=e.length)return;let t=e.slice(i,n);for(n++;/\s/.test(e[n]??``);)n++;if(e[n]===`)`)return{argument:t,end:n+1,valid:!0};if(e[n]!==`,`)return{argument:t,end:Oe(e,n),valid:!1};let a=U(e,n+1);return a.end===-1?void 0:W(e,t,n+1,a.end)}let a=U(e,n);if(a.end!==-1)return a.separator===-1?{argument:e.slice(i,a.end).trim(),end:a.end+1,valid:!0}:W(e,e.slice(i,a.separator).trim(),a.separator+1,a.end)}function Oe(e,t){let n=e.indexOf(`)`,t);return n===-1?e.length:n+1}function G(e,t,n=!0){let r=e.indexOf(`/`),i=r<0?e:e.slice(0,r),a=r<0?void 0:e.slice(r+1),o=i.trim().split(`.`),s=t;for(let e of o){if(typeof s!=`object`||!s){s=void 0;break}s=p(s,e)}if(typeof s==`object`&&s&&(s=p(s,`DEFAULT`)),typeof s==`number`&&Number.isFinite(s)&&a==null)return String(s);if(typeof s==`string`){if(!a)return s;let e=ke(a),t=P(s);return t?I(t,e):`color-mix(in oklab, ${s} ${e}, transparent)`}if(n)throw Error(`theme("${e}") was not found`)}function ke(e){let t=e.trim();return/^\d{1,3}$/.test(t)&&Number(t)<=100?`${Number(t)}%`:t}function K(e){return f(e)??g(e)}function Ae(e){return K(e)??_(e)}function je(e,t,n){return[e,([,e])=>({[t]:K(e)}),{autocomplete:n}]}function Me(e,t,n){return[e,([,e])=>({[t]:Ae(e)}),{autocomplete:n}]}const Ne=new Set(i);function Pe(e,t,n){Object.defineProperty(e,t,{value:n,configurable:!0,enumerable:!0,writable:!0})}function Fe(e,t,n={}){let r=J(typeof e==`string`?[e]:e);if(r.length===0)return[];let{property:i,...a}=n,o=(i??r[0]??``).trim();if(!o)throw Error(`makeShorthandRules requires a non-empty property`);return r.map(e=>[e,{[o]:t},{...a,layer:fe}])}function q(e,t,n={}){let{as:r=`record`,dedupe:i=!0,ignores:a=[]}=n,o=new Set,s=a.length?new Set(a.map(String)):void 0,c=t??(e=>e);if(r===`map`){let t=new Map;for(let n of e){let e=String(n);s?.has(e)||i&&o.has(e)||(o.add(e),t.set(e,c(e)))}return t}let l={};for(let t of e){let e=String(t);if(s?.has(e)||i&&o.has(e))continue;o.add(e);let n=c(e);e===`__proto__`?Pe(l,e,n):l[e]=n}return l}function Ie(e,t={}){return q(e,e=>e.includes(`-`)?e.replaceAll(`-`,` `):e,t)}function J(e){let t=new Set,n=[];for(let r of e)r&&(t.has(r)||(t.add(r),n.push(r)));return n}function Le(e){let t=new Set,n=[];for(let r of e){let e=String(r);t.has(e)||(t.add(e),n.push(e))}return n}function Re(e){if(!e)return()=>void 0;if(typeof e==`function`)return e;if(e instanceof Map)return t=>e.get(t);let t=e;return e=>p(t,e)}function Y(e,t){let n=(e??``).trim(),r=Re(t);return e=>{let t=r(e);if(t!=null&&typeof t!=`string`&&typeof t!=`number`)return t;if(!n)throw Error(`makeStaticRules requires a non-empty property`);return{[n]:t??e}}}function X(e,t,n={}){let{valueMap:r,meta:i}=n,a=typeof e==`string`||e===!1?[e]:e,o=a.includes(!1),s=J(a.filter(e=>typeof e==`string`));if(s.length===0&&!o)return[];let c=Le(t);if(c.length===0)return[];let l=Y(n.property??s[0],r),u=[],d=(e,t)=>u.push(i?[e,l(t),i]:[e,l(t)]);for(let e of s)for(let t of c)d(t?`${e}:${t}`:e,t);if(o){let e=new Set([...Ne,...(n.bareExclude??[]).map(String)]);for(let t of c)t&&!e.has(t)&&d(t,t)}return u}const ze=i.join(`|`),Z=new Set(i),Q=Symbol.for(`@teacss/rule-helpers/global-rule-name`);function $(e){return e[2]?.[Q]}function Be(e){if(e.flags)return;let t=e.source;if(!t.startsWith(`^`))return;let n=1;for(;n<t.length&&/[A-Za-z0-9_-]/.test(t[n]);)n++;return t[n]===`:`?t.slice(1,n):void 0}function Ve(e,t,n={}){let r=J((typeof e==`string`||e===!1?[e]:e).filter(e=>typeof e==`string`)),i=X(e,t.filter(e=>!Z.has(String(e))),n);if(r.length===0)return i;let a=Y(n.property??r[0],n.valueMap),o=n.meta?.autocomplete,s=typeof o==`string`?[o]:o??[],c=n.meta?.prefix==null?[``]:ge(n.meta.prefix);for(let e of r){let t={...n.meta,autocomplete:[...s,...c.map(t=>`${t}${e}:<globalKeyword>`)],[Q]:e},r=[RegExp(`^${x(e)}:(${ze})$`),([,e])=>a(e),t];i.push(r)}if(n.escapeHatch){let e=(n.property??r[0]??``).trim();if(!e)throw Error(`escapeHatch requires a rule name or property`);for(let t of r){let r={...n.meta,autocomplete:[...s,...c.map(e=>`${e}${t}:[]`)]};i.push([RegExp(`^${x(t)}:(.+)$`),([,t])=>({[e]:f(t)??g(t)}),r])}}return i}function He(e,t){let n=e.lastIndexOf(`:`);return n<=0||!Z.has(e.slice(n+1))?!1:t.has(e.slice(0,n))}function Ue(e){let t=new Set;for(let n of e){let e=$(n);e!=null&&t.add(e)}return t.size===0?[...e]:e.map(e=>{if(me(e)||$(e)!=null)return e;let[n,r,i]=e,a=Be(n);if(a!=null&&!t.has(a))return e;let o=(e,n)=>{if(!He(e[0],t))return r(e,n)};return i==null?[n,o]:[n,o,i]})}function We(e){let t=`>:not(:last-child)`;return e.includes(t)?`:where(${e})`:`:where(${e}${t})`}export{k as alphaPlaceholders,A as alphaPlaceholdersRE,se as angleRE,ie as bracketTypeRe,_e as calcMaxWidthBySize,F as colorOpacityToString,I as colorToString,ee as consumeCssEscape,c as consumeCssIdentifier,u as consumeCssName,ae as createValueHandler,T as cssColorFunctions,e as cssLengthPercentageUnitRESource,t as cssLengthUnitRESource,n as cssLengthUnits,r as cssNamedColors,m as decodeArbitraryValue,s as decodeCssIdentifier,Te as defineProperty,ve as getBracket,p as getOwn,C as getStringComponent,w as getStringComponents,i as globalKeywords,v as h,h as handler,Ee as hasIconFn,V as hasThemeFn,N as hex2rgba,O as hueInterpolationMethods,Ie as hyphenToSpace,ce as isBareDashedIdentifier,a as isCssIdentifier,l as isCssNameCharacter,d as isCssNameStartCharacter,o as isCssWhitespace,M as isInterpolatedMethod,re as lengthRE,je as makeArbitraryValueRule,Ve as makeGlobalRules,Me as makeGlobalValueRule,Fe as makeShorthandRules,X as makeStaticRules,We as notLastChildSelector,te as numberRE,b as numberWithUnitRE,P as parseCssColor,de as percentRE,D as polarColorSpace,q as propsToValueMap,E as rectangularColorSpace,Ue as routeGlobalKeywordsToExactRules,H as transformThemeFn,G as transformThemeString,ne as unitOnlyMap,ue as unitOnlyRE,le as valueHandlers};
@@ -0,0 +1 @@
1
+ import{cssLengthUnitRESource as e,cssLengthUnits as t,globalKeywords as n}from"./constants.js";import{a as r,c as i,i as a,n as o,o as s,t as c}from"./css-identifier-4yDg85cV.js";import{escapeSelector as l}from"@teacss/core";const u=`(?:${t.join(`|`)})`,d=RegExp(`^([+-]?\\d*(?:\\.\\d+)?(?:e[+-]?\\d+)?)(${u})?$`,`i`),f=/^([+-]?\d*(?:\.\d+)?(?:e[+-]?\d+)?)$/i,p=/^[+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?(?:deg|grad|rad|turn)$/i,m=/^[+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?%$/i,h=RegExp(`^[+-]?(?:\\d+(?:\\.\\d+)?|\\.\\d+)(?:e[+-]?\\d+)?${e}$`,`i`),g={px:1,vw:100,vh:100,svw:100,svh:100,dvw:100,dvh:100,lvh:100,lvw:100},_=RegExp(`^(${Object.keys(g).join(`|`)})$`,`i`),v=/^\[(color|image|length|size|position|quoted|string):/i,ee=new Set([...t,`angle`,`color`,`dpcm`,`deg`,`dpi`,`dppx`,`flex`,`fr`,`frequency`,`grad`,`hz`,`integer`,`khz`,`length`,`ms`,`number`,`percentage`,`rad`,`raw-string`,`resolution`,`s`,`string`,`time`,`turn`,`url`,`x`]);function y(e){return e.length>2&&e.startsWith(`--`)&&r(e)}function te(e){let t=0,n,r=-1;for(let i=0;i<e.length;i++){let a=e[i];if(n){a===`\\`?i++:a===n&&(n=void 0,r=-1);continue}if(a===`"`||a===`'`)n=a,r=i;else if(a===`\\`)i++;else if(a===`[`)t++;else if(a===`]`&&--t<0)return!1}if(r>=0){for(let n=r+1;n<e.length;n++)if(e[n]===`\\`)n++;else if(e[n]===`[`)t++;else if(e[n]===`]`&&--t<0)return!1}return t===0}function b(e){let t=(t,n)=>{let r=[],i;for(let a=t;a<e.length;a++){let t=e[a];if(i){t===`\\`?a++:t===i&&(i=void 0);continue}if(n&&(t===`"`||t===`'`))i=t;else if(t===`\\`)a++;else if(t===`/`&&e[a+1]===`*`){let t=e.indexOf(`*/`,a+2);if(t===-1)return!1;a=t+1}else if(t===`*`&&e[a+1]===`/`)return!1;else if(t===`(`)r.push(`)`);else if(t===`{`)r.push(`}`);else if(t===`)`||t===`}`){if(r.pop()!==t)return!1}else if(t===`;`&&r.length===0)return!1}return i===void 0?r.length===0:e.length},n=t(0,!0);return typeof n==`boolean`?n:t(0,!1)===!0}function ne(e){if(!e)return;let t=e.length-1;if(!(t<2||e.charCodeAt(0)!==91||e.charCodeAt(t)!==93)&&(e.charCodeAt(1)!==45||e.charCodeAt(2)!==45)){for(let n=1;n<t;n++)switch(e.charCodeAt(n)){case 34:case 39:case 40:case 41:case 58:case 59:case 91:case 92:case 93:case 95:case 96:case 123:case 125:return;case 42:case 47:if(e.charCodeAt(n+1)===42||e.charCodeAt(n+1)===47)return}return e.slice(1,t)}}function x(e){let t=``;for(let n=0;n<e.length;n++)e[n]===`\\`&&e[n+1]===`_`?(t+=`_`,n++):t+=e[n]===`_`?` `:e[n];return t}function S(e,t){let n=0;for(;t>0&&e[--t]===`\\`;)n++;return n%2==1}function C(e,t){if(t===0)return!0;let n=e[t-1];return n===`_`&&!S(e,t-1)||n!==`\\`&&!s(n)}function re(e,t,n,r){for(let i=t;i<n;i++)e[i]===`_`&&!S(e,i)&&!w(e,i)&&r.add(i)}function w(e,t){let n=t-1,r=0;for(;n>=0&&r<6&&/[0-9a-f]/i.test(e[n]);)n--,r++;return r>0&&e[n]===`\\`&&!S(e,n)}function T(e,t,n){let r=e.lastIndexOf(`_`,n-1);for(;r>=t&&S(e,r);)r=e.lastIndexOf(`_`,r-1);return r}function E(e,t,n){let r=T(e,t,n);if(r<t)return n;if(r===n-1&&e[n]===`%`)return r;let i=a(e.slice(r+1,n)).toLowerCase();return ee.has(i)||i===`type`&&e[n]===`(`?r:n}function D(e){return e!=null&&e>=`0`&&e<=`9`}function ie(e,t,n){let r=D(e[n])||e[n]===`+`&&D(e[n+1]);if(e[n-1]===`_`&&!S(e,n-1)&&r)return n-1;let i=n;for(;i>t&&D(e[i-1]);)i--;if(i===n)return n;let a=n;for(;i>t&&e[i-1]===`_`&&!S(e,i-1);){a=--i;let n=i;for(;i>t&&D(e[i-1]);)i--;if(i===n)break}return a}function ae(e){let t=[];return e.replace(/var\((--.+?)[,)]/g,(e,n)=>(t.push(n),e.replace(n,`--calc`))).replace(/(-?\d*\.?\d(?!-\d.+[,)](?![^+\-/*])\D)(?:%|[a-z]+)?|\))([+\-/*])/g,`$1 $2 `).replace(/--calc/g,()=>t.shift())}function oe(e){let t=[],n=/(?:calc|clamp|max|min)\(/gi,r=0,i;for(;(i=n.exec(e))!==null;){if(!C(e,i.index))continue;let a=k(e,n.lastIndex);a!=null&&(t.push(e.slice(r,i.index),ae(e.slice(i.index,a))),r=a,n.lastIndex=a)}return r===0?e:(t.push(e.slice(r)),t.join(``))}function O(e,t){let n=e[t];if(n===`"`||n===`'`){for(let r=t+1;r<e.length;r++)if(e[r]===`\\`)r++;else if(e[r]===n)return r+1;return e.length}if(e[t]===`/`&&e[t+1]===`*`){let n=e.indexOf(`*/`,t+2);return n<0?e.length:n+2}}function se(e,t){let n=t;for(;n<e.length;){if(i(e[n])||e[n]===`_`&&!S(e,n)){n++;continue}if(e[n]!==`/`||e[n+1]!==`*`)return n;let t=O(e,n);if(t==null)return n;n=t}return n}function ce(e){let t=new Set,n=[];for(let r=0;r<e.length;){let i=O(e,r);if(i!=null){r=i;continue}let s=o(e,r);if(s==null){r++;continue}if(!C(e,r)){if(e[s]!==`(`){r=s;continue}let t=e.lastIndexOf(`_`,s-1);r=t>r?t+1:s;continue}if(e[s]!==`(`){r=s;continue}let c=T(e,r,s);if(c>=r){r=c+1;continue}let l=a(e.slice(r,s)).toLowerCase();if(l===`url`){let t=k(e,s+1);if(t==null)break;n.push({start:r,end:t}),r=t;continue}if(l===`attr`||l===`env`||l===`var`){let n=se(e,s+1),r=o(e,n);r!=null&&re(e,n,l===`attr`?E(e,n,r):l===`env`?ie(e,n,r):r,t)}r=s+1}return{indexes:t,literals:n}}function le(e){let t=ce(e),n=0,r=``;for(let i=0;i<e.length;i++){let a=t.literals[n];if(a&&i===a.start){r+=e.slice(a.start,a.end),i=a.end-1,n++;continue}if(e[i]===`\\`&&e[i+1]===`_`){r+=`_`,i++;continue}r+=e[i]===`_`&&!t.indexes.has(i)?` `:e[i]}return r}function k(e,t){let n=1,r;for(let i=t;i<e.length;i++){let t=e[i];if(t===`\\`){i++;continue}if(r)t===r&&(r=void 0);else if(t===`"`||t===`'`)r=t;else if(t===`(`)n++;else if(t===`)`&&--n===0)return i+1}}function A(e){let t=ne(e);if(t!==void 0)return t;if(!e?.startsWith(`[`)||!e.endsWith(`]`))return;let n=e.match(v),r=e.slice(n?.[0].length??1,-1);if(!r||r===`=""`||!te(r))return;let i=n?.[1];if(i===`quoted`)return`"${x(r).replace(/(["\\])/g,`\\$1`)}"`;if(b(r))return i===`string`?x(r):(y(r)&&(r=`var(${r})`),oe(le(r)))}function j(e){return A(e)}function M(e,t){if(e!=null&&Object.hasOwn(e,t))return e[t]}function N(e,t,n=0){let r=`${t}(`,i;for(let t=n;t<=e.length-r.length;t++){let n=e[t];if(i!=null){n===`\\`?t=(c(e,t)??t+1)-1:n===i&&(i=void 0);continue}if(n===`'`||n===`"`){i=n;continue}if(n===`\\`){t=(c(e,t)??t+1)-1;continue}if(n===`/`&&e[t+1]===`*`){let n=e.indexOf(`*/`,t+2);if(n===-1)return-1;t=n+1;continue}if(!e.startsWith(r,t))continue;let a=e[t-1];if(t===0||!s(a))return t}return-1}function P(e,t){let n=N(e,t);return n>=0&&e.indexOf(`)`,n+t.length+1)>=0}function F(e,t,n=!1){if(e.length<=t.length+1||e[t.length]!==`(`||e.at(-1)!==`)`)return!1;let r=e.slice(0,t.length);if(n?r.toLowerCase()!==t.toLowerCase():r!==t)return!1;let i=1,a;for(let n=t.length+1;n<e.length;n++){let t=e[n];if(t===`\\`){n++;continue}if(a!=null){t===a&&(a=void 0);continue}if(t===`'`||t===`"`){a=t;continue}if(t===`(`)i++;else if(t===`)`&&--i===0)return n===e.length-1}return!1}const I=new Set(n),L=String.raw`[+-]?(?:\d+|\d*\.\d+)(?:[eE][+-]?\d+)?`,R=RegExp(`^${L}$`),z=RegExp(`^${L}%$`),B=RegExp(`^(${L})(s|ms)?$`,`i`),V=RegExp(`^(${L})(deg|rad|grad|turn)?$`,`i`),H=`color.border-color.background-color.outline-color.text-decoration-color.flex-grow.flex.flex-shrink.caret-color.font.gap.opacity.visibility.z-index.font-weight.zoom.text-shadow.transform.box-shadow.border.background-position.left.right.top.bottom.object-position.max-height.min-height.max-width.min-width.height.width.border-width.margin.padding.outline-width.outline-offset.font-size.line-height.text-indent.vertical-align.border-spacing.letter-spacing.word-spacing.stroke.filter.backdrop-filter.fill.mask.mask-size.mask-border.clip-path.clip.border-radius`.split(`.`);function U(e){return+e.toFixed(10)}function W(e){let t=e.match(d);if(!t)return;let[,n,r]=t,i=Number.parseFloat(n);if(r&&Number.isFinite(i))return`${U(i)}${r}`}function ue(e){if(e===`auto`)return`auto`}function de(e){if(e===`empty`)return`""`}function fe(e){if(e===`square`)return`1/1`}function pe(e){if(e===`video`)return`16/9`}function me(e){if(!e)return;if(_.test(e))return`${g[e.toLowerCase()]}${e}`;let t=e.match(d);if(!t)return;let[,n,r]=t,i=Number.parseFloat(n);if(Number.isFinite(i))return i===0?`0`:r?`${U(i)}${r}`:`${U(i/4)}rem`}function he(e){if(_.test(e))return`${g[e.toLowerCase()]}${e}`;let t=e?.match(d);if(!t)return;let[,n,r]=t,i=Number.parseFloat(n);if(Number.isFinite(i))return r?`${U(i)}${r}`:`${U(i)}px`}function G(e){if(!f.test(e))return;let t=Number.parseFloat(e);if(Number.isFinite(t))return U(t)}function ge(e){if(/^-?\d+$/.test(e))return e}function _e(e){if(/^[1-9]\d*$/.test(e))return e}function ve(e){if(!r(e))return;let t=a(e).toLowerCase();if(!(t==="default"||I.has(t)))return e}function ye(e){if(e.length>5&&F(e,`url`,!0))return e}function K(e){if(z.test(e))return e;if(f.test(e)){let t=Number.parseFloat(e);if(Number.isFinite(t))return`${U(t)}%`}}function be(e){return/^\d*\.\d+$/.test(e)?e:K(e)}function xe(e){if(!e)return;let t=e.indexOf(`/`);if(t<=0||t!==e.lastIndexOf(`/`)||t===e.length-1)return;let n=e.slice(0,t),r=e.slice(t+1);if(!R.test(n)||!R.test(r))return;let i=Number(r);if(i===0)return;let a=Number(n)/i;if(Number.isFinite(a))return a===0?`0`:`${U(a*100)}%`}function Se(e){let t=G(e);if(t!=null)return Number(t)===0?`0`:`calc(var(--spacing) * ${t})`}function q(e){return j(e)}function J(e){if(!/^\$[^\s'"`;{}]/.test(e))return;let t=e.slice(1),n=t.indexOf(`|`),r=n===-1?t:t.slice(0,n),i=n===-1?void 0:t.slice(n+1);if(!r||/[,@\s'"`;{}]/.test(r)||n!==-1&&!i)return;let a=i;if(i?.startsWith(`$`)){if(a=J(i),a==null)return}else if(i!=null&&!b(i))return;return`var(--${l(r)}${a?`, ${a}`:``})`}function Ce(e){let t=e.match(B);if(!t)return;let[,n,r]=t,i=Number(n);if(Number.isFinite(i))return i===0&&!r?`0s`:r?`${U(i)}${r}`:`${U(i)}ms`}function we(e){let t=e.match(V);if(!t)return;let[,n,r]=t,i=Number(n);if(Number.isFinite(i))return i===0&&!r?`0`:r?`${U(i)}${r}`:`${U(i)}deg`}function Y(e){if(I.has(e))return e}function Te(e){if(e.split(`,`).every(e=>H.includes(e)))return e}function Ee(e){if([`top`,`left`,`right`,`bottom`,`center`].includes(e))return e}function De(e){if([`top`,`bottom`,`left`,`right`,`center`,`top-left`,`top-right`,`bottom-left`,`bottom-right`].includes(e))return e}function Oe(e){if(e===`none`)return`none`}function ke(e){if(e===`none`||e===`zero`)return`0`}function X(e){if(Object.hasOwn(e,`__options`))throw Error(`"__options" is a reserved createValueHandler name`);let t=Object.keys(e),n=Object.create(Function.prototype),r=new WeakMap;function i(t){let i=Object.freeze([...t]),a=((t,n)=>{for(let r of i){let i=e[r](t,n);if(i!=null)return i}});return Object.defineProperty(a,"__options",{enumerable:!0,value:Object.freeze({sequence:Object.freeze([...i])})}),r.set(a,i),Object.setPrototypeOf(a,n),a}function a(e){for(let n of t)Object.defineProperty(e,n,{enumerable:!0,configurable:!0,get(){let e=i([...r.get(this)??[],n]);return Object.defineProperty(this,n,{enumerable:!0,configurable:!0,value:e}),e}})}a(n);let o=i([]);return a(o),o}const Z=Object.freeze({alpha:be,auto:ue,bracket:q,cssvar:J,customIdent:ve,degree:we,empty:de,fraction:xe,global:Y,integer:ge,none:Oe,number:G,numberWithUnit:W,percent:K,placement:De,position:Ee,positiveInteger:_e,properties:Te,px:he,rem:me,spacing:Se,square:fe,time:Ce,url:ye,video:pe,zero:ke}),Q=X(Z),$=Q;export{f as _,q as a,g as b,U as c,M as d,j as f,h as g,v as h,X as i,N as l,p as m,Q as n,J as o,y as p,Z as r,Y as s,$ as t,P as u,d as v,_ as x,m as y};
@@ -1,23 +1,23 @@
1
1
  import { Arrayable } from "@teacss/core";
2
2
  //#region src/color-opacity.d.ts
3
- declare function isValidOpacityModifier(value: string): boolean;
4
- declare function resolveAlphaValue(value: string): string | undefined;
3
+ export declare function isValidOpacityModifier(value: string): boolean;
4
+ export declare function resolveAlphaValue(value: string): string | undefined;
5
5
  /**
6
6
  * Apply an optional `/NN` opacity (integer 0–100) to a color via
7
7
  * `color-mix(in oklab, …)`. An invalid modifier throws instead of silently
8
8
  * passing the color through — callers must pre-validate with
9
9
  * {@link isValidOpacityModifier}.
10
10
  */
11
- declare function applyOpacity(color: string, opacity?: string): string;
11
+ export declare function applyOpacity(color: string, opacity?: string): string;
12
12
  /** Split a color value on a depth-0 `/` into [color, opacity?]. */
13
- declare function splitOpacity(value: string): [color: string, opacity?: string];
13
+ export declare function splitOpacity(value: string): [color: string, opacity?: string];
14
14
  //#endregion
15
15
  //#region src/css-variable-token.d.ts
16
- declare function isCssVariableToken(value: string): boolean;
16
+ export declare function isCssVariableToken(value: string): boolean;
17
17
  //#endregion
18
18
  //#region src/keyword-value-resolvers.d.ts
19
- declare function resolveKeyword(value: string, allowed: ReadonlySet<string>): string | undefined;
20
- declare function resolveKeywordList(value: string, allowed: ReadonlySet<string>): string | undefined;
19
+ export declare function resolveKeyword(value: string, allowed: ReadonlySet<string>): string | undefined;
20
+ export declare function resolveKeywordList(value: string, allowed: ReadonlySet<string>): string | undefined;
21
21
  //#endregion
22
22
  //#region src/number-value-resolvers.d.ts
23
23
  /**
@@ -26,13 +26,13 @@ declare function resolveKeywordList(value: string, allowed: ReadonlySet<string>)
26
26
  * A caller-supplied fallback is normalized with `Number`, preserving `NaN` so
27
27
  * callers can distinguish a present nonnumeric token from a missing token.
28
28
  */
29
- declare function resolveNumber(value: string, fallback?: string | number): number | undefined;
29
+ export declare function resolveNumber(value: string, fallback?: string | number): number | undefined;
30
30
  //#endregion
31
31
  //#region src/shadow-value.d.ts
32
- declare function normalizeShadowLength(value: string): string | undefined;
33
- declare function isNonnegativeLengthValue(value: string): boolean;
34
- declare function splitShadowLayers(value: string): string[];
35
- declare function hasInvalidTextShadowRadius(value: string): boolean;
32
+ export declare function normalizeShadowLength(value: string): string | undefined;
33
+ export declare function isNonnegativeLengthValue(value: string): boolean;
34
+ export declare function splitShadowLayers(value: string): string[];
35
+ export declare function hasInvalidTextShadowRadius(value: string): boolean;
36
36
  //#endregion
37
37
  //#region src/theme-variable.d.ts
38
38
  type ThemeVariableValue = string | readonly string[];
@@ -41,11 +41,10 @@ type ThemeVariableGroupKey<Theme> = { [K in keyof Theme]-?: Theme[K] extends The
41
41
  /**
42
42
  * Convert a camelCase theme key to its kebab-case CSS variable segment.
43
43
  */
44
- declare function camelToKebab(value: string): string;
45
- declare function resolveThemeVariable<Theme extends object, GroupKey extends ThemeVariableGroupKey<Theme>>(theme: Theme | undefined, groupKey: GroupKey, props: Arrayable<string>, variablePrefix?: string, passthrough?: ReadonlySet<string>): string | undefined;
44
+ export declare function camelToKebab(value: string): string;
45
+ export declare function resolveThemeVariable<Theme extends object, GroupKey extends ThemeVariableGroupKey<Theme>>(theme: Theme | undefined, groupKey: GroupKey, props: Arrayable<string>, variablePrefix?: string, passthrough?: ReadonlySet<string>): string | undefined;
46
46
  //#endregion
47
47
  //#region src/time-value-resolvers.d.ts
48
- declare function resolveNonnegativeTime(value: string, keywords?: readonly string[]): string | undefined;
49
- declare function resolveTime(value: string): string | undefined;
50
- //#endregion
51
- export { applyOpacity, camelToKebab, hasInvalidTextShadowRadius, isCssVariableToken, isNonnegativeLengthValue, isValidOpacityModifier, normalizeShadowLength, resolveAlphaValue, resolveKeyword, resolveKeywordList, resolveNonnegativeTime, resolveNumber, resolveThemeVariable, resolveTime, splitOpacity, splitShadowLayers };
48
+ export declare function resolveNonnegativeTime(value: string, keywords?: readonly string[]): string | undefined;
49
+ export declare function resolveTime(value: string): string | undefined;
50
+ //#endregion
@@ -1 +1 @@
1
- import{cssLengthUnitRESource as e,globalKeywords as t}from"./constants.js";import{findLastTopLevelDelimiter as n,splitTopLevelCommas as r,topLevelWhitespaceSpans as i}from"./css-syntax.js";import{c as a,g as o,h as s,n as c,u as l}from"./css-value-syntax-BRbCuvQw.js";import{c as u,d,f,n as p,t as m,x as h}from"./standard-value-handler-DimbUwdo.js";function g(e){return/^\d{1,3}$/.test(e)&&Number(e)<=100}function _(e){let t=m.global.cssvar(e);if(t!=null)return t;let n=m.bracket(e);return n==null?a.test(e)?`${e}%`:m.alpha(e):o(n)?n:void 0}function v(e,t){if(t==null)return e;if(!g(t))throw Error(`applyOpacity received an invalid opacity modifier: ${t}`);return`color-mix(in oklab, ${e} ${Number(t)}%, transparent)`}function y(e){let t=n(e,`/`);return t<0?[e]:[e.slice(0,t),e.slice(t+1)]}function b(e){return m.cssvar(e)!=null}function x(e,t){return m.cssvar.global(e)??m.bracket(e)??(t.has(e)?e:void 0)}function S(e,t){return m.cssvar.global(e)??(t.has(e)?e:m.bracket(e))}function C(e,t){let n=p.fraction.number(e)??t;if(n==null)return;let r=String(n);return r.endsWith(`%`)?u(Number(r.slice(0,-1))/100):Number(n)}const w=RegExp(`^([+-]?(?:\\d+|\\d*\\.\\d+)(?:e[+-]?\\d+)?)(${e})?$`,`i`),T=/^[+-]?(?:\d+|\d*\.\d+)(?:e[+-]?\d+)?%$/i,E=new Set(t);function D(e){return i(e).map(e=>e.value)}function O(e){return/rpx$/i.test(e)||T.test(e)?!1:h.test(e)||w.test(e)}function k(e){if(/rpx$/i.test(e))return;let t=m.px(e);if(t!=null)return t;let n=e.match(w);if(!n)return;let r=Number(n[1]);if(!Number.isFinite(r))return;let i=Number(r.toFixed(10));return n[2]?`${i}${n[2]}`:`${i}px`}function A(e){let t=f(e);return t==null?e.startsWith(`[`)||e.endsWith(`]`)?!1:b(e)?!0:e.startsWith(`-`)||E.has(e)?!1:O(e):j(t).length===1&&D(t).length===1&&s(t)&&!l(t)}function j(e){return r(e)}function M(e){return j(e).some(e=>D(e).filter(e=>w.test(e)).slice(2,4).some(e=>Number(e.match(w)?.[1])<0))}const N=new Set;function P(e){return e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function F(e){return typeof e==`string`?e:e.join(`-`)}function I(e,t,n,r,i=N){let a=d(e,t);if(!a)return;let o=F(n),s=d(a,o);if(s!=null)return i.has(o)?typeof s==`string`?s:s.join(` `):`var(--${r??P(t)}-${o})`}function L(e){return e.replace(/\/\*[\s\S]*?\*\//g,` `).trim()}function R(e,t=[]){let n=m.bracket(e);if(n!=null){let e=r(n);return e.length>0&&e.every(e=>{let n=L(e);return t.includes(n)||c(n)&&!V(n)})?n:void 0}let i=m.cssvar.global(e);if(i!=null)return i;if(t.includes(e))return e;let a=m.time(e);return a?.startsWith(`-`)?void 0:a}function z(e){let t=m.bracket(e);if(t!=null){let e=r(t);return e.length>0&&e.every(e=>c(L(e)))?t:void 0}return m.cssvar.global.time(e)}const B=/^([+-]?(?:\d+|\d*\.\d+)(?:e[+-]?\d+)?)(?:ms|s)?$/i;function V(e){let t=e.match(B);return t!=null&&Number(t[1])<0}export{v as applyOpacity,P as camelToKebab,M as hasInvalidTextShadowRadius,b as isCssVariableToken,A as isNonnegativeLengthValue,g as isValidOpacityModifier,k as normalizeShadowLength,_ as resolveAlphaValue,x as resolveKeyword,S as resolveKeywordList,R as resolveNonnegativeTime,C as resolveNumber,I as resolveThemeVariable,z as resolveTime,y as splitOpacity,j as splitShadowLayers};
1
+ import{cssLengthUnitRESource as e,globalKeywords as t}from"./constants.js";import{findLastTopLevelDelimiter as n,splitTopLevelCommas as r,topLevelWhitespaceSpans as i}from"./css-syntax.js";import{c as a,g as o,h as s,n as c,u as l}from"./css-value-syntax-BRbCuvQw.js";import{c as u,d,f,n as p,t as m,x as h}from"./standard-value-handler-YFojajHy.js";function g(e){return/^\d{1,3}$/.test(e)&&Number(e)<=100}function _(e){let t=m.global.cssvar(e);if(t!=null)return t;let n=m.bracket(e);return n==null?a.test(e)?`${e}%`:m.alpha(e):o(n)?n:void 0}function v(e,t){if(t==null)return e;if(!g(t))throw Error(`applyOpacity received an invalid opacity modifier: ${t}`);return`color-mix(in oklab, ${e} ${Number(t)}%, transparent)`}function y(e){let t=n(e,`/`);return t<0?[e]:[e.slice(0,t),e.slice(t+1)]}function b(e){return m.cssvar(e)!=null}function x(e,t){return m.cssvar.global(e)??m.bracket(e)??(t.has(e)?e:void 0)}function S(e,t){return m.cssvar.global(e)??(t.has(e)?e:m.bracket(e))}function C(e,t){let n=p.fraction.number(e)??t;if(n==null)return;let r=String(n);return r.endsWith(`%`)?u(Number(r.slice(0,-1))/100):Number(n)}const w=RegExp(`^([+-]?(?:\\d+|\\d*\\.\\d+)(?:e[+-]?\\d+)?)(${e})?$`,`i`),T=/^[+-]?(?:\d+|\d*\.\d+)(?:e[+-]?\d+)?%$/i,E=new Set(t);function D(e){return i(e).map(e=>e.value)}function O(e){return/rpx$/i.test(e)||T.test(e)?!1:h.test(e)||w.test(e)}function k(e){if(/rpx$/i.test(e))return;let t=m.px(e);if(t!=null)return t;let n=e.match(w);if(!n)return;let r=Number(n[1]);if(!Number.isFinite(r))return;let i=Number(r.toFixed(10));return n[2]?`${i}${n[2]}`:`${i}px`}function A(e){let t=f(e);return t==null?e.startsWith(`[`)||e.endsWith(`]`)?!1:b(e)?!0:e.startsWith(`-`)||E.has(e)?!1:O(e):j(t).length===1&&D(t).length===1&&s(t)&&!l(t)}function j(e){return r(e)}function M(e){return j(e).some(e=>D(e).filter(e=>w.test(e)).slice(2,4).some(e=>Number(e.match(w)?.[1])<0))}const N=new Set;function P(e){return e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function F(e){return typeof e==`string`?e:e.join(`-`)}function I(e,t,n,r,i=N){let a=d(e,t);if(!a)return;let o=F(n),s=d(a,o);if(s!=null)return i.has(o)?typeof s==`string`?s:s.join(` `):`var(--${r??P(t)}-${o})`}function L(e){return e.replace(/\/\*[\s\S]*?\*\//g,` `).trim()}function R(e,t=[]){let n=m.bracket(e);if(n!=null){let e=r(n);return e.length>0&&e.every(e=>{let n=L(e);return t.includes(n)||c(n)&&!V(n)})?n:void 0}let i=m.cssvar.global(e);if(i!=null)return i;if(t.includes(e))return e;let a=m.time(e);return a?.startsWith(`-`)?void 0:a}function z(e){let t=m.bracket(e);if(t!=null){let e=r(t);return e.length>0&&e.every(e=>c(L(e)))?t:void 0}return m.cssvar.global.time(e)}const B=/^([+-]?(?:\d+|\d*\.\d+)(?:e[+-]?\d+)?)(?:ms|s)?$/i;function V(e){let t=e.match(B);return t!=null&&Number(t[1])<0}export{v as applyOpacity,P as camelToKebab,M as hasInvalidTextShadowRadius,b as isCssVariableToken,A as isNonnegativeLengthValue,g as isValidOpacityModifier,k as normalizeShadowLength,_ as resolveAlphaValue,x as resolveKeyword,S as resolveKeywordList,R as resolveNonnegativeTime,C as resolveNumber,I as resolveThemeVariable,z as resolveTime,y as splitOpacity,j as splitShadowLayers};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teacss/rule-helpers",
3
- "version": "0.4.7",
3
+ "version": "0.5.0",
4
4
  "description": "Helpers for authoring TeaCSS preset rules — static/dynamic rule builders and value resolvers.",
5
5
  "homepage": "https://css.teasim.com",
6
6
  "funding": "https://github.com/sponsors/billgo",
@@ -26,7 +26,7 @@
26
26
  "dev": "tsdown --watch"
27
27
  },
28
28
  "dependencies": {
29
- "@teacss/core": "0.4.7"
29
+ "@teacss/core": "0.5.0"
30
30
  },
31
31
  "engines": {
32
32
  "node": ">=22.12.0"
@@ -1 +0,0 @@
1
- import{cssLengthUnitRESource as e,cssLengthUnits as t,globalKeywords as n}from"./constants.js";import{a as r,c as i,i as a,n as o,o as s,t as c}from"./css-identifier-4yDg85cV.js";import{escapeSelector as l}from"@teacss/core";const u=`(?:${t.join(`|`)})`,d=RegExp(`^([+-]?\\d*(?:\\.\\d+)?(?:e[+-]?\\d+)?)(${u})?$`,`i`),f=/^([+-]?\d*(?:\.\d+)?(?:e[+-]?\d+)?)$/i,p=/^[+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?(?:deg|grad|rad|turn)$/i,m=/^[+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?%$/i,h=RegExp(`^[+-]?(?:\\d+(?:\\.\\d+)?|\\.\\d+)(?:e[+-]?\\d+)?${e}$`,`i`),g={px:1,vw:100,vh:100,svw:100,svh:100,dvw:100,dvh:100,lvh:100,lvw:100},_=RegExp(`^(${Object.keys(g).join(`|`)})$`,`i`),v=/^\[(color|image|length|size|position|quoted|string):/i,ee=new Set([...t,`angle`,`color`,`dpcm`,`deg`,`dpi`,`dppx`,`flex`,`fr`,`frequency`,`grad`,`hz`,`integer`,`khz`,`length`,`ms`,`number`,`percentage`,`rad`,`raw-string`,`resolution`,`s`,`string`,`time`,`turn`,`url`,`x`]);function y(e){return e.length>2&&e.startsWith(`--`)&&r(e)}function te(e){let t=0,n,r=-1;for(let i=0;i<e.length;i++){let a=e[i];if(n){a===`\\`?i++:a===n&&(n=void 0,r=-1);continue}if(a===`"`||a===`'`)n=a,r=i;else if(a===`\\`)i++;else if(a===`[`)t++;else if(a===`]`&&--t<0)return!1}if(r>=0){for(let n=r+1;n<e.length;n++)if(e[n]===`\\`)n++;else if(e[n]===`[`)t++;else if(e[n]===`]`&&--t<0)return!1}return t===0}function b(e){let t=(t,n)=>{let r=[],i;for(let a=t;a<e.length;a++){let t=e[a];if(i){t===`\\`?a++:t===i&&(i=void 0);continue}if(n&&(t===`"`||t===`'`))i=t;else if(t===`\\`)a++;else if(t===`/`&&e[a+1]===`*`){let t=e.indexOf(`*/`,a+2);if(t===-1)return!1;a=t+1}else if(t===`*`&&e[a+1]===`/`)return!1;else if(t===`(`)r.push(`)`);else if(t===`{`)r.push(`}`);else if(t===`)`||t===`}`){if(r.pop()!==t)return!1}else if(t===`;`&&r.length===0)return!1}return i===void 0?r.length===0:e.length},n=t(0,!0);return typeof n==`boolean`?n:t(0,!1)===!0}function ne(e){if(!e)return;let t=e.length-1;if(!(t<2||e.charCodeAt(0)!==91||e.charCodeAt(t)!==93)&&(e.charCodeAt(1)!==45||e.charCodeAt(2)!==45)){for(let n=1;n<t;n++)switch(e.charCodeAt(n)){case 34:case 39:case 40:case 41:case 58:case 59:case 91:case 92:case 93:case 95:case 96:case 123:case 125:return;case 42:case 47:if(e.charCodeAt(n+1)===42||e.charCodeAt(n+1)===47)return;break}return e.slice(1,t)}}function x(e){let t=``;for(let n=0;n<e.length;n++)e[n]===`\\`&&e[n+1]===`_`?(t+=`_`,n++):t+=e[n]===`_`?` `:e[n];return t}function S(e,t){let n=0;for(;t>0&&e[--t]===`\\`;)n++;return n%2==1}function C(e,t){if(t===0)return!0;let n=e[t-1];return n===`_`&&!S(e,t-1)||n!==`\\`&&!s(n)}function re(e,t,n,r){for(let i=t;i<n;i++)e[i]===`_`&&!S(e,i)&&!w(e,i)&&r.add(i)}function w(e,t){let n=t-1,r=0;for(;n>=0&&r<6&&/[0-9a-f]/i.test(e[n]);)n--,r++;return r>0&&e[n]===`\\`&&!S(e,n)}function T(e,t,n){let r=e.lastIndexOf(`_`,n-1);for(;r>=t&&S(e,r);)r=e.lastIndexOf(`_`,r-1);return r}function E(e,t,n){let r=T(e,t,n);if(r<t)return n;if(r===n-1&&e[n]===`%`)return r;let i=a(e.slice(r+1,n)).toLowerCase();return ee.has(i)||i===`type`&&e[n]===`(`?r:n}function D(e){return e!=null&&e>=`0`&&e<=`9`}function ie(e,t,n){let r=D(e[n])||e[n]===`+`&&D(e[n+1]);if(e[n-1]===`_`&&!S(e,n-1)&&r)return n-1;let i=n;for(;i>t&&D(e[i-1]);)i--;if(i===n)return n;let a=n;for(;i>t&&e[i-1]===`_`&&!S(e,i-1);){a=--i;let n=i;for(;i>t&&D(e[i-1]);)i--;if(i===n)break}return a}function ae(e){let t=[];return e.replace(/var\((--.+?)[,)]/g,(e,n)=>(t.push(n),e.replace(n,`--calc`))).replace(/(-?\d*\.?\d(?!-\d.+[,)](?![^+\-/*])\D)(?:%|[a-z]+)?|\))([+\-/*])/g,`$1 $2 `).replace(/--calc/g,()=>t.shift())}function oe(e){let t=[],n=/(?:calc|clamp|max|min)\(/gi,r=0,i;for(;(i=n.exec(e))!==null;){if(!C(e,i.index))continue;let a=k(e,n.lastIndex);a!=null&&(t.push(e.slice(r,i.index),ae(e.slice(i.index,a))),r=a,n.lastIndex=a)}return r===0?e:(t.push(e.slice(r)),t.join(``))}function O(e,t){let n=e[t];if(n===`"`||n===`'`){for(let r=t+1;r<e.length;r++)if(e[r]===`\\`)r++;else if(e[r]===n)return r+1;return e.length}if(e[t]===`/`&&e[t+1]===`*`){let n=e.indexOf(`*/`,t+2);return n<0?e.length:n+2}}function se(e,t){let n=t;for(;n<e.length;){if(i(e[n])||e[n]===`_`&&!S(e,n)){n++;continue}if(e[n]!==`/`||e[n+1]!==`*`)return n;let t=O(e,n);if(t==null)return n;n=t}return n}function ce(e){let t=new Set,n=[];for(let r=0;r<e.length;){let i=O(e,r);if(i!=null){r=i;continue}let s=o(e,r);if(s==null){r++;continue}if(!C(e,r)){if(e[s]!==`(`){r=s;continue}let t=e.lastIndexOf(`_`,s-1);r=t>r?t+1:s;continue}if(e[s]!==`(`){r=s;continue}let c=T(e,r,s);if(c>=r){r=c+1;continue}let l=a(e.slice(r,s)).toLowerCase();if(l===`url`){let t=k(e,s+1);if(t==null)break;n.push({start:r,end:t}),r=t;continue}if(l===`attr`||l===`env`||l===`var`){let n=se(e,s+1),r=o(e,n);r!=null&&re(e,n,l===`attr`?E(e,n,r):l===`env`?ie(e,n,r):r,t)}r=s+1}return{indexes:t,literals:n}}function le(e){let t=ce(e),n=0,r=``;for(let i=0;i<e.length;i++){let a=t.literals[n];if(a&&i===a.start){r+=e.slice(a.start,a.end),i=a.end-1,n++;continue}if(e[i]===`\\`&&e[i+1]===`_`){r+=`_`,i++;continue}r+=e[i]===`_`&&!t.indexes.has(i)?` `:e[i]}return r}function k(e,t){let n=1,r;for(let i=t;i<e.length;i++){let t=e[i];if(t===`\\`){i++;continue}if(r)t===r&&(r=void 0);else if(t===`"`||t===`'`)r=t;else if(t===`(`)n++;else if(t===`)`&&--n===0)return i+1}}function A(e){let t=ne(e);if(t!==void 0)return t;if(!e?.startsWith(`[`)||!e.endsWith(`]`))return;let n=e.match(v),r=e.slice(n?.[0].length??1,-1);if(!r||r===`=""`||!te(r))return;let i=n?.[1];if(i===`quoted`)return`"${x(r).replace(/(["\\])/g,`\\$1`)}"`;if(b(r))return i===`string`?x(r):(y(r)&&(r=`var(${r})`),oe(le(r)))}function j(e){return A(e)}function M(e,t){if(!(e==null||!Object.hasOwn(e,t)))return e[t]}function N(e,t,n=0){let r=`${t}(`,i;for(let t=n;t<=e.length-r.length;t++){let n=e[t];if(i!=null){n===`\\`?t=(c(e,t)??t+1)-1:n===i&&(i=void 0);continue}if(n===`'`||n===`"`){i=n;continue}if(n===`\\`){t=(c(e,t)??t+1)-1;continue}if(n===`/`&&e[t+1]===`*`){let n=e.indexOf(`*/`,t+2);if(n===-1)return-1;t=n+1;continue}if(!e.startsWith(r,t))continue;let a=e[t-1];if(t===0||!s(a))return t}return-1}function P(e,t){let n=N(e,t);return n>=0&&e.indexOf(`)`,n+t.length+1)>=0}function F(e,t,n=!1){if(e.length<=t.length+1||e[t.length]!==`(`||e.at(-1)!==`)`)return!1;let r=e.slice(0,t.length);if(n?r.toLowerCase()!==t.toLowerCase():r!==t)return!1;let i=1,a;for(let n=t.length+1;n<e.length;n++){let t=e[n];if(t===`\\`){n++;continue}if(a!=null){t===a&&(a=void 0);continue}if(t===`'`||t===`"`){a=t;continue}if(t===`(`)i++;else if(t===`)`&&--i===0)return n===e.length-1}return!1}const I=new Set(n),L=String.raw`[+-]?(?:\d+|\d*\.\d+)(?:[eE][+-]?\d+)?`,R=RegExp(`^${L}$`),z=RegExp(`^${L}%$`),B=RegExp(`^(${L})(s|ms)?$`,`i`),V=RegExp(`^(${L})(deg|rad|grad|turn)?$`,`i`),H=`color.border-color.background-color.outline-color.text-decoration-color.flex-grow.flex.flex-shrink.caret-color.font.gap.opacity.visibility.z-index.font-weight.zoom.text-shadow.transform.box-shadow.border.background-position.left.right.top.bottom.object-position.max-height.min-height.max-width.min-width.height.width.border-width.margin.padding.outline-width.outline-offset.font-size.line-height.text-indent.vertical-align.border-spacing.letter-spacing.word-spacing.stroke.filter.backdrop-filter.fill.mask.mask-size.mask-border.clip-path.clip.border-radius`.split(`.`);function U(e){return+e.toFixed(10)}function W(e){let t=e.match(d);if(!t)return;let[,n,r]=t,i=Number.parseFloat(n);if(r&&Number.isFinite(i))return`${U(i)}${r}`}function ue(e){if(e===`auto`)return`auto`}function de(e){if(e===`empty`)return`""`}function fe(e){if(e===`square`)return`1/1`}function pe(e){if(e===`video`)return`16/9`}function me(e){if(!e)return;if(_.test(e))return`${g[e.toLowerCase()]}${e}`;let t=e.match(d);if(!t)return;let[,n,r]=t,i=Number.parseFloat(n);if(Number.isFinite(i))return i===0?`0`:r?`${U(i)}${r}`:`${U(i/4)}rem`}function he(e){if(_.test(e))return`${g[e.toLowerCase()]}${e}`;let t=e?.match(d);if(!t)return;let[,n,r]=t,i=Number.parseFloat(n);if(Number.isFinite(i))return r?`${U(i)}${r}`:`${U(i)}px`}function G(e){if(!f.test(e))return;let t=Number.parseFloat(e);if(Number.isFinite(t))return U(t)}function ge(e){if(/^-?\d+$/.test(e))return e}function _e(e){if(/^[1-9]\d*$/.test(e))return e}function ve(e){if(!r(e))return;let t=a(e).toLowerCase();if(!(t==="default"||I.has(t)))return e}function ye(e){if(e.length>5&&F(e,`url`,!0))return e}function K(e){if(z.test(e))return e;if(f.test(e)){let t=Number.parseFloat(e);if(Number.isFinite(t))return`${U(t)}%`}}function be(e){return/^\d*\.\d+$/.test(e)?e:K(e)}function xe(e){if(!e)return;let t=e.indexOf(`/`);if(t<=0||t!==e.lastIndexOf(`/`)||t===e.length-1)return;let n=e.slice(0,t),r=e.slice(t+1);if(!R.test(n)||!R.test(r))return;let i=Number(r);if(i===0)return;let a=Number(n)/i;if(Number.isFinite(a))return a===0?`0`:`${U(a*100)}%`}function Se(e){let t=G(e);if(t!=null)return Number(t)===0?`0`:`calc(var(--spacing) * ${t})`}function q(e){return j(e)}function J(e){if(!/^\$[^\s'"`;{}]/.test(e))return;let t=e.slice(1),n=t.indexOf(`|`),r=n===-1?t:t.slice(0,n),i=n===-1?void 0:t.slice(n+1);if(!r||/[,@\s'"`;{}]/.test(r)||n!==-1&&!i)return;let a=i;if(i?.startsWith(`$`)){if(a=J(i),a==null)return}else if(i!=null&&!b(i))return;return`var(--${l(r)}${a?`, ${a}`:``})`}function Ce(e){let t=e.match(B);if(!t)return;let[,n,r]=t,i=Number(n);if(Number.isFinite(i))return i===0&&!r?`0s`:r?`${U(i)}${r}`:`${U(i)}ms`}function we(e){let t=e.match(V);if(!t)return;let[,n,r]=t,i=Number(n);if(Number.isFinite(i))return i===0&&!r?`0`:r?`${U(i)}${r}`:`${U(i)}deg`}function Y(e){if(I.has(e))return e}function Te(e){if(e.split(`,`).every(e=>H.includes(e)))return e}function Ee(e){if([`top`,`left`,`right`,`bottom`,`center`].includes(e))return e}function De(e){if([`top`,`bottom`,`left`,`right`,`center`,`top-left`,`top-right`,`bottom-left`,`bottom-right`].includes(e))return e}function Oe(e){if(e===`none`)return`none`}function ke(e){if(e===`none`||e===`zero`)return`0`}function X(e){if(Object.hasOwn(e,`__options`))throw Error(`"__options" is a reserved createValueHandler name`);let t=Object.keys(e),n=Object.create(Function.prototype),r=new WeakMap;function i(t){let i=Object.freeze([...t]),a=((t,n)=>{for(let r of i){let i=e[r](t,n);if(i!=null)return i}});return Object.defineProperty(a,"__options",{enumerable:!0,value:Object.freeze({sequence:Object.freeze([...i])})}),r.set(a,i),Object.setPrototypeOf(a,n),a}function a(e){for(let n of t)Object.defineProperty(e,n,{enumerable:!0,configurable:!0,get(){let e=i([...r.get(this)??[],n]);return Object.defineProperty(this,n,{enumerable:!0,configurable:!0,value:e}),e}})}a(n);let o=i([]);return a(o),o}const Z=Object.freeze({alpha:be,auto:ue,bracket:q,cssvar:J,customIdent:ve,degree:we,empty:de,fraction:xe,global:Y,integer:ge,none:Oe,number:G,numberWithUnit:W,percent:K,placement:De,position:Ee,positiveInteger:_e,properties:Te,px:he,rem:me,spacing:Se,square:fe,time:Ce,url:ye,video:pe,zero:ke}),Q=X(Z),$=Q;export{f as _,q as a,g as b,U as c,M as d,j as f,h as g,v as h,X as i,N as l,p as m,Q as n,J as o,y as p,Z as r,Y as s,$ as t,P as u,d as v,_ as x,m as y};