@contentstack/studio-core 1.1.1 → 1.1.2

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/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import * as _contentstack_studio_client from '@contentstack/studio-client';
3
- import { StudioSpec, UserConfig, LightConfig, StudioSdk, ComposableStudioLightSdk } from '@contentstack/studio-client';
3
+ import { StudioSpec, FontVariants, UserConfig, LightConfig, StudioSdk, ComposableStudioLightSdk } from '@contentstack/studio-client';
4
4
  import { NodeStyles } from '@contentstack/studio-internal';
5
5
 
6
6
  declare const Button: (props: React.ButtonHTMLAttributes<HTMLButtonElement>) => react_jsx_runtime.JSX.Element;
@@ -20,16 +20,7 @@ declare const Button: (props: React.ButtonHTMLAttributes<HTMLButtonElement>) =>
20
20
  */
21
21
  declare const extractStyles: (specs: (StudioSpec | null)[]) => string;
22
22
 
23
- /**
24
- * Processes node styles and generates responsive styles based on the provided style configuration.
25
- * The default styles are not provied in the named style object, as it is assumed that it will be
26
- * passed to the component via `className` and not as a separate prop.
27
- *
28
- * @param nodeStyles - An object containing styles for different sections of a node.
29
- * @param styleConfiguration - Configuration options for registering component styles, including default styles and classes.
30
- * @returns A tuple containing the default style class and an object mapping section names to their respective style classes.
31
- */
32
- declare function handleNodeStyles(nodeStyles: NodeStyles, nodeUid: string): [string, Record<string, string>, Set<string>];
23
+ declare function handleNodeStyles(nodeStyles: NodeStyles, nodeUid: string): [string, Record<string, string>, Set<string>, Map<string, FontVariants>];
33
24
 
34
25
  declare let sdk: StudioSdk | null;
35
26
  declare let lightSdk: ComposableStudioLightSdk | null;
@@ -1,12 +1,4 @@
1
+ import { FontVariants } from "@contentstack/studio-client";
1
2
  import type { NodeStyles } from "@contentstack/studio-internal";
2
- /**
3
- * Processes node styles and generates responsive styles based on the provided style configuration.
4
- * The default styles are not provied in the named style object, as it is assumed that it will be
5
- * passed to the component via `className` and not as a separate prop.
6
- *
7
- * @param nodeStyles - An object containing styles for different sections of a node.
8
- * @param styleConfiguration - Configuration options for registering component styles, including default styles and classes.
9
- * @returns A tuple containing the default style class and an object mapping section names to their respective style classes.
10
- */
11
- export declare function handleNodeStyles(nodeStyles: NodeStyles, nodeUid: string): [string, Record<string, string>, Set<string>];
3
+ export declare function handleNodeStyles(nodeStyles: NodeStyles, nodeUid: string): [string, Record<string, string>, Set<string>, Map<string, FontVariants>];
12
4
  //# sourceMappingURL=handle-responsive-styles.util.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"handle-responsive-styles.util.d.ts","sourceRoot":"","sources":["../../src/utils/handle-responsive-styles.util.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAIhE;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,MAAM,GACd,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAyD/C"}
1
+ {"version":3,"file":"handle-responsive-styles.util.d.ts","sourceRoot":"","sources":["../../src/utils/handle-responsive-styles.util.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,YAAY,EACb,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAchE,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,MAAM,GACd,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAsE1E"}
@@ -11,9 +11,10 @@ import { css } from 'goober';
11
11
  * @param styleConfiguration - Configuration options for registering component styles, including default styles and classes.
12
12
  * @returns A tuple containing the default style class and an object mapping section names to their respective style classes.
13
13
  */
14
+ const fontVariants = new Map();
14
15
  function handleNodeStyles(nodeStyles, nodeUid) {
15
16
  if (!nodeStyles || !Object.keys(nodeStyles).length) {
16
- return ["", {}, new Set()];
17
+ return ["", {}, new Set(), new Map()];
17
18
  }
18
19
  const breakpointManager = BreakpointManager.getInstance();
19
20
  const breakpoints = breakpointManager.getBreakpoints();
@@ -42,6 +43,19 @@ function handleNodeStyles(nodeStyles, nodeUid) {
42
43
  * font on server side.
43
44
  */
44
45
  fontFamilies.add(fontFamily);
46
+ if (!fontVariants.has(fontFamily)) {
47
+ fontVariants.set(fontFamily, {
48
+ weights: new Set(),
49
+ italic: false,
50
+ });
51
+ }
52
+ if (breakpointStyles.fontWeight) {
53
+ const weights = fontVariants.get(fontFamily).weights;
54
+ weights.add(Number(breakpointStyles.fontWeight));
55
+ }
56
+ if (breakpointStyles.fontStyle === "italic") {
57
+ fontVariants.get(fontFamily).italic = true;
58
+ }
45
59
  }
46
60
  });
47
61
  const responsiveClass = css(styles);
