css-calipers 0.9.3 → 0.9.4

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 (259) hide show
  1. package/README.md +100 -0
  2. package/dist/cjs/comparisons/index.js +25 -0
  3. package/dist/cjs/containerQueries/containerQueries.js +115 -0
  4. package/dist/cjs/containerQueries/factory.js +123 -0
  5. package/dist/cjs/containerQueries/helpers.js +95 -0
  6. package/dist/cjs/containerQueries/index.js +16 -0
  7. package/dist/cjs/containerQueries/linting/aspectRatio.js +24 -0
  8. package/dist/cjs/containerQueries/linting/block.js +23 -0
  9. package/dist/cjs/containerQueries/linting/core.js +25 -0
  10. package/dist/cjs/containerQueries/linting/custom.js +11 -0
  11. package/dist/cjs/containerQueries/linting/inline.js +23 -0
  12. package/dist/cjs/containerQueries/linting/resolution.js +12 -0
  13. package/dist/cjs/containerQueries/linting/style.js +28 -0
  14. package/dist/cjs/containerQueries/linting.js +24 -0
  15. package/dist/cjs/containerQueries/moduleRegistry.js +5 -0
  16. package/dist/cjs/containerQueries/modules/aspectRatio.js +51 -0
  17. package/dist/cjs/containerQueries/modules/block.js +53 -0
  18. package/dist/cjs/containerQueries/modules/custom.js +43 -0
  19. package/dist/cjs/containerQueries/modules/index.js +21 -0
  20. package/dist/cjs/containerQueries/modules/inline.js +53 -0
  21. package/dist/cjs/containerQueries/modules/size.js +2 -0
  22. package/dist/cjs/containerQueries/modules/style.js +36 -0
  23. package/dist/cjs/containerQueries/types.js +2 -0
  24. package/dist/cjs/containerQueries/validation.js +191 -0
  25. package/dist/cjs/core.js +5 -278
  26. package/dist/cjs/factory.js +21 -0
  27. package/dist/cjs/fraction.js +139 -0
  28. package/dist/cjs/internal/buildMeasurementCreationError.js +16 -0
  29. package/dist/cjs/internal/buildMeasurementCreationError.tests.js +5 -0
  30. package/dist/cjs/internal/createComponentQueriesApi.js +56 -0
  31. package/dist/cjs/internal/createCoreApi.js +336 -0
  32. package/dist/cjs/internal/createMediaQueriesApi.js +74 -0
  33. package/dist/cjs/internal/createUnitsApi.js +18 -0
  34. package/dist/cjs/internal/errors.js +118 -5
  35. package/dist/cjs/internal/normalizeToArray.js +9 -0
  36. package/dist/cjs/libraryHelpers/vanilla-extract.js +6 -2
  37. package/dist/cjs/logicalOperators/index.js +18 -0
  38. package/dist/cjs/mediaQueries/factory.js +5 -4
  39. package/dist/cjs/mediaQueries/mediaQueries.js +7 -5
  40. package/dist/cjs/mediaQueries/modules/dimensions.js +10 -8
  41. package/dist/cjs/mediaQueries/modules/resolution.js +6 -4
  42. package/dist/cjs/mediaQueries/validation.js +128 -116
  43. package/dist/cjs/ratio.js +141 -0
  44. package/dist/cjs/types.js +2 -0
  45. package/dist/cjs/validation.js +20 -0
  46. package/dist/esm/comparisons/index.d.ts +23 -0
  47. package/dist/esm/comparisons/index.d.ts.map +1 -0
  48. package/dist/esm/comparisons/index.js +22 -0
  49. package/dist/esm/containerQueries/containerQueries.d.ts +36 -0
  50. package/dist/esm/containerQueries/containerQueries.d.ts.map +1 -0
  51. package/dist/esm/containerQueries/containerQueries.js +109 -0
  52. package/dist/esm/containerQueries/factory.d.ts +20 -0
  53. package/dist/esm/containerQueries/factory.d.ts.map +1 -0
  54. package/dist/esm/containerQueries/factory.js +119 -0
  55. package/dist/esm/containerQueries/helpers.d.ts +53 -0
  56. package/dist/esm/containerQueries/helpers.d.ts.map +1 -0
  57. package/dist/esm/containerQueries/helpers.js +82 -0
  58. package/dist/esm/containerQueries/index.d.ts +10 -0
  59. package/dist/esm/containerQueries/index.d.ts.map +1 -0
  60. package/dist/esm/containerQueries/index.js +4 -0
  61. package/dist/esm/containerQueries/linting/aspectRatio.d.ts +4 -0
  62. package/dist/esm/containerQueries/linting/aspectRatio.d.ts.map +1 -0
  63. package/dist/esm/containerQueries/linting/aspectRatio.js +19 -0
  64. package/dist/esm/containerQueries/linting/block.d.ts +4 -0
  65. package/dist/esm/containerQueries/linting/block.d.ts.map +1 -0
  66. package/dist/esm/containerQueries/linting/block.js +18 -0
  67. package/dist/esm/containerQueries/linting/core.d.ts +4 -0
  68. package/dist/esm/containerQueries/linting/core.d.ts.map +1 -0
  69. package/dist/esm/containerQueries/linting/core.js +20 -0
  70. package/dist/esm/containerQueries/linting/custom.d.ts +3 -0
  71. package/dist/esm/containerQueries/linting/custom.d.ts.map +1 -0
  72. package/dist/esm/containerQueries/linting/custom.js +7 -0
  73. package/dist/esm/containerQueries/linting/inline.d.ts +4 -0
  74. package/dist/esm/containerQueries/linting/inline.d.ts.map +1 -0
  75. package/dist/esm/containerQueries/linting/inline.js +18 -0
  76. package/dist/esm/containerQueries/linting/resolution.d.ts +1 -0
  77. package/dist/esm/containerQueries/linting/resolution.d.ts.map +1 -0
  78. package/dist/esm/containerQueries/linting/resolution.js +12 -0
  79. package/dist/esm/containerQueries/linting/style.d.ts +3 -0
  80. package/dist/esm/containerQueries/linting/style.d.ts.map +1 -0
  81. package/dist/esm/containerQueries/linting/style.js +24 -0
  82. package/dist/esm/containerQueries/linting.d.ts +4 -0
  83. package/dist/esm/containerQueries/linting.d.ts.map +1 -0
  84. package/dist/esm/containerQueries/linting.js +20 -0
  85. package/dist/esm/containerQueries/moduleRegistry.d.ts +25 -0
  86. package/dist/esm/containerQueries/moduleRegistry.d.ts.map +1 -0
  87. package/dist/esm/containerQueries/moduleRegistry.js +1 -0
  88. package/dist/esm/containerQueries/modules/aspectRatio.d.ts +17 -0
  89. package/dist/esm/containerQueries/modules/aspectRatio.d.ts.map +1 -0
  90. package/dist/esm/containerQueries/modules/aspectRatio.js +47 -0
  91. package/dist/esm/containerQueries/modules/block.d.ts +20 -0
  92. package/dist/esm/containerQueries/modules/block.d.ts.map +1 -0
  93. package/dist/esm/containerQueries/modules/block.js +49 -0
  94. package/dist/esm/containerQueries/modules/custom.d.ts +13 -0
  95. package/dist/esm/containerQueries/modules/custom.d.ts.map +1 -0
  96. package/dist/esm/containerQueries/modules/custom.js +39 -0
  97. package/dist/esm/containerQueries/modules/index.d.ts +6 -0
  98. package/dist/esm/containerQueries/modules/index.d.ts.map +1 -0
  99. package/dist/esm/containerQueries/modules/index.js +5 -0
  100. package/dist/esm/containerQueries/modules/inline.d.ts +20 -0
  101. package/dist/esm/containerQueries/modules/inline.d.ts.map +1 -0
  102. package/dist/esm/containerQueries/modules/inline.js +49 -0
  103. package/dist/esm/containerQueries/modules/size.d.ts +41 -0
  104. package/dist/esm/containerQueries/modules/size.d.ts.map +1 -0
  105. package/dist/esm/containerQueries/modules/size.js +1 -0
  106. package/dist/esm/containerQueries/modules/style.d.ts +11 -0
  107. package/dist/esm/containerQueries/modules/style.d.ts.map +1 -0
  108. package/dist/esm/containerQueries/modules/style.js +32 -0
  109. package/dist/esm/containerQueries/types.d.ts +81 -0
  110. package/dist/esm/containerQueries/types.d.ts.map +1 -0
  111. package/dist/esm/containerQueries/types.js +1 -0
  112. package/dist/esm/containerQueries/validation.d.ts +41 -0
  113. package/dist/esm/containerQueries/validation.d.ts.map +1 -0
  114. package/dist/esm/containerQueries/validation.js +187 -0
  115. package/dist/esm/core.d.ts +27 -26
  116. package/dist/esm/core.d.ts.map +1 -1
  117. package/dist/esm/core.js +5 -266
  118. package/dist/esm/factory.d.ts +13 -0
  119. package/dist/esm/factory.d.ts.map +1 -0
  120. package/dist/esm/factory.js +17 -0
  121. package/dist/esm/fraction.d.ts +23 -0
  122. package/dist/esm/fraction.d.ts.map +1 -0
  123. package/dist/esm/fraction.js +129 -0
  124. package/dist/esm/internal/buildMeasurementCreationError.d.ts +12 -0
  125. package/dist/esm/internal/buildMeasurementCreationError.d.ts.map +1 -0
  126. package/dist/esm/internal/buildMeasurementCreationError.js +12 -0
  127. package/dist/esm/internal/buildMeasurementCreationError.tests.d.ts +3 -0
  128. package/dist/esm/internal/buildMeasurementCreationError.tests.d.ts.map +1 -0
  129. package/dist/esm/internal/buildMeasurementCreationError.tests.js +1 -0
  130. package/dist/esm/internal/createComponentQueriesApi.d.ts +34 -0
  131. package/dist/esm/internal/createComponentQueriesApi.d.ts.map +1 -0
  132. package/dist/esm/internal/createComponentQueriesApi.js +52 -0
  133. package/dist/esm/internal/createCoreApi.d.ts +289 -0
  134. package/dist/esm/internal/createCoreApi.d.ts.map +1 -0
  135. package/dist/esm/internal/createCoreApi.js +332 -0
  136. package/dist/esm/internal/createMediaQueriesApi.d.ts +35 -0
  137. package/dist/esm/internal/createMediaQueriesApi.d.ts.map +1 -0
  138. package/dist/esm/internal/createMediaQueriesApi.js +70 -0
  139. package/dist/esm/internal/createUnitsApi.d.ts +13 -0
  140. package/dist/esm/internal/createUnitsApi.d.ts.map +1 -0
  141. package/dist/esm/internal/createUnitsApi.js +14 -0
  142. package/dist/esm/internal/errors.d.ts +30 -0
  143. package/dist/esm/internal/errors.d.ts.map +1 -1
  144. package/dist/esm/internal/errors.js +113 -4
  145. package/dist/esm/internal/normalizeToArray.d.ts +2 -0
  146. package/dist/esm/internal/normalizeToArray.d.ts.map +1 -0
  147. package/dist/esm/internal/normalizeToArray.js +5 -0
  148. package/dist/esm/libraryHelpers/vanilla-extract.d.ts +2 -1
  149. package/dist/esm/libraryHelpers/vanilla-extract.d.ts.map +1 -1
  150. package/dist/esm/libraryHelpers/vanilla-extract.js +4 -1
  151. package/dist/esm/logicalOperators/index.d.ts +2 -0
  152. package/dist/esm/logicalOperators/index.d.ts.map +1 -0
  153. package/dist/esm/logicalOperators/index.js +17 -0
  154. package/dist/esm/mediaQueries/factory.d.ts +16 -1
  155. package/dist/esm/mediaQueries/factory.d.ts.map +1 -1
  156. package/dist/esm/mediaQueries/factory.js +3 -2
  157. package/dist/esm/mediaQueries/libraryHelpers/vanilla-extract.d.ts +2 -2
  158. package/dist/esm/mediaQueries/libraryHelpers/vanilla-extract.d.ts.map +1 -1
  159. package/dist/esm/mediaQueries/mediaQueries.d.ts +2 -0
  160. package/dist/esm/mediaQueries/mediaQueries.d.ts.map +1 -1
  161. package/dist/esm/mediaQueries/mediaQueries.js +4 -2
  162. package/dist/esm/mediaQueries/modules/dimensions.d.ts +2 -0
  163. package/dist/esm/mediaQueries/modules/dimensions.d.ts.map +1 -1
  164. package/dist/esm/mediaQueries/modules/dimensions.js +4 -2
  165. package/dist/esm/mediaQueries/modules/resolution.d.ts +2 -0
  166. package/dist/esm/mediaQueries/modules/resolution.d.ts.map +1 -1
  167. package/dist/esm/mediaQueries/modules/resolution.js +4 -2
  168. package/dist/esm/mediaQueries/validation.d.ts +28 -8
  169. package/dist/esm/mediaQueries/validation.d.ts.map +1 -1
  170. package/dist/esm/mediaQueries/validation.js +126 -107
  171. package/dist/esm/ratio.d.ts +22 -0
  172. package/dist/esm/ratio.d.ts.map +1 -0
  173. package/dist/esm/ratio.js +131 -0
  174. package/dist/esm/types.d.ts +35 -0
  175. package/dist/esm/types.d.ts.map +1 -0
  176. package/dist/esm/types.js +1 -0
  177. package/dist/esm/validation.d.ts +10 -0
  178. package/dist/esm/validation.d.ts.map +1 -0
  179. package/dist/esm/validation.js +15 -0
  180. package/dist/examples/containerQueries.example.js +54 -0
  181. package/dist/examples/examples/containerQueries.example.js +54 -0
  182. package/dist/examples/examples/factory-wrapper.example.js +33 -0
  183. package/dist/examples/examples/lineHeight-normalizer.example.js +81 -0
  184. package/dist/examples/examples/mediaQueries-multipleInstances.example.js +127 -0
  185. package/dist/examples/examples/mixedQueries.example.js +55 -0
  186. package/dist/examples/examples/validation-and-runtime-checks.example.js +85 -0
  187. package/dist/examples/examples/validation-unit-tests.example.js +35 -0
  188. package/dist/examples/factory-wrapper.example.js +33 -0
  189. package/dist/examples/lineHeight-normalizer.example.js +81 -0
  190. package/dist/examples/mediaQueries-multipleInstances.example.js +127 -0
  191. package/dist/examples/mixedQueries.example.js +60 -0
  192. package/dist/examples/src/comparisons/index.js +25 -0
  193. package/dist/examples/src/containerQueries/containerQueries.js +96 -0
  194. package/dist/examples/src/containerQueries/factory.js +123 -0
  195. package/dist/examples/src/containerQueries/helpers.js +94 -0
  196. package/dist/examples/src/containerQueries/index.js +16 -0
  197. package/dist/examples/src/containerQueries/linting/aspectRatio.js +20 -0
  198. package/dist/examples/src/containerQueries/linting/block.js +20 -0
  199. package/dist/examples/src/containerQueries/linting/core.js +19 -0
  200. package/dist/examples/src/containerQueries/linting/custom.js +11 -0
  201. package/dist/examples/src/containerQueries/linting/inline.js +20 -0
  202. package/dist/examples/src/containerQueries/linting/style.js +28 -0
  203. package/dist/examples/src/containerQueries/linting.js +24 -0
  204. package/dist/examples/src/containerQueries/moduleRegistry.js +5 -0
  205. package/dist/examples/src/containerQueries/modules/aspectRatio.js +33 -0
  206. package/dist/examples/src/containerQueries/modules/block.js +44 -0
  207. package/dist/examples/src/containerQueries/modules/custom.js +31 -0
  208. package/dist/examples/src/containerQueries/modules/index.js +21 -0
  209. package/dist/examples/src/containerQueries/modules/inline.js +44 -0
  210. package/dist/examples/src/containerQueries/modules/style.js +36 -0
  211. package/dist/examples/src/containerQueries/types.js +2 -0
  212. package/dist/examples/src/containerQueries/validation.js +177 -0
  213. package/dist/examples/src/core.js +16 -0
  214. package/dist/examples/src/factory.js +21 -0
  215. package/dist/examples/src/index.js +30 -0
  216. package/dist/examples/src/internal/buildMeasurementCreationError.js +16 -0
  217. package/dist/examples/src/internal/createCoreApi.js +336 -0
  218. package/dist/examples/src/internal/createMediaQueriesApi.js +74 -0
  219. package/dist/examples/src/internal/createUnitsApi.js +18 -0
  220. package/dist/examples/src/internal/errors.js +130 -0
  221. package/dist/examples/src/libraryHelpers/vanilla-extract.js +11 -0
  222. package/dist/examples/src/mediaQueries/factory.js +163 -0
  223. package/dist/examples/src/mediaQueries/helpers.js +88 -0
  224. package/dist/examples/src/mediaQueries/index.js +23 -0
  225. package/dist/examples/src/mediaQueries/linting/core.js +19 -0
  226. package/dist/examples/src/mediaQueries/linting/resolution.js +11 -0
  227. package/dist/examples/src/mediaQueries/linting.js +24 -0
  228. package/dist/examples/src/mediaQueries/mediaQueries.js +53 -0
  229. package/dist/examples/src/mediaQueries/moduleRegistry.js +5 -0
  230. package/dist/examples/src/mediaQueries/modules/custom.js +26 -0
  231. package/dist/examples/src/mediaQueries/modules/dimensions.js +61 -0
  232. package/dist/examples/src/mediaQueries/modules/display.js +20 -0
  233. package/dist/examples/src/mediaQueries/modules/environment.js +20 -0
  234. package/dist/examples/src/mediaQueries/modules/index.js +23 -0
  235. package/dist/examples/src/mediaQueries/modules/interaction.js +26 -0
  236. package/dist/examples/src/mediaQueries/modules/preferences.js +26 -0
  237. package/dist/examples/src/mediaQueries/modules/resolution.js +31 -0
  238. package/dist/examples/src/mediaQueries/types.js +2 -0
  239. package/dist/examples/src/mediaQueries/validation.js +128 -0
  240. package/dist/examples/src/ratio.js +141 -0
  241. package/dist/examples/src/types.js +2 -0
  242. package/dist/examples/src/unitDefinitions.js +67 -0
  243. package/dist/examples/src/units/absolute.js +11 -0
  244. package/dist/examples/src/units/angle.js +8 -0
  245. package/dist/examples/src/units/container.js +10 -0
  246. package/dist/examples/src/units/font-relative.js +16 -0
  247. package/dist/examples/src/units/frequency.js +6 -0
  248. package/dist/examples/src/units/grid.js +5 -0
  249. package/dist/examples/src/units/percent.js +7 -0
  250. package/dist/examples/src/units/resolution.js +7 -0
  251. package/dist/examples/src/units/time.js +6 -0
  252. package/dist/examples/src/units/viewport-dynamic.js +10 -0
  253. package/dist/examples/src/units/viewport-large.js +10 -0
  254. package/dist/examples/src/units/viewport-small.js +10 -0
  255. package/dist/examples/src/units/viewport.js +10 -0
  256. package/dist/examples/src/validation.js +20 -0
  257. package/dist/examples/validation-and-runtime-checks.example.js +85 -0
  258. package/dist/examples/validation-unit-tests.example.js +35 -0
  259. package/package.json +16 -5
