@builder.io/sdk-solid 0.0.6 → 0.0.9

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.
Files changed (102) hide show
  1. package/package.json +59 -2
  2. package/src/blocks/button/button.jsx +13 -0
  3. package/src/blocks/button/button.lite.tsx +20 -0
  4. package/src/blocks/button/component-info.js +41 -0
  5. package/src/blocks/button/index.js +7 -0
  6. package/src/blocks/columns/columns.jsx +91 -0
  7. package/src/blocks/{columns.lite.tsx → columns/columns.lite.tsx} +4 -3
  8. package/src/blocks/columns/component-info.js +217 -0
  9. package/src/blocks/columns/index.js +7 -0
  10. package/src/blocks/custom-code/component-info.js +31 -0
  11. package/src/blocks/{custom-code.jsx → custom-code/custom-code.jsx} +1 -2
  12. package/src/blocks/{custom-code.lite.tsx → custom-code/custom-code.lite.tsx} +0 -0
  13. package/src/blocks/custom-code/index.js +7 -0
  14. package/src/blocks/embed/component-info.js +24 -0
  15. package/src/blocks/{embed.jsx → embed/embed.jsx} +1 -2
  16. package/src/blocks/{embed.lite.tsx → embed/embed.lite.tsx} +0 -0
  17. package/src/blocks/embed/index.js +7 -0
  18. package/src/blocks/form/component-info.js +262 -0
  19. package/src/blocks/{form.jsx → form/form.jsx} +8 -8
  20. package/src/blocks/{form.lite.tsx → form/form.lite.tsx} +7 -6
  21. package/src/blocks/form/index.js +7 -0
  22. package/src/blocks/fragment/component-info.js +11 -0
  23. package/src/blocks/fragment/fragment.jsx +5 -0
  24. package/src/blocks/{fragment.lite.tsx → fragment/fragment.lite.tsx} +0 -0
  25. package/src/blocks/fragment/index.js +7 -0
  26. package/src/blocks/image/component-info.js +104 -0
  27. package/src/blocks/image/image.jsx +54 -0
  28. package/src/blocks/image/image.lite.tsx +83 -0
  29. package/src/blocks/image/index.js +7 -0
  30. package/src/blocks/img/component-info.js +20 -0
  31. package/src/blocks/img/img.jsx +10 -0
  32. package/src/blocks/{img.lite.tsx → img/img.lite.tsx} +1 -1
  33. package/src/blocks/img/index.js +7 -0
  34. package/src/blocks/input/component-info.js +74 -0
  35. package/src/blocks/input/index.js +7 -0
  36. package/src/blocks/input/input.jsx +7 -0
  37. package/src/blocks/{input.lite.tsx → input/input.lite.tsx} +1 -1
  38. package/src/blocks/raw-text/component-info.js +16 -0
  39. package/src/blocks/raw-text/index.js +7 -0
  40. package/src/blocks/raw-text/raw-text.jsx +5 -0
  41. package/src/blocks/{raw-text.lite.tsx → raw-text/raw-text.lite.tsx} +0 -0
  42. package/src/blocks/section/component-info.js +49 -0
  43. package/src/blocks/section/index.js +7 -0
  44. package/src/blocks/section/section.jsx +9 -0
  45. package/src/blocks/{section.lite.tsx → section/section.lite.tsx} +0 -0
  46. package/src/blocks/select/component-info.js +59 -0
  47. package/src/blocks/select/index.js +7 -0
  48. package/src/blocks/select/select.jsx +16 -0
  49. package/src/blocks/{select.lite.tsx → select/select.lite.tsx} +1 -1
  50. package/src/blocks/submit-button/component-info.js +28 -0
  51. package/src/blocks/submit-button/index.js +7 -0
  52. package/src/blocks/submit-button/submit-button.jsx +7 -0
  53. package/src/blocks/{submit-button.lite.tsx → submit-button/submit-button.lite.tsx} +0 -0
  54. package/src/blocks/symbol/component-info.js +42 -0
  55. package/src/blocks/symbol/index.js +7 -0
  56. package/src/blocks/symbol/symbol.jsx +24 -0
  57. package/src/blocks/{symbol.lite.tsx → symbol/symbol.lite.tsx} +3 -3
  58. package/src/blocks/text/component-info.js +24 -0
  59. package/src/blocks/text/index.js +7 -0
  60. package/src/blocks/text/text.jsx +5 -0
  61. package/src/blocks/{text.lite.tsx → text/text.lite.tsx} +0 -0
  62. package/src/blocks/textarea/component-info.js +47 -0
  63. package/src/blocks/textarea/index.js +7 -0
  64. package/src/blocks/textarea/textarea.jsx +5 -0
  65. package/src/blocks/{textarea.lite.tsx → textarea/textarea.lite.tsx} +0 -0
  66. package/src/blocks/video/component-info.js +106 -0
  67. package/src/blocks/video/index.js +7 -0
  68. package/src/blocks/video/video.jsx +14 -0
  69. package/src/blocks/{video.lite.tsx → video/video.lite.tsx} +0 -0
  70. package/src/components/render-block/block-styles.jsx +36 -0
  71. package/src/components/render-block/block-styles.lite.tsx +38 -0
  72. package/src/components/{render-block.jsx → render-block/render-block.jsx} +13 -10
  73. package/src/components/{render-block.lite.tsx → render-block/render-block.lite.tsx} +13 -10
  74. package/src/components/render-blocks.jsx +1 -1
  75. package/src/components/render-blocks.lite.tsx +1 -1
  76. package/src/components/render-content/components/render-styles.jsx +6 -5
  77. package/src/components/render-content/components/render-styles.lite.tsx +9 -5
  78. package/src/components/render-content/render-content.jsx +16 -15
  79. package/src/components/render-content/render-content.lite.tsx +19 -18
  80. package/src/functions/get-builder-search-params/fn.test.js +1 -1
  81. package/src/functions/get-content/index.js +2 -1
  82. package/src/functions/get-fetch.js +28 -6
  83. package/src/index.js +2 -5
  84. package/src/scripts/init-editing.js +69 -60
  85. package/src/blocks/button.jsx +0 -8
  86. package/src/blocks/button.lite.tsx +0 -14
  87. package/src/blocks/columns.jsx +0 -91
  88. package/src/blocks/fragment.jsx +0 -6
  89. package/src/blocks/image.jsx +0 -120
  90. package/src/blocks/image.lite.tsx +0 -171
  91. package/src/blocks/img.jsx +0 -11
  92. package/src/blocks/input.jsx +0 -8
  93. package/src/blocks/raw-text.jsx +0 -6
  94. package/src/blocks/section.jsx +0 -10
  95. package/src/blocks/select.jsx +0 -17
  96. package/src/blocks/submit-button.jsx +0 -8
  97. package/src/blocks/symbol.jsx +0 -25
  98. package/src/blocks/text.jsx +0 -6
  99. package/src/blocks/textarea.jsx +0 -6
  100. package/src/blocks/video.jsx +0 -15
  101. package/src/components/block-styles.jsx +0 -5
  102. package/src/components/block-styles.lite.tsx +0 -5
