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,127 +0,0 @@
1
- import { applyMediaQueryValidation } from './helpers';
2
- import { assertCondition, assertMatchingUnits, isRatio, ratioToFloat, } from '../core';
3
- const toValidationResult = (error, fallback) => {
4
- if (error instanceof Error && error.message)
5
- return error.message;
6
- return fallback;
7
- };
8
- export const createMediaQueryValidation = (core) => {
9
- const { assertCondition, assertMatchingUnits } = core;
10
- const runMediaQueryValidation = (config, helpers, check, context, fallbackMessage = 'Invalid media query configuration') => {
11
- if (!check)
12
- return true;
13
- try {
14
- check(config);
15
- return true;
16
- }
17
- catch (error) {
18
- const result = toValidationResult(error, fallbackMessage);
19
- return applyMediaQueryValidation(config, helpers, () => result, context);
20
- }
21
- };
22
- const validateMinMaxWidth = (props) => {
23
- if (!props.minWidth || !props.maxWidth)
24
- return;
25
- assertMatchingUnits(props.minWidth, props.maxWidth, 'mediaQueries.minMaxWidth');
26
- assertCondition(props.minWidth.getValue() <= props.maxWidth.getValue(), 'minWidth must be less than or equal to maxWidth');
27
- };
28
- const validateWidthValuesPositive = (props) => {
29
- const assertPositive = (value, label) => {
30
- assertCondition(value.getValue() > 0, `${label} must be greater than 0`);
31
- };
32
- if (props.width) {
33
- assertPositive(props.width, 'width');
34
- }
35
- if (props.minWidth) {
36
- assertPositive(props.minWidth, 'minWidth');
37
- }
38
- if (props.maxWidth) {
39
- assertPositive(props.maxWidth, 'maxWidth');
40
- }
41
- };
42
- const validateMinMaxHeight = (props) => {
43
- if (!props.minHeight || !props.maxHeight)
44
- return;
45
- assertMatchingUnits(props.minHeight, props.maxHeight, 'mediaQueries.minMaxHeight');
46
- assertCondition(props.minHeight.getValue() <= props.maxHeight.getValue(), 'minHeight must be less than or equal to maxHeight');
47
- };
48
- const validateHeightValuesPositive = (props) => {
49
- const assertPositive = (value, label) => {
50
- assertCondition(value.getValue() > 0, `${label} must be greater than 0`);
51
- };
52
- if (props.height) {
53
- assertPositive(props.height, 'height');
54
- }
55
- if (props.minHeight) {
56
- assertPositive(props.minHeight, 'minHeight');
57
- }
58
- if (props.maxHeight) {
59
- assertPositive(props.maxHeight, 'maxHeight');
60
- }
61
- };
62
- const validateMinMaxAspectRatio = (props) => {
63
- if (!props.minAspectRatio || !props.maxAspectRatio)
64
- return;
65
- const assertRatio = (value, label) => {
66
- assertCondition(isRatio(value), `${label} must be a ratio created with r()`);
67
- };
68
- assertRatio(props.minAspectRatio, 'minAspectRatio');
69
- assertRatio(props.maxAspectRatio, 'maxAspectRatio');
70
- const minRatio = ratioToFloat(props.minAspectRatio);
71
- const maxRatio = ratioToFloat(props.maxAspectRatio);
72
- assertCondition(minRatio <= maxRatio, 'minAspectRatio must be less than or equal to maxAspectRatio');
73
- };
74
- const validateAspectRatioValuesPositive = (props) => {
75
- const assertRatio = (value, label) => {
76
- assertCondition(isRatio(value), `${label} must be a ratio created with r()`);
77
- };
78
- const assertValidPositive = (label, ratio) => {
79
- assertCondition(ratioToFloat(ratio) > 0, `${label} must be a valid ratio greater than 0`);
80
- };
81
- if (props.aspectRatio !== undefined) {
82
- assertRatio(props.aspectRatio, 'aspectRatio');
83
- assertValidPositive('aspectRatio', props.aspectRatio);
84
- }
85
- if (props.minAspectRatio !== undefined) {
86
- assertRatio(props.minAspectRatio, 'minAspectRatio');
87
- assertValidPositive('minAspectRatio', props.minAspectRatio);
88
- }
89
- if (props.maxAspectRatio !== undefined) {
90
- assertRatio(props.maxAspectRatio, 'maxAspectRatio');
91
- assertValidPositive('maxAspectRatio', props.maxAspectRatio);
92
- }
93
- };
94
- const validateResolutionValues = (props) => {
95
- const assertPositive = (value, label) => {
96
- assertCondition(value.getValue() > 0, `${label} must be greater than 0`);
97
- };
98
- if (props.resolutionValue) {
99
- assertPositive(props.resolutionValue, 'resolution');
100
- }
101
- if (props.minResolution) {
102
- assertPositive(props.minResolution, 'minResolution');
103
- }
104
- if (props.maxResolution) {
105
- assertPositive(props.maxResolution, 'maxResolution');
106
- }
107
- if (props.minResolution && props.maxResolution) {
108
- assertMatchingUnits(props.minResolution, props.maxResolution, 'mediaQueries.resolutionUnits');
109
- }
110
- };
111
- return {
112
- runMediaQueryValidation,
113
- validateMinMaxWidth,
114
- validateWidthValuesPositive,
115
- validateMinMaxHeight,
116
- validateHeightValuesPositive,
117
- validateMinMaxAspectRatio,
118
- validateAspectRatioValuesPositive,
119
- validateResolutionValues,
120
- };
121
- };
122
- const defaultMediaQueryValidation = createMediaQueryValidation({
123
- assertCondition,
124
- assertMatchingUnits,
125
- });
126
- export const { runMediaQueryValidation, validateMinMaxWidth, validateWidthValuesPositive, validateMinMaxHeight, validateHeightValuesPositive, validateMinMaxAspectRatio, validateAspectRatioValuesPositive, validateResolutionValues, } = defaultMediaQueryValidation;
127
- export { defaultMediaQueryValidation };
@@ -1,35 +0,0 @@
1
- export type Resolve<T> = {
2
- [Key in keyof T]: T[Key];
3
- } & {};
4
- export type CSSVarFunction = string;
5
- export type MapLeafNodes<T, Leaf> = T extends null ? null : T extends string ? Leaf : T extends object ? {
6
- [Key in keyof T]: MapLeafNodes<T[Key], Leaf>;
7
- } : Leaf;
8
- export type NullableTokens = {
9
- [key: string]: string | NullableTokens | null;
10
- };
11
- export type Tokens = {
12
- [key: string]: string | Tokens;
13
- };
14
- export type ThemeVars<ThemeContract extends NullableTokens> = MapLeafNodes<ThemeContract, CSSVarFunction>;
15
- export type ClassNames = string | Array<ClassNames>;
16
- type _PropertySyntax = "<angle>" | "<color>" | "<custom-ident>" | "<image>" | "<integer>" | "<length-percentage>" | "<length>" | "<number>" | "<percentage>" | "<resolution>" | "<string>" | "<time>" | "<transform-function>" | "<transform-list>" | "<url>" | "*";
17
- type LooseAutocomplete<Suggestions extends string> = Suggestions | Omit<string, Suggestions>;
18
- export type PropertySyntax = LooseAutocomplete<_PropertySyntax>;
19
- export type QueryRule<Key extends string, StyleType> = {
20
- [key in Key]?: {
21
- [query: string]: Omit<StyleType, Key>;
22
- };
23
- };
24
- export type QueryMedia<StyleType> = QueryRule<"@media", StyleType>;
25
- export type QueryFeature<StyleType> = QueryRule<"@supports", StyleType>;
26
- export type QueryContainer<StyleType> = QueryRule<"@container", StyleType>;
27
- export type QueryLayer<StyleType> = QueryRule<"@layer", StyleType>;
28
- export type QueryStartingStyle<StyleType> = {
29
- "@starting-style"?: Omit<StyleType, "@starting-style">;
30
- };
31
- export interface QueryAll<StyleType> extends QueryMedia<StyleType & QueryAll<StyleType>>, QueryFeature<StyleType & QueryAll<StyleType>>, QueryContainer<StyleType & QueryAll<StyleType>>, QueryLayer<StyleType & QueryAll<StyleType>>, QueryStartingStyle<StyleType> {
32
- }
33
- export type WithQuery<StyleType> = StyleType & QueryAll<StyleType>;
34
- export {};
35
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI;KACtB,GAAG,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC;CACzB,GAAG,EAAE,CAAC;AAEP,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC;AAEpC,MAAM,MAAM,YAAY,CAAC,CAAC,EAAE,IAAI,IAAI,CAAC,SAAS,IAAI,GAC9C,IAAI,GACJ,CAAC,SAAS,MAAM,GAChB,IAAI,GACJ,CAAC,SAAS,MAAM,GAChB;KAAG,GAAG,IAAI,MAAM,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC;CAAE,GAChD,IAAI,CAAC;AAET,MAAM,MAAM,cAAc,GAAG;IAC3B,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,cAAc,GAAG,IAAI,CAAC;CAC/C,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG;IACnB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,SAAS,CAAC,aAAa,SAAS,cAAc,IAAI,YAAY,CACxE,aAAa,EACb,cAAc,CACf,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC;AAEpD,KAAK,eAAe,GAChB,SAAS,GACT,SAAS,GACT,gBAAgB,GAChB,SAAS,GACT,WAAW,GACX,qBAAqB,GACrB,UAAU,GACV,UAAU,GACV,cAAc,GACd,cAAc,GACd,UAAU,GACV,QAAQ,GACR,sBAAsB,GACtB,kBAAkB,GAClB,OAAO,GACP,GAAG,CAAC;AAER,KAAK,iBAAiB,CAAC,WAAW,SAAS,MAAM,IAC7C,WAAW,GACX,IAAI,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;AAE9B,MAAM,MAAM,cAAc,GAAG,iBAAiB,CAAC,eAAe,CAAC,CAAC;AAEhE,MAAM,MAAM,SAAS,CAAC,GAAG,SAAS,MAAM,EAAE,SAAS,IAAI;KACpD,GAAG,IAAI,GAAG,CAAC,CAAC,EAAE;QACb,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;KACvC;CACF,CAAC;AAEF,MAAM,MAAM,UAAU,CAAC,SAAS,IAAI,SAAS,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;AACnE,MAAM,MAAM,YAAY,CAAC,SAAS,IAAI,SAAS,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;AACxE,MAAM,MAAM,cAAc,CAAC,SAAS,IAAI,SAAS,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC;AAC3E,MAAM,MAAM,UAAU,CAAC,SAAS,IAAI,SAAS,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;AACnE,MAAM,MAAM,kBAAkB,CAAC,SAAS,IAAI;IAC1C,iBAAiB,CAAC,EAAE,IAAI,CAAC,SAAS,EAAE,iBAAiB,CAAC,CAAC;CACxD,CAAC;AAEF,MAAM,WAAW,QAAQ,CAAC,SAAS,CACjC,SAAQ,UAAU,CAAC,SAAS,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC,EACjD,YAAY,CAAC,SAAS,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC,EAC7C,cAAc,CAAC,SAAS,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC,EAC/C,UAAU,CAAC,SAAS,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC,EAC3C,kBAAkB,CAAC,SAAS,CAAC;CAAG;AAEpC,MAAM,MAAM,SAAS,CAAC,SAAS,IAAI,SAAS,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC"}
package/dist/esm/types.js DELETED
@@ -1 +0,0 @@
1
- export {};
@@ -1,10 +0,0 @@
1
- export type ValidationResult = boolean | string | null | undefined | {
2
- valid: boolean;
3
- message?: string;
4
- };
5
- export declare const normalizeValidationResult: (result: ValidationResult) => {
6
- valid: boolean;
7
- message?: string;
8
- };
9
- export declare const toValidationResult: (error: unknown, fallback: string) => ValidationResult;
10
- //# sourceMappingURL=validation.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/validation.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GACxB,OAAO,GACP,MAAM,GACN,IAAI,GACJ,SAAS,GACT;IACE,KAAK,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEN,eAAO,MAAM,yBAAyB,GACpC,QAAQ,gBAAgB,KACvB;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAOpC,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAC7B,OAAO,OAAO,EACd,UAAU,MAAM,KACf,gBAGF,CAAC"}
@@ -1,15 +0,0 @@
1
- export const normalizeValidationResult = (result) => {
2
- if (result === undefined || result === null)
3
- return { valid: true };
4
- if (typeof result === "boolean")
5
- return { valid: result };
6
- if (typeof result === "string") {
7
- return result ? { valid: false, message: result } : { valid: true };
8
- }
9
- return result;
10
- };
11
- export const toValidationResult = (error, fallback) => {
12
- if (error instanceof Error && error.message)
13
- return error.message;
14
- return fallback;
15
- };
@@ -1,54 +0,0 @@
1
- "use strict";
2
- /**
3
- * Example-only file.
4
- *
5
- * This is not part of the public API surface and is not published in the
6
- * package. It shows how to nest media + container query outputs, including
7
- * optional vanilla-extract helpers.
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- const css_1 = require("@vanilla-extract/css");
11
- const factory_wrapper_example_1 = require("./factory-wrapper.example");
12
- const containerQueries_1 = require("../src/containerQueries");
13
- const media = (0, factory_wrapper_example_1.makeMediaQueryStyle)({
14
- desktop: { minWidth: (0, factory_wrapper_example_1.m)(1024) },
15
- });
16
- const container = (0, containerQueries_1.makeContainerQueryStyle)({
17
- wideCard: {
18
- inlineSize: { operator: ">=", value: (0, factory_wrapper_example_1.m)(28, "rem") },
19
- },
20
- });
21
- // const nestedStyles = media({
22
- // desktop: container({
23
- // wideCard: {
24
- // gridTemplateColumns: "1fr 2fr",
25
- // gridTemplateRows: "none",
26
- // alignItems: "stretch",
27
- // },
28
- // }),
29
- // });
30
- const sampleClasses = {
31
- container: (0, css_1.style)({
32
- display: "grid",
33
- }),
34
- logo: (0, css_1.style)({}),
35
- text: (0, css_1.style)({}),
36
- };
37
- const sampleComponent = `
38
- <div className={container}>
39
- <div className={logo}>Logo</div>
40
- <div className={text}>Some text here</div>
41
- </div>
42
- `;
43
- // const vanillaExtractStyles = mediaQueryOutputVanillaExtract(
44
- // media({
45
- // desktop: containerQueryOutputVanillaExtract(
46
- // container({
47
- // wideCard: {
48
- // gridTemplateColumns: "1fr 2fr",
49
- // gridTemplateRows: "none",
50
- // },
51
- // }),
52
- // ),
53
- // }),
54
- // );
@@ -1,54 +0,0 @@
1
- "use strict";
2
- /**
3
- * Example-only file.
4
- *
5
- * This is not part of the public API surface and is not published in the
6
- * package. It shows how to nest media + container query outputs, including
7
- * optional vanilla-extract helpers.
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- const css_1 = require("@vanilla-extract/css");
11
- const factory_wrapper_example_1 = require("./factory-wrapper.example");
12
- const containerQueries_1 = require("../src/containerQueries");
13
- const media = (0, factory_wrapper_example_1.makeMediaQueryStyle)({
14
- desktop: { minWidth: (0, factory_wrapper_example_1.m)(1024) },
15
- });
16
- const container = (0, containerQueries_1.makeContainerQueryStyle)({
17
- wideCard: {
18
- inlineSize: { operator: ">=", value: (0, factory_wrapper_example_1.m)(28, "rem") },
19
- },
20
- });
21
- // const nestedStyles = media({
22
- // desktop: container({
23
- // wideCard: {
24
- // gridTemplateColumns: "1fr 2fr",
25
- // gridTemplateRows: "none",
26
- // alignItems: "stretch",
27
- // },
28
- // }),
29
- // });
30
- const sampleClasses = {
31
- container: (0, css_1.style)({
32
- display: "grid",
33
- }),
34
- logo: (0, css_1.style)({}),
35
- text: (0, css_1.style)({}),
36
- };
37
- const sampleComponent = `
38
- <div className={container}>
39
- <div className={logo}>Logo</div>
40
- <div className={text}>Some text here</div>
41
- </div>
42
- `;
43
- // const vanillaExtractStyles = mediaQueryOutputVanillaExtract(
44
- // media({
45
- // desktop: containerQueryOutputVanillaExtract(
46
- // container({
47
- // wideCard: {
48
- // gridTemplateColumns: "1fr 2fr",
49
- // gridTemplateRows: "none",
50
- // },
51
- // }),
52
- // ),
53
- // }),
54
- // );
@@ -1,33 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.m = exports.mVw = exports.mEm = exports.makeMediaQueryStyle = exports.buildMediaQueryString = exports.units = exports.mediaQueries = exports.assertCondition = exports.assertMatchingUnits = exports.mPercent = exports.mPx = void 0;
4
- const factory_1 = require("css-calipers/factory");
5
- /**
6
- * Example wrapper module.
7
- * Use the factory once, then re-export from here across your app.
8
- * This keeps a single import path and makes refactors cheaper.
9
- */
10
- const calipers = (0, factory_1.createCalipers)({
11
- errorConfig: { stackHints: 'on' },
12
- });
13
- exports.mPx = calipers.mPx, exports.mPercent = calipers.mPercent, exports.assertMatchingUnits = calipers.assertMatchingUnits, exports.assertCondition = calipers.assertCondition, exports.mediaQueries = calipers.mediaQueries, exports.units = calipers.units;
14
- exports.buildMediaQueryString = exports.mediaQueries.buildMediaQueryString, exports.makeMediaQueryStyle = exports.mediaQueries.makeMediaQueryStyle;
15
- exports.mEm = exports.units.mEm, exports.mVw = exports.units.mVw;
16
- /**
17
- * Benefit: you can make custom changes in one place without touching call sites.
18
- * Example wrapper below is intentionally demonstrative, not a recommended m change.
19
- */
20
- const m = (value, unitOrOptions, context) => {
21
- var _a;
22
- if (!unitOrOptions) {
23
- return calipers.m(value, '%', context);
24
- }
25
- if (typeof unitOrOptions === 'object') {
26
- return calipers.m(value, {
27
- ...unitOrOptions,
28
- unit: (_a = unitOrOptions.unit) !== null && _a !== void 0 ? _a : '%',
29
- });
30
- }
31
- return calipers.m(value, unitOrOptions, context);
32
- };
33
- exports.m = m;
@@ -1,81 +0,0 @@
1
- "use strict";
2
- /**
3
- * Example-only file.
4
- *
5
- * This is not part of the public API surface and is not published in the
6
- * package. It exists to demonstrate one way to normalize mixed line-height
7
- * inputs into a single value with a `.css()` method. See the README for a
8
- * deeper discussion of this pattern and its trade-offs.
9
- */
10
- Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.normalizeLineHeight = void 0;
12
- const css_calipers_1 = require("css-calipers");
13
- const parseNumericWithUnit = (raw) => {
14
- const value = raw.trim();
15
- const match = value.match(/^(-?\d*\.?\d+)\s*(px|rem|em|%)$/i);
16
- if (!match)
17
- return null;
18
- const [, numeric, unit] = match;
19
- return {
20
- value: Number(numeric),
21
- unit: unit.toLowerCase(),
22
- };
23
- };
24
- const normalizeLineHeight = (value) => {
25
- // Case 1: bare number (unitless line-height)
26
- if (typeof value === 'number') {
27
- return {
28
- css: () => value,
29
- };
30
- }
31
- const trimmed = value.trim();
32
- // Case 2: numeric value + unit string (for example, "1.5rem", "20px")
33
- const numericWithUnit = parseNumericWithUnit(trimmed);
34
- if (numericWithUnit) {
35
- const measurement = (0, css_calipers_1.m)(numericWithUnit.value, numericWithUnit.unit);
36
- return measurement;
37
- }
38
- // Case 3: unitless numeric string (for example, "1.5")
39
- const numericValue = Number(trimmed);
40
- if (!Number.isNaN(numericValue)) {
41
- return {
42
- css: () => numericValue,
43
- };
44
- }
45
- // Case 4: keywords ("normal") or CSS variables ("var(--body-line-height)")
46
- // remain opaque CSS strings and resolve at runtime.
47
- return {
48
- css: () => trimmed,
49
- };
50
- };
51
- exports.normalizeLineHeight = normalizeLineHeight;
52
- // Example usages (not executed here; for illustration only):
53
- const lineHeightFromNumber = (0, exports.normalizeLineHeight)(1.5);
54
- const lineHeightFromUnitString = (0, exports.normalizeLineHeight)('1.5rem');
55
- const lineHeightFromNumericString = (0, exports.normalizeLineHeight)('1.5');
56
- const lineHeightFromKeyword = (0, exports.normalizeLineHeight)('normal');
57
- const lineHeightFromVar = (0, exports.normalizeLineHeight)('var(--body-line-height)');
58
- // All normalized values expose a `.css()` method:
59
- const lineHeightStyles = {
60
- number: lineHeightFromNumber.css(),
61
- unitString: lineHeightFromUnitString.css(),
62
- numericString: lineHeightFromNumericString.css(),
63
- keyword: lineHeightFromKeyword.css(),
64
- cssVariable: lineHeightFromVar.css(),
65
- };
66
- // Advanced example: if the normalized value happens to be a CSS-Calipers
67
- // measurement, you can safely do math on it before emitting CSS.
68
- const baseLineHeight = (0, exports.normalizeLineHeight)('1.4rem');
69
- const minLineHeight = (0, css_calipers_1.m)(1.2, 'rem');
70
- const maxLineHeight = (0, css_calipers_1.m)(1.8, 'rem');
71
- let clampedLineHeight;
72
- if ((0, css_calipers_1.isMeasurement)(baseLineHeight)) {
73
- // Here TypeScript knows `baseLineHeight` is an IMeasurement, so you can use
74
- // unit-aware helpers before emitting.
75
- const clamped = baseLineHeight.clamp(minLineHeight, maxLineHeight);
76
- clampedLineHeight = clamped.css();
77
- }
78
- else {
79
- // Keywords or CSS variables bypass CSS-Calipers and stay as-is.
80
- clampedLineHeight = baseLineHeight.css();
81
- }
@@ -1,127 +0,0 @@
1
- "use strict";
2
- /**
3
- * Example-only file.
4
- *
5
- * This is not part of the public API surface and is not published in the
6
- * package. It shows how a page layout and a grid component can use different
7
- * media query configs (and different breakpoints) in the same codebase.
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- const css_calipers_1 = require("css-calipers");
11
- const mediaQueries_1 = require("css-calipers/mediaQueries");
12
- // Simple helper: grid component uses its own breakpoints and column labels.
13
- // This helper uses the default builder, which includes all modules.
14
- const gridBreakpoints = {
15
- columns_four: { maxWidth: (0, css_calipers_1.m)(1200) },
16
- columns_three: { maxWidth: (0, css_calipers_1.m)(1024) },
17
- columns_two: { maxWidth: (0, css_calipers_1.m)(768) },
18
- columns_one: { maxWidth: (0, css_calipers_1.m)(520) },
19
- };
20
- const gridMediaSimple = (0, mediaQueries_1.makeMediaQueryStyle)(gridBreakpoints);
21
- const gridStylesSimple = {
22
- display: "grid",
23
- gap: "16px",
24
- gridTemplateColumns: "repeat(4, 1fr)",
25
- ...gridMediaSimple({
26
- columns_four: { gridTemplateColumns: "repeat(4, 1fr)" },
27
- columns_three: { gridTemplateColumns: "repeat(3, 1fr)" },
28
- columns_two: { gridTemplateColumns: "repeat(2, 1fr)" },
29
- columns_one: { gridTemplateColumns: "1fr" },
30
- }),
31
- };
32
- // Multiple instances: page layout and grid component use different configs.
33
- // Layout uses the standard mobile/tablet/desktop breakpoints and defaults.
34
- // The default keeps all modules enabled, if you want to limit modules, you
35
- // can specify what moduels to load explicitely
36
- const layoutMedia = (0, mediaQueries_1.mediaQueryFactory)({
37
- queries: {
38
- mobile: { maxWidth: (0, css_calipers_1.m)(639) },
39
- tablet: { minWidth: (0, css_calipers_1.m)(640), maxWidth: (0, css_calipers_1.m)(1023) },
40
- desktop: { minWidth: (0, css_calipers_1.m)(1024) },
41
- },
42
- config: { label: "layout" },
43
- });
44
- // Grid uses a custom breakpoint map and custom error handling for iteration.
45
- // Note "core" is explicit here and no other modules will be loaded.
46
- const gridMedia = (0, mediaQueries_1.mediaQueryFactory)({
47
- queries: gridBreakpoints,
48
- config: {
49
- label: "product-grid",
50
- modules: ["core"],
51
- errorHandling: {
52
- invalidValueMode: "log",
53
- lintingMode: "log",
54
- },
55
- },
56
- });
57
- const pageStyles = {
58
- display: "grid",
59
- gridTemplateColumns: "repeat(4, 1fr)",
60
- ...layoutMedia({
61
- mobile: { gridTemplateColumns: "1fr" },
62
- tablet: { gridTemplateColumns: "repeat(2, 1fr)" },
63
- desktop: { gridTemplateColumns: "repeat(4, 1fr)" },
64
- }),
65
- };
66
- const gridStyles = {
67
- display: "grid",
68
- gap: "16px",
69
- gridTemplateColumns: "repeat(4, 1fr)",
70
- ...gridMedia({
71
- columns_four: { gridTemplateColumns: "repeat(4, 1fr)" },
72
- columns_three: { gridTemplateColumns: "repeat(3, 1fr)" },
73
- columns_two: { gridTemplateColumns: "repeat(2, 1fr)" },
74
- columns_one: { gridTemplateColumns: "1fr" },
75
- }),
76
- };
77
- // Advanced example: any-hover with custom validation + linting.
78
- // Note
79
- const interactionMedia = (0, mediaQueries_1.mediaQueryFactory)({
80
- queries: {
81
- hoverReady: {
82
- anyHover: "hover",
83
- anyPointer: "fine",
84
- reducedMotion: "no-preference",
85
- },
86
- hoverDisabled: {
87
- anyHover: "none",
88
- anyPointer: "coarse",
89
- reducedMotion: "reduce",
90
- },
91
- },
92
- config: {
93
- label: "interaction",
94
- modules: ["interaction", "preferences"],
95
- errorHandling: {
96
- invalidValueMode: "throw",
97
- lintingMode: "log",
98
- },
99
- output: (media) => ({
100
- label: "interaction",
101
- media,
102
- note: "Custom output for advanced example",
103
- }),
104
- custom: {
105
- key: "any-hover-guard",
106
- validator: (props) => {
107
- if (props.anyHover && !props.anyPointer) {
108
- return "anyHover should be paired with anyPointer for clarity";
109
- }
110
- return true;
111
- },
112
- linter: (props) => {
113
- if (props.anyHover === "none" && props.anyPointer === "fine") {
114
- return "anyHover none rarely pairs with anyPointer fine";
115
- }
116
- return true;
117
- },
118
- },
119
- },
120
- });
121
- const interactionResult = interactionMedia({
122
- hoverReady: { cursor: "pointer", transitionDuration: "160ms" },
123
- hoverDisabled: { cursor: "default", transitionDuration: "0ms" },
124
- });
125
- const interactionStyles = {
126
- ...interactionResult.media,
127
- };
@@ -1,55 +0,0 @@
1
- "use strict";
2
- /**
3
- * Example-only file.
4
- *
5
- * This is not part of the public API surface and is not published in the
6
- * package. It shows how to nest media + container query outputs, including
7
- * optional vanilla-extract helpers.
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- const css_calipers_1 = require("css-calipers");
11
- const mediaQueries_1 = require("css-calipers/mediaQueries");
12
- const containerQueries_1 = require("css-calipers/containerQueries");
13
- const media = (0, mediaQueries_1.makeMediaQueryStyle)({
14
- desktop: { minWidth: (0, css_calipers_1.m)(1024) },
15
- aspectRatio: (0, css_calipers_1.m)("16/9"),
16
- });
17
- // const media2 = makeMediaQueryStyle({
18
- // queryA: {
19
- // // implied "and"
20
- // minWidth: m(1024),
21
- // maxWidth: m(2024),
22
- // },
23
- // queryB: not({
24
- // minResolution: m(2, "dppx"),
25
- // }),
26
- // queryC: or({
27
- // aspectRatio: m("16/9"),
28
- // }),
29
- // });
30
- const container = (0, containerQueries_1.makeContainerQueryStyle)({
31
- wideCard: {
32
- inlineSize: { operator: ">=", value: (0, css_calipers_1.m)(28, "rem") },
33
- },
34
- });
35
- const nestedStyles = media({
36
- desktop: container({
37
- wideCard: {
38
- gridTemplateColumns: "1fr 2fr",
39
- gridTemplateRows: "none",
40
- alignItems: "stretch",
41
- },
42
- }),
43
- });
44
- // const vanillaExtractStyles = mediaQueryOutputVanillaExtract(
45
- // media({
46
- // desktop: containerQueryOutputVanillaExtract(
47
- // container({
48
- // wideCard: {
49
- // gridTemplateColumns: "1fr 2fr",
50
- // gridTemplateRows: "none",
51
- // },
52
- // }),
53
- // ),
54
- // }),
55
- // );