@abgov/jsonforms-components 2.9.1 → 2.10.0
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
|
@@ -3050,6 +3050,7 @@ $$l({ target: 'Iterator', proto: true, real: true, forced: IS_PURE$1 }, {
|
|
|
3050
3050
|
|
|
3051
3051
|
const sinTitle = 'Social insurance number';
|
|
3052
3052
|
const invalidSin = 'Social insurance number is invalid';
|
|
3053
|
+
const DEFAULT_MAX_ITEMS = 50;
|
|
3053
3054
|
|
|
3054
3055
|
/**
|
|
3055
3056
|
* Sets the first word to be capitalized so that it is sentence cased.
|
|
@@ -9582,6 +9583,7 @@ const ObjectArrayControl = props => {
|
|
|
9582
9583
|
const [registers, dispatch] = useReducer(objectListReducer, initialState);
|
|
9583
9584
|
const [open, setOpen] = useState(false);
|
|
9584
9585
|
const [rowData, setRowData] = useState(0);
|
|
9586
|
+
const [maxItemsError, setMaxItemsError] = useState('');
|
|
9585
9587
|
const {
|
|
9586
9588
|
label,
|
|
9587
9589
|
path,
|
|
@@ -9612,11 +9614,23 @@ const ObjectArrayControl = props => {
|
|
|
9612
9614
|
};
|
|
9613
9615
|
// eslint-disable-next-line
|
|
9614
9616
|
const addItem = (path, value) => {
|
|
9615
|
-
|
|
9616
|
-
|
|
9617
|
-
|
|
9618
|
-
|
|
9619
|
-
|
|
9617
|
+
var _a, _b, _c, _d;
|
|
9618
|
+
const maxItems = ((_b = (_a = uischema.options) === null || _a === void 0 ? void 0 : _a.detail) === null || _b === void 0 ? void 0 : _b.maxItems) ? (_d = (_c = uischema.options) === null || _c === void 0 ? void 0 : _c.detail) === null || _d === void 0 ? void 0 : _d.maxItems : DEFAULT_MAX_ITEMS;
|
|
9619
|
+
const categories = registers.categories;
|
|
9620
|
+
const currentCategory = categories[path];
|
|
9621
|
+
const count = (currentCategory === null || currentCategory === void 0 ? void 0 : currentCategory.count) !== undefined ? currentCategory === null || currentCategory === void 0 ? void 0 : currentCategory.count : 0;
|
|
9622
|
+
if (count < maxItems) {
|
|
9623
|
+
dispatch({
|
|
9624
|
+
type: INCREMENT_ACTION,
|
|
9625
|
+
payload: path
|
|
9626
|
+
});
|
|
9627
|
+
return () => props.addItem(path, value);
|
|
9628
|
+
} else {
|
|
9629
|
+
setMaxItemsError(`Maximum ${maxItems} items allowed.`);
|
|
9630
|
+
setTimeout(() => {
|
|
9631
|
+
setMaxItemsError('');
|
|
9632
|
+
}, 3000);
|
|
9633
|
+
}
|
|
9620
9634
|
};
|
|
9621
9635
|
// eslint-disable-next-line
|
|
9622
9636
|
const deleteItem = (path, value) => {
|
|
@@ -9637,6 +9651,7 @@ const ObjectArrayControl = props => {
|
|
|
9637
9651
|
if (handleChangeData.length === 0) {
|
|
9638
9652
|
handleChangeData = null;
|
|
9639
9653
|
}
|
|
9654
|
+
setMaxItemsError('');
|
|
9640
9655
|
props.handleChange(path, handleChangeData);
|
|
9641
9656
|
dispatch({
|
|
9642
9657
|
type: DELETE_ACTION,
|
|
@@ -9718,6 +9733,12 @@ const ObjectArrayControl = props => {
|
|
|
9718
9733
|
}) : jsxs("b", {
|
|
9719
9734
|
children: [listTitle, " ", jsx("span", {
|
|
9720
9735
|
children: additionalProps.required && '(required)'
|
|
9736
|
+
}), maxItemsError && jsx("span", {
|
|
9737
|
+
style: {
|
|
9738
|
+
color: 'red',
|
|
9739
|
+
marginLeft: '1rem'
|
|
9740
|
+
},
|
|
9741
|
+
children: maxItemsError
|
|
9721
9742
|
})]
|
|
9722
9743
|
}), !isInReview && listTitle && jsxs(ObjectArrayTitle, {
|
|
9723
9744
|
children: [listTitle, " ", jsx("span", {
|
|
@@ -10155,20 +10176,37 @@ const ObjectArrayList = ({
|
|
|
10155
10176
|
class ListWithDetailControl extends React.Component {
|
|
10156
10177
|
constructor() {
|
|
10157
10178
|
super(...arguments);
|
|
10179
|
+
this.state = {
|
|
10180
|
+
maxItemsError: ''
|
|
10181
|
+
};
|
|
10158
10182
|
// eslint-disable-next-line
|
|
10159
10183
|
this.addItem = (path, value) => {
|
|
10184
|
+
var _a, _b, _c;
|
|
10160
10185
|
const {
|
|
10161
10186
|
data,
|
|
10162
10187
|
addItem,
|
|
10163
|
-
setCurrentTab
|
|
10188
|
+
setCurrentTab,
|
|
10189
|
+
uischema
|
|
10164
10190
|
} = this.props;
|
|
10165
10191
|
const isNonEmpty = data !== undefined && data !== null;
|
|
10166
10192
|
const newIndex = isNonEmpty ? data !== null && data !== void 0 ? data : 0 : 0;
|
|
10167
|
-
|
|
10168
|
-
|
|
10169
|
-
|
|
10170
|
-
|
|
10171
|
-
|
|
10193
|
+
const maxItems = (_c = (_b = (_a = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _a === void 0 ? void 0 : _a.detail) === null || _b === void 0 ? void 0 : _b.maxItems) !== null && _c !== void 0 ? _c : DEFAULT_MAX_ITEMS;
|
|
10194
|
+
if (data < maxItems) {
|
|
10195
|
+
if (addItem) {
|
|
10196
|
+
addItem(path, value)();
|
|
10197
|
+
}
|
|
10198
|
+
if (typeof setCurrentTab === 'function') {
|
|
10199
|
+
setCurrentTab(newIndex);
|
|
10200
|
+
}
|
|
10201
|
+
} else {
|
|
10202
|
+
this.setState({
|
|
10203
|
+
maxItemsError: `Maximum ${maxItems} items allowed.`
|
|
10204
|
+
});
|
|
10205
|
+
setTimeout(() => {
|
|
10206
|
+
this.setState({
|
|
10207
|
+
maxItemsError: ''
|
|
10208
|
+
});
|
|
10209
|
+
}, 3000);
|
|
10172
10210
|
}
|
|
10173
10211
|
};
|
|
10174
10212
|
}
|
|
@@ -10201,6 +10239,12 @@ class ListWithDetailControl extends React.Component {
|
|
|
10201
10239
|
children: [listTitle && jsxs(ObjectArrayTitle, {
|
|
10202
10240
|
children: [listTitle, " ", jsx("span", {
|
|
10203
10241
|
children: additionalProps.required && '(required)'
|
|
10242
|
+
}), this.state.maxItemsError && jsx("span", {
|
|
10243
|
+
style: {
|
|
10244
|
+
color: 'red',
|
|
10245
|
+
marginLeft: '1rem'
|
|
10246
|
+
},
|
|
10247
|
+
children: this.state.maxItemsError
|
|
10204
10248
|
})]
|
|
10205
10249
|
}), jsx(ObjectArrayToolBar, {
|
|
10206
10250
|
errors: errors,
|
|
@@ -11803,7 +11847,10 @@ const GoAHorizontalLayoutComponent = ({
|
|
|
11803
11847
|
enabled,
|
|
11804
11848
|
direction: 'row',
|
|
11805
11849
|
visible,
|
|
11806
|
-
width: '10ch'
|
|
11850
|
+
width: '10ch',
|
|
11851
|
+
option: {
|
|
11852
|
+
space: 'xl'
|
|
11853
|
+
}
|
|
11807
11854
|
};
|
|
11808
11855
|
return jsx(LayoutRenderer, Object.assign({}, childProps, {
|
|
11809
11856
|
renderers: renderers,
|
|
@@ -11828,7 +11875,10 @@ const GoAHorizontalReviewLayoutComponent = ({
|
|
|
11828
11875
|
enabled,
|
|
11829
11876
|
direction: 'row',
|
|
11830
11877
|
visible,
|
|
11831
|
-
width: ((_b = (_a = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _a === void 0 ? void 0 : _a.review) === null || _b === void 0 ? void 0 : _b.width) || '30ch'
|
|
11878
|
+
width: ((_b = (_a = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _a === void 0 ? void 0 : _a.review) === null || _b === void 0 ? void 0 : _b.width) || '30ch',
|
|
11879
|
+
option: {
|
|
11880
|
+
space: 'xl'
|
|
11881
|
+
}
|
|
11832
11882
|
};
|
|
11833
11883
|
return jsx(ReviewLayoutRenderer, Object.assign({}, childProps, {
|
|
11834
11884
|
renderers: renderers,
|
|
@@ -11847,14 +11897,19 @@ const GoAVerticalLayoutComponent = ({
|
|
|
11847
11897
|
cells,
|
|
11848
11898
|
visible
|
|
11849
11899
|
}) => {
|
|
11900
|
+
var _a;
|
|
11850
11901
|
const verticalLayout = uischema;
|
|
11902
|
+
((_a = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _a === void 0 ? void 0 : _a.spacing) || 's';
|
|
11851
11903
|
const childProps = {
|
|
11852
11904
|
elements: verticalLayout.elements,
|
|
11853
11905
|
schema,
|
|
11854
11906
|
path,
|
|
11855
11907
|
enabled,
|
|
11856
11908
|
direction: 'column',
|
|
11857
|
-
visible
|
|
11909
|
+
visible,
|
|
11910
|
+
option: {
|
|
11911
|
+
space: 'xl'
|
|
11912
|
+
}
|
|
11858
11913
|
};
|
|
11859
11914
|
return jsx(LayoutRenderer, Object.assign({}, childProps, {
|
|
11860
11915
|
renderers: renderers,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abgov/jsonforms-components",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.10.0",
|
|
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",
|
|
@@ -37,6 +37,9 @@ interface ListWithDetailControlProps extends ObjectArrayControlProps {
|
|
|
37
37
|
setCurrentTab: (index: number) => void;
|
|
38
38
|
}
|
|
39
39
|
export declare class ListWithDetailControl extends React.Component<ListWithDetailControlProps, any> {
|
|
40
|
+
state: {
|
|
41
|
+
maxItemsError: string;
|
|
42
|
+
};
|
|
40
43
|
addItem: (path: string, value: any) => void;
|
|
41
44
|
render(): import("react/jsx-runtime").JSX.Element;
|
|
42
45
|
}
|
package/src/lib/util/layout.d.ts
CHANGED