antd-solid 0.0.24 → 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.
package/dist/index.esm.js CHANGED
@@ -570,6 +570,10 @@ function isEmptyJSXElement(element) {
570
570
  return element === undefined || element === null || typeof element === 'boolean' || element === '' || Array.isArray(element) && element.length === 0;
571
571
  }
572
572
 
573
+ const CompactContext = createContext({
574
+ compact: false
575
+ });
576
+
573
577
  var _tmpl$$O = /*#__PURE__*/template(`<span class="i-ant-design:loading [vertical-align:-0.125em] keyframes-spin [animation:spin_1s_linear_infinite]">`),
574
578
  _tmpl$2$v = /*#__PURE__*/template(`<span>`),
575
579
  _tmpl$3$k = /*#__PURE__*/template(`<span class="inline-block leading-inherit">`);
@@ -601,6 +605,9 @@ const Button$1 = _props => {
601
605
  const loading = createMemo(() => typeof props.loading === 'boolean' ? props.loading : innerLoading());
602
606
  const resolvedChildren = children(() => props.children);
603
607
  const resolvedIcon = children(() => unwrapStringOrJSXElement(props.icon));
608
+ const {
609
+ compact
610
+ } = useContext(CompactContext);
604
611
  return createComponent(Element$1, mergeProps$1({
605
612
  tag: "button"
606
613
  }, buttonElementProps, {
@@ -609,7 +616,7 @@ const Button$1 = _props => {
609
616
  typeof _ref$ === "function" ? _ref$(r$) : props.ref = r$;
610
617
  },
611
618
  get ["class"]() {
612
- 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');
619
+ 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');
613
620
  },
614
621
  get style() {
615
622
  return {
@@ -807,10 +814,6 @@ const TextArea = props => {
807
814
  var css_248z$4 = ".ant-input-group > :first-child {\n border-top-left-radius: var(--ant-input-border-radius);\n border-bottom-left-radius: var(--ant-input-border-radius);\n}\n.ant-input-group > :last-child {\n border-top-right-radius: var(--ant-input-border-radius);\n border-bottom-right-radius: var(--ant-input-border-radius);\n}\n\n.ant-compact > :not(:first-child).ant-input-group.ant-compact-item > :first-child, .ant-compact > :not(:first-child) .ant-input-group.ant-compact-item > :first-child {\n border-top-left-radius: 0px;\n border-bottom-left-radius: 0px;\n}\n.ant-compact > :not(:last-child).ant-input-group.ant-compact-item > :last-child, .ant-compact > :not(:last-child) .ant-input-group.ant-compact-item > :last-child {\n border-top-right-radius: 0px;\n border-bottom-right-radius: 0px;\n}";
808
815
  styleInject(css_248z$4);
809
816
 
810
- const CompactContext = createContext({
811
- compact: false
812
- });
813
-
814
817
  var _tmpl$$M = /*#__PURE__*/template(`<div>`),
815
818
  _tmpl$2$u = /*#__PURE__*/template(`<span class="ml-4px i-ant-design:close-circle-filled cursor-pointer text-[var(--ant-color-text-quaternary)] hover:text-[var(--ant-color-text-tertiary)] active:text-[var(--ant-color-text)]">`),
816
819
  _tmpl$3$j = /*#__PURE__*/template(`<div class="[display:var(--actions-display)] absolute top-0 bottom-0 right-0 h-[calc(100%-2px)] translate-y-1px -translate-x-1px">`),
@@ -3679,12 +3682,13 @@ const Slider = _props => {
3679
3682
  case 'ArrowDown':
3680
3683
  e.preventDefault();
3681
3684
  setValue(NP.minus(value(), props.step));
3685
+ props.onChangeComplete?.(value());
3682
3686
  break;
3683
3687
  case 'ArrowRight':
3684
3688
  case 'ArrowUp':
3685
3689
  e.preventDefault();
3686
3690
  setValue(NP.plus(value(), props.step));
3687
- e.preventDefault();
3691
+ props.onChangeComplete?.(value());
3688
3692
  break;
3689
3693
  }
3690
3694
  };
@@ -3725,6 +3729,7 @@ const Slider = _props => {
3725
3729
  const halfHandleWidth = handleWidth / 2;
3726
3730
  const offsetX = clamp(e.offsetX - halfHandleWidth, 0, containerRef.offsetWidth - handleWidth);
3727
3731
  setValue(props.min + offsetX / (containerRef.offsetWidth - handleWidth) * gap());
3732
+ props.onChangeComplete?.(value());
3728
3733
  };
3729
3734
  insert(_el$4, createComponent(Tooltip, {
3730
3735
  get open() {
@@ -5698,7 +5703,7 @@ function getElementCssVariables(type, size) {
5698
5703
  }
5699
5704
 
5700
5705
  var _tmpl$$a = /*#__PURE__*/template(`<span>`),
5701
- _tmpl$2$3 = /*#__PURE__*/template(`<div><span class="inline-flex items-center gap-[--ant-margin-sm]"></span><span class="inline-flex items-center gap-[--ant-margin-sm]">`),
5706
+ _tmpl$2$3 = /*#__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>`),
5702
5707
  _tmpl$3$3 = /*#__PURE__*/template(`<div class=overflow-hidden><div>`);
5703
5708
  const CollapseItem = _props => {
5704
5709
  const props = mergeProps({
@@ -5746,16 +5751,18 @@ const CollapseItem = _props => {
5746
5751
  return [(() => {
5747
5752
  var _el$2 = _tmpl$2$3(),
5748
5753
  _el$3 = _el$2.firstChild,
5749
- _el$4 = _el$3.nextSibling;
5754
+ _el$4 = _el$3.firstChild,
5755
+ _el$5 = _el$3.nextSibling,
5756
+ _el$6 = _el$5.firstChild;
5750
5757
  _el$2.$$click = () => {
5751
5758
  if (props.disabledChildren) return;
5752
5759
  setOpen(!open());
5753
5760
  };
5754
- insert(_el$3, () => getExpandIcon('left'), null);
5755
- insert(_el$3, () => unwrapStringOrJSXElement(props.label), null);
5761
+ insert(_el$3, () => getExpandIcon('left'), _el$4);
5762
+ insert(_el$4, () => unwrapStringOrJSXElement(props.label));
5756
5763
  insert(_el$3, () => getExpandIcon('right'), null);
5757
- insert(_el$4, () => unwrapStringOrJSXElement(props.extra), null);
5758
- insert(_el$4, () => getExpandIcon('end'), null);
5764
+ insert(_el$6, () => unwrapStringOrJSXElement(props.extra));
5765
+ insert(_el$5, () => getExpandIcon('end'), null);
5759
5766
  effect(_p$ => {
5760
5767
  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]'),
5761
5768
  _v$2 = props.headerStyle;
@@ -5792,20 +5799,20 @@ const CollapseItem = _props => {
5792
5799
  return open();
5793
5800
  },
5794
5801
  get children() {
5795
- var _el$5 = _tmpl$3$3(),
5796
- _el$6 = _el$5.firstChild;
5797
- insert(_el$6, () => props.children);
5802
+ var _el$7 = _tmpl$3$3(),
5803
+ _el$8 = _el$7.firstChild;
5804
+ insert(_el$8, () => props.children);
5798
5805
  effect(_p$ => {
5799
5806
  var _v$3 = cs('p-[--ant-collapse-content-padding]', props.type === 'card' && '[border-top:1px_solid_var(--ant-color-border)]'),
5800
5807
  _v$4 = props.bodyStyle;
5801
- _v$3 !== _p$.e && className(_el$6, _p$.e = _v$3);
5802
- _p$.t = style(_el$6, _v$4, _p$.t);
5808
+ _v$3 !== _p$.e && className(_el$8, _p$.e = _v$3);
5809
+ _p$.t = style(_el$8, _v$4, _p$.t);
5803
5810
  return _p$;
5804
5811
  }, {
5805
5812
  e: undefined,
5806
5813
  t: undefined
5807
5814
  });
5808
- return _el$5;
5815
+ return _el$7;
5809
5816
  }
5810
5817
  });
5811
5818
  }
@@ -7368,12 +7375,13 @@ const Cursor = props => {
7368
7375
  _children.style.cursor = 'none';
7369
7376
  };
7370
7377
  const onMouseMove = e => {
7378
+ setHover(true);
7371
7379
  setCursorPosition({
7372
7380
  x: e.clientX,
7373
7381
  y: e.clientY
7374
7382
  });
7375
7383
  };
7376
- const onMouseLeave = (_, _children) => {
7384
+ const onLeave = _children => {
7377
7385
  setHover(false);
7378
7386
  if (originalCursor) {
7379
7387
  _children.style.cursor = originalCursor;
@@ -7382,33 +7390,36 @@ const Cursor = props => {
7382
7390
  }
7383
7391
  originalCursor = undefined;
7384
7392
  };
7393
+ const onMouseLeave = (_, _children) => {
7394
+ onLeave(_children);
7395
+ };
7385
7396
  setRef(props, {
7386
7397
  onMouseEnter,
7387
7398
  onMouseMove,
7388
7399
  onMouseLeave
7389
7400
  });
7390
7401
  createEffect(() => {
7402
+ if (props.disabled) return;
7391
7403
  const _children = resolvedChildren();
7392
7404
  if (!(_children instanceof HTMLElement || _children instanceof SVGElement)) return;
7393
7405
  const abortController = new AbortController();
7406
+ // 注意:不能设置 capture 为 true,否则鼠标移入子元素时,子元素也会触发 mouseenter 事件
7394
7407
  _children.addEventListener('mouseenter', e => {
7395
7408
  onMouseEnter(e, _children);
7396
7409
  }, {
7397
- capture: true,
7398
7410
  signal: abortController.signal
7399
7411
  });
7400
7412
  _children.addEventListener('mousemove', onMouseMove, {
7401
- capture: true,
7402
7413
  signal: abortController.signal
7403
7414
  });
7404
7415
  _children.addEventListener('mouseleave', e => {
7405
7416
  onMouseLeave(e, _children);
7406
7417
  }, {
7407
- capture: true,
7408
7418
  signal: abortController.signal
7409
7419
  });
7410
7420
  onCleanup(() => {
7411
7421
  abortController.abort();
7422
+ onLeave(_children);
7412
7423
  });
7413
7424
  });
7414
7425
  return [resolvedChildren, createComponent(Show, {