forked from vuejs/babel-plugin-jsx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
130 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// @ts-expect-error | ||
import { Dialog, Fragment, Template } from 'one-jsx-loader' | ||
// @ts-expect-error | ||
import { Button, Form, FormItem, Icon, Input, Modal } from './components' | ||
|
||
|
||
function useForm() { | ||
const visible1 = false; | ||
const visible2 = false; | ||
const handleConfirm = () => {} | ||
const handleCancel = () => {} | ||
return <Fragment title="aaaa" tips="bbbb"> | ||
<Form></Form> | ||
<Dialog visible={visible1}> | ||
<Template slot="buttons"> | ||
<Button type="primary" text="确定" onClick={handleConfirm} /> | ||
<Button type="primary" text="取消" onClick={handleCancel} /> | ||
</Template> | ||
</Dialog> | ||
<Dialog visible={visible2} /> | ||
</Fragment> | ||
} | ||
|
||
|
||
export function useFn() { | ||
const a: number = 1; | ||
const b: any = 3; | ||
const c = a + b; | ||
const d = 12 as any; | ||
const e = c + d; | ||
console.log(e); | ||
const rules = {}; | ||
const visible = false; | ||
const onClose = () => {}; | ||
const handleFocus = () => {}; | ||
const handleBlur = () => {}; | ||
return <Form ref="formRef" use={useForm} rules={rules}> | ||
<Modal visible={visible} onClose={onClose} resolve={(row: any) => { | ||
console.log(row) | ||
}}> | ||
</Modal> | ||
<Input /> | ||
<FormItem label="name" prop="name"> | ||
<Input value="xxx" onFocus={handleFocus} onBlur={handleBlur} /> | ||
</FormItem> | ||
<FormItem label="age" prop="age"> | ||
<Input value="xxx"> | ||
<Template slot="prefix" width={100}> | ||
<Icon class="search" /> | ||
</Template> | ||
<Template slot="suffix"> | ||
<Icon class="calendar" /> | ||
</Template> | ||
</Input> | ||
</FormItem> | ||
</Form> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,62 @@ | ||
export const templateStr = `export function useFn() { | ||
export const templateStr = `// @ts-expect-error | ||
import { Template, Fragment, Dialog } from 'one-jsx-loader' | ||
// @ts-expect-error | ||
import { Form, FormItem, Grid, Column, Icon, Tag, Button, Input, Select } from './components' | ||
function useHeader() { | ||
return <Fragment title="xxx" tips="zzz" /> | ||
} | ||
function useForm() { | ||
return <Form ref="formRef" use={useForm} rules={rules}> | ||
<FormItem label="name" prop="name"> | ||
<Input value="xxx" onFocus={handleFocus} onBlur={handleBlur} /> | ||
</FormItem> | ||
<FormItem label="age" prop="age"> | ||
<Input value="xxx"> | ||
<template slot="prefix"> | ||
<Template slot="prefix"> | ||
<Icon class="search" /> | ||
</template> | ||
<template slot="suffix"> | ||
</Template> | ||
<Template slot="suffix"> | ||
<Icon class="calendar" /> | ||
</template> | ||
</Template> | ||
</Input> | ||
</FormItem> | ||
<Dialog visible={visible}> | ||
<Template slot="buttons"> | ||
<Button type="primary" text="Confirm" onClick={handleConfirm} /> | ||
<Button type="primary" text="Cancel" onClick={handleCancel} /> | ||
</Template> | ||
</Dialog> | ||
</Form> | ||
} | ||
function useGrid() { | ||
const handleFocus = () => {} | ||
const handleChange = () => {} | ||
return <Grid> | ||
<Column field="name" title="Name" width={100} showOverflow /> | ||
<Column field="status" title="Status" width={120}> | ||
<Tag resolve={({ row }) => { | ||
return { | ||
props: { | ||
light: 'light', | ||
type: 'error', | ||
value: row.status | ||
} | ||
} | ||
}} /> | ||
</Column> | ||
<Column field="age" title="Age" width={80}> | ||
<Input /> | ||
<Template slot="default" tips="xxx"> | ||
<Input /> | ||
</Template> | ||
<Template slot="header" tips="xxx" /> | ||
<Template slot="edit"> | ||
<Select clearable placeholder="please select..." onFocus={handleFocus} onChange={handleChange} /> | ||
</Template> | ||
</Column> | ||
</Grid> | ||
} | ||
`; |