jy-headless 0.2.31 → 0.2.32
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.
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { InputProps } from '../../types';
|
|
2
|
-
declare const Input: ({ id, suffixElement, prefixElement, wrapperStyle, wrapperClass, onChange, timeout, useThrottle, children, ...props }: InputProps) => import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
declare const Input: ({ id, value, suffixElement, prefixElement, wrapperStyle, wrapperClass, onChange, timeout, useThrottle, children, showLimit, maxLength, ...props }: InputProps) => import("react/jsx-runtime").JSX.Element;
|
|
3
3
|
export default Input;
|
|
@@ -3,9 +3,13 @@
|
|
|
3
3
|
var jsxRuntime = require('react/jsx-runtime');
|
|
4
4
|
var useThrottling = require('../../hooks/useThrottling.js');
|
|
5
5
|
|
|
6
|
-
const Input = ({ id, suffixElement, prefixElement, wrapperStyle, wrapperClass = [], onChange, timeout = 300, useThrottle = false, children, ...props }) => {
|
|
7
|
-
const handleChange =
|
|
8
|
-
|
|
6
|
+
const Input = ({ id, value, suffixElement, prefixElement, wrapperStyle, wrapperClass = [], onChange, timeout = 300, useThrottle = false, children, showLimit, maxLength, ...props }) => {
|
|
7
|
+
const handleChange = (e) => {
|
|
8
|
+
if (maxLength && e.target.value?.length > maxLength)
|
|
9
|
+
return;
|
|
10
|
+
(onChange && useThrottle ? useThrottling(onChange, timeout) : onChange)?.(e);
|
|
11
|
+
};
|
|
12
|
+
return (jsxRuntime.jsxs("span", { "data-testid": 'input-wrapper', id: [id, 'input-wrapper'].join('-'), className: wrapperClass?.join(' '), style: wrapperStyle, children: [prefixElement, jsxRuntime.jsx("input", { role: 'textbox', id: id, value: value, onChange: handleChange, ...props }), showLimit && maxLength && (jsxRuntime.jsxs("span", { id: [id, 'input-limit'].join('-'), children: [(value ?? '').toString().length, "/", maxLength] })), suffixElement] }));
|
|
9
13
|
};
|
|
10
14
|
|
|
11
15
|
module.exports = Input;
|
package/inputs/Input/Input.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { InputProps } from '../../types';
|
|
2
|
-
declare const Input: ({ id, suffixElement, prefixElement, wrapperStyle, wrapperClass, onChange, timeout, useThrottle, children, ...props }: InputProps) => import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
declare const Input: ({ id, value, suffixElement, prefixElement, wrapperStyle, wrapperClass, onChange, timeout, useThrottle, children, showLimit, maxLength, ...props }: InputProps) => import("react/jsx-runtime").JSX.Element;
|
|
3
3
|
export default Input;
|
package/inputs/Input/Input.js
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
2
|
import useThrottling from '../../hooks/useThrottling.js';
|
|
3
3
|
|
|
4
|
-
const Input = ({ id, suffixElement, prefixElement, wrapperStyle, wrapperClass = [], onChange, timeout = 300, useThrottle = false, children, ...props }) => {
|
|
5
|
-
const handleChange =
|
|
6
|
-
|
|
4
|
+
const Input = ({ id, value, suffixElement, prefixElement, wrapperStyle, wrapperClass = [], onChange, timeout = 300, useThrottle = false, children, showLimit, maxLength, ...props }) => {
|
|
5
|
+
const handleChange = (e) => {
|
|
6
|
+
if (maxLength && e.target.value?.length > maxLength)
|
|
7
|
+
return;
|
|
8
|
+
(onChange && useThrottle ? useThrottling(onChange, timeout) : onChange)?.(e);
|
|
9
|
+
};
|
|
10
|
+
return (jsxs("span", { "data-testid": 'input-wrapper', id: [id, 'input-wrapper'].join('-'), className: wrapperClass?.join(' '), style: wrapperStyle, children: [prefixElement, jsx("input", { role: 'textbox', id: id, value: value, onChange: handleChange, ...props }), showLimit && maxLength && (jsxs("span", { id: [id, 'input-limit'].join('-'), children: [(value ?? '').toString().length, "/", maxLength] })), suffixElement] }));
|
|
7
11
|
};
|
|
8
12
|
|
|
9
13
|
export { Input as default };
|
package/package.json
CHANGED
package/types/inputs/index.d.ts
CHANGED
package/version.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.2.
|
|
1
|
+
0.2.32
|