@abgov/jsonforms-components 2.9.0 → 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.
|
|
@@ -5991,6 +5992,9 @@ const CalloutControl = props => {
|
|
|
5991
5992
|
var _a, _b;
|
|
5992
5993
|
return callout(((_b = (_a = props === null || props === void 0 ? void 0 : props.uischema) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.componentProps) || {});
|
|
5993
5994
|
};
|
|
5995
|
+
const CalloutReviewControl = () => {
|
|
5996
|
+
return jsx(Fragment, {});
|
|
5997
|
+
};
|
|
5994
5998
|
const GoACalloutControlTester = rankWith(1, uiTypeIs('Callout'));
|
|
5995
5999
|
var GoACalloutControl = withJsonFormsRendererProps(CalloutControl);
|
|
5996
6000
|
|
|
@@ -9579,6 +9583,7 @@ const ObjectArrayControl = props => {
|
|
|
9579
9583
|
const [registers, dispatch] = useReducer(objectListReducer, initialState);
|
|
9580
9584
|
const [open, setOpen] = useState(false);
|
|
9581
9585
|
const [rowData, setRowData] = useState(0);
|
|
9586
|
+
const [maxItemsError, setMaxItemsError] = useState('');
|
|
9582
9587
|
const {
|
|
9583
9588
|
label,
|
|
9584
9589
|
path,
|
|
@@ -9609,11 +9614,23 @@ const ObjectArrayControl = props => {
|
|
|
9609
9614
|
};
|
|
9610
9615
|
// eslint-disable-next-line
|
|
9611
9616
|
const addItem = (path, value) => {
|
|
9612
|
-
|
|
9613
|
-
|
|
9614
|
-
|
|
9615
|
-
|
|
9616
|
-
|
|
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
|
+
}
|
|
9617
9634
|
};
|
|
9618
9635
|
// eslint-disable-next-line
|
|
9619
9636
|
const deleteItem = (path, value) => {
|
|
@@ -9634,6 +9651,7 @@ const ObjectArrayControl = props => {
|
|
|
9634
9651
|
if (handleChangeData.length === 0) {
|
|
9635
9652
|
handleChangeData = null;
|
|
9636
9653
|
}
|
|
9654
|
+
setMaxItemsError('');
|
|
9637
9655
|
props.handleChange(path, handleChangeData);
|
|
9638
9656
|
dispatch({
|
|
9639
9657
|
type: DELETE_ACTION,
|
|
@@ -9715,6 +9733,12 @@ const ObjectArrayControl = props => {
|
|
|
9715
9733
|
}) : jsxs("b", {
|
|
9716
9734
|
children: [listTitle, " ", jsx("span", {
|
|
9717
9735
|
children: additionalProps.required && '(required)'
|
|
9736
|
+
}), maxItemsError && jsx("span", {
|
|
9737
|
+
style: {
|
|
9738
|
+
color: 'red',
|
|
9739
|
+
marginLeft: '1rem'
|
|
9740
|
+
},
|
|
9741
|
+
children: maxItemsError
|
|
9718
9742
|
})]
|
|
9719
9743
|
}), !isInReview && listTitle && jsxs(ObjectArrayTitle, {
|
|
9720
9744
|
children: [listTitle, " ", jsx("span", {
|
|
@@ -10152,20 +10176,37 @@ const ObjectArrayList = ({
|
|
|
10152
10176
|
class ListWithDetailControl extends React.Component {
|
|
10153
10177
|
constructor() {
|
|
10154
10178
|
super(...arguments);
|
|
10179
|
+
this.state = {
|
|
10180
|
+
maxItemsError: ''
|
|
10181
|
+
};
|
|
10155
10182
|
// eslint-disable-next-line
|
|
10156
10183
|
this.addItem = (path, value) => {
|
|
10184
|
+
var _a, _b, _c;
|
|
10157
10185
|
const {
|
|
10158
10186
|
data,
|
|
10159
10187
|
addItem,
|
|
10160
|
-
setCurrentTab
|
|
10188
|
+
setCurrentTab,
|
|
10189
|
+
uischema
|
|
10161
10190
|
} = this.props;
|
|
10162
10191
|
const isNonEmpty = data !== undefined && data !== null;
|
|
10163
10192
|
const newIndex = isNonEmpty ? data !== null && data !== void 0 ? data : 0 : 0;
|
|
10164
|
-
|
|
10165
|
-
|
|
10166
|
-
|
|
10167
|
-
|
|
10168
|
-
|
|
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);
|
|
10169
10210
|
}
|
|
10170
10211
|
};
|
|
10171
10212
|
}
|
|
@@ -10198,6 +10239,12 @@ class ListWithDetailControl extends React.Component {
|
|
|
10198
10239
|
children: [listTitle && jsxs(ObjectArrayTitle, {
|
|
10199
10240
|
children: [listTitle, " ", jsx("span", {
|
|
10200
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
|
|
10201
10248
|
})]
|
|
10202
10249
|
}), jsx(ObjectArrayToolBar, {
|
|
10203
10250
|
errors: errors,
|
|
@@ -11800,7 +11847,10 @@ const GoAHorizontalLayoutComponent = ({
|
|
|
11800
11847
|
enabled,
|
|
11801
11848
|
direction: 'row',
|
|
11802
11849
|
visible,
|
|
11803
|
-
width: '10ch'
|
|
11850
|
+
width: '10ch',
|
|
11851
|
+
option: {
|
|
11852
|
+
space: 'xl'
|
|
11853
|
+
}
|
|
11804
11854
|
};
|
|
11805
11855
|
return jsx(LayoutRenderer, Object.assign({}, childProps, {
|
|
11806
11856
|
renderers: renderers,
|
|
@@ -11825,7 +11875,10 @@ const GoAHorizontalReviewLayoutComponent = ({
|
|
|
11825
11875
|
enabled,
|
|
11826
11876
|
direction: 'row',
|
|
11827
11877
|
visible,
|
|
11828
|
-
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
|
+
}
|
|
11829
11882
|
};
|
|
11830
11883
|
return jsx(ReviewLayoutRenderer, Object.assign({}, childProps, {
|
|
11831
11884
|
renderers: renderers,
|
|
@@ -11844,14 +11897,19 @@ const GoAVerticalLayoutComponent = ({
|
|
|
11844
11897
|
cells,
|
|
11845
11898
|
visible
|
|
11846
11899
|
}) => {
|
|
11900
|
+
var _a;
|
|
11847
11901
|
const verticalLayout = uischema;
|
|
11902
|
+
((_a = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _a === void 0 ? void 0 : _a.spacing) || 's';
|
|
11848
11903
|
const childProps = {
|
|
11849
11904
|
elements: verticalLayout.elements,
|
|
11850
11905
|
schema,
|
|
11851
11906
|
path,
|
|
11852
11907
|
enabled,
|
|
11853
11908
|
direction: 'column',
|
|
11854
|
-
visible
|
|
11909
|
+
visible,
|
|
11910
|
+
option: {
|
|
11911
|
+
space: 'xl'
|
|
11912
|
+
}
|
|
11855
11913
|
};
|
|
11856
11914
|
return jsx(LayoutRenderer, Object.assign({}, childProps, {
|
|
11857
11915
|
renderers: renderers,
|
|
@@ -12274,6 +12332,9 @@ const GoABaseReviewRenderers = [
|
|
|
12274
12332
|
}, {
|
|
12275
12333
|
tester: HelpContentTester,
|
|
12276
12334
|
renderer: HelpReviewContent
|
|
12335
|
+
}, {
|
|
12336
|
+
tester: GoACalloutControlTester,
|
|
12337
|
+
renderer: CalloutReviewControl
|
|
12277
12338
|
}];
|
|
12278
12339
|
const GoABaseTableReviewRenderers = [
|
|
12279
12340
|
// controls
|
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",
|
|
@@ -7,6 +7,7 @@ export interface CalloutProps {
|
|
|
7
7
|
message?: string;
|
|
8
8
|
}
|
|
9
9
|
export declare const callout: (props: CalloutProps) => JSX.Element;
|
|
10
|
+
export declare const CalloutReviewControl: () => import("react/jsx-runtime").JSX.Element;
|
|
10
11
|
export declare const GoACalloutControlTester: RankedTester;
|
|
11
12
|
declare const _default: React.ComponentType<import("@jsonforms/core").OwnPropsOfJsonFormsRenderer>;
|
|
12
13
|
export default _default;
|
|
@@ -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