antd-solid 0.0.23 → 0.0.25

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.
@@ -1,11 +1,12 @@
1
1
  import { createComponent, mergeProps as mergeProps$1, insert, memo, spread, template } from 'solid-js/web';
2
- import { mergeProps, splitProps, createSignal, createMemo, children, Show } from 'solid-js';
2
+ import { mergeProps, splitProps, createSignal, createMemo, children, useContext, Show } from 'solid-js';
3
3
  import cs from 'classnames';
4
4
  import './index.scss.js';
5
5
  import { wave } from '../utils/animation.js';
6
6
  import Element from '../Element/index.js';
7
7
  import useComponentSize from '../hooks/useComponentSize.js';
8
8
  import { unwrapStringOrJSXElement } from '../utils/solid.js';
9
+ import CompactContext from '../Compact/context.js';
9
10
 
10
11
  var _tmpl$ = /*#__PURE__*/template(`<span class="i-ant-design:loading [vertical-align:-0.125em] keyframes-spin [animation:spin_1s_linear_infinite]">`),
11
12
  _tmpl$2 = /*#__PURE__*/template(`<span>`),
@@ -38,6 +39,9 @@ const Button = _props => {
38
39
  const loading = createMemo(() => typeof props.loading === 'boolean' ? props.loading : innerLoading());
39
40
  const resolvedChildren = children(() => props.children);
40
41
  const resolvedIcon = children(() => unwrapStringOrJSXElement(props.icon));
42
+ const {
43
+ compact
44
+ } = useContext(CompactContext);
41
45
  return createComponent(Element, mergeProps$1({
42
46
  tag: "button"
43
47
  }, buttonElementProps, {
@@ -46,7 +50,7 @@ const Button = _props => {
46
50
  typeof _ref$ === "function" ? _ref$(r$) : props.ref = r$;
47
51
  },
48
52
  get ["class"]() {
49
- return cs(`ant-btn ant-btn-${props.type}`, 'inline-flex justify-center items-center gap-8px', 'relative cursor-pointer [font-size:var(--ant-font-size)] rounded-[--ant-button-border-radius]', 'focus-visible:[outline:4px_solid_var(--ant-color-primary-border)] focus-visible:[outline-offset:1px]', props.block && 'block w-full', props.class, sizeClassMap[size()], props.disabled && 'cursor-not-allowed', typeClassMap[props.type](props.danger, props.disabled), loading() && 'opacity-65');
53
+ return cs(`ant-btn ant-btn-${props.type}`, 'inline-flex justify-center items-center gap-8px', 'relative cursor-pointer [font-size:var(--ant-font-size)] rounded-[--ant-button-border-radius]', 'focus-visible:[outline:4px_solid_var(--ant-color-primary-border)] focus-visible:[outline-offset:1px]', props.block && 'block w-full', props.class, sizeClassMap[size()], props.disabled && 'cursor-not-allowed', typeClassMap[props.type](props.danger, props.disabled), loading() && 'opacity-65', compact && 'ant-compact-item');
50
54
  },
51
55
  get style() {
52
56
  return {
@@ -48,7 +48,8 @@ const CodeInput = _props => {
48
48
  ref: el => {
49
49
  inputRefDict[item] = el;
50
50
  },
51
- "class": "!w-32px !text-center",
51
+ rootClass: "!w-32px",
52
+ "class": "!text-center",
52
53
  get value() {
53
54
  return value()[item];
54
55
  },
@@ -10,7 +10,7 @@ import useComponentSize from '../hooks/useComponentSize.js';
10
10
  import { getElementClass, getElementCssVariables } from './utils.js';
11
11
 
12
12
  var _tmpl$ = /*#__PURE__*/template(`<span>`),
13
- _tmpl$2 = /*#__PURE__*/template(`<div><span class="inline-flex items-center gap-[--ant-margin-sm]"></span><span class="inline-flex items-center gap-[--ant-margin-sm]">`),
13
+ _tmpl$2 = /*#__PURE__*/template(`<div><span class="inline-flex items-center gap-[--ant-margin-sm]"><span></span></span><span class="inline-flex items-center gap-[--ant-margin-sm]"><span>`),
14
14
  _tmpl$3 = /*#__PURE__*/template(`<div class=overflow-hidden><div>`);
15
15
  const CollapseItem = _props => {
16
16
  const props = mergeProps({
@@ -58,16 +58,18 @@ const CollapseItem = _props => {
58
58
  return [(() => {
59
59
  var _el$2 = _tmpl$2(),
60
60
  _el$3 = _el$2.firstChild,
61
- _el$4 = _el$3.nextSibling;
61
+ _el$4 = _el$3.firstChild,
62
+ _el$5 = _el$3.nextSibling,
63
+ _el$6 = _el$5.firstChild;
62
64
  _el$2.$$click = () => {
63
65
  if (props.disabledChildren) return;
64
66
  setOpen(!open());
65
67
  };
66
- insert(_el$3, () => getExpandIcon('left'), null);
67
- insert(_el$3, () => unwrapStringOrJSXElement(props.label), null);
68
+ insert(_el$3, () => getExpandIcon('left'), _el$4);
69
+ insert(_el$4, () => unwrapStringOrJSXElement(props.label));
68
70
  insert(_el$3, () => getExpandIcon('right'), null);
69
- insert(_el$4, () => unwrapStringOrJSXElement(props.extra), null);
70
- insert(_el$4, () => getExpandIcon('end'), null);
71
+ insert(_el$6, () => unwrapStringOrJSXElement(props.extra));
72
+ insert(_el$5, () => getExpandIcon('end'), null);
71
73
  effect(_p$ => {
72
74
  var _v$ = cs('text-[--ant-color-text-heading] flex justify-between items-center cursor-pointer', props.type === 'card' && 'bg-[var(--ant-collapse-header-bg)] p-[--ant-collapse-header-padding]'),
73
75
  _v$2 = props.headerStyle;
@@ -104,20 +106,20 @@ const CollapseItem = _props => {
104
106
  return open();
105
107
  },
106
108
  get children() {
107
- var _el$5 = _tmpl$3(),
108
- _el$6 = _el$5.firstChild;
109
- insert(_el$6, () => props.children);
109
+ var _el$7 = _tmpl$3(),
110
+ _el$8 = _el$7.firstChild;
111
+ insert(_el$8, () => props.children);
110
112
  effect(_p$ => {
111
113
  var _v$3 = cs('p-[--ant-collapse-content-padding]', props.type === 'card' && '[border-top:1px_solid_var(--ant-color-border)]'),
112
114
  _v$4 = props.bodyStyle;
113
- _v$3 !== _p$.e && className(_el$6, _p$.e = _v$3);
114
- _p$.t = style(_el$6, _v$4, _p$.t);
115
+ _v$3 !== _p$.e && className(_el$8, _p$.e = _v$3);
116
+ _p$.t = style(_el$8, _v$4, _p$.t);
115
117
  return _p$;
116
118
  }, {
117
119
  e: undefined,
118
120
  t: undefined
119
121
  });
120
- return _el$5;
122
+ return _el$7;
121
123
  }
122
124
  });
123
125
  }
@@ -49,7 +49,7 @@ const ColorPicker = props => {
49
49
  var _el$ = _tmpl$(),
50
50
  _el$2 = _el$.firstChild;
51
51
  _el$2.$$click = () => {
52
- setColor(new Color());
52
+ setColor(new Color(), true);
53
53
  close();
54
54
  };
55
55
  return _el$;
@@ -7,6 +7,7 @@ export interface CursorIntance {
7
7
  export interface CursorProps extends ParentProps {
8
8
  ref?: Ref<CursorIntance>;
9
9
  cursor: JSX.Element;
10
+ disabled?: boolean;
10
11
  }
11
12
  declare function createCursor(props: CursorProps): {
12
13
  dispose: () => void;
@@ -29,12 +29,13 @@ const Cursor = props => {
29
29
  _children.style.cursor = 'none';
30
30
  };
31
31
  const onMouseMove = e => {
32
+ setHover(true);
32
33
  setCursorPosition({
33
34
  x: e.clientX,
34
35
  y: e.clientY
35
36
  });
36
37
  };
37
- const onMouseLeave = (_, _children) => {
38
+ const onLeave = _children => {
38
39
  setHover(false);
39
40
  if (originalCursor) {
40
41
  _children.style.cursor = originalCursor;
@@ -43,33 +44,36 @@ const Cursor = props => {
43
44
  }
44
45
  originalCursor = undefined;
45
46
  };
47
+ const onMouseLeave = (_, _children) => {
48
+ onLeave(_children);
49
+ };
46
50
  setRef(props, {
47
51
  onMouseEnter,
48
52
  onMouseMove,
49
53
  onMouseLeave
50
54
  });
51
55
  createEffect(() => {
56
+ if (props.disabled) return;
52
57
  const _children = resolvedChildren();
53
58
  if (!(_children instanceof HTMLElement || _children instanceof SVGElement)) return;
54
59
  const abortController = new AbortController();
60
+ // 注意:不能设置 capture 为 true,否则鼠标移入子元素时,子元素也会触发 mouseenter 事件
55
61
  _children.addEventListener('mouseenter', e => {
56
62
  onMouseEnter(e, _children);
57
63
  }, {
58
- capture: true,
59
64
  signal: abortController.signal
60
65
  });
61
66
  _children.addEventListener('mousemove', onMouseMove, {
62
- capture: true,
63
67
  signal: abortController.signal
64
68
  });
65
69
  _children.addEventListener('mouseleave', e => {
66
70
  onMouseLeave(e, _children);
67
71
  }, {
68
- capture: true,
69
72
  signal: abortController.signal
70
73
  });
71
74
  onCleanup(() => {
72
75
  abortController.abort();
76
+ onLeave(_children);
73
77
  });
74
78
  });
75
79
  return [resolvedChildren, createComponent(Show, {
@@ -45,12 +45,13 @@ const Slider = _props => {
45
45
  case 'ArrowDown':
46
46
  e.preventDefault();
47
47
  setValue(NP.minus(value(), props.step));
48
+ props.onChangeComplete?.(value());
48
49
  break;
49
50
  case 'ArrowRight':
50
51
  case 'ArrowUp':
51
52
  e.preventDefault();
52
53
  setValue(NP.plus(value(), props.step));
53
- e.preventDefault();
54
+ props.onChangeComplete?.(value());
54
55
  break;
55
56
  }
56
57
  };
@@ -91,6 +92,7 @@ const Slider = _props => {
91
92
  const halfHandleWidth = handleWidth / 2;
92
93
  const offsetX = clamp(e.offsetX - halfHandleWidth, 0, containerRef.offsetWidth - handleWidth);
93
94
  setValue(props.min + offsetX / (containerRef.offsetWidth - handleWidth) * gap());
95
+ props.onChangeComplete?.(value());
94
96
  };
95
97
  insert(_el$4, createComponent(Tooltip, {
96
98
  get open() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "antd-solid",
3
- "version": "0.0.23",
3
+ "version": "0.0.25",
4
4
  "description": "",
5
5
  "main": "dist/index.esm.js",
6
6
  "module": "es/index.js",