css-calipers 0.14.0 → 1.0.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 +15 -29
- 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 +4 -17
- 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
package/dist/cjs/fraction.js
DELETED
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
-
};
|
|
8
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
-
};
|
|
13
|
-
var _FractionImpl_numerator, _FractionImpl_denominator, _FractionImpl_omitDenominatorWhenOne;
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.fractionToFloat = exports.simplifyFraction = exports.reduceFraction = exports.normalizeFraction = exports.parseRatio = exports.isFraction = void 0;
|
|
16
|
-
exports.r = r;
|
|
17
|
-
class FractionImpl {
|
|
18
|
-
constructor(numerator, denominator, options = {}) {
|
|
19
|
-
var _a;
|
|
20
|
-
_FractionImpl_numerator.set(this, void 0);
|
|
21
|
-
_FractionImpl_denominator.set(this, void 0);
|
|
22
|
-
_FractionImpl_omitDenominatorWhenOne.set(this, void 0);
|
|
23
|
-
if (!Number.isFinite(numerator) || !Number.isFinite(denominator)) {
|
|
24
|
-
throw new Error('Fraction values must be finite numbers.');
|
|
25
|
-
}
|
|
26
|
-
if (denominator === 0) {
|
|
27
|
-
throw new Error('Fraction denominator cannot be zero.');
|
|
28
|
-
}
|
|
29
|
-
__classPrivateFieldSet(this, _FractionImpl_numerator, numerator, "f");
|
|
30
|
-
__classPrivateFieldSet(this, _FractionImpl_denominator, denominator, "f");
|
|
31
|
-
__classPrivateFieldSet(this, _FractionImpl_omitDenominatorWhenOne, (_a = options.omitDenominatorWhenOne) !== null && _a !== void 0 ? _a : false, "f");
|
|
32
|
-
}
|
|
33
|
-
numerator() {
|
|
34
|
-
return __classPrivateFieldGet(this, _FractionImpl_numerator, "f");
|
|
35
|
-
}
|
|
36
|
-
denominator() {
|
|
37
|
-
return __classPrivateFieldGet(this, _FractionImpl_denominator, "f");
|
|
38
|
-
}
|
|
39
|
-
withNumerator(numerator) {
|
|
40
|
-
return new FractionImpl(numerator, __classPrivateFieldGet(this, _FractionImpl_denominator, "f"));
|
|
41
|
-
}
|
|
42
|
-
withDenominator(denominator) {
|
|
43
|
-
return new FractionImpl(__classPrivateFieldGet(this, _FractionImpl_numerator, "f"), denominator);
|
|
44
|
-
}
|
|
45
|
-
valueOf() {
|
|
46
|
-
return __classPrivateFieldGet(this, _FractionImpl_numerator, "f") / __classPrivateFieldGet(this, _FractionImpl_denominator, "f");
|
|
47
|
-
}
|
|
48
|
-
css() {
|
|
49
|
-
if (__classPrivateFieldGet(this, _FractionImpl_omitDenominatorWhenOne, "f") && __classPrivateFieldGet(this, _FractionImpl_denominator, "f") === 1) {
|
|
50
|
-
return String(__classPrivateFieldGet(this, _FractionImpl_numerator, "f"));
|
|
51
|
-
}
|
|
52
|
-
return `${__classPrivateFieldGet(this, _FractionImpl_numerator, "f")}/${__classPrivateFieldGet(this, _FractionImpl_denominator, "f")}`;
|
|
53
|
-
}
|
|
54
|
-
toString() {
|
|
55
|
-
return this.css();
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
_FractionImpl_numerator = new WeakMap(), _FractionImpl_denominator = new WeakMap(), _FractionImpl_omitDenominatorWhenOne = new WeakMap();
|
|
59
|
-
function r(numeratorOrDenominator, denominator) {
|
|
60
|
-
const numerator = denominator === undefined ? numeratorOrDenominator : numeratorOrDenominator;
|
|
61
|
-
const resolvedDenominator = denominator === undefined ? 1 : denominator;
|
|
62
|
-
return new FractionImpl(numerator, resolvedDenominator);
|
|
63
|
-
}
|
|
64
|
-
const isFraction = (value) => {
|
|
65
|
-
return (typeof value === "object" &&
|
|
66
|
-
value !== null &&
|
|
67
|
-
"css" in value &&
|
|
68
|
-
"numerator" in value &&
|
|
69
|
-
"denominator" in value &&
|
|
70
|
-
typeof value.css === "function" &&
|
|
71
|
-
typeof value.numerator === "function" &&
|
|
72
|
-
typeof value.denominator === "function");
|
|
73
|
-
};
|
|
74
|
-
exports.isFraction = isFraction;
|
|
75
|
-
const parseRatio = (value) => {
|
|
76
|
-
if (typeof value === "number") {
|
|
77
|
-
return Number.isFinite(value) ? { numerator: value, denominator: 1 } : null;
|
|
78
|
-
}
|
|
79
|
-
if ((0, exports.isFraction)(value)) {
|
|
80
|
-
return { numerator: value.numerator(), denominator: value.denominator() };
|
|
81
|
-
}
|
|
82
|
-
const trimmed = value.trim();
|
|
83
|
-
if (!trimmed)
|
|
84
|
-
return null;
|
|
85
|
-
if (trimmed.includes("/")) {
|
|
86
|
-
const [left, right] = trimmed.split("/");
|
|
87
|
-
if (left === undefined || right === undefined)
|
|
88
|
-
return null;
|
|
89
|
-
const numerator = Number(left.trim());
|
|
90
|
-
const denominator = Number(right.trim());
|
|
91
|
-
if (!Number.isFinite(numerator) || !Number.isFinite(denominator))
|
|
92
|
-
return null;
|
|
93
|
-
if (denominator === 0)
|
|
94
|
-
return null;
|
|
95
|
-
return { numerator, denominator };
|
|
96
|
-
}
|
|
97
|
-
const parsed = Number(trimmed);
|
|
98
|
-
return Number.isFinite(parsed) ? { numerator: parsed, denominator: 1 } : null;
|
|
99
|
-
};
|
|
100
|
-
exports.parseRatio = parseRatio;
|
|
101
|
-
const normalizeFraction = (fraction) => {
|
|
102
|
-
let numerator = fraction.numerator();
|
|
103
|
-
let denominator = fraction.denominator();
|
|
104
|
-
if (!Number.isFinite(numerator) || !Number.isFinite(denominator)) {
|
|
105
|
-
throw new Error("Fraction values must be finite numbers.");
|
|
106
|
-
}
|
|
107
|
-
if (denominator === 0) {
|
|
108
|
-
throw new Error("Fraction denominator cannot be zero.");
|
|
109
|
-
}
|
|
110
|
-
if (!Number.isInteger(numerator) || !Number.isInteger(denominator)) {
|
|
111
|
-
return new FractionImpl(numerator, denominator);
|
|
112
|
-
}
|
|
113
|
-
if (denominator < 0) {
|
|
114
|
-
numerator = -numerator;
|
|
115
|
-
denominator = Math.abs(denominator);
|
|
116
|
-
}
|
|
117
|
-
const gcd = (a, b) => {
|
|
118
|
-
let x = Math.abs(a);
|
|
119
|
-
let y = Math.abs(b);
|
|
120
|
-
while (y !== 0) {
|
|
121
|
-
const next = x % y;
|
|
122
|
-
x = y;
|
|
123
|
-
y = next;
|
|
124
|
-
}
|
|
125
|
-
return x === 0 ? 1 : x;
|
|
126
|
-
};
|
|
127
|
-
const divisor = gcd(numerator, denominator);
|
|
128
|
-
return new FractionImpl(numerator / divisor, denominator / divisor);
|
|
129
|
-
};
|
|
130
|
-
exports.normalizeFraction = normalizeFraction;
|
|
131
|
-
const reduceFraction = (fraction) => (0, exports.normalizeFraction)(fraction);
|
|
132
|
-
exports.reduceFraction = reduceFraction;
|
|
133
|
-
const simplifyFraction = (fraction) => {
|
|
134
|
-
const reduced = (0, exports.normalizeFraction)(fraction);
|
|
135
|
-
return new FractionImpl(reduced.numerator(), reduced.denominator(), { omitDenominatorWhenOne: true });
|
|
136
|
-
};
|
|
137
|
-
exports.simplifyFraction = simplifyFraction;
|
|
138
|
-
const fractionToFloat = (fraction) => fraction.numerator() / fraction.denominator();
|
|
139
|
-
exports.fractionToFloat = fractionToFloat;
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createContainerQueriesApi = void 0;
|
|
4
|
-
const helpers_1 = require("../containerQueries/helpers");
|
|
5
|
-
const validation_1 = require("../containerQueries/validation");
|
|
6
|
-
const containerQueries_1 = require("../containerQueries/containerQueries");
|
|
7
|
-
const modules_1 = require("../containerQueries/modules");
|
|
8
|
-
const factory_1 = require("../containerQueries/factory");
|
|
9
|
-
const vanilla_extract_1 = require("../libraryHelpers/vanilla-extract");
|
|
10
|
-
const createContainerQueriesApi = (core) => {
|
|
11
|
-
const validation = (0, validation_1.createContainerQueryValidation)({
|
|
12
|
-
assertCondition: core.assertCondition,
|
|
13
|
-
assertMatchingUnits: core.assertMatchingUnits,
|
|
14
|
-
});
|
|
15
|
-
const emitCoreFeatures = (0, containerQueries_1.createEmitCoreFeatures)(validation);
|
|
16
|
-
const emitBaseFeatures = (props, helpers) => {
|
|
17
|
-
emitCoreFeatures(props, helpers);
|
|
18
|
-
(0, modules_1.emitAspectRatioFeatures)(props, helpers);
|
|
19
|
-
(0, modules_1.emitBlockSizeFeatures)(props, helpers);
|
|
20
|
-
(0, modules_1.emitInlineSizeFeatures)(props, helpers);
|
|
21
|
-
(0, modules_1.emitStyleFeatures)(props, helpers);
|
|
22
|
-
(0, modules_1.emitCustomFeatures)(props, helpers);
|
|
23
|
-
};
|
|
24
|
-
const buildContainerQueryString = (0, helpers_1.createContainerQueryBuilder)({
|
|
25
|
-
emitBase: emitBaseFeatures,
|
|
26
|
-
});
|
|
27
|
-
const makeContainerQueryStyle = (queries) => (stylesByQuery) => {
|
|
28
|
-
const result = {};
|
|
29
|
-
Object.keys(stylesByQuery).forEach((key) => {
|
|
30
|
-
const styles = stylesByQuery[key];
|
|
31
|
-
const props = queries[key];
|
|
32
|
-
if (!styles || !props)
|
|
33
|
-
return;
|
|
34
|
-
result[buildContainerQueryString(props)] = styles;
|
|
35
|
-
});
|
|
36
|
-
const containerQuery = {
|
|
37
|
-
"@container": result,
|
|
38
|
-
};
|
|
39
|
-
return containerQuery;
|
|
40
|
-
};
|
|
41
|
-
const containerQueryFactory = (0, factory_1.createContainerQueryFactory)();
|
|
42
|
-
return {
|
|
43
|
-
buildContainerQueryString,
|
|
44
|
-
makeContainerQueryStyle,
|
|
45
|
-
containerQueryFactory,
|
|
46
|
-
emitCoreFeatures,
|
|
47
|
-
emitAspectRatioFeatures: modules_1.emitAspectRatioFeatures,
|
|
48
|
-
emitBlockSizeFeatures: modules_1.emitBlockSizeFeatures,
|
|
49
|
-
emitInlineSizeFeatures: modules_1.emitInlineSizeFeatures,
|
|
50
|
-
emitStyleFeatures: modules_1.emitStyleFeatures,
|
|
51
|
-
emitCustomFeatures: modules_1.emitCustomFeatures,
|
|
52
|
-
containerQueryOutputVanillaExtract: vanilla_extract_1.containerQueryOutputVanillaExtract,
|
|
53
|
-
createContainerQueryBuilder: helpers_1.createContainerQueryBuilder,
|
|
54
|
-
};
|
|
55
|
-
};
|
|
56
|
-
exports.createContainerQueriesApi = createContainerQueriesApi;
|
|
@@ -1,73 +0,0 @@
|
|
|
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("../mediaQueries/libraryHelpers/vanilla-extract");
|
|
11
|
-
const createMediaQueriesApi = (core) => {
|
|
12
|
-
const validation = (0, validation_1.createMediaQueryValidation)({
|
|
13
|
-
assertCondition: core.assertCondition,
|
|
14
|
-
});
|
|
15
|
-
const emitCoreFeatures = (0, mediaQueries_1.createEmitCoreFeatures)(validation);
|
|
16
|
-
const emitDimensionsFeatures = (0, modules_1.createEmitDimensionsFeatures)(validation);
|
|
17
|
-
const emitResolutionFeatures = (0, resolution_1.createEmitResolutionFeatures)(validation);
|
|
18
|
-
const emitBaseFeatures = (props, helpers) => {
|
|
19
|
-
emitCoreFeatures(props, helpers);
|
|
20
|
-
emitDimensionsFeatures(props, helpers);
|
|
21
|
-
emitResolutionFeatures(props, helpers);
|
|
22
|
-
(0, modules_1.emitInteractionFeatures)(props, helpers);
|
|
23
|
-
(0, modules_1.emitPreferencesFeatures)(props, helpers);
|
|
24
|
-
(0, modules_1.emitDisplayFeatures)(props, helpers);
|
|
25
|
-
(0, modules_1.emitEnvironmentFeatures)(props, helpers);
|
|
26
|
-
(0, modules_1.emitCustomFeatures)(props, helpers);
|
|
27
|
-
};
|
|
28
|
-
const buildMediaQueryString = (0, helpers_1.createMediaQueryBuilder)({
|
|
29
|
-
emitBase: emitBaseFeatures,
|
|
30
|
-
resolveType: (props) => props.type,
|
|
31
|
-
});
|
|
32
|
-
const makeMediaQueryStyle = (queries) => (stylesByQuery) => {
|
|
33
|
-
const result = {};
|
|
34
|
-
Object.keys(stylesByQuery).forEach((key) => {
|
|
35
|
-
const styles = stylesByQuery[key];
|
|
36
|
-
const props = queries[key];
|
|
37
|
-
if (!styles || !props)
|
|
38
|
-
return;
|
|
39
|
-
result[buildMediaQueryString(props)] = styles;
|
|
40
|
-
});
|
|
41
|
-
const mediaQuery = {
|
|
42
|
-
'@media': result,
|
|
43
|
-
};
|
|
44
|
-
return mediaQuery;
|
|
45
|
-
};
|
|
46
|
-
const moduleEmitters = {
|
|
47
|
-
core: emitCoreFeatures,
|
|
48
|
-
dimensions: emitDimensionsFeatures,
|
|
49
|
-
resolution: emitResolutionFeatures,
|
|
50
|
-
interaction: modules_1.emitInteractionFeatures,
|
|
51
|
-
preferences: modules_1.emitPreferencesFeatures,
|
|
52
|
-
display: modules_1.emitDisplayFeatures,
|
|
53
|
-
environment: modules_1.emitEnvironmentFeatures,
|
|
54
|
-
custom: modules_1.emitCustomFeatures,
|
|
55
|
-
};
|
|
56
|
-
const mediaQueryFactory = (0, factory_1.createMediaQueryFactory)(moduleEmitters);
|
|
57
|
-
return {
|
|
58
|
-
buildMediaQueryString,
|
|
59
|
-
makeMediaQueryStyle,
|
|
60
|
-
mediaQueryFactory,
|
|
61
|
-
emitCoreFeatures,
|
|
62
|
-
emitDimensionsFeatures,
|
|
63
|
-
emitResolutionFeatures,
|
|
64
|
-
emitInteractionFeatures: modules_1.emitInteractionFeatures,
|
|
65
|
-
emitPreferencesFeatures: modules_1.emitPreferencesFeatures,
|
|
66
|
-
emitDisplayFeatures: modules_1.emitDisplayFeatures,
|
|
67
|
-
emitEnvironmentFeatures: modules_1.emitEnvironmentFeatures,
|
|
68
|
-
emitCustomFeatures: modules_1.emitCustomFeatures,
|
|
69
|
-
mediaQueryOutputVanillaExtract: vanilla_extract_1.mediaQueryOutputVanillaExtract,
|
|
70
|
-
createMediaQueryBuilder: helpers_1.createMediaQueryBuilder,
|
|
71
|
-
};
|
|
72
|
-
};
|
|
73
|
-
exports.createMediaQueriesApi = createMediaQueriesApi;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.normalizeToArray = void 0;
|
|
4
|
-
const normalizeToArray = (value) => {
|
|
5
|
-
if (value === undefined || value === null)
|
|
6
|
-
return [];
|
|
7
|
-
return Array.isArray(value) ? value : [value];
|
|
8
|
-
};
|
|
9
|
-
exports.normalizeToArray = normalizeToArray;
|
|
@@ -1,11 +0,0 @@
|
|
|
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;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
// export type ContentQueryVariable =
|
|
4
|
-
// ContainerQueryModuleKeysMap[keyof ContainerQueryModuleKeysMap];
|
|
5
|
-
// export type ContentQueryComparisonValue = IMeasurement | number | string;
|
|
6
|
-
// export type Comparison<
|
|
7
|
-
// Variable = ContentQueryVariable,
|
|
8
|
-
// Value = ContentQueryComparisonValue
|
|
9
|
-
// > = {
|
|
10
|
-
// variable: Variable;
|
|
11
|
-
// operator: IComparisonOperator;
|
|
12
|
-
// value: Value;
|
|
13
|
-
// };
|
|
14
|
-
// export type ComparisonValue<Value = ContentQueryComparisonValue> = {
|
|
15
|
-
// operator: IComparisonOperator;
|
|
16
|
-
// value: Value;
|
|
17
|
-
// readonly __comparisonBrand: unique symbol;
|
|
18
|
-
// };
|
|
@@ -1,187 +0,0 @@
|
|
|
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
|
-
const handleUnknownQueryKey = (key, config) => {
|
|
146
|
-
var _a, _b;
|
|
147
|
-
const mode = (_b = (_a = config.errorHandling) === null || _a === void 0 ? void 0 : _a.invalidValueMode) !== null && _b !== void 0 ? _b : 'throw';
|
|
148
|
-
const message = `Media query factory "${config.label}" received unknown query key "${key}".`;
|
|
149
|
-
if (mode === 'log') {
|
|
150
|
-
console.warn(message);
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
if (mode === 'allow')
|
|
154
|
-
return;
|
|
155
|
-
throw new Error(message);
|
|
156
|
-
};
|
|
157
|
-
return (stylesByQuery) => {
|
|
158
|
-
const result = {};
|
|
159
|
-
Object.keys(stylesByQuery).forEach((key) => {
|
|
160
|
-
const styles = stylesByQuery[key];
|
|
161
|
-
if (!styles)
|
|
162
|
-
return;
|
|
163
|
-
if (Object.prototype.hasOwnProperty.call(options.queries, key)) {
|
|
164
|
-
return;
|
|
165
|
-
}
|
|
166
|
-
handleUnknownQueryKey(String(key), options.config);
|
|
167
|
-
});
|
|
168
|
-
Object.keys(stylesByQuery).forEach((key) => {
|
|
169
|
-
const styles = stylesByQuery[key];
|
|
170
|
-
const props = options.queries[key];
|
|
171
|
-
if (!styles || !props)
|
|
172
|
-
return;
|
|
173
|
-
result[buildMediaQuery(props)] = styles;
|
|
174
|
-
});
|
|
175
|
-
const mediaQuery = {
|
|
176
|
-
'@media': result,
|
|
177
|
-
};
|
|
178
|
-
const processed = options.config.preProcessor
|
|
179
|
-
? options.config.preProcessor(mediaQuery)
|
|
180
|
-
: mediaQuery;
|
|
181
|
-
return options.config.output
|
|
182
|
-
? options.config.output(processed)
|
|
183
|
-
: processed;
|
|
184
|
-
};
|
|
185
|
-
};
|
|
186
|
-
exports.createMediaQueryFactory = createMediaQueryFactory;
|
|
187
|
-
exports.mediaQueryFactory = (0, exports.createMediaQueryFactory)(MODULE_EMITTERS);
|
|
@@ -1,97 +0,0 @@
|
|
|
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 formatMediaQueryValue = (value) => ((0, core_1.hasCssMethod)(value) ? value.css() : String(value));
|
|
6
|
-
exports.formatMediaQueryValue = formatMediaQueryValue;
|
|
7
|
-
const buildMediaQueryStringFromParts = (mediaType, parts) => (parts.length ? `${mediaType} and ${parts.join(' and ')}` : mediaType);
|
|
8
|
-
exports.buildMediaQueryStringFromParts = buildMediaQueryStringFromParts;
|
|
9
|
-
const createMediaQueryFeatureEmitter = (parts) => (name, value) => {
|
|
10
|
-
parts.push(`(${name}: ${(0, exports.formatMediaQueryValue)(value)})`);
|
|
11
|
-
};
|
|
12
|
-
exports.createMediaQueryFeatureEmitter = createMediaQueryFeatureEmitter;
|
|
13
|
-
const createMediaQueryFeatureEmitterWithTracking = (parts, options = {}) => {
|
|
14
|
-
const { emitted, lintingMode = 'throw' } = options;
|
|
15
|
-
return (name, value) => {
|
|
16
|
-
if (emitted === null || emitted === void 0 ? void 0 : emitted.has(name)) {
|
|
17
|
-
if (lintingMode === 'throw') {
|
|
18
|
-
throw new Error(`Media query feature "${name}" was emitted more than once.`);
|
|
19
|
-
}
|
|
20
|
-
if (lintingMode === 'log') {
|
|
21
|
-
console.warn(`Media query feature "${name}" was emitted more than once; using the latest value.`);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
emitted === null || emitted === void 0 ? void 0 : emitted.add(name);
|
|
25
|
-
parts.push(`(${name}: ${(0, exports.formatMediaQueryValue)(value)})`);
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
exports.createMediaQueryFeatureEmitterWithTracking = createMediaQueryFeatureEmitterWithTracking;
|
|
29
|
-
const createMediaQueryBuilder = (options) => {
|
|
30
|
-
return (config) => {
|
|
31
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
32
|
-
const parts = [];
|
|
33
|
-
const emittedFeatures = new Set();
|
|
34
|
-
const helpers = {
|
|
35
|
-
addFeature: (0, exports.createMediaQueryFeatureEmitterWithTracking)(parts, {
|
|
36
|
-
emitted: emittedFeatures,
|
|
37
|
-
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',
|
|
38
|
-
}),
|
|
39
|
-
config: (_d = options.config) !== null && _d !== void 0 ? _d : {},
|
|
40
|
-
};
|
|
41
|
-
options.emitBase(config, helpers);
|
|
42
|
-
(_e = options.emitExtensions) === null || _e === void 0 ? void 0 : _e.call(options, config, helpers);
|
|
43
|
-
const mediaType = (_g = (_f = options.resolveType) === null || _f === void 0 ? void 0 : _f.call(options, config)) !== null && _g !== void 0 ? _g : 'screen';
|
|
44
|
-
return (0, exports.buildMediaQueryStringFromParts)(mediaType, parts);
|
|
45
|
-
};
|
|
46
|
-
};
|
|
47
|
-
exports.createMediaQueryBuilder = createMediaQueryBuilder;
|
|
48
|
-
const normalizeValidationResult = (result) => {
|
|
49
|
-
if (result === undefined || result === null)
|
|
50
|
-
return { valid: true };
|
|
51
|
-
if (typeof result === 'boolean')
|
|
52
|
-
return { valid: result };
|
|
53
|
-
if (typeof result === 'string') {
|
|
54
|
-
return result ? { valid: false, message: result } : { valid: true };
|
|
55
|
-
}
|
|
56
|
-
return result;
|
|
57
|
-
};
|
|
58
|
-
const applyMediaQueryValidation = (config, helpers, validator, context) => {
|
|
59
|
-
var _a, _b;
|
|
60
|
-
if (!validator)
|
|
61
|
-
return true;
|
|
62
|
-
const normalized = normalizeValidationResult(validator(config));
|
|
63
|
-
if (normalized.valid)
|
|
64
|
-
return true;
|
|
65
|
-
const mode = (_b = (_a = helpers.config.errorHandling) === null || _a === void 0 ? void 0 : _a.invalidValueMode) !== null && _b !== void 0 ? _b : 'throw';
|
|
66
|
-
if (mode === 'log') {
|
|
67
|
-
const suffix = normalized.message ? `: ${normalized.message}` : '';
|
|
68
|
-
const prefix = context
|
|
69
|
-
? `Media query ${context} validation failed`
|
|
70
|
-
: 'Media query validation failed';
|
|
71
|
-
console.warn(`${prefix}${suffix}`);
|
|
72
|
-
}
|
|
73
|
-
if (mode === 'allow')
|
|
74
|
-
return true;
|
|
75
|
-
if (mode === 'log')
|
|
76
|
-
return true;
|
|
77
|
-
const suffix = normalized.message ? `: ${normalized.message}` : '';
|
|
78
|
-
const prefix = context
|
|
79
|
-
? `Media query ${context} validation failed`
|
|
80
|
-
: 'Media query validation failed';
|
|
81
|
-
throw new Error(`${prefix}${suffix}`);
|
|
82
|
-
};
|
|
83
|
-
exports.applyMediaQueryValidation = applyMediaQueryValidation;
|
|
84
|
-
const buildMediaQueryFromFeatures = (features, mediaType = 'screen') => {
|
|
85
|
-
const parts = [];
|
|
86
|
-
const addFeature = (0, exports.createMediaQueryFeatureEmitterWithTracking)(parts, {
|
|
87
|
-
emitted: new Set(),
|
|
88
|
-
lintingMode: 'throw',
|
|
89
|
-
});
|
|
90
|
-
Object.entries(features).forEach(([name, value]) => {
|
|
91
|
-
if (value === undefined || value === null)
|
|
92
|
-
return;
|
|
93
|
-
addFeature(name, value);
|
|
94
|
-
});
|
|
95
|
-
return (0, exports.buildMediaQueryStringFromParts)(mediaType, parts);
|
|
96
|
-
};
|
|
97
|
-
exports.buildMediaQueryFromFeatures = buildMediaQueryFromFeatures;
|
|
@@ -1,23 +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("./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);
|