@headless-adminapp/fluent 0.0.17-alpha.52 → 0.0.17-alpha.53
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/App/App.js +7 -11
- package/App/AppHeaderContianer.js +38 -42
- package/App/AppLogo.js +8 -12
- package/App/AppStringContext.js +9 -13
- package/App/AppUI.js +11 -15
- package/App/LayoutProvider.js +11 -15
- package/App/NavigationContainer.js +25 -29
- package/App/QuickActionItem.js +5 -9
- package/App/index.js +1 -5
- package/App/utils.js +1 -4
- package/CommandBar/Button.js +14 -17
- package/CommandBar/Divider.js +6 -9
- package/CommandBar/IconButton.js +13 -16
- package/CommandBar/Label.js +8 -11
- package/CommandBar/MenuButton.js +17 -20
- package/CommandBar/MenuItem.js +15 -18
- package/CommandBar/MenuItems.js +8 -11
- package/CommandBar/MenuList.js +9 -12
- package/CommandBar/Wrapper.js +7 -10
- package/CommandBar/index.js +13 -15
- package/DataForm/SectionControl.js +4 -7
- package/DataGrid/ActionCell.js +11 -14
- package/DataGrid/CommandContainer.js +6 -10
- package/DataGrid/CustomizeColumns/AddColumns.js +34 -37
- package/DataGrid/CustomizeColumns/ColumnItem.js +19 -23
- package/DataGrid/CustomizeColumns/CustomizeColumns.js +36 -42
- package/DataGrid/CustomizeColumns/index.js +1 -5
- package/DataGrid/FormSubgridCommandContainer.js +13 -17
- package/DataGrid/FormSubgridViewSelector.js +18 -22
- package/DataGrid/GridColumnHeader/ConditionValueControl.js +14 -20
- package/DataGrid/GridColumnHeader/FilterForm.js +23 -27
- package/DataGrid/GridColumnHeader/OperatorSelect.js +13 -19
- package/DataGrid/GridColumnHeader/TableHeaderFilterCell.js +28 -32
- package/DataGrid/GridColumnHeader/index.js +1 -5
- package/DataGrid/GridColumnHeader/utils.js +2 -6
- package/DataGrid/GridHeaderContainer.js +4 -8
- package/DataGrid/GridHeaderDesktop.js +26 -30
- package/DataGrid/GridHeaderMobile.js +17 -21
- package/DataGrid/GridListContainer.js +39 -43
- package/DataGrid/GridPaginationContainer.js +12 -16
- package/DataGrid/GridTableContainer.js +74 -78
- package/DataGrid/TableCell/TableCellAction.js +11 -15
- package/DataGrid/TableCell/TableCellBase.js +4 -8
- package/DataGrid/TableCell/TableCellCheckbox.js +7 -10
- package/DataGrid/TableCell/TableCellChoice.js +11 -14
- package/DataGrid/TableCell/TableCellLink.d.ts +1 -1
- package/DataGrid/TableCell/TableCellLink.js +13 -12
- package/DataGrid/TableCell/TableCellText.js +7 -10
- package/DataGrid/TableCell/index.js +4 -20
- package/DataGrid/index.js +4 -11
- package/DataGrid/types.js +1 -2
- package/DataGrid/useTableColumns.js +139 -90
- package/DataGrid/utils.js +1 -5
- package/DialogContainer/AlertDialog.js +5 -8
- package/DialogContainer/ConfirmDialog.js +6 -9
- package/DialogContainer/DialogContainer.js +14 -18
- package/DialogContainer/ErrorDialog.js +9 -12
- package/DialogContainer/PromptDialog.js +30 -57
- package/DialogContainer/index.js +1 -5
- package/Insights/CommandBarContainer.js +11 -14
- package/Insights/FilterBarContainer.js +17 -20
- package/Insights/Grid.js +9 -13
- package/Insights/InsightsContainer.js +19 -22
- package/Insights/WidgetChartContainer.js +30 -34
- package/Insights/WidgetDataGridContainer.js +32 -35
- package/Insights/WidgetTableContainer.js +24 -28
- package/Insights/WidgetTileContainer.js +12 -16
- package/Insights/WidgetTitleBar.js +9 -15
- package/Insights/Widgets.js +25 -28
- package/Insights/charts/AreaChart.js +12 -15
- package/Insights/charts/BarChart.js +12 -15
- package/Insights/charts/ComposedChart.js +12 -15
- package/Insights/charts/CustomTooltipContent.js +8 -12
- package/Insights/charts/GaugeChart.js +3 -6
- package/Insights/charts/LineChart.js +12 -15
- package/Insights/charts/OhlcChart.js +36 -41
- package/Insights/charts/PieChart.js +23 -26
- package/Insights/charts/RadarChart.js +16 -19
- package/Insights/charts/ScatterChart.js +23 -26
- package/Insights/charts/constants.js +1 -4
- package/Insights/charts/formatters.js +17 -29
- package/Insights/charts/index.js +1 -2
- package/Insights/charts/renderers.js +25 -36
- package/Insights/hooks/useQueriesData.js +19 -25
- package/Insights/hooks/useWidgetDetail.js +13 -16
- package/OverflowCommandBar/OverflowCommandBar.js +12 -19
- package/OverflowCommandBar/OverflowMenu.js +16 -20
- package/OverflowCommandBar/OverflowMenuDivider.js +6 -10
- package/OverflowCommandBar/index.js +3 -9
- package/OverflowCommandBar/render.js +9 -15
- package/OverflowCommandBar/utils.js +1 -4
- package/PageBoard/BoardColumn.js +5 -8
- package/PageBoard/BoardColumnCard.js +12 -15
- package/PageBoard/BoardColumnUI.js +34 -38
- package/PageBoard/BoardingColumnCardLoading.js +10 -13
- package/PageBoard/Header.js +16 -20
- package/PageBoard/PageBoard.d.ts +1 -1
- package/PageBoard/PageBoard.js +26 -29
- package/PageBoard/index.js +1 -5
- package/PageEntityForm/CommandContainer.js +21 -25
- package/PageEntityForm/FormTabRelated.js +17 -20
- package/PageEntityForm/PageEntityForm.js +16 -20
- package/PageEntityForm/PageEntityFormDesktopContainer.js +68 -72
- package/PageEntityForm/PageEntityFormStringContext.js +5 -9
- package/PageEntityForm/ProcessFlow.js +21 -24
- package/PageEntityForm/RecordCard.js +21 -24
- package/PageEntityForm/RecordCardLoading.js +10 -13
- package/PageEntityForm/RecordSetNavigatorContainer.js +30 -34
- package/PageEntityForm/RelatedViewSelector.js +28 -31
- package/PageEntityForm/SectionContainer.js +25 -28
- package/PageEntityForm/StandardControl.d.ts +3 -3
- package/PageEntityForm/StandardControl.js +74 -81
- package/PageEntityForm/SubgridControl.js +20 -23
- package/PageEntityForm/index.js +1 -5
- package/PageEntityView/FormSubgridContainer.js +22 -26
- package/PageEntityView/PageEntityView.js +15 -19
- package/PageEntityView/PageEntityViewDesktopContainer.js +9 -13
- package/PageEntityView/PageEntityViewDesktopFrame.js +17 -21
- package/PageEntityView/PageEntityViewMobileContainer.js +9 -13
- package/PageEntityView/PageEntityViewStringContext.js +5 -9
- package/PageEntityView/index.js +1 -5
- package/PageInsights/PageInsights.js +9 -13
- package/PageInsights/index.js +1 -6
- package/ProgressIndicatorContainer/index.js +10 -14
- package/ToastNotificationContainer/index.js +14 -18
- package/componentStore.js +2 -5
- package/components/BodyLoading.js +7 -11
- package/components/DialogLogin.js +5 -8
- package/components/LoginForm.js +21 -47
- package/components/PageBroken.js +5 -8
- package/components/PageLoading.js +5 -8
- package/components/PageLogin.js +14 -17
- package/form/FormControl.js +39 -44
- package/form/FormControlLoading.js +4 -8
- package/form/controls/AttachmentControl.js +56 -60
- package/form/controls/AttachmentsControl.js +15 -19
- package/form/controls/CurrencyControl.js +10 -13
- package/form/controls/DateControl.js +18 -24
- package/form/controls/DateRangeControl.js +14 -20
- package/form/controls/DateTimeControl.js +39 -45
- package/form/controls/DecimalControl.js +8 -11
- package/form/controls/DurationControl.js +11 -15
- package/form/controls/EmailControl.js +7 -10
- package/form/controls/IntegerControl.js +4 -7
- package/form/controls/LookupControl.d.ts +1 -0
- package/form/controls/LookupControl.js +75 -38
- package/form/controls/MultiSelectControl.js +8 -11
- package/form/controls/MultiSelectLookupControl.js +40 -43
- package/form/controls/PasswordControl.js +8 -11
- package/form/controls/RichTextControl.js +5 -32
- package/form/controls/SelectControl.js +8 -11
- package/form/controls/SwitchControl.js +4 -7
- package/form/controls/TelephoneControl.js +7 -10
- package/form/controls/TextAreaControl.js +4 -7
- package/form/controls/TextControl.js +5 -8
- package/form/controls/UrlControl.js +7 -10
- package/form/controls/types.js +1 -2
- package/form/controls/useLookupData.js +14 -18
- package/form/layout/FormBody/FormBody.js +6 -10
- package/form/layout/FormBody/index.js +1 -17
- package/form/layout/FormSection/FormSection.js +18 -22
- package/form/layout/FormSection/FormSectionColumn.js +3 -7
- package/form/layout/FormSection/FormSectionLoading.js +1 -5
- package/form/layout/FormSection/index.js +1 -5
- package/form/layout/FormTab/FormTab.js +16 -20
- package/form/layout/FormTab/FormTabColumn.js +5 -9
- package/form/layout/FormTab/index.js +1 -5
- package/form/layout/TabContext.js +2 -5
- package/form/layout/index.js +3 -9
- package/form/types.js +1 -2
- package/package.json +3 -2
- package/types/index.js +1 -2
- package/utils/avatar.d.ts +2 -0
- package/utils/avatar.js +42 -0
|
@@ -1,63 +1,61 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
const columnHelper = (0, react_table_1.createColumnHelper)();
|
|
26
|
-
const useStyles = (0, react_components_1.makeStyles)({
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Avatar, makeStyles, mergeClasses, TableHeaderCell, TableSelectionCell, tokens, } from '@fluentui/react-components';
|
|
3
|
+
import { GridContext, } from '@headless-adminapp/app/datagrid';
|
|
4
|
+
import { useDataGridSchema, useGridColumns, useGridData, useGridSelection, useGridSorting, useMainGridContextCommands, useSubGridContextCommands, } from '@headless-adminapp/app/datagrid/hooks';
|
|
5
|
+
import { useOpenRecord } from '@headless-adminapp/app/datagrid/hooks/useOpenRecord';
|
|
6
|
+
import { useElementSize } from '@headless-adminapp/app/hooks';
|
|
7
|
+
import { useLocale } from '@headless-adminapp/app/locale';
|
|
8
|
+
import { useMetadata } from '@headless-adminapp/app/metadata/hooks';
|
|
9
|
+
import { useContextSelector, useMutableState, } from '@headless-adminapp/app/mutable';
|
|
10
|
+
import { useRecordSetSetter } from '@headless-adminapp/app/recordset/hooks';
|
|
11
|
+
import { useRouter, useRouteResolver, } from '@headless-adminapp/app/route/hooks';
|
|
12
|
+
import { calculateColumnWidths, getAttributeFormattedValue, } from '@headless-adminapp/app/utils';
|
|
13
|
+
import { PageType } from '@headless-adminapp/core/experience/app';
|
|
14
|
+
import { createColumnHelper, } from '@tanstack/react-table';
|
|
15
|
+
import { Fragment, useEffect, useMemo, useRef } from 'react';
|
|
16
|
+
import { componentStore } from '../componentStore';
|
|
17
|
+
import { TableHeaderFilterCell } from '../DataGrid/GridColumnHeader';
|
|
18
|
+
import { TableCellText } from '../DataGrid/TableCell';
|
|
19
|
+
import { TableCellLink } from '../DataGrid/TableCell/TableCellLink';
|
|
20
|
+
import { getAvatarColor } from '../utils/avatar';
|
|
21
|
+
import { ActionCell } from './ActionCell';
|
|
22
|
+
import { TableCellChoice } from './TableCell/TableCellChoice';
|
|
23
|
+
const columnHelper = createColumnHelper();
|
|
24
|
+
const useStyles = makeStyles({
|
|
27
25
|
selectionCell: {
|
|
28
26
|
position: 'sticky',
|
|
29
27
|
left: 0,
|
|
30
|
-
background:
|
|
28
|
+
background: tokens.colorNeutralBackground1,
|
|
31
29
|
zIndex: 1,
|
|
32
30
|
display: 'flex',
|
|
33
31
|
alignItems: 'center',
|
|
34
32
|
},
|
|
35
33
|
});
|
|
36
|
-
function useTableColumns({ disableSelection, disableContextMenu, disableColumnResize, disableColumnFilter, disableColumnSort, tableWrapperRef, }) {
|
|
34
|
+
export function useTableColumns({ disableSelection, disableContextMenu, disableColumnResize, disableColumnFilter, disableColumnSort, tableWrapperRef, }) {
|
|
37
35
|
const styles = useStyles();
|
|
38
|
-
const data =
|
|
39
|
-
const columns =
|
|
40
|
-
const [, setSorting] =
|
|
41
|
-
const schema =
|
|
42
|
-
const { schemaStore } =
|
|
43
|
-
const [selectedIds, setSelectedIds] =
|
|
44
|
-
const setSelectedIdsRef =
|
|
36
|
+
const data = useGridData();
|
|
37
|
+
const columns = useGridColumns();
|
|
38
|
+
const [, setSorting] = useGridSorting();
|
|
39
|
+
const schema = useDataGridSchema();
|
|
40
|
+
const { schemaStore } = useMetadata();
|
|
41
|
+
const [selectedIds, setSelectedIds] = useGridSelection();
|
|
42
|
+
const setSelectedIdsRef = useRef(setSelectedIds);
|
|
45
43
|
setSelectedIdsRef.current = setSelectedIds;
|
|
46
|
-
const isSubgrid =
|
|
44
|
+
const isSubgrid = useContextSelector(GridContext, (state) => state.isSubGrid);
|
|
47
45
|
const contextCommands = isSubgrid
|
|
48
46
|
? // eslint-disable-next-line react-hooks/rules-of-hooks
|
|
49
|
-
|
|
47
|
+
useSubGridContextCommands()
|
|
50
48
|
: // eslint-disable-next-line react-hooks/rules-of-hooks
|
|
51
|
-
|
|
52
|
-
const mutableContextCommandState =
|
|
53
|
-
|
|
49
|
+
useMainGridContextCommands();
|
|
50
|
+
const mutableContextCommandState = useMutableState(contextCommands, true);
|
|
51
|
+
useEffect(() => {
|
|
54
52
|
mutableContextCommandState.setValue(contextCommands);
|
|
55
53
|
}, [contextCommands, mutableContextCommandState]);
|
|
56
|
-
const tableWrapperSize =
|
|
57
|
-
const columnWidths =
|
|
54
|
+
const tableWrapperSize = useElementSize(tableWrapperRef, 100);
|
|
55
|
+
const columnWidths = useMemo(() => {
|
|
58
56
|
var _a;
|
|
59
57
|
const availableWidth = Math.max(0, ((_a = tableWrapperSize.width) !== null && _a !== void 0 ? _a : 0) - 32 - 32 - 16);
|
|
60
|
-
const { columns: calculatedColumns } =
|
|
58
|
+
const { columns: calculatedColumns } = calculateColumnWidths({
|
|
61
59
|
availableWidth,
|
|
62
60
|
gapWidth: 0,
|
|
63
61
|
columns: columns.map((column) => {
|
|
@@ -70,15 +68,15 @@ function useTableColumns({ disableSelection, disableContextMenu, disableColumnRe
|
|
|
70
68
|
});
|
|
71
69
|
return calculatedColumns;
|
|
72
70
|
}, [columns, tableWrapperSize.width]);
|
|
73
|
-
const gridColumns =
|
|
74
|
-
const routeResolver =
|
|
75
|
-
const router =
|
|
76
|
-
const recordSetSetter =
|
|
77
|
-
const openRecord =
|
|
78
|
-
const locale =
|
|
79
|
-
const dataRef =
|
|
71
|
+
const gridColumns = useGridColumns();
|
|
72
|
+
const routeResolver = useRouteResolver();
|
|
73
|
+
const router = useRouter();
|
|
74
|
+
const recordSetSetter = useRecordSetSetter();
|
|
75
|
+
const openRecord = useOpenRecord();
|
|
76
|
+
const locale = useLocale();
|
|
77
|
+
const dataRef = useRef(data);
|
|
80
78
|
dataRef.current = data;
|
|
81
|
-
const headingSelectionState =
|
|
79
|
+
const headingSelectionState = useMemo(() => {
|
|
82
80
|
var _a;
|
|
83
81
|
if ((data === null || data === void 0 ? void 0 : data.records.length) === 0) {
|
|
84
82
|
return false;
|
|
@@ -91,13 +89,13 @@ function useTableColumns({ disableSelection, disableContextMenu, disableColumnRe
|
|
|
91
89
|
}
|
|
92
90
|
return 'mixed';
|
|
93
91
|
}, [data === null || data === void 0 ? void 0 : data.records.length, selectedIds]);
|
|
94
|
-
const actionColumns =
|
|
92
|
+
const actionColumns = useMemo(() => {
|
|
95
93
|
if (disableContextMenu)
|
|
96
94
|
return [];
|
|
97
95
|
return [
|
|
98
96
|
columnHelper.accessor((info) => info[schema.idAttribute], {
|
|
99
97
|
id: '$actionColumn',
|
|
100
|
-
header: () => ((
|
|
98
|
+
header: () => (_jsx(TableHeaderCell, { style: {
|
|
101
99
|
minWidth: 32,
|
|
102
100
|
flexShrink: 0,
|
|
103
101
|
// width: 32,
|
|
@@ -107,10 +105,10 @@ function useTableColumns({ disableSelection, disableContextMenu, disableColumnRe
|
|
|
107
105
|
right: 0,
|
|
108
106
|
top: 0,
|
|
109
107
|
// zIndex: 1,
|
|
110
|
-
background:
|
|
111
|
-
borderBottom: `${
|
|
108
|
+
background: tokens.colorNeutralBackground1,
|
|
109
|
+
borderBottom: `${tokens.strokeWidthThin} solid ${tokens.colorNeutralStroke3}`,
|
|
112
110
|
}, children: "\u00A0" })),
|
|
113
|
-
cell: (info) => ((
|
|
111
|
+
cell: (info) => (_jsx(ActionCell, { onOpen: () => {
|
|
114
112
|
const id = info.row.original[schema.idAttribute];
|
|
115
113
|
setSelectedIdsRef.current([id]);
|
|
116
114
|
}, mutableState: mutableContextCommandState })),
|
|
@@ -121,7 +119,7 @@ function useTableColumns({ disableSelection, disableContextMenu, disableColumnRe
|
|
|
121
119
|
}),
|
|
122
120
|
];
|
|
123
121
|
}, [disableContextMenu, mutableContextCommandState, schema.idAttribute]);
|
|
124
|
-
const selectionColumns =
|
|
122
|
+
const selectionColumns = useMemo(() => {
|
|
125
123
|
if (disableSelection)
|
|
126
124
|
return [];
|
|
127
125
|
function getAllIds() {
|
|
@@ -152,18 +150,18 @@ function useTableColumns({ disableSelection, disableContextMenu, disableColumnRe
|
|
|
152
150
|
return [
|
|
153
151
|
columnHelper.accessor((info) => info[schema.idAttribute], {
|
|
154
152
|
id: '$selectColumn',
|
|
155
|
-
header: () => ((
|
|
153
|
+
header: () => (_jsx(TableSelectionCell, { checked: headingSelectionState, as: 'th', style: {
|
|
156
154
|
position: 'sticky',
|
|
157
155
|
display: 'flex',
|
|
158
156
|
left: 0,
|
|
159
157
|
top: 0,
|
|
160
|
-
background:
|
|
158
|
+
background: tokens.colorNeutralBackground1,
|
|
161
159
|
zIndex: 1,
|
|
162
160
|
width: 32,
|
|
163
161
|
maxWidth: 32,
|
|
164
162
|
minWidth: 32,
|
|
165
163
|
}, onClick: toggleAllSelectedIds })),
|
|
166
|
-
cell: (info) => ((
|
|
164
|
+
cell: (info) => (_jsx(TableSelectionCell, { className: mergeClasses(styles.selectionCell), checked: info.row.getIsSelected(), onClick: (event) => {
|
|
167
165
|
event.preventDefault();
|
|
168
166
|
event.stopPropagation();
|
|
169
167
|
toggleSelectedId(info);
|
|
@@ -184,7 +182,7 @@ function useTableColumns({ disableSelection, disableContextMenu, disableColumnRe
|
|
|
184
182
|
schema.idAttribute,
|
|
185
183
|
styles.selectionCell,
|
|
186
184
|
]);
|
|
187
|
-
const restColumns =
|
|
185
|
+
const restColumns = useMemo(() => {
|
|
188
186
|
return gridColumns.map((column, index) => {
|
|
189
187
|
function onChangeSortDirection(direction) {
|
|
190
188
|
setSorting([
|
|
@@ -239,12 +237,12 @@ function useTableColumns({ disableSelection, disableContextMenu, disableColumnRe
|
|
|
239
237
|
recordSetSetter,
|
|
240
238
|
router,
|
|
241
239
|
]);
|
|
242
|
-
return
|
|
240
|
+
return useMemo(() => {
|
|
243
241
|
return [...selectionColumns, ...restColumns, ...actionColumns];
|
|
244
242
|
}, [selectionColumns, restColumns, actionColumns]);
|
|
245
243
|
}
|
|
246
244
|
function renderCellHeaderContent({ column, props, disableColumnResize, disableColumnFilter, disableColumnSort, onChangeSortDirection, attribute, }) {
|
|
247
|
-
return ((
|
|
245
|
+
return (_jsx(TableHeaderFilterCell, { columnName: column.name, sortDirection: props.column.getIsSorted() || undefined, minWidth: props.header.getSize(), column: column, resizable: !disableColumnResize, disableFilter: disableColumnFilter, disableSort: disableColumnSort, onChangeSortDirection: onChangeSortDirection, attribute: attribute, onResetSize: props.column.resetSize, resizeHandler: props.header.getResizeHandler(), children: column.label }, column.id));
|
|
248
246
|
}
|
|
249
247
|
function renderCellContent({ info, column, schema, schemaStore, locale, routeResolver, openRecord, recordSetSetter, router, }) {
|
|
250
248
|
var _a, _b, _c;
|
|
@@ -263,7 +261,7 @@ function renderCellContent({ info, column, schema, schemaStore, locale, routeRes
|
|
|
263
261
|
attribute = schema.attributes[column.name];
|
|
264
262
|
value = info.getValue();
|
|
265
263
|
}
|
|
266
|
-
const formattedValue = (_c =
|
|
264
|
+
const formattedValue = (_c = getAttributeFormattedValue(attribute, value, {
|
|
267
265
|
currency: currency.currency,
|
|
268
266
|
dateFormat: dateFormats.short,
|
|
269
267
|
timeFormat: timeFormats.short,
|
|
@@ -273,51 +271,102 @@ function renderCellContent({ info, column, schema, schemaStore, locale, routeRes
|
|
|
273
271
|
locale: locale.locale,
|
|
274
272
|
})) !== null && _c !== void 0 ? _c : '';
|
|
275
273
|
if (column.plainText) {
|
|
276
|
-
return ((
|
|
274
|
+
return (_jsx(TableCellText, { value: formattedValue, width: info.column.getSize() }, column.id));
|
|
277
275
|
}
|
|
278
276
|
if (column.component) {
|
|
279
|
-
const Component =
|
|
277
|
+
const Component = componentStore.getComponent(column.component);
|
|
280
278
|
if (!Component) {
|
|
281
279
|
throw new Error(`Component with name ${column.component} not found`);
|
|
282
280
|
}
|
|
283
|
-
return ((
|
|
281
|
+
return (_jsx(Component, { column: column, schema: schema, record: info.row.original, value: value, attribute: attribute, formattedValue: formattedValue, width: info.column.getSize() }));
|
|
284
282
|
}
|
|
285
283
|
if (schema.primaryAttribute === column.name) {
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
284
|
+
return renderPrimaryAttribute({
|
|
285
|
+
info,
|
|
286
|
+
column,
|
|
287
|
+
routeResolver,
|
|
288
|
+
openRecord,
|
|
289
|
+
schema,
|
|
290
|
+
value: value,
|
|
290
291
|
});
|
|
291
|
-
return ((0, jsx_runtime_1.jsx)(TableCellLink_1.TableCellLink, { value: value, width: info.column.getSize(), href: path, onClick: () => {
|
|
292
|
-
openRecord(info.row.original[schema.idAttribute]);
|
|
293
|
-
} }, column.id));
|
|
294
292
|
}
|
|
295
293
|
switch (attribute === null || attribute === void 0 ? void 0 : attribute.type) {
|
|
296
294
|
case 'money':
|
|
297
|
-
return ((
|
|
295
|
+
return (_jsx(TableCellText, { value: formattedValue, width: info.column.getSize(), textAlignment: "right" }, column.id));
|
|
298
296
|
case 'lookup': {
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
297
|
+
return renderLookupAttribute({
|
|
298
|
+
info,
|
|
299
|
+
column,
|
|
300
|
+
schemaStore,
|
|
301
|
+
routeResolver,
|
|
302
|
+
recordSetSetter,
|
|
303
|
+
router,
|
|
304
|
+
value,
|
|
305
|
+
attribute,
|
|
306
|
+
formattedValue,
|
|
306
307
|
});
|
|
307
|
-
return ((0, jsx_runtime_1.jsx)(TableCellLink_1.TableCellLink, { value: formattedValue, width: info.column.getSize(), href: path, onClick: () => {
|
|
308
|
-
recordSetSetter('', []);
|
|
309
|
-
router.push(path);
|
|
310
|
-
} }, column.id));
|
|
311
308
|
}
|
|
312
309
|
case 'attachment': {
|
|
313
310
|
const url = value === null || value === void 0 ? void 0 : value.url;
|
|
314
311
|
if (!url) {
|
|
315
|
-
return ((
|
|
312
|
+
return (_jsx(TableCellText, { value: "", width: info.column.getSize() }, column.id));
|
|
316
313
|
}
|
|
317
|
-
return ((
|
|
314
|
+
return (_jsx(TableCellLink, { value: formattedValue, width: info.column.getSize(), href: url, target: "_blank" }, column.id));
|
|
318
315
|
}
|
|
319
316
|
case 'choice':
|
|
320
|
-
return ((
|
|
317
|
+
return (_jsx(TableCellChoice, { column: column, schema: schema, record: info.row.original, value: value, attribute: attribute, formattedValue: formattedValue, width: info.column.getSize() }));
|
|
318
|
+
}
|
|
319
|
+
return (_jsx(TableCellText, { value: formattedValue, width: info.column.getSize() }, column.id));
|
|
320
|
+
}
|
|
321
|
+
function renderPrimaryAttribute({ info, column, schema, routeResolver, openRecord, value, }) {
|
|
322
|
+
const path = routeResolver({
|
|
323
|
+
logicalName: schema.logicalName,
|
|
324
|
+
type: PageType.EntityForm,
|
|
325
|
+
id: info.row.original[schema.idAttribute],
|
|
326
|
+
});
|
|
327
|
+
return (_jsx(TableCellLink, { value: _jsxs(Fragment, { children: [renderPrimaryAttributeAvatar({
|
|
328
|
+
info,
|
|
329
|
+
schema,
|
|
330
|
+
value,
|
|
331
|
+
}), value] }), width: info.column.getSize(), href: path, onClick: () => {
|
|
332
|
+
openRecord(info.row.original[schema.idAttribute]);
|
|
333
|
+
} }, column.id));
|
|
334
|
+
}
|
|
335
|
+
function renderPrimaryAttributeAvatar({ info, schema, value, }) {
|
|
336
|
+
if (!schema.avatarAttribute) {
|
|
337
|
+
return null;
|
|
338
|
+
}
|
|
339
|
+
const avatarAttribute = schema.attributes[schema.avatarAttribute];
|
|
340
|
+
if (avatarAttribute.type !== 'attachment') {
|
|
341
|
+
return null;
|
|
342
|
+
}
|
|
343
|
+
const avatarValue = info.row.original[schema.avatarAttribute];
|
|
344
|
+
return (_jsx(Avatar, { style: {
|
|
345
|
+
width: 24,
|
|
346
|
+
height: 24,
|
|
347
|
+
fontSize: tokens.fontSizeBase100,
|
|
348
|
+
}, name: value, color: getAvatarColor(value), image: {
|
|
349
|
+
src: avatarValue === null || avatarValue === void 0 ? void 0 : avatarValue.url,
|
|
350
|
+
} }));
|
|
351
|
+
}
|
|
352
|
+
function renderLookupAttribute({ value, info, column, schemaStore, routeResolver, recordSetSetter, router, attribute, formattedValue, }) {
|
|
353
|
+
if (!value) {
|
|
354
|
+
return (_jsx(TableCellText, { value: "", width: info.column.getSize() }, column.id));
|
|
321
355
|
}
|
|
322
|
-
|
|
356
|
+
const lookupSchema = schemaStore.getSchema(attribute.entity);
|
|
357
|
+
const path = routeResolver({
|
|
358
|
+
logicalName: attribute.entity,
|
|
359
|
+
type: PageType.EntityForm,
|
|
360
|
+
id: value.id,
|
|
361
|
+
});
|
|
362
|
+
return (_jsx(TableCellLink, { value: _jsxs(Fragment, { children: [!!lookupSchema.avatarAttribute && (_jsx(Avatar, { style: {
|
|
363
|
+
width: 24,
|
|
364
|
+
height: 24,
|
|
365
|
+
fontSize: tokens.fontSizeBase100,
|
|
366
|
+
}, name: formattedValue, color: getAvatarColor(formattedValue), image: {
|
|
367
|
+
src: value.avatar,
|
|
368
|
+
} })), formattedValue] }), width: info.column.getSize(), href: path, onClick: () => {
|
|
369
|
+
recordSetSetter('', []);
|
|
370
|
+
router.push(path);
|
|
371
|
+
} }, column.id));
|
|
323
372
|
}
|
package/DataGrid/utils.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.adjustTableHeight = void 0;
|
|
4
|
-
const adjustTableHeight = (tableRef, virtualHeight) => {
|
|
1
|
+
export const adjustTableHeight = (tableRef, virtualHeight) => {
|
|
5
2
|
if (!tableRef.current)
|
|
6
3
|
return;
|
|
7
4
|
// calculate the height for the pseudo element after the table
|
|
@@ -12,4 +9,3 @@ const adjustTableHeight = (tableRef, virtualHeight) => {
|
|
|
12
9
|
document.documentElement.style.setProperty('--pseudo-height', `${pseudoHeight}px`);
|
|
13
10
|
return pseudoHeight;
|
|
14
11
|
};
|
|
15
|
-
exports.adjustTableHeight = adjustTableHeight;
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const react_components_1 = require("@fluentui/react-components");
|
|
6
|
-
function AlertDialog(props) {
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Button, Dialog, DialogActions, DialogBody, DialogContent, DialogSurface, DialogTitle, } from '@fluentui/react-components';
|
|
3
|
+
export function AlertDialog(props) {
|
|
7
4
|
var _a;
|
|
8
|
-
return ((
|
|
5
|
+
return (_jsx(Dialog, { open: props.open, onOpenChange: () => {
|
|
9
6
|
var _a;
|
|
10
7
|
(_a = props.onDismiss) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
11
|
-
}, children: (
|
|
8
|
+
}, children: _jsx(DialogSurface, { style: { maxWidth: 480 }, children: _jsxs(DialogBody, { children: [!!props.title && _jsx(DialogTitle, { children: props.title }), _jsx(DialogContent, { children: props.message }), _jsx(DialogActions, { children: _jsx(Button, { appearance: "primary", onClick: () => {
|
|
12
9
|
var _a;
|
|
13
10
|
(_a = props.onConfirm) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
14
11
|
}, children: (_a = props.confirmText) !== null && _a !== void 0 ? _a : 'Close' }) })] }) }) }));
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const react_components_1 = require("@fluentui/react-components");
|
|
6
|
-
function ConfirmDialog(props) {
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Button, Dialog, DialogActions, DialogBody, DialogContent, DialogSurface, DialogTitle, } from '@fluentui/react-components';
|
|
3
|
+
export function ConfirmDialog(props) {
|
|
7
4
|
var _a, _b;
|
|
8
|
-
return ((
|
|
5
|
+
return (_jsx(Dialog, { open: props.open, onOpenChange: () => {
|
|
9
6
|
var _a;
|
|
10
7
|
(_a = props.onDismiss) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
11
|
-
}, children: (
|
|
8
|
+
}, children: _jsx(DialogSurface, { style: { maxWidth: 480 }, children: _jsxs(DialogBody, { children: [!!props.title && _jsx(DialogTitle, { children: props.title }), _jsx(DialogContent, { children: props.message }), _jsxs(DialogActions, { children: [_jsx(Button, { appearance: "secondary", onClick: () => {
|
|
12
9
|
var _a;
|
|
13
10
|
(_a = props.onCancel) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
14
|
-
}, children: (_a = props.cancelText) !== null && _a !== void 0 ? _a : 'Cancel' }), (
|
|
11
|
+
}, children: (_a = props.cancelText) !== null && _a !== void 0 ? _a : 'Cancel' }), _jsx(Button, { appearance: "primary", onClick: () => {
|
|
15
12
|
var _a;
|
|
16
13
|
(_a = props.onConfirm) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
17
14
|
}, children: (_b = props.confirmText) !== null && _b !== void 0 ? _b : 'Confirm' })] })] }) }) }));
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
2
|
var t = {};
|
|
4
3
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -10,34 +9,31 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
9
|
}
|
|
11
10
|
return t;
|
|
12
11
|
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
const items = (0, hooks_1.useDialogItems)();
|
|
23
|
-
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: items.map((item) => {
|
|
12
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
13
|
+
import { useDialogItems } from '@headless-adminapp/app/dialog/hooks';
|
|
14
|
+
import { AlertDialog } from './AlertDialog';
|
|
15
|
+
import { ConfirmDialog } from './ConfirmDialog';
|
|
16
|
+
import { ErrorDialog } from './ErrorDialog';
|
|
17
|
+
import { PromptDialog } from './PromptDialog';
|
|
18
|
+
export const DialogContainer = () => {
|
|
19
|
+
const items = useDialogItems();
|
|
20
|
+
return (_jsx(_Fragment, { children: items.map((item) => {
|
|
24
21
|
const { id, isOpen } = item, options = __rest(item, ["id", "isOpen"]);
|
|
25
22
|
switch (options.type) {
|
|
26
23
|
case 'alert':
|
|
27
|
-
return ((
|
|
24
|
+
return (_jsx(AlertDialog, { message: options.text, open: isOpen, confirmText: options.confirmButtonLabel, onConfirm: options.onConfirm, onDismiss: options.onDismiss, title: options.title }, id));
|
|
28
25
|
case 'confirm':
|
|
29
|
-
return ((
|
|
26
|
+
return (_jsx(ConfirmDialog, { message: options.text, title: options.title, onCancel: options.onCancel, onConfirm: options.onConfirm, onDismiss: options.onDismiss, open: isOpen, cancelText: options.cancelButtonLabel, confirmText: options.confirmButtonLabel }, id));
|
|
30
27
|
case 'error':
|
|
31
|
-
return ((
|
|
28
|
+
return (_jsx(ErrorDialog, { message: options.text, open: isOpen, confirmText: options.confirmButtonLabel, onConfirm: options.onConfirm, onDismiss: options.onDismiss, title: options.title }, id));
|
|
32
29
|
case 'prompt':
|
|
33
|
-
return ((
|
|
30
|
+
return (_jsx(PromptDialog, { attributes: options.attributes,
|
|
34
31
|
// cancelButtonLabel={options.cancelButtonLabel}
|
|
35
32
|
// confirmButtonLabel={options.confirmButtonLabel}
|
|
36
33
|
defaultValues: options.defaultValues, onCancel: options.onCancel, onDismiss: options.onDismiss, onConfirm: options.onConfirm, text: options.text, title: options.title, open: isOpen, cancelText: options.cancelButtonLabel, confirmText: options.confirmButtonLabel }, id));
|
|
37
34
|
case 'custom':
|
|
38
|
-
return ((
|
|
35
|
+
return (_jsx(options.Component, Object.assign({ id: id, isOpen: isOpen }, options.props), id));
|
|
39
36
|
}
|
|
40
37
|
return null;
|
|
41
38
|
}) }));
|
|
42
39
|
};
|
|
43
|
-
exports.DialogContainer = DialogContainer;
|
|
@@ -1,21 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const react_components_1 = require("@fluentui/react-components");
|
|
6
|
-
const icons_1 = require("@headless-adminapp/icons");
|
|
7
|
-
function ErrorDialog(props) {
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Button, Dialog, DialogActions, DialogBody, DialogContent, DialogSurface, DialogTitle, tokens, } from '@fluentui/react-components';
|
|
3
|
+
import { Icons } from '@headless-adminapp/icons';
|
|
4
|
+
export function ErrorDialog(props) {
|
|
8
5
|
var _a;
|
|
9
|
-
return ((
|
|
6
|
+
return (_jsx(Dialog, { open: props.open, onOpenChange: () => {
|
|
10
7
|
var _a;
|
|
11
8
|
(_a = props.onDismiss) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
12
|
-
}, children: (
|
|
13
|
-
color:
|
|
9
|
+
}, children: _jsx(DialogSurface, { style: { maxWidth: 480 }, children: _jsxs(DialogBody, { children: [_jsxs(DialogTitle, { style: { display: 'flex', alignItems: 'center' }, children: [_jsx("span", { style: {
|
|
10
|
+
color: tokens.colorPaletteRedForeground1,
|
|
14
11
|
// marginBottom: tokens.spacingVerticalL,
|
|
15
12
|
display: 'inline-flex',
|
|
16
13
|
alignItems: 'center',
|
|
17
|
-
marginRight:
|
|
18
|
-
}, children: (
|
|
14
|
+
marginRight: tokens.spacingHorizontalS,
|
|
15
|
+
}, children: _jsx(Icons.Error, {}) }), props.title || 'Error'] }), _jsx(DialogContent, { children: props.message }), _jsx(DialogActions, { children: _jsx(Button, { appearance: "primary", style: { background: tokens.colorPaletteRedBackground3 }, onClick: () => {
|
|
19
16
|
var _a;
|
|
20
17
|
(_a = props.onConfirm) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
21
18
|
}, children: (_a = props.confirmText) !== null && _a !== void 0 ? _a : 'Close' }) })] }) }) }));
|