@axinom/mosaic-ui 0.66.0-rc.13 → 0.66.0-rc.15

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 (46) hide show
  1. package/dist/components/DynamicDataList/DynamicListHeader/DynamicListHeader.d.ts.map +1 -1
  2. package/dist/components/List/ListHeader/ColumnLabel/ColumnLabel.d.ts.map +1 -1
  3. package/dist/components/List/ListHeader/ListHeader.d.ts.map +1 -1
  4. package/dist/components/List/ListRow/ListRow.d.ts.map +1 -1
  5. package/dist/components/List/ListRow/ListRowCell/ListRowCell.d.ts +15 -0
  6. package/dist/components/List/ListRow/ListRowCell/ListRowCell.d.ts.map +1 -0
  7. package/dist/components/List/ListRow/ListRowCell/renderData.d.ts +9 -0
  8. package/dist/components/List/ListRow/ListRowCell/renderData.d.ts.map +1 -0
  9. package/dist/components/List/ListRow/Renderers/TagsRenderer/TagsRenderer.d.ts.map +1 -1
  10. package/dist/components/Utils/Postgraphile/CreateConnectionRenderer.d.ts +1 -1
  11. package/dist/components/Utils/Postgraphile/CreateConnectionRenderer.d.ts.map +1 -1
  12. package/dist/helpers/idleCallbackHelpers.d.ts +42 -0
  13. package/dist/helpers/idleCallbackHelpers.d.ts.map +1 -0
  14. package/dist/helpers/index.d.ts +1 -0
  15. package/dist/helpers/index.d.ts.map +1 -1
  16. package/dist/hooks/useResize/useResize.d.ts +3 -0
  17. package/dist/hooks/useResize/useResize.d.ts.map +1 -1
  18. package/dist/index.es.js +4 -4
  19. package/dist/index.es.js.map +1 -1
  20. package/dist/index.js +4 -4
  21. package/dist/index.js.map +1 -1
  22. package/package.json +2 -2
  23. package/src/components/DynamicDataList/DynamicDataList.scss +1 -0
  24. package/src/components/DynamicDataList/DynamicListHeader/DynamicListHeader.scss +10 -0
  25. package/src/components/DynamicDataList/DynamicListHeader/DynamicListHeader.spec.tsx +2 -0
  26. package/src/components/DynamicDataList/DynamicListHeader/DynamicListHeader.tsx +65 -49
  27. package/src/components/List/List.scss +1 -0
  28. package/src/components/List/ListHeader/ColumnLabel/ColumnLabel.spec.tsx +4 -4
  29. package/src/components/List/ListHeader/ColumnLabel/ColumnLabel.tsx +5 -1
  30. package/src/components/List/ListHeader/ListHeader.scss +10 -1
  31. package/src/components/List/ListHeader/ListHeader.spec.tsx +2 -0
  32. package/src/components/List/ListHeader/ListHeader.tsx +60 -50
  33. package/src/components/List/ListRow/ListRow.scss +0 -27
  34. package/src/components/List/ListRow/ListRow.spec.tsx +10 -8
  35. package/src/components/List/ListRow/ListRow.tsx +20 -152
  36. package/src/components/List/ListRow/ListRowCell/ListRowCell.scss +26 -0
  37. package/src/components/List/ListRow/ListRowCell/ListRowCell.spec.tsx +491 -0
  38. package/src/components/List/ListRow/ListRowCell/ListRowCell.tsx +57 -0
  39. package/src/components/List/ListRow/ListRowCell/renderData.tsx +124 -0
  40. package/src/components/List/ListRow/Renderers/TagsRenderer/TagsRenderer.spec.tsx +191 -80
  41. package/src/components/List/ListRow/Renderers/TagsRenderer/TagsRenderer.tsx +63 -34
  42. package/src/components/Utils/Postgraphile/CreateConnectionRenderer.spec.ts +48 -12
  43. package/src/components/Utils/Postgraphile/CreateConnectionRenderer.tsx +5 -4
  44. package/src/helpers/idleCallbackHelpers.ts +66 -0
  45. package/src/helpers/index.ts +5 -0
  46. package/src/hooks/useResize/useResize.ts +36 -4
