antd-solid 0.0.11 → 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.
Files changed (50) hide show
  1. package/css/index.css +9 -5
  2. package/dist/index.esm.js +232 -135
  3. package/dist/index.umd.js +1 -1
  4. package/es/{Button.d.ts → Button/index.d.ts} +3 -2
  5. package/es/{Button.js → Button/index.js} +11 -9
  6. package/es/Button/index.scss.js +6 -0
  7. package/es/{Compact.js → Compact/index.js} +4 -4
  8. package/es/Drawer/index.js +2 -3
  9. package/es/Empty/index.d.ts +6 -2
  10. package/es/Empty/index.js +7 -2
  11. package/es/Input.js +3 -3
  12. package/es/InputNumber.js +1 -1
  13. package/es/Modal.d.ts +4 -5
  14. package/es/Modal.js +10 -9
  15. package/es/Popconfirm.js +1 -1
  16. package/es/Progress/index.d.ts +1 -2
  17. package/es/Progress/index.js +18 -8
  18. package/es/Radio.js +2 -2
  19. package/es/Result.js +1 -1
  20. package/es/Select.js +2 -2
  21. package/es/Spin.d.ts +1 -0
  22. package/es/Spin.js +12 -6
  23. package/es/Switch.js +1 -1
  24. package/es/Tabs.js +2 -2
  25. package/es/Timeline.js +1 -1
  26. package/es/Tree.js +2 -2
  27. package/es/Upload.d.ts +56 -10
  28. package/es/Upload.js +93 -3
  29. package/es/index.js +2 -2
  30. package/package.json +1 -1
  31. package/src/Button/index.scss +9 -0
  32. package/src/{Button.tsx → Button/index.tsx} +18 -9
  33. package/src/Compact/index.tsx +20 -0
  34. package/src/Drawer/index.tsx +1 -2
  35. package/src/Empty/index.tsx +11 -6
  36. package/src/Input.tsx +2 -2
  37. package/src/InputNumber.tsx +34 -20
  38. package/src/Modal.tsx +14 -13
  39. package/src/Progress/index.tsx +17 -9
  40. package/src/Radio.tsx +3 -3
  41. package/src/Result.tsx +1 -1
  42. package/src/Select.tsx +14 -4
  43. package/src/Spin.tsx +16 -5
  44. package/src/Switch.tsx +1 -1
  45. package/src/Tabs.tsx +2 -2
  46. package/src/Timeline.tsx +1 -1
  47. package/src/Tree.tsx +4 -3
  48. package/src/Upload.tsx +138 -5
  49. package/src/Compact.tsx +0 -15
  50. /package/es/{Compact.d.ts → Compact/index.d.ts} +0 -0
package/es/Modal.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { delegateEvents, createComponent, Portal, insert, memo, effect, className, render, mergeProps as mergeProps$1, template } from 'solid-js/web';
2
2
  import { mergeProps, createSignal, untrack, Show } from 'solid-js';
3
- import Button from './Button.js';
3
+ import Button from './Button/index.js';
4
4
  import cs from 'classnames';
5
5
 
6
6
  const _tmpl$ = /*#__PURE__*/template(`<span class="i-ant-design:close-outlined">`),
@@ -35,14 +35,15 @@ function Modal(_props) {
35
35
  };
36
36
  },
37
37
  close() {
38
- setHide(true);
39
- cleanup();
40
- props.afterClose?.();
41
- },
42
- destroy() {
43
- setOpen(false);
44
- cleanup();
45
- props.afterClose?.();
38
+ untrack(() => {
39
+ if (props.destroyOnClose) {
40
+ setOpen(false);
41
+ } else {
42
+ setHide(true);
43
+ }
44
+ cleanup();
45
+ props.afterClose?.();
46
+ });
46
47
  }
47
48
  };
