import { parse } from '@babel/parser'
import traverse from '@babel/traverse'
import generate from '@babel/generator'
import * as types from '@babel/types'
import { GeneratedFolder } from '@teleporthq/teleport-types'
import uidlSample from '../../../examples/test-samples/project-sample.json'
import { createNextProjectGenerator } from '../src'
import NextTemplate from '../src/project-template'
/**
* A navigation element the editor's Instant search plugin adopted as the button
* that opens the search modal, as it leaves the editor and as the Next.js
* generator publishes it.
*
* What the editor exports for such an element (the GUI side is proven in
* `teleport-gui/.../domain-to-uidl/__tests__/adopted-navigation-element-export.spec.ts`):
*
* - the element keeps its own link ability and its own look, and gains
* `data-tq-search-control`, `aria-haspopup`, `aria-label`, `role`, `tabindex`;
* - a click workflow whose trigger carries `preventDefault` + `stopPropagation`
* and the element's html id, ending in `general-emit-custom-event`
* `tq-search-open`;
* - a wrapping form gets the same through an `event-element-event` `submit`;
* - a search input carries `readonly` as the boolean `true`;
* - the element's own workflows are paused, so they are not in the UIDL at all.
*
* Published, that must still be a working button. Everything below fails
* silently in a browser, so it is read off the generated component:
*
* 1. the click listener sits on the element that RECEIVES the click. A link
* ability becomes `` (or `` for a url): Next's legacy Link takes
* its click handler from the inner ``, calls it first and navigates only
* when the event was not default-prevented, so the id and the handler must
* both be on that ``, never on the ``;
* 2. that handler cancels the link or the submit (`preventDefault`) and stops
* the event bubbling to a linked card (`stopPropagation`) BEFORE it runs
* the workflow, and only when the trigger asked for it;
* 3. a boolean `readonly` is printed as the bare `readOnly`: `readOnly=""`
* would be read as false by React and leave the field editable;
* 4. `