@headless-adminapp/fluent 0.0.17-alpha.8 → 1.0.1
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.d.ts +0 -1
- package/App/App.js +2 -4
- package/App/AppHeaderContianer.d.ts +5 -1
- package/App/AppHeaderContianer.js +43 -26
- package/App/AppLogo.js +15 -4
- package/App/AppUI.js +9 -1
- package/App/LayoutProvider.d.ts +7 -0
- package/App/LayoutProvider.js +17 -0
- package/App/NavigationContainer.d.ts +10 -1
- package/App/NavigationContainer.js +27 -22
- package/App/QuickActionItem.js +2 -2
- package/App/utils.js +3 -4
- package/CommandBar/Button.d.ts +2 -1
- package/CommandBar/Button.js +2 -2
- package/CommandBar/Divider.d.ts +2 -1
- package/CommandBar/Divider.js +2 -2
- package/CommandBar/IconButton.d.ts +2 -1
- package/CommandBar/IconButton.js +2 -2
- package/CommandBar/Label.d.ts +2 -1
- package/CommandBar/Label.js +2 -2
- package/CommandBar/MenuButton.d.ts +2 -1
- package/CommandBar/MenuButton.js +3 -3
- package/CommandBar/MenuItem.js +5 -4
- package/CommandBar/MenuItems.js +4 -4
- package/CommandBar/MenuList.js +5 -4
- package/CommandBar/Wrapper.d.ts +2 -2
- package/CommandBar/Wrapper.js +2 -2
- package/CommandBar/index.d.ts +6 -6
- package/DataGrid/ActionCell.d.ts +1 -1
- package/DataGrid/ActionCell.js +8 -4
- package/DataGrid/CustomizeColumns/AddColumns.js +33 -35
- package/DataGrid/CustomizeColumns/ColumnItem.js +8 -6
- package/DataGrid/CustomizeColumns/CustomizeColumns.d.ts +2 -2
- package/DataGrid/CustomizeColumns/CustomizeColumns.js +3 -6
- package/DataGrid/FormSubgridViewSelector.js +1 -5
- package/DataGrid/GridColumnHeader/ConditionValueControl.js +19 -25
- package/DataGrid/GridColumnHeader/FilterForm.js +9 -10
- package/DataGrid/GridColumnHeader/OperatorSelect.js +10 -3
- package/DataGrid/GridColumnHeader/TableHeaderFilterCell.js +22 -13
- package/DataGrid/GridColumnHeader/utils.js +10 -7
- package/DataGrid/GridHeaderDesktop.js +4 -5
- package/DataGrid/GridHeaderMobile.d.ts +5 -0
- package/DataGrid/GridHeaderMobile.js +29 -0
- package/DataGrid/GridListContainer.d.ts +12 -0
- package/DataGrid/GridListContainer.js +93 -0
- package/DataGrid/GridPaginationContainer.js +1 -2
- package/DataGrid/GridTableContainer.js +113 -77
- package/DataGrid/TableCell/TableCellBase.d.ts +2 -2
- package/DataGrid/TableCell/TableCellBase.js +6 -1
- package/DataGrid/TableCell/TableCellCheckbox.js +6 -5
- package/DataGrid/TableCell/TableCellChoice.d.ts +15 -0
- package/DataGrid/TableCell/TableCellChoice.js +34 -0
- package/DataGrid/TableCell/TableCellLink.d.ts +2 -1
- package/DataGrid/TableCell/TableCellLink.js +13 -5
- package/DataGrid/TableCell/TableCellText.js +9 -4
- package/DataGrid/types.d.ts +5 -0
- package/DataGrid/types.js +2 -0
- package/DataGrid/useTableColumns.d.ts +2 -3
- package/DataGrid/useTableColumns.js +297 -155
- package/DialogContainer/AlertDialog.js +3 -6
- package/DialogContainer/ConfirmDialog.js +5 -9
- package/DialogContainer/DialogContainer.js +2 -13
- package/DialogContainer/ErrorDialog.js +3 -6
- package/DialogContainer/PromptDialog.d.ts +13 -2
- package/DialogContainer/PromptDialog.js +44 -39
- package/Insights/CommandBarContainer.d.ts +1 -0
- package/Insights/CommandBarContainer.js +18 -0
- package/Insights/FilterBarContainer.d.ts +1 -0
- package/Insights/FilterBarContainer.js +99 -0
- package/Insights/Grid.d.ts +6 -0
- package/Insights/Grid.js +26 -0
- package/Insights/InsightsContainer.d.ts +1 -0
- package/Insights/InsightsContainer.js +35 -0
- package/Insights/WidgetChartContainer.d.ts +7 -0
- package/Insights/WidgetChartContainer.js +56 -0
- package/Insights/WidgetDataGridContainer.d.ts +4 -0
- package/Insights/WidgetDataGridContainer.js +80 -0
- package/Insights/WidgetTableContainer.d.ts +7 -0
- package/Insights/WidgetTableContainer.js +57 -0
- package/Insights/WidgetTileContainer.d.ts +7 -0
- package/Insights/WidgetTileContainer.js +24 -0
- package/Insights/WidgetTitleBar.d.ts +7 -0
- package/Insights/WidgetTitleBar.js +21 -0
- package/Insights/Widgets.d.ts +4 -0
- package/Insights/Widgets.js +57 -0
- package/Insights/charts/AreaChart.d.ts +5 -0
- package/Insights/charts/AreaChart.js +20 -0
- package/Insights/charts/BarChart.d.ts +5 -0
- package/Insights/charts/BarChart.js +20 -0
- package/Insights/charts/ComposedChart.d.ts +5 -0
- package/Insights/charts/ComposedChart.js +19 -0
- package/Insights/charts/CustomTooltipContent.d.ts +7 -0
- package/Insights/charts/CustomTooltipContent.js +25 -0
- package/Insights/charts/GaugeChart.d.ts +5 -0
- package/Insights/charts/GaugeChart.js +8 -0
- package/Insights/charts/LineChart.d.ts +5 -0
- package/Insights/charts/LineChart.js +21 -0
- package/Insights/charts/OhlcChart.d.ts +6 -0
- package/Insights/charts/OhlcChart.js +119 -0
- package/Insights/charts/PieChart.d.ts +5 -0
- package/Insights/charts/PieChart.js +54 -0
- package/Insights/charts/RadarChart.d.ts +5 -0
- package/Insights/charts/RadarChart.js +38 -0
- package/Insights/charts/ScatterChart.d.ts +5 -0
- package/Insights/charts/ScatterChart.js +81 -0
- package/Insights/charts/constants.d.ts +1 -0
- package/Insights/charts/constants.js +25 -0
- package/Insights/charts/formatters.d.ts +14 -0
- package/Insights/charts/formatters.js +186 -0
- package/Insights/charts/index.d.ts +4 -0
- package/Insights/charts/index.js +13 -0
- package/Insights/charts/renderers.d.ts +10 -0
- package/Insights/charts/renderers.js +64 -0
- package/Insights/hooks/useQueriesData.d.ts +7 -0
- package/Insights/hooks/useQueriesData.js +90 -0
- package/Insights/hooks/useWidgetDetail.d.ts +10 -0
- package/Insights/hooks/useWidgetDetail.js +39 -0
- package/OverflowCommandBar/OverflowCommandBar.js +1 -4
- package/OverflowCommandBar/OverflowMenu.js +5 -17
- package/OverflowCommandBar/render.js +3 -4
- package/OverflowCommandBar/utils.js +2 -3
- package/PageBoard/BoardColumn.d.ts +5 -0
- package/PageBoard/BoardColumn.js +9 -0
- package/PageBoard/BoardColumnCard.d.ts +12 -0
- package/PageBoard/BoardColumnCard.js +29 -0
- package/PageBoard/BoardColumnUI.d.ts +2 -0
- package/PageBoard/BoardColumnUI.js +76 -0
- package/PageBoard/BoardingColumnCardLoading.d.ts +1 -0
- package/PageBoard/BoardingColumnCardLoading.js +21 -0
- package/PageBoard/Header.d.ts +7 -0
- package/PageBoard/Header.js +31 -0
- package/PageBoard/PageBoard.d.ts +7 -0
- package/PageBoard/PageBoard.js +46 -0
- package/PageBoard/index.d.ts +1 -0
- package/PageBoard/index.js +5 -0
- package/PageCalendar/CalendarSection.d.ts +20 -0
- package/PageCalendar/CalendarSection.js +108 -0
- package/PageCalendar/EventDialog/AttributeController.d.ts +10 -0
- package/PageCalendar/EventDialog/AttributeController.js +17 -0
- package/PageCalendar/EventDialog/EventDialog.d.ts +25 -0
- package/PageCalendar/EventDialog/EventDialog.js +21 -0
- package/PageCalendar/EventDialog/EventFormBody.d.ts +18 -0
- package/PageCalendar/EventDialog/EventFormBody.js +69 -0
- package/PageCalendar/EventDialog/EventFormContent.d.ts +10 -0
- package/PageCalendar/EventDialog/EventFormContent.js +27 -0
- package/PageCalendar/EventDialog/types.d.ts +3 -0
- package/PageCalendar/EventDialog/types.js +2 -0
- package/PageCalendar/EventDialog/utils.d.ts +23 -0
- package/PageCalendar/EventDialog/utils.js +57 -0
- package/PageCalendar/Header.d.ts +8 -0
- package/PageCalendar/Header.js +35 -0
- package/PageCalendar/PageCalendar.d.ts +7 -0
- package/PageCalendar/PageCalendar.js +231 -0
- package/PageCalendar/TitleSelector.d.ts +10 -0
- package/PageCalendar/TitleSelector.js +73 -0
- package/PageCalendar/ViewSelector.d.ts +8 -0
- package/PageCalendar/ViewSelector.js +52 -0
- package/PageCalendar/baseEventAttributes.d.ts +35 -0
- package/PageCalendar/baseEventAttributes.js +38 -0
- package/PageCalendar/context.d.ts +20 -0
- package/PageCalendar/context.js +5 -0
- package/PageCalendar/hooks/index.d.ts +1 -0
- package/PageCalendar/hooks/index.js +17 -0
- package/PageCalendar/hooks/useConfig.d.ts +3 -0
- package/PageCalendar/hooks/useConfig.js +8 -0
- package/PageCalendar/index.d.ts +1 -0
- package/PageCalendar/index.js +5 -0
- package/PageCalendar/renderEventContent.d.ts +2 -0
- package/PageCalendar/renderEventContent.js +22 -0
- package/PageCalendar/types.d.ts +5 -0
- package/PageCalendar/types.js +9 -0
- package/PageCalendar/utils.d.ts +3 -0
- package/PageCalendar/utils.js +17 -0
- package/PageEntityForm/CommandContainer.js +9 -5
- package/PageEntityForm/PageCustomEntityForm.d.ts +15 -0
- package/PageEntityForm/PageCustomEntityForm.js +17 -0
- package/PageEntityForm/PageEntityFormDesktopContainer.js +39 -19
- package/PageEntityForm/ProcessFlow.d.ts +10 -0
- package/PageEntityForm/ProcessFlow.js +84 -0
- package/PageEntityForm/RecordAvatar.d.ts +2 -0
- package/PageEntityForm/RecordAvatar.js +83 -0
- package/PageEntityForm/RecordCard.d.ts +1 -1
- package/PageEntityForm/RecordCard.js +60 -53
- package/PageEntityForm/RecordCardLoading.d.ts +8 -0
- package/PageEntityForm/RecordCardLoading.js +24 -0
- package/PageEntityForm/RecordSetNavigatorContainer.js +1 -2
- package/PageEntityForm/RelatedViewSelector.d.ts +0 -2
- package/PageEntityForm/RelatedViewSelector.js +37 -11
- package/PageEntityForm/SectionContainer.d.ts +2 -2
- package/PageEntityForm/SectionContainer.js +77 -13
- package/PageEntityForm/StandardControl.d.ts +1 -22
- package/PageEntityForm/StandardControl.js +103 -117
- package/PageEntityForm/SubgridControl.d.ts +1 -0
- package/PageEntityForm/SubgridControl.js +4 -2
- package/PageEntityForm/UploadImageDialog.d.ts +12 -0
- package/PageEntityForm/UploadImageDialog.js +114 -0
- package/PageEntityView/FormSubgridContainer.js +5 -2
- package/PageEntityView/FormSubgridNotAvailableContainer.d.ts +2 -0
- package/PageEntityView/FormSubgridNotAvailableContainer.js +48 -0
- package/PageEntityView/PageEntityView.js +4 -1
- package/PageEntityView/PageEntityViewDesktopFrame.js +1 -0
- package/PageEntityView/PageEntityViewMobileContainer.d.ts +2 -0
- package/PageEntityView/PageEntityViewMobileContainer.js +14 -0
- package/PageEntityView/PageEntityViewStringContext.d.ts +2 -0
- package/PageEntityView/PageEntityViewStringContext.js +2 -0
- package/PageInsights/PageInsights.d.ts +9 -0
- package/PageInsights/PageInsights.js +25 -0
- package/PageInsights/index.d.ts +1 -0
- package/PageInsights/index.js +6 -0
- package/ToastNotificationContainer/index.js +1 -2
- package/componentStore.d.ts +2 -0
- package/componentStore.js +5 -0
- package/components/BodyLoading.d.ts +1 -1
- package/components/BodyLoading.js +13 -8
- package/components/DndProvider.d.ts +12 -0
- package/components/DndProvider.js +68 -0
- package/components/LoginForm.js +5 -21
- package/form/FormControl.js +19 -41
- package/form/controls/AttachmentControl.d.ts +27 -0
- package/form/controls/AttachmentControl.js +220 -0
- package/form/controls/AttachmentsControl.d.ts +6 -0
- package/form/controls/AttachmentsControl.js +35 -0
- package/form/controls/CurrencyControl.js +38 -6
- package/form/controls/DateControl.d.ts +1 -1
- package/form/controls/DateControl.js +18 -7
- package/form/controls/DateRangeControl.js +4 -6
- package/form/controls/DateTimeControl.d.ts +1 -1
- package/form/controls/DateTimeControl.js +108 -12
- package/form/controls/DecimalControl.d.ts +5 -0
- package/form/controls/DecimalControl.js +52 -0
- package/form/controls/DurationControl.d.ts +4 -0
- package/form/controls/DurationControl.js +209 -0
- package/form/controls/EmailControl.d.ts +1 -1
- package/form/controls/EmailControl.js +5 -5
- package/form/controls/IntegerControl.d.ts +4 -0
- package/form/controls/IntegerControl.js +25 -0
- package/form/controls/LookupControl.d.ts +1 -0
- package/form/controls/LookupControl.js +57 -13
- package/form/controls/MultiSelectControl.js +3 -3
- package/form/controls/MultiSelectLookupControl.js +16 -17
- package/form/controls/PasswordControl.js +1 -1
- package/form/controls/RichTextControl.d.ts +5 -0
- package/form/controls/RichTextControl.js +33 -0
- package/form/controls/SelectControl.js +4 -5
- package/form/controls/SwitchControl.d.ts +1 -1
- package/form/controls/SwitchControl.js +4 -2
- package/form/controls/TelephoneControl.d.ts +1 -1
- package/form/controls/TelephoneControl.js +26 -4
- package/form/controls/TextAreaControl.d.ts +1 -1
- package/form/controls/TextAreaControl.js +6 -6
- package/form/controls/TextControl.js +4 -4
- package/form/controls/UrlControl.d.ts +4 -0
- package/form/controls/UrlControl.js +16 -0
- package/form/controls/useLookupData.js +26 -41
- package/form/layout/FormSection/FormSection.js +10 -3
- package/form/layout/FormTab/FormTab.js +4 -4
- package/form/types.d.ts +2 -2
- package/package.json +17 -12
- package/styles.css +149 -0
- package/types/index.d.ts +18 -0
- package/utils/avatar.d.ts +2 -0
- package/utils/avatar.js +45 -0
- package/App/AppProvider.d.ts +0 -9
- package/App/AppProvider.js +0 -50
- package/DataGrid/ScrollbarWithMoreDataRequest.d.ts +0 -9
- package/DataGrid/ScrollbarWithMoreDataRequest.js +0 -33
- package/DataGrid/getAttributeFormattedValue.d.ts +0 -16
- package/DataGrid/getAttributeFormattedValue.js +0 -92
- package/form/controls/NumberControl.d.ts +0 -4
- package/form/controls/NumberControl.js +0 -16
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GridListContainer = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_components_1 = require("@fluentui/react-components");
|
|
6
|
+
const ScrollbarWithMoreDataRequest_1 = require("@headless-adminapp/app/components/ScrollbarWithMoreDataRequest");
|
|
7
|
+
const datagrid_1 = require("@headless-adminapp/app/datagrid");
|
|
8
|
+
const hooks_1 = require("@headless-adminapp/app/datagrid/hooks");
|
|
9
|
+
const locale_1 = require("@headless-adminapp/app/locale");
|
|
10
|
+
const mutable_1 = require("@headless-adminapp/app/mutable");
|
|
11
|
+
const navigation_1 = require("@headless-adminapp/app/navigation");
|
|
12
|
+
const hooks_2 = require("@headless-adminapp/app/recordset/hooks");
|
|
13
|
+
const react_virtual_1 = require("@tanstack/react-virtual");
|
|
14
|
+
const react_1 = require("react");
|
|
15
|
+
const uuid_1 = require("uuid");
|
|
16
|
+
const RecordCard_1 = require("../PageEntityForm/RecordCard");
|
|
17
|
+
const RecordCardLoading_1 = require("../PageEntityForm/RecordCardLoading");
|
|
18
|
+
const useStyles = (0, react_components_1.makeStyles)({
|
|
19
|
+
root: {
|
|
20
|
+
'&:hover': {
|
|
21
|
+
background: react_components_1.tokens.colorNeutralBackground1Hover,
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
const fallbackData = [];
|
|
26
|
+
const GridListContainer = () => {
|
|
27
|
+
const styles = useStyles();
|
|
28
|
+
const data = (0, hooks_1.useGridData)();
|
|
29
|
+
const dataState = (0, hooks_1.useGridDataState)();
|
|
30
|
+
const fetchNextPage = (0, mutable_1.useContextSelector)(datagrid_1.GridContext, (state) => state.fetchNextPage);
|
|
31
|
+
const schema = (0, hooks_1.useDataGridSchema)();
|
|
32
|
+
const view = (0, hooks_1.useSelectedView)();
|
|
33
|
+
const tableWrapperRef = (0, react_1.useRef)(null);
|
|
34
|
+
const { direction } = (0, locale_1.useLocale)();
|
|
35
|
+
const dataRef = (0, react_1.useRef)(data);
|
|
36
|
+
dataRef.current = data;
|
|
37
|
+
const uniqueRecords = (0, react_1.useMemo)(() => {
|
|
38
|
+
return (data?.records.map((record) => ({
|
|
39
|
+
...record,
|
|
40
|
+
__uuid: (0, uuid_1.v4)(),
|
|
41
|
+
})) ?? fallbackData);
|
|
42
|
+
}, [data?.records]);
|
|
43
|
+
const rows = uniqueRecords;
|
|
44
|
+
const virtualizer = (0, react_virtual_1.useVirtualizer)({
|
|
45
|
+
count: rows.length,
|
|
46
|
+
getScrollElement: () => tableWrapperRef.current?.parentElement?.parentElement,
|
|
47
|
+
estimateSize: () => 40,
|
|
48
|
+
overscan: 5,
|
|
49
|
+
enabled: true,
|
|
50
|
+
});
|
|
51
|
+
const virtualItems = virtualizer.getVirtualItems();
|
|
52
|
+
const virtualSize = virtualizer.getTotalSize();
|
|
53
|
+
const recordSetSetter = (0, hooks_2.useRecordSetSetter)();
|
|
54
|
+
const openFormInternal = (0, navigation_1.useOpenForm)();
|
|
55
|
+
const openRecord = (0, react_1.useCallback)((id) => {
|
|
56
|
+
recordSetSetter(schema.logicalName, dataRef.current?.records.map((x) => x[schema.idAttribute]) ??
|
|
57
|
+
[]);
|
|
58
|
+
openFormInternal({
|
|
59
|
+
logicalName: schema.logicalName,
|
|
60
|
+
id,
|
|
61
|
+
});
|
|
62
|
+
}, [openFormInternal, recordSetSetter, schema.idAttribute, schema.logicalName]);
|
|
63
|
+
return ((0, jsx_runtime_1.jsx)("div", { style: { display: 'flex', flex: 1, flexDirection: 'column' }, children: (0, jsx_runtime_1.jsx)(ScrollbarWithMoreDataRequest_1.ScrollbarWithMoreDataRequest, { data: data?.records, hasMore: dataState?.hasNextPage, rtl: direction === 'rtl', onRequestMore: () => {
|
|
64
|
+
fetchNextPage();
|
|
65
|
+
}, children: (0, jsx_runtime_1.jsx)("div", { style: {
|
|
66
|
+
position: 'relative',
|
|
67
|
+
}, ref: tableWrapperRef, children: (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
68
|
+
display: 'flex',
|
|
69
|
+
flexDirection: 'column',
|
|
70
|
+
width: '100%',
|
|
71
|
+
height: virtualizer.getTotalSize(),
|
|
72
|
+
}, children: [(0, jsx_runtime_1.jsx)("div", { style: {
|
|
73
|
+
display: 'flex',
|
|
74
|
+
flexDirection: 'column',
|
|
75
|
+
}, children: virtualItems.map((virtualRow) => {
|
|
76
|
+
const row = rows[virtualRow.index];
|
|
77
|
+
return ((0, jsx_runtime_1.jsx)("div", { ref: virtualizer.measureElement, "data-index": virtualRow.index, className: (0, react_components_1.mergeClasses)(styles.root), style: {
|
|
78
|
+
width: '100%',
|
|
79
|
+
position: 'absolute',
|
|
80
|
+
transform: `translateY(${virtualRow.start}px)`,
|
|
81
|
+
}, onClick: () => {
|
|
82
|
+
const id = row[schema.idAttribute];
|
|
83
|
+
openRecord(id);
|
|
84
|
+
}, children: (0, jsx_runtime_1.jsx)(RecordCard_1.RecordCard, { cardView: view.experience.card, record: row, schema: schema, selected: false }) }, virtualRow.key));
|
|
85
|
+
}) }), dataState.isFetching && ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
86
|
+
display: 'flex',
|
|
87
|
+
flexDirection: 'column',
|
|
88
|
+
width: '100%',
|
|
89
|
+
position: 'absolute',
|
|
90
|
+
transform: `translateY(${virtualSize}px)`,
|
|
91
|
+
}, children: Array.from({ length: 10 }).map((_, index) => ((0, jsx_runtime_1.jsx)(RecordCardLoading_1.RecordCardLoading, { cardView: view.experience.card, schema: schema }, index))) }))] }) }) }) }));
|
|
92
|
+
};
|
|
93
|
+
exports.GridListContainer = GridListContainer;
|
|
@@ -7,7 +7,6 @@ const hooks_1 = require("@headless-adminapp/app/datagrid/hooks");
|
|
|
7
7
|
const react_1 = require("react");
|
|
8
8
|
const PageEntityViewStringContext_1 = require("../PageEntityView/PageEntityViewStringContext");
|
|
9
9
|
const GridPaginationContainer = () => {
|
|
10
|
-
var _a, _b, _c;
|
|
11
10
|
const data = (0, hooks_1.useGridData)();
|
|
12
11
|
const [selectedIds] = (0, hooks_1.useGridSelection)();
|
|
13
12
|
const strings = (0, PageEntityViewStringContext_1.usePageEntityViewStrings)();
|
|
@@ -15,6 +14,6 @@ const GridPaginationContainer = () => {
|
|
|
15
14
|
color: react_components_1.tokens.colorNeutralForeground3,
|
|
16
15
|
display: 'flex',
|
|
17
16
|
gap: 8,
|
|
18
|
-
}, children: [(0, jsx_runtime_1.jsxs)("span", { children: [strings.records, ": ",
|
|
17
|
+
}, children: [(0, jsx_runtime_1.jsxs)("span", { children: [strings.records, ": ", data?.count ?? '-'] }), (0, jsx_runtime_1.jsx)("span", { children: "|" }), (0, jsx_runtime_1.jsxs)("span", { children: [strings.loaded, ": ", data?.records.length ?? '-'] }), (selectedIds.length > 0 || (data?.count ?? 0) > 0) && ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("span", { children: "|" }), (0, jsx_runtime_1.jsxs)("span", { children: [strings.selected, ": ", selectedIds.length] })] }))] }) }));
|
|
19
18
|
};
|
|
20
19
|
exports.GridPaginationContainer = GridPaginationContainer;
|
|
@@ -3,20 +3,32 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.GridTableContainer = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_components_1 = require("@fluentui/react-components");
|
|
6
|
+
const ScrollbarWithMoreDataRequest_1 = require("@headless-adminapp/app/components/ScrollbarWithMoreDataRequest");
|
|
6
7
|
const datagrid_1 = require("@headless-adminapp/app/datagrid");
|
|
7
8
|
const hooks_1 = require("@headless-adminapp/app/datagrid/hooks");
|
|
8
9
|
const locale_1 = require("@headless-adminapp/app/locale");
|
|
9
10
|
const mutable_1 = require("@headless-adminapp/app/mutable");
|
|
10
11
|
const navigation_1 = require("@headless-adminapp/app/navigation");
|
|
11
12
|
const hooks_2 = require("@headless-adminapp/app/recordset/hooks");
|
|
13
|
+
const icons_1 = require("@headless-adminapp/icons");
|
|
12
14
|
const react_table_1 = require("@tanstack/react-table");
|
|
13
15
|
const react_virtual_1 = require("@tanstack/react-virtual");
|
|
14
16
|
const react_1 = require("react");
|
|
15
|
-
const
|
|
17
|
+
const uuid_1 = require("uuid");
|
|
18
|
+
const PageEntityViewStringContext_1 = require("../PageEntityView/PageEntityViewStringContext");
|
|
16
19
|
const useTableColumns_1 = require("./useTableColumns");
|
|
17
20
|
const utils_1 = require("./utils");
|
|
18
21
|
const useStyles = (0, react_components_1.makeStyles)({
|
|
19
22
|
root: {
|
|
23
|
+
'[aria-selected="true"]': {
|
|
24
|
+
background: react_components_1.tokens.colorBrandBackground2,
|
|
25
|
+
'& .fui-TableSelectionCell': {
|
|
26
|
+
background: 'inherit',
|
|
27
|
+
},
|
|
28
|
+
'& .tableCellAction': {
|
|
29
|
+
background: 'inherit',
|
|
30
|
+
},
|
|
31
|
+
},
|
|
20
32
|
'&:hover': {
|
|
21
33
|
// background: tokens.colorNeutralForeground1Hover,
|
|
22
34
|
'& .fui-TableSelectionCell': {
|
|
@@ -54,7 +66,6 @@ const useStyles = (0, react_components_1.makeStyles)({
|
|
|
54
66
|
});
|
|
55
67
|
const fallbackData = [];
|
|
56
68
|
const GridTableContainer = ({ noPadding, disableColumnFilter, disableColumnSort, disableColumnResize, disableContextMenu, disableSelection, }) => {
|
|
57
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
58
69
|
const styles = useStyles();
|
|
59
70
|
const data = (0, hooks_1.useGridData)();
|
|
60
71
|
const dataState = (0, hooks_1.useGridDataState)();
|
|
@@ -75,14 +86,15 @@ const GridTableContainer = ({ noPadding, disableColumnFilter, disableColumnSort,
|
|
|
75
86
|
const recordSetSetter = (0, hooks_2.useRecordSetSetter)();
|
|
76
87
|
const openFormInternal = (0, navigation_1.useOpenForm)();
|
|
77
88
|
const openRecord = (0, react_1.useCallback)((id) => {
|
|
78
|
-
|
|
79
|
-
|
|
89
|
+
recordSetSetter(schema.logicalName, dataRef.current?.records.map((x) => x[schema.idAttribute]) ??
|
|
90
|
+
[]);
|
|
80
91
|
openFormInternal({
|
|
81
92
|
logicalName: schema.logicalName,
|
|
82
93
|
id,
|
|
83
94
|
});
|
|
84
95
|
}, [openFormInternal, recordSetSetter, schema.idAttribute, schema.logicalName]);
|
|
85
96
|
const { direction } = (0, locale_1.useLocale)();
|
|
97
|
+
const strings = (0, PageEntityViewStringContext_1.usePageEntityViewStrings)();
|
|
86
98
|
const dataRef = (0, react_1.useRef)(data);
|
|
87
99
|
dataRef.current = data;
|
|
88
100
|
const tableColumns = (0, useTableColumns_1.useTableColumns)({
|
|
@@ -93,16 +105,26 @@ const GridTableContainer = ({ noPadding, disableColumnFilter, disableColumnSort,
|
|
|
93
105
|
disableSelection,
|
|
94
106
|
tableWrapperRef,
|
|
95
107
|
});
|
|
108
|
+
const uniqueRecords = (0, react_1.useMemo)(() => {
|
|
109
|
+
return (data?.records.map((record) => ({
|
|
110
|
+
...record,
|
|
111
|
+
__uuid: (0, uuid_1.v4)(),
|
|
112
|
+
})) ?? fallbackData);
|
|
113
|
+
}, [data?.records]);
|
|
114
|
+
const idMapping = (0, react_1.useMemo)(() => uniqueRecords.reduce((acc, record) => {
|
|
115
|
+
acc[record[schema.idAttribute]] = record.__uuid;
|
|
116
|
+
return acc;
|
|
117
|
+
}, {}), [uniqueRecords, schema.idAttribute]);
|
|
96
118
|
const rowSelection = (0, react_1.useMemo)(() => {
|
|
97
119
|
return selectedIds.reduce((acc, id) => {
|
|
98
|
-
acc[id] = true;
|
|
120
|
+
acc[idMapping[id]] = true;
|
|
99
121
|
return acc;
|
|
100
122
|
}, {});
|
|
101
|
-
}, [selectedIds]);
|
|
123
|
+
}, [selectedIds, idMapping]);
|
|
102
124
|
const table = (0, react_table_1.useReactTable)({
|
|
103
|
-
data:
|
|
125
|
+
data: uniqueRecords,
|
|
104
126
|
columns: tableColumns,
|
|
105
|
-
getRowId: (row) => row
|
|
127
|
+
getRowId: (row) => row.__uuid,
|
|
106
128
|
enableRowSelection: true,
|
|
107
129
|
getCoreRowModel: (0, react_table_1.getCoreRowModel)(),
|
|
108
130
|
columnResizeMode: 'onChange',
|
|
@@ -123,7 +145,7 @@ const GridTableContainer = ({ noPadding, disableColumnFilter, disableColumnSort,
|
|
|
123
145
|
const rows = table.getRowModel().rows;
|
|
124
146
|
const virtualizer = (0, react_virtual_1.useVirtualizer)({
|
|
125
147
|
count: rows.length,
|
|
126
|
-
getScrollElement: () =>
|
|
148
|
+
getScrollElement: () => tableWrapperRef.current?.parentElement?.parentElement,
|
|
127
149
|
estimateSize: () => 44,
|
|
128
150
|
overscan: 30,
|
|
129
151
|
paddingStart: 33,
|
|
@@ -138,18 +160,16 @@ const GridTableContainer = ({ noPadding, disableColumnFilter, disableColumnSort,
|
|
|
138
160
|
}, [virtualSize]);
|
|
139
161
|
// callback to handle scrolling, checking if we are near the bottom
|
|
140
162
|
const handleScroll = (0, react_1.useCallback)(() => {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
const
|
|
144
|
-
const visibleHeight = (_h = (_g = (_f = tableWrapperRef.current) === null || _f === void 0 ? void 0 : _f.parentElement) === null || _g === void 0 ? void 0 : _g.parentElement) === null || _h === void 0 ? void 0 : _h.clientHeight;
|
|
163
|
+
if (tableWrapperRef.current?.parentElement?.parentElement) {
|
|
164
|
+
const scrollPosition = tableWrapperRef.current?.parentElement?.parentElement?.scrollTop;
|
|
165
|
+
const visibleHeight = tableWrapperRef.current?.parentElement?.parentElement?.clientHeight;
|
|
145
166
|
setIsScrollNearBottom(scrollPosition > virtualSize * 0.95 - visibleHeight);
|
|
146
167
|
}
|
|
147
168
|
}, [virtualSize]);
|
|
148
169
|
// add an event listener on the scrollable parent container and resize the
|
|
149
170
|
// pseudo element whenever the table renders with new data
|
|
150
171
|
(0, react_1.useEffect)(() => {
|
|
151
|
-
|
|
152
|
-
const scrollable = (_b = (_a = tableWrapperRef.current) === null || _a === void 0 ? void 0 : _a.parentElement) === null || _b === void 0 ? void 0 : _b.parentElement;
|
|
172
|
+
const scrollable = tableWrapperRef.current?.parentElement?.parentElement;
|
|
153
173
|
if (scrollable)
|
|
154
174
|
scrollable.addEventListener('scroll', handleScroll);
|
|
155
175
|
handlePseudoResize();
|
|
@@ -165,74 +185,90 @@ const GridTableContainer = ({ noPadding, disableColumnFilter, disableColumnSort,
|
|
|
165
185
|
if (isScrollNearBottom)
|
|
166
186
|
handlePseudoResize();
|
|
167
187
|
}, [isScrollNearBottom, virtualItems.length, handlePseudoResize]);
|
|
168
|
-
const isScrolledToRight =
|
|
169
|
-
(
|
|
170
|
-
(
|
|
171
|
-
return ((0, jsx_runtime_1.jsx)("div", { style: { display: 'flex', flex: 1, flexDirection: 'column' }, children: (0, jsx_runtime_1.
|
|
188
|
+
const isScrolledToRight = tableWrapperRef.current?.parentElement?.parentElement?.scrollLeft ===
|
|
189
|
+
(tableWrapperRef.current?.parentElement?.parentElement?.scrollWidth ?? 0) -
|
|
190
|
+
(tableWrapperRef.current?.parentElement?.parentElement?.clientWidth ?? 0);
|
|
191
|
+
return ((0, jsx_runtime_1.jsx)("div", { style: { display: 'flex', flex: 1, flexDirection: 'column' }, children: (0, jsx_runtime_1.jsxs)(ScrollbarWithMoreDataRequest_1.ScrollbarWithMoreDataRequest, { data: data?.records, hasMore: dataState?.hasNextPage, rtl: direction === 'rtl', onRequestMore: () => {
|
|
172
192
|
fetchNextPage();
|
|
173
|
-
}, children: (0, jsx_runtime_1.jsx)("div", { style: {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
position: 'sticky',
|
|
188
|
-
top: 0,
|
|
189
|
-
background: react_components_1.tokens.colorNeutralBackground3,
|
|
190
|
-
zIndex: 2,
|
|
191
|
-
}, children: table.getHeaderGroups().map((headerGroup) => ((0, jsx_runtime_1.jsx)(react_components_1.TableRow, { style: {
|
|
193
|
+
}, children: [(0, jsx_runtime_1.jsx)("div", { style: {
|
|
194
|
+
paddingInline: noPadding ? 0 : 8,
|
|
195
|
+
position: 'relative',
|
|
196
|
+
}, ref: tableWrapperRef, children: (0, jsx_runtime_1.jsxs)(react_components_1.Table, { style: {
|
|
197
|
+
display: 'flex',
|
|
198
|
+
flexDirection: 'column',
|
|
199
|
+
borderCollapse: 'collapse',
|
|
200
|
+
width: '100%',
|
|
201
|
+
height: virtualizer.getTotalSize() + 33,
|
|
202
|
+
['--action-shadow']: !isScrolledToRight
|
|
203
|
+
? '-2px 0px 6px rgba(0, 0, 0, 0.12)'
|
|
204
|
+
: 'none',
|
|
205
|
+
}, ref: tableElementRef, className: "table-pseduo", children: [(0, jsx_runtime_1.jsx)(react_components_1.TableHeader, { style: {
|
|
206
|
+
display: 'flex',
|
|
192
207
|
position: 'sticky',
|
|
193
208
|
top: 0,
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
}, children:
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
display: 'flex',
|
|
200
|
-
flexDirection: 'column',
|
|
201
|
-
transform: 'translateY(-33px)',
|
|
202
|
-
}, children: virtualItems.map((virtualRow) => {
|
|
203
|
-
const row = rows[virtualRow.index];
|
|
204
|
-
return ((0, jsx_runtime_1.jsx)(react_components_1.TableRow, { className: (0, react_components_1.mergeClasses)(styles.root), style: {
|
|
209
|
+
background: react_components_1.tokens.colorNeutralBackground1,
|
|
210
|
+
zIndex: 2,
|
|
211
|
+
}, children: table.getHeaderGroups().map((headerGroup) => ((0, jsx_runtime_1.jsx)(react_components_1.TableRow, { style: {
|
|
212
|
+
position: 'sticky',
|
|
213
|
+
top: 0,
|
|
205
214
|
display: 'flex',
|
|
206
|
-
height: `${virtualRow.size}px`,
|
|
207
215
|
minWidth: 'calc(100% - 16px)',
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
})
|
|
215
|
-
}, onDoubleClick: () => {
|
|
216
|
-
const id = row.original[schema.idAttribute];
|
|
217
|
-
openRecord(id);
|
|
218
|
-
}, children: row.getVisibleCells().map((cell) => (0, react_table_1.flexRender)(cell.column.columnDef.cell, Object.assign(Object.assign({}, cell.getContext()), { key: cell.column.id }))) }, row.id));
|
|
219
|
-
}) }), dataState.isFetching && ((0, jsx_runtime_1.jsx)(react_components_1.TableBody, { style: {
|
|
220
|
-
display: 'flex',
|
|
221
|
-
flexDirection: 'column',
|
|
222
|
-
position: 'absolute',
|
|
223
|
-
transform: `translateY(${virtualSize}px)`,
|
|
224
|
-
}, children: Array.from({ length: 10 }).map((_, index) => ((0, jsx_runtime_1.jsx)(react_components_1.TableRow, { style: {
|
|
216
|
+
borderBottom: `${react_components_1.tokens.strokeWidthThin} solid ${react_components_1.tokens.colorNeutralStroke3}`,
|
|
217
|
+
}, children: headerGroup.headers.map((header) => header.isPlaceholder
|
|
218
|
+
? null
|
|
219
|
+
: (0, react_table_1.flexRender)(header.column.columnDef.header, {
|
|
220
|
+
...header.getContext(),
|
|
221
|
+
key: header.id,
|
|
222
|
+
})) }, headerGroup.id))) }), (0, jsx_runtime_1.jsx)(react_components_1.TableBody, { style: {
|
|
225
223
|
display: 'flex',
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
}, children:
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
return ((0, jsx_runtime_1.jsx)(react_components_1.TableCell, { style: {
|
|
224
|
+
flexDirection: 'column',
|
|
225
|
+
transform: 'translateY(-33px)',
|
|
226
|
+
}, children: virtualItems.map((virtualRow) => {
|
|
227
|
+
const row = rows[virtualRow.index];
|
|
228
|
+
return ((0, jsx_runtime_1.jsx)(react_components_1.TableRow, { "aria-selected": row.getIsSelected(), className: (0, react_components_1.mergeClasses)(styles.root), style: {
|
|
232
229
|
display: 'flex',
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
230
|
+
height: `${virtualRow.size}px`,
|
|
231
|
+
minWidth: 'calc(100% - 16px)',
|
|
232
|
+
position: 'absolute',
|
|
233
|
+
transform: `translateY(${virtualRow.start}px)`,
|
|
234
|
+
}, onClick: () => {
|
|
235
|
+
setSelectedIdsRef.current(() => {
|
|
236
|
+
const id = row.original[schema.idAttribute];
|
|
237
|
+
return [id];
|
|
238
|
+
});
|
|
239
|
+
}, onDoubleClick: () => {
|
|
240
|
+
const id = row.original[schema.idAttribute];
|
|
241
|
+
openRecord(id);
|
|
242
|
+
}, children: row.getVisibleCells().map((cell) => (0, react_table_1.flexRender)(cell.column.columnDef.cell, {
|
|
243
|
+
...cell.getContext(),
|
|
244
|
+
key: cell.column.id,
|
|
245
|
+
})) }, row.id));
|
|
246
|
+
}) }), dataState.isFetching && ((0, jsx_runtime_1.jsx)(react_components_1.TableBody, { style: {
|
|
247
|
+
display: 'flex',
|
|
248
|
+
flexDirection: 'column',
|
|
249
|
+
position: 'absolute',
|
|
250
|
+
transform: `translateY(${virtualSize}px)`,
|
|
251
|
+
}, children: Array.from({ length: 10 }).map((_, index) => ((0, jsx_runtime_1.jsx)(react_components_1.TableRow, { style: {
|
|
252
|
+
display: 'flex',
|
|
253
|
+
height: 44,
|
|
254
|
+
alignItems: 'center',
|
|
255
|
+
}, children: table.getAllColumns().map((column) => {
|
|
256
|
+
if (!column.getIsVisible())
|
|
257
|
+
return null;
|
|
258
|
+
return ((0, jsx_runtime_1.jsx)(react_components_1.TableCell, { style: {
|
|
259
|
+
display: 'flex',
|
|
260
|
+
alignItems: 'center',
|
|
261
|
+
width: column.getSize(),
|
|
262
|
+
}, children: (0, jsx_runtime_1.jsx)(react_components_1.SkeletonItem, { size: 16 }) }, column.id));
|
|
263
|
+
}) }, index))) }))] }) }), data?.records.length === 0 && !dataState.isFetching && ((0, jsx_runtime_1.jsxs)("div", { style: {
|
|
264
|
+
display: 'flex',
|
|
265
|
+
flexDirection: 'column',
|
|
266
|
+
alignItems: 'center',
|
|
267
|
+
justifyContent: 'center',
|
|
268
|
+
position: 'absolute',
|
|
269
|
+
inset: 0,
|
|
270
|
+
gap: react_components_1.tokens.spacingVerticalL,
|
|
271
|
+
color: react_components_1.tokens.colorNeutralForeground3,
|
|
272
|
+
}, children: [(0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(icons_1.Icons.Search, { size: 64 }) }), (0, jsx_runtime_1.jsx)(react_components_1.Body1, { children: strings.noRecordsFound })] }))] }) }));
|
|
237
273
|
};
|
|
238
274
|
exports.GridTableContainer = GridTableContainer;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CSSProperties, FC, MouseEventHandler, ReactNode } from 'react';
|
|
2
2
|
export interface TableCellBaseProps {
|
|
3
3
|
children?: ReactNode;
|
|
4
|
-
onClick?: MouseEventHandler
|
|
5
|
-
style?: CSSProperties
|
|
4
|
+
onClick?: MouseEventHandler;
|
|
5
|
+
style?: CSSProperties;
|
|
6
6
|
}
|
|
7
7
|
export declare const TableCellBase: FC<TableCellBaseProps>;
|
|
@@ -4,6 +4,11 @@ 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
6
|
const TableCellBase = ({ children, onClick, style, }) => {
|
|
7
|
-
return ((0, jsx_runtime_1.jsx)(react_components_1.TableCell, { onClick: onClick, style:
|
|
7
|
+
return ((0, jsx_runtime_1.jsx)(react_components_1.TableCell, { onClick: onClick, style: {
|
|
8
|
+
display: 'flex',
|
|
9
|
+
alignItems: 'center',
|
|
10
|
+
// borderBottom: `var(--strokeWidthThin) solid var(--colorNeutralStroke2)`,
|
|
11
|
+
...style,
|
|
12
|
+
}, children: children }));
|
|
8
13
|
};
|
|
9
14
|
exports.TableCellBase = TableCellBase;
|
|
@@ -3,12 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.TableCellCheckbox = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_components_1 = require("@fluentui/react-components");
|
|
6
|
-
const
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
exports.TableCellCheckbox = (0, react_1.memo)(({ checked, onChange }) => {
|
|
7
8
|
return ((0, jsx_runtime_1.jsx)(react_components_1.TableCell, { style: { display: 'flex', alignItems: 'center' }, onClick: (event) => {
|
|
8
9
|
event.stopPropagation();
|
|
9
|
-
}, children: (0, jsx_runtime_1.jsx)(react_components_1.Checkbox, { checked: checked
|
|
10
|
+
}, children: (0, jsx_runtime_1.jsx)(react_components_1.Checkbox, { checked: checked ?? false, onChange: (event) => {
|
|
10
11
|
event.stopPropagation();
|
|
11
|
-
onChange
|
|
12
|
+
onChange?.(event);
|
|
12
13
|
} }) }));
|
|
13
|
-
};
|
|
14
|
-
exports.TableCellCheckbox = TableCellCheckbox;
|
|
14
|
+
});
|
|
15
|
+
exports.TableCellCheckbox.displayName = 'TableCellCheckbox';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ChoiceAttribute } from '@headless-adminapp/core/attributes';
|
|
2
|
+
import { ViewColumn } from '@headless-adminapp/core/experience/view';
|
|
3
|
+
import { Schema } from '@headless-adminapp/core/schema';
|
|
4
|
+
import { UniqueRecord } from '../types';
|
|
5
|
+
interface TableCellChoiceProps {
|
|
6
|
+
column: ViewColumn;
|
|
7
|
+
schema: Schema;
|
|
8
|
+
record: UniqueRecord;
|
|
9
|
+
value: unknown;
|
|
10
|
+
attribute: ChoiceAttribute<string | number>;
|
|
11
|
+
formattedValue: string;
|
|
12
|
+
width: number;
|
|
13
|
+
}
|
|
14
|
+
export declare function TableCellChoice(props: TableCellChoiceProps): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TableCellChoice = TableCellChoice;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_components_1 = require("@fluentui/react-components");
|
|
6
|
+
const color_1 = require("@headless-adminapp/app/utils/color");
|
|
7
|
+
const react_1 = require("react");
|
|
8
|
+
const TableCellBase_1 = require("./TableCellBase");
|
|
9
|
+
function TableCellChoice(props) {
|
|
10
|
+
const bgColor = (0, react_1.useMemo)(() => {
|
|
11
|
+
if (!props.value || !props.attribute.options) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
return props.attribute.options.find((option) => option.value === props.value)?.color;
|
|
15
|
+
}, [props.attribute.options, props.value]);
|
|
16
|
+
const color = (0, react_1.useMemo)(() => {
|
|
17
|
+
if (!bgColor) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
return (0, color_1.isColorDark)(bgColor) ? '#FFFFFF' : '#000000';
|
|
21
|
+
}, [bgColor]);
|
|
22
|
+
return ((0, jsx_runtime_1.jsx)(TableCellBase_1.TableCellBase, { style: {
|
|
23
|
+
textOverflow: 'ellipsis',
|
|
24
|
+
overflow: 'hidden',
|
|
25
|
+
whiteSpace: 'nowrap',
|
|
26
|
+
width: props.width,
|
|
27
|
+
minWidth: props.width,
|
|
28
|
+
maxWidth: props.width,
|
|
29
|
+
}, children: (0, jsx_runtime_1.jsx)(react_components_1.Badge, { style: {
|
|
30
|
+
backgroundColor: bgColor,
|
|
31
|
+
color,
|
|
32
|
+
fontWeight: react_components_1.tokens.fontWeightRegular,
|
|
33
|
+
}, children: props.formattedValue }) }));
|
|
34
|
+
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
2
|
export interface TableCellLinkProps {
|
|
3
|
-
value:
|
|
3
|
+
value: React.ReactNode | undefined | null;
|
|
4
4
|
href?: string;
|
|
5
5
|
onClick?: () => void;
|
|
6
6
|
width: number;
|
|
7
|
+
target?: string;
|
|
7
8
|
}
|
|
8
9
|
export declare const TableCellLink: FC<TableCellLinkProps>;
|
|
@@ -4,7 +4,8 @@ exports.TableCellLink = 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 hooks_1 = require("@headless-adminapp/app/route/hooks");
|
|
7
|
-
const
|
|
7
|
+
const react_1 = require("react");
|
|
8
|
+
exports.TableCellLink = (0, react_1.memo)(({ value, href, onClick, width, target }) => {
|
|
8
9
|
const router = (0, hooks_1.useRouter)();
|
|
9
10
|
return ((0, jsx_runtime_1.jsx)(react_components_1.TableCell, { style: {
|
|
10
11
|
textOverflow: 'ellipsis',
|
|
@@ -15,7 +16,10 @@ const TableCellLink = ({ value, href, onClick, width, }) => {
|
|
|
15
16
|
maxWidth: width,
|
|
16
17
|
display: 'flex',
|
|
17
18
|
alignItems: 'center',
|
|
18
|
-
}, children: (0, jsx_runtime_1.jsx)(react_components_1.Link, { as: "a", href: href, onClick: (event) => {
|
|
19
|
+
}, children: (0, jsx_runtime_1.jsx)(react_components_1.Link, { as: "a", href: href, target: target, onClick: (event) => {
|
|
20
|
+
if (target === '_blank') {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
19
23
|
if (event.metaKey || event.ctrlKey) {
|
|
20
24
|
return;
|
|
21
25
|
}
|
|
@@ -24,10 +28,14 @@ const TableCellLink = ({ value, href, onClick, width, }) => {
|
|
|
24
28
|
onClick();
|
|
25
29
|
return;
|
|
26
30
|
}
|
|
27
|
-
if (href
|
|
31
|
+
if (href?.startsWith('/')) {
|
|
28
32
|
router.push(href);
|
|
29
33
|
event.preventDefault();
|
|
30
34
|
}
|
|
35
|
+
}, style: {
|
|
36
|
+
display: 'flex',
|
|
37
|
+
alignItems: 'center',
|
|
38
|
+
gap: react_components_1.tokens.spacingHorizontalXS,
|
|
31
39
|
}, children: value }) }));
|
|
32
|
-
};
|
|
33
|
-
exports.TableCellLink = TableCellLink;
|
|
40
|
+
});
|
|
41
|
+
exports.TableCellLink.displayName = 'TableCellLink';
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TableCellText = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
5
6
|
const TableCellBase_1 = require("./TableCellBase");
|
|
6
|
-
|
|
7
|
+
exports.TableCellText = (0, react_1.memo)(({ value, width, textAlignment }) => {
|
|
7
8
|
return ((0, jsx_runtime_1.jsx)(TableCellBase_1.TableCellBase, { style: {
|
|
8
9
|
textAlign: textAlignment || 'left',
|
|
9
10
|
textOverflow: 'ellipsis',
|
|
@@ -19,6 +20,10 @@ const TableCellText = ({ value, width, textAlignment, }) => {
|
|
|
19
20
|
// display: 'flex',
|
|
20
21
|
// alignItems: 'center',
|
|
21
22
|
// borderBottom: `${tokens.strokeWidthThin} solid ${tokens.colorNeutralStroke3}`,
|
|
22
|
-
}, children: (0, jsx_runtime_1.jsx)("div", { style: {
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
}, children: (0, jsx_runtime_1.jsx)("div", { style: {
|
|
24
|
+
overflow: 'hidden',
|
|
25
|
+
textOverflow: 'ellipsis',
|
|
26
|
+
width: '100%',
|
|
27
|
+
}, children: value }) }));
|
|
28
|
+
});
|
|
29
|
+
exports.TableCellText.displayName = 'TableCellText';
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Data } from '@headless-adminapp/core/transport';
|
|
1
|
+
import { UniqueRecord } from './types';
|
|
3
2
|
export declare function useTableColumns({ disableSelection, disableContextMenu, disableColumnResize, disableColumnFilter, disableColumnSort, tableWrapperRef, }: {
|
|
4
3
|
disableSelection?: boolean;
|
|
5
4
|
disableContextMenu?: boolean;
|
|
@@ -7,4 +6,4 @@ export declare function useTableColumns({ disableSelection, disableContextMenu,
|
|
|
7
6
|
disableColumnFilter?: boolean;
|
|
8
7
|
disableColumnSort?: boolean;
|
|
9
8
|
tableWrapperRef: React.RefObject<HTMLDivElement>;
|
|
10
|
-
}): import("@tanstack/react-table").AccessorFnColumnDef<
|
|
9
|
+
}): import("@tanstack/react-table").AccessorFnColumnDef<UniqueRecord, unknown>[];
|