antd-solid 0.0.10 → 0.0.12
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 +23 -6
- package/dist/index.esm.js +555 -152
- package/dist/index.umd.js +1 -1
- package/es/{Button.d.ts → Button/index.d.ts} +3 -2
- package/es/{Button.js → Button/index.js} +11 -9
- package/es/Button/index.scss.js +6 -0
- package/es/{Compact.js → Compact/index.js} +4 -4
- package/es/Drawer/index.d.ts +44 -0
- package/es/Drawer/index.js +162 -0
- package/es/Drawer/index.scss.js +6 -0
- package/es/Empty/index.d.ts +6 -2
- package/es/Empty/index.js +7 -2
- package/es/Input.js +3 -3
- package/es/InputNumber.js +1 -1
- package/es/Modal.js +23 -8
- package/es/Popconfirm.js +1 -1
- package/es/Progress/index.d.ts +24 -0
- package/es/Progress/index.js +81 -0
- package/es/Radio.js +25 -21
- package/es/Result.js +1 -1
- package/es/Select.js +2 -2
- package/es/Spin.d.ts +1 -0
- package/es/Spin.js +12 -6
- package/es/Switch.js +1 -1
- package/es/Tabs.js +2 -2
- package/es/Timeline.js +1 -1
- package/es/Tree.js +2 -2
- package/es/Upload.d.ts +56 -10
- package/es/Upload.js +93 -3
- 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 +5 -4
- 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 +3 -1
- package/src/Button/index.scss +9 -0
- package/src/{Button.tsx → Button/index.tsx} +23 -11
- package/src/Compact/index.tsx +20 -0
- package/src/Drawer/index.scss +53 -0
- package/src/Drawer/index.tsx +211 -0
- package/src/Empty/index.tsx +11 -6
- package/src/{form → Form}/FormItem.tsx +9 -7
- package/src/Input.tsx +2 -2
- package/src/InputNumber.tsx +34 -20
- package/src/Modal.tsx +37 -12
- package/src/Progress/index.tsx +81 -0
- package/src/Radio.tsx +26 -16
- package/src/Result.tsx +1 -1
- package/src/Select.tsx +14 -4
- package/src/Spin.tsx +16 -5
- package/src/Switch.tsx +1 -1
- package/src/Tabs.tsx +2 -2
- package/src/Timeline.tsx +1 -1
- package/src/Tree.tsx +4 -3
- package/src/Upload.tsx +138 -5
- 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/Compact.tsx +0 -15
- package/src/Progress.tsx +0 -4
- /package/es/{Compact.d.ts → Compact/index.d.ts} +0 -0
- /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
package/es/Tree.js
CHANGED
|
@@ -98,9 +98,9 @@ function SingleLevelTree(props) {
|
|
|
98
98
|
indexes
|
|
99
99
|
}));
|
|
100
100
|
effect(_p$ => {
|
|
101
|
-
const _v$ = cs('ant-flex ant-items-center ant-h-28px ant-pb-4px', isDraggable(item()) && 'ant-[border:1px_solid_var(--
|
|
101
|
+
const _v$ = cs('ant-flex ant-items-center ant-h-28px ant-pb-4px', isDraggable(item()) && 'ant-[border:1px_solid_var(--ant-color-primary)] ant-bg-white', draggableNode() && 'child[]:ant-pointer-events-none'),
|
|
102
102
|
_v$2 = cs('ant-flex-shrink-0 ant-w-24px ant-h-24px ant-flex ant-items-center ant-justify-center ant-cursor-pointer', isEmpty(props.children(item())) && 'opacity-0'),
|
|
103
|
-
_v$3 = cs('ant-h-full ant-leading-24px hover:ant-bg-[var(--hover-bg-color)] ant-rounded-1 ant-px-1 ant-cursor-pointer ant-relative', props.blockNode && 'w-full', selectedNodes()?.includes(item()) && '!ant-bg-[var(--
|
|
103
|
+
_v$3 = cs('ant-h-full ant-leading-24px hover:ant-bg-[var(--hover-bg-color)] ant-rounded-1 ant-px-1 ant-cursor-pointer ant-relative', props.blockNode && 'w-full', selectedNodes()?.includes(item()) && '!ant-bg-[var(--ant-tree-node-selected-bg)]', isTarget(item()) && "before:ant-content-[''] before:ant-inline-block before:ant-w-8px before:ant-h-8px before:ant-absolute before:ant-bottom-0 before:ant-left-0 before:-ant-translate-x-full before:ant-translate-y-1/2 before:ant-rounded-1/2 before:ant-[border:2px_solid_var(--ant-color-primary)] after:ant-content-[''] after:ant-inline-block after:ant-h-2px after:ant-absolute after:ant-left-0 after:ant-right-0 after:ant-bottom--1px after:ant-bg-[var(--ant-color-primary)]");
|
|
104
104
|
_v$ !== _p$._v$ && className(_el$, _p$._v$ = _v$);
|
|
105
105
|
_v$2 !== _p$._v$2 && className(_el$4, _p$._v$2 = _v$2);
|
|
106
106
|
_v$3 !== _p$._v$3 && className(_el$6, _p$._v$3 = _v$3);
|
package/es/Upload.d.ts
CHANGED
|
@@ -1,11 +1,57 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { type Component, type ParentProps, type Signal } from 'solid-js';
|
|
2
|
+
interface UploadProgressEvent extends Partial<ProgressEvent> {
|
|
3
|
+
percent?: number;
|
|
4
|
+
}
|
|
5
|
+
export interface UploadRequestOption<T = any> {
|
|
6
|
+
file: File;
|
|
7
|
+
onProgress?: (event: UploadProgressEvent) => void;
|
|
8
|
+
onError?: (event: Error) => void;
|
|
9
|
+
onSuccess?: (body: T) => void;
|
|
10
|
+
}
|
|
11
|
+
export interface UploadFile<T = any> {
|
|
12
|
+
/**
|
|
13
|
+
* 文件唯一标识
|
|
14
|
+
*/
|
|
15
|
+
id: string;
|
|
16
|
+
/**
|
|
17
|
+
* 文件名
|
|
18
|
+
*/
|
|
19
|
+
name: string;
|
|
20
|
+
/**
|
|
21
|
+
* MIME 类型
|
|
22
|
+
*/
|
|
23
|
+
type?: string;
|
|
24
|
+
/**
|
|
25
|
+
* 文件大小
|
|
26
|
+
*/
|
|
27
|
+
size?: number;
|
|
28
|
+
file?: File;
|
|
29
|
+
response?: T;
|
|
30
|
+
status?: 'pending' | 'uploading' | 'error' | 'finished';
|
|
31
|
+
percent?: number;
|
|
32
|
+
/**
|
|
33
|
+
* 下载地址
|
|
34
|
+
*/
|
|
35
|
+
url?: string;
|
|
36
|
+
}
|
|
37
|
+
export interface UploadProps<T = any> extends ParentProps {
|
|
38
|
+
class?: string;
|
|
39
|
+
accept?: string;
|
|
40
|
+
/**
|
|
41
|
+
* 上传的地址
|
|
42
|
+
*/
|
|
43
|
+
action?: string;
|
|
44
|
+
/**
|
|
45
|
+
* 上传请求的 http method
|
|
46
|
+
* 默认 'post'
|
|
47
|
+
*/
|
|
48
|
+
method?: string;
|
|
49
|
+
customRequest?: (option: UploadRequestOption<T>) => void;
|
|
50
|
+
onAdd?: (fileList: Array<Signal<T>>) => void;
|
|
51
|
+
multiple?: boolean;
|
|
52
|
+
}
|
|
53
|
+
declare function request(file: File, customRequest: UploadProps['customRequest']): Signal<UploadFile<any>>;
|
|
54
|
+
declare const Upload: Component<UploadProps> & {
|
|
55
|
+
request: typeof request;
|
|
56
|
+
};
|
|
11
57
|
export default Upload;
|
package/es/Upload.js
CHANGED
|
@@ -1,6 +1,96 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { delegateEvents, insert, use, effect, className, setAttribute, template } from 'solid-js/web';
|
|
2
|
+
import { nanoid } from 'nanoid';
|
|
3
|
+
import { mergeProps, createSignal } from 'solid-js';
|
|
3
4
|
|
|
4
|
-
const
|
|
5
|
+
const _tmpl$ = /*#__PURE__*/template(`<span><input class="hidden" type="file">`);
|
|
6
|
+
function request(file, customRequest) {
|
|
7
|
+
const id = `upload-${nanoid()}`;
|
|
8
|
+
// eslint-disable-next-line solid/reactivity
|
|
9
|
+
const uploadFileSignal = createSignal({
|
|
10
|
+
id,
|
|
11
|
+
file,
|
|
12
|
+
name: file.name,
|
|
13
|
+
type: file.type,
|
|
14
|
+
size: file.size,
|
|
15
|
+
status: 'pending',
|
|
16
|
+
percent: 0
|
|
17
|
+
});
|
|
18
|
+
const [, setUploadFile] = uploadFileSignal;
|
|
19
|
+
customRequest?.({
|
|
20
|
+
file,
|
|
21
|
+
onProgress(event) {
|
|
22
|
+
setUploadFile(value => ({
|
|
23
|
+
...value,
|
|
24
|
+
status: 'uploading',
|
|
25
|
+
percent: event.percent ?? 0
|
|
26
|
+
}));
|
|
27
|
+
},
|
|
28
|
+
onSuccess(response) {
|
|
29
|
+
setUploadFile(value => ({
|
|
30
|
+
...value,
|
|
31
|
+
status: 'finished',
|
|
32
|
+
response
|
|
33
|
+
}));
|
|
34
|
+
},
|
|
35
|
+
onError() {
|
|
36
|
+
setUploadFile(value => ({
|
|
37
|
+
...value,
|
|
38
|
+
status: 'error'
|
|
39
|
+
}));
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
return uploadFileSignal;
|
|
43
|
+
}
|
|
44
|
+
const Upload = _props => {
|
|
45
|
+
let input;
|
|
46
|
+
const props = mergeProps({
|
|
47
|
+
customRequest: ({
|
|
48
|
+
file,
|
|
49
|
+
onSuccess,
|
|
50
|
+
onError
|
|
51
|
+
}) => {
|
|
52
|
+
if (!_props.action) return;
|
|
53
|
+
const formData = new FormData();
|
|
54
|
+
formData.append('file', file);
|
|
55
|
+
fetch(_props.action, {
|
|
56
|
+
method: _props.method ?? 'post',
|
|
57
|
+
body: formData
|
|
58
|
+
}).then(onSuccess).catch(onError);
|
|
59
|
+
}
|
|
60
|
+
}, _props);
|
|
61
|
+
return (() => {
|
|
62
|
+
const _el$ = _tmpl$(),
|
|
63
|
+
_el$2 = _el$.firstChild;
|
|
64
|
+
_el$.$$click = () => input?.click();
|
|
65
|
+
insert(_el$, () => props.children, _el$2);
|
|
66
|
+
_el$2.$$input = e => {
|
|
67
|
+
const fileList = [];
|
|
68
|
+
for (const file of e.target.files ?? []) {
|
|
69
|
+
const uploadFileSignal = request(file, props.customRequest);
|
|
70
|
+
fileList.push(uploadFileSignal);
|
|
71
|
+
}
|
|
72
|
+
props.onAdd?.(fileList);
|
|
73
|
+
e.target.value = '';
|
|
74
|
+
};
|
|
75
|
+
const _ref$ = input;
|
|
76
|
+
typeof _ref$ === "function" ? use(_ref$, _el$2) : input = _el$2;
|
|
77
|
+
effect(_p$ => {
|
|
78
|
+
const _v$ = props.class,
|
|
79
|
+
_v$2 = props.accept,
|
|
80
|
+
_v$3 = props.multiple;
|
|
81
|
+
_v$ !== _p$._v$ && className(_el$, _p$._v$ = _v$);
|
|
82
|
+
_v$2 !== _p$._v$2 && setAttribute(_el$2, "accept", _p$._v$2 = _v$2);
|
|
83
|
+
_v$3 !== _p$._v$3 && (_el$2.multiple = _p$._v$3 = _v$3);
|
|
84
|
+
return _p$;
|
|
85
|
+
}, {
|
|
86
|
+
_v$: undefined,
|
|
87
|
+
_v$2: undefined,
|
|
88
|
+
_v$3: undefined
|
|
89
|
+
});
|
|
90
|
+
return _el$;
|
|
91
|
+
})();
|
|
92
|
+
};
|
|
93
|
+
Upload.request = request;
|
|
94
|
+
delegateEvents(["click", "input"]);
|
|
5
95
|
|
|
6
96
|
export { Upload as default };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type Accessor } from 'solid-js';
|
|
2
|
+
/**
|
|
3
|
+
* dom 节点显示或隐藏时的动画
|
|
4
|
+
* @param target
|
|
5
|
+
* @param when
|
|
6
|
+
* @param className 动画类名
|
|
7
|
+
*/
|
|
8
|
+
export default function createTransition(target: Accessor<HTMLElement | undefined | null>, when: Accessor<boolean>, className: string): void;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { createEffect, on } from 'solid-js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* dom 节点显示或隐藏时的动画
|
|
5
|
+
* @param target
|
|
6
|
+
* @param when
|
|
7
|
+
* @param className 动画类名
|
|
8
|
+
*/
|
|
9
|
+
function createTransition(target, when, className) {
|
|
10
|
+
createEffect(on(when, input => {
|
|
11
|
+
const targetValue = target();
|
|
12
|
+
if (!targetValue) return;
|
|
13
|
+
if (input) {
|
|
14
|
+
targetValue.style.display = '';
|
|
15
|
+
targetValue.classList.add(`${className}-enter-active`, `${className}-enter`, `${className}-enter-to`);
|
|
16
|
+
requestAnimationFrame(() => {
|
|
17
|
+
targetValue.classList.remove(`${className}-enter`);
|
|
18
|
+
});
|
|
19
|
+
const onTransitionEnd = () => {
|
|
20
|
+
targetValue.classList.remove(`${className}-enter-active`, `${className}-enter-to`);
|
|
21
|
+
targetValue.removeEventListener('transitionend', onTransitionEnd);
|
|
22
|
+
};
|
|
23
|
+
targetValue.addEventListener('transitionend', onTransitionEnd);
|
|
24
|
+
} else {
|
|
25
|
+
targetValue.classList.add(`${className}-exit-active`, `${className}-exit`, `${className}-exit-to`);
|
|
26
|
+
requestAnimationFrame(() => {
|
|
27
|
+
targetValue.classList.remove(`${className}-exit`);
|
|
28
|
+
});
|
|
29
|
+
const onTransitionEnd = () => {
|
|
30
|
+
targetValue.style.display = 'none';
|
|
31
|
+
targetValue.classList.remove(`${className}-exit-active`, `${className}-exit-to`);
|
|
32
|
+
targetValue.removeEventListener('transitionend', onTransitionEnd);
|
|
33
|
+
};
|
|
34
|
+
targetValue.addEventListener('transitionend', onTransitionEnd);
|
|
35
|
+
}
|
|
36
|
+
}));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export { createTransition as default };
|
package/es/index.d.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/es/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
export { default as Button } from './Button.js';
|
|
1
|
+
export { default as Button } from './Button/index.js';
|
|
2
2
|
export { default as Input } from './Input.js';
|
|
3
3
|
export { default as InputNumber } from './InputNumber.js';
|
|
4
4
|
export { default as Timeline } from './Timeline.js';
|
|
5
5
|
export { default as Modal } from './Modal.js';
|
|
6
|
+
export { default as Drawer } from './Drawer/index.js';
|
|
6
7
|
export { default as DatePicker } from './DatePicker.js';
|
|
7
8
|
export { default as Select } from './Select.js';
|
|
8
9
|
export { default as Tree } from './Tree.js';
|
|
@@ -10,18 +11,18 @@ export { default as Popover } from './Popover.js';
|
|
|
10
11
|
export { default as Tooltip } from './Tooltip.js';
|
|
11
12
|
export { default as ColorPicker } from './ColorPicker.js';
|
|
12
13
|
export { default as Result } from './Result.js';
|
|
13
|
-
export { default as Progress } from './Progress.js';
|
|
14
|
+
export { default as Progress } from './Progress/index.js';
|
|
14
15
|
export { default as Tabs } from './Tabs.js';
|
|
15
16
|
export { default as Popconfirm } from './Popconfirm.js';
|
|
16
17
|
export { default as Upload } from './Upload.js';
|
|
17
18
|
export { default as Radio } from './Radio.js';
|
|
18
|
-
export { default as Form } from './
|
|
19
|
+
export { default as Form } from './Form/index.js';
|
|
19
20
|
export { default as Switch } from './Switch.js';
|
|
20
21
|
export { default as Skeleton } from './Skeleton.js';
|
|
21
22
|
export { default as Spin } from './Spin.js';
|
|
22
23
|
export { default as Image } from './Image.js';
|
|
23
24
|
export { default as Table } from './Table.js';
|
|
24
|
-
export { default as Compact } from './Compact.js';
|
|
25
|
+
export { default as Compact } from './Compact/index.js';
|
|
25
26
|
export { default as Collapse } from './Collapse/index.js';
|
|
26
27
|
export { default as Empty } from './Empty/index.js';
|
|
27
28
|
export { default as Segmented } from './Segmented/index.js';
|
package/es/node_modules/.pnpm/style-inject@0.3.0/node_modules/style-inject/dist/style-inject.es.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
function styleInject(css, ref) {
|
|
2
|
+
if (ref === void 0) ref = {};
|
|
3
|
+
var insertAt = ref.insertAt;
|
|
4
|
+
if (!css || typeof document === 'undefined') {
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
var head = document.head || document.getElementsByTagName('head')[0];
|
|
8
|
+
var style = document.createElement('style');
|
|
9
|
+
style.type = 'text/css';
|
|
10
|
+
if (insertAt === 'top') {
|
|
11
|
+
if (head.firstChild) {
|
|
12
|
+
head.insertBefore(style, head.firstChild);
|
|
13
|
+
} else {
|
|
14
|
+
head.appendChild(style);
|
|
15
|
+
}
|
|
16
|
+
} else {
|
|
17
|
+
head.appendChild(style);
|
|
18
|
+
}
|
|
19
|
+
if (style.styleSheet) {
|
|
20
|
+
style.styleSheet.cssText = css;
|
|
21
|
+
} else {
|
|
22
|
+
style.appendChild(document.createTextNode(css));
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { styleInject as default };
|
package/es/utils/solid.d.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, type Ref } from 'solid-js';
|
|
3
3
|
import { type StringOrJSXElement } from '../types';
|
|
4
4
|
/**
|
|
5
5
|
* 判断 JSXElement 是否是基础类型
|
|
@@ -13,3 +13,6 @@ export declare function dispatchEventHandlerUnion<T, E extends Event>(handler: J
|
|
|
13
13
|
target: Element;
|
|
14
14
|
}): void;
|
|
15
15
|
export declare function unwrapStringOrJSXElement(value: StringOrJSXElement): JSXElement;
|
|
16
|
+
export declare function setRef<T>(props: {
|
|
17
|
+
ref?: Ref<T>;
|
|
18
|
+
}, value: T | null): void;
|
package/es/utils/solid.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { untrack } from 'solid-js';
|
|
2
3
|
import { isNil } from 'lodash-es';
|
|
3
4
|
import SolidToReact from './SolidToReact.js';
|
|
4
5
|
|
|
@@ -28,5 +29,12 @@ function dispatchEventHandlerUnion(handler, e) {
|
|
|
28
29
|
function unwrapStringOrJSXElement(value) {
|
|
29
30
|
return typeof value === 'function' ? value() : value;
|
|
30
31
|
}
|
|
32
|
+
function setRef(props, value) {
|
|
33
|
+
untrack(() => {
|
|
34
|
+
if (typeof props.ref === 'function') {
|
|
35
|
+
props.ref?.(value);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
31
39
|
|
|
32
|
-
export { dispatchEventHandlerUnion, isBaseType, solidToReact, unwrapStringOrJSXElement };
|
|
40
|
+
export { dispatchEventHandlerUnion, isBaseType, setRef, solidToReact, unwrapStringOrJSXElement };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "antd-solid",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.12",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"types": "es/index.d.ts",
|
|
@@ -38,7 +38,9 @@
|
|
|
38
38
|
"rollup": "^3.21.0",
|
|
39
39
|
"rollup-plugin-cleanup": "^3.2.1",
|
|
40
40
|
"rollup-plugin-import-css": "^3.2.1",
|
|
41
|
+
"rollup-plugin-postcss": "^4.0.2",
|
|
41
42
|
"rollup-plugin-typescript2": "^0.34.1",
|
|
43
|
+
"sass": "^1.69.6",
|
|
42
44
|
"typescript": "^5.1.6",
|
|
43
45
|
"vite-plugin-solid": "^2.7.0",
|
|
44
46
|
"vitepress": "1.0.0-rc.4",
|
|
@@ -6,17 +6,20 @@ import {
|
|
|
6
6
|
Show,
|
|
7
7
|
createSignal,
|
|
8
8
|
createMemo,
|
|
9
|
+
untrack,
|
|
9
10
|
} from 'solid-js'
|
|
10
11
|
import cs from 'classnames'
|
|
12
|
+
import Compact from '../Compact'
|
|
13
|
+
import './index.scss'
|
|
11
14
|
|
|
12
15
|
interface ButtonProps extends ParentProps, JSX.CustomAttributes<HTMLButtonElement> {
|
|
13
16
|
type?: 'default' | 'primary' | 'dashed' | 'text' | 'link'
|
|
14
17
|
onClick?: ((e: MouseEvent) => void) | ((e: MouseEvent) => Promise<unknown>)
|
|
18
|
+
'on:click'?: (e: MouseEvent) => void
|
|
15
19
|
/**
|
|
16
20
|
* 默认: middle
|
|
17
|
-
* plain: 没有多余的 padding 和高度等
|
|
18
21
|
*/
|
|
19
|
-
size?: 'large' | 'middle' | 'small'
|
|
22
|
+
size?: 'large' | 'middle' | 'small'
|
|
20
23
|
class?: string
|
|
21
24
|
style?: JSX.CSSProperties
|
|
22
25
|
loading?: boolean
|
|
@@ -30,7 +33,6 @@ const sizeClassMap = {
|
|
|
30
33
|
large: 'ant-px-15px ant-py-6px ant-h-40px ant-rounded-8px',
|
|
31
34
|
middle: 'ant-px-15px ant-py-4px ant-h-32px ant-rounded-6px',
|
|
32
35
|
small: 'ant-px-7px ant-h-24px ant-rounded-4px',
|
|
33
|
-
plain: 'ant-p-0',
|
|
34
36
|
} as const
|
|
35
37
|
|
|
36
38
|
const typeClassMap = {
|
|
@@ -39,21 +41,21 @@ const typeClassMap = {
|
|
|
39
41
|
'ant-bg-white',
|
|
40
42
|
danger
|
|
41
43
|
? 'ant-[border:1px_solid_var(--ant-color-error)] ant-text-[var(--ant-color-error)] hover:ant-[border-color:var(--light-error-color)] hover:ant-text-[var(--light-error-color)] active:ant-[border-color:var(--dark-error-color)] active:ant-text-[var(--dark-error-color)]'
|
|
42
|
-
: 'ant-[border:1px_solid_var(--ant-color-border)] ant-text-[var(--dark-color)] hover:ant-[border-color:var(--
|
|
44
|
+
: 'ant-[border:1px_solid_var(--ant-color-border)] ant-text-[var(--dark-color)] hover:ant-[border-color:var(--ant-color-primary-hover)] hover:ant-text-[var(--ant-color-primary-hover)] active:ant-[border-color:var(--ant-color-primary-active)] active:ant-text-[var(--ant-color-primary-active)]',
|
|
43
45
|
),
|
|
44
46
|
primary: (danger: boolean) =>
|
|
45
47
|
cs(
|
|
46
|
-
'ant-
|
|
48
|
+
'ant-text-white',
|
|
47
49
|
danger
|
|
48
|
-
? 'ant-bg-[var(--ant-color-error)] hover:ant-bg-[var(--light-error-color)] active:ant-bg-[var(--dark-error-color)]'
|
|
49
|
-
: 'ant-bg-[var(--primary-color)] hover:ant-bg-[var(--
|
|
50
|
+
? 'ant-[border:1px_solid_var(--ant-color-error)] ant-bg-[var(--ant-color-error)] hover:ant-[border-color:var(--light-error-color)] hover:ant-bg-[var(--light-error-color)] active:ant-[border-color:var(--dark-error-color)] active:ant-bg-[var(--dark-error-color)]'
|
|
51
|
+
: 'ant-[border:1px_solid_var(--ant-color-primary)] ant-bg-[var(--ant-color-primary)] hover:ant-[border-color:var(--ant-color-primary-hover)] hover:ant-bg-[var(--ant-color-primary-hover)] active:ant-[border-color:var(--ant-color-primary-active)] active:ant-bg-[var(--ant-color-primary-active)]',
|
|
50
52
|
),
|
|
51
53
|
dashed: (danger: boolean) =>
|
|
52
54
|
cs(
|
|
53
55
|
' ant-bg-white',
|
|
54
56
|
danger
|
|
55
57
|
? 'ant-[border:1px_dashed_var(--ant-color-error)] ant-text-[var(--ant-color-error)] hover:ant-[border-color:var(--light-error-color)] hover:ant-text-[var(--light-error-color)] active:ant-[border-color:var(--dark-error-color)] active:ant-text-[var(--dark-error-color)]'
|
|
56
|
-
: 'ant-[border:1px_dashed_var(--ant-color-border)] ant-text-[var(--dark-color)] hover:ant-[border-color:var(--
|
|
58
|
+
: 'ant-[border:1px_dashed_var(--ant-color-border)] ant-text-[var(--dark-color)] hover:ant-[border-color:var(--ant-color-primary-hover)] hover:ant-text-[var(--ant-color-primary-hover)] active:ant-[border-color:var(--ant-color-primary-active)] active:ant-text-[var(--ant-color-primary-active)]',
|
|
57
59
|
),
|
|
58
60
|
text: (danger: boolean) =>
|
|
59
61
|
cs(
|
|
@@ -67,7 +69,7 @@ const typeClassMap = {
|
|
|
67
69
|
'ant-border-none ant-bg-transparent',
|
|
68
70
|
danger
|
|
69
71
|
? 'ant-text-[var(--ant-color-error)] hover:ant-text-[var(--light-error-color)] active:ant-text-[var(--dark-error-color)]'
|
|
70
|
-
: 'ant-text-[var(--
|
|
72
|
+
: 'ant-text-[var(--ant-color-primary)] hover:ant-text-[var(--ant-color-primary-hover)] active:ant-text-[var(--ant-color-primary-active)]',
|
|
71
73
|
),
|
|
72
74
|
} as const
|
|
73
75
|
|
|
@@ -80,14 +82,22 @@ const Button: Component<ButtonProps> = props => {
|
|
|
80
82
|
<button
|
|
81
83
|
ref={mergedProps.ref}
|
|
82
84
|
class={cs(
|
|
85
|
+
`ant-btn ant-btn-${mergedProps.type}`,
|
|
83
86
|
'ant-relative ant-cursor-pointer',
|
|
87
|
+
'focus-visible:ant-[outline:4px_solid_var(--ant-color-primary-border)] focus-visible:ant-[outline-offset:1px]',
|
|
84
88
|
mergedProps.class,
|
|
85
89
|
sizeClassMap[mergedProps.size!],
|
|
86
90
|
typeClassMap[mergedProps.type!](props.danger ?? false),
|
|
87
91
|
loading() && 'ant-opacity-65',
|
|
88
|
-
'ant-[--color:--
|
|
92
|
+
'ant-[--color:--ant-color-primary-hover]',
|
|
93
|
+
Compact.compactItemRounded0Class,
|
|
94
|
+
Compact.compactItemZIndexClass,
|
|
95
|
+
Compact.compactItemClass,
|
|
89
96
|
)}
|
|
90
97
|
style={mergedProps.style}
|
|
98
|
+
// @ts-expect-error on:
|
|
99
|
+
on:click={untrack(() => props['on:click'])}
|
|
100
|
+
// eslint-disable-next-line solid/jsx-no-duplicate-props
|
|
91
101
|
onClick={e => {
|
|
92
102
|
const res = mergedProps.onClick?.(e)
|
|
93
103
|
if (res instanceof Promise) {
|
|
@@ -102,7 +112,9 @@ const Button: Component<ButtonProps> = props => {
|
|
|
102
112
|
) {
|
|
103
113
|
const div = document.createElement('div')
|
|
104
114
|
div.className = cs(
|
|
105
|
-
props.danger
|
|
115
|
+
props.danger
|
|
116
|
+
? 'ant-[--color:var(--light-error-color)]'
|
|
117
|
+
: 'ant-[--color:var(--ant-color-primary-hover)]',
|
|
106
118
|
'ant-absolute ant-inset-0 ant-rounded-inherit ant-[background:radial-gradient(var(--color),rgba(0,0,0,0))] ant-z--1 ant-keyframes-button-border[inset:0px][inset:-6px] ant-[animation:button-border_ease-out_0.3s]',
|
|
107
119
|
)
|
|
108
120
|
const onAnimationEnd = () => {
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type ParentProps } from 'solid-js'
|
|
2
|
+
|
|
3
|
+
interface CompactProps extends ParentProps {}
|
|
4
|
+
|
|
5
|
+
function Compact(props: CompactProps) {
|
|
6
|
+
return (
|
|
7
|
+
<div class="ant-compact ant-flex child[:first-child]>:ant-rounded-l-6px child[:last-child]>:ant-rounded-r-6px">
|
|
8
|
+
{props.children}
|
|
9
|
+
</div>
|
|
10
|
+
)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
Compact.compactItemClass = 'p[.ant-compact]:ant-ml--1px p[.ant-compact]:first:ant-ml-0'
|
|
14
|
+
Compact.compactItemRounded0Class = 'p[.ant-compact]:ant-rounded-0'
|
|
15
|
+
Compact.compactItemRoundedLeftClass = 'p[.ant-compact>:first-child]:ant-rounded-l-6px'
|
|
16
|
+
Compact.compactItemRoundedRightClass = 'p[.ant-compact>:last-child]:ant-rounded-r-6px'
|
|
17
|
+
Compact.compactItemZIndexClass =
|
|
18
|
+
'p[.ant-compact]:hover:ant-z-10 p[.ant-compact]:focus:ant-z-10 p[.ant-compact]:focus-within:ant-z-10'
|
|
19
|
+
|
|
20
|
+
export default Compact
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
.ant-drawer-content-right {
|
|
2
|
+
top: 0;
|
|
3
|
+
bottom: 0;
|
|
4
|
+
right: 0;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.ant-drawer-content-left {
|
|
8
|
+
top: 0;
|
|
9
|
+
bottom: 0;
|
|
10
|
+
left: 0;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.ant-drawer-content-top {
|
|
14
|
+
top: 0;
|
|
15
|
+
left: 0;
|
|
16
|
+
right: 0;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.ant-drawer-content-bottom {
|
|
20
|
+
bottom: 0;
|
|
21
|
+
left: 0;
|
|
22
|
+
right: 0;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.ant-drawer-fade-enter-active,
|
|
26
|
+
.ant-drawer-fade-exit-active {
|
|
27
|
+
transition: opacity .3s;
|
|
28
|
+
|
|
29
|
+
.ant-drawer-content {
|
|
30
|
+
transition: transform .3s;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.ant-drawer-fade-enter,
|
|
35
|
+
.ant-drawer-fade-exit-to {
|
|
36
|
+
opacity: 0;
|
|
37
|
+
|
|
38
|
+
.ant-drawer-content-right {
|
|
39
|
+
transform: translateX(100%);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.ant-drawer-content-left {
|
|
43
|
+
transform: translateX(-100%);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.ant-drawer-content-top {
|
|
47
|
+
transform: translateY(-100%);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.ant-drawer-content-bottom {
|
|
51
|
+
transform: translateY(100%);
|
|
52
|
+
}
|
|
53
|
+
}
|