@abgov/jsonforms-components 2.75.2 → 2.75.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/index.esm.js +23 -6
- package/package.json +1 -1
- package/renderer-catalog.json +2 -2
- package/src/lib/util/useMaskedInput.d.ts +2 -1
package/index.esm.js
CHANGED
|
@@ -13890,10 +13890,17 @@ const FullNameDobReviewControl = props => {
|
|
|
13890
13890
|
const GoAInputBaseFullNameDobControlReview = withJsonFormsAllOfProps(FullNameDobReviewControl);
|
|
13891
13891
|
|
|
13892
13892
|
// Encapsulates masked-input state for a GoA input: display value, mount reflection, and change/keypress handling.
|
|
13893
|
+
const resetMaskedValue = (detail, nextValue) => {
|
|
13894
|
+
const target = getMaskInputTarget(detail);
|
|
13895
|
+
if (target) {
|
|
13896
|
+
target.value = nextValue;
|
|
13897
|
+
}
|
|
13898
|
+
};
|
|
13893
13899
|
const useMaskedInput = ({
|
|
13894
13900
|
mask,
|
|
13895
13901
|
inPlace,
|
|
13896
13902
|
data,
|
|
13903
|
+
allowedKeys,
|
|
13897
13904
|
onCommit
|
|
13898
13905
|
}) => {
|
|
13899
13906
|
const format = value => inPlace ? toMaskTemplate(value, mask) : formatWithPattern(value, mask);
|
|
@@ -13909,20 +13916,24 @@ const useMaskedInput = ({
|
|
|
13909
13916
|
const handleChange = detail => {
|
|
13910
13917
|
var _target$selectionStar;
|
|
13911
13918
|
const rawValue = detail.value;
|
|
13919
|
+
const cleaned = allowedKeys ? filterAllowedKeys(rawValue, allowedKeys) : rawValue;
|
|
13912
13920
|
if (!inPlace) {
|
|
13913
|
-
const stored = formatWithPattern(
|
|
13921
|
+
const stored = cleaned === '' ? '' : formatWithPattern(cleaned, mask);
|
|
13922
|
+
if (allowedKeys && cleaned !== rawValue) {
|
|
13923
|
+
resetMaskedValue(detail, stored);
|
|
13924
|
+
}
|
|
13914
13925
|
setValue(stored);
|
|
13915
13926
|
onCommit(stored);
|
|
13916
13927
|
return;
|
|
13917
13928
|
}
|
|
13918
13929
|
const target = getMaskInputTarget(detail);
|
|
13919
|
-
const caretIndex = (_target$selectionStar = target == null ? void 0 : target.selectionStart) != null ? _target$selectionStar :
|
|
13920
|
-
const overflow = overflowMaskEdit(value,
|
|
13930
|
+
const caretIndex = (_target$selectionStar = target == null ? void 0 : target.selectionStart) != null ? _target$selectionStar : cleaned.length;
|
|
13931
|
+
const overflow = overflowMaskEdit(value, cleaned, caretIndex, mask);
|
|
13921
13932
|
if (overflow) {
|
|
13922
13933
|
applyInPlaceEdit(target, overflow);
|
|
13923
13934
|
return;
|
|
13924
13935
|
}
|
|
13925
|
-
const edit = computeMaskEdit(
|
|
13936
|
+
const edit = computeMaskEdit(cleaned, caretIndex, mask);
|
|
13926
13937
|
applyInPlaceEdit(target, edit);
|
|
13927
13938
|
setValue(edit.display);
|
|
13928
13939
|
onCommit(edit.stored);
|
|
@@ -13930,10 +13941,15 @@ const useMaskedInput = ({
|
|
|
13930
13941
|
// In-place has no maxLength (the template is already full length) and GoA keyPress is keyup, so restore on overflow.
|
|
13931
13942
|
const handleKeyPress = detail => {
|
|
13932
13943
|
var _detail$event, _target$value, _target$selectionStar2;
|
|
13933
|
-
|
|
13944
|
+
const blockDisallowed = shouldBlockKey(detail.key, allowedKeys);
|
|
13945
|
+
const blockOverflow = inPlace && /^[A-Za-z0-9]$/.test(detail.key) && isMaskFilled(value, mask);
|
|
13946
|
+
if (!blockDisallowed && !blockOverflow) {
|
|
13934
13947
|
return;
|
|
13935
13948
|
}
|
|
13936
13949
|
(_detail$event = detail.event) == null || _detail$event.preventDefault();
|
|
13950
|
+
if (!blockOverflow) {
|
|
13951
|
+
return;
|
|
13952
|
+
}
|
|
13937
13953
|
const target = getMaskInputTarget(detail);
|
|
13938
13954
|
const rawValue = (_target$value = target == null ? void 0 : target.value) != null ? _target$value : value;
|
|
13939
13955
|
const overflow = overflowMaskEdit(value, rawValue, (_target$selectionStar2 = target == null ? void 0 : target.selectionStart) != null ? _target$selectionStar2 : value.length, mask);
|
|
@@ -13973,6 +13989,7 @@ const PhoneNumberControl = props => {
|
|
|
13973
13989
|
mask: phoneMask,
|
|
13974
13990
|
inPlace,
|
|
13975
13991
|
data,
|
|
13992
|
+
allowedKeys: DEFAULT_PATTERNS.phone.allowedKeys,
|
|
13976
13993
|
onCommit: stored => {
|
|
13977
13994
|
setError(stored && !DEFAULT_PATTERNS.phone.pattern.test(stored) ? DEFAULT_PATTERNS.phone.error : '');
|
|
13978
13995
|
handleChange(path, stored);
|
|
@@ -13995,7 +14012,7 @@ const PhoneNumberControl = props => {
|
|
|
13995
14012
|
maxLength: inPlace ? undefined : phoneMask.length,
|
|
13996
14013
|
placeholder: inPlace ? undefined : maskPlaceholder(phoneMask),
|
|
13997
14014
|
onChange: detail => handleMaskChange(detail),
|
|
13998
|
-
onKeyPress:
|
|
14015
|
+
onKeyPress: detail => handleKeyPress(detail),
|
|
13999
14016
|
width: "100%"
|
|
14000
14017
|
})
|
|
14001
14018
|
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abgov/jsonforms-components",
|
|
3
|
-
"version": "2.75.
|
|
3
|
+
"version": "2.75.3",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "Government of Alberta - React renderers for JSON Forms based on the design system.",
|
|
6
6
|
"repository": "https://github.com/GovAlta/adsp-monorepo",
|
package/renderer-catalog.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": "1.0.0",
|
|
3
|
-
"generatedAt": "2026-09-
|
|
4
|
-
"sourceCommit": "
|
|
3
|
+
"generatedAt": "2026-09-10T20:48:43.882Z",
|
|
4
|
+
"sourceCommit": "5a1d458e5df0177e45371e7770719fd29fb0b773",
|
|
5
5
|
"sourcePath": "libs/jsonforms-components/src/index.ts",
|
|
6
6
|
"rendererCount": 33,
|
|
7
7
|
"renderers": [
|
|
@@ -10,6 +10,7 @@ interface UseMaskedInputOptions {
|
|
|
10
10
|
mask: string;
|
|
11
11
|
inPlace: boolean;
|
|
12
12
|
data: unknown;
|
|
13
|
+
allowedKeys?: RegExp;
|
|
13
14
|
onCommit: (stored: string) => void;
|
|
14
15
|
}
|
|
15
16
|
interface UseMaskedInputResult {
|
|
@@ -17,5 +18,5 @@ interface UseMaskedInputResult {
|
|
|
17
18
|
handleChange: (detail: MaskChangeDetail) => void;
|
|
18
19
|
handleKeyPress: (detail: MaskKeyPressDetail) => void;
|
|
19
20
|
}
|
|
20
|
-
export declare const useMaskedInput: ({ mask, inPlace, data, onCommit }: UseMaskedInputOptions) => UseMaskedInputResult;
|
|
21
|
+
export declare const useMaskedInput: ({ mask, inPlace, data, allowedKeys, onCommit, }: UseMaskedInputOptions) => UseMaskedInputResult;
|
|
21
22
|
export {};
|