@@ -0,0 +1,262 @@
1
+ const componentInfo = {
2
+ name: "Form:Form",
3
+ builtIn: true,
4
+ defaults: {
5
+ responsiveStyles: {
6
+ large: {
7
+ marginTop: "15px",
8
+ paddingBottom: "15px"
9
+ }
10
+ }
11
+ },
12
+ image: "https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2Fef36d2a846134910b64b88e6d18c5ca5",
13
+ inputs: [
14
+ {
15
+ name: "sendSubmissionsTo",
16
+ type: "string",
17
+ enum: [
18
+ {
19
+ label: "Send to email",
20
+ value: "email",
21
+ helperText: "Send form submissions to the email address of your choosing"
22
+ },
23
+ {
24
+ label: "Custom",
25
+ value: "custom",
26
+ helperText: "Handle where the form requests go manually with a little code, e.g. to your own custom backend"
27
+ }
28
+ ],
29
+ defaultValue: "email"
30
+ },
31
+ {
32
+ name: "sendSubmissionsToEmail",
33
+ type: "string",
34
+ required: true,
35
+ defaultValue: "your@email.com",
36
+ showIf: 'options.get("sendSubmissionsTo") === "email"'
37
+ },
38
+ {
39
+ name: "sendWithJs",
40
+ type: "boolean",
41
+ helperText: "Set to false to use basic html form action",
42
+ defaultValue: true,
43
+ showIf: 'options.get("sendSubmissionsTo") === "custom"'
44
+ },
45
+ {
46
+ name: "name",
47
+ type: "string",
48
+ defaultValue: "My form"
49
+ },
50
+ {
51
+ name: "action",
52
+ type: "string",
53
+ helperText: "URL to send the form data to",
54
+ showIf: 'options.get("sendSubmissionsTo") === "custom"'
55
+ },
56
+ {
57
+ name: "contentType",
58
+ type: "string",
59
+ defaultValue: "application/json",
60
+ advanced: true,
61
+ enum: [
62
+ "application/json",
63
+ "multipart/form-data",
64
+ "application/x-www-form-urlencoded"
65
+ ],
66
+ showIf: 'options.get("sendSubmissionsTo") === "custom" && options.get("sendWithJs") === true'
67
+ },
68
+ {
69
+ name: "method",
70
+ type: "string",
71
+ showIf: 'options.get("sendSubmissionsTo") === "custom"',
72
+ defaultValue: "POST",
73
+ advanced: true
74
+ },
75
+ {
76
+ name: "previewState",
77
+ type: "string",
78
+ enum: ["unsubmitted", "sending", "success", "error"],
79
+ defaultValue: "unsubmitted",
80
+ helperText: 'Choose a state to edit, e.g. choose "success" to show what users see on success and edit the message',
81
+ showIf: 'options.get("sendSubmissionsTo") !== "zapier" && options.get("sendWithJs") === true'
82
+ },
83
+ {
84
+ name: "successUrl",
85
+ type: "url",
86
+ helperText: "Optional URL to redirect the user to on form submission success",
87
+ showIf: 'options.get("sendSubmissionsTo") !== "zapier" && options.get("sendWithJs") === true'
88
+ },
89
+ {
90
+ name: "resetFormOnSubmit",
91
+ type: "boolean",
92
+ showIf: "options.get('sendSubmissionsTo') === 'custom' && options.get('sendWithJs') === true",
93
+ advanced: true
94
+ },
95
+ {
96
+ name: "successMessage",
97
+ type: "uiBlocks",
98
+ hideFromUI: true,
99
+ defaultValue: [
100
+ {
101
+ "@type": "@builder.io/sdk:Element",
102
+ responsiveStyles: {
103
+ large: {
104
+ marginTop: "10px"
105
+ }
106
+ },
107
+ component: {
108
+ name: "Text",
109
+ options: {
110
+ text: "<span>Thanks!</span>"
111
+ }
112
+ }
113
+ }
114
+ ]
115
+ },
116
+ {
117
+ name: "validate",
118
+ type: "boolean",
119
+ defaultValue: true,
120
+ advanced: true
121
+ },
122
+ {
123
+ name: "errorMessagePath",
124
+ type: "text",
125
+ advanced: true,
126
+ helperText: 'Path to where to get the error message from in a JSON response to display to the user, e.g. "error.message" for a response like { "error": { "message": "this username is taken" }}'
127
+ },
128
+ {
129
+ name: "errorMessage",
130
+ type: "uiBlocks",
131
+ hideFromUI: true,
132
+ defaultValue: [
133
+ {
134
+ "@type": "@builder.io/sdk:Element",
135
+ responsiveStyles: {
136
+ large: {
137
+ marginTop: "10px"
138
+ }
139
+ },
140
+ bindings: {
141
+ "component.options.text": "state.formErrorMessage || block.component.options.text"
142
+ },
143
+ component: {
144
+ name: "Text",
145
+ options: {
146
+ text: "<span>Form submission error :( Please check your answers and try again</span>"
147
+ }
148
+ }
149
+ }
150
+ ]
151
+ },
152
+ {
153
+ name: "sendingMessage",
154
+ type: "uiBlocks",
155
+ hideFromUI: true,
156
+ defaultValue: [
157
+ {
158
+ "@type": "@builder.io/sdk:Element",
159
+ responsiveStyles: {
160
+ large: {
161
+ marginTop: "10px"
162
+ }
163
+ },
164
+ component: {
165
+ name: "Text",
166
+ options: {
167
+ text: "<span>Sending...</span>"
168
+ }
169
+ }
170
+ }
171
+ ]
172
+ },
173
+ {
174
+ name: "customHeaders",
175
+ type: "map",
176
+ valueType: {
177
+ type: "string"
178
+ },
179
+ advanced: true,
180
+ showIf: 'options.get("sendSubmissionsTo") === "custom" && options.get("sendWithJs") === true'
181
+ }
182
+ ],
183
+ noWrap: true,
184
+ canHaveChildren: true,
185
+ defaultChildren: [
186
+ {
187
+ "@type": "@builder.io/sdk:Element",
188
+ responsiveStyles: {
189
+ large: {
190
+ marginTop: "10px"
191
+ }
192
+ },
193
+ component: {
194
+ name: "Text",
195
+ options: {
196
+ text: "<span>Enter your name</span>"
197
+ }
198
+ }
199
+ },
200
+ {
201
+ "@type": "@builder.io/sdk:Element",
202
+ responsiveStyles: {
203
+ large: {
204
+ marginTop: "10px"
205
+ }
206
+ },
207
+ component: {
208
+ name: "Form:Input",
209
+ options: {
210
+ name: "name",
211
+ placeholder: "Jane Doe"
212
+ }
213
+ }
214
+ },
215
+ {
216
+ "@type": "@builder.io/sdk:Element",
217
+ responsiveStyles: {
218
+ large: {
219
+ marginTop: "10px"
220
+ }
221
+ },
222
+ component: {
223
+ name: "Text",
224
+ options: {
225
+ text: "<span>Enter your email</span>"
226
+ }
227
+ }
228
+ },
229
+ {
230
+ "@type": "@builder.io/sdk:Element",
231
+ responsiveStyles: {
232
+ large: {
233
+ marginTop: "10px"
234
+ }
235
+ },
236
+ component: {
237
+ name: "Form:Input",
238
+ options: {
239
+ name: "email",
240
+ placeholder: "jane@doe.com"
241
+ }
242
+ }
243
+ },
244
+ {
245
+ "@type": "@builder.io/sdk:Element",
246
+ responsiveStyles: {
247
+ large: {
248
+ marginTop: "10px"
249
+ }
250
+ },
251
+ component: {
252
+ name: "Form:SubmitButton",
253
+ options: {
254
+ text: "Submit"
255
+ }
256
+ }
257
+ }
258
+ ]
259
+ };
260
+ export {
261
+ componentInfo
262
+ };
@@ -1,16 +1,17 @@
1
1
  import { Show, For } from "solid-js";
