x-ui-design 0.5.93 → 0.5.94

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.esm.js CHANGED
@@ -974,16 +974,30 @@ function flattenChildren(children) {
974
974
  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}";
975
975
  styleInject(css_248z$l);
976
976
 
977
- const debounce = (func, delay) => {
977
+ const debounce = (func, wait) => {
978
978
  let timeoutId = null;
979
- return (...args) => {
979
+ const debounced = (...args) => {
980
980
  if (timeoutId) {
981
981
  clearTimeout(timeoutId);
982
982
  }
983
983
  timeoutId = setTimeout(() => {
984
984
  func(...args);
985
- }, delay);
985
+ }, wait);
986
986
  };
987
+ debounced.cancel = () => {
988
+ if (timeoutId) {
989
+ clearTimeout(timeoutId);
990
+ timeoutId = null;
991
+ }
992
+ };
993
+ debounced.flush = (...args) => {
994
+ if (timeoutId) {
995
+ clearTimeout(timeoutId);
996
+ timeoutId = null;
997
+ func(...args);
998
+ }
999
+ };
1000
+ return debounced;
987
1001
  };
988
1002
  const FormItem$1 = ({
989
1003
  prefixCls = prefixClsFormItem,
@@ -1135,7 +1149,15 @@ const FormItemChildComponent = ({
1135
1149
  } = formContext || {};
1136
1150
  const debouncedSetFieldValue = useRef(debounce((name, value) => {
1137
1151
  setFieldValue(name, value, undefined, undefined, true);
1138
- }, 500)).current;
1152
+ }, 50)).current;
1153
+ useEffect(() => {
1154
+ return () => {
1155
+ debouncedSetFieldValue.cancel?.();
1156
+ };
1157
+ }, []);
1158
+ const handleBlur = () => {
1159
+ debouncedSetFieldValue.flush?.(name, fieldValue);
1160
+ };
1139
1161
  const handleChange = (e, option) => {
1140
1162
  let rawValue = e?.target ? e.target.value : e;
1141
1163
  if (normalize) {
@@ -1175,6 +1197,7 @@ const FormItemChildComponent = ({
1175
1197
  name: name,
1176
1198
  child: child,
1177
1199
  onChange: handleChange,
1200
+ onBlur: handleBlur,
1178
1201
  key: `${name}_${wasNormalize}`,
1179
1202
  value: fieldValue ?? props.value
1180
1203
  }, 'dangerouslySetInnerHTML' in childProps ? {} : {