@abgov/jsonforms-components 1.25.0 → 1.25.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 +468 -35
- package/package.json +1 -1
- package/src/lib/Controls/ObjectArray/DeleteDialog.d.ts +1 -1
- package/src/lib/Controls/ObjectArray/ListWithDetailControl.d.ts +38 -0
- package/src/lib/Controls/ObjectArray/ObjectArray.d.ts +0 -1
- package/src/lib/Controls/ObjectArray/index.d.ts +1 -0
- package/src/lib/Controls/ObjectArray/listWithDetails.d.ts +5 -0
- package/src/lib/Controls/ObjectArray/styled-components.d.ts +8 -0
package/index.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
2
|
-
import React, { createContext, useContext, useReducer, useMemo, useEffect, useState, useCallback } from 'react';
|
|
2
|
+
import React, { createContext, useContext, useReducer, useMemo, useEffect, useState, useCallback, useRef } from 'react';
|
|
3
3
|
import { GoAFormItem, GoAInput, GoATextArea, GoACallout, GoAInputDate, GoAInputDateTime, GoAInputTime, GoADropdown, GoADropdownItem, GoARadioGroup, GoARadioItem, GoACheckbox, GoAGrid, GoAFormStepper, GoAFormStep, GoAPages, GoAButton, GoAModal, GoAButtonGroup, GoAIconButton, GoAFileUploadInput, GoACircularProgress, GoAContainer, GoADetails } from '@abgov/react-components';
|
|
4
4
|
import styled from 'styled-components';
|
|
5
5
|
import axios from 'axios';
|
|
@@ -3305,7 +3305,7 @@ const GoAInputBaseControl = props => {
|
|
|
3305
3305
|
const InnerComponent = input;
|
|
3306
3306
|
const labelToUpdate = getLabelText(uischema.scope, label || '');
|
|
3307
3307
|
let modifiedErrors = checkFieldValidity(props);
|
|
3308
|
-
if (modifiedErrors === '
|
|
3308
|
+
if (modifiedErrors === 'must be equal to one of the allowed values') {
|
|
3309
3309
|
modifiedErrors = '';
|
|
3310
3310
|
}
|
|
3311
3311
|
const getStepStatus = (props, value) => {
|
|
@@ -4054,6 +4054,7 @@ const EnumSelect = props => {
|
|
|
4054
4054
|
value: data,
|
|
4055
4055
|
disabled: !enabled,
|
|
4056
4056
|
relative: true,
|
|
4057
|
+
width: "100%",
|
|
4057
4058
|
filterable: autocompletion,
|
|
4058
4059
|
testId: `${id || label}-jsonform`
|
|
4059
4060
|
}, appliedUiSchemaOptions, {
|
|
@@ -4440,12 +4441,12 @@ let _$4 = t => t,
|
|
|
4440
4441
|
_t2$2,
|
|
4441
4442
|
_t3$2,
|
|
4442
4443
|
_t4$1,
|
|
4443
|
-
_t5,
|
|
4444
|
-
_t6,
|
|
4445
|
-
_t7,
|
|
4446
|
-
_t8,
|
|
4447
|
-
_t9,
|
|
4448
|
-
_t10;
|
|
4444
|
+
_t5$1,
|
|
4445
|
+
_t6$1,
|
|
4446
|
+
_t7$1,
|
|
4447
|
+
_t8$1,
|
|
4448
|
+
_t9$1,
|
|
4449
|
+
_t10$1;
|
|
4449
4450
|
const ReviewItem = styled.div(_t$4 || (_t$4 = _$4`
|
|
4450
4451
|
display: flex;
|
|
4451
4452
|
flex-direction: column;
|
|
@@ -4472,26 +4473,26 @@ const ReviewItemTitle = styled.div(_t4$1 || (_t4$1 = _$4`
|
|
|
4472
4473
|
line-height: var(--lh-lg);
|
|
4473
4474
|
font-weight: var(--fw-light);
|
|
4474
4475
|
`));
|
|
4475
|
-
const Anchor = styled.div(_t5 || (_t5 = _$4`
|
|
4476
|
+
const Anchor = styled.div(_t5$1 || (_t5$1 = _$4`
|
|
4476
4477
|
color: #0070c4;
|
|
4477
4478
|
text-decoration: underline;
|
|
4478
4479
|
outline: none;
|
|
4479
4480
|
cursor: pointer;
|
|
4480
4481
|
`));
|
|
4481
|
-
styled.div(_t6 || (_t6 = _$4`
|
|
4482
|
+
styled.div(_t6$1 || (_t6$1 = _$4`
|
|
4482
4483
|
margin-left: var(--goa-space-m);
|
|
4483
4484
|
`));
|
|
4484
|
-
styled.div(_t7 || (_t7 = _$4`
|
|
4485
|
+
styled.div(_t7$1 || (_t7$1 = _$4`
|
|
4485
4486
|
margin-bottom: var(--goa-space-m);
|
|
4486
4487
|
`));
|
|
4487
|
-
styled.div(_t8 || (_t8 = _$4`
|
|
4488
|
+
styled.div(_t8$1 || (_t8$1 = _$4`
|
|
4488
4489
|
margin: var(--goa-space-s);
|
|
4489
4490
|
width: 100%;
|
|
4490
4491
|
`));
|
|
4491
|
-
styled.h3(_t9 || (_t9 = _$4`
|
|
4492
|
+
styled.h3(_t9$1 || (_t9$1 = _$4`
|
|
4492
4493
|
text-transform: capitalize;
|
|
4493
4494
|
`));
|
|
4494
|
-
const RightAlignmentDiv = styled.div(_t10 || (_t10 = _$4`
|
|
4495
|
+
const RightAlignmentDiv = styled.div(_t10$1 || (_t10$1 = _$4`
|
|
4495
4496
|
display: flex;
|
|
4496
4497
|
justify-content: flex-end;
|
|
4497
4498
|
`));
|
|
@@ -5426,7 +5427,15 @@ let _$1 = t => t,
|
|
|
5426
5427
|
_t$1,
|
|
5427
5428
|
_t2,
|
|
5428
5429
|
_t3,
|
|
5429
|
-
_t4
|
|
5430
|
+
_t4,
|
|
5431
|
+
_t5,
|
|
5432
|
+
_t6,
|
|
5433
|
+
_t7,
|
|
5434
|
+
_t8,
|
|
5435
|
+
_t9,
|
|
5436
|
+
_t10,
|
|
5437
|
+
_t11,
|
|
5438
|
+
_t12;
|
|
5430
5439
|
const DeleteDialogContent = styled.div(_t$1 || (_t$1 = _$1`
|
|
5431
5440
|
margin-bottom: var(--goa-space-m);
|
|
5432
5441
|
`));
|
|
@@ -5439,9 +5448,46 @@ const ObjectArrayTitle = styled.h2(_t3 || (_t3 = _$1`
|
|
|
5439
5448
|
const TextCenter = styled.div(_t4 || (_t4 = _$1`
|
|
5440
5449
|
text-align: center;
|
|
5441
5450
|
`));
|
|
5451
|
+
const SideMenuItem = styled.div(_t5 || (_t5 = _$1`
|
|
5452
|
+
&:hover {
|
|
5453
|
+
background: #f1f1f1;
|
|
5454
|
+
}
|
|
5455
|
+
`));
|
|
5456
|
+
const RowFlex = styled.div(_t6 || (_t6 = _$1`
|
|
5457
|
+
display: flex;
|
|
5458
|
+
align-items: stretch;
|
|
5459
|
+
`));
|
|
5460
|
+
const RowFlexMenu = styled.div(_t7 || (_t7 = _$1`
|
|
5461
|
+
display: flex;
|
|
5462
|
+
flex-direction: row;
|
|
5463
|
+
border-bottom: 1px solid #dcdcdc;
|
|
5464
|
+
`));
|
|
5465
|
+
const FlexTabs = styled.div(_t8 || (_t8 = _$1`
|
|
5466
|
+
flex-direction: column;
|
|
5467
|
+
flex: 1;
|
|
5468
|
+
overflow-y: auto !important;
|
|
5469
|
+
margin-right: 1.5rem;
|
|
5470
|
+
`));
|
|
5471
|
+
const FlexForm = styled.div(_t9 || (_t9 = _$1`
|
|
5472
|
+
flex-direction: column;
|
|
5473
|
+
margin: 1.5rem 0;
|
|
5474
|
+
flex: 3;
|
|
5475
|
+
`));
|
|
5476
|
+
const TabName = styled.div(_t10 || (_t10 = _$1`
|
|
5477
|
+
margin: 1rem 0 1rem 1rem;
|
|
5478
|
+
font-weight: 700;
|
|
5479
|
+
`));
|
|
5480
|
+
const Trash = styled.div(_t11 || (_t11 = _$1`
|
|
5481
|
+
margin: 0.75rem 1.25rem 0.75rem 0.75rem;
|
|
5482
|
+
margin-left: auto;
|
|
5483
|
+
`));
|
|
5484
|
+
const ListContainer = styled.div(_t12 || (_t12 = _$1`
|
|
5485
|
+
padding: 0 1.5rem 0 0;
|
|
5486
|
+
border: 1px solid #dcdcdc;
|
|
5487
|
+
`));
|
|
5442
5488
|
|
|
5443
5489
|
// eslint-disable-next-line
|
|
5444
|
-
const extractScopesFromUISchema = uischema => {
|
|
5490
|
+
const extractScopesFromUISchema$1 = uischema => {
|
|
5445
5491
|
var _a;
|
|
5446
5492
|
const scopes = [];
|
|
5447
5493
|
if (uischema === null || uischema === void 0 ? void 0 : uischema.elements) {
|
|
@@ -5464,7 +5510,7 @@ const extractScopesFromUISchema = uischema => {
|
|
|
5464
5510
|
}
|
|
5465
5511
|
return scopes;
|
|
5466
5512
|
};
|
|
5467
|
-
const GenerateRows = (Cell, schema, rowPath, enabled, cells, uischema, isInReview) => {
|
|
5513
|
+
const GenerateRows$1 = (Cell, schema, rowPath, enabled, cells, uischema, isInReview) => {
|
|
5468
5514
|
if (schema.type === 'object') {
|
|
5469
5515
|
const props = {
|
|
5470
5516
|
schema,
|
|
@@ -5487,7 +5533,7 @@ const GenerateRows = (Cell, schema, rowPath, enabled, cells, uischema, isInRevie
|
|
|
5487
5533
|
return jsx(Cell, Object.assign({}, props), rowPath);
|
|
5488
5534
|
}
|
|
5489
5535
|
};
|
|
5490
|
-
const getValidColumnProps = scopedSchema => {
|
|
5536
|
+
const getValidColumnProps$1 = scopedSchema => {
|
|
5491
5537
|
if (scopedSchema.type === 'object' && typeof scopedSchema.properties === 'object') {
|
|
5492
5538
|
return Object.keys(scopedSchema.properties).filter(prop => {
|
|
5493
5539
|
var _a;
|
|
@@ -5497,7 +5543,7 @@ const getValidColumnProps = scopedSchema => {
|
|
|
5497
5543
|
// primitives
|
|
5498
5544
|
return [''];
|
|
5499
5545
|
};
|
|
5500
|
-
const EmptyList = ({
|
|
5546
|
+
const EmptyList$1 = ({
|
|
5501
5547
|
numColumns,
|
|
5502
5548
|
translations
|
|
5503
5549
|
}) => jsx(GoAGrid, {
|
|
@@ -5508,7 +5554,7 @@ const EmptyList = ({
|
|
|
5508
5554
|
})
|
|
5509
5555
|
})
|
|
5510
5556
|
});
|
|
5511
|
-
const ctxToNonEmptyCellProps = (ctx, ownProps) => {
|
|
5557
|
+
const ctxToNonEmptyCellProps$1 = (ctx, ownProps) => {
|
|
5512
5558
|
var _a;
|
|
5513
5559
|
ownProps.rowPath + (ownProps.schema.type === 'object' ? '.' + ownProps.propName : '');
|
|
5514
5560
|
const errors = '';
|
|
@@ -5523,7 +5569,7 @@ const ctxToNonEmptyCellProps = (ctx, ownProps) => {
|
|
|
5523
5569
|
renderers: ownProps.renderers || ctx.renderers
|
|
5524
5570
|
};
|
|
5525
5571
|
};
|
|
5526
|
-
const NonEmptyCellComponent = /*#__PURE__*/React.memo(function NonEmptyCellComponent(props) {
|
|
5572
|
+
const NonEmptyCellComponent$1 = /*#__PURE__*/React.memo(function NonEmptyCellComponent(props) {
|
|
5527
5573
|
var _a, _b;
|
|
5528
5574
|
const {
|
|
5529
5575
|
schema,
|
|
@@ -5536,11 +5582,11 @@ const NonEmptyCellComponent = /*#__PURE__*/React.memo(function NonEmptyCellCompo
|
|
|
5536
5582
|
uischema,
|
|
5537
5583
|
isInReview
|
|
5538
5584
|
} = props;
|
|
5539
|
-
const propNames = getValidColumnProps(schema);
|
|
5585
|
+
const propNames = getValidColumnProps$1(schema);
|
|
5540
5586
|
const propScopes = (uischema === null || uischema === void 0 ? void 0 : uischema.scope) ? propNames.map(name => {
|
|
5541
5587
|
return `#/properties/${name}`;
|
|
5542
5588
|
}) : [];
|
|
5543
|
-
const scopesInElements = extractScopesFromUISchema(uischema);
|
|
5589
|
+
const scopesInElements = extractScopesFromUISchema$1(uischema);
|
|
5544
5590
|
const scopesNotInElements = propScopes.filter(scope => {
|
|
5545
5591
|
return !scopesInElements.includes(scope);
|
|
5546
5592
|
});
|
|
@@ -5596,16 +5642,16 @@ const NonEmptyCellComponent = /*#__PURE__*/React.memo(function NonEmptyCellCompo
|
|
|
5596
5642
|
})]
|
|
5597
5643
|
});
|
|
5598
5644
|
});
|
|
5599
|
-
const NonEmptyCell = ownProps => {
|
|
5645
|
+
const NonEmptyCell$1 = ownProps => {
|
|
5600
5646
|
const ctx = useJsonForms();
|
|
5601
|
-
const emptyCellProps = ctxToNonEmptyCellProps(ctx, ownProps);
|
|
5647
|
+
const emptyCellProps = ctxToNonEmptyCellProps$1(ctx, ownProps);
|
|
5602
5648
|
const isValid = isEmpty$1(emptyCellProps.errors);
|
|
5603
|
-
return jsx(NonEmptyCellComponent, Object.assign({}, emptyCellProps, {
|
|
5649
|
+
return jsx(NonEmptyCellComponent$1, Object.assign({}, emptyCellProps, {
|
|
5604
5650
|
isInReview: ownProps === null || ownProps === void 0 ? void 0 : ownProps.isInReview,
|
|
5605
5651
|
isValid: isValid
|
|
5606
5652
|
}));
|
|
5607
5653
|
};
|
|
5608
|
-
const NonEmptyRowComponent = ({
|
|
5654
|
+
const NonEmptyRowComponent$1 = ({
|
|
5609
5655
|
childPath,
|
|
5610
5656
|
schema,
|
|
5611
5657
|
rowIndex,
|
|
@@ -5626,12 +5672,12 @@ const NonEmptyRowComponent = ({
|
|
|
5626
5672
|
"aria-label": translations.removeAriaLabel,
|
|
5627
5673
|
onClick: () => openDeleteDialog(childPath, rowIndex)
|
|
5628
5674
|
})
|
|
5629
|
-
}), GenerateRows(NonEmptyCell, schema, childPath, enabled, cells, uischema, isInReview)]
|
|
5675
|
+
}), GenerateRows$1(NonEmptyCell$1, schema, childPath, enabled, cells, uischema, isInReview)]
|
|
5630
5676
|
}) : null
|
|
5631
5677
|
}, childPath);
|
|
5632
5678
|
};
|
|
5633
|
-
const NonEmptyList = /*#__PURE__*/React.memo(NonEmptyRowComponent);
|
|
5634
|
-
const ObjectArrayList = ({
|
|
5679
|
+
const NonEmptyList$1 = /*#__PURE__*/React.memo(NonEmptyRowComponent$1);
|
|
5680
|
+
const ObjectArrayList$1 = ({
|
|
5635
5681
|
data,
|
|
5636
5682
|
path,
|
|
5637
5683
|
schema,
|
|
@@ -5645,8 +5691,8 @@ const ObjectArrayList = ({
|
|
|
5645
5691
|
}) => {
|
|
5646
5692
|
const isEmptyList = data === 0;
|
|
5647
5693
|
if (isEmptyList) {
|
|
5648
|
-
return jsx(EmptyList, {
|
|
5649
|
-
numColumns: getValidColumnProps(schema).length + 1,
|
|
5694
|
+
return jsx(EmptyList$1, {
|
|
5695
|
+
numColumns: getValidColumnProps$1(schema).length + 1,
|
|
5650
5696
|
translations: translations
|
|
5651
5697
|
});
|
|
5652
5698
|
}
|
|
@@ -5654,7 +5700,7 @@ const ObjectArrayList = ({
|
|
|
5654
5700
|
return jsx(Fragment, {
|
|
5655
5701
|
children: range(data).map(index => {
|
|
5656
5702
|
const childPath = Paths.compose(path, `${index}`);
|
|
5657
|
-
return jsx(NonEmptyList, {
|
|
5703
|
+
return jsx(NonEmptyList$1, {
|
|
5658
5704
|
childPath: childPath,
|
|
5659
5705
|
rowIndex: index,
|
|
5660
5706
|
schema: schema,
|
|
@@ -5722,7 +5768,7 @@ class ObjectArrayControl extends React.Component {
|
|
|
5722
5768
|
translations: translations
|
|
5723
5769
|
})]
|
|
5724
5770
|
}), jsx("div", {
|
|
5725
|
-
children: jsx(ObjectArrayList, Object.assign({
|
|
5771
|
+
children: jsx(ObjectArrayList$1, Object.assign({
|
|
5726
5772
|
path: path,
|
|
5727
5773
|
schema: schema,
|
|
5728
5774
|
uischema: uischema,
|
|
@@ -5764,6 +5810,7 @@ const DeleteDialog = /*#__PURE__*/React.memo(function DeleteDialog({
|
|
|
5764
5810
|
children: "Cancel"
|
|
5765
5811
|
}), jsx(GoAButton, {
|
|
5766
5812
|
type: "primary",
|
|
5813
|
+
variant: "destructive",
|
|
5767
5814
|
testId: "object-array-confirm-button",
|
|
5768
5815
|
onClick: () => {
|
|
5769
5816
|
onConfirm();
|
|
@@ -5825,6 +5872,392 @@ const ArrayBaseReviewControl = props => {
|
|
|
5825
5872
|
const GoAArrayControlTester = rankWith(3, or(isObjectArrayControl, isPrimitiveArrayControl));
|
|
5826
5873
|
const GoAArrayControlRenderer = withJsonFormsArrayLayoutProps(ArrayControl);
|
|
5827
5874
|
const GoAArrayControlReviewRenderer = withJsonFormsArrayLayoutProps(ArrayBaseReviewControl);
|
|
5875
|
+
|
|
5876
|
+
// eslint-disable-next-line
|
|
5877
|
+
const extractScopesFromUISchema = uischema => {
|
|
5878
|
+
var _a;
|
|
5879
|
+
const scopes = [];
|
|
5880
|
+
if (uischema === null || uischema === void 0 ? void 0 : uischema.elements) {
|
|
5881
|
+
// eslint-disable-next-line
|
|
5882
|
+
(_a = uischema === null || uischema === void 0 ? void 0 : uischema.elements) === null || _a === void 0 ? void 0 : _a.forEach(element => {
|
|
5883
|
+
var _a;
|
|
5884
|
+
if (element === null || element === void 0 ? void 0 : element.elements) {
|
|
5885
|
+
// eslint-disable-next-line
|
|
5886
|
+
(_a = element === null || element === void 0 ? void 0 : element.elements) === null || _a === void 0 ? void 0 : _a.forEach(internalElement => {
|
|
5887
|
+
if (internalElement === null || internalElement === void 0 ? void 0 : internalElement.scope) {
|
|
5888
|
+
scopes.push(internalElement === null || internalElement === void 0 ? void 0 : internalElement.scope);
|
|
5889
|
+
}
|
|
5890
|
+
});
|
|
5891
|
+
} else {
|
|
5892
|
+
if (element === null || element === void 0 ? void 0 : element.scope) {
|
|
5893
|
+
scopes.push(element === null || element === void 0 ? void 0 : element.scope);
|
|
5894
|
+
}
|
|
5895
|
+
}
|
|
5896
|
+
});
|
|
5897
|
+
}
|
|
5898
|
+
return scopes;
|
|
5899
|
+
};
|
|
5900
|
+
const GenerateRows = (Cell, schema, rowPath, enabled, cells, uischema) => {
|
|
5901
|
+
if (schema.type === 'object') {
|
|
5902
|
+
const props = {
|
|
5903
|
+
schema,
|
|
5904
|
+
rowPath,
|
|
5905
|
+
enabled,
|
|
5906
|
+
cells,
|
|
5907
|
+
uischema
|
|
5908
|
+
};
|
|
5909
|
+
return jsx(Cell, Object.assign({}, props));
|
|
5910
|
+
} else {
|
|
5911
|
+
// primitives
|
|
5912
|
+
const props = {
|
|
5913
|
+
schema,
|
|
5914
|
+
rowPath,
|
|
5915
|
+
cellPath: rowPath,
|
|
5916
|
+
enabled
|
|
5917
|
+
};
|
|
5918
|
+
return jsx(Cell, Object.assign({}, props), rowPath);
|
|
5919
|
+
}
|
|
5920
|
+
};
|
|
5921
|
+
const getValidColumnProps = scopedSchema => {
|
|
5922
|
+
if (scopedSchema.type === 'object' && typeof scopedSchema.properties === 'object') {
|
|
5923
|
+
return Object.keys(scopedSchema.properties).filter(prop => {
|
|
5924
|
+
var _a;
|
|
5925
|
+
return ((_a = scopedSchema.properties) === null || _a === void 0 ? void 0 : _a[prop].type) !== 'array';
|
|
5926
|
+
});
|
|
5927
|
+
}
|
|
5928
|
+
// primitives
|
|
5929
|
+
return [''];
|
|
5930
|
+
};
|
|
5931
|
+
const EmptyList = ({
|
|
5932
|
+
numColumns,
|
|
5933
|
+
translations
|
|
5934
|
+
}) => jsx(GoAGrid, {
|
|
5935
|
+
minChildWidth: "60ch",
|
|
5936
|
+
children: jsx(TextCenter, {
|
|
5937
|
+
children: jsx("b", {
|
|
5938
|
+
children: translations.noDataMessage
|
|
5939
|
+
})
|
|
5940
|
+
})
|
|
5941
|
+
});
|
|
5942
|
+
const ctxToNonEmptyCellProps = (ctx, ownProps) => {
|
|
5943
|
+
var _a;
|
|
5944
|
+
ownProps.rowPath + (ownProps.schema.type === 'object' ? '.' + ownProps.propName : '');
|
|
5945
|
+
const errors = '';
|
|
5946
|
+
return {
|
|
5947
|
+
uischema: ownProps.uischema,
|
|
5948
|
+
rowPath: ownProps.rowPath,
|
|
5949
|
+
schema: ownProps.schema,
|
|
5950
|
+
rootSchema: (_a = ctx.core) === null || _a === void 0 ? void 0 : _a.schema,
|
|
5951
|
+
errors,
|
|
5952
|
+
enabled: ownProps.enabled,
|
|
5953
|
+
cells: ownProps.cells || ctx.cells,
|
|
5954
|
+
renderers: ownProps.renderers || ctx.renderers
|
|
5955
|
+
};
|
|
5956
|
+
};
|
|
5957
|
+
const NonEmptyCellComponent = /*#__PURE__*/React.memo(function NonEmptyCellComponent(props) {
|
|
5958
|
+
var _a, _b;
|
|
5959
|
+
const {
|
|
5960
|
+
schema,
|
|
5961
|
+
errors,
|
|
5962
|
+
enabled,
|
|
5963
|
+
renderers,
|
|
5964
|
+
cells,
|
|
5965
|
+
rowPath,
|
|
5966
|
+
isValid,
|
|
5967
|
+
uischema
|
|
5968
|
+
} = props;
|
|
5969
|
+
const propNames = getValidColumnProps(schema);
|
|
5970
|
+
const propScopes = (uischema === null || uischema === void 0 ? void 0 : uischema.scope) ? propNames.map(name => {
|
|
5971
|
+
return `#/properties/${name}`;
|
|
5972
|
+
}) : [];
|
|
5973
|
+
const scopesInElements = extractScopesFromUISchema(uischema);
|
|
5974
|
+
const scopesNotInElements = propScopes.filter(scope => {
|
|
5975
|
+
return !scopesInElements.includes(scope);
|
|
5976
|
+
});
|
|
5977
|
+
/**
|
|
5978
|
+
* Get the first layout type in the elements for the object array and used it
|
|
5979
|
+
* as the default type, if none is provided.
|
|
5980
|
+
* @returns layout type
|
|
5981
|
+
*/
|
|
5982
|
+
const getFirstLayoutType = () => {
|
|
5983
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
5984
|
+
let defaultType = 'VerticalLayout';
|
|
5985
|
+
if ((_a = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _a === void 0 ? void 0 : _a.defaultType) return (_b = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _b === void 0 ? void 0 : _b.defaultType;
|
|
5986
|
+
if (((_c = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _c === void 0 ? void 0 : _c.detail) && ((_f = (_e = (_d = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _d === void 0 ? void 0 : _d.detail) === null || _e === void 0 ? void 0 : _e.elements) === null || _f === void 0 ? void 0 : _f.length) > 0) {
|
|
5987
|
+
defaultType = (_h = (_g = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _g === void 0 ? void 0 : _g.detail) === null || _h === void 0 ? void 0 : _h.elements.at(0).type;
|
|
5988
|
+
}
|
|
5989
|
+
return defaultType;
|
|
5990
|
+
};
|
|
5991
|
+
/* Create default elements for scope not defined in the uischema
|
|
5992
|
+
* future work: merge the options
|
|
5993
|
+
*/
|
|
5994
|
+
const uiSchemaElementsForNotDefined = {
|
|
5995
|
+
type: getFirstLayoutType(),
|
|
5996
|
+
elements: scopesNotInElements.map(scope => {
|
|
5997
|
+
return {
|
|
5998
|
+
type: 'Control',
|
|
5999
|
+
scope
|
|
6000
|
+
};
|
|
6001
|
+
})
|
|
6002
|
+
};
|
|
6003
|
+
return jsxs(Fragment, {
|
|
6004
|
+
children: [
|
|
6005
|
+
// eslint-disable-next-line
|
|
6006
|
+
(_a = uischema === null || uischema === void 0 ? void 0 : uischema.elements) === null || _a === void 0 ? void 0 : _a.map(element => {
|
|
6007
|
+
return jsx(JsonFormsDispatch, {
|
|
6008
|
+
"data-testid": `jsonforms-object-list-defined-elements-dispatch`,
|
|
6009
|
+
schema: schema,
|
|
6010
|
+
uischema: element,
|
|
6011
|
+
path: rowPath,
|
|
6012
|
+
enabled: enabled,
|
|
6013
|
+
renderers: renderers,
|
|
6014
|
+
cells: cells
|
|
6015
|
+
}, rowPath);
|
|
6016
|
+
}), ((_b = uiSchemaElementsForNotDefined === null || uiSchemaElementsForNotDefined === void 0 ? void 0 : uiSchemaElementsForNotDefined.elements) === null || _b === void 0 ? void 0 : _b.length) > 0 && jsx(JsonFormsDispatch, {
|
|
6017
|
+
schema: schema,
|
|
6018
|
+
uischema: uiSchemaElementsForNotDefined,
|
|
6019
|
+
path: rowPath,
|
|
6020
|
+
enabled: enabled,
|
|
6021
|
+
renderers: renderers,
|
|
6022
|
+
cells: cells
|
|
6023
|
+
})]
|
|
6024
|
+
});
|
|
6025
|
+
});
|
|
6026
|
+
const NonEmptyCell = ownProps => {
|
|
6027
|
+
const ctx = useJsonForms();
|
|
6028
|
+
const emptyCellProps = ctxToNonEmptyCellProps(ctx, ownProps);
|
|
6029
|
+
const isValid = isEmpty$1(emptyCellProps.errors);
|
|
6030
|
+
return jsx(NonEmptyCellComponent, Object.assign({}, emptyCellProps, {
|
|
6031
|
+
isValid: isValid
|
|
6032
|
+
}));
|
|
6033
|
+
};
|
|
6034
|
+
const NonEmptyRowComponent = ({
|
|
6035
|
+
childPath,
|
|
6036
|
+
schema,
|
|
6037
|
+
enabled,
|
|
6038
|
+
cells,
|
|
6039
|
+
uischema
|
|
6040
|
+
}) => {
|
|
6041
|
+
return jsx("div", {
|
|
6042
|
+
children: enabled ? jsx(GoAGrid, {
|
|
6043
|
+
minChildWidth: "30ch",
|
|
6044
|
+
children: GenerateRows(NonEmptyCell, schema, childPath, enabled, cells, uischema)
|
|
6045
|
+
}) : null
|
|
6046
|
+
}, childPath);
|
|
6047
|
+
};
|
|
6048
|
+
const LeftTab = ({
|
|
6049
|
+
childPath,
|
|
6050
|
+
rowIndex,
|
|
6051
|
+
openDeleteDialog,
|
|
6052
|
+
selectCurrentTab,
|
|
6053
|
+
enabled,
|
|
6054
|
+
currentTab,
|
|
6055
|
+
name,
|
|
6056
|
+
translations
|
|
6057
|
+
}) => {
|
|
6058
|
+
return jsx("div", {
|
|
6059
|
+
children: enabled ? jsx(SideMenuItem, {
|
|
6060
|
+
style: currentTab === rowIndex ? {
|
|
6061
|
+
background: '#EFF8FF'
|
|
6062
|
+
} : {},
|
|
6063
|
+
onClick: () => selectCurrentTab(rowIndex),
|
|
6064
|
+
children: jsxs(RowFlexMenu, {
|
|
6065
|
+
children: [jsx(TabName, {
|
|
6066
|
+
children: name
|
|
6067
|
+
}), jsx(Trash, {
|
|
6068
|
+
children: jsx(GoAIconButton, {
|
|
6069
|
+
icon: "trash",
|
|
6070
|
+
"aria-label": translations.removeAriaLabel,
|
|
6071
|
+
onClick: () => openDeleteDialog(childPath, rowIndex, name)
|
|
6072
|
+
})
|
|
6073
|
+
})]
|
|
6074
|
+
})
|
|
6075
|
+
}) : null
|
|
6076
|
+
}, childPath);
|
|
6077
|
+
};
|
|
6078
|
+
const NonEmptyList = /*#__PURE__*/React.memo(NonEmptyRowComponent);
|
|
6079
|
+
const ObjectArrayList = ({
|
|
6080
|
+
data,
|
|
6081
|
+
path,
|
|
6082
|
+
schema,
|
|
6083
|
+
openDeleteDialog,
|
|
6084
|
+
uischema,
|
|
6085
|
+
config,
|
|
6086
|
+
enabled,
|
|
6087
|
+
cells,
|
|
6088
|
+
translations
|
|
6089
|
+
}) => {
|
|
6090
|
+
const isEmptyList = data === 0;
|
|
6091
|
+
const rightRef = useRef(null);
|
|
6092
|
+
const current = rightRef.current;
|
|
6093
|
+
const [rightHeight, setRightHeight] = useState(0);
|
|
6094
|
+
const [currentTab, setCurrentTab] = useState(0);
|
|
6095
|
+
useEffect(() => {
|
|
6096
|
+
const resizeObserver = new ResizeObserver(entries => {
|
|
6097
|
+
if (rightHeight !== (current === null || current === void 0 ? void 0 : current.offsetHeight)) setRightHeight(current === null || current === void 0 ? void 0 : current.offsetHeight);
|
|
6098
|
+
});
|
|
6099
|
+
if (current) {
|
|
6100
|
+
resizeObserver.observe(current);
|
|
6101
|
+
}
|
|
6102
|
+
return () => {
|
|
6103
|
+
if (current) {
|
|
6104
|
+
resizeObserver.unobserve(current);
|
|
6105
|
+
}
|
|
6106
|
+
};
|
|
6107
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
6108
|
+
}, [current]);
|
|
6109
|
+
if (isEmptyList) {
|
|
6110
|
+
return jsx(EmptyList, {
|
|
6111
|
+
numColumns: getValidColumnProps(schema).length + 1,
|
|
6112
|
+
translations: translations
|
|
6113
|
+
});
|
|
6114
|
+
}
|
|
6115
|
+
const appliedUiSchemaOptions = merge({}, config, uischema.options);
|
|
6116
|
+
const selectCurrentTab = index => {
|
|
6117
|
+
setCurrentTab(index);
|
|
6118
|
+
};
|
|
6119
|
+
const paddedHeight = rightHeight && rightHeight + 48;
|
|
6120
|
+
return jsx(ListContainer, {
|
|
6121
|
+
children: jsxs(RowFlex, {
|
|
6122
|
+
children: [jsx(FlexTabs, {
|
|
6123
|
+
style: {
|
|
6124
|
+
height: paddedHeight
|
|
6125
|
+
},
|
|
6126
|
+
children: range(data).map(index => {
|
|
6127
|
+
const childPath = Paths.compose(path, `${index}`);
|
|
6128
|
+
const name = `${index}: ${path}`;
|
|
6129
|
+
return jsx(LeftTab, {
|
|
6130
|
+
childPath: childPath,
|
|
6131
|
+
rowIndex: index,
|
|
6132
|
+
currentTab: currentTab,
|
|
6133
|
+
name: name,
|
|
6134
|
+
openDeleteDialog: openDeleteDialog,
|
|
6135
|
+
selectCurrentTab: selectCurrentTab,
|
|
6136
|
+
enabled: enabled,
|
|
6137
|
+
translations: translations
|
|
6138
|
+
}, childPath);
|
|
6139
|
+
})
|
|
6140
|
+
}), jsx(FlexForm, {
|
|
6141
|
+
ref: rightRef,
|
|
6142
|
+
children: jsx(NonEmptyList, {
|
|
6143
|
+
childPath: Paths.compose(path, `${currentTab}`),
|
|
6144
|
+
rowIndex: currentTab,
|
|
6145
|
+
schema: schema,
|
|
6146
|
+
openDeleteDialog: openDeleteDialog,
|
|
6147
|
+
showSortButtons: appliedUiSchemaOptions.showSortButtons || appliedUiSchemaOptions.showArrayTableSortButtons,
|
|
6148
|
+
enabled: enabled,
|
|
6149
|
+
cells: cells,
|
|
6150
|
+
path: path,
|
|
6151
|
+
uischema: uischema,
|
|
6152
|
+
translations: translations
|
|
6153
|
+
}, Paths.compose(path, `${currentTab}`))
|
|
6154
|
+
})]
|
|
6155
|
+
})
|
|
6156
|
+
});
|
|
6157
|
+
};
|
|
6158
|
+
// eslint-disable-next-line
|
|
6159
|
+
class ListWithDetailControl extends React.Component {
|
|
6160
|
+
constructor() {
|
|
6161
|
+
super(...arguments);
|
|
6162
|
+
// eslint-disable-next-line
|
|
6163
|
+
this.addItem = (path, value) => this.props.addItem(path, value);
|
|
6164
|
+
}
|
|
6165
|
+
render() {
|
|
6166
|
+
var _a;
|
|
6167
|
+
const _b = this.props,
|
|
6168
|
+
{
|
|
6169
|
+
label,
|
|
6170
|
+
path,
|
|
6171
|
+
schema,
|
|
6172
|
+
rootSchema,
|
|
6173
|
+
uischema,
|
|
6174
|
+
errors,
|
|
6175
|
+
openDeleteDialog,
|
|
6176
|
+
visible,
|
|
6177
|
+
enabled,
|
|
6178
|
+
cells,
|
|
6179
|
+
translations,
|
|
6180
|
+
data,
|
|
6181
|
+
config
|
|
6182
|
+
} = _b,
|
|
6183
|
+
additionalProps = __rest(_b, ["label", "path", "schema", "rootSchema", "uischema", "errors", "openDeleteDialog", "visible", "enabled", "cells", "translations", "data", "config"]);
|
|
6184
|
+
const controlElement = uischema;
|
|
6185
|
+
// eslint-disable-next-line
|
|
6186
|
+
const listTitle = label || ((_a = uischema.options) === null || _a === void 0 ? void 0 : _a.title);
|
|
6187
|
+
return jsxs(Visible, {
|
|
6188
|
+
visible: visible,
|
|
6189
|
+
"data-testid": "jsonforms-object-list-wrapper",
|
|
6190
|
+
children: [jsxs(ToolBarHeader, {
|
|
6191
|
+
children: [listTitle && jsx(ObjectArrayTitle, {
|
|
6192
|
+
children: listTitle
|
|
6193
|
+
}), jsx(ObjectArrayToolBar, {
|
|
6194
|
+
errors: errors,
|
|
6195
|
+
label: label,
|
|
6196
|
+
addItem: this.addItem,
|
|
6197
|
+
numColumns: 0,
|
|
6198
|
+
path: path,
|
|
6199
|
+
uischema: controlElement,
|
|
6200
|
+
schema: schema,
|
|
6201
|
+
rootSchema: rootSchema,
|
|
6202
|
+
enabled: enabled,
|
|
6203
|
+
translations: translations
|
|
6204
|
+
})]
|
|
6205
|
+
}), jsx("div", {
|
|
6206
|
+
children: jsx(ObjectArrayList, Object.assign({
|
|
6207
|
+
path: path,
|
|
6208
|
+
schema: schema,
|
|
6209
|
+
uischema: uischema,
|
|
6210
|
+
enabled: enabled,
|
|
6211
|
+
openDeleteDialog: openDeleteDialog,
|
|
6212
|
+
translations: translations,
|
|
6213
|
+
data: data,
|
|
6214
|
+
cells: cells,
|
|
6215
|
+
config: config
|
|
6216
|
+
}, additionalProps))
|
|
6217
|
+
})]
|
|
6218
|
+
});
|
|
6219
|
+
}
|
|
6220
|
+
}
|
|
6221
|
+
|
|
6222
|
+
const ListWithDetailsControl = props => {
|
|
6223
|
+
const [open, setOpen] = useState(false);
|
|
6224
|
+
const [path, setPath] = useState();
|
|
6225
|
+
const [name, setName] = useState();
|
|
6226
|
+
const [rowData, setRowData] = useState(0);
|
|
6227
|
+
const {
|
|
6228
|
+
removeItems,
|
|
6229
|
+
visible
|
|
6230
|
+
} = props;
|
|
6231
|
+
const openDeleteDialog = useCallback((p, rowIndex, name) => {
|
|
6232
|
+
setOpen(true);
|
|
6233
|
+
setPath(p);
|
|
6234
|
+
setName(name);
|
|
6235
|
+
setRowData(rowIndex);
|
|
6236
|
+
}, [setOpen, setPath, setRowData]);
|
|
6237
|
+
const deleteCancel = useCallback(() => setOpen(false), [setOpen]);
|
|
6238
|
+
// eslint-disable-next-line
|
|
6239
|
+
const deleteConfirm = useCallback(() => {
|
|
6240
|
+
const p = path === null || path === void 0 ? void 0 : path.substring(0, path.lastIndexOf('.'));
|
|
6241
|
+
if (removeItems && p) {
|
|
6242
|
+
removeItems(p, [rowData])();
|
|
6243
|
+
}
|
|
6244
|
+
setOpen(false);
|
|
6245
|
+
// eslint-disable-next-line
|
|
6246
|
+
}, [setOpen, path, rowData]);
|
|
6247
|
+
return jsxs(Visible, {
|
|
6248
|
+
visible: visible,
|
|
6249
|
+
children: [jsx(ListWithDetailControl, Object.assign({}, props, {
|
|
6250
|
+
openDeleteDialog: openDeleteDialog
|
|
6251
|
+
})), jsx(DeleteDialog, {
|
|
6252
|
+
open: open,
|
|
6253
|
+
onCancel: deleteCancel,
|
|
6254
|
+
onConfirm: deleteConfirm,
|
|
6255
|
+
title: props.translations.deleteDialogTitle || '',
|
|
6256
|
+
message: `Are you sure you wish to delete ${name} `
|
|
6257
|
+
})]
|
|
6258
|
+
});
|
|
6259
|
+
};
|
|
6260
|
+
const GoAListWithDetailsControlRenderer = withJsonFormsArrayLayoutProps(ListWithDetailsControl);
|
|
5828
6261
|
const GoAListWithDetailsTester = rankWith(3, and(uiTypeIs('ListWithDetail')));
|
|
5829
6262
|
|
|
5830
6263
|
const GoATextCell = props => jsx(GoAInputText, Object.assign({}, props));
|
|
@@ -6384,7 +6817,7 @@ const GoABaseRenderers = [
|
|
|
6384
6817
|
renderer: GoAArrayControlRenderer
|
|
6385
6818
|
}, {
|
|
6386
6819
|
tester: GoAListWithDetailsTester,
|
|
6387
|
-
renderer:
|
|
6820
|
+
renderer: GoAListWithDetailsControlRenderer
|
|
6388
6821
|
},
|
|
6389
6822
|
// layouts
|
|
6390
6823
|
{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abgov/jsonforms-components",
|
|
3
|
-
"version": "1.25.
|
|
3
|
+
"version": "1.25.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",
|
|
@@ -7,6 +7,6 @@ export interface DeleteDialogProps {
|
|
|
7
7
|
message: string;
|
|
8
8
|
}
|
|
9
9
|
export interface WithDeleteDialogSupport {
|
|
10
|
-
openDeleteDialog(path: string, data: number): void;
|
|
10
|
+
openDeleteDialog(path: string, data: number, name?: string): void;
|
|
11
11
|
}
|
|
12
12
|
export declare const DeleteDialog: React.NamedExoticComponent<DeleteDialogProps>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ArrayLayoutProps, ControlElement, JsonSchema, JsonFormsRendererRegistryEntry, JsonFormsCellRendererRegistryEntry, ArrayTranslations, Layout } from '@jsonforms/core';
|
|
3
|
+
import { WithDeleteDialogSupport } from './DeleteDialog';
|
|
4
|
+
export type ObjectArrayControlProps = ArrayLayoutProps & WithDeleteDialogSupport;
|
|
5
|
+
export interface EmptyListProps {
|
|
6
|
+
numColumns: number;
|
|
7
|
+
translations: ArrayTranslations;
|
|
8
|
+
}
|
|
9
|
+
interface NonEmptyRowComponentProps {
|
|
10
|
+
propName?: string;
|
|
11
|
+
schema: JsonSchema;
|
|
12
|
+
rootSchema?: JsonSchema;
|
|
13
|
+
rowPath: string;
|
|
14
|
+
errors: string;
|
|
15
|
+
enabled: boolean;
|
|
16
|
+
renderers?: JsonFormsRendererRegistryEntry[];
|
|
17
|
+
cells?: JsonFormsCellRendererRegistryEntry[];
|
|
18
|
+
isValid: boolean;
|
|
19
|
+
uischema?: ControlElement | Layout;
|
|
20
|
+
}
|
|
21
|
+
export declare const NonEmptyCellComponent: React.NamedExoticComponent<NonEmptyRowComponentProps>;
|
|
22
|
+
interface NonEmptyRowProps {
|
|
23
|
+
childPath: string;
|
|
24
|
+
schema: JsonSchema;
|
|
25
|
+
rowIndex: number;
|
|
26
|
+
showSortButtons: boolean;
|
|
27
|
+
enabled: boolean;
|
|
28
|
+
cells?: JsonFormsCellRendererRegistryEntry[];
|
|
29
|
+
path: string;
|
|
30
|
+
translations: ArrayTranslations;
|
|
31
|
+
uischema: ControlElement;
|
|
32
|
+
}
|
|
33
|
+
export declare const NonEmptyList: React.MemoExoticComponent<({ childPath, schema, enabled, cells, uischema, }: NonEmptyRowProps & WithDeleteDialogSupport) => import("react/jsx-runtime").JSX.Element>;
|
|
34
|
+
export declare class ListWithDetailControl extends React.Component<ObjectArrayControlProps, any> {
|
|
35
|
+
addItem: (path: string, value: any) => () => void;
|
|
36
|
+
render(): import("react/jsx-runtime").JSX.Element;
|
|
37
|
+
}
|
|
38
|
+
export {};
|
|
@@ -5,4 +5,3 @@ export declare const ArrayBaseReviewControl: (props: ArrayLayoutProps) => import
|
|
|
5
5
|
export declare const GoAArrayControlTester: RankedTester;
|
|
6
6
|
export declare const GoAArrayControlRenderer: React.ComponentType<import("@jsonforms/core").OwnPropsOfControl>;
|
|
7
7
|
export declare const GoAArrayControlReviewRenderer: React.ComponentType<import("@jsonforms/core").OwnPropsOfControl>;
|
|
8
|
-
export declare const GoAListWithDetailsTester: RankedTester;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ArrayLayoutProps, RankedTester } from '@jsonforms/core';
|
|
3
|
+
export declare const ListWithDetailsControl: (props: ArrayLayoutProps) => import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
export declare const GoAListWithDetailsControlRenderer: React.ComponentType<import("@jsonforms/core").OwnPropsOfControl>;
|
|
5
|
+
export declare const GoAListWithDetailsTester: RankedTester;
|
|
@@ -2,3 +2,11 @@ export declare const DeleteDialogContent: import("styled-components").StyledComp
|
|
|
2
2
|
export declare const ToolBarHeader: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
3
3
|
export declare const ObjectArrayTitle: import("styled-components").StyledComponent<"h2", any, {}, never>;
|
|
4
4
|
export declare const TextCenter: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
5
|
+
export declare const SideMenuItem: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
6
|
+
export declare const RowFlex: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
7
|
+
export declare const RowFlexMenu: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
8
|
+
export declare const FlexTabs: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
9
|
+
export declare const FlexForm: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
10
|
+
export declare const TabName: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
11
|
+
export declare const Trash: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
12
|
+
export declare const ListContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
|