@axinom/mosaic-ui 0.36.0-rc.2 → 0.36.0-rc.20

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.
Files changed (34) hide show
  1. package/dist/components/DynamicDataList/DynamicDataList.d.ts.map +1 -1
  2. package/dist/components/DynamicDataList/DynamicDataList.model.d.ts +2 -0
  3. package/dist/components/DynamicDataList/DynamicDataList.model.d.ts.map +1 -1
  4. package/dist/components/DynamicDataList/DynamicListHeader/DynamicListHeader.d.ts +7 -1
  5. package/dist/components/DynamicDataList/DynamicListHeader/DynamicListHeader.d.ts.map +1 -1
  6. package/dist/components/DynamicDataList/helpers/useColumnDefs.d.ts +2 -0
  7. package/dist/components/DynamicDataList/helpers/useColumnDefs.d.ts.map +1 -1
  8. package/dist/components/List/ListHeader/ListHeader.d.ts.map +1 -1
  9. package/dist/components/List/useColumnsSize.d.ts +1 -2
  10. package/dist/components/List/useColumnsSize.d.ts.map +1 -1
  11. package/dist/{components/List/ListHeader → hooks/useResize}/useResize.d.ts +4 -3
  12. package/dist/hooks/useResize/useResize.d.ts.map +1 -0
  13. package/dist/index.es.js +4 -4
  14. package/dist/index.es.js.map +1 -1
  15. package/dist/index.js +4 -4
  16. package/dist/index.js.map +1 -1
  17. package/dist/types/ui-config.d.ts +2 -0
  18. package/dist/types/ui-config.d.ts.map +1 -1
  19. package/package.json +3 -3
  20. package/src/components/DynamicDataList/DynamicDataList.model.ts +3 -0
  21. package/src/components/DynamicDataList/DynamicDataList.stories.tsx +1 -1
  22. package/src/components/DynamicDataList/DynamicDataList.tsx +17 -9
  23. package/src/components/DynamicDataList/DynamicListDataEntry/DynamicListDataEntry.scss +4 -0
  24. package/src/components/DynamicDataList/DynamicListHeader/DynamicListHeader.scss +18 -4
  25. package/src/components/DynamicDataList/DynamicListHeader/DynamicListHeader.spec.tsx +64 -3
  26. package/src/components/DynamicDataList/DynamicListHeader/DynamicListHeader.tsx +34 -1
  27. package/src/components/DynamicDataList/DynamicListRow/DynamicListRow.scss +4 -0
  28. package/src/components/DynamicDataList/helpers/useColumnDefs.ts +92 -21
  29. package/src/components/List/List.scss +1 -0
  30. package/src/components/List/ListHeader/ListHeader.tsx +1 -1
  31. package/src/components/List/useColumnsSize.ts +3 -3
  32. package/src/{components/List/ListHeader → hooks/useResize}/useResize.ts +4 -3
  33. package/src/types/ui-config.ts +2 -0
  34. package/dist/components/List/ListHeader/useResize.d.ts.map +0 -1
@@ -11,7 +11,9 @@ export interface Notification {
11
11
  options?: NotificationOptions;
12
12
  }
13
13
  export interface NotificationOptions {
14
+ /** Type of the notification */
14
15
  type?: NotificationType;
16
+ /** Set to false to disable auto-closing of the notification, or specify a custom timeout in milliseconds */
15
17
  autoClose?: number | false;
16
18
  }
17
19
  export type NotificationId = string | number;
