keywords.js 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. 'use strict';
  2. const uniteSets = require('../utils/uniteSets.js');
  3. const basicKeywords = new Set(['initial', 'inherit', 'revert', 'revert-layer', 'unset']);
  4. const systemFontKeywords = uniteSets(basicKeywords, [
  5. 'caption',
  6. 'icon',
  7. 'menu',
  8. 'message-box',
  9. 'small-caption',
  10. 'status-bar',
  11. ]);
  12. const fontFamilyKeywords = uniteSets(basicKeywords, [
  13. 'serif',
  14. 'sans-serif',
  15. 'cursive',
  16. 'fantasy',
  17. 'monospace',
  18. 'system-ui',
  19. 'ui-serif',
  20. 'ui-sans-serif',
  21. 'ui-monospace',
  22. 'ui-rounded',
  23. ]);
  24. const fontWeightRelativeKeywords = new Set(['bolder', 'lighter']);
  25. const fontWeightAbsoluteKeywords = new Set(['normal', 'bold']);
  26. const fontWeightNonNumericKeywords = uniteSets(
  27. fontWeightRelativeKeywords,
  28. fontWeightAbsoluteKeywords,
  29. );
  30. const fontWeightNumericKeywords = new Set([
  31. '100',
  32. '200',
  33. '300',
  34. '400',
  35. '500',
  36. '600',
  37. '700',
  38. '800',
  39. '900',
  40. ]);
  41. const fontWeightKeywords = uniteSets(
  42. basicKeywords,
  43. fontWeightNonNumericKeywords,
  44. fontWeightNumericKeywords,
  45. );
  46. const fontStyleKeywords = uniteSets(basicKeywords, ['normal', 'italic', 'oblique']);
  47. const fontVariantKeywords = uniteSets(basicKeywords, [
  48. 'normal',
  49. 'none',
  50. 'historical-forms',
  51. 'none',
  52. 'common-ligatures',
  53. 'no-common-ligatures',
  54. 'discretionary-ligatures',
  55. 'no-discretionary-ligatures',
  56. 'historical-ligatures',
  57. 'no-historical-ligatures',
  58. 'contextual',
  59. 'no-contextual',
  60. 'small-caps',
  61. 'small-caps',
  62. 'all-small-caps',
  63. 'petite-caps',
  64. 'all-petite-caps',
  65. 'unicase',
  66. 'titling-caps',
  67. 'lining-nums',
  68. 'oldstyle-nums',
  69. 'proportional-nums',
  70. 'tabular-nums',
  71. 'diagonal-fractions',
  72. 'stacked-fractions',
  73. 'ordinal',
  74. 'slashed-zero',
  75. 'jis78',
  76. 'jis83',
  77. 'jis90',
  78. 'jis04',
  79. 'simplified',
  80. 'traditional',
  81. 'full-width',
  82. 'proportional-width',
  83. 'ruby',
  84. ]);
  85. const fontStretchKeywords = uniteSets(basicKeywords, [
  86. 'semi-condensed',
  87. 'condensed',
  88. 'extra-condensed',
  89. 'ultra-condensed',
  90. 'semi-expanded',
  91. 'expanded',
  92. 'extra-expanded',
  93. 'ultra-expanded',
  94. ]);
  95. const fontSizeKeywords = uniteSets(basicKeywords, [
  96. 'xx-small',
  97. 'x-small',
  98. 'small',
  99. 'medium',
  100. 'large',
  101. 'x-large',
  102. 'xx-large',
  103. 'larger',
  104. 'smaller',
  105. ]);
  106. const lineHeightKeywords = uniteSets(basicKeywords, ['normal']);
  107. const fontShorthandKeywords = uniteSets(
  108. basicKeywords,
  109. fontStyleKeywords,
  110. fontVariantKeywords,
  111. fontWeightKeywords,
  112. fontStretchKeywords,
  113. fontSizeKeywords,
  114. lineHeightKeywords,
  115. fontFamilyKeywords,
  116. );
  117. const animationNameKeywords = uniteSets(basicKeywords, ['none']);
  118. const animationTimingFunctionKeywords = uniteSets(basicKeywords, [
  119. 'linear',
  120. 'ease',
  121. 'ease-in',
  122. 'ease-in-out',
  123. 'ease-out',
  124. 'step-start',
  125. 'step-end',
  126. 'steps',
  127. 'cubic-bezier',
  128. ]);
  129. const animationIterationCountKeywords = new Set(['infinite']);
  130. const animationDirectionKeywords = uniteSets(basicKeywords, [
  131. 'normal',
  132. 'reverse',
  133. 'alternate',
  134. 'alternate-reverse',
  135. ]);
  136. const animationFillModeKeywords = new Set(['none', 'forwards', 'backwards', 'both']);
  137. const animationPlayStateKeywords = uniteSets(basicKeywords, ['running', 'paused']);
  138. // cf. https://developer.mozilla.org/en-US/docs/Web/CSS/animation
  139. const animationShorthandKeywords = uniteSets(
  140. basicKeywords,
  141. animationNameKeywords,
  142. animationTimingFunctionKeywords,
  143. animationIterationCountKeywords,
  144. animationDirectionKeywords,
  145. animationFillModeKeywords,
  146. animationPlayStateKeywords,
  147. );
  148. const gridRowKeywords = uniteSets(basicKeywords, ['auto', 'span']);
  149. const gridColumnKeywords = uniteSets(basicKeywords, ['auto', 'span']);
  150. const gridAreaKeywords = uniteSets(basicKeywords, ['auto', 'span']);
  151. // https://developer.mozilla.org/docs/Web/CSS/counter-increment
  152. const counterIncrementKeywords = uniteSets(basicKeywords, ['none']);
  153. const counterResetKeywords = uniteSets(basicKeywords, ['none']);
  154. // https://developer.mozilla.org/ru/docs/Web/CSS/list-style-type
  155. const listStyleTypeKeywords = uniteSets(basicKeywords, [
  156. 'none',
  157. 'disc',
  158. 'circle',
  159. 'square',
  160. 'decimal',
  161. 'cjk-decimal',
  162. 'decimal-leading-zero',
  163. 'lower-roman',
  164. 'upper-roman',
  165. 'lower-greek',
  166. 'lower-alpha',
  167. 'lower-latin',
  168. 'upper-alpha',
  169. 'upper-latin',
  170. 'arabic-indic',
  171. 'armenian',
  172. 'bengali',
  173. 'cambodian',
  174. 'cjk-earthly-branch',
  175. 'cjk-ideographic',
  176. 'devanagari',
  177. 'ethiopic-numeric',
  178. 'georgian',
  179. 'gujarati',
  180. 'gurmukhi',
  181. 'hebrew',
  182. 'hiragana',
  183. 'hiragana-iroha',
  184. 'japanese-formal',
  185. 'japanese-informal',
  186. 'kannada',
  187. 'katakana',
  188. 'katakana-iroha',
  189. 'khmer',
  190. 'korean-hangul-formal',
  191. 'korean-hanja-formal',
  192. 'korean-hanja-informal',
  193. 'lao',
  194. 'lower-armenian',
  195. 'malayalam',
  196. 'mongolian',
  197. 'myanmar',
  198. 'oriya',
  199. 'persian',
  200. 'simp-chinese-formal',
  201. 'simp-chinese-informal',
  202. 'tamil',
  203. 'telugu',
  204. 'thai',
  205. 'tibetan',
  206. 'trad-chinese-formal',
  207. 'trad-chinese-informal',
  208. 'upper-armenian',
  209. 'disclosure-open',
  210. 'disclosure-closed',
  211. // Non-standard extensions (without prefixe)
  212. 'ethiopic-halehame',
  213. 'ethiopic-halehame-am',
  214. 'ethiopic-halehame-ti-er',
  215. 'ethiopic-halehame-ti-et',
  216. 'hangul',
  217. 'hangul-consonant',
  218. 'urdu',
  219. ]);
  220. const listStylePositionKeywords = uniteSets(basicKeywords, ['inside', 'outside']);
  221. const listStyleImageKeywords = uniteSets(basicKeywords, ['none']);
  222. const listStyleShorthandKeywords = uniteSets(
  223. basicKeywords,
  224. listStyleTypeKeywords,
  225. listStylePositionKeywords,
  226. listStyleImageKeywords,
  227. );
  228. const camelCaseKeywords = new Set([
  229. 'optimizeSpeed',
  230. 'optimizeQuality',
  231. 'optimizeLegibility',
  232. 'geometricPrecision',
  233. 'currentColor',
  234. 'crispEdges',
  235. 'visiblePainted',
  236. 'visibleFill',
  237. 'visibleStroke',
  238. 'sRGB',
  239. 'linearRGB',
  240. ]);
  241. const keyframeSelectorKeywords = new Set(['from', 'to']);
  242. // https://www.w3.org/TR/CSS22/ui.html#system-colors
  243. const systemColorsKeywords = new Set([
  244. 'activeborder',
  245. 'activecaption',
  246. 'appworkspace',
  247. 'background',
  248. 'buttonface',
  249. 'buttonhighlight',
  250. 'buttonshadow',
  251. 'buttontext',
  252. 'captiontext',
  253. 'graytext',
  254. 'highlight',
  255. 'highlighttext',
  256. 'inactiveborder',
  257. 'inactivecaption',
  258. 'inactivecaptiontext',
  259. 'infobackground',
  260. 'infotext',
  261. 'menu',
  262. 'menutext',
  263. 'scrollbar',
  264. 'threeddarkshadow',
  265. 'threedface',
  266. 'threedhighlight',
  267. 'threedlightshadow',
  268. 'threedshadow',
  269. 'window',
  270. 'windowframe',
  271. 'windowtext',
  272. ]);
  273. module.exports = {
  274. animationNameKeywords,
  275. animationShorthandKeywords,
  276. basicKeywords,
  277. camelCaseKeywords,
  278. counterIncrementKeywords,
  279. counterResetKeywords,
  280. fontFamilyKeywords,
  281. fontShorthandKeywords,
  282. fontSizeKeywords,
  283. fontWeightAbsoluteKeywords,
  284. fontWeightKeywords,
  285. fontWeightNonNumericKeywords,
  286. fontWeightRelativeKeywords,
  287. gridAreaKeywords,
  288. gridColumnKeywords,
  289. gridRowKeywords,
  290. keyframeSelectorKeywords,
  291. listStyleImageKeywords,
  292. listStylePositionKeywords,
  293. listStyleShorthandKeywords,
  294. listStyleTypeKeywords,
  295. systemColorsKeywords,
  296. systemFontKeywords,
  297. };