antd-solid 0.0.2
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/.eslintrc.cjs +36 -0
- package/.prettierrc +11 -0
- package/.vscode/settings.json +13 -0
- package/README.md +11 -0
- package/docs/.vitepress/components/Code.vue +59 -0
- package/docs/.vitepress/config.ts +49 -0
- package/docs/.vitepress/theme/index.css +15 -0
- package/docs/.vitepress/theme/index.ts +13 -0
- package/docs/components/Button.tsx +20 -0
- package/docs/components/Table.tsx +34 -0
- package/docs/components/button.md +23 -0
- package/docs/components/table.md +23 -0
- package/docs/index.md +28 -0
- package/package.json +62 -0
- package/rollup.config.js +25 -0
- package/src/Button.css +14 -0
- package/src/Button.tsx +86 -0
- package/src/ColorPicker.tsx +66 -0
- package/src/DatePicker.tsx +12 -0
- package/src/Form.tsx +98 -0
- package/src/Image.tsx +29 -0
- package/src/Input.tsx +110 -0
- package/src/InputNumber.test.tsx +46 -0
- package/src/InputNumber.tsx +119 -0
- package/src/Modal.tsx +168 -0
- package/src/Popconfirm.tsx +73 -0
- package/src/Popover.tsx +30 -0
- package/src/Progress.tsx +4 -0
- package/src/Radio.tsx +132 -0
- package/src/Result.tsx +38 -0
- package/src/Select.tsx +6 -0
- package/src/Skeleton.tsx +14 -0
- package/src/Spin.tsx +23 -0
- package/src/Switch.tsx +34 -0
- package/src/Table.tsx +46 -0
- package/src/Tabs.tsx +88 -0
- package/src/Timeline.tsx +33 -0
- package/src/Tooltip.tsx +209 -0
- package/src/Tree.tsx +246 -0
- package/src/Upload.tsx +10 -0
- package/src/hooks/createControllableValue.ts +65 -0
- package/src/hooks/createUpdateEffect.ts +16 -0
- package/src/hooks/index.ts +2 -0
- package/src/hooks/useClickAway.ts +18 -0
- package/src/hooks/useSize.ts +26 -0
- package/src/index.css +21 -0
- package/src/index.ts +37 -0
- package/src/utils/ReactToSolid.tsx +38 -0
- package/src/utils/SolidToReact.tsx +27 -0
- package/src/utils/array.ts +21 -0
- package/src/utils/component.tsx +85 -0
- package/src/utils/solid.ts +48 -0
- package/tsconfig.json +23 -0
- package/unocss.config.ts +92 -0
package/.eslintrc.cjs
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
env: {
|
|
3
|
+
browser: true,
|
|
4
|
+
es2021: true,
|
|
5
|
+
},
|
|
6
|
+
parser: '@typescript-eslint/parser',
|
|
7
|
+
plugins: ['solid'],
|
|
8
|
+
extends: ['standard-with-typescript', 'plugin:solid/typescript', 'prettier'],
|
|
9
|
+
overrides: [],
|
|
10
|
+
parserOptions: {
|
|
11
|
+
ecmaVersion: 'latest',
|
|
12
|
+
sourceType: 'module',
|
|
13
|
+
project: ['./tsconfig.json'],
|
|
14
|
+
},
|
|
15
|
+
rules: {
|
|
16
|
+
"no-shadow": "error",
|
|
17
|
+
'@typescript-eslint/explicit-function-return-type': 'off',
|
|
18
|
+
'@typescript-eslint/no-non-null-assertion': 'off',
|
|
19
|
+
'@typescript-eslint/no-unused-vars': [
|
|
20
|
+
'error',
|
|
21
|
+
{ argsIgnorePattern: '^_', destructuredArrayIgnorePattern: '^_' },
|
|
22
|
+
],
|
|
23
|
+
'@typescript-eslint/comma-dangle': ['error', 'only-multiline'],
|
|
24
|
+
'@typescript-eslint/strict-boolean-expressions': 'off',
|
|
25
|
+
indent: 'off',
|
|
26
|
+
'@typescript-eslint/indent': ['error', 2],
|
|
27
|
+
quotes: 'off',
|
|
28
|
+
'@typescript-eslint/quotes': 'error',
|
|
29
|
+
'no-template-curly-in-string': 'off',
|
|
30
|
+
'@typescript-eslint/no-floating-promises': 'off',
|
|
31
|
+
'@typescript-eslint/consistent-type-assertions': 'off',
|
|
32
|
+
'@typescript-eslint/no-unnecessary-type-assertion': 'off',
|
|
33
|
+
'@typescript-eslint/restrict-template-expressions': 'off',
|
|
34
|
+
'@typescript-eslint/ban-types': 'off',
|
|
35
|
+
},
|
|
36
|
+
}
|
package/.prettierrc
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"editor.formatOnSave": false,
|
|
3
|
+
"[typescript]": {
|
|
4
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
|
5
|
+
},
|
|
6
|
+
"[typescriptreact]": {
|
|
7
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
|
8
|
+
},
|
|
9
|
+
"eslint.format.enable": true,
|
|
10
|
+
"editor.codeActionsOnSave": {
|
|
11
|
+
"source.fixAll.eslint": true
|
|
12
|
+
}
|
|
13
|
+
}
|
package/README.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://mapojs.com/antd-solid">
|
|
3
|
+
<img width="200" src="https://gw.alipayobjects.com/zos/rmsportal/rlpTLlbMzTNYuZGGCVYM.png">
|
|
4
|
+
</a>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
<h1 align="center">Antd-solid</h1>
|
|
8
|
+
|
|
9
|
+
<div align="center">
|
|
10
|
+
|
|
11
|
+
Ant Design 的 solid 版本
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="ant-[border:1px_solid_rgba(5,5,5,0.06)] ant-rounded-6px">
|
|
3
|
+
<div class="ant-px-24px ant-py-36px">
|
|
4
|
+
<div ref="demoContainer"></div>
|
|
5
|
+
</div>
|
|
6
|
+
<!-- <div class="ant-[border-top:1px_solid_rgba(5,5,5,0.06)] ant-relative ant-px-24px ant-pt-18px ant-pb-12px">
|
|
7
|
+
<div class="ant-font-bold ant-absolute -ant-translate-y-1/2 ant-left-16px ant-top-0 ant-bg-white ant-px-8px">{{
|
|
8
|
+
title }}</div>
|
|
9
|
+
<div>{{ description }}</div>
|
|
10
|
+
</div> -->
|
|
11
|
+
<div
|
|
12
|
+
class="ant-[border-top:1px_dashed_rgba(5,5,5,0.06)] ant-flex ant-justify-center ant-items-center ant-py-12px ant-gap-16px ant-h-40px">
|
|
13
|
+
<span class="i-ant-design:copy ant-cursor-pointer" @click="() => onCopy(code)" />
|
|
14
|
+
<img v-show="!expand" class="ant-w-16px ant-cursor-pointer"
|
|
15
|
+
src="https://gw.alipayobjects.com/zos/antfincdn/Z5c7kzvi30/expand.svg" alt="expand" @click="expand = !expand" />
|
|
16
|
+
<img v-show="expand" class="ant-w-16px ant-cursor-pointer"
|
|
17
|
+
src="https://gw.alipayobjects.com/zos/antfincdn/4zAaozCvUH/unexpand.svg" alt="unexpand"
|
|
18
|
+
@click="expand = !expand" />
|
|
19
|
+
</div>
|
|
20
|
+
<div v-show="expand" class="ant-[border-top:1px_dashed_rgba(5,5,5,0.06)]">
|
|
21
|
+
<pre class='language-typescript !ant-m-0 !ant-bg-white !ant-p-16px !ant-flex'>
|
|
22
|
+
<code class="!ant-text-[var(--dark-color)] !ant-p-0" v-html="codeHtml"></code>
|
|
23
|
+
</pre>
|
|
24
|
+
</div>
|
|
25
|
+
</div>
|
|
26
|
+
</template>
|
|
27
|
+
|
|
28
|
+
<script lang="ts" setup>
|
|
29
|
+
import { type Component } from 'solid-js'
|
|
30
|
+
import { render, createComponent } from 'solid-js/web'
|
|
31
|
+
import { onMounted, ref } from 'vue'
|
|
32
|
+
import Prism from 'prismjs'
|
|
33
|
+
import 'prismjs/themes/prism.css'
|
|
34
|
+
import 'prismjs/components/prism-typescript'
|
|
35
|
+
|
|
36
|
+
interface Props {
|
|
37
|
+
component: Component
|
|
38
|
+
code: string
|
|
39
|
+
// title?: string
|
|
40
|
+
// description?: string
|
|
41
|
+
}
|
|
42
|
+
const props = defineProps<Props>()
|
|
43
|
+
|
|
44
|
+
let demoContainer = ref<HTMLDivElement>()
|
|
45
|
+
|
|
46
|
+
let expand = ref(false)
|
|
47
|
+
|
|
48
|
+
let codeHtml = ref('')
|
|
49
|
+
|
|
50
|
+
onMounted(() => {
|
|
51
|
+
render(() => createComponent(props.component, {}), demoContainer.value!)
|
|
52
|
+
|
|
53
|
+
codeHtml.value = Prism.highlight(props.code, Prism.languages.typescript, 'typescript')
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
function onCopy(text: string) {
|
|
57
|
+
navigator.clipboard.writeText(text)
|
|
58
|
+
}
|
|
59
|
+
</script>
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { defineConfig } from 'vitepress'
|
|
2
|
+
import UnocssPlugin from '@unocss/vite'
|
|
3
|
+
import solidPlugin from 'vite-plugin-solid'
|
|
4
|
+
import path from 'path'
|
|
5
|
+
|
|
6
|
+
export default defineConfig({
|
|
7
|
+
title: "Antd-solid",
|
|
8
|
+
description: "UI 库",
|
|
9
|
+
cleanUrls: true,
|
|
10
|
+
head: [['link', { rel: 'shortcut icon', href: 'https://gw.alipayobjects.com/zos/rmsportal/rlpTLlbMzTNYuZGGCVYM.png' }]],
|
|
11
|
+
themeConfig: {
|
|
12
|
+
logo: 'https://gw.alipayobjects.com/zos/rmsportal/rlpTLlbMzTNYuZGGCVYM.png',
|
|
13
|
+
nav: [
|
|
14
|
+
{ text: '首页', link: '/' },
|
|
15
|
+
{ text: '组件', link: '/components/button' }
|
|
16
|
+
],
|
|
17
|
+
sidebar: [
|
|
18
|
+
{
|
|
19
|
+
text: '通用组件',
|
|
20
|
+
items: [
|
|
21
|
+
{ text: 'Button 按钮', link: '/components/button' },
|
|
22
|
+
]
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
text: '数据展示',
|
|
26
|
+
items: [
|
|
27
|
+
{ text: 'Table 表格', link: '/components/table' },
|
|
28
|
+
]
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
socialLinks: [
|
|
32
|
+
{ icon: 'github', link: 'https://github.com/Reinhard2019/antd-solid' }
|
|
33
|
+
],
|
|
34
|
+
footer: {
|
|
35
|
+
copyright: 'Released under the MIT License. Copyright © 2023-present 丁磊',
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
vite: {
|
|
39
|
+
resolve: {
|
|
40
|
+
alias: {
|
|
41
|
+
'antd-solid': path.resolve(__dirname, '../../src'),
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
plugins: [
|
|
45
|
+
UnocssPlugin(),
|
|
46
|
+
solidPlugin(),
|
|
47
|
+
],
|
|
48
|
+
}
|
|
49
|
+
})
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
--vp-home-hero-name-color: transparent;
|
|
3
|
+
--vp-home-hero-name-background: linear-gradient(
|
|
4
|
+
120deg,
|
|
5
|
+
#1184ff 30%,
|
|
6
|
+
#f64a5b
|
|
7
|
+
);
|
|
8
|
+
|
|
9
|
+
--vp-home-hero-image-background-image: linear-gradient(
|
|
10
|
+
-90deg,
|
|
11
|
+
#f64a5b 10%,
|
|
12
|
+
#1184ff 60%
|
|
13
|
+
);
|
|
14
|
+
--vp-home-hero-image-filter: blur(40px);
|
|
15
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import 'uno.css'
|
|
2
|
+
import DefaultTheme from 'vitepress/theme'
|
|
3
|
+
import 'antd-solid/index.css'
|
|
4
|
+
import './index.css'
|
|
5
|
+
import Code from '../components/Code.vue'
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
...DefaultTheme,
|
|
9
|
+
enhanceApp(ctx) {
|
|
10
|
+
DefaultTheme.enhanceApp(ctx)
|
|
11
|
+
ctx.app.component('Code', Code)
|
|
12
|
+
},
|
|
13
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type Component } from 'solid-js'
|
|
2
|
+
import { Button } from 'antd-solid'
|
|
3
|
+
|
|
4
|
+
const Index: Component = () => {
|
|
5
|
+
return (
|
|
6
|
+
<div
|
|
7
|
+
style={{
|
|
8
|
+
display: 'flex',
|
|
9
|
+
gap: '8px',
|
|
10
|
+
}}
|
|
11
|
+
>
|
|
12
|
+
<Button type="primary">Primary Button</Button>
|
|
13
|
+
<Button>Default Button</Button>
|
|
14
|
+
<Button type="text">Text Button</Button>
|
|
15
|
+
<Button type="link">Link Button</Button>
|
|
16
|
+
</div>
|
|
17
|
+
)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export default Index
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type Component } from 'solid-js'
|
|
2
|
+
import { type Column, Table } from 'antd-solid'
|
|
3
|
+
|
|
4
|
+
interface Row {
|
|
5
|
+
name: string
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const Index: Component = () => {
|
|
9
|
+
const columns: Array<Column<Row>> = [
|
|
10
|
+
{
|
|
11
|
+
title: '动画',
|
|
12
|
+
render(row) {
|
|
13
|
+
return <div>{row.name}</div>
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
title: '属性',
|
|
18
|
+
render(row) {
|
|
19
|
+
return <div>{row.name}</div>
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
]
|
|
23
|
+
const dataSource = [
|
|
24
|
+
{
|
|
25
|
+
name: '1',
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
name: '2',
|
|
29
|
+
},
|
|
30
|
+
]
|
|
31
|
+
return <Table columns={columns} dataSource={dataSource} />
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export default Index
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
outline: deep
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Button 按钮 {#title}
|
|
6
|
+
|
|
7
|
+
按钮用来触发一些操作。
|
|
8
|
+
|
|
9
|
+
## 代码演示
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### 按钮类型
|
|
13
|
+
|
|
14
|
+
按钮有五种类型:主按钮、次按钮、虚线按钮、文本按钮和链接按钮。主按钮在同一个操作区域最多出现一次。
|
|
15
|
+
|
|
16
|
+
<!-- The following frontmatter options are only applicable when using the default theme. -->
|
|
17
|
+
|
|
18
|
+
<script lang="ts" setup>
|
|
19
|
+
import component from './Button.tsx'
|
|
20
|
+
import code from './Button.tsx?raw'
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<Code :component="component" :code="code" />
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
outline: deep
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Table 表格 {#title}
|
|
6
|
+
|
|
7
|
+
展示行列数据。
|
|
8
|
+
|
|
9
|
+
## 代码演示
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### 基本用法
|
|
13
|
+
|
|
14
|
+
简单的表格
|
|
15
|
+
|
|
16
|
+
<!-- The following frontmatter options are only applicable when using the default theme. -->
|
|
17
|
+
|
|
18
|
+
<script lang="ts" setup>
|
|
19
|
+
import component from './Table.tsx'
|
|
20
|
+
import code from './Table.tsx?raw'
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<Code :component="component" :code="code" />
|
package/docs/index.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
---
|
|
2
|
+
# https://vitepress.dev/reference/default-theme-home-page
|
|
3
|
+
layout: home
|
|
4
|
+
|
|
5
|
+
hero:
|
|
6
|
+
name: "Antd-solid"
|
|
7
|
+
text: "UI 库"
|
|
8
|
+
tagline: Ant Design 的 solid 版本
|
|
9
|
+
image:
|
|
10
|
+
src: https://gw.alipayobjects.com/zos/rmsportal/rlpTLlbMzTNYuZGGCVYM.png
|
|
11
|
+
alt: Antd-solid
|
|
12
|
+
actions:
|
|
13
|
+
- theme: brand
|
|
14
|
+
text: 开始使用
|
|
15
|
+
link: /components/button
|
|
16
|
+
# - theme: alt
|
|
17
|
+
# text: API Examples
|
|
18
|
+
# link: /api-examples
|
|
19
|
+
|
|
20
|
+
features:
|
|
21
|
+
- title: 支持 solid
|
|
22
|
+
details: Ant Design 的 solid 版本
|
|
23
|
+
- title: 定制主题,随心所欲
|
|
24
|
+
details: 使用 css 变量,让你定制主题更简单
|
|
25
|
+
- title: 组件丰富,选用自如
|
|
26
|
+
details: 大量实用组件满足你的需求,灵活定制与拓展
|
|
27
|
+
---
|
|
28
|
+
|
package/package.json
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "antd-solid",
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"devDependencies": {
|
|
8
|
+
"@iconify-json/ant-design": "^1.1.5",
|
|
9
|
+
"@rollup/plugin-babel": "^6.0.3",
|
|
10
|
+
"@rollup/plugin-commonjs": "^24.1.0",
|
|
11
|
+
"@solidjs/testing-library": "^0.7.0",
|
|
12
|
+
"@testing-library/jest-dom": "^5.16.5",
|
|
13
|
+
"@types/lodash-es": "^4.17.7",
|
|
14
|
+
"@types/react": "^18.0.26",
|
|
15
|
+
"@types/react-color": "^3.0.6",
|
|
16
|
+
"@types/react-dom": "^18.0.9",
|
|
17
|
+
"@typescript-eslint/eslint-plugin": "^5.59.0",
|
|
18
|
+
"@typescript-eslint/parser": "^5.59.0",
|
|
19
|
+
"@unocss/cli": "^0.51.8",
|
|
20
|
+
"@unocss/preset-icons": "^0.51.6",
|
|
21
|
+
"@unocss/preset-mini": "^0.51.6",
|
|
22
|
+
"@unocss/transformer-variant-group": "^0.51.6",
|
|
23
|
+
"@unocss/vite": "^0.51.6",
|
|
24
|
+
"babel-preset-solid": "^1.7.3",
|
|
25
|
+
"eslint": "^8.39.0",
|
|
26
|
+
"eslint-config-prettier": "^8.8.0",
|
|
27
|
+
"eslint-config-standard-with-typescript": "^34.0.1",
|
|
28
|
+
"eslint-plugin-import": "^2.27.5",
|
|
29
|
+
"eslint-plugin-n": "^15.7.0",
|
|
30
|
+
"eslint-plugin-promise": "^6.1.1",
|
|
31
|
+
"eslint-plugin-solid": "^0.12.1",
|
|
32
|
+
"jsdom": "^21.1.1",
|
|
33
|
+
"rollup": "^3.21.0",
|
|
34
|
+
"rollup-plugin-import-css": "^3.2.1",
|
|
35
|
+
"rollup-plugin-typescript2": "^0.34.1",
|
|
36
|
+
"typescript": "^5.1.6",
|
|
37
|
+
"vite-plugin-solid": "^2.7.0",
|
|
38
|
+
"vitepress": "1.0.0-rc.4",
|
|
39
|
+
"vitest": "^0.30.1"
|
|
40
|
+
},
|
|
41
|
+
"keywords": [],
|
|
42
|
+
"author": "",
|
|
43
|
+
"license": "ISC",
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"antd": "^5.3.0",
|
|
46
|
+
"classnames": "^2.3.2",
|
|
47
|
+
"lodash-es": "^4.17.21",
|
|
48
|
+
"prismjs": "^1.29.0",
|
|
49
|
+
"react": "^18.2.0",
|
|
50
|
+
"react-color": "^2.19.3",
|
|
51
|
+
"react-dom": "^18.2.0",
|
|
52
|
+
"solid-js": "^1.7.8"
|
|
53
|
+
},
|
|
54
|
+
"scripts": {
|
|
55
|
+
"docs:dev": "vitepress dev docs",
|
|
56
|
+
"docs:build": "vitepress build docs",
|
|
57
|
+
"docs:preview": "vitepress preview docs",
|
|
58
|
+
"build": "npx rollup -c && npm run build:unocss",
|
|
59
|
+
"build:unocss": "npx unocss './src/**' -o es/unocss.css -m",
|
|
60
|
+
"test": "vitest"
|
|
61
|
+
}
|
|
62
|
+
}
|
package/rollup.config.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import ts from "rollup-plugin-typescript2"
|
|
2
|
+
import css from "rollup-plugin-import-css"
|
|
3
|
+
import commonjs from "@rollup/plugin-commonjs"
|
|
4
|
+
import { babel } from "@rollup/plugin-babel"
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
input: "src/index.ts",
|
|
8
|
+
output: {
|
|
9
|
+
file: "es/index.js",
|
|
10
|
+
},
|
|
11
|
+
plugins: [
|
|
12
|
+
ts({
|
|
13
|
+
tsconfig: "./tsconfig.json",
|
|
14
|
+
// include: "src/**/*.ts+(|x)",
|
|
15
|
+
exclude: ["**/*.test.[ts|tsx]"],
|
|
16
|
+
}),
|
|
17
|
+
babel({
|
|
18
|
+
extensions: [".js", ".ts", ".jsx", ".tsx"],
|
|
19
|
+
presets: ["babel-preset-solid"],
|
|
20
|
+
}),
|
|
21
|
+
commonjs(),
|
|
22
|
+
css(),
|
|
23
|
+
],
|
|
24
|
+
external: ["uno.css"],
|
|
25
|
+
}
|
package/src/Button.css
ADDED
package/src/Button.tsx
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type Component,
|
|
3
|
+
mergeProps,
|
|
4
|
+
type ParentProps,
|
|
5
|
+
type JSX,
|
|
6
|
+
Show,
|
|
7
|
+
createSignal,
|
|
8
|
+
createMemo,
|
|
9
|
+
} from 'solid-js'
|
|
10
|
+
import cs from 'classnames'
|
|
11
|
+
import './Button.css'
|
|
12
|
+
|
|
13
|
+
interface ButtonProps extends ParentProps, JSX.CustomAttributes<HTMLButtonElement> {
|
|
14
|
+
type?: 'default' | 'primary' | 'text' | 'link'
|
|
15
|
+
onClick?: ((e: MouseEvent) => void) | ((e: MouseEvent) => Promise<unknown>)
|
|
16
|
+
/**
|
|
17
|
+
* 默认: middle
|
|
18
|
+
* plain: 没有多余的 padding 和高度等
|
|
19
|
+
*/
|
|
20
|
+
size?: 'large' | 'middle' | 'small' | 'plain'
|
|
21
|
+
class?: string
|
|
22
|
+
style?: JSX.CSSProperties
|
|
23
|
+
loading?: boolean
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const sizeClassMap = {
|
|
27
|
+
large: 'ant-px-15px ant-py-6px ant-h-40px ant-rounded-8px',
|
|
28
|
+
middle: 'ant-px-15px ant-py-4px ant-h-32px ant-rounded-6px',
|
|
29
|
+
small: 'ant-px-7px ant-h-24px ant-rounded-4px',
|
|
30
|
+
plain: 'ant-p-0',
|
|
31
|
+
} as const
|
|
32
|
+
|
|
33
|
+
const typeClassMap = {
|
|
34
|
+
default:
|
|
35
|
+
'ant-[border:1px_solid_rgb(217,217,217)] ant-bg-white ant-text-[var(--dark-color)] hover:ant-[border-color:var(--light-primary-color)] hover:ant-text-[var(--light-primary-color)]',
|
|
36
|
+
primary:
|
|
37
|
+
'ant-border-none ant-bg-[var(--primary-color)] hover:ant-bg-[var(--light-primary-color)] ant-text-white',
|
|
38
|
+
text: 'ant-border-none ant-bg-transparent ant-text-[var(--dark-color)] hover:ant-bg-[rgba(0,0,0,0.06)] active:ant-bg-[rgba(0,0,0,.15)]',
|
|
39
|
+
link: 'ant-border-none ant-bg-transparent ant-text-[var(--primary-color)] hover:ant-text-[var(--light-primary-color)] active:ant-text-[var(--dark-primary-color)]',
|
|
40
|
+
} as const
|
|
41
|
+
|
|
42
|
+
const Button: Component<ButtonProps> = props => {
|
|
43
|
+
const mergedProps = mergeProps({ type: 'default', size: 'middle' } as ButtonProps, props)
|
|
44
|
+
const [innerLoading, setLoading] = createSignal(false)
|
|
45
|
+
const loading = createMemo(() => props.loading ?? innerLoading())
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<button
|
|
49
|
+
ref={mergedProps.ref}
|
|
50
|
+
class={cs(
|
|
51
|
+
'ant-relative ant-cursor-pointer',
|
|
52
|
+
mergedProps.class,
|
|
53
|
+
sizeClassMap[mergedProps.size!],
|
|
54
|
+
typeClassMap[mergedProps.type!],
|
|
55
|
+
loading() && 'ant-opacity-65',
|
|
56
|
+
)}
|
|
57
|
+
style={mergedProps.style}
|
|
58
|
+
onClick={e => {
|
|
59
|
+
const res = mergedProps.onClick?.(e)
|
|
60
|
+
if (res instanceof Promise) {
|
|
61
|
+
setLoading(true)
|
|
62
|
+
res.finally(() => setLoading(false))
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (mergedProps.type === 'default' || mergedProps.type === 'primary') {
|
|
66
|
+
const div = document.createElement('div')
|
|
67
|
+
div.className =
|
|
68
|
+
'ant-absolute ant-inset-0 ant-rounded-inherit ant-[border:1px_solid_var(--light-primary-color)] ant-[animation:button-border_linear_1s]'
|
|
69
|
+
const onAnimationEnd = () => {
|
|
70
|
+
div.remove()
|
|
71
|
+
div.removeEventListener('animationend', onAnimationEnd)
|
|
72
|
+
}
|
|
73
|
+
div.addEventListener('animationend', onAnimationEnd)
|
|
74
|
+
e.currentTarget.insertBefore(div, e.currentTarget.childNodes[0])
|
|
75
|
+
}
|
|
76
|
+
}}
|
|
77
|
+
>
|
|
78
|
+
<Show when={loading()}>
|
|
79
|
+
<span class="i-ant-design:loading ant-[vertical-align:-0.125em] keyframes-spin ant-[animation:spin_1s_linear_infinite] ant-mr-8px" />
|
|
80
|
+
</Show>
|
|
81
|
+
<span>{mergedProps.children}</span>
|
|
82
|
+
</button>
|
|
83
|
+
)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export default Button
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { type Component, createSignal, mergeProps, untrack } from 'solid-js'
|
|
2
|
+
import { type ColorResult, SketchPicker, type Color, type RGBColor, type HSLColor } from 'react-color'
|
|
3
|
+
import { reactToSolidComponent } from './utils/component'
|
|
4
|
+
import Button from './Button'
|
|
5
|
+
import Popover from './Popover'
|
|
6
|
+
import { get, isNil } from 'lodash-es'
|
|
7
|
+
|
|
8
|
+
const _SketchPicker = reactToSolidComponent(SketchPicker)
|
|
9
|
+
|
|
10
|
+
export interface ColorPickerProps {
|
|
11
|
+
/**
|
|
12
|
+
* 默认: rgba
|
|
13
|
+
*/
|
|
14
|
+
type?: 'rgba' | 'hsla'
|
|
15
|
+
defaultColor?: string
|
|
16
|
+
onChange?: (colorString: string, color: ColorResult) => void
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function isRGBColor(color: Color): color is RGBColor {
|
|
20
|
+
return ['r', 'g', 'b'].every(k => !isNil(get(color, k)))
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function isHSLColor(color: Color): color is HSLColor {
|
|
24
|
+
return ['r', 'g', 'b'].every(k => !isNil(get(color, k)))
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function colorStringify(color: Color | undefined) {
|
|
28
|
+
if (!color) return
|
|
29
|
+
|
|
30
|
+
if (isRGBColor(color)) return `rgba(${color.r},${color.g},${color.b},${color.a ?? 1})`
|
|
31
|
+
|
|
32
|
+
if (isHSLColor(color)) return `hsla(${color.h},${color.s},${color.l},${color.a ?? 1})`
|
|
33
|
+
|
|
34
|
+
return color
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const ColorPicker: Component<ColorPickerProps> = _props => {
|
|
38
|
+
const props = mergeProps({ type: 'rgba' } as ColorPickerProps, _props)
|
|
39
|
+
const [color, setColor] = createSignal(props.defaultColor ?? 'black')
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<Popover
|
|
43
|
+
content={
|
|
44
|
+
<_SketchPicker
|
|
45
|
+
color={color()}
|
|
46
|
+
onChange={colorResult =>
|
|
47
|
+
{ untrack(() => {
|
|
48
|
+
const colorString = colorStringify(
|
|
49
|
+
props.type === 'rgba' ? colorResult.rgb : colorResult.hsl,
|
|
50
|
+
)!
|
|
51
|
+
setColor(colorString)
|
|
52
|
+
|
|
53
|
+
props.onChange?.(colorString, colorResult)
|
|
54
|
+
}); }
|
|
55
|
+
}
|
|
56
|
+
/>
|
|
57
|
+
}
|
|
58
|
+
trigger="click"
|
|
59
|
+
placement="bottomLeft"
|
|
60
|
+
>
|
|
61
|
+
<Button style={{ background: color() }} />
|
|
62
|
+
</Popover>
|
|
63
|
+
)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export default ColorPicker
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { DatePicker as DatePickerAntd } from 'antd'
|
|
2
|
+
import { reactToSolidComponent, replaceClassName } from './utils/component'
|
|
3
|
+
|
|
4
|
+
const RangePicker = replaceClassName(reactToSolidComponent(DatePickerAntd.RangePicker))
|
|
5
|
+
|
|
6
|
+
const _DatePicker = replaceClassName(reactToSolidComponent(DatePickerAntd))
|
|
7
|
+
const DatePicker = _DatePicker as typeof _DatePicker & {
|
|
8
|
+
RangePicker: typeof RangePicker
|
|
9
|
+
}
|
|
10
|
+
DatePicker.RangePicker = RangePicker
|
|
11
|
+
|
|
12
|
+
export default DatePicker
|