@builder.io/sdk-svelte 0.0.4 → 0.0.6

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 (123) hide show
  1. package/package/--package.json +3 -2
  2. package/package/components/render-content/render-content.svelte +13 -7
  3. package/package/functions/track.d.ts +35 -5
  4. package/package/functions/track.js +5 -4
  5. package/package/index.d.ts +1 -0
  6. package/package/index.js +1 -0
  7. package/package.json +3 -2
  8. package/src/blocks/BaseText.svelte +27 -0
  9. package/src/blocks/button/button.svelte +36 -0
  10. package/src/blocks/button/component-info.ts +42 -0
  11. package/src/blocks/columns/columns.svelte +148 -0
  12. package/src/blocks/columns/component-info.ts +254 -0
  13. package/src/blocks/custom-code/component-info.ts +31 -0
  14. package/src/blocks/custom-code/custom-code.svelte +66 -0
  15. package/src/blocks/embed/component-info.ts +53 -0
  16. package/src/blocks/embed/embed.svelte +51 -0
  17. package/src/blocks/embed/helpers.ts +8 -0
  18. package/src/blocks/form/component-info.ts +282 -0
  19. package/src/blocks/form/form.svelte +332 -0
  20. package/src/blocks/fragment/component-info.ts +10 -0
  21. package/src/blocks/fragment/fragment.svelte +12 -0
  22. package/src/blocks/image/component-info.ts +170 -0
  23. package/src/blocks/image/image.helpers.ts +75 -0
  24. package/src/blocks/image/image.svelte +145 -0
  25. package/src/blocks/img/component-info.ts +21 -0
  26. package/src/blocks/img/img.svelte +51 -0
  27. package/src/blocks/input/component-info.ts +78 -0
  28. package/src/blocks/input/input.svelte +34 -0
  29. package/src/blocks/raw-text/component-info.ts +15 -0
  30. package/src/blocks/raw-text/raw-text.svelte +16 -0
  31. package/src/blocks/section/component-info.ts +50 -0
  32. package/src/blocks/section/section.svelte +34 -0
  33. package/src/blocks/select/component-info.ts +61 -0
  34. package/src/blocks/select/select.svelte +34 -0
  35. package/src/blocks/submit-button/component-info.ts +32 -0
  36. package/src/blocks/submit-button/submit-button.svelte +15 -0
  37. package/src/blocks/symbol/component-info.ts +43 -0
  38. package/src/blocks/symbol/symbol.svelte +100 -0
  39. package/src/blocks/text/component-info.ts +24 -0
  40. package/src/blocks/text/text.svelte +11 -0
  41. package/src/blocks/textarea/component-info.ts +48 -0
  42. package/src/blocks/textarea/textarea.svelte +19 -0
  43. package/src/blocks/util.ts +6 -0
  44. package/src/blocks/video/component-info.ts +109 -0
  45. package/src/blocks/video/video.svelte +102 -0
  46. package/src/components/render-block/block-styles.svelte +62 -0
  47. package/src/components/render-block/render-block.helpers.ts +27 -0
  48. package/src/components/render-block/render-block.svelte +228 -0
  49. package/src/components/render-block/render-component-with-context.svelte +38 -0
  50. package/src/components/render-block/render-component.svelte +35 -0
  51. package/src/components/render-block/render-repeated-block.svelte +53 -0
  52. package/src/components/render-block/types.ts +7 -0
  53. package/src/components/render-blocks.svelte +104 -0
  54. package/src/components/render-content/components/render-styles.svelte +80 -0
  55. package/src/components/render-content/index.ts +1 -0
  56. package/src/components/render-content/render-content.svelte +360 -0
  57. package/src/components/render-inlined-styles.svelte +26 -0
  58. package/src/constants/builder-registered-components.ts +42 -0
  59. package/src/constants/device-sizes.ts +28 -0
  60. package/src/constants/target.ts +2 -0
  61. package/src/context/builder.context.ts +13 -0
  62. package/src/context/types.ts +23 -0
  63. package/src/functions/camel-to-kebab-case.ts +2 -0
  64. package/src/functions/evaluate.ts +52 -0
  65. package/src/functions/event-handler-name.ts +6 -0
  66. package/src/functions/extract-text-styles.ts +39 -0
  67. package/src/functions/fast-clone.ts +5 -0
  68. package/src/functions/get-block-actions-handler.ts +19 -0
  69. package/src/functions/get-block-actions.ts +25 -0
  70. package/src/functions/get-block-component-options.ts +12 -0
  71. package/src/functions/get-block-properties.ts +11 -0
  72. package/src/functions/get-block-tag.ts +7 -0
  73. package/src/functions/get-builder-search-params/fn.test.ts +19 -0
  74. package/src/functions/get-builder-search-params/index.ts +48 -0
  75. package/src/functions/get-content/ab-testing.ts +132 -0
  76. package/src/functions/get-content/fn.test.ts +35 -0
  77. package/src/functions/get-content/index.ts +77 -0
  78. package/src/functions/get-content/types.ts +36 -0
  79. package/src/functions/get-fetch.ts +14 -0
  80. package/src/functions/get-global-this.ts +15 -0
  81. package/src/functions/get-processed-block.test.ts +33 -0
  82. package/src/functions/get-processed-block.ts +54 -0
  83. package/src/functions/get-react-native-block-styles.ts +30 -0
  84. package/src/functions/if-target.ts +20 -0
  85. package/src/functions/is-browser.ts +3 -0
  86. package/src/functions/is-editing.ts +7 -0
  87. package/src/functions/is-iframe.ts +5 -0
  88. package/src/functions/is-previewing.ts +14 -0
  89. package/src/functions/mark-mutable.ts +7 -0
  90. package/src/functions/on-change.test.ts +23 -0
  91. package/src/functions/on-change.ts +29 -0
  92. package/src/functions/register-component.ts +67 -0
  93. package/src/functions/register.ts +46 -0
  94. package/src/functions/sanitize-react-native-block-styles.ts +65 -0
  95. package/src/functions/set-editor-settings.ts +16 -0
  96. package/src/functions/set.test.ts +19 -0
  97. package/src/functions/set.ts +26 -0
  98. package/src/functions/track.ts +124 -0
  99. package/src/functions/transform-block.ts +6 -0
  100. package/src/helpers/ab-tests.ts +22 -0
  101. package/src/helpers/cookie.ts +102 -0
  102. package/src/helpers/css.ts +33 -0
  103. package/src/helpers/flatten.ts +24 -0
  104. package/src/helpers/localStorage.ts +38 -0
  105. package/src/helpers/nullable.ts +4 -0
  106. package/src/helpers/sessionId.ts +34 -0
  107. package/src/helpers/time.ts +4 -0
  108. package/src/helpers/url.test.ts +16 -0
  109. package/src/helpers/url.ts +12 -0
  110. package/src/helpers/uuid.ts +17 -0
  111. package/src/helpers/visitorId.ts +38 -0
  112. package/src/index-helpers/blocks-exports.ts +10 -0
  113. package/src/index-helpers/top-of-file.ts +4 -0
  114. package/src/index.ts +13 -0
  115. package/src/scripts/init-editing.ts +102 -0
  116. package/src/types/builder-block.ts +58 -0
  117. package/src/types/builder-content.ts +39 -0
  118. package/src/types/can-track.ts +3 -0
  119. package/src/types/components.ts +188 -0
  120. package/src/types/deep-partial.ts +7 -0
  121. package/src/types/element.ts +60 -0
  122. package/src/types/targets.ts +6 -0
  123. package/src/types/typescript.ts +7 -0
