@versini/ui-textinput 6.2.0 → 6.3.0
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.d.ts +21 -17
- package/dist/index.js +32 -33
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { JSX } from 'react/jsx-runtime';
|
|
2
|
-
import { default as React_2 } from 'react';
|
|
3
2
|
|
|
4
3
|
declare type CommonTextInputProps = {
|
|
5
4
|
/**
|
|
@@ -68,24 +67,29 @@ export declare const TEXT_INPUT_WRAPPER_CLASSNAME = "av-text-input-wrapper";
|
|
|
68
67
|
|
|
69
68
|
export declare function TextInput({ id, name, label, error, raw, className, inputClassName, mode, focusMode, disabled, noBorder, labelId, labelHidden, type, helperText, rightElement, rightElementClassName, size, ref, ...extraProps }: TextInputProps): JSX.Element;
|
|
70
69
|
|
|
71
|
-
export declare
|
|
72
|
-
|
|
70
|
+
export declare function TextInputMask({ name, disabled, label, labelHidden, onMaskChange, onChange, onBlur, onFocus, onTextInputMaskBlur, rightElement, ref, ...otherProps }: TextInputMaskProps): JSX.Element;
|
|
71
|
+
|
|
72
|
+
declare type TextInputMaskProps = {
|
|
73
|
+
/**
|
|
74
|
+
* A ref to the input element.
|
|
75
|
+
*/
|
|
76
|
+
ref?: React.Ref<HTMLInputElement>;
|
|
77
|
+
/**
|
|
78
|
+
* This prop allows you to pass in a React element to render on the right
|
|
79
|
+
* side of the TextInput. This is useful for adding icons or actionable
|
|
80
|
+
* elements, such a Button.
|
|
81
|
+
*/
|
|
82
|
+
rightElement: React.ReactElement;
|
|
83
|
+
/**
|
|
84
|
+
* Callback fired when the value changes.
|
|
85
|
+
* @param masked whether or not the value is masked
|
|
86
|
+
*/
|
|
73
87
|
onMaskChange?: (masked: boolean) => void;
|
|
88
|
+
/**
|
|
89
|
+
* Callback fired when the user blurs out of the TextInputMask.
|
|
90
|
+
*/
|
|
74
91
|
onTextInputMaskBlur?: () => void;
|
|
75
|
-
} &
|
|
76
|
-
label: string;
|
|
77
|
-
name: string;
|
|
78
|
-
error?: boolean;
|
|
79
|
-
focusMode?: "dark" | "light" | "system" | "alt-system";
|
|
80
|
-
helperText?: string;
|
|
81
|
-
inputClassName?: string;
|
|
82
|
-
labelHidden?: boolean;
|
|
83
|
-
labelId?: string;
|
|
84
|
-
mode?: "dark" | "light" | "system" | "alt-system";
|
|
85
|
-
noBorder?: boolean;
|
|
86
|
-
raw?: boolean;
|
|
87
|
-
size?: Size;
|
|
88
|
-
} & Omit<React_2.InputHTMLAttributes<HTMLInputElement>, "size"> & React_2.RefAttributes<HTMLInputElement>>;
|
|
92
|
+
} & CommonTextInputProps;
|
|
89
93
|
|
|
90
94
|
declare type TextInputProps = {
|
|
91
95
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
@versini/ui-textinput v6.
|
|
2
|
+
@versini/ui-textinput v6.3.0
|
|
3
3
|
© 2025 gizmette.com
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -301,7 +301,7 @@ function TextInput({ id, name, label, error = false, raw = false, className, inp
|
|
|
301
301
|
const CLEAR_ANNOUNCEMENT_TIMEOUT = 500;
|
|
302
302
|
const AUTO_HIDE_CLEAR_ANNOUNCEMENT_TIMEOUT = 5000;
|
|
303
303
|
const AUTO_HIDE_TIMEOUT = 20000;
|
|
304
|
-
|
|
304
|
+
function TextInputMask({ name, disabled, label, labelHidden, onMaskChange, onChange, onBlur, onFocus, onTextInputMaskBlur, rightElement, ref, ...otherProps }) {
|
|
305
305
|
const [masked, setMasked] = useState(true);
|
|
306
306
|
const [liveRegionStatus, setLiveRegionStatus] = useState({
|
|
307
307
|
message: null,
|
|
@@ -327,9 +327,9 @@ const TextInputMask = /*#__PURE__*/ react.forwardRef(({ name, disabled, label, l
|
|
|
327
327
|
message: `${label} hiding characters`
|
|
328
328
|
});
|
|
329
329
|
/**
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
330
|
+
* Callback that can be used to generate
|
|
331
|
+
* show/hide analytics.
|
|
332
|
+
*/ onMaskChange && onMaskChange(true);
|
|
333
333
|
}, AUTO_HIDE_TIMEOUT);
|
|
334
334
|
}
|
|
335
335
|
};
|
|
@@ -345,19 +345,19 @@ const TextInputMask = /*#__PURE__*/ react.forwardRef(({ name, disabled, label, l
|
|
|
345
345
|
message: newHiddenState ? "Characters hidden" : "Characters showing"
|
|
346
346
|
});
|
|
347
347
|
/**
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
348
|
+
* Callback that can be used to generate
|
|
349
|
+
* show/hide analytics.
|
|
350
|
+
*/ onMaskChange && onMaskChange(newHiddenState);
|
|
351
351
|
};
|
|
352
352
|
const handleTextInputMaskBlur = (e)=>{
|
|
353
353
|
const { relatedTarget } = e;
|
|
354
354
|
/**
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
355
|
+
* If the related target is not a child of the input,
|
|
356
|
+
* then the blur is leaving the input
|
|
357
|
+
* and not going to a child of the input.
|
|
358
|
+
* This is the case when the user blurs from the show/hide button.
|
|
359
|
+
* In this case, we want to call the onTextInputMaskBlur callback.
|
|
360
|
+
*/ const parent = inputRef.current?.parentElement;
|
|
361
361
|
if (!parent?.contains(relatedTarget)) {
|
|
362
362
|
onTextInputMaskBlur && onTextInputMaskBlur();
|
|
363
363
|
}
|
|
@@ -381,23 +381,23 @@ const TextInputMask = /*#__PURE__*/ react.forwardRef(({ name, disabled, label, l
|
|
|
381
381
|
};
|
|
382
382
|
}, []);
|
|
383
383
|
/**
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
384
|
+
* TextInputMask rules.
|
|
385
|
+
*
|
|
386
|
+
* If button label is "Show", then characters must be masked.
|
|
387
|
+
* - Type is set to password e.g. <input type="password">.
|
|
388
|
+
* - Once button is clicked, toggle the input text to show characters
|
|
389
|
+
* (type="text") and live region (aria-live="assertive") should
|
|
390
|
+
* announce, "showing characters" or similar.
|
|
391
|
+
* If button label is "Hide", then characters must be unmasked.
|
|
392
|
+
* Type is set to password e.g. <input type="text">.
|
|
393
|
+
* - Once button is clicked, toggle the input text to hide characters
|
|
394
|
+
* (type="password") and live region (aria-live="assertive") should
|
|
395
|
+
* announce, "hiding characters" or similar.
|
|
396
|
+
* If 20 seconds have passed and text input mask field has no focus-in nor
|
|
397
|
+
* keystrokes while text input mask characters are shown, then hide characters,
|
|
398
|
+
* toggle control label back to "Show", and use aria-live="polite" to announce
|
|
399
|
+
* "[text input mask label] hiding characters" or similar.
|
|
400
|
+
*/ return /*#__PURE__*/ jsxs(Fragment, {
|
|
401
401
|
children: [
|
|
402
402
|
/*#__PURE__*/ jsx(TextInput, {
|
|
403
403
|
ref: mergedInputRef,
|
|
@@ -426,8 +426,7 @@ const TextInputMask = /*#__PURE__*/ react.forwardRef(({ name, disabled, label, l
|
|
|
426
426
|
})
|
|
427
427
|
]
|
|
428
428
|
});
|
|
429
|
-
}
|
|
430
|
-
TextInputMask.displayName = "TextInputMask";
|
|
429
|
+
}
|
|
431
430
|
|
|
432
431
|
;// CONCATENATED MODULE: ./src/components/index.ts
|
|
433
432
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@versini/ui-textinput",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.3.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Arno Versini",
|
|
6
6
|
"publishConfig": {
|
|
@@ -38,17 +38,17 @@
|
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@testing-library/jest-dom": "6.9.1",
|
|
41
|
-
"@versini/ui-types": "8.
|
|
41
|
+
"@versini/ui-types": "8.2.0"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@tailwindcss/typography": "0.5.19",
|
|
45
45
|
"@versini/ui-hooks": "6.1.1",
|
|
46
|
-
"@versini/ui-liveregion": "3.2.
|
|
46
|
+
"@versini/ui-liveregion": "3.2.2",
|
|
47
47
|
"clsx": "2.1.1",
|
|
48
48
|
"tailwindcss": "4.1.18"
|
|
49
49
|
},
|
|
50
50
|
"sideEffects": [
|
|
51
51
|
"**/*.css"
|
|
52
52
|
],
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "5cc3c9aaf61ca3843f16a3d6b322a92f7fb210ca"
|
|
54
54
|
}
|