antd-solid 0.0.2 → 0.0.4
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/dist/index.css +69 -0
- package/dist/index.esm.js +2369 -0
- package/dist/index.umd.js +1 -0
- package/package.json +32 -14
- package/src/index.ts +12 -5
- package/.eslintrc.cjs +0 -36
- package/.prettierrc +0 -11
- package/.vscode/settings.json +0 -13
- package/docs/.vitepress/components/Code.vue +0 -59
- package/docs/.vitepress/config.ts +0 -49
- package/docs/.vitepress/theme/index.css +0 -15
- package/docs/.vitepress/theme/index.ts +0 -13
- package/docs/components/Button.tsx +0 -20
- package/docs/components/Table.tsx +0 -34
- package/docs/components/button.md +0 -23
- package/docs/components/table.md +0 -23
- package/docs/index.md +0 -28
- package/rollup.config.js +0 -25
- package/src/Button.css +0 -14
- package/src/Button.tsx +0 -86
- package/src/ColorPicker.tsx +0 -66
- package/src/DatePicker.tsx +0 -12
- package/src/Form.tsx +0 -98
- package/src/Image.tsx +0 -29
- package/src/Input.tsx +0 -110
- package/src/InputNumber.test.tsx +0 -46
- package/src/InputNumber.tsx +0 -119
- package/src/Modal.tsx +0 -168
- package/src/Popconfirm.tsx +0 -73
- package/src/Popover.tsx +0 -30
- package/src/Progress.tsx +0 -4
- package/src/Radio.tsx +0 -132
- package/src/Result.tsx +0 -38
- package/src/Select.tsx +0 -6
- package/src/Skeleton.tsx +0 -14
- package/src/Spin.tsx +0 -23
- package/src/Switch.tsx +0 -34
- package/src/Table.tsx +0 -46
- package/src/Tabs.tsx +0 -88
- package/src/Timeline.tsx +0 -33
- package/src/Tooltip.tsx +0 -209
- package/src/Tree.tsx +0 -246
- package/src/Upload.tsx +0 -10
- package/src/hooks/createControllableValue.ts +0 -65
- package/src/hooks/createUpdateEffect.ts +0 -16
- package/src/hooks/index.ts +0 -2
- package/src/hooks/useClickAway.ts +0 -18
- package/src/hooks/useSize.ts +0 -26
- package/src/index.css +0 -21
- package/src/utils/ReactToSolid.tsx +0 -38
- package/src/utils/SolidToReact.tsx +0 -27
- package/src/utils/array.ts +0 -21
- package/src/utils/component.tsx +0 -85
- package/src/utils/solid.ts +0 -48
- package/tsconfig.json +0 -23
- package/unocss.config.ts +0 -92
package/src/utils/array.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 如果传入一个非数组字段,则将其转化为数组
|
|
3
|
-
* @param value
|
|
4
|
-
* @returns
|
|
5
|
-
*/
|
|
6
|
-
export function toArray<T>(value: T | T[]) {
|
|
7
|
-
return Array.isArray(value) ? value : [value]
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface StandardNode {
|
|
11
|
-
children?: this[]
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* 将数组中每个对象的 children 拍扁后返回
|
|
15
|
-
* @param nodes
|
|
16
|
-
* @returns
|
|
17
|
-
*/
|
|
18
|
-
export function flatChildren<T extends StandardNode = StandardNode>(nodes: T[] | undefined): T[] {
|
|
19
|
-
if (!nodes) return []
|
|
20
|
-
return nodes.flatMap(node => [node, ...flatChildren(node.children)])
|
|
21
|
-
}
|
package/src/utils/component.tsx
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import { type Component, createMemo, type JSXElement } from 'solid-js'
|
|
3
|
-
import { omit } from 'lodash-es'
|
|
4
|
-
import { solidToReact } from './solid'
|
|
5
|
-
import ReactToSolid from './ReactToSolid'
|
|
6
|
-
import { ConfigProvider } from 'antd'
|
|
7
|
-
import zhCN from 'antd/locale/zh_CN'
|
|
8
|
-
import { type ConfigProviderProps } from 'antd/es/config-provider'
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* 将组件 props 中的 className 替换为 class
|
|
12
|
-
* @param C
|
|
13
|
-
* @returns
|
|
14
|
-
*/
|
|
15
|
-
export function replaceClassName<
|
|
16
|
-
T extends { className?: string },
|
|
17
|
-
Target extends Omit<T, 'className'> & { class?: string },
|
|
18
|
-
>(C: Component<T>): Component<Target> {
|
|
19
|
-
return function (_props: Target) {
|
|
20
|
-
const props = createMemo(() => {
|
|
21
|
-
return {
|
|
22
|
-
...omit(_props, 'class'),
|
|
23
|
-
className: _props.class,
|
|
24
|
-
}
|
|
25
|
-
})
|
|
26
|
-
return <C {...(props() as unknown as T)} />
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* 将组件 props 中的 children 替换为 JSXElement
|
|
32
|
-
* @param C
|
|
33
|
-
* @returns
|
|
34
|
-
*/
|
|
35
|
-
export function replaceChildren<
|
|
36
|
-
T extends { children?: React.ReactNode },
|
|
37
|
-
Target extends Omit<T, 'children'> & { children?: JSXElement },
|
|
38
|
-
>(C: Component<T>): Component<Target> {
|
|
39
|
-
return function (_props: Target) {
|
|
40
|
-
const props = createMemo(() => {
|
|
41
|
-
return {
|
|
42
|
-
..._props,
|
|
43
|
-
children: solidToReact(_props.children),
|
|
44
|
-
}
|
|
45
|
-
})
|
|
46
|
-
return <C {...(props() as unknown as T)} />
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export function reactToSolidComponent<P extends {} = {}>(
|
|
51
|
-
component: React.FunctionComponent<P> | React.ComponentClass<P>,
|
|
52
|
-
container?: Element | (() => Element),
|
|
53
|
-
) {
|
|
54
|
-
return function (props: P) {
|
|
55
|
-
return (
|
|
56
|
-
<ReactToSolid
|
|
57
|
-
component={component}
|
|
58
|
-
props={props}
|
|
59
|
-
container={typeof container === 'function' ? container() : container}
|
|
60
|
-
/>
|
|
61
|
-
)
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* 返回被 ConfigProvider 包裹后的 component
|
|
67
|
-
* @param component
|
|
68
|
-
* @param configProviderProps
|
|
69
|
-
* @returns
|
|
70
|
-
*/
|
|
71
|
-
export function configProvider<P extends {} = {}>(
|
|
72
|
-
component: React.FunctionComponent<P> | React.ComponentClass<P>,
|
|
73
|
-
configProviderProps?: ConfigProviderProps,
|
|
74
|
-
) {
|
|
75
|
-
return function (props: P) {
|
|
76
|
-
return React.createElement(
|
|
77
|
-
ConfigProvider,
|
|
78
|
-
{
|
|
79
|
-
locale: zhCN,
|
|
80
|
-
...configProviderProps,
|
|
81
|
-
},
|
|
82
|
-
React.createElement(component, props),
|
|
83
|
-
)
|
|
84
|
-
}
|
|
85
|
-
}
|
package/src/utils/solid.ts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import { type JSXElement , type JSX } from 'solid-js'
|
|
3
|
-
import { isNil } from 'lodash-es'
|
|
4
|
-
import SolidToReact from './SolidToReact'
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* 判断 JSXElement 是否是基础类型
|
|
8
|
-
* @param value JSXElement
|
|
9
|
-
* @returns
|
|
10
|
-
*/
|
|
11
|
-
export function isBaseType(
|
|
12
|
-
value: JSXElement,
|
|
13
|
-
): value is string | number | boolean | null | undefined {
|
|
14
|
-
return (
|
|
15
|
-
typeof value === 'string' ||
|
|
16
|
-
typeof value === 'number' ||
|
|
17
|
-
typeof value === 'boolean' ||
|
|
18
|
-
value === null ||
|
|
19
|
-
value === undefined
|
|
20
|
-
)
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export function solidToReact(children: JSXElement) {
|
|
24
|
-
return isBaseType(children)
|
|
25
|
-
? children
|
|
26
|
-
: React.createElement(SolidToReact, {
|
|
27
|
-
children,
|
|
28
|
-
})
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export function dispatchEventHandlerUnion<T, E extends Event>(
|
|
32
|
-
handler: JSX.EventHandlerUnion<T, E> | undefined,
|
|
33
|
-
e: E & {
|
|
34
|
-
currentTarget: T
|
|
35
|
-
target: Element
|
|
36
|
-
},
|
|
37
|
-
) {
|
|
38
|
-
if (isNil(handler)) {
|
|
39
|
-
return
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if (typeof handler === 'function') {
|
|
43
|
-
handler(e)
|
|
44
|
-
return
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
handler[0](handler[1], e);
|
|
48
|
-
}
|
package/tsconfig.json
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"strictNullChecks": true,
|
|
4
|
-
"noImplicitAny": true,
|
|
5
|
-
"allowSyntheticDefaultImports": true,
|
|
6
|
-
"esModuleInterop": true,
|
|
7
|
-
"target": "ESNext",
|
|
8
|
-
"module": "ESNext",
|
|
9
|
-
"moduleResolution": "node",
|
|
10
|
-
"jsxImportSource": "solid-js",
|
|
11
|
-
"jsx": "preserve",
|
|
12
|
-
"emitDecoratorMetadata": true,
|
|
13
|
-
"experimentalDecorators": true,
|
|
14
|
-
"baseUrl": ".",
|
|
15
|
-
"paths": {
|
|
16
|
-
"antd-solid": ["src/index"],
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
"include": [
|
|
20
|
-
"./src/**/*",
|
|
21
|
-
"./docs/**/*",
|
|
22
|
-
],
|
|
23
|
-
}
|
package/unocss.config.ts
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/promise-function-async */
|
|
2
|
-
import { defineConfig } from '@unocss/vite'
|
|
3
|
-
import { presetMini } from '@unocss/preset-mini'
|
|
4
|
-
import transformerVariantGroup from '@unocss/transformer-variant-group'
|
|
5
|
-
import presetIcons from '@unocss/preset-icons'
|
|
6
|
-
|
|
7
|
-
export default defineConfig({
|
|
8
|
-
presets: [
|
|
9
|
-
presetMini({
|
|
10
|
-
prefix: 'ant-'
|
|
11
|
-
}),
|
|
12
|
-
presetIcons({
|
|
13
|
-
collections: {
|
|
14
|
-
'ant-design': () => import('@iconify-json/ant-design').then(i => i.icons),
|
|
15
|
-
},
|
|
16
|
-
extraProperties: {
|
|
17
|
-
display: 'inline-block',
|
|
18
|
-
'vertical-align': 'middle',
|
|
19
|
-
},
|
|
20
|
-
}) as any,
|
|
21
|
-
],
|
|
22
|
-
transformers: [transformerVariantGroup()],
|
|
23
|
-
variants: [
|
|
24
|
-
/**
|
|
25
|
-
* not[.*]:
|
|
26
|
-
*/
|
|
27
|
-
matcher => {
|
|
28
|
-
const prevReg = /^not\[(.*)\]:/
|
|
29
|
-
const match = matcher.match(prevReg)
|
|
30
|
-
if (!match) return matcher
|
|
31
|
-
return {
|
|
32
|
-
matcher: matcher.slice(match[0].length),
|
|
33
|
-
selector: s => `${s}:not(${match[1]})`,
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
/**
|
|
37
|
-
* where:
|
|
38
|
-
*/
|
|
39
|
-
matcher => {
|
|
40
|
-
const prev = 'where:'
|
|
41
|
-
if (!matcher.startsWith(prev)) {
|
|
42
|
-
return matcher
|
|
43
|
-
}
|
|
44
|
-
return {
|
|
45
|
-
matcher: matcher.slice(prev.length),
|
|
46
|
-
selector: s => `:where(${s})`,
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
/**
|
|
50
|
-
* 定义子级的样式
|
|
51
|
-
* child[.*]:
|
|
52
|
-
*/
|
|
53
|
-
matcher => {
|
|
54
|
-
const prevReg = /^child\[(.*)\]:/
|
|
55
|
-
const match = matcher.match(prevReg)
|
|
56
|
-
if (!match) return matcher
|
|
57
|
-
return {
|
|
58
|
-
matcher: matcher.slice(match[0].length),
|
|
59
|
-
selector: s => `${s} ${match[1] || '*'}`,
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
/**
|
|
63
|
-
* 父级 hover 的状态定义子级的样式
|
|
64
|
-
* p-hover-child[.*]:
|
|
65
|
-
*/
|
|
66
|
-
matcher => {
|
|
67
|
-
const prevReg = /^p-hover-child\[(.*)\]:/
|
|
68
|
-
const match = matcher.match(prevReg)
|
|
69
|
-
if (!match) return matcher
|
|
70
|
-
return {
|
|
71
|
-
matcher: matcher.slice(match[0].length),
|
|
72
|
-
selector: s => `${s}:hover ${match[1] || '*'}`,
|
|
73
|
-
}
|
|
74
|
-
},
|
|
75
|
-
],
|
|
76
|
-
rules: [
|
|
77
|
-
['rm-size-btn', { padding: 0, border: 'none', height: 'auto' }],
|
|
78
|
-
[
|
|
79
|
-
/^keyframes-spin$/,
|
|
80
|
-
() => {
|
|
81
|
-
return `@keyframes spin {
|
|
82
|
-
from {
|
|
83
|
-
transform: rotate(0deg);
|
|
84
|
-
}
|
|
85
|
-
to {
|
|
86
|
-
transform: rotate(360deg);
|
|
87
|
-
}
|
|
88
|
-
}`
|
|
89
|
-
},
|
|
90
|
-
],
|
|
91
|
-
],
|
|
92
|
-
})
|