diff --git a/packages/core/src/__tests__/__snapshots__/mitosis.test.ts.snap b/packages/core/src/__tests__/__snapshots__/mitosis.test.ts.snap new file mode 100644 index 0000000000..f99972960f --- /dev/null +++ b/packages/core/src/__tests__/__snapshots__/mitosis.test.ts.snap @@ -0,0 +1,20726 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`Mitosis, format: legacy (native loops and conditionals) > jsx > Javascript Test > AdvancedRef 1`] = ` +"import { useStore, useRef } from \\"@builder.io/mitosis\\"; +import { Show, Fragment } from \\"@components\\"; + +export default function MyBasicRefComponent(props) { + const state = useStore({ + name: \\"PatrickJS\\", + onBlur: function onBlur() { + // Maintain focus + inputRef.current.focus(); + }, + lowerCaseName: function lowerCaseName() { + return state.name.toLowerCase(); + }, + }); + + const inputRef = useRef(null); + const inputNoArgRef = useRef(null); + const inputRef = useRef(null); + const inputNoArgRef = useRef(null); + + return ( +
+ {props.showInput ? ( + + state.onBlur()} + onChange={(event) => (state.name = event.target.value)} + /> + + + + ) : null} + Hello + {state.lowerCaseName()}! I can run in React, Qwik, Vue, Solid, or Web + Component! +
+ ); +} +" +`; + +exports[`Mitosis, format: legacy (native loops and conditionals) > jsx > Javascript Test > Basic 1`] = ` +"import { useStore } from \\"@builder.io/mitosis\\"; + +export const DEFAULT_VALUES = { + name: \\"Steve\\", +}; + +export default function MyBasicComponent(props) { + const state = useStore({ + name: \\"Steve\\", + underscore_fn_name() { + return \\"bar\\"; + }, + age: 1, + sports: [\\"\\"], + }); + + return ( +
+ (state.name = myEvent.target.value)} + /> + Hello! I can run in React, Vue, Solid, or Liquid! > +
+ ); +} +" +`; + +exports[`Mitosis, format: legacy (native loops and conditionals) > jsx > Javascript Test > Basic 2`] = ` +"import { useStore } from \\"@builder.io/mitosis\\"; +import { For, Show } from \\"@components\\"; + +export default function MyBasicForShowComponent(props) { + const state = useStore({ name: \\"PatrickJS\\", names: [\\"Steve\\", \\"PatrickJS\\"] }); + + return ( +
+ {state.names.map((person, index) => + person === state.name ? ( + <> + { + state.name = event.target.value + \\" and \\" + person; + }} + /> + Hello + {person}! I can run in Qwik, Web Component, React, Vue, Solid, or + Liquid! + + ) : null + )} +
+ ); +} +" +`; + +exports[`Mitosis, format: legacy (native loops and conditionals) > jsx > Javascript Test > Basic Context 1`] = ` +"import { useStore } from \\"@builder.io/mitosis\\"; + +import { Injector, MyService, createInjector } from \\"@dummy/injection-js\\"; + +export default function MyBasicComponent(props) { + const state = useStore({ + name: \\"PatrickJS\\", + onChange: function onChange() { + const change = myService.method(\\"change\\"); + console.log(change); + }, + }); + + onMount(() => { + const bye = myService.method(\\"hi\\"); + console.log(bye); + }); + + return ( +
+ {myService.method(\\"hello\\") + state.name} + Hello! I can run in React, Vue, Solid, or Liquid! + state.onChange} /> +
+ ); +} +" +`; + +exports[`Mitosis, format: legacy (native loops and conditionals) > jsx > Javascript Test > Basic OnMount Update 1`] = ` +"import { useStore } from \\"@builder.io/mitosis\\"; + +export default function MyBasicOnMountUpdateComponent(props) { + const state = useStore({ name: \\"PatrickJS\\", names: [\\"Steve\\", \\"PatrickJS\\"] }); + + onMount(() => { + state.name = \\"PatrickJS onMount\\" + props.bye; + }); + + return ( +
+ Hello + {state.name} +
+ ); +} +" +`; + +exports[`Mitosis, format: legacy (native loops and conditionals) > jsx > Javascript Test > Basic Outputs 1`] = ` +"import { useStore } from \\"@builder.io/mitosis\\"; + +export default function MyBasicOutputsComponent(props) { + const state = useStore({ name: \\"PatrickJS\\" }); + + onMount(() => { + props.onMessage(state.name); + props.onEvent(props.message); + }); + + return
; +} +" +`; + +exports[`Mitosis, format: legacy (native loops and conditionals) > jsx > Javascript Test > Basic Outputs Meta 1`] = ` +"import { useStore } from \\"@builder.io/mitosis\\"; + +useMetadata({ + outputs: [\\"onMessage\\", \\"onEvent\\"], + baz: \\"metadata inside component\\", +}); + +export default function MyBasicOutputsComponent(props) { + const state = useStore({ name: \\"PatrickJS\\" }); + + onMount(() => { + props.onMessage(state.name); + props.onEvent(props.message); + }); + + return
; +} +" +`; + +exports[`Mitosis, format: legacy (native loops and conditionals) > jsx > Javascript Test > BasicAttribute 1`] = ` +"export default function MyComponent(props) { + return ; +} +" +`; + +exports[`Mitosis, format: legacy (native loops and conditionals) > jsx > Javascript Test > BasicBooleanAttribute 1`] = ` +"import { Show, MyBooleanAttributeComponent } from \\"@components\\"; + +import MyBooleanAttributeComponent from \\"./basic-boolean-attribute-component.raw\\"; + +export default function MyBooleanAttribute(props) { + return ( +
+ {props.children ? ( + <> + {props.children} + {props.type} + + ) : null} + + + +
+ ); +} +" +`; + +exports[`Mitosis, format: legacy (native loops and conditionals) > jsx > Javascript Test > BasicChildComponent 1`] = ` +"import { useStore } from \\"@builder.io/mitosis\\"; +import { MyBasicComponent, MyBasicOnMountUpdateComponent } from \\"@components\\"; + +import MyBasicOnMountUpdateComponent from \\"./basic-onMount-update.raw\\"; +import MyBasicComponent from \\"./basic.raw\\"; + +export default function MyBasicChildComponent(props) { + const state = useStore({ name: \\"Steve\\", dev: \\"PatrickJS\\" }); + + return ( +
+ +
+ +
+
+ ); +} +" +`; + +exports[`Mitosis, format: legacy (native loops and conditionals) > jsx > Javascript Test > BasicFor 1`] = ` +"import { useStore } from \\"@builder.io/mitosis\\"; +import { For, Fragment } from \\"@components\\"; + +export default function MyBasicForComponent(props) { + const state = useStore({ name: \\"PatrickJS\\", names: [\\"Steve\\", \\"PatrickJS\\"] }); + + onMount(() => { + console.log(\\"onMount code\\"); + }); + + return ( +
+ {state.names.map((person, index) => ( + + { + state.name = event.target.value + \\" and \\" + person; + }} + /> + Hello + {person}! I can run in Qwik, Web Component, React, Vue, Solid, or + Liquid! + + ))} +
+ ); +} +" +`; + +exports[`Mitosis, format: legacy (native loops and conditionals) > jsx > Javascript Test > BasicRef 1`] = ` +"import { useStore, useRef } from \\"@builder.io/mitosis\\"; +import { Show, Fragment } from \\"@components\\"; + +export default function MyBasicRefComponent(props) { + const state = useStore({ + name: \\"PatrickJS\\", + onBlur: function onBlur() { + // Maintain focus + inputRef.current.focus(); + }, + lowerCaseName: function lowerCaseName() { + return state.name.toLowerCase(); + }, + }); + + const inputRef = useRef(null); + const inputNoArgRef = useRef(null); + const inputRef = useRef(null); + const inputNoArgRef = useRef(null); + + return ( +
+ {props.showInput ? ( + + state.onBlur()} + onChange={(event) => (state.name = event.target.value)} + /> + + + + ) : null} + Hello + {state.lowerCaseName()}! I can run in React, Qwik, Vue, Solid, or Web + Component! +
+ ); +} +" +`; + +exports[`Mitosis, format: legacy (native loops and conditionals) > jsx > Javascript Test > BasicRefAssignment 1`] = `"unknown: Maximum call stack size exceeded"`; + +exports[`Mitosis, format: legacy (native loops and conditionals) > jsx > Javascript Test > BasicRefPrevious 1`] = `"unknown: Maximum call stack size exceeded"`; + +exports[`Mitosis, format: legacy (native loops and conditionals) > jsx > Javascript Test > Button 1`] = ` +"import { Show } from \\"@components\\"; + +export default function Button(props) { + return ( +
+ {props.link ? ( + + {props.text} + + ) : null} + {!props.link ? ( + + ) : null} +
+ ); +} +" +`; + +exports[`Mitosis, format: legacy (native loops and conditionals) > jsx > Javascript Test > Columns 1`] = ` +"import { useStore } from \\"@builder.io/mitosis\\"; +import { For } from \\"@components\\"; + +export default function Column(props) { + const state = useStore({ + getColumns() { + return props.columns || []; + }, + getGutterSize() { + return typeof props.space === \\"number\\" ? props.space || 0 : 20; + }, + getWidth(index) { + const columns = state.getColumns(); + return (columns[index] && columns[index].width) || 100 / columns.length; + }, + getColumnCssWidth(index) { + const columns = state.getColumns(); + const gutterSize = state.getGutterSize(); + const subtractWidth = + (gutterSize * (columns.length - 1)) / columns.length; + return \`calc(\${state.getWidth(index)}% - \${subtractWidth}px)\`; + }, + }); + + return ( +
+ {props.columns.map((column, index) => ( +
+ {column.content} + {index} +
+ ))} +
+ ); +} +" +`; + +exports[`Mitosis, format: legacy (native loops and conditionals) > jsx > Javascript Test > ContentSlotHtml 1`] = ` +"import { Slot } from \\"@components\\"; + +export default function ContentSlotCode(props) { + return ( +
+ +
+
+
+
+ +
+
+ ); +} +" +`; + +exports[`Mitosis, format: legacy (native loops and conditionals) > jsx > Javascript Test > ContentSlotJSX 1`] = ` +"import { useStore } from \\"@builder.io/mitosis\\"; +import { Show, Slot } from \\"@components\\"; + +export default function ContentSlotJsxCode(props) { + const state = useStore({ + name: \\"king\\", + showContent: false, + get cls() { + return props.slotContent && props.children ? \`\${state.name}-content\` : \\"\\"; + }, + show() { + props.slotContent ? 1 : \\"\\"; + }, + }); + + return props.slotReference ? ( +
state.show()} + class={state.cls} + > + {state.showContent && props.slotContent ? ( + {props.content} + ) : null} +
+
+
+
{props.children}
+
+ ) : null; +} +" +`; + +exports[`Mitosis, format: legacy (native loops and conditionals) > jsx > Javascript Test > CustomCode 1`] = ` +"import { useStore, useRef } from \\"@builder.io/mitosis\\"; + +export default function CustomCode(props) { + const state = useStore({ + scriptsInserted: [], + scriptsRun: [], + findAndRunScripts() { + // TODO: Move this function to standalone one in '@builder.io/utils' + if (elem.current && typeof window !== \\"undefined\\") { + /** @type {HTMLScriptElement[]} */ + const scripts = elem.current.getElementsByTagName(\\"script\\"); + + for (let i = 0; i < scripts.length; i++) { + const script = scripts[i]; + + if (script.src) { + if (state.scriptsInserted.includes(script.src)) { + continue; + } + + state.scriptsInserted.push(script.src); + const newScript = document.createElement(\\"script\\"); + newScript.async = true; + newScript.src = script.src; + document.head.appendChild(newScript); + } else if ( + !script.type || + [ + \\"text/javascript\\", + \\"application/javascript\\", + \\"application/ecmascript\\", + ].includes(script.type) + ) { + if (state.scriptsRun.includes(script.innerText)) { + continue; + } + + try { + state.scriptsRun.push(script.innerText); + new Function(script.innerText)(); + } catch (error) { + console.warn(\\"\`CustomCode\`: Error running script:\\", error); + } + } + } + } + }, + }); + + const elem = useRef(null); + const elem = useRef(null); + + onMount(() => { + state.findAndRunScripts(); + }); + + return ( +
+ ); +} +" +`; + +exports[`Mitosis, format: legacy (native loops and conditionals) > jsx > Javascript Test > Embed 1`] = ` +"import { useStore, useRef } from \\"@builder.io/mitosis\\"; + +export default function CustomCode(props) { + const state = useStore({ + scriptsInserted: [], + scriptsRun: [], + findAndRunScripts() { + // TODO: Move this function to standalone one in '@builder.io/utils' + if (elem.current && typeof window !== \\"undefined\\") { + /** @type {HTMLScriptElement[]} */ + const scripts = elem.current.getElementsByTagName(\\"script\\"); + + for (let i = 0; i < scripts.length; i++) { + const script = scripts[i]; + + if (script.src) { + if (state.scriptsInserted.includes(script.src)) { + continue; + } + + state.scriptsInserted.push(script.src); + const newScript = document.createElement(\\"script\\"); + newScript.async = true; + newScript.src = script.src; + document.head.appendChild(newScript); + } else if ( + !script.type || + [ + \\"text/javascript\\", + \\"application/javascript\\", + \\"application/ecmascript\\", + ].includes(script.type) + ) { + if (state.scriptsRun.includes(script.innerText)) { + continue; + } + + try { + state.scriptsRun.push(script.innerText); + new Function(script.innerText)(); + } catch (error) { + console.warn(\\"\`CustomCode\`: Error running script:\\", error); + } + } + } + } + }, + }); + + const elem = useRef(null); + const elem = useRef(null); + + onMount(() => { + state.findAndRunScripts(); + }); + + return ( +
+ ); +} +" +`; + +exports[`Mitosis, format: legacy (native loops and conditionals) > jsx > Javascript Test > Form 1`] = ` +"import { useStore, useRef } from \\"@builder.io/mitosis\\"; +import { Show, For, BuilderBlockComponent, BuilderBlocks } from \\"@components\\"; + +import { Builder, builder } from \\"@builder.io/sdk\\"; +import { + BuilderBlock as BuilderBlockComponent, + BuilderBlocks, + get, + set, +} from \\"@fake\\"; + +export default function FormComponent(props) { + const state = useStore({ + formState: \\"unsubmitted\\", + responseData: null, + formErrorMessage: \\"\\", + get submissionState() { + return (Builder.isEditing && props.previewState) || state.formState; + }, + onSubmit(event) { + const sendWithJs = + props.sendWithJs || props.sendSubmissionsTo === \\"email\\"; + + if (props.sendSubmissionsTo === \\"zapier\\") { + event.preventDefault(); + } else if (sendWithJs) { + if (!(props.action || props.sendSubmissionsTo === \\"email\\")) { + event.preventDefault(); + return; + } + + event.preventDefault(); + const el = event.currentTarget; + const headers = props.customHeaders || {}; + let body; + const formData = new FormData(el); // TODO: maybe support null + + const formPairs = Array.from( + event.currentTarget.querySelectorAll(\\"input,select,textarea\\") + ) + .filter((el) => !!el.name) + .map((el) => { + let value; + const key = el.name; + + if (el instanceof HTMLInputElement) { + if (el.type === \\"radio\\") { + if (el.checked) { + value = el.name; + return { + key, + value, + }; + } + } else if (el.type === \\"checkbox\\") { + value = el.checked; + } else if (el.type === \\"number\\" || el.type === \\"range\\") { + const num = el.valueAsNumber; + + if (!isNaN(num)) { + value = num; + } + } else if (el.type === \\"file\\") { + // TODO: one vs multiple files + value = el.files; + } else { + value = el.value; + } + } else { + value = el.value; + } + + return { + key, + value, + }; + }); + let contentType = props.contentType; + + if (props.sendSubmissionsTo === \\"email\\") { + contentType = \\"multipart/form-data\\"; + } + + Array.from(formPairs).forEach(({ value }) => { + if ( + value instanceof File || + (Array.isArray(value) && value[0] instanceof File) || + value instanceof FileList + ) { + contentType = \\"multipart/form-data\\"; + } + }); // TODO: send as urlEncoded or multipart by default + // because of ease of use and reliability in browser API + // for encoding the form? + + if (contentType !== \\"application/json\\") { + body = formData; + } else { + // Json + const json = {}; + Array.from(formPairs).forEach(({ value, key }) => { + set(json, key, value); + }); + body = JSON.stringify(json); + } + + if (contentType && contentType !== \\"multipart/form-data\\") { + if ( + /* Zapier doesn't allow content-type header to be sent from browsers */ + !(sendWithJs && props.action?.includes(\\"zapier.com\\")) + ) { + headers[\\"content-type\\"] = contentType; + } + } + + const presubmitEvent = new CustomEvent(\\"presubmit\\", { + detail: { + body, + }, + }); + + if (formRef.current) { + formRef.current.dispatchEvent(presubmitEvent); + + if (presubmitEvent.defaultPrevented) { + return; + } + } + + state.formState = \\"sending\\"; + 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 || \\"\\")}\`; + fetch( + props.sendSubmissionsTo === \\"email\\" ? formUrl : props.action, + /* TODO: throw error if no action URL */ + { + body, + headers, + method: props.method || \\"post\\", + } + ).then( + async (res) => { + let body; + const contentType = res.headers.get(\\"content-type\\"); + + if (contentType && contentType.indexOf(\\"application/json\\") !== -1) { + body = await res.json(); + } else { + body = await res.text(); + } + + if (!res.ok && props.errorMessagePath) { + /* TODO: allow supplying an error formatter function */ + let message = get(body, props.errorMessagePath); + + if (message) { + if (typeof message !== \\"string\\") { + /* TODO: ideally convert json to yaml so it woul dbe like + error: - email has been taken */ + message = JSON.stringify(message); + } + + state.formErrorMessage = message; + } + } + + state.responseData = body; + state.formState = res.ok ? \\"success\\" : \\"error\\"; + + if (res.ok) { + const submitSuccessEvent = new CustomEvent(\\"submit:success\\", { + detail: { + res, + body, + }, + }); + + if (formRef.current) { + formRef.current.dispatchEvent(submitSuccessEvent); + + if (submitSuccessEvent.defaultPrevented) { + return; + } + /* TODO: option to turn this on/off? */ + + if (props.resetFormOnSubmit !== false) { + formRef.current.reset(); + } + } + /* TODO: client side route event first that can be preventDefaulted */ + + if (props.successUrl) { + if (formRef.current) { + const event = new CustomEvent(\\"route\\", { + detail: { + url: props.successUrl, + }, + }); + formRef.current.dispatchEvent(event); + + if (!event.defaultPrevented) { + location.href = props.successUrl; + } + } else { + location.href = props.successUrl; + } + } + } + }, + (err) => { + const submitErrorEvent = new CustomEvent(\\"submit:error\\", { + detail: { + error: err, + }, + }); + + if (formRef.current) { + formRef.current.dispatchEvent(submitErrorEvent); + + if (submitErrorEvent.defaultPrevented) { + return; + } + } + + state.responseData = err; + state.formState = \\"error\\"; + } + ); + } + }, + }); + + const formRef = useRef(null); + const formRef = useRef(null); + + return ( +
state.onSubmit(event)} + {...props.attributes} + > + {props.builderBlock && props.builderBlock.children + ? (props.builderBlock?.children).map((block, index) => ( + + )) + : null} + {state.submissionState === \\"error\\" ? ( + + ) : null} + {state.submissionState === \\"sending\\" ? ( + + ) : null} + {state.submissionState === \\"error\\" && state.responseData ? ( +
+          {JSON.stringify(state.responseData, null, 2)}
+        
+ ) : null} + {state.submissionState === \\"success\\" ? ( + + ) : null} + + ); +} +" +`; + +exports[`Mitosis, format: legacy (native loops and conditionals) > jsx > Javascript Test > Image 1`] = ` +"import { useStore, useRef } from \\"@builder.io/mitosis\\"; +import { Show } from \\"@components\\"; + +export default function Image(props) { + const state = useStore({ + scrollListener: null, + imageLoaded: false, + setLoaded() { + state.imageLoaded = true; + }, + useLazyLoading() { + // TODO: Add more checks here, like testing for real web browsers + return !!props.lazy && state.isBrowser(); + }, + isBrowser: function isBrowser() { + return ( + typeof window !== \\"undefined\\" && + window.navigator.product != \\"ReactNative\\" + ); + }, + load: false, + }); + + const pictureRef = useRef(); + const pictureRef = useRef(); + + onMount(() => { + if (state.useLazyLoading()) { + // throttled scroll capture listener + const listener = () => { + if (pictureRef.current) { + const rect = pictureRef.current.getBoundingClientRect(); + const buffer = window.innerHeight / 2; + + if (rect.top < window.innerHeight + buffer) { + state.load = true; + state.scrollListener = null; + window.removeEventListener(\\"scroll\\", listener); + } + } + }; + + state.scrollListener = listener; + window.addEventListener(\\"scroll\\", listener, { + capture: true, + passive: true, + }); + listener(); + } + }); + + onUnMount(() => { + if (state.scrollListener) { + window.removeEventListener(\\"scroll\\", state.scrollListener); + } + }); + + return ( +
+ + {!state.useLazyLoading() || state.load ? ( + {props.altText} state.setLoaded()} + srcset={props.srcset} + sizes={props.sizes} + /> + ) : null} + + + {props.children} +
+ ); +} +" +`; + +exports[`Mitosis, format: legacy (native loops and conditionals) > jsx > Javascript Test > Image State 1`] = ` +"import { useStore } from \\"@builder.io/mitosis\\"; +import { For, Fragment } from \\"@components\\"; + +export default function ImgStateComponent(props) { + const state = useStore({ + canShow: true, + images: [\\"http://example.com/qwik.png\\"], + }); + + return ( +
+ {state.images.map((item, itemIndex) => ( + + + + ))} +
+ ); +} +" +`; + +exports[`Mitosis, format: legacy (native loops and conditionals) > jsx > Javascript Test > Img 1`] = ` +"import { Builder } from \\"@builder.io/sdk\\"; + +export default function ImgComponent(props) { + return ( + {props.altText} + ); +} +" +`; + +exports[`Mitosis, format: legacy (native loops and conditionals) > jsx > Javascript Test > Input 1`] = ` +"import { Builder } from \\"@builder.io/sdk\\"; + +export default function FormInputComponent(props) { + return ( + props.onChange?.(event.target.value)} + /> + ); +} +" +`; + +exports[`Mitosis, format: legacy (native loops and conditionals) > jsx > Javascript Test > InputParent 1`] = ` +"import { useStore } from \\"@builder.io/mitosis\\"; +import { FormInputComponent } from \\"@components\\"; + +import FormInputComponent from \\"./input.raw\\"; + +export default function Stepper(props) { + const state = useStore({ + handleChange(value) { + console.log(value); + }, + }); + + return ( + state.handleChange(value)} + /> + ); +} +" +`; + +exports[`Mitosis, format: legacy (native loops and conditionals) > jsx > Javascript Test > RawText 1`] = ` +"export default function RawText(props) { + return ( + + ); +} +" +`; + +exports[`Mitosis, format: legacy (native loops and conditionals) > jsx > Javascript Test > Section 1`] = ` +"export default function SectionComponent(props) { + return ( +
+ {props.children} +
+ ); +} +" +`; + +exports[`Mitosis, format: legacy (native loops and conditionals) > jsx > Javascript Test > Section 2`] = ` +"import { useStore } from \\"@builder.io/mitosis\\"; +import { Show, For } from \\"@components\\"; + +export default function SectionStateComponent(props) { + const state = useStore({ max: 42, items: [42] }); + + return state.max + ? state.items.map((item, index) => ( +
+ {props.children} +
+ )) + : null; +} +" +`; + +exports[`Mitosis, format: legacy (native loops and conditionals) > jsx > Javascript Test > Select 1`] = ` +"import { For } from \\"@components\\"; + +import { Builder } from \\"@builder.io/sdk\\"; + +export default function SelectComponent(props) { + return ( + + ); +} +" +`; + +exports[`Mitosis, format: legacy (native loops and conditionals) > jsx > Javascript Test > SlotDefault 1`] = ` +"import { Slot } from \\"@components\\"; + +export default function SlotCode(props) { + return ( +
+ +
Default content
+
+
+ ); +} +" +`; + +exports[`Mitosis, format: legacy (native loops and conditionals) > jsx > Javascript Test > SlotHtml 1`] = ` +"import { ContentSlotCode, Slot } from \\"@components\\"; + +import ContentSlotCode from \\"./content-slot-jsx.raw\\"; + +export default function SlotCode(props) { + return ( +
+ + Hello
} /> + +
+ ); +} +" +`; + +exports[`Mitosis, format: legacy (native loops and conditionals) > jsx > Javascript Test > SlotJsx 1`] = ` +"import { ContentSlotCode } from \\"@components\\"; + +import ContentSlotCode from \\"./content-slot-jsx.raw\\"; + +export default function SlotCode(props) { + return ( +
+ Hello
} /> +
+ ); +} +" +`; + +exports[`Mitosis, format: legacy (native loops and conditionals) > jsx > Javascript Test > SlotNamed 1`] = ` +"import { Slot } from \\"@components\\"; + +export default function SlotCode(props) { + return ( +
+ + + Default left + Default Child +
+ ); +} +" +`; + +exports[`Mitosis, format: legacy (native loops and conditionals) > jsx > Javascript Test > Stamped.io 1`] = ` +"import { useStore } from \\"@builder.io/mitosis\\"; +import { Show, For } from \\"@components\\"; + +import { kebabCase, snakeCase } from \\"lodash\\"; + +export default function SmileReviews(props) { + const state = useStore({ + reviews: [], + name: \\"test\\", + showReviewPrompt: false, + kebabCaseValue() { + return kebabCase(\\"testThat\\"); + }, + snakeCaseValue() { + return snakeCase(\\"testThis\\"); + }, + }); + + onMount(() => { + fetch( + \`https://stamped.io/api/widget/reviews?storeUrl=builder-io.myshopify.com&apiKey=\${ + props.apiKey || \\"pubkey-8bbDq7W6w4sB3OWeM1HUy2s47702hM\\" + }&productId=\${props.productId || \\"2410511106127\\"}\` + ) + .then((res) => res.json()) + .then((data) => { + state.reviews = data.data; + }); + }); + + return ( +
+ + {state.showReviewPrompt || \\"asdf\\" ? ( + <> + + +