@abgov/jsonforms-components 2.42.4 → 2.43.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
@@ -1,6 +1,6 @@
1
1
  import * as runtime from 'react/jsx-runtime';
2
2
  import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
3
- import React, { createContext, useContext, useReducer, useMemo, useEffect, useCallback, useState, useRef } from 'react';
3
+ import React, { createContext, useContext, useReducer, useMemo, useEffect, useCallback, useState, useRef, useLayoutEffect } from 'react';
4
4
  import { GoabFormItem, GoabInput, GoabTextArea, GoabCallout, GoabRadioGroup, GoabRadioItem, GoabCheckbox, GoabIcon, GoabGrid, GoabFormStepper, GoabFormStep, GoabPages, GoabButton, GoabModal, GoabButtonGroup, GoabBadge, GoabText, GoabTable, GoabIconButton, GoabFileUploadInput, GoabCircularProgress, GoabContainer, GoabDropdown, GoabDropdownItem, GoabDetails, GoabSpinner } from '@abgov/react-components';
5
5
  import styled from 'styled-components';
6
6
  import axios from 'axios';
@@ -8172,7 +8172,7 @@ let _$6 = t => t,
8172
8172
  _t23$1,
8173
8173
  _t24$1,
8174
8174
  _t25$1,
8175
- _t26,
8175
+ _t26$1,
8176
8176
  _t27,
8177
8177
  _t28;