48
49
  untrack(() => {
package/es/Popconfirm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { createComponent, mergeProps as mergeProps$1, insert, template } from 'solid-js/web';
2
2
  import { mergeProps, splitProps, createSignal, untrack } from 'solid-js';
3
- import Button from './Button.js';
3
+ import Button from './Button/index.js';
4
4
  import Tooltip from './Tooltip.js';
5
5
 
6
6
  const _tmpl$ = /*#__PURE__*/template(`<div><div class="ant-mb-8px ant-flex ant-items-center"><span class="i-ant-design:exclamation-circle-fill ant-text-#faad14"></span><span class="ant-ml-8px ant-text-[rgba(0,0,0,0.88)] ant-font-600"></span></div><div class="ant-ml-22px ant-mb-8px ant-text-[rgba(0,0,0,0.88)]"></div><div class="ant-text-right">`);
@@ -7,9 +7,8 @@ export interface ProgressProps {
7
7
  percent?: number;
8
8
  /**
9
9
  * 状态
10
- * 默认 'default'
11
10
  */
12
- status?: 'default' | 'success' | 'error';
11
+ status?: 'normal' | 'success' | 'error';
13
12
  /**
14
13
  * 'line' 类型进度条的高度
15
14
  * 默认 8
@@ -1,18 +1,21 @@
1
1
  import { insert, createComponent, effect, className, template } from 'solid-js/web';
2
- import { mergeProps, Show, Switch, Match } from 'solid-js';
2
+ import { mergeProps, createMemo, Show, Switch, Match } from 'solid-js';
3
3
  import cs from 'classnames';
4
4
 
5
- const _tmpl$ = /*#__PURE__*/template(`<span class="i-ant-design:check-circle-filled ant-text-[var(--primary-color)]">`),
5
+ const _tmpl$ = /*#__PURE__*/template(`<span class="i-ant-design:check-circle-filled ant-text-[var(--ant-color-success)]">`),
6
6
  _tmpl$2 = /*#__PURE__*/template(`<span class="i-ant-design:close-circle-filled ant-text-[var(--ant-color-error)]">`),
7
7
  _tmpl$3 = /*#__PURE__*/template(`<span class="ant-shrink-0 ant-min-w-40px ant-ml-8px ant-text-center">`),
8
8
  _tmpl$4 = /*#__PURE__*/template(`<div class="ant-flex ant-items-center"><div>`);
9
9
  const Progress = _props => {
10
10
  const props = mergeProps({
11
11
  percent: 0,
12
- status: 'default',
13
12
  height: 8,
14
13
  showInfo: true
15
14
  }, _props);
15
+ const status = createMemo(() => {
16
+ if (props.status) return props.status;
17
+ return props.percent >= 100 ? 'success' : 'normal';
18
+ });
16
19
  return (() => {
17
20
  const _el$ = _tmpl$4(),
18
21
  _el$2 = _el$.firstChild;
@@ -30,14 +33,14 @@ const Progress = _props => {
30
33
  get children() {
31
34
  return [createComponent(Match, {
32
35
  get when() {
33
- return props.status === 'success' || props.percent >= 100;
36
+ return status() === 'success';
34
37
  },
35
38
  get children() {
36
39
  return _tmpl$();
37
40
  }
38
41
  }), createComponent(Match, {
39
42
  get when() {
40
- return props.status === 'error';
43
+ return status() === 'error';
41
44
  },
42
45
  get children() {
43
46
  return _tmpl$2();
@@ -49,20 +52,27 @@ const Progress = _props => {
49
52
  }
50
53
  }), null);
51
54
  effect(_p$ => {
52
- const _v$ = cs('ant-w-full ant-bg-[var(--ant-progress-remaining-color)]', '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'),
55
+ const _v$ = cs('ant-w-full ant-bg-[var(--ant-progress-remaining-color)]', 'before:ant-content-empty before:ant-block before:ant-bg-[var(--color)] before:ant-w-[var(--percent)] before:ant-h-full before:ant-rounded-inherit'),
53
56
  _v$2 = `${props.height}px`,
54
57
  _v$3 = `${props.height / 2}px`,
55
- _v$4 = `${props.percent}%`;
58
+ _v$4 = `${props.percent}%`,
59
+ _v$5 = {
60
+ normal: 'var(--ant-color-primary)',
61
+ success: 'var(--ant-color-success)',
62
+ error: 'var(--ant-color-error)'
63
+ }[status()];
56
64
  _v$ !== _p$._v$ && className(_el$2, _p$._v$ = _v$);
57
65
  _v$2 !== _p$._v$2 && ((_p$._v$2 = _v$2) != null ? _el$2.style.setProperty("height", _v$2) : _el$2.style.removeProperty("height"));
58
66
  _v$3 !== _p$._v$3 && ((_p$._v$3 = _v$3) != null ? _el$2.style.setProperty("border-radius", _v$3) : _el$2.style.removeProperty("border-radius"));
59
67
  _v$4 !== _p$._v$4 && ((_p$._v$4 = _v$4) != null ? _el$2.style.setProperty("--percent", _v$4) : _el$2.style.removeProperty("--percent"));
68
+ _v$5 !== _p$._v$5 && ((_p$._v$5 = _v$5) != null ? _el$2.style.setProperty("--color", _v$5) : _el$2.style.removeProperty("--color"));
60
69
  return _p$;
61
70
  }, {
62
71
  _v$: undefined,
63
72
  _v$2: undefined,
64
73
  _v$3: undefined,
65
- _v$4: undefined
74
+ _v$4: undefined,
75
+ _v$5: undefined
66
76
  });
67
77
  return _el$;
68
78
  })();
package/es/Radio.js CHANGED
@@ -22,7 +22,7 @@ const Radio = props => {
22
22
  untrack(() => props.onChange?.(e));
23
23
  };
24
24
  insert(_el$, () => props.children, null);
25
- effect(() => className(_el$2, cs('ant-w-16px ant-h-16px ant-rounded-50% ant-[border:1px_solid_var(--ant-color-border)]', checked() && 'ant-[border:5px_solid_var(--primary-color)]')));
25
+ effect(() => className(_el$2, cs('ant-w-16px ant-h-16px ant-rounded-50% ant-[border:1px_solid_var(--ant-color-border)]', checked() && 'ant-[border:5px_solid_var(--ant-color-primary)]')));
26
26
  effect(() => _el$3.checked = checked());
27
27
  effect(() => _el$3.value = props.value ?? '');
28
28
  return _el$;
@@ -43,7 +43,7 @@ Radio.Button = props => {
43
43
  untrack(() => props.onChange?.(e));
44
44
  };
45
45
  insert(_el$4, () => props.children, null);
46
- effect(() => className(_el$4, cs('ant-px-15px ant-[border:1px_solid_rgb(217,217,217)] first:ant-rounded-l-6px last:ant-rounded-r-6px ant-h-32px ant-inline-flex ant-items-center hover:ant-text-[var(--primary-color)] not[:last-child]:ant-border-r-transparent ant-cursor-pointer ant-flex-grow ant-justify-center', checked() && 'ant-text-[var(--primary-color)] ant-[border:1px_solid_var(--primary-color)] !ant-border-r-[var(--primary-color)]')));
46
+ effect(() => className(_el$4, cs('ant-px-15px ant-[border:1px_solid_rgb(217,217,217)] first:ant-rounded-l-6px last:ant-rounded-r-6px ant-h-32px ant-inline-flex ant-items-center hover:ant-text-[var(--ant-color-primary)] not[:last-child]:ant-border-r-transparent ant-cursor-pointer ant-flex-grow ant-justify-center', checked() && 'ant-text-[var(--ant-color-primary)] ant-[border:1px_solid_var(--ant-color-primary)] !ant-border-r-[var(--ant-color-primary)]')));
47
47
  effect(() => _el$5.checked = checked());
48
48
  effect(() => _el$5.value = props.value ?? '');
49
49
  return _el$4;
package/es/Result.js CHANGED
@@ -4,7 +4,7 @@ import cs from 'classnames';
4
4
  const _tmpl$ = /*#__PURE__*/template(`<div class="ant-text-center ant-px-32px ant-py-48px"><div class="ant-mb-24px"><span></span></div><div class="ant-my-8px ant-text-[rgba(0,0,0,.88)] ant-text-24px"></div><div class="ant-text-[rgba(0,0,0,.45)] ant-text-14px"></div><div class="ant-mt-24px"></div><div class="ant-mt-24px">`);
5
5
  const statusIconMap = {
6
6
  success: 'ant-text-#52c41a i-ant-design:check-circle-filled',
7
- info: 'ant-text-[var(--primary-color)] i-ant-design:exclamation-circle-filled',
7
+ info: 'ant-text-[var(--ant-color-primary)] i-ant-design:exclamation-circle-filled',
8
8
  warning: 'ant-text-#faad14 i-ant-design:warning-filled',
9
9
  error: 'ant-text-#ff4d4f i-ant-design:close-circle-filled'
10
10
  };
package/es/Select.js CHANGED
@@ -47,7 +47,7 @@ const Select = props => {
47
47
  close();
48
48
  };
49
49
  insert(_el$7, () => item.label);
50
- effect(() => className(_el$7, cs('ant-box-content ant-px-12px ant-py-5px ant-h-22px ant-leading-22px hover:ant-bg-[var(--hover-bg-color)]', selectedValue(item.value) ? '!ant-bg-[var(--active-bg-color)]' : '')));
50
+ effect(() => className(_el$7, cs('ant-box-content ant-px-12px ant-py-5px ant-h-22px ant-leading-22px hover:ant-bg-[var(--hover-bg-color)]', selectedValue(item.value) ? '!ant-bg-[var(--ant-select-option-selected-bg)]' : '')));
51
51
  return _el$7;
52
52
  })()
53
53
  }));
@@ -103,7 +103,7 @@ const Select = props => {
103
103
  return _el$5;
104
104
  }
105
105
  }));
