@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.
Files changed (174) hide show
  1. package/App/App.js +7 -11
  2. package/App/AppHeaderContianer.js +38 -42
  3. package/App/AppLogo.js +8 -12
  4. package/App/AppStringContext.js +9 -13
  5. package/App/AppUI.js +11 -15
  6. package/App/LayoutProvider.js +11 -15
  7. package/App/NavigationContainer.js +25 -29
  8. package/App/QuickActionItem.js +5 -9
  9. package/App/index.js +1 -5
  10. package/App/utils.js +1 -4
  11. package/CommandBar/Button.js +14 -17
  12. package/CommandBar/Divider.js +6 -9
  13. package/CommandBar/IconButton.js +13 -16
  14. package/CommandBar/Label.js +8 -11
  15. package/CommandBar/MenuButton.js +17 -20
  16. package/CommandBar/MenuItem.js +15 -18
  17. package/CommandBar/MenuItems.js +8 -11
  18. package/CommandBar/MenuList.js +9 -12
  19. package/CommandBar/Wrapper.js +7 -10
  20. package/CommandBar/index.js +13 -15
  21. package/DataForm/SectionControl.js +4 -7
  22. package/DataGrid/ActionCell.js +11 -14
  23. package/DataGrid/CommandContainer.js +6 -10
  24. package/DataGrid/CustomizeColumns/AddColumns.js +34 -37
  25. package/DataGrid/CustomizeColumns/ColumnItem.js +19 -23
  26. package/DataGrid/CustomizeColumns/CustomizeColumns.js +36 -42
  27. package/DataGrid/CustomizeColumns/index.js +1 -5
  28. package/DataGrid/FormSubgridCommandContainer.js +13 -17
  29. package/DataGrid/FormSubgridViewSelector.js +18 -22
  30. package/DataGrid/GridColumnHeader/ConditionValueControl.js +14 -20
  31. package/DataGrid/GridColumnHeader/FilterForm.js +23 -27
  32. package/DataGrid/GridColumnHeader/OperatorSelect.js +13 -19
  33. package/DataGrid/GridColumnHeader/TableHeaderFilterCell.js +28 -32
  34. package/DataGrid/GridColumnHeader/index.js +1 -5
  35. package/DataGrid/GridColumnHeader/utils.js +2 -6
  36. package/DataGrid/GridHeaderContainer.js +4 -8
  37. package/DataGrid/GridHeaderDesktop.js +26 -30
  38. package/DataGrid/GridHeaderMobile.js +17 -21
  39. package/DataGrid/GridListContainer.js +39 -43
  40. package/DataGrid/GridPaginationContainer.js +12 -16
  41. package/DataGrid/GridTableContainer.js +74 -78
  42. package/DataGrid/TableCell/TableCellAction.js +11 -15
  43. package/DataGrid/TableCell/TableCellBase.js +4 -8
  44. package/DataGrid/TableCell/TableCellCheckbox.js +7 -10
  45. package/DataGrid/TableCell/TableCellChoice.js +11 -14
  46. package/DataGrid/TableCell/TableCellLink.d.ts +1 -1
  47. package/DataGrid/TableCell/TableCellLink.js +13 -12
  48. package/DataGrid/TableCell/TableCellText.js +7 -10
  49. package/DataGrid/TableCell/index.js +4 -20
  50. package/DataGrid/index.js +4 -11
  51. package/DataGrid/types.js +1 -2
  52. package/DataGrid/useTableColumns.js +139 -90
  53. package/DataGrid/utils.js +1 -5
  54. package/DialogContainer/AlertDialog.js +5 -8
  55. package/DialogContainer/ConfirmDialog.js +6 -9
  56. package/DialogContainer/DialogContainer.js +14 -18
  57. package/DialogContainer/ErrorDialog.js +9 -12
  58. package/DialogContainer/PromptDialog.js +30 -57
  59. package/DialogContainer/index.js +1 -5
  60. package/Insights/CommandBarContainer.js +11 -14
  61. package/Insights/FilterBarContainer.js +17 -20
  62. package/Insights/Grid.js +9 -13
  63. package/Insights/InsightsContainer.js +19 -22
  64. package/Insights/WidgetChartContainer.js +30 -34
  65. package/Insights/WidgetDataGridContainer.js +32 -35
  66. package/Insights/WidgetTableContainer.js +24 -28
  67. package/Insights/WidgetTileContainer.js +12 -16
  68. package/Insights/WidgetTitleBar.js +9 -15
  69. package/Insights/Widgets.js +25 -28
  70. package/Insights/charts/AreaChart.js +12 -15
  71. package/Insights/charts/BarChart.js +12 -15
  72. package/Insights/charts/ComposedChart.js +12 -15
  73. package/Insights/charts/CustomTooltipContent.js +8 -12
  74. package/Insights/charts/GaugeChart.js +3 -6
  75. package/Insights/charts/LineChart.js +12 -15
  76. package/Insights/charts/OhlcChart.js +36 -41
  77. package/Insights/charts/PieChart.js +23 -26
  78. package/Insights/charts/RadarChart.js +16 -19
  79. package/Insights/charts/ScatterChart.js +23 -26
  80. package/Insights/charts/constants.js +1 -4
  81. package/Insights/charts/formatters.js +17 -29
  82. package/Insights/charts/index.js +1 -2
  83. package/Insights/charts/renderers.js +25 -36
  84. package/Insights/hooks/useQueriesData.js +19 -25
  85. package/Insights/hooks/useWidgetDetail.js +13 -16
  86. package/OverflowCommandBar/OverflowCommandBar.js +12 -19
  87. package/OverflowCommandBar/OverflowMenu.js +16 -20
  88. package/OverflowCommandBar/OverflowMenuDivider.js +6 -10
  89. package/OverflowCommandBar/index.js +3 -9
  90. package/OverflowCommandBar/render.js +9 -15
  91. package/OverflowCommandBar/utils.js +1 -4
  92. package/PageBoard/BoardColumn.js +5 -8
  93. package/PageBoard/BoardColumnCard.js +12 -15
  94. package/PageBoard/BoardColumnUI.js +34 -38
  95. package/PageBoard/BoardingColumnCardLoading.js +10 -13
  96. package/PageBoard/Header.js +16 -20
  97. package/PageBoard/PageBoard.d.ts +1 -1
  98. package/PageBoard/PageBoard.js +26 -29
  99. package/PageBoard/index.js +1 -5
  100. package/PageEntityForm/CommandContainer.js +21 -25
  101. package/PageEntityForm/FormTabRelated.js +17 -20
  102. package/PageEntityForm/PageEntityForm.js +16 -20
  103. package/PageEntityForm/PageEntityFormDesktopContainer.js +68 -72
  104. package/PageEntityForm/PageEntityFormStringContext.js +5 -9
  105. package/PageEntityForm/ProcessFlow.js +21 -24
  106. package/PageEntityForm/RecordCard.js +21 -24
  107. package/PageEntityForm/RecordCardLoading.js +10 -13
  108. package/PageEntityForm/RecordSetNavigatorContainer.js +30 -34
  109. package/PageEntityForm/RelatedViewSelector.js +28 -31
  110. package/PageEntityForm/SectionContainer.js +25 -28
  111. package/PageEntityForm/StandardControl.d.ts +3 -3
  112. package/PageEntityForm/StandardControl.js +74 -81
  113. package/PageEntityForm/SubgridControl.js +20 -23
  114. package/PageEntityForm/index.js +1 -5
  115. package/PageEntityView/FormSubgridContainer.js +22 -26
  116. package/PageEntityView/PageEntityView.js +15 -19
  117. package/PageEntityView/PageEntityViewDesktopContainer.js +9 -13
  118. package/PageEntityView/PageEntityViewDesktopFrame.js +17 -21
  119. package/PageEntityView/PageEntityViewMobileContainer.js +9 -13
  120. package/PageEntityView/PageEntityViewStringContext.js +5 -9
  121. package/PageEntityView/index.js +1 -5
  122. package/PageInsights/PageInsights.js +9 -13
  123. package/PageInsights/index.js +1 -6
  124. package/ProgressIndicatorContainer/index.js +10 -14
  125. package/ToastNotificationContainer/index.js +14 -18
  126. package/componentStore.js +2 -5
  127. package/components/BodyLoading.js +7 -11
  128. package/components/DialogLogin.js +5 -8
  129. package/components/LoginForm.js +21 -47
  130. package/components/PageBroken.js +5 -8
  131. package/components/PageLoading.js +5 -8
  132. package/components/PageLogin.js +14 -17
  133. package/form/FormControl.js +39 -44
  134. package/form/FormControlLoading.js +4 -8
  135. package/form/controls/AttachmentControl.js +56 -60
  136. package/form/controls/AttachmentsControl.js +15 -19
  137. package/form/controls/CurrencyControl.js +10 -13
  138. package/form/controls/DateControl.js +18 -24
  139. package/form/controls/DateRangeControl.js +14 -20
  140. package/form/controls/DateTimeControl.js +39 -45
  141. package/form/controls/DecimalControl.js +8 -11
  142. package/form/controls/DurationControl.js +11 -15
  143. package/form/controls/EmailControl.js +7 -10
  144. package/form/controls/IntegerControl.js +4 -7
  145. package/form/controls/LookupControl.d.ts +1 -0
  146. package/form/controls/LookupControl.js +75 -38
  147. package/form/controls/MultiSelectControl.js +8 -11
  148. package/form/controls/MultiSelectLookupControl.js +40 -43
  149. package/form/controls/PasswordControl.js +8 -11
  150. package/form/controls/RichTextControl.js +5 -32
  151. package/form/controls/SelectControl.js +8 -11
  152. package/form/controls/SwitchControl.js +4 -7
  153. package/form/controls/TelephoneControl.js +7 -10
  154. package/form/controls/TextAreaControl.js +4 -7
  155. package/form/controls/TextControl.js +5 -8
  156. package/form/controls/UrlControl.js +7 -10
  157. package/form/controls/types.js +1 -2
  158. package/form/controls/useLookupData.js +14 -18
  159. package/form/layout/FormBody/FormBody.js +6 -10
  160. package/form/layout/FormBody/index.js +1 -17
  161. package/form/layout/FormSection/FormSection.js +18 -22
  162. package/form/layout/FormSection/FormSectionColumn.js +3 -7
  163. package/form/layout/FormSection/FormSectionLoading.js +1 -5
  164. package/form/layout/FormSection/index.js +1 -5
  165. package/form/layout/FormTab/FormTab.js +16 -20
  166. package/form/layout/FormTab/FormTabColumn.js +5 -9
  167. package/form/layout/FormTab/index.js +1 -5
  168. package/form/layout/TabContext.js +2 -5
  169. package/form/layout/index.js +3 -9
  170. package/form/types.js +1 -2
  171. package/package.json +3 -2
  172. package/types/index.js +1 -2
  173. package/utils/avatar.d.ts +2 -0
  174. package/utils/avatar.js +42 -0
