@contentful/experiences-sdk-react 1.31.0 → 1.31.1-prerelease-20250218T2104-febb4f2.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.
|
@@ -10,12 +10,11 @@ import { useState, useEffect, useCallback } from 'react';
|
|
|
10
10
|
* and then decending by screen width. For mobile-first designs, the order would be ascending
|
|
11
11
|
*/
|
|
12
12
|
const useBreakpoints = (breakpoints) => {
|
|
13
|
-
const [,
|
|
14
|
-
const [mediaQueryMatches, setMediaQueryMatches] = useState(initialMediaQueryMatches);
|
|
15
|
-
const fallbackBreakpointIndex = getFallbackBreakpointIndex(breakpoints);
|
|
13
|
+
const [mediaQueryMatches, setMediaQueryMatches] = useState({});
|
|
16
14
|
// Register event listeners to update the media query states
|
|
17
15
|
useEffect(() => {
|
|
18
|
-
const [mediaQueryMatchers] = mediaQueryMatcher(breakpoints);
|
|
16
|
+
const [mediaQueryMatchers, initialMediaQueryMatches] = mediaQueryMatcher(breakpoints);
|
|
17
|
+
setMediaQueryMatches(initialMediaQueryMatches);
|
|
19
18
|
const eventListeners = mediaQueryMatchers.map(({ id, signal }) => {
|
|
20
19
|
const onChange = () => setMediaQueryMatches((prev) => ({
|
|
21
20
|
...prev,
|
|
@@ -30,10 +29,11 @@ const useBreakpoints = (breakpoints) => {
|
|
|
30
29
|
});
|
|
31
30
|
};
|
|
32
31
|
}, [breakpoints]);
|
|
33
|
-
const activeBreakpointIndex = getActiveBreakpointIndex(breakpoints, mediaQueryMatches, fallbackBreakpointIndex);
|
|
34
32
|
const resolveDesignValue = useCallback((valuesByBreakpoint, variableName) => {
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
const fallbackBreakpointIndex = getFallbackBreakpointIndex(breakpoints);
|
|
34
|
+
const activeBreakpointIndex = getActiveBreakpointIndex(breakpoints, mediaQueryMatches, fallbackBreakpointIndex);
|
|
35
|
+
return getValueForBreakpoint(valuesByBreakpoint, breakpoints, activeBreakpointIndex, fallbackBreakpointIndex, variableName);
|
|
36
|
+
}, [mediaQueryMatches, breakpoints]);
|
|
37
37
|
return { resolveDesignValue };
|
|
38
38
|
};
|
|
39
39
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBreakpoints.js","sources":["../../../src/hooks/useBreakpoints.ts"],"sourcesContent":["import type { Breakpoint, ResolveDesignValueType } from '@contentful/experiences-core/types';\nimport {\n mediaQueryMatcher,\n getFallbackBreakpointIndex,\n getActiveBreakpointIndex,\n getValueForBreakpoint,\n} from '@contentful/experiences-core';\nimport { useCallback, useEffect, useState } from 'react';\n\n// TODO: In order to support integrations without React, we should extract this heavy logic into simple\n// functions that we can reuse in other frameworks.\n\n/*\n * Registers media query change listeners for each breakpoint (except for \"*\").\n * It will always assume the last matching media query in the list. It therefore,\n * assumes that the breakpoints are sorted beginning with the default value (query: \"*\")\n * and then decending by screen width. For mobile-first designs, the order would be ascending\n */\nexport const useBreakpoints = (breakpoints: Breakpoint[]) => {\n const [,
|
|
1
|
+
{"version":3,"file":"useBreakpoints.js","sources":["../../../src/hooks/useBreakpoints.ts"],"sourcesContent":["import type { Breakpoint, ResolveDesignValueType } from '@contentful/experiences-core/types';\nimport {\n mediaQueryMatcher,\n getFallbackBreakpointIndex,\n getActiveBreakpointIndex,\n getValueForBreakpoint,\n} from '@contentful/experiences-core';\nimport { useCallback, useEffect, useState } from 'react';\n\n// TODO: In order to support integrations without React, we should extract this heavy logic into simple\n// functions that we can reuse in other frameworks.\n\n/*\n * Registers media query change listeners for each breakpoint (except for \"*\").\n * It will always assume the last matching media query in the list. It therefore,\n * assumes that the breakpoints are sorted beginning with the default value (query: \"*\")\n * and then decending by screen width. For mobile-first designs, the order would be ascending\n */\nexport const useBreakpoints = (breakpoints: Breakpoint[]) => {\n const [mediaQueryMatches, setMediaQueryMatches] = useState<Record<string, boolean>>({});\n\n // Register event listeners to update the media query states\n useEffect(() => {\n const [mediaQueryMatchers, initialMediaQueryMatches] = mediaQueryMatcher(breakpoints);\n\n setMediaQueryMatches(initialMediaQueryMatches);\n\n const eventListeners = mediaQueryMatchers.map(({ id, signal }) => {\n const onChange = () =>\n setMediaQueryMatches((prev) => ({\n ...prev,\n [id]: signal.matches,\n }));\n\n signal.addEventListener('change', onChange);\n return onChange;\n });\n\n return () => {\n eventListeners.forEach((eventListener, index) => {\n mediaQueryMatchers[index].signal.removeEventListener('change', eventListener);\n });\n };\n }, [breakpoints]);\n\n const resolveDesignValue: ResolveDesignValueType = useCallback(\n (valuesByBreakpoint, variableName) => {\n const fallbackBreakpointIndex = getFallbackBreakpointIndex(breakpoints);\n\n const activeBreakpointIndex = getActiveBreakpointIndex(\n breakpoints,\n mediaQueryMatches,\n fallbackBreakpointIndex,\n );\n\n return getValueForBreakpoint(\n valuesByBreakpoint,\n breakpoints,\n activeBreakpointIndex,\n fallbackBreakpointIndex,\n variableName,\n );\n },\n [mediaQueryMatches, breakpoints],\n );\n\n return { resolveDesignValue };\n};\n"],"names":[],"mappings":";;;AASA;AACA;AAEA;;;;;AAKG;AACU,MAAA,cAAc,GAAG,CAAC,WAAyB,KAAI;IAC1D,MAAM,CAAC,iBAAiB,EAAE,oBAAoB,CAAC,GAAG,QAAQ,CAA0B,EAAE,CAAC,CAAC;;IAGxF,SAAS,CAAC,MAAK;QACb,MAAM,CAAC,kBAAkB,EAAE,wBAAwB,CAAC,GAAG,iBAAiB,CAAC,WAAW,CAAC,CAAC;QAEtF,oBAAoB,CAAC,wBAAwB,CAAC,CAAC;AAE/C,QAAA,MAAM,cAAc,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,KAAI;AAC/D,YAAA,MAAM,QAAQ,GAAG,MACf,oBAAoB,CAAC,CAAC,IAAI,MAAM;AAC9B,gBAAA,GAAG,IAAI;AACP,gBAAA,CAAC,EAAE,GAAG,MAAM,CAAC,OAAO;AACrB,aAAA,CAAC,CAAC,CAAC;AAEN,YAAA,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;AAC5C,YAAA,OAAO,QAAQ,CAAC;AAClB,SAAC,CAAC,CAAC;AAEH,QAAA,OAAO,MAAK;YACV,cAAc,CAAC,OAAO,CAAC,CAAC,aAAa,EAAE,KAAK,KAAI;AAC9C,gBAAA,kBAAkB,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;AAChF,aAAC,CAAC,CAAC;AACL,SAAC,CAAC;AACJ,KAAC,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC;IAElB,MAAM,kBAAkB,GAA2B,WAAW,CAC5D,CAAC,kBAAkB,EAAE,YAAY,KAAI;AACnC,QAAA,MAAM,uBAAuB,GAAG,0BAA0B,CAAC,WAAW,CAAC,CAAC;QAExE,MAAM,qBAAqB,GAAG,wBAAwB,CACpD,WAAW,EACX,iBAAiB,EACjB,uBAAuB,CACxB,CAAC;AAEF,QAAA,OAAO,qBAAqB,CAC1B,kBAAkB,EAClB,WAAW,EACX,qBAAqB,EACrB,uBAAuB,EACvB,YAAY,CACb,CAAC;AACJ,KAAC,EACD,CAAC,iBAAiB,EAAE,WAAW,CAAC,CACjC,CAAC;IAEF,OAAO,EAAE,kBAAkB,EAAE,CAAC;AAChC;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ import * as _contentful_experiences_core_constants from '@contentful/experiences
|
|
|
8
8
|
export { CF_STYLE_ATTRIBUTES, CONTENTFUL_COMPONENTS, LATEST_SCHEMA_VERSION } from '@contentful/experiences-core/constants';
|
|
9
9
|
import { ContentfulClientApi } from 'contentful';
|
|
10
10
|
|
|
11
|
-
declare const SDK_VERSION = "1.31.0";
|
|
11
|
+
declare const SDK_VERSION = "1.31.1-prerelease-20250218T2104-febb4f2.0";
|
|
12
12
|
|
|
13
13
|
type ExperienceRootProps = {
|
|
14
14
|
experience?: Experience<EntityStore> | string | null;
|
package/dist/sdkVersion.js
CHANGED
package/dist/sdkVersion.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdkVersion.js","sources":["../../src/sdkVersion.ts"],"sourcesContent":["export const SDK_VERSION = '1.31.0';\n"],"names":[],"mappings":"AAAO,MAAM,WAAW,GAAG;;;;"}
|
|
1
|
+
{"version":3,"file":"sdkVersion.js","sources":["../../src/sdkVersion.ts"],"sourcesContent":["export const SDK_VERSION = '1.31.1-prerelease-20250218T2104-febb4f2.0';\n"],"names":[],"mappings":"AAAO,MAAM,WAAW,GAAG;;;;"}
|
package/dist/src/sdkVersion.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "1.31.0";
|
|
1
|
+
export declare const SDK_VERSION = "1.31.1-prerelease-20250218T2104-febb4f2.0";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/experiences-sdk-react",
|
|
3
|
-
"version": "1.31.0",
|
|
3
|
+
"version": "1.31.1-prerelease-20250218T2104-febb4f2.0",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"module": "./dist/index.js",
|
|
6
6
|
"typings": "./dist/src/index.d.ts",
|
|
@@ -41,10 +41,10 @@
|
|
|
41
41
|
"depcruise": "depcruise src"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@contentful/experiences-components-react": "1.31.0",
|
|
45
|
-
"@contentful/experiences-core": "1.31.0",
|
|
46
|
-
"@contentful/experiences-validators": "1.31.0",
|
|
47
|
-
"@contentful/experiences-visual-editor-react": "1.31.0",
|
|
44
|
+
"@contentful/experiences-components-react": "1.31.1-prerelease-20250218T2104-febb4f2.0",
|
|
45
|
+
"@contentful/experiences-core": "1.31.1-prerelease-20250218T2104-febb4f2.0",
|
|
46
|
+
"@contentful/experiences-validators": "1.31.1-prerelease-20250218T2104-febb4f2.0",
|
|
47
|
+
"@contentful/experiences-visual-editor-react": "1.31.1-prerelease-20250218T2104-febb4f2.0",
|
|
48
48
|
"@contentful/rich-text-types": "^17.0.0",
|
|
49
49
|
"classnames": "^2.3.2",
|
|
50
50
|
"csstype": "^3.1.2",
|
|
@@ -102,5 +102,5 @@
|
|
|
102
102
|
"dist",
|
|
103
103
|
"package.json"
|
|
104
104
|
],
|
|
105
|
-
"gitHead": "
|
|
105
|
+
"gitHead": "b25a64bef095e7ad95d644918cd574f3a042fd50"
|
|
106
106
|
}
|