@abgov/jsonforms-components 2.1.0 → 2.1.2
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 +354 -210
- package/package.json +1 -1
- package/src/lib/Controls/ObjectArray/ObjectListControl.d.ts +1 -45
- package/src/lib/Controls/ObjectArray/ObjectListControlTypes.d.ts +109 -0
- package/src/lib/Controls/ObjectArray/ObjectListControlUtils.d.ts +11 -0
- package/src/lib/Controls/ObjectArray/styled-components.d.ts +4 -0
package/index.esm.js
CHANGED
|
@@ -8,7 +8,7 @@ import get$1 from 'lodash/get';
|
|
|
8
8
|
import { rankWith, isStringControl, and, optionIs, uiTypeIs, isDateControl, isNumberControl, isIntegerControl, isDateTimeControl, isTimeControl, isEnumControl, isBooleanControl, getAjv, isVisible, getControlPath, toDataPath, deriveLabelForUISchemaElement, isEnabled, schemaTypeIs, formatIs, createDefaultValue, or, isObjectArrayControl, isPrimitiveArrayControl, Paths, schemaMatches, hasType, isControl, isCategorization, isLayout } from '@jsonforms/core';
|
|
9
9
|
import { withJsonFormsControlProps, withJsonFormsRendererProps, withJsonFormsEnumProps, withTranslateProps, useJsonForms, JsonFormsDispatch, withJsonFormsLayoutProps, withJsonFormsArrayLayoutProps, withJsonFormsCellProps } from '@jsonforms/react';
|
|
10
10
|
import * as _$c from 'lodash';
|
|
11
|
-
import { isEqual, isObject as isObject$f } from 'lodash';
|
|
11
|
+
import { isEqual, isEmpty as isEmpty$1, isObject as isObject$f } from 'lodash';
|
|
12
12
|
import merge from 'lodash/merge';
|
|
13
13
|
import isEmpty from 'lodash/isEmpty';
|
|
14
14
|
import range from 'lodash/range';
|
|
@@ -2635,7 +2635,8 @@ const invalidSin = 'Social insurance number is invalid';
|
|
|
2635
2635
|
* @param words
|
|
2636
2636
|
* @returns sentence word string.
|
|
2637
2637
|
*/
|
|
2638
|
-
const capitalizeFirstLetter
|
|
2638
|
+
const capitalizeFirstLetter = words => {
|
|
2639
|
+
if (!words) return ''; // Handle empty strings
|
|
2639
2640
|
const value = words.charAt(0).toUpperCase() + words.slice(1).toLowerCase();
|
|
2640
2641
|
return value;
|
|
2641
2642
|
};
|
|
@@ -2661,7 +2662,7 @@ const controlScopeMatchesLabel = (scope, label) => {
|
|
|
2661
2662
|
const getLabelText = (scope, label) => {
|
|
2662
2663
|
let labelToUpdate = '';
|
|
2663
2664
|
if (controlScopeMatchesLabel(scope, label || '') && !areAllUppercase(label)) {
|
|
2664
|
-
labelToUpdate = capitalizeFirstLetter
|
|
2665
|
+
labelToUpdate = capitalizeFirstLetter(label || '');
|
|
2665
2666
|
} else {
|
|
2666
2667
|
labelToUpdate = label || '';
|
|
2667
2668
|
}
|
|
@@ -4390,7 +4391,7 @@ const formatSin = value => {
|
|
|
4390
4391
|
return formatVal;
|
|
4391
4392
|
};
|
|
4392
4393
|
const GoAInputText = props => {
|
|
4393
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
4394
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
4394
4395
|
const {
|
|
4395
4396
|
data,
|
|
4396
4397
|
config,
|
|
@@ -4405,14 +4406,15 @@ const GoAInputText = props => {
|
|
|
4405
4406
|
isVisited,
|
|
4406
4407
|
setIsVisited
|
|
4407
4408
|
} = props;
|
|
4409
|
+
const width = (_c = (_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.width) !== null && _c !== void 0 ? _c : '100%';
|
|
4408
4410
|
const registerCtx = useContext(JsonFormsRegisterContext);
|
|
4409
|
-
const registerConfig = fetchRegisterConfigFromOptions$1((
|
|
4411
|
+
const registerConfig = fetchRegisterConfigFromOptions$1((_e = (_d = props.uischema) === null || _d === void 0 ? void 0 : _d.options) === null || _e === void 0 ? void 0 : _e.register);
|
|
4410
4412
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4411
4413
|
let registerData = [];
|
|
4412
4414
|
if (registerConfig) {
|
|
4413
4415
|
registerData = registerCtx === null || registerCtx === void 0 ? void 0 : registerCtx.selectRegisterData(registerConfig);
|
|
4414
4416
|
}
|
|
4415
|
-
const autoCompletion = ((
|
|
4417
|
+
const autoCompletion = ((_g = (_f = props.uischema) === null || _f === void 0 ? void 0 : _f.options) === null || _g === void 0 ? void 0 : _g.autoComplete) === true;
|
|
4416
4418
|
const mergedOptions = useMemo(() => {
|
|
4417
4419
|
const newOptions = [...((registerData === null || registerData === void 0 ? void 0 : registerData.map(d => {
|
|
4418
4420
|
if (typeof d === 'string') {
|
|
@@ -4444,8 +4446,8 @@ const GoAInputText = props => {
|
|
|
4444
4446
|
const appliedUiSchemaOptions = Object.assign(Object.assign({}, config), uischema === null || uischema === void 0 ? void 0 : uischema.options);
|
|
4445
4447
|
const placeholder = (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.placeholder) || (schema === null || schema === void 0 ? void 0 : schema.description) || '';
|
|
4446
4448
|
const isSinField = schema.title === sinTitle;
|
|
4447
|
-
const autoCapitalize = ((
|
|
4448
|
-
const readOnly = (
|
|
4449
|
+
const autoCapitalize = ((_j = (_h = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _h === void 0 ? void 0 : _h.componentProps) === null || _j === void 0 ? void 0 : _j.autoCapitalize) === true || ((_k = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _k === void 0 ? void 0 : _k.autoCapitalize) === true;
|
|
4450
|
+
const readOnly = (_o = (_m = (_l = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _l === void 0 ? void 0 : _l.componentProps) === null || _m === void 0 ? void 0 : _m.readOnly) !== null && _o !== void 0 ? _o : false;
|
|
4449
4451
|
return jsx("div", {
|
|
4450
4452
|
children: mergedOptions.length > 0 ? jsx(Dropdown, {
|
|
4451
4453
|
items: mergedOptions,
|
|
@@ -4462,11 +4464,11 @@ const GoAInputText = props => {
|
|
|
4462
4464
|
type: appliedUiSchemaOptions.format === 'password' ? 'password' : 'text',
|
|
4463
4465
|
disabled: !enabled,
|
|
4464
4466
|
value: data,
|
|
4465
|
-
width:
|
|
4467
|
+
width: width,
|
|
4466
4468
|
readonly: readOnly,
|
|
4467
4469
|
maxLength: isSinField ? 11 : '',
|
|
4468
4470
|
placeholder: placeholder
|
|
4469
|
-
}, (
|
|
4471
|
+
}, (_p = uischema.options) === null || _p === void 0 ? void 0 : _p.componentProps, {
|
|
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`,
|
|
@@ -4494,7 +4496,7 @@ const GoAInputText = props => {
|
|
|
4494
4496
|
value: autoCapitalize ? value.toUpperCase() : value
|
|
4495
4497
|
});
|
|
4496
4498
|
}
|
|
4497
|
-
}, (
|
|
4499
|
+
}, (_q = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _q === void 0 ? void 0 : _q.componentProps))
|
|
4498
4500
|
});
|
|
4499
4501
|
};
|
|
4500
4502
|
const GoATextControl = props => jsx(GoAInputBaseControl, Object.assign({}, props, {
|
|
@@ -4524,7 +4526,7 @@ const MultiLineText = props => {
|
|
|
4524
4526
|
const [textAreaValue, _] = React.useState(data);
|
|
4525
4527
|
const appliedUiSchemaOptions = Object.assign(Object.assign({}, config), uischema === null || uischema === void 0 ? void 0 : uischema.options);
|
|
4526
4528
|
const placeholder = (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.placeholder) || (schema === null || schema === void 0 ? void 0 : schema.description) || '';
|
|
4527
|
-
const width = (_c = (_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.
|
|
4529
|
+
const width = (_c = (_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.width) !== null && _c !== void 0 ? _c : '100%';
|
|
4528
4530
|
const autoCapitalize = ((_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.autoCapitalize) === true || ((_f = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _f === void 0 ? void 0 : _f.autoCapitalize) === true;
|
|
4529
4531
|
const readOnly = (_j = (_h = (_g = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _g === void 0 ? void 0 : _g.componentProps) === null || _h === void 0 ? void 0 : _h.readOnly) !== null && _j !== void 0 ? _j : false;
|
|
4530
4532
|
const textAreaName = `${label || path}-text-area` || '';
|
|
@@ -5432,8 +5434,8 @@ let _$6 = t => t,
|
|
|
5432
5434
|
_t13$1,
|
|
5433
5435
|
_t14$1,
|
|
5434
5436
|
_t15$1,
|
|
5435
|
-
_t16,
|
|
5436
|
-
_t17;
|
|
5437
|
+
_t16$1,
|
|
5438
|
+
_t17$1;
|
|
5437
5439
|
const ReviewItem = styled.div(_t$6 || (_t$6 = _$6`
|
|
5438
5440
|
display: flex;
|
|
5439
5441
|
flex-direction: column;
|
|
@@ -5524,14 +5526,14 @@ const TableReviewItem = styled.div(_t15$1 || (_t15$1 = _$6`
|
|
|
5524
5526
|
border-radius: 5px;
|
|
5525
5527
|
padding: var(--goa-space-2xl);
|
|
5526
5528
|
`));
|
|
5527
|
-
const TableReviewPageTitleRow = styled.div(_t16 || (_t16 = _$6`
|
|
5529
|
+
const TableReviewPageTitleRow = styled.div(_t16$1 || (_t16$1 = _$6`
|
|
5528
5530
|
margin-top: var(--goa-space-xl);
|
|
5529
5531
|
display: flex;
|
|
5530
5532
|
.right {
|
|
5531
5533
|
margin-left: auto;
|
|
5532
5534
|
}
|
|
5533
5535
|
`));
|
|
5534
|
-
const TableReviewCategoryLabel = styled.h3(_t17 || (_t17 = _$6`
|
|
5536
|
+
const TableReviewCategoryLabel = styled.h3(_t17$1 || (_t17$1 = _$6`
|
|
5535
5537
|
color: var(--goa-color-text-secondary) !important;
|
|
5536
5538
|
`));
|
|
5537
5539
|
|
|
@@ -7206,6 +7208,92 @@ $$8({ global: true, forced: parseInt !== $parseInt }, {
|
|
|
7206
7208
|
parseInt: $parseInt
|
|
7207
7209
|
});
|
|
7208
7210
|
|
|
7211
|
+
const ADD_DATA_ACTION = 'jsonforms/register/add_data_action';
|
|
7212
|
+
const SET_DATA_ACTION = 'jsonforms/register/set_data_action';
|
|
7213
|
+
const INCREMENT_ACTION = 'jsonforms/register/increment_action';
|
|
7214
|
+
const DELETE_ACTION = 'jsonforms/register/delete_action';
|
|
7215
|
+
const initialState = {
|
|
7216
|
+
categories: {}
|
|
7217
|
+
};
|
|
7218
|
+
|
|
7219
|
+
function objectListReducer(state, action) {
|
|
7220
|
+
switch (action.type) {
|
|
7221
|
+
case ADD_DATA_ACTION:
|
|
7222
|
+
{
|
|
7223
|
+
//ok so we're assuming we're already getting the updated category data
|
|
7224
|
+
const {
|
|
7225
|
+
categories
|
|
7226
|
+
} = state;
|
|
7227
|
+
const {
|
|
7228
|
+
name,
|
|
7229
|
+
category
|
|
7230
|
+
} = action.payload;
|
|
7231
|
+
const newCategories = Object.assign({}, categories);
|
|
7232
|
+
if (!newCategories[name]) {
|
|
7233
|
+
newCategories[name] = {
|
|
7234
|
+
data: category
|
|
7235
|
+
};
|
|
7236
|
+
} else {
|
|
7237
|
+
newCategories[name].data = category;
|
|
7238
|
+
}
|
|
7239
|
+
return Object.assign(Object.assign({}, state), {
|
|
7240
|
+
categories: newCategories
|
|
7241
|
+
});
|
|
7242
|
+
}
|
|
7243
|
+
case SET_DATA_ACTION:
|
|
7244
|
+
{
|
|
7245
|
+
const CategoriesStateData = action.payload;
|
|
7246
|
+
return Object.assign(Object.assign({}, state), {
|
|
7247
|
+
categories: CategoriesStateData
|
|
7248
|
+
});
|
|
7249
|
+
}
|
|
7250
|
+
case INCREMENT_ACTION:
|
|
7251
|
+
{
|
|
7252
|
+
const {
|
|
7253
|
+
categories
|
|
7254
|
+
} = state;
|
|
7255
|
+
const name = action.payload;
|
|
7256
|
+
const newCategories = Object.assign({}, categories);
|
|
7257
|
+
// Assuming you want to increment the count of a category:
|
|
7258
|
+
if (newCategories[name]) {
|
|
7259
|
+
const updatedCategory = Object.assign(Object.assign({}, categories[name]), {
|
|
7260
|
+
count: (categories[name].count || 0) + 1
|
|
7261
|
+
});
|
|
7262
|
+
return Object.assign(Object.assign({}, state), {
|
|
7263
|
+
categories: Object.assign(Object.assign({}, categories), {
|
|
7264
|
+
[name]: updatedCategory
|
|
7265
|
+
})
|
|
7266
|
+
});
|
|
7267
|
+
} else {
|
|
7268
|
+
newCategories[name] = {
|
|
7269
|
+
count: 1,
|
|
7270
|
+
data: {}
|
|
7271
|
+
};
|
|
7272
|
+
}
|
|
7273
|
+
return Object.assign(Object.assign({}, state), {
|
|
7274
|
+
categories: newCategories
|
|
7275
|
+
});
|
|
7276
|
+
}
|
|
7277
|
+
case DELETE_ACTION:
|
|
7278
|
+
{
|
|
7279
|
+
const {
|
|
7280
|
+
name,
|
|
7281
|
+
category
|
|
7282
|
+
} = action.payload;
|
|
7283
|
+
const {
|
|
7284
|
+
categories
|
|
7285
|
+
} = state;
|
|
7286
|
+
const newCategories = Object.assign({}, categories);
|
|
7287
|
+
newCategories[name] = category;
|
|
7288
|
+
return Object.assign(Object.assign({}, state), {
|
|
7289
|
+
categories: newCategories
|
|
7290
|
+
});
|
|
7291
|
+
}
|
|
7292
|
+
default:
|
|
7293
|
+
return state;
|
|
7294
|
+
}
|
|
7295
|
+
}
|
|
7296
|
+
|
|
7209
7297
|
let _$2 = t => t,
|
|
7210
7298
|
_t$2,
|
|
7211
7299
|
_t2$2,
|
|
@@ -7221,7 +7309,11 @@ let _$2 = t => t,
|
|
|
7221
7309
|
_t12,
|
|
7222
7310
|
_t13,
|
|
7223
7311
|
_t14,
|
|
7224
|
-
_t15
|
|
7312
|
+
_t15,
|
|
7313
|
+
_t16,
|
|
7314
|
+
_t17,
|
|
7315
|
+
_t18,
|
|
7316
|
+
_t19;
|
|
7225
7317
|
const DeleteDialogContent = styled.div(_t$2 || (_t$2 = _$2`
|
|
7226
7318
|
margin-bottom: var(--goa-space-m);
|
|
7227
7319
|
`));
|
|
@@ -7288,6 +7380,32 @@ const ListContainer = styled.div(_t14 || (_t14 = _$2`
|
|
|
7288
7380
|
`));
|
|
7289
7381
|
const TableTHHeader = styled.th(_t15 || (_t15 = _$2`
|
|
7290
7382
|
background-color: var(--goa-color-greyscale-100) !important;
|
|
7383
|
+
vertical-align: top;
|
|
7384
|
+
`));
|
|
7385
|
+
const ObjectArrayWarningIconDiv = styled.div(_t16 || (_t16 = _$2`
|
|
7386
|
+
display: inline-flex;
|
|
7387
|
+
align-items: flex-start;
|
|
7388
|
+
gap: 0.25rem;
|
|
7389
|
+
font-size: var(--goa-font-size-2);
|
|
7390
|
+
color: var(--goa-color-interactive-error);
|
|
7391
|
+
`));
|
|
7392
|
+
styled.label(_t17 || (_t17 = _$2`
|
|
7393
|
+
color: var(--goa-color-interactive-error);
|
|
7394
|
+
font-weight: var(--goa-font-weight-regular);
|
|
7395
|
+
font-size: var(--goa-font-size-3);
|
|
7396
|
+
line-height: var(--goa-line-height-1);
|
|
7397
|
+
font-style: normal;
|
|
7398
|
+
`));
|
|
7399
|
+
styled.div(_t18 || (_t18 = _$2`
|
|
7400
|
+
margin-top: var(--goa-space-m);
|
|
7401
|
+
color: var(--goa-color-interactive-error);
|
|
7402
|
+
font-weight: var(--goa-font-weight-regular);
|
|
7403
|
+
font-size: var(--goa-font-size-2);
|
|
7404
|
+
line-height: var(--goa-line-height-1);
|
|
7405
|
+
font-style: normal;
|
|
7406
|
+
`));
|
|
7407
|
+
const HilightCellWarning = styled.div(_t19 || (_t19 = _$2`
|
|
7408
|
+
background-color: var(--goa-color-warning-default);
|
|
7291
7409
|
`));
|
|
7292
7410
|
|
|
7293
7411
|
const DeleteDialog = /*#__PURE__*/React.memo(function DeleteDialog({
|
|
@@ -7361,116 +7479,112 @@ const ObjectArrayToolBar = /*#__PURE__*/React.memo(function TableToolbar({
|
|
|
7361
7479
|
"aria-label": translations.addAriaLabel,
|
|
7362
7480
|
onClick: addItem(path, createDefaultValue(schema, rootSchema)),
|
|
7363
7481
|
type: (_c = (_b = uischema.options) === null || _b === void 0 ? void 0 : _b.addButtonType) !== null && _c !== void 0 ? _c : 'primary',
|
|
7364
|
-
children: ((_d = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _d === void 0 ? void 0 : _d.addButtonText) || capitalizeFirstLetter
|
|
7482
|
+
children: ((_d = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _d === void 0 ? void 0 : _d.addButtonText) || capitalizeFirstLetter(`Add ${arrayLabel}`)
|
|
7365
7483
|
})
|
|
7366
7484
|
})
|
|
7367
7485
|
});
|
|
7368
7486
|
});
|
|
7369
7487
|
|
|
7370
|
-
const
|
|
7371
|
-
const
|
|
7372
|
-
|
|
7373
|
-
|
|
7374
|
-
|
|
7375
|
-
|
|
7488
|
+
const extractNestedFields = (properties, propertyKeys) => {
|
|
7489
|
+
const nestedItems = {};
|
|
7490
|
+
propertyKeys.forEach(key => {
|
|
7491
|
+
var _a, _b;
|
|
7492
|
+
if (properties[key].type === 'array') {
|
|
7493
|
+
const propItems = properties[key] && ((_a = properties[key].items) === null || _a === void 0 ? void 0 : _a.properties) || [];
|
|
7494
|
+
const propReqItems = properties[key].items && ((_b = properties[key].items) === null || _b === void 0 ? void 0 : _b.required) || [];
|
|
7495
|
+
nestedItems[key] = {
|
|
7496
|
+
properties: [...Object.keys(propItems)],
|
|
7497
|
+
required: [...Object.keys(propReqItems)]
|
|
7498
|
+
};
|
|
7499
|
+
}
|
|
7500
|
+
});
|
|
7501
|
+
return nestedItems;
|
|
7376
7502
|
};
|
|
7377
|
-
|
|
7378
|
-
|
|
7379
|
-
|
|
7380
|
-
|
|
7381
|
-
|
|
7382
|
-
|
|
7383
|
-
|
|
7384
|
-
categories
|
|
7385
|
-
} = state;
|
|
7386
|
-
const {
|
|
7387
|
-
name,
|
|
7388
|
-
category
|
|
7389
|
-
} = action.payload;
|
|
7390
|
-
const newCategories = Object.assign({}, categories);
|
|
7391
|
-
if (!newCategories[name]) {
|
|
7392
|
-
newCategories[name] = {
|
|
7393
|
-
data: category
|
|
7394
|
-
};
|
|
7395
|
-
} else {
|
|
7396
|
-
newCategories[name].data = category;
|
|
7397
|
-
}
|
|
7398
|
-
return Object.assign(Object.assign({}, state), {
|
|
7399
|
-
categories: newCategories
|
|
7400
|
-
});
|
|
7401
|
-
}
|
|
7402
|
-
case SET_DATA_ACTION:
|
|
7403
|
-
{
|
|
7404
|
-
const CategoriesStateData = action.payload;
|
|
7405
|
-
return Object.assign(Object.assign({}, state), {
|
|
7406
|
-
categories: CategoriesStateData
|
|
7407
|
-
});
|
|
7408
|
-
}
|
|
7409
|
-
case INCREMENT_ACTION:
|
|
7410
|
-
{
|
|
7411
|
-
const {
|
|
7412
|
-
categories
|
|
7413
|
-
} = state;
|
|
7414
|
-
const name = action.payload;
|
|
7415
|
-
const newCategories = Object.assign({}, categories);
|
|
7416
|
-
// Assuming you want to increment the count of a category:
|
|
7417
|
-
if (newCategories[name]) {
|
|
7418
|
-
const updatedCategory = Object.assign(Object.assign({}, categories[name]), {
|
|
7419
|
-
count: (categories[name].count || 0) + 1
|
|
7420
|
-
});
|
|
7421
|
-
return Object.assign(Object.assign({}, state), {
|
|
7422
|
-
categories: Object.assign(Object.assign({}, categories), {
|
|
7423
|
-
[name]: updatedCategory
|
|
7424
|
-
})
|
|
7425
|
-
});
|
|
7426
|
-
} else {
|
|
7427
|
-
newCategories[name] = {
|
|
7428
|
-
count: 1,
|
|
7429
|
-
data: {}
|
|
7430
|
-
};
|
|
7431
|
-
}
|
|
7432
|
-
return Object.assign(Object.assign({}, state), {
|
|
7433
|
-
categories: newCategories
|
|
7434
|
-
});
|
|
7435
|
-
}
|
|
7436
|
-
case DELETE_ACTION:
|
|
7437
|
-
{
|
|
7438
|
-
const {
|
|
7439
|
-
name,
|
|
7440
|
-
category
|
|
7441
|
-
} = action.payload;
|
|
7442
|
-
const {
|
|
7443
|
-
categories
|
|
7444
|
-
} = state;
|
|
7445
|
-
const newCategories = Object.assign({}, categories);
|
|
7446
|
-
newCategories[name] = category;
|
|
7447
|
-
return Object.assign(Object.assign({}, state), {
|
|
7448
|
-
categories: newCategories
|
|
7449
|
-
});
|
|
7450
|
-
}
|
|
7451
|
-
default:
|
|
7452
|
-
return state;
|
|
7453
|
-
}
|
|
7454
|
-
}
|
|
7455
|
-
|
|
7456
|
-
function extractNames(obj, names = []) {
|
|
7503
|
+
/**
|
|
7504
|
+
* Extract Json data schema name attribute and the ui schema label name.
|
|
7505
|
+
* @param obj
|
|
7506
|
+
* @param names
|
|
7507
|
+
* @returns A key value of the data attribute name and the uiSchema label value
|
|
7508
|
+
*/
|
|
7509
|
+
const extractNames = (obj, names = {}) => {
|
|
7457
7510
|
if (Array.isArray(obj)) {
|
|
7458
7511
|
obj.forEach(item => extractNames(item, names));
|
|
7459
7512
|
} else if (typeof obj === 'object' && obj !== null) {
|
|
7460
7513
|
const typedObj = obj;
|
|
7461
|
-
if (typeof typedObj.
|
|
7462
|
-
names.push(typedObj.label);
|
|
7463
|
-
} else if (typeof typedObj.scope === 'string') {
|
|
7514
|
+
if (typeof typedObj.scope === 'string') {
|
|
7464
7515
|
const parts = typedObj.scope.split('/');
|
|
7465
|
-
|
|
7516
|
+
if (typeof typedObj.label === 'string') {
|
|
7517
|
+
names[parts[parts.length - 1]] = typedObj.label;
|
|
7518
|
+
} else if (typeof typedObj.scope === 'string') {
|
|
7519
|
+
const _parts = typedObj.scope.split('/');
|
|
7520
|
+
names[_parts[_parts.length - 1]] = _parts[_parts.length - 1];
|
|
7521
|
+
}
|
|
7466
7522
|
}
|
|
7467
7523
|
Object.values(typedObj).forEach(value => extractNames(value, names));
|
|
7468
7524
|
}
|
|
7469
7525
|
return names;
|
|
7470
|
-
}
|
|
7471
|
-
const
|
|
7472
|
-
|
|
7473
|
-
|
|
7526
|
+
};
|
|
7527
|
+
const isObjectArrayEmpty = currentData => {
|
|
7528
|
+
const result = isEmpty$1(currentData) || JSON.stringify(currentData) === '[{}]';
|
|
7529
|
+
return result;
|
|
7530
|
+
};
|
|
7531
|
+
const renderCellColumn = ({
|
|
7532
|
+
currentData,
|
|
7533
|
+
error,
|
|
7534
|
+
errors,
|
|
7535
|
+
index,
|
|
7536
|
+
rowPath,
|
|
7537
|
+
element,
|
|
7538
|
+
isRequired
|
|
7539
|
+
}) => {
|
|
7540
|
+
const renderWarningCell = data => {
|
|
7541
|
+
return jsx(HilightCellWarning, {
|
|
7542
|
+
children: jsxs(ObjectArrayWarningIconDiv, {
|
|
7543
|
+
children: [jsx(GoAIcon, {
|
|
7544
|
+
type: "warning",
|
|
7545
|
+
title: "warning",
|
|
7546
|
+
size: "small",
|
|
7547
|
+
theme: "filled",
|
|
7548
|
+
ml: "2xs",
|
|
7549
|
+
mt: "2xs"
|
|
7550
|
+
}), data]
|
|
7551
|
+
})
|
|
7552
|
+
});
|
|
7553
|
+
};
|
|
7554
|
+
if (currentData === undefined && isRequired || error !== '' && error !== undefined) {
|
|
7555
|
+
return renderWarningCell(currentData);
|
|
7556
|
+
} else if (currentData !== undefined && isRequired && error) {
|
|
7557
|
+
return renderWarningCell(currentData);
|
|
7558
|
+
}
|
|
7559
|
+
const path = `/${rowPath}/${index}/${element}/${index === 0 ? index : index - 1}`;
|
|
7560
|
+
const nestedErrors = errors === null || errors === void 0 ? void 0 : errors.filter(e => e.instancePath.includes(path));
|
|
7561
|
+
if (typeof currentData === 'string') {
|
|
7562
|
+
return currentData;
|
|
7563
|
+
} else if (typeof currentData === 'object' || Array.isArray(currentData)) {
|
|
7564
|
+
const result = Object.keys(currentData);
|
|
7565
|
+
if (result.length === 0) {
|
|
7566
|
+
return renderWarningCell();
|
|
7567
|
+
} else if (result.length > 0 && (isObjectArrayEmpty(currentData) || nestedErrors.length > 0)) {
|
|
7568
|
+
return jsx("pre", {
|
|
7569
|
+
children: renderWarningCell(JSON.stringify(currentData, null, 2))
|
|
7570
|
+
});
|
|
7571
|
+
} else if (currentData !== undefined && result.length > 0 && error !== '' && error !== undefined) {
|
|
7572
|
+
const values = Object.values(currentData);
|
|
7573
|
+
if (values && values.length > 0) {
|
|
7574
|
+
return jsx("pre", {
|
|
7575
|
+
children: renderWarningCell(JSON.stringify(values.at(0), null, 2))
|
|
7576
|
+
});
|
|
7577
|
+
}
|
|
7578
|
+
} else {
|
|
7579
|
+
return jsx("pre", {
|
|
7580
|
+
children: JSON.stringify(currentData, null, 2)
|
|
7581
|
+
});
|
|
7582
|
+
}
|
|
7583
|
+
}
|
|
7584
|
+
return null;
|
|
7585
|
+
};
|
|
7586
|
+
|
|
7587
|
+
const GenerateRows$1 = (Cell, schema, rowPath, enabled, openDeleteDialog, handleChange, cells, uischema, isInReview, count, data, errors) => {
|
|
7474
7588
|
if ((schema === null || schema === void 0 ? void 0 : schema.type) === 'object') {
|
|
7475
7589
|
const props = {
|
|
7476
7590
|
schema,
|
|
@@ -7545,12 +7659,8 @@ const ctxToNonEmptyCellProps$1 = (ctx, ownProps) => {
|
|
|
7545
7659
|
handleChange: ownProps.handleChange
|
|
7546
7660
|
};
|
|
7547
7661
|
};
|
|
7548
|
-
function capitalizeFirstLetter(str) {
|
|
7549
|
-
if (!str) return ''; // Handle empty strings
|
|
7550
|
-
return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
|
|
7551
|
-
}
|
|
7552
7662
|
const NonEmptyCellComponent$1 = /*#__PURE__*/React.memo(function NonEmptyCellComponent(props) {
|
|
7553
|
-
var _a, _b, _c;
|
|
7663
|
+
var _a, _b, _c, _d;
|
|
7554
7664
|
const {
|
|
7555
7665
|
schema,
|
|
7556
7666
|
enabled,
|
|
@@ -7567,14 +7677,29 @@ const NonEmptyCellComponent$1 = /*#__PURE__*/React.memo(function NonEmptyCellCom
|
|
|
7567
7677
|
} = props;
|
|
7568
7678
|
const properties = (schema === null || schema === void 0 ? void 0 : schema.items) && 'properties' in schema.items && schema.items.properties || {};
|
|
7569
7679
|
const required = (_a = schema.items) === null || _a === void 0 ? void 0 : _a.required;
|
|
7680
|
+
const propertyKeys = Object.keys(properties);
|
|
7681
|
+
const nestedItems = extractNestedFields(properties, propertyKeys);
|
|
7570
7682
|
let tableKeys = extractNames((_b = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _b === void 0 ? void 0 : _b.detail);
|
|
7571
|
-
if (tableKeys.length === 0) {
|
|
7572
|
-
|
|
7683
|
+
if (Object.keys(tableKeys).length === 0) {
|
|
7684
|
+
Object.keys(properties).forEach(item => {
|
|
7685
|
+
tableKeys[item] = item;
|
|
7686
|
+
});
|
|
7573
7687
|
}
|
|
7688
|
+
if (Object.keys(properties).length !== Object.keys(tableKeys).length) {
|
|
7689
|
+
const tempTableKeys = {};
|
|
7690
|
+
//For nested objects to display only the top level column.
|
|
7691
|
+
Object.keys(properties).forEach(item => {
|
|
7692
|
+
if (Object.keys(tableKeys).includes(item)) {
|
|
7693
|
+
tempTableKeys[item] = tableKeys[item];
|
|
7694
|
+
}
|
|
7695
|
+
});
|
|
7696
|
+
tableKeys = tempTableKeys;
|
|
7697
|
+
}
|
|
7698
|
+
const hasAnyErrors = Array.isArray(errors) ? ((_c = errors === null || errors === void 0 ? void 0 : errors.filter(err => {
|
|
7699
|
+
return err.instancePath.includes(rowPath);
|
|
7700
|
+
})) === null || _c === void 0 ? void 0 : _c.length) > 0 : false;
|
|
7574
7701
|
return jsxs(NonEmptyCellStyle, {
|
|
7575
|
-
children: [
|
|
7576
|
-
// eslint-disable-next-line
|
|
7577
|
-
(_c = uischema === null || uischema === void 0 ? void 0 : uischema.elements) === null || _c === void 0 ? void 0 : _c.map(element => {
|
|
7702
|
+
children: [(_d = uischema === null || uischema === void 0 ? void 0 : uischema.elements) === null || _d === void 0 ? void 0 : _d.map(element => {
|
|
7578
7703
|
return jsx(JsonFormsDispatch, {
|
|
7579
7704
|
"data-testid": `jsonforms-object-list-defined-elements-dispatch`,
|
|
7580
7705
|
schema: schema,
|
|
@@ -7584,99 +7709,120 @@ const NonEmptyCellComponent$1 = /*#__PURE__*/React.memo(function NonEmptyCellCom
|
|
|
7584
7709
|
renderers: isInReview ? GoAReviewRenderers : renderers,
|
|
7585
7710
|
cells: cells
|
|
7586
7711
|
}, rowPath);
|
|
7587
|
-
}), Object.keys(properties).length > 0 && jsxs(
|
|
7588
|
-
|
|
7589
|
-
|
|
7590
|
-
children:
|
|
7591
|
-
children:
|
|
7592
|
-
|
|
7593
|
-
|
|
7712
|
+
}), Object.keys(properties).length > 0 && jsxs(Fragment, {
|
|
7713
|
+
children: [jsxs(GoATable, {
|
|
7714
|
+
width: "100%",
|
|
7715
|
+
children: [jsx("thead", {
|
|
7716
|
+
children: jsxs("tr", {
|
|
7717
|
+
children: [Object.entries(tableKeys).map(([value, index]) => {
|
|
7718
|
+
var _a;
|
|
7719
|
+
if (!isInReview) {
|
|
7720
|
+
return jsx("th", {
|
|
7721
|
+
children: jsxs("p", {
|
|
7722
|
+
children: [convertToSentenceCase(index), (required === null || required === void 0 ? void 0 : required.includes(value)) && jsx(RequiredSpan, {
|
|
7723
|
+
children: "(required)"
|
|
7724
|
+
})]
|
|
7725
|
+
})
|
|
7726
|
+
}, index);
|
|
7727
|
+
}
|
|
7728
|
+
return jsx(TableTHHeader, {
|
|
7594
7729
|
children: jsxs("p", {
|
|
7595
|
-
children: [convertToSentenceCase(
|
|
7596
|
-
children: "(required)"
|
|
7730
|
+
children: [`${convertToSentenceCase(index)}`, ((required === null || required === void 0 ? void 0 : required.includes(value)) || ((_a = nestedItems[value]) === null || _a === void 0 ? void 0 : _a.required.length) > 0) && jsxs(RequiredSpan, {
|
|
7731
|
+
children: [jsx("br", {}), " (required)"]
|
|
7597
7732
|
})]
|
|
7598
7733
|
})
|
|
7599
7734
|
}, index);
|
|
7600
|
-
}
|
|
7601
|
-
return jsx(TableTHHeader, {
|
|
7735
|
+
}), isInReview !== true && jsx("th", {
|
|
7602
7736
|
children: jsx("p", {
|
|
7603
|
-
children:
|
|
7737
|
+
children: "Actions"
|
|
7604
7738
|
})
|
|
7605
|
-
}
|
|
7606
|
-
}
|
|
7607
|
-
|
|
7608
|
-
|
|
7609
|
-
})
|
|
7610
|
-
|
|
7611
|
-
|
|
7612
|
-
|
|
7613
|
-
|
|
7614
|
-
|
|
7615
|
-
|
|
7616
|
-
|
|
7617
|
-
|
|
7618
|
-
|
|
7619
|
-
|
|
7620
|
-
|
|
7621
|
-
|
|
7622
|
-
|
|
7623
|
-
|
|
7624
|
-
|
|
7625
|
-
|
|
7626
|
-
|
|
7627
|
-
|
|
7628
|
-
|
|
7629
|
-
|
|
7630
|
-
|
|
7631
|
-
|
|
7632
|
-
|
|
7739
|
+
})]
|
|
7740
|
+
}, 0)
|
|
7741
|
+
}), jsx("tbody", {
|
|
7742
|
+
children: range(count || 0).map((num, i) => {
|
|
7743
|
+
const errorRow = errors === null || errors === void 0 ? void 0 : errors.find(error => error.instancePath.includes(`/${props.rowPath.replace(/\./g, '/')}/${i}`));
|
|
7744
|
+
return jsxs("tr", {
|
|
7745
|
+
children: [Object.keys(properties).map((element, ix) => {
|
|
7746
|
+
var _a;
|
|
7747
|
+
const dataObject = properties[element];
|
|
7748
|
+
const schemaName = element;
|
|
7749
|
+
const currentData = data && data[num] ? data[num][element] : '';
|
|
7750
|
+
//Get out of the loop to not render extra blank columns at the end of the table
|
|
7751
|
+
if (ix > 1 && Object.keys(tableKeys).length === ix) return null;
|
|
7752
|
+
const error = (errors === null || errors === void 0 ? void 0 : errors.filter(e => e.instancePath === `/${props.rowPath.replace(/\./g, '/')}/${i}/${element}` || e.instancePath === `/${props.rowPath.replace(/\./g, '/')}/${i}`)).find(y => {
|
|
7753
|
+
var _a;
|
|
7754
|
+
return ((_a = y === null || y === void 0 ? void 0 : y.message) === null || _a === void 0 ? void 0 : _a.includes(element)) || y.instancePath.includes(element);
|
|
7755
|
+
});
|
|
7756
|
+
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))) {
|
|
7757
|
+
error.message = `${capitalizeFirstLetter(schemaName)} is required`;
|
|
7758
|
+
}
|
|
7759
|
+
if (isInReview === true) {
|
|
7760
|
+
return jsx("td", {
|
|
7761
|
+
children: jsx("div", {
|
|
7762
|
+
"data-testid": `#/properties/${schemaName}-input-${i}-review`,
|
|
7763
|
+
children: renderCellColumn({
|
|
7764
|
+
currentData,
|
|
7765
|
+
error: error === null || error === void 0 ? void 0 : error.message,
|
|
7766
|
+
isRequired: required === null || required === void 0 ? void 0 : required.includes(tableKeys[element]),
|
|
7767
|
+
errors: errors !== undefined ? errors : [],
|
|
7768
|
+
count: count !== undefined ? count : -1,
|
|
7769
|
+
element,
|
|
7770
|
+
rowPath,
|
|
7771
|
+
index: i
|
|
7772
|
+
})
|
|
7773
|
+
})
|
|
7774
|
+
}, ix);
|
|
7775
|
+
}
|
|
7776
|
+
return jsx("td", {
|
|
7777
|
+
children: jsx(GoAFormItem, {
|
|
7778
|
+
error: (_a = error === null || error === void 0 ? void 0 : error.message) !== null && _a !== void 0 ? _a : '',
|
|
7779
|
+
mb: errorRow && !error && '2xl' || 'xs',
|
|
7780
|
+
children: dataObject.type === 'number' || dataObject.type === 'string' && !dataObject.enum ? jsx(GoAInput, {
|
|
7781
|
+
error: (error === null || error === void 0 ? void 0 : error.message.length) > 0,
|
|
7782
|
+
type: dataObject.type === 'number' ? 'number' : 'text',
|
|
7783
|
+
id: schemaName,
|
|
7784
|
+
name: schemaName,
|
|
7785
|
+
value: currentData,
|
|
7786
|
+
testId: `#/properties/${schemaName}-input-${i}`,
|
|
7787
|
+
onChange: (name, value) => {
|
|
7788
|
+
handleChange(rowPath, {
|
|
7789
|
+
[num]: {
|
|
7790
|
+
[name]: dataObject.type === 'number' ? parseInt(value) : value
|
|
7791
|
+
}
|
|
7792
|
+
});
|
|
7793
|
+
},
|
|
7794
|
+
"aria-label": schemaName,
|
|
7795
|
+
width: "100%"
|
|
7796
|
+
}) : jsx(GoACallout, {
|
|
7797
|
+
type: "important",
|
|
7798
|
+
size: "medium",
|
|
7799
|
+
testId: "form-support-callout",
|
|
7800
|
+
heading: "Not supported",
|
|
7801
|
+
children: "Only string and number are supported inside arrays"
|
|
7802
|
+
})
|
|
7633
7803
|
})
|
|
7634
|
-
}
|
|
7635
|
-
|
|
7636
|
-
|
|
7637
|
-
|
|
7638
|
-
|
|
7639
|
-
|
|
7640
|
-
|
|
7641
|
-
|
|
7642
|
-
|
|
7643
|
-
|
|
7644
|
-
|
|
7645
|
-
|
|
7646
|
-
|
|
7647
|
-
|
|
7648
|
-
}
|
|
7649
|
-
});
|
|
7650
|
-
},
|
|
7651
|
-
"aria-label": schemaName,
|
|
7652
|
-
width: "100%"
|
|
7653
|
-
}) : jsx(GoACallout, {
|
|
7654
|
-
type: "important",
|
|
7655
|
-
size: "medium",
|
|
7656
|
-
testId: "form-support-callout",
|
|
7657
|
-
heading: "Not supported",
|
|
7658
|
-
children: "Only string and number are supported inside arrays"
|
|
7804
|
+
}, ix);
|
|
7805
|
+
}), !isInReview && jsx("td", {
|
|
7806
|
+
style: {
|
|
7807
|
+
alignContent: 'baseLine',
|
|
7808
|
+
paddingTop: '18px'
|
|
7809
|
+
},
|
|
7810
|
+
children: jsx("div", {
|
|
7811
|
+
"aria-hidden": "true",
|
|
7812
|
+
children: jsx(GoAIconButton, {
|
|
7813
|
+
icon: "trash",
|
|
7814
|
+
title: "trash button",
|
|
7815
|
+
testId: "trash-icon-button",
|
|
7816
|
+
"aria-label": `remove-element-${num}`,
|
|
7817
|
+
onClick: () => openDeleteDialog(num)
|
|
7659
7818
|
})
|
|
7660
7819
|
})
|
|
7661
|
-
}
|
|
7662
|
-
}
|
|
7663
|
-
|
|
7664
|
-
|
|
7665
|
-
|
|
7666
|
-
|
|
7667
|
-
children: jsx("div", {
|
|
7668
|
-
"aria-hidden": "true",
|
|
7669
|
-
children: !isInReview && jsx(GoAIconButton, {
|
|
7670
|
-
icon: "trash",
|
|
7671
|
-
title: "trash button",
|
|
7672
|
-
testId: "trash-icon-button",
|
|
7673
|
-
"aria-label": `remove-element-${num}`,
|
|
7674
|
-
onClick: () => openDeleteDialog(num)
|
|
7675
|
-
})
|
|
7676
|
-
})
|
|
7677
|
-
})]
|
|
7678
|
-
}, i);
|
|
7679
|
-
})
|
|
7820
|
+
})]
|
|
7821
|
+
}, `${rowPath}-${i}-${num}`);
|
|
7822
|
+
})
|
|
7823
|
+
})]
|
|
7824
|
+
}), hasAnyErrors && isInReview && jsx(GoAFormItem, {
|
|
7825
|
+
error: `There are validation errors for '${capitalizeFirstLetter(rowPath)}'`
|
|
7680
7826
|
})]
|
|
7681
7827
|
})]
|
|
7682
7828
|
});
|
|
@@ -7760,7 +7906,6 @@ const ObjectArrayList$1 = ({
|
|
|
7760
7906
|
data: data
|
|
7761
7907
|
}, 0);
|
|
7762
7908
|
};
|
|
7763
|
-
// eslint-disable-next-line
|
|
7764
7909
|
const ObjectArrayControl = props => {
|
|
7765
7910
|
var _a, _b, _c;
|
|
7766
7911
|
const [registers, dispatch] = useReducer(objectListReducer, initialState);
|
|
@@ -7866,8 +8011,7 @@ const ObjectArrayControl = props => {
|
|
|
7866
8011
|
}
|
|
7867
8012
|
};
|
|
7868
8013
|
useEffect(() => {
|
|
7869
|
-
|
|
7870
|
-
const updatedData = Array.isArray(parsedData) ? Object.fromEntries(parsedData.map((item, index) => [index, item])) : {};
|
|
8014
|
+
const updatedData = Object.fromEntries((parsedData || []).map((item, index) => [index, item]));
|
|
7871
8015
|
const count = Object.keys(updatedData).length;
|
|
7872
8016
|
const dispatchData = {
|
|
7873
8017
|
[path]: {
|
|
@@ -7881,9 +8025,9 @@ const ObjectArrayControl = props => {
|
|
|
7881
8025
|
payload: dispatchData
|
|
7882
8026
|
});
|
|
7883
8027
|
}
|
|
8028
|
+
// eslint-disable-next-line
|
|
7884
8029
|
}, []);
|
|
7885
8030
|
const controlElement = uischema;
|
|
7886
|
-
// eslint-disable-next-line
|
|
7887
8031
|
const listTitle = label || ((_a = uischema.options) === null || _a === void 0 ? void 0 : _a.title);
|
|
7888
8032
|
const isInReview = isStepperReview === true;
|
|
7889
8033
|
return jsxs(Visible, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abgov/jsonforms-components",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.2",
|
|
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,50 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { ArrayLayoutProps, ControlElement, JsonSchema, JsonFormsRendererRegistryEntry, JsonFormsCellRendererRegistryEntry, ArrayTranslations, Layout, ControlProps } from '@jsonforms/core';
|
|
3
2
|
import { WithBasicDeleteDialogSupport } from './DeleteDialog';
|
|
4
|
-
import {
|
|
5
|
-
interface ArrayLayoutExtProps {
|
|
6
|
-
isStepperReview?: boolean;
|
|
7
|
-
}
|
|
8
|
-
interface HandleChangeProps {
|
|
9
|
-
handleChange(path: string, value: any): void;
|
|
10
|
-
}
|
|
11
|
-
export type ObjectArrayControlProps = ArrayLayoutProps & ArrayLayoutExtProps & ControlProps;
|
|
12
|
-
export interface EmptyListProps {
|
|
13
|
-
numColumns: number;
|
|
14
|
-
translations: ArrayTranslations;
|
|
15
|
-
}
|
|
16
|
-
interface NonEmptyRowComponentProps {
|
|
17
|
-
propName?: string;
|
|
18
|
-
schema: JsonSchema;
|
|
19
|
-
rootSchema?: JsonSchema;
|
|
20
|
-
rowPath: string;
|
|
21
|
-
errors?: Record<string, any>;
|
|
22
|
-
enabled: boolean;
|
|
23
|
-
renderers?: JsonFormsRendererRegistryEntry[];
|
|
24
|
-
cells?: JsonFormsCellRendererRegistryEntry[];
|
|
25
|
-
isValid: boolean;
|
|
26
|
-
uischema?: ControlElement | Layout;
|
|
27
|
-
isInReview?: boolean;
|
|
28
|
-
count?: number;
|
|
29
|
-
data: StateData | undefined;
|
|
30
|
-
handleChange(path: string, value: string): void;
|
|
31
|
-
openDeleteDialog(rowIndex: number): void;
|
|
32
|
-
}
|
|
3
|
+
import { HandleChangeProps, NonEmptyRowComponentProps, NonEmptyRowProps, ObjectArrayControlProps } from './ObjectListControlTypes';
|
|
33
4
|
export declare const NonEmptyCellComponent: React.NamedExoticComponent<NonEmptyRowComponentProps & HandleChangeProps>;
|
|
34
|
-
interface NonEmptyRowProps {
|
|
35
|
-
childPath: string;
|
|
36
|
-
schema: JsonSchema;
|
|
37
|
-
rowIndex: number;
|
|
38
|
-
showSortButtons: boolean;
|
|
39
|
-
enabled: boolean;
|
|
40
|
-
cells?: JsonFormsCellRendererRegistryEntry[];
|
|
41
|
-
path: string;
|
|
42
|
-
translations: ArrayTranslations;
|
|
43
|
-
uischema: ControlElement;
|
|
44
|
-
isInReview?: boolean;
|
|
45
|
-
data?: StateData;
|
|
46
|
-
count: number;
|
|
47
|
-
}
|
|
48
5
|
export declare const NonEmptyList: React.MemoExoticComponent<({ childPath, schema, openDeleteDialog, enabled, cells, uischema, isInReview, data, count, handleChange, }: NonEmptyRowProps & WithBasicDeleteDialogSupport & HandleChangeProps) => import("react/jsx-runtime").JSX.Element>;
|
|
49
6
|
export declare const ObjectArrayControl: (props: ObjectArrayControlProps) => JSX.Element;
|
|
50
|
-
export {};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { ArrayLayoutProps, ArrayTranslations, ControlElement, ControlProps, JsonFormsCellRendererRegistryEntry, JsonFormsRendererRegistryEntry, JsonSchema, Layout } from '@jsonforms/core';
|
|
2
|
+
import { StateData } from './arrayData';
|
|
3
|
+
import { ErrorObject } from 'ajv';
|
|
4
|
+
export type ObjectArrayControlProps = ArrayLayoutProps & ArrayLayoutExtProps & ControlProps;
|
|
5
|
+
export interface ArrayLayoutExtProps {
|
|
6
|
+
isStepperReview?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface DataProperty {
|
|
9
|
+
type: string;
|
|
10
|
+
format?: string;
|
|
11
|
+
maxLength?: number;
|
|
12
|
+
required?: string[];
|
|
13
|
+
enum: string[];
|
|
14
|
+
items?: Record<string, unknown>;
|
|
15
|
+
}
|
|
16
|
+
export interface DataObject {
|
|
17
|
+
[key: string]: DataProperty;
|
|
18
|
+
}
|
|
19
|
+
export interface NestedItem {
|
|
20
|
+
properties: string[];
|
|
21
|
+
required: string[];
|
|
22
|
+
}
|
|
23
|
+
export interface Items {
|
|
24
|
+
type: string;
|
|
25
|
+
properties: DataObject;
|
|
26
|
+
}
|
|
27
|
+
export interface HandleChangeProps {
|
|
28
|
+
handleChange(path: string, value: any): void;
|
|
29
|
+
}
|
|
30
|
+
export interface NonEmptyCellProps extends OwnPropsOfNonEmptyCell {
|
|
31
|
+
rootSchema?: JsonSchema;
|
|
32
|
+
errors?: ErrorObject[];
|
|
33
|
+
enabled: boolean;
|
|
34
|
+
}
|
|
35
|
+
export interface OwnPropsOfNonEmptyCell {
|
|
36
|
+
rowPath: string;
|
|
37
|
+
propName?: string;
|
|
38
|
+
schema: JsonSchema;
|
|
39
|
+
enabled: boolean;
|
|
40
|
+
renderers?: JsonFormsRendererRegistryEntry[];
|
|
41
|
+
cells?: JsonFormsCellRendererRegistryEntry[];
|
|
42
|
+
uischema?: ControlElement;
|
|
43
|
+
isInReview?: boolean;
|
|
44
|
+
data?: StateData;
|
|
45
|
+
count?: number;
|
|
46
|
+
handleChange(path: string, value: string): void;
|
|
47
|
+
}
|
|
48
|
+
export interface OwnPropsOfNonEmptyCellWithDialog extends OwnPropsOfNonEmptyCell {
|
|
49
|
+
openDeleteDialog: (rowIndex: number) => void;
|
|
50
|
+
}
|
|
51
|
+
export interface NonEmptyRowComponentProps {
|
|
52
|
+
propName?: string;
|
|
53
|
+
schema: JsonSchema;
|
|
54
|
+
rootSchema?: JsonSchema;
|
|
55
|
+
rowPath: string;
|
|
56
|
+
errors?: ErrorObject[];
|
|
57
|
+
enabled: boolean;
|
|
58
|
+
renderers?: JsonFormsRendererRegistryEntry[];
|
|
59
|
+
cells?: JsonFormsCellRendererRegistryEntry[];
|
|
60
|
+
isValid: boolean;
|
|
61
|
+
uischema?: ControlElement | Layout;
|
|
62
|
+
isInReview?: boolean;
|
|
63
|
+
count?: number;
|
|
64
|
+
data: StateData | undefined;
|
|
65
|
+
handleChange(path: string, value: string): void;
|
|
66
|
+
openDeleteDialog(rowIndex: number): void;
|
|
67
|
+
}
|
|
68
|
+
export interface NonEmptyRowProps {
|
|
69
|
+
childPath: string;
|
|
70
|
+
schema: JsonSchema;
|
|
71
|
+
rowIndex: number;
|
|
72
|
+
showSortButtons: boolean;
|
|
73
|
+
enabled: boolean;
|
|
74
|
+
cells?: JsonFormsCellRendererRegistryEntry[];
|
|
75
|
+
path: string;
|
|
76
|
+
translations: ArrayTranslations;
|
|
77
|
+
uischema: ControlElement;
|
|
78
|
+
isInReview?: boolean;
|
|
79
|
+
data?: StateData;
|
|
80
|
+
count: number;
|
|
81
|
+
}
|
|
82
|
+
export interface EmptyListProps {
|
|
83
|
+
numColumns: number;
|
|
84
|
+
translations: ArrayTranslations;
|
|
85
|
+
}
|
|
86
|
+
export interface TableRowsProp {
|
|
87
|
+
data: StateData;
|
|
88
|
+
path: string;
|
|
89
|
+
schema: JsonSchema;
|
|
90
|
+
uischema: ControlElement;
|
|
91
|
+
config?: any;
|
|
92
|
+
enabled: boolean;
|
|
93
|
+
cells?: JsonFormsCellRendererRegistryEntry[];
|
|
94
|
+
translations: ArrayTranslations;
|
|
95
|
+
count: number;
|
|
96
|
+
isInReview?: boolean;
|
|
97
|
+
handleChange: (path: string, value: any) => void;
|
|
98
|
+
}
|
|
99
|
+
export interface RenderCellColumnProps {
|
|
100
|
+
currentData: string | undefined;
|
|
101
|
+
error: string | undefined;
|
|
102
|
+
isRequired: boolean;
|
|
103
|
+
tableKeys?: string[];
|
|
104
|
+
errors: ErrorObject[];
|
|
105
|
+
count: number;
|
|
106
|
+
rowPath: string;
|
|
107
|
+
index: number;
|
|
108
|
+
element: string;
|
|
109
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DataObject, NestedItem, RenderCellColumnProps } from './ObjectListControlTypes';
|
|
2
|
+
export declare const extractNestedFields: (properties: DataObject, propertyKeys: string[]) => Record<string, NestedItem>;
|
|
3
|
+
/**
|
|
4
|
+
* Extract Json data schema name attribute and the ui schema label name.
|
|
5
|
+
* @param obj
|
|
6
|
+
* @param names
|
|
7
|
+
* @returns A key value of the data attribute name and the uiSchema label value
|
|
8
|
+
*/
|
|
9
|
+
export declare const extractNames: (obj: unknown, names?: Record<string, string>) => Record<string, string>;
|
|
10
|
+
export declare const isObjectArrayEmpty: (currentData: string) => boolean;
|
|
11
|
+
export declare const renderCellColumn: ({ currentData, error, errors, index, rowPath, element, isRequired, }: RenderCellColumnProps) => string | import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -14,3 +14,7 @@ export declare const TabName: import("styled-components/dist/types").IStyledComp
|
|
|
14
14
|
export declare const Trash: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
15
15
|
export declare const ListContainer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
16
16
|
export declare const TableTHHeader: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").ThHTMLAttributes<HTMLTableHeaderCellElement>, HTMLTableHeaderCellElement>, never>> & string;
|
|
17
|
+
export declare const ObjectArrayWarningIconDiv: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
18
|
+
export declare const ObjectArrayRequiredTextLabel: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>, never>> & string;
|
|
19
|
+
export declare const HasErrorLabel: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
20
|
+
export declare const HilightCellWarning: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|