@@ -1,10 +1,9 @@
1
1
  import clsx from 'clsx';
2
2
  import { LocationDescriptor } from 'history';
3
- import React, { PropsWithChildren, useCallback } from 'react';
3
+ import React, { PropsWithChildren, useCallback, useMemo } from 'react';
4
4
  import { Link } from 'react-router-dom';
5
5
  import { noop } from '../../../helpers/utils';
6
6
  import { Data } from '../../../types/data';
7
- import { getTooltipText } from '../../../utils/ToolTipHelpers';
8
7
  import { ActionData } from '../../Actions/Actions.models';
9
8
  import { Button } from '../../Buttons';
10
9
  import { IconName } from '../../Icons';
@@ -12,6 +11,7 @@ import { InlineMenu } from '../../InlineMenu/InlineMenu';
12
11
  import { Column, ListSelectMode } from '../List.model';
13
12
  import { ListCheckBox } from '../ListCheckBox/ListCheckBox';
14
13
  import classes from './ListRow.scss';
14
+ import { ListRowCell } from './ListRowCell/ListRowCell';
15
15
 
16
16
  export interface ListRowProps<T extends Data> {
17
17
  /** Spacing between columns */
@@ -76,124 +76,6 @@ export const setLocale = (locale: string): void => {
76
76
 
77
77
  setLocale(navigator.language);
78
78
 
79
- const renderData = <T extends Data>(
80
- column: Column<T>,
81
- rowData: T,
82
- ): {
83
- columnData: React.ReactNode;
84
- tooltip: string | undefined;
85
- isDataTestIdSet: boolean;
86
- } => {
87
- const getTooltip = (value: unknown): string | undefined =>
88
- column.tooltip !== false ? getTooltipText(value) : undefined;
89
-
90
- if (!column.propertyName) {
91
- const columnData = column.render?.(undefined, rowData);
92
-
93
- if (typeof columnData === 'string') {
94
- return {
95
- columnData: (
96
- <span
97
- data-test-id={`list-entry-property:${
98
- column.propertyName as string
99
- }`}
100
- >
101
- {columnData}
102
- </span>
103
- ),
104
- isDataTestIdSet: true,
105
- tooltip: getTooltip(columnData),
106
- };
107
- }
108
-
109
- return {
110
- columnData,
111
- tooltip: getTooltip(columnData),
112
- isDataTestIdSet: false,
113
- };
114
- }
115
- const value: unknown = rowData[column.propertyName];
116
- if (column.render) {
117
- const columnData = column.render(value, rowData);
118
-
119
- if (typeof columnData === 'string') {
120
- return {
121
- columnData: (
122
- <span
123
- data-test-id={`list-entry-property:${
124
- column.propertyName as string
125
- }`}
126
- >
127
- {columnData}
128
- </span>
129
- ),
130
- isDataTestIdSet: true,
131
- tooltip: getTooltip(columnData),
132
- };
133
- }
134
-
135
- return {
136
- columnData,
137
- tooltip: getTooltip(columnData),
138
- isDataTestIdSet: false,
139
- };
140
- }
141
-
142
- if (value === null || value === undefined) {
143
- return {
144
- columnData: (
145
- <span
146
- data-test-id={`list-entry-property:${column.propertyName as string}`}
147
- />
148
- ),
149
- tooltip: undefined,
150
- isDataTestIdSet: true,
151
- };
152
- }
153
-
154
- if (typeof value === 'number') {
155
- const columnData = numberFormatter.format(value);
156
- return {
157
- columnData: (
158
- <span
159
- data-test-id={`list-entry-property:${column.propertyName as string}`}
160
- >
161
- {columnData}
162
- </span>
163
- ),
164
- tooltip: getTooltip(columnData),
165
- isDataTestIdSet: true,
166
- };
167
- }
168
-
169
- if (value instanceof Date) {
170
- const columnData = dateFormatter.format(value);
171
- return {
172
- columnData: (
173
- <span
174
- data-test-id={`list-entry-property:${column.propertyName as string}`}
175
- >
176
- {columnData}
177
- </span>
178
- ),
179
- tooltip: getTooltip(columnData),
180
- isDataTestIdSet: true,
181
- };
182
- }
183
-
184
- return {
185
- columnData: (
186
- <span
187
- data-test-id={`list-entry-property:${column.propertyName as string}`}
188
- >
189
- {String(value)}
190
- </span>
191
- ),
192
- tooltip: getTooltip(String(value)),
193
- isDataTestIdSet: true,
194
- };
195
- };
196
-
197
79
  /**
198
80
  * Renders the rows for the list component
199
81
  * @example
@@ -260,42 +142,28 @@ const ListRowComponent = <T extends Data>(
260
142
  selectionMode === ListSelectMode.None &&
261
143
  typeof onItemClicked !== 'function';
262
144
 
263
- const generateCells: JSX.Element[] = columns.map((column: Column<T>) => {
264
- const { columnData, tooltip, isDataTestIdSet } = renderData<T>(
265
- column,
266
- data,
267
- );
268
-
269
- return (
270
- <div
271
- key={column.key ?? (column.propertyName as string)}
272
- className={classes.cellWrapper}
273
- >
274
- <div
275
- className={clsx(classes.cell, { [classes.nowrap]: !textWrap })}
276
- title={tooltip}
277
- style={{
278
- justifySelf: column.horizontalColumnAlign, // Horizontal alignment based on column config
279
- alignSelf: verticalTextAlign, // Vertical alignment based on props
280
- textAlign: horizontalTextAlign, // Additional text alignment inside the cell
281
- }}
282
- data-test-id={
283
- isDataTestIdSet
284
- ? null
285
- : `list-entry-property:${column.propertyName as string}`
286
- }
287
- >
288
- {columnData}
289
- </div>
290
- </div>
291
- );
292
- });
145
+ const generateCells = useMemo(() => {
146
+ return columns.map((column: Column<T>) => {
147
+ return (
148
+ <ListRowCell<T>
149
+ key={column.key ?? (column.propertyName as string)}
150
+ column={column}
151
+ data={data}
152
+ horizontalTextAlign={horizontalTextAlign}
153
+ verticalTextAlign={verticalTextAlign}
154
+ textWrap={textWrap}
155
+ dateFormatter={dateFormatter}
156
+ numberFormatter={numberFormatter}
157
+ />
158
+ );
159
+ });
160
+ }, [columns, data, horizontalTextAlign, textWrap, verticalTextAlign]);
293
161
 
294
162
  const inlineActionMenuData = inlineMenuActions
295
163
  ? inlineMenuActions(data)
296
164
  : undefined;
297
165
 
298
- const Row = (
166
+ return (
299
167
  <div
300
168
  className={clsx(classes.columnsRoot, {
301
169
  [classes.selected]: itemSelected,
@@ -382,7 +250,7 @@ const ListRowComponent = <T extends Data>(
382
250
  </div>
383
251
  );
384
252
 
385
- return Row;
253
+ // return Row;
386
254
  };
387
255
 
388
256
  export const ListRow = React.forwardRef(ListRowComponent) as <T extends Data>(
@@ -0,0 +1,26 @@
1
+ .cellWrapper {
2
+ display: grid;
3
+ width: 100%;
4
+ height: 100%;
5
+ }
6
+
7
+ .cell {
8
+ max-width: 100%;
9
+ max-height: 100%;
10
+
11
+ span {
12
+ padding: 5px 0;
13
+ display: block;
14
+ width: 100%;
15
+ }
16
+
17
+ &.nowrap {
18
+ overflow: hidden;
19
+
20
+ span {
21
+ white-space: nowrap;
22
+ text-overflow: ellipsis;
23
+ overflow: hidden;
24
+ }
25
+ }
26
+ }