css-calipers 0.13.0 → 0.15.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.
Files changed (293) hide show
  1. package/README.md +21 -25
  2. package/dist/cjs/factory.js +0 -3
  3. package/dist/cjs/internal/createCoreApi.js +30 -9
  4. package/dist/esm/core.d.ts +21 -17
  5. package/dist/esm/core.d.ts.map +1 -1
  6. package/dist/esm/factory.d.ts +0 -2
  7. package/dist/esm/factory.d.ts.map +1 -1
  8. package/dist/esm/factory.js +0 -3
  9. package/dist/esm/internal/createCoreApi.d.ts +7 -11
  10. package/dist/esm/internal/createCoreApi.d.ts.map +1 -1
  11. package/dist/esm/internal/createCoreApi.js +30 -9
  12. package/package.json +11 -24
  13. package/RELEASING.md +0 -62
  14. package/dist/cjs/comparisons/index.js +0 -25
  15. package/dist/cjs/containerQueries/containerQueries.js +0 -115
  16. package/dist/cjs/containerQueries/factory.js +0 -123
  17. package/dist/cjs/containerQueries/helpers.js +0 -95
  18. package/dist/cjs/containerQueries/index.js +0 -16
  19. package/dist/cjs/containerQueries/linting/aspectRatio.js +0 -24
  20. package/dist/cjs/containerQueries/linting/block.js +0 -23
  21. package/dist/cjs/containerQueries/linting/core.js +0 -25
  22. package/dist/cjs/containerQueries/linting/custom.js +0 -11
  23. package/dist/cjs/containerQueries/linting/inline.js +0 -23
  24. package/dist/cjs/containerQueries/linting/resolution.js +0 -12
  25. package/dist/cjs/containerQueries/linting/style.js +0 -28
  26. package/dist/cjs/containerQueries/linting.js +0 -24
  27. package/dist/cjs/containerQueries/moduleRegistry.js +0 -5
  28. package/dist/cjs/containerQueries/modules/aspectRatio.js +0 -51
  29. package/dist/cjs/containerQueries/modules/block.js +0 -53
  30. package/dist/cjs/containerQueries/modules/custom.js +0 -43
  31. package/dist/cjs/containerQueries/modules/index.js +0 -21
  32. package/dist/cjs/containerQueries/modules/inline.js +0 -53
  33. package/dist/cjs/containerQueries/modules/size.js +0 -2
  34. package/dist/cjs/containerQueries/modules/style.js +0 -36
  35. package/dist/cjs/containerQueries/types.js +0 -2
  36. package/dist/cjs/containerQueries/validation.js +0 -191
  37. package/dist/cjs/fraction.js +0 -139
  38. package/dist/cjs/internal/createComponentQueriesApi.js +0 -56
  39. package/dist/cjs/internal/createMediaQueriesApi.js +0 -74
  40. package/dist/cjs/internal/normalizeToArray.js +0 -9
  41. package/dist/cjs/libraryHelpers/vanilla-extract.js +0 -11
  42. package/dist/cjs/logicalOperators/index.js +0 -18
  43. package/dist/cjs/mediaQueries/factory.js +0 -187
  44. package/dist/cjs/mediaQueries/helpers.js +0 -97
  45. package/dist/cjs/mediaQueries/index.js +0 -23
  46. package/dist/cjs/mediaQueries/libraryHelpers/vanilla-extract.js +0 -77
  47. package/dist/cjs/mediaQueries/linting/core.js +0 -19
  48. package/dist/cjs/mediaQueries/linting/resolution.js +0 -11
  49. package/dist/cjs/mediaQueries/linting.js +0 -24
  50. package/dist/cjs/mediaQueries/mediaQueries.js +0 -53
  51. package/dist/cjs/mediaQueries/mediaQueryFactory.js +0 -120
  52. package/dist/cjs/mediaQueries/moduleRegistry.js +0 -5
  53. package/dist/cjs/mediaQueries/modules/custom.js +0 -26
  54. package/dist/cjs/mediaQueries/modules/dimensions.js +0 -61
  55. package/dist/cjs/mediaQueries/modules/display.js +0 -20
  56. package/dist/cjs/mediaQueries/modules/environment.js +0 -20
  57. package/dist/cjs/mediaQueries/modules/index.js +0 -23
  58. package/dist/cjs/mediaQueries/modules/interaction.js +0 -26
  59. package/dist/cjs/mediaQueries/modules/preferences.js +0 -26
  60. package/dist/cjs/mediaQueries/modules/resolution.js +0 -31
  61. package/dist/cjs/mediaQueries/types.js +0 -2
  62. package/dist/cjs/mediaQueries/validation.js +0 -131
  63. package/dist/cjs/types.js +0 -2
  64. package/dist/cjs/validation.js +0 -20
  65. package/dist/esm/comparisons/index.d.ts +0 -23
  66. package/dist/esm/comparisons/index.d.ts.map +0 -1
  67. package/dist/esm/comparisons/index.js +0 -22
  68. package/dist/esm/containerQueries/containerQueries.d.ts +0 -36
  69. package/dist/esm/containerQueries/containerQueries.d.ts.map +0 -1
  70. package/dist/esm/containerQueries/containerQueries.js +0 -109
  71. package/dist/esm/containerQueries/factory.d.ts +0 -20
  72. package/dist/esm/containerQueries/factory.d.ts.map +0 -1
  73. package/dist/esm/containerQueries/factory.js +0 -119
  74. package/dist/esm/containerQueries/helpers.d.ts +0 -53
  75. package/dist/esm/containerQueries/helpers.d.ts.map +0 -1
  76. package/dist/esm/containerQueries/helpers.js +0 -82
  77. package/dist/esm/containerQueries/index.d.ts +0 -10
  78. package/dist/esm/containerQueries/index.d.ts.map +0 -1
  79. package/dist/esm/containerQueries/index.js +0 -4
  80. package/dist/esm/containerQueries/linting/aspectRatio.d.ts +0 -4
  81. package/dist/esm/containerQueries/linting/aspectRatio.d.ts.map +0 -1
  82. package/dist/esm/containerQueries/linting/aspectRatio.js +0 -19
  83. package/dist/esm/containerQueries/linting/block.d.ts +0 -4
  84. package/dist/esm/containerQueries/linting/block.d.ts.map +0 -1
  85. package/dist/esm/containerQueries/linting/block.js +0 -18
  86. package/dist/esm/containerQueries/linting/core.d.ts +0 -4
  87. package/dist/esm/containerQueries/linting/core.d.ts.map +0 -1
  88. package/dist/esm/containerQueries/linting/core.js +0 -20
  89. package/dist/esm/containerQueries/linting/custom.d.ts +0 -3
  90. package/dist/esm/containerQueries/linting/custom.d.ts.map +0 -1
  91. package/dist/esm/containerQueries/linting/custom.js +0 -7
  92. package/dist/esm/containerQueries/linting/inline.d.ts +0 -4
  93. package/dist/esm/containerQueries/linting/inline.d.ts.map +0 -1
  94. package/dist/esm/containerQueries/linting/inline.js +0 -18
  95. package/dist/esm/containerQueries/linting/resolution.d.ts +0 -1
  96. package/dist/esm/containerQueries/linting/resolution.d.ts.map +0 -1
  97. package/dist/esm/containerQueries/linting/resolution.js +0 -12
  98. package/dist/esm/containerQueries/linting/style.d.ts +0 -3
  99. package/dist/esm/containerQueries/linting/style.d.ts.map +0 -1
  100. package/dist/esm/containerQueries/linting/style.js +0 -24
  101. package/dist/esm/containerQueries/linting.d.ts +0 -4
  102. package/dist/esm/containerQueries/linting.d.ts.map +0 -1
  103. package/dist/esm/containerQueries/linting.js +0 -20
  104. package/dist/esm/containerQueries/moduleRegistry.d.ts +0 -25
  105. package/dist/esm/containerQueries/moduleRegistry.d.ts.map +0 -1
  106. package/dist/esm/containerQueries/moduleRegistry.js +0 -1
  107. package/dist/esm/containerQueries/modules/aspectRatio.d.ts +0 -17
  108. package/dist/esm/containerQueries/modules/aspectRatio.d.ts.map +0 -1
  109. package/dist/esm/containerQueries/modules/aspectRatio.js +0 -47
  110. package/dist/esm/containerQueries/modules/block.d.ts +0 -20
  111. package/dist/esm/containerQueries/modules/block.d.ts.map +0 -1
  112. package/dist/esm/containerQueries/modules/block.js +0 -49
  113. package/dist/esm/containerQueries/modules/custom.d.ts +0 -13
  114. package/dist/esm/containerQueries/modules/custom.d.ts.map +0 -1
  115. package/dist/esm/containerQueries/modules/custom.js +0 -39
  116. package/dist/esm/containerQueries/modules/index.d.ts +0 -6
  117. package/dist/esm/containerQueries/modules/index.d.ts.map +0 -1
  118. package/dist/esm/containerQueries/modules/index.js +0 -5
  119. package/dist/esm/containerQueries/modules/inline.d.ts +0 -20
  120. package/dist/esm/containerQueries/modules/inline.d.ts.map +0 -1
  121. package/dist/esm/containerQueries/modules/inline.js +0 -49
  122. package/dist/esm/containerQueries/modules/size.d.ts +0 -41
  123. package/dist/esm/containerQueries/modules/size.d.ts.map +0 -1
  124. package/dist/esm/containerQueries/modules/size.js +0 -1
  125. package/dist/esm/containerQueries/modules/style.d.ts +0 -11
  126. package/dist/esm/containerQueries/modules/style.d.ts.map +0 -1
  127. package/dist/esm/containerQueries/modules/style.js +0 -32
  128. package/dist/esm/containerQueries/types.d.ts +0 -81
  129. package/dist/esm/containerQueries/types.d.ts.map +0 -1
  130. package/dist/esm/containerQueries/types.js +0 -1
  131. package/dist/esm/containerQueries/validation.d.ts +0 -41
  132. package/dist/esm/containerQueries/validation.d.ts.map +0 -1
  133. package/dist/esm/containerQueries/validation.js +0 -187
  134. package/dist/esm/fraction.d.ts +0 -23
  135. package/dist/esm/fraction.d.ts.map +0 -1
  136. package/dist/esm/fraction.js +0 -129
  137. package/dist/esm/internal/createComponentQueriesApi.d.ts +0 -34
  138. package/dist/esm/internal/createComponentQueriesApi.d.ts.map +0 -1
  139. package/dist/esm/internal/createComponentQueriesApi.js +0 -52
  140. package/dist/esm/internal/createMediaQueriesApi.d.ts +0 -35
  141. package/dist/esm/internal/createMediaQueriesApi.d.ts.map +0 -1
  142. package/dist/esm/internal/createMediaQueriesApi.js +0 -70
  143. package/dist/esm/internal/normalizeToArray.d.ts +0 -2
  144. package/dist/esm/internal/normalizeToArray.d.ts.map +0 -1
  145. package/dist/esm/internal/normalizeToArray.js +0 -5
  146. package/dist/esm/libraryHelpers/vanilla-extract.d.ts +0 -4
  147. package/dist/esm/libraryHelpers/vanilla-extract.d.ts.map +0 -1
  148. package/dist/esm/libraryHelpers/vanilla-extract.js +0 -6
  149. package/dist/esm/logicalOperators/index.d.ts +0 -2
  150. package/dist/esm/logicalOperators/index.d.ts.map +0 -1
  151. package/dist/esm/logicalOperators/index.js +0 -17
  152. package/dist/esm/mediaQueries/factory.d.ts +0 -45
  153. package/dist/esm/mediaQueries/factory.d.ts.map +0 -1
  154. package/dist/esm/mediaQueries/factory.js +0 -183
  155. package/dist/esm/mediaQueries/helpers.d.ts +0 -40
  156. package/dist/esm/mediaQueries/helpers.d.ts.map +0 -1
  157. package/dist/esm/mediaQueries/helpers.js +0 -87
  158. package/dist/esm/mediaQueries/index.d.ts +0 -8
  159. package/dist/esm/mediaQueries/index.d.ts.map +0 -1
  160. package/dist/esm/mediaQueries/index.js +0 -7
  161. package/dist/esm/mediaQueries/libraryHelpers/vanilla-extract.d.ts +0 -5
  162. package/dist/esm/mediaQueries/libraryHelpers/vanilla-extract.d.ts.map +0 -1
  163. package/dist/esm/mediaQueries/libraryHelpers/vanilla-extract.js +0 -71
  164. package/dist/esm/mediaQueries/linting/core.d.ts +0 -5
  165. package/dist/esm/mediaQueries/linting/core.d.ts.map +0 -1
  166. package/dist/esm/mediaQueries/linting/core.js +0 -14
  167. package/dist/esm/mediaQueries/linting/resolution.d.ts +0 -3
  168. package/dist/esm/mediaQueries/linting/resolution.d.ts.map +0 -1
  169. package/dist/esm/mediaQueries/linting/resolution.js +0 -7
  170. package/dist/esm/mediaQueries/linting.d.ts +0 -4
  171. package/dist/esm/mediaQueries/linting.d.ts.map +0 -1
  172. package/dist/esm/mediaQueries/linting.js +0 -20
  173. package/dist/esm/mediaQueries/mediaQueries.d.ts +0 -23
  174. package/dist/esm/mediaQueries/mediaQueries.d.ts.map +0 -1
  175. package/dist/esm/mediaQueries/mediaQueries.js +0 -48
  176. package/dist/esm/mediaQueries/moduleRegistry.d.ts +0 -27
  177. package/dist/esm/mediaQueries/moduleRegistry.d.ts.map +0 -1
  178. package/dist/esm/mediaQueries/moduleRegistry.js +0 -1
  179. package/dist/esm/mediaQueries/modules/custom.d.ts +0 -10
  180. package/dist/esm/mediaQueries/modules/custom.d.ts.map +0 -1
  181. package/dist/esm/mediaQueries/modules/custom.js +0 -22
  182. package/dist/esm/mediaQueries/modules/dimensions.d.ts +0 -19
  183. package/dist/esm/mediaQueries/modules/dimensions.d.ts.map +0 -1
  184. package/dist/esm/mediaQueries/modules/dimensions.js +0 -57
  185. package/dist/esm/mediaQueries/modules/display.d.ts +0 -9
  186. package/dist/esm/mediaQueries/modules/display.d.ts.map +0 -1
  187. package/dist/esm/mediaQueries/modules/display.js +0 -16
  188. package/dist/esm/mediaQueries/modules/environment.d.ts +0 -9
  189. package/dist/esm/mediaQueries/modules/environment.d.ts.map +0 -1
  190. package/dist/esm/mediaQueries/modules/environment.js +0 -16
  191. package/dist/esm/mediaQueries/modules/index.d.ts +0 -8
  192. package/dist/esm/mediaQueries/modules/index.d.ts.map +0 -1
  193. package/dist/esm/mediaQueries/modules/index.js +0 -7
  194. package/dist/esm/mediaQueries/modules/interaction.d.ts +0 -11
  195. package/dist/esm/mediaQueries/modules/interaction.d.ts.map +0 -1
  196. package/dist/esm/mediaQueries/modules/interaction.js +0 -22
  197. package/dist/esm/mediaQueries/modules/preferences.d.ts +0 -11
  198. package/dist/esm/mediaQueries/modules/preferences.d.ts.map +0 -1
  199. package/dist/esm/mediaQueries/modules/preferences.js +0 -22
  200. package/dist/esm/mediaQueries/modules/resolution.d.ts +0 -12
  201. package/dist/esm/mediaQueries/modules/resolution.d.ts.map +0 -1
  202. package/dist/esm/mediaQueries/modules/resolution.js +0 -27
  203. package/dist/esm/mediaQueries/types.d.ts +0 -117
  204. package/dist/esm/mediaQueries/types.d.ts.map +0 -1
  205. package/dist/esm/mediaQueries/types.js +0 -1
  206. package/dist/esm/mediaQueries/validation.d.ts +0 -34
  207. package/dist/esm/mediaQueries/validation.d.ts.map +0 -1
  208. package/dist/esm/mediaQueries/validation.js +0 -127
  209. package/dist/esm/types.d.ts +0 -35
  210. package/dist/esm/types.d.ts.map +0 -1
  211. package/dist/esm/types.js +0 -1
  212. package/dist/esm/validation.d.ts +0 -10
  213. package/dist/esm/validation.d.ts.map +0 -1
  214. package/dist/esm/validation.js +0 -15
  215. package/dist/examples/containerQueries.example.js +0 -54
  216. package/dist/examples/examples/containerQueries.example.js +0 -54
  217. package/dist/examples/examples/factory-wrapper.example.js +0 -33
  218. package/dist/examples/examples/lineHeight-normalizer.example.js +0 -81
  219. package/dist/examples/examples/mediaQueries-multipleInstances.example.js +0 -127
  220. package/dist/examples/examples/mixedQueries.example.js +0 -55
  221. package/dist/examples/examples/validation-and-runtime-checks.example.js +0 -85
  222. package/dist/examples/examples/validation-unit-tests.example.js +0 -35
  223. package/dist/examples/factory-wrapper.example.js +0 -33
  224. package/dist/examples/lineHeight-normalizer.example.js +0 -81
  225. package/dist/examples/mediaQueries-multipleInstances.example.js +0 -127
  226. package/dist/examples/mixedQueries.example.js +0 -60
  227. package/dist/examples/src/comparisons/index.js +0 -25
  228. package/dist/examples/src/containerQueries/containerQueries.js +0 -96
  229. package/dist/examples/src/containerQueries/factory.js +0 -123
  230. package/dist/examples/src/containerQueries/helpers.js +0 -94
  231. package/dist/examples/src/containerQueries/index.js +0 -16
  232. package/dist/examples/src/containerQueries/linting/aspectRatio.js +0 -20
  233. package/dist/examples/src/containerQueries/linting/block.js +0 -20
  234. package/dist/examples/src/containerQueries/linting/core.js +0 -19
  235. package/dist/examples/src/containerQueries/linting/custom.js +0 -11
  236. package/dist/examples/src/containerQueries/linting/inline.js +0 -20
  237. package/dist/examples/src/containerQueries/linting/style.js +0 -28
  238. package/dist/examples/src/containerQueries/linting.js +0 -24
  239. package/dist/examples/src/containerQueries/moduleRegistry.js +0 -5
  240. package/dist/examples/src/containerQueries/modules/aspectRatio.js +0 -33
  241. package/dist/examples/src/containerQueries/modules/block.js +0 -44
  242. package/dist/examples/src/containerQueries/modules/custom.js +0 -31
  243. package/dist/examples/src/containerQueries/modules/index.js +0 -21
  244. package/dist/examples/src/containerQueries/modules/inline.js +0 -44
  245. package/dist/examples/src/containerQueries/modules/style.js +0 -36
  246. package/dist/examples/src/containerQueries/types.js +0 -2
  247. package/dist/examples/src/containerQueries/validation.js +0 -177
  248. package/dist/examples/src/core.js +0 -16
  249. package/dist/examples/src/factory.js +0 -21
  250. package/dist/examples/src/index.js +0 -30
  251. package/dist/examples/src/internal/buildMeasurementCreationError.js +0 -16
  252. package/dist/examples/src/internal/createCoreApi.js +0 -336
  253. package/dist/examples/src/internal/createMediaQueriesApi.js +0 -74
  254. package/dist/examples/src/internal/createUnitsApi.js +0 -18
  255. package/dist/examples/src/internal/errors.js +0 -130
  256. package/dist/examples/src/libraryHelpers/vanilla-extract.js +0 -11
  257. package/dist/examples/src/mediaQueries/factory.js +0 -163
  258. package/dist/examples/src/mediaQueries/helpers.js +0 -88
  259. package/dist/examples/src/mediaQueries/index.js +0 -23
  260. package/dist/examples/src/mediaQueries/linting/core.js +0 -19
  261. package/dist/examples/src/mediaQueries/linting/resolution.js +0 -11
  262. package/dist/examples/src/mediaQueries/linting.js +0 -24
  263. package/dist/examples/src/mediaQueries/mediaQueries.js +0 -53
  264. package/dist/examples/src/mediaQueries/moduleRegistry.js +0 -5
  265. package/dist/examples/src/mediaQueries/modules/custom.js +0 -26
  266. package/dist/examples/src/mediaQueries/modules/dimensions.js +0 -61
  267. package/dist/examples/src/mediaQueries/modules/display.js +0 -20
  268. package/dist/examples/src/mediaQueries/modules/environment.js +0 -20
  269. package/dist/examples/src/mediaQueries/modules/index.js +0 -23
  270. package/dist/examples/src/mediaQueries/modules/interaction.js +0 -26
  271. package/dist/examples/src/mediaQueries/modules/preferences.js +0 -26
  272. package/dist/examples/src/mediaQueries/modules/resolution.js +0 -31
  273. package/dist/examples/src/mediaQueries/types.js +0 -2
  274. package/dist/examples/src/mediaQueries/validation.js +0 -128
  275. package/dist/examples/src/ratio.js +0 -141
  276. package/dist/examples/src/types.js +0 -2
  277. package/dist/examples/src/unitDefinitions.js +0 -67
  278. package/dist/examples/src/units/absolute.js +0 -11
  279. package/dist/examples/src/units/angle.js +0 -8
  280. package/dist/examples/src/units/container.js +0 -10
  281. package/dist/examples/src/units/font-relative.js +0 -16
  282. package/dist/examples/src/units/frequency.js +0 -6
  283. package/dist/examples/src/units/grid.js +0 -5
  284. package/dist/examples/src/units/percent.js +0 -7
  285. package/dist/examples/src/units/resolution.js +0 -7
  286. package/dist/examples/src/units/time.js +0 -6
  287. package/dist/examples/src/units/viewport-dynamic.js +0 -10
  288. package/dist/examples/src/units/viewport-large.js +0 -10
  289. package/dist/examples/src/units/viewport-small.js +0 -10
  290. package/dist/examples/src/units/viewport.js +0 -10
  291. package/dist/examples/src/validation.js +0 -20
  292. package/dist/examples/validation-and-runtime-checks.example.js +0 -85
  293. package/dist/examples/validation-unit-tests.example.js +0 -35