@@ -54,7 +68,7 @@ function handleNodeStyles(nodeStyles, nodeUid) {
54
68
  const DEFAULT_STYLE_KEY = "default";
55
69
  const defaultStyle = namedStyles[DEFAULT_STYLE_KEY] ?? "";
56
70
  delete namedStyles[DEFAULT_STYLE_KEY];
57
- return [defaultStyle, namedStyles, fontFamilies];
71
+ return [defaultStyle, namedStyles, fontFamilies, fontVariants];
58
72
  }
59
73
 
60
74
  export { handleNodeStyles };
@@ -1 +1 @@
1
- {"version":3,"file":"handle-responsive-styles.util.js","sources":["../../src/utils/handle-responsive-styles.util.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAQA;;;;;;;;AAQG;AACG,SAAU,gBAAgB,CAC9B,UAAsB,EACtB,OAAe,EAAA;AAEf,IAAA,IAAI,CAAC,UAAU,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,EAAE;QAClD,OAAO,CAAC,EAAE,EAAE,EAAE,EAAE,IAA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C,OAAO;YACL,OAAO;YACP,UAAU,CAAC,eAAe,EAAE,SAAS,CAAC,OAAO,IAAI,EAAE,EAAE,YAAY,CAAC;SACnE;AACH,IAAA,CAAC,CACF;IAED,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC,eAAe,CAAC;IAEvD,MAAM,iBAAiB,GAAG,SAAS;IAEnC,MAAM,YAAY,GAAG,WAAW,CAAC,iBAAiB,CAAC,IAAI,EAAE;AACzD,IAAA,OAAO,WAAW,CAAC,iBAAiB,CAAC;AAErC,IAAA,OAAO,CAAC,YAAY,EAAE,WAAW,EAAE,YAAY,CAAC;AAClD;;;;"}
1
+ {"version":3,"file":"handle-responsive-styles.util.js","sources":["../../src/utils/handle-responsive-styles.util.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AASA;;;;;;;;AAQG;AACH,MAAM,YAAY,GAAG,IAAI,GAAG,EAAwB;AAC9C,SAAU,gBAAgB,CAC9B,UAAsB,EACtB,OAAe,EAAA;AAEf,IAAA,IAAI,CAAC,UAAU,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,EAAE;AAClD,QAAA,OAAO,CAAC,EAAE,EAAE,EAAE,EAAE,IAAI,GAAG,EAAU,EAAE,IAAI,GAAG,EAAwB,CAAC;IACrE;AACA,IAAA,MAAM,iBAAiB,GAAG,iBAAiB,CAAC,WAAW,EAAE;AACzD,IAAA,MAAM,WAAW,GAAG,iBAAiB,CAAC,cAAc,EAAE;AACtD,IAAA,MAAM,YAAY,GAAG,IAAI,GAAG,EAAU,CAAC;AAEvC,IAAA,MAAM,eAAe,GAAuB,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,GAAG,CACxE,CAAC,CAAC,OAAO,EAAE,SAAS,CAAC,KAAI;AACvB,QAAA,MAAM,gBAAgB,GAAG,SAAS,CAAC,gBAAgB,IAAI,EAAE;;QAGzD,MAAM,YAAY,GAAG,kBAAkB,CAAC,OAAO,EAAE,OAAO,C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gBAC7C;YACF;AACF,QAAA,CAAC,CAAC;AAEF,QAAA,MAAM,eAAe,GAAG,GAAG,CAAC,MAAM,CAAC;QACnC,OAAO;YACL,OAAO;YACP,UAAU,CAAC,eAAe,EAAE,SAAS,CAAC,OAAO,IAAI,EAAE,EAAE,YAAY,CAAC;SACnE;AACH,IAAA,CAAC,CACF;IAED,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC,eAAe,CAAC;IAEvD,MAAM,iBAAiB,GAAG,SAAS;IAEnC,MAAM,YAAY,GAAG,WAAW,CAAC,iBAAiB,CAAC,IAAI,EAAE;AACzD,IAAA,OAAO,WAAW,CAAC,iBAAiB,CAAC;IAErC,OAAO,CAAC,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,CAAC;AAChE;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentstack/studio-core",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "Provides utility to fetch spec for composable component",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -40,8 +40,8 @@
40
40
  "tsup": "^8.5.0"
41
41
  },
42
42
  "dependencies": {
43
- "@contentstack/studio-client": "^1.1.1",
44
- "@contentstack/studio-registry": "^1.1.1",
43
+ "@contentstack/studio-client": "^1.1.2",
44
+ "@contentstack/studio-registry": "^1.1.2",
45
45
  "classnames": "^2.5.1",
46
46
  "goober": "^2.1.16"
47
47
  },
@@ -49,5 +49,5 @@
49
49
  "react": ">=16.0.0",
50
50
  "react-dom": ">=16.0.0"
51
51
  },
52
- "gitHead": "45c22680a39f6565ed7ac060b9ffa1b625afa69c"
52
+ "gitHead": "62e9ef094542a3a51e4b0bea6c745098b3202bc2"
53
53
  }