Skip to content

Commit

Permalink
fix(printer): fix print schema (#710)
Browse files Browse the repository at this point in the history
* fix(printer): fix print schema

* fix(printer): fix ci
  • Loading branch information
janryWang authored Mar 11, 2020
1 parent 2c71363 commit eb4b4e3
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 33 deletions.
27 changes: 2 additions & 25 deletions packages/printer/src/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState } from 'react'
import ReactDOM from 'react-dom'
import { createFormActions } from '@formily/react-schema-renderer'
import { createFormActions, Schema } from '@formily/react-schema-renderer'
import styled from 'styled-components'
import Modal from 'react-modal'

Expand Down Expand Up @@ -76,31 +76,8 @@ const createAlert = (config = {}) => {
)
}

const cleanSchema = schema => {
if (!schema) return
return {
type: schema.type,
'x-props': schema['x-props'],
'x-component': schema['x-component'],
'x-index': schema['x-index'],
'x-rules': schema['x-rules'],
maxItems: schema.maxItems,
minItems: schema.minItems,
default: schema.default,
enum: schema.enum,
title: schema.title,
required: schema.required,
properties: Object.keys(schema.properties || {}).reduce((buf, key) => {
buf = buf || {}
buf[key] = cleanSchema(schema.properties[key])
return buf
}, undefined),
items: cleanSchema(schema.items)
}
}

const printSchema = schema => {
return JSON.stringify(cleanSchema(schema), null, 2)
return JSON.stringify(new Schema(schema).toJSON(), null, 2)
}

export default class extends React.Component {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,6 @@ Object {
"x-component-props": Object {
"title": "this is card",
},
"x-props": Object {
"title": "this is card",
},
},
"unmounted": false,
"visible": true,
Expand Down Expand Up @@ -192,9 +189,6 @@ Object {
"x-component-props": Object {
"title": "this is card",
},
"x-props": Object {
"title": "this is card",
},
},
},
"type": "object",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ export function createVirtualBox<T = {}>(
visible={visible}
display={display}
x-component={key}
x-props={props}
x-component-props={props}
>
{children}
Expand All @@ -122,7 +121,6 @@ export function createControllerBox<T = {}>(
type="object"
name={name}
x-component={key}
x-props={props}
x-component-props={props}
>
{children}
Expand Down

0 comments on commit eb4b4e3

Please sign in to comment.