@abgov/jsonforms-components 2.6.8 → 2.6.10
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
|
@@ -6617,7 +6617,7 @@ const CheckboxGroup = props => {
|
|
|
6617
6617
|
} else {
|
|
6618
6618
|
newData = newData.filter(item => item !== enumValue);
|
|
6619
6619
|
}
|
|
6620
|
-
handleChange(path, newData);
|
|
6620
|
+
handleChange(path, newData.length === 0 ? undefined : newData);
|
|
6621
6621
|
}
|
|
6622
6622
|
}));
|
|
6623
6623
|
})
|
|
@@ -7492,7 +7492,7 @@ function isNumber(value) {
|
|
|
7492
7492
|
}
|
|
7493
7493
|
const getIncompletePaths = (ajv, scopes) => {
|
|
7494
7494
|
var _a;
|
|
7495
|
-
const requiredErrorPaths = (_a = ajv === null || ajv === void 0 ? void 0 : ajv.errors) === null || _a === void 0 ? void 0 : _a.filter(e => e.keyword === 'required' || e.keyword === 'minLength').map(e => {
|
|
7495
|
+
const requiredErrorPaths = (_a = ajv === null || ajv === void 0 ? void 0 : ajv.errors) === null || _a === void 0 ? void 0 : _a.filter(e => e.keyword === 'required' || e.keyword === 'minLength' || e.keyword === 'minItems' || e.keyword === 'errorMessage').map(e => {
|
|
7496
7496
|
return getControlPath(e);
|
|
7497
7497
|
});
|
|
7498
7498
|
const _scopes = scopes.map(scope => toDataPath(scope)).filter(path => requiredErrorPaths && isErrorPathIncluded(requiredErrorPaths, path));
|
|
@@ -9975,8 +9975,8 @@ const ObjectArrayList = ({
|
|
|
9975
9975
|
enabled,
|
|
9976
9976
|
cells,
|
|
9977
9977
|
translations,
|
|
9978
|
-
|
|
9979
|
-
|
|
9978
|
+
currentIndex,
|
|
9979
|
+
setCurrentIndex
|
|
9980
9980
|
}) => {
|
|
9981
9981
|
const isEmptyList = data === 0;
|
|
9982
9982
|
const rightRef = useRef(null);
|
|
@@ -10005,7 +10005,7 @@ const ObjectArrayList = ({
|
|
|
10005
10005
|
}
|
|
10006
10006
|
const appliedUiSchemaOptions = merge({}, config, uischema.options);
|
|
10007
10007
|
const selectCurrentTab = index => {
|
|
10008
|
-
|
|
10008
|
+
setCurrentIndex(index);
|
|
10009
10009
|
};
|
|
10010
10010
|
const paddedHeight = rightHeight && rightHeight + 48;
|
|
10011
10011
|
return jsx(ListContainer, {
|
|
@@ -10020,7 +10020,7 @@ const ObjectArrayList = ({
|
|
|
10020
10020
|
return jsx(LeftTab, {
|
|
10021
10021
|
childPath: childPath,
|
|
10022
10022
|
rowIndex: index,
|
|
10023
|
-
currentTab:
|
|
10023
|
+
currentTab: currentIndex,
|
|
10024
10024
|
name: name,
|
|
10025
10025
|
openDeleteDialog: openDeleteDialog,
|
|
10026
10026
|
selectCurrentTab: selectCurrentTab,
|
|
@@ -10031,8 +10031,8 @@ const ObjectArrayList = ({
|
|
|
10031
10031
|
}), jsx(FlexForm, {
|
|
10032
10032
|
ref: rightRef,
|
|
10033
10033
|
children: jsx(NonEmptyList, {
|
|
10034
|
-
childPath: Paths.compose(path, `${
|
|
10035
|
-
rowIndex:
|
|
10034
|
+
childPath: Paths.compose(path, `${currentIndex}`),
|
|
10035
|
+
rowIndex: currentIndex,
|
|
10036
10036
|
schema: schema,
|
|
10037
10037
|
openDeleteDialog: openDeleteDialog,
|
|
10038
10038
|
showSortButtons: appliedUiSchemaOptions.showSortButtons || appliedUiSchemaOptions.showArrayTableSortButtons,
|
|
@@ -10041,7 +10041,7 @@ const ObjectArrayList = ({
|
|
|
10041
10041
|
path: path,
|
|
10042
10042
|
uischema: uischema,
|
|
10043
10043
|
translations: translations
|
|
10044
|
-
}, Paths.compose(path, `${
|
|
10044
|
+
}, Paths.compose(path, `${currentIndex}`))
|
|
10045
10045
|
})]
|
|
10046
10046
|
})
|
|
10047
10047
|
});
|
|
@@ -10052,16 +10052,19 @@ class ListWithDetailControl extends React.Component {
|
|
|
10052
10052
|
super(...arguments);
|
|
10053
10053
|
// eslint-disable-next-line
|
|
10054
10054
|
this.addItem = (path, value) => {
|
|
10055
|
-
const
|
|
10056
|
-
|
|
10057
|
-
|
|
10058
|
-
|
|
10059
|
-
|
|
10060
|
-
|
|
10055
|
+
const {
|
|
10056
|
+
data,
|
|
10057
|
+
addItem,
|
|
10058
|
+
setCurrentTab
|
|
10059
|
+
} = this.props;
|
|
10060
|
+
const isNonEmpty = data !== undefined && data !== null;
|
|
10061
|
+
const newIndex = isNonEmpty ? data !== null && data !== void 0 ? data : 0 : 0;
|
|
10062
|
+
if (addItem) {
|
|
10063
|
+
addItem(path, value)();
|
|
10064
|
+
}
|
|
10065
|
+
if (typeof setCurrentTab === 'function') {
|
|
10066
|
+
setCurrentTab(newIndex);
|
|
10061
10067
|
}
|
|
10062
|
-
};
|
|
10063
|
-
this.state = {
|
|
10064
|
-
currentTab: 0
|
|
10065
10068
|
};
|
|
10066
10069
|
}
|
|
10067
10070
|
render() {
|
|
@@ -10119,10 +10122,8 @@ class ListWithDetailControl extends React.Component {
|
|
|
10119
10122
|
data: data,
|
|
10120
10123
|
cells: cells,
|
|
10121
10124
|
config: config,
|
|
10122
|
-
|
|
10123
|
-
|
|
10124
|
-
currentTab: i
|
|
10125
|
-
})
|
|
10125
|
+
currentIndex: this.props.currentTab,
|
|
10126
|
+
setCurrentIndex: this.props.setCurrentTab
|
|
10126
10127
|
}, additionalProps))
|
|
10127
10128
|
})]
|
|
10128
10129
|
});
|
|
@@ -10139,6 +10140,7 @@ const ListWithDetailsControl = props => {
|
|
|
10139
10140
|
visible,
|
|
10140
10141
|
handleChange
|
|
10141
10142
|
} = props;
|
|
10143
|
+
const [currentTab, setCurrentTab] = useState(0);
|
|
10142
10144
|
const openDeleteDialog = useCallback((p, rowIndex, name) => {
|
|
10143
10145
|
setOpen(true);
|
|
10144
10146
|
setPath(p);
|
|
@@ -10152,18 +10154,22 @@ const ListWithDetailsControl = props => {
|
|
|
10152
10154
|
if (removeItems && p) {
|
|
10153
10155
|
if (props.data === 1) {
|
|
10154
10156
|
handleChange(p, null);
|
|
10157
|
+
setCurrentTab(0);
|
|
10155
10158
|
} else {
|
|
10156
10159
|
removeItems(p, [rowData])();
|
|
10160
|
+
setCurrentTab(prev => Math.max(0, rowData - 1)); // Safe fallback
|
|
10157
10161
|
}
|
|
10158
10162
|
}
|
|
10159
10163
|
setOpen(false);
|
|
10160
10164
|
// eslint-disable-next-line
|
|
10161
|
-
}, [setOpen, path, rowData]);
|
|
10165
|
+
}, [setOpen, path, rowData, rowData]);
|
|
10162
10166
|
return jsxs(Visible, {
|
|
10163
10167
|
visible: visible,
|
|
10164
10168
|
children: [jsx(ListWithDetailControl, Object.assign({}, props, {
|
|
10165
10169
|
openDeleteDialog: openDeleteDialog,
|
|
10166
|
-
enabled: true
|
|
10170
|
+
enabled: true,
|
|
10171
|
+
currentTab: currentTab,
|
|
10172
|
+
setCurrentTab: setCurrentTab
|
|
10167
10173
|
})), jsx(DeleteDialog, {
|
|
10168
10174
|
open: open,
|
|
10169
10175
|
onCancel: deleteCancel,
|
|
@@ -11420,6 +11426,7 @@ formData,
|
|
|
11420
11426
|
updateFormData,
|
|
11421
11427
|
// eslint-disable-next-line
|
|
11422
11428
|
handleRequiredFieldBlur) {
|
|
11429
|
+
/* istanbul ignore next */
|
|
11423
11430
|
useEffect(() => {
|
|
11424
11431
|
const rAF = requestAnimationFrame(() => {
|
|
11425
11432
|
const timeout = setTimeout(() => {
|
|
@@ -11970,7 +11977,8 @@ const createDefaultAjv = (...schemas) => {
|
|
|
11970
11977
|
allErrors: true,
|
|
11971
11978
|
verbose: true,
|
|
11972
11979
|
strict: 'log',
|
|
11973
|
-
strictRequired: false
|
|
11980
|
+
strictRequired: false,
|
|
11981
|
+
useDefaults: true
|
|
11974
11982
|
});
|
|
11975
11983
|
ajv.addSchema(schemas);
|
|
11976
11984
|
addErrors(ajv);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abgov/jsonforms-components",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.10",
|
|
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",
|
|
@@ -32,11 +32,12 @@ interface NonEmptyRowProps {
|
|
|
32
32
|
uischema: ControlElement;
|
|
33
33
|
}
|
|
34
34
|
export declare const NonEmptyList: React.MemoExoticComponent<({ childPath, schema, enabled, cells, uischema, }: NonEmptyRowProps & WithDeleteDialogSupport) => import("react/jsx-runtime").JSX.Element>;
|
|
35
|
-
|
|
35
|
+
interface ListWithDetailControlProps extends ObjectArrayControlProps {
|
|
36
|
+
currentTab: number;
|
|
37
|
+
setCurrentTab: (index: number) => void;
|
|
38
|
+
}
|
|
39
|
+
export declare class ListWithDetailControl extends React.Component<ListWithDetailControlProps, any> {
|
|
36
40
|
addItem: (path: string, value: any) => void;
|
|
37
|
-
state: {
|
|
38
|
-
currentTab: number;
|
|
39
|
-
};
|
|
40
41
|
render(): import("react/jsx-runtime").JSX.Element;
|
|
41
42
|
}
|
|
42
43
|
export {};
|