@antscorp/antsomi-ui 1.3.3-beta.76 → 1.3.3-beta.77
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.
|
@@ -25,6 +25,7 @@ export const AllowDynamicType = {
|
|
|
25
25
|
const defaultProps = {
|
|
26
26
|
value: '',
|
|
27
27
|
isViewMode: false,
|
|
28
|
+
isRealTime: true,
|
|
28
29
|
errors: [],
|
|
29
30
|
canMultipleLine: false,
|
|
30
31
|
apiConfig: {
|
|
@@ -43,7 +44,7 @@ const defaultProps = {
|
|
|
43
44
|
addMessageToQueue: () => { },
|
|
44
45
|
};
|
|
45
46
|
export const InputDynamic = (props) => {
|
|
46
|
-
const { value, isViewMode, errors, disabledOpts, disabled, canMultipleLine, allowDynamicOptions, showIndex, showDisplayFormat, isShowCustomFunction, apiConfig, onError, onChange, addMessageToQueue, } = props;
|
|
47
|
+
const { value, isViewMode, isRealTime, errors, disabledOpts, disabled, canMultipleLine, allowDynamicOptions, showIndex, showDisplayFormat, isShowCustomFunction, apiConfig, onError, onChange, addMessageToQueue, } = props;
|
|
47
48
|
// States
|
|
48
49
|
const [textValue, setTextValue] = useState(initialValue(value));
|
|
49
50
|
const [initSelectedProperties, setInitSelectedProperties] = useState({
|
|
@@ -75,6 +76,7 @@ export const InputDynamic = (props) => {
|
|
|
75
76
|
const [tooltipHoverDebounce, _tooltipHover, setTooltipHover] = useDebounce({ x: 0, y: 0 }, 200);
|
|
76
77
|
// Refs
|
|
77
78
|
const caretPositionRef = useRef(null);
|
|
79
|
+
const timerRef = useRef();
|
|
78
80
|
const personalizationInputRef = useRef(null);
|
|
79
81
|
const isRenderAddDynamicContent = useMemo(() => {
|
|
80
82
|
if (isEmpty(apiConfig) ||
|
|
@@ -244,7 +246,17 @@ export const InputDynamic = (props) => {
|
|
|
244
246
|
console.log(error);
|
|
245
247
|
}
|
|
246
248
|
};
|
|
249
|
+
const handleChangeInputDebounce = () => {
|
|
250
|
+
clearTimeout(timerRef.current);
|
|
251
|
+
timerRef.current = setTimeout(() => {
|
|
252
|
+
caretPositionRef.current = CaretPositioning.saveSelection(personalizationInputRef.current);
|
|
253
|
+
onTriggerChange();
|
|
254
|
+
}, 1000);
|
|
255
|
+
};
|
|
247
256
|
const handleKeyPress = (e) => {
|
|
257
|
+
if (isRealTime) {
|
|
258
|
+
handleChangeInputDebounce();
|
|
259
|
+
}
|
|
248
260
|
if (canMultipleLine)
|
|
249
261
|
return;
|
|
250
262
|
if (+e.charCode === 13) {
|
|
@@ -11,6 +11,7 @@ export type AllowDynamicOptions = (typeof AllowDynamicType)[keyof typeof AllowDy
|
|
|
11
11
|
export type InputDynamicProps = {
|
|
12
12
|
value: string;
|
|
13
13
|
isViewMode?: boolean;
|
|
14
|
+
isRealTime?: boolean;
|
|
14
15
|
errors?: string[];
|
|
15
16
|
disabled?: boolean;
|
|
16
17
|
disabledOpts?: DisableShortLinkTypeProps;
|