8178
8178
  const ReviewItem = styled.div(_t$6 || (_t$6 = _$6`
@@ -8358,7 +8358,7 @@ const PageStepperRow = styled.tr(_t25$1 || (_t25$1 = _$6`
8358
8358
  outline: 3px solid var(--goa-color-interactive-focus);
8359
8359
  }
8360
8360
  `);
8361
- const SectionHeaderRowTr = styled.tr(_t26 || (_t26 = _$6`
8361
+ const SectionHeaderRowTr = styled.tr(_t26$1 || (_t26$1 = _$6`
8362
8362
  & > td {
8363
8363
  border: 0 !important;
8364
8364
  padding-top: var(--goa-space-l);
@@ -10106,7 +10106,8 @@ let _$3 = t => t,
10106
10106
  _t22,
10107
10107
  _t23,
10108
10108
  _t24,
10109
- _t25;
10109
+ _t25,
10110
+ _t26;
10110
10111
  const DeleteDialogContent = styled.div(_t$3 || (_t$3 = _$3`
10111
10112
  margin-bottom: var(--goa-space-m);
10112
10113
  `));
@@ -10144,7 +10145,8 @@ const SideMenuItem = styled.div(_t8 || (_t8 = _$3`
10144
10145
  `));
10145
10146
  const RowFlex = styled.div(_t9 || (_t9 = _$3`
10146
10147
  display: flex;
10147
- align-items: stretch;
10148
+
10149
+ align-items: flex-start;
10148
10150
  `));
10149
10151
  const RowFlexMenu = styled.div(_t0 || (_t0 = _$3`
10150
10152
  display: flex;
@@ -10157,65 +10159,76 @@ const FlexTabs = styled.div(_t1 || (_t1 = _$3`
10157
10159
  flex: 1;
10158
10160
  overflow-y: auto !important;
10159
10161
  `));
10160
- const FlexForm = styled.div(_t10 || (_t10 = _$3`
10162
+ const FlexTabsWithMargin = styled.div(_t10 || (_t10 = _$3`
10163
+ flex-direction: column;
10164
+ flex: 1;
10165
+ overflow-y: auto !important;
10166
+ margin-right: 1.5rem;
10167
+
10168
+ flex-shrink: 1;
10169
+ // max-height: 500px;
10170
+ `));
10171
+ const FlexForm = styled.div(_t11 || (_t11 = _$3`
10161
10172
  flex-direction: column;
10162
10173
  flex: 3;
10174
+ flex-shrink: 0;
10175
+ overflow-y: auto;
10163
10176
  `));
10164
- const TabName = styled.div(_t11 || (_t11 = _$3`
10177
+ const TabName = styled.div(_t12 || (_t12 = _$3`
10165
10178
  margin: 1rem 0 1rem 1rem;
10166
10179
  font-weight: 400;
10167
10180
  white-space: nowrap;
10168
10181
  overflow: hidden;
10169
10182
  text-overflow: ellipsis;
10170
10183
  `));
10171
- const Trash = styled.div(_t12 || (_t12 = _$3`
10184
+ const Trash = styled.div(_t13 || (_t13 = _$3`
10172
10185
  margin: 0.9rem 0.4rem 0.6rem 0.75rem;
10173
10186
  margin-left: auto;
10174
10187
  `));
10175
- const ListContainer = styled.div(_t13 || (_t13 = _$3`
10188
+ const ListContainer = styled.div(_t14 || (_t14 = _$3`
10176
10189
  padding: 0 0 0 0;
10177
10190
  `));
10178
- styled.div(_t14 || (_t14 = _$3`
10191
+ styled.div(_t15 || (_t15 = _$3`
10179
10192
  padding: 0 0 var(--goa-space-l) 0;
10180
10193
  `));
10181
- const IconPadding = styled.div(_t15 || (_t15 = _$3`
10194
+ const IconPadding = styled.div(_t16 || (_t16 = _$3`
10182
10195
  padding: 0.9rem 0.5rem 0 0;
10183
10196
  `));
10184
- const UpdateListContainer = styled.div(_t16 || (_t16 = _$3`
10197
+ const UpdateListContainer = styled.div(_t17 || (_t17 = _$3`
10185
10198
  width: 100%;
10186
10199
  border: 1px solid #dcdcdc;
10187
10200
  padding: var(--goa-space-xl);
10188
10201
  `));
10189
- styled.div(_t17 || (_t17 = _$3`
10202
+ styled.div(_t18 || (_t18 = _$3`
10190
10203
  padding: 0 1.5rem 0 0;
10191
10204
  border: 1px solid #dcdcdc;
10192
10205
  `));
10193
- const TableTHHeader = styled.th(_t18 || (_t18 = _$3`
10206
+ const TableTHHeader = styled.th(_t19 || (_t19 = _$3`
10194
10207
  background-color: var(--goa-color-greyscale-100) !important;
10195
10208
  vertical-align: top;
10196
10209
  `));
10197
- const ObjectArrayWarningIconDiv = styled.div(_t19 || (_t19 = _$3`
10210
+ const ObjectArrayWarningIconDiv = styled.div(_t20 || (_t20 = _$3`
10198
10211
  display: inline-flex;
10199
10212
  align-items: flex-start;
10200
10213
  gap: 0.25rem;
10201
10214
  font-size: var(--goa-font-size-2);
10202
10215
  color: var(--goa-color-interactive-error);
10203
10216
  `));
10204
- const ListWithDetailWarningIconDiv = styled.div(_t20 || (_t20 = _$3`
10217
+ const ListWithDetailWarningIconDiv = styled.div(_t21 || (_t21 = _$3`
10205
10218
  display: inline-flex;
10206
10219
  align-items: flex-start;
10207
10220
  gap: 0.25rem;
10208
10221
  font-size: var(--goa-font-size-3);
10209
10222
  color: var(--goa-color-interactive-error);
10210
10223
  `));
10211
- styled.label(_t21 || (_t21 = _$3`
10224
+ styled.label(_t22 || (_t22 = _$3`
10212
10225
  color: var(--goa-color-interactive-error);
10213
10226
  font-weight: var(--goa-font-weight-regular);
10214
10227
  font-size: var(--goa-font-size-3);
10215
10228
  line-height: var(--goa-line-height-1);
10216
10229
  font-style: normal;
10217
10230
  `));
10218
- styled.div(_t22 || (_t22 = _$3`
10231
+ styled.div(_t23 || (_t23 = _$3`
10219
10232
  margin-top: var(--goa-space-m);
10220
10233
  color: var(--goa-color-interactive-error);
10221
10234
  font-weight: var(--goa-font-weight-regular);
@@ -10223,10 +10236,10 @@ styled.div(_t22 || (_t22 = _$3`
10223
10236
  line-height: var(--goa-line-height-1);
10224
10237
  font-style: normal;
10225
10238
  `));
10226
- const HilightCellWarning = styled.div(_t23 || (_t23 = _$3`
10239
+ const HilightCellWarning = styled.div(_t24 || (_t24 = _$3`
10227
10240
  background-color: var(--goa-color-warning-default);
10228
10241
  `));
10229
- const FixTableHeaderAlignment = styled.div(_t24 || (_t24 = _$3`
10242
+ const FixTableHeaderAlignment = styled.div(_t25 || (_t25 = _$3`
10230
10243
  table thead th:nth-child(3) {
10231
10244
  text-align: center;
10232
10245
  }
@@ -10235,7 +10248,7 @@ const FixTableHeaderAlignment = styled.div(_t24 || (_t24 = _$3`
10235
10248
  text-align: center;
10236
10249
  }
10237
10250
  `));
10238
- const ListWithDetailsReviewCellDiv = styled.div(_t25 || (_t25 = _$3`
10251
+ const ListWithDetailsReviewCellDiv = styled.div(_t26 || (_t26 = _$3`
10239
10252
  display: 'flex';
10240
10253
  flex-direction: 'column';
10241
10254
  text-align: 'start';
@@ -11528,6 +11541,53 @@ function humanizeAjvError(error, schema, uischema) {
11528
11541
  return `${label} ${(_a = error.message) !== null && _a !== void 0 ? _a : ''}`.trim();
11529
11542
  }
11530
11543
  }
11544
+ const LeftTab = ({
11545
+ childPath,
11546
+ rowIndex,
11547
+ openDeleteDialog,
11548
+ selectCurrentTab,
11549
+ enabled,
11550
+ currentTab,
11551
+ name,
11552
+ current
11553
+ }) => {
11554
+ return jsx("div", {
11555
+ children: jsx(SideMenuItem, {
11556
+ style: currentTab === rowIndex ? {
11557
+ background: '#EFF8FF'
11558
+ } : {},
11559
+ onClick: () => selectCurrentTab(rowIndex),
11560
+ onKeyDown: e => {
11561
+ if (e.key === 'ArrowRight') {
11562
+ e.preventDefault();
11563
+ if (current) {
11564
+ const goa = current === null || current === void 0 ? void 0 : current.querySelector('goa-input, goa-button');
11565
+ if (goa === null || goa === void 0 ? void 0 : goa.shadowRoot) {
11566
+ const internal = goa.shadowRoot.querySelector('input, button');
11567
+ internal === null || internal === void 0 ? void 0 : internal.focus();
11568
+ selectCurrentTab(rowIndex);
11569
+ }
11570
+ }
11571
+ }
11572
+ },
11573
+ children: jsxs(RowFlexMenu, {
11574
+ tabIndex: 0,
11575
+ children: [jsx(TabName, {
11576
+ children: name
11577
+ }), enabled ? jsx(Trash, {
11578
+ role: "trash button",
11579
+ children: jsx(GoabIconButton, {
11580
+ disabled: !enabled,
11581
+ icon: "trash",
11582
+ title: 'trash button',
11583
+ testId: "remove the details",
11584
+ onClick: () => openDeleteDialog(childPath, rowIndex, name)
11585
+ })
11586
+ }) : null]
11587
+ })
11588
+ })
11589
+ }, childPath);
11590
+ };
11531
11591
  const MainTab = ({
11532
11592
  childPath,
11533
11593
  rowIndex,
@@ -11607,26 +11667,21 @@ const ObjectArrayList = ({
11607
11667
  listTitle,
11608
11668
  errors
11609
11669
  }) => {
11610
- var _a, _b, _c, _d;
11670
+ var _a, _b, _c, _d, _e, _f;
11611
11671
  const isEmptyList = data === 0;
11612
- const rightRef = useRef(null);
11613
- const current = rightRef.current;
11614
11672
  const minHeight = 100;
11615
- const [rightHeight, setRightHeight] = useState(minHeight);
11616
- useEffect(() => {
11617
- const resizeObserver = new ResizeObserver(() => {
11618
- if (rightHeight !== (current === null || current === void 0 ? void 0 : current.offsetHeight) && (current === null || current === void 0 ? void 0 : current.offsetHeight)) setRightHeight((current === null || current === void 0 ? void 0 : current.offsetHeight) > minHeight ? current === null || current === void 0 ? void 0 : current.offsetHeight : minHeight);
11619
- });
11620
- if (current) {
11621
- resizeObserver.observe(current);
11673
+ const totalContentRef = useRef(null);
11674
+ const leftRef = useRef(null);
11675
+ const rightRef = useRef(null);
11676
+ const current = totalContentRef.current;
11677
+ useLayoutEffect(() => {
11678
+ var _a;
11679
+ if (!leftRef.current || !rightRef.current) return;
11680
+ const height = (_a = rightRef.current) === null || _a === void 0 ? void 0 : _a.scrollHeight;
11681
+ if (height && height > minHeight) {
11682
+ leftRef.current.style.height = `${height}px`;
11622
11683
  }
11623
- return () => {
11624
- if (current) {
11625
- resizeObserver.unobserve(current);
11626
- }
11627
- };
11628
- // eslint-disable-next-line react-hooks/exhaustive-deps
11629
- }, [current, rightHeight, rightRef]);
11684
+ }, [setCurrentListPage]);
11630
11685
  if (isEmptyList) {
11631
11686
  const noDataMessge = (_b = (_a = uischema.options) === null || _a === void 0 ? void 0 : _a.noDataMessage) !== null && _b !== void 0 ? _b : 'No data';
11632
11687
  return jsx(EmptyList, {
@@ -11640,34 +11695,34 @@ const ObjectArrayList = ({
11640
11695
  setCurrentIndex(index);
11641
11696
  };
11642
11697
  const continueButtonTitle = (_d = (_c = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _c === void 0 ? void 0 : _c.componentProps) === null || _d === void 0 ? void 0 : _d.listWithDetailsContinueButtonTitle;
11698
+ const withLeftTab = (_f = (_e = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _e === void 0 ? void 0 : _e.componentProps) === null || _f === void 0 ? void 0 : _f.withLeftTab;
11643
11699
  return jsx(ListContainer, {
11644
- children: jsxs(RowFlex, {
11645
- children: [currentListPage === 0 && jsx(FlexTabs, {
11646
- style: {
11647
- height: '100%'
11648
- },
11649
- children: range(data).map(index => {
11650
- const childPath = Paths.compose(path, `${index}`);
11651
- return jsx(MainTab, {
11652
- childPath: childPath,
11653
- rowIndex: index,
11654
- currentTab: currentIndex,
11655
- openDeleteDialog: openDeleteDialog,
11656
- selectCurrentTab: selectCurrentTab,
11657
- enabled: enabled,
11658
- current: current,
11659
- setCurrentListPage: index => setCurrentListPage(index),
11660
- uischema: uischema,
11661
- schema: schema
11662
- }, childPath);
11663
- })
11664
- }), currentListPage > 0 && jsxs(UpdateListContainer, {
11665
- children: [jsxs(FlexForm, {
11666
- ref: rightRef,
11700
+ children: jsx("div", {
11701
+ children: withLeftTab ? jsxs(RowFlex, {
11702
+ ref: totalContentRef,
11703
+ children: [jsx(FlexTabsWithMargin, {
11704
+ ref: leftRef,
11705
+ children: jsx("div", {
11706
+ children: range(data).map(index => {
11707
+ const childPath = Paths.compose(path, `${index}`);
11708
+ const name = (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.itemLabel) ? `${appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.itemLabel} ${index + 1}` : `${path} ${index + 1}`;
11709
+ return jsx(LeftTab, {
11710
+ childPath: childPath,
11711
+ rowIndex: index,
11712
+ currentTab: currentIndex,
11713
+ name: name,
11714
+ openDeleteDialog: openDeleteDialog,
11715
+ selectCurrentTab: selectCurrentTab,
11716
+ enabled: enabled,
11717
+ current: current,
11718
+ translations: translations
11719
+ }, childPath);
11720
+ })
11721
+ })
11722
+ }), jsx(FlexForm, {
11667
11723
  tabIndex: -1,
11668
- children: [jsx(ObjectArrayTitle, {
11669
- children: listTitle
11670
- }), jsx(NonEmptyList, {
11724
+ ref: rightRef,
11725
+ children: jsx(NonEmptyList, {
11671
11726
  childPath: Paths.compose(path, `${currentIndex}`),
11672
11727
  rowIndex: currentIndex,
11673
11728
  schema: schema,
@@ -11678,16 +11733,55 @@ const ObjectArrayList = ({
11678
11733
  path: path,
11679
11734
  uischema: uischema,
11680
11735
  translations: translations
11681
- }, Paths.compose(path, `${currentIndex}`))]
11682
- }), jsx(GoabButton, {
11683
- type: 'primary',
11684
- onClick: () => {
11685
- setCurrentListPage(0);
11736
+ }, Paths.compose(path, `${currentIndex}`))
11737
+ })]
11738
+ }) : jsxs(RowFlex, {
11739
+ children: [currentListPage === 0 && jsx(FlexTabs, {
11740
+ style: {
11741
+ height: '100%'
11686
11742
  },
11687
- testId: "next-list-button",
11688
- children: continueButtonTitle ? continueButtonTitle : 'Continue'
11743
+ children: range(data).map(index => {
11744
+ const childPath = Paths.compose(path, `${index}`);
11745
+ return jsx(MainTab, {
11746
+ childPath: childPath,
11747
+ rowIndex: index,
11748
+ currentTab: currentIndex,
11749
+ openDeleteDialog: openDeleteDialog,
11750
+ selectCurrentTab: selectCurrentTab,
11751
+ enabled: enabled,
11752
+ current: current,
11753
+ setCurrentListPage: index => setCurrentListPage(index),
11754
+ uischema: uischema,
11755
+ schema: schema
11756
+ }, childPath);
11757
+ })
11758
+ }), currentListPage > 0 && jsxs(UpdateListContainer, {
11759
+ children: [jsxs(FlexForm, {
11760
+ tabIndex: -1,
11761
+ children: [jsx(ObjectArrayTitle, {
11762
+ children: listTitle
11763
+ }), jsx(NonEmptyList, {
11764
+ childPath: Paths.compose(path, `${currentIndex}`),
11765
+ rowIndex: currentIndex,
11766
+ schema: schema,
11767
+ openDeleteDialog: openDeleteDialog,
11768
+ showSortButtons: appliedUiSchemaOptions.showSortButtons || appliedUiSchemaOptions.showArrayTableSortButtons,
11769
+ enabled: enabled,
11770
+ cells: cells,
11771
+ path: path,
11772
+ uischema: uischema,
11773
+ translations: translations
11774
+ }, Paths.compose(path, `${currentIndex}`))]
11775
+ }), jsx(GoabButton, {
11776
+ type: 'primary',
11777
+ onClick: () => {
11778
+ setCurrentListPage(0);
11779
+ },
11780
+ testId: "next-list-button",
11781
+ children: continueButtonTitle ? continueButtonTitle : 'Continue'
11782
+ })]
11689
11783
  })]
11690
- })]
11784
+ })
11691
11785
  })
11692
11786
  });
11693
11787
  };
@@ -11731,7 +11825,7 @@ class ListWithDetailControl extends React.Component {
11731
11825
  };
11732
11826
  }
11733
11827
  render() {
11734
- var _a, _b, _c, _d, _e;
11828
+ var _a, _b, _c, _d, _e, _f, _g;
11735
11829
  const _this$props = this.props,
11736
11830
  {
11737
11831
  label,
@@ -11751,11 +11845,15 @@ class ListWithDetailControl extends React.Component {
11751
11845
  const controlElement = uischema;
11752
11846
  // eslint-disable-next-line
11753
11847
  const listTitle = (_e = (_d = (_c = (_a = uischema === null || uischema === void 0 ? void 0 : uischema.label) !== null && _a !== void 0 ? _a : (_b = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _b === void 0 ? void 0 : _b.title) !== null && _c !== void 0 ? _c : getItemsTitle(schema)) !== null && _d !== void 0 ? _d : schema === null || schema === void 0 ? void 0 : schema.title) !== null && _e !== void 0 ? _e : label;
11848
+ const withLeftTab = (_g = (_f = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _f === void 0 ? void 0 : _f.componentProps) === null || _g === void 0 ? void 0 : _g.withLeftTab;
11849
+ const noLeftTabBlankButton = this.state.currentListPage === 0 && data === 0;
11850
+ const showMainItems = withLeftTab || this.state.currentListPage === 0;
11851
+ const showSecondaryButton = withLeftTab || noLeftTabBlankButton;
11754
11852
  return jsxs(Visible, {
11755
11853
  visible: visible,
11756
11854
  "data-testid": "jsonforms-object-list-wrapper",
11757
11855
  children: [jsxs(ToolBarHeader, {
11758
- children: [listTitle && this.state.currentListPage === 0 && jsx(MarginTop, {
11856
+ children: [listTitle && showMainItems && jsx(MarginTop, {
11759
11857
  children: jsxs(ObjectArrayTitle, {
11760
11858
  children: [listTitle, " ", jsx("span", {
11761
11859
  children: additionalProps.required && '(required)'
@@ -11767,7 +11865,7 @@ class ListWithDetailControl extends React.Component {
11767
11865
  children: this.state.maxItemsError
11768
11866
  })]
11769
11867
  })
11770
- }), this.state.currentListPage === 0 && data === 0 && jsx(ObjectArrayToolBar, {
11868
+ }), showSecondaryButton && jsx(ObjectArrayToolBar, {
11771
11869
  data: data,
11772
11870
  errors: errors,
11773
11871
  label: label,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abgov/jsonforms-components",
3
- "version": "2.42.4",
3
+ "version": "2.43.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",
@@ -9,6 +9,7 @@ export declare const SideMenuItem: import("styled-components/dist/types").IStyle
9
9
  export declare const RowFlex: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
10
10
  export declare const RowFlexMenu: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
11
11
  export declare const FlexTabs: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
12
+ export declare const FlexTabsWithMargin: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
12
13
  export declare const FlexForm: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
13
14
  export declare const TabName: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
14
15
  export declare const Trash: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;