@@ -0,0 +1,2 @@
1
+ export declare const normalizeToArray: <T>(value: T | T[] | null | undefined) => T[];
2
+ //# sourceMappingURL=normalizeToArray.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalizeToArray.d.ts","sourceRoot":"","sources":["../../../src/internal/normalizeToArray.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,GAAI,CAAC,EAChC,OAAO,CAAC,GAAG,CAAC,EAAE,GAAG,IAAI,GAAG,SAAS,KAChC,CAAC,EAGH,CAAC"}
@@ -0,0 +1,5 @@
1
+ export const normalizeToArray = (value) => {
2
+ if (value === undefined || value === null)
3
+ return [];
4
+ return Array.isArray(value) ? value : [value];
5
+ };
@@ -1,3 +1,4 @@
1
- import type { ComplexStyleRule } from '../mediaQueries/types';
1
+ import type { ComplexStyleRule } from "../mediaQueries/types";
2
2
  export declare const mediaQueryOutputVanillaExtract: (media: ComplexStyleRule) => Record<string, unknown>;
3
+ export declare const containerQueryOutputVanillaExtract: (container: ComplexStyleRule) => Record<string, unknown>;
3
4
  //# sourceMappingURL=vanilla-extract.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"vanilla-extract.d.ts","sourceRoot":"","sources":["../../../src/libraryHelpers/vanilla-extract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,eAAO,MAAM,8BAA8B,GACzC,OAAO,gBAAgB,KACtB,MAAM,CAAC,MAAM,EAAE,OAAO,CAEvB,CAAC"}
