@symply.io/basic-components 1.5.5-alpha.2 → 1.5.5-alpha.3
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/NumberInput/index.js
CHANGED
@@ -40,8 +40,8 @@ function NumberInput(props) {
|
|
40
40
|
decimals: decimals,
|
41
41
|
integerOnly: integerOnly,
|
42
42
|
onChange: onChange
|
43
|
-
}), typing = _f.typing, exceedError = _f.exceedError, tooltipOpen = _f.tooltipOpen, roundedValue = _f.roundedValue, handleBlur = _f.handleBlur, handleFocus = _f.handleFocus, handleChange = _f.handleChange, onOpenTooltip = _f.onOpenTooltip, onCloseTooltip = _f.onCloseTooltip, handleKeyboardEvent = _f.handleKeyboardEvent;
|
43
|
+
}), typing = _f.typing, exceedError = _f.exceedError, tooltipOpen = _f.tooltipOpen, roundedValue = _f.roundedValue, handleBlur = _f.handleBlur, handleFocus = _f.handleFocus, handleClick = _f.handleClick, handleChange = _f.handleChange, onOpenTooltip = _f.onOpenTooltip, onCloseTooltip = _f.onCloseTooltip, handleKeyboardEvent = _f.handleKeyboardEvent;
|
44
44
|
var valueDisplay = useMemo(function () { return (typing ? value : roundedValue); }, [typing, value, roundedValue]);
|
45
|
-
return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(Tooltip, __assign({ arrow: true, placement: "top", title: tooltip !== null && tooltip !== void 0 ? tooltip : "", open: !!tooltip && tooltipOpen }, { children: _jsx(Field, __assign({ size: size, margin: "dense", type: "number", value: value === undefined || value === null ? "" : valueDisplay, onMouseEnter: onOpenTooltip, onMouseLeave: onCloseTooltip, onBlur: handleBlur, onFocus: handleFocus, onChange: handleChange, error: error || exceedError, helperText: helperText || (exceedError ? EXCEED_ERROR : ""), inputProps: { onKeyDown: handleKeyboardEvent } }, rest)) })) })));
|
45
|
+
return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(Tooltip, __assign({ arrow: true, placement: "top", title: tooltip !== null && tooltip !== void 0 ? tooltip : "", open: !!tooltip && tooltipOpen }, { children: _jsx(Field, __assign({ size: size, margin: "dense", type: "number", value: value === undefined || value === null ? "" : valueDisplay, onMouseEnter: onOpenTooltip, onMouseLeave: onCloseTooltip, onBlur: handleBlur, onFocus: handleFocus, onChange: handleChange, error: error || exceedError, helperText: helperText || (exceedError ? EXCEED_ERROR : ""), inputProps: { onKeyDown: handleKeyboardEvent, onClick: handleClick } }, rest)) })) })));
|
46
46
|
}
|
47
47
|
export default NumberInput;
|
package/NumberInput/types.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { CSSProperties, ChangeEvent, FocusEventHandler, KeyboardEventHandler } from "react";
|
1
|
+
import { CSSProperties, ChangeEvent, MouseEventHandler, FocusEventHandler, KeyboardEventHandler } from "react";
|
2
2
|
import { TextFieldProps } from "@mui/material/TextField";
|
3
3
|
export interface InteractionStates {
|
4
4
|
typing: boolean;
|
@@ -7,6 +7,7 @@ export interface InteractionStates {
|
|
7
7
|
roundedValue: string;
|
8
8
|
exceedError: boolean;
|
9
9
|
handleKeyboardEvent: KeyboardEventHandler<HTMLInputElement | HTMLTextAreaElement>;
|
10
|
+
handleClick: MouseEventHandler<HTMLInputElement | HTMLTextAreaElement>;
|
10
11
|
handleChange: (event: ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
|
11
12
|
handleFocus: FocusEventHandler<HTMLInputElement | HTMLTextAreaElement>;
|
12
13
|
handleBlur: FocusEventHandler<HTMLInputElement | HTMLTextAreaElement>;
|
@@ -7,6 +7,7 @@ declare function useInteractions(props: InteractionProps): {
|
|
7
7
|
roundedValue: string;
|
8
8
|
handleBlur: FocusEventHandler<HTMLInputElement | HTMLTextAreaElement>;
|
9
9
|
handleFocus: FocusEventHandler<HTMLInputElement | HTMLTextAreaElement>;
|
10
|
+
handleClick: import("react").MouseEventHandler<HTMLInputElement | HTMLTextAreaElement>;
|
10
11
|
handleChange: (event: ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
|
11
12
|
onOpenTooltip: () => void;
|
12
13
|
onCloseTooltip: () => void;
|
@@ -74,10 +74,16 @@ function useInteractions(props) {
|
|
74
74
|
return;
|
75
75
|
onChange(val);
|
76
76
|
}, [onChange, minValue, integerOnly]);
|
77
|
-
var
|
77
|
+
var handleClick = useCallback(function (event) {
|
78
|
+
console.log({
|
79
|
+
cts: event.currentTarget.selectionStart,
|
80
|
+
cte: event.currentTarget.selectionEnd
|
81
|
+
});
|
82
|
+
setCursorIndex(event.currentTarget.selectionStart || 0);
|
83
|
+
}, []);
|
84
|
+
var handleFocus = useCallback(function () {
|
78
85
|
setTyping(true);
|
79
|
-
|
80
|
-
}, [value]);
|
86
|
+
}, []);
|
81
87
|
var handleBlur = useCallback(function () {
|
82
88
|
var excludedValue = [
|
83
89
|
null,
|
@@ -112,6 +118,7 @@ function useInteractions(props) {
|
|
112
118
|
roundedValue: roundedValue,
|
113
119
|
handleBlur: handleBlur,
|
114
120
|
handleFocus: handleFocus,
|
121
|
+
handleClick: handleClick,
|
115
122
|
handleChange: handleChange,
|
116
123
|
onOpenTooltip: onOpenTooltip,
|
117
124
|
onCloseTooltip: onCloseTooltip,
|