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.
- package/README.md +21 -25
- package/dist/cjs/factory.js +0 -3
- package/dist/cjs/internal/createCoreApi.js +30 -9
- package/dist/esm/core.d.ts +21 -17
- package/dist/esm/core.d.ts.map +1 -1
- package/dist/esm/factory.d.ts +0 -2
- package/dist/esm/factory.d.ts.map +1 -1
- package/dist/esm/factory.js +0 -3
- package/dist/esm/internal/createCoreApi.d.ts +7 -11
- package/dist/esm/internal/createCoreApi.d.ts.map +1 -1
- package/dist/esm/internal/createCoreApi.js +30 -9
- package/package.json +11 -24
- package/RELEASING.md +0 -62
- package/dist/cjs/comparisons/index.js +0 -25
- package/dist/cjs/containerQueries/containerQueries.js +0 -115
- package/dist/cjs/containerQueries/factory.js +0 -123
- package/dist/cjs/containerQueries/helpers.js +0 -95
- package/dist/cjs/containerQueries/index.js +0 -16
- package/dist/cjs/containerQueries/linting/aspectRatio.js +0 -24
- package/dist/cjs/containerQueries/linting/block.js +0 -23
- package/dist/cjs/containerQueries/linting/core.js +0 -25
- package/dist/cjs/containerQueries/linting/custom.js +0 -11
- package/dist/cjs/containerQueries/linting/inline.js +0 -23
- package/dist/cjs/containerQueries/linting/resolution.js +0 -12
- package/dist/cjs/containerQueries/linting/style.js +0 -28
- package/dist/cjs/containerQueries/linting.js +0 -24
- package/dist/cjs/containerQueries/moduleRegistry.js +0 -5
- package/dist/cjs/containerQueries/modules/aspectRatio.js +0 -51
- package/dist/cjs/containerQueries/modules/block.js +0 -53
- package/dist/cjs/containerQueries/modules/custom.js +0 -43
- package/dist/cjs/containerQueries/modules/index.js +0 -21
- package/dist/cjs/containerQueries/modules/inline.js +0 -53
- package/dist/cjs/containerQueries/modules/size.js +0 -2
- package/dist/cjs/containerQueries/modules/style.js +0 -36
- package/dist/cjs/containerQueries/types.js +0 -2
- package/dist/cjs/containerQueries/validation.js +0 -191
- package/dist/cjs/fraction.js +0 -139
- package/dist/cjs/internal/createComponentQueriesApi.js +0 -56
- package/dist/cjs/internal/createMediaQueriesApi.js +0 -74
- package/dist/cjs/internal/normalizeToArray.js +0 -9
- package/dist/cjs/libraryHelpers/vanilla-extract.js +0 -11
- package/dist/cjs/logicalOperators/index.js +0 -18
- package/dist/cjs/mediaQueries/factory.js +0 -187
- package/dist/cjs/mediaQueries/helpers.js +0 -97
- package/dist/cjs/mediaQueries/index.js +0 -23
- package/dist/cjs/mediaQueries/libraryHelpers/vanilla-extract.js +0 -77
- package/dist/cjs/mediaQueries/linting/core.js +0 -19
- package/dist/cjs/mediaQueries/linting/resolution.js +0 -11
- package/dist/cjs/mediaQueries/linting.js +0 -24
- package/dist/cjs/mediaQueries/mediaQueries.js +0 -53
- package/dist/cjs/mediaQueries/mediaQueryFactory.js +0 -120
- package/dist/cjs/mediaQueries/moduleRegistry.js +0 -5
- package/dist/cjs/mediaQueries/modules/custom.js +0 -26
- package/dist/cjs/mediaQueries/modules/dimensions.js +0 -61
- package/dist/cjs/mediaQueries/modules/display.js +0 -20
- package/dist/cjs/mediaQueries/modules/environment.js +0 -20
- package/dist/cjs/mediaQueries/modules/index.js +0 -23
- package/dist/cjs/mediaQueries/modules/interaction.js +0 -26
- package/dist/cjs/mediaQueries/modules/preferences.js +0 -26
- package/dist/cjs/mediaQueries/modules/resolution.js +0 -31
- package/dist/cjs/mediaQueries/types.js +0 -2
- package/dist/cjs/mediaQueries/validation.js +0 -131
- package/dist/cjs/types.js +0 -2
- package/dist/cjs/validation.js +0 -20
- package/dist/esm/comparisons/index.d.ts +0 -23
- package/dist/esm/comparisons/index.d.ts.map +0 -1
- package/dist/esm/comparisons/index.js +0 -22
- package/dist/esm/containerQueries/containerQueries.d.ts +0 -36
- package/dist/esm/containerQueries/containerQueries.d.ts.map +0 -1
- package/dist/esm/containerQueries/containerQueries.js +0 -109
- package/dist/esm/containerQueries/factory.d.ts +0 -20
- package/dist/esm/containerQueries/factory.d.ts.map +0 -1
- package/dist/esm/containerQueries/factory.js +0 -119
- package/dist/esm/containerQueries/helpers.d.ts +0 -53
- package/dist/esm/containerQueries/helpers.d.ts.map +0 -1
- package/dist/esm/containerQueries/helpers.js +0 -82
- package/dist/esm/containerQueries/index.d.ts +0 -10
- package/dist/esm/containerQueries/index.d.ts.map +0 -1
- package/dist/esm/containerQueries/index.js +0 -4
- package/dist/esm/containerQueries/linting/aspectRatio.d.ts +0 -4
- package/dist/esm/containerQueries/linting/aspectRatio.d.ts.map +0 -1
- package/dist/esm/containerQueries/linting/aspectRatio.js +0 -19
- package/dist/esm/containerQueries/linting/block.d.ts +0 -4
- package/dist/esm/containerQueries/linting/block.d.ts.map +0 -1
- package/dist/esm/containerQueries/linting/block.js +0 -18
- package/dist/esm/containerQueries/linting/core.d.ts +0 -4
- package/dist/esm/containerQueries/linting/core.d.ts.map +0 -1
- package/dist/esm/containerQueries/linting/core.js +0 -20
- package/dist/esm/containerQueries/linting/custom.d.ts +0 -3
- package/dist/esm/containerQueries/linting/custom.d.ts.map +0 -1
- package/dist/esm/containerQueries/linting/custom.js +0 -7
- package/dist/esm/containerQueries/linting/inline.d.ts +0 -4
- package/dist/esm/containerQueries/linting/inline.d.ts.map +0 -1
- package/dist/esm/containerQueries/linting/inline.js +0 -18
- package/dist/esm/containerQueries/linting/resolution.d.ts +0 -1
- package/dist/esm/containerQueries/linting/resolution.d.ts.map +0 -1
- package/dist/esm/containerQueries/linting/resolution.js +0 -12
- package/dist/esm/containerQueries/linting/style.d.ts +0 -3
- package/dist/esm/containerQueries/linting/style.d.ts.map +0 -1
- package/dist/esm/containerQueries/linting/style.js +0 -24
- package/dist/esm/containerQueries/linting.d.ts +0 -4
- package/dist/esm/containerQueries/linting.d.ts.map +0 -1
- package/dist/esm/containerQueries/linting.js +0 -20
- package/dist/esm/containerQueries/moduleRegistry.d.ts +0 -25
- package/dist/esm/containerQueries/moduleRegistry.d.ts.map +0 -1
- package/dist/esm/containerQueries/moduleRegistry.js +0 -1
- package/dist/esm/containerQueries/modules/aspectRatio.d.ts +0 -17
- package/dist/esm/containerQueries/modules/aspectRatio.d.ts.map +0 -1
- package/dist/esm/containerQueries/modules/aspectRatio.js +0 -47
- package/dist/esm/containerQueries/modules/block.d.ts +0 -20
- package/dist/esm/containerQueries/modules/block.d.ts.map +0 -1
- package/dist/esm/containerQueries/modules/block.js +0 -49
- package/dist/esm/containerQueries/modules/custom.d.ts +0 -13
- package/dist/esm/containerQueries/modules/custom.d.ts.map +0 -1
- package/dist/esm/containerQueries/modules/custom.js +0 -39
- package/dist/esm/containerQueries/modules/index.d.ts +0 -6
- package/dist/esm/containerQueries/modules/index.d.ts.map +0 -1
- package/dist/esm/containerQueries/modules/index.js +0 -5
- package/dist/esm/containerQueries/modules/inline.d.ts +0 -20
- package/dist/esm/containerQueries/modules/inline.d.ts.map +0 -1
- package/dist/esm/containerQueries/modules/inline.js +0 -49
- package/dist/esm/containerQueries/modules/size.d.ts +0 -41
- package/dist/esm/containerQueries/modules/size.d.ts.map +0 -1
- package/dist/esm/containerQueries/modules/size.js +0 -1
- package/dist/esm/containerQueries/modules/style.d.ts +0 -11
- package/dist/esm/containerQueries/modules/style.d.ts.map +0 -1
- package/dist/esm/containerQueries/modules/style.js +0 -32
- package/dist/esm/containerQueries/types.d.ts +0 -81
- package/dist/esm/containerQueries/types.d.ts.map +0 -1
- package/dist/esm/containerQueries/types.js +0 -1
- package/dist/esm/containerQueries/validation.d.ts +0 -41
- package/dist/esm/containerQueries/validation.d.ts.map +0 -1
- package/dist/esm/containerQueries/validation.js +0 -187
- package/dist/esm/fraction.d.ts +0 -23
- package/dist/esm/fraction.d.ts.map +0 -1
- package/dist/esm/fraction.js +0 -129
- package/dist/esm/internal/createComponentQueriesApi.d.ts +0 -34
- package/dist/esm/internal/createComponentQueriesApi.d.ts.map +0 -1
- package/dist/esm/internal/createComponentQueriesApi.js +0 -52
- package/dist/esm/internal/createMediaQueriesApi.d.ts +0 -35
- package/dist/esm/internal/createMediaQueriesApi.d.ts.map +0 -1
- package/dist/esm/internal/createMediaQueriesApi.js +0 -70
- package/dist/esm/internal/normalizeToArray.d.ts +0 -2
- package/dist/esm/internal/normalizeToArray.d.ts.map +0 -1
- package/dist/esm/internal/normalizeToArray.js +0 -5
- package/dist/esm/libraryHelpers/vanilla-extract.d.ts +0 -4
- package/dist/esm/libraryHelpers/vanilla-extract.d.ts.map +0 -1
- package/dist/esm/libraryHelpers/vanilla-extract.js +0 -6
- package/dist/esm/logicalOperators/index.d.ts +0 -2
- package/dist/esm/logicalOperators/index.d.ts.map +0 -1
- package/dist/esm/logicalOperators/index.js +0 -17
- package/dist/esm/mediaQueries/factory.d.ts +0 -45
- package/dist/esm/mediaQueries/factory.d.ts.map +0 -1
- package/dist/esm/mediaQueries/factory.js +0 -183
- package/dist/esm/mediaQueries/helpers.d.ts +0 -40
- package/dist/esm/mediaQueries/helpers.d.ts.map +0 -1
- package/dist/esm/mediaQueries/helpers.js +0 -87
- package/dist/esm/mediaQueries/index.d.ts +0 -8
- package/dist/esm/mediaQueries/index.d.ts.map +0 -1
- package/dist/esm/mediaQueries/index.js +0 -7
- package/dist/esm/mediaQueries/libraryHelpers/vanilla-extract.d.ts +0 -5
- package/dist/esm/mediaQueries/libraryHelpers/vanilla-extract.d.ts.map +0 -1
- package/dist/esm/mediaQueries/libraryHelpers/vanilla-extract.js +0 -71
- package/dist/esm/mediaQueries/linting/core.d.ts +0 -5
- package/dist/esm/mediaQueries/linting/core.d.ts.map +0 -1
- package/dist/esm/mediaQueries/linting/core.js +0 -14
- package/dist/esm/mediaQueries/linting/resolution.d.ts +0 -3
- package/dist/esm/mediaQueries/linting/resolution.d.ts.map +0 -1
- package/dist/esm/mediaQueries/linting/resolution.js +0 -7
- package/dist/esm/mediaQueries/linting.d.ts +0 -4
- package/dist/esm/mediaQueries/linting.d.ts.map +0 -1
- package/dist/esm/mediaQueries/linting.js +0 -20
- package/dist/esm/mediaQueries/mediaQueries.d.ts +0 -23
- package/dist/esm/mediaQueries/mediaQueries.d.ts.map +0 -1
- package/dist/esm/mediaQueries/mediaQueries.js +0 -48
- package/dist/esm/mediaQueries/moduleRegistry.d.ts +0 -27
- package/dist/esm/mediaQueries/moduleRegistry.d.ts.map +0 -1
- package/dist/esm/mediaQueries/moduleRegistry.js +0 -1
- package/dist/esm/mediaQueries/modules/custom.d.ts +0 -10
- package/dist/esm/mediaQueries/modules/custom.d.ts.map +0 -1
- package/dist/esm/mediaQueries/modules/custom.js +0 -22
- package/dist/esm/mediaQueries/modules/dimensions.d.ts +0 -19
- package/dist/esm/mediaQueries/modules/dimensions.d.ts.map +0 -1
- package/dist/esm/mediaQueries/modules/dimensions.js +0 -57
- package/dist/esm/mediaQueries/modules/display.d.ts +0 -9
- package/dist/esm/mediaQueries/modules/display.d.ts.map +0 -1
- package/dist/esm/mediaQueries/modules/display.js +0 -16
- package/dist/esm/mediaQueries/modules/environment.d.ts +0 -9
- package/dist/esm/mediaQueries/modules/environment.d.ts.map +0 -1
- package/dist/esm/mediaQueries/modules/environment.js +0 -16
- package/dist/esm/mediaQueries/modules/index.d.ts +0 -8
- package/dist/esm/mediaQueries/modules/index.d.ts.map +0 -1
- package/dist/esm/mediaQueries/modules/index.js +0 -7
- package/dist/esm/mediaQueries/modules/interaction.d.ts +0 -11
- package/dist/esm/mediaQueries/modules/interaction.d.ts.map +0 -1
- package/dist/esm/mediaQueries/modules/interaction.js +0 -22
- package/dist/esm/mediaQueries/modules/preferences.d.ts +0 -11
- package/dist/esm/mediaQueries/modules/preferences.d.ts.map +0 -1
- package/dist/esm/mediaQueries/modules/preferences.js +0 -22
- package/dist/esm/mediaQueries/modules/resolution.d.ts +0 -12
- package/dist/esm/mediaQueries/modules/resolution.d.ts.map +0 -1
- package/dist/esm/mediaQueries/modules/resolution.js +0 -27
- package/dist/esm/mediaQueries/types.d.ts +0 -117
- package/dist/esm/mediaQueries/types.d.ts.map +0 -1
- package/dist/esm/mediaQueries/types.js +0 -1
- package/dist/esm/mediaQueries/validation.d.ts +0 -34
- package/dist/esm/mediaQueries/validation.d.ts.map +0 -1
- package/dist/esm/mediaQueries/validation.js +0 -127
- package/dist/esm/types.d.ts +0 -35
- package/dist/esm/types.d.ts.map +0 -1
- package/dist/esm/types.js +0 -1
- package/dist/esm/validation.d.ts +0 -10
- package/dist/esm/validation.d.ts.map +0 -1
- package/dist/esm/validation.js +0 -15
- package/dist/examples/containerQueries.example.js +0 -54
- package/dist/examples/examples/containerQueries.example.js +0 -54
- package/dist/examples/examples/factory-wrapper.example.js +0 -33
- package/dist/examples/examples/lineHeight-normalizer.example.js +0 -81
- package/dist/examples/examples/mediaQueries-multipleInstances.example.js +0 -127
- package/dist/examples/examples/mixedQueries.example.js +0 -55
- package/dist/examples/examples/validation-and-runtime-checks.example.js +0 -85
- package/dist/examples/examples/validation-unit-tests.example.js +0 -35
- package/dist/examples/factory-wrapper.example.js +0 -33
- package/dist/examples/lineHeight-normalizer.example.js +0 -81
- package/dist/examples/mediaQueries-multipleInstances.example.js +0 -127
- package/dist/examples/mixedQueries.example.js +0 -60
- package/dist/examples/src/comparisons/index.js +0 -25
- package/dist/examples/src/containerQueries/containerQueries.js +0 -96
- package/dist/examples/src/containerQueries/factory.js +0 -123
- package/dist/examples/src/containerQueries/helpers.js +0 -94
- package/dist/examples/src/containerQueries/index.js +0 -16
- package/dist/examples/src/containerQueries/linting/aspectRatio.js +0 -20
- package/dist/examples/src/containerQueries/linting/block.js +0 -20
- package/dist/examples/src/containerQueries/linting/core.js +0 -19
- package/dist/examples/src/containerQueries/linting/custom.js +0 -11
- package/dist/examples/src/containerQueries/linting/inline.js +0 -20
- package/dist/examples/src/containerQueries/linting/style.js +0 -28
- package/dist/examples/src/containerQueries/linting.js +0 -24
- package/dist/examples/src/containerQueries/moduleRegistry.js +0 -5
- package/dist/examples/src/containerQueries/modules/aspectRatio.js +0 -33
- package/dist/examples/src/containerQueries/modules/block.js +0 -44
- package/dist/examples/src/containerQueries/modules/custom.js +0 -31
- package/dist/examples/src/containerQueries/modules/index.js +0 -21
- package/dist/examples/src/containerQueries/modules/inline.js +0 -44
- package/dist/examples/src/containerQueries/modules/style.js +0 -36
- package/dist/examples/src/containerQueries/types.js +0 -2
- package/dist/examples/src/containerQueries/validation.js +0 -177
- package/dist/examples/src/core.js +0 -16
- package/dist/examples/src/factory.js +0 -21
- package/dist/examples/src/index.js +0 -30
- package/dist/examples/src/internal/buildMeasurementCreationError.js +0 -16
- package/dist/examples/src/internal/createCoreApi.js +0 -336
- package/dist/examples/src/internal/createMediaQueriesApi.js +0 -74
- package/dist/examples/src/internal/createUnitsApi.js +0 -18
- package/dist/examples/src/internal/errors.js +0 -130
- package/dist/examples/src/libraryHelpers/vanilla-extract.js +0 -11
- package/dist/examples/src/mediaQueries/factory.js +0 -163
- package/dist/examples/src/mediaQueries/helpers.js +0 -88
- package/dist/examples/src/mediaQueries/index.js +0 -23
- package/dist/examples/src/mediaQueries/linting/core.js +0 -19
- package/dist/examples/src/mediaQueries/linting/resolution.js +0 -11
- package/dist/examples/src/mediaQueries/linting.js +0 -24
- package/dist/examples/src/mediaQueries/mediaQueries.js +0 -53
- package/dist/examples/src/mediaQueries/moduleRegistry.js +0 -5
- package/dist/examples/src/mediaQueries/modules/custom.js +0 -26
- package/dist/examples/src/mediaQueries/modules/dimensions.js +0 -61
- package/dist/examples/src/mediaQueries/modules/display.js +0 -20
- package/dist/examples/src/mediaQueries/modules/environment.js +0 -20
- package/dist/examples/src/mediaQueries/modules/index.js +0 -23
- package/dist/examples/src/mediaQueries/modules/interaction.js +0 -26
- package/dist/examples/src/mediaQueries/modules/preferences.js +0 -26
- package/dist/examples/src/mediaQueries/modules/resolution.js +0 -31
- package/dist/examples/src/mediaQueries/types.js +0 -2
- package/dist/examples/src/mediaQueries/validation.js +0 -128
- package/dist/examples/src/ratio.js +0 -141
- package/dist/examples/src/types.js +0 -2
- package/dist/examples/src/unitDefinitions.js +0 -67
- package/dist/examples/src/units/absolute.js +0 -11
- package/dist/examples/src/units/angle.js +0 -8
- package/dist/examples/src/units/container.js +0 -10
- package/dist/examples/src/units/font-relative.js +0 -16
- package/dist/examples/src/units/frequency.js +0 -6
- package/dist/examples/src/units/grid.js +0 -5
- package/dist/examples/src/units/percent.js +0 -7
- package/dist/examples/src/units/resolution.js +0 -7
- package/dist/examples/src/units/time.js +0 -6
- package/dist/examples/src/units/viewport-dynamic.js +0 -10
- package/dist/examples/src/units/viewport-large.js +0 -10
- package/dist/examples/src/units/viewport-small.js +0 -10
- package/dist/examples/src/units/viewport.js +0 -10
- package/dist/examples/src/validation.js +0 -20
- package/dist/examples/validation-and-runtime-checks.example.js +0 -85
- package/dist/examples/validation-unit-tests.example.js +0 -35
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { buildContainerConditionString } from "./containerQueries";
|
|
2
|
-
const ALL_CONTAINER_QUERY_MODULES = [
|
|
3
|
-
"core",
|
|
4
|
-
"inline",
|
|
5
|
-
"block",
|
|
6
|
-
"aspectRatio",
|
|
7
|
-
"style",
|
|
8
|
-
"custom",
|
|
9
|
-
];
|
|
10
|
-
const MODULE_KEYS = {
|
|
11
|
-
core: ["minWidth", "maxWidth", "minHeight", "maxHeight"],
|
|
12
|
-
inline: ["inlineSize", "inlineSizeRange"],
|
|
13
|
-
block: ["blockSize", "blockSizeRange"],
|
|
14
|
-
aspectRatio: ["aspectRatio", "minAspectRatio", "maxAspectRatio"],
|
|
15
|
-
style: ["style"],
|
|
16
|
-
custom: ["customFeatures"],
|
|
17
|
-
};
|
|
18
|
-
const KEY_TO_MODULE = Object.fromEntries(Object.keys(MODULE_KEYS).flatMap((moduleId) => MODULE_KEYS[moduleId].map((key) => [key, moduleId])));
|
|
19
|
-
const collectConditionKeys = (condition, keys) => {
|
|
20
|
-
if ("and" in condition) {
|
|
21
|
-
condition.and.forEach((entry) => collectConditionKeys(entry, keys));
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
if ("or" in condition) {
|
|
25
|
-
condition.or.forEach((entry) => collectConditionKeys(entry, keys));
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
if ("not" in condition) {
|
|
29
|
-
collectConditionKeys(condition.not, keys);
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
Object.keys(condition).forEach((key) => keys.add(key));
|
|
33
|
-
};
|
|
34
|
-
const collectAndConditionKeys = (condition, keys) => {
|
|
35
|
-
if ("and" in condition) {
|
|
36
|
-
condition.and.forEach((entry) => collectAndConditionKeys(entry, keys));
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
if ("or" in condition || "not" in condition) {
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
Object.keys(condition).forEach((key) => keys.push(key));
|
|
43
|
-
};
|
|
44
|
-
const guardUnsupportedCondition = (condition, modules, config, label) => {
|
|
45
|
-
const allowed = new Set();
|
|
46
|
-
modules.forEach((moduleId) => {
|
|
47
|
-
MODULE_KEYS[moduleId].forEach((key) => {
|
|
48
|
-
allowed.add(key);
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
const conditionKeys = new Set();
|
|
52
|
-
collectConditionKeys(condition, conditionKeys);
|
|
53
|
-
conditionKeys.forEach((key) => {
|
|
54
|
-
var _a, _b;
|
|
55
|
-
if (allowed.has(key))
|
|
56
|
-
return;
|
|
57
|
-
const mode = (_b = (_a = config.errorHandling) === null || _a === void 0 ? void 0 : _a.invalidValueMode) !== null && _b !== void 0 ? _b : "throw";
|
|
58
|
-
const moduleHint = KEY_TO_MODULE[key];
|
|
59
|
-
const moduleSuffix = moduleHint
|
|
60
|
-
? ` Add "${moduleHint}" to modules.`
|
|
61
|
-
: "";
|
|
62
|
-
const message = `Container query factory "${label}" received unsupported feature "${key}".${moduleSuffix}`;
|
|
63
|
-
if (mode === "log") {
|
|
64
|
-
console.warn(message);
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
if (mode === "allow")
|
|
68
|
-
return;
|
|
69
|
-
throw new Error(message);
|
|
70
|
-
});
|
|
71
|
-
};
|
|
72
|
-
const guardDuplicateConditions = (condition, config, label) => {
|
|
73
|
-
var _a, _b;
|
|
74
|
-
const keys = [];
|
|
75
|
-
collectAndConditionKeys(condition, keys);
|
|
76
|
-
const seen = new Set();
|
|
77
|
-
const duplicates = new Set();
|
|
78
|
-
keys.forEach((key) => {
|
|
79
|
-
if (seen.has(key)) {
|
|
80
|
-
duplicates.add(key);
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
seen.add(key);
|
|
84
|
-
});
|
|
85
|
-
if (!duplicates.size)
|
|
86
|
-
return;
|
|
87
|
-
const mode = (_b = (_a = config.errorHandling) === null || _a === void 0 ? void 0 : _a.invalidValueMode) !== null && _b !== void 0 ? _b : "throw";
|
|
88
|
-
const message = `Container query factory "${label}" received duplicate condition "${Array.from(duplicates).join('", "')}".`;
|
|
89
|
-
if (mode === "log") {
|
|
90
|
-
console.warn(message);
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
if (mode === "allow")
|
|
94
|
-
return;
|
|
95
|
-
throw new Error(message);
|
|
96
|
-
};
|
|
97
|
-
export const createContainerQueryFactory = () => (options) => {
|
|
98
|
-
var _a;
|
|
99
|
-
const modules = (_a = options.config.modules) !== null && _a !== void 0 ? _a : ALL_CONTAINER_QUERY_MODULES;
|
|
100
|
-
return (stylesByQuery) => {
|
|
101
|
-
const result = {};
|
|
102
|
-
Object.keys(stylesByQuery).forEach((key) => {
|
|
103
|
-
const styles = stylesByQuery[key];
|
|
104
|
-
const rule = options.queries[key];
|
|
105
|
-
if (!styles || !(rule === null || rule === void 0 ? void 0 : rule.query))
|
|
106
|
-
return;
|
|
107
|
-
guardUnsupportedCondition(rule.query.condition, modules, options.config, options.config.label);
|
|
108
|
-
guardDuplicateConditions(rule.query.condition, options.config, options.config.label);
|
|
109
|
-
result[buildContainerConditionString(rule.query.condition)] = styles;
|
|
110
|
-
});
|
|
111
|
-
const containerQuery = {
|
|
112
|
-
"@container": result,
|
|
113
|
-
};
|
|
114
|
-
return options.config.output
|
|
115
|
-
? options.config.output(containerQuery)
|
|
116
|
-
: containerQuery;
|
|
117
|
-
};
|
|
118
|
-
};
|
|
119
|
-
export const containerQueryFactory = createContainerQueryFactory();
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import type { IRatio } from "../ratio";
|
|
2
|
-
import type { IMeasurement } from "../core";
|
|
3
|
-
import type { ComparisonValue } from "../comparisons";
|
|
4
|
-
import type { CSSComparison, CSSRange } from "./types";
|
|
5
|
-
import type { ValidationResult } from "../validation";
|
|
6
|
-
export type ContainerQueryValidationResult = ValidationResult;
|
|
7
|
-
export type ContainerQueryValidator<TConfig> = (config: TConfig) => ContainerQueryValidationResult;
|
|
8
|
-
type ContainerQueryFeatureValue = string | number | IMeasurement | IRatio;
|
|
9
|
-
type ContainerQueryFeatureEmitter = (name: string, value: ContainerQueryFeatureValue) => void;
|
|
10
|
-
type ContainerQueryConditionEmitter = (condition: string) => void;
|
|
11
|
-
export type ContainerQueryInvalidValueMode = "allow" | "log" | "throw";
|
|
12
|
-
export type ContainerQueryLintingMode = "allow" | "log" | "throw";
|
|
13
|
-
export type ContainerQueryBuilderConfig = {
|
|
14
|
-
errorHandling?: {
|
|
15
|
-
invalidValueMode?: ContainerQueryInvalidValueMode;
|
|
16
|
-
lintingMode?: ContainerQueryLintingMode;
|
|
17
|
-
};
|
|
18
|
-
allowQueryArrays?: boolean;
|
|
19
|
-
};
|
|
20
|
-
export interface ContainerQueryBuilderHelpers {
|
|
21
|
-
addFeature: ContainerQueryFeatureEmitter;
|
|
22
|
-
addFeatureUnsafe: ContainerQueryFeatureEmitter;
|
|
23
|
-
addCondition: ContainerQueryConditionEmitter;
|
|
24
|
-
config: ContainerQueryBuilderConfig;
|
|
25
|
-
}
|
|
26
|
-
export type ContainerQueryExtensionHandler<TConfig> = (config: TConfig, helpers: ContainerQueryBuilderHelpers) => void;
|
|
27
|
-
type ContainerQueryBuilderOptions<TConfig> = {
|
|
28
|
-
emitBase: ContainerQueryExtensionHandler<TConfig>;
|
|
29
|
-
emitExtensions?: ContainerQueryExtensionHandler<TConfig>;
|
|
30
|
-
resolveType?: (config: TConfig) => "all" | "print" | "screen" | undefined;
|
|
31
|
-
config?: ContainerQueryBuilderConfig;
|
|
32
|
-
};
|
|
33
|
-
export declare const formatContainerQueryValue: (value: ContainerQueryFeatureValue) => string;
|
|
34
|
-
type ContainerQueryRangeMode = "min" | "max";
|
|
35
|
-
type ContainerQueryRangeOptions = {
|
|
36
|
-
mode?: ContainerQueryRangeMode;
|
|
37
|
-
inclusive?: boolean;
|
|
38
|
-
};
|
|
39
|
-
export declare const buildContainerComparison: <TValue>(comparison: ComparisonValue<TValue>) => CSSComparison<TValue>;
|
|
40
|
-
export declare const buildContainerRange: <TValue>(min: TValue, max: TValue, options?: ContainerQueryRangeOptions) => CSSRange<TValue>;
|
|
41
|
-
export declare const buildContainerQueryStringFromParts: (parts: string[]) => string;
|
|
42
|
-
export declare const formatContainerQueryComparison: (name: string, operator: string, value: ContainerQueryFeatureValue) => string;
|
|
43
|
-
export declare const createContainerQueryFeatureEmitter: (parts: string[]) => ContainerQueryFeatureEmitter;
|
|
44
|
-
export declare const createContainerQueryConditionEmitter: (parts: string[]) => ContainerQueryConditionEmitter;
|
|
45
|
-
type ContainerQueryFeatureEmitterOptions = {
|
|
46
|
-
emitted?: Set<string>;
|
|
47
|
-
lintingMode?: ContainerQueryLintingMode;
|
|
48
|
-
};
|
|
49
|
-
export declare const createContainerQueryFeatureEmitterWithTracking: (parts: string[], options?: ContainerQueryFeatureEmitterOptions) => ContainerQueryFeatureEmitter;
|
|
50
|
-
export declare const createContainerQueryBuilder: <TConfig>(options: ContainerQueryBuilderOptions<TConfig>) => (config: TConfig) => string;
|
|
51
|
-
export declare const applyContainerQueryValidation: <TConfig>(config: TConfig, helpers: ContainerQueryBuilderHelpers, validator?: ContainerQueryValidator<TConfig>, context?: string) => boolean;
|
|
52
|
-
export {};
|
|
53
|
-
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/containerQueries/helpers.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { hasCssMethod } from "../core";
|
|
2
|
-
import { normalizeValidationResult } from "../validation";
|
|
3
|
-
export const formatContainerQueryValue = (value) => (hasCssMethod(value) ? value.css() : String(value));
|
|
4
|
-
export const buildContainerComparison = (comparison) => comparison;
|
|
5
|
-
export const buildContainerRange = (min, max, options = {}) => {
|
|
6
|
-
var _a;
|
|
7
|
-
const mode = (_a = options.mode) !== null && _a !== void 0 ? _a : "min";
|
|
8
|
-
const operator = options.inclusive === false ? "<" : "<=";
|
|
9
|
-
if (mode === "max") {
|
|
10
|
-
return { min, max, maxOperator: operator };
|
|
11
|
-
}
|
|
12
|
-
return { min, max, minOperator: operator };
|
|
13
|
-
};
|
|
14
|
-
export const buildContainerQueryStringFromParts = (parts) => parts.join(" and ");
|
|
15
|
-
export const formatContainerQueryComparison = (name, operator, value) => {
|
|
16
|
-
return `(${name} ${operator} ${formatContainerQueryValue(value)})`;
|
|
17
|
-
};
|
|
18
|
-
export const createContainerQueryFeatureEmitter = (parts) => (name, value) => {
|
|
19
|
-
parts.push(`(${name}: ${formatContainerQueryValue(value)})`);
|
|
20
|
-
};
|
|
21
|
-
export const createContainerQueryConditionEmitter = (parts) => (condition) => {
|
|
22
|
-
parts.push(condition);
|
|
23
|
-
};
|
|
24
|
-
export const createContainerQueryFeatureEmitterWithTracking = (parts, options = {}) => {
|
|
25
|
-
const { emitted, lintingMode = "throw" } = options;
|
|
26
|
-
return (name, value) => {
|
|
27
|
-
if (emitted === null || emitted === void 0 ? void 0 : emitted.has(name)) {
|
|
28
|
-
if (lintingMode === "throw") {
|
|
29
|
-
throw new Error(`Container query feature "${name}" was emitted more than once.`);
|
|
30
|
-
}
|
|
31
|
-
if (lintingMode === "log") {
|
|
32
|
-
console.warn(`Container query feature "${name}" was emitted more than once; using the latest value.`);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
emitted === null || emitted === void 0 ? void 0 : emitted.add(name);
|
|
36
|
-
parts.push(`(${name}: ${formatContainerQueryValue(value)})`);
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
export const createContainerQueryBuilder = (options) => {
|
|
40
|
-
return (config) => {
|
|
41
|
-
var _a, _b, _c, _d, _e;
|
|
42
|
-
const parts = [];
|
|
43
|
-
const emittedFeatures = new Set();
|
|
44
|
-
const helpers = {
|
|
45
|
-
addFeature: createContainerQueryFeatureEmitterWithTracking(parts, {
|
|
46
|
-
emitted: emittedFeatures,
|
|
47
|
-
lintingMode: (_c = (_b = (_a = options.config) === null || _a === void 0 ? void 0 : _a.errorHandling) === null || _b === void 0 ? void 0 : _b.lintingMode) !== null && _c !== void 0 ? _c : "throw",
|
|
48
|
-
}),
|
|
49
|
-
addFeatureUnsafe: createContainerQueryFeatureEmitter(parts),
|
|
50
|
-
addCondition: createContainerQueryConditionEmitter(parts),
|
|
51
|
-
config: (_d = options.config) !== null && _d !== void 0 ? _d : {},
|
|
52
|
-
};
|
|
53
|
-
options.emitBase(config, helpers);
|
|
54
|
-
(_e = options.emitExtensions) === null || _e === void 0 ? void 0 : _e.call(options, config, helpers);
|
|
55
|
-
return buildContainerQueryStringFromParts(parts);
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
|
-
export const applyContainerQueryValidation = (config, helpers, validator, context) => {
|
|
59
|
-
var _a, _b;
|
|
60
|
-
if (!validator)
|
|
61
|
-
return true;
|
|
62
|
-
const normalized = normalizeValidationResult(validator(config));
|
|
63
|
-
if (normalized.valid)
|
|
64
|
-
return true;
|
|
65
|
-
const mode = (_b = (_a = helpers.config.errorHandling) === null || _a === void 0 ? void 0 : _a.invalidValueMode) !== null && _b !== void 0 ? _b : "throw";
|
|
66
|
-
if (mode === "log") {
|
|
67
|
-
const suffix = normalized.message ? `: ${normalized.message}` : "";
|
|
68
|
-
const prefix = context
|
|
69
|
-
? `Container query ${context} validation failed`
|
|
70
|
-
: "Container query validation failed";
|
|
71
|
-
console.warn(`${prefix}${suffix}`);
|
|
72
|
-
}
|
|
73
|
-
if (mode === "allow")
|
|
74
|
-
return true;
|
|
75
|
-
if (mode === "log")
|
|
76
|
-
return true;
|
|
77
|
-
const suffix = normalized.message ? `: ${normalized.message}` : "";
|
|
78
|
-
const prefix = context
|
|
79
|
-
? `Container query ${context} validation failed`
|
|
80
|
-
: "Container query validation failed";
|
|
81
|
-
throw new Error(`${prefix}${suffix}`);
|
|
82
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export { buildContainerConditionString, buildContainerQueryString, makeContainerQueryStyle, } from "./containerQueries";
|
|
2
|
-
export { buildContainerComparison, buildContainerRange, formatContainerQueryValue, } from "./helpers";
|
|
3
|
-
export { containerQueryFactory, createContainerQueryFactory } from "./factory";
|
|
4
|
-
export { defineContainerQueryModules } from "./moduleRegistry";
|
|
5
|
-
export type * from "./types";
|
|
6
|
-
export type * from "./containerQueries";
|
|
7
|
-
export type * from "./factory";
|
|
8
|
-
export type * from "./modules";
|
|
9
|
-
export type * from "./moduleRegistry";
|
|
10
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/containerQueries/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,6BAA6B,EAC7B,yBAAyB,EACzB,uBAAuB,GACxB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,wBAAwB,EACxB,mBAAmB,EACnB,yBAAyB,GAC1B,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,qBAAqB,EAAE,2BAA2B,EAAE,MAAM,WAAW,CAAC;AAC/E,OAAO,EAAE,2BAA2B,EAAE,MAAM,kBAAkB,CAAC;AAC/D,mBAAmB,SAAS,CAAC;AAC7B,mBAAmB,oBAAoB,CAAC;AACxC,mBAAmB,WAAW,CAAC;AAC/B,mBAAmB,WAAW,CAAC;AAC/B,mBAAmB,kBAAkB,CAAC"}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export { buildContainerConditionString, buildContainerQueryString, makeContainerQueryStyle, } from "./containerQueries";
|
|
2
|
-
export { buildContainerComparison, buildContainerRange, formatContainerQueryValue, } from "./helpers";
|
|
3
|
-
export { containerQueryFactory, createContainerQueryFactory } from "./factory";
|
|
4
|
-
export { defineContainerQueryModules } from "./moduleRegistry";
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { IContainerQueryAspectRatio } from "../modules/aspectRatio";
|
|
2
|
-
export declare const lintAspectRatioRedundancy: (props: IContainerQueryAspectRatio) => void;
|
|
3
|
-
export declare const lintAspectRatioRangeCollapse: (props: IContainerQueryAspectRatio) => void;
|
|
4
|
-
//# sourceMappingURL=aspectRatio.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"aspectRatio.d.ts","sourceRoot":"","sources":["../../../../src/containerQueries/linting/aspectRatio.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AAGzE,eAAO,MAAM,yBAAyB,GACpC,OAAO,0BAA0B,KAChC,IAOF,CAAC;AAEF,eAAO,MAAM,4BAA4B,GACvC,OAAO,0BAA0B,KAChC,IAeF,CAAC"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { ratioToFloat } from "../../ratio";
|
|
2
|
-
export const lintAspectRatioRedundancy = (props) => {
|
|
3
|
-
if (!props.aspectRatio)
|
|
4
|
-
return;
|
|
5
|
-
if (props.minAspectRatio || props.maxAspectRatio) {
|
|
6
|
-
throw new Error("aspectRatio should not be combined with minAspectRatio or maxAspectRatio");
|
|
7
|
-
}
|
|
8
|
-
};
|
|
9
|
-
export const lintAspectRatioRangeCollapse = (props) => {
|
|
10
|
-
if (!props.minAspectRatio || !props.maxAspectRatio)
|
|
11
|
-
return;
|
|
12
|
-
if (Array.isArray(props.minAspectRatio) ||
|
|
13
|
-
Array.isArray(props.maxAspectRatio)) {
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
if (ratioToFloat(props.minAspectRatio) === ratioToFloat(props.maxAspectRatio)) {
|
|
17
|
-
throw new Error("minAspectRatio and maxAspectRatio are equal; use aspectRatio instead");
|
|
18
|
-
}
|
|
19
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"block.d.ts","sourceRoot":"","sources":["../../../../src/containerQueries/linting/block.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAG7D,eAAO,MAAM,mBAAmB,GAC9B,OAAO,oBAAoB,KAC1B,IAOF,CAAC;AAEF,eAAO,MAAM,sBAAsB,GACjC,OAAO,oBAAoB,KAC1B,IAUF,CAAC"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { normalizeToArray } from "../../internal/normalizeToArray";
|
|
2
|
-
export const lintBlockRedundancy = (props) => {
|
|
3
|
-
if (!props.blockSize)
|
|
4
|
-
return;
|
|
5
|
-
if (props.blockSizeRange) {
|
|
6
|
-
throw new Error("blockSize should not be combined with blockSizeRange");
|
|
7
|
-
}
|
|
8
|
-
};
|
|
9
|
-
export const lintBlockRangeCollapse = (props) => {
|
|
10
|
-
if (!props.blockSizeRange)
|
|
11
|
-
return;
|
|
12
|
-
normalizeToArray(props.blockSizeRange).forEach((range) => {
|
|
13
|
-
const { min, max } = range;
|
|
14
|
-
if (min.equals(max)) {
|
|
15
|
-
throw new Error("blockSizeRange min and max are equal; use blockSize instead");
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { IContainerQueryCore } from "../containerQueries";
|
|
2
|
-
export declare const lintWidthExactRedundancy: (props: IContainerQueryCore) => void;
|
|
3
|
-
export declare const lintHeightExactRedundancy: (props: IContainerQueryCore) => void;
|
|
4
|
-
//# sourceMappingURL=core.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../../../src/containerQueries/linting/core.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE/D,eAAO,MAAM,wBAAwB,GACnC,OAAO,mBAAmB,KACzB,IAUF,CAAC;AAEF,eAAO,MAAM,yBAAyB,GACpC,OAAO,mBAAmB,KACzB,IAUF,CAAC"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export const lintWidthExactRedundancy = (props) => {
|
|
2
|
-
if (!props.minWidth || !props.maxWidth)
|
|
3
|
-
return;
|
|
4
|
-
if (Array.isArray(props.minWidth) || Array.isArray(props.maxWidth)) {
|
|
5
|
-
return;
|
|
6
|
-
}
|
|
7
|
-
if (props.minWidth.equals(props.maxWidth)) {
|
|
8
|
-
throw new Error("minWidth should not be combined with maxWidth when both are equal");
|
|
9
|
-
}
|
|
10
|
-
};
|
|
11
|
-
export const lintHeightExactRedundancy = (props) => {
|
|
12
|
-
if (!props.minHeight || !props.maxHeight)
|
|
13
|
-
return;
|
|
14
|
-
if (Array.isArray(props.minHeight) || Array.isArray(props.maxHeight)) {
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
if (props.minHeight.equals(props.maxHeight)) {
|
|
18
|
-
throw new Error("minHeight should not be combined with maxHeight when both are equal");
|
|
19
|
-
}
|
|
20
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"custom.d.ts","sourceRoot":"","sources":["../../../../src/containerQueries/linting/custom.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAC;AAEvE,eAAO,MAAM,kBAAkB,GAC7B,OAAO,6BAA6B,KACnC,IAKF,CAAC"}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { IContainerQueryInline } from "../modules/inline";
|
|
2
|
-
export declare const lintInlineRedundancy: (props: IContainerQueryInline) => void;
|
|
3
|
-
export declare const lintInlineRangeCollapse: (props: IContainerQueryInline) => void;
|
|
4
|
-
//# sourceMappingURL=inline.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"inline.d.ts","sourceRoot":"","sources":["../../../../src/containerQueries/linting/inline.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAG/D,eAAO,MAAM,oBAAoB,GAC/B,OAAO,qBAAqB,KAC3B,IAOF,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAClC,OAAO,qBAAqB,KAC3B,IAUF,CAAC"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { normalizeToArray } from "../../internal/normalizeToArray";
|
|
2
|
-
export const lintInlineRedundancy = (props) => {
|
|
3
|
-
if (!props.inlineSize)
|
|
4
|
-
return;
|
|
5
|
-
if (props.inlineSizeRange) {
|
|
6
|
-
throw new Error("inlineSize should not be combined with inlineSizeRange");
|
|
7
|
-
}
|
|
8
|
-
};
|
|
9
|
-
export const lintInlineRangeCollapse = (props) => {
|
|
10
|
-
if (!props.inlineSizeRange)
|
|
11
|
-
return;
|
|
12
|
-
normalizeToArray(props.inlineSizeRange).forEach((range) => {
|
|
13
|
-
const { min, max } = range;
|
|
14
|
-
if (min.equals(max)) {
|
|
15
|
-
throw new Error("inlineSizeRange min and max are equal; use inlineSize instead");
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=resolution.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolution.d.ts","sourceRoot":"","sources":["../../../../src/containerQueries/linting/resolution.ts"],"names":[],"mappings":""}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// import type { IMediaQueryResolutionRange } from '../modules/resolution';
|
|
3
|
-
// export const lintResolutionRedundancy = (
|
|
4
|
-
// props: IMediaQueryResolutionRange,
|
|
5
|
-
// ): void => {
|
|
6
|
-
// if (!props.resolutionValue) return;
|
|
7
|
-
// if (props.minResolution || props.maxResolution) {
|
|
8
|
-
// throw new Error(
|
|
9
|
-
// 'resolution should not be combined with minResolution or maxResolution',
|
|
10
|
-
// );
|
|
11
|
-
// }
|
|
12
|
-
// };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../../../../src/containerQueries/linting/style.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAO7D,eAAO,MAAM,kBAAkB,GAC7B,OAAO,oBAAoB,KAC1B,IAiBF,CAAC"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { hasCssMethod } from "../../core";
|
|
2
|
-
const isComparisonShape = (value) => {
|
|
3
|
-
if (typeof value !== "object" || value === null)
|
|
4
|
-
return false;
|
|
5
|
-
return "operator" in value && "value" in value;
|
|
6
|
-
};
|
|
7
|
-
export const lintStyleCondition = (props) => {
|
|
8
|
-
if (!props.style)
|
|
9
|
-
return;
|
|
10
|
-
if (!Object.keys(props.style).length) {
|
|
11
|
-
throw new Error("style conditions must not be empty.");
|
|
12
|
-
}
|
|
13
|
-
Object.values(props.style).forEach((value) => {
|
|
14
|
-
if (value === undefined || value === null)
|
|
15
|
-
return;
|
|
16
|
-
if (Array.isArray(value))
|
|
17
|
-
return;
|
|
18
|
-
if (hasCssMethod(value))
|
|
19
|
-
return;
|
|
20
|
-
if (isComparisonShape(value)) {
|
|
21
|
-
throw new Error("style conditions must not contain comparisons.");
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { ContainerQueryBuilderHelpers } from "./helpers";
|
|
2
|
-
export type ContainerQueryLintCheck<TConfig> = (config: TConfig) => void;
|
|
3
|
-
export declare const runContainerQueryLint: <TConfig>(config: TConfig, helpers: ContainerQueryBuilderHelpers, check?: ContainerQueryLintCheck<TConfig>, message?: string) => boolean;
|
|
4
|
-
//# sourceMappingURL=linting.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"linting.d.ts","sourceRoot":"","sources":["../../../src/containerQueries/linting.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,4BAA4B,EAE7B,MAAM,WAAW,CAAC;AAEnB,MAAM,MAAM,uBAAuB,CAAC,OAAO,IAAI,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;AAEzE,eAAO,MAAM,qBAAqB,GAAI,OAAO,EAC3C,QAAQ,OAAO,EACf,SAAS,4BAA4B,EACrC,QAAQ,uBAAuB,CAAC,OAAO,CAAC,EACxC,gBAAuC,KACtC,OAiBF,CAAC"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export const runContainerQueryLint = (config, helpers, check, message = "Container query lint failed") => {
|
|
2
|
-
var _a, _b;
|
|
3
|
-
if (!check)
|
|
4
|
-
return true;
|
|
5
|
-
const mode = (_b = (_a = helpers.config.errorHandling) === null || _a === void 0 ? void 0 : _a.lintingMode) !== null && _b !== void 0 ? _b : "throw";
|
|
6
|
-
if (mode === "allow")
|
|
7
|
-
return true;
|
|
8
|
-
if (mode === "log") {
|
|
9
|
-
try {
|
|
10
|
-
check(config);
|
|
11
|
-
return true;
|
|
12
|
-
}
|
|
13
|
-
catch {
|
|
14
|
-
console.warn(message);
|
|
15
|
-
return true;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
check(config);
|
|
19
|
-
return true;
|
|
20
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { IContainerQueryCore } from "./containerQueries";
|
|
2
|
-
import type { IContainerQueryBlock, IContainerQueryInline, IContainerQueryAspectRatio, IContainerQueryStyle } from "./modules";
|
|
3
|
-
import { IContainerQueryCustomFeatures } from "./modules/custom";
|
|
4
|
-
export type ContainerQueryModuleId = "core" | "inline" | "block" | "aspectRatio" | "style" | "custom";
|
|
5
|
-
export type ContainerQueryModulePropsMap = {
|
|
6
|
-
core: IContainerQueryCore;
|
|
7
|
-
block: IContainerQueryBlock;
|
|
8
|
-
custom: IContainerQueryCustomFeatures;
|
|
9
|
-
inline: IContainerQueryInline;
|
|
10
|
-
aspectRatio: IContainerQueryAspectRatio;
|
|
11
|
-
style: IContainerQueryStyle;
|
|
12
|
-
};
|
|
13
|
-
export type ContentQueryValues = IContainerQueryCore[keyof IContainerQueryCore] | IContainerQueryInline[keyof IContainerQueryInline] | IContainerQueryBlock[keyof IContainerQueryBlock] | IContainerQueryAspectRatio[keyof IContainerQueryAspectRatio] | IContainerQueryStyle[keyof IContainerQueryStyle] | IContainerQueryCustomFeatures[keyof IContainerQueryCustomFeatures];
|
|
14
|
-
export type ContainerQueryModuleKeysMap = {
|
|
15
|
-
core: "minWidth" | "maxWidth" | "minHeight" | "maxHeight";
|
|
16
|
-
inline: "inlineSize" | "inlineSizeRange";
|
|
17
|
-
block: "blockSize" | "blockSizeRange";
|
|
18
|
-
aspectRatio: "aspectRatio" | "minAspectRatio" | "maxAspectRatio";
|
|
19
|
-
style: "style";
|
|
20
|
-
custom: "customFeatures";
|
|
21
|
-
};
|
|
22
|
-
export type ContainerQueryModuleKeys<M extends ContainerQueryModuleId> = ContainerQueryModuleKeysMap[M];
|
|
23
|
-
export type ContainerQueryModulesList = readonly ContainerQueryModuleId[];
|
|
24
|
-
export declare const defineContainerQueryModules: <T extends ContainerQueryModulesList>(...modules: T) => T;
|
|
25
|
-
//# sourceMappingURL=moduleRegistry.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"moduleRegistry.d.ts","sourceRoot":"","sources":["../../../src/containerQueries/moduleRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EACV,oBAAoB,EACpB,qBAAqB,EACrB,0BAA0B,EAC1B,oBAAoB,EACrB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,6BAA6B,EAAE,MAAM,kBAAkB,CAAC;AAEjE,MAAM,MAAM,sBAAsB,GAC9B,MAAM,GACN,QAAQ,GACR,OAAO,GACP,aAAa,GACb,OAAO,GACP,QAAQ,CAAC;AAEb,MAAM,MAAM,4BAA4B,GAAG;IACzC,IAAI,EAAE,mBAAmB,CAAC;IAC1B,KAAK,EAAE,oBAAoB,CAAC;IAC5B,MAAM,EAAE,6BAA6B,CAAC;IACtC,MAAM,EAAE,qBAAqB,CAAC;IAC9B,WAAW,EAAE,0BAA0B,CAAC;IACxC,KAAK,EAAE,oBAAoB,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAC1B,mBAAmB,CAAC,MAAM,mBAAmB,CAAC,GAC9C,qBAAqB,CAAC,MAAM,qBAAqB,CAAC,GAClD,oBAAoB,CAAC,MAAM,oBAAoB,CAAC,GAChD,0BAA0B,CAAC,MAAM,0BAA0B,CAAC,GAC5D,oBAAoB,CAAC,MAAM,oBAAoB,CAAC,GAChD,6BAA6B,CAAC,MAAM,6BAA6B,CAAC,CAAC;AAEvE,MAAM,MAAM,2BAA2B,GAAG;IACxC,IAAI,EAAE,UAAU,GAAG,UAAU,GAAG,WAAW,GAAG,WAAW,CAAC;IAC1D,MAAM,EAAE,YAAY,GAAG,iBAAiB,CAAC;IACzC,KAAK,EAAE,WAAW,GAAG,gBAAgB,CAAC;IACtC,WAAW,EAAE,aAAa,GAAG,gBAAgB,GAAG,gBAAgB,CAAC;IACjE,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,gBAAgB,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,wBAAwB,CAAC,CAAC,SAAS,sBAAsB,IACnE,2BAA2B,CAAC,CAAC,CAAC,CAAC;AAEjC,MAAM,MAAM,yBAAyB,GAAG,SAAS,sBAAsB,EAAE,CAAC;AAE1E,eAAO,MAAM,2BAA2B,GACtC,CAAC,SAAS,yBAAyB,EAEnC,GAAG,SAAS,CAAC,KACZ,CAAY,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const defineContainerQueryModules = (...modules) => modules;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { ContentQueryVariable, IComparisonOperator } from "../../comparisons";
|
|
2
|
-
import type { IRatio } from "../../ratio";
|
|
3
|
-
import type { ContainerQueryBuilderHelpers, ContainerQueryValidator } from "../helpers";
|
|
4
|
-
export interface IContainerQueryAspectRatio {
|
|
5
|
-
aspectRatio?: IRatio | IRatio[];
|
|
6
|
-
minAspectRatio?: IRatio | IRatio[];
|
|
7
|
-
maxAspectRatio?: IRatio | IRatio[];
|
|
8
|
-
}
|
|
9
|
-
export type ContainerQueryAspectRatioValidator = ContainerQueryValidator<IContainerQueryAspectRatio>;
|
|
10
|
-
export type AspectRatioComparisonVariable = "aspectRatio" | "minAspectRatio" | "maxAspectRatio";
|
|
11
|
-
export type ComparisonAspectRatio<Variable = ContentQueryVariable, Value = IRatio> = {
|
|
12
|
-
variable: Variable;
|
|
13
|
-
operator: IComparisonOperator;
|
|
14
|
-
value: Value;
|
|
15
|
-
};
|
|
16
|
-
export declare const emitAspectRatioFeatures: (props: IContainerQueryAspectRatio, helpers: ContainerQueryBuilderHelpers, validate?: ContainerQueryAspectRatioValidator) => void;
|
|
17
|
-
//# sourceMappingURL=aspectRatio.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"aspectRatio.d.ts","sourceRoot":"","sources":["../../../../src/containerQueries/modules/aspectRatio.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,mBAAmB,EACpB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,EACV,4BAA4B,EAC5B,uBAAuB,EACxB,MAAM,YAAY,CAAC;AASpB,MAAM,WAAW,0BAA0B;IACzC,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAChC,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACnC,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CACpC;AAED,MAAM,MAAM,kCAAkC,GAC5C,uBAAuB,CAAC,0BAA0B,CAAC,CAAC;AAEtD,MAAM,MAAM,6BAA6B,GACrC,aAAa,GACb,gBAAgB,GAChB,gBAAgB,CAAC;AAErB,MAAM,MAAM,qBAAqB,CAC/B,QAAQ,GAAG,oBAAoB,EAC/B,KAAK,GAAG,MAAM,IACZ;IACF,QAAQ,EAAE,QAAQ,CAAC;IACnB,QAAQ,EAAE,mBAAmB,CAAC;IAC9B,KAAK,EAAE,KAAK,CAAC;CACd,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAClC,OAAO,0BAA0B,EACjC,SAAS,4BAA4B,EACrC,WAAW,kCAAkC,KAC5C,IAsEF,CAAC"}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { applyContainerQueryValidation } from "../helpers";
|
|
2
|
-
import { defaultContainerQueryValidation } from "../validation";
|
|
3
|
-
import { runContainerQueryLint } from "../linting";
|
|
4
|
-
import { lintAspectRatioRangeCollapse, lintAspectRatioRedundancy, } from "../linting/aspectRatio";
|
|
5
|
-
export const emitAspectRatioFeatures = (props, helpers, validate) => {
|
|
6
|
-
const allowQueryArrays = helpers.config.allowQueryArrays !== false;
|
|
7
|
-
const assertNoArray = (value, label) => {
|
|
8
|
-
if (Array.isArray(value) && !allowQueryArrays) {
|
|
9
|
-
throw new Error(`${label} does not allow arrays.`);
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
const { runContainerQueryValidation, validateAspectRatioValues } = defaultContainerQueryValidation;
|
|
13
|
-
if (!runContainerQueryValidation(props, helpers, validateAspectRatioValues, "aspectRatio", "aspect ratio values must be valid ratio greater than 0")) {
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
if (!runContainerQueryLint(props, helpers, lintAspectRatioRedundancy, "aspectRatio should not be combined with minAspectRatio or maxAspectRatio")) {
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
if (!runContainerQueryLint(props, helpers, lintAspectRatioRangeCollapse, "minAspectRatio and maxAspectRatio are equal; use aspectRatio instead")) {
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
if (!applyContainerQueryValidation(props, helpers, validate, "aspectRatio")) {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
const emitFeature = (name, value) => {
|
|
26
|
-
if (Array.isArray(value)) {
|
|
27
|
-
value.forEach((entry) => {
|
|
28
|
-
var _a;
|
|
29
|
-
((_a = helpers.addFeatureUnsafe) !== null && _a !== void 0 ? _a : helpers.addFeature)(name, entry);
|
|
30
|
-
});
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
helpers.addFeature(name, value);
|
|
34
|
-
};
|
|
35
|
-
if (props.aspectRatio !== undefined) {
|
|
36
|
-
assertNoArray(props.aspectRatio, "aspectRatio");
|
|
37
|
-
emitFeature("aspect-ratio", props.aspectRatio);
|
|
38
|
-
}
|
|
39
|
-
if (props.minAspectRatio !== undefined) {
|
|
40
|
-
assertNoArray(props.minAspectRatio, "minAspectRatio");
|
|
41
|
-
emitFeature("min-aspect-ratio", props.minAspectRatio);
|
|
42
|
-
}
|
|
43
|
-
if (props.maxAspectRatio !== undefined) {
|
|
44
|
-
assertNoArray(props.maxAspectRatio, "maxAspectRatio");
|
|
45
|
-
emitFeature("max-aspect-ratio", props.maxAspectRatio);
|
|
46
|
-
}
|
|
47
|
-
};
|