1
+ {"version":3,"file":"vanilla-extract.d.ts","sourceRoot":"","sources":["../../../src/libraryHelpers/vanilla-extract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,eAAO,MAAM,8BAA8B,GACzC,OAAO,gBAAgB,KACtB,MAAM,CAAC,MAAM,EAAE,OAAO,CAEvB,CAAC;AAEH,eAAO,MAAM,kCAAkC,GAC7C,WAAW,gBAAgB,KAC1B,MAAM,CAAC,MAAM,EAAE,OAAO,CAEvB,CAAC"}
@@ -1,3 +1,6 @@
1
1
  export const mediaQueryOutputVanillaExtract = (media) => ({
2
- '&': media,
2
+ "&": media,
3
+ });
4
+ export const containerQueryOutputVanillaExtract = (container) => ({
5
+ "&": container,
3
6
  });
@@ -0,0 +1,2 @@
1
+ export type IComparisonOperator = " and " | " or " | " not ";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/logicalOperators/index.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,mBAAmB,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC"}
@@ -0,0 +1,17 @@
1
+ export {};
2
+ // export type ContentQueryVariable =
3
+ // ContainerQueryModuleKeysMap[keyof ContainerQueryModuleKeysMap];
4
+ // export type ContentQueryComparisonValue = IMeasurement | number | string;
5
+ // export type Comparison<
6
+ // Variable = ContentQueryVariable,
7
+ // Value = ContentQueryComparisonValue
8
+ // > = {
9
+ // variable: Variable;
10
+ // operator: IComparisonOperator;
11
+ // value: Value;
12
+ // };
13
+ // export type ComparisonValue<Value = ContentQueryComparisonValue> = {
14
+ // operator: IComparisonOperator;
15
+ // value: Value;
16
+ // readonly __comparisonBrand: unique symbol;
17
+ // };
@@ -15,12 +15,27 @@ type MediaQueryFactoryCustomHooks = {
15
15
  validator?: (props: IMediaQueryProps) => CustomHookResult;
16
16
  linter?: (props: IMediaQueryProps) => CustomHookResult;
17
17
  };
18
+ declare const MODULE_EMITTERS: {
19
+ core: (props: import("./mediaQueries").IMediaQueryCore, helpers: import("./helpers").MediaQueryBuilderHelpers) => void;
20
+ dimensions: (props: import("./modules").IMediaQueryDimensions, helpers: import("./helpers").MediaQueryBuilderHelpers, validate?: import("./modules").MediaQueryDimensionsValidator) => void;
21
+ resolution: (props: import("./modules").IMediaQueryResolutionRange, helpers: import("./helpers").MediaQueryBuilderHelpers, validate?: import("./modules").MediaQueryResolutionValidator) => void;
22
+ interaction: (props: import("./modules").IMediaQueryInteraction, helpers: import("./helpers").MediaQueryBuilderHelpers, validate?: import("./modules").MediaQueryInteractionValidator) => void;
23
+ preferences: (props: import("./modules").IMediaQueryPreferences, helpers: import("./helpers").MediaQueryBuilderHelpers, validate?: import("./modules").MediaQueryPreferencesValidator) => void;
24
+ display: (props: import("./modules").IMediaQueryDisplay, helpers: import("./helpers").MediaQueryBuilderHelpers, validate?: import("./modules").MediaQueryDisplayValidator) => void;
25
+ environment: (props: import("./modules").IMediaQueryEnvironment, helpers: import("./helpers").MediaQueryBuilderHelpers, validate?: import("./modules").MediaQueryEnvironmentValidator) => void;
26
+ custom: (props: import("./modules").IMediaQueryCustomFeatures, helpers: import("./helpers").MediaQueryBuilderHelpers, validate?: import("./modules").MediaQueryCustomFeaturesValidator) => void;
27
+ };
28
+ export type MediaQueryModuleEmitters = typeof MODULE_EMITTERS;
18
29
  export type MediaQueryFactoryConfig<TModules extends MediaQueryModulesList | undefined = undefined, TOutput = ComplexStyleRule> = MediaQueryBuilderConfig & {
19
30
  label: string;
20
31
  modules?: TModules;
21
- output?: (media: ComplexStyleRule) => TOutput;
32
+ output?: (media: StyleRule) => TOutput;
22
33
  custom?: MediaQueryFactoryCustomHooks;
23
34
  };
35
+ export declare const createMediaQueryFactory: (emitters: MediaQueryModuleEmitters) => <TModules extends MediaQueryModulesList | undefined, TQueries extends Record<string, FactoryQueryProps<TModules>>, TOutput = ComplexStyleRule>(options: {
36
+ queries: TQueries;
37
+ config: MediaQueryFactoryConfig<TModules, TOutput>;
38
+ }) => (stylesByQuery: MediaQueryStyleMap<TQueries>) => TOutput;
24
39
  export declare const mediaQueryFactory: <TModules extends MediaQueryModulesList | undefined, TQueries extends Record<string, FactoryQueryProps<TModules>>, TOutput = ComplexStyleRule>(options: {
25
40
  queries: TQueries;
26
41
  config: MediaQueryFactoryConfig<TModules, TOutput>;
@@ -1 +1 @@
1
- {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../src/mediaQueries/factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAC3D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC;AAEzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBA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,CAAC,QAAQ,CAAC,KAAG,OAkBvD,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAjD5B,QAAQ,SAAS,qBAAqB,GAAG,SAAS,EAClD,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,QAAQ,CAAC,CAAC,EAC5D,OAAO,8BACE;IACT,OAAO,EAAE,QAAQ,CAAC;IAClB,MAAM,EAAE,uBAAuB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;CACpD,MAuBS,eAAe,kBAAkB,CAAC,QAAQ,CAAC,KAAG,OAoBiB,CAAC"}
@@ -124,7 +124,7 @@ const runCustomLinter = (props, config) => {
124
124
  return;
125
125
  throw new Error(message);
126
126
  };
127
- export const mediaQueryFactory = (options) => {
127
+ export const createMediaQueryFactory = (emitters) => (options) => {
128
128
  var _a;
129
129
  const modules = (_a = options.config.modules) !== null && _a !== void 0 ? _a : ALL_MEDIA_QUERY_MODULES;
130
130
  const buildMediaQuery = createMediaQueryBuilder({
@@ -133,7 +133,7 @@ export const mediaQueryFactory = (options) => {
133
133
  runCustomValidator(props, options.config);
134
134
  runCustomLinter(props, options.config);
135
135
  modules.forEach((moduleId) => {
136
- MODULE_EMITTERS[moduleId](props, helpers);
136
+ emitters[moduleId](props, helpers);
137
137
  });
138
138
  },
139
139
  resolveType: (props) => props.type,
@@ -156,3 +156,4 @@ export const mediaQueryFactory = (options) => {
156
156
  : mediaQuery;
157
157
  };
158
158
  };
159
+ export const mediaQueryFactory = createMediaQueryFactory(MODULE_EMITTERS);
@@ -1,3 +1,3 @@
1
- import type { ComplexStyleRule } from '../types';
2
- export declare const mediaQueryOutputVanillaExtract: (media: ComplexStyleRule) => Record<string, unknown>;
1
+ import type { SelectorMap, StyleRule } from '../types';
2
+ export declare const mediaQueryOutputVanillaExtract: (media: StyleRule) => SelectorMap;
3
3
  //# sourceMappingURL=vanilla-extract.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"vanilla-extract.d.ts","sourceRoot":"","sources":["../../../../src/mediaQueries/libraryHelpers/vanilla-extract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAEjD,eAAO,MAAM,8BAA8B,GACzC,OAAO,gBAAgB,KACtB,MAAM,CAAC,MAAM,EAAE,OAAO,CAEvB,CAAC"}
1
+ {"version":3,"file":"vanilla-extract.d.ts","sourceRoot":"","sources":["../../../../src/mediaQueries/libraryHelpers/vanilla-extract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAEvD,eAAO,MAAM,8BAA8B,GACzC,OAAO,SAAS,KACf,WAED,CAAC"}
@@ -1,6 +1,7 @@
1
1
  import type { IMeasurement } from "../core";
2
2
  import type { ComplexStyleRule, StyleRule } from "./types";
3
3
  import type { MediaQueryBuilderHelpers } from "./helpers";
4
+ import { type MediaQueryValidation } from "./validation";
4
5
  import { IMediaQueryCustomFeatures, IMediaQueryDimensions, IMediaQueryDisplay, IMediaQueryEnvironment, IMediaQueryInteraction, IMediaQueryPreferences, IMediaQueryResolutionRange } from "./modules";
5
6
  export interface IMediaQueryProps extends IMediaQueryCore, IMediaQueryDimensions, IMediaQueryResolutionRange, IMediaQueryInteraction, IMediaQueryPreferences, IMediaQueryDisplay, IMediaQueryEnvironment, IMediaQueryCustomFeatures {
6
7
  }
@@ -15,6 +16,7 @@ export interface IMediaQuery {
15
16
  }
16
17
  export type IMediaQueries = Record<string, IMediaQueryProps>;
17
18
  export type IMediaQueryStyles<T extends IMediaQueries> = Partial<Record<keyof T, StyleRule>>;
19
+ export declare const createEmitCoreFeatures: (validation: MediaQueryValidation) => (props: IMediaQueryCore, helpers: MediaQueryBuilderHelpers) => void;
18
20
  export declare const emitCoreFeatures: (props: IMediaQueryCore, helpers: MediaQueryBuilderHelpers) => void;
19
21
  export declare const buildMediaQueryString: (config: IMediaQueryProps) => string;
20
22
  export declare const makeMediaQueryStyle: <T extends IMediaQueries>(queries: T) => (stylesByQuery: IMediaQueryStyles<T>) => ComplexStyleRule;
@@ -1 +1 @@
1
- {"version":3,"file":"mediaQueries.d.ts","sourceRoot":"","sources":["../../../src/mediaQueries/mediaQueries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,KAAK,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAC3D,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AAO1D,OAAO,EAQL,yBAAyB,EACzB,qBAAqB,EACrB,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,sBAAsB,EACtB,0BAA0B,EAC3B,MAAM,WAAW,CAAC;AAEnB,MAAM,WAAW,gBACf,SAAQ,eAAe,EACrB,qBAAqB,EACrB,0BAA0B,EAC1B,sBAAsB,EACtB,sBAAsB,EACtB,kBAAkB,EAClB,sBAAsB,EACtB,yBAAyB;CAAG;AAEhC,MAAM,WAAW,eAAe;IAC9B,IAAI,CAAC,EAAE,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAC;IAClC,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,QAAQ,CAAC,EAAE,YAAY,CAAC;CACzB;AAED,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,gBAAgB,CAAC;IACxB,MAAM,EAAE,SAAS,CAAC;CACnB;AAED,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;AAE7D,MAAM,MAAM,iBAAiB,CAAC,CAAC,SAAS,aAAa,IAAI,OAAO,CAC9D,MAAM,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC,CAC3B,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAC3B,OAAO,eAAe,EACtB,SAAS,wBAAwB,KAChC,IA+BF,CAAC;AAgBF,eAAO,MAAM,qBAAqB,sCAGhC,CAAC;AAEH,eA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,oBAAoB,MAEhC,OAAO,eAAe,EACtB,SAAS,wBAAwB,KAChC,IAqCF,CAAC;AAEF,eAAO,MAAM,gBAAgB,UAzCpB,eAAe,WACb,wBAAwB,KAChC,IAyCF,CAAC;AAgBF,eAAO,MAAM,qBAAqB,sCAGhC,CAAC;AAEH,eAAO,MAAM,mBAAmB,GAC7B,CAAC,SAAS,aAAa,EAAE,SAAS,CAAC,MACnC,eAAe,iBAAiB,CAAC,CAAC,CAAC,KAAG,gBActC,CAAC"}
@@ -1,7 +1,8 @@
1
1
  import { createMediaQueryBuilder } from "./helpers";
2
- import { runMediaQueryValidation, validateMinMaxWidth, validateWidthValuesPositive, } from "./validation";
2
+ import { defaultMediaQueryValidation, } from "./validation";
3
3
  import { emitCustomFeatures, emitDimensionsFeatures, emitDisplayFeatures, emitEnvironmentFeatures, emitInteractionFeatures, emitPreferencesFeatures, emitResolutionFeatures, } from "./modules";
4
- export const emitCoreFeatures = (props, helpers) => {
4
+ export const createEmitCoreFeatures = (validation) => (props, helpers) => {
5
+ const { runMediaQueryValidation, validateMinMaxWidth, validateWidthValuesPositive, } = validation;
5
6
  if (!runMediaQueryValidation(props, helpers, validateMinMaxWidth, "core", "minWidth must be less than or equal to maxWidth")) {
6
7
  return;
7
8
  }
@@ -16,6 +17,7 @@ export const emitCoreFeatures = (props, helpers) => {
16
17
  addFeature("max-width", props.maxWidth);
17
18
  }
18
19
  };
20
+ export const emitCoreFeatures = createEmitCoreFeatures(defaultMediaQueryValidation);
19
21
  const emitBaseFeatures = (props, helpers) => {
20
22
  emitCoreFeatures(props, helpers);
21
23
  emitDimensionsFeatures(props, helpers);
@@ -1,5 +1,6 @@
1
1
  import type { IMeasurement } from '../../core';
2
2
  import type { MediaQueryBuilderHelpers, MediaQueryValidator } from '../helpers';
3
+ import { type MediaQueryValidation } from '../validation';
3
4
  type MediaQueryRatio = number | string;
4
5
  export interface IMediaQueryDimensions {
5
6
  width?: IMeasurement;
@@ -12,6 +13,7 @@ export interface IMediaQueryDimensions {
12
13
  orientation?: 'landscape' | 'portrait';
13
14
  }
14
15
  export type MediaQueryDimensionsValidator = MediaQueryValidator<IMediaQueryDimensions>;
16
+ export declare const createEmitDimensionsFeatures: (validation: MediaQueryValidation) => (props: IMediaQueryDimensions, helpers: MediaQueryBuilderHelpers, validate?: MediaQueryDimensionsValidator) => void;
15
17
  export declare const emitDimensionsFeatures: (props: IMediaQueryDimensions, helpers: MediaQueryBuilderHelpers, validate?: MediaQueryDimensionsValidator) => void;
16
18
  export {};
17
19
  //# sourceMappingURL=dimensions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"dimensions.d.ts","sourceRoot":"","sources":["../../../../src/mediaQueries/modules/dimensions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,KAAK,EACV,wBAAwB,EACxB,mBAAmB,EACpB,MAAM,YAAY,CAAC;AAgBpB,KAAK,eAAe,GAAG,MAAM,GAAG,MAAM,CAAC;AAEvC,MAAM,WAAW,qBAAqB;IACpC,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB,SAAS,CAAC,EAAE,YAAY,CAAC;IACzB,SAAS,CAAC,EAAE,YAAY,CAAC;IACzB,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,WAAW,CAAC,EAAE,eAAe,CAAC;IAC9B,cAAc,CAAC,EAAE,eAAe,CAAC;IACjC,cAAc,CAAC,EAAE,eAAe,CAAC;IACjC,WAAW,CAAC,EAAE,WAAW,GAAG,UAAU,CAAC;CACxC;AAED,MAAM,MAAM,6BAA6B,GACvC,mBAAmB,CAAC,qBAAqB,CAAC,CAAC;AAE7C,eAAO,MAAM,sBAAsB,GACjC,OAAO,qBAAqB,EAC5B,SAAS,wBAAwB,EACjC,WAAW,6BAA6B,KACvC,IA0GF,CAAC"}
1
+ {"version":3,"file":"dimensions.d.ts","sourceRoot":"","sources":["../../../../src/mediaQueries/modules/dimensions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,KAAK,EACV,wBAAwB,EACxB,mBAAmB,EACpB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAEL,KAAK,oBAAoB,EAC1B,MAAM,eAAe,CAAC;AAOvB,KAAK,eAAe,GAAG,MAAM,GAAG,MAAM,CAAC;AAEvC,MAAM,WAAW,qBAAqB;IACpC,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB,SAAS,CAAC,EAAE,YAAY,CAAC;IACzB,SAAS,CAAC,EAAE,YAAY,CAAC;IACzB,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,WAAW,CAAC,EAAE,eAAe,CAAC;IAC9B,cAAc,CAAC,EAAE,eAAe,CAAC;IACjC,cAAc,CAAC,EAAE,eAAe,CAAC;IACjC,WAAW,CAAC,EAAE,WAAW,GAAG,UAAU,CAAC;CACxC;AAED,MAAM,MAAM,6BAA6B,GACvC,mBAAmB,CAAC,qBAAqB,CAAC,CAAC;AAE7C,eAAO,MAAM,4BAA4B,GACvC,YAAY,oBAAoB,MAEhC,OAAO,qBAAqB,EAC5B,SAAS,wBAAwB,EACjC,WAAW,6BAA6B,KACvC,IAmHF,CAAC;AAEF,eAAO,MAAM,sBAAsB,UAxH1B,qBAAqB,WACnB,wBAAwB,aACtB,6BAA6B,KACvC,IAuHF,CAAC"}
@@ -1,8 +1,9 @@
1
1
  import { applyMediaQueryValidation } from '../helpers';
2
- import { runMediaQueryValidation, validateAspectRatioValuesPositive, validateHeightValuesPositive, validateMinMaxAspectRatio, validateMinMaxHeight, validateWidthValuesPositive, } from '../validation';
2
+ import { defaultMediaQueryValidation, } from '../validation';
3
3
  import { runMediaQueryLint } from '../linting';
4
4
  import { lintHeightRedundancy, lintWidthRedundancy, } from '../linting/core';
5
- export const emitDimensionsFeatures = (props, helpers, validate) => {
5
+ export const createEmitDimensionsFeatures = (validation) => (props, helpers, validate) => {
6
+ const { runMediaQueryValidation, validateMinMaxHeight, validateHeightValuesPositive, validateMinMaxAspectRatio, validateAspectRatioValuesPositive, validateWidthValuesPositive, } = validation;
6
7
  if (!runMediaQueryValidation(props, helpers, validateMinMaxHeight, 'dimensions', 'minHeight must be less than or equal to maxHeight')) {
7
8
  return;
8
9
  }
@@ -53,3 +54,4 @@ export const emitDimensionsFeatures = (props, helpers, validate) => {
53
54
  addFeature('orientation', props.orientation);
54
55
  }
55
56
  };
57
+ export const emitDimensionsFeatures = createEmitDimensionsFeatures(defaultMediaQueryValidation);
@@ -1,10 +1,12 @@
1
1
  import type { IMeasurement } from '../../core';
2
2
  import type { MediaQueryBuilderHelpers, MediaQueryValidator } from '../helpers';
3
+ import { type MediaQueryValidation } from '../validation';
3
4
  export interface IMediaQueryResolutionRange {
4
5
  minResolution?: IMeasurement;
5
6
  maxResolution?: IMeasurement;
6
7
  resolutionValue?: IMeasurement;
7
8
  }
8
9
  export type MediaQueryResolutionValidator = MediaQueryValidator<IMediaQueryResolutionRange>;
10
+ export declare const createEmitResolutionFeatures: (validation: MediaQueryValidation) => (props: IMediaQueryResolutionRange, helpers: MediaQueryBuilderHelpers, validate?: MediaQueryResolutionValidator) => void;
9
11
  export declare const emitResolutionFeatures: (props: IMediaQueryResolutionRange, helpers: MediaQueryBuilderHelpers, validate?: MediaQueryResolutionValidator) => void;
10
12
  //# sourceMappingURL=resolution.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"resolution.d.ts","sourceRoot":"","sources":["../../../../src/mediaQueries/modules/resolution.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,KAAK,EACV,wBAAwB,EACxB,mBAAmB,EACpB,MAAM,YAAY,CAAC;AAMpB,MAAM,WAAW,0BAA0B;IACzC,aAAa,CAAC,EAAE,YAAY,CAAC;IAC7B,aAAa,CAAC,EAAE,YAAY,CAAC;IAC7B,eAAe,CAAC,EAAE,YAAY,CAAC;CAChC;AAED,MAAM,MAAM,6BAA6B,GACvC,mBAAmB,CAAC,0BAA0B,CAAC,CAAC;AAElD,eAAO,MAAM,sBAAsB,GACjC,OAAO,0BAA0B,EACjC,SAAS,wBAAwB,EACjC,WAAW,6BAA6B,KACvC,IAqCF,CAAC"}
1
+ {"version":3,"file":"resolution.d.ts","sourceRoot":"","sources":["../../../../src/mediaQueries/modules/resolution.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,KAAK,EACV,wBAAwB,EACxB,mBAAmB,EACpB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAEL,KAAK,oBAAoB,EAC1B,MAAM,eAAe,CAAC;AAIvB,MAAM,WAAW,0BAA0B;IACzC,aAAa,CAAC,EAAE,YAAY,CAAC;IAC7B,aAAa,CAAC,EAAE,YAAY,CAAC;IAC7B,eAAe,CAAC,EAAE,YAAY,CAAC;CAChC;AAED,MAAM,MAAM,6BAA6B,GACvC,mBAAmB,CAAC,0BAA0B,CAAC,CAAC;AAElD,eAAO,MAAM,4BAA4B,GACvC,YAAY,oBAAoB,MAEhC,OAAO,0BAA0B,EACjC,SAAS,wBAAwB,EACjC,WAAW,6BAA6B,KACvC,IAwCF,CAAC;AAEF,eAAO,MAAM,sBAAsB,UA7C1B,0BAA0B,WACxB,wBAAwB,aACtB,6BAA6B,KACvC,IA4CF,CAAC"}
@@ -1,8 +1,9 @@
1
1
  import { applyMediaQueryValidation } from '../helpers';
2
- import { runMediaQueryValidation, validateResolutionValues } from '../validation';
2
+ import { defaultMediaQueryValidation, } from '../validation';
3
3
  import { runMediaQueryLint } from '../linting';
4
4
  import { lintResolutionRedundancy } from '../linting/resolution';
5
- export const emitResolutionFeatures = (props, helpers, validate) => {
5
+ export const createEmitResolutionFeatures = (validation) => (props, helpers, validate) => {
6
+ const { runMediaQueryValidation, validateResolutionValues } = validation;
6
7
  if (!runMediaQueryValidation(props, helpers, validateResolutionValues, 'resolution', 'resolution values must be greater than 0')) {
7
8
  return;
8
9
  }
@@ -23,3 +24,4 @@ export const emitResolutionFeatures = (props, helpers, validate) => {
23
24
  addFeature('max-resolution', props.maxResolution);
24
25
  }
25
26
  };
27
+ export const emitResolutionFeatures = createEmitResolutionFeatures(defaultMediaQueryValidation);
@@ -1,14 +1,34 @@
1
1
  import type { MediaQueryBuilderHelpers } from './helpers';
2
+ import { assertCondition, assertMatchingUnits } from '../core';
2
3
  import type { IMediaQueryCore } from './mediaQueries';
3
4
  import type { IMediaQueryDimensions } from './modules/dimensions';
4
5
  import type { IMediaQueryResolutionRange } from './modules/resolution';
5
6
  export type MediaQueryValidationCheck<TConfig> = (config: TConfig) => void;
6
- export declare const runMediaQueryValidation: <TConfig>(config: TConfig, helpers: MediaQueryBuilderHelpers, check?: MediaQueryValidationCheck<TConfig>, context?: string, fallbackMessage?: string) => boolean;
7
- export declare const validateMinMaxWidth: (props: IMediaQueryCore) => void;
8
- export declare const validateWidthValuesPositive: (props: IMediaQueryCore & IMediaQueryDimensions) => void;
9
- export declare const validateMinMaxHeight: (props: IMediaQueryDimensions) => void;
10
- export declare const validateHeightValuesPositive: (props: IMediaQueryDimensions) => void;
11
- export declare const validateMinMaxAspectRatio: (props: IMediaQueryDimensions) => void;
12
- export declare const validateAspectRatioValuesPositive: (props: IMediaQueryDimensions) => void;
13
- export declare const validateResolutionValues: (props: IMediaQueryResolutionRange) => void;
7
+ export type MediaQueryCoreHelpers = {
8
+ assertCondition: typeof assertCondition;
9
+ assertMatchingUnits: typeof assertMatchingUnits;
10
+ };
11
+ export type MediaQueryValidation = ReturnType<typeof createMediaQueryValidation>;
12
+ export declare const createMediaQueryValidation: (core: MediaQueryCoreHelpers) => {
13
+ runMediaQueryValidation: <TConfig>(config: TConfig, helpers: MediaQueryBuilderHelpers, check?: MediaQueryValidationCheck<TConfig>, context?: string, fallbackMessage?: string) => boolean;
14
+ validateMinMaxWidth: (props: IMediaQueryCore) => void;
15
+ validateWidthValuesPositive: (props: IMediaQueryCore & IMediaQueryDimensions) => void;
16
+ validateMinMaxHeight: (props: IMediaQueryDimensions) => void;
17
+ validateHeightValuesPositive: (props: IMediaQueryDimensions) => void;
18
+ validateMinMaxAspectRatio: (props: IMediaQueryDimensions) => void;
19
+ validateAspectRatioValuesPositive: (props: IMediaQueryDimensions) => void;
20
+ validateResolutionValues: (props: IMediaQueryResolutionRange) => void;
21
+ };
22
+ declare const defaultMediaQueryValidation: {
23
+ runMediaQueryValidation: <TConfig>(config: TConfig, helpers: MediaQueryBuilderHelpers, check?: MediaQueryValidationCheck<TConfig>, context?: string, fallbackMessage?: string) => boolean;
24
+ validateMinMaxWidth: (props: IMediaQueryCore) => void;
25
+ validateWidthValuesPositive: (props: IMediaQueryCore & IMediaQueryDimensions) => void;
26
+ validateMinMaxHeight: (props: IMediaQueryDimensions) => void;
27
+ validateHeightValuesPositive: (props: IMediaQueryDimensions) => void;
28
+ validateMinMaxAspectRatio: (props: IMediaQueryDimensions) => void;
29
+ validateAspectRatioValuesPositive: (props: IMediaQueryDimensions) => void;
30
+ validateResolutionValues: (props: IMediaQueryResolutionRange) => void;
31
+ };
32
+ export declare const runMediaQueryValidation: <TConfig>(config: TConfig, helpers: MediaQueryBuilderHelpers, check?: MediaQueryValidationCheck<TConfig>, context?: string, fallbackMessage?: string) => boolean, validateMinMaxWidth: (props: IMediaQueryCore) => void, validateWidthValuesPositive: (props: IMediaQueryCore & IMediaQueryDimensions) => void, validateMinMaxHeight: (props: IMediaQueryDimensions) => void, validateHeightValuesPositive: (props: IMediaQueryDimensions) => void, validateMinMaxAspectRatio: (props: IMediaQueryDimensions) => void, validateAspectRatioValuesPositive: (props: IMediaQueryDimensions) => void, validateResolutionValues: (props: IMediaQueryResolutionRange) => void;
33
+ export { defaultMediaQueryValidation };
14
34
  //# sourceMappingURL=validation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../../src/mediaQueries/validation.ts"],"names":[],"mappings":"AAAA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BAEf,OAAO,EAqNV,mBAAmB,UArMiB,eAAe,KAAG,IAAI,EAsM1D,2BAA2B,UAxLlB,eAAe,GAAG,qBAAqB,KAC7C,IAAI,EAwLP,oBAAoB,UAjKX,qBAAqB,KAC3B,IAAI,EAiKP,4BAA4B,UAnJnB,qBAAqB,KAC3B,IAAI,EAmJP,yBAAyB,UAtGhB,qBAAqB,KAC3B,IAAI,EAsGP,iCAAiC,UAvFxB,qBAAqB,KAC3B,IAAI,EAuFP,wBAAwB,UAvDf,0BAA0B,KAChC,IAuD0B,CAAC;AAEhC,OAAO,EAAE,2BAA2B,EAAE,CAAC"}
@@ -5,118 +5,137 @@ const toValidationResult = (error, fallback) => {
5
5
  return error.message;
6
6
  return fallback;
7
7
  };
8
- export const runMediaQueryValidation = (config, helpers, check, context, fallbackMessage = 'Invalid media query configuration') => {
9
- if (!check)
10
- return true;
11
- try {
12
- check(config);
13
- return true;
14
- }
15
- catch (error) {
16
- const result = toValidationResult(error, fallbackMessage);
17
- return applyMediaQueryValidation(config, helpers, () => result, context);
18
- }
19
- };
20
- export const validateMinMaxWidth = (props) => {
21
- if (!props.minWidth || !props.maxWidth)
22
- return;
23
- assertMatchingUnits(props.minWidth, props.maxWidth, 'mediaQueries.minMaxWidth');
24
- assertCondition(props.minWidth.getValue() <= props.maxWidth.getValue(), 'minWidth must be less than or equal to maxWidth');
25
- };
26
- export const validateWidthValuesPositive = (props) => {
27
- const assertPositive = (value, label) => {
28
- assertCondition(value.getValue() > 0, `${label} must be greater than 0`);
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
+ }
29
21
  };
30
- if (props.width) {
31
- assertPositive(props.width, 'width');
32
- }
33
- if (props.minWidth) {
34
- assertPositive(props.minWidth, 'minWidth');
35
- }
36
- if (props.maxWidth) {
37
- assertPositive(props.maxWidth, 'maxWidth');
38
- }
39
- };
40
- export const validateMinMaxHeight = (props) => {
41
- if (!props.minHeight || !props.maxHeight)
42
- return;
43
- assertMatchingUnits(props.minHeight, props.maxHeight, 'mediaQueries.minMaxHeight');
44
- assertCondition(props.minHeight.getValue() <= props.maxHeight.getValue(), 'minHeight must be less than or equal to maxHeight');
45
- };
46
- export const validateHeightValuesPositive = (props) => {
47
- const assertPositive = (value, label) => {
48
- assertCondition(value.getValue() > 0, `${label} must be greater than 0`);
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');
49
27
  };
50
- if (props.height) {
51
- assertPositive(props.height, 'height');
52
- }
53
- if (props.minHeight) {
54
- assertPositive(props.minHeight, 'minHeight');
55
- }
56
- if (props.maxHeight) {
57
- assertPositive(props.maxHeight, 'maxHeight');
58
- }
59
- };
60
- const parseAspectRatio = (value) => {
61
- if (value === undefined || value === null)
62
- return null;
63
- if (typeof value === 'number')
64
- return Number.isFinite(value) ? value : null;
65
- const trimmed = value.trim();
66
- if (!trimmed)
67
- return null;
68
- if (trimmed.includes('/')) {
69
- const [left, right] = trimmed.split('/');
70
- if (left === undefined || right === undefined)
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 parseAspectRatio = (value) => {
63
+ if (value === undefined || value === null)
71
64
  return null;
72
- const numerator = Number(left.trim());
73
- const denominator = Number(right.trim());
74
- if (!Number.isFinite(numerator) || !Number.isFinite(denominator)) {
65
+ if (typeof value === 'number')
66
+ return Number.isFinite(value) ? value : null;
67
+ const trimmed = value.trim();
68
+ if (!trimmed)
75
69
  return null;
70
+ if (trimmed.includes('/')) {
71
+ const [left, right] = trimmed.split('/');
72
+ if (left === undefined || right === undefined)
73
+ return null;
74
+ const numerator = Number(left.trim());
75
+ const denominator = Number(right.trim());
76
+ if (!Number.isFinite(numerator) || !Number.isFinite(denominator)) {
77
+ return null;
78
+ }
79
+ if (denominator === 0)
80
+ return null;
81
+ return numerator / denominator;
76
82
  }
77
- if (denominator === 0)
78
- return null;
79
- return numerator / denominator;
80
- }
81
- const parsed = Number(trimmed);
82
- return Number.isFinite(parsed) ? parsed : null;
83
- };
84
- export const validateMinMaxAspectRatio = (props) => {
85
- if (!props.minAspectRatio || !props.maxAspectRatio)
86
- return;
87
- const minRatio = parseAspectRatio(props.minAspectRatio);
88
- const maxRatio = parseAspectRatio(props.maxAspectRatio);
89
- assertCondition(minRatio !== null && maxRatio !== null, 'aspectRatio values must be valid numbers or ratio strings');
90
- assertCondition(minRatio <= maxRatio, 'minAspectRatio must be less than or equal to maxAspectRatio');
91
- };
92
- export const validateAspectRatioValuesPositive = (props) => {
93
- const assertValidPositive = (label, value) => {
94
- assertCondition(value !== null && value > 0, `${label} must be a valid ratio greater than 0`);
83
+ const parsed = Number(trimmed);
84
+ return Number.isFinite(parsed) ? parsed : null;
95
85
  };
96
- if (props.aspectRatio !== undefined) {
97
- assertValidPositive('aspectRatio', parseAspectRatio(props.aspectRatio));
98
- }
99
- if (props.minAspectRatio !== undefined) {
100
- assertValidPositive('minAspectRatio', parseAspectRatio(props.minAspectRatio));
101
- }
102
- if (props.maxAspectRatio !== undefined) {
103
- assertValidPositive('maxAspectRatio', parseAspectRatio(props.maxAspectRatio));
104
- }
105
- };
106
- export const validateResolutionValues = (props) => {
107
- const assertPositive = (value, label) => {
108
- assertCondition(value.getValue() > 0, `${label} must be greater than 0`);
86
+ const validateMinMaxAspectRatio = (props) => {
87
+ if (!props.minAspectRatio || !props.maxAspectRatio)
88
+ return;
89
+ const minRatio = parseAspectRatio(props.minAspectRatio);
90
+ const maxRatio = parseAspectRatio(props.maxAspectRatio);
91
+ assertCondition(minRatio !== null && maxRatio !== null, 'aspectRatio values must be valid numbers or ratio strings');
92
+ assertCondition(minRatio <= maxRatio, 'minAspectRatio must be less than or equal to maxAspectRatio');
93
+ };
94
+ const validateAspectRatioValuesPositive = (props) => {
95
+ const assertValidPositive = (label, value) => {
96
+ assertCondition(value !== null && value > 0, `${label} must be a valid ratio greater than 0`);
97
+ };
98
+ if (props.aspectRatio !== undefined) {
99
+ assertValidPositive('aspectRatio', parseAspectRatio(props.aspectRatio));
100
+ }
101
+ if (props.minAspectRatio !== undefined) {
102
+ assertValidPositive('minAspectRatio', parseAspectRatio(props.minAspectRatio));
103
+ }
104
+ if (props.maxAspectRatio !== undefined) {
105
+ assertValidPositive('maxAspectRatio', parseAspectRatio(props.maxAspectRatio));
106
+ }
107
+ };
108
+ const validateResolutionValues = (props) => {
109
+ const assertPositive = (value, label) => {
110
+ assertCondition(value.getValue() > 0, `${label} must be greater than 0`);
111
+ };
112
+ if (props.resolutionValue) {
113
+ assertPositive(props.resolutionValue, 'resolution');
114
+ }
115
+ if (props.minResolution) {
116
+ assertPositive(props.minResolution, 'minResolution');
117
+ }
118
+ if (props.maxResolution) {
119
+ assertPositive(props.maxResolution, 'maxResolution');
120
+ }
121
+ if (props.minResolution && props.maxResolution) {
122
+ assertMatchingUnits(props.minResolution, props.maxResolution, 'mediaQueries.resolutionUnits');
123
+ }
124
+ };
125
+ return {
126
+ runMediaQueryValidation,
127
+ validateMinMaxWidth,
128
+ validateWidthValuesPositive,
129
+ validateMinMaxHeight,
130
+ validateHeightValuesPositive,
131
+ validateMinMaxAspectRatio,
132
+ validateAspectRatioValuesPositive,
133
+ validateResolutionValues,
109
134
  };
110
- if (props.resolutionValue) {
111
- assertPositive(props.resolutionValue, 'resolution');
112
- }
113
- if (props.minResolution) {
114
- assertPositive(props.minResolution, 'minResolution');
115
- }
116
- if (props.maxResolution) {
117
- assertPositive(props.maxResolution, 'maxResolution');
118
- }
119
- if (props.minResolution && props.maxResolution) {
120
- assertMatchingUnits(props.minResolution, props.maxResolution, 'mediaQueries.resolutionUnits');
121
- }
122
135
  };
136
+ const defaultMediaQueryValidation = createMediaQueryValidation({
137
+ assertCondition,
138
+ assertMatchingUnits,
139
+ });
140
+ export const { runMediaQueryValidation, validateMinMaxWidth, validateWidthValuesPositive, validateMinMaxHeight, validateHeightValuesPositive, validateMinMaxAspectRatio, validateAspectRatioValuesPositive, validateResolutionValues, } = defaultMediaQueryValidation;
141
+ export { defaultMediaQueryValidation };
@@ -0,0 +1,22 @@
1
+ export interface IRatio {
2
+ css: () => string;
3
+ toString: () => string;
4
+ valueOf: () => number;
5
+ numerator: () => number;
6
+ denominator: () => number;
7
+ withNumerator: (numerator: number) => IRatio;
8
+ withDenominator: (denominator: number) => IRatio;
9
+ }
10
+ export type RatioParts = {
11
+ numerator: number;
12
+ denominator: number;
13
+ };
14
+ export declare function r(denominator: number): IRatio;
15
+ export declare function r(numerator: number, denominator: number): IRatio;
16
+ export declare const isRatio: (value: unknown) => value is IRatio;
17
+ export declare const parseRatio: (value: number | string | IRatio) => RatioParts | null;
18
+ export declare const normalizeRatio: (ratio: IRatio) => IRatio;
19
+ export declare const reduceRatio: (ratio: IRatio) => IRatio;
20
+ export declare const simplifyRatio: (ratio: IRatio) => IRatio;
21
+ export declare const ratioToFloat: (ratio: IRatio) => number;
22
+ //# sourceMappingURL=ratio.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ratio.d.ts","sourceRoot":"","sources":["../../src/ratio.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,MAAM;IACrB,GAAG,EAAE,MAAM,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,MAAM,CAAC;IAC1B,aAAa,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,CAAC;IAC7C,eAAe,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,MAAM,CAAC;CAClD;AAED,MAAM,MAAM,UAAU,GAAG;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAuDF,wBAAgB,CAAC,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAAC;AAC/C,wBAAgB,CAAC,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAAC;AAWlE,eAAO,MAAM,OAAO,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,MAWjD,CAAC;AAEF,eAAO,MAAM,UAAU,GACrB,OAAO,MAAM,GAAG,MAAM,GAAG,MAAM,KAC9B,UAAU,GAAG,IAqBf,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,OAAO,MAAM,KAAG,MAiC9C,CAAC;AAEF,eAAO,MAAM,WAAW,GAAI,OAAO,MAAM,KAAG,MAA+B,CAAC;AAC5E,eAAO,MAAM,aAAa,GAAI,OAAO,MAAM,KAAG,MAK7C,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,OAAO,MAAM,KAAG,MACJ,CAAC"}