Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修改 npm包依赖 #659

Merged
merged 8 commits into from
Feb 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/meet-componments/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
*.log
build
__tests__
20 changes: 20 additions & 0 deletions packages/meet-componments/LESENCE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
The MIT License (MIT)

Copyright (c) 2015-present, Alibaba Group Holding Limited. All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
9 changes: 9 additions & 0 deletions packages/meet-componments/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# @formily/meet-components

### Install

```bash
npm install --save @formily/meet-components
```


8 changes: 8 additions & 0 deletions packages/meet-componments/README.zh-cn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# @formily/meet-components

### 安装

```bash
npm install --save @formily/meet-components
```

13 changes: 13 additions & 0 deletions packages/meet-componments/build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"plugins": [
[
"rax-plugin-app",
{
"targets": [
"web"
]
}
],
"rax-plugin-compat-react"
]
}
37 changes: 37 additions & 0 deletions packages/meet-componments/build.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { compile, getCompileConfig } from '../../scripts/build'
import ts from 'typescript'
import tsImportPluginFactory from 'ts-import-plugin'
import glob from 'glob'

const transformer = tsImportPluginFactory({
libraryName: '@alifd/meet-componments',
//style: importPath => `${importPath}/style`,
})

function buildESM() {
const { fileNames, options } = getCompileConfig(require.resolve('./tsconfig.json'), {
outDir: './esm',
module: ts.ModuleKind.ESNext
})
compile(fileNames, options, { before: [transformer] })
console.log('esm build successfully')
}

function buildES5() {
const rootNames = glob.sync('./esm/**/*.js')
compile(rootNames, {
allowJs: true,
esModuleInterop: true,
moduleResolution: ts.ModuleResolutionKind.NodeJs,
module: ts.ModuleKind.CommonJS,
target: ts.ScriptTarget.ES5,
outDir: './lib',
declaration: false,
})
console.log('es5 build successfully')
}



buildESM()
buildES5()
52 changes: 52 additions & 0 deletions packages/meet-componments/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"name": "@formily/meet-components",
"version": "1.0.0",
"license": "MIT",
"main": "lib",
"module": "esm",
"repository": {
"type": "git",
"url": "git+https://github.com/alibaba/formily.git"
},
"types": "esm/index.d.ts",
"bugs": {
"url": "https://github.com/alibaba/formily/issues"
},
"homepage": "https://github.com/alibaba/formily#readme",
"engines": {
"npm": ">=3.0.0"
},
"scripts": {
"build": "ts-node --project ../../tsconfig.build.json build.ts"
},
"peerDependencies": {
"@babel/runtime": "^7.4.4",
"react": ">=16.8.0",
"react-dom": ">=16.8.0"
},
"dependencies": {
"@alifd/meet": "^1.0.0-beta.25",
"@formily/react": "^1.0.0-rc.4",
"@formily/react-schema-renderer": "^1.0.0-rc.4",
"@formily/react-shared-components": "^1.0.0-rc.4",
"@formily/shared": "^1.0.0-rc.4",
"classnames": "^2.2.6",
"styled-components": "^4.1.1",
"@rax-ui/locale": "^1.0.0-beta.10",
"rax-plugin-app": "^0.2.19",
"rax": "^1.1.1",
"rax-app": "^0.1.0",
"rax-dom": "^1.0.1",
"rax-image": "^1.0.3",
"rax-link": "^1.0.1",
"rax-recyclerview": "^1.1.1",
"rax-text": "^1.0.0",
"rax-view": "^1.0.0",
"universal-navigate": "^1.0.0"
},
"devDependencies": {},
"publishConfig": {
"access": "public"
},
"gitHead": "4d068dad6183e8da294a4c899a158326c0b0b050"
}
1 change: 1 addition & 0 deletions packages/meet-componments/src/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './registry'
5 changes: 5 additions & 0 deletions packages/meet-componments/src/registry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { registerFormFields } from '@formily/meet'

export const setup = () => {
registerFormFields({})
}
64 changes: 64 additions & 0 deletions packages/meet-componments/src/shared.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import React from 'react'
import { mapTextComponent, mapStyledProps, normalizeCol } from '@formily/meet'
import { Select as MeetSelect } from '@alifd/meet'
import { SelectComponent as MeetSelectProps } from '@alifd/meet/types/select'
import styled from 'styled-components'
export * from '@formily/shared'

export const compose = (...args: any[]) => {
return (payload: any, ...extra: any[]) => {
return args.reduce((buf, fn) => {
return buf !== undefined ? fn(buf, ...extra) : fn(payload, ...extra)
}, payload)
}
}

interface SelectOption {
label: React.ReactText
value: any
[key: string]: any
}

type SelectProps = MeetSelectProps & {
dataSource?: SelectOption[]
}

const Select: React.FC<SelectProps> = styled((props: SelectProps) => {
const { dataSource = [], ...others } = props
const children = dataSource.map(item => {
const { label, value, ...others } = item
return (
<MeetSelect key={value} {...others} title={label as string} value={value}>
{label}
</MeetSelect>
)
})
return (
<MeetSelect className={props.className} {...others}>
{children}
</MeetSelect>
)
})`
min-width: 100px;
width: 100%;
`
export const acceptEnum = (component: React.JSXElementConstructor<any>) => {
return ({ dataSource, ...others }) => {
if (dataSource) {
return React.createElement(Select, { dataSource, ...others })
} else {
return React.createElement(component, others)
}
}
}

