From 06837f9e04eb7be30909a6806efccef51adefe17 Mon Sep 17 00:00:00 2001 From: DarK-AleX-alibaba <56540313+DarK-AleX-alibaba@users.noreply.github.com> Date: Wed, 19 Feb 2020 19:50:51 +0800 Subject: [PATCH] fix(@formily/meet): fix pacakge config (#659) --- packages/meet-componments/.npmignore | 4 ++ packages/meet-componments/LESENCE.md | 20 ++++++ packages/meet-componments/README.md | 9 +++ packages/meet-componments/README.zh-cn.md | 8 +++ packages/meet-componments/build.json | 13 ++++ packages/meet-componments/build.ts | 37 ++++++++++ packages/meet-componments/package.json | 52 ++++++++++++++ packages/meet-componments/src/index.tsx | 1 + packages/meet-componments/src/registry.ts | 5 ++ packages/meet-componments/src/shared.tsx | 64 +++++++++++++++++ packages/meet-componments/src/types.ts | 88 +++++++++++++++++++++++ packages/meet-componments/tsconfig.json | 14 ++++ packages/meet/build.ts | 37 ++++++++++ packages/meet/package.json | 6 +- packages/meet/src/shared.ts | 1 - 15 files changed, 354 insertions(+), 5 deletions(-) create mode 100644 packages/meet-componments/.npmignore create mode 100644 packages/meet-componments/LESENCE.md create mode 100644 packages/meet-componments/README.md create mode 100644 packages/meet-componments/README.zh-cn.md create mode 100644 packages/meet-componments/build.json create mode 100644 packages/meet-componments/build.ts create mode 100644 packages/meet-componments/package.json create mode 100644 packages/meet-componments/src/index.tsx create mode 100644 packages/meet-componments/src/registry.ts create mode 100644 packages/meet-componments/src/shared.tsx create mode 100644 packages/meet-componments/src/types.ts create mode 100644 packages/meet-componments/tsconfig.json create mode 100644 packages/meet/build.ts diff --git a/packages/meet-componments/.npmignore b/packages/meet-componments/.npmignore new file mode 100644 index 00000000000..cc5cbf1a4ed --- /dev/null +++ b/packages/meet-componments/.npmignore @@ -0,0 +1,4 @@ +node_modules +*.log +build +__tests__ \ No newline at end of file diff --git a/packages/meet-componments/LESENCE.md b/packages/meet-componments/LESENCE.md new file mode 100644 index 00000000000..2bd9316cd51 --- /dev/null +++ b/packages/meet-componments/LESENCE.md @@ -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. \ No newline at end of file diff --git a/packages/meet-componments/README.md b/packages/meet-componments/README.md new file mode 100644 index 00000000000..d0e974659f1 --- /dev/null +++ b/packages/meet-componments/README.md @@ -0,0 +1,9 @@ +# @formily/meet-components + +### Install + +```bash +npm install --save @formily/meet-components +``` + + diff --git a/packages/meet-componments/README.zh-cn.md b/packages/meet-componments/README.zh-cn.md new file mode 100644 index 00000000000..dbb252f9132 --- /dev/null +++ b/packages/meet-componments/README.zh-cn.md @@ -0,0 +1,8 @@ +# @formily/meet-components + +### 安装 + +```bash +npm install --save @formily/meet-components +``` + diff --git a/packages/meet-componments/build.json b/packages/meet-componments/build.json new file mode 100644 index 00000000000..95623900c9a --- /dev/null +++ b/packages/meet-componments/build.json @@ -0,0 +1,13 @@ +{ + "plugins": [ + [ + "rax-plugin-app", + { + "targets": [ + "web" + ] + } + ], + "rax-plugin-compat-react" + ] +} diff --git a/packages/meet-componments/build.ts b/packages/meet-componments/build.ts new file mode 100644 index 00000000000..5e869726c0b --- /dev/null +++ b/packages/meet-componments/build.ts @@ -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() diff --git a/packages/meet-componments/package.json b/packages/meet-componments/package.json new file mode 100644 index 00000000000..d52acf5b560 --- /dev/null +++ b/packages/meet-componments/package.json @@ -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" +} diff --git a/packages/meet-componments/src/index.tsx b/packages/meet-componments/src/index.tsx new file mode 100644 index 00000000000..62365fb9375 --- /dev/null +++ b/packages/meet-componments/src/index.tsx @@ -0,0 +1 @@ +export * from './registry' diff --git a/packages/meet-componments/src/registry.ts b/packages/meet-componments/src/registry.ts new file mode 100644 index 00000000000..e1b0e12c191 --- /dev/null +++ b/packages/meet-componments/src/registry.ts @@ -0,0 +1,5 @@ +import { registerFormFields } from '@formily/meet' + +export const setup = () => { + registerFormFields({}) +} diff --git a/packages/meet-componments/src/shared.tsx b/packages/meet-componments/src/shared.tsx new file mode 100644 index 00000000000..a2bc81cb020 --- /dev/null +++ b/packages/meet-componments/src/shared.tsx @@ -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 = styled((props: SelectProps) => { + const { dataSource = [], ...others } = props + const children = dataSource.map(item => { + const { label, value, ...others } = item + return ( + + {label} + + ) + }) + return ( + + {children} + + ) +})` + min-width: 100px; + width: 100%; +` +export const acceptEnum = (component: React.JSXElementConstructor) => { + 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 } diff --git a/packages/meet-componments/src/types.ts b/packages/meet-componments/src/types.ts new file mode 100644 index 00000000000..182da45dc59 --- /dev/null +++ b/packages/meet-componments/src/types.ts @@ -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, + '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, + Partial { + labelCol?: number | { span: number; offset?: number } + wrapperCol?: number | { span: number; offset?: number } +} + +export type StyledCP

= StyledComponent< + (props: React.PropsWithChildren

) => React.ReactElement, + any, + {}, + never +> + +export type StyledCC = StyledCP & 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 + gutter?: number +} + +export interface IFormTextBox extends IItemProps { + text?: string + gutter?: number +} diff --git a/packages/meet-componments/tsconfig.json b/packages/meet-componments/tsconfig.json new file mode 100644 index 00000000000..7bd62b594ce --- /dev/null +++ b/packages/meet-componments/tsconfig.json @@ -0,0 +1,14 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "outDir": "./lib" + }, + "include": [ + "./src/**/*.js", + "./src/**/*.ts", + "./src/**/*.tsx" + ], + "exclude": [ + "./src/__tests__/*" + ] +} diff --git a/packages/meet/build.ts b/packages/meet/build.ts new file mode 100644 index 00000000000..74bfdc62644 --- /dev/null +++ b/packages/meet/build.ts @@ -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() diff --git a/packages/meet/package.json b/packages/meet/package.json index 9cff2b49ea3..d89f1e0b41c 100644 --- a/packages/meet/package.json +++ b/packages/meet/package.json @@ -1,5 +1,5 @@ { - "name": "@formily/next", + "name": "@formily/meet", "version": "1.0.0", "license": "MIT", "main": "lib", @@ -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", diff --git a/packages/meet/src/shared.ts b/packages/meet/src/shared.ts index b0dd993c6ed..98f0550a62f 100644 --- a/packages/meet/src/shared.ts +++ b/packages/meet/src/shared.ts @@ -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 = (