@@ -1,63 +1,61 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useTableColumns = useTableColumns;
4
- const jsx_runtime_1 = require("react/jsx-runtime");
5
- const react_components_1 = require("@fluentui/react-components");
6
- const datagrid_1 = require("@headless-adminapp/app/datagrid");
7
- const hooks_1 = require("@headless-adminapp/app/datagrid/hooks");
8
- const useOpenRecord_1 = require("@headless-adminapp/app/datagrid/hooks/useOpenRecord");
9
- const hooks_2 = require("@headless-adminapp/app/hooks");
10
- const locale_1 = require("@headless-adminapp/app/locale");
11
- const hooks_3 = require("@headless-adminapp/app/metadata/hooks");
12
- const mutable_1 = require("@headless-adminapp/app/mutable");
13
- const hooks_4 = require("@headless-adminapp/app/recordset/hooks");
14
- const hooks_5 = require("@headless-adminapp/app/route/hooks");
15
- const utils_1 = require("@headless-adminapp/app/utils");
16
- const app_1 = require("@headless-adminapp/core/experience/app");
17
- const react_table_1 = require("@tanstack/react-table");
18
- const react_1 = require("react");
19
- const componentStore_1 = require("../componentStore");
20
- const GridColumnHeader_1 = require("../DataGrid/GridColumnHeader");
21
- const TableCell_1 = require("../DataGrid/TableCell");
22
- const TableCellLink_1 = require("../DataGrid/TableCell/TableCellLink");
23
- const ActionCell_1 = require("./ActionCell");
24
- const TableCellChoice_1 = require("./TableCell/TableCellChoice");
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: react_components_1.tokens.colorNeutralBackground1,
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 = (0, hooks_1.useGridData)();
39
- const columns = (0, hooks_1.useGridColumns)();
40
- const [, setSorting] = (0, hooks_1.useGridSorting)();
41
- const schema = (0, hooks_1.useDataGridSchema)();
42
- const { schemaStore } = (0, hooks_3.useMetadata)();
43
- const [selectedIds, setSelectedIds] = (0, hooks_1.useGridSelection)();
44
- const setSelectedIdsRef = (0, react_1.useRef)(setSelectedIds);
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 = (0, mutable_1.useContextSelector)(datagrid_1.GridContext, (state) => state.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
- (0, hooks_1.useSubGridContextCommands)()
47
+ useSubGridContextCommands()
50
48
  : // eslint-disable-next-line react-hooks/rules-of-hooks
51
- (0, hooks_1.useMainGridContextCommands)();
52
- const mutableContextCommandState = (0, mutable_1.useMutableState)(contextCommands, true);
53
- (0, react_1.useEffect)(() => {
49
+ useMainGridContextCommands();
50
+ const mutableContextCommandState = useMutableState(contextCommands, true);
51
+ useEffect(() => {
54
52
  mutableContextCommandState.setValue(contextCommands);
55
53
  }, [contextCommands, mutableContextCommandState]);
56
- const tableWrapperSize = (0, hooks_2.useElementSize)(tableWrapperRef, 100);
57
- const columnWidths = (0, react_1.useMemo)(() => {
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 } = (0, utils_1.calculateColumnWidths)({
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 = (0, hooks_1.useGridColumns)();
74
- const routeResolver = (0, hooks_5.useRouteResolver)();
75
- const router = (0, hooks_5.useRouter)();
76
- const recordSetSetter = (0, hooks_4.useRecordSetSetter)();
77
- const openRecord = (0, useOpenRecord_1.useOpenRecord)();
78
- const locale = (0, locale_1.useLocale)();
79
- const dataRef = (0, react_1.useRef)(data);
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 = (0, react_1.useMemo)(() => {
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 = (0, react_1.useMemo)(() => {
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: () => ((0, jsx_runtime_1.jsx)(react_components_1.TableHeaderCell, { style: {
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: react_components_1.tokens.colorNeutralBackground1,
111
- borderBottom: `${react_components_1.tokens.strokeWidthThin} solid ${react_components_1.tokens.colorNeutralStroke3}`,
108
+ background: tokens.colorNeutralBackground1,
109
+ borderBottom: `${tokens.strokeWidthThin} solid ${tokens.colorNeutralStroke3}`,
112
110
  }, children: "\u00A0" })),
113
- cell: (info) => ((0, jsx_runtime_1.jsx)(ActionCell_1.ActionCell, { onOpen: () => {
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 = (0, react_1.useMemo)(() => {
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: () => ((0, jsx_runtime_1.jsx)(react_components_1.TableSelectionCell, { checked: headingSelectionState, as: 'th', style: {
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: react_components_1.tokens.colorNeutralBackground1,
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) => ((0, jsx_runtime_1.jsx)(react_components_1.TableSelectionCell, { className: (0, react_components_1.mergeClasses)(styles.selectionCell), checked: info.row.getIsSelected(), onClick: (event) => {
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 = (0, react_1.useMemo)(() => {
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 (0, react_1.useMemo)(() => {
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 ((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));
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 = (0, utils_1.getAttributeFormattedValue)(attribute, value, {
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 ((0, jsx_runtime_1.jsx)(TableCell_1.TableCellText, { value: formattedValue, width: info.column.getSize() }, column.id));
274
+ return (_jsx(TableCellText, { value: formattedValue, width: info.column.getSize() }, column.id));
277
275
  }
278
276
  if (column.component) {
279
- const Component = componentStore_1.componentStore.getComponent(column.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 ((0, jsx_runtime_1.jsx)(Component, { column: column, schema: schema, record: info.row.original, value: value, attribute: attribute, formattedValue: formattedValue, width: info.column.getSize() }));
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
- const path = routeResolver({
287
- logicalName: schema.logicalName,
288
- type: app_1.PageType.EntityForm,
289
- id: info.row.original[schema.idAttribute],
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 ((0, jsx_runtime_1.jsx)(TableCell_1.TableCellText, { value: formattedValue, width: info.column.getSize(), textAlignment: "right" }, column.id));
295
+ return (_jsx(TableCellText, { value: formattedValue, width: info.column.getSize(), textAlignment: "right" }, column.id));
298
296
  case 'lookup': {
299
- if (!value) {
300
- return ((0, jsx_runtime_1.jsx)(TableCell_1.TableCellText, { value: "", width: info.column.getSize() }, column.id));
301
- }
302
- const path = routeResolver({
303
- logicalName: attribute.entity,
304
- type: app_1.PageType.EntityForm,
305
- id: value.id,
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 ((0, jsx_runtime_1.jsx)(TableCell_1.TableCellText, { value: "", width: info.column.getSize() }, column.id));
312
+ return (_jsx(TableCellText, { value: "", width: info.column.getSize() }, column.id));
316
313
  }
317
- return ((0, jsx_runtime_1.jsx)(TableCellLink_1.TableCellLink, { value: formattedValue, width: info.column.getSize(), href: url, target: "_blank" }, column.id));
314
+ return (_jsx(TableCellLink, { value: formattedValue, width: info.column.getSize(), href: url, target: "_blank" }, column.id));
318
315
  }
319
316
  case 'choice':
320
- return ((0, jsx_runtime_1.jsx)(TableCellChoice_1.TableCellChoice, { column: column, schema: schema, record: info.row.original, value: value, attribute: attribute, formattedValue: formattedValue, width: info.column.getSize() }));
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
- return ((0, jsx_runtime_1.jsx)(TableCell_1.TableCellText, { value: formattedValue, width: info.column.getSize() }, column.id));
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
- "use strict";
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
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AlertDialog = AlertDialog;
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 ((0, jsx_runtime_1.jsx)(react_components_1.Dialog, { open: props.open, onOpenChange: () => {
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: (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: () => {
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
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ConfirmDialog = ConfirmDialog;
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 ((0, jsx_runtime_1.jsx)(react_components_1.Dialog, { open: props.open, onOpenChange: () => {
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: (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: () => {
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' }), (0, jsx_runtime_1.jsx)(react_components_1.Button, { appearance: "primary", onClick: () => {
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
- Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.DialogContainer = void 0;
15
- const jsx_runtime_1 = require("react/jsx-runtime");
16
- const hooks_1 = require("@headless-adminapp/app/dialog/hooks");
17
- const AlertDialog_1 = require("./AlertDialog");
18
- const ConfirmDialog_1 = require("./ConfirmDialog");
19
- const ErrorDialog_1 = require("./ErrorDialog");
20
- const PromptDialog_1 = require("./PromptDialog");
21
- const DialogContainer = () => {
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 ((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));
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 ((0, jsx_runtime_1.jsx)(ConfirmDialog_1.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));
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 ((0, jsx_runtime_1.jsx)(ErrorDialog_1.ErrorDialog, { message: options.text, open: isOpen, confirmText: options.confirmButtonLabel, onConfirm: options.onConfirm, onDismiss: options.onDismiss, title: options.title }, id));
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 ((0, jsx_runtime_1.jsx)(PromptDialog_1.PromptDialog, { attributes: options.attributes,
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 ((0, jsx_runtime_1.jsx)(options.Component, Object.assign({ id: id, isOpen: isOpen }, options.props), id));
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
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ErrorDialog = ErrorDialog;
4
- const jsx_runtime_1 = require("react/jsx-runtime");
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 ((0, jsx_runtime_1.jsx)(react_components_1.Dialog, { open: props.open, onOpenChange: () => {
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: (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
- color: react_components_1.tokens.colorPaletteRedForeground1,
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: react_components_1.tokens.spacingHorizontalS,
18
- }, 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: () => {
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' }) })] }) }) }));