@xfe-repo/web-components 1.7.3 → 1.7.5

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.d.mts CHANGED
@@ -893,8 +893,6 @@ interface Props$7 {
893
893
  onChange?: (value?: BrandValueType, label?: string) => void;
894
894
  value?: BrandValueType;
895
895
  defaultValue?: BrandValueType;
896
- /** 已知初始选项的显示文本,传入后首屏跳过接口请求,展开下拉时再加载完整选项 */
897
- defaultLabel?: string;
898
896
  disabled?: boolean;
899
897
  categoryId?: number;
900
898
  mode?: 'multiple' | 'tags';
package/dist/index.d.ts CHANGED
@@ -893,8 +893,6 @@ interface Props$7 {
893
893
  onChange?: (value?: BrandValueType, label?: string) => void;
894
894
  value?: BrandValueType;
895
895
  defaultValue?: BrandValueType;
896
- /** 已知初始选项的显示文本,传入后首屏跳过接口请求,展开下拉时再加载完整选项 */
897
- defaultLabel?: string;
898
896
  disabled?: boolean;
899
897
  categoryId?: number;
900
898
  mode?: 'multiple' | 'tags';
package/dist/index.js CHANGED
@@ -4383,12 +4383,10 @@ var import_antd23 = require("antd");
4383
4383
  var import_immutable2 = __toESM(require("swr/immutable"));
4384
4384
  function useBrandOptions(params) {
4385
4385
  var _useRequestConfig = useRequestConfig(), config = _useRequestConfig.config, apiService = _useRequestConfig.apiService;
4386
- var _ref = (0, import_immutable2.default)(// 只有当 params 存在时才发起请求,避免无效请求
4387
- params != null ? [
4386
+ var _ref = (0, import_immutable2.default)([
4388
4387
  "/product/brand/combo-box",
4389
4388
  params
4390
- ] : null, function(param) {
4391
- var _param = _sliced_to_array(param, 2), _params = _param[1];
4389
+ ], function() {
4392
4390
  return _async_to_generator(function() {
4393
4391
  var _res_data, res, options;
4394
4392
  return _ts_generator(this, function(_state) {
@@ -4399,7 +4397,7 @@ function useBrandOptions(params) {
4399
4397
  apiService.brandComboBox(_object_spread({
4400
4398
  page: 1,
4401
4399
  pageSize: 500
4402
- }, _params), config)
4400
+ }, params), config)
4403
4401
  ];
4404
4402
  case 1:
4405
4403
  res = _state.sent();
@@ -4724,9 +4722,9 @@ var import_antd29 = require("antd");
4724
4722
  // src/EffectBrandSelect/index.tsx
4725
4723
  var import_react39 = require("react");
4726
4724
  var import_react_use10 = require("react-use");
4727
- var import_tools7 = require("@xfe-repo/web-utils/tools");
4728
- var import_classnames9 = __toESM(require("classnames"));
4729
4725
  var import_antd26 = require("antd");
4726
+ var import_classnames9 = __toESM(require("classnames"));
4727
+ var import_tools7 = require("@xfe-repo/web-utils/tools");
4730
4728
  // src/EffectSkuSelect/index.tsx
4731
4729
  var import_react38 = require("react");
4732
4730
  var import_react_use9 = require("react-use");
@@ -5129,26 +5127,17 @@ var OTHER_BRAND_OPTION = {
5129
5127
  value: 1310
5130
5128
  };
5131
5129
  var EffectBrandSelect = (0, import_react39.memo)(function(props) {
5132
- var onChange = props.onChange, className = props.className, defaultValue = props.defaultValue, controlValue = props.value, defaultLabel = props.defaultLabel, disabled = props.disabled, mode = props.mode, categoryId = props.categoryId, sysBizTypeId = props.sysBizTypeId, showOtherBrand = props.showOtherBrand, style = props.style;
5133
- var initialValue = controlValue !== null && controlValue !== void 0 ? controlValue : defaultValue;
5134
- var hasDefaultLabel = !!defaultLabel && initialValue !== void 0;
5135
- var _ref = _sliced_to_array((0, import_react39.useState)(controlValue || defaultValue), 2), value = _ref[0], setValue = _ref[1];
5136
- var _ref1 = _sliced_to_array((0, import_react39.useState)(function() {
5137
- if (hasDefaultLabel) return null;
5138
- return {
5139
- /** 兼容 props 分类 Id 异常传入 */ categoryId: getNumberValue(categoryId),
5140
- sysBizTypeId: sysBizTypeId,
5141
- brandId: initialValue === null || initialValue === void 0 ? void 0 : initialValue.toString()
5142
- };
5130
+ var _state_data;
5131
+ var onChange = props.onChange, className = props.className, defaultValue = props.defaultValue, controlValue = props.value, disabled = props.disabled, mode = props.mode, categoryId = props.categoryId, sysBizTypeId = props.sysBizTypeId, showOtherBrand = props.showOtherBrand, style = props.style;
5132
+ var _ref = _sliced_to_array((0, import_react39.useState)(controlValue !== null && controlValue !== void 0 ? controlValue : defaultValue), 2), value = _ref[0], setValue = _ref[1];
5133
+ var _ref1 = _sliced_to_array((0, import_react39.useState)({
5134
+ /** 兼容 props 分类 Id 异常传入 */ categoryId: getNumberValue(categoryId),
5135
+ sysBizTypeId: sysBizTypeId,
5136
+ brandId: value === null || value === void 0 ? void 0 : value.toString()
5143
5137
  }), 2), params = _ref1[0], setParams = _ref1[1];
5144
- var _ref2 = _sliced_to_array((0, import_react39.useState)(hasDefaultLabel ? [
5145
- {
5146
- label: defaultLabel,
5147
- value: initialValue
5148
- }
5149
- ] : []), 2), options = _ref2[0], setOptions = _ref2[1];
5150
5138
  var prevControlValue = (0, import_react_use10.usePrevious)(controlValue);
5151
5139
  var state = useBrandOptions(params);
5140
+ var _ref2 = _sliced_to_array((0, import_react39.useState)((_state_data = state.data) !== null && _state_data !== void 0 ? _state_data : []), 2), options = _ref2[0], setOptions = _ref2[1];
5152
5141
  var searchFetch = (0, import_react39.useCallback)(function(brandName, brandId) {
5153
5142
  setParams({
5154
5143
  /** 兼容 props 分类 Id 异常传入 */ categoryId: getNumberValue(categoryId),
@@ -5196,19 +5185,22 @@ var EffectBrandSelect = (0, import_react39.memo)(function(props) {
5196
5185
  }, [
5197
5186
  controlValue
5198
5187
  ]);
5199
- var handleChange = function handleChange(_value, _option) {
5188
+ var handleChange = (0, import_react39.useCallback)(function(_value, _option) {
5200
5189
  setValue(_value);
5201
5190
  if (mode === "multiple") {
5202
- var options2 = _option;
5203
- var labels = options2 === null || options2 === void 0 ? void 0 : options2.map(function(option) {
5204
- return option.label;
5191
+ var selectedOptions = _option;
5192
+ var labels = selectedOptions === null || selectedOptions === void 0 ? void 0 : selectedOptions.map(function(opt) {
5193
+ return opt.label;
5205
5194
  }).join(">>>");
5206
5195
  onChange === null || onChange === void 0 ? void 0 : onChange(_value, labels);
5207
5196
  } else {
5208
- var option = _option;
5209
- onChange === null || onChange === void 0 ? void 0 : onChange(_value, option === null || option === void 0 ? void 0 : option.label);
5197
+ var selectedOption = _option;
5198
+ onChange === null || onChange === void 0 ? void 0 : onChange(_value, selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.label);
5210
5199
  }
5211
- };
5200
+ }, [
5201
+ mode,
5202
+ onChange
5203
+ ]);
5212
5204
  if (state.error) {
5213
5205
  var _state_error;
5214
5206
  return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_antd26.Typography.Text, {
package/dist/index.mjs CHANGED
@@ -4089,12 +4089,10 @@ import { Transfer, Typography as Typography2 } from "antd";
4089
4089
  import useSWRImmutable2 from "swr/immutable";
4090
4090
  function useBrandOptions(params) {
4091
4091
  var _useRequestConfig = useRequestConfig(), config = _useRequestConfig.config, apiService = _useRequestConfig.apiService;
4092
- var _useSWRImmutable2 = useSWRImmutable2(// 只有当 params 存在时才发起请求,避免无效请求
4093
- params != null ? [
4092
+ var _useSWRImmutable2 = useSWRImmutable2([
4094
4093
  "/product/brand/combo-box",
4095
4094
  params
4096
- ] : null, function(param) {
4097
- var _param = _sliced_to_array(param, 2), _params = _param[1];
4095
+ ], function() {
4098
4096
  return _async_to_generator(function() {
4099
4097
  var _res_data, res, options;
4100
4098
  return _ts_generator(this, function(_state) {
@@ -4105,7 +4103,7 @@ function useBrandOptions(params) {
4105
4103
  apiService.brandComboBox(_object_spread({
4106
4104
  page: 1,
4107
4105
  pageSize: 500
4108
- }, _params), config)
4106
+ }, params), config)
4109
4107
  ];
4110
4108
  case 1:
4111
4109
  res = _state.sent();
@@ -4430,9 +4428,9 @@ import { Table as Table3 } from "antd";
4430
4428
  // src/EffectBrandSelect/index.tsx
4431
4429
  import { memo as memo25, useCallback as useCallback18, useState as useState19 } from "react";
4432
4430
  import { usePrevious as usePrevious4, useUpdateEffect as useUpdateEffect9 } from "react-use";
4433
- import { debounce as debounce3 } from "@xfe-repo/web-utils/tools";
4434
- import classnames8 from "classnames";
4435
4431
  import { Select as Select4, Typography as Typography3 } from "antd";
4432
+ import classnames8 from "classnames";
4433
+ import { debounce as debounce3 } from "@xfe-repo/web-utils/tools";
4436
4434
  // src/EffectSkuSelect/index.tsx
4437
4435
  import { memo as memo24, useCallback as useCallback17, useEffect as useEffect16, useMemo as useMemo14, useState as useState18 } from "react";
4438
4436
  import { useMount, useUpdateEffect as useUpdateEffect8, usePrevious as usePrevious3 } from "react-use";
@@ -4835,26 +4833,17 @@ var OTHER_BRAND_OPTION = {
4835
4833
  value: 1310
4836
4834
  };
4837
4835
  var EffectBrandSelect = memo25(function(props) {
4838
- var onChange = props.onChange, className = props.className, defaultValue = props.defaultValue, controlValue = props.value, defaultLabel = props.defaultLabel, disabled = props.disabled, mode = props.mode, categoryId = props.categoryId, sysBizTypeId = props.sysBizTypeId, showOtherBrand = props.showOtherBrand, style = props.style;
4839
- var initialValue = controlValue !== null && controlValue !== void 0 ? controlValue : defaultValue;
4840
- var hasDefaultLabel = !!defaultLabel && initialValue !== void 0;
4841
- var _useState19 = _sliced_to_array(useState19(controlValue || defaultValue), 2), value = _useState19[0], setValue = _useState19[1];
4842
- var _useState191 = _sliced_to_array(useState19(function() {
4843
- if (hasDefaultLabel) return null;
4844
- return {
4845
- /** 兼容 props 分类 Id 异常传入 */ categoryId: getNumberValue(categoryId),
4846
- sysBizTypeId: sysBizTypeId,
4847
- brandId: initialValue === null || initialValue === void 0 ? void 0 : initialValue.toString()
4848
- };
4836
+ var _state_data;
4837
+ var onChange = props.onChange, className = props.className, defaultValue = props.defaultValue, controlValue = props.value, disabled = props.disabled, mode = props.mode, categoryId = props.categoryId, sysBizTypeId = props.sysBizTypeId, showOtherBrand = props.showOtherBrand, style = props.style;
4838
+ var _useState19 = _sliced_to_array(useState19(controlValue !== null && controlValue !== void 0 ? controlValue : defaultValue), 2), value = _useState19[0], setValue = _useState19[1];
4839
+ var _useState191 = _sliced_to_array(useState19({
4840
+ /** 兼容 props 分类 Id 异常传入 */ categoryId: getNumberValue(categoryId),
4841
+ sysBizTypeId: sysBizTypeId,
4842
+ brandId: value === null || value === void 0 ? void 0 : value.toString()
4849
4843
  }), 2), params = _useState191[0], setParams = _useState191[1];
4850
- var _useState192 = _sliced_to_array(useState19(hasDefaultLabel ? [
4851
- {
4852
- label: defaultLabel,
4853
- value: initialValue
4854
- }
4855
- ] : []), 2), options = _useState192[0], setOptions = _useState192[1];
4856
4844
  var prevControlValue = usePrevious4(controlValue);
4857
4845
  var state = useBrandOptions(params);
4846
+ var _useState192 = _sliced_to_array(useState19((_state_data = state.data) !== null && _state_data !== void 0 ? _state_data : []), 2), options = _useState192[0], setOptions = _useState192[1];
4858
4847
  var searchFetch = useCallback18(function(brandName, brandId) {
4859
4848
  setParams({
4860
4849
  /** 兼容 props 分类 Id 异常传入 */ categoryId: getNumberValue(categoryId),
@@ -4902,19 +4891,22 @@ var EffectBrandSelect = memo25(function(props) {
4902
4891
  }, [
4903
4892
  controlValue
4904
4893
  ]);
4905
- var handleChange = function handleChange(_value, _option) {
4894
+ var handleChange = useCallback18(function(_value, _option) {
4906
4895
  setValue(_value);
4907
4896
  if (mode === "multiple") {
4908
- var options2 = _option;
4909
- var labels = options2 === null || options2 === void 0 ? void 0 : options2.map(function(option) {
4910
- return option.label;
4897
+ var selectedOptions = _option;
4898
+ var labels = selectedOptions === null || selectedOptions === void 0 ? void 0 : selectedOptions.map(function(opt) {
4899
+ return opt.label;
4911
4900
  }).join(">>>");
4912
4901
  onChange === null || onChange === void 0 ? void 0 : onChange(_value, labels);
4913
4902
  } else {
4914
- var option = _option;
4915
- onChange === null || onChange === void 0 ? void 0 : onChange(_value, option === null || option === void 0 ? void 0 : option.label);
4903
+ var selectedOption = _option;
4904
+ onChange === null || onChange === void 0 ? void 0 : onChange(_value, selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.label);
4916
4905
  }
4917
- };
4906
+ }, [
4907
+ mode,
4908
+ onChange
4909
+ ]);
4918
4910
  if (state.error) {
4919
4911
  var _state_error;
4920
4912
  return /* @__PURE__ */ jsx35(Typography3.Text, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xfe-repo/web-components",
3
- "version": "1.7.3",
3
+ "version": "1.7.5",
4
4
  "module": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "sideEffects": [