antd-solid 0.0.2 → 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.
- package/.eslintignore +2 -0
- package/.husky/pre-commit +4 -0
- package/.vscode/settings.json +1 -1
- package/docs/.vitepress/components/Code.vue +127 -11
- package/docs/.vitepress/config.ts +39 -1
- package/docs/.vitepress/theme/index.css +4 -0
- package/docs/.vitepress/theme/index.ts +0 -1
- package/docs/components/{Button.tsx → button/Base.tsx} +1 -0
- package/docs/components/button/Danger.tsx +21 -0
- package/docs/components/button.md +19 -7
- package/docs/components/collapse/Base.tsx +25 -0
- package/docs/components/collapse.md +26 -0
- package/docs/components/color-picker/Base.tsx +14 -0
- package/docs/components/color-picker.md +26 -0
- package/docs/components/compact/Base.tsx +27 -0
- package/docs/components/compact.md +26 -0
- package/docs/components/date-picker/Base.tsx +15 -0
- package/docs/components/date-picker.md +26 -0
- package/docs/components/empty/Base.tsx +8 -0
- package/docs/components/empty/PRESENTED_IMAGE_SIMPLE.tsx +8 -0
- package/docs/components/empty.md +32 -0
- package/docs/components/form/Base.tsx +63 -0
- package/docs/components/form.md +27 -0
- package/docs/components/image/Base.tsx +13 -0
- package/docs/components/image.md +26 -0
- package/docs/components/input/AddonBeforeAndAfter.tsx +14 -0
- package/docs/components/input/Base.tsx +15 -0
- package/docs/components/input/Disabled.tsx +19 -0
- package/docs/components/input/PrefixAndSuffix.tsx +14 -0
- package/docs/components/input/Status.tsx +25 -0
- package/docs/components/input/TextArea.tsx +14 -0
- package/docs/components/input-number/Base.tsx +15 -0
- package/docs/components/input-number/MinMax.tsx +17 -0
- package/docs/components/input-number.md +34 -0
- package/docs/components/input.md +57 -0
- package/docs/components/modal/Base.tsx +35 -0
- package/docs/components/modal.md +26 -0
- package/docs/components/popconfirm/Base.tsx +25 -0
- package/docs/components/popconfirm.md +26 -0
- package/docs/components/popover/Base.tsx +19 -0
- package/docs/components/popover.md +26 -0
- package/docs/components/progress/Base.tsx +16 -0
- package/docs/components/progress.md +26 -0
- package/docs/components/radio/Base.tsx +10 -0
- package/docs/components/radio.md +26 -0
- package/docs/components/segmented/Base.tsx +10 -0
- package/docs/components/segmented/Block.tsx +10 -0
- package/docs/components/segmented/Disabled.tsx +28 -0
- package/docs/components/segmented.md +38 -0
- package/docs/components/select/AllowClear.tsx +18 -0
- package/docs/components/select/Base.tsx +17 -0
- package/docs/components/select.md +35 -0
- package/docs/components/switch/Base.tsx +14 -0
- package/docs/components/switch.md +26 -0
- package/docs/components/{Table.tsx → table/Base.tsx} +2 -2
- package/docs/components/table.md +12 -6
- package/docs/components/tabs/Base.tsx +25 -0
- package/docs/components/tabs/Segment.tsx +25 -0
- package/docs/components/tabs.md +33 -0
- package/docs/components/tooltip/Base.tsx +12 -0
- package/docs/components/tooltip/Placement.tsx +90 -0
- package/docs/components/tooltip.md +32 -0
- package/docs/components/tree/Base.tsx +45 -0
- package/docs/components/tree.md +26 -0
- package/global.d.ts +9 -0
- package/package.json +29 -14
- package/patches/vitepress@1.0.0-rc.4.patch +60 -0
- package/rollup.config.js +60 -20
- package/scripts/annotationNonProductionCode.js +30 -0
- package/scripts/cancelAnnotationNonProductionCode.js +30 -0
- package/src/Button.tsx +51 -12
- package/src/Collapse/index.tsx +86 -0
- package/src/ColorPicker.tsx +6 -61
- package/src/Compact.tsx +15 -0
- package/src/Empty/PRESENTED_IMAGE_SIMPLE.tsx +15 -0
- package/src/Empty/assets/EmptySvg.tsx +43 -0
- package/src/Empty/assets/SimpleEmptySvg.tsx +16 -0
- package/src/Empty/index.tsx +20 -0
- package/src/Input.tsx +154 -62
- package/src/InputNumber.tsx +68 -62
- package/src/Modal.tsx +90 -62
- package/src/Popconfirm.tsx +5 -3
- package/src/Segmented/index.tsx +95 -0
- package/src/Select.tsx +125 -3
- package/src/Switch.tsx +1 -1
- package/src/Table.tsx +36 -29
- package/src/Tabs.tsx +88 -45
- package/src/Tooltip.tsx +233 -87
- package/src/Tree.tsx +4 -4
- package/src/form/Form.tsx +94 -0
- package/src/form/FormItem.tsx +139 -0
- package/src/form/context.ts +16 -0
- package/src/form/index.ts +13 -0
- package/src/hooks/createControllableValue.ts +9 -6
- package/src/index.ts +12 -5
- package/src/types/index.ts +5 -0
- package/src/utils/EventEmitter.ts +15 -0
- package/src/utils/component.tsx +1 -1
- package/src/utils/solid.ts +8 -3
- package/src/utils/zh_CN.ts +236 -0
- package/tsconfig.json +6 -4
- package/unocss.config.ts +90 -6
- package/src/Button.css +0 -14
- package/src/Form.tsx +0 -98
- package/src/index.css +0 -21
package/unocss.config.ts
CHANGED
|
@@ -1,17 +1,75 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/promise-function-async */
|
|
2
1
|
import { defineConfig } from '@unocss/vite'
|
|
3
2
|
import { presetMini } from '@unocss/preset-mini'
|
|
4
3
|
import transformerVariantGroup from '@unocss/transformer-variant-group'
|
|
5
4
|
import presetIcons from '@unocss/preset-icons'
|
|
6
5
|
|
|
7
6
|
export default defineConfig({
|
|
7
|
+
preflights: [
|
|
8
|
+
{
|
|
9
|
+
getCSS: () => `
|
|
10
|
+
:root {
|
|
11
|
+
--primary-color: #52c41a;
|
|
12
|
+
--light-primary-color: #95de64;
|
|
13
|
+
--dark-primary-color: #237804;
|
|
14
|
+
--active-bg-color: #d9f7be;
|
|
15
|
+
--hover-bg-color: rgba(0,0,0,.04);
|
|
16
|
+
|
|
17
|
+
--light-error-color: #ff7875;
|
|
18
|
+
--dark-error-color: #d9363e;
|
|
19
|
+
|
|
20
|
+
--error-bg-color: #fff2f0;
|
|
21
|
+
--error-bg-hover-color: #fff1f0;
|
|
22
|
+
|
|
23
|
+
--warning-color: #faad14;
|
|
24
|
+
--color-warning-border-hover: #ffd666;
|
|
25
|
+
|
|
26
|
+
--secondary-border-color: #f0f0f0;
|
|
27
|
+
|
|
28
|
+
--light-color: rgba(0, 0, 0, 0.45);
|
|
29
|
+
--dark-color: rgba(0, 0, 0, 0.88);
|
|
30
|
+
|
|
31
|
+
--color-text-secondary: rgba(0, 0, 0, 0.65);
|
|
32
|
+
--color-text-tertiary: rgba(0, 0, 0, 0.45);
|
|
33
|
+
--color-text-quaternary: rgba(0, 0, 0, 0.25);
|
|
34
|
+
|
|
35
|
+
--light-bg-color: #fafafa;
|
|
36
|
+
|
|
37
|
+
--ant-color-error: #ff4d4f;
|
|
38
|
+
--ant-color-text: rgba(0, 0, 0, 0.88);
|
|
39
|
+
--ant-color-text-disabled: rgba(0, 0, 0, 0.25);
|
|
40
|
+
--ant-color-text-heading: rgba(0, 0, 0, 0.88);
|
|
41
|
+
--ant-color-border: #d9d9d9;
|
|
42
|
+
--ant-color-bg-container-disabled: rgba(0, 0, 0, 0.04);
|
|
43
|
+
|
|
44
|
+
--ant-color-bg-layout: #f5f5f5;
|
|
45
|
+
|
|
46
|
+
--ant-margin-xs: 8px;
|
|
47
|
+
--ant-margin-sm: 12px;
|
|
48
|
+
--ant-margin-xl: 32px;
|
|
49
|
+
|
|
50
|
+
--ant-padding-sm: 12px;
|
|
51
|
+
|
|
52
|
+
--ant-box-shadow-tertiary: 0 1px 2px 0 rgba(0, 0, 0, 0.03), 0 1px 6px -1px rgba(0, 0, 0, 0.02), 0 2px 4px 0 rgba(0, 0, 0, 0.02);
|
|
53
|
+
|
|
54
|
+
--ant-border-radius-sm: 4px;
|
|
55
|
+
--ant-border-radius: 6px;
|
|
56
|
+
--ant-border-radius-lg: 8px;
|
|
57
|
+
|
|
58
|
+
--ant-collapse-header-bg: rgba(0, 0, 0, 0.02);
|
|
59
|
+
--ant-collapse-header-padding: 12px 16px;
|
|
60
|
+
|
|
61
|
+
font-size: 14px;
|
|
62
|
+
}
|
|
63
|
+
`,
|
|
64
|
+
},
|
|
65
|
+
],
|
|
8
66
|
presets: [
|
|
9
67
|
presetMini({
|
|
10
|
-
prefix: 'ant-'
|
|
68
|
+
prefix: 'ant-',
|
|
11
69
|
}),
|
|
12
70
|
presetIcons({
|
|
13
71
|
collections: {
|
|
14
|
-
'ant-design': () => import('@iconify-json/ant-design').then(i => i.icons),
|
|
72
|
+
'ant-design': async () => await import('@iconify-json/ant-design').then(i => i.icons),
|
|
15
73
|
},
|
|
16
74
|
extraProperties: {
|
|
17
75
|
display: 'inline-block',
|
|
@@ -61,10 +119,10 @@ export default defineConfig({
|
|
|
61
119
|
},
|
|
62
120
|
/**
|
|
63
121
|
* 父级 hover 的状态定义子级的样式
|
|
64
|
-
* p
|
|
122
|
+
* p:hover-child[.*]:
|
|
65
123
|
*/
|
|
66
124
|
matcher => {
|
|
67
|
-
const prevReg = /^p
|
|
125
|
+
const prevReg = /^p:hover-child\[(.*)\]:/
|
|
68
126
|
const match = matcher.match(prevReg)
|
|
69
127
|
if (!match) return matcher
|
|
70
128
|
return {
|
|
@@ -72,9 +130,22 @@ export default defineConfig({
|
|
|
72
130
|
selector: s => `${s}:hover ${match[1] || '*'}`,
|
|
73
131
|
}
|
|
74
132
|
},
|
|
133
|
+
/**
|
|
134
|
+
* 有父级 class 的时候才会生效
|
|
135
|
+
* p[.*]:
|
|
136
|
+
*/
|
|
137
|
+
matcher => {
|
|
138
|
+
const prevReg = /^p\[(.*)\]:/
|
|
139
|
+
const match = matcher.match(prevReg)
|
|
140
|
+
if (!match) return matcher
|
|
141
|
+
return {
|
|
142
|
+
matcher: matcher.slice(match[0].length),
|
|
143
|
+
selector: s => `${match[1] || '*'} ${s}`,
|
|
144
|
+
}
|
|
145
|
+
},
|
|
75
146
|
],
|
|
76
147
|
rules: [
|
|
77
|
-
['rm-size-btn', { padding: 0, border: 'none', height: 'auto' }],
|
|
148
|
+
['ant-rm-size-btn', { padding: 0, border: 'none', height: 'auto' }],
|
|
78
149
|
[
|
|
79
150
|
/^keyframes-spin$/,
|
|
80
151
|
() => {
|
|
@@ -88,5 +159,18 @@ export default defineConfig({
|
|
|
88
159
|
}`
|
|
89
160
|
},
|
|
90
161
|
],
|
|
162
|
+
[
|
|
163
|
+
/^ant-keyframes-(.*)(\[.*\])(\[.*\])$/,
|
|
164
|
+
match => {
|
|
165
|
+
return `@keyframes ${match[1]} {
|
|
166
|
+
from {
|
|
167
|
+
${match[2].slice(1, -1)};
|
|
168
|
+
}
|
|
169
|
+
to {
|
|
170
|
+
${match[3].slice(1, -1)};
|
|
171
|
+
}
|
|
172
|
+
}`
|
|
173
|
+
},
|
|
174
|
+
],
|
|
91
175
|
],
|
|
92
176
|
})
|
package/src/Button.css
DELETED
package/src/Form.tsx
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import { set } from 'lodash-es'
|
|
2
|
-
import {
|
|
3
|
-
type JSXElement,
|
|
4
|
-
type Component,
|
|
5
|
-
type JSX,
|
|
6
|
-
mergeProps,
|
|
7
|
-
Show,
|
|
8
|
-
Index,
|
|
9
|
-
createMemo,
|
|
10
|
-
} from 'solid-js'
|
|
11
|
-
import { Dynamic } from 'solid-js/web'
|
|
12
|
-
import { toArray } from './utils/array'
|
|
13
|
-
import cs from 'classnames'
|
|
14
|
-
|
|
15
|
-
export interface FormInstance<T extends {} = {}> {
|
|
16
|
-
validateFields: () => Promise<T>
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export interface FormProps<T extends {} = {}> {
|
|
20
|
-
ref?: (form: FormInstance<T>) => void;
|
|
21
|
-
/**
|
|
22
|
-
* 表单布局
|
|
23
|
-
* 默认: horizontal
|
|
24
|
-
*/
|
|
25
|
-
layout?: 'horizontal' | 'vertical' | 'inline'
|
|
26
|
-
/**
|
|
27
|
-
* 提交按钮
|
|
28
|
-
* @deprecated
|
|
29
|
-
*/
|
|
30
|
-
submit?: (form: FormInstance<T>) => JSXElement
|
|
31
|
-
children: JSXElement
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export interface FormItemComponentProps<T = any> {
|
|
35
|
-
defaultValue?: T
|
|
36
|
-
onChange?: (value: T) => void
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export interface FormItemProps {
|
|
40
|
-
class?: string
|
|
41
|
-
style?: JSX.CSSProperties
|
|
42
|
-
required?: boolean
|
|
43
|
-
label?: JSXElement
|
|
44
|
-
name?: string
|
|
45
|
-
initialValue?: any
|
|
46
|
-
component: Component<FormItemComponentProps>
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
function Form<T extends {} = {}>(_props: FormProps<T>) {
|
|
50
|
-
const props = mergeProps({ layout: 'horizontal' } as FormProps, _props)
|
|
51
|
-
|
|
52
|
-
const resolvedChildren = createMemo(() => {
|
|
53
|
-
return toArray(props.children) as unknown as FormItemProps[]
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
const values = Object.fromEntries(
|
|
57
|
-
resolvedChildren().map(child => [child.name, child.initialValue]),
|
|
58
|
-
) as T
|
|
59
|
-
const formInstance: FormInstance<T> = {
|
|
60
|
-
async validateFields() {
|
|
61
|
-
return await Promise.resolve(values)
|
|
62
|
-
},
|
|
63
|
-
}
|
|
64
|
-
_props.ref?.(formInstance)
|
|
65
|
-
|
|
66
|
-
return (
|
|
67
|
-
<div>
|
|
68
|
-
<Index each={resolvedChildren()}>
|
|
69
|
-
{item => (
|
|
70
|
-
<div class={cs('ant-flex ant-items-center ant-mb-16px', item().class)} style={item().style}>
|
|
71
|
-
<span class="ant-flex-shrink-0 ant-mr-8px">
|
|
72
|
-
<Show when={item().required}>
|
|
73
|
-
<span class='ant-mr-4px ant-text-[var(--error-color)]'>*</span>
|
|
74
|
-
</Show>
|
|
75
|
-
<label>{item().label}</label>
|
|
76
|
-
</span>
|
|
77
|
-
|
|
78
|
-
<Dynamic
|
|
79
|
-
component={item().component}
|
|
80
|
-
defaultValue={item().initialValue}
|
|
81
|
-
onChange={(value: any) => {
|
|
82
|
-
set(values, item().name!, value)
|
|
83
|
-
}}
|
|
84
|
-
/>
|
|
85
|
-
</div>
|
|
86
|
-
)}
|
|
87
|
-
</Index>
|
|
88
|
-
|
|
89
|
-
{props.submit?.(formInstance as FormInstance<T>)}
|
|
90
|
-
</div>
|
|
91
|
-
)
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
Form.Item = (props: FormItemProps) => props as any
|
|
95
|
-
|
|
96
|
-
Form.createForm = () => {}
|
|
97
|
-
|
|
98
|
-
export default Form
|
package/src/index.css
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
body {
|
|
2
|
-
--primary-color: #52c41a;
|
|
3
|
-
--light-primary-color: #95de64;
|
|
4
|
-
--dark-primary-color: #237804;
|
|
5
|
-
--active-bg-color: #d9f7be;
|
|
6
|
-
|
|
7
|
-
--error-color: #ff4d4f;
|
|
8
|
-
--warning-color: #faad14;
|
|
9
|
-
|
|
10
|
-
--border-color: #d9d9d9;
|
|
11
|
-
--secondary-border-color: #f0f0f0;
|
|
12
|
-
|
|
13
|
-
--light-color: rgba(0, 0, 0, 0.45);
|
|
14
|
-
--dark-color: rgba(0, 0, 0, 0.88);
|
|
15
|
-
|
|
16
|
-
--light-bg-color: #fafafa;
|
|
17
|
-
|
|
18
|
-
--secondary-border-color: #f0f0f0;
|
|
19
|
-
|
|
20
|
-
font-size: 14px;
|
|
21
|
-
}
|