antd-solid 0.0.9 → 0.0.11
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/css/index.css +15 -2
- package/dist/index.esm.js +408 -102
- package/dist/index.umd.js +1 -1
- package/es/Button.js +2 -2
- package/es/Drawer/index.d.ts +44 -0
- package/es/Drawer/index.js +163 -0
- package/es/Drawer/index.scss.js +6 -0
- package/es/Modal.d.ts +5 -4
- package/es/Modal.js +28 -14
- package/es/Progress/index.d.ts +25 -0
- package/es/Progress/index.js +71 -0
- package/es/Radio.js +25 -21
- package/es/hooks/createControllableValue.d.ts +1 -1
- package/es/hooks/createTransition.d.ts +8 -0
- package/es/hooks/createTransition.js +39 -0
- package/es/index.d.ts +5 -2
- package/es/index.js +3 -2
- package/es/node_modules/.pnpm/style-inject@0.3.0/node_modules/style-inject/dist/style-inject.es.js +26 -0
- package/es/utils/solid.d.ts +4 -1
- package/es/utils/solid.js +9 -1
- package/package.json +4 -2
- package/src/Button.tsx +8 -5
- package/src/Drawer/index.scss +53 -0
- package/src/Drawer/index.tsx +212 -0
- package/src/{form → Form}/FormItem.tsx +9 -7
- package/src/Modal.tsx +46 -22
- package/src/Progress/index.tsx +73 -0
- package/src/Radio.tsx +24 -14
- package/src/hooks/createControllableValue.ts +3 -3
- package/src/hooks/createTransition.ts +52 -0
- package/src/index.ts +5 -2
- package/src/utils/solid.ts +9 -1
- package/es/Progress.d.ts +0 -7
- package/es/Progress.js +0 -6
- package/src/Progress.tsx +0 -4
- /package/es/{form → Form}/Form.d.ts +0 -0
- /package/es/{form → Form}/Form.js +0 -0
- /package/es/{form → Form}/FormItem.d.ts +0 -0
- /package/es/{form → Form}/FormItem.js +0 -0
- /package/es/{form → Form}/context.d.ts +0 -0
- /package/es/{form → Form}/context.js +0 -0
- /package/es/{form → Form}/index.d.ts +0 -0
- /package/es/{form → Form}/index.js +0 -0
- /package/src/{form → Form}/Form.tsx +0 -0
- /package/src/{form → Form}/context.ts +0 -0
- /package/src/{form → Form}/index.ts +0 -0
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import {
|
|
2
|
+
mergeProps,
|
|
3
|
+
type Component,
|
|
4
|
+
Show,
|
|
5
|
+
type JSXElement,
|
|
6
|
+
type Ref,
|
|
7
|
+
createSignal,
|
|
8
|
+
untrack,
|
|
9
|
+
createMemo,
|
|
10
|
+
} from 'solid-js'
|
|
11
|
+
import cs from 'classnames'
|
|
12
|
+
import Button from '../Button'
|
|
13
|
+
import { setRef } from '../utils/solid'
|
|
14
|
+
import { Portal } from 'solid-js/web'
|
|
15
|
+
import { Transition } from 'solid-transition-group'
|
|
16
|
+
import './index.scss'
|
|
17
|
+
import createTransition from '../hooks/createTransition'
|
|
18
|
+
|
|
19
|
+
export interface DrawerInstance {
|
|
20
|
+
open: () => void
|
|
21
|
+
close: () => void
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface DrawerProps {
|
|
25
|
+
ref?: Ref<DrawerInstance>
|
|
26
|
+
title?: JSXElement
|
|
27
|
+
extra?: JSXElement
|
|
28
|
+
children?: JSXElement
|
|
29
|
+
/**
|
|
30
|
+
* 宽度
|
|
31
|
+
* 默认 378px
|
|
32
|
+
*/
|
|
33
|
+
width?: string
|
|
34
|
+
/**
|
|
35
|
+
* 高度,在 placement 为 top 或 bottom 时使用
|
|
36
|
+
* 默认 378px
|
|
37
|
+
*/
|
|
38
|
+
height?: string
|
|
39
|
+
closeIcon?: boolean
|
|
40
|
+
/**
|
|
41
|
+
* 点击蒙层是否允许关闭
|
|
42
|
+
* 默认 true
|
|
43
|
+
*/
|
|
44
|
+
maskClosable?: boolean
|
|
45
|
+
/**
|
|
46
|
+
* 关闭时销毁 Modal 里的子元素
|
|
47
|
+
*/
|
|
48
|
+
destroyOnClose?: boolean
|
|
49
|
+
/**
|
|
50
|
+
* 抽屉的方向
|
|
51
|
+
* 默认 right
|
|
52
|
+
*/
|
|
53
|
+
placement?: 'top' | 'right' | 'bottom' | 'left'
|
|
54
|
+
/**
|
|
55
|
+
* 指定 Drawer 挂载的节点,并在容器内展现,false 为挂载在当前位置
|
|
56
|
+
* 默认 body
|
|
57
|
+
*/
|
|
58
|
+
getContainer?: HTMLElement | (() => HTMLElement) | false
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const Drawer: Component<DrawerProps> = _props => {
|
|
62
|
+
const props = mergeProps(
|
|
63
|
+
{
|
|
64
|
+
width: '378px',
|
|
65
|
+
height: '378px',
|
|
66
|
+
maskClosable: true,
|
|
67
|
+
placement: 'right',
|
|
68
|
+
getContainer: document.body,
|
|
69
|
+
},
|
|
70
|
+
_props,
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* 控制是否打开/销毁
|
|
75
|
+
*/
|
|
76
|
+
const [open, setOpen] = createSignal(false)
|
|
77
|
+
/**
|
|
78
|
+
* 控制显隐
|
|
79
|
+
*/
|
|
80
|
+
const [hide, setHide] = createSignal(false)
|
|
81
|
+
let cleanup: (() => void) | undefined
|
|
82
|
+
|
|
83
|
+
const container = createMemo(() => {
|
|
84
|
+
if (typeof props.getContainer === 'function') {
|
|
85
|
+
return props.getContainer()
|
|
86
|
+
}
|
|
87
|
+
if (props.getContainer instanceof HTMLElement) {
|
|
88
|
+
return props.getContainer
|
|
89
|
+
}
|
|
90
|
+
return undefined
|
|
91
|
+
})
|
|
92
|
+
const isBody = createMemo(() => container() === document.body)
|
|
93
|
+
|
|
94
|
+
const instance: DrawerInstance = {
|
|
95
|
+
open() {
|
|
96
|
+
setOpen(true)
|
|
97
|
+
setHide(false)
|
|
98
|
+
|
|
99
|
+
untrack(() => {
|
|
100
|
+
if (!isBody()) return
|
|
101
|
+
|
|
102
|
+
const originOverflow = document.body.style.overflow
|
|
103
|
+
document.body.style.overflow = 'hidden'
|
|
104
|
+
|
|
105
|
+
const onKeyup = (e: KeyboardEvent) => {
|
|
106
|
+
if (e.key === 'Escape') {
|
|
107
|
+
instance.close()
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
document.addEventListener('keyup', onKeyup)
|
|
111
|
+
|
|
112
|
+
cleanup = () => {
|
|
113
|
+
document.body.style.overflow = originOverflow
|
|
114
|
+
document.removeEventListener('keyup', onKeyup)
|
|
115
|
+
}
|
|
116
|
+
})
|
|
117
|
+
},
|
|
118
|
+
close() {
|
|
119
|
+
untrack(() => {
|
|
120
|
+
if (props.destroyOnClose) {
|
|
121
|
+
setOpen(false)
|
|
122
|
+
} else {
|
|
123
|
+
setHide(true)
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
cleanup?.()
|
|
127
|
+
})
|
|
128
|
+
},
|
|
129
|
+
}
|
|
130
|
+
setRef(props, instance)
|
|
131
|
+
|
|
132
|
+
let drawer: HTMLDivElement | undefined
|
|
133
|
+
createTransition(
|
|
134
|
+
() => drawer,
|
|
135
|
+
() => !hide(),
|
|
136
|
+
'ant-drawer-fade',
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
const direction = createMemo(() =>
|
|
140
|
+
['top', 'bottom'].includes(props.placement) ? 'vertical' : 'horizontal',
|
|
141
|
+
)
|
|
142
|
+
|
|
143
|
+
const children = (
|
|
144
|
+
<Transition name="ant-drawer-fade">
|
|
145
|
+
<Show when={open()}>
|
|
146
|
+
<div
|
|
147
|
+
ref={drawer}
|
|
148
|
+
class={cs(
|
|
149
|
+
'ant-inset-0 ant-bg-[rgba(0,0,0,.45)] ant-z-1000',
|
|
150
|
+
isBody() ? 'ant-fixed' : 'ant-absolute',
|
|
151
|
+
)}
|
|
152
|
+
onClick={() => {
|
|
153
|
+
if (props.maskClosable) {
|
|
154
|
+
instance.close()
|
|
155
|
+
}
|
|
156
|
+
}}
|
|
157
|
+
>
|
|
158
|
+
<div
|
|
159
|
+
class={cs(
|
|
160
|
+
'ant-drawer-content',
|
|
161
|
+
{
|
|
162
|
+
left: 'ant-drawer-content-left',
|
|
163
|
+
right: 'ant-drawer-content-right',
|
|
164
|
+
top: 'ant-drawer-content-top',
|
|
165
|
+
bottom: 'ant-drawer-content-bottom',
|
|
166
|
+
}[props.placement],
|
|
167
|
+
'ant-absolute ant-bg-white ant-grid ant-[grid-template-rows:auto_1fr]',
|
|
168
|
+
)}
|
|
169
|
+
style={{
|
|
170
|
+
width: direction() === 'horizontal' ? props.width : undefined,
|
|
171
|
+
height: direction() === 'vertical' ? props.height : undefined,
|
|
172
|
+
}}
|
|
173
|
+
onClick={e => {
|
|
174
|
+
e.stopPropagation()
|
|
175
|
+
}}
|
|
176
|
+
>
|
|
177
|
+
<div class="ant-px-[var(--ant-padding-lg)] ant-py-[var(--ant-padding)] ant-flex ant-justify-between ant-items-center ant-[border-bottom:var(--ant-line-width)_solid_var(--ant-color-split)]">
|
|
178
|
+
<div class="ant-flex ant-items-center">
|
|
179
|
+
<Show when={props.closeIcon !== false}>
|
|
180
|
+
<Button
|
|
181
|
+
type="text"
|
|
182
|
+
size="plain"
|
|
183
|
+
class="ant-mr-[var(--ant-margin-sm)] ant-text-size-[var(--ant-font-size-lg)] ant-h-[var(--ant-font-size-lg)] ant-leading-[var(--ant-font-size-lg)] hover:!ant-bg-transparent !ant-text-[var(--ant-color-icon)] hover:!ant-text-[var(--ant-color-icon-hover)]"
|
|
184
|
+
onClick={() => {
|
|
185
|
+
instance?.close()
|
|
186
|
+
}}
|
|
187
|
+
>
|
|
188
|
+
<span class="i-ant-design:close-outlined" />
|
|
189
|
+
</Button>
|
|
190
|
+
</Show>
|
|
191
|
+
<span class="ant-text-[var(--ant-color-text)] ant-text-size-[var(--ant-font-size-lg)] ant-[font-weight:var(--ant-font-weight-strong)] ant-leading-[var(--ant-line-height-lg)]">
|
|
192
|
+
{props.title}
|
|
193
|
+
</span>
|
|
194
|
+
</div>
|
|
195
|
+
|
|
196
|
+
<div>{props.extra}</div>
|
|
197
|
+
</div>
|
|
198
|
+
<div class="ant-p-[var(--ant-padding-lg)] ant-overflow-auto">{props.children}</div>
|
|
199
|
+
</div>
|
|
200
|
+
</div>
|
|
201
|
+
</Show>
|
|
202
|
+
</Transition>
|
|
203
|
+
)
|
|
204
|
+
|
|
205
|
+
return (
|
|
206
|
+
<Show when={props.getContainer !== false} fallback={children}>
|
|
207
|
+
<Portal mount={container()}>{children}</Portal>
|
|
208
|
+
</Show>
|
|
209
|
+
)
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export default Drawer
|
|
@@ -67,7 +67,7 @@ const FormItem: Component<FormItemProps> = props => {
|
|
|
67
67
|
})
|
|
68
68
|
|
|
69
69
|
resizeObserver.observe(label)
|
|
70
|
-
|
|
70
|
+
|
|
71
71
|
onCleanup(() => {
|
|
72
72
|
setItemWidthDict(dict => {
|
|
73
73
|
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
|
@@ -84,13 +84,15 @@ const FormItem: Component<FormItemProps> = props => {
|
|
|
84
84
|
'ant-shrink-0 ant-h-32px ant-leading-32px not[:empty]:ant-pr-8px ant-text-right ant-[white-space:nowrap]',
|
|
85
85
|
hidden && 'ant-absolute ant-opacity-0',
|
|
86
86
|
)}
|
|
87
|
-
{...hidden
|
|
88
|
-
|
|
89
|
-
|
|
87
|
+
{...(hidden
|
|
88
|
+
? {
|
|
89
|
+
ref: el => {
|
|
90
|
+
label = el
|
|
91
|
+
},
|
|
90
92
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
93
|
+
: {
|
|
94
|
+
style: { width: `${maxItemWidth() ?? 0}px` },
|
|
95
|
+
})}
|
|
94
96
|
>
|
|
95
97
|
<Show when={!isNil(props.required)}>
|
|
96
98
|
<span class="ant-mr-4px ant-text-[var(--ant-color-error)]">*</span>
|
package/src/Modal.tsx
CHANGED
|
@@ -6,6 +6,11 @@ import cs from 'classnames'
|
|
|
6
6
|
export interface ModalInstance {
|
|
7
7
|
open: () => void
|
|
8
8
|
close: () => void
|
|
9
|
+
/**
|
|
10
|
+
* 与 close 相似,但关闭时会销毁 Modal 里的子元素
|
|
11
|
+
* @returns
|
|
12
|
+
*/
|
|
13
|
+
destroy: () => void
|
|
9
14
|
}
|
|
10
15
|
|
|
11
16
|
export interface ModalProps {
|
|
@@ -29,10 +34,6 @@ export interface ModalProps {
|
|
|
29
34
|
*/
|
|
30
35
|
closeIcon?: boolean
|
|
31
36
|
footer?: boolean | ((modal: ModalInstance) => JSXElement)
|
|
32
|
-
/**
|
|
33
|
-
* 关闭时销毁 Modal 里的子元素
|
|
34
|
-
*/
|
|
35
|
-
destroyOnClose?: boolean
|
|
36
37
|
/**
|
|
37
38
|
* 返回 true,会自动关闭 modal
|
|
38
39
|
*/
|
|
@@ -51,20 +52,37 @@ function Modal(_props: ModalProps) {
|
|
|
51
52
|
const props = mergeProps({ footer: true }, _props)
|
|
52
53
|
const [open, setOpen] = createSignal(props.defaultOpen ?? false)
|
|
53
54
|
const [hide, setHide] = createSignal(false)
|
|
55
|
+
let cleanup: () => void
|
|
54
56
|
|
|
55
57
|
const instance: ModalInstance = {
|
|
56
58
|
open() {
|
|
57
59
|
setOpen(true)
|
|
58
60
|
setHide(false)
|
|
61
|
+
|
|
62
|
+
const originOverflow = document.body.style.overflow
|
|
63
|
+
document.body.style.overflow = 'hidden'
|
|
64
|
+
|
|
65
|
+
const onKeyup = (e: KeyboardEvent) => {
|
|
66
|
+
if (e.key === 'Escape') {
|
|
67
|
+
instance.close()
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
document.addEventListener('keyup', onKeyup)
|
|
71
|
+
|
|
72
|
+
cleanup = () => {
|
|
73
|
+
document.body.style.overflow = originOverflow
|
|
74
|
+
document.removeEventListener('keyup', onKeyup)
|
|
75
|
+
}
|
|
59
76
|
},
|
|
60
77
|
close() {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
78
|
+
setHide(true)
|
|
79
|
+
cleanup()
|
|
80
|
+
props.afterClose?.()
|
|
81
|
+
},
|
|
82
|
+
destroy() {
|
|
83
|
+
setOpen(false)
|
|
84
|
+
cleanup()
|
|
85
|
+
props.afterClose?.()
|
|
68
86
|
},
|
|
69
87
|
}
|
|
70
88
|
untrack(() => {
|
|
@@ -73,11 +91,6 @@ function Modal(_props: ModalProps) {
|
|
|
73
91
|
}
|
|
74
92
|
})
|
|
75
93
|
|
|
76
|
-
const close = () => {
|
|
77
|
-
instance.close()
|
|
78
|
-
props.afterClose?.()
|
|
79
|
-
}
|
|
80
|
-
|
|
81
94
|
const [confirmLoading, setConfirmLoading] = createSignal(false)
|
|
82
95
|
|
|
83
96
|
return (
|
|
@@ -90,7 +103,7 @@ function Modal(_props: ModalProps) {
|
|
|
90
103
|
)}
|
|
91
104
|
onClick={() => {
|
|
92
105
|
if (props.maskClosable ?? true) {
|
|
93
|
-
close()
|
|
106
|
+
instance.close()
|
|
94
107
|
}
|
|
95
108
|
}}
|
|
96
109
|
style={{ display: hide() ? 'none' : undefined }}
|
|
@@ -117,7 +130,9 @@ function Modal(_props: ModalProps) {
|
|
|
117
130
|
class={cs(
|
|
118
131
|
'ant-rm-size-btn !ant-w-22px !ant-h-22px !ant-flex !ant-justify-center !ant-items-center ant-text-center ant-text-18px !ant-absolute !ant-top-16px !ant-right-16px ant-z-1000 ant-text-[rgba(0,0,0,.45)] hover:!ant-text-[rgba(0,0,0,.88)]',
|
|
119
132
|
)}
|
|
120
|
-
onClick={
|
|
133
|
+
onClick={() => {
|
|
134
|
+
instance.close()
|
|
135
|
+
}}
|
|
121
136
|
>
|
|
122
137
|
<span class="i-ant-design:close-outlined" />
|
|
123
138
|
</Button>
|
|
@@ -130,9 +145,18 @@ function Modal(_props: ModalProps) {
|
|
|
130
145
|
|
|
131
146
|
<Show when={props.footer !== false}>
|
|
132
147
|
<div class="ant-mt-12px">
|
|
133
|
-
<Show
|
|
134
|
-
|
|
135
|
-
|
|
148
|
+
<Show
|
|
149
|
+
when={typeof props.footer !== 'function'}
|
|
150
|
+
fallback={typeof props.footer === 'function' && props.footer(instance)}
|
|
151
|
+
>
|
|
152
|
+
<div class="ant-flex ant-gap-8px ant-justify-end">
|
|
153
|
+
<Button
|
|
154
|
+
onClick={() => {
|
|
155
|
+
instance.close()
|
|
156
|
+
}}
|
|
157
|
+
>
|
|
158
|
+
取消
|
|
159
|
+
</Button>
|
|
136
160
|
<Button
|
|
137
161
|
type="primary"
|
|
138
162
|
loading={confirmLoading()}
|
|
@@ -150,7 +174,7 @@ function Modal(_props: ModalProps) {
|
|
|
150
174
|
}
|
|
151
175
|
}}
|
|
152
176
|
>
|
|
153
|
-
|
|
177
|
+
确定
|
|
154
178
|
</Button>
|
|
155
179
|
</div>
|
|
156
180
|
</Show>
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { mergeProps, type Component, Switch, Match, Show } from 'solid-js'
|
|
2
|
+
import cs from 'classnames'
|
|
3
|
+
|
|
4
|
+
export interface ProgressProps {
|
|
5
|
+
/**
|
|
6
|
+
* 百分比
|
|
7
|
+
* 默认 0
|
|
8
|
+
*/
|
|
9
|
+
percent?: number
|
|
10
|
+
/**
|
|
11
|
+
* 状态
|
|
12
|
+
* 默认 'default'
|
|
13
|
+
*/
|
|
14
|
+
status?: 'default' | 'success' | 'error'
|
|
15
|
+
/**
|
|
16
|
+
* 'line' 类型进度条的高度
|
|
17
|
+
* 默认 8
|
|
18
|
+
*/
|
|
19
|
+
height?: number
|
|
20
|
+
/**
|
|
21
|
+
* 是否显示进度数值或状态图标
|
|
22
|
+
* 默认 true
|
|
23
|
+
*/
|
|
24
|
+
showInfo?: boolean
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const Progress: Component<ProgressProps> = _props => {
|
|
28
|
+
const props = mergeProps(
|
|
29
|
+
{
|
|
30
|
+
percent: 0,
|
|
31
|
+
status: 'default',
|
|
32
|
+
height: 8,
|
|
33
|
+
showInfo: true,
|
|
34
|
+
} as Required<ProgressProps>,
|
|
35
|
+
_props,
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<div
|
|
40
|
+
class="ant-flex ant-items-center"
|
|
41
|
+
style={{
|
|
42
|
+
'--ant-progress-remaining-color': 'rgba(0, 0, 0, 0.06)',
|
|
43
|
+
}}
|
|
44
|
+
>
|
|
45
|
+
<div
|
|
46
|
+
class={cs(
|
|
47
|
+
'ant-w-full ant-bg-[var(--ant-progress-remaining-color)]',
|
|
48
|
+
'before:ant-content-empty before:ant-block before:ant-bg-[var(--primary-color)] before:ant-w-[var(--percent)] before:ant-h-full before:ant-rounded-inherit',
|
|
49
|
+
)}
|
|
50
|
+
style={{
|
|
51
|
+
height: `${props.height}px`,
|
|
52
|
+
'border-radius': `${props.height / 2}px`,
|
|
53
|
+
'--percent': `${props.percent}%`,
|
|
54
|
+
}}
|
|
55
|
+
/>
|
|
56
|
+
|
|
57
|
+
<Show when={props.showInfo}>
|
|
58
|
+
<span class="ant-shrink-0 ant-min-w-40px ant-ml-8px ant-text-center">
|
|
59
|
+
<Switch fallback={`${props.percent}%`}>
|
|
60
|
+
<Match when={props.status === 'success' || props.percent >= 100}>
|
|
61
|
+
<span class="i-ant-design:check-circle-filled ant-text-[var(--primary-color)]" />
|
|
62
|
+
</Match>
|
|
63
|
+
<Match when={props.status === 'error'}>
|
|
64
|
+
<span class="i-ant-design:close-circle-filled ant-text-[var(--ant-color-error)]" />
|
|
65
|
+
</Match>
|
|
66
|
+
</Switch>
|
|
67
|
+
</span>
|
|
68
|
+
</Show>
|
|
69
|
+
</div>
|
|
70
|
+
)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export default Progress
|
package/src/Radio.tsx
CHANGED
|
@@ -39,20 +39,28 @@ const Radio: Component<RadioProps> & {
|
|
|
39
39
|
defaultValue: false,
|
|
40
40
|
defaultValuePropName: 'defaultChecked',
|
|
41
41
|
valuePropName: 'checked',
|
|
42
|
-
trigger:
|
|
42
|
+
trigger: null,
|
|
43
43
|
})
|
|
44
44
|
|
|
45
45
|
return (
|
|
46
|
-
<label class="ant-inline-flex ant-gap-4px">
|
|
47
|
-
<
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
46
|
+
<label class="ant-inline-flex ant-gap-4px ant-cursor-pointer ant-inline-flex ant-items-center">
|
|
47
|
+
<span
|
|
48
|
+
class={cs(
|
|
49
|
+
'ant-w-16px ant-h-16px ant-rounded-50% ant-[border:1px_solid_var(--ant-color-border)]',
|
|
50
|
+
checked() && 'ant-[border:5px_solid_var(--primary-color)]',
|
|
51
|
+
)}
|
|
52
|
+
>
|
|
53
|
+
<input
|
|
54
|
+
class="ant-m-0 ant-hidden"
|
|
55
|
+
checked={checked()}
|
|
56
|
+
value={props.value ?? ''}
|
|
57
|
+
type="radio"
|
|
58
|
+
onInput={e => {
|
|
59
|
+
setChecked(e.target.checked)
|
|
60
|
+
untrack(() => props.onChange?.(e))
|
|
61
|
+
}}
|
|
62
|
+
/>
|
|
63
|
+
</span>
|
|
56
64
|
{props.children}
|
|
57
65
|
</label>
|
|
58
66
|
)
|
|
@@ -63,7 +71,7 @@ Radio.Button = props => {
|
|
|
63
71
|
defaultValue: false,
|
|
64
72
|
defaultValuePropName: 'defaultChecked',
|
|
65
73
|
valuePropName: 'checked',
|
|
66
|
-
trigger:
|
|
74
|
+
trigger: null,
|
|
67
75
|
})
|
|
68
76
|
|
|
69
77
|
return (
|
|
@@ -97,7 +105,7 @@ Radio.Group = _props => {
|
|
|
97
105
|
_props,
|
|
98
106
|
)
|
|
99
107
|
const [value, setValue] = createControllableValue<string>(props, {
|
|
100
|
-
trigger:
|
|
108
|
+
trigger: null,
|
|
101
109
|
})
|
|
102
110
|
const isChecked = createSelector(value)
|
|
103
111
|
|
|
@@ -117,7 +125,9 @@ Radio.Group = _props => {
|
|
|
117
125
|
onChange={
|
|
118
126
|
(e => {
|
|
119
127
|
setValue(option.value)
|
|
120
|
-
untrack(() =>
|
|
128
|
+
untrack(() => {
|
|
129
|
+
props.onChange?.(e)
|
|
130
|
+
})
|
|
121
131
|
}) as JSX.ChangeEventHandler<HTMLInputElement, Event>
|
|
122
132
|
}
|
|
123
133
|
>
|
|
@@ -5,7 +5,7 @@ export interface Options<T> {
|
|
|
5
5
|
defaultValue?: T
|
|
6
6
|
defaultValuePropName?: string
|
|
7
7
|
valuePropName?: string
|
|
8
|
-
trigger?: string |
|
|
8
|
+
trigger?: string | null
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
export type Props = Record<string, any>
|
|
@@ -46,8 +46,8 @@ function createControllableValue<T = any>(props: Props, options: Options<T> = {}
|
|
|
46
46
|
})
|
|
47
47
|
|
|
48
48
|
const setValue = (v: ((prev: T) => T) | T | undefined) => {
|
|
49
|
-
const newValue = typeof v === 'function'? (v as (prev: T) => T)(value()!) : v
|
|
50
|
-
|
|
49
|
+
const newValue = typeof v === 'function' ? (v as (prev: T) => T)(value()!) : v
|
|
50
|
+
|
|
51
51
|
if (!isControlled()) {
|
|
52
52
|
_setValue(newValue as any)
|
|
53
53
|
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { createEffect, type Accessor, on } from 'solid-js'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* dom 节点显示或隐藏时的动画
|
|
5
|
+
* @param target
|
|
6
|
+
* @param when
|
|
7
|
+
* @param className 动画类名
|
|
8
|
+
*/
|
|
9
|
+
export default function createTransition(
|
|
10
|
+
target: Accessor<HTMLElement | undefined | null>,
|
|
11
|
+
when: Accessor<boolean>,
|
|
12
|
+
className: string,
|
|
13
|
+
) {
|
|
14
|
+
createEffect(
|
|
15
|
+
on(when, input => {
|
|
16
|
+
const targetValue = target()
|
|
17
|
+
if (!targetValue) return
|
|
18
|
+
|
|
19
|
+
if (input) {
|
|
20
|
+
targetValue.style.display = ''
|
|
21
|
+
targetValue.classList.add(
|
|
22
|
+
`${className}-enter-active`,
|
|
23
|
+
`${className}-enter`,
|
|
24
|
+
`${className}-enter-to`,
|
|
25
|
+
)
|
|
26
|
+
requestAnimationFrame(() => {
|
|
27
|
+
targetValue!.classList.remove(`${className}-enter`)
|
|
28
|
+
})
|
|
29
|
+
const onTransitionEnd = () => {
|
|
30
|
+
targetValue!.classList.remove(`${className}-enter-active`, `${className}-enter-to`)
|
|
31
|
+
targetValue!.removeEventListener('transitionend', onTransitionEnd)
|
|
32
|
+
}
|
|
33
|
+
targetValue.addEventListener('transitionend', onTransitionEnd)
|
|
34
|
+
} else {
|
|
35
|
+
targetValue.classList.add(
|
|
36
|
+
`${className}-exit-active`,
|
|
37
|
+
`${className}-exit`,
|
|
38
|
+
`${className}-exit-to`,
|
|
39
|
+
)
|
|
40
|
+
requestAnimationFrame(() => {
|
|
41
|
+
targetValue!.classList.remove(`${className}-exit`)
|
|
42
|
+
})
|
|
43
|
+
const onTransitionEnd = () => {
|
|
44
|
+
targetValue!.style.display = 'none'
|
|
45
|
+
targetValue!.classList.remove(`${className}-exit-active`, `${className}-exit-to`)
|
|
46
|
+
targetValue!.removeEventListener('transitionend', onTransitionEnd)
|
|
47
|
+
}
|
|
48
|
+
targetValue.addEventListener('transitionend', onTransitionEnd)
|
|
49
|
+
}
|
|
50
|
+
}),
|
|
51
|
+
)
|
|
52
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -6,6 +6,8 @@ export type { InputNumberProps } from './InputNumber'
|
|
|
6
6
|
export { default as Timeline } from './Timeline'
|
|
7
7
|
export { default as Modal } from './Modal'
|
|
8
8
|
export type { ModalInstance } from './Modal'
|
|
9
|
+
export { default as Drawer } from './Drawer'
|
|
10
|
+
export type { DrawerProps, DrawerInstance } from './Drawer'
|
|
9
11
|
export { default as DatePicker } from './DatePicker'
|
|
10
12
|
export { default as Select } from './Select'
|
|
11
13
|
export { default as Tree } from './Tree'
|
|
@@ -16,6 +18,7 @@ export { default as ColorPicker } from './ColorPicker'
|
|
|
16
18
|
export type { ColorPickerProps } from './ColorPicker'
|
|
17
19
|
export { default as Result } from './Result'
|
|
18
20
|
export { default as Progress } from './Progress'
|
|
21
|
+
export type { ProgressProps } from './Progress'
|
|
19
22
|
export { default as Tabs } from './Tabs'
|
|
20
23
|
export type { TabsProps, Tab } from './Tabs'
|
|
21
24
|
export { default as Popconfirm } from './Popconfirm'
|
|
@@ -23,8 +26,8 @@ export { default as Upload } from './Upload'
|
|
|
23
26
|
export type { UploadProps, UploadFile } from './Upload'
|
|
24
27
|
export { default as Radio } from './Radio'
|
|
25
28
|
export type { RadioProps, RadioGroupProps } from './Radio'
|
|
26
|
-
export { default as Form } from './
|
|
27
|
-
export type { FormInstance, FormProps, FormItemProps, FormItemComponentProps } from './
|
|
29
|
+
export { default as Form } from './Form'
|
|
30
|
+
export type { FormInstance, FormProps, FormItemProps, FormItemComponentProps } from './Form'
|
|
28
31
|
export { default as Switch } from './Switch'
|
|
29
32
|
export type { SwitchProps } from './Switch'
|
|
30
33
|
export { default as Skeleton } from './Skeleton'
|
package/src/utils/solid.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import { type JSXElement, type JSX } from 'solid-js'
|
|
2
|
+
import { type JSXElement, type JSX, untrack, type Ref } from 'solid-js'
|
|
3
3
|
import { isNil } from 'lodash-es'
|
|
4
4
|
import SolidToReact from './SolidToReact'
|
|
5
5
|
import { type StringOrJSXElement } from '../types'
|
|
@@ -51,3 +51,11 @@ export function dispatchEventHandlerUnion<T, E extends Event>(
|
|
|
51
51
|
export function unwrapStringOrJSXElement(value: StringOrJSXElement): JSXElement {
|
|
52
52
|
return typeof value === 'function' ? value() : value
|
|
53
53
|
}
|
|
54
|
+
|
|
55
|
+
export function setRef<T>(props: { ref?: Ref<T> }, value: T | null) {
|
|
56
|
+
untrack(() => {
|
|
57
|
+
if (typeof props.ref === 'function') {
|
|
58
|
+
;(props.ref as (v: T | null) => void)?.(value)
|
|
59
|
+
}
|
|
60
|
+
})
|
|
61
|
+
}
|
package/es/Progress.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
declare const _default: import("solid-js").Component<Omit<Omit<import("antd").ProgressProps & import("react").RefAttributes<HTMLDivElement>, "className"> & {
|
|
3
|
-
class?: string | undefined;
|
|
4
|
-
}, "children"> & {
|
|
5
|
-
children?: import("solid-js").JSX.Element;
|
|
6
|
-
}>;
|
|
7
|
-
export default _default;
|
package/es/Progress.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { Progress as Progress$1 } from 'antd';
|
|
2
|
-
import { replaceChildren, replaceClassName, reactToSolidComponent } from './utils/component.js';
|
|
3
|
-
|
|
4
|
-
var Progress = replaceChildren(replaceClassName(reactToSolidComponent(Progress$1)));
|
|
5
|
-
|
|
6
|
-
export { Progress as default };
|
package/src/Progress.tsx
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|