@headless-adminapp/fluent 0.0.17-alpha.52 → 0.0.17-alpha.55
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/AppHeaderContianer.js +13 -11
- package/App/AppLogo.js +1 -2
- package/App/LayoutProvider.js +3 -15
- package/App/NavigationContainer.js +2 -6
- package/App/QuickActionItem.js +1 -1
- package/App/utils.d.ts +1 -1
- package/App/utils.js +3 -4
- package/CommandBar/MenuItem.js +1 -1
- package/CommandBar/MenuItems.js +1 -4
- package/CommandBar/MenuList.js +1 -1
- package/DataGrid/CustomizeColumns/AddColumns.js +33 -34
- package/DataGrid/CustomizeColumns/ColumnItem.js +5 -5
- package/DataGrid/CustomizeColumns/CustomizeColumns.js +2 -3
- package/DataGrid/FormSubgridViewSelector.js +1 -5
- package/DataGrid/GridColumnHeader/ConditionValueControl.js +19 -25
- package/DataGrid/GridColumnHeader/FilterForm.js +6 -9
- package/DataGrid/GridColumnHeader/OperatorSelect.js +1 -1
- package/DataGrid/GridColumnHeader/TableHeaderFilterCell.js +4 -4
- package/DataGrid/GridHeaderDesktop.js +1 -5
- package/DataGrid/GridHeaderMobile.js +1 -4
- package/DataGrid/GridListContainer.js +9 -7
- package/DataGrid/GridPaginationContainer.js +1 -2
- package/DataGrid/GridTableContainer.js +25 -20
- package/DataGrid/TableCell/TableCellBase.js +6 -1
- package/DataGrid/TableCell/TableCellCheckbox.js +2 -2
- package/DataGrid/TableCell/TableCellChoice.js +1 -2
- package/DataGrid/TableCell/TableCellLink.d.ts +1 -1
- package/DataGrid/TableCell/TableCellLink.js +5 -1
- package/DataGrid/useTableColumns.js +85 -41
- 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.js +22 -31
- package/Insights/CommandBarContainer.js +4 -1
- package/Insights/FilterBarContainer.js +12 -20
- package/Insights/WidgetDataGridContainer.js +11 -2
- package/Insights/WidgetTableContainer.js +2 -3
- package/Insights/WidgetTitleBar.js +1 -2
- package/Insights/charts/ComposedChart.js +1 -2
- package/Insights/charts/CustomTooltipContent.js +1 -1
- package/Insights/charts/OhlcChart.js +8 -7
- package/Insights/charts/PieChart.js +4 -8
- package/Insights/charts/RadarChart.js +2 -3
- package/Insights/charts/ScatterChart.js +4 -9
- package/Insights/charts/formatters.js +4 -6
- package/Insights/charts/renderers.js +1 -2
- package/Insights/hooks/useQueriesData.js +3 -12
- package/Insights/hooks/useWidgetDetail.js +9 -3
- package/OverflowCommandBar/OverflowMenu.js +4 -16
- package/OverflowCommandBar/render.js +3 -4
- package/OverflowCommandBar/utils.js +2 -3
- package/PageBoard/BoardColumnCard.d.ts +1 -1
- package/PageBoard/BoardColumnCard.js +3 -2
- package/PageBoard/BoardColumnUI.js +12 -17
- package/PageBoard/Header.js +3 -12
- package/PageBoard/PageBoard.d.ts +1 -1
- package/PageBoard/PageBoard.js +2 -3
- package/PageEntityForm/PageEntityFormDesktopContainer.js +8 -5
- package/PageEntityForm/RecordCard.js +8 -4
- package/PageEntityForm/RecordCardLoading.js +1 -2
- package/PageEntityForm/RecordSetNavigatorContainer.js +1 -2
- package/PageEntityForm/RelatedViewSelector.js +5 -10
- package/PageEntityForm/SectionContainer.js +7 -6
- package/PageEntityForm/StandardControl.d.ts +3 -3
- package/PageEntityForm/StandardControl.js +33 -32
- package/PageEntityForm/SubgridControl.js +2 -3
- package/ToastNotificationContainer/index.js +1 -2
- package/components/DndProvider.d.ts +12 -0
- package/components/DndProvider.js +68 -0
- package/components/LoginForm.js +5 -21
- package/form/FormControl.js +17 -28
- package/form/controls/AttachmentControl.js +13 -22
- package/form/controls/AttachmentsControl.js +8 -18
- package/form/controls/CurrencyControl.js +4 -4
- package/form/controls/DateControl.js +2 -2
- package/form/controls/DateRangeControl.js +4 -6
- package/form/controls/DateTimeControl.js +7 -7
- package/form/controls/DecimalControl.js +4 -4
- package/form/controls/DurationControl.js +3 -3
- package/form/controls/EmailControl.js +4 -4
- package/form/controls/IntegerControl.js +5 -5
- package/form/controls/LookupControl.d.ts +1 -0
- package/form/controls/LookupControl.js +50 -11
- 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.js +1 -1
- package/form/controls/SelectControl.js +4 -5
- package/form/controls/SwitchControl.js +1 -1
- package/form/controls/TelephoneControl.js +1 -1
- package/form/controls/TextAreaControl.js +4 -4
- package/form/controls/TextControl.js +4 -4
- package/form/controls/UrlControl.js +1 -1
- package/form/controls/useLookupData.js +26 -41
- package/form/layout/FormSection/FormSection.js +10 -3
- package/form/layout/FormTab/FormTab.js +2 -2
- package/package.json +4 -11
- package/utils/avatar.d.ts +2 -0
- package/utils/avatar.js +45 -0
- package/DataGrid/ScrollbarWithMoreDataRequest.d.ts +0 -9
- package/DataGrid/ScrollbarWithMoreDataRequest.js +0 -33
- package/form/controls/NumberControl.d.ts +0 -4
- package/form/controls/NumberControl.js +0 -16
- package/form/controls/utils.d.ts +0 -4
- package/form/controls/utils.js +0 -42
|
@@ -24,9 +24,6 @@ const GridHeaderMobile = () => {
|
|
|
24
24
|
gap: 16,
|
|
25
25
|
justifyContent: 'space-between',
|
|
26
26
|
display: 'flex',
|
|
27
|
-
}, children: (0, jsx_runtime_1.jsxs)(react_components_1.Menu, { hasIcons: true, children: [(0, jsx_runtime_1.jsx)(react_components_1.MenuTrigger, { children: (0, jsx_runtime_1.jsx)(react_components_1.Button, { appearance: "subtle", icon: (0, jsx_runtime_1.jsx)(icons_1.Icons.Filter, {}), iconPosition: "after" }) }), (0, jsx_runtime_1.jsx)(react_components_1.MenuPopover, { children: (0, jsx_runtime_1.jsx)(react_components_1.MenuList, { children: viewLookup.map((view) => {
|
|
28
|
-
var _a, _b;
|
|
29
|
-
return ((0, jsx_runtime_1.jsx)(react_components_1.MenuItem, { onClick: () => changeView(view.id), icon: selectedView.id === view.id ? ((0, jsx_runtime_1.jsx)(icons_1.Icons.Checkmark, {})) : undefined, children: (_b = (_a = view.localizedNames) === null || _a === void 0 ? void 0 : _a[language]) !== null && _b !== void 0 ? _b : view.name }, view.id));
|
|
30
|
-
}) }) })] }) })] }));
|
|
27
|
+
}, children: (0, jsx_runtime_1.jsxs)(react_components_1.Menu, { hasIcons: true, children: [(0, jsx_runtime_1.jsx)(react_components_1.MenuTrigger, { children: (0, jsx_runtime_1.jsx)(react_components_1.Button, { appearance: "subtle", icon: (0, jsx_runtime_1.jsx)(icons_1.Icons.Filter, {}), iconPosition: "after" }) }), (0, jsx_runtime_1.jsx)(react_components_1.MenuPopover, { children: (0, jsx_runtime_1.jsx)(react_components_1.MenuList, { children: viewLookup.map((view) => ((0, jsx_runtime_1.jsx)(react_components_1.MenuItem, { onClick: () => changeView(view.id), icon: selectedView.id === view.id ? ((0, jsx_runtime_1.jsx)(icons_1.Icons.Checkmark, {})) : undefined, children: view.localizedNames?.[language] ?? view.name }, view.id))) }) })] }) })] }));
|
|
31
28
|
};
|
|
32
29
|
exports.GridHeaderMobile = GridHeaderMobile;
|
|
@@ -35,13 +35,15 @@ const GridListContainer = () => {
|
|
|
35
35
|
const dataRef = (0, react_1.useRef)(data);
|
|
36
36
|
dataRef.current = data;
|
|
37
37
|
const uniqueRecords = (0, react_1.useMemo)(() => {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
return (data?.records.map((record) => ({
|
|
39
|
+
...record,
|
|
40
|
+
__uuid: (0, uuid_1.v4)(),
|
|
41
|
+
})) ?? fallbackData);
|
|
42
|
+
}, [data?.records]);
|
|
41
43
|
const rows = uniqueRecords;
|
|
42
44
|
const virtualizer = (0, react_virtual_1.useVirtualizer)({
|
|
43
45
|
count: rows.length,
|
|
44
|
-
getScrollElement: () =>
|
|
46
|
+
getScrollElement: () => tableWrapperRef.current?.parentElement?.parentElement,
|
|
45
47
|
estimateSize: () => 40,
|
|
46
48
|
overscan: 5,
|
|
47
49
|
enabled: true,
|
|
@@ -51,14 +53,14 @@ const GridListContainer = () => {
|
|
|
51
53
|
const recordSetSetter = (0, hooks_2.useRecordSetSetter)();
|
|
52
54
|
const openFormInternal = (0, navigation_1.useOpenForm)();
|
|
53
55
|
const openRecord = (0, react_1.useCallback)((id) => {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
+
recordSetSetter(schema.logicalName, dataRef.current?.records.map((x) => x[schema.idAttribute]) ??
|
|
57
|
+
[]);
|
|
56
58
|
openFormInternal({
|
|
57
59
|
logicalName: schema.logicalName,
|
|
58
60
|
id,
|
|
59
61
|
});
|
|
60
62
|
}, [openFormInternal, recordSetSetter, schema.idAttribute, schema.logicalName]);
|
|
61
|
-
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
|
|
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: () => {
|
|
62
64
|
fetchNextPage();
|
|
63
65
|
}, children: (0, jsx_runtime_1.jsx)("div", { style: {
|
|
64
66
|
position: 'relative',
|
|
@@ -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;
|
|
@@ -66,7 +66,6 @@ const useStyles = (0, react_components_1.makeStyles)({
|
|
|
66
66
|
});
|
|
67
67
|
const fallbackData = [];
|
|
68
68
|
const GridTableContainer = ({ noPadding, disableColumnFilter, disableColumnSort, disableColumnResize, disableContextMenu, disableSelection, }) => {
|
|
69
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
70
69
|
const styles = useStyles();
|
|
71
70
|
const data = (0, hooks_1.useGridData)();
|
|
72
71
|
const dataState = (0, hooks_1.useGridDataState)();
|
|
@@ -87,8 +86,8 @@ const GridTableContainer = ({ noPadding, disableColumnFilter, disableColumnSort,
|
|
|
87
86
|
const recordSetSetter = (0, hooks_2.useRecordSetSetter)();
|
|
88
87
|
const openFormInternal = (0, navigation_1.useOpenForm)();
|
|
89
88
|
const openRecord = (0, react_1.useCallback)((id) => {
|
|
90
|
-
|
|
91
|
-
|
|
89
|
+
recordSetSetter(schema.logicalName, dataRef.current?.records.map((x) => x[schema.idAttribute]) ??
|
|
90
|
+
[]);
|
|
92
91
|
openFormInternal({
|
|
93
92
|
logicalName: schema.logicalName,
|
|
94
93
|
id,
|
|
@@ -107,9 +106,11 @@ const GridTableContainer = ({ noPadding, disableColumnFilter, disableColumnSort,
|
|
|
107
106
|
tableWrapperRef,
|
|
108
107
|
});
|
|
109
108
|
const uniqueRecords = (0, react_1.useMemo)(() => {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
109
|
+
return (data?.records.map((record) => ({
|
|
110
|
+
...record,
|
|
111
|
+
__uuid: (0, uuid_1.v4)(),
|
|
112
|
+
})) ?? fallbackData);
|
|
113
|
+
}, [data?.records]);
|
|
113
114
|
const idMapping = (0, react_1.useMemo)(() => uniqueRecords.reduce((acc, record) => {
|
|
114
115
|
acc[record[schema.idAttribute]] = record.__uuid;
|
|
115
116
|
return acc;
|
|
@@ -144,7 +145,7 @@ const GridTableContainer = ({ noPadding, disableColumnFilter, disableColumnSort,
|
|
|
144
145
|
const rows = table.getRowModel().rows;
|
|
145
146
|
const virtualizer = (0, react_virtual_1.useVirtualizer)({
|
|
146
147
|
count: rows.length,
|
|
147
|
-
getScrollElement: () =>
|
|
148
|
+
getScrollElement: () => tableWrapperRef.current?.parentElement?.parentElement,
|
|
148
149
|
estimateSize: () => 44,
|
|
149
150
|
overscan: 30,
|
|
150
151
|
paddingStart: 33,
|
|
@@ -159,18 +160,16 @@ const GridTableContainer = ({ noPadding, disableColumnFilter, disableColumnSort,
|
|
|
159
160
|
}, [virtualSize]);
|
|
160
161
|
// callback to handle scrolling, checking if we are near the bottom
|
|
161
162
|
const handleScroll = (0, react_1.useCallback)(() => {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
const
|
|
165
|
-
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;
|
|
166
166
|
setIsScrollNearBottom(scrollPosition > virtualSize * 0.95 - visibleHeight);
|
|
167
167
|
}
|
|
168
168
|
}, [virtualSize]);
|
|
169
169
|
// add an event listener on the scrollable parent container and resize the
|
|
170
170
|
// pseudo element whenever the table renders with new data
|
|
171
171
|
(0, react_1.useEffect)(() => {
|
|
172
|
-
|
|
173
|
-
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;
|
|
174
173
|
if (scrollable)
|
|
175
174
|
scrollable.addEventListener('scroll', handleScroll);
|
|
176
175
|
handlePseudoResize();
|
|
@@ -186,10 +185,10 @@ const GridTableContainer = ({ noPadding, disableColumnFilter, disableColumnSort,
|
|
|
186
185
|
if (isScrollNearBottom)
|
|
187
186
|
handlePseudoResize();
|
|
188
187
|
}, [isScrollNearBottom, virtualItems.length, handlePseudoResize]);
|
|
189
|
-
const isScrolledToRight =
|
|
190
|
-
(
|
|
191
|
-
(
|
|
192
|
-
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
|
|
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: () => {
|
|
193
192
|
fetchNextPage();
|
|
194
193
|
}, children: [(0, jsx_runtime_1.jsx)("div", { style: {
|
|
195
194
|
paddingInline: noPadding ? 0 : 8,
|
|
@@ -217,7 +216,10 @@ const GridTableContainer = ({ noPadding, disableColumnFilter, disableColumnSort,
|
|
|
217
216
|
borderBottom: `${react_components_1.tokens.strokeWidthThin} solid ${react_components_1.tokens.colorNeutralStroke3}`,
|
|
218
217
|
}, children: headerGroup.headers.map((header) => header.isPlaceholder
|
|
219
218
|
? null
|
|
220
|
-
: (0, react_table_1.flexRender)(header.column.columnDef.header,
|
|
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: {
|
|
221
223
|
display: 'flex',
|
|
222
224
|
flexDirection: 'column',
|
|
223
225
|
transform: 'translateY(-33px)',
|
|
@@ -237,7 +239,10 @@ const GridTableContainer = ({ noPadding, disableColumnFilter, disableColumnSort,
|
|
|
237
239
|
}, onDoubleClick: () => {
|
|
238
240
|
const id = row.original[schema.idAttribute];
|
|
239
241
|
openRecord(id);
|
|
240
|
-
}, children: row.getVisibleCells().map((cell) => (0, react_table_1.flexRender)(cell.column.columnDef.cell,
|
|
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));
|
|
241
246
|
}) }), dataState.isFetching && ((0, jsx_runtime_1.jsx)(react_components_1.TableBody, { style: {
|
|
242
247
|
display: 'flex',
|
|
243
248
|
flexDirection: 'column',
|
|
@@ -255,7 +260,7 @@ const GridTableContainer = ({ noPadding, disableColumnFilter, disableColumnSort,
|
|
|
255
260
|
alignItems: 'center',
|
|
256
261
|
width: column.getSize(),
|
|
257
262
|
}, children: (0, jsx_runtime_1.jsx)(react_components_1.SkeletonItem, { size: 16 }) }, column.id));
|
|
258
|
-
}) }, index))) }))] }) }),
|
|
263
|
+
}) }, index))) }))] }) }), data?.records.length === 0 && !dataState.isFetching && ((0, jsx_runtime_1.jsxs)("div", { style: {
|
|
259
264
|
display: 'flex',
|
|
260
265
|
flexDirection: 'column',
|
|
261
266
|
alignItems: 'center',
|
|
@@ -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;
|
|
@@ -7,9 +7,9 @@ const react_1 = require("react");
|
|
|
7
7
|
exports.TableCellCheckbox = (0, react_1.memo)(({ checked, onChange }) => {
|
|
8
8
|
return ((0, jsx_runtime_1.jsx)(react_components_1.TableCell, { style: { display: 'flex', alignItems: 'center' }, onClick: (event) => {
|
|
9
9
|
event.stopPropagation();
|
|
10
|
-
}, 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) => {
|
|
11
11
|
event.stopPropagation();
|
|
12
|
-
onChange
|
|
12
|
+
onChange?.(event);
|
|
13
13
|
} }) }));
|
|
14
14
|
});
|
|
15
15
|
exports.TableCellCheckbox.displayName = 'TableCellCheckbox';
|
|
@@ -8,11 +8,10 @@ const react_1 = require("react");
|
|
|
8
8
|
const TableCellBase_1 = require("./TableCellBase");
|
|
9
9
|
function TableCellChoice(props) {
|
|
10
10
|
const bgColor = (0, react_1.useMemo)(() => {
|
|
11
|
-
var _a;
|
|
12
11
|
if (!props.value || !props.attribute.options) {
|
|
13
12
|
return;
|
|
14
13
|
}
|
|
15
|
-
return
|
|
14
|
+
return props.attribute.options.find((option) => option.value === props.value)?.color;
|
|
16
15
|
}, [props.attribute.options, props.value]);
|
|
17
16
|
const color = (0, react_1.useMemo)(() => {
|
|
18
17
|
if (!bgColor) {
|
|
@@ -28,10 +28,14 @@ exports.TableCellLink = (0, react_1.memo)(({ value, href, onClick, width, target
|
|
|
28
28
|
onClick();
|
|
29
29
|
return;
|
|
30
30
|
}
|
|
31
|
-
if (href
|
|
31
|
+
if (href?.startsWith('/')) {
|
|
32
32
|
router.push(href);
|
|
33
33
|
event.preventDefault();
|
|
34
34
|
}
|
|
35
|
+
}, style: {
|
|
36
|
+
display: 'flex',
|
|
37
|
+
alignItems: 'center',
|
|
38
|
+
gap: react_components_1.tokens.spacingHorizontalXS,
|
|
35
39
|
}, children: value }) }));
|
|
36
40
|
});
|
|
37
41
|
exports.TableCellLink.displayName = 'TableCellLink';
|
|
@@ -20,6 +20,7 @@ const componentStore_1 = require("../componentStore");
|
|
|
20
20
|
const GridColumnHeader_1 = require("../DataGrid/GridColumnHeader");
|
|
21
21
|
const TableCell_1 = require("../DataGrid/TableCell");
|
|
22
22
|
const TableCellLink_1 = require("../DataGrid/TableCell/TableCellLink");
|
|
23
|
+
const avatar_1 = require("../utils/avatar");
|
|
23
24
|
const ActionCell_1 = require("./ActionCell");
|
|
24
25
|
const TableCellChoice_1 = require("./TableCell/TableCellChoice");
|
|
25
26
|
const columnHelper = (0, react_table_1.createColumnHelper)();
|
|
@@ -55,18 +56,14 @@ function useTableColumns({ disableSelection, disableContextMenu, disableColumnRe
|
|
|
55
56
|
}, [contextCommands, mutableContextCommandState]);
|
|
56
57
|
const tableWrapperSize = (0, hooks_2.useElementSize)(tableWrapperRef, 100);
|
|
57
58
|
const columnWidths = (0, react_1.useMemo)(() => {
|
|
58
|
-
|
|
59
|
-
const availableWidth = Math.max(0, ((_a = tableWrapperSize.width) !== null && _a !== void 0 ? _a : 0) - 32 - 32 - 16);
|
|
59
|
+
const availableWidth = Math.max(0, (tableWrapperSize.width ?? 0) - 32 - 32 - 16);
|
|
60
60
|
const { columns: calculatedColumns } = (0, utils_1.calculateColumnWidths)({
|
|
61
61
|
availableWidth,
|
|
62
62
|
gapWidth: 0,
|
|
63
|
-
columns: columns.map((column) => {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
maxWidth: (_b = column.maxWidth) !== null && _b !== void 0 ? _b : 1000,
|
|
68
|
-
});
|
|
69
|
-
}),
|
|
63
|
+
columns: columns.map((column) => ({
|
|
64
|
+
width: column.width ?? 100,
|
|
65
|
+
maxWidth: column.maxWidth ?? 1000,
|
|
66
|
+
})),
|
|
70
67
|
});
|
|
71
68
|
return calculatedColumns;
|
|
72
69
|
}, [columns, tableWrapperSize.width]);
|
|
@@ -79,18 +76,17 @@ function useTableColumns({ disableSelection, disableContextMenu, disableColumnRe
|
|
|
79
76
|
const dataRef = (0, react_1.useRef)(data);
|
|
80
77
|
dataRef.current = data;
|
|
81
78
|
const headingSelectionState = (0, react_1.useMemo)(() => {
|
|
82
|
-
|
|
83
|
-
if ((data === null || data === void 0 ? void 0 : data.records.length) === 0) {
|
|
79
|
+
if (data?.records.length === 0) {
|
|
84
80
|
return false;
|
|
85
81
|
}
|
|
86
82
|
if (selectedIds.length === 0) {
|
|
87
83
|
return false;
|
|
88
84
|
}
|
|
89
|
-
if (selectedIds.length ===
|
|
85
|
+
if (selectedIds.length === dataRef.current?.records.length) {
|
|
90
86
|
return true;
|
|
91
87
|
}
|
|
92
88
|
return 'mixed';
|
|
93
|
-
}, [data
|
|
89
|
+
}, [data?.records.length, selectedIds]);
|
|
94
90
|
const actionColumns = (0, react_1.useMemo)(() => {
|
|
95
91
|
if (disableContextMenu)
|
|
96
92
|
return [];
|
|
@@ -125,13 +121,11 @@ function useTableColumns({ disableSelection, disableContextMenu, disableColumnRe
|
|
|
125
121
|
if (disableSelection)
|
|
126
122
|
return [];
|
|
127
123
|
function getAllIds() {
|
|
128
|
-
|
|
129
|
-
return ((_b = (_a = dataRef.current) === null || _a === void 0 ? void 0 : _a.records.map((record) => record[schema.idAttribute])) !== null && _b !== void 0 ? _b : []);
|
|
124
|
+
return (dataRef.current?.records.map((record) => record[schema.idAttribute]) ?? []);
|
|
130
125
|
}
|
|
131
126
|
function toggleAllSelectedIds() {
|
|
132
127
|
setSelectedIdsRef.current((ids) => {
|
|
133
|
-
|
|
134
|
-
if (ids.length === ((_a = dataRef.current) === null || _a === void 0 ? void 0 : _a.records.length)) {
|
|
128
|
+
if (ids.length === dataRef.current?.records.length) {
|
|
135
129
|
return [];
|
|
136
130
|
}
|
|
137
131
|
return getAllIds();
|
|
@@ -247,7 +241,6 @@ function renderCellHeaderContent({ column, props, disableColumnResize, disableCo
|
|
|
247
241
|
return ((0, jsx_runtime_1.jsx)(GridColumnHeader_1.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
242
|
}
|
|
249
243
|
function renderCellContent({ info, column, schema, schemaStore, locale, routeResolver, openRecord, recordSetSetter, router, }) {
|
|
250
|
-
var _a, _b, _c;
|
|
251
244
|
const { currency, dateFormats, timezone, timeFormats } = locale;
|
|
252
245
|
let attribute;
|
|
253
246
|
let value;
|
|
@@ -257,13 +250,13 @@ function renderCellContent({ info, column, schema, schemaStore, locale, routeRes
|
|
|
257
250
|
const entity = schema.attributes[lookup].entity;
|
|
258
251
|
const lookupSchema = schemaStore.getSchema(entity);
|
|
259
252
|
attribute = lookupSchema.attributes[field];
|
|
260
|
-
value =
|
|
253
|
+
value = info.row.original.$expand?.[lookup]?.[field];
|
|
261
254
|
}
|
|
262
255
|
else {
|
|
263
256
|
attribute = schema.attributes[column.name];
|
|
264
257
|
value = info.getValue();
|
|
265
258
|
}
|
|
266
|
-
const formattedValue = (
|
|
259
|
+
const formattedValue = (0, utils_1.getAttributeFormattedValue)(attribute, value, {
|
|
267
260
|
currency: currency.currency,
|
|
268
261
|
dateFormat: dateFormats.short,
|
|
269
262
|
timeFormat: timeFormats.short,
|
|
@@ -271,7 +264,7 @@ function renderCellContent({ info, column, schema, schemaStore, locale, routeRes
|
|
|
271
264
|
currencyDisplay: currency.currencyDisplay,
|
|
272
265
|
currencySign: currency.currencySign,
|
|
273
266
|
locale: locale.locale,
|
|
274
|
-
})
|
|
267
|
+
}) ?? '';
|
|
275
268
|
if (column.plainText) {
|
|
276
269
|
return ((0, jsx_runtime_1.jsx)(TableCell_1.TableCellText, { value: formattedValue, width: info.column.getSize() }, column.id));
|
|
277
270
|
}
|
|
@@ -283,34 +276,33 @@ function renderCellContent({ info, column, schema, schemaStore, locale, routeRes
|
|
|
283
276
|
return ((0, jsx_runtime_1.jsx)(Component, { column: column, schema: schema, record: info.row.original, value: value, attribute: attribute, formattedValue: formattedValue, width: info.column.getSize() }));
|
|
284
277
|
}
|
|
285
278
|
if (schema.primaryAttribute === column.name) {
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
279
|
+
return renderPrimaryAttribute({
|
|
280
|
+
info,
|
|
281
|
+
column,
|
|
282
|
+
routeResolver,
|
|
283
|
+
openRecord,
|
|
284
|
+
schema,
|
|
285
|
+
value: value,
|
|
290
286
|
});
|
|
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
287
|
}
|
|
295
|
-
switch (attribute
|
|
288
|
+
switch (attribute?.type) {
|
|
296
289
|
case 'money':
|
|
297
290
|
return ((0, jsx_runtime_1.jsx)(TableCell_1.TableCellText, { value: formattedValue, width: info.column.getSize(), textAlignment: "right" }, column.id));
|
|
298
291
|
case 'lookup': {
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
292
|
+
return renderLookupAttribute({
|
|
293
|
+
info,
|
|
294
|
+
column,
|
|
295
|
+
schemaStore,
|
|
296
|
+
routeResolver,
|
|
297
|
+
recordSetSetter,
|
|
298
|
+
router,
|
|
299
|
+
value,
|
|
300
|
+
attribute,
|
|
301
|
+
formattedValue,
|
|
306
302
|
});
|
|
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
303
|
}
|
|
312
304
|
case 'attachment': {
|
|
313
|
-
const url = value
|
|
305
|
+
const url = value?.url;
|
|
314
306
|
if (!url) {
|
|
315
307
|
return ((0, jsx_runtime_1.jsx)(TableCell_1.TableCellText, { value: "", width: info.column.getSize() }, column.id));
|
|
316
308
|
}
|
|
@@ -321,3 +313,55 @@ function renderCellContent({ info, column, schema, schemaStore, locale, routeRes
|
|
|
321
313
|
}
|
|
322
314
|
return ((0, jsx_runtime_1.jsx)(TableCell_1.TableCellText, { value: formattedValue, width: info.column.getSize() }, column.id));
|
|
323
315
|
}
|
|
316
|
+
function renderPrimaryAttribute({ info, column, schema, routeResolver, openRecord, value, }) {
|
|
317
|
+
const path = routeResolver({
|
|
318
|
+
logicalName: schema.logicalName,
|
|
319
|
+
type: app_1.PageType.EntityForm,
|
|
320
|
+
id: info.row.original[schema.idAttribute],
|
|
321
|
+
});
|
|
322
|
+
return ((0, jsx_runtime_1.jsx)(TableCellLink_1.TableCellLink, { value: (0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [renderPrimaryAttributeAvatar({
|
|
323
|
+
info,
|
|
324
|
+
schema,
|
|
325
|
+
value,
|
|
326
|
+
}), value] }), width: info.column.getSize(), href: path, onClick: () => {
|
|
327
|
+
openRecord(info.row.original[schema.idAttribute]);
|
|
328
|
+
} }, column.id));
|
|
329
|
+
}
|
|
330
|
+
function renderPrimaryAttributeAvatar({ info, schema, value, }) {
|
|
331
|
+
if (!schema.avatarAttribute) {
|
|
332
|
+
return null;
|
|
333
|
+
}
|
|
334
|
+
const avatarAttribute = schema.attributes[schema.avatarAttribute];
|
|
335
|
+
if (avatarAttribute.type !== 'attachment') {
|
|
336
|
+
return null;
|
|
337
|
+
}
|
|
338
|
+
const avatarValue = info.row.original[schema.avatarAttribute];
|
|
339
|
+
return ((0, jsx_runtime_1.jsx)(react_components_1.Avatar, { style: {
|
|
340
|
+
width: 24,
|
|
341
|
+
height: 24,
|
|
342
|
+
fontSize: react_components_1.tokens.fontSizeBase100,
|
|
343
|
+
}, name: value, color: (0, avatar_1.getAvatarColor)(value), image: {
|
|
344
|
+
src: avatarValue?.url,
|
|
345
|
+
} }));
|
|
346
|
+
}
|
|
347
|
+
function renderLookupAttribute({ value, info, column, schemaStore, routeResolver, recordSetSetter, router, attribute, formattedValue, }) {
|
|
348
|
+
if (!value) {
|
|
349
|
+
return ((0, jsx_runtime_1.jsx)(TableCell_1.TableCellText, { value: "", width: info.column.getSize() }, column.id));
|
|
350
|
+
}
|
|
351
|
+
const lookupSchema = schemaStore.getSchema(attribute.entity);
|
|
352
|
+
const path = routeResolver({
|
|
353
|
+
logicalName: attribute.entity,
|
|
354
|
+
type: app_1.PageType.EntityForm,
|
|
355
|
+
id: value.id,
|
|
356
|
+
});
|
|
357
|
+
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: {
|
|
358
|
+
width: 24,
|
|
359
|
+
height: 24,
|
|
360
|
+
fontSize: react_components_1.tokens.fontSizeBase100,
|
|
361
|
+
}, name: formattedValue, color: (0, avatar_1.getAvatarColor)(formattedValue), image: {
|
|
362
|
+
src: value.avatar,
|
|
363
|
+
} })), formattedValue] }), width: info.column.getSize(), href: path, onClick: () => {
|
|
364
|
+
recordSetSetter('', []);
|
|
365
|
+
router.push(path);
|
|
366
|
+
} }, column.id));
|
|
367
|
+
}
|
|
@@ -4,12 +4,9 @@ exports.AlertDialog = AlertDialog;
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_components_1 = require("@fluentui/react-components");
|
|
6
6
|
function AlertDialog(props) {
|
|
7
|
-
var _a;
|
|
8
7
|
return ((0, jsx_runtime_1.jsx)(react_components_1.Dialog, { open: props.open, onOpenChange: () => {
|
|
9
|
-
|
|
10
|
-
(_a = props.onDismiss) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
8
|
+
props.onDismiss?.();
|
|
11
9
|
}, children: (0, jsx_runtime_1.jsx)(react_components_1.DialogSurface, { style: { maxWidth: 480 }, children: (0, jsx_runtime_1.jsxs)(react_components_1.DialogBody, { children: [!!props.title && (0, jsx_runtime_1.jsx)(react_components_1.DialogTitle, { children: props.title }), (0, jsx_runtime_1.jsx)(react_components_1.DialogContent, { children: props.message }), (0, jsx_runtime_1.jsx)(react_components_1.DialogActions, { children: (0, jsx_runtime_1.jsx)(react_components_1.Button, { appearance: "primary", onClick: () => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}, children: (_a = props.confirmText) !== null && _a !== void 0 ? _a : 'Close' }) })] }) }) }));
|
|
10
|
+
props.onConfirm?.();
|
|
11
|
+
}, children: props.confirmText ?? 'Close' }) })] }) }) }));
|
|
15
12
|
}
|
|
@@ -4,15 +4,11 @@ exports.ConfirmDialog = ConfirmDialog;
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_components_1 = require("@fluentui/react-components");
|
|
6
6
|
function ConfirmDialog(props) {
|
|
7
|
-
var _a, _b;
|
|
8
7
|
return ((0, jsx_runtime_1.jsx)(react_components_1.Dialog, { open: props.open, onOpenChange: () => {
|
|
9
|
-
|
|
10
|
-
(_a = props.onDismiss) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
8
|
+
props.onDismiss?.();
|
|
11
9
|
}, children: (0, jsx_runtime_1.jsx)(react_components_1.DialogSurface, { style: { maxWidth: 480 }, children: (0, jsx_runtime_1.jsxs)(react_components_1.DialogBody, { children: [!!props.title && (0, jsx_runtime_1.jsx)(react_components_1.DialogTitle, { children: props.title }), (0, jsx_runtime_1.jsx)(react_components_1.DialogContent, { children: props.message }), (0, jsx_runtime_1.jsxs)(react_components_1.DialogActions, { children: [(0, jsx_runtime_1.jsx)(react_components_1.Button, { appearance: "secondary", onClick: () => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
(_a = props.onConfirm) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
17
|
-
}, children: (_b = props.confirmText) !== null && _b !== void 0 ? _b : 'Confirm' })] })] }) }) }));
|
|
10
|
+
props.onCancel?.();
|
|
11
|
+
}, children: props.cancelText ?? 'Cancel' }), (0, jsx_runtime_1.jsx)(react_components_1.Button, { appearance: "primary", onClick: () => {
|
|
12
|
+
props.onConfirm?.();
|
|
13
|
+
}, children: props.confirmText ?? 'Confirm' })] })] }) }) }));
|
|
18
14
|
}
|
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
-
var t = {};
|
|
4
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
-
t[p] = s[p];
|
|
6
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
-
t[p[i]] = s[p[i]];
|
|
10
|
-
}
|
|
11
|
-
return t;
|
|
12
|
-
};
|
|
13
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
3
|
exports.DialogContainer = void 0;
|
|
15
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
@@ -21,7 +10,7 @@ const PromptDialog_1 = require("./PromptDialog");
|
|
|
21
10
|
const DialogContainer = () => {
|
|
22
11
|
const items = (0, hooks_1.useDialogItems)();
|
|
23
12
|
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: items.map((item) => {
|
|
24
|
-
const { id, isOpen
|
|
13
|
+
const { id, isOpen, ...options } = item;
|
|
25
14
|
switch (options.type) {
|
|
26
15
|
case 'alert':
|
|
27
16
|
return ((0, jsx_runtime_1.jsx)(AlertDialog_1.AlertDialog, { message: options.text, open: isOpen, confirmText: options.confirmButtonLabel, onConfirm: options.onConfirm, onDismiss: options.onDismiss, title: options.title }, id));
|
|
@@ -35,7 +24,7 @@ const DialogContainer = () => {
|
|
|
35
24
|
// confirmButtonLabel={options.confirmButtonLabel}
|
|
36
25
|
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
26
|
case 'custom':
|
|
38
|
-
return ((0, jsx_runtime_1.jsx)(options.Component,
|
|
27
|
+
return ((0, jsx_runtime_1.jsx)(options.Component, { id: id, isOpen: isOpen, ...options.props }, id));
|
|
39
28
|
}
|
|
40
29
|
return null;
|
|
41
30
|
}) }));
|
|
@@ -5,10 +5,8 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
5
5
|
const react_components_1 = require("@fluentui/react-components");
|
|
6
6
|
const icons_1 = require("@headless-adminapp/icons");
|
|
7
7
|
function ErrorDialog(props) {
|
|
8
|
-
var _a;
|
|
9
8
|
return ((0, jsx_runtime_1.jsx)(react_components_1.Dialog, { open: props.open, onOpenChange: () => {
|
|
10
|
-
|
|
11
|
-
(_a = props.onDismiss) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
9
|
+
props.onDismiss?.();
|
|
12
10
|
}, children: (0, jsx_runtime_1.jsx)(react_components_1.DialogSurface, { style: { maxWidth: 480 }, children: (0, jsx_runtime_1.jsxs)(react_components_1.DialogBody, { children: [(0, jsx_runtime_1.jsxs)(react_components_1.DialogTitle, { style: { display: 'flex', alignItems: 'center' }, children: [(0, jsx_runtime_1.jsx)("span", { style: {
|
|
13
11
|
color: react_components_1.tokens.colorPaletteRedForeground1,
|
|
14
12
|
// marginBottom: tokens.spacingVerticalL,
|
|
@@ -16,7 +14,6 @@ function ErrorDialog(props) {
|
|
|
16
14
|
alignItems: 'center',
|
|
17
15
|
marginRight: react_components_1.tokens.spacingHorizontalS,
|
|
18
16
|
}, children: (0, jsx_runtime_1.jsx)(icons_1.Icons.Error, {}) }), props.title || 'Error'] }), (0, jsx_runtime_1.jsx)(react_components_1.DialogContent, { children: props.message }), (0, jsx_runtime_1.jsx)(react_components_1.DialogActions, { children: (0, jsx_runtime_1.jsx)(react_components_1.Button, { appearance: "primary", style: { background: react_components_1.tokens.colorPaletteRedBackground3 }, onClick: () => {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}, children: (_a = props.confirmText) !== null && _a !== void 0 ? _a : 'Close' }) })] }) }) }));
|
|
17
|
+
props.onConfirm?.();
|
|
18
|
+
}, children: props.confirmText ?? 'Close' }) })] }) }) }));
|
|
22
19
|
}
|