@headless-adminapp/fluent 1.4.10 → 1.4.12
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/DataGrid/TableCell/TableCellBase.d.ts +2 -0
- package/DataGrid/TableCell/TableCellBase.js +2 -2
- package/DataGrid/TableCell/TableCellChoice.d.ts +3 -1
- package/DataGrid/TableCell/TableCellChoice.js +1 -1
- package/DataGrid/TableCell/TableCellLink.d.ts +3 -1
- package/DataGrid/TableCell/TableCellLink.js +2 -2
- package/DataGrid/TableCell/TableCellText.d.ts +3 -1
- package/DataGrid/TableCell/TableCellText.js +2 -2
- package/DataGrid/useTableColumns.d.ts +18 -0
- package/DataGrid/useTableColumns.js +27 -20
- package/Insights/Header.js +1 -1
- package/Insights/WidgetTableContainer.d.ts +7 -0
- package/Insights/WidgetTableContainer.js +62 -30
- package/Insights/WidgetTitleBar.d.ts +2 -1
- package/Insights/WidgetTitleBar.js +3 -3
- package/components/ChoiceBadge.js +4 -1
- package/package.json +2 -2
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { CSSProperties, FC, MouseEventHandler, ReactNode } from 'react';
|
|
2
|
+
export type CellDisplayType = 'flex' | 'table-cell';
|
|
2
3
|
export interface TableCellBaseProps {
|
|
3
4
|
children?: ReactNode;
|
|
4
5
|
onClick?: MouseEventHandler;
|
|
5
6
|
style?: CSSProperties;
|
|
7
|
+
display?: CellDisplayType;
|
|
6
8
|
}
|
|
7
9
|
export declare const TableCellBase: FC<TableCellBaseProps>;
|
|
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.TableCellBase = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_components_1 = require("@fluentui/react-components");
|
|
6
|
-
const TableCellBase = ({ children, onClick, style, }) => {
|
|
6
|
+
const TableCellBase = ({ children, onClick, style, display = 'flex', }) => {
|
|
7
7
|
return ((0, jsx_runtime_1.jsx)(react_components_1.TableCell, { onClick: onClick, style: {
|
|
8
|
-
display
|
|
8
|
+
display,
|
|
9
9
|
alignItems: 'center',
|
|
10
10
|
height: '100%',
|
|
11
11
|
// borderBottom: `var(--strokeWidthThin) solid var(--colorNeutralStroke2)`,
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { ChoiceAttribute } from '@headless-adminapp/core/attributes';
|
|
2
|
+
import { CellDisplayType } from './TableCellBase';
|
|
2
3
|
interface TableCellChoiceProps {
|
|
3
4
|
value: unknown;
|
|
4
5
|
attribute: ChoiceAttribute<string | number>;
|
|
5
6
|
formattedValue: string;
|
|
6
|
-
width
|
|
7
|
+
width?: number;
|
|
8
|
+
display?: CellDisplayType;
|
|
7
9
|
}
|
|
8
10
|
export declare function TableCellChoice(props: Readonly<TableCellChoiceProps>): import("react/jsx-runtime").JSX.Element;
|
|
9
11
|
export {};
|
|
@@ -12,5 +12,5 @@ function TableCellChoice(props) {
|
|
|
12
12
|
width: props.width,
|
|
13
13
|
minWidth: props.width,
|
|
14
14
|
maxWidth: props.width,
|
|
15
|
-
}, children: (0, jsx_runtime_1.jsx)(ChoiceBadge_1.ChoiceBadge, { attribute: props.attribute, formattedValue: props.formattedValue, value: props.value }) }));
|
|
15
|
+
}, display: props.display, children: (0, jsx_runtime_1.jsx)(ChoiceBadge_1.ChoiceBadge, { attribute: props.attribute, formattedValue: props.formattedValue, value: props.value }) }));
|
|
16
16
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
|
+
import { CellDisplayType } from './TableCellBase';
|
|
2
3
|
export interface TableCellLinkProps {
|
|
3
4
|
value: React.ReactNode | undefined | null;
|
|
4
5
|
href?: string;
|
|
5
6
|
onClick?: () => void;
|
|
6
|
-
width
|
|
7
|
+
width?: number;
|
|
7
8
|
target?: string;
|
|
9
|
+
display?: CellDisplayType;
|
|
8
10
|
}
|
|
9
11
|
export declare const TableCellLink: FC<TableCellLinkProps>;
|
|
@@ -5,7 +5,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
5
5
|
const react_components_1 = require("@fluentui/react-components");
|
|
6
6
|
const hooks_1 = require("@headless-adminapp/app/route/hooks");
|
|
7
7
|
const react_1 = require("react");
|
|
8
|
-
exports.TableCellLink = (0, react_1.memo)(({ value, href, onClick, width, target }) => {
|
|
8
|
+
exports.TableCellLink = (0, react_1.memo)(({ value, href, onClick, width, target, display = 'flex' }) => {
|
|
9
9
|
const router = (0, hooks_1.useRouter)();
|
|
10
10
|
return ((0, jsx_runtime_1.jsx)(react_components_1.TableCell, { style: {
|
|
11
11
|
textOverflow: 'ellipsis',
|
|
@@ -14,7 +14,7 @@ exports.TableCellLink = (0, react_1.memo)(({ value, href, onClick, width, target
|
|
|
14
14
|
width,
|
|
15
15
|
minWidth: width,
|
|
16
16
|
maxWidth: width,
|
|
17
|
-
display
|
|
17
|
+
display,
|
|
18
18
|
alignItems: 'center',
|
|
19
19
|
height: '100%',
|
|
20
20
|
}, children: (0, jsx_runtime_1.jsx)(react_components_1.Link, { as: "a", href: href, target: target, onClick: (event) => {
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
|
+
import { CellDisplayType } from './TableCellBase';
|
|
2
3
|
export interface TableCellTextProps {
|
|
3
4
|
value: string;
|
|
4
|
-
width
|
|
5
|
+
width?: number;
|
|
5
6
|
textAlignment?: 'left' | 'center' | 'right';
|
|
7
|
+
display?: CellDisplayType;
|
|
6
8
|
}
|
|
7
9
|
export declare const TableCellText: FC<TableCellTextProps>;
|
|
@@ -4,8 +4,8 @@ exports.TableCellText = void 0;
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const TableCellBase_1 = require("./TableCellBase");
|
|
7
|
-
exports.TableCellText = (0, react_1.memo)(({ value, width, textAlignment }) => {
|
|
8
|
-
return ((0, jsx_runtime_1.jsx)(TableCellBase_1.TableCellBase, { style: {
|
|
7
|
+
exports.TableCellText = (0, react_1.memo)(({ value, width, textAlignment, display }) => {
|
|
8
|
+
return ((0, jsx_runtime_1.jsx)(TableCellBase_1.TableCellBase, { display: display, style: {
|
|
9
9
|
textAlign: textAlignment ?? 'left',
|
|
10
10
|
textOverflow: 'ellipsis',
|
|
11
11
|
overflow: 'hidden',
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
import { TransformedViewColumn } from '@headless-adminapp/app/datagrid';
|
|
2
|
+
import { InternalRouteResolver, RouterInstance } from '@headless-adminapp/app/route/context';
|
|
3
|
+
import { LookupAttribute } from '@headless-adminapp/core/attributes';
|
|
4
|
+
import { SchemaAttributes } from '@headless-adminapp/core/schema';
|
|
5
|
+
import { ISchemaStore } from '@headless-adminapp/core/store';
|
|
6
|
+
import { CellContext } from '@tanstack/react-table';
|
|
7
|
+
import { CellDisplayType } from './TableCell';
|
|
1
8
|
import { UniqueRecord } from './types';
|
|
2
9
|
export declare function useTableColumns({ disableSelection, disableContextMenu, disableColumnResize, disableColumnFilter, disableColumnSort, tableWrapperRef, }: {
|
|
3
10
|
disableSelection?: boolean;
|
|
@@ -7,3 +14,14 @@ export declare function useTableColumns({ disableSelection, disableContextMenu,
|
|
|
7
14
|
disableColumnSort?: boolean;
|
|
8
15
|
tableWrapperRef: React.RefObject<HTMLDivElement>;
|
|
9
16
|
}): import("@tanstack/react-table").AccessorFnColumnDef<UniqueRecord, unknown>[];
|
|
17
|
+
export declare function renderLookupAttribute({ value, info, column, schemaStore, routeResolver, router, attribute, formattedValue, display, }: {
|
|
18
|
+
value: unknown;
|
|
19
|
+
info?: CellContext<UniqueRecord, unknown>;
|
|
20
|
+
column?: TransformedViewColumn<SchemaAttributes>;
|
|
21
|
+
schemaStore: ISchemaStore;
|
|
22
|
+
routeResolver: InternalRouteResolver;
|
|
23
|
+
router: RouterInstance;
|
|
24
|
+
attribute: LookupAttribute;
|
|
25
|
+
formattedValue: string;
|
|
26
|
+
display?: CellDisplayType;
|
|
27
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useTableColumns = useTableColumns;
|
|
4
|
+
exports.renderLookupAttribute = renderLookupAttribute;
|
|
4
5
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
6
|
const react_components_1 = require("@fluentui/react-components");
|
|
6
7
|
const datagrid_1 = require("@headless-adminapp/app/datagrid");
|
|
@@ -218,12 +219,15 @@ function useTableColumns({ disableSelection, disableContextMenu, disableColumnRe
|
|
|
218
219
|
cell: (info) => renderCellContent({
|
|
219
220
|
info,
|
|
220
221
|
column,
|
|
221
|
-
schema,
|
|
222
|
+
attributes: schema.attributes,
|
|
222
223
|
locale,
|
|
223
224
|
schemaStore,
|
|
224
225
|
routeResolver,
|
|
225
226
|
openRecord,
|
|
226
227
|
router,
|
|
228
|
+
primaryAttributeName: schema.primaryAttribute,
|
|
229
|
+
idAttributeName: schema.idAttribute,
|
|
230
|
+
avatarAttributeName: schema.avatarAttribute,
|
|
227
231
|
}),
|
|
228
232
|
enableResizing: true,
|
|
229
233
|
size: columnWidths[index],
|
|
@@ -252,19 +256,19 @@ function useTableColumns({ disableSelection, disableContextMenu, disableColumnRe
|
|
|
252
256
|
function renderCellHeaderContent({ column, props, disableColumnResize, disableColumnFilter, disableColumnSort, onChangeSortDirection, }) {
|
|
253
257
|
return ((0, jsx_runtime_1.jsx)(GridColumnHeader_1.TableHeaderFilterCell, { sortDirection: props.column.getIsSorted(), minWidth: props.header.getSize(), column: column, resizable: !disableColumnResize, disableFilter: disableColumnFilter, disableSort: disableColumnSort, onChangeSortDirection: onChangeSortDirection, onResetSize: props.column.resetSize, resizeHandler: props.header.getResizeHandler(), children: column.label }, column.id));
|
|
254
258
|
}
|
|
255
|
-
function renderCellContent({ info, column,
|
|
259
|
+
function renderCellContent({ info, column, attributes, schemaStore, locale, routeResolver, openRecord, router, primaryAttributeName, idAttributeName, avatarAttributeName, }) {
|
|
256
260
|
let attribute;
|
|
257
261
|
let value;
|
|
258
262
|
if (column.expandedKey) {
|
|
259
263
|
const lookup = column.name;
|
|
260
264
|
const field = column.expandedKey;
|
|
261
|
-
const entity =
|
|
265
|
+
const entity = attributes[lookup].entity;
|
|
262
266
|
const lookupSchema = schemaStore.getSchema(entity);
|
|
263
267
|
attribute = lookupSchema.attributes[field];
|
|
264
268
|
value = info.row.original.$expand?.[lookup]?.[field];
|
|
265
269
|
}
|
|
266
270
|
else {
|
|
267
|
-
attribute =
|
|
271
|
+
attribute = attributes[column.name];
|
|
268
272
|
value = info.getValue();
|
|
269
273
|
}
|
|
270
274
|
const formattedValue = (0, utils_1.getAttributeFormattedValue)(attribute, value, locale) ?? '';
|
|
@@ -287,15 +291,17 @@ function renderCellContent({ info, column, schema, schemaStore, locale, routeRes
|
|
|
287
291
|
if (!Component) {
|
|
288
292
|
throw new Error(`Component with name ${column.component} not found`);
|
|
289
293
|
}
|
|
290
|
-
return ((0, jsx_runtime_1.jsx)(Component, { column: column,
|
|
294
|
+
return ((0, jsx_runtime_1.jsx)(Component, { column: column, record: info.row.original, value: value, attribute: attribute, formattedValue: formattedValue, width: info.column.getSize() }));
|
|
291
295
|
}
|
|
292
|
-
if (
|
|
296
|
+
if (idAttributeName && primaryAttributeName === column.name) {
|
|
293
297
|
return renderPrimaryAttribute({
|
|
294
298
|
info,
|
|
295
299
|
column,
|
|
296
300
|
routeResolver,
|
|
297
301
|
openRecord,
|
|
298
|
-
|
|
302
|
+
attributes,
|
|
303
|
+
idAttributeName,
|
|
304
|
+
avatarAttributeName,
|
|
299
305
|
value: value,
|
|
300
306
|
});
|
|
301
307
|
}
|
|
@@ -354,29 +360,30 @@ function renderCellContent({ info, column, schema, schemaStore, locale, routeRes
|
|
|
354
360
|
}
|
|
355
361
|
return ((0, jsx_runtime_1.jsx)(TableCell_1.TableCellText, { value: formattedValue, width: info.column.getSize() }, column.id));
|
|
356
362
|
}
|
|
357
|
-
function renderPrimaryAttribute({ info, column,
|
|
363
|
+
function renderPrimaryAttribute({ info, column, attributes, routeResolver, openRecord, value, idAttributeName, avatarAttributeName, }) {
|
|
358
364
|
const path = routeResolver({
|
|
359
365
|
logicalName: info.row.original.$entity,
|
|
360
366
|
type: app_1.PageType.EntityForm,
|
|
361
|
-
id: info.row.original[
|
|
367
|
+
id: info.row.original[idAttributeName],
|
|
362
368
|
});
|
|
363
369
|
return ((0, jsx_runtime_1.jsx)(TableCellLink_1.TableCellLink, { value: (0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [renderPrimaryAttributeAvatar({
|
|
364
370
|
info,
|
|
365
|
-
schema,
|
|
366
371
|
value,
|
|
372
|
+
avatarAttributeName,
|
|
373
|
+
attributes,
|
|
367
374
|
}), value] }), width: info.column.getSize(), href: path, onClick: () => {
|
|
368
|
-
openRecord(info.row.original[
|
|
375
|
+
openRecord?.(info.row.original[idAttributeName], info.row.original.$entity);
|
|
369
376
|
} }, column.id));
|
|
370
377
|
}
|
|
371
|
-
function renderPrimaryAttributeAvatar({ info,
|
|
372
|
-
if (!
|
|
378
|
+
function renderPrimaryAttributeAvatar({ info, value, avatarAttributeName, attributes, }) {
|
|
379
|
+
if (!avatarAttributeName) {
|
|
373
380
|
return null;
|
|
374
381
|
}
|
|
375
|
-
const avatarAttribute =
|
|
382
|
+
const avatarAttribute = attributes[avatarAttributeName];
|
|
376
383
|
if (avatarAttribute.type !== 'attachment') {
|
|
377
384
|
return null;
|
|
378
385
|
}
|
|
379
|
-
const avatarValue = info.row.original[
|
|
386
|
+
const avatarValue = info.row.original[avatarAttributeName];
|
|
380
387
|
return ((0, jsx_runtime_1.jsx)(react_components_1.Avatar, { style: {
|
|
381
388
|
width: 24,
|
|
382
389
|
height: 24,
|
|
@@ -385,9 +392,9 @@ function renderPrimaryAttributeAvatar({ info, schema, value, }) {
|
|
|
385
392
|
src: avatarValue?.url,
|
|
386
393
|
} }));
|
|
387
394
|
}
|
|
388
|
-
function renderLookupAttribute({ value, info, column, schemaStore, routeResolver, router, attribute, formattedValue, }) {
|
|
395
|
+
function renderLookupAttribute({ value, info, column, schemaStore, routeResolver, router, attribute, formattedValue, display, }) {
|
|
389
396
|
if (!value) {
|
|
390
|
-
return ((0, jsx_runtime_1.jsx)(TableCell_1.TableCellText, { value: "", width: info
|
|
397
|
+
return ((0, jsx_runtime_1.jsx)(TableCell_1.TableCellText, { value: "", width: info?.column.getSize(), display: display }, column?.id));
|
|
391
398
|
}
|
|
392
399
|
const lookupSchema = schemaStore.getSchema(attribute.entity);
|
|
393
400
|
const path = routeResolver({
|
|
@@ -395,15 +402,15 @@ function renderLookupAttribute({ value, info, column, schemaStore, routeResolver
|
|
|
395
402
|
type: app_1.PageType.EntityForm,
|
|
396
403
|
id: value.id,
|
|
397
404
|
});
|
|
398
|
-
return ((0, jsx_runtime_1.jsx)(TableCellLink_1.TableCellLink, { value: (0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [!!lookupSchema.avatarAttribute && ((0, jsx_runtime_1.jsx)(react_components_1.Avatar, { style: {
|
|
405
|
+
return ((0, jsx_runtime_1.jsx)(TableCellLink_1.TableCellLink, { display: display, value: (0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [!!lookupSchema.avatarAttribute && ((0, jsx_runtime_1.jsx)(react_components_1.Avatar, { style: {
|
|
399
406
|
width: 24,
|
|
400
407
|
height: 24,
|
|
401
408
|
fontSize: react_components_1.tokens.fontSizeBase100,
|
|
402
409
|
}, name: formattedValue, color: (0, avatar_1.getAvatarColor)(formattedValue), image: {
|
|
403
410
|
src: value.avatar,
|
|
404
|
-
} })), formattedValue] }), width: info
|
|
411
|
+
} })), formattedValue] }), width: info?.column.getSize(), href: path, onClick: () => {
|
|
405
412
|
router.push(path);
|
|
406
|
-
} }, column
|
|
413
|
+
} }, column?.id));
|
|
407
414
|
}
|
|
408
415
|
function renderRegardingAttribute({ value, info, column, schemaStore, routeResolver, router, formattedValue, }) {
|
|
409
416
|
if (!value) {
|
package/Insights/Header.js
CHANGED
|
@@ -35,7 +35,7 @@ const Header = () => {
|
|
|
35
35
|
display: 'flex',
|
|
36
36
|
alignItems: 'center',
|
|
37
37
|
gap: react_components_1.tokens.spacingHorizontalM,
|
|
38
|
-
}, children: [(0, jsx_runtime_1.jsx)("div", { style: { flex: 1 }, children: (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'column' }, children: [(0, jsx_runtime_1.jsx)(react_components_1.Subtitle2, { style: { color: react_components_1.tokens.colorNeutralForeground1 }, children:
|
|
38
|
+
}, children: [(0, jsx_runtime_1.jsx)("div", { style: { flex: 1 }, children: (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'column' }, children: [(0, jsx_runtime_1.jsx)(react_components_1.Subtitle2, { style: { color: react_components_1.tokens.colorNeutralForeground1 }, children: config.title }), (0, jsx_runtime_1.jsx)(react_components_1.Caption1, { style: { color: react_components_1.tokens.colorNeutralForeground2 }, children: config.subtitle })] }) }) }), (0, jsx_runtime_1.jsx)("div", { style: {
|
|
39
39
|
display: 'flex',
|
|
40
40
|
alignItems: 'center',
|
|
41
41
|
gap: react_components_1.tokens.spacingHorizontalS,
|
|
@@ -8,7 +8,14 @@ interface WidgetTableContainerProps {
|
|
|
8
8
|
isPending?: boolean;
|
|
9
9
|
isFetching?: boolean;
|
|
10
10
|
commands?: CommandItemState[][];
|
|
11
|
+
headerRightContent?: React.ReactNode;
|
|
11
12
|
data: any[];
|
|
12
13
|
}
|
|
13
14
|
export declare const WidgetTableContainer: FC<WidgetTableContainerProps>;
|
|
15
|
+
interface WidgetTableProps {
|
|
16
|
+
columns: string[];
|
|
17
|
+
attributes: Record<string, Attribute>;
|
|
18
|
+
data: any[];
|
|
19
|
+
}
|
|
20
|
+
export declare const WidgetTable: FC<WidgetTableProps>;
|
|
14
21
|
export {};
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WidgetTableContainer = void 0;
|
|
3
|
+
exports.WidgetTable = exports.WidgetTableContainer = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_components_1 = require("@fluentui/react-components");
|
|
6
6
|
const locale_1 = require("@headless-adminapp/app/locale");
|
|
7
|
+
const metadata_1 = require("@headless-adminapp/app/metadata");
|
|
8
|
+
const route_1 = require("@headless-adminapp/app/route");
|
|
7
9
|
const utils_1 = require("@headless-adminapp/app/utils");
|
|
8
10
|
const BodyLoading_1 = require("../components/BodyLoading");
|
|
11
|
+
const TableCell_1 = require("../DataGrid/TableCell");
|
|
12
|
+
const TableCellChoice_1 = require("../DataGrid/TableCell/TableCellChoice");
|
|
13
|
+
const TableCellLink_1 = require("../DataGrid/TableCell/TableCellLink");
|
|
14
|
+
const useTableColumns_1 = require("../DataGrid/useTableColumns");
|
|
9
15
|
const WidgetSection_1 = require("./WidgetSection");
|
|
10
16
|
const WidgetTitleBar_1 = require("./WidgetTitleBar");
|
|
11
17
|
const useStyles = (0, react_components_1.makeStyles)({
|
|
@@ -35,35 +41,61 @@ const useStyles = (0, react_components_1.makeStyles)({
|
|
|
35
41
|
},
|
|
36
42
|
},
|
|
37
43
|
});
|
|
38
|
-
const WidgetTableContainer = ({ title, columns, attributes, isPending, isFetching, commands, data, }) => {
|
|
44
|
+
const WidgetTableContainer = ({ title, columns, attributes, isPending, isFetching, commands, headerRightContent, data, }) => {
|
|
45
|
+
return ((0, jsx_runtime_1.jsxs)(WidgetSection_1.WidgetSection, { children: [(0, jsx_runtime_1.jsx)(WidgetTitleBar_1.WidgetTitleBar, { title: title, commands: commands, rightContent: headerRightContent }), (0, jsx_runtime_1.jsxs)("div", { style: { flex: 1, position: 'relative', overflow: 'auto' }, children: [!isPending && ((0, jsx_runtime_1.jsx)(exports.WidgetTable, { columns: columns, attributes: attributes, data: data })), (0, jsx_runtime_1.jsx)(BodyLoading_1.BodyLoading, { loading: isFetching })] })] }));
|
|
46
|
+
};
|
|
47
|
+
exports.WidgetTableContainer = WidgetTableContainer;
|
|
48
|
+
const WidgetTable = ({ columns, attributes, data, }) => {
|
|
39
49
|
const locale = (0, locale_1.useLocale)();
|
|
40
50
|
const styles = useStyles();
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
51
|
+
const router = (0, route_1.useRouter)();
|
|
52
|
+
const routeResolver = (0, route_1.useRouteResolver)();
|
|
53
|
+
const { schemaStore } = (0, metadata_1.useMetadata)();
|
|
54
|
+
return ((0, jsx_runtime_1.jsxs)(react_components_1.Table, { className: styles.table, children: [(0, jsx_runtime_1.jsx)(react_components_1.TableHeader, { style: {
|
|
55
|
+
position: 'sticky',
|
|
56
|
+
top: 0,
|
|
57
|
+
background: react_components_1.tokens.colorNeutralBackground3,
|
|
58
|
+
zIndex: 2,
|
|
59
|
+
}, children: (0, jsx_runtime_1.jsx)(react_components_1.TableRow, { style: {
|
|
60
|
+
position: 'sticky',
|
|
61
|
+
top: 0,
|
|
62
|
+
minWidth: 'calc(100% - 16px)',
|
|
63
|
+
}, children: columns.map((column, index) => {
|
|
64
|
+
const attribute = attributes[column];
|
|
65
|
+
return ((0, jsx_runtime_1.jsx)(react_components_1.TableHeaderCell, { align: "right", className: attribute?.type === 'money' ? styles.headerAlignRight : '', children: attribute.label }, column + String(index)));
|
|
66
|
+
}) }) }), (0, jsx_runtime_1.jsx)(react_components_1.TableBody, { children: data.map((row, index) => ((0, jsx_runtime_1.jsx)(react_components_1.TableRow, { children: columns.map((column) => {
|
|
67
|
+
const attribute = attributes[column];
|
|
68
|
+
const value = row[column];
|
|
69
|
+
const formattedValue = (0, utils_1.getAttributeFormattedValue)(attribute, value, locale) ?? '';
|
|
70
|
+
switch (attribute?.type) {
|
|
71
|
+
case 'money':
|
|
72
|
+
return ((0, jsx_runtime_1.jsx)(react_components_1.TableCell, { style: { textAlign: 'right' }, children: formattedValue }, column));
|
|
73
|
+
case 'lookup':
|
|
74
|
+
return (0, useTableColumns_1.renderLookupAttribute)({
|
|
75
|
+
column: {
|
|
76
|
+
id: column,
|
|
77
|
+
label: attribute.label,
|
|
78
|
+
name: column,
|
|
79
|
+
},
|
|
80
|
+
value,
|
|
81
|
+
attribute,
|
|
82
|
+
router,
|
|
83
|
+
routeResolver,
|
|
84
|
+
schemaStore,
|
|
85
|
+
formattedValue,
|
|
86
|
+
display: 'table-cell',
|
|
87
|
+
});
|
|
88
|
+
case 'choice':
|
|
89
|
+
return ((0, jsx_runtime_1.jsx)(TableCellChoice_1.TableCellChoice, { value: value, attribute: attribute, formattedValue: formattedValue, display: "table-cell" }, column));
|
|
90
|
+
case 'attachment': {
|
|
91
|
+
const url = value?.url;
|
|
92
|
+
if (!url) {
|
|
93
|
+
return (0, jsx_runtime_1.jsx)(TableCell_1.TableCellText, { value: "" }, column);
|
|
94
|
+
}
|
|
95
|
+
return ((0, jsx_runtime_1.jsx)(TableCellLink_1.TableCellLink, { value: formattedValue, href: url, target: "_blank", display: "table-cell" }, column));
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return (0, jsx_runtime_1.jsx)(react_components_1.TableCell, { children: formattedValue }, column);
|
|
99
|
+
}) }, index))) })] }));
|
|
68
100
|
};
|
|
69
|
-
exports.
|
|
101
|
+
exports.WidgetTable = WidgetTable;
|
|
@@ -2,6 +2,7 @@ import { CommandItemState } from '@headless-adminapp/app/command';
|
|
|
2
2
|
interface WidgetTitleBarProps {
|
|
3
3
|
title: string;
|
|
4
4
|
commands?: CommandItemState[][];
|
|
5
|
+
rightContent?: React.ReactNode;
|
|
5
6
|
}
|
|
6
|
-
export declare function WidgetTitleBar({ title, commands, }: Readonly<WidgetTitleBarProps>): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare function WidgetTitleBar({ title, commands, rightContent, }: Readonly<WidgetTitleBarProps>): import("react/jsx-runtime").JSX.Element;
|
|
7
8
|
export {};
|
|
@@ -9,13 +9,13 @@ const react_components_1 = require("@fluentui/react-components");
|
|
|
9
9
|
const locale_1 = require("@headless-adminapp/app/locale");
|
|
10
10
|
const CommandBar_1 = __importDefault(require("../CommandBar"));
|
|
11
11
|
const OverflowCommandBar_1 = require("../OverflowCommandBar");
|
|
12
|
-
function WidgetTitleBar({ title, commands, }) {
|
|
12
|
+
function WidgetTitleBar({ title, commands, rightContent, }) {
|
|
13
13
|
const { language } = (0, locale_1.useLocale)();
|
|
14
14
|
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { style: {
|
|
15
15
|
display: 'flex',
|
|
16
|
-
|
|
16
|
+
paddingLeft: 16,
|
|
17
17
|
paddingBlock: 8,
|
|
18
18
|
height: 40,
|
|
19
19
|
alignItems: 'center',
|
|
20
|
-
}, children: (0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', alignItems: 'center', width: '100%' }, children: [(0, jsx_runtime_1.jsx)(react_components_1.Body1Strong, { children: title }), (0, jsx_runtime_1.jsx)("div", { style: { flex: 1 } }), !!commands && commands[0]?.length > 0 && ((0, jsx_runtime_1.jsx)(
|
|
20
|
+
}, children: (0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', alignItems: 'center', width: '100%' }, children: [(0, jsx_runtime_1.jsx)(react_components_1.Body1Strong, { children: title }), (0, jsx_runtime_1.jsx)("div", { style: { flex: 1 } }), rightContent, !!commands && commands[0]?.length > 0 && ((0, jsx_runtime_1.jsx)(CommandBar_1.default.Wrapper, { children: commands[0].map((command, index) => (0, OverflowCommandBar_1.renderCommandItem)(index, command, language)) }))] }) }), (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(react_components_1.Divider, { style: { opacity: 0.2 } }) })] }));
|
|
21
21
|
}
|
|
@@ -38,5 +38,8 @@ function ChoiceBadge(props) {
|
|
|
38
38
|
backgroundColor: bgColor ?? react_components_1.tokens.colorNeutralBackground3,
|
|
39
39
|
color: color ?? react_components_1.tokens.colorNeutralForeground2,
|
|
40
40
|
fontWeight: react_components_1.tokens.fontWeightRegular,
|
|
41
|
-
|
|
41
|
+
minWidth: 'unset',
|
|
42
|
+
maxWidth: 'max-content',
|
|
43
|
+
width: '100%',
|
|
44
|
+
}, size: props.size, children: (0, jsx_runtime_1.jsx)("div", { style: { textOverflow: 'ellipsis', overflow: 'hidden' }, children: formattedValue }) }));
|
|
42
45
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@headless-adminapp/fluent",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.12",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -52,5 +52,5 @@
|
|
|
52
52
|
"uuid": "11.0.3",
|
|
53
53
|
"yup": "^1.4.0"
|
|
54
54
|
},
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "ff83d8ca2e616d6125781975cfc1dde6a1fc05c3"
|
|
56
56
|
}
|