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
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type JSXElement,
|
|
3
|
+
type Ref,
|
|
4
|
+
mergeProps,
|
|
5
|
+
type Setter,
|
|
6
|
+
onMount,
|
|
7
|
+
createSignal,
|
|
8
|
+
createMemo,
|
|
9
|
+
} from 'solid-js'
|
|
10
|
+
import { get, max, set } from 'lodash-es'
|
|
11
|
+
import Context from './context'
|
|
12
|
+
import { type Schema } from 'yup'
|
|
13
|
+
|
|
14
|
+
export interface FormInstance<T extends {} = {}> {
|
|
15
|
+
validateFields: () => Promise<T>
|
|
16
|
+
setFieldValue: (name: Parameters<typeof set>[1], value: any) => void
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface FormProps<T extends {} = {}> {
|
|
20
|
+
ref?: Ref<FormInstance<T>>
|
|
21
|
+
/**
|
|
22
|
+
* 表单布局
|
|
23
|
+
* 默认: horizontal
|
|
24
|
+
*/
|
|
25
|
+
layout?: 'horizontal' | 'vertical' | 'inline'
|
|
26
|
+
children: JSXElement
|
|
27
|
+
initialValues?: T
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function Form<T extends {} = {}>(_props: FormProps<T>) {
|
|
31
|
+
const props = mergeProps({ layout: 'horizontal' } as FormProps, _props)
|
|
32
|
+
const rulesDict: Record<string, Schema[]> = {}
|
|
33
|
+
const setErrMsgDict: Record<string, Setter<string>> = {}
|
|
34
|
+
|
|
35
|
+
const values = props.initialValues ? { ...props.initialValues } : ({} as T)
|
|
36
|
+
const formInstance: FormInstance<T> = {
|
|
37
|
+
async validateFields() {
|
|
38
|
+
const promises = Object.entries(rulesDict).flatMap(([name, rules]) => {
|
|
39
|
+
return rules.map(
|
|
40
|
+
async rule =>
|
|
41
|
+
await rule.validate(get(values, name)).catch(err => {
|
|
42
|
+
setErrMsgDict[name](err.message)
|
|
43
|
+
throw err
|
|
44
|
+
}),
|
|
45
|
+
)
|
|
46
|
+
})
|
|
47
|
+
const results = await Promise.allSettled(promises)
|
|
48
|
+
if (results.some(result => result.status === 'rejected')) {
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/no-throw-literal
|
|
50
|
+
throw {
|
|
51
|
+
errorFields: results.filter(res => res.status === 'rejected'),
|
|
52
|
+
values,
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return values as T
|
|
56
|
+
},
|
|
57
|
+
setFieldValue(name, value) {
|
|
58
|
+
set(values, name, value)
|
|
59
|
+
},
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
onMount(() => {
|
|
63
|
+
if (typeof _props.ref === 'function') {
|
|
64
|
+
_props.ref?.(formInstance)
|
|
65
|
+
}
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
// 存储 form item 的 dom 节点宽度
|
|
69
|
+
const [itemWidthDict, setItemWidthDict] = createSignal<Record<string, number>>({})
|
|
70
|
+
const maxItemWidth = createMemo(() => max(Object.values(itemWidthDict())))
|
|
71
|
+
|
|
72
|
+
return (
|
|
73
|
+
<form
|
|
74
|
+
onSubmit={e => {
|
|
75
|
+
e.preventDefault()
|
|
76
|
+
}}
|
|
77
|
+
>
|
|
78
|
+
<Context.Provider
|
|
79
|
+
value={{
|
|
80
|
+
formInstance,
|
|
81
|
+
rulesDict,
|
|
82
|
+
setErrMsgDict,
|
|
83
|
+
initialValues: props.initialValues as {},
|
|
84
|
+
setItemWidthDict,
|
|
85
|
+
maxItemWidth,
|
|
86
|
+
}}
|
|
87
|
+
>
|
|
88
|
+
{props.children}
|
|
89
|
+
</Context.Provider>
|
|
90
|
+
</form>
|
|
91
|
+
)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export default Form
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type JSXElement,
|
|
3
|
+
type Component,
|
|
4
|
+
type JSX,
|
|
5
|
+
Show,
|
|
6
|
+
useContext,
|
|
7
|
+
createSignal,
|
|
8
|
+
onMount,
|
|
9
|
+
onCleanup,
|
|
10
|
+
} from 'solid-js'
|
|
11
|
+
import { get, isNil } from 'lodash-es'
|
|
12
|
+
import { Dynamic } from 'solid-js/web'
|
|
13
|
+
import { nanoid } from 'nanoid'
|
|
14
|
+
import cs from 'classnames'
|
|
15
|
+
import { type Schema } from 'yup'
|
|
16
|
+
import Context from './context'
|
|
17
|
+
|
|
18
|
+
export interface FormItemComponentProps<T = any> {
|
|
19
|
+
defaultValue?: T
|
|
20
|
+
status?: 'error' | 'warning'
|
|
21
|
+
onChange?: (value: T) => void
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface FormItemProps {
|
|
25
|
+
class?: string
|
|
26
|
+
style?: JSX.CSSProperties
|
|
27
|
+
required?: boolean
|
|
28
|
+
label?: JSXElement
|
|
29
|
+
name?: string
|
|
30
|
+
initialValue?: any
|
|
31
|
+
rules?: Schema[]
|
|
32
|
+
component: Component<FormItemComponentProps>
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const FormItem: Component<FormItemProps> = props => {
|
|
36
|
+
const { formInstance, rulesDict, setErrMsgDict, initialValues, setItemWidthDict, maxItemWidth } =
|
|
37
|
+
useContext(Context)
|
|
38
|
+
const [errMsg, setErrMsg] = createSignal('')
|
|
39
|
+
const id = nanoid()
|
|
40
|
+
|
|
41
|
+
onMount(() => {
|
|
42
|
+
if (isNil(props.name)) return
|
|
43
|
+
|
|
44
|
+
if (!isNil(props.initialValue)) {
|
|
45
|
+
formInstance.setFieldValue(props.name, props.initialValue)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (!isNil(props.rules)) {
|
|
49
|
+
rulesDict[props.name] = props.rules
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
setErrMsgDict[props.name] = setErrMsg
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
let label: HTMLLabelElement
|
|
56
|
+
onMount(() => {
|
|
57
|
+
const resizeObserver = new ResizeObserver(entries => {
|
|
58
|
+
const [entry] = entries
|
|
59
|
+
// Firefox implements `borderBoxSize` as a single content rect, rather than an array
|
|
60
|
+
const borderBoxSize: ResizeObserverSize = Array.isArray(entry.borderBoxSize)
|
|
61
|
+
? entry.borderBoxSize[0]
|
|
62
|
+
: entry.borderBoxSize
|
|
63
|
+
setItemWidthDict(dict => ({
|
|
64
|
+
...dict,
|
|
65
|
+
[id]: borderBoxSize.inlineSize,
|
|
66
|
+
}))
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
resizeObserver.observe(label)
|
|
70
|
+
|
|
71
|
+
onCleanup(() => {
|
|
72
|
+
setItemWidthDict(dict => {
|
|
73
|
+
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
|
74
|
+
delete dict[id]
|
|
75
|
+
return { ...dict }
|
|
76
|
+
})
|
|
77
|
+
resizeObserver.disconnect()
|
|
78
|
+
})
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
const getLabel = (hidden?: boolean) => (
|
|
82
|
+
<label
|
|
83
|
+
class={cs(
|
|
84
|
+
'ant-shrink-0 ant-h-32px ant-leading-32px not[:empty]:ant-pr-8px ant-text-right ant-[white-space:nowrap]',
|
|
85
|
+
hidden && 'ant-absolute ant-opacity-0',
|
|
86
|
+
)}
|
|
87
|
+
{...hidden ? {
|
|
88
|
+
ref: (el) => {
|
|
89
|
+
label = el
|
|
90
|
+
}
|
|
91
|
+
}: {
|
|
92
|
+
style: { width: `${maxItemWidth() ?? 0}px` }
|
|
93
|
+
}}
|
|
94
|
+
>
|
|
95
|
+
<Show when={!isNil(props.required)}>
|
|
96
|
+
<span class="ant-mr-4px ant-text-[var(--ant-color-error)]">*</span>
|
|
97
|
+
</Show>
|
|
98
|
+
<Show when={!isNil(props.label)}>
|
|
99
|
+
<label>{props.label}</label>
|
|
100
|
+
</Show>
|
|
101
|
+
</label>
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
return (
|
|
105
|
+
<div class={cs(props.class, 'ant-flex ant-items-center ant-mb-16px')} style={props.style}>
|
|
106
|
+
{/* 第一个 label 仅用于计算实际宽度 */}
|
|
107
|
+
{getLabel(true)}
|
|
108
|
+
{getLabel()}
|
|
109
|
+
|
|
110
|
+
<div class="ant-w-full">
|
|
111
|
+
<Dynamic
|
|
112
|
+
component={props.component}
|
|
113
|
+
defaultValue={props.initialValue ?? get(initialValues, props.name!)}
|
|
114
|
+
status={errMsg() ? 'error' : undefined}
|
|
115
|
+
onChange={(value: any) => {
|
|
116
|
+
if (!isNil(props.name)) formInstance.setFieldValue(props.name, value)
|
|
117
|
+
|
|
118
|
+
props.rules?.forEach(rule => {
|
|
119
|
+
rule
|
|
120
|
+
.validate(value)
|
|
121
|
+
.then(() => {
|
|
122
|
+
setErrMsg('')
|
|
123
|
+
})
|
|
124
|
+
.catch(err => {
|
|
125
|
+
setErrMsg(err.message)
|
|
126
|
+
})
|
|
127
|
+
})
|
|
128
|
+
}}
|
|
129
|
+
/>
|
|
130
|
+
|
|
131
|
+
<Show when={errMsg()}>
|
|
132
|
+
<div class="ant-text-[var(--ant-color-error)]">{errMsg()}</div>
|
|
133
|
+
</Show>
|
|
134
|
+
</div>
|
|
135
|
+
</div>
|
|
136
|
+
)
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export default FormItem
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type Setter, createContext, type Accessor } from 'solid-js'
|
|
2
|
+
import { type FormInstance } from './Form'
|
|
3
|
+
import { type Schema } from 'yup'
|
|
4
|
+
|
|
5
|
+
const Context = createContext(
|
|
6
|
+
{} as {
|
|
7
|
+
formInstance: FormInstance
|
|
8
|
+
rulesDict: Record<string, Schema[]>
|
|
9
|
+
setErrMsgDict: Record<string, Setter<string>>
|
|
10
|
+
initialValues: {}
|
|
11
|
+
setItemWidthDict: Setter<Record<string, number>>
|
|
12
|
+
maxItemWidth: Accessor<number | undefined>
|
|
13
|
+
},
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
export default Context
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import InternalForm from './Form'
|
|
2
|
+
import FormItem from './FormItem'
|
|
3
|
+
|
|
4
|
+
export type { FormInstance, FormProps } from './Form'
|
|
5
|
+
export type { FormItemProps, FormItemComponentProps } from './FormItem'
|
|
6
|
+
|
|
7
|
+
const Form = InternalForm as typeof InternalForm & {
|
|
8
|
+
Item: typeof FormItem
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
Form.Item = FormItem
|
|
12
|
+
|
|
13
|
+
export default Form
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type Signal, createSignal } from 'solid-js'
|
|
2
2
|
import createUpdateEffect from './createUpdateEffect'
|
|
3
3
|
|
|
4
4
|
export interface Options<T> {
|
|
@@ -42,12 +42,15 @@ function createControllableValue<T = any>(props: Props, options: Options<T> = {}
|
|
|
42
42
|
createUpdateEffect(getValue, () => {
|
|
43
43
|
if (!isControlled()) return
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
_setValue(getValue())
|
|
45
|
+
_setValue(getValue() as any)
|
|
47
46
|
})
|
|
48
47
|
|
|
49
|
-
const setValue
|
|
50
|
-
const newValue =
|
|
48
|
+
const setValue = (v: ((prev: T) => T) | T | undefined) => {
|
|
49
|
+
const newValue = typeof v === 'function'? (v as (prev: T) => T)(value()!) : v
|
|
50
|
+
|
|
51
|
+
if (!isControlled()) {
|
|
52
|
+
_setValue(newValue as any)
|
|
53
|
+
}
|
|
51
54
|
|
|
52
55
|
if (trigger) {
|
|
53
56
|
const onChange = props[trigger]
|
|
@@ -57,7 +60,7 @@ function createControllableValue<T = any>(props: Props, options: Options<T> = {}
|
|
|
57
60
|
}
|
|
58
61
|
|
|
59
62
|
return newValue
|
|
60
|
-
}
|
|
63
|
+
}
|
|
61
64
|
|
|
62
65
|
return [value, setValue] as Signal<T>
|
|
63
66
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import 'uno.css'
|
|
2
|
-
|
|
3
1
|
export { default as Button } from './Button'
|
|
4
2
|
export { default as Input } from './Input'
|
|
5
3
|
export type { InputProps } from './Input'
|
|
@@ -7,6 +5,7 @@ export { default as InputNumber } from './InputNumber'
|
|
|
7
5
|
export type { InputNumberProps } from './InputNumber'
|
|
8
6
|
export { default as Timeline } from './Timeline'
|
|
9
7
|
export { default as Modal } from './Modal'
|
|
8
|
+
export type { ModalInstance } from './Modal'
|
|
10
9
|
export { default as DatePicker } from './DatePicker'
|
|
11
10
|
export { default as Select } from './Select'
|
|
12
11
|
export { default as Tree } from './Tree'
|
|
@@ -24,14 +23,22 @@ export { default as Upload } from './Upload'
|
|
|
24
23
|
export type { UploadProps, UploadFile } from './Upload'
|
|
25
24
|
export { default as Radio } from './Radio'
|
|
26
25
|
export type { RadioProps, RadioGroupProps } from './Radio'
|
|
27
|
-
export { default as Form } from './
|
|
28
|
-
export type { FormProps, FormItemProps, FormItemComponentProps } from './
|
|
26
|
+
export { default as Form } from './form'
|
|
27
|
+
export type { FormInstance, FormProps, FormItemProps, FormItemComponentProps } from './form'
|
|
29
28
|
export { default as Switch } from './Switch'
|
|
30
29
|
export type { SwitchProps } from './Switch'
|
|
31
30
|
export { default as Skeleton } from './Skeleton'
|
|
32
31
|
export { default as Spin } from './Spin'
|
|
33
32
|
export { default as Image } from './Image'
|
|
34
33
|
export { default as Table } from './Table'
|
|
35
|
-
export type { TableProps,
|
|
34
|
+
export type { TableProps, TableColumn } from './Table'
|
|
35
|
+
export { default as Compact } from './Compact'
|
|
36
|
+
export type { CollapseProps, CollapseItem } from './Collapse'
|
|
37
|
+
export { default as Collapse } from './Collapse'
|
|
38
|
+
export { default as Empty } from './Empty'
|
|
39
|
+
export type { SegmentedProps } from './Segmented'
|
|
40
|
+
export { default as Segmented } from './Segmented'
|
|
41
|
+
|
|
42
|
+
export { default as createControllableValue } from './hooks/createControllableValue'
|
|
36
43
|
|
|
37
44
|
export { message } from 'antd'
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
type Subscription<T> = (val: T) => void
|
|
2
|
+
|
|
3
|
+
export default class EventEmitter<T> {
|
|
4
|
+
private readonly subscriptions = new Set<Subscription<T>>()
|
|
5
|
+
|
|
6
|
+
emit = (val: T) => {
|
|
7
|
+
for (const subscription of this.subscriptions) {
|
|
8
|
+
subscription(val)
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
subscription = (callback: Subscription<T>) => {
|
|
13
|
+
this.subscriptions.add(callback)
|
|
14
|
+
}
|
|
15
|
+
}
|
package/src/utils/component.tsx
CHANGED
|
@@ -4,7 +4,7 @@ import { omit } from 'lodash-es'
|
|
|
4
4
|
import { solidToReact } from './solid'
|
|
5
5
|
import ReactToSolid from './ReactToSolid'
|
|
6
6
|
import { ConfigProvider } from 'antd'
|
|
7
|
-
import zhCN from '
|
|
7
|
+
import zhCN from './zh_CN'
|
|
8
8
|
import { type ConfigProviderProps } from 'antd/es/config-provider'
|
|
9
9
|
|
|
10
10
|
/**
|
package/src/utils/solid.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import { type JSXElement
|
|
2
|
+
import { type JSXElement, type JSX } from 'solid-js'
|
|
3
3
|
import { isNil } from 'lodash-es'
|
|
4
4
|
import SolidToReact from './SolidToReact'
|
|
5
|
+
import { type StringOrJSXElement } from '../types'
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* 判断 JSXElement 是否是基础类型
|
|
@@ -44,5 +45,9 @@ export function dispatchEventHandlerUnion<T, E extends Event>(
|
|
|
44
45
|
return
|
|
45
46
|
}
|
|
46
47
|
|
|
47
|
-
handler[0](handler[1], e)
|
|
48
|
-
}
|
|
48
|
+
handler[0](handler[1], e)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function unwrapStringOrJSXElement(value: StringOrJSXElement): JSXElement {
|
|
52
|
+
return typeof value === 'function' ? value() : value
|
|
53
|
+
}
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import { type ConfigProviderProps } from 'antd/es/config-provider'
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
locale: 'zh-cn',
|
|
5
|
+
Pagination: {
|
|
6
|
+
items_per_page: '条/页',
|
|
7
|
+
jump_to: '跳至',
|
|
8
|
+
jump_to_confirm: '确定',
|
|
9
|
+
page: '页',
|
|
10
|
+
prev_page: '上一页',
|
|
11
|
+
next_page: '下一页',
|
|
12
|
+
prev_5: '向前 5 页',
|
|
13
|
+
next_5: '向后 5 页',
|
|
14
|
+
prev_3: '向前 3 页',
|
|
15
|
+
next_3: '向后 3 页',
|
|
16
|
+
page_size: '页码',
|
|
17
|
+
},
|
|
18
|
+
DatePicker: {
|
|
19
|
+
lang: {
|
|
20
|
+
placeholder: '请选择日期',
|
|
21
|
+
yearPlaceholder: '请选择年份',
|
|
22
|
+
quarterPlaceholder: '请选择季度',
|
|
23
|
+
monthPlaceholder: '请选择月份',
|
|
24
|
+
weekPlaceholder: '请选择周',
|
|
25
|
+
rangePlaceholder: ['开始日期', '结束日期'],
|
|
26
|
+
rangeYearPlaceholder: ['开始年份', '结束年份'],
|
|
27
|
+
rangeMonthPlaceholder: ['开始月份', '结束月份'],
|
|
28
|
+
rangeQuarterPlaceholder: ['开始季度', '结束季度'],
|
|
29
|
+
rangeWeekPlaceholder: ['开始周', '结束周'],
|
|
30
|
+
locale: 'zh_CN',
|
|
31
|
+
today: '今天',
|
|
32
|
+
now: '此刻',
|
|
33
|
+
backToToday: '返回今天',
|
|
34
|
+
ok: '确定',
|
|
35
|
+
timeSelect: '选择时间',
|
|
36
|
+
dateSelect: '选择日期',
|
|
37
|
+
weekSelect: '选择周',
|
|
38
|
+
clear: '清除',
|
|
39
|
+
month: '月',
|
|
40
|
+
year: '年',
|
|
41
|
+
previousMonth: '上个月 (翻页上键)',
|
|
42
|
+
nextMonth: '下个月 (翻页下键)',
|
|
43
|
+
monthSelect: '选择月份',
|
|
44
|
+
yearSelect: '选择年份',
|
|
45
|
+
decadeSelect: '选择年代',
|
|
46
|
+
yearFormat: 'YYYY年',
|
|
47
|
+
dayFormat: 'D日',
|
|
48
|
+
dateFormat: 'YYYY年M月D日',
|
|
49
|
+
dateTimeFormat: 'YYYY年M月D日 HH时mm分ss秒',
|
|
50
|
+
previousYear: '上一年 (Control键加左方向键)',
|
|
51
|
+
nextYear: '下一年 (Control键加右方向键)',
|
|
52
|
+
previousDecade: '上一年代',
|
|
53
|
+
nextDecade: '下一年代',
|
|
54
|
+
previousCentury: '上一世纪',
|
|
55
|
+
nextCentury: '下一世纪',
|
|
56
|
+
},
|
|
57
|
+
timePickerLocale: {
|
|
58
|
+
placeholder: '请选择时间',
|
|
59
|
+
rangePlaceholder: ['开始时间', '结束时间'],
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
TimePicker: {
|
|
63
|
+
placeholder: '请选择时间',
|
|
64
|
+
rangePlaceholder: ['开始时间', '结束时间'],
|
|
65
|
+
},
|
|
66
|
+
Calendar: {
|
|
67
|
+
lang: {
|
|
68
|
+
placeholder: '请选择日期',
|
|
69
|
+
yearPlaceholder: '请选择年份',
|
|
70
|
+
quarterPlaceholder: '请选择季度',
|
|
71
|
+
monthPlaceholder: '请选择月份',
|
|
72
|
+
weekPlaceholder: '请选择周',
|
|
73
|
+
rangePlaceholder: ['开始日期', '结束日期'],
|
|
74
|
+
rangeYearPlaceholder: ['开始年份', '结束年份'],
|
|
75
|
+
rangeMonthPlaceholder: ['开始月份', '结束月份'],
|
|
76
|
+
rangeQuarterPlaceholder: ['开始季度', '结束季度'],
|
|
77
|
+
rangeWeekPlaceholder: ['开始周', '结束周'],
|
|
78
|
+
locale: 'zh_CN',
|
|
79
|
+
today: '今天',
|
|
80
|
+
now: '此刻',
|
|
81
|
+
backToToday: '返回今天',
|
|
82
|
+
ok: '确定',
|
|
83
|
+
timeSelect: '选择时间',
|
|
84
|
+
dateSelect: '选择日期',
|
|
85
|
+
weekSelect: '选择周',
|
|
86
|
+
clear: '清除',
|
|
87
|
+
month: '月',
|
|
88
|
+
year: '年',
|
|
89
|
+
previousMonth: '上个月 (翻页上键)',
|
|
90
|
+
nextMonth: '下个月 (翻页下键)',
|
|
91
|
+
monthSelect: '选择月份',
|
|
92
|
+
yearSelect: '选择年份',
|
|
93
|
+
decadeSelect: '选择年代',
|
|
94
|
+
yearFormat: 'YYYY年',
|
|
95
|
+
dayFormat: 'D日',
|
|
96
|
+
dateFormat: 'YYYY年M月D日',
|
|
97
|
+
dateTimeFormat: 'YYYY年M月D日 HH时mm分ss秒',
|
|
98
|
+
previousYear: '上一年 (Control键加左方向键)',
|
|
99
|
+
nextYear: '下一年 (Control键加右方向键)',
|
|
100
|
+
previousDecade: '上一年代',
|
|
101
|
+
nextDecade: '下一年代',
|
|
102
|
+
previousCentury: '上一世纪',
|
|
103
|
+
nextCentury: '下一世纪',
|
|
104
|
+
},
|
|
105
|
+
timePickerLocale: {
|
|
106
|
+
placeholder: '请选择时间',
|
|
107
|
+
rangePlaceholder: ['开始时间', '结束时间'],
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
global: {
|
|
111
|
+
placeholder: '请选择',
|
|
112
|
+
},
|
|
113
|
+
Table: {
|
|
114
|
+
filterTitle: '筛选',
|
|
115
|
+
filterConfirm: '确定',
|
|
116
|
+
filterReset: '重置',
|
|
117
|
+
filterEmptyText: '无筛选项',
|
|
118
|
+
filterCheckall: '全选',
|
|
119
|
+
filterSearchPlaceholder: '在筛选项中搜索',
|
|
120
|
+
selectAll: '全选当页',
|
|
121
|
+
selectInvert: '反选当页',
|
|
122
|
+
selectNone: '清空所有',
|
|
123
|
+
selectionAll: '全选所有',
|
|
124
|
+
sortTitle: '排序',
|
|
125
|
+
expand: '展开行',
|
|
126
|
+
collapse: '关闭行',
|
|
127
|
+
triggerDesc: '点击降序',
|
|
128
|
+
triggerAsc: '点击升序',
|
|
129
|
+
cancelSort: '取消排序',
|
|
130
|
+
},
|
|
131
|
+
Modal: {
|
|
132
|
+
okText: '确定',
|
|
133
|
+
cancelText: '取消',
|
|
134
|
+
justOkText: '知道了',
|
|
135
|
+
},
|
|
136
|
+
Tour: {
|
|
137
|
+
Next: '下一步',
|
|
138
|
+
Previous: '上一步',
|
|
139
|
+
Finish: '结束导览',
|
|
140
|
+
},
|
|
141
|
+
Popconfirm: {
|
|
142
|
+
cancelText: '取消',
|
|
143
|
+
okText: '确定',
|
|
144
|
+
},
|
|
145
|
+
Transfer: {
|
|
146
|
+
titles: ['', ''],
|
|
147
|
+
searchPlaceholder: '请输入搜索内容',
|
|
148
|
+
itemUnit: '项',
|
|
149
|
+
itemsUnit: '项',
|
|
150
|
+
remove: '删除',
|
|
151
|
+
selectCurrent: '全选当页',
|
|
152
|
+
removeCurrent: '删除当页',
|
|
153
|
+
selectAll: '全选所有',
|
|
154
|
+
removeAll: '删除全部',
|
|
155
|
+
selectInvert: '反选当页',
|
|
156
|
+
},
|
|
157
|
+
Upload: {
|
|
158
|
+
uploading: '文件上传中',
|
|
159
|
+
removeFile: '删除文件',
|
|
160
|
+
uploadError: '上传错误',
|
|
161
|
+
previewFile: '预览文件',
|
|
162
|
+
downloadFile: '下载文件',
|
|
163
|
+
},
|
|
164
|
+
Empty: {
|
|
165
|
+
description: '暂无数据',
|
|
166
|
+
},
|
|
167
|
+
Icon: {
|
|
168
|
+
icon: '图标',
|
|
169
|
+
},
|
|
170
|
+
Text: {
|
|
171
|
+
edit: '编辑',
|
|
172
|
+
copy: '复制',
|
|
173
|
+
copied: '复制成功',
|
|
174
|
+
expand: '展开',
|
|
175
|
+
},
|
|
176
|
+
PageHeader: {
|
|
177
|
+
back: '返回',
|
|
178
|
+
},
|
|
179
|
+
Form: {
|
|
180
|
+
optional: '(可选)',
|
|
181
|
+
defaultValidateMessages: {
|
|
182
|
+
default: '字段验证错误${label}',
|
|
183
|
+
required: '请输入${label}',
|
|
184
|
+
enum: '${label}必须是其中一个[${enum}]',
|
|
185
|
+
whitespace: '${label}不能为空字符',
|
|
186
|
+
date: {
|
|
187
|
+
format: '${label}日期格式无效',
|
|
188
|
+
parse: '${label}不能转换为日期',
|
|
189
|
+
invalid: '${label}是一个无效日期',
|
|
190
|
+
},
|
|
191
|
+
types: {
|
|
192
|
+
string: '${label}不是一个有效的${type}',
|
|
193
|
+
method: '${label}不是一个有效的${type}',
|
|
194
|
+
array: '${label}不是一个有效的${type}',
|
|
195
|
+
object: '${label}不是一个有效的${type}',
|
|
196
|
+
number: '${label}不是一个有效的${type}',
|
|
197
|
+
date: '${label}不是一个有效的${type}',
|
|
198
|
+
boolean: '${label}不是一个有效的${type}',
|
|
199
|
+
integer: '${label}不是一个有效的${type}',
|
|
200
|
+
float: '${label}不是一个有效的${type}',
|
|
201
|
+
regexp: '${label}不是一个有效的${type}',
|
|
202
|
+
email: '${label}不是一个有效的${type}',
|
|
203
|
+
url: '${label}不是一个有效的${type}',
|
|
204
|
+
hex: '${label}不是一个有效的${type}',
|
|
205
|
+
},
|
|
206
|
+
string: {
|
|
207
|
+
len: '${label}须为${len}个字符',
|
|
208
|
+
min: '${label}最少${min}个字符',
|
|
209
|
+
max: '${label}最多${max}个字符',
|
|
210
|
+
range: '${label}须在${min}-${max}字符之间',
|
|
211
|
+
},
|
|
212
|
+
number: {
|
|
213
|
+
len: '${label}必须等于${len}',
|
|
214
|
+
min: '${label}最小值为${min}',
|
|
215
|
+
max: '${label}最大值为${max}',
|
|
216
|
+
range: '${label}须在${min}-${max}之间',
|
|
217
|
+
},
|
|
218
|
+
array: {
|
|
219
|
+
len: '须为${len}个${label}',
|
|
220
|
+
min: '最少${min}个${label}',
|
|
221
|
+
max: '最多${max}个${label}',
|
|
222
|
+
range: '${label}数量须在${min}-${max}之间',
|
|
223
|
+
},
|
|
224
|
+
pattern: {
|
|
225
|
+
mismatch: '${label}与模式不匹配${pattern}',
|
|
226
|
+
},
|
|
227
|
+
},
|
|
228
|
+
},
|
|
229
|
+
Image: {
|
|
230
|
+
preview: '预览',
|
|
231
|
+
},
|
|
232
|
+
QRCode: {
|
|
233
|
+
expired: '二维码过期',
|
|
234
|
+
refresh: '点击刷新',
|
|
235
|
+
},
|
|
236
|
+
} as ConfigProviderProps['locale']
|
package/tsconfig.json
CHANGED
|
@@ -11,13 +11,15 @@
|
|
|
11
11
|
"jsx": "preserve",
|
|
12
12
|
"emitDecoratorMetadata": true,
|
|
13
13
|
"experimentalDecorators": true,
|
|
14
|
-
"baseUrl": ".",
|
|
15
14
|
"paths": {
|
|
16
|
-
"antd-solid": ["src/index"],
|
|
15
|
+
"antd-solid": ["./src/index"],
|
|
17
16
|
},
|
|
17
|
+
"skipLibCheck": true,
|
|
18
18
|
},
|
|
19
19
|
"include": [
|
|
20
|
-
"./src
|
|
21
|
-
"./docs
|
|
20
|
+
"./src",
|
|
21
|
+
"./docs",
|
|
22
|
+
"./global.d.ts",
|
|
23
|
+
"./unocss.config.ts"
|
|
22
24
|
],
|
|
23
25
|
}
|