resolve-config-QUZ9b-Gn.d.mts 3.5 KB

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