@abgov/jsonforms-components 1.24.8 → 1.24.10
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
CHANGED
|
@@ -3207,9 +3207,10 @@ const fetchRegister = props => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
3207
3207
|
}
|
|
3208
3208
|
return undefined;
|
|
3209
3209
|
});
|
|
3210
|
-
const
|
|
3211
|
-
const
|
|
3212
|
-
|
|
3210
|
+
const isValidHref = function isValidHref(url) {
|
|
3211
|
+
const httpPattern = new RegExp(/^(http|https):\/\/[^ "]+$/);
|
|
3212
|
+
const mailToPattern = new RegExp(/^(mailto):[^ "]+$/);
|
|
3213
|
+
return httpPattern.test(url) || mailToPattern.test(url);
|
|
3213
3214
|
};
|
|
3214
3215
|
|
|
3215
3216
|
const JsonFormsRegisterContext = /*#__PURE__*/createContext(undefined);
|
|
@@ -3458,8 +3459,7 @@ const GoATextControlTester = rankWith(1, isStringControl);
|
|
|
3458
3459
|
const GoAInputTextControl = withJsonFormsControlProps(GoATextControl);
|
|
3459
3460
|
|
|
3460
3461
|
const MultiLineText = props => {
|
|
3461
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
3462
|
-
// eslint-disable-next-line
|
|
3462
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
3463
3463
|
const {
|
|
3464
3464
|
data,
|
|
3465
3465
|
config,
|
|
@@ -3471,35 +3471,69 @@ const MultiLineText = props => {
|
|
|
3471
3471
|
schema,
|
|
3472
3472
|
label
|
|
3473
3473
|
} = props;
|
|
3474
|
+
const {
|
|
3475
|
+
required
|
|
3476
|
+
} = props;
|
|
3477
|
+
const [textAreaValue, _] = React.useState(data);
|
|
3474
3478
|
const appliedUiSchemaOptions = Object.assign(Object.assign({}, config), uischema === null || uischema === void 0 ? void 0 : uischema.options);
|
|
3475
3479
|
const placeholder = (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.placeholder) || (schema === null || schema === void 0 ? void 0 : schema.description) || '';
|
|
3476
3480
|
const errorsFormInput = checkFieldValidity(props);
|
|
3477
3481
|
const autoCapitalize = ((_b = (_a = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _a === void 0 ? void 0 : _a.componentProps) === null || _b === void 0 ? void 0 : _b.autoCapitalize) === true || ((_c = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _c === void 0 ? void 0 : _c.autoCapitalize) === true;
|
|
3478
3482
|
const readOnly = (_f = (_e = (_d = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _d === void 0 ? void 0 : _d.componentProps) === null || _e === void 0 ? void 0 : _e.readOnly) !== null && _f !== void 0 ? _f : false;
|
|
3479
|
-
|
|
3483
|
+
const textAreaName = `${label || path}-text-area` || '';
|
|
3484
|
+
const textarea = (_g = document.getElementsByName(textAreaName)[0]) !== null && _g !== void 0 ? _g : null;
|
|
3485
|
+
useEffect(() => {
|
|
3486
|
+
if (textarea) {
|
|
3487
|
+
textarea.addEventListener('blur', onBlur);
|
|
3488
|
+
}
|
|
3489
|
+
return () => {
|
|
3490
|
+
if (textarea) {
|
|
3491
|
+
textarea.removeEventListener('blur', onBlur);
|
|
3492
|
+
}
|
|
3493
|
+
};
|
|
3494
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3495
|
+
}, [textarea]);
|
|
3496
|
+
const onBlur = event => {
|
|
3497
|
+
let eventTargetValue = '';
|
|
3498
|
+
if (event.target) {
|
|
3499
|
+
eventTargetValue = event.target.value;
|
|
3500
|
+
}
|
|
3501
|
+
onBlurForTextControl({
|
|
3502
|
+
name: path,
|
|
3503
|
+
controlProps: props,
|
|
3504
|
+
value: autoCapitalize ? eventTargetValue.toUpperCase() : eventTargetValue
|
|
3505
|
+
});
|
|
3506
|
+
};
|
|
3507
|
+
const txtAreaComponent = jsx(GoATextArea, Object.assign({
|
|
3480
3508
|
error: errorsFormInput.length > 0,
|
|
3481
|
-
value:
|
|
3509
|
+
value: textAreaValue,
|
|
3482
3510
|
disabled: !enabled,
|
|
3483
3511
|
readOnly: readOnly,
|
|
3484
3512
|
placeholder: placeholder,
|
|
3485
3513
|
testId: (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.testId) || `${id}-input`,
|
|
3486
|
-
name:
|
|
3514
|
+
name: textAreaName,
|
|
3487
3515
|
width: '100%',
|
|
3488
3516
|
// Note: Paul Jan-09-2023. The latest ui-component come with the maxCount. We need to uncomment the following line when the component is updated
|
|
3489
3517
|
// maxCount={schema.maxLength || 256}
|
|
3490
3518
|
onKeyPress: (name, value, key) => {
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
|
|
3519
|
+
const newValue = autoCapitalize ? value.toUpperCase() : value;
|
|
3520
|
+
if (value.length === 0) {
|
|
3521
|
+
onKeyPressForTextControl({
|
|
3522
|
+
name,
|
|
3523
|
+
value: newValue,
|
|
3524
|
+
key,
|
|
3525
|
+
controlProps: props
|
|
3526
|
+
});
|
|
3527
|
+
} else if (required && errorsFormInput.length === 0 && value.length > 0) {
|
|
3528
|
+
handleChange(path, newValue);
|
|
3529
|
+
}
|
|
3497
3530
|
},
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
}, (
|
|
3531
|
+
onChange: (name, value) => {
|
|
3532
|
+
const newValue = autoCapitalize ? value.toUpperCase() : value;
|
|
3533
|
+
handleChange(path, newValue);
|
|
3534
|
+
}
|
|
3535
|
+
}, (_h = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _h === void 0 ? void 0 : _h.componentProps));
|
|
3536
|
+
return txtAreaComponent;
|
|
3503
3537
|
};
|
|
3504
3538
|
const MultiLineTextControlInput = props => jsx(GoAInputBaseControl, Object.assign({}, props, {
|
|
3505
3539
|
input: MultiLineText
|
|
@@ -6310,7 +6344,7 @@ const RenderLink = props => {
|
|
|
6310
6344
|
}
|
|
6311
6345
|
useEffect(() => {
|
|
6312
6346
|
if (linkUrl) {
|
|
6313
|
-
setLinkValid(
|
|
6347
|
+
setLinkValid(isValidHref(linkUrl));
|
|
6314
6348
|
}
|
|
6315
6349
|
}, [linkUrl]);
|
|
6316
6350
|
if (!linkLabel && !error) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abgov/jsonforms-components",
|
|
3
|
-
"version": "1.24.
|
|
3
|
+
"version": "1.24.10",
|
|
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",
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { CellProps, WithClassname, ControlProps, RankedTester } from '@jsonforms/core';
|
|
3
3
|
import { WithInputProps } from './type';
|
|
4
4
|
export type GoAInputMultiLineTextProps = CellProps & WithClassname & WithInputProps;
|
|
5
5
|
export declare const MultiLineText: (props: GoAInputMultiLineTextProps) => JSX.Element;
|
|
6
6
|
export declare const MultiLineTextControlInput: (props: ControlProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
7
|
export declare const MultiLineTextControlTester: RankedTester;
|
|
8
|
-
export declare const MultiLineTextControl:
|
|
8
|
+
export declare const MultiLineTextControl: React.ComponentType<import("@jsonforms/core").OwnPropsOfControl>;
|