antd-solid 0.0.34 → 0.0.35

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
@@ -592,7 +592,7 @@ const CompactContext = createContext({
592
592
  });
593
593
 
594
594
  var _tmpl$$Q = /*#__PURE__*/template(`<span class="i-ant-design:loading [vertical-align:-0.125em] keyframes-spin [animation:spin_1s_linear_infinite]">`),
595
- _tmpl$2$w = /*#__PURE__*/template(`<span>`),
595
+ _tmpl$2$x = /*#__PURE__*/template(`<span>`),
596
596
  _tmpl$3$l = /*#__PURE__*/template(`<span class="inline-block leading-inherit">`);
597
597
  const sizeClassMap = {
598
598
  large: 'px-15px py-7px h-40px leading-24px',
@@ -683,7 +683,7 @@ const Button$1 = _props => {
683
683
  return memo(() => !!resolvedChildren())() && !(props.hideChildrenWhenLoading && loading());
684
684
  },
685
685
  get children() {
686
- var _el$2 = _tmpl$2$w();
686
+ var _el$2 = _tmpl$2$x();
687
687
  spread(_el$2, mergeProps$1(() => props.contentHTMLAttributes, {
688
688
  get ["class"]() {
689
689
  return cs('inline-block leading-inherit', props.contentHTMLAttributes?.class);
@@ -839,7 +839,7 @@ var css_248z$4 = ".ant-input-group > :first-child {\n border-top-left-radius: v
839
839
  styleInject(css_248z$4);
840
840
 
841
841
  var _tmpl$$O = /*#__PURE__*/template(`<div>`),
842
- _tmpl$2$v = /*#__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)]">`),
842
+ _tmpl$2$w = /*#__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)]">`),
843
843
  _tmpl$3$k = /*#__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">`),
844
844
  _tmpl$4$e = /*#__PURE__*/template(`<div><input>`);
845
845
  const statusClassDict$1 = {
@@ -1001,7 +1001,7 @@ function CommonInput(props) {
1001
1001
  return showClearBtn();
1002
1002
  },
1003
1003
  get children() {
1004
- var _el$5 = _tmpl$2$v();
1004
+ var _el$5 = _tmpl$2$w();
1005
1005
  _el$5.$$click = e => {
1006
1006
  e.stopPropagation();
1007
1007
  inputRef.value = '';
@@ -1179,7 +1179,7 @@ const InputNumber = _props => {
1179
1179
  delegateEvents(["click"]);
1180
1180
 
1181
1181
  var _tmpl$$M = /*#__PURE__*/template(`<div class="flex relative"><div class="w-[10px] h-[10px] border-solid border-width-[3px] border-[var(--ant-color-primary)] bg-white rounded-[50%] mt-[8px]"></div><div class=ml-[8px]>`),
1182
- _tmpl$2$u = /*#__PURE__*/template(`<div class="absolute top-[8px] bottom-[-24px] left-[4px] w-[2px] bg-[rgba(5,5,5,.06)]">`);
1182
+ _tmpl$2$v = /*#__PURE__*/template(`<div class="absolute top-[8px] bottom-[-24px] left-[4px] w-[2px] bg-[rgba(5,5,5,.06)]">`);
1183
1183
  const Timeline = props => {
1184
1184
  return createComponent(Element$1, {
1185
1185
  "class": "flex flex-col gap-[16px]",
@@ -1194,7 +1194,7 @@ const Timeline = props => {
1194
1194
  _el$3 = _el$2.nextSibling;
1195
1195
  insert(_el$, (() => {
1196
1196
  var _c$ = memo(() => i() !== props.items.length - 1);
1197
- return () => _c$() && _tmpl$2$u();
1197
+ return () => _c$() && _tmpl$2$v();
1198
1198
  })(), _el$2);
1199
1199
  insert(_el$3, () => item.children?.());
1200
1200
  return _el$;
@@ -1271,7 +1271,7 @@ function createTransition(target, when, props = {}) {
1271
1271
  }
1272
1272
 
1273
1273
  var _tmpl$$L = /*#__PURE__*/template(`<div class="flex items-center gap-12px"><span class="i-ant-design:exclamation-circle text-22px text-[var(--ant-color-warning)] shrink-0">`),
1274
- _tmpl$2$t = /*#__PURE__*/template(`<div class=ml-34px>`);
1274
+ _tmpl$2$u = /*#__PURE__*/template(`<div class=ml-34px>`);
1275
1275
  function useModal() {
1276
1276
  const [open, setOpen] = createSignal(false);
1277
1277
  const [modalProps, setModalProps] = createSignal({});
@@ -1296,7 +1296,7 @@ function useModal() {
1296
1296
  },
1297
1297
  get children() {
1298
1298
  return (() => {
1299
- var _el$3 = _tmpl$2$t();
1299
+ var _el$3 = _tmpl$2$u();
1300
1300
  insert(_el$3, () => modalProps().children);
1301
1301
  return _el$3;
1302
1302
  })();
@@ -1317,7 +1317,7 @@ function useModal() {
1317
1317
  }
1318
1318
 
1319
1319
  var _tmpl$$K = /*#__PURE__*/template(`<div class="flex items-center gap-12px"><span class="i-ant-design:exclamation-circle text-22px text-[var(--ant-color-warning)] shrink-0">`),
1320
- _tmpl$2$s = /*#__PURE__*/template(`<div class=ml-34px>`);
1320
+ _tmpl$2$t = /*#__PURE__*/template(`<div class=ml-34px>`);
1321
1321
  function warning$1(props) {
1322
1322
  const div = document.createElement('div');
1323
1323
  document.body.appendChild(div);
@@ -1336,7 +1336,7 @@ function warning$1(props) {
1336
1336
  },
1337
1337
  get children() {
1338
1338
  return (() => {
1339
- var _el$3 = _tmpl$2$s();
1339
+ var _el$3 = _tmpl$2$t();
1340
1340
  insert(_el$3, () => props.children);
1341
1341
  return _el$3;
1342
1342
  })();
@@ -1363,7 +1363,7 @@ function useLocale() {
1363
1363
  }
1364
1364
 
1365
1365
  var _tmpl$$J = /*#__PURE__*/template(`<div aria-label=mask>`),
1366
- _tmpl$2$r = /*#__PURE__*/template(`<span class=i-ant-design:close-outlined>`),
1366
+ _tmpl$2$s = /*#__PURE__*/template(`<span class=i-ant-design:close-outlined>`),
1367
1367
  _tmpl$3$j = /*#__PURE__*/template(`<div class="inline-flex gap-8px">`),
1368
1368
  _tmpl$4$d = /*#__PURE__*/template(`<div class="mt-12px text-right">`),
1369
1369
  _tmpl$5$9 = /*#__PURE__*/template(`<div class="ant-modal-wrap z-1000 fixed inset-0 overflow-auto pointer-events-none"><div><div class="text-[var(--ant-modal-title-color)] text-16px font-600 mb-8px"></div><div class=grow>`);
@@ -1501,7 +1501,7 @@ const Modal = _props => {
1501
1501
  props.onCancel?.();
1502
1502
  },
1503
1503
  get children() {
1504
- return _tmpl$2$r();
1504
+ return _tmpl$2$s();
1505
1505
  }
1506
1506
  });
1507
1507
  }
@@ -1588,7 +1588,7 @@ var css_248z$2 = ".ant-drawer-content-right {\n top: 0;\n bottom: 0;\n right:
1588
1588
  styleInject(css_248z$2);
1589
1589
 
1590
1590
  var _tmpl$$I = /*#__PURE__*/template(`<div aria-label=mask>`),
1591
- _tmpl$2$q = /*#__PURE__*/template(`<span class=i-ant-design:close-outlined>`),
1591
+ _tmpl$2$r = /*#__PURE__*/template(`<span class=i-ant-design:close-outlined>`),
1592
1592
  _tmpl$3$i = /*#__PURE__*/template(`<div class="w-full text-[var(--ant-color-text)] text-size-[var(--ant-font-size-lg)] [font-weight:var(--ant-font-weight-strong)] leading-[var(--ant-line-height-lg)]">`),
1593
1593
  _tmpl$4$c = /*#__PURE__*/template(`<div class=shrink-0>`),
1594
1594
  _tmpl$5$8 = /*#__PURE__*/template(`<div><div class="px-[var(--ant-padding-lg)] py-[var(--ant-padding)] flex items-center [border-bottom:var(--ant-line-width)_solid_var(--ant-color-split)] empty:hidden"></div><div class="p-[--ant-drawer-body-padding] overflow-auto">`);
@@ -1716,7 +1716,7 @@ const Drawer = _props => {
1716
1716
  props.onClose?.();
1717
1717
  },
1718
1718
  get children() {
1719
- return _tmpl$2$q();
1719
+ return _tmpl$2$r();
1720
1720
  }
1721
1721
  });
1722
1722
  }
@@ -1810,9 +1810,13 @@ function useClickAway(onClickAway, target) {
1810
1810
  onClickAway(event);
1811
1811
  }
1812
1812
  };
1813
- window.addEventListener('click', onClick);
1813
+ window.addEventListener('click', onClick, {
1814
+ capture: true
1815
+ });
1814
1816
  onCleanup(() => {
1815
- window.removeEventListener('click', onClick);
1817
+ window.removeEventListener('click', onClick, {
1818
+ capture: true
1819
+ });
1816
1820
  });
1817
1821
  }
1818
1822
 
@@ -1877,7 +1881,8 @@ function useHover(target) {
1877
1881
 
1878
1882
  const TooltipContext = createContext();
1879
1883
 
1880
- var _tmpl$$H = /*#__PURE__*/template(`<div>`);
1884
+ var _tmpl$$H = /*#__PURE__*/template(`<div>`),
1885
+ _tmpl$2$q = /*#__PURE__*/template(`<div class=relative><div>`);
1881
1886
  const unwrapContent = (content, close) => {
1882
1887
  return typeof content === 'function' ? content(close) : content;
1883
1888
  };
@@ -2005,7 +2010,6 @@ const getMinorPlacement = placement => {
2005
2010
  }
2006
2011
  return minorPlacement;
2007
2012
  };
2008
- // TODO 超出范围滚动
2009
2013
  const Tooltip = _props => {
2010
2014
  const props = mergeProps({
2011
2015
  trigger: 'hover',
@@ -2100,7 +2104,9 @@ const Tooltip = _props => {
2100
2104
  _children.addEventListener('click', reverseOpen, {
2101
2105
  signal: abortController.signal
2102
2106
  });
2103
- useClickAway(hide, () => compact([...Object.values(subPopupElements()), contentRef(), _children]));
2107
+ useClickAway(() => {
2108
+ hide();
2109
+ }, () => compact([...Object.values(subPopupElements()), contentRef(), _children]));
2104
2110
  break;
2105
2111
  case 'focus':
2106
2112
  _children.addEventListener('focusin', show, {
@@ -2124,6 +2130,10 @@ const Tooltip = _props => {
2124
2130
  }));
2125
2131
  const [reversedMainPlacement, setReversedMainPlacement] = createSignal('top');
2126
2132
  const [reversedMinorPlacement, setReversedMinorPlacement] = createSignal();
2133
+ const [maxWidth, setMaxWidth] = createSignal();
2134
+ const [maxHeight, setMaxHeight] = createSignal();
2135
+ const [_translateX, setTranslateX] = createSignal(0);
2136
+ const [_translateY, setTranslateY] = createSignal(0);
2127
2137
  const contentSize = useSize(contentRef);
2128
2138
  // 设置 content 显示时的 translate
2129
2139
  createEffect(() => {
@@ -2172,15 +2182,19 @@ const Tooltip = _props => {
2172
2182
  switch (mainPlacement) {
2173
2183
  case 'top':
2174
2184
  translateY = _childrenRect.top - arrowOffset() - defaultOffset - _contentSize.height;
2185
+ setMaxHeight(translateY);
2175
2186
  break;
2176
2187
  case 'bottom':
2177
2188
  translateY = _childrenRect.bottom + arrowOffset() + defaultOffset;
2189
+ setMaxHeight(window.innerHeight - translateY);
2178
2190
  break;
2179
2191
  case 'left':
2180
2192
  translateX = _childrenRect.left - arrowOffset() - defaultOffset - _contentSize.width;
2193
+ setMaxWidth(translateX);
2181
2194
  break;
2182
2195
  case 'right':
2183
2196
  translateX = _childrenRect.right + arrowOffset() + defaultOffset;
2197
+ setMaxWidth(window.innerWidth - translateX);
2184
2198
  break;
2185
2199
  }
2186
2200
  };
@@ -2202,12 +2216,12 @@ const Tooltip = _props => {
2202
2216
  }
2203
2217
  break;
2204
2218
  case 'bottom':
2205
- if (translateY + _contentSize.height > window.innerHeight) {
2219
+ if (translateY > _contentSize.height && translateY + _contentSize.height > window.innerHeight) {
2206
2220
  reverseMainPlacement();
2207
2221
  }
2208
2222
  break;
2209
2223
  case 'left':
2210
- if (translateX + _contentSize.width > window.innerWidth) {
2224
+ if (translateX > _contentSize.width && translateX + _contentSize.width > window.innerWidth) {
2211
2225
  reverseMainPlacement();
2212
2226
  }
2213
2227
  break;
@@ -2257,8 +2271,8 @@ const Tooltip = _props => {
2257
2271
  } else {
2258
2272
  updateTranslateByMainPlacement(mainPlacement);
2259
2273
  }
2260
- _contentRef.style.setProperty('--translate-x', `${translateX}px`);
2261
- _contentRef.style.setProperty('--translate-y', `${translateY}px`);
2274
+ setTranslateX(translateX);
2275
+ setTranslateY(translateY);
2262
2276
  // placement 为 top 和 bottom 时,tooltip 超出可视区域时对 content 进行偏移矫正
2263
2277
  if (props.placement === 'top' || props.placement === 'bottom') {
2264
2278
  let innerTranslateX = 0;
@@ -2298,37 +2312,40 @@ const Tooltip = _props => {
2298
2312
  },
2299
2313
  get children() {
2300
2314
  return createComponent(Element$1, {
2301
- ref: setPopupRef,
2302
2315
  get ["class"]() {
2303
- return cs('z-1000 fixed left-0 top-0 [font-size:var(--ant-font-size)] text-[var(--ant-color-text)] leading-[var(--ant-line-height)]', open() ? 'block' : 'hidden');
2316
+ return cs('z-1000 fixed left-0 top-0 [font-size:var(--ant-font-size)] text-[--ant-color-text] leading-[--ant-line-height] overflow-auto', open() ? 'block' : 'hidden');
2304
2317
  },
2305
- style: {
2306
- transform: 'translate(var(--translate-x), var(--translate-y))'
2318
+ get style() {
2319
+ return {
2320
+ transform: `translate(${_translateX()}px, ${_translateY()}px)`,
2321
+ 'max-width': typeof maxWidth() === 'number' ? `${maxWidth()}px` : undefined,
2322
+ 'max-height': typeof maxHeight() === 'number' ? `${maxHeight()}px` : undefined
2323
+ };
2307
2324
  },
2308
2325
  onClick: e => {
2309
2326
  e.stopPropagation();
2310
2327
  },
2311
2328
  get children() {
2312
- return [(() => {
2313
- var _el$ = _tmpl$$H();
2314
- spread(_el$, mergeProps$1(() => props.contentHTMLAttributes, {
2315
- get ["class"]() {
2316
- return cs(props.contentHTMLAttributes?.class, 'px-8px py-6px [box-shadow:var(--ant-box-shadow)] rounded-[var(--ant-border-radius-lg)] overflow-auto translate-x-[--inner-translate-x] translate-y-[--inner-translate-y]', props.plain ? 'text-[var(--ant-color-text)] bg-[var(--ant-color-bg-container-tertiary)]' : 'text-[var(--ant-color-text-light-solid)] bg-[var(--ant-color-bg-spotlight)]');
2317
- }
2318
- }), false, true);
2319
- insert(_el$, createComponent(TooltipContext.Provider, {
2320
- value: context,
2321
- get children() {
2322
- return unwrapContent(props.content, () => setOpen(false));
2323
- }
2324
- }));
2325
- return _el$;
2326
- })(), createComponent(Show, {
2329
+ var _el$ = _tmpl$2$q(),
2330
+ _el$2 = _el$.firstChild;
2331
+ use(setPopupRef, _el$);
2332
+ spread(_el$2, mergeProps$1(() => props.contentHTMLAttributes, {
2333
+ get ["class"]() {
2334
+ return cs(props.contentHTMLAttributes?.class, 'px-8px py-6px [box-shadow:var(--ant-box-shadow)] rounded-[var(--ant-border-radius-lg)] overflow-auto translate-x-[--inner-translate-x] translate-y-[--inner-translate-y]', props.plain ? 'text-[var(--ant-color-text)] bg-[var(--ant-color-bg-container-tertiary)]' : 'text-[var(--ant-color-text-light-solid)] bg-[var(--ant-color-bg-spotlight)]');
2335
+ }
2336
+ }), false, true);
2337
+ insert(_el$2, createComponent(TooltipContext.Provider, {
2338
+ value: context,
2339
+ get children() {
2340
+ return unwrapContent(props.content, () => setOpen(false));
2341
+ }
2342
+ }));
2343
+ insert(_el$, createComponent(Show, {
2327
2344
  get when() {
2328
2345
  return props.arrow;
2329
2346
  },
2330
2347
  get children() {
2331
- var _el$2 = _tmpl$$H();
2348
+ var _el$3 = _tmpl$$H();
2332
2349
  effect(_p$ => {
2333
2350
  var _v$ = cs('w-8px h-8px absolute border-transparent [box-shadow:var(--ant-box-shadow)]'),
2334
2351
  _v$2 = {
@@ -2336,16 +2353,17 @@ const Tooltip = _props => {
2336
2353
  'background-color': props.plain ? 'var(--ant-color-bg-container-tertiary)' : 'var(--ant-color-bg-spotlight)',
2337
2354
  ...ARROW_STYLE_DICT[mergePlacement(reversedMainPlacement(), reversedMinorPlacement())]
2338
2355
  };
2339
- _v$ !== _p$.e && className(_el$2, _p$.e = _v$);
2340
- _p$.t = style(_el$2, _v$2, _p$.t);
2356
+ _v$ !== _p$.e && className(_el$3, _p$.e = _v$);
2357
+ _p$.t = style(_el$3, _v$2, _p$.t);
2341
2358
  return _p$;
2342
2359
  }, {
2343
2360
  e: undefined,
2344
2361
  t: undefined
2345
2362
  });
2346
- return _el$2;
2363
+ return _el$3;
2347
2364
  }
2348
- })];
2365
+ }), null);
2366
+ return _el$;
2349
2367
  }
2350
2368
  });
2351
2369
  }