2
2
  import { createMutable } from "solid-js/store";
3
3
  import { css } from "solid-styled-components";
4
- import RenderBlock from "../components/render-block";
4
+ import RenderBlock from "../../components/render-block/render-block";
5
+ import { isEditing } from "../../functions/is-editing";
5
6
 
6
7
  function FormComponent(props) {
7
8
  const state = createMutable({
8
- state: "unsubmitted",
9
+ formState: "unsubmitted",
9
10
  responseData: null,
10
11
  formErrorMessage: "",
11
12
 
12
13
  get submissionState() {
13
- return Builder.isEditing && props.previewState || state.state;
14
+ return isEditing() && props.previewState || state.formState;
14
15
  },
15
16
 
16
17
  onSubmit(event) {
@@ -118,7 +119,7 @@ function FormComponent(props) {
118
119
  }
119
120
  }
120
121
 
121
- state.state = "sending";
122
+ state.formState = "sending";
122
123
  const formUrl = `${builder.env === "dev" ? "http://localhost:5000" : "https://builder.io"}/api/v1/form-submit?apiKey=${builder.apiKey}&to=${btoa(props.sendSubmissionsToEmail || "")}&name=${encodeURIComponent(props.name || "")}`;
123
124
  fetch(props.sendSubmissionsTo === "email" ? formUrl : props.action,
124
125
  /* TODO: throw error if no action URL */
@@ -152,7 +153,7 @@ function FormComponent(props) {
152
153
  }
153
154
 
154
155
  state.responseData = body;
155
- state.state = res.ok ? "success" : "error";
156
+ state.formState = res.ok ? "success" : "error";
156
157
 
157
158
  if (res.ok) {
158
159
  const submitSuccessEvent = new CustomEvent("submit:success", {
@@ -211,7 +212,7 @@ function FormComponent(props) {
211
212
  }
212
213
 
213
214
  state.responseData = err;
214
- state.state = "error";
215
+ state.formState = "error";
215
216
  });
216
217
  }
217
218
  }
@@ -249,5 +250,4 @@ function FormComponent(props) {
249
250
  </form>;
250
251
  }
251
252
 
252
- export default FormComponent;import { registerComponent } from '../functions/register-component';
253
- registerComponent(FormComponent, {name:'Form:Form',builtIn:true,defaults:{responsiveStyles:{large:{marginTop:'15px',paddingBottom:'15px'}}},image:'https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2Fef36d2a846134910b64b88e6d18c5ca5',inputs:[{name:'sendSubmissionsTo',type:'string',enum:[{label:'Send to email',value:'email',helperText:'Send form submissions to the email address of your choosing'},{label:'Custom',value:'custom',helperText:'Handle where the form requests go manually with a little code, e.g. to your own custom backend'}],defaultValue:'email'},{name:'sendSubmissionsToEmail',type:'string',required:true,defaultValue:'your@email.com',showIf:'options.get("sendSubmissionsTo") === "email"'},{name:'sendWithJs',type:'boolean',helperText:'Set to false to use basic html form action',defaultValue:true,showIf:'options.get("sendSubmissionsTo") === "custom"'},{name:'name',type:'string',defaultValue:'My form'},{name:'action',type:'string',helperText:'URL to send the form data to',showIf:'options.get("sendSubmissionsTo") === "custom"'},{name:'contentType',type:'string',defaultValue:'application/json',advanced:true,enum:['application/json','multipart/form-data','application/x-www-form-urlencoded'],showIf:'options.get("sendSubmissionsTo") === "custom" && options.get("sendWithJs") === true'},{name:'method',type:'string',showIf:'options.get("sendSubmissionsTo") === "custom"',defaultValue:'POST',advanced:true},{name:'previewState',type:'string',enum:['unsubmitted','sending','success','error'],defaultValue:'unsubmitted',helperText:'Choose a state to edit, e.g. choose "success" to show what users see on success and edit the message',showIf:'options.get("sendSubmissionsTo") !== "zapier" && options.get("sendWithJs") === true'},{name:'successUrl',type:'url',helperText:'Optional URL to redirect the user to on form submission success',showIf:'options.get("sendSubmissionsTo") !== "zapier" && options.get("sendWithJs") === true'},{name:'resetFormOnSubmit',type:'boolean',showIf:"options.get('sendSubmissionsTo') === 'custom' && options.get('sendWithJs') === true",advanced:true},{name:'successMessage',type:'uiBlocks',hideFromUI:true,defaultValue:[{'@type':'@builder.io/sdk:Element',responsiveStyles:{large:{marginTop:'10px'}},component:{name:'Text',options:{text:'<span>Thanks!</span>'}}}]},{name:'validate',type:'boolean',defaultValue:true,advanced:true},{name:'errorMessagePath',type:'text',advanced:true,helperText:'Path to where to get the error message from in a JSON response to display to the user, e.g. "error.message" for a response like { "error": { "message": "this username is taken" }}'},{name:'errorMessage',type:'uiBlocks',hideFromUI:true,defaultValue:[{'@type':'@builder.io/sdk:Element',responsiveStyles:{large:{marginTop:'10px'}},bindings:{'component.options.text':'state.formErrorMessage || block.component.options.text'},component:{name:'Text',options:{text:'<span>Form submission error :( Please check your answers and try again</span>'}}}]},{name:'sendingMessage',type:'uiBlocks',hideFromUI:true,defaultValue:[{'@type':'@builder.io/sdk:Element',responsiveStyles:{large:{marginTop:'10px'}},component:{name:'Text',options:{text:'<span>Sending...</span>'}}}]},{name:'customHeaders',type:'map',valueType:{type:'string'},advanced:true,showIf:'options.get("sendSubmissionsTo") === "custom" && options.get("sendWithJs") === true'}],noWrap:true,canHaveChildren:true,defaultChildren:[{'@type':'@builder.io/sdk:Element',responsiveStyles:{large:{marginTop:'10px'}},component:{name:'Text',options:{text:'<span>Enter your name</span>'}}},{'@type':'@builder.io/sdk:Element',responsiveStyles:{large:{marginTop:'10px'}},component:{name:'Form:Input',options:{name:'name',placeholder:'Jane Doe'}}},{'@type':'@builder.io/sdk:Element',responsiveStyles:{large:{marginTop:'10px'}},component:{name:'Text',options:{text:'<span>Enter your email</span>'}}},{'@type':'@builder.io/sdk:Element',responsiveStyles:{large:{marginTop:'10px'}},component:{name:'Form:Input',options:{name:'email',placeholder:'jane@doe.com'}}},{'@type':'@builder.io/sdk:Element',responsiveStyles:{large:{marginTop:'10px'}},component:{name:'Form:SubmitButton',options:{text:'Submit'}}}]});
253
+ export default FormComponent;
@@ -3,15 +3,16 @@ import { Show, For } from "solid-js";
3
3
  import { createMutable } from "solid-js/store";
4
4
  import { css } from "solid-styled-components";
5
5
 
6
- import RenderBlock from "../components/render-block.lite";
6
+ import RenderBlock from "../../components/render-block/render-block.lite";
7
+ import { isEditing } from "../../functions/is-editing";
7
8
 
8
9
  function FormComponent(props) {
9
10
  const state = createMutable({
10
- state: "unsubmitted",
11
+ formState: "unsubmitted",
11
12
  responseData: null,
12
13
  formErrorMessage: "",
13
14
  get submissionState() {
14
- return (Builder.isEditing && props.previewState) || state.state;
15
+ return (isEditing() && props.previewState) || state.formState;
15
16
  },
16
17
  onSubmit(
17
18
  event: Event & {
@@ -130,7 +131,7 @@ function FormComponent(props) {
130
131
  }
131
132
  }
132
133
 
133
- state.state = "sending";
134
+ state.formState = "sending";
134
135
  const formUrl = `${
135
136
  builder.env === "dev" ? "http://localhost:5000" : "https://builder.io"
136
137
  }/api/v1/form-submit?apiKey=${builder.apiKey}&to=${btoa(
@@ -171,7 +172,7 @@ function FormComponent(props) {
171
172
  }
172
173
 
173
174
  state.responseData = body;
174
- state.state = res.ok ? "success" : "error";
175
+ state.formState = res.ok ? "success" : "error";
175
176
 
176
177
  if (res.ok) {
177
178
  const submitSuccessEvent = new CustomEvent("submit:success", {
@@ -229,7 +230,7 @@ function FormComponent(props) {
229
230
  }
230
231
 
231
232
  state.responseData = err;
232
- state.state = "error";
233
+ state.formState = "error";
233
234
  }
234
235
  );
235
236
  }
@@ -0,0 +1,7 @@
1
+ import { registerComponent } from "../../functions/register-component";
2
+ import { componentInfo } from "./component-info";
3
+ import component from "./form";
4
+ var stdin_default = registerComponent(component, componentInfo);
5
+ export {
6
+ stdin_default as default
7
+ };
@@ -0,0 +1,11 @@
1
+ const componentInfo = {
2
+ name: "Fragment",
3
+ static: true,
4
+ hidden: true,
5
+ builtIn: true,
6
+ canHaveChildren: true,
7
+ noWrap: true
8
+ };
9
+ export {
10
+ componentInfo
11
+ };
@@ -0,0 +1,5 @@
1
+ function FragmentComponent(props) {
2
+ return <span>{props.children}</span>;
3
+ }
4
+
5
+ export default FragmentComponent;
@@ -0,0 +1,7 @@
1
+ import { registerComponent } from "../../functions/register-component";
2
+ import { componentInfo } from "./component-info";
3
+ import component from "./fragment";
4
+ var stdin_default = registerComponent(component, componentInfo);
5
+ export {
6
+ stdin_default as default
7
+ };
@@ -0,0 +1,104 @@
1
+ const componentInfo = {
2
+ name: "Image",
3
+ static: true,
4
+ builtIn: true,
5
+ image: "https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-insert_photo-24px.svg?alt=media&token=4e5d0ef4-f5e8-4e57-b3a9-38d63a9b9dc4",
6
+ defaultStyles: {
7
+ position: "relative",
8
+ minHeight: "20px",
9
+ minWidth: "20px",
10
+ overflow: "hidden"
11
+ },
12
+ canHaveChildren: true,
13
+ inputs: [
14
+ {
15
+ name: "image",
16
+ type: "file",
17
+ bubble: true,
18
+ allowedFileTypes: ["jpeg", "jpg", "png", "svg"],
19
+ required: true,
20
+ defaultValue: "https://cdn.builder.io/api/v1/image/assets%2Fpwgjf0RoYWbdnJSbpBAjXNRMe9F2%2Ffb27a7c790324294af8be1c35fe30f4d",
21
+ onChange: " const DEFAULT_ASPECT_RATIO = 0.7041; options.delete('srcset'); options.delete('noWebp'); function loadImage(url, timeout) { return new Promise((resolve, reject) => { const img = document.createElement('img'); let loaded = false; img.onload = () => { loaded = true; resolve(img); }; img.addEventListener('error', event => { console.warn('Image load failed', event.error); reject(event.error); }); img.src = url; setTimeout(() => { if (!loaded) { reject(new Error('Image load timed out')); } }, timeout); }); } function round(num) { return Math.round(num * 1000) / 1000; } const value = options.get('image'); const aspectRatio = options.get('aspectRatio'); // For SVG images - don't render as webp, keep them as SVG fetch(value) .then(res => res.blob()) .then(blob => { if (blob.type.includes('svg')) { options.set('noWebp', true); } }); if (value && (!aspectRatio || aspectRatio === DEFAULT_ASPECT_RATIO)) { return loadImage(value).then(img => { const possiblyUpdatedAspectRatio = options.get('aspectRatio'); if ( options.get('image') === value && (!possiblyUpdatedAspectRatio || possiblyUpdatedAspectRatio === DEFAULT_ASPECT_RATIO) ) { if (img.width && img.height) { options.set('aspectRatio', round(img.height / img.width)); options.set('height', img.height); options.set('width', img.width); } } }); }"
22
+ },
23
+ {
24
+ name: "backgroundSize",
25
+ type: "text",
26
+ defaultValue: "cover",
27
+ enum: [
28
+ {
29
+ label: "contain",
30
+ value: "contain",
31
+ helperText: "The image should never get cropped"
32
+ },
33
+ {
34
+ label: "cover",
35
+ value: "cover",
36
+ helperText: "The image should fill it's box, cropping when needed"
37
+ }
38
+ ]
39
+ },
40
+ {
41
+ name: "backgroundPosition",
42
+ type: "text",
43
+ defaultValue: "center",
44
+ enum: [
45
+ "center",
46
+ "top",
47
+ "left",
48
+ "right",
49
+ "bottom",
50
+ "top left",
51
+ "top right",
52
+ "bottom left",
53
+ "bottom right"
54
+ ]
55
+ },
56
+ {
57
+ name: "altText",
58
+ type: "string",
59
+ helperText: "Text to display when the user has images off"
60
+ },
61
+ {
62
+ name: "height",
63
+ type: "number",
64
+ hideFromUI: true
65
+ },
66
+ {
67
+ name: "width",
68
+ type: "number",
69
+ hideFromUI: true
70
+ },
71
+ {
72
+ name: "sizes",
73
+ type: "string",
74
+ hideFromUI: true
75
+ },
76
+ {
77
+ name: "srcset",
78
+ type: "string",
79
+ hideFromUI: true
80
+ },
81
+ {
82
+ name: "lazy",
83
+ type: "boolean",
84
+ defaultValue: true,
85
+ hideFromUI: true
86
+ },
87
+ {
88
+ name: "fitContent",
89
+ type: "boolean",
90
+ helperText: "When child blocks are provided, fit to them instead of using the image's aspect ratio",
91
+ defaultValue: true
92
+ },
93
+ {
94
+ name: "aspectRatio",
95
+ type: "number",
96
+ helperText: "This is the ratio of height/width, e.g. set to 1.5 for a 300px wide and 200px tall photo. Set to 0 to not force the image to maintain it's aspect ratio",
97
+ advanced: true,
98
+ defaultValue: 0.7041
99
+ }
100
+ ]
101
+ };
102
+ export {
103
+ componentInfo
104
+ };
@@ -0,0 +1,54 @@
1
+ import { Show } from "solid-js";
2
+ import { css } from "solid-styled-components";
3
+
4
+ function Image(props) {
5
+ return <div class={css({
6
+ position: "relative"
7
+ })}>
8
+ <picture>
9
+ <img class={"builder-image" + (props.className ? " " + props.className : "") + " " + css({
10
+ opacity: "1",
11
+ transition: "opacity 0.2s ease-in-out",
12
+ position: "absolute",
13
+ height: "100%",
14
+ width: "100%",
15
+ top: "0px",
16
+ left: "0px"
17
+ })} loading="lazy" alt={props.altText} aria-role={props.altText ? "presentation" : undefined} style={{
18
+ "object-position": props.backgroundSize || "center",
19
+ "object-fit": props.backgroundSize || "cover"
20
+ }} src={props.image} srcset={props.srcset} sizes={props.sizes} />
21
+ <source srcSet={props.srcset} />
22
+ </picture>
23
+ <Show when={props.aspectRatio && !(props.fitContent && props.builderBlock?.children?.length)}>
24
+ <div class={css({
25
+ width: "100%",
26
+ pointerEvents: "none",
27
+ fontSize: "0"
28
+ })} style={{
29
+ "padding-top": props.aspectRatio * 100 + "%"
30
+ }}>
31
+ {" "}
32
+ </div>
33
+ </Show>
34
+ <Show when={props.builderBlock?.children?.length && props.fitContent}>
35
+ {props.children}
36
+ </Show>
37
+ <Show when={!props.fitContent}>
38
+ <div class={css({
39
+ display: "flex",
40
+ flexDirection: "column",
41
+ alignItems: "stretch",
42
+ position: "absolute",
43
+ top: "0",
44
+ left: "0",
45
+ width: "100%",
46
+ height: "100%"
47
+ })}>
48
+ {props.children}
49
+ </div>
50
+ </Show>
51
+ </div>;
52
+ }
53
+
54
+ export default Image;
@@ -0,0 +1,83 @@
1
+ import { Show } from "solid-js";
2
+
3
+ import { css } from "solid-styled-components";
4
+
5
+ function Image(props) {
6
+ return (
7
+ <div
8
+ class={css({
9
+ position: "relative",
10
+ })}
11
+ >
12
+ <picture>
13
+ <img
14
+ class={
15
+ "builder-image" +
16
+ (props.className ? " " + props.className : "") +
17
+ " " +
18
+ css({
19
+ opacity: "1",
20
+ transition: "opacity 0.2s ease-in-out",
21
+ position: "absolute",
22
+ height: "100%",
23
+ width: "100%",
24
+ top: "0px",
25
+ left: "0px",
26
+ })
27
+ }
28
+ loading="lazy"
29
+ alt={props.altText}
30
+ aria-role={props.altText ? "presentation" : undefined}
31
+ style={{
32
+ "object-position": props.backgroundSize || "center",
33
+ "object-fit": props.backgroundSize || "cover",
34
+ }}
35
+ src={props.image}
36
+ srcset={props.srcset}
37
+ sizes={props.sizes}
38
+ />
39
+ <source srcSet={props.srcset} />
40
+ </picture>
41
+ <Show
42
+ when={
43
+ props.aspectRatio &&
44
+ !(props.fitContent && props.builderBlock?.children?.length)
45
+ }
46
+ >
47
+ <div
48
+ class={css({
49
+ width: "100%",
50
+ pointerEvents: "none",
51
+ fontSize: "0",
52
+ })}
53
+ style={{
54
+ "padding-top": props.aspectRatio * 100 + "%",
55
+ }}
56
+ >
57
+ {" "}
58
+ </div>
59
+ </Show>
60
+ <Show when={props.builderBlock?.children?.length && props.fitContent}>
61
+ {props.children}
62
+ </Show>
63
+ <Show when={!props.fitContent}>
64
+ <div
65
+ class={css({
66
+ display: "flex",
67
+ flexDirection: "column",
68
+ alignItems: "stretch",
69
+ position: "absolute",
70
+ top: "0",
71
+ left: "0",
72
+ width: "100%",
73
+ height: "100%",
74
+ })}
75
+ >
76
+ {props.children}
77
+ </div>
78
+ </Show>
79
+ </div>
80
+ );
81
+ }
82
+
83
+ export default Image;
@@ -0,0 +1,7 @@
1
+ import { registerComponent } from "../../functions/register-component";
2
+ import { componentInfo } from "./component-info";
3
+ import component from "./image";
4
+ var stdin_default = registerComponent(component, componentInfo);
5
+ export {
6
+ stdin_default as default
7
+ };
@@ -0,0 +1,20 @@
1
+ const componentInfo = {
2
+ name: "Raw:Img",
3
+ hideFromInsertMenu: true,
4
+ builtIn: true,
5
+ image: "https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-insert_photo-24px.svg?alt=media&token=4e5d0ef4-f5e8-4e57-b3a9-38d63a9b9dc4",
6
+ inputs: [
7
+ {
8
+ name: "image",
9
+ bubble: true,
10
+ type: "file",
11
+ allowedFileTypes: ["jpeg", "jpg", "png", "svg"],
12
+ required: true
13
+ }
14
+ ],
15
+ noWrap: true,
16
+ static: true
17
+ };
18
+ export {
19
+ componentInfo
20
+ };