@webstudio-is/react-sdk 0.145.0 → 0.151.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/lib/index.js CHANGED
@@ -214,7 +214,7 @@ var getPresetStyleRules = (component, presetStyle) => {
214
214
  // src/css/css.ts
215
215
  import {
216
216
  createRegularStyleSheet,
217
- createAtomicStyleSheet
217
+ generateAtomic
218
218
  } from "@webstudio-is/css-engine";
219
219
  var createImageValueTransformer = (assets, { assetBaseUrl }) => (styleValue) => {
220
220
  if (styleValue.type === "image" && styleValue.value.type === "asset") {
@@ -242,12 +242,10 @@ var generateCss = ({
242
242
  assetBaseUrl,
243
243
  atomic
244
244
  }) => {
245
- const classesMap = /* @__PURE__ */ new Map();
246
- const regularSheet = createRegularStyleSheet({ name: "ssr-regular" });
247
- const atomicSheet = atomic ? createAtomicStyleSheet({ name: "ssr-atomic" }) : void 0;
248
- addGlobalRules(regularSheet, { assets, assetBaseUrl });
245
+ const sheet = createRegularStyleSheet({ name: "ssr" });
246
+ addGlobalRules(sheet, { assets, assetBaseUrl });
249
247
  for (const breakpoint of breakpoints.values()) {
250
- (atomicSheet ?? regularSheet).addMediaRule(breakpoint.id, breakpoint);
248
+ sheet.addMediaRule(breakpoint.id, breakpoint);
251
249
  }
252
250
  for (const [component, meta] of componentMetas) {
253
251
  const presetStyle = meta.presetStyle;
@@ -256,35 +254,37 @@ var generateCss = ({
256
254
  }
257
255
  const rules = getPresetStyleRules(component, presetStyle);
258
256
  for (const [selector, style] of rules) {
259
- regularSheet.addStyleRule({ style }, selector);
257
+ sheet.addStyleRule({ style }, selector);
260
258
  }
261
259
  }
262
- const styleRules = getStyleRules(styles, styleSourceSelections);
263
260
  const imageValueTransformer = createImageValueTransformer(assets, {
264
261
  assetBaseUrl
265
262
  });
266
- for (const { breakpointId, instanceId, state, style } of styleRules) {
267
- if (atomicSheet) {
268
- const { classes } = atomicSheet.addStyleRule(
269
- { breakpoint: breakpointId, style },
270
- state,
271
- imageValueTransformer
272
- );
273
- classesMap.set(instanceId, [
274
- ...classesMap.get(instanceId) ?? [],
275
- ...classes
276
- ]);
277
- continue;
278
- }
279
- regularSheet.addStyleRule(
280
- { breakpoint: breakpointId, style },
281
- `[${idAttribute}="${instanceId}"]${state ?? ""}`,
282
- imageValueTransformer
283
- );
263
+ sheet.setTransformer(imageValueTransformer);
264
+ for (const styleDecl of styles.values()) {
265
+ const rule = sheet.addMixinRule(styleDecl.styleSourceId);
266
+ rule.setDeclaration({
267
+ breakpoint: styleDecl.breakpointId,
268
+ selector: styleDecl.state ?? "",
269
+ property: styleDecl.property,
270
+ value: styleDecl.value
271
+ });
272
+ }
273
+ const instanceByRule = /* @__PURE__ */ new Map();
274
+ for (const { instanceId, values } of styleSourceSelections.values()) {
275
+ const rule = sheet.addNestingRule(`[${idAttribute}="${instanceId}"]`);
276
+ rule.applyMixins(values);
277
+ instanceByRule.set(rule, instanceId);
278
+ }
279
+ if (atomic) {
280
+ return generateAtomic(sheet, {
281
+ getKey: (rule) => instanceByRule.get(rule) ?? "",
282
+ transformValue: imageValueTransformer
283
+ });
284
284
  }
285
285
  return {
286
- cssText: regularSheet.cssText + (atomicSheet?.cssText ?? ""),
287
- classesMap
286
+ cssText: sheet.cssText,
287
+ classesMap: /* @__PURE__ */ new Map()
288
288
  };
289
289
  };
290
290
 
@@ -498,12 +498,10 @@ var Code = z.object({
498
498
  ...common,
499
499
  control: z.literal("code"),
500
500
  type: z.literal("string"),
501
- defaultValue: z.string().optional(),
502
- /**
503
- * The number of rows in <textarea>. If set to 0 an <input> will be used instead.
504
- * In line with Storybook team's plan: https://github.com/storybookjs/storybook/issues/21100
505
- */
506
- rows: z.number().optional()
501
+ defaultValue: z.string().optional()
502
+ });
503
+ var CodeText = Code.extend({
504
+ control: z.literal("codetext")
507
505
  });
508
506
  var Color = z.object({
509
507
  ...common,
@@ -604,6 +602,7 @@ var PropMeta = z.union([
604
602
  Range,
605
603
  Text,
606
604
  Code,
605
+ CodeText,
607
606
  Color,
608
607
  Boolean,
609
608
  Radio,
@@ -1011,6 +1010,7 @@ var componentCategories = [
1011
1010
  "media",
1012
1011
  "forms",
1013
1012
  "radix",
1013
+ "xml",
1014
1014
  "hidden"
1015
1015
  ];
1016
1016
  var stateCategories = ["states", "component-states"];
@@ -73,7 +73,6 @@ declare const WsComponentPropsMeta: z.ZodObject<{
73
73
  control: z.ZodLiteral<"code">;
74
74
  type: z.ZodLiteral<"string">;
75
75
  defaultValue: z.ZodOptional<z.ZodString>;
76
- rows: z.ZodOptional<z.ZodNumber>;
77
76
  label: z.ZodOptional<z.ZodString>;
78
77
  description: z.ZodOptional<z.ZodString>;
79
78
  required: z.ZodBoolean;
@@ -82,7 +81,6 @@ declare const WsComponentPropsMeta: z.ZodObject<{
82
81
  required: boolean;
83
82
  control: "code";
84
83
  defaultValue?: string | undefined;
85
- rows?: number | undefined;
86
84
  label?: string | undefined;
87
85
  description?: string | undefined;
88
86
  }, {
@@ -90,9 +88,29 @@ declare const WsComponentPropsMeta: z.ZodObject<{
90
88
  required: boolean;
91
89
  control: "code";
92
90
  defaultValue?: string | undefined;
93
- rows?: number | undefined;
94
91
  label?: string | undefined;
95
92
  description?: string | undefined;
93
+ }>, z.ZodObject<{
94
+ type: z.ZodLiteral<"string">;
95
+ required: z.ZodBoolean;
96
+ description: z.ZodOptional<z.ZodString>;
97
+ label: z.ZodOptional<z.ZodString>;
98
+ defaultValue: z.ZodOptional<z.ZodString>;
99
+ control: z.ZodLiteral<"codetext">;
100
+ }, "strip", z.ZodTypeAny, {
101
+ type: "string";
102
+ required: boolean;
103
+ control: "codetext";
104
+ description?: string | undefined;
105
+ label?: string | undefined;
106
+ defaultValue?: string | undefined;
107
+ }, {
108
+ type: "string";
109
+ required: boolean;
110
+ control: "codetext";
111
+ description?: string | undefined;
112
+ label?: string | undefined;
113
+ defaultValue?: string | undefined;
96
114
  }>, z.ZodObject<{
97
115
  control: z.ZodLiteral<"color">;
98
116
  type: z.ZodLiteral<"string">;
@@ -438,9 +456,15 @@ declare const WsComponentPropsMeta: z.ZodObject<{
438
456
  required: boolean;
439
457
  control: "code";
440
458
  defaultValue?: string | undefined;
441
- rows?: number | undefined;
442
459
  label?: string | undefined;
443
460
  description?: string | undefined;
461
+ } | {
462
+ type: "string";
463
+ required: boolean;
464
+ control: "codetext";
465
+ description?: string | undefined;
466
+ label?: string | undefined;
467
+ defaultValue?: string | undefined;
444
468
  } | {
445
469
  type: "string";
446
470
  required: boolean;
@@ -576,9 +600,15 @@ declare const WsComponentPropsMeta: z.ZodObject<{
576
600
  required: boolean;
577
601
  control: "code";
578
602
  defaultValue?: string | undefined;
579
- rows?: number | undefined;
580
603
  label?: string | undefined;
581
604
  description?: string | undefined;
605
+ } | {
606
+ type: "string";
607
+ required: boolean;
608
+ control: "codetext";
609
+ description?: string | undefined;
610
+ label?: string | undefined;
611
+ defaultValue?: string | undefined;
582
612
  } | {
583
613
  type: "string";
584
614
  required: boolean;
@@ -688,7 +718,7 @@ declare const WsComponentPropsMeta: z.ZodObject<{
688
718
  initialProps?: string[] | undefined;
689
719
  }>;
690
720
  export type WsComponentPropsMeta = z.infer<typeof WsComponentPropsMeta>;
691
- export declare const componentCategories: readonly ["general", "text", "data", "media", "forms", "radix", "hidden"];
721
+ export declare const componentCategories: readonly ["general", "text", "data", "media", "forms", "radix", "xml", "hidden"];
692
722
  export declare const stateCategories: readonly ["states", "component-states"];
693
723
  export declare const ComponentState: z.ZodObject<{
694
724
  category: z.ZodOptional<z.ZodEnum<["states", "component-states"]>>;
@@ -706,7 +736,7 @@ export declare const ComponentState: z.ZodObject<{
706
736
  export type ComponentState = z.infer<typeof ComponentState>;
707
737
  export declare const defaultStates: ComponentState[];
708
738
  export declare const WsComponentMeta: z.ZodObject<{
709
- category: z.ZodOptional<z.ZodEnum<["general", "text", "data", "media", "forms", "radix", "hidden"]>>;
739
+ category: z.ZodOptional<z.ZodEnum<["general", "text", "data", "media", "forms", "radix", "xml", "hidden"]>>;
710
740
  type: z.ZodEnum<["container", "control", "embed", "rich-text-child"]>;
711
741
  requiredAncestors: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
712
742
  invalidAncestors: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
@@ -3355,7 +3385,7 @@ export declare const WsComponentMeta: z.ZodObject<{
3355
3385
  }, "strip", z.ZodTypeAny, {
3356
3386
  type: "embed" | "control" | "container" | "rich-text-child";
3357
3387
  icon: string;
3358
- category?: "data" | "text" | "hidden" | "media" | "general" | "forms" | "radix" | undefined;
3388
+ category?: "data" | "text" | "hidden" | "media" | "general" | "forms" | "radix" | "xml" | undefined;
3359
3389
  requiredAncestors?: string[] | undefined;
3360
3390
  invalidAncestors?: string[] | undefined;
3361
3391
  indexWithinAncestor?: string | undefined;
@@ -4248,7 +4278,7 @@ export declare const WsComponentMeta: z.ZodObject<{
4248
4278
  }, {
4249
4279
  type: "embed" | "control" | "container" | "rich-text-child";
4250
4280
  icon: string;
4251
- category?: "data" | "text" | "hidden" | "media" | "general" | "forms" | "radix" | undefined;
4281
+ category?: "data" | "text" | "hidden" | "media" | "general" | "forms" | "radix" | "xml" | undefined;
4252
4282
  requiredAncestors?: string[] | undefined;
4253
4283
  invalidAncestors?: string[] | undefined;
4254
4284
  indexWithinAncestor?: string | undefined;
@@ -33,9 +33,15 @@ export declare const corePropsMetas: {
33
33
  required: boolean;
34
34
  control: "code";
35
35
  defaultValue?: string | undefined;
36
- rows?: number | undefined;
37
36
  label?: string | undefined;
38
37
  description?: string | undefined;
38
+ } | {
39
+ type: "string";
40
+ required: boolean;
41
+ control: "codetext";
42
+ description?: string | undefined;
43
+ label?: string | undefined;
44
+ defaultValue?: string | undefined;
39
45
  } | {
40
46
  type: "string";
41
47
  required: boolean;
@@ -1,6 +1,6 @@
1
- import type { StyleSheetAtomic, StyleSheetRegular } from "@webstudio-is/css-engine";
1
+ import type { StyleSheetRegular } from "@webstudio-is/css-engine";
2
2
  import type { Assets } from "@webstudio-is/sdk";
3
- export declare const addGlobalRules: (sheet: StyleSheetRegular | StyleSheetAtomic, { assets, assetBaseUrl }: {
3
+ export declare const addGlobalRules: (sheet: StyleSheetRegular, { assets, assetBaseUrl }: {
4
4
  assets: Assets;
5
5
  assetBaseUrl: string;
6
6
  }) => void;
@@ -10,6 +10,8 @@ type StyleRule = {
10
10
  /**
11
11
  * Merge styles from different style sources
12
12
  * and group by instance and breakpoint
13
+ *
14
+ * @deprecated
13
15
  */
14
16
  export declare const getStyleRules: (styles: Styles, styleSourceSelections: Map<string, {
15
17
  values: string[];
@@ -10706,7 +10706,7 @@ export declare const namespaceMeta: (meta: WsComponentMeta, namespace: string, c
10706
10706
  value: string;
10707
10707
  type: "expression";
10708
10708
  } | EmbedTemplateInstance)[] | undefined;
10709
- category?: "data" | "text" | "hidden" | "media" | "general" | "forms" | "radix" | undefined;
10709
+ category?: "data" | "text" | "hidden" | "media" | "general" | "forms" | "radix" | "xml" | undefined;
10710
10710
  requiredAncestors?: string[] | undefined;
10711
10711
  invalidAncestors?: string[] | undefined;
10712
10712
  indexWithinAncestor?: string | undefined;
@@ -73,11 +73,6 @@ export declare const PropMeta: z.ZodUnion<[z.ZodObject<{
73
73
  control: z.ZodLiteral<"code">;
74
74
  type: z.ZodLiteral<"string">;
75
75
  defaultValue: z.ZodOptional<z.ZodString>;
76
- /**
77
- * The number of rows in <textarea>. If set to 0 an <input> will be used instead.
78
- * In line with Storybook team's plan: https://github.com/storybookjs/storybook/issues/21100
79
- */
80
- rows: z.ZodOptional<z.ZodNumber>;
81
76
  label: z.ZodOptional<z.ZodString>;
82
77
  description: z.ZodOptional<z.ZodString>;
83
78
  required: z.ZodBoolean;
@@ -86,7 +81,6 @@ export declare const PropMeta: z.ZodUnion<[z.ZodObject<{
86
81
  required: boolean;
87
82
  control: "code";
88
83
  defaultValue?: string | undefined;
89
- rows?: number | undefined;
90
84
  label?: string | undefined;
91
85
  description?: string | undefined;
92
86
  }, {
@@ -94,9 +88,29 @@ export declare const PropMeta: z.ZodUnion<[z.ZodObject<{
94
88
  required: boolean;
95
89
  control: "code";
96
90
  defaultValue?: string | undefined;
97
- rows?: number | undefined;
98
91
  label?: string | undefined;
99
92
  description?: string | undefined;
93
+ }>, z.ZodObject<{
94
+ type: z.ZodLiteral<"string">;
95
+ required: z.ZodBoolean;
96
+ description: z.ZodOptional<z.ZodString>;
97
+ label: z.ZodOptional<z.ZodString>;
98
+ defaultValue: z.ZodOptional<z.ZodString>;
99
+ control: z.ZodLiteral<"codetext">;
100
+ }, "strip", z.ZodTypeAny, {
101
+ type: "string";
102
+ required: boolean;
103
+ control: "codetext";
104
+ description?: string | undefined;
105
+ label?: string | undefined;
106
+ defaultValue?: string | undefined;
107
+ }, {
108
+ type: "string";
109
+ required: boolean;
110
+ control: "codetext";
111
+ description?: string | undefined;
112
+ label?: string | undefined;
113
+ defaultValue?: string | undefined;
100
114
  }>, z.ZodObject<{
101
115
  control: z.ZodLiteral<"color">;
102
116
  type: z.ZodLiteral<"string">;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webstudio-is/react-sdk",
3
- "version": "0.145.0",
3
+ "version": "0.151.0",
4
4
  "description": "Webstudio JavaScript / TypeScript API",
5
5
  "author": "Webstudio <github@webstudio.is>",
6
6
  "homepage": "https://webstudio.is",
@@ -28,11 +28,11 @@
28
28
  "html-tags": "^3.3.1",
29
29
  "nanoid": "^5.0.1",
30
30
  "title-case": "^4.1.0",
31
- "@webstudio-is/css-engine": "0.145.0",
32
- "@webstudio-is/fonts": "0.145.0",
33
- "@webstudio-is/icons": "^0.145.0",
34
- "@webstudio-is/image": "0.145.0",
35
- "@webstudio-is/sdk": "0.145.0"
31
+ "@webstudio-is/css-engine": "0.151.0",
32
+ "@webstudio-is/icons": "^0.151.0",
33
+ "@webstudio-is/image": "0.151.0",
34
+ "@webstudio-is/fonts": "0.151.0",
35
+ "@webstudio-is/sdk": "0.151.0"
36
36
  },
37
37
  "exports": {
38
38
  ".": {