css-calipers 0.9.3 → 0.9.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +100 -0
- package/dist/cjs/comparisons/index.js +25 -0
- package/dist/cjs/containerQueries/containerQueries.js +115 -0
- package/dist/cjs/containerQueries/factory.js +123 -0
- package/dist/cjs/containerQueries/helpers.js +95 -0
- package/dist/cjs/containerQueries/index.js +16 -0
- package/dist/cjs/containerQueries/linting/aspectRatio.js +24 -0
- package/dist/cjs/containerQueries/linting/block.js +23 -0
- package/dist/cjs/containerQueries/linting/core.js +25 -0
- package/dist/cjs/containerQueries/linting/custom.js +11 -0
- package/dist/cjs/containerQueries/linting/inline.js +23 -0
- package/dist/cjs/containerQueries/linting/resolution.js +12 -0
- package/dist/cjs/containerQueries/linting/style.js +28 -0
- package/dist/cjs/containerQueries/linting.js +24 -0
- package/dist/cjs/containerQueries/moduleRegistry.js +5 -0
- package/dist/cjs/containerQueries/modules/aspectRatio.js +51 -0
- package/dist/cjs/containerQueries/modules/block.js +53 -0
- package/dist/cjs/containerQueries/modules/custom.js +43 -0
- package/dist/cjs/containerQueries/modules/index.js +21 -0
- package/dist/cjs/containerQueries/modules/inline.js +53 -0
- package/dist/cjs/containerQueries/modules/size.js +2 -0
- package/dist/cjs/containerQueries/modules/style.js +36 -0
- package/dist/cjs/containerQueries/types.js +2 -0
- package/dist/cjs/containerQueries/validation.js +191 -0
- package/dist/cjs/core.js +5 -278
- package/dist/cjs/factory.js +21 -0
- package/dist/cjs/fraction.js +139 -0
- package/dist/cjs/internal/buildMeasurementCreationError.js +16 -0
- package/dist/cjs/internal/buildMeasurementCreationError.tests.js +5 -0
- package/dist/cjs/internal/createComponentQueriesApi.js +56 -0
- package/dist/cjs/internal/createCoreApi.js +336 -0
- package/dist/cjs/internal/createMediaQueriesApi.js +74 -0
- package/dist/cjs/internal/createUnitsApi.js +18 -0
- package/dist/cjs/internal/errors.js +118 -5
- package/dist/cjs/internal/normalizeToArray.js +9 -0
- package/dist/cjs/libraryHelpers/vanilla-extract.js +6 -2
- package/dist/cjs/logicalOperators/index.js +18 -0
- package/dist/cjs/mediaQueries/factory.js +5 -4
- package/dist/cjs/mediaQueries/mediaQueries.js +7 -5
- package/dist/cjs/mediaQueries/modules/dimensions.js +10 -8
- package/dist/cjs/mediaQueries/modules/resolution.js +6 -4
- package/dist/cjs/mediaQueries/validation.js +128 -116
- package/dist/cjs/ratio.js +141 -0
- package/dist/cjs/types.js +2 -0
- package/dist/cjs/validation.js +20 -0
- package/dist/esm/comparisons/index.d.ts +23 -0
- package/dist/esm/comparisons/index.d.ts.map +1 -0
- package/dist/esm/comparisons/index.js +22 -0
- package/dist/esm/containerQueries/containerQueries.d.ts +36 -0
- package/dist/esm/containerQueries/containerQueries.d.ts.map +1 -0
- package/dist/esm/containerQueries/containerQueries.js +109 -0
- package/dist/esm/containerQueries/factory.d.ts +20 -0
- package/dist/esm/containerQueries/factory.d.ts.map +1 -0
- package/dist/esm/containerQueries/factory.js +119 -0
- package/dist/esm/containerQueries/helpers.d.ts +53 -0
- package/dist/esm/containerQueries/helpers.d.ts.map +1 -0
- package/dist/esm/containerQueries/helpers.js +82 -0
- package/dist/esm/containerQueries/index.d.ts +10 -0
- package/dist/esm/containerQueries/index.d.ts.map +1 -0
- package/dist/esm/containerQueries/index.js +4 -0
- package/dist/esm/containerQueries/linting/aspectRatio.d.ts +4 -0
- package/dist/esm/containerQueries/linting/aspectRatio.d.ts.map +1 -0
- package/dist/esm/containerQueries/linting/aspectRatio.js +19 -0
- package/dist/esm/containerQueries/linting/block.d.ts +4 -0
- package/dist/esm/containerQueries/linting/block.d.ts.map +1 -0
- package/dist/esm/containerQueries/linting/block.js +18 -0
- package/dist/esm/containerQueries/linting/core.d.ts +4 -0
- package/dist/esm/containerQueries/linting/core.d.ts.map +1 -0
- package/dist/esm/containerQueries/linting/core.js +20 -0
- package/dist/esm/containerQueries/linting/custom.d.ts +3 -0
- package/dist/esm/containerQueries/linting/custom.d.ts.map +1 -0
- package/dist/esm/containerQueries/linting/custom.js +7 -0
- package/dist/esm/containerQueries/linting/inline.d.ts +4 -0
- package/dist/esm/containerQueries/linting/inline.d.ts.map +1 -0
- package/dist/esm/containerQueries/linting/inline.js +18 -0
- package/dist/esm/containerQueries/linting/resolution.d.ts +1 -0
- package/dist/esm/containerQueries/linting/resolution.d.ts.map +1 -0
- package/dist/esm/containerQueries/linting/resolution.js +12 -0
- package/dist/esm/containerQueries/linting/style.d.ts +3 -0
- package/dist/esm/containerQueries/linting/style.d.ts.map +1 -0
- package/dist/esm/containerQueries/linting/style.js +24 -0
- package/dist/esm/containerQueries/linting.d.ts +4 -0
- package/dist/esm/containerQueries/linting.d.ts.map +1 -0
- package/dist/esm/containerQueries/linting.js +20 -0
- package/dist/esm/containerQueries/moduleRegistry.d.ts +25 -0
- package/dist/esm/containerQueries/moduleRegistry.d.ts.map +1 -0
- package/dist/esm/containerQueries/moduleRegistry.js +1 -0
- package/dist/esm/containerQueries/modules/aspectRatio.d.ts +17 -0
- package/dist/esm/containerQueries/modules/aspectRatio.d.ts.map +1 -0
- package/dist/esm/containerQueries/modules/aspectRatio.js +47 -0
- package/dist/esm/containerQueries/modules/block.d.ts +20 -0
- package/dist/esm/containerQueries/modules/block.d.ts.map +1 -0
- package/dist/esm/containerQueries/modules/block.js +49 -0
- package/dist/esm/containerQueries/modules/custom.d.ts +13 -0
- package/dist/esm/containerQueries/modules/custom.d.ts.map +1 -0
- package/dist/esm/containerQueries/modules/custom.js +39 -0
- package/dist/esm/containerQueries/modules/index.d.ts +6 -0
- package/dist/esm/containerQueries/modules/index.d.ts.map +1 -0
- package/dist/esm/containerQueries/modules/index.js +5 -0
- package/dist/esm/containerQueries/modules/inline.d.ts +20 -0
- package/dist/esm/containerQueries/modules/inline.d.ts.map +1 -0
- package/dist/esm/containerQueries/modules/inline.js +49 -0
- package/dist/esm/containerQueries/modules/size.d.ts +41 -0
- package/dist/esm/containerQueries/modules/size.d.ts.map +1 -0
- package/dist/esm/containerQueries/modules/size.js +1 -0
- package/dist/esm/containerQueries/modules/style.d.ts +11 -0
- package/dist/esm/containerQueries/modules/style.d.ts.map +1 -0
- package/dist/esm/containerQueries/modules/style.js +32 -0
- package/dist/esm/containerQueries/types.d.ts +81 -0
- package/dist/esm/containerQueries/types.d.ts.map +1 -0
- package/dist/esm/containerQueries/types.js +1 -0
- package/dist/esm/containerQueries/validation.d.ts +41 -0
- package/dist/esm/containerQueries/validation.d.ts.map +1 -0
- package/dist/esm/containerQueries/validation.js +187 -0
- package/dist/esm/core.d.ts +27 -26
- package/dist/esm/core.d.ts.map +1 -1
- package/dist/esm/core.js +5 -266
- package/dist/esm/factory.d.ts +13 -0
- package/dist/esm/factory.d.ts.map +1 -0
- package/dist/esm/factory.js +17 -0
- package/dist/esm/fraction.d.ts +23 -0
- package/dist/esm/fraction.d.ts.map +1 -0
- package/dist/esm/fraction.js +129 -0
- package/dist/esm/internal/buildMeasurementCreationError.d.ts +12 -0
- package/dist/esm/internal/buildMeasurementCreationError.d.ts.map +1 -0
- package/dist/esm/internal/buildMeasurementCreationError.js +12 -0
- package/dist/esm/internal/buildMeasurementCreationError.tests.d.ts +3 -0
- package/dist/esm/internal/buildMeasurementCreationError.tests.d.ts.map +1 -0
- package/dist/esm/internal/buildMeasurementCreationError.tests.js +1 -0
- package/dist/esm/internal/createComponentQueriesApi.d.ts +34 -0
- package/dist/esm/internal/createComponentQueriesApi.d.ts.map +1 -0
- package/dist/esm/internal/createComponentQueriesApi.js +52 -0
- package/dist/esm/internal/createCoreApi.d.ts +289 -0
- package/dist/esm/internal/createCoreApi.d.ts.map +1 -0
- package/dist/esm/internal/createCoreApi.js +332 -0
- package/dist/esm/internal/createMediaQueriesApi.d.ts +35 -0
- package/dist/esm/internal/createMediaQueriesApi.d.ts.map +1 -0
- package/dist/esm/internal/createMediaQueriesApi.js +70 -0
- package/dist/esm/internal/createUnitsApi.d.ts +13 -0
- package/dist/esm/internal/createUnitsApi.d.ts.map +1 -0
- package/dist/esm/internal/createUnitsApi.js +14 -0
- package/dist/esm/internal/errors.d.ts +30 -0
- package/dist/esm/internal/errors.d.ts.map +1 -1
- package/dist/esm/internal/errors.js +113 -4
- package/dist/esm/internal/normalizeToArray.d.ts +2 -0
- package/dist/esm/internal/normalizeToArray.d.ts.map +1 -0
- package/dist/esm/internal/normalizeToArray.js +5 -0
- package/dist/esm/libraryHelpers/vanilla-extract.d.ts +2 -1
- package/dist/esm/libraryHelpers/vanilla-extract.d.ts.map +1 -1
- package/dist/esm/libraryHelpers/vanilla-extract.js +4 -1
- package/dist/esm/logicalOperators/index.d.ts +2 -0
- package/dist/esm/logicalOperators/index.d.ts.map +1 -0
- package/dist/esm/logicalOperators/index.js +17 -0
- package/dist/esm/mediaQueries/factory.d.ts +16 -1
- package/dist/esm/mediaQueries/factory.d.ts.map +1 -1
- package/dist/esm/mediaQueries/factory.js +3 -2
- package/dist/esm/mediaQueries/libraryHelpers/vanilla-extract.d.ts +2 -2
- package/dist/esm/mediaQueries/libraryHelpers/vanilla-extract.d.ts.map +1 -1
- package/dist/esm/mediaQueries/mediaQueries.d.ts +2 -0
- package/dist/esm/mediaQueries/mediaQueries.d.ts.map +1 -1
- package/dist/esm/mediaQueries/mediaQueries.js +4 -2
- package/dist/esm/mediaQueries/modules/dimensions.d.ts +2 -0
- package/dist/esm/mediaQueries/modules/dimensions.d.ts.map +1 -1
- package/dist/esm/mediaQueries/modules/dimensions.js +4 -2
- package/dist/esm/mediaQueries/modules/resolution.d.ts +2 -0
- package/dist/esm/mediaQueries/modules/resolution.d.ts.map +1 -1
- package/dist/esm/mediaQueries/modules/resolution.js +4 -2
- package/dist/esm/mediaQueries/validation.d.ts +28 -8
- package/dist/esm/mediaQueries/validation.d.ts.map +1 -1
- package/dist/esm/mediaQueries/validation.js +126 -107
- package/dist/esm/ratio.d.ts +22 -0
- package/dist/esm/ratio.d.ts.map +1 -0
- package/dist/esm/ratio.js +131 -0
- package/dist/esm/types.d.ts +35 -0
- package/dist/esm/types.d.ts.map +1 -0
- package/dist/esm/types.js +1 -0
- package/dist/esm/validation.d.ts +10 -0
- package/dist/esm/validation.d.ts.map +1 -0
- package/dist/esm/validation.js +15 -0
- package/dist/examples/containerQueries.example.js +54 -0
- package/dist/examples/examples/containerQueries.example.js +54 -0
- package/dist/examples/examples/factory-wrapper.example.js +33 -0
- package/dist/examples/examples/lineHeight-normalizer.example.js +81 -0
- package/dist/examples/examples/mediaQueries-multipleInstances.example.js +127 -0
- package/dist/examples/examples/mixedQueries.example.js +55 -0
- package/dist/examples/examples/validation-and-runtime-checks.example.js +85 -0
- package/dist/examples/examples/validation-unit-tests.example.js +35 -0
- package/dist/examples/factory-wrapper.example.js +33 -0
- package/dist/examples/lineHeight-normalizer.example.js +81 -0
- package/dist/examples/mediaQueries-multipleInstances.example.js +127 -0
- package/dist/examples/mixedQueries.example.js +60 -0
- package/dist/examples/src/comparisons/index.js +25 -0
- package/dist/examples/src/containerQueries/containerQueries.js +96 -0
- package/dist/examples/src/containerQueries/factory.js +123 -0
- package/dist/examples/src/containerQueries/helpers.js +94 -0
- package/dist/examples/src/containerQueries/index.js +16 -0
- package/dist/examples/src/containerQueries/linting/aspectRatio.js +20 -0
- package/dist/examples/src/containerQueries/linting/block.js +20 -0
- package/dist/examples/src/containerQueries/linting/core.js +19 -0
- package/dist/examples/src/containerQueries/linting/custom.js +11 -0
- package/dist/examples/src/containerQueries/linting/inline.js +20 -0
- package/dist/examples/src/containerQueries/linting/style.js +28 -0
- package/dist/examples/src/containerQueries/linting.js +24 -0
- package/dist/examples/src/containerQueries/moduleRegistry.js +5 -0
- package/dist/examples/src/containerQueries/modules/aspectRatio.js +33 -0
- package/dist/examples/src/containerQueries/modules/block.js +44 -0
- package/dist/examples/src/containerQueries/modules/custom.js +31 -0
- package/dist/examples/src/containerQueries/modules/index.js +21 -0
- package/dist/examples/src/containerQueries/modules/inline.js +44 -0
- package/dist/examples/src/containerQueries/modules/style.js +36 -0
- package/dist/examples/src/containerQueries/types.js +2 -0
- package/dist/examples/src/containerQueries/validation.js +177 -0
- package/dist/examples/src/core.js +16 -0
- package/dist/examples/src/factory.js +21 -0
- package/dist/examples/src/index.js +30 -0
- package/dist/examples/src/internal/buildMeasurementCreationError.js +16 -0
- package/dist/examples/src/internal/createCoreApi.js +336 -0
- package/dist/examples/src/internal/createMediaQueriesApi.js +74 -0
- package/dist/examples/src/internal/createUnitsApi.js +18 -0
- package/dist/examples/src/internal/errors.js +130 -0
- package/dist/examples/src/libraryHelpers/vanilla-extract.js +11 -0
- package/dist/examples/src/mediaQueries/factory.js +163 -0
- package/dist/examples/src/mediaQueries/helpers.js +88 -0
- package/dist/examples/src/mediaQueries/index.js +23 -0
- package/dist/examples/src/mediaQueries/linting/core.js +19 -0
- package/dist/examples/src/mediaQueries/linting/resolution.js +11 -0
- package/dist/examples/src/mediaQueries/linting.js +24 -0
- package/dist/examples/src/mediaQueries/mediaQueries.js +53 -0
- package/dist/examples/src/mediaQueries/moduleRegistry.js +5 -0
- package/dist/examples/src/mediaQueries/modules/custom.js +26 -0
- package/dist/examples/src/mediaQueries/modules/dimensions.js +61 -0
- package/dist/examples/src/mediaQueries/modules/display.js +20 -0
- package/dist/examples/src/mediaQueries/modules/environment.js +20 -0
- package/dist/examples/src/mediaQueries/modules/index.js +23 -0
- package/dist/examples/src/mediaQueries/modules/interaction.js +26 -0
- package/dist/examples/src/mediaQueries/modules/preferences.js +26 -0
- package/dist/examples/src/mediaQueries/modules/resolution.js +31 -0
- package/dist/examples/src/mediaQueries/types.js +2 -0
- package/dist/examples/src/mediaQueries/validation.js +128 -0
- package/dist/examples/src/ratio.js +141 -0
- package/dist/examples/src/types.js +2 -0
- package/dist/examples/src/unitDefinitions.js +67 -0
- package/dist/examples/src/units/absolute.js +11 -0
- package/dist/examples/src/units/angle.js +8 -0
- package/dist/examples/src/units/container.js +10 -0
- package/dist/examples/src/units/font-relative.js +16 -0
- package/dist/examples/src/units/frequency.js +6 -0
- package/dist/examples/src/units/grid.js +5 -0
- package/dist/examples/src/units/percent.js +7 -0
- package/dist/examples/src/units/resolution.js +7 -0
- package/dist/examples/src/units/time.js +6 -0
- package/dist/examples/src/units/viewport-dynamic.js +10 -0
- package/dist/examples/src/units/viewport-large.js +10 -0
- package/dist/examples/src/units/viewport-small.js +10 -0
- package/dist/examples/src/units/viewport.js +10 -0
- package/dist/examples/src/validation.js +20 -0
- package/dist/examples/validation-and-runtime-checks.example.js +85 -0
- package/dist/examples/validation-unit-tests.example.js +35 -0
- package/package.json +16 -5
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createMediaQueriesApi = void 0;
|
|
4
|
+
const helpers_1 = require("../mediaQueries/helpers");
|
|
5
|
+
const validation_1 = require("../mediaQueries/validation");
|
|
6
|
+
const mediaQueries_1 = require("../mediaQueries/mediaQueries");
|
|
7
|
+
const modules_1 = require("../mediaQueries/modules");
|
|
8
|
+
const resolution_1 = require("../mediaQueries/modules/resolution");
|
|
9
|
+
const factory_1 = require("../mediaQueries/factory");
|
|
10
|
+
const vanilla_extract_1 = require("../libraryHelpers/vanilla-extract");
|
|
11
|
+
const createMediaQueriesApi = (core) => {
|
|
12
|
+
const validation = (0, validation_1.createMediaQueryValidation)({
|
|
13
|
+
assertCondition: core.assertCondition,
|
|
14
|
+
assertMatchingUnits: core.assertMatchingUnits,
|
|
15
|
+
});
|
|
16
|
+
const emitCoreFeatures = (0, mediaQueries_1.createEmitCoreFeatures)(validation);
|
|
17
|
+
const emitDimensionsFeatures = (0, modules_1.createEmitDimensionsFeatures)(validation);
|
|
18
|
+
const emitResolutionFeatures = (0, resolution_1.createEmitResolutionFeatures)(validation);
|
|
19
|
+
const emitBaseFeatures = (props, helpers) => {
|
|
20
|
+
emitCoreFeatures(props, helpers);
|
|
21
|
+
emitDimensionsFeatures(props, helpers);
|
|
22
|
+
emitResolutionFeatures(props, helpers);
|
|
23
|
+
(0, modules_1.emitInteractionFeatures)(props, helpers);
|
|
24
|
+
(0, modules_1.emitPreferencesFeatures)(props, helpers);
|
|
25
|
+
(0, modules_1.emitDisplayFeatures)(props, helpers);
|
|
26
|
+
(0, modules_1.emitEnvironmentFeatures)(props, helpers);
|
|
27
|
+
(0, modules_1.emitCustomFeatures)(props, helpers);
|
|
28
|
+
};
|
|
29
|
+
const buildMediaQueryString = (0, helpers_1.createMediaQueryBuilder)({
|
|
30
|
+
emitBase: emitBaseFeatures,
|
|
31
|
+
resolveType: (props) => props.type,
|
|
32
|
+
});
|
|
33
|
+
const makeMediaQueryStyle = (queries) => (stylesByQuery) => {
|
|
34
|
+
const result = {};
|
|
35
|
+
Object.keys(stylesByQuery).forEach((key) => {
|
|
36
|
+
const styles = stylesByQuery[key];
|
|
37
|
+
const props = queries[key];
|
|
38
|
+
if (!styles || !props)
|
|
39
|
+
return;
|
|
40
|
+
result[buildMediaQueryString(props)] = styles;
|
|
41
|
+
});
|
|
42
|
+
const mediaQuery = {
|
|
43
|
+
"@media": result,
|
|
44
|
+
};
|
|
45
|
+
return mediaQuery;
|
|
46
|
+
};
|
|
47
|
+
const moduleEmitters = {
|
|
48
|
+
core: emitCoreFeatures,
|
|
49
|
+
dimensions: emitDimensionsFeatures,
|
|
50
|
+
resolution: emitResolutionFeatures,
|
|
51
|
+
interaction: modules_1.emitInteractionFeatures,
|
|
52
|
+
preferences: modules_1.emitPreferencesFeatures,
|
|
53
|
+
display: modules_1.emitDisplayFeatures,
|
|
54
|
+
environment: modules_1.emitEnvironmentFeatures,
|
|
55
|
+
custom: modules_1.emitCustomFeatures,
|
|
56
|
+
};
|
|
57
|
+
const mediaQueryFactory = (0, factory_1.createMediaQueryFactory)(moduleEmitters);
|
|
58
|
+
return {
|
|
59
|
+
buildMediaQueryString,
|
|
60
|
+
makeMediaQueryStyle,
|
|
61
|
+
mediaQueryFactory,
|
|
62
|
+
emitCoreFeatures,
|
|
63
|
+
emitDimensionsFeatures,
|
|
64
|
+
emitResolutionFeatures,
|
|
65
|
+
emitInteractionFeatures: modules_1.emitInteractionFeatures,
|
|
66
|
+
emitPreferencesFeatures: modules_1.emitPreferencesFeatures,
|
|
67
|
+
emitDisplayFeatures: modules_1.emitDisplayFeatures,
|
|
68
|
+
emitEnvironmentFeatures: modules_1.emitEnvironmentFeatures,
|
|
69
|
+
emitCustomFeatures: modules_1.emitCustomFeatures,
|
|
70
|
+
mediaQueryOutputVanillaExtract: vanilla_extract_1.mediaQueryOutputVanillaExtract,
|
|
71
|
+
createMediaQueryBuilder: helpers_1.createMediaQueryBuilder,
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
exports.createMediaQueriesApi = createMediaQueriesApi;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createUnitsApi = void 0;
|
|
4
|
+
const unitDefinitions_1 = require("../unitDefinitions");
|
|
5
|
+
const createUnitsApi = (core) => {
|
|
6
|
+
const helpers = Object.keys(unitDefinitions_1.UNIT_DEFINITIONS).reduce((acc, name) => {
|
|
7
|
+
const helperName = name;
|
|
8
|
+
acc[helperName] = core.makeUnitHelperFromDefinition(helperName);
|
|
9
|
+
return acc;
|
|
10
|
+
}, {});
|
|
11
|
+
const mPercent = helpers.mPercent;
|
|
12
|
+
return {
|
|
13
|
+
...helpers,
|
|
14
|
+
isPercentMeasurement: core.makeUnitGuard(mPercent),
|
|
15
|
+
assertPercentMeasurement: core.makeUnitAssert(mPercent),
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
exports.createUnitsApi = createUnitsApi;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.throwHelperError = exports.throwMeasurementMethodError = exports.createErrorHelpers = exports.getErrorConfig = exports.setErrorConfig = exports.createErrorConfigStore = void 0;
|
|
4
|
+
const DEFAULT_ERROR_CONFIG = {
|
|
5
|
+
stackHints: "auto",
|
|
6
|
+
};
|
|
7
|
+
let errorConfig = { ...DEFAULT_ERROR_CONFIG };
|
|
8
|
+
const createErrorConfigStore = (initial = {}) => {
|
|
9
|
+
let config = {
|
|
10
|
+
...DEFAULT_ERROR_CONFIG,
|
|
11
|
+
...initial,
|
|
12
|
+
};
|
|
13
|
+
return {
|
|
14
|
+
getErrorConfig: () => config,
|
|
15
|
+
setErrorConfig: (next) => {
|
|
16
|
+
config = { ...config, ...next };
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
exports.createErrorConfigStore = createErrorConfigStore;
|
|
21
|
+
const setErrorConfig = (next) => {
|
|
22
|
+
errorConfig = { ...errorConfig, ...next };
|
|
23
|
+
};
|
|
24
|
+
exports.setErrorConfig = setErrorConfig;
|
|
25
|
+
const getErrorConfig = () => errorConfig;
|
|
26
|
+
exports.getErrorConfig = getErrorConfig;
|
|
27
|
+
const createErrorHelpers = (store) => {
|
|
28
|
+
const getConfig = () => store.getErrorConfig();
|
|
29
|
+
const throwMeasurementMethodError = (ctx) => {
|
|
30
|
+
const includeStack = shouldIncludeStackHint(ctx.includeStackHint, getConfig());
|
|
31
|
+
const stackHint = includeStack
|
|
32
|
+
? extractStackHint(new Error().stack)
|
|
33
|
+
: undefined;
|
|
34
|
+
throw new Error(formatErrorMessage(ctx.operation, ctx.message, ctx.context, {
|
|
35
|
+
...ctx.details,
|
|
36
|
+
stackHint,
|
|
37
|
+
}));
|
|
38
|
+
};
|
|
39
|
+
const throwHelperError = (ctx) => {
|
|
40
|
+
const includeStack = shouldIncludeStackHint(ctx.includeStackHint, getConfig());
|
|
41
|
+
const stackHint = includeStack
|
|
42
|
+
? extractStackHint(new Error().stack)
|
|
43
|
+
: undefined;
|
|
44
|
+
throw new Error(formatErrorMessage(ctx.operation, ctx.message, ctx.context, {
|
|
45
|
+
...ctx.details,
|
|
46
|
+
stackHint,
|
|
47
|
+
}));
|
|
48
|
+
};
|
|
49
|
+
return { throwMeasurementMethodError, throwHelperError };
|
|
50
|
+
};
|
|
51
|
+
exports.createErrorHelpers = createErrorHelpers;
|
|
52
|
+
const isProductionEnv = () => {
|
|
53
|
+
var _a;
|
|
54
|
+
if (typeof globalThis === "undefined")
|
|
55
|
+
return false;
|
|
56
|
+
const maybeProcess = globalThis
|
|
57
|
+
.process;
|
|
58
|
+
return ((_a = maybeProcess === null || maybeProcess === void 0 ? void 0 : maybeProcess.env) === null || _a === void 0 ? void 0 : _a.NODE_ENV) === "production";
|
|
59
|
+
};
|
|
60
|
+
const shouldIncludeStackHint = (override, config = errorConfig) => {
|
|
61
|
+
if (override === false)
|
|
62
|
+
return false;
|
|
63
|
+
if (config.stackHints === "off")
|
|
64
|
+
return false;
|
|
65
|
+
if (config.stackHints === "on")
|
|
66
|
+
return true;
|
|
67
|
+
if (override === true)
|
|
68
|
+
return !isProductionEnv();
|
|
69
|
+
return false;
|
|
70
|
+
};
|
|
71
|
+
const formatDetailBlock = (details) => {
|
|
72
|
+
if (!details)
|
|
73
|
+
return "";
|
|
74
|
+
const parts = [];
|
|
75
|
+
if (details.code)
|
|
76
|
+
parts.push(`code=${details.code}`);
|
|
77
|
+
if (details.helper)
|
|
78
|
+
parts.push(`helper=${details.helper}`);
|
|
79
|
+
if (details.inputSummary)
|
|
80
|
+
parts.push(`inputs=${details.inputSummary}`);
|
|
81
|
+
if (details.stackHint)
|
|
82
|
+
parts.push(`stack=${details.stackHint}`);
|
|
83
|
+
return parts.length > 0 ? ` [${parts.join(" | ")}]` : "";
|
|
84
|
+
};
|
|
85
|
+
const formatErrorMessage = (operation, message, context, details) => {
|
|
86
|
+
const core = `${operation}: ${message}`;
|
|
87
|
+
const base = context ? `${context}: ${core}` : core;
|
|
88
|
+
return `${base}${formatDetailBlock(details)}`;
|
|
89
|
+
};
|
|
90
|
+
const extractStackHint = (stack) => {
|
|
91
|
+
var _a;
|
|
92
|
+
if (!stack)
|
|
93
|
+
return undefined;
|
|
94
|
+
const lines = stack
|
|
95
|
+
.split("\n")
|
|
96
|
+
.map((line) => line.trim())
|
|
97
|
+
.filter(Boolean)
|
|
98
|
+
.slice(1);
|
|
99
|
+
if (lines.length === 0)
|
|
100
|
+
return undefined;
|
|
101
|
+
const filtered = lines.filter((line) => !line.includes("/src/internal/errors") &&
|
|
102
|
+
!line.includes("throwHelperError") &&
|
|
103
|
+
!line.includes("throwMeasurementMethodError"));
|
|
104
|
+
const hint = (_a = filtered[0]) !== null && _a !== void 0 ? _a : lines[0];
|
|
105
|
+
return hint.replace(/^at\s+/, "");
|
|
106
|
+
};
|
|
107
|
+
/** Throw an Error for a Measurement instance method using a structured context. */
|
|
108
|
+
const throwMeasurementMethodError = (ctx) => {
|
|
109
|
+
const includeStack = shouldIncludeStackHint(ctx.includeStackHint);
|
|
110
|
+
const stackHint = includeStack
|
|
111
|
+
? extractStackHint(new Error().stack)
|
|
112
|
+
: undefined;
|
|
113
|
+
throw new Error(formatErrorMessage(ctx.operation, ctx.message, ctx.context, {
|
|
114
|
+
...ctx.details,
|
|
115
|
+
stackHint,
|
|
116
|
+
}));
|
|
117
|
+
};
|
|
118
|
+
exports.throwMeasurementMethodError = throwMeasurementMethodError;
|
|
119
|
+
/** Throw an Error for a helper/free function using a structured context. */
|
|
120
|
+
const throwHelperError = (ctx) => {
|
|
121
|
+
const includeStack = shouldIncludeStackHint(ctx.includeStackHint);
|
|
122
|
+
const stackHint = includeStack
|
|
123
|
+
? extractStackHint(new Error().stack)
|
|
124
|
+
: undefined;
|
|
125
|
+
throw new Error(formatErrorMessage(ctx.operation, ctx.message, ctx.context, {
|
|
126
|
+
...ctx.details,
|
|
127
|
+
stackHint,
|
|
128
|
+
}));
|
|
129
|
+
};
|
|
130
|
+
exports.throwHelperError = throwHelperError;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.containerQueryOutputVanillaExtract = exports.mediaQueryOutputVanillaExtract = void 0;
|
|
4
|
+
const mediaQueryOutputVanillaExtract = (media) => ({
|
|
5
|
+
"&": media,
|
|
6
|
+
});
|
|
7
|
+
exports.mediaQueryOutputVanillaExtract = mediaQueryOutputVanillaExtract;
|
|
8
|
+
const containerQueryOutputVanillaExtract = (container) => ({
|
|
9
|
+
"&": container,
|
|
10
|
+
});
|
|
11
|
+
exports.containerQueryOutputVanillaExtract = containerQueryOutputVanillaExtract;
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mediaQueryFactory = exports.createMediaQueryFactory = void 0;
|
|
4
|
+
const helpers_1 = require("./helpers");
|
|
5
|
+
const mediaQueries_1 = require("./mediaQueries");
|
|
6
|
+
const modules_1 = require("./modules");
|
|
7
|
+
const ALL_MEDIA_QUERY_MODULES = [
|
|
8
|
+
'core',
|
|
9
|
+
'dimensions',
|
|
10
|
+
'resolution',
|
|
11
|
+
'interaction',
|
|
12
|
+
'preferences',
|
|
13
|
+
'display',
|
|
14
|
+
'environment',
|
|
15
|
+
'custom',
|
|
16
|
+
];
|
|
17
|
+
const MODULE_KEYS = {
|
|
18
|
+
core: ['type', 'minWidth', 'maxWidth'],
|
|
19
|
+
dimensions: [
|
|
20
|
+
'width',
|
|
21
|
+
'height',
|
|
22
|
+
'minHeight',
|
|
23
|
+
'maxHeight',
|
|
24
|
+
'aspectRatio',
|
|
25
|
+
'minAspectRatio',
|
|
26
|
+
'maxAspectRatio',
|
|
27
|
+
'orientation',
|
|
28
|
+
],
|
|
29
|
+
resolution: ['resolutionValue', 'minResolution', 'maxResolution'],
|
|
30
|
+
interaction: ['hover', 'anyHover', 'pointer', 'anyPointer', 'update'],
|
|
31
|
+
preferences: [
|
|
32
|
+
'colorScheme',
|
|
33
|
+
'reducedMotion',
|
|
34
|
+
'reducedData',
|
|
35
|
+
'contrast',
|
|
36
|
+
'forcedColors',
|
|
37
|
+
],
|
|
38
|
+
display: ['colorGamut', 'dynamicRange', 'invertedColors'],
|
|
39
|
+
environment: ['scripting', 'overflowBlock', 'overflowInline'],
|
|
40
|
+
custom: ['customFeatures'],
|
|
41
|
+
};
|
|
42
|
+
const MODULE_EMITTERS = {
|
|
43
|
+
core: mediaQueries_1.emitCoreFeatures,
|
|
44
|
+
dimensions: modules_1.emitDimensionsFeatures,
|
|
45
|
+
resolution: modules_1.emitResolutionFeatures,
|
|
46
|
+
interaction: modules_1.emitInteractionFeatures,
|
|
47
|
+
preferences: modules_1.emitPreferencesFeatures,
|
|
48
|
+
display: modules_1.emitDisplayFeatures,
|
|
49
|
+
environment: modules_1.emitEnvironmentFeatures,
|
|
50
|
+
custom: modules_1.emitCustomFeatures,
|
|
51
|
+
};
|
|
52
|
+
const ALL_MODULE_KEYS = MODULE_KEYS;
|
|
53
|
+
const KEY_TO_MODULE = Object.fromEntries(Object.keys(ALL_MODULE_KEYS).flatMap((moduleId) => ALL_MODULE_KEYS[moduleId].map((key) => [key, moduleId])));
|
|
54
|
+
const guardUnsupportedProps = (props, modules, config, label) => {
|
|
55
|
+
const allowed = new Set();
|
|
56
|
+
modules.forEach((moduleId) => {
|
|
57
|
+
ALL_MODULE_KEYS[moduleId].forEach((key) => {
|
|
58
|
+
allowed.add(key);
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
Object.keys(props).forEach((key) => {
|
|
62
|
+
var _a, _b;
|
|
63
|
+
if (props[key] === undefined)
|
|
64
|
+
return;
|
|
65
|
+
if (allowed.has(key))
|
|
66
|
+
return;
|
|
67
|
+
const mode = (_b = (_a = config.errorHandling) === null || _a === void 0 ? void 0 : _a.invalidValueMode) !== null && _b !== void 0 ? _b : 'throw';
|
|
68
|
+
const moduleHint = KEY_TO_MODULE[key];
|
|
69
|
+
const moduleSuffix = moduleHint
|
|
70
|
+
? ` Add "${moduleHint}" to modules.`
|
|
71
|
+
: '';
|
|
72
|
+
const message = `Media query factory "${label}" received unsupported feature "${key}".${moduleSuffix}`;
|
|
73
|
+
if (mode === 'log') {
|
|
74
|
+
console.warn(message);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if (mode === 'allow')
|
|
78
|
+
return;
|
|
79
|
+
throw new Error(message);
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
const normalizeCustomResult = (result) => {
|
|
83
|
+
if (result === undefined || result === null)
|
|
84
|
+
return { valid: true };
|
|
85
|
+
if (typeof result === 'boolean')
|
|
86
|
+
return { valid: result };
|
|
87
|
+
if (typeof result === 'string') {
|
|
88
|
+
return result ? { valid: false, message: result } : { valid: true };
|
|
89
|
+
}
|
|
90
|
+
return result;
|
|
91
|
+
};
|
|
92
|
+
const runCustomValidator = (props, config) => {
|
|
93
|
+
var _a, _b;
|
|
94
|
+
const custom = config.custom;
|
|
95
|
+
if (!(custom === null || custom === void 0 ? void 0 : custom.validator))
|
|
96
|
+
return;
|
|
97
|
+
const normalized = normalizeCustomResult(custom.validator(props));
|
|
98
|
+
if (normalized.valid)
|
|
99
|
+
return;
|
|
100
|
+
const mode = (_b = (_a = config.errorHandling) === null || _a === void 0 ? void 0 : _a.invalidValueMode) !== null && _b !== void 0 ? _b : 'throw';
|
|
101
|
+
const suffix = normalized.message ? `: ${normalized.message}` : '';
|
|
102
|
+
const message = `Media query factory "${config.label}" custom validator "${custom.key}" failed${suffix}`;
|
|
103
|
+
if (mode === 'log') {
|
|
104
|
+
console.warn(message);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
if (mode === 'allow')
|
|
108
|
+
return;
|
|
109
|
+
throw new Error(message);
|
|
110
|
+
};
|
|
111
|
+
const runCustomLinter = (props, config) => {
|
|
112
|
+
var _a, _b;
|
|
113
|
+
const custom = config.custom;
|
|
114
|
+
if (!(custom === null || custom === void 0 ? void 0 : custom.linter))
|
|
115
|
+
return;
|
|
116
|
+
const normalized = normalizeCustomResult(custom.linter(props));
|
|
117
|
+
if (normalized.valid)
|
|
118
|
+
return;
|
|
119
|
+
const mode = (_b = (_a = config.errorHandling) === null || _a === void 0 ? void 0 : _a.lintingMode) !== null && _b !== void 0 ? _b : 'throw';
|
|
120
|
+
const suffix = normalized.message ? `: ${normalized.message}` : '';
|
|
121
|
+
const message = `Media query factory "${config.label}" custom linter "${custom.key}" flagged${suffix}`;
|
|
122
|
+
if (mode === 'log') {
|
|
123
|
+
console.warn(message);
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
if (mode === 'allow')
|
|
127
|
+
return;
|
|
128
|
+
throw new Error(message);
|
|
129
|
+
};
|
|
130
|
+
const createMediaQueryFactory = (emitters) => (options) => {
|
|
131
|
+
var _a;
|
|
132
|
+
const modules = (_a = options.config.modules) !== null && _a !== void 0 ? _a : ALL_MEDIA_QUERY_MODULES;
|
|
133
|
+
const buildMediaQuery = (0, helpers_1.createMediaQueryBuilder)({
|
|
134
|
+
emitBase: (props, helpers) => {
|
|
135
|
+
guardUnsupportedProps(props, modules, options.config, options.config.label);
|
|
136
|
+
runCustomValidator(props, options.config);
|
|
137
|
+
runCustomLinter(props, options.config);
|
|
138
|
+
modules.forEach((moduleId) => {
|
|
139
|
+
emitters[moduleId](props, helpers);
|
|
140
|
+
});
|
|
141
|
+
},
|
|
142
|
+
resolveType: (props) => props.type,
|
|
143
|
+
config: options.config,
|
|
144
|
+
});
|
|
145
|
+
return (stylesByQuery) => {
|
|
146
|
+
const result = {};
|
|
147
|
+
Object.keys(stylesByQuery).forEach((key) => {
|
|
148
|
+
const styles = stylesByQuery[key];
|
|
149
|
+
const props = options.queries[key];
|
|
150
|
+
if (!styles || !props)
|
|
151
|
+
return;
|
|
152
|
+
result[buildMediaQuery(props)] = styles;
|
|
153
|
+
});
|
|
154
|
+
const mediaQuery = {
|
|
155
|
+
'@media': result,
|
|
156
|
+
};
|
|
157
|
+
return options.config.output
|
|
158
|
+
? options.config.output(mediaQuery)
|
|
159
|
+
: mediaQuery;
|
|
160
|
+
};
|
|
161
|
+
};
|
|
162
|
+
exports.createMediaQueryFactory = createMediaQueryFactory;
|
|
163
|
+
exports.mediaQueryFactory = (0, exports.createMediaQueryFactory)(MODULE_EMITTERS);
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildMediaQueryFromFeatures = exports.applyMediaQueryValidation = exports.createMediaQueryBuilder = exports.createMediaQueryFeatureEmitterWithTracking = exports.createMediaQueryFeatureEmitter = exports.buildMediaQueryStringFromParts = exports.formatMediaQueryValue = void 0;
|
|
4
|
+
const core_1 = require("../core");
|
|
5
|
+
const validation_1 = require("../validation");
|
|
6
|
+
const formatMediaQueryValue = (value) => ((0, core_1.hasCssMethod)(value) ? value.css() : String(value));
|
|
7
|
+
exports.formatMediaQueryValue = formatMediaQueryValue;
|
|
8
|
+
const buildMediaQueryStringFromParts = (mediaType, parts) => (parts.length ? `${mediaType} and ${parts.join(' and ')}` : mediaType);
|
|
9
|
+
exports.buildMediaQueryStringFromParts = buildMediaQueryStringFromParts;
|
|
10
|
+
const createMediaQueryFeatureEmitter = (parts) => (name, value) => {
|
|
11
|
+
parts.push(`(${name}: ${(0, exports.formatMediaQueryValue)(value)})`);
|
|
12
|
+
};
|
|
13
|
+
exports.createMediaQueryFeatureEmitter = createMediaQueryFeatureEmitter;
|
|
14
|
+
const createMediaQueryFeatureEmitterWithTracking = (parts, options = {}) => {
|
|
15
|
+
const { emitted, lintingMode = 'throw' } = options;
|
|
16
|
+
return (name, value) => {
|
|
17
|
+
if (emitted === null || emitted === void 0 ? void 0 : emitted.has(name)) {
|
|
18
|
+
if (lintingMode === 'throw') {
|
|
19
|
+
throw new Error(`Media query feature "${name}" was emitted more than once.`);
|
|
20
|
+
}
|
|
21
|
+
if (lintingMode === 'log') {
|
|
22
|
+
console.warn(`Media query feature "${name}" was emitted more than once; using the latest value.`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
emitted === null || emitted === void 0 ? void 0 : emitted.add(name);
|
|
26
|
+
parts.push(`(${name}: ${(0, exports.formatMediaQueryValue)(value)})`);
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
exports.createMediaQueryFeatureEmitterWithTracking = createMediaQueryFeatureEmitterWithTracking;
|
|
30
|
+
const createMediaQueryBuilder = (options) => {
|
|
31
|
+
return (config) => {
|
|
32
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
33
|
+
const parts = [];
|
|
34
|
+
const emittedFeatures = new Set();
|
|
35
|
+
const helpers = {
|
|
36
|
+
addFeature: (0, exports.createMediaQueryFeatureEmitterWithTracking)(parts, {
|
|
37
|
+
emitted: emittedFeatures,
|
|
38
|
+
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',
|
|
39
|
+
}),
|
|
40
|
+
config: (_d = options.config) !== null && _d !== void 0 ? _d : {},
|
|
41
|
+
};
|
|
42
|
+
options.emitBase(config, helpers);
|
|
43
|
+
(_e = options.emitExtensions) === null || _e === void 0 ? void 0 : _e.call(options, config, helpers);
|
|
44
|
+
const mediaType = (_g = (_f = options.resolveType) === null || _f === void 0 ? void 0 : _f.call(options, config)) !== null && _g !== void 0 ? _g : 'screen';
|
|
45
|
+
return (0, exports.buildMediaQueryStringFromParts)(mediaType, parts);
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
exports.createMediaQueryBuilder = createMediaQueryBuilder;
|
|
49
|
+
const applyMediaQueryValidation = (config, helpers, validator, context) => {
|
|
50
|
+
var _a, _b;
|
|
51
|
+
if (!validator)
|
|
52
|
+
return true;
|
|
53
|
+
const normalized = (0, validation_1.normalizeValidationResult)(validator(config));
|
|
54
|
+
if (normalized.valid)
|
|
55
|
+
return true;
|
|
56
|
+
const mode = (_b = (_a = helpers.config.errorHandling) === null || _a === void 0 ? void 0 : _a.invalidValueMode) !== null && _b !== void 0 ? _b : 'throw';
|
|
57
|
+
if (mode === 'log') {
|
|
58
|
+
const suffix = normalized.message ? `: ${normalized.message}` : '';
|
|
59
|
+
const prefix = context
|
|
60
|
+
? `Media query ${context} validation failed`
|
|
61
|
+
: 'Media query validation failed';
|
|
62
|
+
console.warn(`${prefix}${suffix}`);
|
|
63
|
+
}
|
|
64
|
+
if (mode === 'allow')
|
|
65
|
+
return true;
|
|
66
|
+
if (mode === 'log')
|
|
67
|
+
return true;
|
|
68
|
+
const suffix = normalized.message ? `: ${normalized.message}` : '';
|
|
69
|
+
const prefix = context
|
|
70
|
+
? `Media query ${context} validation failed`
|
|
71
|
+
: 'Media query validation failed';
|
|
72
|
+
throw new Error(`${prefix}${suffix}`);
|
|
73
|
+
};
|
|
74
|
+
exports.applyMediaQueryValidation = applyMediaQueryValidation;
|
|
75
|
+
const buildMediaQueryFromFeatures = (features, mediaType = 'screen') => {
|
|
76
|
+
const parts = [];
|
|
77
|
+
const addFeature = (0, exports.createMediaQueryFeatureEmitterWithTracking)(parts, {
|
|
78
|
+
emitted: new Set(),
|
|
79
|
+
lintingMode: 'throw',
|
|
80
|
+
});
|
|
81
|
+
Object.entries(features).forEach(([name, value]) => {
|
|
82
|
+
if (value === undefined || value === null)
|
|
83
|
+
return;
|
|
84
|
+
addFeature(name, value);
|
|
85
|
+
});
|
|
86
|
+
return (0, exports.buildMediaQueryStringFromParts)(mediaType, parts);
|
|
87
|
+
};
|
|
88
|
+
exports.buildMediaQueryFromFeatures = buildMediaQueryFromFeatures;
|
|
@@ -0,0 +1,23 @@
|
|
|
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("./types"), exports);
|
|
18
|
+
__exportStar(require("./helpers"), exports);
|
|
19
|
+
__exportStar(require("./factory"), exports);
|
|
20
|
+
__exportStar(require("./mediaQueries"), exports);
|
|
21
|
+
__exportStar(require("./modules"), exports);
|
|
22
|
+
__exportStar(require("./moduleRegistry"), exports);
|
|
23
|
+
__exportStar(require("../libraryHelpers/vanilla-extract"), exports);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.lintHeightRedundancy = exports.lintWidthRedundancy = void 0;
|
|
4
|
+
const lintWidthRedundancy = (props) => {
|
|
5
|
+
if (!props.width)
|
|
6
|
+
return;
|
|
7
|
+
if (props.minWidth || props.maxWidth) {
|
|
8
|
+
throw new Error('width should not be combined with minWidth or maxWidth');
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
exports.lintWidthRedundancy = lintWidthRedundancy;
|
|
12
|
+
const lintHeightRedundancy = (props) => {
|
|
13
|
+
if (!props.height)
|
|
14
|
+
return;
|
|
15
|
+
if (props.minHeight || props.maxHeight) {
|
|
16
|
+
throw new Error('height should not be combined with minHeight or maxHeight');
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
exports.lintHeightRedundancy = lintHeightRedundancy;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.lintResolutionRedundancy = void 0;
|
|
4
|
+
const lintResolutionRedundancy = (props) => {
|
|
5
|
+
if (!props.resolutionValue)
|
|
6
|
+
return;
|
|
7
|
+
if (props.minResolution || props.maxResolution) {
|
|
8
|
+
throw new Error('resolution should not be combined with minResolution or maxResolution');
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
exports.lintResolutionRedundancy = lintResolutionRedundancy;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runMediaQueryLint = void 0;
|
|
4
|
+
const runMediaQueryLint = (config, helpers, check, message = 'Media 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.runMediaQueryLint = runMediaQueryLint;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeMediaQueryStyle = exports.buildMediaQueryString = exports.emitCoreFeatures = exports.createEmitCoreFeatures = void 0;
|
|
4
|
+
const helpers_1 = require("./helpers");
|
|
5
|
+
const validation_1 = require("./validation");
|
|
6
|
+
const modules_1 = require("./modules");
|
|
7
|
+
const createEmitCoreFeatures = (validation) => (props, helpers) => {
|
|
8
|
+
const { runMediaQueryValidation, validateMinMaxWidth, validateWidthValuesPositive, } = validation;
|
|
9
|
+
if (!runMediaQueryValidation(props, helpers, validateMinMaxWidth, "core", "minWidth must be less than or equal to maxWidth")) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
if (!runMediaQueryValidation(props, helpers, validateWidthValuesPositive, "core", "width values must be greater than 0")) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const { addFeature } = helpers;
|
|
16
|
+
if (props.minWidth) {
|
|
17
|
+
addFeature("min-width", props.minWidth);
|
|
18
|
+
}
|
|
19
|
+
if (props.maxWidth) {
|
|
20
|
+
addFeature("max-width", props.maxWidth);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
exports.createEmitCoreFeatures = createEmitCoreFeatures;
|
|
24
|
+
exports.emitCoreFeatures = (0, exports.createEmitCoreFeatures)(validation_1.defaultMediaQueryValidation);
|
|
25
|
+
const emitBaseFeatures = (props, helpers) => {
|
|
26
|
+
(0, exports.emitCoreFeatures)(props, helpers);
|
|
27
|
+
(0, modules_1.emitDimensionsFeatures)(props, helpers);
|
|
28
|
+
(0, modules_1.emitResolutionFeatures)(props, helpers);
|
|
29
|
+
(0, modules_1.emitInteractionFeatures)(props, helpers);
|
|
30
|
+
(0, modules_1.emitPreferencesFeatures)(props, helpers);
|
|
31
|
+
(0, modules_1.emitDisplayFeatures)(props, helpers);
|
|
32
|
+
(0, modules_1.emitEnvironmentFeatures)(props, helpers);
|
|
33
|
+
(0, modules_1.emitCustomFeatures)(props, helpers);
|
|
34
|
+
};
|
|
35
|
+
exports.buildMediaQueryString = (0, helpers_1.createMediaQueryBuilder)({
|
|
36
|
+
emitBase: emitBaseFeatures,
|
|
37
|
+
resolveType: (props) => props.type,
|
|
38
|
+
});
|
|
39
|
+
const makeMediaQueryStyle = (queries) => (stylesByQuery) => {
|
|
40
|
+
const result = {};
|
|
41
|
+
Object.keys(stylesByQuery).forEach((key) => {
|
|
42
|
+
const styles = stylesByQuery[key];
|
|
43
|
+
const props = queries[key];
|
|
44
|
+
if (!styles || !props)
|
|
45
|
+
return;
|
|
46
|
+
result[(0, exports.buildMediaQueryString)(props)] = styles;
|
|
47
|
+
});
|
|
48
|
+
const mediaQuery = {
|
|
49
|
+
"@media": result,
|
|
50
|
+
};
|
|
51
|
+
return mediaQuery;
|
|
52
|
+
};
|
|
53
|
+
exports.makeMediaQueryStyle = makeMediaQueryStyle;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.emitCustomFeatures = void 0;
|
|
4
|
+
const core_1 = require("../../core");
|
|
5
|
+
const helpers_1 = require("../helpers");
|
|
6
|
+
const emitCustomFeatures = (props, helpers, validate) => {
|
|
7
|
+
if (!(0, helpers_1.applyMediaQueryValidation)(props, helpers, validate, 'custom')) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
const { addFeature } = helpers;
|
|
11
|
+
if (!props.customFeatures)
|
|
12
|
+
return;
|
|
13
|
+
Object.entries(props.customFeatures).forEach(([name, value]) => {
|
|
14
|
+
if (value === undefined || value === null)
|
|
15
|
+
return;
|
|
16
|
+
const trimmedName = name.trim();
|
|
17
|
+
if (!trimmedName) {
|
|
18
|
+
throw new Error('Custom feature name must be non-empty.');
|
|
19
|
+
}
|
|
20
|
+
if (typeof value === 'object' && !(0, core_1.hasCssMethod)(value)) {
|
|
21
|
+
throw new Error(`Custom feature "${trimmedName}" must be a primitive or a measurement.`);
|
|
22
|
+
}
|
|
23
|
+
addFeature(trimmedName, value);
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
exports.emitCustomFeatures = emitCustomFeatures;
|