106
- effect(() => className(_el$, cs('ant-h-32px ant-leading-32px ant-rounded-6px ant-[border:1px_solid_var(--ant-color-border)] ant-px-11px focus:ant-[border-color:var(--primary-color)]', props.class)));
106
+ effect(() => className(_el$, cs('ant-h-32px ant-leading-32px ant-rounded-6px ant-[border:1px_solid_var(--ant-color-border)] ant-px-11px focus:ant-[border-color:var(--ant-color-primary)]', props.class)));
107
107
  return _el$;
108
108
  }
109
109
  });
package/es/Spin.d.ts CHANGED
@@ -4,6 +4,7 @@ interface SpinProps extends ParentProps {
4
4
  * 是否为加载中状态
5
5
  */
6
6
  spinning?: boolean;
7
+ size?: number;
7
8
  }
8
9
  declare const Spin: Component<SpinProps>;
9
10
  export default Spin;
package/es/Spin.js CHANGED
@@ -1,9 +1,12 @@
1
- import { insert, createComponent, template } from 'solid-js/web';
2
- import { Show } from 'solid-js';
1
+ import { insert, createComponent, effect, template } from 'solid-js/web';
2
+ import { mergeProps, Show } from 'solid-js';
3
3
 
4
- const _tmpl$ = /*#__PURE__*/template(`<div class="ant-absolute ant-inset-0 ant-flex ant-items-center ant-justify-center ant-bg-[rgba(255,255,255,.5)]"><span class="i-ant-design:loading keyframes-spin ant-[animation:spin_1s_linear_infinite] ant-text-32px ant-text-[var(--primary-color)]">`),
5
- _tmpl$2 = /*#__PURE__*/template(`<div class="ant-relative ant-min-h-32px">`);
6
- const Spin = props => {
4
+ const _tmpl$ = /*#__PURE__*/template(`<div class="ant-flex ant-items-center ant-justify-center ant-bg-[rgba(255,255,255,.5)]"><span class="i-ant-design:loading keyframes-spin ant-[animation:spin_1s_linear_infinite] ant-text-[var(--ant-color-primary)]">`),
5
+ _tmpl$2 = /*#__PURE__*/template(`<div>`);
6
+ const Spin = _props => {
7
+ const props = mergeProps({
8
+ size: 20
9
+ }, _props);
7
10
  return (() => {
8
11
  const _el$ = _tmpl$2();
9
12
  insert(_el$, () => props.children, null);
@@ -12,7 +15,10 @@ const Spin = props => {
12
15
  return props.spinning;
13
16
  },
14
17
  get children() {
15
- return _tmpl$();
18
+ const _el$2 = _tmpl$(),
19
+ _el$3 = _el$2.firstChild;
20
+ effect(() => `${props.size}px` != null ? _el$3.style.setProperty("font-size", `${props.size}px`) : _el$3.style.removeProperty("font-size"));
21
+ return _el$2;
16
22
  }
17
23
  }), null);
18
24
  return _el$;
package/es/Switch.js CHANGED
@@ -13,7 +13,7 @@ const Switch = props => {
13
13
  _el$2 = _el$.firstChild;
14
14
  _el$.$$click = () => setChecked(c => !c);
15
15
  effect(_p$ => {
16
- const _v$ = cs('ant-w-44px ant-h-22px ant-rounded-100px ant-relative', checked() ? 'ant-bg-[var(--primary-color)]' : 'ant-bg-[rgba(0,0,0,0.45)]'),
16
+ const _v$ = cs('ant-w-44px ant-h-22px ant-rounded-100px ant-relative', checked() ? 'ant-bg-[var(--ant-color-primary)]' : 'ant-bg-[rgba(0,0,0,0.45)]'),
17
17
  _v$2 = cs('ant-w-18px ant-h-18px ant-rounded-50% ant-bg-white ant-absolute ant-top-1/2 -ant-translate-y-1/2 ant-transition-left', checked() ? 'ant-left-[calc(100%-20px)]' : 'ant-left-2px');
18
18
  _v$ !== _p$._v$ && className(_el$, _p$._v$ = _v$);
19
19
  _v$2 !== _p$._v$2 && className(_el$2, _p$._v$2 = _v$2);
package/es/Tabs.js CHANGED
@@ -4,7 +4,7 @@ import cs from 'classnames';
4
4
  import Segmented from './Segmented/index.js';
5
5
  import { unwrapStringOrJSXElement } from './utils/solid.js';
6
6
 
7
- const _tmpl$ = /*#__PURE__*/template(`<div><div role="selected-bar" class="ant-absolute ant-bottom-0 ant-bg-[var(--primary-color)] ant-h-2px ant-transition-left">`),
7
+ const _tmpl$ = /*#__PURE__*/template(`<div><div role="selected-bar" class="ant-absolute ant-bottom-0 ant-bg-[var(--ant-color-primary)] ant-h-2px ant-transition-left">`),
8
8
  _tmpl$2 = /*#__PURE__*/template(`<div><div>`),
9
9
  _tmpl$3 = /*#__PURE__*/template(`<div>`);
10
10
  const Tabs = _props => {
@@ -63,7 +63,7 @@ const Tabs = _props => {
63
63
  updateSelectedBarStyle();
64
64
  };
65
65
  insert(_el$5, () => unwrapStringOrJSXElement(item.label));
66
- effect(() => className(_el$5, cs('ant-py-12px ant-cursor-pointer', props.navItemClass, isSelectedItem(item.key) && 'ant-text-[var(--primary-color)] selected')));
66
+ effect(() => className(_el$5, cs('ant-py-12px ant-cursor-pointer', props.navItemClass, isSelectedItem(item.key) && 'ant-text-[var(--ant-color-primary)] selected')));
67
67
  return _el$5;
68
68
  })()
69
69
  }), _el$3);
