css-calipers 0.14.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/esm/factory.d.ts +0 -2
- package/dist/esm/factory.d.ts.map +1 -1
- package/dist/esm/factory.js +0 -3
- package/package.json +5 -18
- 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 -73
- 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 -134
- package/dist/cjs/sciNotation.js +0 -74
- 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 -69
- 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 -33
- package/dist/esm/mediaQueries/validation.d.ts.map +0 -1
- package/dist/esm/mediaQueries/validation.js +0 -130
- package/dist/esm/sciNotation.d.ts +0 -14
- package/dist/esm/sciNotation.d.ts.map +0 -1
- package/dist/esm/sciNotation.js +0 -69
- 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,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;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.emitCustomFeatures = void 0;
|
|
4
|
-
const helpers_1 = require("../helpers");
|
|
5
|
-
const validation_1 = require("../validation");
|
|
6
|
-
const linting_1 = require("../linting");
|
|
7
|
-
const custom_1 = require("../linting/custom");
|
|
8
|
-
const normalizeToArray_1 = require("../../internal/normalizeToArray");
|
|
9
|
-
const emitCustomFeatures = (props, helpers, options, validate) => {
|
|
10
|
-
var _a, _b;
|
|
11
|
-
const { runContainerQueryValidation, validateCustomFeatures } = validation_1.defaultContainerQueryValidation;
|
|
12
|
-
if (!runContainerQueryValidation(props, helpers, validateCustomFeatures, "custom", "custom features must be valid and non-empty")) {
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
if (!(0, linting_1.runContainerQueryLint)(props, helpers, custom_1.lintCustomFeatures, "customFeatures should not be empty")) {
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
if (!(0, helpers_1.applyContainerQueryValidation)(props, helpers, validate, "custom")) {
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
const { addFeatureUnsafe, addFeature } = helpers;
|
|
22
|
-
const allowQueryArrays = (_b = (_a = options === null || options === void 0 ? void 0 : options.allowQueryArrays) !== null && _a !== void 0 ? _a : helpers.config.allowQueryArrays) !== null && _b !== void 0 ? _b : true;
|
|
23
|
-
if (!props.customFeatures)
|
|
24
|
-
return;
|
|
25
|
-
Object.entries(props.customFeatures).forEach(([name, value]) => {
|
|
26
|
-
if (value === undefined || value === null)
|
|
27
|
-
return;
|
|
28
|
-
const trimmedName = name.trim();
|
|
29
|
-
if (!trimmedName)
|
|
30
|
-
return;
|
|
31
|
-
if (Array.isArray(value) && !allowQueryArrays) {
|
|
32
|
-
throw new Error(`Custom feature "${trimmedName}" does not allow arrays.`);
|
|
33
|
-
}
|
|
34
|
-
if (Array.isArray(value)) {
|
|
35
|
-
(0, normalizeToArray_1.normalizeToArray)(value).forEach((entry) => {
|
|
36
|
-
(addFeatureUnsafe !== null && addFeatureUnsafe !== void 0 ? addFeatureUnsafe : addFeature)(trimmedName, entry);
|
|
37
|
-
});
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
addFeature(trimmedName, value);
|
|
41
|
-
});
|
|
42
|
-
};
|
|
43
|
-
exports.emitCustomFeatures = emitCustomFeatures;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./aspectRatio"), exports);
|
|
18
|
-
__exportStar(require("./block"), exports);
|
|
19
|
-
__exportStar(require("./custom"), exports);
|
|
20
|
-
__exportStar(require("./inline"), exports);
|
|
21
|
-
__exportStar(require("./style"), exports);
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.emitInlineSizeFeatures = void 0;
|
|
4
|
-
const helpers_1 = require("../helpers");
|
|
5
|
-
const validation_1 = require("../validation");
|
|
6
|
-
const linting_1 = require("../linting");
|
|
7
|
-
const inline_1 = require("../linting/inline");
|
|
8
|
-
const normalizeToArray_1 = require("../../internal/normalizeToArray");
|
|
9
|
-
const emitInlineComparison = (name, comparison, addCondition) => {
|
|
10
|
-
addCondition((0, helpers_1.formatContainerQueryComparison)(name, comparison.operator, comparison.value));
|
|
11
|
-
};
|
|
12
|
-
const emitInlineRange = (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 emitInlineSizeFeatures = (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, validateInlineSizeValues, } = validation_1.defaultContainerQueryValidation;
|
|
31
|
-
if (!runContainerQueryValidation(props, helpers, validateInlineSizeValues, "inline", "inline size values must be valid measurements greater than 0")) {
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
if (!(0, linting_1.runContainerQueryLint)(props, helpers, inline_1.lintInlineRedundancy, "inlineSize should not be combined with inlineSizeRange")) {
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
if (!(0, linting_1.runContainerQueryLint)(props, helpers, inline_1.lintInlineRangeCollapse, "inlineSizeRange min and max are equal; use inlineSize instead")) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
if (!(0, helpers_1.applyContainerQueryValidation)(props, helpers, validate, "inline")) {
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
const { addCondition } = helpers;
|
|
44
|
-
assertNoArray(props.inlineSize, "inlineSize");
|
|
45
|
-
(0, normalizeToArray_1.normalizeToArray)(props.inlineSize).forEach((value) => {
|
|
46
|
-
emitInlineComparison("inline-size", value, addCondition);
|
|
47
|
-
});
|
|
48
|
-
assertNoArray(props.inlineSizeRange, "inlineSizeRange");
|
|
49
|
-
(0, normalizeToArray_1.normalizeToArray)(props.inlineSizeRange).forEach((value) => {
|
|
50
|
-
emitInlineRange("inline-size", value, addCondition);
|
|
51
|
-
});
|
|
52
|
-
};
|
|
53
|
-
exports.emitInlineSizeFeatures = emitInlineSizeFeatures;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.emitStyleFeatures = void 0;
|
|
4
|
-
const helpers_1 = require("../helpers");
|
|
5
|
-
const validation_1 = require("../validation");
|
|
6
|
-
const linting_1 = require("../linting");
|
|
7
|
-
const style_1 = require("../linting/style");
|
|
8
|
-
const emitStyleFeatures = (props, helpers, validate) => {
|
|
9
|
-
const { runContainerQueryValidation, validateStyleValues, } = validation_1.defaultContainerQueryValidation;
|
|
10
|
-
if (!runContainerQueryValidation(props, helpers, validateStyleValues, "style", "style conditions must be valid and non-empty")) {
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
if (!(0, linting_1.runContainerQueryLint)(props, helpers, style_1.lintStyleCondition, "style conditions must be valid and non-empty")) {
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
if (!(0, helpers_1.applyContainerQueryValidation)(props, helpers, validate, "style")) {
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
if (!props.style)
|
|
20
|
-
return;
|
|
21
|
-
const { addCondition } = helpers;
|
|
22
|
-
Object.entries(props.style).forEach(([name, value]) => {
|
|
23
|
-
if (value === undefined || value === null)
|
|
24
|
-
return;
|
|
25
|
-
if (Array.isArray(value)) {
|
|
26
|
-
value.forEach((entry) => {
|
|
27
|
-
if (entry === undefined || entry === null)
|
|
28
|
-
return;
|
|
29
|
-
addCondition(`(style(${name}: ${(0, helpers_1.formatContainerQueryValue)(entry)}))`);
|
|
30
|
-
});
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
addCondition(`(style(${name}: ${(0, helpers_1.formatContainerQueryValue)(value)}))`);
|
|
34
|
-
});
|
|
35
|
-
};
|
|
36
|
-
exports.emitStyleFeatures = emitStyleFeatures;
|
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.defaultContainerQueryValidation = exports.validateCustomFeatures = exports.validateStyleValues = exports.validateAspectRatioValues = exports.validateBlockSizeValues = exports.validateInlineSizeValues = exports.validateHeightValuesPositive = exports.validateMinMaxHeight = exports.validateWidthValuesPositive = exports.validateMinMaxWidth = exports.runContainerQueryValidation = exports.createContainerQueryValidation = void 0;
|
|
4
|
-
const helpers_1 = require("./helpers");
|
|
5
|
-
const core_1 = require("../core");
|
|
6
|
-
const validation_1 = require("../validation");
|
|
7
|
-
const normalizeToArray_1 = require("../internal/normalizeToArray");
|
|
8
|
-
const ratio_1 = require("../ratio");
|
|
9
|
-
const isFiniteNumber = (value) => typeof value === "number" && Number.isFinite(value);
|
|
10
|
-
const assertMeasurement = (value, label) => {
|
|
11
|
-
(0, core_1.assertCondition)((0, core_1.isMeasurement)(value), `${label} must be a measurement`);
|
|
12
|
-
};
|
|
13
|
-
const assertMeasurementPositive = (value, label) => {
|
|
14
|
-
(0, core_1.assertCondition)(value.getValue() > 0, `${label} must be greater than 0`);
|
|
15
|
-
};
|
|
16
|
-
const assertRatio = (value, label) => {
|
|
17
|
-
(0, core_1.assertCondition)((0, core_1.isRatio)(value), `${label} must be a ratio created with r()`);
|
|
18
|
-
};
|
|
19
|
-
const assertRatioPositive = (value, label) => {
|
|
20
|
-
(0, core_1.assertCondition)(value.numerator() > 0, `${label} numerator must be greater than 0`);
|
|
21
|
-
(0, core_1.assertCondition)(value.denominator() > 0, `${label} denominator must be greater than 0`);
|
|
22
|
-
};
|
|
23
|
-
const isStyleValue = (value) => {
|
|
24
|
-
if (typeof value === "string")
|
|
25
|
-
return true;
|
|
26
|
-
if (isFiniteNumber(value))
|
|
27
|
-
return true;
|
|
28
|
-
if ((0, core_1.hasCssMethod)(value))
|
|
29
|
-
return true;
|
|
30
|
-
return false;
|
|
31
|
-
};
|
|
32
|
-
const createContainerQueryValidation = (core) => {
|
|
33
|
-
const assertCondition = core.assertCondition;
|
|
34
|
-
const assertMatchingUnits = core.assertMatchingUnits;
|
|
35
|
-
const runContainerQueryValidation = (config, helpers, check, context, fallbackMessage = "Invalid container query configuration") => {
|
|
36
|
-
if (!check)
|
|
37
|
-
return true;
|
|
38
|
-
try {
|
|
39
|
-
check(config);
|
|
40
|
-
return true;
|
|
41
|
-
}
|
|
42
|
-
catch (error) {
|
|
43
|
-
const result = (0, validation_1.toValidationResult)(error, fallbackMessage);
|
|
44
|
-
return (0, helpers_1.applyContainerQueryValidation)(config, helpers, () => result, context);
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
const validateMinMaxWidth = (props) => {
|
|
48
|
-
if (!props.minWidth || !props.maxWidth)
|
|
49
|
-
return;
|
|
50
|
-
if (Array.isArray(props.minWidth) || Array.isArray(props.maxWidth)) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
assertMatchingUnits(props.minWidth, props.maxWidth, "containerQueries.minMaxWidth");
|
|
54
|
-
assertCondition(props.minWidth.getValue() <= props.maxWidth.getValue(), "minWidth must be less than or equal to maxWidth");
|
|
55
|
-
};
|
|
56
|
-
const validateWidthValuesPositive = (props) => {
|
|
57
|
-
(0, normalizeToArray_1.normalizeToArray)(props.minWidth).forEach((value) => {
|
|
58
|
-
assertMeasurement(value, "minWidth");
|
|
59
|
-
assertMeasurementPositive(value, "minWidth");
|
|
60
|
-
});
|
|
61
|
-
(0, normalizeToArray_1.normalizeToArray)(props.maxWidth).forEach((value) => {
|
|
62
|
-
assertMeasurement(value, "maxWidth");
|
|
63
|
-
assertMeasurementPositive(value, "maxWidth");
|
|
64
|
-
});
|
|
65
|
-
};
|
|
66
|
-
const validateMinMaxHeight = (props) => {
|
|
67
|
-
if (!props.minHeight || !props.maxHeight)
|
|
68
|
-
return;
|
|
69
|
-
if (Array.isArray(props.minHeight) || Array.isArray(props.maxHeight)) {
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
assertMatchingUnits(props.minHeight, props.maxHeight, "containerQueries.minMaxHeight");
|
|
73
|
-
assertCondition(props.minHeight.getValue() <= props.maxHeight.getValue(), "minHeight must be less than or equal to maxHeight");
|
|
74
|
-
};
|
|
75
|
-
const validateHeightValuesPositive = (props) => {
|
|
76
|
-
(0, normalizeToArray_1.normalizeToArray)(props.minHeight).forEach((value) => {
|
|
77
|
-
assertMeasurement(value, "minHeight");
|
|
78
|
-
assertMeasurementPositive(value, "minHeight");
|
|
79
|
-
});
|
|
80
|
-
(0, normalizeToArray_1.normalizeToArray)(props.maxHeight).forEach((value) => {
|
|
81
|
-
assertMeasurement(value, "maxHeight");
|
|
82
|
-
assertMeasurementPositive(value, "maxHeight");
|
|
83
|
-
});
|
|
84
|
-
};
|
|
85
|
-
const validateInlineSizeValues = (props) => {
|
|
86
|
-
(0, normalizeToArray_1.normalizeToArray)(props.inlineSize).forEach((value) => {
|
|
87
|
-
assertMeasurement(value.value, "inlineSize");
|
|
88
|
-
assertMeasurementPositive(value.value, "inlineSize");
|
|
89
|
-
});
|
|
90
|
-
(0, normalizeToArray_1.normalizeToArray)(props.inlineSizeRange).forEach((value) => {
|
|
91
|
-
assertMeasurement(value.min, "inlineSizeRange.min");
|
|
92
|
-
assertMeasurement(value.max, "inlineSizeRange.max");
|
|
93
|
-
assertMeasurementPositive(value.min, "inlineSizeRange.min");
|
|
94
|
-
assertMeasurementPositive(value.max, "inlineSizeRange.max");
|
|
95
|
-
assertMatchingUnits(value.min, value.max, "containerQueries.inlineSizeRangeUnits");
|
|
96
|
-
assertCondition(value.min.getValue() <= value.max.getValue(), "inlineSizeRange min must be less than or equal to max");
|
|
97
|
-
});
|
|
98
|
-
};
|
|
99
|
-
const validateBlockSizeValues = (props) => {
|
|
100
|
-
(0, normalizeToArray_1.normalizeToArray)(props.blockSize).forEach((value) => {
|
|
101
|
-
assertMeasurement(value.value, "blockSize");
|
|
102
|
-
assertMeasurementPositive(value.value, "blockSize");
|
|
103
|
-
});
|
|
104
|
-
(0, normalizeToArray_1.normalizeToArray)(props.blockSizeRange).forEach((value) => {
|
|
105
|
-
assertMeasurement(value.min, "blockSizeRange.min");
|
|
106
|
-
assertMeasurement(value.max, "blockSizeRange.max");
|
|
107
|
-
assertMeasurementPositive(value.min, "blockSizeRange.min");
|
|
108
|
-
assertMeasurementPositive(value.max, "blockSizeRange.max");
|
|
109
|
-
assertMatchingUnits(value.min, value.max, "containerQueries.blockSizeRangeUnits");
|
|
110
|
-
assertCondition(value.min.getValue() <= value.max.getValue(), "blockSizeRange min must be less than or equal to max");
|
|
111
|
-
});
|
|
112
|
-
};
|
|
113
|
-
const validateAspectRatioValues = (props) => {
|
|
114
|
-
(0, normalizeToArray_1.normalizeToArray)(props.aspectRatio).forEach((value) => {
|
|
115
|
-
assertRatio(value, "aspectRatio");
|
|
116
|
-
assertRatioPositive(value, "aspectRatio");
|
|
117
|
-
});
|
|
118
|
-
(0, normalizeToArray_1.normalizeToArray)(props.minAspectRatio).forEach((value) => {
|
|
119
|
-
assertRatio(value, "minAspectRatio");
|
|
120
|
-
assertRatioPositive(value, "minAspectRatio");
|
|
121
|
-
});
|
|
122
|
-
(0, normalizeToArray_1.normalizeToArray)(props.maxAspectRatio).forEach((value) => {
|
|
123
|
-
assertRatio(value, "maxAspectRatio");
|
|
124
|
-
assertRatioPositive(value, "maxAspectRatio");
|
|
125
|
-
});
|
|
126
|
-
if (props.minAspectRatio &&
|
|
127
|
-
props.maxAspectRatio &&
|
|
128
|
-
!Array.isArray(props.minAspectRatio) &&
|
|
129
|
-
!Array.isArray(props.maxAspectRatio)) {
|
|
130
|
-
const minValue = (0, ratio_1.ratioToFloat)(props.minAspectRatio);
|
|
131
|
-
const maxValue = (0, ratio_1.ratioToFloat)(props.maxAspectRatio);
|
|
132
|
-
assertCondition(minValue <= maxValue, "minAspectRatio must be less than or equal to maxAspectRatio");
|
|
133
|
-
}
|
|
134
|
-
};
|
|
135
|
-
const validateStyleValues = (props) => {
|
|
136
|
-
if (!props.style)
|
|
137
|
-
return;
|
|
138
|
-
const entries = Object.entries(props.style);
|
|
139
|
-
assertCondition(entries.length > 0, "style conditions must not be empty.");
|
|
140
|
-
entries.forEach(([name, value]) => {
|
|
141
|
-
if (value === undefined || value === null)
|
|
142
|
-
return;
|
|
143
|
-
if (Array.isArray(value)) {
|
|
144
|
-
assertCondition(value.length > 0, `style.${name} must not be empty`);
|
|
145
|
-
value.forEach((entry, index) => {
|
|
146
|
-
assertCondition(isStyleValue(entry), `style.${name}[${index}] must be a primitive or measurement`);
|
|
147
|
-
});
|
|
148
|
-
return;
|
|
149
|
-
}
|
|
150
|
-
assertCondition(isStyleValue(value), `style.${name} must be a primitive or measurement`);
|
|
151
|
-
});
|
|
152
|
-
};
|
|
153
|
-
const validateCustomFeatures = (props) => {
|
|
154
|
-
if (!props.customFeatures)
|
|
155
|
-
return;
|
|
156
|
-
const entries = Object.entries(props.customFeatures);
|
|
157
|
-
assertCondition(entries.length > 0, "customFeatures should not be empty.");
|
|
158
|
-
entries.forEach(([name, value]) => {
|
|
159
|
-
const trimmedName = name.trim();
|
|
160
|
-
assertCondition(trimmedName.length > 0, "Custom feature name must be non-empty.");
|
|
161
|
-
if (value === undefined || value === null)
|
|
162
|
-
return;
|
|
163
|
-
if (Array.isArray(value)) {
|
|
164
|
-
value.forEach((entry, index) => {
|
|
165
|
-
assertCondition(isStyleValue(entry), `Custom feature "${trimmedName}[${index}]" must be a primitive or a measurement.`);
|
|
166
|
-
});
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
169
|
-
assertCondition(isStyleValue(value), `Custom feature "${trimmedName}" must be a primitive or a measurement.`);
|
|
170
|
-
});
|
|
171
|
-
};
|
|
172
|
-
return {
|
|
173
|
-
runContainerQueryValidation,
|
|
174
|
-
validateMinMaxWidth,
|
|
175
|
-
validateWidthValuesPositive,
|
|
176
|
-
validateMinMaxHeight,
|
|
177
|
-
validateHeightValuesPositive,
|
|
178
|
-
validateInlineSizeValues,
|
|
179
|
-
validateBlockSizeValues,
|
|
180
|
-
validateAspectRatioValues,
|
|
181
|
-
validateStyleValues,
|
|
182
|
-
validateCustomFeatures,
|
|
183
|
-
};
|
|
184
|
-
};
|
|
185
|
-
exports.createContainerQueryValidation = createContainerQueryValidation;
|
|
186
|
-
const defaultContainerQueryValidation = (0, exports.createContainerQueryValidation)({
|
|
187
|
-
assertCondition: core_1.assertCondition,
|
|
188
|
-
assertMatchingUnits: core_1.assertMatchingUnits,
|
|
189
|
-
});
|
|
190
|
-
exports.defaultContainerQueryValidation = defaultContainerQueryValidation;
|
|
191
|
-
exports.runContainerQueryValidation = defaultContainerQueryValidation.runContainerQueryValidation, exports.validateMinMaxWidth = defaultContainerQueryValidation.validateMinMaxWidth, exports.validateWidthValuesPositive = defaultContainerQueryValidation.validateWidthValuesPositive, exports.validateMinMaxHeight = defaultContainerQueryValidation.validateMinMaxHeight, exports.validateHeightValuesPositive = defaultContainerQueryValidation.validateHeightValuesPositive, exports.validateInlineSizeValues = defaultContainerQueryValidation.validateInlineSizeValues, exports.validateBlockSizeValues = defaultContainerQueryValidation.validateBlockSizeValues, exports.validateAspectRatioValues = defaultContainerQueryValidation.validateAspectRatioValues, exports.validateStyleValues = defaultContainerQueryValidation.validateStyleValues, exports.validateCustomFeatures = defaultContainerQueryValidation.validateCustomFeatures;
|