@@ -0,0 +1,145 @@
1
+ <script context="module" lang="ts">
2
+ import type { BuilderBlock } from "../../types/builder-block.js";
3
+
4
+ export interface ImageProps {
5
+ className?: string;
6
+ image: string;
7
+ sizes?: string;
8
+ lazy?: boolean;
9
+ height?: number;
10
+ width?: number;
11
+ altText?: string;
12
+ backgroundSize?: string;
13
+ backgroundPosition?: string;
14
+ srcset?: string;
15
+ aspectRatio?: number;
16
+ children?: JSX.Element;
17
+ fitContent?: boolean;
18
+ builderBlock?: BuilderBlock;
19
+ noWebp?: boolean;
20
+ src?: string;
21
+ }
22
+ </script>
23
+
24
+ <script lang="ts">
25
+ import { getSrcSet } from "./image.helpers.js";
26
+
27
+ export let image: ImageProps["image"];
28
+ export let src: ImageProps["src"];
29
+ export let srcset: ImageProps["srcset"];
30
+ export let noWebp: ImageProps["noWebp"];
31
+ export let altText: ImageProps["altText"];
32
+ export let backgroundSize: ImageProps["backgroundSize"];
33
+ export let className: ImageProps["className"];
34
+ export let sizes: ImageProps["sizes"];
35
+ export let aspectRatio: ImageProps["aspectRatio"];
36
+ export let builderBlock: ImageProps["builderBlock"];
37
+ export let fitContent: ImageProps["fitContent"];
38
+
39
+ function mitosis_styling(node, vars) {
40
+ Object.entries(vars || {}).forEach(([p, v]) => {
41
+ if (p.startsWith("--")) {
42
+ node.style.setProperty(p, v);
43
+ } else {
44
+ node.style[p] = v;
45
+ }
46
+ });
47
+ }
48
+
49
+ $: srcSetToUse = () => {
50
+ const imageToUse = image || src;
51
+ const url = imageToUse;
52
+ if (
53
+ !url ||
54
+ // We can auto add srcset for cdn.builder.io and shopify
55
+ // images, otherwise you can supply this prop manually
56
+ !(url.match(/builder\.io/) || url.match(/cdn\.shopify\.com/))
57
+ ) {
58
+ return srcset;
59
+ }
60
+ if (srcset && image?.includes("builder.io/api/v1/image")) {
61
+ if (!srcset.includes(image.split("?")[0])) {
62
+ console.debug("Removed given srcset");
63
+ return getSrcSet(url);
64
+ }
65
+ } else if (image && !srcset) {
66
+ return getSrcSet(url);
67
+ }
68
+ return getSrcSet(url);
69
+ };
70
+ $: webpSrcSet = () => {
71
+ if (srcSetToUse?.()?.match(/builder\.io/) && !noWebp) {
72
+ return srcSetToUse().replace(/\?/g, "?format=webp&");
73
+ } else {
74
+ return "";
75
+ }
76
+ };
77
+ </script>
78
+
79
+ <picture>
80
+ {#if webpSrcSet()}
81
+ <source type="image/webp" srcset={webpSrcSet()} />
82
+ {/if}
83
+ <img
84
+ use:mitosis_styling={{
85
+ objectPosition: backgroundSize || "center",
86
+ objectFit: backgroundSize || "cover",
87
+ }}
88
+ loading="lazy"
89
+ alt={altText}
90
+ role={altText ? "presentation" : undefined}
91
+ class={"builder-image" + (className ? " " + className : "") + " img"}
92
+ src={image}
93
+ srcset={srcSetToUse()}
94
+ {sizes}
95
+ />
96
+ <source srcset={srcSetToUse()} />
97
+ </picture>
98
+
99
+ {#if aspectRatio && !(builderBlock?.children?.length && fitContent)}
100
+ <div
101
+ use:mitosis_styling={{
102
+ paddingTop:
103
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
104
+ aspectRatio * 100 + "%",
105
+ }}
106
+ class="builder-image-sizer div"
107
+ />
108
+ {/if}
109
+
110
+ {#if builderBlock?.children?.length && fitContent}
111
+ <slot />
112
+ {/if}
113
+
114
+ {#if !fitContent && $$slots.default}
115
+ <div class="div-2">
116
+ <slot />
117
+ </div>
118
+ {/if}
119
+
120
+ <style>
121
+ .img {
122
+ opacity: 1;
123
+ transition: opacity 0.2s ease-in-out;
124
+ position: absolute;
125
+ height: 100%;
126
+ width: 100%;
127
+ top: 0px;
128
+ left: 0px;
129
+ }
130
+ .div {
131
+ width: 100%;
132
+ pointer-events: none;
133
+ font-size: 0;
134
+ }
135
+ .div-2 {
136
+ display: flex;
137
+ flex-direction: column;
138
+ align-items: stretch;
139
+ position: absolute;
140
+ top: 0;
141
+ left: 0;
142
+ width: 100%;
143
+ height: 100%;
144
+ }
145
+ </style>
@@ -0,0 +1,21 @@
1
+ import type { ComponentInfo } from '../../types/components';
2
+
3
+ export const componentInfo: ComponentInfo = {
4
+ // friendlyName?
5
+ name: 'Raw:Img',
6
+ hideFromInsertMenu: true,
7
+ builtIn: true,
8
+ image:
9
+ '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',
10
+ inputs: [
11
+ {
12
+ name: 'image',
13
+ bubble: true,
14
+ type: 'file',
15
+ allowedFileTypes: ['jpeg', 'jpg', 'png', 'svg'],
16
+ required: true,
17
+ },
18
+ ],
19
+ noWrap: true,
20
+ static: true,
21
+ };
@@ -0,0 +1,51 @@
1
+ <script context="module" lang="ts">
2
+ export interface ImgProps {
3
+ attributes?: any;
4
+ imgSrc?: string; // TODO(misko): I think this is unused
5
+ image?: string;
6
+ altText?: string;
7
+ backgroundSize?: "cover" | "contain";
8
+ backgroundPosition?:
9
+ | "center"
10
+ | "top"
11
+ | "left"
12
+ | "right"
13
+ | "bottom"
14
+ | "top left"
15
+ | "top right"
16
+ | "bottom left"
17
+ | "bottom right";
18
+ }
19
+ </script>
20
+
21
+ <script lang="ts">
22
+ import { isEditing } from "../../functions/is-editing.js";
23
+
24
+ export let backgroundSize: ImgProps["backgroundSize"];
25
+ export let backgroundPosition: ImgProps["backgroundPosition"];
26
+ export let imgSrc: ImgProps["imgSrc"];
27
+ export let altText: ImgProps["altText"];
28
+ export let image: ImgProps["image"];
29
+ export let attributes: ImgProps["attributes"];
30
+
31
+ function mitosis_styling(node, vars) {
32
+ Object.entries(vars || {}).forEach(([p, v]) => {
33
+ if (p.startsWith("--")) {
34
+ node.style.setProperty(p, v);
35
+ } else {
36
+ node.style[p] = v;
37
+ }
38
+ });
39
+ }
40
+ </script>
41
+
42
+ <img
43
+ {...attributes}
44
+ use:mitosis_styling={{
45
+ objectFit: backgroundSize || "cover",
46
+ objectPosition: backgroundPosition || "center",
47
+ }}
48
+ key={(isEditing() && imgSrc) || "default-key"}
49
+ alt={altText}
50
+ src={imgSrc || image}
51
+ />
@@ -0,0 +1,78 @@
1
+ import type { ComponentInfo } from '../../types/components';
2
+
3
+ export const componentInfo: ComponentInfo = {
4
+ name: 'Form:Input',
5
+ builtIn: true,
6
+ image:
7
+ 'https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2Fad6f37889d9e40bbbbc72cdb5875d6ca',
8
+ inputs: [
9
+ {
10
+ name: 'type',
11
+ type: 'text',
12
+ enum: [
13
+ 'text',
14
+ 'number',
15
+ 'email',
16
+ 'url',
17
+ 'checkbox',
18
+ 'radio',
19
+ 'range',
20
+ 'date',
21
+ 'datetime-local',
22
+ 'search',
23
+ 'tel',
24
+ 'time',
25
+ 'file',
26
+ 'month',
27
+ 'week',
28
+ 'password',
29
+ 'color',
30
+ 'hidden',
31
+ ],
32
+ defaultValue: 'text',
33
+ },
34
+ {
35
+ name: 'name',
36
+ type: 'string',
37
+ required: true,
38
+ helperText:
39
+ 'Every input in a form needs a unique name describing what it takes, e.g. "email"',
40
+ },
41
+ {
42
+ name: 'placeholder',
43
+ type: 'string',
44
+ defaultValue: 'Hello there',
45
+ helperText: 'Text to display when there is no value',
46
+ },
47
+ // TODO: handle value vs default value automatically like ng-model
48
+ {
49
+ name: 'defaultValue',
50
+ type: 'string',
51
+ },
52
+ {
53
+ name: 'value',
54
+ type: 'string',
55
+ advanced: true,
56
+ },
57
+
58
+ {
59
+ name: 'required',
60
+ type: 'boolean',
61
+ helperText: 'Is this input required to be filled out to submit a form',
62
+ defaultValue: false,
63
+ },
64
+ ],
65
+
66
+ noWrap: true,
67
+ static: true,
68
+ defaultStyles: {
69
+ paddingTop: '10px',
70
+ paddingBottom: '10px',
71
+ paddingLeft: '10px',
72
+ paddingRight: '10px',
73
+ borderRadius: '3px',
74
+ borderWidth: '1px',
75
+ borderStyle: 'solid',
76
+ borderColor: '#ccc',
77
+ },
78
+ };
@@ -0,0 +1,34 @@
1
+ <script context="module" lang="ts">
2
+ export interface FormInputProps {
3
+ type?: string;
4
+ attributes?: any;
5
+ name?: string;
6
+ value?: string;
7
+ placeholder?: string;
8
+ defaultValue?: string;
9
+ required?: boolean;
10
+ }
11
+ </script>
12
+
13
+ <script lang="ts">
14
+ import { isEditing } from "../../functions/is-editing.js";
15
+
16
+ export let attributes: FormInputProps["attributes"];
17
+ export let defaultValue: FormInputProps["defaultValue"];
18
+ export let placeholder: FormInputProps["placeholder"];
19
+ export let type: FormInputProps["type"];
20
+ export let name: FormInputProps["name"];
21
+ export let value: FormInputProps["value"];
22
+ export let required: FormInputProps["required"];
23
+ </script>
24
+
25
+ <input
26
+ {...attributes}
27
+ key={isEditing() && defaultValue ? defaultValue : "default-key"}
28
+ {placeholder}
29
+ {type}
30
+ {name}
31
+ {value}
32
+ {defaultValue}
33
+ {required}
34
+ />
@@ -0,0 +1,15 @@
1
+ import type { ComponentInfo } from '../../types/components';
2
+
3
+ export const componentInfo: ComponentInfo = {
4
+ name: 'Builder:RawText',
5
+ hideFromInsertMenu: true,
6
+ builtIn: true,
7
+ inputs: [
8
+ {
9
+ name: 'text',
10
+ bubble: true,
11
+ type: 'longText',
12
+ required: true,
13
+ },
14
+ ],
15
+ };
@@ -0,0 +1,16 @@
1
+ <script context="module" lang="ts">
2
+ export interface RawTextProps {
3
+ attributes?: any;
4
+ text?: string;
5
+ // builderBlock?: any;
6
+ }
7
+ </script>
8
+
9
+ <script lang="ts">
10
+ export let attributes: RawTextProps["attributes"];
11
+ export let text: RawTextProps["text"];
12
+ </script>
13
+
14
+ <span class={attributes?.class || attributes?.className}
15
+ >{@html text || ""}</span
16
+ >
@@ -0,0 +1,50 @@
1
+ import type { ComponentInfo } from '../../types/components';
2
+
3
+ export const componentInfo: ComponentInfo = {
4
+ name: 'Core:Section',
5
+ static: true,
6
+ builtIn: true,
7
+ image:
8
+ 'https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2F682efef23ace49afac61748dd305c70a',
9
+ inputs: [
10
+ {
11
+ name: 'maxWidth',
12
+ type: 'number',
13
+ defaultValue: 1200,
14
+ },
15
+ {
16
+ name: 'lazyLoad',
17
+ type: 'boolean',
18
+ defaultValue: false,
19
+ advanced: true,
20
+ description: 'Only render this section when in view',
21
+ },
22
+ ],
23
+ defaultStyles: {
24
+ paddingLeft: '20px',
25
+ paddingRight: '20px',
26
+ paddingTop: '50px',
27
+ paddingBottom: '50px',
28
+ marginTop: '0px',
29
+ width: '100vw',
30
+ marginLeft: 'calc(50% - 50vw)',
31
+ },
32
+ canHaveChildren: true,
33
+
34
+ defaultChildren: [
35
+ {
36
+ '@type': '@builder.io/sdk:Element',
37
+ responsiveStyles: {
38
+ large: {
39
+ textAlign: 'center',
40
+ },
41
+ },
42
+ component: {
43
+ name: 'Text',
44
+ options: {
45
+ 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>",
46
+ },
47
+ },
48
+ },
49
+ ],
50
+ };
@@ -0,0 +1,34 @@
1
+ <script context="module" lang="ts">
2
+ export interface SectionProps {
3
+ maxWidth?: number;
4
+ attributes?: any;
5
+ children?: any;
6
+ builderBlock?: any;
7
+ }
8
+ </script>
9
+
10
+ <script lang="ts">
11
+ export let attributes: SectionProps["attributes"];
12
+ export let maxWidth: SectionProps["maxWidth"];
13
+
14
+ function mitosis_styling(node, vars) {
15
+ Object.entries(vars || {}).forEach(([p, v]) => {
16
+ if (p.startsWith("--")) {
17
+ node.style.setProperty(p, v);
18
+ } else {
19
+ node.style[p] = v;
20
+ }
21
+ });
22
+ }
23
+ </script>
24
+
25
+ <section
26
+ {...attributes}
27
+ use:mitosis_styling={maxWidth && typeof maxWidth === "number"
28
+ ? {
29
+ maxWidth: maxWidth,
30
+ }
31
+ : undefined}
32
+ >
33
+ <slot />
34
+ </section>
@@ -0,0 +1,61 @@
1
+ import type { ComponentInfo } from '../../types/components';
2
+
3
+ export const componentInfo: ComponentInfo = {
4
+ name: 'Form:Select',
5
+ builtIn: true,
6
+ image:
7
+ 'https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2F83acca093fb24aaf94dee136e9a4b045',
8
+ defaultStyles: {
9
+ alignSelf: 'flex-start',
10
+ },
11
+ inputs: [
12
+ {
13
+ name: 'options',
14
+ type: 'list',
15
+ required: true,
16
+ subFields: [
17
+ {
18
+ name: 'value',
19
+ type: 'text',
20
+ required: true,
21
+ },
22
+ {
23
+ name: 'name',
24
+ type: 'text',
25
+ },
26
+ ],
27
+ defaultValue: [
28
+ {
29
+ value: 'option 1',
30
+ },
31
+ {
32
+ value: 'option 2',
33
+ },
34
+ ],
35
+ },
36
+ {
37
+ name: 'name',
38
+ type: 'string',
39
+ required: true,
40
+ helperText:
41
+ 'Every select in a form needs a unique name describing what it gets, e.g. "email"',
42
+ },
43
+ {
44
+ name: 'defaultValue',
45
+ type: 'string',
46
+ },
47
+ {
48
+ name: 'value',
49
+ type: 'string',
50
+ advanced: true,
51
+ },
52
+
53
+ {
54
+ name: 'required',
55
+ type: 'boolean',
56
+ defaultValue: false,
57
+ },
58
+ ],
59
+ static: true,
60
+ noWrap: true,
61
+ };
@@ -0,0 +1,34 @@
1
+ <script context="module" lang="ts">
2
+ export interface FormSelectProps {
3
+ options?: {
4
+ name?: string;
5
+ value: string;
6
+ }[];
7
+ attributes?: any;
8
+ name?: string;
9
+ value?: string;
10
+ defaultValue?: string;
11
+ }
12
+ </script>
13
+
14
+ <script lang="ts">
15
+ import { isEditing } from "../../functions/is-editing.js";
16
+
17
+ export let attributes: FormSelectProps["attributes"];
18
+ export let value: FormSelectProps["value"];
19
+ export let defaultValue: FormSelectProps["defaultValue"];
20
+ export let name: FormSelectProps["name"];
21
+ export let options: FormSelectProps["options"];
22
+ </script>
23
+
24
+ <select
25
+ {...attributes}
26
+ {value}
27
+ key={isEditing() && defaultValue ? defaultValue : "default-key"}
28
+ {defaultValue}
29
+ {name}
30
+ >
31
+ {#each options as option}
32
+ <option value={option.value}>{option.name || option.value}</option>
33
+ {/each}
34
+ </select>
@@ -0,0 +1,32 @@
1
+ import type { ComponentInfo } from '../../types/components';
2
+
3
+ export const componentInfo: ComponentInfo = {
4
+ name: 'Form:SubmitButton',
5
+ builtIn: true,
6
+ image:
7
+ 'https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2Fdf2820ffed1f4349a94c40b3221f5b98',
8
+ defaultStyles: {
9
+ appearance: 'none',
10
+ paddingTop: '15px',
11
+ paddingBottom: '15px',
12
+ paddingLeft: '25px',
13
+ paddingRight: '25px',
14
+ backgroundColor: '#3898EC',
15
+ color: 'white',
16
+ borderRadius: '4px',
17
+ cursor: 'pointer',
18
+ },
19
+ inputs: [
20
+ {
21
+ name: 'text',
22
+ type: 'text',
23
+ defaultValue: 'Click me',
24
+ },
25
+ ],
26
+ static: true,
27
+ noWrap: true,
28
+ // TODO: optional children? maybe as optional form input
29
+ // that only shows if advanced setting is flipped
30
+ // TODO: defaultChildren
31
+ // canHaveChildren: true,
32
+ };
@@ -0,0 +1,15 @@
1
+ <script context="module" lang="ts">
2
+ export interface ButtonProps {
3
+ attributes?: any;
4
+ text?: string;
5
+ }
6
+ </script>
7
+
8
+ <script lang="ts">
9
+ export let attributes: ButtonProps["attributes"];
10
+ export let text: ButtonProps["text"];
11
+ </script>
12
+
13
+ <button {...attributes} type="submit">
14
+ {text}
15
+ </button>
@@ -0,0 +1,43 @@
1
+ import type { ComponentInfo } from '../../types/components';
2
+
3
+ export const componentInfo: ComponentInfo = {
4
+ name: 'Symbol',
5
+ noWrap: true,
6
+ static: true,
7
+ builtIn: true,
8
+ inputs: [
9
+ {
10
+ name: 'symbol',
11
+ type: 'uiSymbol',
12
+ },
13
+ {
14
+ name: 'dataOnly',
15
+ helperText: "Make this a data symbol that doesn't display any UI",
16
+ type: 'boolean',
17
+ defaultValue: false,
18
+ advanced: true,
19
+ hideFromUI: true,
20
+ },
21
+ {
22
+ name: 'inheritState',
23
+ helperText: 'Inherit the parent component state and data',
24
+ type: 'boolean',
25
+ defaultValue: false,
26
+ advanced: true,
27
+ },
28
+ {
29
+ name: 'renderToLiquid',
30
+ helperText:
31
+ 'Render this symbols contents to liquid. Turn off to fetch with javascript and use custom targeting',
32
+ type: 'boolean',
33
+ defaultValue: false,
34
+ advanced: true,
35
+ hideFromUI: true,
36
+ },
37
+ {
38
+ name: 'useChildren',
39
+ hideFromUI: true,
40
+ type: 'boolean',
41
+ },
42
+ ],
43
+ };