package/es/Timeline.js CHANGED
@@ -2,7 +2,7 @@ import { insert, createComponent, memo, template } from 'solid-js/web';
2
2
  import { For } from 'solid-js';
3
3
 
4
4
  const _tmpl$ = /*#__PURE__*/template(`<div class="ant-flex ant-flex-col ant-gap-[16px]">`),
5
- _tmpl$2 = /*#__PURE__*/template(`<div class="ant-flex ant-relative"><div class="ant-w-[10px] ant-h-[10px] ant-border-solid ant-border-width-[3px] ant-border-[var(--primary-color)] ant-bg-white ant-rounded-[50%] ant-mt-[8px]"></div><div class="ant-ml-[8px]">`),
5
+ _tmpl$2 = /*#__PURE__*/template(`<div class="ant-flex ant-relative"><div class="ant-w-[10px] ant-h-[10px] ant-border-solid ant-border-width-[3px] ant-border-[var(--ant-color-primary)] ant-bg-white ant-rounded-[50%] ant-mt-[8px]"></div><div class="ant-ml-[8px]">`),
6
6
  _tmpl$3 = /*#__PURE__*/template(`<div class="ant-absolute ant-top-[8px] ant-bottom-[-24px] ant-left-[4px] ant-w-[2px] ant-bg-[rgba(5,5,5,.06)]">`);
