dune-react 0.0.39 → 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.
@@ -36,6 +36,85 @@ declare const conf: {
36
36
  description: {
37
37
  type: string;
38
38
  };
39
+ buttons: {
40
+ readonly type: "array";
41
+ readonly max: 3;
42
+ readonly getItemSummary: (item: {
43
+ label?: string;
44
+ }, index?: number) => string;
45
+ readonly arrayFields: {
46
+ readonly label: {
47
+ readonly type: "text";
48
+ };
49
+ readonly action: {
50
+ type: "custom";
51
+ label: string;
52
+ render: typeof import("../../..").ActionField;
53
+ };
54
+ readonly variant: {
55
+ readonly type: "select";
56
+ readonly options: readonly [{
57
+ readonly label: "primary";
58
+ readonly value: "default";
59
+ }, {
60
+ readonly label: "secondary";
61
+ readonly value: "secondary";
62
+ }, {
63
+ readonly label: "outline";
64
+ readonly value: "outline";
65
+ }, {
66
+ readonly label: "ghost";
67
+ readonly value: "ghost";
68
+ }, {
69
+ readonly label: "link";
70
+ readonly value: "link";
71
+ }, {
72
+ readonly label: "destructive";
73
+ readonly value: "destructive";
74
+ }];
75
+ };
76
+ readonly size: {
77
+ readonly type: "select";
78
+ readonly options: readonly [{
79
+ readonly label: "default";
80
+ readonly value: "default";
81
+ }, {
82
+ readonly label: "sm";
83
+ readonly value: "sm";
84
+ }, {
85
+ readonly label: "lg";
86
+ readonly value: "lg";
87
+ }, {
88
+ readonly label: "icon";
89
+ readonly value: "icon";
90
+ }];
91
+ };
92
+ readonly icon: {
93
+ type: "custom";
94
+ render: typeof import("../../../puck-core/fields/icon-picker-field").IconPickerField;
95
+ };
96
+ };
97
+ readonly defaultItemProps: {
98
+ readonly label: "Button";
99
+ readonly action: {
100
+ readonly type: "page";
101
+ readonly pageUrl: "";
102
+ readonly externalUrl: "";
103
+ readonly openInNewTab: "false";
104
+ readonly email: "";
105
+ readonly subject: "";
106
+ readonly phone: "";
107
+ readonly sectionId: "";
108
+ readonly downloadUrl: "";
109
+ };
110
+ readonly variant: "default";
111
+ readonly size: "default";
112
+ readonly icon: "none";
113
+ };
114
+ readonly ai: {
115
+ readonly instructions: "Buttons must use the same size";
116
+ };
117
+ };
39
118
  media: {
40
119
  type: "object";
41
120
  objectFields: {
@@ -1,6 +1,7 @@
1
1
  import { TabHero, TabHeroDefaults } from "./component.js";
2
2
  import { sectionWrapperFields } from "../../../puck-core/section-wrapper.js";
3
3
  import { mediaField } from "../../../puck-core/core/props/media.js";
4
+ import { buttonsField } from "../../../puck-core/core/props/interactive.js";
4
5
  const conf = {
5
6
  fields: {
6
7
  defaultTabValue: { type: "text" },
@@ -23,6 +24,7 @@ const conf = {
23
24
  value: { type: "text" },
24
25
  heading: { type: "text" },
25
26
  description: { type: "textarea" },
27
+ buttons: buttonsField,
26
28
  media: mediaField
27
29
  }
28
30
  }
@@ -7502,6 +7502,85 @@ declare const confMap: {
7502
7502
  description: {
7503
7503
  type: string;
7504
7504
  };
7505
+ buttons: {
7506
+ readonly type: "array";
7507
+ readonly max: 3;
7508
+ readonly getItemSummary: (item: {
7509
+ label?: string;
7510
+ }, index?: number) => string;
7511
+ readonly arrayFields: {
7512
+ readonly label: {
7513
+ readonly type: "text";
7514
+ };
7515
+ readonly action: {
7516
+ type: "custom";
7517
+ label: string;
7518
+ render: typeof import("..").ActionField;
7519
+ };
7520
+ readonly variant: {
7521
+ readonly type: "select";
7522
+ readonly options: readonly [{
7523
+ readonly label: "primary";
7524
+ readonly value: "default";
7525
+ }, {
7526
+ readonly label: "secondary";
7527
+ readonly value: "secondary";
7528
+ }, {
7529
+ readonly label: "outline";
7530
+ readonly value: "outline";
7531
+ }, {
7532
+ readonly label: "ghost";
7533
+ readonly value: "ghost";
7534
+ }, {
7535
+ readonly label: "link";
7536
+ readonly value: "link";
7537
+ }, {
7538
+ readonly label: "destructive";
7539
+ readonly value: "destructive";
7540
+ }];
7541
+ };
7542
+ readonly size: {
7543
+ readonly type: "select";
7544
+ readonly options: readonly [{
7545
+ readonly label: "default";
7546
+ readonly value: "default";
7547
+ }, {
7548
+ readonly label: "sm";
7549
+ readonly value: "sm";
7550
+ }, {
7551
+ readonly label: "lg";
7552
+ readonly value: "lg";
7553
+ }, {
7554
+ readonly label: "icon";
7555
+ readonly value: "icon";
7556
+ }];
7557
+ };
7558
+ readonly icon: {
7559
+ type: "custom";
7560
+ render: typeof import("../puck-core/fields/icon-picker-field").IconPickerField;
7561
+ };
7562
+ };
7563
+ readonly defaultItemProps: {
7564
+ readonly label: "Button";
7565
+ readonly action: {
7566
+ readonly type: "page";
7567
+ readonly pageUrl: "";
7568
+ readonly externalUrl: "";
7569
+ readonly openInNewTab: "false";
7570
+ readonly email: "";
7571
+ readonly subject: "";
7572
+ readonly phone: "";
7573
+ readonly sectionId: "";
7574
+ readonly downloadUrl: "";
7575
+ };
7576
+ readonly variant: "default";
7577
+ readonly size: "default";
7578
+ readonly icon: "none";
7579
+ };
7580
+ readonly ai: {
7581
+ readonly instructions: "Buttons must use the same size";
7582
+ };
7583
+ };
7505
7584
  media: {
7506
7585
  type: "object";
7507
7586
  objectFields: {
@@ -11058,6 +11137,99 @@ declare const confMap: {
11058
11137
  value: string;
11059
11138
  }[];
11060
11139
  };
11140
+ props: {
11141
+ type: string;
11142
+ label: string;
11143
+ objectFields: {
11144
+ media: {
11145
+ ai: {
11146
+ instructions: string;
11147
+ };
11148
+ type: "object";
11149
+ objectFields: {
11150
+ src: import("@puckeditor/core").Field<string>;
11151
+ alt: {
11152
+ type: "text";
11153
+ };
11154
+ };
11155
+ };
11156
+ heading: {
11157
+ type: string;
11158
+ };
11159
+ button: {
11160
+ readonly type: "object";
11161
+ readonly objectFields: {
11162
+ readonly label: {
11163
+ readonly type: "text";
11164
+ };
11165
+ readonly action: {
11166
+ type: "custom";
11167
+ label: string;
11168
+ render: typeof import("..").ActionField;
11169
+ };
11170
+ readonly variant: {
11171
+ readonly type: "select";
11172
+ readonly options: readonly [{
11173
+ readonly label: "primary";
11174
+ readonly value: "default";
11175
+ }, {
11176
+ readonly label: "secondary";
11177
+ readonly value: "secondary";
11178
+ }, {
11179
+ readonly label: "outline";
11180
+ readonly value: "outline";
11181
+ }, {
11182
+ readonly label: "ghost";
11183
+ readonly value: "ghost";
11184
+ }, {
11185
+ readonly label: "link";
11186
+ readonly value: "link";
11187
+ }, {
11188
+ readonly label: "destructive";
11189
+ readonly value: "destructive";
11190
+ }];
11191
+ };
11192
+ readonly size: {
11193
+ readonly type: "select";
11194
+ readonly options: readonly [{
11195
+ readonly label: "default";
11196
+ readonly value: "default";
11197
+ }, {
11198
+ readonly label: "sm";
11199
+ readonly value: "sm";
11200
+ }, {
11201
+ readonly label: "lg";
11202
+ readonly value: "lg";
11203
+ }, {
11204
+ readonly label: "icon";
11205
+ readonly value: "icon";
11206
+ }];
11207
+ };
11208
+ readonly icon: {
11209
+ type: "custom";
11210
+ render: typeof import("../puck-core/fields/icon-picker-field").IconPickerField;
11211
+ };
11212
+ };
11213
+ };
11214
+ numberOfStars: {
11215
+ type: string;
11216
+ min: number;
11217
+ max: number;
11218
+ };
11219
+ quote: {
11220
+ type: string;
11221
+ };
11222
+ name: {
11223
+ type: string;
11224
+ };
11225
+ position: {
11226
+ type: string;
11227
+ };
11228
+ companyName: {
11229
+ type: string;
11230
+ };
11231
+ };
11232
+ };
11061
11233
  };
11062
11234
  };
11063
11235
  styles: {
@@ -2,7 +2,7 @@ import type { TestimonialComponentProps, BaseMedia, BaseButton } from "../props"
2
2
  type BackgroundImageCard = {
3
3
  component: "background";
4
4
  props: {
5
- backgroundImage: BaseMedia;
5
+ media: BaseMedia;
6
6
  heading: string;
7
7
  button: BaseButton;
8
8
  };
@@ -10,7 +10,7 @@ type BackgroundImageCard = {
10
10
  type LogoCard = {
11
11
  component: "logo";
12
12
  props: {
13
- logo: BaseMedia;
13
+ media: BaseMedia;
14
14
  };
15
15
  };
16
16
  type QuoteCard = {
@@ -59,9 +59,9 @@ const BentoTestimonial = (props) => {
59
59
  /* @__PURE__ */ jsx(
60
60
  CompoundMedia,
61
61
  {
62
- src: card.props.backgroundImage.src,
62
+ src: card.props.media.src,
63
63
  className: "size-full object-cover",
64
- alt: card.props.backgroundImage.alt
64
+ alt: card.props.media.alt
65
65
  }
66
66
  ),
67
67
  /* @__PURE__ */ jsx("div", { className: "absolute inset-0 bg-black/50" })
@@ -84,8 +84,8 @@ const BentoTestimonial = (props) => {
84
84
  children: /* @__PURE__ */ jsx(
85
85
  CompoundMedia,
86
86
  {
87
- src: card.props.logo.src,
88
- alt: card.props.logo.alt,
87
+ src: card.props.media.src,
88
+ alt: card.props.media.alt,
89
89
  className: "max-h-16"
90
90
  }
91
91
  )
@@ -139,7 +139,7 @@ const BentoTestimonialDefaults = {
139
139
  {
140
140
  component: "background",
141
141
  props: {
142
- backgroundImage: {
142
+ media: {
143
143
  src: "https://picsum.photos/seed/bento-bg-1/600/400",
144
144
  alt: "Background image 1"
145
145
  },
@@ -150,7 +150,7 @@ const BentoTestimonialDefaults = {
150
150
  {
151
151
  component: "logo",
152
152
  props: {
153
- logo: {
153
+ media: {
154
154
  src: "https://file.springbrand.ai/web_assets/template-logo.svg",
155
155
  alt: "Logo 1"
156
156
  }
@@ -173,7 +173,7 @@ const BentoTestimonialDefaults = {
173
173
  {
174
174
  component: "logo",
175
175
  props: {
176
- logo: {
176
+ media: {
177
177
  src: "https://file.springbrand.ai/web_assets/template-logo.svg",
178
178
  alt: "Webflow logo 1"
179
179
  }
@@ -182,7 +182,7 @@ const BentoTestimonialDefaults = {
182
182
  {
183
183
  component: "background",
184
184
  props: {
185
- backgroundImage: {
185
+ media: {
186
186
  src: "https://picsum.photos/seed/bento-bg-2/600/400",
187
187
  alt: "Background image 2"
188
188
  },
@@ -193,7 +193,7 @@ const BentoTestimonialDefaults = {
193
193
  {
194
194
  component: "logo",
195
195
  props: {
196
- logo: {
196
+ media: {
197
197
  src: "https://file.springbrand.ai/web_assets/template-logo.svg",
198
198
  alt: "Logo 2"
199
199
  }
@@ -202,7 +202,7 @@ const BentoTestimonialDefaults = {
202
202
  {
203
203
  component: "background",
204
204
  props: {
205
- backgroundImage: {
205
+ media: {
206
206
  src: "https://picsum.photos/seed/bento-bg-3/600/400",
207
207
  alt: "Background image 3"
208
208
  },
@@ -227,7 +227,7 @@ const BentoTestimonialDefaults = {
227
227
  {
228
228
  component: "background",
229
229
  props: {
230
- backgroundImage: {
230
+ media: {
231
231
  src: "https://picsum.photos/seed/bento-bg-4/600/400",
232
232
  alt: "Background image 4"
233
233
  },
@@ -238,7 +238,7 @@ const BentoTestimonialDefaults = {
238
238
  {
239
239
  component: "logo",
240
240
  props: {
241
- logo: {
241
+ media: {
242
242
  src: "https://file.springbrand.ai/web_assets/template-logo.svg",
243
243
  alt: "Webflow logo 2"
244
244
  }
@@ -25,6 +25,99 @@ declare const conf: {
25
25
  value: string;
26
26
  }[];
27
27
  };
28
+ props: {
29
+ type: string;
30
+ label: string;
31
+ objectFields: {
32
+ media: {
33
+ ai: {
34
+ instructions: string;
35
+ };
36
+ type: "object";
37
+ objectFields: {
38
+ src: import("@puckeditor/core").Field<string>;
39
+ alt: {
40
+ type: "text";
41
+ };
42
+ };
43
+ };
44
+ heading: {
45
+ type: string;
46
+ };
47
+ button: {
48
+ readonly type: "object";
49
+ readonly objectFields: {
50
+ readonly label: {
51
+ readonly type: "text";
52
+ };
53
+ readonly action: {
54
+ type: "custom";
55
+ label: string;
56
+ render: typeof import("../../..").ActionField;
57
+ };
58
+ readonly variant: {
59
+ readonly type: "select";
60
+ readonly options: readonly [{
61
+ readonly label: "primary";
62
+ readonly value: "default";
63
+ }, {
64
+ readonly label: "secondary";
65
+ readonly value: "secondary";
66
+ }, {
67
+ readonly label: "outline";
68
+ readonly value: "outline";
69
+ }, {
70
+ readonly label: "ghost";
71
+ readonly value: "ghost";
72
+ }, {
73
+ readonly label: "link";
74
+ readonly value: "link";
75
+ }, {
76
+ readonly label: "destructive";
77
+ readonly value: "destructive";
78
+ }];
79
+ };
80
+ readonly size: {
81
+ readonly type: "select";
82
+ readonly options: readonly [{
83
+ readonly label: "default";
84
+ readonly value: "default";
85
+ }, {
86
+ readonly label: "sm";
87
+ readonly value: "sm";
88
+ }, {
89
+ readonly label: "lg";
90
+ readonly value: "lg";
91
+ }, {
92
+ readonly label: "icon";
93
+ readonly value: "icon";
94
+ }];
95
+ };
96
+ readonly icon: {
97
+ type: "custom";
98
+ render: typeof import("../../../puck-core/fields/icon-picker-field").IconPickerField;
99
+ };
100
+ };
101
+ };
102
+ numberOfStars: {
103
+ type: string;
104
+ min: number;
105
+ max: number;
106
+ };
107
+ quote: {
108
+ type: string;
109
+ };
110
+ name: {
111
+ type: string;
112
+ };
113
+ position: {
114
+ type: string;
115
+ };
116
+ companyName: {
117
+ type: string;
118
+ };
119
+ };
120
+ };
28
121
  };
29
122
  };
30
123
  styles: {
@@ -2,6 +2,8 @@ import { BentoTestimonial, BentoTestimonialDefaults } from "./component.js";
2
2
  import { descriptionField, headingField } from "../../../puck-core/core/props/content.js";
3
3
  import { testimonialStyleFields } from "../props.js";
4
4
  import { sectionWrapperFields } from "../../../puck-core/section-wrapper.js";
5
+ import { mediaField } from "../../../puck-core/core/props/media.js";
6
+ import { buttonField } from "../../../puck-core/core/props/interactive.js";
5
7
  const conf = {
6
8
  fields: {
7
9
  heading: headingField,
@@ -17,6 +19,28 @@ const conf = {
17
19
  { label: "Logo", value: "logo" },
18
20
  { label: "Quote", value: "quote" }
19
21
  ]
22
+ },
23
+ props: {
24
+ type: "object",
25
+ label: "Props",
26
+ objectFields: {
27
+ // Shared media field (BackgroundImageCard / LogoCard / QuoteCard)
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
+ },
34
+ // BackgroundImageCard
35
+ heading: { type: "text" },
36
+ button: buttonField,
37
+ // QuoteCard
38
+ numberOfStars: { type: "number", min: 0, max: 5 },
39
+ quote: { type: "textarea" },
40
+ name: { type: "text" },
41
+ position: { type: "text" },
42
+ companyName: { type: "text" }
43
+ }
20
44
  }
21
45
  }
22
46
  },
@@ -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.39",
3
+ "version": "0.0.41",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "scripts": {