x-ui-design 0.6.12 → 0.6.13

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.js CHANGED
@@ -976,6 +976,17 @@ function flattenChildren(children) {
976
976
  var css_248z$l = ".xUi-form-item{display:flex;position:relative}.xUi-form-item.noStyle{display:inline-flex;margin-bottom:0}.xUi-form-item-label{align-items:center;color:var(--xui-text-color);display:flex;font-size:var(--xui-font-size-md);font-weight:500;line-height:20px;margin-bottom:4px}.xUi-form-item-error{color:var(--xui-error-color);display:block;font-size:var(--xui-font-size-xs);line-height:16px;margin-bottom:8px;margin-top:4px;min-height:16px;position:relative;right:0;text-align:end;user-select:none}.xUi-form-item-required{color:var(--xui-error-color);display:inline-block;font-size:var(--xui-font-size-md);line-height:1;margin-left:4px;margin-right:4px}.xUi-form-item.horizontal{align-items:center;flex-direction:row;gap:4px}.xUi-form-item.vertical{align-self:flex-start;flex-direction:column}.xUi-form-item .xUi-input-container{width:-webkit-fill-available}";
977
977
  styleInject(css_248z$l);
978
978
 
979
+ const debounce = (func, delay) => {
980
+ let timeoutId = null;
981
+ return (...args) => {
982
+ if (timeoutId) {
983
+ clearTimeout(timeoutId);
984
+ }
985
+ timeoutId = setTimeout(() => {
986
+ func(...args);
987
+ }, delay);
988
+ };
989
+ };
979
990
  const FormItem$1 = ({
980
991
  prefixCls = prefixClsFormItem,
981
992
  name,
@@ -1114,12 +1125,14 @@ const FormItemChildComponent = ({
1114
1125
  ...props
1115
1126
  }) => {
1116
1127
  const formContext = React.useContext(FormContext);
1117
- const animationRef = React.useRef(null);
1118
1128
  const [wasNormalize, setWasNormalize] = React.useState(false);
1119
1129
  const {
1120
1130
  getFieldsValue
1121
1131
  } = formContext || {};
1122
- const handleChange = React.useCallback((e, option) => {
1132
+ const debouncedSetFieldValue = React.useRef(debounce((name, value) => {
1133
+ setFieldValue(name, value, undefined, undefined, true);
1134
+ }, 200)).current;
1135
+ const handleChange = (e, option) => {
1123
1136
  let rawValue = e?.target ? e.target.value : e;
1124
1137
  if (normalize) {
1125
1138
  const prevValue = fieldValue ?? props.value;
@@ -1128,18 +1141,16 @@ const FormItemChildComponent = ({
1128
1141
  if (rawValue === prevValue) {
1129
1142
  e.target.value = rawValue;
1130
1143
  setWasNormalize(prev => !prev);
1131
- if (animationRef.current) {
1132
- cancelAnimationFrame(animationRef.current);
1133
- }
1134
- animationRef.current = requestAnimationFrame(() => {
1144
+ const timeout = setTimeout(() => {
1135
1145
  document.querySelector(`[name='${name}']`)?.focus();
1136
- });
1146
+ clearTimeout(timeout);
1147
+ }, 0);
1137
1148
  return;
1138
1149
  }
1139
1150
  }
1140
- setFieldValue(name, rawValue, undefined, undefined, true);
1151
+ debouncedSetFieldValue(name, rawValue);
1141
1152
  onChange?.(e, option);
1142
- }, [fieldValue, props.value, name]);
1153
+ };
1143
1154
  const injectPropsIntoFinalLeaf = child => {
1144
1155
  if (! /*#__PURE__*/React.isValidElement(child)) {
1145
1156
  return child;
@@ -3008,12 +3019,7 @@ const InputComponent = ({
3008
3019
  value: rawInput
3009
3020
  }
3010
3021
  };
3011
- if (animationRef.current) {
3012
- cancelAnimationFrame(animationRef.current);
3013
- }
3014
- animationRef.current = requestAnimationFrame(() => {
3015
- props.onChange?.(eventWithMaskedValue);
3016
- });
3022
+ props.onChange?.(eventWithMaskedValue);
3017
3023
  };
3018
3024
  const handleClear = e => {
3019
3025
  if (mask) {