@sheinx/base 3.9.0-beta.26 → 3.9.0-beta.27

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 +1 @@
1
- {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["node.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAuB,MAAM,eAAe,CAAC;AAElE,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAQhD,QAAA,MAAM,YAAY,gIAqJjB,CAAC;AAEF,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["node.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAuB,MAAM,eAAe,CAAC;AAElE,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAQhD,QAAA,MAAM,YAAY,gIAuJjB,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -103,6 +103,8 @@ var CascaderNode = function CascaderNode(props) {
103
103
  handleSelect(e);
104
104
  };
105
105
  hasHandleSelectRef.current = true;
106
+ } else {
107
+ hasHandleSelectRef.current = false;
106
108
  }
107
109
  return events;
108
110
  };
@@ -1 +1 @@
1
- {"version":3,"file":"descriptions.d.ts","sourceRoot":"","sources":["descriptions.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAuB,MAAM,qBAAqB,CAAC;AAGlF,QAAA,MAAM,YAAY,UAAW,iBAAiB,4CAyI7C,CAAC;AAEF,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"descriptions.d.ts","sourceRoot":"","sources":["descriptions.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAuB,MAAM,qBAAqB,CAAC;AAGlF,QAAA,MAAM,YAAY,UAAW,iBAAiB,4CA8I7C,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -18,7 +18,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
18
18
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
19
19
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
20
20
  var Descriptions = function Descriptions(props) {
21
- var _jssStyleProps$descri, _renderItem$;
21
+ var _jssStyleProps$descri;
22
22
  var className = props.className,
23
23
  jssStyleProps = props.jssStyle,
24
24
  style = props.style,
@@ -46,6 +46,11 @@ var Descriptions = function Descriptions(props) {
46
46
  labelStyle: labelStyle
47
47
  }),
48
48
  renderItem = _useDescriptions.renderItem;
49
+ var longestItem = (0, _react.useMemo)(function () {
50
+ return renderItem.reduce(function (prev, curr) {
51
+ return prev.length >= curr.length ? prev : curr;
52
+ }, []);
53
+ }, [renderItem]);
49
54
  var jssStyle = (jssStyleProps === null || jssStyleProps === void 0 || (_jssStyleProps$descri = jssStyleProps.descriptions) === null || _jssStyleProps$descri === void 0 ? void 0 : _jssStyleProps$descri.call(jssStyleProps)) || {};
50
55
  var Header = function Header() {
51
56
  if (!title && !extra) return null;
@@ -142,7 +147,7 @@ var Descriptions = function Descriptions(props) {
142
147
  cellPadding: 0,
143
148
  cellSpacing: 0,
144
149
  children: [layout === 'inlineHorizontal' && typeof column === 'number' && column > 1 && /*#__PURE__*/(0, _jsxRuntime.jsx)("colgroup", {
145
- children: (_renderItem$ = renderItem[0]) === null || _renderItem$ === void 0 ? void 0 : _renderItem$.map(function (_, index, arr) {
150
+ children: longestItem === null || longestItem === void 0 ? void 0 : longestItem.map(function (_, index, arr) {
146
151
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("col", {
147
152
  style: {
148
153
  width: "".concat(1 / arr.length * 100, "%")
@@ -1,4 +1,6 @@
1
+ import React from 'react';
1
2
  import { BaseListProps } from './select.type';
3
+ export declare const defaultRenderItem: <DataItem>(d: DataItem) => React.ReactNode;
2
4
  declare const List: <DataItem, Value>(props: BaseListProps<DataItem, Value>) => import("react/jsx-runtime").JSX.Element;
3
5
  export default List;
4
6
  //# sourceMappingURL=list.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"list.d.ts","sourceRoot":"","sources":["list.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAiB,aAAa,EAAE,MAAM,eAAe,CAAC;AAK7D,QAAA,MAAM,IAAI,qGAoNT,CAAC;AAEF,eAAe,IAAI,CAAC"}
1
+ {"version":3,"file":"list.d.ts","sourceRoot":"","sources":["list.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAG3D,OAAO,EAAiB,aAAa,EAAE,MAAM,eAAe,CAAC;AAK7D,eAAO,MAAM,iBAAiB,4CAA8D,CAAC;AAC7F,QAAA,MAAM,IAAI,qGAoNT,CAAC;AAEF,eAAe,IAAI,CAAC"}
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = void 0;
6
+ exports.defaultRenderItem = exports.default = void 0;
7
7
  var _react = _interopRequireWildcard(require("react"));
8
8
  var _classnames = _interopRequireDefault(require("classnames"));
9
9
  var _hooks = require("@sheinx/hooks");
@@ -26,6 +26,9 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
26
26
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
27
27
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
28
28
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
29
+ var defaultRenderItem = exports.defaultRenderItem = function defaultRenderItem(d) {
30
+ return d;
31
+ };
29
32
  var List = function List(props) {
30
33
  var _jssStyle$select;
31
34
  var jssStyle = props.jssStyle,
@@ -45,9 +48,7 @@ var List = function List(props) {
45
48
  optionListRef = props.optionListRef,
46
49
  isAnimationFinish = props.isAnimationFinish,
47
50
  _props$renderItem = props.renderItem,
48
- renderItemProp = _props$renderItem === void 0 ? function (d) {
49
- return d;
50
- } : _props$renderItem,
51
+ renderItemProp = _props$renderItem === void 0 ? defaultRenderItem : _props$renderItem,
51
52
  closePop = props.closePop,
52
53
  onControlTypeChange = props.onControlTypeChange,
53
54
  onOptionClick = props.onOptionClick;
@@ -188,7 +188,7 @@ var Result = function Result(props) {
188
188
  handleResultItemClick(e, item);
189
189
  };
190
190
  var content = renderResultContent(item, index, nodes);
191
- if (!content) return null;
191
+ if (!content && content !== 0) return null;
192
192
  if (renderResultContentProp) {
193
193
  // cascader 不渲染tag
194
194
  return renderResultContentProp(_objectSpread({
@@ -13,7 +13,7 @@ var _useInnerTitle = _interopRequireDefault(require("../common/use-inner-title")
13
13
  var _animationList = _interopRequireDefault(require("../animation-list"));
14
14
  var _spin = _interopRequireDefault(require("../spin"));
15
15
  var _result = _interopRequireDefault(require("./result"));
16
- var _list = _interopRequireDefault(require("./list"));
16
+ var _list = _interopRequireWildcard(require("./list"));
17
17
  var _listTree = _interopRequireDefault(require("./list-tree"));
18
18
  var _icons = _interopRequireDefault(require("../icons"));
19
19
  var _listColumns = _interopRequireDefault(require("./list-columns"));
@@ -101,9 +101,7 @@ function Select(props0) {
101
101
  autoAdapt = props.autoAdapt,
102
102
  groupBy = props.groupBy,
103
103
  _props$renderItem = props.renderItem,
104
- renderItemProp = _props$renderItem === void 0 ? function (d) {
105
- return d;
106
- } : _props$renderItem,
104
+ renderItemProp = _props$renderItem === void 0 ? _list.defaultRenderItem : _props$renderItem,
107
105
  renderResultProp = props.renderResult,
108
106
  renderUnmatched = props.renderUnmatched,
109
107
  resultClassName = props.resultClassName,
@@ -324,7 +322,8 @@ function Select(props0) {
324
322
  });
325
323
  var rootClass = (0, _classnames.default)(className, styles === null || styles === void 0 ? void 0 : styles.rootClass, styles === null || styles === void 0 ? void 0 : styles.wrapper, isEmpty && styles.wrapperEmpty, open && (styles === null || styles === void 0 ? void 0 : styles.wrapperOpen), open && trigger === 'hover' && (styles === null || styles === void 0 ? void 0 : styles.triggerHover), disabled === true && (styles === null || styles === void 0 ? void 0 : styles.wrapperDisabled), disabled !== true && focused && (styles === null || styles === void 0 ? void 0 : styles.wrapperFocus), innerTitle && (styles === null || styles === void 0 ? void 0 : styles.wrapperInnerTitle), size === 'small' && (styles === null || styles === void 0 ? void 0 : styles.wrapperSmall), size === 'large' && (styles === null || styles === void 0 ? void 0 : styles.wrapperLarge), (!!props.error || props.status === 'error') && (styles === null || styles === void 0 ? void 0 : styles.wrapperError), clearable && (styles === null || styles === void 0 ? void 0 : styles.clearable), !border && (styles === null || styles === void 0 ? void 0 : styles.wrapperNoBorder), !!underline && (styles === null || styles === void 0 ? void 0 : styles.wrapperUnderline), _defineProperty({}, styles === null || styles === void 0 ? void 0 : styles.multiple, multiple));
326
324
  var getRenderItem = function getRenderItem(data, index) {
327
- return typeof renderItemProp === 'function' ? renderItemProp(data, index) : (data === null || data === void 0 ? void 0 : data[renderItemProp]) || '';
325
+ var _data$renderItemProp;
326
+ return typeof renderItemProp === 'function' ? renderItemProp(data, index) : (_data$renderItemProp = data === null || data === void 0 ? void 0 : data[renderItemProp]) !== null && _data$renderItemProp !== void 0 ? _data$renderItemProp : '';
328
327
  };
329
328
  var renderItem = getRenderItem;
330
329
  var handleFocus = (0, _hooks.usePersistFn)(function (e) {
@@ -1 +1 @@
1
- {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["node.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAuB,MAAM,eAAe,CAAC;AAElE,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAQhD,QAAA,MAAM,YAAY,gIAqJjB,CAAC;AAEF,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["node.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAuB,MAAM,eAAe,CAAC;AAElE,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAQhD,QAAA,MAAM,YAAY,gIAuJjB,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -97,6 +97,8 @@ var CascaderNode = function CascaderNode(props) {
97
97
  handleSelect(e);
98
98
  };
99
99
  hasHandleSelectRef.current = true;
100
+ } else {
101
+ hasHandleSelectRef.current = false;
100
102
  }
101
103
  return events;
102
104
  };
@@ -1 +1 @@
1
- {"version":3,"file":"descriptions.d.ts","sourceRoot":"","sources":["descriptions.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAuB,MAAM,qBAAqB,CAAC;AAGlF,QAAA,MAAM,YAAY,UAAW,iBAAiB,4CAyI7C,CAAC;AAEF,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"descriptions.d.ts","sourceRoot":"","sources":["descriptions.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAuB,MAAM,qBAAqB,CAAC;AAGlF,QAAA,MAAM,YAAY,UAAW,iBAAiB,4CA8I7C,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -4,13 +4,13 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
4
4
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
5
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
6
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
- import React, { Fragment } from 'react';
7
+ import React, { Fragment, useMemo } from 'react';
8
8
  import classNames from 'classnames';
9
9
  import { useDescriptions, usePersistFn } from '@sheinx/hooks';
10
10
  import { jsx as _jsx } from "react/jsx-runtime";
11
11
  import { jsxs as _jsxs } from "react/jsx-runtime";
12
12
  var Descriptions = function Descriptions(props) {
13
- var _jssStyleProps$descri, _renderItem$;
13
+ var _jssStyleProps$descri;
14
14
  var className = props.className,
15
15
  jssStyleProps = props.jssStyle,
16
16
  style = props.style,
@@ -38,6 +38,11 @@ var Descriptions = function Descriptions(props) {
38
38
  labelStyle: labelStyle
39
39
  }),
40
40
  renderItem = _useDescriptions.renderItem;
41
+ var longestItem = useMemo(function () {
42
+ return renderItem.reduce(function (prev, curr) {
43
+ return prev.length >= curr.length ? prev : curr;
44
+ }, []);
45
+ }, [renderItem]);
41
46
  var jssStyle = (jssStyleProps === null || jssStyleProps === void 0 || (_jssStyleProps$descri = jssStyleProps.descriptions) === null || _jssStyleProps$descri === void 0 ? void 0 : _jssStyleProps$descri.call(jssStyleProps)) || {};
42
47
  var Header = function Header() {
43
48
  if (!title && !extra) return null;
@@ -134,7 +139,7 @@ var Descriptions = function Descriptions(props) {
134
139
  cellPadding: 0,
135
140
  cellSpacing: 0,
136
141
  children: [layout === 'inlineHorizontal' && typeof column === 'number' && column > 1 && /*#__PURE__*/_jsx("colgroup", {
137
- children: (_renderItem$ = renderItem[0]) === null || _renderItem$ === void 0 ? void 0 : _renderItem$.map(function (_, index, arr) {
142
+ children: longestItem === null || longestItem === void 0 ? void 0 : longestItem.map(function (_, index, arr) {
138
143
  return /*#__PURE__*/_jsx("col", {
139
144
  style: {
140
145
  width: "".concat(1 / arr.length * 100, "%")
@@ -1,4 +1,6 @@
1
+ import React from 'react';
1
2
  import { BaseListProps } from './select.type';
3
+ export declare const defaultRenderItem: <DataItem>(d: DataItem) => React.ReactNode;
2
4
  declare const List: <DataItem, Value>(props: BaseListProps<DataItem, Value>) => import("react/jsx-runtime").JSX.Element;
3
5
  export default List;
4
6
  //# sourceMappingURL=list.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"list.d.ts","sourceRoot":"","sources":["list.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAiB,aAAa,EAAE,MAAM,eAAe,CAAC;AAK7D,QAAA,MAAM,IAAI,qGAoNT,CAAC;AAEF,eAAe,IAAI,CAAC"}
1
+ {"version":3,"file":"list.d.ts","sourceRoot":"","sources":["list.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAG3D,OAAO,EAAiB,aAAa,EAAE,MAAM,eAAe,CAAC;AAK7D,eAAO,MAAM,iBAAiB,4CAA8D,CAAC;AAC7F,QAAA,MAAM,IAAI,qGAoNT,CAAC;AAEF,eAAe,IAAI,CAAC"}
@@ -17,6 +17,9 @@ import { usePersistFn } from '@sheinx/hooks';
17
17
  import { VirtualScrollList } from "../virtual-scroll";
18
18
  import ListOption from "./list-option";
19
19
  import { jsx as _jsx } from "react/jsx-runtime";
20
+ export var defaultRenderItem = function defaultRenderItem(d) {
21
+ return d;
22
+ };
20
23
  var List = function List(props) {
21
24
  var _jssStyle$select;
22
25
  var jssStyle = props.jssStyle,
@@ -36,9 +39,7 @@ var List = function List(props) {
36
39
  optionListRef = props.optionListRef,
37
40
  isAnimationFinish = props.isAnimationFinish,
38
41
  _props$renderItem = props.renderItem,
39
- renderItemProp = _props$renderItem === void 0 ? function (d) {
40
- return d;
41
- } : _props$renderItem,
42
+ renderItemProp = _props$renderItem === void 0 ? defaultRenderItem : _props$renderItem,
42
43
  closePop = props.closePop,
43
44
  onControlTypeChange = props.onControlTypeChange,
44
45
  onOptionClick = props.onOptionClick;
@@ -180,7 +180,7 @@ var Result = function Result(props) {
180
180
  handleResultItemClick(e, item);
181
181
  };
182
182
  var content = renderResultContent(item, index, nodes);
183
- if (!content) return null;
183
+ if (!content && content !== 0) return null;
184
184
  if (renderResultContentProp) {
185
185
  // cascader 不渲染tag
186
186
  return renderResultContentProp(_objectSpread({
@@ -22,7 +22,7 @@ import useInnerTitle from "../common/use-inner-title";
22
22
  import AnimationList from "../animation-list";
23
23
  import Spin from "../spin";
24
24
  import Result from "./result";
25
- import List from "./list";
25
+ import List, { defaultRenderItem } from "./list";
26
26
  import TreeList from "./list-tree";
27
27
  import Icons from "../icons";
28
28
  import ColumnsList from "./list-columns";
@@ -94,9 +94,7 @@ function Select(props0) {
94
94
  autoAdapt = props.autoAdapt,
95
95
  groupBy = props.groupBy,
96
96
  _props$renderItem = props.renderItem,
97
- renderItemProp = _props$renderItem === void 0 ? function (d) {
98
- return d;
99
- } : _props$renderItem,
97
+ renderItemProp = _props$renderItem === void 0 ? defaultRenderItem : _props$renderItem,
100
98
  renderResultProp = props.renderResult,
101
99
  renderUnmatched = props.renderUnmatched,
102
100
  resultClassName = props.resultClassName,
@@ -317,7 +315,8 @@ function Select(props0) {
317
315
  });
318
316
  var rootClass = classNames(className, styles === null || styles === void 0 ? void 0 : styles.rootClass, styles === null || styles === void 0 ? void 0 : styles.wrapper, isEmpty && styles.wrapperEmpty, open && (styles === null || styles === void 0 ? void 0 : styles.wrapperOpen), open && trigger === 'hover' && (styles === null || styles === void 0 ? void 0 : styles.triggerHover), disabled === true && (styles === null || styles === void 0 ? void 0 : styles.wrapperDisabled), disabled !== true && focused && (styles === null || styles === void 0 ? void 0 : styles.wrapperFocus), innerTitle && (styles === null || styles === void 0 ? void 0 : styles.wrapperInnerTitle), size === 'small' && (styles === null || styles === void 0 ? void 0 : styles.wrapperSmall), size === 'large' && (styles === null || styles === void 0 ? void 0 : styles.wrapperLarge), (!!props.error || props.status === 'error') && (styles === null || styles === void 0 ? void 0 : styles.wrapperError), clearable && (styles === null || styles === void 0 ? void 0 : styles.clearable), !border && (styles === null || styles === void 0 ? void 0 : styles.wrapperNoBorder), !!underline && (styles === null || styles === void 0 ? void 0 : styles.wrapperUnderline), _defineProperty({}, styles === null || styles === void 0 ? void 0 : styles.multiple, multiple));
319
317
  var getRenderItem = function getRenderItem(data, index) {
320
- return typeof renderItemProp === 'function' ? renderItemProp(data, index) : (data === null || data === void 0 ? void 0 : data[renderItemProp]) || '';
318
+ var _data$renderItemProp;
319
+ return typeof renderItemProp === 'function' ? renderItemProp(data, index) : (_data$renderItemProp = data === null || data === void 0 ? void 0 : data[renderItemProp]) !== null && _data$renderItemProp !== void 0 ? _data$renderItemProp : '';
321
320
  };
322
321
  var renderItem = getRenderItem;
323
322
  var handleFocus = usePersistFn(function (e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sheinx/base",
3
- "version": "3.9.0-beta.26",
3
+ "version": "3.9.0-beta.27",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "license": "MIT",
@@ -10,7 +10,7 @@
10
10
  "module": "./esm/index.js",
11
11
  "typings": "./cjs/index.d.ts",
12
12
  "dependencies": {
13
- "@sheinx/hooks": "3.9.0-beta.26",
13
+ "@sheinx/hooks": "3.9.0-beta.27",
14
14
  "immer": "^10.0.0",
15
15
  "classnames": "^2.0.0",
16
16
  "@shined/reactive": "^0.3.3"