@pisell/materials 1.0.508 → 1.0.510

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.
@@ -109,15 +109,17 @@ var PhoneInput = function PhoneInput(_ref) {
109
109
  },
110
110
  onBlur: handleBlur,
111
111
  popupMatchSelectWidth: false,
112
- optionLabelProp: "label",
113
- showSearch: true
114
- }, countries.map(function (country) {
115
- return /*#__PURE__*/React.createElement(Option, {
116
- key: country.code,
117
- value: country.code,
118
- label: country.prefix
119
- }, translationOriginal(country.name), " (", country.prefix, ")");
120
- })), /*#__PURE__*/React.createElement(Input, _extends({}, props, {
112
+ optionLabelProp: "inputValue",
113
+ optionFilterProp: "label",
114
+ showSearch: true,
115
+ options: countries.map(function (country) {
116
+ return {
117
+ value: country.code,
118
+ label: "".concat(translationOriginal(country.name), " (").concat(country.prefix, ")"),
119
+ inputValue: country.prefix
120
+ };
121
+ })
122
+ }), /*#__PURE__*/React.createElement(Input, _extends({}, props, {
121
123
  status: status,
122
124
  type: "tel",
123
125
  value: phoneNumber,
@@ -1,4 +1,4 @@
1
- import React, { useMemo, useRef, useEffect } from 'react';
1
+ import React, { useMemo, useRef } from 'react';
2
2
  import { isArr, isString, isUndefined } from '@pisell/utils';
3
3
  import { useMemoizedFn } from 'ahooks';
4
4
  import VariablesContext from "./VariablesContext";
@@ -18,14 +18,15 @@ var VariablesProvider = function VariablesProvider(props) {
18
18
  variables = props.variables;
19
19
 
20
20
  // 变量存储
21
- var variablesRef = useRef({});
21
+ var variablesRef = useRef(variables || {});
22
22
  // 添加变量变化监听器存储
23
23
  var listenersRef = useRef(new Set());
24
- useEffect(function () {
25
- if (variables) {
26
- variablesRef.current = variables;
27
- }
28
- }, [variables]);
24
+
25
+ // useEffect(() => {
26
+ // if (variables) {
27
+ // variablesRef.current = variables;
28
+ // }
29
+ // }, [variables]);
29
30
 
30
31
  // 注册变量
31
32
  var registerVariable = useMemoizedFn(function (value) {
@@ -41,7 +41,7 @@ var SelectBase = /*#__PURE__*/forwardRef(function (props, ref) {
41
41
  setSearchValue = _useState2[1];
42
42
  var filteredOptions = useMemo(function () {
43
43
  if (!searchValue) return options;
44
- return options.filter(function (option) {
44
+ return (options || []).filter(function (option) {
45
45
  var _option$optionFilterP;
46
46
  var optionValue = ((_option$optionFilterP = option[optionFilterProp]) === null || _option$optionFilterP === void 0 ? void 0 : _option$optionFilterP.toString().toLowerCase()) || '';
47
47
  return optionValue.includes(searchValue.toLowerCase());
@@ -111,21 +111,15 @@ var PhoneInput = ({ value: propsValue, onChange, isVerification, ...props }) =>
111
111
  style: { width: "90px" },
112
112
  onBlur: handleBlur,
113
113
  popupMatchSelectWidth: false,
114
- optionLabelProp: "label",
115
- showSearch: true
116
- },
117
- countries.map((country) => /* @__PURE__ */ import_react.default.createElement(
118
- Option,
119
- {
120
- key: country.code,
114
+ optionLabelProp: "inputValue",
115
+ optionFilterProp: "label",
116
+ showSearch: true,
117
+ options: countries.map((country) => ({
121
118
  value: country.code,
122
- label: country.prefix
123
- },
124
- translationOriginal(country.name),
125
- " (",
126
- country.prefix,
127
- ")"
128
- ))
119
+ label: `${translationOriginal(country.name)} (${country.prefix})`,
120
+ inputValue: country.prefix
121
+ }))
122
+ }
129
123
  ), /* @__PURE__ */ import_react.default.createElement(
130
124
  import_antd.Input,
131
125
  {
@@ -47,13 +47,8 @@ var defaultCustomizer = (objValue, srcValue) => {
47
47
  var VARIABLE_PATTERN = /{{([^}]+)}}/g;
48
48
  var VariablesProvider = (props) => {
49
49
  const { children, variables } = props;
50
- const variablesRef = (0, import_react.useRef)({});
50
+ const variablesRef = (0, import_react.useRef)(variables || {});
51
51
  const listenersRef = (0, import_react.useRef)(/* @__PURE__ */ new Set());
52
- (0, import_react.useEffect)(() => {
53
- if (variables) {
54
- variablesRef.current = variables;
55
- }
56
- }, [variables]);
57
52
  const registerVariable = (0, import_ahooks.useMemoizedFn)((value2) => {
58
53
  variablesRef.current = (0, import_utils3.mergeWith)(
59
54
  variablesRef.current,
@@ -63,7 +63,7 @@ var SelectBase = (0, import_react.forwardRef)((props, ref) => {
63
63
  const filteredOptions = (0, import_react.useMemo)(() => {
64
64
  if (!searchValue)
65
65
  return options;
66
- return options.filter(
66
+ return (options || []).filter(
67
67
  (option) => {
68
68
  var _a;
69
69
  const optionValue = ((_a = option[optionFilterProp]) == null ? void 0 : _a.toString().toLowerCase()) || "";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pisell/materials",
3
- "version": "1.0.508",
3
+ "version": "1.0.510",
4
4
  "main": "./lib/index.js",
5
5
  "module": "./es/index.js",
6
6
  "types": "./lib/index.d.ts",