export const transformDataSourceKey = (component, dataSourceKey) => {
return ({ dataSource, ...others }) => {
return React.createElement(component, {
[dataSourceKey]: dataSource,
...others
})
}
}

export { mapTextComponent, mapStyledProps, normalizeCol }
88 changes: 88 additions & 0 deletions packages/meet-componments/src/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import { ButtonProps } from '@alifd/meet/types/button'
import { FormProps, FormItemProps as ItemProps } from '@alifd/meet/types/form'
import {
ISchemaFormProps,
IMarkupSchemaFieldProps,
ISchemaFieldComponentProps
// FormPathPattern
} from '@formily/react-schema-renderer'
import { PreviewTextConfigProps } from '@formily/react-shared-components'
import { StyledComponent } from 'styled-components'

type ColSpanType = number | string

export type IAntdSchemaFormProps = Omit<
FormProps,
'onSubmit' | 'defaultValue'
> &
IFormItemTopProps &
PreviewTextConfigProps &
ISchemaFormProps

export type IAntdSchemaFieldProps = IMarkupSchemaFieldProps

export interface ISubmitProps extends ButtonProps {
onSubmit?: ISchemaFormProps['onSubmit']
showLoading?: boolean
}

export interface IResetProps extends ButtonProps {
forceClear?: boolean
validate?: boolean
}

export type IFormItemTopProps = React.PropsWithChildren<
Exclude<
Pick<ItemProps, 'prefixCls' | 'labelCol' | 'wrapperCol' | 'labelAlign'>,
'labelCol' | 'wrapperCol'
> & {
inline?: boolean
className?: string
style?: React.CSSProperties
labelCol?: number | { span: number; offset?: number }
wrapperCol?: number | { span: number; offset?: number }
}
>

export interface ISchemaFieldAdaptorProps
extends Omit<ItemProps, 'labelCol' | 'wrapperCol'>,
Partial<ISchemaFieldComponentProps> {
labelCol?: number | { span: number; offset?: number }
wrapperCol?: number | { span: number; offset?: number }
}

export type StyledCP<P extends {}> = StyledComponent<
(props: React.PropsWithChildren<P>) => React.ReactElement,
any,
{},
never
>

export type StyledCC<Props, Statics = {}> = StyledCP<Props> & Statics

export interface IFormButtonGroupProps {
sticky?: boolean
style?: React.CSSProperties
itemStyle?: React.CSSProperties
className?: string
align?: 'left' | 'right' | 'start' | 'end' | 'top' | 'bottom' | 'center'
triggerDistance?: number
zIndex?: number
span?: ColSpanType
offset?: ColSpanType
}

export interface IItemProps {
title?: React.ReactText
description?: React.ReactText
}

export interface IFormItemGridProps extends IItemProps {
cols?: Array<number | { span: number; offset: number }>
gutter?: number
}

export interface IFormTextBox extends IItemProps {
text?: string
gutter?: number
}
14 changes: 14 additions & 0 deletions packages/meet-componments/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "./lib"
},
"include": [
"./src/**/*.js",
"./src/**/*.ts",
"./src/**/*.tsx"
],
"exclude": [
"./src/__tests__/*"
]
}
37 changes: 37 additions & 0 deletions packages/meet/build.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { compile, getCompileConfig } from '../../scripts/build'
import ts from 'typescript'
import tsImportPluginFactory from 'ts-import-plugin'
import glob from 'glob'

const transformer = tsImportPluginFactory({
libraryName: '@alifd/meet',
//style: importPath => `${importPath}/style`,
})

function buildESM() {
const { fileNames, options } = getCompileConfig(require.resolve('./tsconfig.json'), {
outDir: './esm',
module: ts.ModuleKind.ESNext
})
compile(fileNames, options, { before: [transformer] })
console.log('esm build successfully')
}

function buildES5() {
const rootNames = glob.sync('./esm/**/*.js')
compile(rootNames, {
allowJs: true,
esModuleInterop: true,
moduleResolution: ts.ModuleResolutionKind.NodeJs,
module: ts.ModuleKind.CommonJS,
target: ts.ScriptTarget.ES5,
outDir: './lib',
declaration: false,
})
console.log('es5 build successfully')
}



buildESM()
buildES5()
6 changes: 2 additions & 4 deletions packages/meet/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@formily/next",
"name": "@formily/meet",
"version": "1.0.0",
"license": "MIT",
"main": "lib",
Expand All @@ -26,9 +26,7 @@
},
"dependencies": {
"@alifd/meet": "^1.0.0-beta.25",
"@formily/react": "^0.4.4",
"@formily/types": "^0.4.4",
"@formily/utils": "^0.4.4",
"@formily/react": "^1.0.0-rc.4",
"@formily/react-schema-renderer": "^1.0.0-rc.4",
"@formily/react-shared-components": "^1.0.0-rc.4",
"@formily/shared": "^1.0.0-rc.4",
Expand Down
1 change: 0 additions & 1 deletion packages/meet/src/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
MergedFieldComponentProps
} from '@formily/react-schema-renderer'
import { Select } from '@alifd/meet'
// import RadioSelect from './extends/RadioSelect'
export * from '@formily/shared'

export const mapSelectComponent = (
Expand Down