@@ -1,61 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.emitDimensionsFeatures = exports.createEmitDimensionsFeatures = void 0;
4
- const helpers_1 = require("../helpers");
5
- const validation_1 = require("../validation");
6
- const linting_1 = require("../linting");
7
- const core_1 = require("../linting/core");
8
- const createEmitDimensionsFeatures = (validation) => (props, helpers, validate) => {
9
- const { runMediaQueryValidation, validateMinMaxHeight, validateHeightValuesPositive, validateMinMaxAspectRatio, validateAspectRatioValuesPositive, validateWidthValuesPositive, } = validation;
10
- if (!runMediaQueryValidation(props, helpers, validateMinMaxHeight, 'dimensions', 'minHeight must be less than or equal to maxHeight')) {
11
- return;
12
- }
13
- if (!runMediaQueryValidation(props, helpers, validateHeightValuesPositive, 'dimensions', 'height values must be greater than 0')) {
14
- return;
15
- }
16
- if (!(0, linting_1.runMediaQueryLint)(props, helpers, core_1.lintWidthRedundancy, 'width should not be combined with minWidth or maxWidth')) {
17
- return;
18
- }
19
- if (!(0, linting_1.runMediaQueryLint)(props, helpers, core_1.lintHeightRedundancy, 'height should not be combined with minHeight or maxHeight')) {
20
- return;
21
- }
22
- if (!runMediaQueryValidation(props, helpers, validateWidthValuesPositive, 'dimensions', 'width values must be greater than 0')) {
23
- return;
24
- }
25
- if (!runMediaQueryValidation(props, helpers, validateMinMaxAspectRatio, 'dimensions', 'minAspectRatio must be less than or equal to maxAspectRatio')) {
26
- return;
27
- }
28
- if (!runMediaQueryValidation(props, helpers, validateAspectRatioValuesPositive, 'dimensions', 'aspect ratio values must be greater than 0')) {
29
- return;
30
- }
31
- if (!(0, helpers_1.applyMediaQueryValidation)(props, helpers, validate, 'dimensions')) {
32
- return;
33
- }
34
- const { addFeature } = helpers;
35
- if (props.width) {
36
- addFeature('width', props.width);
37
- }
38
- if (props.height) {
39
- addFeature('height', props.height);
40
- }
41
- if (props.minHeight) {
42
- addFeature('min-height', props.minHeight);
43
- }
44
- if (props.maxHeight) {
45
- addFeature('max-height', props.maxHeight);
46
- }
47
- if (props.aspectRatio) {
48
- addFeature('aspect-ratio', props.aspectRatio);
49
- }
50
- if (props.minAspectRatio) {
51
- addFeature('min-aspect-ratio', props.minAspectRatio);
52
- }
53
- if (props.maxAspectRatio) {
54
- addFeature('max-aspect-ratio', props.maxAspectRatio);
55
- }
56
- if (props.orientation) {
57
- addFeature('orientation', props.orientation);
58
- }
59
- };
60
- exports.createEmitDimensionsFeatures = createEmitDimensionsFeatures;
61
- exports.emitDimensionsFeatures = (0, exports.createEmitDimensionsFeatures)(validation_1.defaultMediaQueryValidation);
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.emitDisplayFeatures = void 0;
4
- const helpers_1 = require("../helpers");
5
- const emitDisplayFeatures = (props, helpers, validate) => {
6
- if (!(0, helpers_1.applyMediaQueryValidation)(props, helpers, validate, 'display')) {
7
- return;
8
- }
9
- const { addFeature } = helpers;
10
- if (props.colorGamut) {
11
- addFeature('color-gamut', props.colorGamut);
12
- }
13
- if (props.dynamicRange) {
14
- addFeature('dynamic-range', props.dynamicRange);
15
- }
16
- if (props.invertedColors) {
17
- addFeature('inverted-colors', props.invertedColors);
18
- }
19
- };
20
- exports.emitDisplayFeatures = emitDisplayFeatures;
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.emitEnvironmentFeatures = void 0;
4
- const helpers_1 = require("../helpers");
5
- const emitEnvironmentFeatures = (props, helpers, validate) => {
6
- if (!(0, helpers_1.applyMediaQueryValidation)(props, helpers, validate, 'environment')) {
7
- return;
8
- }
9
- const { addFeature } = helpers;
10
- if (props.scripting) {
11
- addFeature('scripting', props.scripting);
12
- }
13
- if (props.overflowBlock) {
14
- addFeature('overflow-block', props.overflowBlock);
15
- }
16
- if (props.overflowInline) {
17
- addFeature('overflow-inline', props.overflowInline);
18
- }
19
- };
20
- exports.emitEnvironmentFeatures = emitEnvironmentFeatures;
@@ -1,23 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./custom"), exports);
18
- __exportStar(require("./dimensions"), exports);
19
- __exportStar(require("./display"), exports);
20
- __exportStar(require("./environment"), exports);
21
- __exportStar(require("./interaction"), exports);
22
- __exportStar(require("./preferences"), exports);
23
- __exportStar(require("./resolution"), exports);
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.emitInteractionFeatures = void 0;
4
- const helpers_1 = require("../helpers");
5
- const emitInteractionFeatures = (props, helpers, validate) => {
6
- if (!(0, helpers_1.applyMediaQueryValidation)(props, helpers, validate, 'interaction')) {
7
- return;
8
- }
9
- const { addFeature } = helpers;
10
- if (props.hover) {
11
- addFeature('hover', props.hover);
12
- }
13
- if (props.anyHover) {
14
- addFeature('any-hover', props.anyHover);
15
- }
16
- if (props.pointer) {
17
- addFeature('pointer', props.pointer);
18
- }
19
- if (props.anyPointer) {
20
- addFeature('any-pointer', props.anyPointer);
21
- }
22
- if (props.update) {
23
- addFeature('update', props.update);
24
- }
25
- };
26
- exports.emitInteractionFeatures = emitInteractionFeatures;
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.emitPreferencesFeatures = void 0;
4
- const helpers_1 = require("../helpers");
5
- const emitPreferencesFeatures = (props, helpers, validate) => {
6
- if (!(0, helpers_1.applyMediaQueryValidation)(props, helpers, validate, 'preferences')) {
7
- return;
8
- }
9
- const { addFeature } = helpers;
10
- if (props.colorScheme) {
11
- addFeature('prefers-color-scheme', props.colorScheme);
12
- }
13
- if (props.reducedMotion) {
14
- addFeature('prefers-reduced-motion', props.reducedMotion);
15
- }
16
- if (props.reducedData) {
17
- addFeature('prefers-reduced-data', props.reducedData);
18
- }
19
- if (props.contrast) {
20
- addFeature('prefers-contrast', props.contrast);
21
- }
22
- if (props.forcedColors) {
23
- addFeature('forced-colors', props.forcedColors);
24
- }
25
- };
26
- exports.emitPreferencesFeatures = emitPreferencesFeatures;
@@ -1,31 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.emitResolutionFeatures = exports.createEmitResolutionFeatures = void 0;
4
- const helpers_1 = require("../helpers");
5
- const validation_1 = require("../validation");
6
- const linting_1 = require("../linting");
7
- const resolution_1 = require("../linting/resolution");
8
- const createEmitResolutionFeatures = (validation) => (props, helpers, validate) => {
9
- const { runMediaQueryValidation, validateResolutionValues } = validation;
10
- if (!runMediaQueryValidation(props, helpers, validateResolutionValues, 'resolution', 'resolution values must be greater than 0')) {
11
- return;
12
- }
13
- if (!(0, linting_1.runMediaQueryLint)(props, helpers, resolution_1.lintResolutionRedundancy, 'resolution should not be combined with minResolution or maxResolution')) {
14
- return;
15
- }
16
- if (!(0, helpers_1.applyMediaQueryValidation)(props, helpers, validate, 'resolution')) {
17
- return;
18
- }
19
- const { addFeature } = helpers;
20
- if (props.resolutionValue) {
21
- addFeature('resolution', props.resolutionValue);
22
- }
23
- if (props.minResolution) {
24
- addFeature('min-resolution', props.minResolution);
25
- }
26
- if (props.maxResolution) {
27
- addFeature('max-resolution', props.maxResolution);
28
- }
29
- };
30
- exports.createEmitResolutionFeatures = createEmitResolutionFeatures;
31
- exports.emitResolutionFeatures = (0, exports.createEmitResolutionFeatures)(validation_1.defaultMediaQueryValidation);
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,131 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.defaultMediaQueryValidation = exports.validateResolutionValues = exports.validateAspectRatioValuesPositive = exports.validateMinMaxAspectRatio = exports.validateHeightValuesPositive = exports.validateMinMaxHeight = exports.validateWidthValuesPositive = exports.validateMinMaxWidth = exports.runMediaQueryValidation = exports.createMediaQueryValidation = void 0;
4
- const helpers_1 = require("./helpers");
5
- const core_1 = require("../core");
6
- const toValidationResult = (error, fallback) => {
7
- if (error instanceof Error && error.message)
8
- return error.message;
9
- return fallback;
10
- };
11
- const createMediaQueryValidation = (core) => {
12
- const { assertCondition, assertMatchingUnits } = core;
13
- const runMediaQueryValidation = (config, helpers, check, context, fallbackMessage = 'Invalid media query configuration') => {
14
- if (!check)
15
- return true;
16
- try {
17
- check(config);
18
- return true;
19
- }
20
- catch (error) {
21
- const result = toValidationResult(error, fallbackMessage);
22
- return (0, helpers_1.applyMediaQueryValidation)(config, helpers, () => result, context);
23
- }
24
- };
25
- const validateMinMaxWidth = (props) => {
26
- if (!props.minWidth || !props.maxWidth)
27
- return;
28
- assertMatchingUnits(props.minWidth, props.maxWidth, 'mediaQueries.minMaxWidth');
29
- assertCondition(props.minWidth.getValue() <= props.maxWidth.getValue(), 'minWidth must be less than or equal to maxWidth');
30
- };
31
- const validateWidthValuesPositive = (props) => {
32
- const assertPositive = (value, label) => {
33
- assertCondition(value.getValue() > 0, `${label} must be greater than 0`);
34
- };
35
- if (props.width) {
36
- assertPositive(props.width, 'width');
37
- }
38
- if (props.minWidth) {
39
- assertPositive(props.minWidth, 'minWidth');
40
- }
41
- if (props.maxWidth) {
42
- assertPositive(props.maxWidth, 'maxWidth');
43
- }
44
- };
45
- const validateMinMaxHeight = (props) => {
46
- if (!props.minHeight || !props.maxHeight)
47
- return;
48
- assertMatchingUnits(props.minHeight, props.maxHeight, 'mediaQueries.minMaxHeight');
49
- assertCondition(props.minHeight.getValue() <= props.maxHeight.getValue(), 'minHeight must be less than or equal to maxHeight');
50
- };
51
- const validateHeightValuesPositive = (props) => {
52
- const assertPositive = (value, label) => {
53
- assertCondition(value.getValue() > 0, `${label} must be greater than 0`);
54
- };
55
- if (props.height) {
56
- assertPositive(props.height, 'height');
57
- }
58
- if (props.minHeight) {
59
- assertPositive(props.minHeight, 'minHeight');
60
- }
61
- if (props.maxHeight) {
62
- assertPositive(props.maxHeight, 'maxHeight');
63
- }
64
- };
65
- const validateMinMaxAspectRatio = (props) => {
66
- if (!props.minAspectRatio || !props.maxAspectRatio)
67
- return;
68
- const assertRatio = (value, label) => {
69
- assertCondition((0, core_1.isRatio)(value), `${label} must be a ratio created with r()`);
70
- };
71
- assertRatio(props.minAspectRatio, 'minAspectRatio');
72
- assertRatio(props.maxAspectRatio, 'maxAspectRatio');
73
- const minRatio = (0, core_1.ratioToFloat)(props.minAspectRatio);
74
- const maxRatio = (0, core_1.ratioToFloat)(props.maxAspectRatio);
75
- assertCondition(minRatio <= maxRatio, 'minAspectRatio must be less than or equal to maxAspectRatio');
76
- };
77
- const validateAspectRatioValuesPositive = (props) => {
78
- const assertRatio = (value, label) => {
79
- assertCondition((0, core_1.isRatio)(value), `${label} must be a ratio created with r()`);
80
- };
81
- const assertValidPositive = (label, ratio) => {
82
- assertCondition((0, core_1.ratioToFloat)(ratio) > 0, `${label} must be a valid ratio greater than 0`);
83
- };
84
- if (props.aspectRatio !== undefined) {
85
- assertRatio(props.aspectRatio, 'aspectRatio');
86
- assertValidPositive('aspectRatio', props.aspectRatio);
87
- }
88
- if (props.minAspectRatio !== undefined) {
89
- assertRatio(props.minAspectRatio, 'minAspectRatio');
90
- assertValidPositive('minAspectRatio', props.minAspectRatio);
91
- }
92
- if (props.maxAspectRatio !== undefined) {
93
- assertRatio(props.maxAspectRatio, 'maxAspectRatio');
94
- assertValidPositive('maxAspectRatio', props.maxAspectRatio);
95
- }
96
- };
97
- const validateResolutionValues = (props) => {
98
- const assertPositive = (value, label) => {
99
- assertCondition(value.getValue() > 0, `${label} must be greater than 0`);
100
- };
101
- if (props.resolutionValue) {
102
- assertPositive(props.resolutionValue, 'resolution');
103
- }
104
- if (props.minResolution) {
105
- assertPositive(props.minResolution, 'minResolution');
106
- }
107
- if (props.maxResolution) {
108
- assertPositive(props.maxResolution, 'maxResolution');
109
- }
110
- if (props.minResolution && props.maxResolution) {
111
- assertMatchingUnits(props.minResolution, props.maxResolution, 'mediaQueries.resolutionUnits');
112
- }
113
- };
114
- return {
115
- runMediaQueryValidation,
116
- validateMinMaxWidth,
117
- validateWidthValuesPositive,
118
- validateMinMaxHeight,
119
- validateHeightValuesPositive,
120
- validateMinMaxAspectRatio,
121
- validateAspectRatioValuesPositive,
122
- validateResolutionValues,
123
- };
124
- };
125
- exports.createMediaQueryValidation = createMediaQueryValidation;
126
- const defaultMediaQueryValidation = (0, exports.createMediaQueryValidation)({
127
- assertCondition: core_1.assertCondition,
128
- assertMatchingUnits: core_1.assertMatchingUnits,
129
- });
130
- exports.defaultMediaQueryValidation = defaultMediaQueryValidation;
131
- exports.runMediaQueryValidation = defaultMediaQueryValidation.runMediaQueryValidation, exports.validateMinMaxWidth = defaultMediaQueryValidation.validateMinMaxWidth, exports.validateWidthValuesPositive = defaultMediaQueryValidation.validateWidthValuesPositive, exports.validateMinMaxHeight = defaultMediaQueryValidation.validateMinMaxHeight, exports.validateHeightValuesPositive = defaultMediaQueryValidation.validateHeightValuesPositive, exports.validateMinMaxAspectRatio = defaultMediaQueryValidation.validateMinMaxAspectRatio, exports.validateAspectRatioValuesPositive = defaultMediaQueryValidation.validateAspectRatioValuesPositive, exports.validateResolutionValues = defaultMediaQueryValidation.validateResolutionValues;
package/dist/cjs/types.js DELETED
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toValidationResult = exports.normalizeValidationResult = void 0;
4
- const normalizeValidationResult = (result) => {
5
- if (result === undefined || result === null)
6
- return { valid: true };
7
- if (typeof result === "boolean")
8
- return { valid: result };
9
- if (typeof result === "string") {
10
- return result ? { valid: false, message: result } : { valid: true };
11
- }
12
- return result;
13
- };
14
- exports.normalizeValidationResult = normalizeValidationResult;
15
- const toValidationResult = (error, fallback) => {
16
- if (error instanceof Error && error.message)
17
- return error.message;
18
- return fallback;
19
- };
20
- exports.toValidationResult = toValidationResult;
@@ -1,23 +0,0 @@
1
- import type { ContainerQueryModuleKeysMap } from "../containerQueries/moduleRegistry";
2
- import type { IMeasurement } from "../core";
3
- export type IComparisonOperator = "<" | "<=" | ">" | ">=" | "=";
4
- export type ContentQueryVariable = ContainerQueryModuleKeysMap[keyof ContainerQueryModuleKeysMap];
5
- export type ContentQueryComparisonValue = IMeasurement | number | string;
6
- export type Comparison<Variable = ContentQueryVariable, Value = ContentQueryComparisonValue> = {
7
- variable: Variable;
8
- operator: IComparisonOperator;
9
- value: Value;
10
- };
11
- export type ComparisonValue<Value = ContentQueryComparisonValue> = {
12
- operator: IComparisonOperator;
13
- value: Value;
14
- readonly __comparisonBrand: unique symbol;
15
- };
16
- export declare const compare: {
17
- eq: <T extends ContentQueryComparisonValue>(value: T) => ComparisonValue<T>;
18
- lt: <T extends ContentQueryComparisonValue>(value: T) => ComparisonValue<T>;
19
- lte: <T extends ContentQueryComparisonValue>(value: T) => ComparisonValue<T>;
20
- gt: <T extends ContentQueryComparisonValue>(value: T) => ComparisonValue<T>;
21
- gte: <T extends ContentQueryComparisonValue>(value: T) => ComparisonValue<T>;
22
- };
23
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/comparisons/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,oCAAoC,CAAC;AACtF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,MAAM,MAAM,mBAAmB,GAAG,GAAG,GAAG,IAAI,GAAG,GAAG,GAAG,IAAI,GAAG,GAAG,CAAC;AAEhE,MAAM,MAAM,oBAAoB,GAC9B,2BAA2B,CAAC,MAAM,2BAA2B,CAAC,CAAC;AAEjE,MAAM,MAAM,2BAA2B,GACnC,YAAY,GACZ,MAAM,GACN,MAAM,CAAC;AAEX,MAAM,MAAM,UAAU,CACpB,QAAQ,GAAG,oBAAoB,EAC/B,KAAK,GAAG,2BAA2B,IACjC;IACF,QAAQ,EAAE,QAAQ,CAAC;IACnB,QAAQ,EAAE,mBAAmB,CAAC;IAC9B,KAAK,EAAE,KAAK,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,eAAe,CAAC,KAAK,GAAG,2BAA2B,IAAI;IACjE,QAAQ,EAAE,mBAAmB,CAAC;IAC9B,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,CAAC,iBAAiB,EAAE,OAAO,MAAM,CAAC;CAC3C,CAAC;AAEF,eAAO,MAAM,OAAO;SACb,CAAC,SAAS,2BAA2B,SACjC,CAAC,KACP,eAAe,CAAC,CAAC,CAAC;SAIhB,CAAC,SAAS,2BAA2B,SACjC,CAAC,KACP,eAAe,CAAC,CAAC,CAAC;UAIf,CAAC,SAAS,2BAA2B,SAClC,CAAC,KACP,eAAe,CAAC,CAAC,CAAC;SAIhB,CAAC,SAAS,2BAA2B,SACjC,CAAC,KACP,eAAe,CAAC,CAAC,CAAC;UAIf,CAAC,SAAS,2BAA2B,SAClC,CAAC,KACP,eAAe,CAAC,CAAC,CAAC;CAItB,CAAC"}
@@ -1,22 +0,0 @@
1
- export const compare = {
2
- eq: (value) => ({
3
- operator: "=",
4
- value,
5
- }),
6
- lt: (value) => ({
7
- operator: "<",
8
- value,
9
- }),
10
- lte: (value) => ({
11
- operator: "<=",
12
- value,
13
- }),
14
- gt: (value) => ({
15
- operator: ">",
16
- value,
17
- }),
18
- gte: (value) => ({
19
- operator: ">=",
20
- value,
21
- }),
22
- };
@@ -1,36 +0,0 @@
1
- import { IMeasurement } from "../core";
2
- import type { Comparison, IComparisonOperator } from "../comparisons";
3
- import type { IContainerQueryAspectRatio, IContainerQueryBlock, IContainerQueryCustomFeatures, IContainerQueryInline, IContainerQueryStyle } from "./modules";
4
- import { ContainerQueryValidation } from "./validation";
5
- import { ContainerQueryBuilderHelpers } from "./helpers";
6
- import type { StyleRule } from "../mediaQueries/types";
7
- import type { CSSContainerCondition } from "./types";
8
- export interface IContainerQueryProps extends IContainerQueryCore, IContainerQueryInline, IContainerQueryBlock, IContainerQueryAspectRatio, IContainerQueryStyle, IContainerQueryCustomFeatures {
9
- }
10
- export interface IContainerQueryCore {
11
- minWidth?: IMeasurement | IMeasurement[];
12
- maxWidth?: IMeasurement | IMeasurement[];
13
- minHeight?: IMeasurement | IMeasurement[];
14
- maxHeight?: IMeasurement | IMeasurement[];
15
- }
16
- export type IContainerQueryCoreVariables = IContainerQueryCore["minWidth"] | IContainerQueryCore["maxWidth"] | IContainerQueryCore["minHeight"] | IContainerQueryCore["maxHeight"];
17
- export type SizeComparisonValue = IMeasurement | string | number;
18
- export type CoreComparisonVariable = "minWidth" | "maxWidth" | "minHeight" | "maxHeight";
19
- export type CoreComparison = Comparison<CoreComparisonVariable, IMeasurement>;
20
- export type CoreComparisonBlock<Variable = CoreComparisonVariable, Value = IMeasurement> = {
21
- variable: Variable;
22
- operator: IComparisonOperator;
23
- value: Value;
24
- };
25
- export interface IContainerQuery {
26
- props: IContainerQueryProps;
27
- styles: StyleRule;
28
- }
29
- export type IContainerQueries = Record<string, IContainerQueryProps>;
30
- export type IContainerQueryStyles<T extends IContainerQueries> = Partial<Record<keyof T, StyleRule>>;
31
- export declare const createEmitCoreFeatures: (validation: ContainerQueryValidation) => (props: IContainerQueryCore, helpers: ContainerQueryBuilderHelpers) => void;
32
- export declare const emitCoreFeatures: (props: IContainerQueryCore, helpers: ContainerQueryBuilderHelpers) => void;
33
- export declare const buildContainerQueryString: (config: IContainerQueryProps) => string;
34
- export declare const buildContainerConditionString: (condition: CSSContainerCondition) => string;
35
- export declare const makeContainerQueryStyle: <T extends IContainerQueries>(queries: T) => (stylesByQuery: IContainerQueryStyles<T>) => StyleRule;
36
- //# sourceMappingURL=containerQueries.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"containerQueries.d.ts","sourceRoot":"","sources":["../../../src/containerQueries/containerQueries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,KAAK,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACtE,OAAO,KAAK,EACV,0BAA0B,EAC1B,oBAAoB,EACpB,6BAA6B,EAC7B,qBAAqB,EACrB,oBAAoB,EACrB,MAAM,WAAW,CAAC;AAanB,OAAO,EAAE,wBAAwB,EAAmC,MAAM,cAAc,CAAC;AACzF,OAAO,EAAE,4BAA4B,EAA+B,MAAM,WAAW,CAAC;AACtF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAErD,MAAM,WAAW,oBACf,SAAQ,mBAAmB,EACzB,qBAAqB,EACrB,oBAAoB,EACpB,0BAA0B,EAC1B,oBAAoB,EACpB,6BAA6B;CAAG;AAEpC,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,EAAE,YAAY,GAAG,YAAY,EAAE,CAAC;IACzC,QAAQ,CAAC,EAAE,YAAY,GAAG,YAAY,EAAE,CAAC;IACzC,SAAS,CAAC,EAAE,YAAY,GAAG,YAAY,EAAE,CAAC;IAC1C,SAAS,CAAC,EAAE,YAAY,GAAG,YAAY,EAAE,CAAC;CAC3C;AAED,MAAM,MAAM,4BAA4B,GACpC,mBAAmB,CAAC,UAAU,CAAC,GAC/B,mBAAmB,CAAC,UAAU,CAAC,GAC/B,mBAAmB,CAAC,WAAW,CAAC,GAChC,mBAAmB,CAAC,WAAW,CAAC,CAAC;AAErC,MAAM,MAAM,mBAAmB,GAAG,YAAY,GAAG,MAAM,GAAG,MAAM,CAAC;AAEjE,MAAM,MAAM,sBAAsB,GAC9B,UAAU,GACV,UAAU,GACV,WAAW,GACX,WAAW,CAAC;AAEhB,MAAM,MAAM,cAAc,GAAG,UAAU,CAAC,sBAAsB,EAAE,YAAY,CAAC,CAAC;AAE9E,MAAM,MAAM,mBAAmB,CAC7B,QAAQ,GAAG,sBAAsB,EACjC,KAAK,GAAG,YAAY,IAClB;IACF,QAAQ,EAAE,QAAQ,CAAC;IACnB,QAAQ,EAAE,mBAAmB,CAAC;IAC9B,KAAK,EAAE,KAAK,CAAC;CACd,CAAC;AAEF,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,oBAAoB,CAAC;IAC5B,MAAM,EAAE,SAAS,CAAC;CACnB;AAED,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;AAErE,MAAM,MAAM,qBAAqB,CAAC,CAAC,SAAS,iBAAiB,IAAI,OAAO,CACtE,MAAM,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC,CAC3B,CAAC;AAEF,eAAO,MAAM,sBAAsB,GAChC,YAAY,wBAAwB,MACpC,OAAO,mBAAmB,EAAE,SAAS,4BAA4B,KAAG,IA6GpE,CAAC;AAEJ,eAAO,MAAM,gBAAgB,UA/GnB,mBAAmB,WAAW,4BAA4B,KAAG,IAiHtE,CAAC;AAcF,eAAO,MAAM,yBAAyB,0CAEpC,CAAC;AAcH,eAAO,MAAM,6BAA6B,GACxC,WAAW,qBAAqB,KAC/B,MAeF,CAAC;AAEF,eAAO,MAAM,uBAAuB,GACjC,CAAC,SAAS,iBAAiB,EAAE,SAAS,CAAC,MACvC,eAAe,qBAAqB,CAAC,CAAC,CAAC,KAAG,SAc1C,CAAC"}
@@ -1,109 +0,0 @@
1
- import { emitAspectRatioFeatures, emitBlockSizeFeatures, emitCustomFeatures, emitInlineSizeFeatures, emitStyleFeatures, } from "./modules";
2
- import { runContainerQueryLint } from "./linting";
3
- import { lintHeightExactRedundancy, lintWidthExactRedundancy, } from "./linting/core";
4
- import { defaultContainerQueryValidation } from "./validation";
5
- import { createContainerQueryBuilder } from "./helpers";
6
- export const createEmitCoreFeatures = (validation) => (props, helpers) => {
7
- const allowQueryArrays = helpers.config.allowQueryArrays !== false;
8
- const assertNoArray = (value, label) => {
9
- if (Array.isArray(value) && !allowQueryArrays) {
10
- throw new Error(`${label} does not allow arrays.`);
11
- }
12
- };
13
- const emitFeature = (name, value) => {
14
- if (Array.isArray(value)) {
15
- value.forEach((entry) => {
16
- var _a;
17
- ((_a = helpers.addFeatureUnsafe) !== null && _a !== void 0 ? _a : helpers.addFeature)(name, entry);
18
- });
19
- return;
20
- }
21
- helpers.addFeature(name, value);
22
- };
23
- const { runContainerQueryValidation, validateMinMaxWidth, validateWidthValuesPositive, validateMinMaxHeight, validateHeightValuesPositive, } = validation;
24
- if (!runContainerQueryValidation(props, helpers, validateMinMaxWidth, "core", "minWidth must be less than or equal to maxWidth")) {
25
- return;
26
- }
27
- if (!runContainerQueryValidation(props, helpers, validateMinMaxHeight, "core", "minHeight must be less than or equal to maxHeight")) {
28
- return;
29
- }
30
- if (!runContainerQueryValidation(props, helpers, validateWidthValuesPositive, "core", "width values must be greater than 0")) {
31
- return;
32
- }
33
- if (!runContainerQueryValidation(props, helpers, validateHeightValuesPositive, "core", "height values must be greater than 0")) {
34
- return;
35
- }
36
- if (!runContainerQueryLint(props, helpers, lintWidthExactRedundancy, "minWidth should not be combined with maxWidth when both are equal")) {
37
- return;
38
- }
39
- if (!runContainerQueryLint(props, helpers, lintHeightExactRedundancy, "minHeight should not be combined with maxHeight when both are equal")) {
40
- return;
41
- }
42
- if (props.minWidth !== undefined) {
43
- assertNoArray(props.minWidth, "minWidth");
44
- emitFeature("min-width", props.minWidth);
45
- }
46
- if (props.maxWidth !== undefined) {
47
- assertNoArray(props.maxWidth, "maxWidth");
48
- emitFeature("max-width", props.maxWidth);
49
- }
50
- if (props.minHeight !== undefined) {
51
- assertNoArray(props.minHeight, "minHeight");
52
- emitFeature("min-height", props.minHeight);
53
- }
54
- if (props.maxHeight !== undefined) {
55
- assertNoArray(props.maxHeight, "maxHeight");
56
- emitFeature("max-height", props.maxHeight);
57
- }
58
- };
59
- export const emitCoreFeatures = createEmitCoreFeatures(defaultContainerQueryValidation);
60
- const emitBaseFeatures = (props, helpers) => {
61
- emitCoreFeatures(props, helpers);
62
- emitAspectRatioFeatures(props, helpers);
63
- emitInlineSizeFeatures(props, helpers);
64
- emitBlockSizeFeatures(props, helpers);
65
- emitStyleFeatures(props, helpers);
66
- emitCustomFeatures(props, helpers);
67
- };
68
- export const buildContainerQueryString = createContainerQueryBuilder({
69
- emitBase: emitBaseFeatures,
70
- });
71
- const wrapContainerCondition = (value) => {
72
- const trimmed = value.trim();
73
- if (trimmed.includes(" and ") ||
74
- trimmed.includes(" or ") ||
75
- trimmed.startsWith("not ")) {
76
- return `(${trimmed})`;
77
- }
78
- return trimmed;
79
- };
80
- export const buildContainerConditionString = (condition) => {
81
- if ("and" in condition) {
82
- return condition.and
83
- .map((entry) => wrapContainerCondition(buildContainerConditionString(entry)))
84
- .join(" and ");
85
- }
86
- if ("or" in condition) {
87
- return condition.or
88
- .map((entry) => wrapContainerCondition(buildContainerConditionString(entry)))
89
- .join(" or ");
90
- }
91
- if ("not" in condition) {
92
- return `not ${wrapContainerCondition(buildContainerConditionString(condition.not))}`;
93
- }
94
- return buildContainerQueryString(condition);
95
- };
96
- export const makeContainerQueryStyle = (queries) => (stylesByQuery) => {
97
- const result = {};
98
- Object.keys(stylesByQuery).forEach((key) => {
99
- const styles = stylesByQuery[key];
100
- const props = queries[key];
101
- if (!styles || !props)
102
- return;
103
- result[buildContainerQueryString(props)] = styles;
104
- });
105
- const containerQuery = {
106
- "@container": result,
107
- };
108
- return containerQuery;
109
- };
@@ -1,20 +0,0 @@
1
- import type { ComplexStyleRule, StyleRule } from "../mediaQueries/types";
2
- import type { CSSContainerQueries } from "./types";
3
- import type { ContainerQueryBuilderConfig } from "./helpers";
4
- import type { ContainerQueryModulesList } from "./moduleRegistry";
5
- type ContainerQueryStyleMap<TQueries> = Partial<Record<keyof TQueries, StyleRule>>;
6
- export type ContainerQueryFactoryConfig<TModules extends ContainerQueryModulesList | undefined = undefined, TOutput = ComplexStyleRule> = ContainerQueryBuilderConfig & {
7
- label: string;
8
- modules?: TModules;
9
- output?: (container: ComplexStyleRule) => TOutput;
10
- };
11
- export declare const createContainerQueryFactory: () => <TModules extends ContainerQueryModulesList | undefined, TQueries extends CSSContainerQueries, TOutput = ComplexStyleRule>(options: {
12
- queries: TQueries;
13
- config: ContainerQueryFactoryConfig<TModules, TOutput>;
14
- }) => (stylesByQuery: ContainerQueryStyleMap<TQueries>) => TOutput;
15
- export declare const containerQueryFactory: <TModules extends ContainerQueryModulesList | undefined, TQueries extends CSSContainerQueries, TOutput = ComplexStyleRule>(options: {
16
- queries: TQueries;
17
- config: ContainerQueryFactoryConfig<TModules, TOutput>;
18
- }) => (stylesByQuery: ContainerQueryStyleMap<TQueries>) => TOutput;
19
- export {};
20
- //# sourceMappingURL=factory.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../src/containerQueries/factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACzE,OAAO,KAAK,EAEV,mBAAmB,EACpB,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EACV,2BAA2B,EAC5B,MAAM,WAAW,CAAC;AAEnB,OAAO,KAAK,EAEV,yBAAyB,EAC1B,MAAM,kBAAkB,CAAC;AAE1B,KAAK,sBAAsB,CAAC,QAAQ,IAAI,OAAO,CAC7C,MAAM,CAAC,MAAM,QAAQ,EAAE,SAAS,CAAC,CAClC,CAAC;AAqIF,MAAM,MAAM,2BAA2B,CACrC,QAAQ,SAAS,yBAAyB,GAAG,SAAS,GAAG,SAAS,EAClE,OAAO,GAAG,gBAAgB,IACxB,2BAA2B,GAAG;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,QAAQ,CAAC;IACnB,MAAM,CAAC,EAAE,CAAC,SAAS,EAAE,gBAAgB,KAAK,OAAO,CAAC;CACnD,CAAC;AAEF,eAAO,MAAM,2BAA2B,SACtC,QAAQ,SAAS,yBAAyB,GAAG,SAAS,EACtD,QAAQ,SAAS,mBAAmB,EACpC,OAAO,GAAG,gBAAgB,EAC1B,SAAS;IACT,OAAO,EAAE,QAAQ,CAAC;IAClB,MAAM,EAAE,2BAA2B,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;CACxD,MAGS,eAAe,sBAAsB,CAAC,QAAQ,CAAC,KAAG,OA6B3D,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAxChC,QAAQ,SAAS,yBAAyB,GAAG,SAAS,EACtD,QAAQ,SAAS,mBAAmB,EACpC,OAAO,8BACE;IACT,OAAO,EAAE,QAAQ,CAAC;IAClB,MAAM,EAAE,2BAA2B,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;CACxD,MAGS,eAAe,sBAAsB,CAAC,QAAQ,CAAC,KAAG,OA+BM,CAAC"}