@vtx/components 4.0.0-beta.85 → 4.0.0-beta.87

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,5 +1,6 @@
1
1
  var _excluded = ["value", "mode", "size", "onChange", "maxTagCount", "maxTagTextLength", "maxTagPlaceholder", "showAll", "selectStyle", "selectAll", "selectSearchAll", "defaultBindBodyToPopupContainer", "customEnumText", "showSearch", "optionFilterProp", "onSearch"],
2
- _excluded2 = ["onSearch", "optionFilterProp"];
2
+ _excluded2 = ["key", "value", "children"],
3
+ _excluded3 = ["onSearch", "optionFilterProp"];
3
4
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
5
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
5
6
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
@@ -106,14 +107,31 @@ var VtxSelect = /*#__PURE__*/forwardRef(function (props, ref) {
106
107
  };
107
108
  }
108
109
  }, [mode]);
109
- var newChildren = props.children ? React.Children.toArray(props.children) : ((_props$options = props.options) === null || _props$options === void 0 ? void 0 : _props$options.map(function (v) {
110
- return _objectSpread(_objectSpread({}, v), {}, {
110
+
111
+ // Merge object-style `options` into React elements so they can be used
112
+ // interchangeably with <VtxSelect.Option /> children.
113
+ var mergedChildren = React.Children.toArray(props.children);
114
+ var optionsAsElements = ((_props$options = props.options) === null || _props$options === void 0 ? void 0 : _props$options.map(function (v) {
115
+ return /*#__PURE__*/React.isValidElement(v) ? v : /*#__PURE__*/React.createElement(Select.Option, {
111
116
  key: v.value,
112
- props: _objectSpread(_objectSpread({}, v), {}, {
113
- children: v.label
114
- })
117
+ value: v.value,
118
+ label: v.label
115
119
  });
116
120
  })) || [];
121
+ var normalizeChild = function normalizeChild(child) {
122
+ if (! /*#__PURE__*/React.isValidElement(child)) return child;
123
+ var _child$props = child.props,
124
+ key = _child$props.key,
125
+ value = _child$props.value,
126
+ label = _child$props.children,
127
+ rest = _objectWithoutProperties(_child$props, _excluded2);
128
+ var optionValue = value !== null && value !== void 0 ? value : key;
129
+ return /*#__PURE__*/React.cloneElement(child, _objectSpread(_objectSpread({}, rest), {}, {
130
+ key: key,
131
+ value: optionValue
132
+ }));
133
+ };
134
+ var finalChildren = [].concat(_toConsumableArray(optionsAsElements), _toConsumableArray(mergedChildren.map(normalizeChild)));
117
135
  var getOptionValue = function getOptionValue(item) {
118
136
  var _ref, _itemProps$value;
119
137
  var itemProps = (item === null || item === void 0 ? void 0 : item.props) || {};
@@ -131,7 +149,7 @@ var VtxSelect = /*#__PURE__*/forwardRef(function (props, ref) {
131
149
  }
132
150
  return item;
133
151
  };
134
- var normalizedOptions = newChildren.map(function (item) {
152
+ var normalizedOptions = finalChildren.filter(React.isValidElement).map(function (item) {
135
153
  return {
136
154
  value: getOptionValue(item),
137
155
  label: getOptionLabel(item),
@@ -190,7 +208,7 @@ var VtxSelect = /*#__PURE__*/forwardRef(function (props, ref) {
190
208
  if (showSearch && _typeof(showSearch) === 'object') {
191
209
  var showSearchOnSearch = showSearch.onSearch,
192
210
  showSearchOptionFilterProp = showSearch.optionFilterProp,
193
- searchConfig = _objectWithoutProperties(showSearch, _excluded2);
211
+ searchConfig = _objectWithoutProperties(showSearch, _excluded3);
194
212
  return {
195
213
  showSearch: _objectSpread(_objectSpread({}, searchConfig), {}, {
196
214
  optionFilterProp: showSearchOptionFilterProp || optionFilterProp || defaultOptionFilterProp,
@@ -242,11 +260,11 @@ var VtxSelect = /*#__PURE__*/forwardRef(function (props, ref) {
242
260
  return e.preventDefault();
243
261
  },
244
262
  children: /*#__PURE__*/_jsx(Checkbox, {
245
- indeterminate: valueLength && valueLength < newChildren.length,
246
- checked: valueLength && valueLength === newChildren.length,
263
+ indeterminate: valueLength && valueLength < finalChildren.length,
264
+ checked: valueLength && valueLength === finalChildren.length,
247
265
  onChange: function onChange(e) {
248
266
  if (e.target.checked) {
249
- var tempChildren = newChildren.filter(function (item) {
267
+ var tempChildren = finalChildren.filter(function (item) {
250
268
  if (selectSearchAll && searchValue) {
251
269
  return String(getOptionLabel(item)).toLowerCase().indexOf(searchValue) > -1;
252
270
  }
@@ -304,7 +322,7 @@ var VtxSelect = /*#__PURE__*/forwardRef(function (props, ref) {
304
322
  style: _objectSpread({
305
323
  width: '100%'
306
324
  }, selectStyle),
307
- children: props.children
325
+ children: finalChildren
308
326
  })), (mode == 'multiple' || mode == 'tags') && showAll ? /*#__PURE__*/_jsx(Popover, {
309
327
  content: getContent(),
310
328
  placement: "bottomRight",
@@ -18,15 +18,16 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
18
18
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
19
19
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
20
20
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
21
- import { Button, Empty, Popover, Tag, TreeSelect, ConfigProvider, Space } from 'antd';
22
- import React, { useContext, useEffect, useMemo, useRef, useState } from 'react';
23
- import PropTypes from 'prop-types';
24
21
  import { DownOutlined, MoreOutlined } from '@ant-design/icons';
22
+ import { useSize } from 'ahooks';
23
+ import { Button, Empty, Popover, Space, Tag, TreeSelect } from 'antd';
25
24
  import classnames from 'classnames';
26
25
  import pull from 'lodash-es/pull';
27
- import { useStyle } from "./style/index";
28
- import { useSize } from 'ahooks';
26
+ import PropTypes from 'prop-types';
27
+ import { useContext, useEffect, useMemo, useRef, useState } from 'react';
28
+ import VtxIcon from "../vtx-icon";
29
29
  import { VtxProvider, useIntl } from "../vtx-provider";
30
+ import { useStyle } from "./style/index";
30
31
  import { jsxs as _jsxs } from "react/jsx-runtime";
31
32
  import { jsx as _jsx } from "react/jsx-runtime";
32
33
  import { Fragment as _Fragment } from "react/jsx-runtime";
@@ -40,9 +41,9 @@ var VtxTreeSelect = function VtxTreeSelect(_ref) {
40
41
  style = _ref.style,
41
42
  _ref$fieldNames = _ref.fieldNames,
42
43
  fieldNames = _ref$fieldNames === void 0 ? {
43
- label: "title",
44
- value: "value",
45
- key: "value",
44
+ label: 'title',
45
+ value: 'value',
46
+ key: 'value',
46
47
  children: 'children'
47
48
  } : _ref$fieldNames,
48
49
  onChange = _ref.onChange,
@@ -188,6 +189,10 @@ var VtxTreeSelect = function VtxTreeSelect(_ref) {
188
189
  showLeafIcon: false
189
190
  },
190
191
  switcherIcon: /*#__PURE__*/_jsx(DownOutlined, {}),
192
+ suffixIcon: /*#__PURE__*/_jsx(VtxIcon, {
193
+ type: "downOutlined",
194
+ fileType: "svg"
195
+ }),
191
196
  multiple: multiple,
192
197
  treeCheckable: treeCheckable,
193
198
  className: classnames("".concat(prefixCls, " ").concat(props.prefixCls), hashId),
@@ -14,7 +14,8 @@ var _utils = require("../utils");
14
14
  var _vtxProvider = require("../vtx-provider");
15
15
  var _jsxRuntime = require("react/jsx-runtime");
16
16
  var _excluded = ["value", "mode", "size", "onChange", "maxTagCount", "maxTagTextLength", "maxTagPlaceholder", "showAll", "selectStyle", "selectAll", "selectSearchAll", "defaultBindBodyToPopupContainer", "customEnumText", "showSearch", "optionFilterProp", "onSearch"],
17
- _excluded2 = ["onSearch", "optionFilterProp"];
17
+ _excluded2 = ["key", "value", "children"],
18
+ _excluded3 = ["onSearch", "optionFilterProp"];
18
19
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
19
20
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
20
21
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -114,14 +115,31 @@ var VtxSelect = exports.VtxSelect = /*#__PURE__*/(0, _react.forwardRef)(function
114
115
  };
115
116
  }
116
117
  }, [mode]);
117
- var newChildren = props.children ? _react.default.Children.toArray(props.children) : ((_props$options = props.options) === null || _props$options === void 0 ? void 0 : _props$options.map(function (v) {
118
- return _objectSpread(_objectSpread({}, v), {}, {
118
+
119
+ // Merge object-style `options` into React elements so they can be used
120
+ // interchangeably with <VtxSelect.Option /> children.
121
+ var mergedChildren = _react.default.Children.toArray(props.children);
122
+ var optionsAsElements = ((_props$options = props.options) === null || _props$options === void 0 ? void 0 : _props$options.map(function (v) {
123
+ return /*#__PURE__*/_react.default.isValidElement(v) ? v : /*#__PURE__*/_react.default.createElement(_antd.Select.Option, {
119
124
  key: v.value,
120
- props: _objectSpread(_objectSpread({}, v), {}, {
121
- children: v.label
122
- })
125
+ value: v.value,
126
+ label: v.label
123
127
  });
124
128
  })) || [];
129
+ var normalizeChild = function normalizeChild(child) {
130
+ if (! /*#__PURE__*/_react.default.isValidElement(child)) return child;
131
+ var _child$props = child.props,
132
+ key = _child$props.key,
133
+ value = _child$props.value,
134
+ label = _child$props.children,
135
+ rest = _objectWithoutProperties(_child$props, _excluded2);
136
+ var optionValue = value !== null && value !== void 0 ? value : key;
137
+ return /*#__PURE__*/_react.default.cloneElement(child, _objectSpread(_objectSpread({}, rest), {}, {
138
+ key: key,
139
+ value: optionValue
140
+ }));
141
+ };
142
+ var finalChildren = [].concat(_toConsumableArray(optionsAsElements), _toConsumableArray(mergedChildren.map(normalizeChild)));
125
143
  var getOptionValue = function getOptionValue(item) {
126
144
  var _ref, _itemProps$value;
127
145
  var itemProps = (item === null || item === void 0 ? void 0 : item.props) || {};
@@ -139,7 +157,7 @@ var VtxSelect = exports.VtxSelect = /*#__PURE__*/(0, _react.forwardRef)(function
139
157
  }
140
158
  return item;
141
159
  };
142
- var normalizedOptions = newChildren.map(function (item) {
160
+ var normalizedOptions = finalChildren.filter(_react.default.isValidElement).map(function (item) {
143
161
  return {
144
162
  value: getOptionValue(item),
145
163
  label: getOptionLabel(item),
@@ -198,7 +216,7 @@ var VtxSelect = exports.VtxSelect = /*#__PURE__*/(0, _react.forwardRef)(function
198
216
  if (showSearch && _typeof(showSearch) === 'object') {
199
217
  var showSearchOnSearch = showSearch.onSearch,
200
218
  showSearchOptionFilterProp = showSearch.optionFilterProp,
201
- searchConfig = _objectWithoutProperties(showSearch, _excluded2);
219
+ searchConfig = _objectWithoutProperties(showSearch, _excluded3);
202
220
  return {
203
221
  showSearch: _objectSpread(_objectSpread({}, searchConfig), {}, {
204
222
  optionFilterProp: showSearchOptionFilterProp || optionFilterProp || defaultOptionFilterProp,
@@ -250,11 +268,11 @@ var VtxSelect = exports.VtxSelect = /*#__PURE__*/(0, _react.forwardRef)(function
250
268
  return e.preventDefault();
251
269
  },
252
270
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Checkbox, {
253
- indeterminate: valueLength && valueLength < newChildren.length,
254
- checked: valueLength && valueLength === newChildren.length,
271
+ indeterminate: valueLength && valueLength < finalChildren.length,
272
+ checked: valueLength && valueLength === finalChildren.length,
255
273
  onChange: function onChange(e) {
256
274
  if (e.target.checked) {
257
- var tempChildren = newChildren.filter(function (item) {
275
+ var tempChildren = finalChildren.filter(function (item) {
258
276
  if (selectSearchAll && searchValue) {
259
277
  return String(getOptionLabel(item)).toLowerCase().indexOf(searchValue) > -1;
260
278
  }
@@ -312,7 +330,7 @@ var VtxSelect = exports.VtxSelect = /*#__PURE__*/(0, _react.forwardRef)(function
312
330
  style: _objectSpread({
313
331
  width: '100%'
314
332
  }, selectStyle),
315
- children: props.children
333
+ children: finalChildren
316
334
  })), (mode == 'multiple' || mode == 'tags') && showAll ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Popover, {
317
335
  content: getContent(),
318
336
  placement: "bottomRight",
@@ -5,20 +5,19 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.default = exports.VtxTreeSelect = void 0;
8
- var _antd = require("antd");
9
- var _react = _interopRequireWildcard(require("react"));
10
- var _propTypes = _interopRequireDefault(require("prop-types"));
11
8
  var _icons = require("@ant-design/icons");
9
+ var _ahooks = require("ahooks");
10
+ var _antd = require("antd");
12
11
  var _classnames = _interopRequireDefault(require("classnames"));
13
12
  var _pull = _interopRequireDefault(require("lodash-es/pull"));
14
- var _index = require("./style/index");
15
- var _ahooks = require("ahooks");
13
+ var _propTypes = _interopRequireDefault(require("prop-types"));
14
+ var _react = require("react");
15
+ var _vtxIcon = _interopRequireDefault(require("../vtx-icon"));
16
16
  var _vtxProvider = require("../vtx-provider");
17
+ var _index = require("./style/index");
17
18
  var _jsxRuntime = require("react/jsx-runtime");
18
19
  var _excluded = ["multiple", "treeData", "placeholder", "treeCheckable", "disabled", "style", "fieldNames", "onChange", "labelInValue"];
19
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
21
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
22
21
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
23
22
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
24
23
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
@@ -47,9 +46,9 @@ var VtxTreeSelect = exports.VtxTreeSelect = function VtxTreeSelect(_ref) {
47
46
  style = _ref.style,
48
47
  _ref$fieldNames = _ref.fieldNames,
49
48
  fieldNames = _ref$fieldNames === void 0 ? {
50
- label: "title",
51
- value: "value",
52
- key: "value",
49
+ label: 'title',
50
+ value: 'value',
51
+ key: 'value',
53
52
  children: 'children'
54
53
  } : _ref$fieldNames,
55
54
  onChange = _ref.onChange,
@@ -195,6 +194,10 @@ var VtxTreeSelect = exports.VtxTreeSelect = function VtxTreeSelect(_ref) {
195
194
  showLeafIcon: false
196
195
  },
197
196
  switcherIcon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.DownOutlined, {}),
197
+ suffixIcon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_vtxIcon.default, {
198
+ type: "downOutlined",
199
+ fileType: "svg"
200
+ }),
198
201
  multiple: multiple,
199
202
  treeCheckable: treeCheckable,
200
203
  className: (0, _classnames.default)("".concat(prefixCls, " ").concat(props.prefixCls), hashId),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vtx/components",
3
- "version": "4.0.0-beta.85",
3
+ "version": "4.0.0-beta.87",
4
4
  "description": "React components for Vortex",
5
5
  "keywords": [
6
6
  "react",
@@ -87,6 +87,9 @@
87
87
  "@emotion/serialize": "^1.3.3",
88
88
  "@rc-component/util": "1.3.0",
89
89
  "@types/react": "^18.0.0",
90
+ "@wangeditor/editor": "^5.1.23",
91
+ "@wangeditor/editor-for-react": "^1.0.6",
92
+ "@wangeditor/plugin-upload-attachment": "^1.1.0",
90
93
  "ahooks": "^3.9.6",
91
94
  "antd-img-crop": "4.25.0",
92
95
  "axios": "^1.13.2",
@@ -115,15 +118,11 @@
115
118
  "uninstall": "^0.0.0",
116
119
  "use-deep-compare": "^1.3.0",
117
120
  "viewerjs": "1.3.3",
118
- "xgplayer": "^3.0.23",
119
- "@wangeditor/editor": "^5.1.23",
120
- "@wangeditor/editor-for-react": "^1.0.6",
121
- "@wangeditor/plugin-upload-attachment": "^1.1.0"
121
+ "xgplayer": "^3.0.23"
122
122
  },
123
123
  "devDependencies": {
124
124
  "@ant-design/antd-theme-variable": "^1.0.0",
125
125
  "@ant-design/icons": "^6.0.0",
126
- "dayjs": "^1.11.18",
127
126
  "@babel/core": "^7.28.5",
128
127
  "@babel/eslint-plugin": "^7.27.1",
129
128
  "@babel/parser": "^7.28.5",
@@ -154,11 +153,13 @@
154
153
  "@vitest/browser": "^3.2.4",
155
154
  "@vitest/coverage-istanbul": "^3.2.4",
156
155
  "@vitest/ui": "^3.2.4",
156
+ "@vtx/utils": "^1.0.25",
157
157
  "animated-scroll-to": "^2.3.2",
158
- "antd": "^6.3.5",
158
+ "antd": "^6.6.4",
159
159
  "chalk": "^4.1.2",
160
160
  "copy-to-clipboard": "^3.3.3",
161
161
  "cross-env": "^7.0.3",
162
+ "dayjs": "^1.11.18",
162
163
  "dumi": "^2.4.21",
163
164
  "dumi-theme-vortex-style": "^1.0.0",
164
165
  "esbuild": "^0.15.18",
@@ -215,18 +216,16 @@
215
216
  "write-pkg": "^4.0.0",
216
217
  "xhr-mock": "^2.5.1",
217
218
  "yorkie": "^2.0.0",
218
- "zustand": "^4.5.7",
219
- "@vtx/utils": "^1.0.25"
219
+ "zustand": "^4.5.7"
220
220
  },
221
221
  "peerDependencies": {
222
222
  "@ant-design/icons": "^6.0.0",
223
+ "@vtx/utils": "^1.0.25",
223
224
  "antd": "^6.0.0",
225
+ "dayjs": "^1.11.18",
224
226
  "lodash-es": "^4.17.21",
225
227
  "react": "^18.3.1",
226
- "react-dom": "^18.3.1",
227
- "dayjs": "^1.11.18",
228
- "@vtx/utils": "^1.0.25"
229
-
228
+ "react-dom": "^18.3.1"
230
229
  },
231
230
  "peerDependenciesName": "声明宿主依赖",
232
231
  "packageManager": "pnpm@9.6.0",