@rainte/ant 0.0.1 → 0.0.3

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.
Files changed (108) hide show
  1. package/README.md +10 -27
  2. package/dist/browser-ponyfill-BhoWWtMr.js +341 -0
  3. package/dist/index-DStl3yyY.js +95046 -0
  4. package/dist/index.css +7 -0
  5. package/dist/index.js +9 -0
  6. package/dist/index.umd.cjs +600 -0
  7. package/dist/types/lib/index.d.ts +10 -0
  8. package/dist/types/src/App.d.ts +1 -0
  9. package/dist/types/src/components/Editor/index.d.ts +9 -0
  10. package/dist/types/src/components/Form/index.d.ts +7 -0
  11. package/dist/types/src/components/Provider/index.d.ts +2 -0
  12. package/dist/types/src/components/Table/index.d.ts +4 -0
  13. package/dist/types/src/components/Upload/index.d.ts +7 -0
  14. package/dist/types/src/main.d.ts +1 -0
  15. package/dist/types/src/router/index.d.ts +7 -0
  16. package/dist/types/src/utils/i18n.d.ts +70 -0
  17. package/dist/types/src/views/form/index.d.ts +1 -0
  18. package/dist/types/src/views/layout/blank/index.d.ts +1 -0
  19. package/dist/types/src/views/layout/menu/index.d.ts +1 -0
  20. package/dist/types/src/views/table/index.d.ts +1 -0
  21. package/dist/types/vite.config.d.ts +2 -0
  22. package/dist/vite.svg +1 -0
  23. package/package.json +41 -43
  24. package/.editorconfig +0 -9
  25. package/.fatherrc.ts +0 -15
  26. package/.gitattributes +0 -1
  27. package/.prettierignore +0 -7
  28. package/.prettierrc +0 -13
  29. package/.umirc.ts +0 -24
  30. package/LICENSE +0 -21
  31. package/docs/index.md +0 -9
  32. package/es/components/Editor/index.d.ts +0 -8
  33. package/es/components/Editor/index.js +0 -35
  34. package/es/components/Editor/props.d.ts +0 -13
  35. package/es/components/Editor/props.js +0 -12
  36. package/es/components/Form/index.d.ts +0 -8
  37. package/es/components/Form/index.js +0 -53
  38. package/es/components/Image/index.d.ts +0 -5
  39. package/es/components/Image/index.js +0 -14
  40. package/es/components/Table/index.d.ts +0 -9
  41. package/es/components/Table/index.js +0 -35
  42. package/es/components/Tabs/index.d.ts +0 -9
  43. package/es/components/Tabs/index.js +0 -22
  44. package/es/components/ValueType/components/Cascader.d.ts +0 -3
  45. package/es/components/ValueType/components/Cascader.js +0 -89
  46. package/es/components/ValueType/components/Editor.d.ts +0 -3
  47. package/es/components/ValueType/components/Editor.js +0 -18
  48. package/es/components/ValueType/components/TreeSelect.d.ts +0 -3
  49. package/es/components/ValueType/components/TreeSelect.js +0 -87
  50. package/es/components/ValueType/components/Upload.d.ts +0 -4
  51. package/es/components/ValueType/components/Upload.js +0 -73
  52. package/es/components/ValueType/index.d.ts +0 -15
  53. package/es/components/ValueType/index.js +0 -10
  54. package/es/index.d.ts +0 -11
  55. package/es/index.js +0 -6
  56. package/es/utils/Swr.d.ts +0 -1
  57. package/es/utils/Swr.js +0 -58
  58. package/es/utils/Tree.d.ts +0 -2
  59. package/es/utils/Tree.js +0 -65
  60. package/lib/components/Editor/index.d.ts +0 -8
  61. package/lib/components/Editor/index.js +0 -43
  62. package/lib/components/Editor/props.d.ts +0 -13
  63. package/lib/components/Editor/props.js +0 -19
  64. package/lib/components/Form/index.d.ts +0 -8
  65. package/lib/components/Form/index.js +0 -64
  66. package/lib/components/Image/index.d.ts +0 -5
  67. package/lib/components/Image/index.js +0 -22
  68. package/lib/components/Table/index.d.ts +0 -9
  69. package/lib/components/Table/index.js +0 -46
  70. package/lib/components/Tabs/index.d.ts +0 -9
  71. package/lib/components/Tabs/index.js +0 -30
  72. package/lib/components/ValueType/components/Cascader.d.ts +0 -3
  73. package/lib/components/ValueType/components/Cascader.js +0 -97
  74. package/lib/components/ValueType/components/Editor.d.ts +0 -3
  75. package/lib/components/ValueType/components/Editor.js +0 -26
  76. package/lib/components/ValueType/components/TreeSelect.d.ts +0 -3
  77. package/lib/components/ValueType/components/TreeSelect.js +0 -95
  78. package/lib/components/ValueType/components/Upload.d.ts +0 -4
  79. package/lib/components/ValueType/components/Upload.js +0 -82
  80. package/lib/components/ValueType/index.d.ts +0 -15
  81. package/lib/components/ValueType/index.js +0 -18
  82. package/lib/index.d.ts +0 -11
  83. package/lib/index.js +0 -41
  84. package/lib/utils/Swr.d.ts +0 -1
  85. package/lib/utils/Swr.js +0 -66
  86. package/lib/utils/Tree.d.ts +0 -2
  87. package/lib/utils/Tree.js +0 -73
  88. package/src/components/Editor/index.md +0 -8
  89. package/src/components/Editor/index.tsx +0 -20
  90. package/src/components/Editor/props.ts +0 -50
  91. package/src/components/Form/index.md +0 -132
  92. package/src/components/Form/index.tsx +0 -48
  93. package/src/components/Image/index.md +0 -8
  94. package/src/components/Image/index.tsx +0 -16
  95. package/src/components/Table/index.md +0 -80
  96. package/src/components/Table/index.tsx +0 -45
  97. package/src/components/Tabs/index.md +0 -24
  98. package/src/components/Tabs/index.tsx +0 -21
  99. package/src/components/ValueType/components/Cascader.tsx +0 -79
  100. package/src/components/ValueType/components/Editor.tsx +0 -18
  101. package/src/components/ValueType/components/TreeSelect.tsx +0 -74
  102. package/src/components/ValueType/components/Upload.tsx +0 -74
  103. package/src/components/ValueType/index.ts +0 -33
  104. package/src/index.ts +0 -12
  105. package/src/utils/Swr.ts +0 -29
  106. package/src/utils/Tree.ts +0 -51
  107. package/tsconfig.json +0 -31
  108. package/typings.d.ts +0 -4
