x-ui-design 0.5.94 → 0.5.95

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
@@ -1,5 +1,5 @@
1
1
  import require$$1 from 'react/jsx-runtime';
2
- import React, { useRef, useState, Children, isValidElement, Fragment, Suspense, useContext, useMemo, useEffect, createContext, useImperativeHandle, useCallback, useLayoutEffect } from 'react';
2
+ import React, { useRef, useState, Children, isValidElement, Fragment, Suspense, useContext, useMemo, useEffect, useCallback, createContext, useImperativeHandle, useLayoutEffect } from 'react';
3
3
  import { createPortal } from 'react-dom';
4
4
  import ReactDOMServer from 'react-dom/server';
5
5
 
@@ -974,31 +974,6 @@ 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, wait) => {
978
- let timeoutId = null;
979
- const debounced = (...args) => {
980
- if (timeoutId) {
981
- clearTimeout(timeoutId);
982
- }
983
- timeoutId = setTimeout(() => {
984
- func(...args);
985
- }, wait);
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;
1001
- };
1002
977
  const FormItem$1 = ({
1003
978
  prefixCls = prefixClsFormItem,
1004
979
  name,
@@ -1147,17 +1122,20 @@ const FormItemChildComponent = ({
1147
1122
  const {
1148
1123
  getFieldsValue
1149
1124
  } = formContext || {};
1150
- const debouncedSetFieldValue = useRef(debounce((name, value) => {
1151
- setFieldValue(name, value, undefined, undefined, true);
1152
- }, 50)).current;
1153
- useEffect(() => {
1154
- return () => {
1155
- debouncedSetFieldValue.cancel?.();
1125
+ const debounce = useCallback((func, delay) => {
1126
+ let timeoutId = null;
1127
+ return (...args) => {
1128
+ if (timeoutId) {
1129
+ clearTimeout(timeoutId);
1130
+ }
1131
+ timeoutId = setTimeout(() => {
1132
+ func(...args);
1133
+ }, delay);
1156
1134
  };
1157
1135
  }, []);
1158
- const handleBlur = () => {
1159
- debouncedSetFieldValue.flush?.(name, fieldValue);
1160
- };
1136
+ const debouncedSetFieldValue = useRef(debounce((name, value) => {
1137
+ setFieldValue(name, value, undefined, undefined, true);
1138
+ }, 70)).current;
1161
1139
  const handleChange = (e, option) => {
1162
1140
  let rawValue = e?.target ? e.target.value : e;
1163
1141
  if (normalize) {
@@ -1197,7 +1175,6 @@ const FormItemChildComponent = ({
1197
1175
  name: name,
1198
1176
  child: child,
1199
1177
  onChange: handleChange,
1200
- onBlur: handleBlur,
1201
1178
  key: `${name}_${wasNormalize}`,
1202
1179
  value: fieldValue ?? props.value
1203
1180
  }, 'dangerouslySetInnerHTML' in childProps ? {} : {