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,115 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.makeContainerQueryStyle = exports.buildContainerConditionString = exports.buildContainerQueryString = exports.emitCoreFeatures = exports.createEmitCoreFeatures = void 0;
|
|
4
|
-
const modules_1 = require("./modules");
|
|
5
|
-
const linting_1 = require("./linting");
|
|
6
|
-
const core_1 = require("./linting/core");
|
|
7
|
-
const validation_1 = require("./validation");
|
|
8
|
-
const helpers_1 = require("./helpers");
|
|
9
|
-
const createEmitCoreFeatures = (validation) => (props, helpers) => {
|
|
10
|
-
const allowQueryArrays = helpers.config.allowQueryArrays !== false;
|
|
11
|
-
const assertNoArray = (value, label) => {
|
|
12
|
-
if (Array.isArray(value) && !allowQueryArrays) {
|
|
13
|
-
throw new Error(`${label} does not allow arrays.`);
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
const emitFeature = (name, value) => {
|
|
17
|
-
if (Array.isArray(value)) {
|
|
18
|
-
value.forEach((entry) => {
|
|
19
|
-
var _a;
|
|
20
|
-
((_a = helpers.addFeatureUnsafe) !== null && _a !== void 0 ? _a : helpers.addFeature)(name, entry);
|
|
21
|
-
});
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
helpers.addFeature(name, value);
|
|
25
|
-
};
|
|
26
|
-
const { runContainerQueryValidation, validateMinMaxWidth, validateWidthValuesPositive, validateMinMaxHeight, validateHeightValuesPositive, } = validation;
|
|
27
|
-
if (!runContainerQueryValidation(props, helpers, validateMinMaxWidth, "core", "minWidth must be less than or equal to maxWidth")) {
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
if (!runContainerQueryValidation(props, helpers, validateMinMaxHeight, "core", "minHeight must be less than or equal to maxHeight")) {
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
if (!runContainerQueryValidation(props, helpers, validateWidthValuesPositive, "core", "width values must be greater than 0")) {
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
if (!runContainerQueryValidation(props, helpers, validateHeightValuesPositive, "core", "height values must be greater than 0")) {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
if (!(0, linting_1.runContainerQueryLint)(props, helpers, core_1.lintWidthExactRedundancy, "minWidth should not be combined with maxWidth when both are equal")) {
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
if (!(0, linting_1.runContainerQueryLint)(props, helpers, core_1.lintHeightExactRedundancy, "minHeight should not be combined with maxHeight when both are equal")) {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
if (props.minWidth !== undefined) {
|
|
46
|
-
assertNoArray(props.minWidth, "minWidth");
|
|
47
|
-
emitFeature("min-width", props.minWidth);
|
|
48
|
-
}
|
|
49
|
-
if (props.maxWidth !== undefined) {
|
|
50
|
-
assertNoArray(props.maxWidth, "maxWidth");
|
|
51
|
-
emitFeature("max-width", props.maxWidth);
|
|
52
|
-
}
|
|
53
|
-
if (props.minHeight !== undefined) {
|
|
54
|
-
assertNoArray(props.minHeight, "minHeight");
|
|
55
|
-
emitFeature("min-height", props.minHeight);
|
|
56
|
-
}
|
|
57
|
-
if (props.maxHeight !== undefined) {
|
|
58
|
-
assertNoArray(props.maxHeight, "maxHeight");
|
|
59
|
-
emitFeature("max-height", props.maxHeight);
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
exports.createEmitCoreFeatures = createEmitCoreFeatures;
|
|
63
|
-
exports.emitCoreFeatures = (0, exports.createEmitCoreFeatures)(validation_1.defaultContainerQueryValidation);
|
|
64
|
-
const emitBaseFeatures = (props, helpers) => {
|
|
65
|
-
(0, exports.emitCoreFeatures)(props, helpers);
|
|
66
|
-
(0, modules_1.emitAspectRatioFeatures)(props, helpers);
|
|
67
|
-
(0, modules_1.emitInlineSizeFeatures)(props, helpers);
|
|
68
|
-
(0, modules_1.emitBlockSizeFeatures)(props, helpers);
|
|
69
|
-
(0, modules_1.emitStyleFeatures)(props, helpers);
|
|
70
|
-
(0, modules_1.emitCustomFeatures)(props, helpers);
|
|
71
|
-
};
|
|
72
|
-
exports.buildContainerQueryString = (0, helpers_1.createContainerQueryBuilder)({
|
|
73
|
-
emitBase: emitBaseFeatures,
|
|
74
|
-
});
|
|
75
|
-
const wrapContainerCondition = (value) => {
|
|
76
|
-
const trimmed = value.trim();
|
|
77
|
-
if (trimmed.includes(" and ") ||
|
|
78
|
-
trimmed.includes(" or ") ||
|
|
79
|
-
trimmed.startsWith("not ")) {
|
|
80
|
-
return `(${trimmed})`;
|
|
81
|
-
}
|
|
82
|
-
return trimmed;
|
|
83
|
-
};
|
|
84
|
-
const buildContainerConditionString = (condition) => {
|
|
85
|
-
if ("and" in condition) {
|
|
86
|
-
return condition.and
|
|
87
|
-
.map((entry) => wrapContainerCondition((0, exports.buildContainerConditionString)(entry)))
|
|
88
|
-
.join(" and ");
|
|
89
|
-
}
|
|
90
|
-
if ("or" in condition) {
|
|
91
|
-
return condition.or
|
|
92
|
-
.map((entry) => wrapContainerCondition((0, exports.buildContainerConditionString)(entry)))
|
|
93
|
-
.join(" or ");
|
|
94
|
-
}
|
|
95
|
-
if ("not" in condition) {
|
|
96
|
-
return `not ${wrapContainerCondition((0, exports.buildContainerConditionString)(condition.not))}`;
|
|
97
|
-
}
|
|
98
|
-
return (0, exports.buildContainerQueryString)(condition);
|
|
99
|
-
};
|
|
100
|
-
exports.buildContainerConditionString = buildContainerConditionString;
|
|
101
|
-
const makeContainerQueryStyle = (queries) => (stylesByQuery) => {
|
|
102
|
-
const result = {};
|
|
103
|
-
Object.keys(stylesByQuery).forEach((key) => {
|
|
104
|
-
const styles = stylesByQuery[key];
|
|
105
|
-
const props = queries[key];
|
|
106
|
-
if (!styles || !props)
|
|
107
|
-
return;
|
|
108
|
-
result[(0, exports.buildContainerQueryString)(props)] = styles;
|
|
109
|
-
});
|
|
110
|
-
const containerQuery = {
|
|
111
|
-
"@container": result,
|
|
112
|
-
};
|
|
113
|
-
return containerQuery;
|
|
114
|
-
};
|
|
115
|
-
exports.makeContainerQueryStyle = makeContainerQueryStyle;
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.containerQueryFactory = exports.createContainerQueryFactory = void 0;
|
|
4
|
-
const containerQueries_1 = require("./containerQueries");
|
|
5
|
-
const ALL_CONTAINER_QUERY_MODULES = [
|
|
6
|
-
"core",
|
|
7
|
-
"inline",
|
|
8
|
-
"block",
|
|
9
|
-
"aspectRatio",
|
|
10
|
-
"style",
|
|
11
|
-
"custom",
|
|
12
|
-
];
|
|
13
|
-
const MODULE_KEYS = {
|
|
14
|
-
core: ["minWidth", "maxWidth", "minHeight", "maxHeight"],
|
|
15
|
-
inline: ["inlineSize", "inlineSizeRange"],
|
|
16
|
-
block: ["blockSize", "blockSizeRange"],
|
|
17
|
-
aspectRatio: ["aspectRatio", "minAspectRatio", "maxAspectRatio"],
|
|
18
|
-
style: ["style"],
|
|
19
|
-
custom: ["customFeatures"],
|
|
20
|
-
};
|
|
21
|
-
const KEY_TO_MODULE = Object.fromEntries(Object.keys(MODULE_KEYS).flatMap((moduleId) => MODULE_KEYS[moduleId].map((key) => [key, moduleId])));
|
|
22
|
-
const collectConditionKeys = (condition, keys) => {
|
|
23
|
-
if ("and" in condition) {
|
|
24
|
-
condition.and.forEach((entry) => collectConditionKeys(entry, keys));
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
if ("or" in condition) {
|
|
28
|
-
condition.or.forEach((entry) => collectConditionKeys(entry, keys));
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
if ("not" in condition) {
|
|
32
|
-
collectConditionKeys(condition.not, keys);
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
Object.keys(condition).forEach((key) => keys.add(key));
|
|
36
|
-
};
|
|
37
|
-
const collectAndConditionKeys = (condition, keys) => {
|
|
38
|
-
if ("and" in condition) {
|
|
39
|
-
condition.and.forEach((entry) => collectAndConditionKeys(entry, keys));
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
if ("or" in condition || "not" in condition) {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
Object.keys(condition).forEach((key) => keys.push(key));
|
|
46
|
-
};
|
|
47
|
-
const guardUnsupportedCondition = (condition, modules, config, label) => {
|
|
48
|
-
const allowed = new Set();
|
|
49
|
-
modules.forEach((moduleId) => {
|
|
50
|
-
MODULE_KEYS[moduleId].forEach((key) => {
|
|
51
|
-
allowed.add(key);
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
const conditionKeys = new Set();
|
|
55
|
-
collectConditionKeys(condition, conditionKeys);
|
|
56
|
-
conditionKeys.forEach((key) => {
|
|
57
|
-
var _a, _b;
|
|
58
|
-
if (allowed.has(key))
|
|
59
|
-
return;
|
|
60
|
-
const mode = (_b = (_a = config.errorHandling) === null || _a === void 0 ? void 0 : _a.invalidValueMode) !== null && _b !== void 0 ? _b : "throw";
|
|
61
|
-
const moduleHint = KEY_TO_MODULE[key];
|
|
62
|
-
const moduleSuffix = moduleHint
|
|
63
|
-
? ` Add "${moduleHint}" to modules.`
|
|
64
|
-
: "";
|
|
65
|
-
const message = `Container query factory "${label}" received unsupported feature "${key}".${moduleSuffix}`;
|
|
66
|
-
if (mode === "log") {
|
|
67
|
-
console.warn(message);
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
if (mode === "allow")
|
|
71
|
-
return;
|
|
72
|
-
throw new Error(message);
|
|
73
|
-
});
|
|
74
|
-
};
|
|
75
|
-
const guardDuplicateConditions = (condition, config, label) => {
|
|
76
|
-
var _a, _b;
|
|
77
|
-
const keys = [];
|
|
78
|
-
collectAndConditionKeys(condition, keys);
|
|
79
|
-
const seen = new Set();
|
|
80
|
-
const duplicates = new Set();
|
|
81
|
-
keys.forEach((key) => {
|
|
82
|
-
if (seen.has(key)) {
|
|
83
|
-
duplicates.add(key);
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
seen.add(key);
|
|
87
|
-
});
|
|
88
|
-
if (!duplicates.size)
|
|
89
|
-
return;
|
|
90
|
-
const mode = (_b = (_a = config.errorHandling) === null || _a === void 0 ? void 0 : _a.invalidValueMode) !== null && _b !== void 0 ? _b : "throw";
|
|
91
|
-
const message = `Container query factory "${label}" received duplicate condition "${Array.from(duplicates).join('", "')}".`;
|
|
92
|
-
if (mode === "log") {
|
|
93
|
-
console.warn(message);
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
if (mode === "allow")
|
|
97
|
-
return;
|
|
98
|
-
throw new Error(message);
|
|
99
|
-
};
|
|
100
|
-
const createContainerQueryFactory = () => (options) => {
|
|
101
|
-
var _a;
|
|
102
|
-
const modules = (_a = options.config.modules) !== null && _a !== void 0 ? _a : ALL_CONTAINER_QUERY_MODULES;
|
|
103
|
-
return (stylesByQuery) => {
|
|
104
|
-
const result = {};
|
|
105
|
-
Object.keys(stylesByQuery).forEach((key) => {
|
|
106
|
-
const styles = stylesByQuery[key];
|
|
107
|
-
const rule = options.queries[key];
|
|
108
|
-
if (!styles || !(rule === null || rule === void 0 ? void 0 : rule.query))
|
|
109
|
-
return;
|
|
110
|
-
guardUnsupportedCondition(rule.query.condition, modules, options.config, options.config.label);
|
|
111
|
-
guardDuplicateConditions(rule.query.condition, options.config, options.config.label);
|
|
112
|
-
result[(0, containerQueries_1.buildContainerConditionString)(rule.query.condition)] = styles;
|
|
113
|
-
});
|
|
114
|
-
const containerQuery = {
|
|
115
|
-
"@container": result,
|
|
116
|
-
};
|
|
117
|
-
return options.config.output
|
|
118
|
-
? options.config.output(containerQuery)
|
|
119
|
-
: containerQuery;
|
|
120
|
-
};
|
|
121
|
-
};
|
|
122
|
-
exports.createContainerQueryFactory = createContainerQueryFactory;
|
|
123
|
-
exports.containerQueryFactory = (0, exports.createContainerQueryFactory)();
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.applyContainerQueryValidation = exports.createContainerQueryBuilder = exports.createContainerQueryFeatureEmitterWithTracking = exports.createContainerQueryConditionEmitter = exports.createContainerQueryFeatureEmitter = exports.formatContainerQueryComparison = exports.buildContainerQueryStringFromParts = exports.buildContainerRange = exports.buildContainerComparison = exports.formatContainerQueryValue = void 0;
|
|
4
|
-
const core_1 = require("../core");
|
|
5
|
-
const validation_1 = require("../validation");
|
|
6
|
-
const formatContainerQueryValue = (value) => ((0, core_1.hasCssMethod)(value) ? value.css() : String(value));
|
|
7
|
-
exports.formatContainerQueryValue = formatContainerQueryValue;
|
|
8
|
-
const buildContainerComparison = (comparison) => comparison;
|
|
9
|
-
exports.buildContainerComparison = buildContainerComparison;
|
|
10
|
-
const buildContainerRange = (min, max, options = {}) => {
|
|
11
|
-
var _a;
|
|
12
|
-
const mode = (_a = options.mode) !== null && _a !== void 0 ? _a : "min";
|
|
13
|
-
const operator = options.inclusive === false ? "<" : "<=";
|
|
14
|
-
if (mode === "max") {
|
|
15
|
-
return { min, max, maxOperator: operator };
|
|
16
|
-
}
|
|
17
|
-
return { min, max, minOperator: operator };
|
|
18
|
-
};
|
|
19
|
-
exports.buildContainerRange = buildContainerRange;
|
|
20
|
-
const buildContainerQueryStringFromParts = (parts) => parts.join(" and ");
|
|
21
|
-
exports.buildContainerQueryStringFromParts = buildContainerQueryStringFromParts;
|
|
22
|
-
const formatContainerQueryComparison = (name, operator, value) => {
|
|
23
|
-
return `(${name} ${operator} ${(0, exports.formatContainerQueryValue)(value)})`;
|
|
24
|
-
};
|
|
25
|
-
exports.formatContainerQueryComparison = formatContainerQueryComparison;
|
|
26
|
-
const createContainerQueryFeatureEmitter = (parts) => (name, value) => {
|
|
27
|
-
parts.push(`(${name}: ${(0, exports.formatContainerQueryValue)(value)})`);
|
|
28
|
-
};
|
|
29
|
-
exports.createContainerQueryFeatureEmitter = createContainerQueryFeatureEmitter;
|
|
30
|
-
const createContainerQueryConditionEmitter = (parts) => (condition) => {
|
|
31
|
-
parts.push(condition);
|
|
32
|
-
};
|
|
33
|
-
exports.createContainerQueryConditionEmitter = createContainerQueryConditionEmitter;
|
|
34
|
-
const createContainerQueryFeatureEmitterWithTracking = (parts, options = {}) => {
|
|
35
|
-
const { emitted, lintingMode = "throw" } = options;
|
|
36
|
-
return (name, value) => {
|
|
37
|
-
if (emitted === null || emitted === void 0 ? void 0 : emitted.has(name)) {
|
|
38
|
-
if (lintingMode === "throw") {
|
|
39
|
-
throw new Error(`Container query feature "${name}" was emitted more than once.`);
|
|
40
|
-
}
|
|
41
|
-
if (lintingMode === "log") {
|
|
42
|
-
console.warn(`Container query feature "${name}" was emitted more than once; using the latest value.`);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
emitted === null || emitted === void 0 ? void 0 : emitted.add(name);
|
|
46
|
-
parts.push(`(${name}: ${(0, exports.formatContainerQueryValue)(value)})`);
|
|
47
|
-
};
|
|
48
|
-
};
|
|
49
|
-
exports.createContainerQueryFeatureEmitterWithTracking = createContainerQueryFeatureEmitterWithTracking;
|
|
50
|
-
const createContainerQueryBuilder = (options) => {
|
|
51
|
-
return (config) => {
|
|
52
|
-
var _a, _b, _c, _d, _e;
|
|
53
|
-
const parts = [];
|
|
54
|
-
const emittedFeatures = new Set();
|
|
55
|
-
const helpers = {
|
|
56
|
-
addFeature: (0, exports.createContainerQueryFeatureEmitterWithTracking)(parts, {
|
|
57
|
-
emitted: emittedFeatures,
|
|
58
|
-
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",
|
|
59
|
-
}),
|
|
60
|
-
addFeatureUnsafe: (0, exports.createContainerQueryFeatureEmitter)(parts),
|
|
61
|
-
addCondition: (0, exports.createContainerQueryConditionEmitter)(parts),
|
|
62
|
-
config: (_d = options.config) !== null && _d !== void 0 ? _d : {},
|
|
63
|
-
};
|
|
64
|
-
options.emitBase(config, helpers);
|
|
65
|
-
(_e = options.emitExtensions) === null || _e === void 0 ? void 0 : _e.call(options, config, helpers);
|
|
66
|
-
return (0, exports.buildContainerQueryStringFromParts)(parts);
|
|
67
|
-
};
|
|
68
|
-
};
|
|
69
|
-
exports.createContainerQueryBuilder = createContainerQueryBuilder;
|
|
70
|
-
const applyContainerQueryValidation = (config, helpers, validator, context) => {
|
|
71
|
-
var _a, _b;
|
|
72
|
-
if (!validator)
|
|
73
|
-
return true;
|
|
74
|
-
const normalized = (0, validation_1.normalizeValidationResult)(validator(config));
|
|
75
|
-
if (normalized.valid)
|
|
76
|
-
return true;
|
|
77
|
-
const mode = (_b = (_a = helpers.config.errorHandling) === null || _a === void 0 ? void 0 : _a.invalidValueMode) !== null && _b !== void 0 ? _b : "throw";
|
|
78
|
-
if (mode === "log") {
|
|
79
|
-
const suffix = normalized.message ? `: ${normalized.message}` : "";
|
|
80
|
-
const prefix = context
|
|
81
|
-
? `Container query ${context} validation failed`
|
|
82
|
-
: "Container query validation failed";
|
|
83
|
-
console.warn(`${prefix}${suffix}`);
|
|
84
|
-
}
|
|
85
|
-
if (mode === "allow")
|
|
86
|
-
return true;
|
|
87
|
-
if (mode === "log")
|
|
88
|
-
return true;
|
|
89
|
-
const suffix = normalized.message ? `: ${normalized.message}` : "";
|
|
90
|
-
const prefix = context
|
|
91
|
-
? `Container query ${context} validation failed`
|
|
92
|
-
: "Container query validation failed";
|
|
93
|
-
throw new Error(`${prefix}${suffix}`);
|
|
94
|
-
};
|
|
95
|
-
exports.applyContainerQueryValidation = applyContainerQueryValidation;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.defineContainerQueryModules = exports.createContainerQueryFactory = exports.containerQueryFactory = exports.formatContainerQueryValue = exports.buildContainerRange = exports.buildContainerComparison = exports.makeContainerQueryStyle = exports.buildContainerQueryString = exports.buildContainerConditionString = void 0;
|
|
4
|
-
var containerQueries_1 = require("./containerQueries");
|
|
5
|
-
Object.defineProperty(exports, "buildContainerConditionString", { enumerable: true, get: function () { return containerQueries_1.buildContainerConditionString; } });
|
|
6
|
-
Object.defineProperty(exports, "buildContainerQueryString", { enumerable: true, get: function () { return containerQueries_1.buildContainerQueryString; } });
|
|
7
|
-
Object.defineProperty(exports, "makeContainerQueryStyle", { enumerable: true, get: function () { return containerQueries_1.makeContainerQueryStyle; } });
|
|
8
|
-
var helpers_1 = require("./helpers");
|
|
9
|
-
Object.defineProperty(exports, "buildContainerComparison", { enumerable: true, get: function () { return helpers_1.buildContainerComparison; } });
|
|
10
|
-
Object.defineProperty(exports, "buildContainerRange", { enumerable: true, get: function () { return helpers_1.buildContainerRange; } });
|
|
11
|
-
Object.defineProperty(exports, "formatContainerQueryValue", { enumerable: true, get: function () { return helpers_1.formatContainerQueryValue; } });
|
|
12
|
-
var factory_1 = require("./factory");
|
|
13
|
-
Object.defineProperty(exports, "containerQueryFactory", { enumerable: true, get: function () { return factory_1.containerQueryFactory; } });
|
|
14
|
-
Object.defineProperty(exports, "createContainerQueryFactory", { enumerable: true, get: function () { return factory_1.createContainerQueryFactory; } });
|
|
15
|
-
var moduleRegistry_1 = require("./moduleRegistry");
|
|
16
|
-
Object.defineProperty(exports, "defineContainerQueryModules", { enumerable: true, get: function () { return moduleRegistry_1.defineContainerQueryModules; } });
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.lintAspectRatioRangeCollapse = exports.lintAspectRatioRedundancy = void 0;
|
|
4
|
-
const ratio_1 = require("../../ratio");
|
|
5
|
-
const lintAspectRatioRedundancy = (props) => {
|
|
6
|
-
if (!props.aspectRatio)
|
|
7
|
-
return;
|
|
8
|
-
if (props.minAspectRatio || props.maxAspectRatio) {
|
|
9
|
-
throw new Error("aspectRatio should not be combined with minAspectRatio or maxAspectRatio");
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
exports.lintAspectRatioRedundancy = lintAspectRatioRedundancy;
|
|
13
|
-
const lintAspectRatioRangeCollapse = (props) => {
|
|
14
|
-
if (!props.minAspectRatio || !props.maxAspectRatio)
|
|
15
|
-
return;
|
|
16
|
-
if (Array.isArray(props.minAspectRatio) ||
|
|
17
|
-
Array.isArray(props.maxAspectRatio)) {
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
if ((0, ratio_1.ratioToFloat)(props.minAspectRatio) === (0, ratio_1.ratioToFloat)(props.maxAspectRatio)) {
|
|
21
|
-
throw new Error("minAspectRatio and maxAspectRatio are equal; use aspectRatio instead");
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
exports.lintAspectRatioRangeCollapse = lintAspectRatioRangeCollapse;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.lintBlockRangeCollapse = exports.lintBlockRedundancy = void 0;
|
|
4
|
-
const normalizeToArray_1 = require("../../internal/normalizeToArray");
|
|
5
|
-
const lintBlockRedundancy = (props) => {
|
|
6
|
-
if (!props.blockSize)
|
|
7
|
-
return;
|
|
8
|
-
if (props.blockSizeRange) {
|
|
9
|
-
throw new Error("blockSize should not be combined with blockSizeRange");
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
exports.lintBlockRedundancy = lintBlockRedundancy;
|
|
13
|
-
const lintBlockRangeCollapse = (props) => {
|
|
14
|
-
if (!props.blockSizeRange)
|
|
15
|
-
return;
|
|
16
|
-
(0, normalizeToArray_1.normalizeToArray)(props.blockSizeRange).forEach((range) => {
|
|
17
|
-
const { min, max } = range;
|
|
18
|
-
if (min.equals(max)) {
|
|
19
|
-
throw new Error("blockSizeRange min and max are equal; use blockSize instead");
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
exports.lintBlockRangeCollapse = lintBlockRangeCollapse;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.lintHeightExactRedundancy = exports.lintWidthExactRedundancy = void 0;
|
|
4
|
-
const lintWidthExactRedundancy = (props) => {
|
|
5
|
-
if (!props.minWidth || !props.maxWidth)
|
|
6
|
-
return;
|
|
7
|
-
if (Array.isArray(props.minWidth) || Array.isArray(props.maxWidth)) {
|
|
8
|
-
return;
|
|
9
|
-
}
|
|
10
|
-
if (props.minWidth.equals(props.maxWidth)) {
|
|
11
|
-
throw new Error("minWidth should not be combined with maxWidth when both are equal");
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
exports.lintWidthExactRedundancy = lintWidthExactRedundancy;
|
|
15
|
-
const lintHeightExactRedundancy = (props) => {
|
|
16
|
-
if (!props.minHeight || !props.maxHeight)
|
|
17
|
-
return;
|
|
18
|
-
if (Array.isArray(props.minHeight) || Array.isArray(props.maxHeight)) {
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
if (props.minHeight.equals(props.maxHeight)) {
|
|
22
|
-
throw new Error("minHeight should not be combined with maxHeight when both are equal");
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
exports.lintHeightExactRedundancy = lintHeightExactRedundancy;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.lintCustomFeatures = void 0;
|
|
4
|
-
const lintCustomFeatures = (props) => {
|
|
5
|
-
if (!props.customFeatures)
|
|
6
|
-
return;
|
|
7
|
-
if (!Object.keys(props.customFeatures).length) {
|
|
8
|
-
throw new Error("customFeatures should not be empty.");
|
|
9
|
-
}
|
|
10
|
-
};
|
|
11
|
-
exports.lintCustomFeatures = lintCustomFeatures;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.lintInlineRangeCollapse = exports.lintInlineRedundancy = void 0;
|
|
4
|
-
const normalizeToArray_1 = require("../../internal/normalizeToArray");
|
|
5
|
-
const lintInlineRedundancy = (props) => {
|
|
6
|
-
if (!props.inlineSize)
|
|
7
|
-
return;
|
|
8
|
-
if (props.inlineSizeRange) {
|
|
9
|
-
throw new Error("inlineSize should not be combined with inlineSizeRange");
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
exports.lintInlineRedundancy = lintInlineRedundancy;
|
|
13
|
-
const lintInlineRangeCollapse = (props) => {
|
|
14
|
-
if (!props.inlineSizeRange)
|
|
15
|
-
return;
|
|
16
|
-
(0, normalizeToArray_1.normalizeToArray)(props.inlineSizeRange).forEach((range) => {
|
|
17
|
-
const { min, max } = range;
|
|
18
|
-
if (min.equals(max)) {
|
|
19
|
-
throw new Error("inlineSizeRange min and max are equal; use inlineSize instead");
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
exports.lintInlineRangeCollapse = lintInlineRangeCollapse;
|
|
@@ -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,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.lintStyleCondition = void 0;
|
|
4
|
-
const core_1 = require("../../core");
|
|
5
|
-
const isComparisonShape = (value) => {
|
|
6
|
-
if (typeof value !== "object" || value === null)
|
|
7
|
-
return false;
|
|
8
|
-
return "operator" in value && "value" in value;
|
|
9
|
-
};
|
|
10
|
-
const lintStyleCondition = (props) => {
|
|
11
|
-
if (!props.style)
|
|
12
|
-
return;
|
|
13
|
-
if (!Object.keys(props.style).length) {
|
|
14
|
-
throw new Error("style conditions must not be empty.");
|
|
15
|
-
}
|
|
16
|
-
Object.values(props.style).forEach((value) => {
|
|
17
|
-
if (value === undefined || value === null)
|
|
18
|
-
return;
|
|
19
|
-
if (Array.isArray(value))
|
|
20
|
-
return;
|
|
21
|
-
if ((0, core_1.hasCssMethod)(value))
|
|
22
|
-
return;
|
|
23
|
-
if (isComparisonShape(value)) {
|
|
24
|
-
throw new Error("style conditions must not contain comparisons.");
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
};
|
|
28
|
-
exports.lintStyleCondition = lintStyleCondition;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.runContainerQueryLint = void 0;
|
|
4
|
-
const runContainerQueryLint = (config, helpers, check, message = "Container query lint failed") => {
|
|
5
|
-
var _a, _b;
|
|
6
|
-
if (!check)
|
|
7
|
-
return true;
|
|
8
|
-
const mode = (_b = (_a = helpers.config.errorHandling) === null || _a === void 0 ? void 0 : _a.lintingMode) !== null && _b !== void 0 ? _b : "throw";
|
|
9
|
-
if (mode === "allow")
|
|
10
|
-
return true;
|
|
11
|
-
if (mode === "log") {
|
|
12
|
-
try {
|
|
13
|
-
check(config);
|
|
14
|
-
return true;
|
|
15
|
-
}
|
|
16
|
-
catch {
|
|
17
|
-
console.warn(message);
|
|
18
|
-
return true;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
check(config);
|
|
22
|
-
return true;
|
|
23
|
-
};
|
|
24
|
-
exports.runContainerQueryLint = runContainerQueryLint;
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.emitAspectRatioFeatures = void 0;
|
|
4
|
-
const helpers_1 = require("../helpers");
|
|
5
|
-
const validation_1 = require("../validation");
|
|
6
|
-
const linting_1 = require("../linting");
|
|
7
|
-
const aspectRatio_1 = require("../linting/aspectRatio");
|
|
8
|
-
const emitAspectRatioFeatures = (props, helpers, validate) => {
|
|
9
|
-
const allowQueryArrays = helpers.config.allowQueryArrays !== false;
|
|
10
|
-
const assertNoArray = (value, label) => {
|
|
11
|
-
if (Array.isArray(value) && !allowQueryArrays) {
|
|
12
|
-
throw new Error(`${label} does not allow arrays.`);
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
const { runContainerQueryValidation, validateAspectRatioValues } = validation_1.defaultContainerQueryValidation;
|
|
16
|
-
if (!runContainerQueryValidation(props, helpers, validateAspectRatioValues, "aspectRatio", "aspect ratio values must be valid ratio greater than 0")) {
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
if (!(0, linting_1.runContainerQueryLint)(props, helpers, aspectRatio_1.lintAspectRatioRedundancy, "aspectRatio should not be combined with minAspectRatio or maxAspectRatio")) {
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
if (!(0, linting_1.runContainerQueryLint)(props, helpers, aspectRatio_1.lintAspectRatioRangeCollapse, "minAspectRatio and maxAspectRatio are equal; use aspectRatio instead")) {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
if (!(0, helpers_1.applyContainerQueryValidation)(props, helpers, validate, "aspectRatio")) {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
const emitFeature = (name, value) => {
|
|
29
|
-
if (Array.isArray(value)) {
|
|
30
|
-
value.forEach((entry) => {
|
|
31
|
-
var _a;
|
|
32
|
-
((_a = helpers.addFeatureUnsafe) !== null && _a !== void 0 ? _a : helpers.addFeature)(name, entry);
|
|
33
|
-
});
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
helpers.addFeature(name, value);
|
|
37
|
-
};
|
|
38
|
-
if (props.aspectRatio !== undefined) {
|
|
39
|
-
assertNoArray(props.aspectRatio, "aspectRatio");
|
|
40
|
-
emitFeature("aspect-ratio", props.aspectRatio);
|
|
41
|
-
}
|
|
42
|
-
if (props.minAspectRatio !== undefined) {
|
|
43
|
-
assertNoArray(props.minAspectRatio, "minAspectRatio");
|
|
44
|
-
emitFeature("min-aspect-ratio", props.minAspectRatio);
|
|
45
|
-
}
|
|
46
|
-
if (props.maxAspectRatio !== undefined) {
|
|
47
|
-
assertNoArray(props.maxAspectRatio, "maxAspectRatio");
|
|
48
|
-
emitFeature("max-aspect-ratio", props.maxAspectRatio);
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
exports.emitAspectRatioFeatures = emitAspectRatioFeatures;
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.emitBlockSizeFeatures = void 0;
|
|
4
|
-
const helpers_1 = require("../helpers");
|
|
5
|
-
const validation_1 = require("../validation");
|
|
6
|
-
const linting_1 = require("../linting");
|
|
7
|
-
const block_1 = require("../linting/block");
|
|
8
|
-
const normalizeToArray_1 = require("../../internal/normalizeToArray");
|
|
9
|
-
const emitBlockComparison = (name, comparison, addCondition) => {
|
|
10
|
-
addCondition((0, helpers_1.formatContainerQueryComparison)(name, comparison.operator, comparison.value));
|
|
11
|
-
};
|
|
12
|
-
const emitBlockRange = (name, range, addCondition) => {
|
|
13
|
-
const min = (0, helpers_1.formatContainerQueryValue)(range.min);
|
|
14
|
-
const max = (0, helpers_1.formatContainerQueryValue)(range.max);
|
|
15
|
-
if ("minOperator" in range) {
|
|
16
|
-
addCondition(`(${min} ${range.minOperator} ${name})`);
|
|
17
|
-
addCondition(`(${name} <= ${max})`);
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
addCondition(`(${min} <= ${name})`);
|
|
21
|
-
addCondition(`(${name} ${range.maxOperator} ${max})`);
|
|
22
|
-
};
|
|
23
|
-
const emitBlockSizeFeatures = (props, helpers, validate) => {
|
|
24
|
-
const allowQueryArrays = helpers.config.allowQueryArrays !== false;
|
|
25
|
-
const assertNoArray = (value, label) => {
|
|
26
|
-
if (Array.isArray(value) && !allowQueryArrays) {
|
|
27
|
-
throw new Error(`${label} does not allow arrays.`);
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
const { runContainerQueryValidation, validateBlockSizeValues, } = validation_1.defaultContainerQueryValidation;
|
|
31
|
-
if (!runContainerQueryValidation(props, helpers, validateBlockSizeValues, "block", "block size values must be valid measurements greater than 0")) {
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
if (!(0, linting_1.runContainerQueryLint)(props, helpers, block_1.lintBlockRedundancy, "blockSize should not be combined with blockSizeRange")) {
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
if (!(0, linting_1.runContainerQueryLint)(props, helpers, block_1.lintBlockRangeCollapse, "blockSizeRange min and max are equal; use blockSize instead")) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
if (!(0, helpers_1.applyContainerQueryValidation)(props, helpers, validate, "block")) {
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
const { addCondition } = helpers;
|
|
44
|
-
assertNoArray(props.blockSize, "blockSize");
|
|
45
|
-
(0, normalizeToArray_1.normalizeToArray)(props.blockSize).forEach((value) => {
|
|
46
|
-
emitBlockComparison("block-size", value, addCondition);
|
|
47
|
-
});
|
|
48
|
-
assertNoArray(props.blockSizeRange, "blockSizeRange");
|
|
49
|
-
(0, normalizeToArray_1.normalizeToArray)(props.blockSizeRange).forEach((value) => {
|
|
50
|
-
emitBlockRange("block-size", value, addCondition);
|
|
51
|
-
});
|
|
52
|
-
};
|
|
53
|
-
exports.emitBlockSizeFeatures = emitBlockSizeFeatures;
|