@@ -1,79 +0,0 @@
1
- import React from 'react'
2
- import {
3
- Space,
4
- Cascader as AntCascader,
5
- CascaderProps as AntCascaderProps,
6
- } from 'antd'
7
- import { RenderProps, FieldProps, RequestProps } from '../index'
8
- import { fetch } from '../../../utils/Swr'
9
- import { equal, intact } from '../../../utils/Tree'
10
-
11
- type CascaderProps<T = any> = AntCascaderProps<T> & RequestProps
12
- type TextProps = CascaderProps & { iValue: any; iDom: any }
13
-
14
- const entire = (value: any, options: any[]) => {
15
- if (Array.isArray(value)) {
16
- if (value.length === 1) {
17
- return intact(options, { value: value[0] }, 'value')
18
- }
19
-
20
- return value
21
- }
22
-
23
- return []
24
- }
25
-
26
- const combine = (text: any[], options: any[], dom: any) => {
27
- return text
28
- .map((item: any) => {
29
- const node = equal(options, { value: item })
30
- return node ? node.label : text ? text : dom
31
- })
32
- .join(' / ')
33
- }
34
-
35
- const Cascader: React.FC<CascaderProps> = props => {
36
- const { iParams, iRequest, ...attrs } = props
37
-
38
- const data = fetch(iRequest, iParams, attrs)
39
-
40
- const options = (iRequest ? data : attrs.options) ?? []
41
- const values = entire(attrs.value, options) ?? []
42
-
43
- return <AntCascader {...attrs} options={options} value={values} />
44
- }
45
-
46
- const Text: React.FC<TextProps> = props => {
47
- const { iValue, iDom, iParams, iRequest, ...attrs } = props
48
-
49
- const data = fetch(iRequest, iParams, attrs)
50
-
51
- const options = (iRequest ? data : attrs.options) ?? []
52
- const values = entire(iValue, options) ?? []
53
-
54
- const dom = values.length ? combine(values, options, iDom) : iDom
55
-
56
- return <Space>{dom}</Space>
57
- }
58
-
59
- const Render: RenderProps = {
60
- name: 'cascader',
61
- render: (text, props: FieldProps, dom) => {
62
- const { params, request, fieldProps } = props
63
- const iParams = params
64
- const iRequest = request
65
- const attrs = { iValue: text, iDom: dom, iParams, iRequest }
66
-
67
- return <Text {...fieldProps} {...attrs} />
68
- },
69
- renderFormItem: (_, props: FieldProps) => {
70
- const { params, request, fieldProps } = props
71
- const iParams = params
72
- const iRequest = request
73
- const attrs = { iParams, iRequest }
74
-
75
- return <Cascader {...fieldProps} {...attrs} />
76
- },
77
- }
78
-
79
- export default Render
@@ -1,18 +0,0 @@
1
- import React from 'react'
2
- import Editor from '../../Editor'
3
- import { RenderProps, FieldProps } from '../index'
4
-
5
- const Render: RenderProps = {
6
- name: 'editor',
7
- render: (text, props, dom) => {
8
- if (text instanceof Object) {
9
- return <>{text.toHTML()}</>
10
- }
11
- return dom
12
- },
13
- renderFormItem: (_, props: FieldProps) => {
14
- return <Editor {...props.fieldProps} />
15
- },
16
- }
17
-
18
- export default Render
@@ -1,74 +0,0 @@
1
- import React from 'react'
2
- import {
3
- Tag,
4
- TreeSelect as AntTreeSelect,
5
- TreeSelectProps as AntTreeSelectProps,
6
- Space,
7
- } from 'antd'
8
- import { RenderProps, FieldProps, RequestProps } from '../index'
9
- import { fetch } from '../../../utils/Swr'
10
- import { equal } from '../../../utils/Tree'
11
-
12
- type TreeSelectProps<T = any> = AntTreeSelectProps<T> & RequestProps
13
- type TextProps<T = any> = TreeSelectProps<T> & { iValue: any; iDom: any }
14
-
15
- const combine = (text: any[], options: any[], dom: any) => {
16
- return text.map((item: any) => {
17
- const node = equal(options, { value: item })
18
-
19
- return <Tag>{node ? node.title : text ? text : dom}</Tag>
20
- })
21
- }
22
-
23
- const TreeSelect: React.FC<TreeSelectProps> = props => {
24
- const { iParams, iRequest, ...attrs } = props
25
-
26
- const data = fetch(iRequest, iParams, attrs)
27
-
28
- const options = (iRequest ? data : attrs.treeData) ?? []
29
-
30
- return <AntTreeSelect {...attrs} treeData={options} />
31
- }
32
-
33
- const Text: React.FC<TextProps> = props => {
34
- const { iValue, iDom, iParams, iRequest, ...attrs } = props
35
-
36
- const data = fetch(iRequest, iParams, attrs)
37
-
38
- const options = (iRequest ? data : attrs.treeData) ?? []
39
-
40
- if (Array.isArray(iValue)) {
41
- return <Space>{combine(iValue, options, iDom)}</Space>
42
- }
43
-
44
- const node = equal(options, { value: iValue })
45
- return <>{node ? node.title : iValue ? iValue : iDom}</>
46
- }
47
-
48
- const Render: RenderProps = {
49
- name: 'treeSelect',
50
- render: (text, props: FieldProps, dom) => {
51
- const { params, request, fieldProps } = props
52
- const iParams = params
53
- const iRequest = request
54
- const attrs = { iValue: text, iDom: dom, iParams, iRequest }
55
-
56
- return <Text {...fieldProps} {...attrs} />
57
- },
58
- renderFormItem: (_, props: FieldProps) => {
59
- const { params, request, fieldProps } = props
60
- const iParams = params
61
- const iRequest = request
62
- const attrs = { iParams, iRequest }
63
-
64
- return <TreeSelect {...fieldProps} {...attrs} />
65
- },
66
- }
67
-
68
- export default Render
69
-
70
- TreeSelect.defaultProps = {
71
- allowClear: true,
72
- showSearch: true,
73
- treeNodeFilterProp: 'title',
74
- }
@@ -1,74 +0,0 @@
1
- import React from 'react'
2
- import {
3
- Button,
4
- Space,
5
- Upload as AntUpload,
6
- UploadProps,
7
- Typography,
8
- } from 'antd'
9
- import { PlusOutlined, UploadOutlined } from '@ant-design/icons'
10
- import { RenderProps, FieldProps } from '../index'
11
-
12
- export const files = (e: any) => (Array.isArray(e) ? e : e && e.fileList)
13
-
14
- const links = (text: any[], dom: any) => {
15
- return text.map((item: any) => {
16
- if (item && item.url) {
17
- return (
18
- <Typography.Link href={item.url} target="_blank" key={item.url}>
19
- {item.url}
20
- </Typography.Link>
21
- )
22
- }
23
-
24
- return dom
25
- })
26
- }
27
-
28
- const Upload: React.FC<UploadProps & { value?: any }> = props => {
29
- const { value, ...attrs } = props
30
- const fileList = files(value)
31
- const length = Array.isArray(fileList) ? fileList.length : 0
32
- const max = attrs.maxCount ?? 1
33
-
34
- let button
35
- if (length < max) {
36
- if (props.listType === 'picture-card') {
37
- button = <PlusOutlined />
38
- } else {
39
- button = <Button icon={<UploadOutlined />}>上传</Button>
40
- }
41
- }
42
-
43
- return (
44
- <AntUpload {...attrs} fileList={fileList}>
45
- {button}
46
- </AntUpload>
47
- )
48
- }
49
-
50
- const Render: RenderProps = {
51
- name: 'upload',
52
- render: (text, props, dom) => {
53
- const value = files(text)
54
-
55
- if (Array.isArray(value) && value.length) {
56
- return <Space>{links(value, dom)}</Space>
57
- }
58
-
59
- return <>{dom}</>
60
- },
61
- renderFormItem: (_, props: FieldProps) => {
62
- return <Upload {...props.fieldProps} />
63
- },
64
- }
65
-
66
- export default Render
67
-
68
- Upload.defaultProps = {
69
- listType: 'picture-card',
70
- value: [],
71
- maxCount: 1,
72
- multiple: true,
73
- showUploadList: true,
74
- }
@@ -1,33 +0,0 @@
1
- import {
2
- ProRenderFieldPropsType,
3
- ProFieldFCRenderProps,
4
- } from '@ant-design/pro-provider'
5
-
6
- import Cascader from './components/Cascader'
7
- import Editor from './components/Editor'
8
- import TreeSelect from './components/TreeSelect'
9
- import Upload from './components/Upload'
10
-
11
- export type RenderProps = ProRenderFieldPropsType & { name: string }
12
- export type FieldProps = ProFieldFCRenderProps & {
13
- params?: any
14
- request?: <T = any>(params: T, props: any) => Promise<any>
15
- }
16
- export type RequestProps = {
17
- iParams?: any
18
- iRequest?: <T = any>(params: T, props: any) => Promise<any>
19
- }
20
- export type ValueTypeEnum =
21
- | 'text'
22
- | 'cascader'
23
- | 'editor'
24
- | 'treeSelect'
25
- | 'upload'
26
-
27
- const modules = [Cascader, Editor, TreeSelect, Upload]
28
- const ValueTypeMap: Record<string, ProRenderFieldPropsType> = {}
29
- modules.forEach((module: any) => {
30
- ValueTypeMap[module.name] = module as ProRenderFieldPropsType
31
- })
32
-
33
- export default ValueTypeMap
package/src/index.ts DELETED
@@ -1,12 +0,0 @@
1
- /// <reference path="../typings.d.ts" />
2
-
3
- export { default as Editor } from './components/Editor'
4
- export type { EditorProps } from './components/Editor'
5
- export { default as Form } from './components/Form'
6
- export type { FormProps } from './components/Form'
7
- export { default as Image } from './components/Image'
8
- export type { ImageProps } from './components/Image'
9
- export { default as Table } from './components/Table'
10
- export type { TableProps } from './components/Table'
11
- export { default as Tabs } from './components/Tabs'
12
- export type { TabsProps } from './components/Tabs'
package/src/utils/Swr.ts DELETED
@@ -1,29 +0,0 @@
1
- import { useMemo } from 'react'
2
- import { v4 as uuid } from 'uuid'
3
- import useSWR from 'swr'
4
-
5
- const key = (request: any, params: any) => {
6
- return useMemo(() => {
7
- if (!request) {
8
- return 'no-fetch'
9
- }
10
-
11
- if (!params) {
12
- return uuid()
13
- }
14
-
15
- return JSON.stringify(params)
16
- }, [params, request])
17
- }
18
-
19
- export const fetch = (request: any, params: any, props: any) => {
20
- const fetcher = async () => (request ? await request(params, props) : [])
21
-
22
- const { data } = useSWR(key(request, params), fetcher, {
23
- revalidateOnFocus: false,
24
- shouldRetryOnError: false,
25
- revalidateOnReconnect: false,
26
- })
27
-
28
- return data
29
- }
package/src/utils/Tree.ts DELETED
@@ -1,51 +0,0 @@
1
- export const equal: any = (rows: any[], props: Record<string, any>) => {
2
- for (const row of rows) {
3
- let flag = true
4
-
5
- for (const key in props) {
6
- if (props[key] !== row[key]) {
7
- flag = false
8
- break
9
- }
10
- }
11
-
12
- if (flag) {
13
- return row
14
- }
15
-
16
- if (row.children) {
17
- const node = equal(row.children, props)
18
- if (node) {
19
- return node
20
- }
21
- }
22
- }
23
- }
24
-
25
- export const intact = (
26
- rows: any[],
27
- equal: Record<string, any>,
28
- prop: string,
29
- ) => {
30
- for (const row of rows) {
31
- let flag = true
32
-
33
- for (const key in equal) {
34
- if (equal[key] !== row[key]) {
35
- flag = false
36
- break
37
- }
38
- }
39
-
40
- if (!flag && row.children) {
41
- const sonids: any = intact(row.children, equal, prop)
42
- if (sonids && Array.isArray(sonids)) {
43
- return [row[prop], ...sonids]
44
- }
45
- }
46
-
47
- if (flag) {
48
- return [row[prop]]
49
- }
50
- }
51
- }
package/tsconfig.json DELETED
@@ -1,31 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "allowSyntheticDefaultImports": true,
4
- "baseUrl": "./",
5
- "declaration": true,
6
- "esModuleInterop": true,
7
- "importHelpers": true,
8
- "jsx": "react",
9
- "module": "esnext",
10
- "moduleResolution": "node",
11
- "skipLibCheck": true,
12
- "sourceMap": true,
13
- "strict": true,
14
- "target": "esnext",
15
- "paths": {
16
- "@/*": ["src/*"],
17
- "@@/*": ["src/.umi/*"]
18
- }
19
- },
20
- "exclude": [
21
- "node_modules",
22
- "lib",
23
- "es",
24
- "dist",
25
- "typings",
26
- "**/__test__",
27
- "test",
28
- "docs",
29
- "tests"
30
- ]
31
- }
package/typings.d.ts DELETED
@@ -1,4 +0,0 @@
1
- declare module '*.css'
2
- declare module '*.less'
3
- declare module 'uuid'
4
- declare module 'braft-extensions/dist/*'