@faasjs/ant-design 0.0.3-development → 0.0.4-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,79 +1,50 @@
1
1
  {
2
2
  "name": "@faasjs/ant-design",
3
- "version": "0.0.3-development",
4
- "main": "lib/index.js",
5
- "module": "lib/index.esm.js",
6
- "types": "lib/index.d.ts",
7
- "scripts": {
8
- "dev": "start-storybook",
9
- "build": "build-storybook",
10
- "prepack": "rollup -c",
11
- "test": "jest --coverage --ci"
12
- },
3
+ "version": "0.0.4-beta.10",
4
+ "license": "MIT",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.mjs",
7
+ "types": "dist/index.d.ts",
8
+ "homepage": "https://faasjs.com/doc/ant-design",
13
9
  "repository": {
14
10
  "type": "git",
15
- "url": "git+https://github.com/faasjs/ant-design.git"
11
+ "url": "git+https://github.com/faasjs/faasjs.git",
12
+ "directory": "packages/ant-design"
16
13
  },
17
- "license": "MIT",
18
14
  "bugs": {
19
- "url": "https://github.com/faasjs/ant-design/issues"
15
+ "url": "https://github.com/faasjs/faasjs/issues"
20
16
  },
21
- "homepage": "https://faasjs.com/ant-design",
22
17
  "funding": "https://github.com/sponsors/faasjs",
23
- "engines": {
24
- "npm": ">=8.0.0"
18
+ "scripts": {
19
+ "build": "tsup-node src/index.ts --config ../../tsup.config.json"
25
20
  },
26
21
  "files": [
27
- "lib"
22
+ "dist"
28
23
  ],
29
- "devDependencies": {
30
- "@faasjs/eslint-config-react": "^0.0.2-beta.302",
31
- "@storybook/addon-actions": "*",
32
- "@storybook/addon-essentials": "*",
33
- "@storybook/addon-links": "*",
34
- "@storybook/addon-postcss": "*",
35
- "@storybook/builder-webpack5": "*",
36
- "@storybook/manager-webpack5": "*",
37
- "@storybook/react": "*",
38
- "webpack": "^5",
39
- "rollup": "*",
40
- "rollup-plugin-typescript2": "*",
41
- "swc-loader": "*",
42
- "@swc/jest": "*",
43
- "@testing-library/jest-dom": "*",
44
- "@testing-library/react": "*",
45
- "jest": "*",
46
- "trim": ">=0.0.3",
47
- "immer": ">=9.0.6",
48
- "@types/lodash": "*"
24
+ "dependencies": {
25
+ "@ant-design/icons": "*",
26
+ "lodash-es": "*"
49
27
  },
50
28
  "peerDependencies": {
29
+ "@faasjs/react": "0.0.4-beta.10",
30
+ "antd": "*",
51
31
  "react": "*",
52
32
  "react-dom": "*",
53
- "antd": "*",
54
- "@ant-design/icons": "*",
55
- "lodash": "*"
33
+ "react-router-dom": "*"
56
34
  },
57
- "eslintConfig": {
58
- "extends": [
59
- "@faasjs/react"
60
- ]
35
+ "devDependencies": {
36
+ "@types/lodash-es": "*",
37
+ "@testing-library/jest-dom": "*",
38
+ "@testing-library/react": "*",
39
+ "@testing-library/user-event": "*",
40
+ "@faasjs/react": "0.0.4-beta.10",
41
+ "antd": "*",
42
+ "react": "*",
43
+ "react-dom": "*",
44
+ "react-router-dom": "*"
61
45
  },
62
- "jest": {
63
- "rootDir": "src",
64
- "transform": {
65
- ".(jsx|tsx?)": "@swc/jest"
66
- },
67
- "testEnvironment": "jsdom",
68
- "collectCoverageFrom": [
69
- "**/*.tsx"
70
- ],
71
- "testRegex": "/*\\.test\\.tsx?$",
72
- "moduleNameMapper": {
73
- "\\.(css|less)$": "<rootDir>/style-mock.js"
74
- },
75
- "setupFilesAfterEnv": [
76
- "./jest.setup.ts"
77
- ]
46
+ "engines": {
47
+ "npm": ">=9.0.0",
48
+ "node": ">=18.0.0"
78
49
  }
79
50
  }
@@ -1,60 +0,0 @@
1
- /// <reference types="react" />
2
- import { InferProps } from 'prop-types';
3
- import './button.css';
4
- declare const PropTypes: {
5
- /**
6
- * Is this the principal call to action on the page?
7
- */
8
- primary: import("prop-types").Requireable<boolean>;
9
- /**
10
- * What background color to use
11
- */
12
- backgroundColor: import("prop-types").Requireable<string>;
13
- /**
14
- * How large should the button be?
15
- */
16
- size: import("prop-types").Requireable<string>;
17
- /**
18
- * Button contents
19
- */
20
- label: import("prop-types").Validator<string>;
21
- /**
22
- * Optional click handler
23
- */
24
- onClick: import("prop-types").Requireable<(...args: any[]) => any>;
25
- };
26
- /**
27
- * Primary UI component for user interaction
28
- */
29
- export declare const Button: {
30
- ({ primary, backgroundColor, size, label, ...props }: InferProps<typeof PropTypes>): JSX.Element;
31
- propTypes: {
32
- /**
33
- * Is this the principal call to action on the page?
34
- */
35
- primary: import("prop-types").Requireable<boolean>;
36
- /**
37
- * What background color to use
38
- */
39
- backgroundColor: import("prop-types").Requireable<string>;
40
- /**
41
- * How large should the button be?
42
- */
43
- size: import("prop-types").Requireable<string>;
44
- /**
45
- * Button contents
46
- */
47
- label: import("prop-types").Validator<string>;
48
- /**
49
- * Optional click handler
50
- */
51
- onClick: import("prop-types").Requireable<(...args: any[]) => any>;
52
- };
53
- defaultProps: {
54
- backgroundColor: any;
55
- primary: boolean;
56
- size: string;
57
- onClick: any;
58
- };
59
- };
60
- export {};
@@ -1,36 +0,0 @@
1
- /// <reference types="react" />
2
- declare const _default: {
3
- title: string;
4
- component: {
5
- ({ primary, backgroundColor, size, label, ...props }: import("prop-types").InferProps<{
6
- primary: import("prop-types").Requireable<boolean>;
7
- backgroundColor: import("prop-types").Requireable<string>;
8
- size: import("prop-types").Requireable<string>;
9
- label: import("prop-types").Validator<string>;
10
- onClick: import("prop-types").Requireable<(...args: any[]) => any>;
11
- }>): JSX.Element;
12
- propTypes: {
13
- primary: import("prop-types").Requireable<boolean>;
14
- backgroundColor: import("prop-types").Requireable<string>;
15
- size: import("prop-types").Requireable<string>;
16
- label: import("prop-types").Validator<string>;
17
- onClick: import("prop-types").Requireable<(...args: any[]) => any>;
18
- };
19
- defaultProps: {
20
- backgroundColor: any;
21
- primary: boolean;
22
- size: string;
23
- onClick: any;
24
- };
25
- };
26
- argTypes: {
27
- backgroundColor: {
28
- control: string;
29
- };
30
- };
31
- };
32
- export default _default;
33
- export declare const Primary: any;
34
- export declare const Secondary: any;
35
- export declare const Large: any;
36
- export declare const Small: any;
@@ -1,11 +0,0 @@
1
- /// <reference types="react" />
2
- import { DescriptionsProps } from 'antd';
3
- import { FaasItemProps } from './data';
4
- export declare type DescriptionItemProps = FaasItemProps & {
5
- children?: JSX.Element;
6
- };
7
- export declare type DescriptionProps<T = any> = DescriptionsProps & {
8
- items: DescriptionItemProps[];
9
- dataSource: T;
10
- };
11
- export declare function Description(props: DescriptionProps): JSX.Element;
@@ -1,6 +0,0 @@
1
- import { ComponentStory, ComponentMeta } from '@storybook/react';
2
- import { Description } from './Description';
3
- import 'antd/dist/antd.css';
4
- declare const _default: ComponentMeta<typeof Description>;
5
- export default _default;
6
- export declare const Default: ComponentStory<typeof Description>;
@@ -1,7 +0,0 @@
1
- /// <reference types="react" />
2
- import { FormProps as AntdFormProps } from 'antd';
3
- import { FormItemProps } from './FormItem';
4
- export declare type FormProps = AntdFormProps & {
5
- items: FormItemProps[];
6
- };
7
- export declare function Form(props: FormProps): JSX.Element;
@@ -1,7 +0,0 @@
1
- import { ComponentStory, ComponentMeta } from '@storybook/react';
2
- import { Form } from './Form';
3
- import 'antd/dist/antd.css';
4
- declare const _default: ComponentMeta<typeof Form>;
5
- export default _default;
6
- export declare const Default: ComponentStory<typeof Form>;
7
- export declare const Required: ComponentStory<typeof Form>;
@@ -1,7 +0,0 @@
1
- /// <reference types="react" />
2
- import { FormItemProps as AntdFormItemProps } from 'antd';
3
- import { FaasItemProps } from './data';
4
- export declare type FormItemProps<T = any> = AntdFormItemProps<T> & FaasItemProps & {
5
- children?: JSX.Element;
6
- };
7
- export declare function FormItem<T>(props: FormItemProps<T>): JSX.Element;
@@ -1,11 +0,0 @@
1
- import { ComponentStory, ComponentMeta } from '@storybook/react';
2
- import { FormItem } from './FormItem';
3
- import 'antd/dist/antd.css';
4
- declare const _default: ComponentMeta<typeof FormItem>;
5
- export default _default;
6
- export declare const String: ComponentStory<typeof FormItem>;
7
- export declare const StringList: ComponentStory<typeof FormItem>;
8
- export declare const Number: ComponentStory<typeof FormItem>;
9
- export declare const NumberList: ComponentStory<typeof FormItem>;
10
- export declare const Boolean: ComponentStory<typeof FormItem>;
11
- export declare const Children: ComponentStory<typeof FormItem>;
@@ -1,19 +0,0 @@
1
- /// <reference types="react" />
2
- import './header.css';
3
- export declare const Header: {
4
- ({ user, onLogin, onLogout, onCreateAccount }: {
5
- user: any;
6
- onLogin: any;
7
- onLogout: any;
8
- onCreateAccount: any;
9
- }): JSX.Element;
10
- propTypes: {
11
- user: import("prop-types").Requireable<import("prop-types").InferProps<{}>>;
12
- onLogin: import("prop-types").Validator<(...args: any[]) => any>;
13
- onLogout: import("prop-types").Validator<(...args: any[]) => any>;
14
- onCreateAccount: import("prop-types").Validator<(...args: any[]) => any>;
15
- };
16
- defaultProps: {
17
- user: any;
18
- };
19
- };
@@ -1,24 +0,0 @@
1
- /// <reference types="react" />
2
- declare const _default: {
3
- title: string;
4
- component: {
5
- ({ user, onLogin, onLogout, onCreateAccount }: {
6
- user: any;
7
- onLogin: any;
8
- onLogout: any;
9
- onCreateAccount: any;
10
- }): JSX.Element;
11
- propTypes: {
12
- user: import("prop-types").Requireable<import("prop-types").InferProps<{}>>;
13
- onLogin: import("prop-types").Validator<(...args: any[]) => any>;
14
- onLogout: import("prop-types").Validator<(...args: any[]) => any>;
15
- onCreateAccount: import("prop-types").Validator<(...args: any[]) => any>;
16
- };
17
- defaultProps: {
18
- user: any;
19
- };
20
- };
21
- };
22
- export default _default;
23
- export declare const LoggedIn: any;
24
- export declare const LoggedOut: any;
@@ -1,22 +0,0 @@
1
- /// <reference types="react" />
2
- import { InferProps } from 'prop-types';
3
- import './page.css';
4
- declare const PropTypes: {
5
- user: import("prop-types").Requireable<InferProps<{}>>;
6
- onLogin: import("prop-types").Validator<(...args: any[]) => any>;
7
- onLogout: import("prop-types").Validator<(...args: any[]) => any>;
8
- onCreateAccount: import("prop-types").Validator<(...args: any[]) => any>;
9
- };
10
- export declare const Page: {
11
- ({ user, onLogin, onLogout, onCreateAccount }: InferProps<typeof PropTypes>): JSX.Element;
12
- propTypes: {
13
- user: import("prop-types").Requireable<InferProps<{}>>;
14
- onLogin: import("prop-types").Validator<(...args: any[]) => any>;
15
- onLogout: import("prop-types").Validator<(...args: any[]) => any>;
16
- onCreateAccount: import("prop-types").Validator<(...args: any[]) => any>;
17
- };
18
- defaultProps: {
19
- user: any;
20
- };
21
- };
22
- export {};
@@ -1,24 +0,0 @@
1
- /// <reference types="react" />
2
- declare const _default: {
3
- title: string;
4
- component: {
5
- ({ user, onLogin, onLogout, onCreateAccount }: import("prop-types").InferProps<{
6
- user: import("prop-types").Requireable<import("prop-types").InferProps<{}>>;
7
- onLogin: import("prop-types").Validator<(...args: any[]) => any>;
8
- onLogout: import("prop-types").Validator<(...args: any[]) => any>;
9
- onCreateAccount: import("prop-types").Validator<(...args: any[]) => any>;
10
- }>): JSX.Element;
11
- propTypes: {
12
- user: import("prop-types").Requireable<import("prop-types").InferProps<{}>>;
13
- onLogin: import("prop-types").Validator<(...args: any[]) => any>;
14
- onLogout: import("prop-types").Validator<(...args: any[]) => any>;
15
- onCreateAccount: import("prop-types").Validator<(...args: any[]) => any>;
16
- };
17
- defaultProps: {
18
- user: any;
19
- };
20
- };
21
- };
22
- export default _default;
23
- export declare const LoggedIn: any;
24
- export declare const LoggedOut: any;
@@ -1,8 +0,0 @@
1
- /// <reference types="react" />
2
- import { TableProps as AntdTableProps, TableColumnProps as AntdTableColumnProps } from 'antd';
3
- import { FaasItemProps } from './data';
4
- export declare type TableItemProps<T = any> = AntdTableColumnProps<T> & FaasItemProps;
5
- export declare type TableProps<T = any> = AntdTableProps<T> & {
6
- items: TableItemProps[];
7
- };
8
- export declare function Table(props: TableProps): JSX.Element;
@@ -1,6 +0,0 @@
1
- import { ComponentStory, ComponentMeta } from '@storybook/react';
2
- import { Table } from './Table';
3
- import 'antd/dist/antd.css';
4
- declare const _default: ComponentMeta<typeof Table>;
5
- export default _default;
6
- export declare const Default: ComponentStory<typeof Table>;
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,17 +0,0 @@
1
- export declare type FaasItemType = 'string' | 'string[]' | 'number' | 'number[]' | 'boolean';
2
- export declare type FaasItemTypeValue = {
3
- string: string;
4
- 'string[]': string[];
5
- number: number;
6
- 'number[]': number[];
7
- boolean: boolean;
8
- };
9
- export declare type FaasItemProps = {
10
- /**
11
- * Support string, string[], number, number[], boolean
12
- * @default 'string'
13
- */
14
- type?: FaasItemType;
15
- id: string;
16
- title?: string;
17
- };
package/lib/index.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export * from './components/Form';
2
- export * from './components/FormItem';
package/lib/index.esm.js DELETED
@@ -1,57 +0,0 @@
1
- import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
- import { Form as Form$1, Switch, Row, Col, InputNumber, Button, Input } from 'antd';
3
- import { MinusCircleOutlined, PlusOutlined } from '@ant-design/icons';
4
- import { useState, useEffect } from 'react';
5
- import { upperFirst } from 'lodash';
6
-
7
- function FormItem(props) {
8
- const [computedProps, setComputedProps] = useState();
9
- useEffect(() => {
10
- const propsCopy = { ...props };
11
- if (!propsCopy.title)
12
- propsCopy.title = upperFirst(propsCopy.id);
13
- if (!propsCopy.label)
14
- propsCopy.label = propsCopy.title;
15
- if (!propsCopy.name)
16
- propsCopy.name = propsCopy.id;
17
- if (!propsCopy.type)
18
- propsCopy.type = 'string';
19
- switch (propsCopy.type) {
20
- case 'boolean':
21
- propsCopy.valuePropName = 'checked';
22
- break;
23
- }
24
- setComputedProps(propsCopy);
25
- }, [JSON.stringify(props)]);
26
- if (!computedProps)
27
- return null;
28
- if (computedProps.children)
29
- return jsx(Form$1.Item, { ...computedProps, children: computedProps.children }, void 0);
30
- switch (computedProps.type) {
31
- case 'string':
32
- return jsx(Form$1.Item, { ...computedProps, children: jsx(Input, {}, void 0) }, void 0);
33
- case 'string[]':
34
- return jsx(Form$1.List, { name: computedProps.name, rules: computedProps.rules, children: (fields, { add, remove }) => {
35
- var _a;
36
- return jsxs(Fragment, { children: [jsx("div", { className: 'ant-row ant-form-item ant-form-item-label', style: { rowGap: '0px' }, children: jsx("label", { className: ((_a = computedProps.rules) === null || _a === void 0 ? void 0 : _a.find((r) => r.required)) && 'ant-form-item-required', children: computedProps.label }, void 0) }, void 0), fields.map(field => jsx(Form$1.Item, { children: jsxs(Row, { gutter: 16, children: [jsx(Col, { span: 23, children: jsx(Form$1.Item, { ...field, noStyle: true, children: jsx(Input, {}, void 0) }, void 0) }, void 0), jsx(Col, { span: 1, children: jsx(Button, { danger: true, type: 'link', style: { float: 'right' }, icon: jsx(MinusCircleOutlined, {}, void 0), onClick: () => remove(field.name) }, void 0) }, void 0)] }, void 0) }, field.key)), jsx(Form$1.Item, { children: jsx(Button, { type: 'dashed', block: true, onClick: () => add(), icon: jsx(PlusOutlined, {}, void 0) }, void 0) }, void 0)] }, void 0);
37
- } }, void 0);
38
- case 'number':
39
- return jsx(Form$1.Item, { ...computedProps, children: jsx(InputNumber, { style: { width: '100%' } }, void 0) }, void 0);
40
- case 'number[]':
41
- return jsx(Form$1.List, { name: computedProps.name, rules: computedProps.rules, children: (fields, { add, remove }) => {
42
- var _a;
43
- return jsxs(Fragment, { children: [jsx("div", { className: 'ant-row ant-form-item ant-form-item-label', style: { rowGap: '0px' }, children: jsx("label", { className: ((_a = computedProps.rules) === null || _a === void 0 ? void 0 : _a.find((r) => r.required)) && 'ant-form-item-required', children: computedProps.label }, void 0) }, void 0), fields.map(field => jsx(Form$1.Item, { children: jsxs(Row, { gutter: 16, children: [jsx(Col, { span: 23, children: jsx(Form$1.Item, { ...field, noStyle: true, children: jsx(InputNumber, { style: { width: '100%' } }, void 0) }, void 0) }, void 0), jsx(Col, { span: 1, children: jsx(Button, { danger: true, type: 'link', style: { float: 'right' }, icon: jsx(MinusCircleOutlined, {}, void 0), onClick: () => remove(field.name) }, void 0) }, void 0)] }, void 0) }, field.key)), jsx(Form$1.Item, { children: jsx(Button, { type: 'dashed', block: true, onClick: () => add(), icon: jsx(PlusOutlined, {}, void 0) }, void 0) }, void 0)] }, void 0);
44
- } }, void 0);
45
- case 'boolean':
46
- return jsx(Form$1.Item, { ...computedProps, children: jsx(Switch, {}, void 0) }, void 0);
47
- default:
48
- return null;
49
- }
50
- }
51
-
52
- function Form(props) {
53
- console.log(props);
54
- return jsx(Form$1, { ...props, children: props.items.map(item => jsx(FormItem, { ...item }, item.id)) }, void 0);
55
- }
56
-
57
- export { Form, FormItem };
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.esm.js","sources":["../node_modules/style-inject/dist/style-inject.es.js"],"sourcesContent":["function styleInject(css, ref) {\n if ( ref === void 0 ) ref = {};\n var insertAt = ref.insertAt;\n\n if (!css || typeof document === 'undefined') { return; }\n\n var head = document.head || document.getElementsByTagName('head')[0];\n var style = document.createElement('style');\n style.type = 'text/css';\n\n if (insertAt === 'top') {\n if (head.firstChild) {\n head.insertBefore(style, head.firstChild);\n } else {\n head.appendChild(style);\n }\n } else {\n head.appendChild(style);\n }\n\n if (style.styleSheet) {\n style.styleSheet.cssText = css;\n } else {\n style.appendChild(document.createTextNode(css));\n }\n}\n\nexport default styleInject;\n"],"names":[],"mappings":";;;AAAA,SAAS,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE;AAC/B,EAAE,KAAK,GAAG,KAAK,KAAK,CAAC,GAAG,GAAG,GAAG,EAAE,CAAC;AACjC,EAAE,IAAI,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC;AAC9B;AACA,EAAE,IAAI,CAAC,GAAG,IAAI,OAAO,QAAQ,KAAK,WAAW,EAAE,EAAE,OAAO,EAAE;AAC1D;AACA,EAAE,IAAI,IAAI,GAAG,QAAQ,CAAC,IAAI,IAAI,QAAQ,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;AACvE,EAAE,IAAI,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;AAC9C,EAAE,KAAK,CAAC,IAAI,GAAG,UAAU,CAAC;AAC1B;AACA,EAAE,IAAI,QAAQ,KAAK,KAAK,EAAE;AAC1B,IAAI,IAAI,IAAI,CAAC,UAAU,EAAE;AACzB,MAAM,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;AAChD,KAAK,MAAM;AACX,MAAM,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;AAC9B,KAAK;AACL,GAAG,MAAM;AACT,IAAI,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;AAC5B,GAAG;AACH;AACA,EAAE,IAAI,KAAK,CAAC,UAAU,EAAE;AACxB,IAAI,KAAK,CAAC,UAAU,CAAC,OAAO,GAAG,GAAG,CAAC;AACnC,GAAG,MAAM;AACT,IAAI,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC;AACpD,GAAG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/lib/index.js DELETED
@@ -1,62 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var jsxRuntime = require('react/jsx-runtime');
6
- var antd = require('antd');
7
- var icons = require('@ant-design/icons');
8
- var react = require('react');
9
- var lodash = require('lodash');
10
-
11
- function FormItem(props) {
12
- const [computedProps, setComputedProps] = react.useState();
13
- react.useEffect(() => {
14
- const propsCopy = { ...props };
15
- if (!propsCopy.title)
16
- propsCopy.title = lodash.upperFirst(propsCopy.id);
17
- if (!propsCopy.label)
18
- propsCopy.label = propsCopy.title;
19
- if (!propsCopy.name)
20
- propsCopy.name = propsCopy.id;
21
- if (!propsCopy.type)
22
- propsCopy.type = 'string';
23
- switch (propsCopy.type) {
24
- case 'boolean':
25
- propsCopy.valuePropName = 'checked';
26
- break;
27
- }
28
- setComputedProps(propsCopy);
29
- }, [JSON.stringify(props)]);
30
- if (!computedProps)
31
- return null;
32
- if (computedProps.children)
33
- return jsxRuntime.jsx(antd.Form.Item, { ...computedProps, children: computedProps.children }, void 0);
34
- switch (computedProps.type) {
35
- case 'string':
36
- return jsxRuntime.jsx(antd.Form.Item, { ...computedProps, children: jsxRuntime.jsx(antd.Input, {}, void 0) }, void 0);
37
- case 'string[]':
38
- return jsxRuntime.jsx(antd.Form.List, { name: computedProps.name, rules: computedProps.rules, children: (fields, { add, remove }) => {
39
- var _a;
40
- return jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: 'ant-row ant-form-item ant-form-item-label', style: { rowGap: '0px' }, children: jsxRuntime.jsx("label", { className: ((_a = computedProps.rules) === null || _a === void 0 ? void 0 : _a.find((r) => r.required)) && 'ant-form-item-required', children: computedProps.label }, void 0) }, void 0), fields.map(field => jsxRuntime.jsx(antd.Form.Item, { children: jsxRuntime.jsxs(antd.Row, { gutter: 16, children: [jsxRuntime.jsx(antd.Col, { span: 23, children: jsxRuntime.jsx(antd.Form.Item, { ...field, noStyle: true, children: jsxRuntime.jsx(antd.Input, {}, void 0) }, void 0) }, void 0), jsxRuntime.jsx(antd.Col, { span: 1, children: jsxRuntime.jsx(antd.Button, { danger: true, type: 'link', style: { float: 'right' }, icon: jsxRuntime.jsx(icons.MinusCircleOutlined, {}, void 0), onClick: () => remove(field.name) }, void 0) }, void 0)] }, void 0) }, field.key)), jsxRuntime.jsx(antd.Form.Item, { children: jsxRuntime.jsx(antd.Button, { type: 'dashed', block: true, onClick: () => add(), icon: jsxRuntime.jsx(icons.PlusOutlined, {}, void 0) }, void 0) }, void 0)] }, void 0);
41
- } }, void 0);
42
- case 'number':
43
- return jsxRuntime.jsx(antd.Form.Item, { ...computedProps, children: jsxRuntime.jsx(antd.InputNumber, { style: { width: '100%' } }, void 0) }, void 0);
44
- case 'number[]':
45
- return jsxRuntime.jsx(antd.Form.List, { name: computedProps.name, rules: computedProps.rules, children: (fields, { add, remove }) => {
46
- var _a;
47
- return jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: 'ant-row ant-form-item ant-form-item-label', style: { rowGap: '0px' }, children: jsxRuntime.jsx("label", { className: ((_a = computedProps.rules) === null || _a === void 0 ? void 0 : _a.find((r) => r.required)) && 'ant-form-item-required', children: computedProps.label }, void 0) }, void 0), fields.map(field => jsxRuntime.jsx(antd.Form.Item, { children: jsxRuntime.jsxs(antd.Row, { gutter: 16, children: [jsxRuntime.jsx(antd.Col, { span: 23, children: jsxRuntime.jsx(antd.Form.Item, { ...field, noStyle: true, children: jsxRuntime.jsx(antd.InputNumber, { style: { width: '100%' } }, void 0) }, void 0) }, void 0), jsxRuntime.jsx(antd.Col, { span: 1, children: jsxRuntime.jsx(antd.Button, { danger: true, type: 'link', style: { float: 'right' }, icon: jsxRuntime.jsx(icons.MinusCircleOutlined, {}, void 0), onClick: () => remove(field.name) }, void 0) }, void 0)] }, void 0) }, field.key)), jsxRuntime.jsx(antd.Form.Item, { children: jsxRuntime.jsx(antd.Button, { type: 'dashed', block: true, onClick: () => add(), icon: jsxRuntime.jsx(icons.PlusOutlined, {}, void 0) }, void 0) }, void 0)] }, void 0);
48
- } }, void 0);
49
- case 'boolean':
50
- return jsxRuntime.jsx(antd.Form.Item, { ...computedProps, children: jsxRuntime.jsx(antd.Switch, {}, void 0) }, void 0);
51
- default:
52
- return null;
53
- }
54
- }
55
-
56
- function Form(props) {
57
- console.log(props);
58
- return jsxRuntime.jsx(antd.Form, { ...props, children: props.items.map(item => jsxRuntime.jsx(FormItem, { ...item }, item.id)) }, void 0);
59
- }
60
-
61
- exports.Form = Form;
62
- exports.FormItem = FormItem;
package/lib/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":["../node_modules/style-inject/dist/style-inject.es.js"],"sourcesContent":["function styleInject(css, ref) {\n if ( ref === void 0 ) ref = {};\n var insertAt = ref.insertAt;\n\n if (!css || typeof document === 'undefined') { return; }\n\n var head = document.head || document.getElementsByTagName('head')[0];\n var style = document.createElement('style');\n style.type = 'text/css';\n\n if (insertAt === 'top') {\n if (head.firstChild) {\n head.insertBefore(style, head.firstChild);\n } else {\n head.appendChild(style);\n }\n } else {\n head.appendChild(style);\n }\n\n if (style.styleSheet) {\n style.styleSheet.cssText = css;\n } else {\n style.appendChild(document.createTextNode(css));\n }\n}\n\nexport default styleInject;\n"],"names":[],"mappings":";;;;;;;AAAA,SAAS,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE;AAC/B,EAAE,KAAK,GAAG,KAAK,KAAK,CAAC,GAAG,GAAG,GAAG,EAAE,CAAC;AACjC,EAAE,IAAI,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC;AAC9B;AACA,EAAE,IAAI,CAAC,GAAG,IAAI,OAAO,QAAQ,KAAK,WAAW,EAAE,EAAE,OAAO,EAAE;AAC1D;AACA,EAAE,IAAI,IAAI,GAAG,QAAQ,CAAC,IAAI,IAAI,QAAQ,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;AACvE,EAAE,IAAI,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;AAC9C,EAAE,KAAK,CAAC,IAAI,GAAG,UAAU,CAAC;AAC1B;AACA,EAAE,IAAI,QAAQ,KAAK,KAAK,EAAE;AAC1B,IAAI,IAAI,IAAI,CAAC,UAAU,EAAE;AACzB,MAAM,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;AAChD,KAAK,MAAM;AACX,MAAM,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;AAC9B,KAAK;AACL,GAAG,MAAM;AACT,IAAI,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;AAC5B,GAAG;AACH;AACA,EAAE,IAAI,KAAK,CAAC,UAAU,EAAE;AACxB,IAAI,KAAK,CAAC,UAAU,CAAC,OAAO,GAAG,GAAG,CAAC;AACnC,GAAG,MAAM;AACT,IAAI,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC;AACpD,GAAG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1 +0,0 @@
1
- import '@testing-library/jest-dom';