@builder.io/sdk-solid 0.13.1 → 0.13.3

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/node/index.js CHANGED
@@ -929,7 +929,7 @@ function BlockStyles(props) {
929
929
  }
930
930
  return true;
931
931
  }
932
- function css4() {
932
+ function css5() {
933
933
  const processedBlock = getProcessedBlock({
934
934
  block: props.block,
935
935
  localState: props.context.localState,
@@ -966,12 +966,12 @@ function BlockStyles(props) {
966
966
  }
967
967
  return createComponent(Show, {
968
968
  get when() {
969
- return memo(() => !!(TARGET !== "reactNative" && css4()))() && canShowBlock();
969
+ return memo(() => !!(TARGET !== "reactNative" && css5()))() && canShowBlock();
970
970
  },
971
971
  get children() {
972
972
  return createComponent(inlined_styles_default, {
973
973
  get styles() {
974
- return css4();
974
+ return css5();
975
975
  }
976
976
  });
977
977
  }
@@ -1306,10 +1306,10 @@ function Block(props) {
1306
1306
  componentOptions: {
1307
1307
  ...getBlockComponentOptions(processedBlock()),
1308
1308
  builderContext: props.context,
1309
- ...blockComponent()?.name === "Core:Button" || blockComponent()?.name === "Symbol" || blockComponent()?.name === "Columns" ? {
1309
+ ...blockComponent()?.name === "Core:Button" || blockComponent()?.name === "Symbol" || blockComponent()?.name === "Columns" || blockComponent()?.name === "Form:Form" ? {
1310
1310
  builderLinkComponent: props.linkComponent
1311
1311
  } : {},
1312
- ...blockComponent()?.name === "Symbol" || blockComponent()?.name === "Columns" ? {
1312
+ ...blockComponent()?.name === "Symbol" || blockComponent()?.name === "Columns" || blockComponent()?.name === "Form:Form" ? {
1313
1313
  builderComponents: props.registeredComponents
1314
1314
  } : {}
1315
1315
  },
@@ -2435,170 +2435,8 @@ var componentInfo2 = {
2435
2435
  }]
2436
2436
  };
2437
2437
 
2438
- // src/blocks/custom-code/component-info.ts
2439
- var componentInfo3 = {
2440
- name: "Custom Code",
2441
- static: true,
2442
- requiredPermissions: ["editCode"],
2443
- inputs: [{
2444
- name: "code",
2445
- type: "html",
2446
- required: true,
2447
- defaultValue: "<p>Hello there, I am custom HTML code!</p>",
2448
- code: true
2449
- }, {
2450
- name: "replaceNodes",
2451
- type: "boolean",
2452
- helperText: "Preserve server rendered dom nodes",
2453
- advanced: true
2454
- }, {
2455
- name: "scriptsClientOnly",
2456
- type: "boolean",
2457
- defaultValue: false,
2458
- helperText: "Only print and run scripts on the client. Important when scripts influence DOM that could be replaced when client loads",
2459
- advanced: true
2460
- }]
2461
- };
2462
- var _tmpl$6 = /* @__PURE__ */ template(`<div>`);
2463
- function CustomCode(props) {
2464
- const [scriptsInserted, setScriptsInserted] = createSignal([]);
2465
- const [scriptsRun, setScriptsRun] = createSignal([]);
2466
- let elementRef;
2467
- onMount(() => {
2468
- if (!elementRef?.getElementsByTagName || typeof window === "undefined") {
2469
- return;
2470
- }
2471
- const scripts = elementRef.getElementsByTagName("script");
2472
- for (let i = 0; i < scripts.length; i++) {
2473
- const script = scripts[i];
2474
- if (script.src) {
2475
- if (scriptsInserted().includes(script.src)) {
2476
- continue;
2477
- }
2478
- scriptsInserted().push(script.src);
2479
- const newScript = document.createElement("script");
2480
- newScript.async = true;
2481
- newScript.src = script.src;
2482
- document.head.appendChild(newScript);
2483
- } else if (!script.type || ["text/javascript", "application/javascript", "application/ecmascript"].includes(script.type)) {
2484
- if (scriptsRun().includes(script.innerText)) {
2485
- continue;
2486
- }
2487
- try {
2488
- scriptsRun().push(script.innerText);
2489
- new Function(script.innerText)();
2490
- } catch (error2) {
2491
- }
2492
- }
2493
- }
2494
- });
2495
- return (() => {
2496
- const _el$ = _tmpl$6();
2497
- const _ref$ = elementRef;
2498
- typeof _ref$ === "function" ? use(_ref$, _el$) : elementRef = _el$;
2499
- effect((_p$) => {
2500
- const _v$ = "builder-custom-code" + (props.replaceNodes ? " replace-nodes" : ""), _v$2 = props.code;
2501
- _v$ !== _p$._v$ && className(_el$, _p$._v$ = _v$);
2502
- _v$2 !== _p$._v$2 && (_el$.innerHTML = _p$._v$2 = _v$2);
2503
- return _p$;
2504
- }, {
2505
- _v$: void 0,
2506
- _v$2: void 0
2507
- });
2508
- return _el$;
2509
- })();
2510
- }
2511
- var custom_code_default = CustomCode;
2512
-
2513
- // src/blocks/embed/component-info.ts
2514
- var componentInfo4 = {
2515
- name: "Embed",
2516
- static: true,
2517
- inputs: [{
2518
- name: "url",
2519
- type: "url",
2520
- required: true,
2521
- defaultValue: "",
2522
- helperText: "e.g. enter a youtube url, google map, etc",
2523
- onChange: (options) => {
2524
- const url = options.get("url");
2525
- if (url) {
2526
- options.set("content", "Loading...");
2527
- const apiKey = "ae0e60e78201a3f2b0de4b";
2528
- return fetch(`https://iframe.ly/api/iframely?url=${url}&api_key=${apiKey}`).then((res) => res.json()).then((data) => {
2529
- if (options.get("url") === url) {
2530
- if (data.html) {
2531
- options.set("content", data.html);
2532
- } else {
2533
- options.set("content", "Invalid url, please try another");
2534
- }
2535
- }
2536
- }).catch((_err) => {
2537
- options.set("content", "There was an error embedding this URL, please try again or another URL");
2538
- });
2539
- } else {
2540
- options.delete("content");
2541
- }
2542
- }
2543
- }, {
2544
- name: "content",
2545
- type: "html",
2546
- defaultValue: '<div style="padding: 20px; text-align: center">(Choose an embed URL)<div>',
2547
- hideFromUI: true
2548
- }]
2549
- };
2550
-
2551
- // src/blocks/embed/helpers.ts
2552
- var SCRIPT_MIME_TYPES = ["text/javascript", "application/javascript", "application/ecmascript"];
2553
- var isJsScript = (script) => SCRIPT_MIME_TYPES.includes(script.type);
2554
-
2555
- // src/blocks/embed/embed.tsx
2556
- var _tmpl$7 = /* @__PURE__ */ template(`<div class=builder-embed>`);
2557
- function Embed(props) {
2558
- const [scriptsInserted, setScriptsInserted] = createSignal([]);
2559
- const [scriptsRun, setScriptsRun] = createSignal([]);
2560
- const [ranInitFn, setRanInitFn] = createSignal(false);
2561
- function findAndRunScripts() {
2562
- if (!elem || !elem.getElementsByTagName)
2563
- return;
2564
- const scripts = elem.getElementsByTagName("script");
2565
- for (let i = 0; i < scripts.length; i++) {
2566
- const script = scripts[i];
2567
- if (script.src && !scriptsInserted().includes(script.src)) {
2568
- scriptsInserted().push(script.src);
2569
- const newScript = document.createElement("script");
2570
- newScript.async = true;
2571
- newScript.src = script.src;
2572
- document.head.appendChild(newScript);
2573
- } else if (isJsScript(script) && !scriptsRun().includes(script.innerText)) {
2574
- try {
2575
- scriptsRun().push(script.innerText);
2576
- new Function(script.innerText)();
2577
- } catch (error2) {
2578
- }
2579
- }
2580
- }
2581
- }
2582
- let elem;
2583
- function onUpdateFn_0() {
2584
- if (elem && !ranInitFn()) {
2585
- setRanInitFn(true);
2586
- findAndRunScripts();
2587
- }
2588
- }
2589
- createEffect(on(() => [elem, ranInitFn()], onUpdateFn_0));
2590
- return (() => {
2591
- const _el$ = _tmpl$7();
2592
- const _ref$ = elem;
2593
- typeof _ref$ === "function" ? use(_ref$, _el$) : elem = _el$;
2594
- effect(() => _el$.innerHTML = props.content);
2595
- return _el$;
2596
- })();
2597
- }
2598
- var embed_default = Embed;
2599
-
2600
2438
  // src/blocks/fragment/component-info.ts
2601
- var componentInfo5 = {
2439
+ var componentInfo3 = {
2602
2440
  name: "Fragment",
2603
2441
  static: true,
2604
2442
  hidden: true,
@@ -2607,7 +2445,7 @@ var componentInfo5 = {
2607
2445
  };
2608
2446
 
2609
2447
  // src/blocks/image/component-info.ts
2610
- var componentInfo6 = {
2448
+ var componentInfo4 = {
2611
2449
  name: "Image",
2612
2450
  static: true,
2613
2451
  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",
@@ -2708,28 +2546,1095 @@ var componentInfo6 = {
2708
2546
  }, {
2709
2547
  name: "srcset",
2710
2548
  type: "string",
2711
- hideFromUI: true
2549
+ hideFromUI: true
2550
+ }, {
2551
+ name: "lazy",
2552
+ type: "boolean",
2553
+ defaultValue: true,
2554
+ hideFromUI: true
2555
+ }, {
2556
+ name: "fitContent",
2557
+ type: "boolean",
2558
+ helperText: "When child blocks are provided, fit to them instead of using the image's aspect ratio",
2559
+ defaultValue: true
2560
+ }, {
2561
+ name: "aspectRatio",
2562
+ type: "number",
2563
+ 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",
2564
+ advanced: true,
2565
+ defaultValue: 0.7041
2566
+ }]
2567
+ };
2568
+
2569
+ // src/blocks/section/component-info.ts
2570
+ var componentInfo5 = {
2571
+ name: "Core:Section",
2572
+ static: true,
2573
+ image: "https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2F682efef23ace49afac61748dd305c70a",
2574
+ inputs: [{
2575
+ name: "maxWidth",
2576
+ type: "number",
2577
+ defaultValue: 1200
2578
+ }, {
2579
+ name: "lazyLoad",
2580
+ type: "boolean",
2581
+ defaultValue: false,
2582
+ advanced: true,
2583
+ description: "Only render this section when in view"
2584
+ }],
2585
+ defaultStyles: {
2586
+ paddingLeft: "20px",
2587
+ paddingRight: "20px",
2588
+ paddingTop: "50px",
2589
+ paddingBottom: "50px",
2590
+ marginTop: "0px",
2591
+ width: "100vw",
2592
+ marginLeft: "calc(50% - 50vw)"
2593
+ },
2594
+ canHaveChildren: true,
2595
+ defaultChildren: [{
2596
+ "@type": "@builder.io/sdk:Element",
2597
+ responsiveStyles: {
2598
+ large: {
2599
+ textAlign: "center"
2600
+ }
2601
+ },
2602
+ component: {
2603
+ name: "Text",
2604
+ options: {
2605
+ text: "<p><b>I am a section! My content keeps from getting too wide, so that it's easy to read even on big screens.</b></p><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur</p>"
2606
+ }
2607
+ }
2608
+ }]
2609
+ };
2610
+
2611
+ // src/blocks/slot/component-info.ts
2612
+ var componentInfo6 = {
2613
+ name: "Slot",
2614
+ isRSC: true,
2615
+ description: "Allow child blocks to be inserted into this content when used as a Symbol",
2616
+ docsLink: "https://www.builder.io/c/docs/symbols-with-blocks",
2617
+ image: "https://cdn.builder.io/api/v1/image/assets%2FYJIGb4i01jvw0SRdL5Bt%2F3aad6de36eae43b59b52c85190fdef56",
2618
+ // Maybe wrap this for canHaveChildren so bind children to this hm
2619
+ inputs: [{
2620
+ name: "name",
2621
+ type: "string",
2622
+ required: true,
2623
+ defaultValue: "children"
2624
+ }]
2625
+ };
2626
+ var _tmpl$6 = /* @__PURE__ */ template(`<div>`);
2627
+ function Slot(props) {
2628
+ return (() => {
2629
+ const _el$ = _tmpl$6();
2630
+ _el$.style.setProperty("pointer-events", "auto");
2631
+ spread(_el$, mergeProps(() => !props.builderContext.context?.symbolId && {
2632
+ "builder-slot": props.name
2633
+ }), false, true);
2634
+ insert(_el$, createComponent(blocks_default, {
2635
+ get parent() {
2636
+ return props.builderContext.context?.symbolId;
2637
+ },
2638
+ get path() {
2639
+ return `symbol.data.${props.name}`;
2640
+ },
2641
+ get context() {
2642
+ return props.builderContext;
2643
+ },
2644
+ get blocks() {
2645
+ return props.builderContext.rootState?.[props.name];
2646
+ }
2647
+ }));
2648
+ return _el$;
2649
+ })();
2650
+ }
2651
+ var slot_default = Slot;
2652
+
2653
+ // src/blocks/symbol/component-info.ts
2654
+ var componentInfo7 = {
2655
+ name: "Symbol",
2656
+ noWrap: true,
2657
+ static: true,
2658
+ isRSC: true,
2659
+ inputs: [{
2660
+ name: "symbol",
2661
+ type: "uiSymbol"
2662
+ }, {
2663
+ name: "dataOnly",
2664
+ helperText: "Make this a data symbol that doesn't display any UI",
2665
+ type: "boolean",
2666
+ defaultValue: false,
2667
+ advanced: true,
2668
+ hideFromUI: true
2669
+ }, {
2670
+ name: "inheritState",
2671
+ helperText: "Inherit the parent component state and data",
2672
+ type: "boolean",
2673
+ defaultValue: false,
2674
+ advanced: true
2675
+ }, {
2676
+ name: "renderToLiquid",
2677
+ helperText: "Render this symbols contents to liquid. Turn off to fetch with javascript and use custom targeting",
2678
+ type: "boolean",
2679
+ defaultValue: false,
2680
+ advanced: true,
2681
+ hideFromUI: true
2682
+ }, {
2683
+ name: "useChildren",
2684
+ hideFromUI: true,
2685
+ type: "boolean"
2686
+ }]
2687
+ };
2688
+
2689
+ // src/blocks/text/component-info.ts
2690
+ var componentInfo8 = {
2691
+ name: "Text",
2692
+ static: true,
2693
+ isRSC: true,
2694
+ image: "https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-text_fields-24px%20(1).svg?alt=media&token=12177b73-0ee3-42ca-98c6-0dd003de1929",
2695
+ inputs: [{
2696
+ name: "text",
2697
+ type: "html",
2698
+ required: true,
2699
+ autoFocus: true,
2700
+ bubble: true,
2701
+ defaultValue: "Enter some text..."
2702
+ }],
2703
+ defaultStyles: {
2704
+ lineHeight: "normal",
2705
+ height: "auto",
2706
+ textAlign: "center"
2707
+ }
2708
+ };
2709
+ var _tmpl$7 = /* @__PURE__ */ template(`<div class=builder-text>`);
2710
+ function Text(props) {
2711
+ return (() => {
2712
+ const _el$ = _tmpl$7();
2713
+ _el$.style.setProperty("outline", "none");
2714
+ effect(() => _el$.innerHTML = props.text?.toString() || "");
2715
+ return _el$;
2716
+ })();
2717
+ }
2718
+ var text_default = Text;
2719
+
2720
+ // src/blocks/custom-code/component-info.ts
2721
+ var componentInfo9 = {
2722
+ name: "Custom Code",
2723
+ static: true,
2724
+ requiredPermissions: ["editCode"],
2725
+ inputs: [{
2726
+ name: "code",
2727
+ type: "html",
2728
+ required: true,
2729
+ defaultValue: "<p>Hello there, I am custom HTML code!</p>",
2730
+ code: true
2731
+ }, {
2732
+ name: "replaceNodes",
2733
+ type: "boolean",
2734
+ helperText: "Preserve server rendered dom nodes",
2735
+ advanced: true
2736
+ }, {
2737
+ name: "scriptsClientOnly",
2738
+ type: "boolean",
2739
+ defaultValue: false,
2740
+ helperText: "Only print and run scripts on the client. Important when scripts influence DOM that could be replaced when client loads",
2741
+ advanced: true
2742
+ }]
2743
+ };
2744
+ var _tmpl$8 = /* @__PURE__ */ template(`<div>`);
2745
+ function CustomCode(props) {
2746
+ const [scriptsInserted, setScriptsInserted] = createSignal([]);
2747
+ const [scriptsRun, setScriptsRun] = createSignal([]);
2748
+ let elementRef;
2749
+ onMount(() => {
2750
+ if (!elementRef?.getElementsByTagName || typeof window === "undefined") {
2751
+ return;
2752
+ }
2753
+ const scripts = elementRef.getElementsByTagName("script");
2754
+ for (let i = 0; i < scripts.length; i++) {
2755
+ const script = scripts[i];
2756
+ if (script.src) {
2757
+ if (scriptsInserted().includes(script.src)) {
2758
+ continue;
2759
+ }
2760
+ scriptsInserted().push(script.src);
2761
+ const newScript = document.createElement("script");
2762
+ newScript.async = true;
2763
+ newScript.src = script.src;
2764
+ document.head.appendChild(newScript);
2765
+ } else if (!script.type || ["text/javascript", "application/javascript", "application/ecmascript"].includes(script.type)) {
2766
+ if (scriptsRun().includes(script.innerText)) {
2767
+ continue;
2768
+ }
2769
+ try {
2770
+ scriptsRun().push(script.innerText);
2771
+ new Function(script.innerText)();
2772
+ } catch (error2) {
2773
+ }
2774
+ }
2775
+ }
2776
+ });
2777
+ return (() => {
2778
+ const _el$ = _tmpl$8();
2779
+ const _ref$ = elementRef;
2780
+ typeof _ref$ === "function" ? use(_ref$, _el$) : elementRef = _el$;
2781
+ effect((_p$) => {
2782
+ const _v$ = "builder-custom-code" + (props.replaceNodes ? " replace-nodes" : ""), _v$2 = props.code;
2783
+ _v$ !== _p$._v$ && className(_el$, _p$._v$ = _v$);
2784
+ _v$2 !== _p$._v$2 && (_el$.innerHTML = _p$._v$2 = _v$2);
2785
+ return _p$;
2786
+ }, {
2787
+ _v$: void 0,
2788
+ _v$2: void 0
2789
+ });
2790
+ return _el$;
2791
+ })();
2792
+ }
2793
+ var custom_code_default = CustomCode;
2794
+
2795
+ // src/blocks/embed/component-info.ts
2796
+ var componentInfo10 = {
2797
+ name: "Embed",
2798
+ static: true,
2799
+ inputs: [{
2800
+ name: "url",
2801
+ type: "url",
2802
+ required: true,
2803
+ defaultValue: "",
2804
+ helperText: "e.g. enter a youtube url, google map, etc",
2805
+ onChange: (options) => {
2806
+ const url = options.get("url");
2807
+ if (url) {
2808
+ options.set("content", "Loading...");
2809
+ const apiKey = "ae0e60e78201a3f2b0de4b";
2810
+ return fetch(`https://iframe.ly/api/iframely?url=${url}&api_key=${apiKey}`).then((res) => res.json()).then((data) => {
2811
+ if (options.get("url") === url) {
2812
+ if (data.html) {
2813
+ options.set("content", data.html);
2814
+ } else {
2815
+ options.set("content", "Invalid url, please try another");
2816
+ }
2817
+ }
2818
+ }).catch((_err) => {
2819
+ options.set("content", "There was an error embedding this URL, please try again or another URL");
2820
+ });
2821
+ } else {
2822
+ options.delete("content");
2823
+ }
2824
+ }
2825
+ }, {
2826
+ name: "content",
2827
+ type: "html",
2828
+ defaultValue: '<div style="padding: 20px; text-align: center">(Choose an embed URL)<div>',
2829
+ hideFromUI: true
2830
+ }]
2831
+ };
2832
+
2833
+ // src/blocks/embed/helpers.ts
2834
+ var SCRIPT_MIME_TYPES = ["text/javascript", "application/javascript", "application/ecmascript"];
2835
+ var isJsScript = (script) => SCRIPT_MIME_TYPES.includes(script.type);
2836
+
2837
+ // src/blocks/embed/embed.tsx
2838
+ var _tmpl$9 = /* @__PURE__ */ template(`<div class=builder-embed>`);
2839
+ function Embed(props) {
2840
+ const [scriptsInserted, setScriptsInserted] = createSignal([]);
2841
+ const [scriptsRun, setScriptsRun] = createSignal([]);
2842
+ const [ranInitFn, setRanInitFn] = createSignal(false);
2843
+ function findAndRunScripts() {
2844
+ if (!elem || !elem.getElementsByTagName)
2845
+ return;
2846
+ const scripts = elem.getElementsByTagName("script");
2847
+ for (let i = 0; i < scripts.length; i++) {
2848
+ const script = scripts[i];
2849
+ if (script.src && !scriptsInserted().includes(script.src)) {
2850
+ scriptsInserted().push(script.src);
2851
+ const newScript = document.createElement("script");
2852
+ newScript.async = true;
2853
+ newScript.src = script.src;
2854
+ document.head.appendChild(newScript);
2855
+ } else if (isJsScript(script) && !scriptsRun().includes(script.innerText)) {
2856
+ try {
2857
+ scriptsRun().push(script.innerText);
2858
+ new Function(script.innerText)();
2859
+ } catch (error2) {
2860
+ }
2861
+ }
2862
+ }
2863
+ }
2864
+ let elem;
2865
+ function onUpdateFn_0() {
2866
+ if (elem && !ranInitFn()) {
2867
+ setRanInitFn(true);
2868
+ findAndRunScripts();
2869
+ }
2870
+ }
2871
+ createEffect(on(() => [elem, ranInitFn()], onUpdateFn_0));
2872
+ return (() => {
2873
+ const _el$ = _tmpl$9();
2874
+ const _ref$ = elem;
2875
+ typeof _ref$ === "function" ? use(_ref$, _el$) : elem = _el$;
2876
+ effect(() => _el$.innerHTML = props.content);
2877
+ return _el$;
2878
+ })();
2879
+ }
2880
+ var embed_default = Embed;
2881
+
2882
+ // src/blocks/form/form/component-info.ts
2883
+ var componentInfo11 = {
2884
+ name: "Form:Form",
2885
+ // editableTags: ['builder-form-error']
2886
+ defaults: {
2887
+ responsiveStyles: {
2888
+ large: {
2889
+ marginTop: "15px",
2890
+ paddingBottom: "15px"
2891
+ }
2892
+ }
2893
+ },
2894
+ image: "https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2Fef36d2a846134910b64b88e6d18c5ca5",
2895
+ inputs: [{
2896
+ name: "sendSubmissionsTo",
2897
+ type: "string",
2898
+ // TODO: save to builder data and user can download as csv
2899
+ // TODO: easy for mode too or computed add/remove fields form mode
2900
+ // so you can edit details and high level mode at same time...
2901
+ // Later - more integrations like mailchimp
2902
+ // /api/v1/form-submit?to=mailchimp
2903
+ enum: [{
2904
+ label: "Send to email",
2905
+ value: "email",
2906
+ helperText: "Send form submissions to the email address of your choosing"
2907
+ }, {
2908
+ label: "Custom",
2909
+ value: "custom",
2910
+ helperText: "Handle where the form requests go manually with a little code, e.g. to your own custom backend"
2911
+ }],
2912
+ defaultValue: "email"
2913
+ }, {
2914
+ name: "sendSubmissionsToEmail",
2915
+ type: "string",
2916
+ required: true,
2917
+ // TODO: required: () => options.get("sendSubmissionsTo") === "email"
2918
+ defaultValue: "your@email.com",
2919
+ showIf: 'options.get("sendSubmissionsTo") === "email"'
2920
+ }, {
2921
+ name: "sendWithJs",
2922
+ type: "boolean",
2923
+ helperText: "Set to false to use basic html form action",
2924
+ defaultValue: true,
2925
+ showIf: 'options.get("sendSubmissionsTo") === "custom"'
2926
+ }, {
2927
+ name: "name",
2928
+ type: "string",
2929
+ defaultValue: "My form"
2930
+ // advanced: true
2931
+ }, {
2932
+ name: "action",
2933
+ type: "string",
2934
+ helperText: "URL to send the form data to",
2935
+ showIf: 'options.get("sendSubmissionsTo") === "custom"'
2936
+ }, {
2937
+ name: "contentType",
2938
+ type: "string",
2939
+ defaultValue: "application/json",
2940
+ advanced: true,
2941
+ // TODO: do automatically if file input
2942
+ enum: ["application/json", "multipart/form-data", "application/x-www-form-urlencoded"],
2943
+ showIf: 'options.get("sendSubmissionsTo") === "custom" && options.get("sendWithJs") === true'
2944
+ }, {
2945
+ name: "method",
2946
+ type: "string",
2947
+ showIf: 'options.get("sendSubmissionsTo") === "custom"',
2948
+ defaultValue: "POST",
2949
+ advanced: true
2950
+ }, {
2951
+ name: "previewState",
2952
+ type: "string",
2953
+ // TODO: persist: false flag
2954
+ enum: ["unsubmitted", "sending", "success", "error"],
2955
+ defaultValue: "unsubmitted",
2956
+ helperText: 'Choose a state to edit, e.g. choose "success" to show what users see on success and edit the message',
2957
+ showIf: 'options.get("sendSubmissionsTo") !== "zapier" && options.get("sendWithJs") === true'
2958
+ }, {
2959
+ name: "successUrl",
2960
+ type: "url",
2961
+ helperText: "Optional URL to redirect the user to on form submission success",
2962
+ showIf: 'options.get("sendSubmissionsTo") !== "zapier" && options.get("sendWithJs") === true'
2963
+ }, {
2964
+ name: "resetFormOnSubmit",
2965
+ type: "boolean",
2966
+ showIf: "options.get('sendSubmissionsTo') === 'custom' && options.get('sendWithJs') === true",
2967
+ advanced: true
2968
+ }, {
2969
+ name: "successMessage",
2970
+ type: "uiBlocks",
2971
+ hideFromUI: true,
2972
+ defaultValue: [{
2973
+ "@type": "@builder.io/sdk:Element",
2974
+ responsiveStyles: {
2975
+ large: {
2976
+ marginTop: "10px"
2977
+ }
2978
+ },
2979
+ component: {
2980
+ name: "Text",
2981
+ options: {
2982
+ text: "<span>Thanks!</span>"
2983
+ }
2984
+ }
2985
+ }]
2986
+ }, {
2987
+ name: "validate",
2988
+ type: "boolean",
2989
+ defaultValue: true,
2990
+ advanced: true
2991
+ }, {
2992
+ name: "errorMessagePath",
2993
+ type: "text",
2994
+ advanced: true,
2995
+ 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" }}'
2996
+ }, {
2997
+ name: "errorMessage",
2998
+ type: "uiBlocks",
2999
+ hideFromUI: true,
3000
+ defaultValue: [{
3001
+ "@type": "@builder.io/sdk:Element",
3002
+ responsiveStyles: {
3003
+ large: {
3004
+ marginTop: "10px"
3005
+ }
3006
+ },
3007
+ bindings: {
3008
+ "component.options.text": "state.formErrorMessage || block.component.options.text"
3009
+ },
3010
+ component: {
3011
+ name: "Text",
3012
+ options: {
3013
+ text: "<span>Form submission error :( Please check your answers and try again</span>"
3014
+ }
3015
+ }
3016
+ }]
3017
+ }, {
3018
+ name: "sendingMessage",
3019
+ type: "uiBlocks",
3020
+ hideFromUI: true,
3021
+ defaultValue: [{
3022
+ "@type": "@builder.io/sdk:Element",
3023
+ responsiveStyles: {
3024
+ large: {
3025
+ marginTop: "10px"
3026
+ }
3027
+ },
3028
+ component: {
3029
+ name: "Text",
3030
+ options: {
3031
+ text: "<span>Sending...</span>"
3032
+ }
3033
+ }
3034
+ }]
3035
+ }, {
3036
+ name: "customHeaders",
3037
+ type: "map",
3038
+ valueType: {
3039
+ type: "string"
3040
+ },
3041
+ advanced: true,
3042
+ showIf: 'options.get("sendSubmissionsTo") === "custom" && options.get("sendWithJs") === true'
3043
+ }],
3044
+ noWrap: true,
3045
+ canHaveChildren: true,
3046
+ defaultChildren: [{
3047
+ "@type": "@builder.io/sdk:Element",
3048
+ responsiveStyles: {
3049
+ large: {
3050
+ marginTop: "10px"
3051
+ }
3052
+ },
3053
+ component: {
3054
+ name: "Text",
3055
+ options: {
3056
+ text: "<span>Enter your name</span>"
3057
+ }
3058
+ }
3059
+ }, {
3060
+ "@type": "@builder.io/sdk:Element",
3061
+ responsiveStyles: {
3062
+ large: {
3063
+ marginTop: "10px"
3064
+ }
3065
+ },
3066
+ component: {
3067
+ name: "Form:Input",
3068
+ options: {
3069
+ name: "name",
3070
+ placeholder: "Jane Doe"
3071
+ }
3072
+ }
3073
+ }, {
3074
+ "@type": "@builder.io/sdk:Element",
3075
+ responsiveStyles: {
3076
+ large: {
3077
+ marginTop: "10px"
3078
+ }
3079
+ },
3080
+ component: {
3081
+ name: "Text",
3082
+ options: {
3083
+ text: "<span>Enter your email</span>"
3084
+ }
3085
+ }
3086
+ }, {
3087
+ "@type": "@builder.io/sdk:Element",
3088
+ responsiveStyles: {
3089
+ large: {
3090
+ marginTop: "10px"
3091
+ }
3092
+ },
3093
+ component: {
3094
+ name: "Form:Input",
3095
+ options: {
3096
+ name: "email",
3097
+ placeholder: "jane@doe.com"
3098
+ }
3099
+ }
3100
+ }, {
3101
+ "@type": "@builder.io/sdk:Element",
3102
+ responsiveStyles: {
3103
+ large: {
3104
+ marginTop: "10px"
3105
+ }
3106
+ },
3107
+ component: {
3108
+ name: "Form:SubmitButton",
3109
+ options: {
3110
+ text: "Submit"
3111
+ }
3112
+ }
3113
+ }]
3114
+ };
3115
+
3116
+ // src/functions/get-env.ts
3117
+ var validEnvList = ["production", "qa", "test", "development", "dev", "cdn-qa", "cloud", "fast", "cdn2", "cdn-prod"];
3118
+ var getEnv = () => {
3119
+ const env = "production";
3120
+ return validEnvList.includes(env) ? env : "production";
3121
+ };
3122
+
3123
+ // src/functions/get.ts
3124
+ var get = (obj, path, defaultValue) => {
3125
+ const result = String.prototype.split.call(path, /[,[\].]+?/).filter(Boolean).reduce((res, key) => res !== null && res !== void 0 ? res[key] : res, obj);
3126
+ return result === void 0 || result === obj ? defaultValue : result;
3127
+ };
3128
+
3129
+ // src/blocks/form/form/form.tsx
3130
+ var _tmpl$10 = /* @__PURE__ */ template(`<pre>`);
3131
+ var _tmpl$23 = /* @__PURE__ */ template(`<form>`);
3132
+ function FormComponent(props) {
3133
+ const [formState, setFormState] = createSignal("unsubmitted");
3134
+ const [responseData, setResponseData] = createSignal(null);
3135
+ const [formErrorMessage, setFormErrorMessage] = createSignal("");
3136
+ function mergeNewRootState(newData) {
3137
+ const combinedState = {
3138
+ ...props.builderContext.rootState,
3139
+ ...newData
3140
+ };
3141
+ if (props.builderContext.rootSetState) {
3142
+ props.builderContext.rootSetState?.(combinedState);
3143
+ } else {
3144
+ props.builderContext.rootState = combinedState;
3145
+ }
3146
+ }
3147
+ function submissionState() {
3148
+ return isEditing() && props.previewState || formState();
3149
+ }
3150
+ function onSubmit(event) {
3151
+ const sendWithJsProp = props.sendWithJs || props.sendSubmissionsTo === "email";
3152
+ if (props.sendSubmissionsTo === "zapier") {
3153
+ event.preventDefault();
3154
+ } else if (sendWithJsProp) {
3155
+ if (!(props.action || props.sendSubmissionsTo === "email")) {
3156
+ event.preventDefault();
3157
+ return;
3158
+ }
3159
+ event.preventDefault();
3160
+ const el = event.currentTarget;
3161
+ const headers = props.customHeaders || {};
3162
+ let body;
3163
+ const formData = new FormData(el);
3164
+ const formPairs = Array.from(event.currentTarget.querySelectorAll("input,select,textarea")).filter((el2) => !!el2.name).map((el2) => {
3165
+ let value;
3166
+ const key = el2.name;
3167
+ if (el2 instanceof HTMLInputElement) {
3168
+ if (el2.type === "radio") {
3169
+ if (el2.checked) {
3170
+ value = el2.name;
3171
+ return {
3172
+ key,
3173
+ value
3174
+ };
3175
+ }
3176
+ } else if (el2.type === "checkbox") {
3177
+ value = el2.checked;
3178
+ } else if (el2.type === "number" || el2.type === "range") {
3179
+ const num = el2.valueAsNumber;
3180
+ if (!isNaN(num)) {
3181
+ value = num;
3182
+ }
3183
+ } else if (el2.type === "file") {
3184
+ value = el2.files;
3185
+ } else {
3186
+ value = el2.value;
3187
+ }
3188
+ } else {
3189
+ value = el2.value;
3190
+ }
3191
+ return {
3192
+ key,
3193
+ value
3194
+ };
3195
+ });
3196
+ let formContentType = props.contentType;
3197
+ if (props.sendSubmissionsTo === "email") {
3198
+ formContentType = "multipart/form-data";
3199
+ }
3200
+ Array.from(formPairs).forEach(({
3201
+ value
3202
+ }) => {
3203
+ if (value instanceof File || Array.isArray(value) && value[0] instanceof File || value instanceof FileList) {
3204
+ formContentType = "multipart/form-data";
3205
+ }
3206
+ });
3207
+ if (formContentType !== "application/json") {
3208
+ body = formData;
3209
+ } else {
3210
+ const json = {};
3211
+ Array.from(formPairs).forEach(({
3212
+ value,
3213
+ key
3214
+ }) => {
3215
+ set(json, key, value);
3216
+ });
3217
+ body = JSON.stringify(json);
3218
+ }
3219
+ if (formContentType && formContentType !== "multipart/form-data") {
3220
+ if (
3221
+ /* Zapier doesn't allow content-type header to be sent from browsers */
3222
+ !(sendWithJsProp && props.action?.includes("zapier.com"))
3223
+ ) {
3224
+ headers["content-type"] = formContentType;
3225
+ }
3226
+ }
3227
+ const presubmitEvent = new CustomEvent("presubmit", {
3228
+ detail: {
3229
+ body
3230
+ }
3231
+ });
3232
+ if (formRef) {
3233
+ formRef.dispatchEvent(presubmitEvent);
3234
+ if (presubmitEvent.defaultPrevented) {
3235
+ return;
3236
+ }
3237
+ }
3238
+ setFormState("sending");
3239
+ const formUrl = `${getEnv() === "dev" ? "http://localhost:5000" : "https://builder.io"}/api/v1/form-submit?apiKey=${props.builderContext.apiKey}&to=${btoa(props.sendSubmissionsToEmail || "")}&name=${encodeURIComponent(props.name || "")}`;
3240
+ fetch(props.sendSubmissionsTo === "email" ? formUrl : props.action, {
3241
+ body,
3242
+ headers,
3243
+ method: props.method || "post"
3244
+ }).then(async (res) => {
3245
+ let body2;
3246
+ const contentType = res.headers.get("content-type");
3247
+ if (contentType && contentType.indexOf("application/json") !== -1) {
3248
+ body2 = await res.json();
3249
+ } else {
3250
+ body2 = await res.text();
3251
+ }
3252
+ if (!res.ok && props.errorMessagePath) {
3253
+ let message = get(body2, props.errorMessagePath);
3254
+ if (message) {
3255
+ if (typeof message !== "string") {
3256
+ message = JSON.stringify(message);
3257
+ }
3258
+ setFormErrorMessage(message);
3259
+ mergeNewRootState({
3260
+ formErrorMessage: message
3261
+ });
3262
+ }
3263
+ }
3264
+ setResponseData(body2);
3265
+ setFormState(res.ok ? "success" : "error");
3266
+ if (res.ok) {
3267
+ const submitSuccessEvent = new CustomEvent("submit:success", {
3268
+ detail: {
3269
+ res,
3270
+ body: body2
3271
+ }
3272
+ });
3273
+ if (formRef) {
3274
+ formRef.dispatchEvent(submitSuccessEvent);
3275
+ if (submitSuccessEvent.defaultPrevented) {
3276
+ return;
3277
+ }
3278
+ if (props.resetFormOnSubmit !== false) {
3279
+ formRef.reset();
3280
+ }
3281
+ }
3282
+ if (props.successUrl) {
3283
+ if (formRef) {
3284
+ const event2 = new CustomEvent("route", {
3285
+ detail: {
3286
+ url: props.successUrl
3287
+ }
3288
+ });
3289
+ formRef.dispatchEvent(event2);
3290
+ if (!event2.defaultPrevented) {
3291
+ location.href = props.successUrl;
3292
+ }
3293
+ } else {
3294
+ location.href = props.successUrl;
3295
+ }
3296
+ }
3297
+ }
3298
+ }, (err) => {
3299
+ const submitErrorEvent = new CustomEvent("submit:error", {
3300
+ detail: {
3301
+ error: err
3302
+ }
3303
+ });
3304
+ if (formRef) {
3305
+ formRef.dispatchEvent(submitErrorEvent);
3306
+ if (submitErrorEvent.defaultPrevented) {
3307
+ return;
3308
+ }
3309
+ }
3310
+ setResponseData(err);
3311
+ setFormState("error");
3312
+ });
3313
+ }
3314
+ }
3315
+ let formRef;
3316
+ return (() => {
3317
+ const _el$ = _tmpl$23();
3318
+ _el$.addEventListener("submit", (event) => onSubmit(event));
3319
+ const _ref$ = formRef;
3320
+ typeof _ref$ === "function" ? use(_ref$, _el$) : formRef = _el$;
3321
+ spread(_el$, mergeProps({
3322
+ get validate() {
3323
+ return props.validate;
3324
+ },
3325
+ get action() {
3326
+ return !props.sendWithJs && props.action;
3327
+ },
3328
+ get method() {
3329
+ return props.method;
3330
+ },
3331
+ get name() {
3332
+ return props.name;
3333
+ }
3334
+ }, {}, () => props.attributes), false, true);
3335
+ insert(_el$, createComponent(Show, {
3336
+ get when() {
3337
+ return props.builderBlock && props.builderBlock.children;
3338
+ },
3339
+ get children() {
3340
+ return createComponent(For, {
3341
+ get each() {
3342
+ return props.builderBlock?.children;
3343
+ },
3344
+ children: (block, _index) => {
3345
+ const idx = _index();
3346
+ return createComponent(block_default, {
3347
+ key: `form-block-${idx}`,
3348
+ block,
3349
+ get context() {
3350
+ return props.builderContext;
3351
+ },
3352
+ get registeredComponents() {
3353
+ return props.builderComponents;
3354
+ },
3355
+ get linkComponent() {
3356
+ return props.builderLinkComponent;
3357
+ }
3358
+ });
3359
+ }
3360
+ });
3361
+ }
3362
+ }), null);
3363
+ insert(_el$, createComponent(Show, {
3364
+ get when() {
3365
+ return submissionState() === "error";
3366
+ },
3367
+ get children() {
3368
+ return createComponent(blocks_default, {
3369
+ path: "errorMessage",
3370
+ get blocks() {
3371
+ return props.errorMessage;
3372
+ },
3373
+ get context() {
3374
+ return props.builderContext;
3375
+ }
3376
+ });
3377
+ }
3378
+ }), null);
3379
+ insert(_el$, createComponent(Show, {
3380
+ get when() {
3381
+ return submissionState() === "sending";
3382
+ },
3383
+ get children() {
3384
+ return createComponent(blocks_default, {
3385
+ path: "sendingMessage",
3386
+ get blocks() {
3387
+ return props.sendingMessage;
3388
+ },
3389
+ get context() {
3390
+ return props.builderContext;
3391
+ }
3392
+ });
3393
+ }
3394
+ }), null);
3395
+ insert(_el$, createComponent(Show, {
3396
+ get when() {
3397
+ return memo(() => submissionState() === "error")() && responseData();
3398
+ },
3399
+ get children() {
3400
+ const _el$2 = _tmpl$10();
3401
+ insert(_el$2, () => JSON.stringify(responseData(), null, 2));
3402
+ effect(() => className(_el$2, "builder-form-error-text " + css({
3403
+ padding: "10px",
3404
+ color: "red",
3405
+ textAlign: "center"
3406
+ })));
3407
+ return _el$2;
3408
+ }
3409
+ }), null);
3410
+ insert(_el$, createComponent(Show, {
3411
+ get when() {
3412
+ return submissionState() === "success";
3413
+ },
3414
+ get children() {
3415
+ return createComponent(blocks_default, {
3416
+ path: "successMessage",
3417
+ get blocks() {
3418
+ return props.successMessage;
3419
+ },
3420
+ get context() {
3421
+ return props.builderContext;
3422
+ }
3423
+ });
3424
+ }
3425
+ }), null);
3426
+ return _el$;
3427
+ })();
3428
+ }
3429
+ var form_default = FormComponent;
3430
+
3431
+ // src/blocks/form/input/component-info.ts
3432
+ var componentInfo12 = {
3433
+ name: "Form:Input",
3434
+ image: "https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2Fad6f37889d9e40bbbbc72cdb5875d6ca",
3435
+ inputs: [
3436
+ {
3437
+ name: "type",
3438
+ type: "text",
3439
+ enum: ["text", "number", "email", "url", "checkbox", "radio", "range", "date", "datetime-local", "search", "tel", "time", "file", "month", "week", "password", "color", "hidden"],
3440
+ defaultValue: "text"
3441
+ },
3442
+ {
3443
+ name: "name",
3444
+ type: "string",
3445
+ required: true,
3446
+ helperText: 'Every input in a form needs a unique name describing what it takes, e.g. "email"'
3447
+ },
3448
+ {
3449
+ name: "placeholder",
3450
+ type: "string",
3451
+ defaultValue: "Hello there",
3452
+ helperText: "Text to display when there is no value"
3453
+ },
3454
+ // TODO: handle value vs default value automatically like ng-model
3455
+ {
3456
+ name: "defaultValue",
3457
+ type: "string"
3458
+ },
3459
+ {
3460
+ name: "value",
3461
+ type: "string",
3462
+ advanced: true
3463
+ },
3464
+ {
3465
+ name: "required",
3466
+ type: "boolean",
3467
+ helperText: "Is this input required to be filled out to submit a form",
3468
+ defaultValue: false
3469
+ }
3470
+ ],
3471
+ noWrap: true,
3472
+ static: true,
3473
+ defaultStyles: {
3474
+ paddingTop: "10px",
3475
+ paddingBottom: "10px",
3476
+ paddingLeft: "10px",
3477
+ paddingRight: "10px",
3478
+ borderRadius: "3px",
3479
+ borderWidth: "1px",
3480
+ borderStyle: "solid",
3481
+ borderColor: "#ccc"
3482
+ }
3483
+ };
3484
+ var _tmpl$11 = /* @__PURE__ */ template(`<input>`);
3485
+ function FormInputComponent(props) {
3486
+ return (() => {
3487
+ const _el$ = _tmpl$11();
3488
+ spread(_el$, mergeProps({}, () => props.attributes, {
3489
+ get key() {
3490
+ return isEditing() && props.defaultValue ? props.defaultValue : "default-key";
3491
+ },
3492
+ get placeholder() {
3493
+ return props.placeholder;
3494
+ },
3495
+ get type() {
3496
+ return props.type;
3497
+ },
3498
+ get name() {
3499
+ return props.name;
3500
+ },
3501
+ get value() {
3502
+ return props.value;
3503
+ },
3504
+ get defaultValue() {
3505
+ return props.defaultValue;
3506
+ },
3507
+ get required() {
3508
+ return props.required;
3509
+ }
3510
+ }), false, false);
3511
+ return _el$;
3512
+ })();
3513
+ }
3514
+ var input_default = FormInputComponent;
3515
+
3516
+ // src/blocks/form/select/component-info.ts
3517
+ var componentInfo13 = {
3518
+ name: "Form:Select",
3519
+ image: "https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2F83acca093fb24aaf94dee136e9a4b045",
3520
+ defaultStyles: {
3521
+ alignSelf: "flex-start"
3522
+ },
3523
+ inputs: [{
3524
+ name: "options",
3525
+ type: "list",
3526
+ required: true,
3527
+ subFields: [{
3528
+ name: "value",
3529
+ type: "text",
3530
+ required: true
3531
+ }, {
3532
+ name: "name",
3533
+ type: "text"
3534
+ }],
3535
+ defaultValue: [{
3536
+ value: "option 1"
3537
+ }, {
3538
+ value: "option 2"
3539
+ }]
3540
+ }, {
3541
+ name: "name",
3542
+ type: "string",
3543
+ required: true,
3544
+ helperText: 'Every select in a form needs a unique name describing what it gets, e.g. "email"'
2712
3545
  }, {
2713
- name: "lazy",
2714
- type: "boolean",
2715
- defaultValue: true,
2716
- hideFromUI: true
3546
+ name: "defaultValue",
3547
+ type: "string"
2717
3548
  }, {
2718
- name: "fitContent",
2719
- type: "boolean",
2720
- helperText: "When child blocks are provided, fit to them instead of using the image's aspect ratio",
2721
- defaultValue: true
3549
+ name: "value",
3550
+ type: "string",
3551
+ advanced: true
2722
3552
  }, {
2723
- name: "aspectRatio",
2724
- type: "number",
2725
- 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",
2726
- advanced: true,
2727
- defaultValue: 0.7041
2728
- }]
3553
+ name: "required",
3554
+ type: "boolean",
3555
+ defaultValue: false
3556
+ }],
3557
+ static: true,
3558
+ noWrap: true
3559
+ };
3560
+ var _tmpl$12 = /* @__PURE__ */ template(`<select>`);
3561
+ var _tmpl$24 = /* @__PURE__ */ template(`<option>`);
3562
+ function SelectComponent(props) {
3563
+ return (() => {
3564
+ const _el$ = _tmpl$12();
3565
+ spread(_el$, mergeProps({}, () => props.attributes, {
3566
+ get value() {
3567
+ return props.value;
3568
+ },
3569
+ get key() {
3570
+ return isEditing() && props.defaultValue ? props.defaultValue : "default-key";
3571
+ },
3572
+ get defaultValue() {
3573
+ return props.defaultValue;
3574
+ },
3575
+ get name() {
3576
+ return props.name;
3577
+ }
3578
+ }), false, true);
3579
+ insert(_el$, createComponent(For, {
3580
+ get each() {
3581
+ return props.options;
3582
+ },
3583
+ children: (option, _index) => {
3584
+ _index();
3585
+ return (() => {
3586
+ const _el$2 = _tmpl$24();
3587
+ insert(_el$2, () => option.name || option.value);
3588
+ effect(() => _el$2.value = option.value);
3589
+ return _el$2;
3590
+ })();
3591
+ }
3592
+ }));
3593
+ return _el$;
3594
+ })();
3595
+ }
3596
+ var select_default = SelectComponent;
3597
+
3598
+ // src/blocks/form/submit-button/component-info.ts
3599
+ var componentInfo14 = {
3600
+ name: "Form:SubmitButton",
3601
+ image: "https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2Fdf2820ffed1f4349a94c40b3221f5b98",
3602
+ defaultStyles: {
3603
+ appearance: "none",
3604
+ paddingTop: "15px",
3605
+ paddingBottom: "15px",
3606
+ paddingLeft: "25px",
3607
+ paddingRight: "25px",
3608
+ backgroundColor: "#3898EC",
3609
+ color: "white",
3610
+ borderRadius: "4px",
3611
+ cursor: "pointer"
3612
+ },
3613
+ inputs: [{
3614
+ name: "text",
3615
+ type: "text",
3616
+ defaultValue: "Click me"
3617
+ }],
3618
+ static: true,
3619
+ noWrap: true
3620
+ // TODO: optional children? maybe as optional form input
3621
+ // that only shows if advanced setting is flipped
3622
+ // TODO: defaultChildren
3623
+ // canHaveChildren: true,
2729
3624
  };
3625
+ var _tmpl$13 = /* @__PURE__ */ template(`<button type=submit>`);
3626
+ function SubmitButton(props) {
3627
+ return (() => {
3628
+ const _el$ = _tmpl$13();
3629
+ spread(_el$, mergeProps({}, () => props.attributes), false, true);
3630
+ insert(_el$, () => props.text);
3631
+ return _el$;
3632
+ })();
3633
+ }
3634
+ var submit_button_default = SubmitButton;
2730
3635
 
2731
3636
  // src/blocks/img/component-info.ts
2732
- var componentInfo7 = {
3637
+ var componentInfo15 = {
2733
3638
  // friendlyName?
2734
3639
  name: "Raw:Img",
2735
3640
  hideFromInsertMenu: true,
@@ -2744,10 +3649,10 @@ var componentInfo7 = {
2744
3649
  noWrap: true,
2745
3650
  static: true
2746
3651
  };
2747
- var _tmpl$8 = /* @__PURE__ */ template(`<img>`);
3652
+ var _tmpl$14 = /* @__PURE__ */ template(`<img>`);
2748
3653
  function ImgComponent(props) {
2749
3654
  return (() => {
2750
- const _el$ = _tmpl$8();
3655
+ const _el$ = _tmpl$14();
2751
3656
  spread(_el$, mergeProps({
2752
3657
  get style() {
2753
3658
  return {
@@ -2770,159 +3675,8 @@ function ImgComponent(props) {
2770
3675
  }
2771
3676
  var img_default = ImgComponent;
2772
3677
 
2773
- // src/blocks/section/component-info.ts
2774
- var componentInfo8 = {
2775
- name: "Core:Section",
2776
- static: true,
2777
- image: "https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2F682efef23ace49afac61748dd305c70a",
2778
- inputs: [{
2779
- name: "maxWidth",
2780
- type: "number",
2781
- defaultValue: 1200
2782
- }, {
2783
- name: "lazyLoad",
2784
- type: "boolean",
2785
- defaultValue: false,
2786
- advanced: true,
2787
- description: "Only render this section when in view"
2788
- }],
2789
- defaultStyles: {
2790
- paddingLeft: "20px",
2791
- paddingRight: "20px",
2792
- paddingTop: "50px",
2793
- paddingBottom: "50px",
2794
- marginTop: "0px",
2795
- width: "100vw",
2796
- marginLeft: "calc(50% - 50vw)"
2797
- },
2798
- canHaveChildren: true,
2799
- defaultChildren: [{
2800
- "@type": "@builder.io/sdk:Element",
2801
- responsiveStyles: {
2802
- large: {
2803
- textAlign: "center"
2804
- }
2805
- },
2806
- component: {
2807
- name: "Text",
2808
- options: {
2809
- text: "<p><b>I am a section! My content keeps from getting too wide, so that it's easy to read even on big screens.</b></p><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur</p>"
2810
- }
2811
- }
2812
- }]
2813
- };
2814
-
2815
- // src/blocks/slot/component-info.ts
2816
- var componentInfo9 = {
2817
- name: "Slot",
2818
- isRSC: true,
2819
- description: "Allow child blocks to be inserted into this content when used as a Symbol",
2820
- docsLink: "https://www.builder.io/c/docs/symbols-with-blocks",
2821
- image: "https://cdn.builder.io/api/v1/image/assets%2FYJIGb4i01jvw0SRdL5Bt%2F3aad6de36eae43b59b52c85190fdef56",
2822
- // Maybe wrap this for canHaveChildren so bind children to this hm
2823
- inputs: [{
2824
- name: "name",
2825
- type: "string",
2826
- required: true,
2827
- defaultValue: "children"
2828
- }]
2829
- };
2830
- var _tmpl$9 = /* @__PURE__ */ template(`<div>`);
2831
- function Slot(props) {
2832
- return (() => {
2833
- const _el$ = _tmpl$9();
2834
- _el$.style.setProperty("pointer-events", "auto");
2835
- spread(_el$, mergeProps(() => !props.builderContext.context?.symbolId && {
2836
- "builder-slot": props.name
2837
- }), false, true);
2838
- insert(_el$, createComponent(blocks_default, {
2839
- get parent() {
2840
- return props.builderContext.context?.symbolId;
2841
- },
2842
- get path() {
2843
- return `symbol.data.${props.name}`;
2844
- },
2845
- get context() {
2846
- return props.builderContext;
2847
- },
2848
- get blocks() {
2849
- return props.builderContext.rootState?.[props.name];
2850
- }
2851
- }));
2852
- return _el$;
2853
- })();
2854
- }
2855
- var slot_default = Slot;
2856
-
2857
- // src/blocks/symbol/component-info.ts
2858
- var componentInfo10 = {
2859
- name: "Symbol",
2860
- noWrap: true,
2861
- static: true,
2862
- isRSC: true,
2863
- inputs: [{
2864
- name: "symbol",
2865
- type: "uiSymbol"
2866
- }, {
2867
- name: "dataOnly",
2868
- helperText: "Make this a data symbol that doesn't display any UI",
2869
- type: "boolean",
2870
- defaultValue: false,
2871
- advanced: true,
2872
- hideFromUI: true
2873
- }, {
2874
- name: "inheritState",
2875
- helperText: "Inherit the parent component state and data",
2876
- type: "boolean",
2877
- defaultValue: false,
2878
- advanced: true
2879
- }, {
2880
- name: "renderToLiquid",
2881
- helperText: "Render this symbols contents to liquid. Turn off to fetch with javascript and use custom targeting",
2882
- type: "boolean",
2883
- defaultValue: false,
2884
- advanced: true,
2885
- hideFromUI: true
2886
- }, {
2887
- name: "useChildren",
2888
- hideFromUI: true,
2889
- type: "boolean"
2890
- }]
2891
- };
2892
-
2893
- // src/blocks/text/component-info.ts
2894
- var componentInfo11 = {
2895
- name: "Text",
2896
- static: true,
2897
- isRSC: true,
2898
- image: "https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-text_fields-24px%20(1).svg?alt=media&token=12177b73-0ee3-42ca-98c6-0dd003de1929",
2899
- inputs: [{
2900
- name: "text",
2901
- type: "html",
2902
- required: true,
2903
- autoFocus: true,
2904
- bubble: true,
2905
- defaultValue: "Enter some text..."
2906
- }],
2907
- defaultStyles: {
2908
- lineHeight: "normal",
2909
- height: "auto",
2910
- textAlign: "center"
2911
- }
2912
- };
2913
- var _tmpl$10 = /* @__PURE__ */ template(`<div class=builder-text>`);
2914
- function Text(props) {
2915
- return (() => {
2916
- const _el$ = _tmpl$10();
2917
- _el$.style.setProperty("outline", "none");
2918
- effect(() => _el$.innerHTML = props.text?.toString() || "");
2919
- return _el$;
2920
- })();
2921
- }
2922
- var text_default = Text;
2923
-
2924
3678
  // src/blocks/video/component-info.ts
2925
- var componentInfo12 = {
3679
+ var componentInfo16 = {
2926
3680
  name: "Video",
2927
3681
  canHaveChildren: true,
2928
3682
  defaultStyles: {
@@ -3004,8 +3758,8 @@ var componentInfo12 = {
3004
3758
  advanced: true
3005
3759
  }]
3006
3760
  };
3007
- var _tmpl$11 = /* @__PURE__ */ template(`<source type=video/mp4>`);
3008
- var _tmpl$23 = /* @__PURE__ */ template(`<div>`);
3761
+ var _tmpl$15 = /* @__PURE__ */ template(`<source type=video/mp4>`);
3762
+ var _tmpl$25 = /* @__PURE__ */ template(`<div>`);
3009
3763
  var _tmpl$33 = /* @__PURE__ */ template(`<div><video class=builder-video>`);
3010
3764
  function Video(props) {
3011
3765
  function videoProps() {
@@ -3067,7 +3821,7 @@ function Video(props) {
3067
3821
  return !props.lazyLoad;
3068
3822
  },
3069
3823
  get children() {
3070
- const _el$3 = _tmpl$11();
3824
+ const _el$3 = _tmpl$15();
3071
3825
  effect(() => setAttribute(_el$3, "src", props.video));
3072
3826
  return _el$3;
3073
3827
  }
@@ -3077,7 +3831,7 @@ function Video(props) {
3077
3831
  return props.aspectRatio && !(props.fitContent && props.builderBlock?.children?.length);
3078
3832
  },
3079
3833
  get children() {
3080
- const _el$4 = _tmpl$23();
3834
+ const _el$4 = _tmpl$25();
3081
3835
  _el$4.style.setProperty("width", "100%");
3082
3836
  _el$4.style.setProperty("pointer-events", "none");
3083
3837
  _el$4.style.setProperty("font-size", "0px");
@@ -3090,7 +3844,7 @@ function Video(props) {
3090
3844
  return props.builderBlock?.children?.length && props.fitContent;
3091
3845
  },
3092
3846
  get children() {
3093
- const _el$5 = _tmpl$23();
3847
+ const _el$5 = _tmpl$25();
3094
3848
  _el$5.style.setProperty("display", "flex");
3095
3849
  _el$5.style.setProperty("flex-direction", "column");
3096
3850
  _el$5.style.setProperty("align-items", "stretch");
@@ -3103,7 +3857,7 @@ function Video(props) {
3103
3857
  return props.builderBlock?.children?.length && !props.fitContent;
3104
3858
  },
3105
3859
  get children() {
3106
- const _el$6 = _tmpl$23();
3860
+ const _el$6 = _tmpl$25();
3107
3861
  _el$6.style.setProperty("pointer-events", "none");
3108
3862
  _el$6.style.setProperty("display", "flex");
3109
3863
  _el$6.style.setProperty("flex-direction", "column");
@@ -3122,6 +3876,33 @@ function Video(props) {
3122
3876
  }
3123
3877
  var video_default = Video;
3124
3878
 
3879
+ // src/constants/extra-components.ts
3880
+ var getExtraComponents = () => [{
3881
+ component: custom_code_default,
3882
+ ...componentInfo9
3883
+ }, {
3884
+ component: embed_default,
3885
+ ...componentInfo10
3886
+ }, ...TARGET === "rsc" ? [] : [{
3887
+ component: form_default,
3888
+ ...componentInfo11
3889
+ }, {
3890
+ component: input_default,
3891
+ ...componentInfo12
3892
+ }, {
3893
+ component: submit_button_default,
3894
+ ...componentInfo14
3895
+ }, {
3896
+ component: select_default,
3897
+ ...componentInfo13
3898
+ }], {
3899
+ component: img_default,
3900
+ ...componentInfo15
3901
+ }, {
3902
+ component: video_default,
3903
+ ...componentInfo16
3904
+ }];
3905
+
3125
3906
  // src/constants/builder-registered-components.ts
3126
3907
  var getDefaultRegisteredComponents = () => [{
3127
3908
  component: button_default,
@@ -3130,36 +3911,24 @@ var getDefaultRegisteredComponents = () => [{
3130
3911
  component: columns_default,
3131
3912
  ...componentInfo2
3132
3913
  }, {
3133
- component: custom_code_default,
3914
+ component: fragment_default,
3134
3915
  ...componentInfo3
3135
3916
  }, {
3136
- component: embed_default,
3917
+ component: image_default,
3137
3918
  ...componentInfo4
3138
3919
  }, {
3139
- component: fragment_default,
3920
+ component: section_default,
3140
3921
  ...componentInfo5
3141
3922
  }, {
3142
- component: image_default,
3923
+ component: slot_default,
3143
3924
  ...componentInfo6
3144
- }, {
3145
- component: img_default,
3146
- ...componentInfo7
3147
- }, {
3148
- component: section_default,
3149
- ...componentInfo8
3150
3925
  }, {
3151
3926
  component: symbol_default,
3152
- ...componentInfo10
3927
+ ...componentInfo7
3153
3928
  }, {
3154
3929
  component: text_default,
3155
- ...componentInfo11
3156
- }, {
3157
- component: video_default,
3158
- ...componentInfo12
3159
- }, {
3160
- component: slot_default,
3161
- ...componentInfo9
3162
- }];
3930
+ ...componentInfo8
3931
+ }, ...getExtraComponents()];
3163
3932
 
3164
3933
  // src/functions/register-component.ts
3165
3934
  var components = [];
@@ -3229,10 +3998,10 @@ var getUpdateVariantVisibilityScript = ({
3229
3998
  }) => `window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME}(
3230
3999
  "${variationId}", "${contentId}", ${isHydrationTarget}
3231
4000
  )`;
3232
- var _tmpl$12 = /* @__PURE__ */ template(`<script>`);
4001
+ var _tmpl$16 = /* @__PURE__ */ template(`<script>`);
3233
4002
  function InlinedScript(props) {
3234
4003
  return (() => {
3235
- const _el$ = _tmpl$12();
4004
+ const _el$ = _tmpl$16();
3236
4005
  effect((_p$) => {
3237
4006
  const _v$ = props.scriptStr, _v$2 = props.id || "";
3238
4007
  _v$ !== _p$._v$ && (_el$.innerHTML = _p$._v$ = _v$);
@@ -3734,7 +4503,7 @@ function isFromTrustedHost(trustedHosts, e) {
3734
4503
  }
3735
4504
 
3736
4505
  // src/constants/sdk-version.ts
3737
- var SDK_VERSION = "0.13.1";
4506
+ var SDK_VERSION = "0.13.3";
3738
4507
 
3739
4508
  // src/functions/register.ts
3740
4509
  var registry = {};
@@ -4735,7 +5504,7 @@ var fetchSymbolContent = async ({
4735
5504
  };
4736
5505
 
4737
5506
  // src/blocks/symbol/symbol.tsx
4738
- var _tmpl$13 = /* @__PURE__ */ template(`<div>`);
5507
+ var _tmpl$17 = /* @__PURE__ */ template(`<div>`);
4739
5508
  function Symbol(props) {
4740
5509
  const [contentToUse, setContentToUse] = createSignal(props.symbol?.content);
4741
5510
  function className() {
@@ -4761,7 +5530,7 @@ function Symbol(props) {
4761
5530
  }
4762
5531
  createEffect(on(() => [props.symbol], onUpdateFn_0));
4763
5532
  return (() => {
4764
- const _el$ = _tmpl$13();
5533
+ const _el$ = _tmpl$17();
4765
5534
  spread(_el$, mergeProps({
4766
5535
  get ["class"]() {
4767
5536
  return className();