| [2058e5c] | 1 | import _default from './colors.mjs';
|
|---|
| 2 |
|
|---|
| 3 | type ArbitraryUtilityValue = {
|
|---|
| 4 | kind: 'arbitrary';
|
|---|
| 5 | /**
|
|---|
| 6 | * ```
|
|---|
| 7 | * bg-[color:var(--my-color)]
|
|---|
| 8 | * ^^^^^
|
|---|
| 9 | *
|
|---|
| 10 | * bg-(color:--my-color)
|
|---|
| 11 | * ^^^^^
|
|---|
| 12 | * ```
|
|---|
| 13 | */
|
|---|
| 14 | dataType: string | null;
|
|---|
| 15 | /**
|
|---|
| 16 | * ```
|
|---|
| 17 | * bg-[#0088cc]
|
|---|
| 18 | * ^^^^^^^
|
|---|
| 19 | *
|
|---|
| 20 | * bg-[var(--my_variable)]
|
|---|
| 21 | * ^^^^^^^^^^^^^^^^^^
|
|---|
| 22 | *
|
|---|
| 23 | * bg-(--my_variable)
|
|---|
| 24 | * ^^^^^^^^^^^^^^
|
|---|
| 25 | * ```
|
|---|
| 26 | */
|
|---|
| 27 | value: string;
|
|---|
| 28 | };
|
|---|
| 29 | type NamedUtilityValue = {
|
|---|
| 30 | kind: 'named';
|
|---|
| 31 | /**
|
|---|
| 32 | * ```
|
|---|
| 33 | * bg-red-500
|
|---|
| 34 | * ^^^^^^^
|
|---|
| 35 | *
|
|---|
| 36 | * w-1/2
|
|---|
| 37 | * ^
|
|---|
| 38 | * ```
|
|---|
| 39 | */
|
|---|
| 40 | value: string;
|
|---|
| 41 | /**
|
|---|
| 42 | * ```
|
|---|
| 43 | * w-1/2
|
|---|
| 44 | * ^^^
|
|---|
| 45 | * ```
|
|---|
| 46 | */
|
|---|
| 47 | fraction: string | null;
|
|---|
| 48 | };
|
|---|
| 49 | type ArbitraryModifier = {
|
|---|
| 50 | kind: 'arbitrary';
|
|---|
| 51 | /**
|
|---|
| 52 | * ```
|
|---|
| 53 | * bg-red-500/[50%]
|
|---|
| 54 | * ^^^
|
|---|
| 55 | * ```
|
|---|
| 56 | */
|
|---|
| 57 | value: string;
|
|---|
| 58 | };
|
|---|
| 59 | type NamedModifier = {
|
|---|
| 60 | kind: 'named';
|
|---|
| 61 | /**
|
|---|
| 62 | * ```
|
|---|
| 63 | * bg-red-500/50
|
|---|
| 64 | * ^^
|
|---|
| 65 | * ```
|
|---|
| 66 | */
|
|---|
| 67 | value: string;
|
|---|
| 68 | };
|
|---|
| 69 | type ArbitraryVariantValue = {
|
|---|
| 70 | kind: 'arbitrary';
|
|---|
| 71 | value: string;
|
|---|
| 72 | };
|
|---|
| 73 | type NamedVariantValue = {
|
|---|
| 74 | kind: 'named';
|
|---|
| 75 | value: string;
|
|---|
| 76 | };
|
|---|
| 77 | type Variant =
|
|---|
| 78 | /**
|
|---|
| 79 | * Arbitrary variants are variants that take a selector and generate a variant
|
|---|
| 80 | * on the fly.
|
|---|
| 81 | *
|
|---|
| 82 | * E.g.: `[&_p]`
|
|---|
| 83 | */
|
|---|
| 84 | {
|
|---|
| 85 | kind: 'arbitrary';
|
|---|
| 86 | selector: string;
|
|---|
| 87 | relative: boolean;
|
|---|
| 88 | }
|
|---|
| 89 | /**
|
|---|
| 90 | * Static variants are variants that don't take any arguments.
|
|---|
| 91 | *
|
|---|
| 92 | * E.g.: `hover`
|
|---|
| 93 | */
|
|---|
| 94 | | {
|
|---|
| 95 | kind: 'static';
|
|---|
| 96 | root: string;
|
|---|
| 97 | }
|
|---|
| 98 | /**
|
|---|
| 99 | * Functional variants are variants that can take an argument. The argument is
|
|---|
| 100 | * either a named variant value or an arbitrary variant value.
|
|---|
| 101 | *
|
|---|
| 102 | * E.g.:
|
|---|
| 103 | *
|
|---|
| 104 | * - `aria-disabled`
|
|---|
| 105 | * - `aria-[disabled]`
|
|---|
| 106 | * - `@container-size` -> @container, with named value `size`
|
|---|
| 107 | * - `@container-[inline-size]` -> @container, with arbitrary variant value `inline-size`
|
|---|
| 108 | * - `@container` -> @container, with no value
|
|---|
| 109 | */
|
|---|
| 110 | | {
|
|---|
| 111 | kind: 'functional';
|
|---|
| 112 | root: string;
|
|---|
| 113 | value: ArbitraryVariantValue | NamedVariantValue | null;
|
|---|
| 114 | modifier: ArbitraryModifier | NamedModifier | null;
|
|---|
| 115 | }
|
|---|
| 116 | /**
|
|---|
| 117 | * Compound variants are variants that take another variant as an argument.
|
|---|
| 118 | *
|
|---|
| 119 | * E.g.:
|
|---|
| 120 | *
|
|---|
| 121 | * - `has-[&_p]`
|
|---|
| 122 | * - `group-*`
|
|---|
| 123 | * - `peer-*`
|
|---|
| 124 | */
|
|---|
| 125 | | {
|
|---|
| 126 | kind: 'compound';
|
|---|
| 127 | root: string;
|
|---|
| 128 | modifier: ArbitraryModifier | NamedModifier | null;
|
|---|
| 129 | variant: Variant;
|
|---|
| 130 | };
|
|---|
| 131 | type Candidate =
|
|---|
| 132 | /**
|
|---|
| 133 | * Arbitrary candidates are candidates that register utilities on the fly with
|
|---|
| 134 | * a property and a value.
|
|---|
| 135 | *
|
|---|
| 136 | * E.g.:
|
|---|
| 137 | *
|
|---|
| 138 | * - `[color:red]`
|
|---|
| 139 | * - `[color:red]/50`
|
|---|
| 140 | * - `[color:red]/50!`
|
|---|
| 141 | */
|
|---|
| 142 | {
|
|---|
| 143 | kind: 'arbitrary';
|
|---|
| 144 | property: string;
|
|---|
| 145 | value: string;
|
|---|
| 146 | modifier: ArbitraryModifier | NamedModifier | null;
|
|---|
| 147 | variants: Variant[];
|
|---|
| 148 | important: boolean;
|
|---|
| 149 | raw: string;
|
|---|
| 150 | }
|
|---|
| 151 | /**
|
|---|
| 152 | * Static candidates are candidates that don't take any arguments.
|
|---|
| 153 | *
|
|---|
| 154 | * E.g.:
|
|---|
| 155 | *
|
|---|
| 156 | * - `underline`
|
|---|
| 157 | * - `box-border`
|
|---|
| 158 | */
|
|---|
| 159 | | {
|
|---|
| 160 | kind: 'static';
|
|---|
| 161 | root: string;
|
|---|
| 162 | variants: Variant[];
|
|---|
| 163 | important: boolean;
|
|---|
| 164 | raw: string;
|
|---|
| 165 | }
|
|---|
| 166 | /**
|
|---|
| 167 | * Functional candidates are candidates that can take an argument.
|
|---|
| 168 | *
|
|---|
| 169 | * E.g.:
|
|---|
| 170 | *
|
|---|
| 171 | * - `bg-red-500`
|
|---|
| 172 | * - `bg-[#0088cc]`
|
|---|
| 173 | * - `w-1/2`
|
|---|
| 174 | */
|
|---|
| 175 | | {
|
|---|
| 176 | kind: 'functional';
|
|---|
| 177 | root: string;
|
|---|
| 178 | value: ArbitraryUtilityValue | NamedUtilityValue | null;
|
|---|
| 179 | modifier: ArbitraryModifier | NamedModifier | null;
|
|---|
| 180 | variants: Variant[];
|
|---|
| 181 | important: boolean;
|
|---|
| 182 | raw: string;
|
|---|
| 183 | };
|
|---|
| 184 |
|
|---|
| 185 | type PluginUtils = {
|
|---|
| 186 | theme: (keypath: string, defaultValue?: any) => any;
|
|---|
| 187 | colors: typeof _default;
|
|---|
| 188 | };
|
|---|
| 189 |
|
|---|
| 190 | export type { Candidate as C, NamedUtilityValue as N, PluginUtils as P, Variant as V };
|
|---|