dune-react 0.0.40 → 0.0.41

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.
@@ -11142,6 +11142,9 @@ declare const confMap: {
11142
11142
  label: string;
11143
11143
  objectFields: {
11144
11144
  media: {
11145
+ ai: {
11146
+ instructions: string;
11147
+ };
11145
11148
  type: "object";
11146
11149
  objectFields: {
11147
11150
  src: import("@puckeditor/core").Field<string>;
@@ -30,6 +30,9 @@ declare const conf: {
30
30
  label: string;
31
31
  objectFields: {
32
32
  media: {
33
+ ai: {
34
+ instructions: string;
35
+ };
33
36
  type: "object";
34
37
  objectFields: {
35
38
  src: import("@puckeditor/core").Field<string>;
@@ -25,7 +25,12 @@ const conf = {
25
25
  label: "Props",
26
26
  objectFields: {
27
27
  // Shared media field (BackgroundImageCard / LogoCard / QuoteCard)
28
- media: mediaField,
28
+ media: {
29
+ ...mediaField,
30
+ ai: {
31
+ instructions: "Image/media for this card. Usage depends on component type: 'background' → full-bleed background image, 'logo' → company logo, 'quote' → avatar/profile photo of the person."
32
+ }
33
+ },
29
34
  // BackgroundImageCard
30
35
  heading: { type: "text" },
31
36
  button: buttonField,
@@ -2,6 +2,7 @@ import { buttonsField, badgeField } from "./interactive.js";
2
2
  import { actionDefaults, actionField, buttonDefaults, buttonField, iconField, resolveActionUrl } from "./interactive.js";
3
3
  import { descriptionField, headingField, featuresField } from "./content.js";
4
4
  import { cardField, cardsField } from "./content.js";
5
+ import { getPlaceholderMediaUrl, media16x9Placeholder, media1x1Placeholder, media9x16Placeholder, mediaField, mediasField } from "./media.js";
5
6
  const contentFields = {
6
7
  heading: headingField,
7
8
  description: descriptionField,
@@ -28,7 +29,13 @@ export {
28
29
  contentFieldsWithFeatures,
29
30
  descriptionField,
30
31
  featuresField,
32
+ getPlaceholderMediaUrl,
31
33
  headingField,
32
34
  iconField,
35
+ media16x9Placeholder,
36
+ media1x1Placeholder,
37
+ media9x16Placeholder,
38
+ mediaField,
39
+ mediasField,
33
40
  resolveActionUrl
34
41
  };
@@ -13,6 +13,7 @@ type PuckField = {
13
13
  instructions?: string;
14
14
  exclude?: boolean;
15
15
  stream?: boolean;
16
+ optional?: boolean;
16
17
  };
17
18
  [key: string]: unknown;
18
19
  };
@@ -54,45 +54,55 @@ function withDescribe(schema, field) {
54
54
  const desc = (_a = field.ai) == null ? void 0 : _a.instructions;
55
55
  return desc ? schema.describe(desc) : schema;
56
56
  }
57
- function puckFieldToZod(field) {
57
+ function isFieldOptional(field, fieldKey) {
58
+ var _a, _b;
59
+ if (((_a = field.ai) == null ? void 0 : _a.optional) === true) return true;
60
+ if (((_b = field.ai) == null ? void 0 : _b.optional) === false) return false;
61
+ if (fieldKey === "styles") return true;
62
+ return false;
63
+ }
64
+ function maybeOptional(schema, field, fieldKey) {
65
+ return isFieldOptional(field, fieldKey) ? schema.optional() : schema;
66
+ }
67
+ function puckFieldToZod(field, fieldKey) {
58
68
  var _a, _b;
59
69
  let schema;
60
70
  switch (field.type) {
61
71
  case "text":
62
72
  case "textarea":
63
- schema = string().optional();
73
+ schema = string();
64
74
  break;
65
75
  case "select":
66
76
  case "radio": {
67
77
  const values = (field.options ?? []).map((o) => o.value);
68
- schema = values.length === 0 ? string().optional() : _enum(values).optional();
78
+ schema = values.length === 0 ? string() : _enum(values);
69
79
  break;
70
80
  }
71
81
  case "object": {
72
82
  if (!field.objectFields || Object.keys(field.objectFields).length === 0) {
73
- schema = record(string(), unknown()).optional();
83
+ schema = record(string(), unknown());
74
84
  } else {
75
85
  const shape = {};
76
86
  for (const [k, v] of Object.entries(field.objectFields)) {
77
87
  if ((_a = v.ai) == null ? void 0 : _a.exclude) continue;
78
- shape[k] = puckFieldToZod(v);
88
+ shape[k] = puckFieldToZod(v, k);
79
89
  }
80
- schema = object(shape).optional();
90
+ schema = object(shape);
81
91
  }
82
92
  break;
83
93
  }
84
94
  case "array": {
85
95
  if (!field.arrayFields || Object.keys(field.arrayFields).length === 0) {
86
- schema = array(unknown()).optional();
96
+ schema = array(unknown());
87
97
  } else {
88
98
  const itemShape = {};
89
99
  for (const [k, v] of Object.entries(field.arrayFields)) {
90
100
  if ((_b = v.ai) == null ? void 0 : _b.exclude) continue;
91
- itemShape[k] = puckFieldToZod(v);
101
+ itemShape[k] = puckFieldToZod(v, k);
92
102
  }
93
103
  let arraySchema = array(object(itemShape));
94
104
  if (field.max) arraySchema = arraySchema.max(field.max);
95
- schema = arraySchema.optional();
105
+ schema = arraySchema;
96
106
  }
97
107
  break;
98
108
  }
@@ -102,6 +112,7 @@ function puckFieldToZod(field) {
102
112
  default:
103
113
  schema = any();
104
114
  }
115
+ schema = maybeOptional(schema, field, fieldKey);
105
116
  return withDescribe(schema, field);
106
117
  }
107
118
  function puckFieldsToZod(fields) {
@@ -109,7 +120,7 @@ function puckFieldsToZod(fields) {
109
120
  const shape = {};
110
121
  for (const [key, field] of Object.entries(fields)) {
111
122
  if ((_a = field.ai) == null ? void 0 : _a.exclude) continue;
112
- shape[key] = puckFieldToZod(field);
123
+ shape[key] = puckFieldToZod(field, key);
113
124
  }
114
125
  return object(shape);
115
126
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dune-react",
3
- "version": "0.0.40",
3
+ "version": "0.0.41",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "scripts": {