@abgov/jsonforms-components 2.9.1 → 2.11.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.
|
|
@@ -6646,7 +6647,7 @@ const warningIcon = errorMessage => {
|
|
|
6646
6647
|
});
|
|
6647
6648
|
};
|
|
6648
6649
|
const GoABaseInputReviewComponent = props => {
|
|
6649
|
-
var _a, _b, _c;
|
|
6650
|
+
var _a, _b, _c, _d, _e;
|
|
6650
6651
|
// eslint-disable-next-line
|
|
6651
6652
|
const {
|
|
6652
6653
|
data,
|
|
@@ -6695,11 +6696,7 @@ const GoABaseInputReviewComponent = props => {
|
|
|
6695
6696
|
if (((_c = uischema.options) === null || _c === void 0 ? void 0 : _c.radio) === true) {
|
|
6696
6697
|
reviewText = data ? `Yes` : `No`;
|
|
6697
6698
|
} else {
|
|
6698
|
-
|
|
6699
|
-
reviewText = data ? `Yes` : `No`;
|
|
6700
|
-
} else {
|
|
6701
|
-
reviewText = data ? `Yes (${checkboxLabel.trim()})` : `No (${checkboxLabel.trim()})`;
|
|
6702
|
-
}
|
|
6699
|
+
reviewText = data ? `Yes (${checkboxLabel.trim()})` : `No (${checkboxLabel.trim()})`;
|
|
6703
6700
|
}
|
|
6704
6701
|
}
|
|
6705
6702
|
if (isTime) {
|
|
@@ -6708,6 +6705,24 @@ const GoABaseInputReviewComponent = props => {
|
|
|
6708
6705
|
if (isDateTime) {
|
|
6709
6706
|
reviewText = reviewText && UTCToFullLocalTime(reviewText);
|
|
6710
6707
|
}
|
|
6708
|
+
if (Array.isArray(data) && data.length > 0) {
|
|
6709
|
+
reviewText = jsx("ul", {
|
|
6710
|
+
children: data.map((checkbox, index) => {
|
|
6711
|
+
var _a, _b;
|
|
6712
|
+
const checkboxLabel = ((_b = (_a = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _a === void 0 ? void 0 : _a.text) === null || _b === void 0 ? void 0 : _b.trim()) || convertToSentenceCase(getLastSegmentFromPointer(uischema.scope));
|
|
6713
|
+
return jsx("li", {
|
|
6714
|
+
children: checkbox.trim() || checkboxLabel.trim()
|
|
6715
|
+
}, index);
|
|
6716
|
+
})
|
|
6717
|
+
});
|
|
6718
|
+
} else if (data === undefined || data === false) {
|
|
6719
|
+
const checkboxLabel = ((_e = (_d = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _d === void 0 ? void 0 : _d.text) === null || _e === void 0 ? void 0 : _e.trim()) || convertToSentenceCase(getLastSegmentFromPointer(uischema.scope));
|
|
6720
|
+
reviewText = jsx("ul", {
|
|
6721
|
+
children: jsx("li", {
|
|
6722
|
+
children: `No (${checkboxLabel.trim()})`
|
|
6723
|
+
})
|
|
6724
|
+
});
|
|
6725
|
+
}
|
|
6711
6726
|
return jsxs("div", {
|
|
6712
6727
|
style: {
|
|
6713
6728
|
fontWeight: '400',
|
|
@@ -8585,7 +8600,7 @@ const FileUploader = _ref => {
|
|
|
8585
8600
|
uischema
|
|
8586
8601
|
} = _ref,
|
|
8587
8602
|
props = _objectWithoutPropertiesLoose(_ref, _excluded$3);
|
|
8588
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
8603
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
8589
8604
|
const enumerators = useContext(JsonFormContext);
|
|
8590
8605
|
const uploadTriggerFunction = (_a = enumerators === null || enumerators === void 0 ? void 0 : enumerators.functions) === null || _a === void 0 ? void 0 : _a.get('upload-file');
|
|
8591
8606
|
const uploadTrigger = uploadTriggerFunction && uploadTriggerFunction();
|
|
@@ -8608,9 +8623,10 @@ const FileUploader = _ref => {
|
|
|
8608
8623
|
} = props;
|
|
8609
8624
|
const propertyId = i18nKeyPrefix;
|
|
8610
8625
|
const variant = ((_d = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _d === void 0 ? void 0 : _d.variant) || 'button';
|
|
8626
|
+
const noDownloadButton = (_f = (_e = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _e === void 0 ? void 0 : _e.format) === null || _f === void 0 ? void 0 : _f.noDownloadButton;
|
|
8611
8627
|
const multiFileUploader = variant === 'dragdrop';
|
|
8612
8628
|
const [deleteHide, setDeleteHide] = useState(false);
|
|
8613
|
-
const fileListLength = fileList && ((
|
|
8629
|
+
const fileListLength = fileList && ((_g = fileList[props.i18nKeyPrefix]) === null || _g === void 0 ? void 0 : _g.length) || 0;
|
|
8614
8630
|
function uploadFile(file) {
|
|
8615
8631
|
if (uploadTrigger) {
|
|
8616
8632
|
if (!multiFileUploader) {
|
|
@@ -8666,13 +8682,13 @@ const FileUploader = _ref => {
|
|
|
8666
8682
|
const timeoutId = setTimeout(delayedFunction, 1);
|
|
8667
8683
|
return () => clearTimeout(timeoutId);
|
|
8668
8684
|
}, [handleChange, fileList, propertyId]);
|
|
8669
|
-
const readOnly = ((
|
|
8670
|
-
const maxFileSize = (
|
|
8671
|
-
const accept = (
|
|
8685
|
+
const readOnly = ((_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.readOnly) === true || (props === null || props === void 0 ? void 0 : props.isStepperReview) === true || user === null;
|
|
8686
|
+
const maxFileSize = (_m = (_l = (_k = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _k === void 0 ? void 0 : _k.componentProps) === null || _l === void 0 ? void 0 : _l.maxFileSize) !== null && _m !== void 0 ? _m : '';
|
|
8687
|
+
const accept = (_q = (_p = (_o = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _o === void 0 ? void 0 : _o.componentProps) === null || _p === void 0 ? void 0 : _p.accept) !== null && _q !== void 0 ? _q : '';
|
|
8672
8688
|
if (!enumerators) {
|
|
8673
8689
|
return jsx(Fragment, {});
|
|
8674
8690
|
}
|
|
8675
|
-
const helpText = (
|
|
8691
|
+
const helpText = (_r = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _r === void 0 ? void 0 : _r.help;
|
|
8676
8692
|
const sentenceCaseLabel = convertToSentenceCase(label);
|
|
8677
8693
|
const DownloadFileWidget = ({
|
|
8678
8694
|
index
|
|
@@ -8696,7 +8712,7 @@ const FileUploader = _ref => {
|
|
|
8696
8712
|
title: "Download",
|
|
8697
8713
|
type: "download",
|
|
8698
8714
|
onClick: () => downloadFile(getFile(index))
|
|
8699
|
-
}), jsx(GoAContextMenuIcon, {
|
|
8715
|
+
}), noDownloadButton !== true && jsx(GoAContextMenuIcon, {
|
|
8700
8716
|
"data-testid": "delete-icon",
|
|
8701
8717
|
title: "Delete",
|
|
8702
8718
|
type: "trash",
|
|
@@ -9582,6 +9598,7 @@ const ObjectArrayControl = props => {
|
|
|
9582
9598
|
const [registers, dispatch] = useReducer(objectListReducer, initialState);
|
|
9583
9599
|
const [open, setOpen] = useState(false);
|
|
9584
9600
|
const [rowData, setRowData] = useState(0);
|
|
9601
|
+
const [maxItemsError, setMaxItemsError] = useState('');
|
|
9585
9602
|
const {
|
|
9586
9603
|
label,
|
|
9587
9604
|
path,
|
|
@@ -9612,11 +9629,23 @@ const ObjectArrayControl = props => {
|
|
|
9612
9629
|
};
|
|
9613
9630
|
// eslint-disable-next-line
|
|
9614
9631
|
const addItem = (path, value) => {
|
|
9615
|
-
|
|
9616
|
-
|
|
9617
|
-
|
|
9618
|
-
|
|
9619
|
-
|
|
9632
|
+
var _a, _b, _c, _d;
|
|
9633
|
+
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;
|
|
9634
|
+
const categories = registers.categories;
|
|
9635
|
+
const currentCategory = categories[path];
|
|
9636
|
+
const count = (currentCategory === null || currentCategory === void 0 ? void 0 : currentCategory.count) !== undefined ? currentCategory === null || currentCategory === void 0 ? void 0 : currentCategory.count : 0;
|
|
9637
|
+
if (count < maxItems) {
|
|
9638
|
+
dispatch({
|
|
9639
|
+
type: INCREMENT_ACTION,
|
|
9640
|
+
payload: path
|
|
9641
|
+
});
|
|
9642
|
+
return () => props.addItem(path, value);
|
|
9643
|
+
} else {
|
|
9644
|
+
setMaxItemsError(`Maximum ${maxItems} items allowed.`);
|
|
9645
|
+
setTimeout(() => {
|
|
9646
|
+
setMaxItemsError('');
|
|
9647
|
+
}, 3000);
|
|
9648
|
+
}
|
|
9620
9649
|
};
|
|
9621
9650
|
// eslint-disable-next-line
|
|
9622
9651
|
const deleteItem = (path, value) => {
|
|
@@ -9637,6 +9666,7 @@ const ObjectArrayControl = props => {
|
|
|
9637
9666
|
if (handleChangeData.length === 0) {
|
|
9638
9667
|
handleChangeData = null;
|
|
9639
9668
|
}
|
|
9669
|
+
setMaxItemsError('');
|
|
9640
9670
|
props.handleChange(path, handleChangeData);
|
|
9641
9671
|
dispatch({
|
|
9642
9672
|
type: DELETE_ACTION,
|
|
@@ -9718,6 +9748,12 @@ const ObjectArrayControl = props => {
|
|
|
9718
9748
|
}) : jsxs("b", {
|
|
9719
9749
|
children: [listTitle, " ", jsx("span", {
|
|
9720
9750
|
children: additionalProps.required && '(required)'
|
|
9751
|
+
}), maxItemsError && jsx("span", {
|
|
9752
|
+
style: {
|
|
9753
|
+
color: 'red',
|
|
9754
|
+
marginLeft: '1rem'
|
|
9755
|
+
},
|
|
9756
|
+
children: maxItemsError
|
|
9721
9757
|
})]
|
|
9722
9758
|
}), !isInReview && listTitle && jsxs(ObjectArrayTitle, {
|
|
9723
9759
|
children: [listTitle, " ", jsx("span", {
|
|
@@ -10155,20 +10191,37 @@ const ObjectArrayList = ({
|
|
|
10155
10191
|
class ListWithDetailControl extends React.Component {
|
|
10156
10192
|
constructor() {
|
|
10157
10193
|
super(...arguments);
|
|
10194
|
+
this.state = {
|
|
10195
|
+
maxItemsError: ''
|
|
10196
|
+
};
|
|
10158
10197
|
// eslint-disable-next-line
|
|
10159
10198
|
this.addItem = (path, value) => {
|
|
10199
|
+
var _a, _b, _c;
|
|
10160
10200
|
const {
|
|
10161
10201
|
data,
|
|
10162
10202
|
addItem,
|
|
10163
|
-
setCurrentTab
|
|
10203
|
+
setCurrentTab,
|
|
10204
|
+
uischema
|
|
10164
10205
|
} = this.props;
|
|
10165
10206
|
const isNonEmpty = data !== undefined && data !== null;
|
|
10166
10207
|
const newIndex = isNonEmpty ? data !== null && data !== void 0 ? data : 0 : 0;
|
|
10167
|
-
|
|
10168
|
-
|
|
10169
|
-
|
|
10170
|
-
|
|
10171
|
-
|
|
10208
|
+
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;
|
|
10209
|
+
if (data < maxItems) {
|
|
10210
|
+
if (addItem) {
|
|
10211
|
+
addItem(path, value)();
|
|
10212
|
+
}
|
|
10213
|
+
if (typeof setCurrentTab === 'function') {
|
|
10214
|
+
setCurrentTab(newIndex);
|
|
10215
|
+
}
|
|
10216
|
+
} else {
|
|
10217
|
+
this.setState({
|
|
10218
|
+
maxItemsError: `Maximum ${maxItems} items allowed.`
|
|
10219
|
+
});
|
|
10220
|
+
setTimeout(() => {
|
|
10221
|
+
this.setState({
|
|
10222
|
+
maxItemsError: ''
|
|
10223
|
+
});
|
|
10224
|
+
}, 3000);
|
|
10172
10225
|
}
|
|
10173
10226
|
};
|
|
10174
10227
|
}
|
|
@@ -10201,6 +10254,12 @@ class ListWithDetailControl extends React.Component {
|
|
|
10201
10254
|
children: [listTitle && jsxs(ObjectArrayTitle, {
|
|
10202
10255
|
children: [listTitle, " ", jsx("span", {
|
|
10203
10256
|
children: additionalProps.required && '(required)'
|
|
10257
|
+
}), this.state.maxItemsError && jsx("span", {
|
|
10258
|
+
style: {
|
|
10259
|
+
color: 'red',
|
|
10260
|
+
marginLeft: '1rem'
|
|
10261
|
+
},
|
|
10262
|
+
children: this.state.maxItemsError
|
|
10204
10263
|
})]
|
|
10205
10264
|
}), jsx(ObjectArrayToolBar, {
|
|
10206
10265
|
errors: errors,
|
|
@@ -11803,7 +11862,10 @@ const GoAHorizontalLayoutComponent = ({
|
|
|
11803
11862
|
enabled,
|
|
11804
11863
|
direction: 'row',
|
|
11805
11864
|
visible,
|
|
11806
|
-
width: '10ch'
|
|
11865
|
+
width: '10ch',
|
|
11866
|
+
option: {
|
|
11867
|
+
space: 'xl'
|
|
11868
|
+
}
|
|
11807
11869
|
};
|
|
11808
11870
|
return jsx(LayoutRenderer, Object.assign({}, childProps, {
|
|
11809
11871
|
renderers: renderers,
|
|
@@ -11828,7 +11890,10 @@ const GoAHorizontalReviewLayoutComponent = ({
|
|
|
11828
11890
|
enabled,
|
|
11829
11891
|
direction: 'row',
|
|
11830
11892
|
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'
|
|
11893
|
+
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',
|
|
11894
|
+
option: {
|
|
11895
|
+
space: 'xl'
|
|
11896
|
+
}
|
|
11832
11897
|
};
|
|
11833
11898
|
return jsx(ReviewLayoutRenderer, Object.assign({}, childProps, {
|
|
11834
11899
|
renderers: renderers,
|
|
@@ -11847,14 +11912,19 @@ const GoAVerticalLayoutComponent = ({
|
|
|
11847
11912
|
cells,
|
|
11848
11913
|
visible
|
|
11849
11914
|
}) => {
|
|
11915
|
+
var _a;
|
|
11850
11916
|
const verticalLayout = uischema;
|
|
11917
|
+
((_a = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _a === void 0 ? void 0 : _a.spacing) || 's';
|
|
11851
11918
|
const childProps = {
|
|
11852
11919
|
elements: verticalLayout.elements,
|
|
11853
11920
|
schema,
|
|
11854
11921
|
path,
|
|
11855
11922
|
enabled,
|
|
11856
11923
|
direction: 'column',
|
|
11857
|
-
visible
|
|
11924
|
+
visible,
|
|
11925
|
+
option: {
|
|
11926
|
+
space: 'xl'
|
|
11927
|
+
}
|
|
11858
11928
|
};
|
|
11859
11929
|
return jsx(LayoutRenderer, Object.assign({}, childProps, {
|
|
11860
11930
|
renderers: renderers,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abgov/jsonforms-components",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.11.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