@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.
- package/dist/components/DynamicDataList/DynamicListHeader/DynamicListHeader.d.ts.map +1 -1
- package/dist/components/List/ListHeader/ColumnLabel/ColumnLabel.d.ts.map +1 -1
- package/dist/components/List/ListHeader/ListHeader.d.ts.map +1 -1
- package/dist/components/List/ListRow/ListRow.d.ts.map +1 -1
- package/dist/components/List/ListRow/ListRowCell/ListRowCell.d.ts +15 -0
- package/dist/components/List/ListRow/ListRowCell/ListRowCell.d.ts.map +1 -0
- package/dist/components/List/ListRow/ListRowCell/renderData.d.ts +9 -0
- package/dist/components/List/ListRow/ListRowCell/renderData.d.ts.map +1 -0
- package/dist/components/List/ListRow/Renderers/TagsRenderer/TagsRenderer.d.ts.map +1 -1
- package/dist/components/Utils/Postgraphile/CreateConnectionRenderer.d.ts +1 -1
- package/dist/components/Utils/Postgraphile/CreateConnectionRenderer.d.ts.map +1 -1
- package/dist/helpers/idleCallbackHelpers.d.ts +42 -0
- package/dist/helpers/idleCallbackHelpers.d.ts.map +1 -0
- package/dist/helpers/index.d.ts +1 -0
- package/dist/helpers/index.d.ts.map +1 -1
- package/dist/hooks/useResize/useResize.d.ts +3 -0
- package/dist/hooks/useResize/useResize.d.ts.map +1 -1
- package/dist/index.es.js +4 -4
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/components/DynamicDataList/DynamicDataList.scss +1 -0
- package/src/components/DynamicDataList/DynamicListHeader/DynamicListHeader.scss +10 -0
- package/src/components/DynamicDataList/DynamicListHeader/DynamicListHeader.spec.tsx +2 -0
- package/src/components/DynamicDataList/DynamicListHeader/DynamicListHeader.tsx +65 -49
- package/src/components/List/List.scss +1 -0
- package/src/components/List/ListHeader/ColumnLabel/ColumnLabel.spec.tsx +4 -4
- package/src/components/List/ListHeader/ColumnLabel/ColumnLabel.tsx +5 -1
- package/src/components/List/ListHeader/ListHeader.scss +10 -1
- package/src/components/List/ListHeader/ListHeader.spec.tsx +2 -0
- package/src/components/List/ListHeader/ListHeader.tsx +60 -50
- package/src/components/List/ListRow/ListRow.scss +0 -27
- package/src/components/List/ListRow/ListRow.spec.tsx +10 -8
- package/src/components/List/ListRow/ListRow.tsx +20 -152
- package/src/components/List/ListRow/ListRowCell/ListRowCell.scss +26 -0
- package/src/components/List/ListRow/ListRowCell/ListRowCell.spec.tsx +491 -0
- package/src/components/List/ListRow/ListRowCell/ListRowCell.tsx +57 -0
- package/src/components/List/ListRow/ListRowCell/renderData.tsx +124 -0
- package/src/components/List/ListRow/Renderers/TagsRenderer/TagsRenderer.spec.tsx +191 -80
- package/src/components/List/ListRow/Renderers/TagsRenderer/TagsRenderer.tsx +63 -34
- package/src/components/Utils/Postgraphile/CreateConnectionRenderer.spec.ts +48 -12
- package/src/components/Utils/Postgraphile/CreateConnectionRenderer.tsx +5 -4
- package/src/helpers/idleCallbackHelpers.ts +66 -0
- package/src/helpers/index.ts +5 -0
- 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
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
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
|
-
|
|
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
|
+
}
|