mirror of
https://github.com/ritz078/transform.git
synced 2026-11-25 02:10:02 +03:00
move constants folder to src/constants
This commit is contained in:
1 parent
cfa569da78
commit
2faec2dcba
6 files changed
+2
-2
No files matched your search
@@ -0,0 +1,5 @@
|
||||
export enum BabelTransforms {
|
||||
JSON_TO_PROPTYPES = 1,
|
||||
OBJECT_STYLES_TO_TEMPLATE,
|
||||
JSON_TO_MOBX_TREE
|
||||
}
|
||||
@@ -0,0 +1,327 @@
|
||||
export const json = JSON.stringify(
|
||||
{
|
||||
userId: 1,
|
||||
id: 1,
|
||||
title: "delectus aut autem",
|
||||
completed: false
|
||||
},
|
||||
null,
|
||||
2
|
||||
);
|
||||
|
||||
export const html = `<!-- Hello world -->
|
||||
<div class="awesome" style="border: 1px solid red">
|
||||
<label for="name">Enter your name: </label>
|
||||
<input type="text" id="name" />
|
||||
</div>
|
||||
<p>Enter your HTML here</p>`;
|
||||
|
||||
export const svg = `<svg style="flex:1;" xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<rect x="10" y="10" height="100" width="100"
|
||||
style="stroke:#ff0000; fill: #0000ff"/>
|
||||
</svg>`;
|
||||
|
||||
export const css = `.main-wrapper {
|
||||
flex-direction: row;
|
||||
display: flex;
|
||||
flex: 1;
|
||||
}
|
||||
#content {
|
||||
flex: 1;
|
||||
}
|
||||
ul {
|
||||
padding: 20px 0;
|
||||
flex: 1;
|
||||
}
|
||||
li {
|
||||
font-family:'Lato';
|
||||
color: whitesmoke;
|
||||
line-height: 44px;
|
||||
}
|
||||
`;
|
||||
|
||||
export const javascript = `const container = css({
|
||||
flex: 1,
|
||||
padding: 10,
|
||||
backgroundColor: 'orange',
|
||||
color: colors.white,
|
||||
|
||||
'&:hover': {
|
||||
backgroundColor: 'tomato',
|
||||
},
|
||||
});`;
|
||||
|
||||
export const yaml = `---
|
||||
foo: "bar"
|
||||
baz:
|
||||
- "qux"
|
||||
- "quxx"
|
||||
corge: null
|
||||
grault: 1
|
||||
garply: true
|
||||
waldo: "false"
|
||||
fred: "undefined"
|
||||
emptyarr: []
|
||||
emptyobj: {}
|
||||
`;
|
||||
|
||||
export const xml = `<note>
|
||||
<to>Tove</to>
|
||||
<from>Jani</from>
|
||||
<heading>Reminder</heading>
|
||||
<body>Don't forget me this weekend!</body>
|
||||
</note>
|
||||
`;
|
||||
|
||||
export const markdown = `Heading
|
||||
=======
|
||||
## Sub-heading
|
||||
Paragraphs are separated
|
||||
by a blank line.
|
||||
Two spaces at the end of a line
|
||||
produces a line break.
|
||||
Text attributes _italic_,
|
||||
**bold**, \`monospace\`.
|
||||
Horizontal rule:
|
||||
---
|
||||
Bullet list:
|
||||
* apples
|
||||
* oranges
|
||||
* pears
|
||||
Numbered list:
|
||||
1. wash
|
||||
2. rinse
|
||||
3. repeat
|
||||
A [link](http://example.com).
|
||||

|
||||
> Markdown uses email-style > characters for blockquoting.
|
||||
`;
|
||||
|
||||
export const flow = `export type AlertType = 'success'
|
||||
|
||||
export type AlertProps = {
|
||||
type: AlertType,
|
||||
text: string,
|
||||
testId: string,
|
||||
}
|
||||
|
||||
type AlertTypeIconMap = {
|
||||
+[AlertType]: IconType,
|
||||
}
|
||||
|
||||
const Alert = ({ type, text, testId }: AlertProps) => {
|
||||
const alertTypeIconMap: AlertTypeIconMap = {
|
||||
success: 'tick',
|
||||
}
|
||||
const styles = getStyles({ type })
|
||||
|
||||
return (
|
||||
<View style={styles.iconContainer}>
|
||||
<Icon type={alertTypeIconMap[type]} />
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
export default Alert`;
|
||||
|
||||
export const graphql = `type Query {
|
||||
user: User!
|
||||
}
|
||||
type User {
|
||||
id: ID!
|
||||
profile: Profile!
|
||||
email: String!
|
||||
username: String!
|
||||
}
|
||||
type Profile {
|
||||
name: String!
|
||||
age: Int!
|
||||
}`;
|
||||
|
||||
export const graphql1 = `scalar Date
|
||||
|
||||
schema {
|
||||
query: Query
|
||||
}
|
||||
|
||||
type Query {
|
||||
me: User!
|
||||
user(id: ID!): User
|
||||
allUsers: [User]
|
||||
search(term: String!): [SearchResult!]!
|
||||
myChats: [Chat!]!
|
||||
}
|
||||
|
||||
enum Role {
|
||||
USER,
|
||||
ADMIN,
|
||||
}
|
||||
|
||||
interface Node {
|
||||
id: ID!
|
||||
}
|
||||
|
||||
union SearchResult = User | Chat | ChatMessage
|
||||
|
||||
type User implements Node {
|
||||
id: ID!
|
||||
username: String!
|
||||
email: String!
|
||||
role: Role!
|
||||
}
|
||||
|
||||
type Chat implements Node {
|
||||
id: ID!
|
||||
users: [User!]!
|
||||
messages: [ChatMessage!]!
|
||||
}
|
||||
|
||||
type ChatMessage implements Node {
|
||||
id: ID!
|
||||
content: String!
|
||||
time: Date!
|
||||
user: User!
|
||||
}
|
||||
`;
|
||||
|
||||
export const graphqlDocument = `query findUser($userId: ID!) {
|
||||
user(id: $userId) {
|
||||
...UserFields
|
||||
}
|
||||
}
|
||||
|
||||
fragment UserFields on User {
|
||||
id
|
||||
username
|
||||
role
|
||||
}`;
|
||||
|
||||
export const graphqlMongodb = `type User @entity {
|
||||
id: ID! @id
|
||||
username: String! @column
|
||||
email: String! @column @map(
|
||||
path: "login.email"
|
||||
)
|
||||
profile: Profile! @column
|
||||
chats: [Chat!]! @link
|
||||
}
|
||||
|
||||
type Profile @entity(embedded: true,
|
||||
additionalFields: [
|
||||
{ path: "dateOfBirth", type: "string" }
|
||||
]) {
|
||||
name: String! @column
|
||||
age: Int
|
||||
}
|
||||
|
||||
type Chat @entity {
|
||||
id: ID! @id
|
||||
users: [User!]! @link
|
||||
messages: [ChatMessage!]!
|
||||
}
|
||||
|
||||
type ChatMessage @entity {
|
||||
id: ID! @id
|
||||
chat: Chat! @link
|
||||
content: String! @column
|
||||
author: User! @link
|
||||
}`;
|
||||
|
||||
export const jsObject = `{
|
||||
title: {
|
||||
type: 'String',
|
||||
trim: true,
|
||||
index: true,
|
||||
required: true
|
||||
},
|
||||
year: {
|
||||
type: 'Number',
|
||||
max: 2012,
|
||||
validate: 'validateBookYear'
|
||||
},
|
||||
author: {
|
||||
type: 'ObjectId',
|
||||
ref: 'Author',
|
||||
index: true,
|
||||
required: true
|
||||
}
|
||||
}`;
|
||||
|
||||
export const jsonSchema = `{
|
||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||
"title": "Example Schema",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"firstName": {
|
||||
"type": "string"
|
||||
},
|
||||
"lastName": {
|
||||
"type": "string"
|
||||
},
|
||||
"age": {
|
||||
"description": "Age in years",
|
||||
"type": "integer",
|
||||
"minimum": 0
|
||||
},
|
||||
"height": {
|
||||
"type": ["number", "null"]
|
||||
},
|
||||
"favoriteFoods": {
|
||||
"type": "array",
|
||||
"minItems": 0,
|
||||
"maxItems": 2,
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"likesDogs": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"required": ["firstName", "lastName"]
|
||||
}`;
|
||||
|
||||
export const jsonLd = `{
|
||||
"@context": "https://schema.org/",
|
||||
"@type": "Person",
|
||||
"name": "Jane Doe",
|
||||
"jobTitle": "Professor",
|
||||
"telephone": "(425) 123-4567",
|
||||
"url": "http://www.janedoe.com"
|
||||
}
|
||||
`;
|
||||
|
||||
export const jsonLdContext = `{
|
||||
"@context": "https://schema.org/"
|
||||
}`;
|
||||
|
||||
export const typescript = `declare module "evergreen-ui" {
|
||||
export interface PaneProps {
|
||||
elevation?: number;
|
||||
className?: string;
|
||||
css?: any;
|
||||
is?: any;
|
||||
}
|
||||
|
||||
type Intent = "none" | "success" | "warning" | "danger";
|
||||
type Appearance = "minimal" | "primary" | "default";
|
||||
|
||||
export interface ButtonProps {
|
||||
intent?: Intent;
|
||||
appearance?: Appearance;
|
||||
isLoading?: boolean;
|
||||
isActive?: boolean;
|
||||
iconBefore?: string;
|
||||
iconAfter?: string;
|
||||
disabled?: boolean;
|
||||
theme?: any;
|
||||
className?: string;
|
||||
children: any;
|
||||
is?: string;
|
||||
href?: string;
|
||||
onClick?: () => void;
|
||||
css?: any;
|
||||
}
|
||||
}
|
||||
`;
|
||||
@@ -0,0 +1,16 @@
|
||||
export enum GraphqlTransforms {
|
||||
TO_TYPESCRIPT = 1,
|
||||
TO_FLOW,
|
||||
TO_INTROSPECTION_JSON,
|
||||
TO_FRAGMENT_MATCHER,
|
||||
TO_SCHEMA_AST,
|
||||
TO_JAVA,
|
||||
TO_REACT_APOLLO,
|
||||
TO_APOLLO_ANGULAR,
|
||||
TO_STENCIL_APOLLO,
|
||||
TO_JAVA_RESOLVERS_SIGNATURE,
|
||||
TO_TYPESCRIPT_RESOLVERS_SIGNATURE,
|
||||
TO_FLOW_RESOLVERS_SIGNATURE,
|
||||
TO_URQL,
|
||||
TO_TYPESCRIPT_MONGODB
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
import { InputType } from "@components/Form";
|
||||
import { lowerCase, omit } from "lodash";
|
||||
|
||||
export interface Settings {
|
||||
removeTitle: boolean;
|
||||
removeDesc: boolean;
|
||||
removeUselessDefs: boolean;
|
||||
removeEditorsNSData: boolean;
|
||||
removeEmptyAttrs: boolean;
|
||||
removeHiddenElems: boolean;
|
||||
removeEmptyText: boolean;
|
||||
removeEmptyContainers: boolean;
|
||||
removeViewBox: boolean;
|
||||
cleanupEnableBackground: boolean;
|
||||
convertColors: boolean;
|
||||
convertPathData: boolean;
|
||||
convertTransform: boolean;
|
||||
removeUnknownsAndDefaults: boolean;
|
||||
removeNonInheritableGroupAttrs: boolean;
|
||||
removeUselessStrokeAndFill: boolean;
|
||||
removeUnusedNS: boolean;
|
||||
cleanupIDs: boolean;
|
||||
cleanupNumericValues: boolean;
|
||||
moveElemsAttrsToGroup: boolean;
|
||||
moveGroupAttrsToElems: boolean;
|
||||
collapseGroups: boolean;
|
||||
removeRasterImages: boolean;
|
||||
mergePaths: boolean;
|
||||
convertShapeToPath: boolean;
|
||||
sortAttrs: boolean;
|
||||
optimizeSvg: boolean;
|
||||
}
|
||||
|
||||
export const nativeRequiredSettings = {
|
||||
cleanupAttrs: true,
|
||||
inlineStyles: true,
|
||||
minifyStyles: true,
|
||||
convertStyleToAttrs: true,
|
||||
removeDoctype: true,
|
||||
removeXMLProcInst: false,
|
||||
removeComments: true,
|
||||
removeMetadata: true,
|
||||
removeDimensions: false
|
||||
};
|
||||
|
||||
export const defaultSettings = {
|
||||
optimizeSvg: true,
|
||||
...nativeRequiredSettings,
|
||||
removeComments: true,
|
||||
removeMetadata: true,
|
||||
removeTitle: true,
|
||||
removeDesc: true,
|
||||
removeUselessDefs: true,
|
||||
removeEditorsNSData: true,
|
||||
removeEmptyAttrs: true,
|
||||
removeHiddenElems: true,
|
||||
removeEmptyText: true,
|
||||
removeEmptyContainers: true,
|
||||
removeViewBox: false,
|
||||
cleanupEnableBackground: true,
|
||||
convertColors: true,
|
||||
convertPathData: true,
|
||||
convertTransform: true,
|
||||
removeUnknownsAndDefaults: true,
|
||||
removeNonInheritableGroupAttrs: true,
|
||||
removeUselessStrokeAndFill: true,
|
||||
removeUnusedNS: true,
|
||||
cleanupIDs: true,
|
||||
cleanupNumericValues: false,
|
||||
moveElemsAttrsToGroup: true,
|
||||
moveGroupAttrsToElems: true,
|
||||
collapseGroups: true,
|
||||
removeRasterImages: true,
|
||||
mergePaths: true,
|
||||
convertShapeToPath: true,
|
||||
sortAttrs: true
|
||||
};
|
||||
|
||||
export const defaultNativeSettings = omit(
|
||||
defaultSettings,
|
||||
Object.keys(nativeRequiredSettings)
|
||||
);
|
||||
|
||||
export const formFields = settings =>
|
||||
Object.keys(settings).map((property: keyof Settings) => ({
|
||||
label: lowerCase(property),
|
||||
type: InputType.SWITCH,
|
||||
key: property,
|
||||
...(property !== "optimizeSvg"
|
||||
? {
|
||||
isDisabled: values => !values.optimizeSvg,
|
||||
props: { paddingLeft: 20, borderLeft: "2px solid #FDF8F3" }
|
||||
}
|
||||
: {})
|
||||
}));
|
||||
Reference in new issue
Block a user