7
7
  const Timeline = props => {
8
8
  return (() => {
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(--primary-color)] ant-bg-white', draggableNode() && 'child[]:ant-pointer-events-none'),
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(--active-bg-color)]', 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(--primary-color)] 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(--primary-color)]");
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
- /// <reference types="react" />
2
- export type { UploadFile } from 'antd/es/upload';
3
- declare const Upload: import("solid-js").Component<Omit<Omit<import("antd").UploadProps<any> & {
4
- children?: import("react").ReactNode;
5
- } & import("react").RefAttributes<any>, "className"> & {
6
- class?: string | undefined;
7
- }, "children"> & {
8
- children?: import("solid-js").JSX.Element;
9
- }>;
10
- export type UploadProps = Parameters<typeof Upload>[0];
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 { replaceChildren, replaceClassName, reactToSolidComponent } from './utils/component.js';
2
- import { Upload as Upload$1 } from 'antd';
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 Upload = replaceChildren(replaceClassName(reactToSolidComponent(Upload$1)));
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 };
package/es/index.js CHANGED
@@ -1,4 +1,4 @@
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';
@@ -22,7 +22,7 @@ export { default as Skeleton } from './Skeleton.js';
22
22
  export { default as Spin } from './Spin.js';
23
23
  export { default as Image } from './Image.js';
24
24
  export { default as Table } from './Table.js';
25
- export { default as Compact } from './Compact.js';
25
+ export { default as Compact } from './Compact/index.js';
26
26
  export { default as Collapse } from './Collapse/index.js';
