antd-solid 0.0.24 → 0.0.26

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 {
@@ -28,16 +28,16 @@ const Checkbox = props => {
28
28
  _el$2 = _el$.firstChild;
29
29
  _el$2.addEventListener("change", e => {
30
30
  if (props.disabled) return;
31
- e.target.checked = setChecked(v => !v);
31
+ e.target.checked = props.indeterminate ? setChecked(true) : setChecked(v => !v);
32
32
  props.onChange?.(e);
33
33
  });
34
34
  effect(() => className(_el$, cs('w-16px h-16px rounded-[var(--ant-border-radius-sm)] relative', (() => {
35
- if (checked()) {
36
- return ['after:content-empty after:block after:absolute after:top-[calc(50%-1px)] after:left-1/2 after:-translate-1/2 after:-rotate-45 after:w-10px after:h-6px', 'after:border-solid after:border-2px after:border-t-0px after:border-r-0px', props.disabled ? 'bg-[var(--ant-color-bg-container-disabled)] [border:1px_solid_var(--ant-color-border)] after:border-[var(--ant-color-text-disabled)]' : 'bg-[var(--ant-color-primary)] after:border-white'];
37
- }
38
35
  if (props.indeterminate) {
39
36
  return ['[border:1px_solid_var(--ant-color-border)]', 'after:content-empty after:block after:absolute after:top-1/2 after:left-1/2 after:-translate-1/2 after:w-8px after:h-8px', props.disabled ? 'after:bg-[var(--ant-color-text-disabled)]' : 'after:bg-[var(--ant-color-primary)]'];
40
37
  }
38
+ if (checked()) {
39
+ return ['after:content-empty after:block after:absolute after:top-[calc(50%-1px)] after:left-1/2 after:-translate-1/2 after:-rotate-45 after:w-10px after:h-6px', 'after:border-solid after:border-2px after:border-t-0px after:border-r-0px', props.disabled ? 'bg-[var(--ant-color-bg-container-disabled)] [border:1px_solid_var(--ant-color-border)] after:border-[var(--ant-color-text-disabled)]' : 'bg-[var(--ant-color-primary)] after:border-white'];
40
+ }
41
41
  return ['[border:1px_solid_var(--ant-color-border)]', props.disabled ? 'bg-[var(--ant-color-bg-container-disabled)]' : 'bg-[--ant-color-bg-container]'];
42
42
  })())));
43
43
  return _el$;
@@ -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
  }
@@ -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, {
@@ -10,7 +10,7 @@ var _tmpl$ = /*#__PURE__*/template(`<label class=mr-4px>`),
10
10
  _tmpl$2 = /*#__PURE__*/template(`<span class=text-[var(--ant-color-error)]>*`),
11
11
  _tmpl$3 = /*#__PURE__*/template(`<div class="flex items-center"><label>`),
12
12
  _tmpl$4 = /*#__PURE__*/template(`<div class="absolute top-[100%] text-[var(--ant-color-error)]">`),
13
- _tmpl$5 = /*#__PURE__*/template(`<div class="flex flex-col relative flex-grow-1"><div>`);
13
+ _tmpl$5 = /*#__PURE__*/template(`<div class="flex flex-col relative flex-grow-1"><div class=flex>`);
14
14
  const FormItem = props => {
15
15
  const {
16
16
  formInstance,
@@ -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() {
@@ -22,7 +22,7 @@ function createControllableValue(props, options = {}) {
22
22
  const setValue = v => {
23
23
  const _value = untrack(value);
24
24
  const newValue = typeof v === 'function' ? v(_value) : v;
25
- if (newValue === _value) return;
25
+ if (newValue === _value) return newValue;
26
26
  if (!isControlled()) {
27
27
  _setValue(newValue);
28
28
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "antd-solid",
3
- "version": "0.0.24",
3
+ "version": "0.0.26",
4
4
  "description": "",
5
5
  "main": "dist/index.esm.js",
6
6
  "module": "es/index.js",