@contentful/experiences-design 0.7.5 → 0.7.6
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/CHANGELOG.md +10 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/media-query-matchers.d.ts +17 -0
- package/dist/media-query-matchers.js +23 -0
- package/dist/media-query-matchers.js.map +1 -0
- package/dist/select-resolved-design.d.ts +11 -0
- package/dist/select-resolved-design.js +12 -0
- package/dist/select-resolved-design.js.map +1 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
## 0.7.6 (2026-08-20)
|
|
2
|
+
|
|
3
|
+
### 🚀 Features
|
|
4
|
+
|
|
5
|
+
- **adapter-angular:** scaffold @contentful/experiences-angular [AIS-361] ([#134](https://github.com/contentful/experiences/pull/134))
|
|
6
|
+
|
|
7
|
+
### 🧱 Updated Dependencies
|
|
8
|
+
|
|
9
|
+
- Updated core to 0.7.6
|
|
10
|
+
|
|
1
11
|
## 0.7.5 (2026-08-12)
|
|
2
12
|
|
|
3
13
|
### 🧱 Updated Dependencies
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export { toCssMediaQuery } from './viewport.js';
|
|
2
2
|
export { CSS_PROPERTIES, isCssProperty, toCssKey } from './css-properties.js';
|
|
3
|
+
export { selectResolvedDesign } from './select-resolved-design.js';
|
|
4
|
+
export { MediaQueryMatcher, createMediaQueryMatchers } from './media-query-matchers.js';
|
|
3
5
|
export { applyTokenResolver, getValueForViewport, getViewportIndex, resolveDesignProperties } from '@contentful/experiences-sdk-core';
|
package/dist/index.js
CHANGED
|
@@ -6,13 +6,17 @@ import {
|
|
|
6
6
|
toCssMediaQuery
|
|
7
7
|
} from "./viewport";
|
|
8
8
|
import { CSS_PROPERTIES, isCssProperty, toCssKey } from "./css-properties";
|
|
9
|
+
import { selectResolvedDesign } from "./select-resolved-design";
|
|
10
|
+
import { createMediaQueryMatchers } from "./media-query-matchers";
|
|
9
11
|
export {
|
|
10
12
|
CSS_PROPERTIES,
|
|
11
13
|
applyTokenResolver,
|
|
14
|
+
createMediaQueryMatchers,
|
|
12
15
|
getValueForViewport,
|
|
13
16
|
getViewportIndex,
|
|
14
17
|
isCssProperty,
|
|
15
18
|
resolveDesignProperties,
|
|
19
|
+
selectResolvedDesign,
|
|
16
20
|
toCssKey,
|
|
17
21
|
toCssMediaQuery
|
|
18
22
|
};
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export {\n applyTokenResolver,\n getValueForViewport,\n getViewportIndex,\n resolveDesignProperties,\n toCssMediaQuery,\n} from './viewport';\nexport { CSS_PROPERTIES, isCssProperty, toCssKey } from './css-properties';\n"],"mappings":"AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,gBAAgB,eAAe,gBAAgB;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export {\n applyTokenResolver,\n getValueForViewport,\n getViewportIndex,\n resolveDesignProperties,\n toCssMediaQuery,\n} from './viewport';\nexport { CSS_PROPERTIES, isCssProperty, toCssKey } from './css-properties';\nexport { selectResolvedDesign } from './select-resolved-design';\nexport { createMediaQueryMatchers } from './media-query-matchers';\nexport type { MediaQueryMatcher } from './media-query-matchers';\n"],"mappings":"AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,gBAAgB,eAAe,gBAAgB;AACxD,SAAS,4BAA4B;AACrC,SAAS,gCAAgC;","names":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ViewportDef } from '@contentful/experiences-sdk-core';
|
|
2
|
+
|
|
3
|
+
interface MediaQueryMatcher {
|
|
4
|
+
index: number;
|
|
5
|
+
signal: MediaQueryList;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Builds one `MediaQueryList` per viewport that has a real media query, plus a
|
|
9
|
+
* parallel array of their current match states.
|
|
10
|
+
*
|
|
11
|
+
* Outside the browser the matcher list comes back empty and only the wildcard
|
|
12
|
+
* viewport is marked as matching, so callers stay SSR-safe without their own
|
|
13
|
+
* `typeof window` guard.
|
|
14
|
+
*/
|
|
15
|
+
declare function createMediaQueryMatchers(viewports: ViewportDef[]): [MediaQueryMatcher[], boolean[]];
|
|
16
|
+
|
|
17
|
+
export { type MediaQueryMatcher, createMediaQueryMatchers };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { toCssMediaQuery } from "./viewport";
|
|
2
|
+
function createMediaQueryMatchers(viewports) {
|
|
3
|
+
const mediaQueryMatches = new Array(viewports.length).fill(false);
|
|
4
|
+
mediaQueryMatches[0] = true;
|
|
5
|
+
const mediaQueryMatchers = [];
|
|
6
|
+
if (typeof window === "undefined") {
|
|
7
|
+
return [mediaQueryMatchers, mediaQueryMatches];
|
|
8
|
+
}
|
|
9
|
+
for (let index = 0; index < viewports.length; index++) {
|
|
10
|
+
const viewport = viewports[index];
|
|
11
|
+
if (!viewport) continue;
|
|
12
|
+
const cssQuery = toCssMediaQuery(viewport);
|
|
13
|
+
if (!cssQuery) continue;
|
|
14
|
+
const matcher = window.matchMedia(cssQuery);
|
|
15
|
+
mediaQueryMatches[index] = matcher.matches;
|
|
16
|
+
mediaQueryMatchers.push({ index, signal: matcher });
|
|
17
|
+
}
|
|
18
|
+
return [mediaQueryMatchers, mediaQueryMatches];
|
|
19
|
+
}
|
|
20
|
+
export {
|
|
21
|
+
createMediaQueryMatchers
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=media-query-matchers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/media-query-matchers.ts"],"sourcesContent":["/*\n * `window.matchMedia` plumbing for viewport tracking, shared by every adapter.\n *\n * Each adapter owns its own reactivity primitive (React `useState`, Svelte\n * `$state`, Angular signals) but the matcher construction and the SSR guard are\n * identical, so they live here.\n *\n * \"Active viewport\" = the last-matching media query in the ordered viewports\n * list. With desktop-first ordering (`*`, `<992px`, `<576px`), the narrowest\n * matching query wins. With mobile-first ordering, the widest wins. Either\n * way: the last `findLastIndex` of `mediaQueryMatches[i] === true`.\n */\n\nimport type { ViewportDef } from '@contentful/experiences-sdk-core';\n\nimport { toCssMediaQuery } from './viewport';\n\nexport interface MediaQueryMatcher {\n index: number;\n signal: MediaQueryList;\n}\n\n/**\n * Builds one `MediaQueryList` per viewport that has a real media query, plus a\n * parallel array of their current match states.\n *\n * Outside the browser the matcher list comes back empty and only the wildcard\n * viewport is marked as matching, so callers stay SSR-safe without their own\n * `typeof window` guard.\n */\nexport function createMediaQueryMatchers(\n viewports: ViewportDef[]\n): [MediaQueryMatcher[], boolean[]] {\n const mediaQueryMatches: boolean[] = new Array(viewports.length).fill(false);\n // The first viewport is the wildcard \"*\" and always matches.\n mediaQueryMatches[0] = true;\n\n const mediaQueryMatchers: MediaQueryMatcher[] = [];\n if (typeof window === 'undefined') {\n return [mediaQueryMatchers, mediaQueryMatches];\n }\n for (let index = 0; index < viewports.length; index++) {\n const viewport = viewports[index];\n if (!viewport) continue;\n const cssQuery = toCssMediaQuery(viewport);\n if (!cssQuery) continue;\n const matcher = window.matchMedia(cssQuery);\n mediaQueryMatches[index] = matcher.matches;\n mediaQueryMatchers.push({ index, signal: matcher });\n }\n return [mediaQueryMatchers, mediaQueryMatches];\n}\n"],"mappings":"AAeA,SAAS,uBAAuB;AAezB,SAAS,yBACd,WACkC;AAClC,QAAM,oBAA+B,IAAI,MAAM,UAAU,MAAM,EAAE,KAAK,KAAK;AAE3E,oBAAkB,CAAC,IAAI;AAEvB,QAAM,qBAA0C,CAAC;AACjD,MAAI,OAAO,WAAW,aAAa;AACjC,WAAO,CAAC,oBAAoB,iBAAiB;AAAA,EAC/C;AACA,WAAS,QAAQ,GAAG,QAAQ,UAAU,QAAQ,SAAS;AACrD,UAAM,WAAW,UAAU,KAAK;AAChC,QAAI,CAAC,SAAU;AACf,UAAM,WAAW,gBAAgB,QAAQ;AACzC,QAAI,CAAC,SAAU;AACf,UAAM,UAAU,OAAO,WAAW,QAAQ;AAC1C,sBAAkB,KAAK,IAAI,QAAQ;AACnC,uBAAmB,KAAK,EAAE,OAAO,QAAQ,QAAQ,CAAC;AAAA,EACpD;AACA,SAAO,CAAC,oBAAoB,iBAAiB;AAC/C;","names":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DesignPropValue, ViewportDef, ResolveToken } from '@contentful/experiences-sdk-core';
|
|
2
|
+
|
|
3
|
+
declare function selectResolvedDesign(props: {
|
|
4
|
+
design: Record<string, unknown>;
|
|
5
|
+
designRaw: Record<string, DesignPropValue>;
|
|
6
|
+
}, viewports: ViewportDef[], activeViewportIndex: number, fallbackViewportIndex: number, resolveToken: ResolveToken | undefined): {
|
|
7
|
+
props: Record<string, unknown>;
|
|
8
|
+
unresolved: string[];
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export { selectResolvedDesign };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { applyTokenResolver, resolveDesignProperties } from "@contentful/experiences-sdk-core";
|
|
2
|
+
function selectResolvedDesign(props, viewports, activeViewportIndex, fallbackViewportIndex, resolveToken) {
|
|
3
|
+
if (activeViewportIndex === fallbackViewportIndex) {
|
|
4
|
+
return { props: props.design, unresolved: [] };
|
|
5
|
+
}
|
|
6
|
+
const resolvedDesign = resolveDesignProperties(props.designRaw, viewports, activeViewportIndex);
|
|
7
|
+
return applyTokenResolver(resolvedDesign, resolveToken);
|
|
8
|
+
}
|
|
9
|
+
export {
|
|
10
|
+
selectResolvedDesign
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=select-resolved-design.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/select-resolved-design.ts"],"sourcesContent":["/*\n * Picks the design record a renderer should use for the active viewport.\n *\n * Shared by every framework adapter: the choice between \"trust the server's\n * pre-resolved values\" and \"recompute the cascade client-side\" is a property of\n * the IR, not of any one framework.\n */\n\nimport type { DesignPropValue, ResolveToken, ViewportDef } from '@contentful/experiences-sdk-core';\nimport { applyTokenResolver, resolveDesignProperties } from '@contentful/experiences-sdk-core';\n\n// Use the server-resolved `props.design` when the active viewport matches the\n// fallback; otherwise recompute the cascade from raw `props.designRaw`.\nexport function selectResolvedDesign(\n props: { design: Record<string, unknown>; designRaw: Record<string, DesignPropValue> },\n viewports: ViewportDef[],\n activeViewportIndex: number,\n fallbackViewportIndex: number,\n resolveToken: ResolveToken | undefined\n): { props: Record<string, unknown>; unresolved: string[] } {\n if (activeViewportIndex === fallbackViewportIndex) {\n return { props: props.design, unresolved: [] };\n }\n const resolvedDesign = resolveDesignProperties(props.designRaw, viewports, activeViewportIndex);\n return applyTokenResolver(resolvedDesign, resolveToken);\n}\n"],"mappings":"AASA,SAAS,oBAAoB,+BAA+B;AAIrD,SAAS,qBACd,OACA,WACA,qBACA,uBACA,cAC0D;AAC1D,MAAI,wBAAwB,uBAAuB;AACjD,WAAO,EAAE,OAAO,MAAM,QAAQ,YAAY,CAAC,EAAE;AAAA,EAC/C;AACA,QAAM,iBAAiB,wBAAwB,MAAM,WAAW,WAAW,mBAAmB;AAC9F,SAAO,mBAAmB,gBAAgB,YAAY;AACxD;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/experiences-design",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.6",
|
|
4
4
|
"description": "Viewport math and design-property resolution utilities for Contentful Experiences",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -30,6 +30,6 @@
|
|
|
30
30
|
"directory": "packages/design"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@contentful/experiences-sdk-core": "0.7.
|
|
33
|
+
"@contentful/experiences-sdk-core": "0.7.6"
|
|
34
34
|
}
|
|
35
35
|
}
|