27
27
  export { default as Empty } from './Empty/index.js';
28
28
  export { default as Segmented } from './Segmented/index.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "antd-solid",
3
- "version": "0.0.11",
3
+ "version": "0.0.12",
4
4
  "description": "",
5
5
  "main": "src/index.ts",
6
6
  "types": "es/index.d.ts",
@@ -0,0 +1,9 @@
1
+ .ant-compact {
2
+ .ant-btn-primary:not(:first-child) {
3
+ border-left: 1px solid white;
4
+ }
5
+ .ant-btn-primary:not(:last-child) {
6
+ border-right: 1px solid white;
7
+
8
+ }
9
+ }
@@ -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' | 'plain'
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(--light-primary-color)] hover:ant-text-[var(--light-primary-color)] active:ant-[border-color:var(--dark-primary-color)] active:ant-text-[var(--dark-primary-color)]',
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
48
  'ant-text-white',
47
49
  danger
48
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)]'
49
- : 'ant-[border:1px_solid_var(--primary-color)] ant-bg-[var(--primary-color)] hover:ant-[border-color:var(--light-primary-color)] hover:ant-bg-[var(--light-primary-color)] active:ant-[border-color:var(--dark-primary-color)] active:ant-bg-[var(--dark-primary-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(--light-primary-color)] hover:ant-text-[var(--light-primary-color)] active:ant-[border-color:var(--dark-primary-color)] active:ant-text-[var(--dark-primary-color)]',
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(--primary-color)] hover:ant-text-[var(--light-primary-color)] active:ant-text-[var(--dark-primary-color)]',
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,15 +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',
84
87
  'focus-visible:ant-[outline:4px_solid_var(--ant-color-primary-border)] focus-visible:ant-[outline-offset:1px]',
85
88
  mergedProps.class,
86
89
  sizeClassMap[mergedProps.size!],
87
90
  typeClassMap[mergedProps.type!](props.danger ?? false),
88
91
  loading() && 'ant-opacity-65',
89
- 'ant-[--color:--light-primary-color]',
92
+ 'ant-[--color:--ant-color-primary-hover]',
93
+ Compact.compactItemRounded0Class,
94
+ Compact.compactItemZIndexClass,
95
+ Compact.compactItemClass,
90
96
  )}
91
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
92
101
  onClick={e => {
93
102
  const res = mergedProps.onClick?.(e)
94
103
  if (res instanceof Promise) {
@@ -105,7 +114,7 @@ const Button: Component<ButtonProps> = props => {
105
114
  div.className = cs(
106
115
  props.danger
107
116
  ? 'ant-[--color:var(--light-error-color)]'
108
- : 'ant-[--color:var(--light-primary-color)]',
117
+ : 'ant-[--color:var(--ant-color-primary-hover)]',
109
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]',
110
119
  )
111
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
@@ -179,8 +179,7 @@ const Drawer: Component<DrawerProps> = _props => {
179
179
  <Show when={props.closeIcon !== false}>
180
180
  <Button
181
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)]"
182
+ 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)] !ant-p-0"
184
183
  onClick={() => {
185
184
  instance?.close()
186
185
  }}
@@ -1,16 +1,21 @@
1
- import { type Component } from 'solid-js'
1
+ import { type Component, type JSX } from 'solid-js'
2
2
  import PRESENTED_IMAGE_SIMPLE from './PRESENTED_IMAGE_SIMPLE'
3
3
  import EmptySvg from './assets/EmptySvg'
4
4
 
5
- const Empty: Component & {
5
+ export interface EmptyProps {
6
+ class?: string
7
+ style?: JSX.CSSProperties
8
+ }
9
+
10
+ const Empty: Component<EmptyProps> & {
6
11
  PRESENTED_IMAGE_SIMPLE: Component
7
- } = () => {
12
+ } = props => {
8
13
  return (
9
- <div>
10
- <div class='ant-mb-[var(--ant-margin-xs)] ant-flex ant-justify-center'>
14
+ <div {...props} style={props.style}>
15
+ <div class="ant-mb-[var(--ant-margin-xs)] ant-flex ant-justify-center">
11
16
  <EmptySvg />
12
17
  </div>
13
- <div class='ant-text-[var(--ant-color-text)] ant-text-center'>暂无数据</div>
18
+ <div class="ant-text-[var(--ant-color-text)] ant-text-center">暂无数据</div>
14
19
  </div>
15
20
  )
16
21
  }