@@ -1 +1 @@
1
- {"version":3,"file":"ui-config.d.ts","sourceRoot":"","sources":["../../src/types/ui-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE7C,MAAM,MAAM,gBAAgB,GAAG,CAAC,YAAY,EAAE,YAAY,KAAK,cAAc,CAAC;AAE9E,MAAM,MAAM,kBAAkB,GAAG,CAC/B,EAAE,EAAE,cAAc,EAClB,YAAY,EAAE,YAAY,KACvB,IAAI,CAAC;AAEV,MAAM,MAAM,mBAAmB,GAAG,CAAC,EAAE,EAAE,cAAc,KAAK,IAAI,CAAC;AAE/D,MAAM,WAAW,YAAY;IAC3B,2CAA2C;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,wCAAwC;IACxC,IAAI,CAAC,EAAE,gBAAgB,CAAC;IACxB,8CAA8C;IAC9C,OAAO,CAAC,EAAE,mBAAmB,CAAC;CAC/B;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,CAAC,EAAE,gBAAgB,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;CAC5B;AAED,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,MAAM,CAAC;AAE7C,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,CAAC;AAE9D,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC;AAExE,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC;AAEjC,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,SAAS,KAAK,WAAW,CAAC;AAErE,MAAM,MAAM,eAAe,GAAG,CAAC,EAAE,EAAE,WAAW,KAAK,IAAI,CAAC;AAExD,MAAM,MAAM,eAAe,GAAG,CAC5B,EAAE,EAAE,WAAW,EACf,OAAO,EAAE,KAAK,CAAC,SAAS,KACrB,IAAI,CAAC;AAEV,MAAM,WAAW,kBAAkB;IACjC,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,GAAG,IAAI,CAAC;CACrE"}
1
+ {"version":3,"file":"ui-config.d.ts","sourceRoot":"","sources":["../../src/types/ui-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE7C,MAAM,MAAM,gBAAgB,GAAG,CAAC,YAAY,EAAE,YAAY,KAAK,cAAc,CAAC;AAE9E,MAAM,MAAM,kBAAkB,GAAG,CAC/B,EAAE,EAAE,cAAc,EAClB,YAAY,EAAE,YAAY,KACvB,IAAI,CAAC;AAEV,MAAM,MAAM,mBAAmB,GAAG,CAAC,EAAE,EAAE,cAAc,KAAK,IAAI,CAAC;AAE/D,MAAM,WAAW,YAAY;IAC3B,2CAA2C;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,wCAAwC;IACxC,IAAI,CAAC,EAAE,gBAAgB,CAAC;IACxB,8CAA8C;IAC9C,OAAO,CAAC,EAAE,mBAAmB,CAAC;CAC/B;AAED,MAAM,WAAW,mBAAmB;IAClC,+BAA+B;IAC/B,IAAI,CAAC,EAAE,gBAAgB,CAAC;IACxB,4GAA4G;IAC5G,SAAS,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;CAC5B;AAED,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,MAAM,CAAC;AAE7C,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,CAAC;AAE9D,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC;AAExE,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC;AAEjC,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,SAAS,KAAK,WAAW,CAAC;AAErE,MAAM,MAAM,eAAe,GAAG,CAAC,EAAE,EAAE,WAAW,KAAK,IAAI,CAAC;AAExD,MAAM,MAAM,eAAe,GAAG,CAC5B,EAAE,EAAE,WAAW,EACf,OAAO,EAAE,KAAK,CAAC,SAAS,KACrB,IAAI,CAAC;AAEV,MAAM,WAAW,kBAAkB;IACjC,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,GAAG,IAAI,CAAC;CACrE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axinom/mosaic-ui",
3
- "version": "0.36.0-rc.2",
3
+ "version": "0.36.0-rc.20",
4
4
  "description": "UI components for building Axinom Mosaic applications",
5
5
  "author": "Axinom",
6
6
  "license": "PROPRIETARY",
@@ -32,7 +32,7 @@
32
32
  "build-storybook": "storybook build"
33
33
  },
34
34
  "dependencies": {
35
- "@axinom/mosaic-core": "^0.4.9-rc.2",
35
+ "@axinom/mosaic-core": "^0.4.9-rc.20",
36
36
  "@faker-js/faker": "^7.4.0",
37
37
  "@popperjs/core": "^2.9.2",
38
38
  "clsx": "^1.1.0",
@@ -104,5 +104,5 @@
104
104
  "publishConfig": {
105
105
  "access": "public"
106
106
  },
107
- "gitHead": "52333cdf9f4680e6adc74a576fdc87bfd85b3d31"
107
+ "gitHead": "ad32da3e9da19743e5ce764bc173650a3ab9631a"
108
108
  }
@@ -34,6 +34,9 @@ export interface DynamicListColumn<T extends Data> {
34
34
 
35
35
  /** Performs a transformation on the value before being added to the list */
36
36
  onAddTransformer?: (value: unknown, data: T) => unknown;
37
+
38
+ /** If set to true, the column will not be resizable */
39
+ disableResizing?: boolean;
37
40
  }
38
41
 
39
42
  export type DynamicListDataEntryRenderer = (
@@ -193,7 +193,7 @@ export const WithSelectInputRenderer: StoryObj<StoryDDLType> = {
193
193
  {
194
194
  propertyName: 'id',
195
195
  label: 'Id',
196
- size: '50px',
196
+ size: '100px',
197
197
  dataEntryRender: createSelectRenderer({
198
198
  options: [
199
199
  { value: '10', label: '10' },
@@ -132,15 +132,20 @@ export const DynamicDataList = <T extends Data>({
132
132
  rowClassNameProvider,
133
133
  inlineMenuActions,
134
134
  }: PropsWithChildren<DynamicDataListProps<T>>): JSX.Element => {
135
- const { columnSizes, showActionColumn, showPositionColumn } =
136
- useColumnDefs<T>(
137
- columns,
138
- allowReordering,
139
- allowNewData,
140
- allowRowDragging,
141
- positionPropertyName,
142
- !!inlineMenuActions,
143
- );
135
+ const {
136
+ columnSizes,
137
+ showActionColumn,
138
+ showPositionColumn,
139
+ setColumnSizes,
140
+ resetColumnSizes,
141
+ } = useColumnDefs<T>(
142
+ columns,
143
+ allowReordering,
144
+ allowNewData,
145
+ allowRowDragging,
146
+ positionPropertyName,
147
+ !!inlineMenuActions,
148
+ );
144
149
 
145
150
  const { addItem, removeItem, updateItem, canAddItems, items, nextPosition } =
146
151
  useDataHandler(
@@ -310,6 +315,9 @@ export const DynamicDataList = <T extends Data>({
310
315
  sticky={stickyHeader}
311
316
  allowDragging={allowRowDragging}
312
317
  showPositionColumn={showPositionColumn}
318
+ showActionColumn={showActionColumn}
319
+ onColumnSizesChanged={setColumnSizes}
320
+ onResetColumnSizes={resetColumnSizes}
313
321
  />
314
322
  )}
315
323
  {canAddItems &&
@@ -25,6 +25,10 @@
25
25
 
26
26
  padding: 1px 0px 1px 0px;
27
27
 
28
+ > .column:first-child {
29
+ padding-left: var(--dynamic-list-column-gap, $dynamic-list-column-gap);
30
+ }
31
+
28
32
  .column {
29
33
  width: 100%;
30
34
  height: 100%;
@@ -18,7 +18,7 @@
18
18
  justify-items: left;
19
19
  align-items: center;
20
20
 
21
- &:first-child {
21
+ > :first-child {
22
22
  padding-left: var(--dynamic-list-column-gap, $dynamic-list-column-gap);
23
23
  }
24
24
 
@@ -28,11 +28,25 @@
28
28
 
29
29
  display: grid;
30
30
  align-items: center;
31
+ position: relative;
31
32
 
32
- border-right: solid 1px lighten($gray, 15%);
33
+ .resizeHandle {
34
+ cursor: col-resize;
35
+ width: 7px;
36
+ height: 100%;
33
37
 
34
- &:last-of-type {
35
- border-right: none;
38
+ z-index: 1;
39
+ border-right: var(--explorer-list-row-border, 1px solid #dddddd);
40
+ position: absolute;
41
+ right: 0;
42
+
43
+ &:hover:not(.resizeHandleDisabled) {
44
+ border-width: 3px;
45
+ }
46
+
47
+ &.resizeHandleDisabled {
48
+ cursor: default;
49
+ }
36
50
  }
37
51
  }
38
52
 
@@ -1,4 +1,4 @@
1
- import { shallow } from 'enzyme';
1
+ import { mount, shallow } from 'enzyme';
2
2
  import React from 'react';
3
3
  import { DynamicListColumn } from '../DynamicDataList.model';
4
4
  import { DynamicListHeader, DynamicListHeaderProps } from './DynamicListHeader';
@@ -30,11 +30,12 @@ const defaultProps: DynamicListHeaderProps<DynamicListHeaderTestData> = {
30
30
  columnSizes: 'column-size',
31
31
  columnGap: 'column-gap',
32
32
  rowHeight: 'row-height',
33
- //actionSize: 'action-size',
34
33
  horizontalTextAlign: 'left',
35
34
  verticalTextAlign: 'center',
36
35
  positionKey: 'position',
37
36
  allowReordering: undefined,
37
+ onColumnSizesChanged: jest.fn(),
38
+ onResetColumnSizes: jest.fn(),
38
39
  };
39
40
 
40
41
  describe('DynamicListHeader', () => {
@@ -47,6 +48,7 @@ describe('DynamicListHeader', () => {
47
48
  it('header should not be draggable', () => {
48
49
  const wrapper = shallow(
49
50
  <DynamicListHeader
51
+ {...defaultProps}
50
52
  columns={defaultColumns}
51
53
  columnSizes={defaultProps.columnSizes}
52
54
  />,
@@ -62,6 +64,8 @@ describe('DynamicListHeader', () => {
62
64
  <DynamicListHeader
63
65
  columns={defaultColumns}
64
66
  columnSizes={defaultProps.columnSizes}
67
+ onColumnSizesChanged={jest.fn()}
68
+ onResetColumnSizes={jest.fn()}
65
69
  />,
66
70
  );
67
71
 
@@ -107,7 +111,7 @@ describe('DynamicListHeader', () => {
107
111
  it('renders a label for every column if set', () => {
108
112
  const wrapper = shallow(<DynamicListHeader {...defaultProps} />);
109
113
 
110
- const columns = wrapper.find('.column');
114
+ const columns = wrapper.find('.column').slice(0, -1); // remove the last column, which is the action column
111
115
 
112
116
  columns.forEach((column, idx) => {
113
117
  expect(column.text()).toEqual(defaultColumns[idx].label);
@@ -117,6 +121,7 @@ describe('DynamicListHeader', () => {
117
121
  it(`renders the position column if 'showPositionColumn' is set to true`, () => {
118
122
  const wrapper = shallow(
119
123
  <DynamicListHeader
124
+ {...defaultProps}
120
125
  columnSizes={''}
121
126
  columns={defaultColumns}
122
127
  positionKey={'position'}
@@ -137,6 +142,7 @@ describe('DynamicListHeader', () => {
137
142
 
138
143
  const wrapper = shallow(
139
144
  <DynamicListHeader
145
+ {...defaultProps}
140
146
  columnSizes={''}
141
147
  columns={defaultColumns}
142
148
  positionKey={'position'}
@@ -155,6 +161,7 @@ describe('DynamicListHeader', () => {
155
161
  it(`doesn't render the position column if a 'positionKey' isn't set`, () => {
156
162
  const wrapper = shallow(
157
163
  <DynamicListHeader
164
+ {...defaultProps}
158
165
  columnSizes={''}
159
166
  columns={defaultColumns}
160
167
  allowReordering={true}
@@ -169,6 +176,7 @@ describe('DynamicListHeader', () => {
169
176
  it(`doesn't render the position column if 'allowReordering' is false`, () => {
170
177
  const wrapper = shallow(
171
178
  <DynamicListHeader
179
+ {...defaultProps}
172
180
  columnSizes={''}
173
181
  columns={defaultColumns}
174
182
  positionKey={'position'}
@@ -180,4 +188,57 @@ describe('DynamicListHeader', () => {
180
188
 
181
189
  expect(position.exists()).toBe(false);
182
190
  });
191
+
192
+ describe('Column Resizing', () => {
193
+ it('calls onResetColumnSizes when the reset button is clicked', () => {
194
+ const spy = jest.fn();
195
+ const wrapper = shallow(
196
+ <DynamicListHeader {...defaultProps} onResetColumnSizes={spy} />,
197
+ );
198
+
199
+ const resetButton = wrapper.find('.resizeHandle').first();
200
+ resetButton.simulate('doubleClick');
201
+
202
+ expect(spy).toHaveBeenCalledTimes(1);
203
+ });
204
+
205
+ it('calls onResetColumnSizes when the reset button is clicked also on non-resizable column', () => {
206
+ const spy = jest.fn();
207
+ const wrapper = shallow(
208
+ <DynamicListHeader
209
+ {...defaultProps}
210
+ columns={[
211
+ { ...defaultColumns[0], disableResizing: true },
212
+ ...defaultColumns.slice(1),
213
+ ]}
214
+ onResetColumnSizes={spy}
215
+ />,
216
+ );
217
+
218
+ const resetButton = wrapper.find('.resizeHandle').first();
219
+ resetButton.simulate('doubleClick');
220
+
221
+ expect(spy).toHaveBeenCalledTimes(1);
222
+ });
223
+
224
+ it('calls onColumnSizesChanged when the column is resized', () => {
225
+ const spy = jest.fn();
226
+ const wrapper = mount(
227
+ <DynamicListHeader {...defaultProps} onColumnSizesChanged={spy} />,
228
+ );
229
+
230
+ const resizeHandle = wrapper.find('.resizeHandle').first();
231
+ resizeHandle.invoke('onMouseDown')!({
232
+ preventDefault: jest.fn(),
233
+ } as any);
234
+
235
+ window.dispatchEvent(
236
+ new Event('mousemove', {
237
+ clientX: 100,
238
+ } as any),
239
+ );
240
+
241
+ expect(spy).toHaveBeenCalledTimes(1);
242
+ });
243
+ });
183
244
  });
@@ -1,5 +1,6 @@
1
1
  import clsx from 'clsx';
2
2
  import React, { PropsWithChildren } from 'react';
3
+ import { useResize } from '../../../hooks/useResize/useResize';
3
4
  import { Data } from '../../../types/data';
4
5
  import { DynamicListColumn } from '../DynamicDataList.model';
5
6
  import classes from './DynamicListHeader.scss';
@@ -32,6 +33,12 @@ export interface DynamicListHeaderProps<T extends Data> {
32
33
  showPositionColumn?: boolean;
33
34
  /** This will be used to determine the label for the position column if a positionLabel is not defined (default: false) */
34
35
  allowDragging?: boolean;
36
+ /** If set to true, the action column will be shown (default: false) */
37
+ showActionColumn?: boolean;
38
+ /** called when the column sizes should be reset */
39
+ onResetColumnSizes: () => void;
40
+ /** called when the column sizes should be updated */
41
+ onColumnSizesChanged: (columnSizes: string) => void;
35
42
  }
36
43
 
37
44
  export const DynamicListHeader = <T extends Data>({
@@ -46,6 +53,9 @@ export const DynamicListHeader = <T extends Data>({
46
53
  sticky = true,
47
54
  showPositionColumn = false,
48
55
  allowDragging = false,
56
+ showActionColumn,
57
+ onColumnSizesChanged,
58
+ onResetColumnSizes,
49
59
  }: PropsWithChildren<DynamicListHeaderProps<T>>): JSX.Element => {
50
60
  const customStyles = {
51
61
  gridAutoRows: rowHeight,
@@ -60,6 +70,8 @@ export const DynamicListHeader = <T extends Data>({
60
70
  customStyles.top = 0;
61
71
  }
62
72
 
73
+ const { cols, mouseDown } = useResize(columns, onColumnSizesChanged);
74
+
63
75
  return (
64
76
  <div
65
77
  className={clsx(
@@ -78,19 +90,40 @@ export const DynamicListHeader = <T extends Data>({
78
90
  <p className={clsx(classes.position)}>
79
91
  {positionLabel ?? (allowDragging ? 'Position' : 'Pos')}
80
92
  </p>
93
+ <div
94
+ className={clsx(classes.resizeHandle, classes.resizeHandleDisabled)}
95
+ />
81
96
  </div>
82
97
  )}
83
- {columns.map((column) => (
98
+ {columns.map((column, i) => (
84
99
  <div
85
100
  key={column.propertyName as string}
86
101
  className={clsx(classes.column)}
102
+ ref={cols[i].ref}
87
103
  data-test-id={`dynamic-list-header-property:${
88
104
  column.propertyName as string
89
105
  }`}
90
106
  >
91
107
  <p>{column.label}</p>
108
+ <div
109
+ onMouseDown={
110
+ !column.disableResizing
111
+ ? (e) => {
112
+ e.preventDefault();
113
+ mouseDown(i);
114
+ }
115
+ : undefined
116
+ }
117
+ onDoubleClick={onResetColumnSizes}
118
+ className={clsx(classes.resizeHandle, {
119
+ [classes.resizeHandleDisabled]: column.disableResizing ?? false,
120
+ })}
121
+ />
92
122
  </div>
93
123
  ))}
124
+ {showActionColumn && (
125
+ <div className={clsx(classes.column)} ref={cols[cols.length - 1].ref} />
126
+ )}
94
127
  </div>
95
128
  );
96
129
  };
@@ -14,6 +14,10 @@
14
14
 
15
15
  border-bottom: var(--dynamic-list-row-border, $dynamic-list-row-border);
16
16
 
17
+ > .wrapper:first-child {
18
+ padding-left: var(--dynamic-list-column-gap, $dynamic-list-column-gap);
19
+ }
20
+
17
21
  &.dragging {
18
22
  border-bottom: 0;
19
23
  }
@@ -1,3 +1,4 @@
1
+ import { useEffect, useState } from 'react';
1
2
  import { Data } from '../../../types';
2
3
  import { DynamicListColumn } from '../DynamicDataList.model';
3
4
 
@@ -18,39 +19,109 @@ export const useColumnDefs = function <T extends Data>(
18
19
  readonly columnSizes: string;
19
20
  readonly showPositionColumn: boolean;
20
21
  readonly showActionColumn: boolean;
22
+ resetColumnSizes: () => void;
23
+ setColumnSizes: (newColumnSizes: string) => void;
21
24
  } {
22
- let positionColumn = '';
25
+ const [isResized, setIsResized] = useState<boolean>(false);
26
+
27
+ const [orgColumnSizes, setOrgColumnSizes] = useState<string>(
28
+ calculateColumnSizes(
29
+ columns,
30
+ allowReordering,
31
+ allowRowDragging,
32
+ positionKey,
33
+ allowNewData || showInlineMenu,
34
+ ),
35
+ );
36
+
37
+ const [columnSizes, setColumnSizes] = useState<string>(orgColumnSizes);
38
+
39
+ useEffect(() => {
40
+ setOrgColumnSizes(
41
+ calculateColumnSizes(
42
+ columns,
43
+ allowReordering,
44
+ allowRowDragging,
45
+ positionKey,
46
+ allowNewData || showInlineMenu,
47
+ ),
48
+ );
49
+ if (!isResized) {
50
+ setColumnSizes(orgColumnSizes);
51
+ }
52
+ }, [
53
+ allowNewData,
54
+ allowReordering,
55
+ allowRowDragging,
56
+ columns,
57
+ isResized,
58
+ orgColumnSizes,
59
+ positionKey,
60
+ showInlineMenu,
61
+ ]);
62
+
63
+ const resetColumnSizes = (): void => {
64
+ setColumnSizes(orgColumnSizes);
65
+ setIsResized(false);
66
+ };
67
+
68
+ return {
69
+ columnSizes,
70
+ showPositionColumn: allowReordering && positionKey !== undefined,
71
+ showActionColumn: (allowNewData || showInlineMenu) ?? false,
72
+ resetColumnSizes,
73
+ setColumnSizes: (newColumnSizes: string) => {
74
+ const positionColumn = getPositionColumnWidth(
75
+ allowReordering,
76
+ allowRowDragging,
77
+ positionKey,
78
+ );
79
+
80
+ setIsResized(true);
81
+ setColumnSizes(`${positionColumn} ${newColumnSizes}`.trim());
82
+ },
83
+ } as const;
84
+ };
85
+
86
+ function calculateColumnSizes<T extends Data>(
87
+ columns: DynamicListColumn<T>[],
88
+ allowReordering: boolean,
89
+ allowRowDragging: boolean,
90
+ positionKey?: keyof T,
91
+ showActionColumn?: boolean,
92
+ ): string {
93
+ const positionColumn = getPositionColumnWidth(
94
+ allowReordering,
95
+ allowRowDragging,
96
+ positionKey,
97
+ );
23
98
  let actionColumn = '';
24
- let showPositionColumn = false;
25
- let showActionColumn = false;
26
99
 
27
100
  const columnDefinition = columns
28
101
  .filter((columns) => columns.propertyName !== positionKey) // do not allow a column to be created for 'position'
29
102
  .reduce((prev, current) => `${prev} ${current.size ?? '1fr'}`, '')
30
103
  .trim();
31
104
 
105
+ if (showActionColumn) {
106
+ actionColumn = '50px';
107
+ }
108
+
109
+ return `${positionColumn} ${columnDefinition} ${actionColumn}`.trim();
110
+ }
111
+
112
+ function getPositionColumnWidth<T extends Data>(
113
+ allowReordering: boolean,
114
+ allowRowDragging: boolean,
115
+ positionKey?: keyof T,
116
+ ): string {
32
117
  // only show position column if allowReordering is true and the positionKey exists
33
118
  if (allowReordering && positionKey !== undefined) {
34
119
  if (allowRowDragging === true) {
35
- positionColumn = '100px';
120
+ return '100px';
36
121
  } else {
37
- positionColumn = '50px';
122
+ return '50px';
38
123
  }
39
-
40
- showPositionColumn = true;
41
124
  }
42
125
 
43
- if (allowNewData || showInlineMenu) {
44
- actionColumn = '50px';
45
- showActionColumn = true;
46
- }
47
-
48
- const columnSizes =
49
- `${positionColumn} ${columnDefinition} ${actionColumn}`.trim();
50
-
51
- return {
52
- columnSizes,
53
- showPositionColumn,
54
- showActionColumn,
55
- } as const;
56
- };
126
+ return '';
127
+ }
@@ -11,6 +11,7 @@
11
11
  --explorer-background-color,
12
12
  $explorer-background-color
13
13
  );
14
+ overflow-x: auto;
14
15
 
15
16
  .LoadingData {
16
17
  margin: 1rem 0;
@@ -1,11 +1,11 @@
1
1
  import clsx from 'clsx';
2
2
  import React, { PropsWithChildren } from 'react';
3
+ import { useResize } from '../../../hooks/useResize/useResize';
3
4
  import { Data } from '../../../types/data';
4
5
  import { Column, SortData } from '../List.model';
5
6
  import { ListCheckBox } from '../ListCheckBox/ListCheckBox';
6
7
  import { ColumnLabel } from './ColumnLabel/ColumnLabel';
7
8
  import classes from './ListHeader.scss';
8
- import { useResize } from './useResize';
9
9
 
10
10
  export interface ListHeaderProps<T extends Data> {
11
11
  /** Column definitions */
@@ -1,4 +1,4 @@
1
- import { SetStateAction, useEffect, useState } from 'react';
1
+ import { useEffect, useState } from 'react';
2
2
  import { Data } from '../../types';
3
3
  import { Column, ListSelectMode } from './List.model';
4
4
 
@@ -70,7 +70,7 @@ export const useColumnsSize = <T extends Data>(
70
70
  ): {
71
71
  columnSizes: string;
72
72
  resetColumnSizes: () => void;
73
- setColumnSizes: React.Dispatch<React.SetStateAction<string>>;
73
+ setColumnSizes: (newColumnSizes: string) => void;
74
74
  hasActionColumn: boolean;
75
75
  } => {
76
76
  const [isResized, setIsResized] = useState<boolean>(false);
@@ -115,7 +115,7 @@ export const useColumnsSize = <T extends Data>(
115
115
  return {
116
116
  columnSizes,
117
117
  resetColumnSizes,
118
- setColumnSizes: (newColumnSizes: SetStateAction<string>) => {
118
+ setColumnSizes: (newColumnSizes: string) => {
119
119
  setIsResized(true);
120
120
  setColumnSizes(newColumnSizes);
121
121
  },
@@ -1,6 +1,7 @@
1
1
  import React, { useCallback, useEffect, useMemo, useState } from 'react';
2
- import { Data } from '../../../types';
3
- import { Column } from '../List.model';
2
+ import { DynamicListColumn } from '../../components';
3
+ import { Column } from '../../components/List/List.model';
4
+ import { Data } from '../../types';
4
5
 
5
6
  /**
6
7
  * Handles the resizing logic of the columns
@@ -10,7 +11,7 @@ import { Column } from '../List.model';
10
11
  * and the mouseDown handler (add this to the element that should be used to resize the column)
11
12
  */
12
13
  export const useResize = <T extends Data>(
13
- columns: Column<T>[],
14
+ columns: Column<T>[] | DynamicListColumn<T>[],
14
15
  onColumnSizesChanged: (columnSizes: string) => void,
15
16
  ): {
16
17
  cols: {
@@ -19,7 +19,9 @@ export interface Notification {
19
19
  }
20
20
 
21
21
  export interface NotificationOptions {
22
+ /** Type of the notification */
22
23
  type?: NotificationType;
24
+ /** Set to false to disable auto-closing of the notification, or specify a custom timeout in milliseconds */
23
25
  autoClose?: number | false;
24
26
  }
25
27
 
@@ -1 +0,0 @@
1
- {"version":3,"file":"useResize.d.ts","sourceRoot":"","sources":["../../../../src/components/List/ListHeader/useResize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAoD,MAAM,OAAO,CAAC;AACzE,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,6EAEgB,MAAM,KAAK,IAAI;UAE7C;QACJ,GAAG,EAAE,MAAM,SAAS,CAAC,oBAAoB,CAAC,CAAC;QAC3C,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;KAC7B,EAAE;uBACgB,MAAM,KAAK,IAAI;CAwFnC,CAAC"}