@abgov/jsonforms-components 1.53.8 → 1.53.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
|
@@ -2635,7 +2635,7 @@ const invalidSin = 'Social insurance number is invalid';
|
|
|
2635
2635
|
* @param words
|
|
2636
2636
|
* @returns sentence word string.
|
|
2637
2637
|
*/
|
|
2638
|
-
const capitalizeFirstLetter = words => {
|
|
2638
|
+
const capitalizeFirstLetter$1 = words => {
|
|
2639
2639
|
const value = words.charAt(0).toUpperCase() + words.slice(1).toLowerCase();
|
|
2640
2640
|
return value;
|
|
2641
2641
|
};
|
|
@@ -2661,7 +2661,7 @@ const controlScopeMatchesLabel = (scope, label) => {
|
|
|
2661
2661
|
const getLabelText = (scope, label) => {
|
|
2662
2662
|
let labelToUpdate = '';
|
|
2663
2663
|
if (controlScopeMatchesLabel(scope, label || '') && !areAllUppercase(label)) {
|
|
2664
|
-
labelToUpdate = capitalizeFirstLetter(label || '');
|
|
2664
|
+
labelToUpdate = capitalizeFirstLetter$1(label || '');
|
|
2665
2665
|
} else {
|
|
2666
2666
|
labelToUpdate = label || '';
|
|
2667
2667
|
}
|
|
@@ -2709,7 +2709,7 @@ const checkFieldValidity = props => {
|
|
|
2709
2709
|
uischema,
|
|
2710
2710
|
schema
|
|
2711
2711
|
} = props;
|
|
2712
|
-
const labelToUpdate = getLabelText(uischema.scope, label);
|
|
2712
|
+
const labelToUpdate = (uischema === null || uischema === void 0 ? void 0 : uischema.scope) ? getLabelText(uischema === null || uischema === void 0 ? void 0 : uischema.scope, label) : label;
|
|
2713
2713
|
const extraSchema = schema;
|
|
2714
2714
|
if (extraSchema && data && (extraSchema === null || extraSchema === void 0 ? void 0 : extraSchema.title) === sinTitle) {
|
|
2715
2715
|
if (data.length === 11 && !validateSinWithLuhn(data)) {
|
|
@@ -2991,7 +2991,7 @@ const onChangeForInputControl = props => {
|
|
|
2991
2991
|
handleChange,
|
|
2992
2992
|
path
|
|
2993
2993
|
} = controlProps;
|
|
2994
|
-
handleChange(path, value);
|
|
2994
|
+
handleChange(path, value === '' ? undefined : value);
|
|
2995
2995
|
};
|
|
2996
2996
|
/**
|
|
2997
2997
|
* Helper function to process onChange event for Date controls.
|
|
@@ -3043,6 +3043,8 @@ const onChangeForNumericControl = props => {
|
|
|
3043
3043
|
}
|
|
3044
3044
|
handleChange(path, newValue);
|
|
3045
3045
|
}
|
|
3046
|
+
} else {
|
|
3047
|
+
handleChange(path, value);
|
|
3046
3048
|
}
|
|
3047
3049
|
};
|
|
3048
3050
|
/**
|
|
@@ -4470,9 +4472,6 @@ const GoAInputText = props => {
|
|
|
4470
4472
|
// maxLength={appliedUiSchemaOptions?.maxLength}
|
|
4471
4473
|
name: (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.name) || `${id || label}-input`,
|
|
4472
4474
|
testId: (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.testId) || `${id}-input`,
|
|
4473
|
-
// Don't use handleChange in the onChange event, use the keyPress or onBlur.
|
|
4474
|
-
// If you use it onChange along with keyPress event it will cause a
|
|
4475
|
-
// side effect that causes the validation to render when it shouldn't.
|
|
4476
4475
|
onChange: (name, value) => {
|
|
4477
4476
|
let formattedValue = value;
|
|
4478
4477
|
if (schema && schema.title === sinTitle && value !== '') {
|
|
@@ -6793,7 +6792,8 @@ let _$2 = t => t,
|
|
|
6793
6792
|
_t11,
|
|
6794
6793
|
_t12,
|
|
6795
6794
|
_t13,
|
|
6796
|
-
_t14
|
|
6795
|
+
_t14,
|
|
6796
|
+
_t15;
|
|
6797
6797
|
const DeleteDialogContent = styled.div(_t$2 || (_t$2 = _$2`
|
|
6798
6798
|
margin-bottom: var(--goa-space-m);
|
|
6799
6799
|
`));
|
|
@@ -6813,47 +6813,52 @@ const ObjectArrayTitle = styled.h3(_t4$1 || (_t4$1 = _$2`
|
|
|
6813
6813
|
font-size: var(--goa-font-size-2);
|
|
6814
6814
|
}
|
|
6815
6815
|
`));
|
|
6816
|
-
const
|
|
6816
|
+
const RequiredSpan = styled.span(_t5$1 || (_t5$1 = _$2`
|
|
6817
|
+
color: #666666;
|
|
6818
|
+
font-weight: var(--goa-font-weight-regular);
|
|
6819
|
+
font-size: var(--goa-font-size-2);
|
|
6820
|
+
`));
|
|
6821
|
+
const TextCenter = styled.div(_t6$1 || (_t6$1 = _$2`
|
|
6817
6822
|
text-align: center;
|
|
6818
6823
|
`));
|
|
6819
|
-
const SideMenuItem = styled.div(
|
|
6824
|
+
const SideMenuItem = styled.div(_t7 || (_t7 = _$2`
|
|
6820
6825
|
&:hover {
|
|
6821
6826
|
background: #f1f1f1;
|
|
6822
6827
|
}
|
|
6823
6828
|
`));
|
|
6824
|
-
const RowFlex = styled.div(
|
|
6829
|
+
const RowFlex = styled.div(_t8 || (_t8 = _$2`
|
|
6825
6830
|
display: flex;
|
|
6826
6831
|
align-items: stretch;
|
|
6827
6832
|
`));
|
|
6828
|
-
const RowFlexMenu = styled.div(
|
|
6833
|
+
const RowFlexMenu = styled.div(_t9 || (_t9 = _$2`
|
|
6829
6834
|
display: flex;
|
|
6830
6835
|
flex-direction: row;
|
|
6831
6836
|
border-bottom: 1px solid #dcdcdc;
|
|
6832
6837
|
`));
|
|
6833
|
-
const FlexTabs = styled.div(
|
|
6838
|
+
const FlexTabs = styled.div(_t10 || (_t10 = _$2`
|
|
6834
6839
|
flex-direction: column;
|
|
6835
6840
|
flex: 1;
|
|
6836
6841
|
overflow-y: auto !important;
|
|
6837
6842
|
margin-right: 1.5rem;
|
|
6838
6843
|
`));
|
|
6839
|
-
const FlexForm = styled.div(
|
|
6844
|
+
const FlexForm = styled.div(_t11 || (_t11 = _$2`
|
|
6840
6845
|
flex-direction: column;
|
|
6841
6846
|
margin: 1.5rem 0;
|
|
6842
6847
|
flex: 3;
|
|
6843
6848
|
`));
|
|
6844
|
-
const TabName = styled.div(
|
|
6849
|
+
const TabName = styled.div(_t12 || (_t12 = _$2`
|
|
6845
6850
|
margin: 1rem 0 1rem 1rem;
|
|
6846
6851
|
font-weight: 700;
|
|
6847
6852
|
`));
|
|
6848
|
-
const Trash = styled.div(
|
|
6853
|
+
const Trash = styled.div(_t13 || (_t13 = _$2`
|
|
6849
6854
|
margin: 0.75rem 1.25rem 0.75rem 0.75rem;
|
|
6850
6855
|
margin-left: auto;
|
|
6851
6856
|
`));
|
|
6852
|
-
const ListContainer = styled.div(
|
|
6857
|
+
const ListContainer = styled.div(_t14 || (_t14 = _$2`
|
|
6853
6858
|
padding: 0 1.5rem 0 0;
|
|
6854
6859
|
border: 1px solid #dcdcdc;
|
|
6855
6860
|
`));
|
|
6856
|
-
const TableTHHeader = styled.th(
|
|
6861
|
+
const TableTHHeader = styled.th(_t15 || (_t15 = _$2`
|
|
6857
6862
|
background-color: var(--goa-color-greyscale-100) !important;
|
|
6858
6863
|
`));
|
|
6859
6864
|
|
|
@@ -6928,7 +6933,7 @@ const ObjectArrayToolBar = /*#__PURE__*/React.memo(function TableToolbar({
|
|
|
6928
6933
|
"aria-label": translations.addAriaLabel,
|
|
6929
6934
|
onClick: addItem(path, createDefaultValue(schema, rootSchema)),
|
|
6930
6935
|
type: (_c = (_b = uischema.options) === null || _b === void 0 ? void 0 : _b.addButtonType) !== null && _c !== void 0 ? _c : 'primary',
|
|
6931
|
-
children: ((_d = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _d === void 0 ? void 0 : _d.addButtonText) || capitalizeFirstLetter(`Add ${arrayLabel}`)
|
|
6936
|
+
children: ((_d = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _d === void 0 ? void 0 : _d.addButtonText) || capitalizeFirstLetter$1(`Add ${arrayLabel}`)
|
|
6932
6937
|
})
|
|
6933
6938
|
})
|
|
6934
6939
|
});
|
|
@@ -6955,7 +6960,13 @@ function objectListReducer(state, action) {
|
|
|
6955
6960
|
category
|
|
6956
6961
|
} = action.payload;
|
|
6957
6962
|
const newCategories = Object.assign({}, categories);
|
|
6958
|
-
newCategories[name]
|
|
6963
|
+
if (!newCategories[name]) {
|
|
6964
|
+
newCategories[name] = {
|
|
6965
|
+
data: category
|
|
6966
|
+
};
|
|
6967
|
+
} else {
|
|
6968
|
+
newCategories[name].data = category;
|
|
6969
|
+
}
|
|
6959
6970
|
return Object.assign(Object.assign({}, state), {
|
|
6960
6971
|
categories: newCategories
|
|
6961
6972
|
});
|
|
@@ -7090,8 +7101,12 @@ const ctxToNonEmptyCellProps$1 = (ctx, ownProps) => {
|
|
|
7090
7101
|
handleChange: ownProps.handleChange
|
|
7091
7102
|
};
|
|
7092
7103
|
};
|
|
7104
|
+
function capitalizeFirstLetter(str) {
|
|
7105
|
+
if (!str) return ''; // Handle empty strings
|
|
7106
|
+
return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
|
|
7107
|
+
}
|
|
7093
7108
|
const NonEmptyCellComponent$1 = /*#__PURE__*/React.memo(function NonEmptyCellComponent(props) {
|
|
7094
|
-
var _a;
|
|
7109
|
+
var _a, _b;
|
|
7095
7110
|
const {
|
|
7096
7111
|
schema,
|
|
7097
7112
|
enabled,
|
|
@@ -7107,10 +7122,11 @@ const NonEmptyCellComponent$1 = /*#__PURE__*/React.memo(function NonEmptyCellCom
|
|
|
7107
7122
|
errors
|
|
7108
7123
|
} = props;
|
|
7109
7124
|
const properties = (schema === null || schema === void 0 ? void 0 : schema.items) && 'properties' in schema.items && schema.items.properties || {};
|
|
7125
|
+
const required = (_a = schema.items) === null || _a === void 0 ? void 0 : _a.required;
|
|
7110
7126
|
return jsxs(NonEmptyCellStyle, {
|
|
7111
7127
|
children: [
|
|
7112
7128
|
// eslint-disable-next-line
|
|
7113
|
-
(
|
|
7129
|
+
(_b = uischema === null || uischema === void 0 ? void 0 : uischema.elements) === null || _b === void 0 ? void 0 : _b.map(element => {
|
|
7114
7130
|
return jsx(JsonFormsDispatch, {
|
|
7115
7131
|
"data-testid": `jsonforms-object-list-defined-elements-dispatch`,
|
|
7116
7132
|
schema: schema,
|
|
@@ -7127,8 +7143,10 @@ const NonEmptyCellComponent$1 = /*#__PURE__*/React.memo(function NonEmptyCellCom
|
|
|
7127
7143
|
children: [Object.keys(properties).map((key, index) => {
|
|
7128
7144
|
if (!isInReview) {
|
|
7129
7145
|
return jsx("th", {
|
|
7130
|
-
children:
|
|
7131
|
-
children: convertToSentenceCase(key)
|
|
7146
|
+
children: jsxs("p", {
|
|
7147
|
+
children: [convertToSentenceCase(key), (required === null || required === void 0 ? void 0 : required.includes(key)) && jsx(RequiredSpan, {
|
|
7148
|
+
children: "(required)"
|
|
7149
|
+
})]
|
|
7132
7150
|
})
|
|
7133
7151
|
}, index);
|
|
7134
7152
|
}
|
|
@@ -7152,21 +7170,26 @@ const NonEmptyCellComponent$1 = /*#__PURE__*/React.memo(function NonEmptyCellCom
|
|
|
7152
7170
|
var _a;
|
|
7153
7171
|
const dataObject = properties[element];
|
|
7154
7172
|
const schemaName = element;
|
|
7173
|
+
const currentData = data && data[num] ? data[num][element] : '';
|
|
7155
7174
|
const error = errors === null || errors === void 0 ? void 0 : errors.find(
|
|
7156
7175
|
// eslint-disable-next-line
|
|
7157
7176
|
e => e.instancePath === `/${props.rowPath.replace(/\./g, '/')}/${i}/${element}`);
|
|
7177
|
+
if ((error === null || error === void 0 ? void 0 : error.message.includes('must NOT have fewer')) && required.find(r => r === schemaName) && (isEmptyBoolean(schema, currentData) || isEmptyNumber(schema, currentData))) {
|
|
7178
|
+
error.message = `${capitalizeFirstLetter(schemaName)} is required`;
|
|
7179
|
+
}
|
|
7158
7180
|
return jsx("td", {
|
|
7159
7181
|
children: isInReview ? jsx("div", {
|
|
7160
7182
|
"data-testid": `#/properties/${schemaName}-input-${i}-review`,
|
|
7161
|
-
children:
|
|
7183
|
+
children: currentData
|
|
7162
7184
|
}) : jsx(GoAFormItem, {
|
|
7163
7185
|
error: (_a = error === null || error === void 0 ? void 0 : error.message) !== null && _a !== void 0 ? _a : '',
|
|
7164
7186
|
mb: errorRow && !error && '2xl' || 'xs',
|
|
7165
7187
|
children: dataObject.type === 'number' || dataObject.type === 'string' && !dataObject.enum ? jsx(GoAInput, {
|
|
7188
|
+
error: (error === null || error === void 0 ? void 0 : error.message.length) > 0,
|
|
7166
7189
|
type: dataObject.type === 'number' ? 'number' : 'text',
|
|
7167
7190
|
id: schemaName,
|
|
7168
7191
|
name: schemaName,
|
|
7169
|
-
value:
|
|
7192
|
+
value: currentData,
|
|
7170
7193
|
testId: `#/properties/${schemaName}-input-${i}`,
|
|
7171
7194
|
onChange: (name, value) => {
|
|
7172
7195
|
handleChange(rowPath, {
|
|
@@ -7338,7 +7361,7 @@ const ObjectArrayControl = props => {
|
|
|
7338
7361
|
});
|
|
7339
7362
|
currentCategory.data = newCategoryData;
|
|
7340
7363
|
}
|
|
7341
|
-
if ((currentCategory === null || currentCategory === void 0 ? void 0 : currentCategory.count) > 0) currentCategory.count--;
|
|
7364
|
+
if ((currentCategory === null || currentCategory === void 0 ? void 0 : currentCategory.count) && (currentCategory === null || currentCategory === void 0 ? void 0 : currentCategory.count) > 0) currentCategory.count--;
|
|
7342
7365
|
let handleChangeData = Object.keys(newCategoryData).map(key => {
|
|
7343
7366
|
return newCategoryData[key];
|
|
7344
7367
|
});
|
|
@@ -7354,12 +7377,14 @@ const ObjectArrayControl = props => {
|
|
|
7354
7377
|
}
|
|
7355
7378
|
});
|
|
7356
7379
|
};
|
|
7380
|
+
//eslint-disable-next-line
|
|
7357
7381
|
const handleChangeWithData = (path, value) => {
|
|
7382
|
+
var _a;
|
|
7358
7383
|
if (path) {
|
|
7359
7384
|
const categories = registers.categories;
|
|
7360
|
-
const currentCategory = categories[path].data;
|
|
7385
|
+
const currentCategory = ((_a = categories[path]) === null || _a === void 0 ? void 0 : _a.data) || {};
|
|
7361
7386
|
const newData = {};
|
|
7362
|
-
const allKeys = Object.keys(value).concat(Object.keys(currentCategory));
|
|
7387
|
+
const allKeys = Object.keys(value).concat(Object.keys(currentCategory || []));
|
|
7363
7388
|
const allKeysUnique = allKeys.filter((a, b) => allKeys.indexOf(a) === b);
|
|
7364
7389
|
Object.keys(allKeysUnique).forEach(num => {
|
|
7365
7390
|
if (!newData[num]) {
|
|
@@ -7369,7 +7394,7 @@ const ObjectArrayControl = props => {
|
|
|
7369
7394
|
newData[num][path] = currentCategory[num][path];
|
|
7370
7395
|
});
|
|
7371
7396
|
value[num] && Object.keys(value[num]).forEach(path => {
|
|
7372
|
-
newData[num][path] = value[num][path]
|
|
7397
|
+
newData[num][path] = value[num][path] !== undefined ? value[num][path] : currentCategory[num] && currentCategory[num][path];
|
|
7373
7398
|
});
|
|
7374
7399
|
});
|
|
7375
7400
|
const handleChangeData = Object.keys(newData).map(key => {
|
|
@@ -7410,8 +7435,10 @@ const ObjectArrayControl = props => {
|
|
|
7410
7435
|
visible: visible,
|
|
7411
7436
|
"data-testid": "jsonforms-object-list-wrapper",
|
|
7412
7437
|
children: [jsxs(ToolBarHeader, {
|
|
7413
|
-
children: [isInReview && listTitle &&
|
|
7414
|
-
children: listTitle
|
|
7438
|
+
children: [isInReview && listTitle && jsxs("b", {
|
|
7439
|
+
children: [listTitle, " ", jsx("span", {
|
|
7440
|
+
children: additionalProps.required && '(required)'
|
|
7441
|
+
})]
|
|
7415
7442
|
}), !isInReview && listTitle && jsxs(ObjectArrayTitle, {
|
|
7416
7443
|
children: [listTitle, " ", jsx("span", {
|
|
7417
7444
|
children: additionalProps.required && '(required)'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abgov/jsonforms-components",
|
|
3
|
-
"version": "1.53.
|
|
3
|
+
"version": "1.53.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",
|
|
@@ -3,6 +3,7 @@ export declare const DeleteDialogContent: import("styled-components/dist/types")
|
|
|
3
3
|
export declare const NonEmptyCellStyle: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
4
4
|
export declare const ToolBarHeader: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
5
5
|
export declare const ObjectArrayTitle: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>, never>> & string;
|
|
6
|
+
export declare const RequiredSpan: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, never>> & string;
|
|
6
7
|
export declare const TextCenter: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
7
8
|
export declare const SideMenuItem: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
8
9
|
export declare const RowFlex: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|