@headless-adminapp/fluent 0.0.17-alpha.53 → 0.0.17-alpha.56

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 (178) hide show
  1. package/App/App.js +11 -7
  2. package/App/AppHeaderContianer.js +50 -44
  3. package/App/AppLogo.js +12 -9
  4. package/App/AppStringContext.js +13 -9
  5. package/App/AppUI.js +15 -11
  6. package/App/LayoutProvider.js +16 -24
  7. package/App/NavigationContainer.js +28 -28
  8. package/App/QuickActionItem.js +10 -6
  9. package/App/index.js +5 -1
  10. package/App/utils.js +7 -5
  11. package/CommandBar/Button.js +17 -14
  12. package/CommandBar/Divider.js +9 -6
  13. package/CommandBar/IconButton.js +16 -13
  14. package/CommandBar/Label.js +11 -8
  15. package/CommandBar/MenuButton.js +20 -17
  16. package/CommandBar/MenuItem.js +19 -16
  17. package/CommandBar/MenuItems.js +10 -10
  18. package/CommandBar/MenuList.js +12 -9
  19. package/CommandBar/Wrapper.js +10 -7
  20. package/CommandBar/index.js +15 -13
  21. package/DataForm/SectionControl.js +7 -4
  22. package/DataGrid/ActionCell.js +14 -11
  23. package/DataGrid/CommandContainer.js +10 -6
  24. package/DataGrid/CustomizeColumns/AddColumns.js +61 -59
  25. package/DataGrid/CustomizeColumns/ColumnItem.js +23 -19
  26. package/DataGrid/CustomizeColumns/CustomizeColumns.js +41 -36
  27. package/DataGrid/CustomizeColumns/index.js +5 -1
  28. package/DataGrid/FormSubgridCommandContainer.js +17 -13
  29. package/DataGrid/FormSubgridViewSelector.js +21 -21
  30. package/DataGrid/GridColumnHeader/ConditionValueControl.js +33 -33
  31. package/DataGrid/GridColumnHeader/FilterForm.js +28 -27
  32. package/DataGrid/GridColumnHeader/OperatorSelect.js +19 -13
  33. package/DataGrid/GridColumnHeader/TableHeaderFilterCell.js +35 -31
  34. package/DataGrid/GridColumnHeader/index.js +5 -1
  35. package/DataGrid/GridColumnHeader/utils.js +6 -2
  36. package/DataGrid/GridHeaderContainer.js +8 -4
  37. package/DataGrid/GridHeaderDesktop.js +28 -28
  38. package/DataGrid/GridHeaderMobile.js +20 -19
  39. package/DataGrid/GridListContainer.js +50 -44
  40. package/DataGrid/GridPaginationContainer.js +16 -13
  41. package/DataGrid/GridTableContainer.js +98 -89
  42. package/DataGrid/TableCell/TableCellAction.js +15 -11
  43. package/DataGrid/TableCell/TableCellBase.js +13 -4
  44. package/DataGrid/TableCell/TableCellCheckbox.js +11 -8
  45. package/DataGrid/TableCell/TableCellChoice.js +15 -13
  46. package/DataGrid/TableCell/TableCellLink.js +14 -11
  47. package/DataGrid/TableCell/TableCellText.js +10 -7
  48. package/DataGrid/TableCell/index.js +20 -4
  49. package/DataGrid/index.js +11 -4
  50. package/DataGrid/types.js +2 -1
  51. package/DataGrid/useTableColumns.js +98 -103
  52. package/DataGrid/utils.js +5 -1
  53. package/DialogContainer/AlertDialog.js +11 -11
  54. package/DialogContainer/ConfirmDialog.js +13 -14
  55. package/DialogContainer/DialogContainer.js +19 -26
  56. package/DialogContainer/ErrorDialog.js +15 -15
  57. package/DialogContainer/PromptDialog.js +76 -58
  58. package/DialogContainer/index.js +5 -1
  59. package/Insights/CommandBarContainer.js +17 -11
  60. package/Insights/FilterBarContainer.js +32 -37
  61. package/Insights/Grid.js +13 -9
  62. package/Insights/InsightsContainer.js +22 -19
  63. package/Insights/WidgetChartContainer.js +34 -30
  64. package/Insights/WidgetDataGridContainer.js +45 -33
  65. package/Insights/WidgetTableContainer.js +29 -26
  66. package/Insights/WidgetTileContainer.js +16 -12
  67. package/Insights/WidgetTitleBar.js +15 -10
  68. package/Insights/Widgets.js +28 -25
  69. package/Insights/charts/AreaChart.js +15 -12
  70. package/Insights/charts/BarChart.js +15 -12
  71. package/Insights/charts/ComposedChart.js +15 -13
  72. package/Insights/charts/CustomTooltipContent.js +13 -9
  73. package/Insights/charts/GaugeChart.js +6 -3
  74. package/Insights/charts/LineChart.js +15 -12
  75. package/Insights/charts/OhlcChart.js +46 -40
  76. package/Insights/charts/PieChart.js +25 -26
  77. package/Insights/charts/RadarChart.js +19 -17
  78. package/Insights/charts/ScatterChart.js +26 -28
  79. package/Insights/charts/constants.js +4 -1
  80. package/Insights/charts/formatters.js +33 -23
  81. package/Insights/charts/index.js +2 -1
  82. package/Insights/charts/renderers.js +36 -26
  83. package/Insights/hooks/useQueriesData.js +27 -30
  84. package/Insights/hooks/useWidgetDetail.js +24 -15
  85. package/OverflowCommandBar/OverflowCommandBar.js +19 -12
  86. package/OverflowCommandBar/OverflowMenu.js +22 -30
  87. package/OverflowCommandBar/OverflowMenuDivider.js +10 -6
  88. package/OverflowCommandBar/index.js +9 -3
  89. package/OverflowCommandBar/render.js +15 -10
  90. package/OverflowCommandBar/utils.js +6 -4
  91. package/PageBoard/BoardColumn.js +8 -5
  92. package/PageBoard/BoardColumnCard.d.ts +1 -1
  93. package/PageBoard/BoardColumnCard.js +15 -11
  94. package/PageBoard/BoardColumnUI.js +45 -46
  95. package/PageBoard/BoardingColumnCardLoading.js +13 -10
  96. package/PageBoard/Header.js +23 -28
  97. package/PageBoard/PageBoard.js +28 -26
  98. package/PageBoard/index.js +5 -1
  99. package/PageEntityForm/CommandContainer.js +25 -21
  100. package/PageEntityForm/FormTabRelated.js +20 -17
  101. package/PageEntityForm/PageEntityForm.js +20 -16
  102. package/PageEntityForm/PageEntityFormDesktopContainer.js +77 -70
  103. package/PageEntityForm/PageEntityFormStringContext.js +9 -5
  104. package/PageEntityForm/ProcessFlow.js +24 -21
  105. package/PageEntityForm/RecordCard.js +31 -24
  106. package/PageEntityForm/RecordCardLoading.js +13 -11
  107. package/PageEntityForm/RecordSetNavigatorContainer.js +34 -31
  108. package/PageEntityForm/RelatedViewSelector.js +34 -36
  109. package/PageEntityForm/SectionContainer.js +35 -31
  110. package/PageEntityForm/StandardControl.js +84 -76
  111. package/PageEntityForm/SubgridControl.js +23 -21
  112. package/PageEntityForm/index.js +5 -1
  113. package/PageEntityView/FormSubgridContainer.js +26 -22
  114. package/PageEntityView/PageEntityView.js +19 -15
  115. package/PageEntityView/PageEntityViewDesktopContainer.js +13 -9
  116. package/PageEntityView/PageEntityViewDesktopFrame.js +21 -17
  117. package/PageEntityView/PageEntityViewMobileContainer.js +13 -9
  118. package/PageEntityView/PageEntityViewStringContext.js +9 -5
  119. package/PageEntityView/index.js +5 -1
  120. package/PageInsights/PageInsights.js +13 -9
  121. package/PageInsights/index.js +6 -1
  122. package/ProgressIndicatorContainer/index.js +14 -10
  123. package/ToastNotificationContainer/index.js +18 -15
  124. package/componentStore.js +5 -2
  125. package/components/BodyLoading.js +11 -7
  126. package/components/DialogLogin.js +8 -5
  127. package/components/DndProvider.d.ts +12 -0
  128. package/components/DndProvider.js +68 -0
  129. package/components/LoginForm.js +46 -36
  130. package/components/PageBroken.js +8 -5
  131. package/components/PageLoading.js +8 -5
  132. package/components/PageLogin.js +17 -14
  133. package/form/FormControl.js +44 -50
  134. package/form/FormControlLoading.js +8 -4
  135. package/form/controls/AttachmentControl.js +72 -77
  136. package/form/controls/AttachmentsControl.js +24 -30
  137. package/form/controls/CurrencyControl.js +16 -13
  138. package/form/controls/DateControl.js +24 -18
  139. package/form/controls/DateRangeControl.js +22 -18
  140. package/form/controls/DateTimeControl.js +49 -43
  141. package/form/controls/DecimalControl.js +14 -11
  142. package/form/controls/DurationControl.js +18 -14
  143. package/form/controls/EmailControl.js +14 -11
  144. package/form/controls/IntegerControl.js +11 -8
  145. package/form/controls/LookupControl.js +58 -56
  146. package/form/controls/MultiSelectControl.js +12 -9
  147. package/form/controls/MultiSelectLookupControl.js +55 -53
  148. package/form/controls/PasswordControl.js +11 -8
  149. package/form/controls/RichTextControl.js +32 -5
  150. package/form/controls/SelectControl.js +15 -13
  151. package/form/controls/SwitchControl.js +7 -4
  152. package/form/controls/TelephoneControl.js +10 -7
  153. package/form/controls/TextAreaControl.js +11 -8
  154. package/form/controls/TextControl.js +12 -9
  155. package/form/controls/UrlControl.js +10 -7
  156. package/form/controls/types.js +2 -1
  157. package/form/controls/useLookupData.js +43 -54
  158. package/form/layout/FormBody/FormBody.js +10 -6
  159. package/form/layout/FormBody/index.js +17 -1
  160. package/form/layout/FormSection/FormSection.js +31 -20
  161. package/form/layout/FormSection/FormSectionColumn.js +7 -3
  162. package/form/layout/FormSection/FormSectionLoading.js +5 -1
  163. package/form/layout/FormSection/index.js +5 -1
  164. package/form/layout/FormTab/FormTab.js +21 -17
  165. package/form/layout/FormTab/FormTabColumn.js +9 -5
  166. package/form/layout/FormTab/index.js +5 -1
  167. package/form/layout/TabContext.js +5 -2
  168. package/form/layout/index.js +9 -3
  169. package/form/types.js +2 -1
  170. package/package.json +4 -12
  171. package/types/index.js +2 -1
  172. package/utils/avatar.js +4 -1
  173. package/DataGrid/ScrollbarWithMoreDataRequest.d.ts +0 -9
  174. package/DataGrid/ScrollbarWithMoreDataRequest.js +0 -33
  175. package/form/controls/NumberControl.d.ts +0 -4
  176. package/form/controls/NumberControl.js +0 -16
  177. package/form/controls/utils.d.ts +0 -4
  178. package/form/controls/utils.js +0 -42
@@ -1,34 +1,39 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Button, Divider, Drawer, DrawerBody, DrawerHeader, DrawerHeaderTitle, tokens, } from '@fluentui/react-components';
3
- import { GridContext, } from '@headless-adminapp/app/datagrid';
4
- import { useGridColumns } from '@headless-adminapp/app/datagrid/hooks';
5
- import { useContextSetValue } from '@headless-adminapp/app/mutable';
6
- import { Icons } from '@headless-adminapp/icons';
7
- import update from 'immutability-helper';
8
- import { useCallback, useMemo, useState } from 'react';
9
- import { DndProvider } from 'react-dnd';
10
- import { HTML5Backend } from 'react-dnd-html5-backend';
11
- import { usePageEntityViewStrings } from '../../PageEntityView/PageEntityViewStringContext';
12
- import { AddColumns } from './AddColumns';
13
- import { ColumnItem } from './ColumnItem';
14
- export function CustomizeColumns({ onClose, opened }) {
15
- const columns = useGridColumns();
16
- const setContextValue = useContextSetValue(GridContext);
17
- const [showAddColumns, setShowAddColumns] = useState(false);
18
- const [items, setItems] = useState(columns);
19
- const strings = usePageEntityViewStrings();
20
- const isDirty = useMemo(() => {
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.CustomizeColumns = CustomizeColumns;
7
+ const jsx_runtime_1 = require("react/jsx-runtime");
8
+ const react_components_1 = require("@fluentui/react-components");
9
+ const datagrid_1 = require("@headless-adminapp/app/datagrid");
10
+ const hooks_1 = require("@headless-adminapp/app/datagrid/hooks");
11
+ const mutable_1 = require("@headless-adminapp/app/mutable");
12
+ const icons_1 = require("@headless-adminapp/icons");
13
+ const immutability_helper_1 = __importDefault(require("immutability-helper"));
14
+ const react_1 = require("react");
15
+ const DndProvider_1 = require("../../components/DndProvider");
16
+ const PageEntityViewStringContext_1 = require("../../PageEntityView/PageEntityViewStringContext");
17
+ const AddColumns_1 = require("./AddColumns");
18
+ const ColumnItem_1 = require("./ColumnItem");
19
+ function CustomizeColumns({ onClose, opened }) {
20
+ const columns = (0, hooks_1.useGridColumns)();
21
+ const setContextValue = (0, mutable_1.useContextSetValue)(datagrid_1.GridContext);
22
+ const [showAddColumns, setShowAddColumns] = (0, react_1.useState)(false);
23
+ const [items, setItems] = (0, react_1.useState)(columns);
24
+ const strings = (0, PageEntityViewStringContext_1.usePageEntityViewStrings)();
25
+ const isDirty = (0, react_1.useMemo)(() => {
21
26
  return JSON.stringify(items) !== JSON.stringify(columns);
22
27
  }, [columns, items]);
23
- const moveItem = useCallback((dragIndex, hoverIndex) => {
24
- setItems((prevCards) => update(prevCards, {
28
+ const moveItem = (0, react_1.useCallback)((dragIndex, hoverIndex) => {
29
+ setItems((prevCards) => (0, immutability_helper_1.default)(prevCards, {
25
30
  $splice: [
26
31
  [dragIndex, 1],
27
32
  [hoverIndex, 0, prevCards[dragIndex]],
28
33
  ],
29
34
  }));
30
35
  }, []);
31
- const onColumnAdd = useCallback((column) => {
36
+ const onColumnAdd = (0, react_1.useCallback)((column) => {
32
37
  setItems((prev) => {
33
38
  if (prev.some((x) => x.id === column.id)) {
34
39
  return prev;
@@ -36,37 +41,37 @@ export function CustomizeColumns({ onClose, opened }) {
36
41
  return [...prev, column];
37
42
  });
38
43
  }, []);
39
- const onColumnRemove = useCallback((column) => {
44
+ const onColumnRemove = (0, react_1.useCallback)((column) => {
40
45
  setItems((prev) => prev.filter((x) => x.id !== column.id));
41
46
  }, []);
42
- return (_jsxs(Drawer, { separator: true, open: opened, position: "end", size: "small", children: [_jsx(DrawerHeader, { children: _jsx(DrawerHeaderTitle, { action: _jsx(Button, { appearance: "subtle", "aria-label": "Close", icon: _jsx(Icons.Close, {}), onClick: onClose }), children: strings.editColumns }) }), _jsxs("div", { style: { width: '100%', display: 'flex', flexDirection: 'column' }, children: [_jsxs("div", { style: {
47
+ return ((0, jsx_runtime_1.jsxs)(react_components_1.Drawer, { separator: true, open: opened, position: "end", size: "small", children: [(0, jsx_runtime_1.jsx)(react_components_1.DrawerHeader, { children: (0, jsx_runtime_1.jsx)(react_components_1.DrawerHeaderTitle, { action: (0, jsx_runtime_1.jsx)(react_components_1.Button, { appearance: "subtle", "aria-label": "Close", icon: (0, jsx_runtime_1.jsx)(icons_1.Icons.Close, {}), onClick: onClose }), children: strings.editColumns }) }), (0, jsx_runtime_1.jsxs)("div", { style: { width: '100%', display: 'flex', flexDirection: 'column' }, children: [(0, jsx_runtime_1.jsxs)("div", { style: {
43
48
  display: 'flex',
44
49
  gap: 8,
45
- marginBottom: tokens.spacingVerticalXS,
46
- paddingInline: tokens.spacingHorizontalS,
47
- }, children: [_jsx(Button, { appearance: "subtle", icon: _jsx(Icons.Add, {}), style: {
48
- fontWeight: tokens.fontSizeBase400,
50
+ marginBottom: react_components_1.tokens.spacingVerticalXS,
51
+ paddingInline: react_components_1.tokens.spacingHorizontalS,
52
+ }, children: [(0, jsx_runtime_1.jsx)(react_components_1.Button, { appearance: "subtle", icon: (0, jsx_runtime_1.jsx)(icons_1.Icons.Add, {}), style: {
53
+ fontWeight: react_components_1.tokens.fontSizeBase400,
49
54
  minWidth: 'unset',
50
- }, onClick: () => setShowAddColumns(true), children: strings.add }), _jsx(Button, { appearance: "subtle", icon: _jsx(Icons.Edit, {}), style: { fontWeight: tokens.fontSizeBase400, minWidth: 'unset' }, disabled: !isDirty, onClick: () => {
55
+ }, onClick: () => setShowAddColumns(true), children: strings.add }), (0, jsx_runtime_1.jsx)(react_components_1.Button, { appearance: "subtle", icon: (0, jsx_runtime_1.jsx)(icons_1.Icons.Edit, {}), style: { fontWeight: react_components_1.tokens.fontSizeBase400, minWidth: 'unset' }, disabled: !isDirty, onClick: () => {
51
56
  setItems(columns);
52
- }, children: strings.reset })] }), _jsx(AddColumns, { onColumnAdd: onColumnAdd, onColumnRemove: onColumnRemove, columns: items, opened: showAddColumns, onClose: () => setShowAddColumns(false) }), _jsx(Divider, {})] }), _jsx(DrawerBody, { style: { paddingInline: tokens.spacingHorizontalS }, children: _jsx(DndProvider, { backend: HTML5Backend, children: _jsx("div", { style: {
57
+ }, children: strings.reset })] }), (0, jsx_runtime_1.jsx)(AddColumns_1.AddColumns, { onColumnAdd: onColumnAdd, onColumnRemove: onColumnRemove, columns: items, opened: showAddColumns, onClose: () => setShowAddColumns(false) }), (0, jsx_runtime_1.jsx)(react_components_1.Divider, {})] }), (0, jsx_runtime_1.jsx)(react_components_1.DrawerBody, { style: { paddingInline: react_components_1.tokens.spacingHorizontalS }, children: (0, jsx_runtime_1.jsx)(DndProvider_1.DndProvider, { children: (0, jsx_runtime_1.jsx)("div", { style: {
53
58
  display: 'flex',
54
59
  flexDirection: 'column',
55
60
  width: '100%',
56
- gap: tokens.spacingVerticalS,
61
+ gap: react_components_1.tokens.spacingVerticalS,
57
62
  // padding: tokens.spacingHorizontalS,
58
- paddingBlock: tokens.spacingVerticalS,
59
- }, children: items.map((item, index) => (_jsx(ColumnItem, { index: index, item: item, moveItem: moveItem, isFirst: index === 0, isLast: index === items.length - 1, onRemove: () => onColumnRemove(item), stringSet: strings }, item.id))) }) }) }), _jsxs("div", { style: { display: 'flex', flexDirection: 'column', width: '100%' }, children: [_jsx(Divider, {}), _jsxs("div", { style: {
63
+ paddingBlock: react_components_1.tokens.spacingVerticalS,
64
+ }, children: items.map((item, index) => ((0, jsx_runtime_1.jsx)(ColumnItem_1.ColumnItem, { index: index, item: item, moveItem: moveItem, isFirst: index === 0, isLast: index === items.length - 1, onRemove: () => onColumnRemove(item), stringSet: strings }, item.id))) }) }) }), (0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'column', width: '100%' }, children: [(0, jsx_runtime_1.jsx)(react_components_1.Divider, {}), (0, jsx_runtime_1.jsxs)("div", { style: {
60
65
  display: 'flex',
61
66
  padding: 8,
62
67
  gap: 8,
63
68
  justifyContent: 'flex-end',
64
- }, children: [_jsx(Button, { onClick: () => {
69
+ }, children: [(0, jsx_runtime_1.jsx)(react_components_1.Button, { onClick: () => {
65
70
  setContextValue({
66
71
  columns: items,
67
72
  });
68
73
  onClose();
69
- }, appearance: "primary", children: strings.apply }), _jsx(Button, { onClick: () => {
74
+ }, appearance: "primary", children: strings.apply }), (0, jsx_runtime_1.jsx)(react_components_1.Button, { onClick: () => {
70
75
  onClose();
71
76
  }, children: strings.cancel })] })] })] }));
72
77
  }
@@ -1 +1,5 @@
1
- export { CustomizeColumns } from './CustomizeColumns';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CustomizeColumns = void 0;
4
+ var CustomizeColumns_1 = require("./CustomizeColumns");
5
+ Object.defineProperty(exports, "CustomizeColumns", { enumerable: true, get: function () { return CustomizeColumns_1.CustomizeColumns; } });
@@ -1,20 +1,24 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { GridContext } from '@headless-adminapp/app/datagrid';
3
- import { useMainGridCommands, useSubGridCommands, } from '@headless-adminapp/app/datagrid/hooks';
4
- import { useContextSelector } from '@headless-adminapp/app/mutable';
5
- import { OverflowCommandBar } from '../OverflowCommandBar';
6
- export const FormSubgridCommandContainer = () => {
7
- const isSubgrid = useContextSelector(GridContext, (state) => state.isSubGrid);
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FormSubgridCommandContainer = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const datagrid_1 = require("@headless-adminapp/app/datagrid");
6
+ const hooks_1 = require("@headless-adminapp/app/datagrid/hooks");
7
+ const mutable_1 = require("@headless-adminapp/app/mutable");
8
+ const OverflowCommandBar_1 = require("../OverflowCommandBar");
9
+ const FormSubgridCommandContainer = () => {
10
+ const isSubgrid = (0, mutable_1.useContextSelector)(datagrid_1.GridContext, (state) => state.isSubGrid);
8
11
  if (isSubgrid) {
9
- return _jsx(InternalSubGridCommandContainer, {});
12
+ return (0, jsx_runtime_1.jsx)(InternalSubGridCommandContainer, {});
10
13
  }
11
- return _jsx(InternalMainGridCommandContainer, {});
14
+ return (0, jsx_runtime_1.jsx)(InternalMainGridCommandContainer, {});
12
15
  };
16
+ exports.FormSubgridCommandContainer = FormSubgridCommandContainer;
13
17
  const InternalMainGridCommandContainer = () => {
14
- const gridCommands = useMainGridCommands();
15
- return _jsx(OverflowCommandBar, { commands: gridCommands });
18
+ const gridCommands = (0, hooks_1.useMainGridCommands)();
19
+ return (0, jsx_runtime_1.jsx)(OverflowCommandBar_1.OverflowCommandBar, { commands: gridCommands });
16
20
  };
17
21
  const InternalSubGridCommandContainer = () => {
18
- const gridCommands = useSubGridCommands();
19
- return _jsx(OverflowCommandBar, { commands: gridCommands });
22
+ const gridCommands = (0, hooks_1.useSubGridCommands)();
23
+ return (0, jsx_runtime_1.jsx)(OverflowCommandBar_1.OverflowCommandBar, { commands: gridCommands });
20
24
  };
@@ -1,18 +1,20 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Button, Menu, MenuItem, MenuList, MenuPopover, MenuTrigger, } from '@fluentui/react-components';
3
- import { GridContext } from '@headless-adminapp/app/datagrid';
4
- import { useChangeView, useGridViewLookupData, useSelectedView, } from '@headless-adminapp/app/datagrid/hooks';
5
- import { useLocale } from '@headless-adminapp/app/locale';
6
- import { useContextSelector } from '@headless-adminapp/app/mutable';
7
- import { Icons } from '@headless-adminapp/icons';
8
- export const FormSubgridViewSelector = () => {
9
- var _a, _b;
10
- const viewLookup = useGridViewLookupData();
11
- const selectedView = useSelectedView();
12
- const changeView = useChangeView();
13
- const { language } = useLocale();
14
- const allowViewSelection = useContextSelector(GridContext, (state) => state.allowViewSelection);
15
- return (_jsx("div", { style: {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FormSubgridViewSelector = void 0;
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 locale_1 = require("@headless-adminapp/app/locale");
9
+ const mutable_1 = require("@headless-adminapp/app/mutable");
10
+ const icons_1 = require("@headless-adminapp/icons");
11
+ const FormSubgridViewSelector = () => {
12
+ const viewLookup = (0, hooks_1.useGridViewLookupData)();
13
+ const selectedView = (0, hooks_1.useSelectedView)();
14
+ const changeView = (0, hooks_1.useChangeView)();
15
+ const { language } = (0, locale_1.useLocale)();
16
+ const allowViewSelection = (0, mutable_1.useContextSelector)(datagrid_1.GridContext, (state) => state.allowViewSelection);
17
+ return ((0, jsx_runtime_1.jsx)("div", { style: {
16
18
  alignItems: 'center',
17
19
  paddingBlock: 4,
18
20
  paddingInline: 4,
@@ -20,18 +22,16 @@ export const FormSubgridViewSelector = () => {
20
22
  width: '100%',
21
23
  display: 'flex',
22
24
  height: 40,
23
- }, children: _jsx("div", { style: {
25
+ }, children: (0, jsx_runtime_1.jsx)("div", { style: {
24
26
  flex: 1,
25
27
  alignItems: 'center',
26
28
  gap: 16,
27
29
  justifyContent: 'space-between',
28
30
  display: 'flex',
29
- }, children: _jsxs(Menu, { children: [_jsx(MenuTrigger, { children: _jsx(Button, { appearance: "subtle", icon: allowViewSelection ? _jsx(Icons.ChevronDown, {}) : null, iconPosition: "after", style: {
31
+ }, children: (0, jsx_runtime_1.jsxs)(react_components_1.Menu, { children: [(0, jsx_runtime_1.jsx)(react_components_1.MenuTrigger, { children: (0, jsx_runtime_1.jsx)(react_components_1.Button, { appearance: "subtle", icon: allowViewSelection ? (0, jsx_runtime_1.jsx)(icons_1.Icons.ChevronDown, {}) : null, iconPosition: "after", style: {
30
32
  paddingInline: 8,
31
33
  paddingBlock: 4,
32
34
  pointerEvents: allowViewSelection ? 'auto' : 'none',
33
- }, children: (_b = (_a = selectedView.localizedNames) === null || _a === void 0 ? void 0 : _a[language]) !== null && _b !== void 0 ? _b : selectedView.name }) }), _jsx(MenuPopover, { children: _jsx(MenuList, { children: viewLookup.map((view) => {
34
- var _a, _b;
35
- return (_jsx(MenuItem, { onClick: () => changeView(view.id), children: (_b = (_a = view.localizedNames) === null || _a === void 0 ? void 0 : _a[language]) !== null && _b !== void 0 ? _b : view.name }, view.id));
36
- }) }) })] }) }) }));
35
+ }, children: selectedView.localizedNames?.[language] ?? selectedView.name }) }), (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), children: view.localizedNames?.[language] ?? view.name }, view.id))) }) })] }) }) }));
37
36
  };
37
+ exports.FormSubgridViewSelector = FormSubgridViewSelector;
@@ -1,30 +1,35 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useMetadata } from '@headless-adminapp/app/metadata/hooks';
3
- import { useDataService } from '@headless-adminapp/app/transport';
4
- import FormControl from '../../form/FormControl';
5
- export function ConditionValueControl({ attribute, type, value, onChange, }) {
6
- var _a, _b, _c, _d;
7
- const dataService = useDataService();
8
- const { schemaStore, experienceStore } = useMetadata();
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ConditionValueControl = ConditionValueControl;
7
+ const jsx_runtime_1 = require("react/jsx-runtime");
8
+ const hooks_1 = require("@headless-adminapp/app/metadata/hooks");
9
+ const transport_1 = require("@headless-adminapp/app/transport");
10
+ const FormControl_1 = __importDefault(require("../../form/FormControl"));
11
+ function ConditionValueControl({ attribute, type, value, onChange, }) {
12
+ const dataService = (0, transport_1.useDataService)();
13
+ const { schemaStore, experienceStore } = (0, hooks_1.useMetadata)();
9
14
  switch (type) {
10
15
  case 'string':
11
- return (_jsx(FormControl, { type: "text", value: value !== null && value !== void 0 ? value : null, onChange: (value) => {
12
- onChange === null || onChange === void 0 ? void 0 : onChange(value);
16
+ return ((0, jsx_runtime_1.jsx)(FormControl_1.default, { type: "text", value: value ?? null, onChange: (value) => {
17
+ onChange?.(value);
13
18
  } }));
14
19
  case 'number':
15
- return (_jsx(FormControl, { type: "number", value: value !== null && value !== void 0 ? value : null, onChange: (value) => {
16
- onChange === null || onChange === void 0 ? void 0 : onChange(value);
20
+ return ((0, jsx_runtime_1.jsx)(FormControl_1.default, { type: "number", value: value ?? null, onChange: (value) => {
21
+ onChange?.(value);
17
22
  } }));
18
23
  case 'money':
19
- return (_jsx(FormControl, { type: "currency", value: value !== null && value !== void 0 ? value : null, onChange: (value) => {
20
- onChange === null || onChange === void 0 ? void 0 : onChange(value);
24
+ return ((0, jsx_runtime_1.jsx)(FormControl_1.default, { type: "currency", value: value ?? null, onChange: (value) => {
25
+ onChange?.(value);
21
26
  } }));
22
27
  case 'lookup':
23
28
  if (attribute.type !== 'lookup') {
24
29
  return null;
25
30
  }
26
- return (_jsx(FormControl, { type: "lookups", async: true, dataService: dataService, schema: schemaStore.getSchema(attribute.entity), experienceStore: experienceStore, value: value !== null && value !== void 0 ? value : null, onChange: (value) => {
27
- onChange === null || onChange === void 0 ? void 0 : onChange(value !== null && value !== void 0 ? value : []);
31
+ return ((0, jsx_runtime_1.jsx)(FormControl_1.default, { type: "lookups", async: true, dataService: dataService, schema: schemaStore.getSchema(attribute.entity), experienceStore: experienceStore, value: value ?? null, onChange: (value) => {
32
+ onChange?.(value ?? []);
28
33
  } }));
29
34
  // return (
30
35
  // <FormControl
@@ -40,25 +45,24 @@ export function ConditionValueControl({ attribute, type, value, onChange, }) {
40
45
  // />
41
46
  // );
42
47
  case 'date':
43
- return (_jsx(FormControl, { type: "date", value: value !== null && value !== void 0 ? value : null, onChange: (value) => {
44
- onChange === null || onChange === void 0 ? void 0 : onChange(value);
48
+ return ((0, jsx_runtime_1.jsx)(FormControl_1.default, { type: "date", value: value ?? null, onChange: (value) => {
49
+ onChange?.(value);
45
50
  } }));
46
51
  case 'boolean':
47
52
  if (attribute.type !== 'boolean') {
48
53
  return null;
49
54
  }
50
- return (_jsx(FormControl, { type: "multi-select", options: [
55
+ return ((0, jsx_runtime_1.jsx)(FormControl_1.default, { type: "multi-select", options: [
51
56
  {
52
- label: (_a = attribute.trueLabel) !== null && _a !== void 0 ? _a : 'Yes',
57
+ label: attribute.trueLabel ?? 'Yes',
53
58
  value: 'true',
54
59
  },
55
60
  {
56
- label: (_b = attribute.falseLabel) !== null && _b !== void 0 ? _b : 'No',
61
+ label: attribute.falseLabel ?? 'No',
57
62
  value: 'false',
58
63
  },
59
- ], value: (_c = value === null || value === void 0 ? void 0 : value.map((x) => (x === true ? 'true' : 'false'))) !== null && _c !== void 0 ? _c : [], onChange: (value) => {
60
- var _a;
61
- onChange === null || onChange === void 0 ? void 0 : onChange((_a = value === null || value === void 0 ? void 0 : value.map((x) => x === 'true')) !== null && _a !== void 0 ? _a : []);
64
+ ], value: value?.map((x) => (x === true ? 'true' : 'false')) ?? [], onChange: (value) => {
65
+ onChange?.(value?.map((x) => x === 'true') ?? []);
62
66
  } }));
63
67
  case 'choice':
64
68
  case 'choices':
@@ -67,15 +71,11 @@ export function ConditionValueControl({ attribute, type, value, onChange, }) {
67
71
  }
68
72
  const isNumeric = 'number' in attribute && attribute.number === true;
69
73
  // const isString = 'string' in attribute && attribute.string === true;
70
- return (_jsx(FormControl, { type: "multi-select", options: attribute.options.map((x) => {
71
- var _a;
72
- return ({
73
- label: x.label,
74
- value: isNumeric ? (_a = x.value) === null || _a === void 0 ? void 0 : _a.toString() : x.value,
75
- });
76
- }), value: (_d = value === null || value === void 0 ? void 0 : value.map((x) => (isNumeric ? x.toString() : x))) !== null && _d !== void 0 ? _d : [], onChange: (value) => {
77
- var _a;
78
- onChange === null || onChange === void 0 ? void 0 : onChange((_a = value === null || value === void 0 ? void 0 : value.map((x) => (isNumeric ? +x : x))) !== null && _a !== void 0 ? _a : []);
74
+ return ((0, jsx_runtime_1.jsx)(FormControl_1.default, { type: "multi-select", options: attribute.options.map((x) => ({
75
+ label: x.label,
76
+ value: isNumeric ? x.value?.toString() : x.value,
77
+ })), value: value?.map((x) => (isNumeric ? x.toString() : x)) ?? [], onChange: (value) => {
78
+ onChange?.(value?.map((x) => (isNumeric ? +x : x)) ?? []);
79
79
  } }));
80
80
  default:
81
81
  return null;
@@ -1,23 +1,26 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Button, DialogActions, DialogContent, DialogTrigger, tokens, } from '@fluentui/react-components';
3
- import { getLocalizedOperatorOptions } from '@headless-adminapp/app/datagrid/column-filter';
4
- import { Fragment, useMemo, useState } from 'react';
5
- import { useAppStrings } from '../../App/AppStringContext';
6
- import { usePageEntityViewStrings } from '../../PageEntityView/PageEntityViewStringContext';
7
- import { ConditionValueControl } from './ConditionValueControl';
8
- import { OperatorSelect } from './OperatorSelect';
9
- import { getDefaultOperator, getDefaultValues } from './utils';
10
- export const FilterForm = ({ defaultValue, attribute, onApply, onCancel, }) => {
11
- const [operator, setOperator] = useState(getDefaultOperator(defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue.operator, attribute.type));
12
- const strings = usePageEntityViewStrings();
13
- const { operatorStrings } = useAppStrings();
14
- const operatorOptions = useMemo(() => {
15
- return getLocalizedOperatorOptions(operatorStrings);
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FilterForm = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_components_1 = require("@fluentui/react-components");
6
+ const column_filter_1 = require("@headless-adminapp/app/datagrid/column-filter");
7
+ const react_1 = require("react");
8
+ const AppStringContext_1 = require("../../App/AppStringContext");
9
+ const PageEntityViewStringContext_1 = require("../../PageEntityView/PageEntityViewStringContext");
10
+ const ConditionValueControl_1 = require("./ConditionValueControl");
11
+ const OperatorSelect_1 = require("./OperatorSelect");
12
+ const utils_1 = require("./utils");
13
+ const FilterForm = ({ defaultValue, attribute, onApply, onCancel, }) => {
14
+ const [operator, setOperator] = (0, react_1.useState)((0, utils_1.getDefaultOperator)(defaultValue?.operator, attribute.type));
15
+ const strings = (0, PageEntityViewStringContext_1.usePageEntityViewStrings)();
16
+ const { operatorStrings } = (0, AppStringContext_1.useAppStrings)();
17
+ const operatorOptions = (0, react_1.useMemo)(() => {
18
+ return (0, column_filter_1.getLocalizedOperatorOptions)(operatorStrings);
16
19
  }, [operatorStrings]);
17
- const selectedOption = useMemo(() => {
20
+ const selectedOption = (0, react_1.useMemo)(() => {
18
21
  return operatorOptions[attribute.type].find((option) => option.value === operator);
19
22
  }, [operator, attribute.type, operatorOptions]);
20
- const [values, setValues] = useState(getDefaultValues(selectedOption, defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue.value, attribute.type));
23
+ const [values, setValues] = (0, react_1.useState)((0, utils_1.getDefaultValues)(selectedOption, defaultValue?.value, attribute.type));
21
24
  const handleChangeOperator = (operator) => {
22
25
  setOperator(operator);
23
26
  setValues([]);
@@ -29,25 +32,23 @@ export const FilterForm = ({ defaultValue, attribute, onApply, onCancel, }) => {
29
32
  return next;
30
33
  });
31
34
  };
32
- const isValid = useMemo(() => {
35
+ const isValid = (0, react_1.useMemo)(() => {
33
36
  return (!!selectedOption &&
34
37
  values.filter((value) => {
35
38
  return value !== null && value !== undefined;
36
39
  }).length === selectedOption.controls.length);
37
40
  }, [selectedOption, values]);
38
- return (_jsxs(Fragment, { children: [_jsx(DialogContent, { style: { paddingBlock: 8 }, children: _jsxs("div", { style: {
41
+ return ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_components_1.DialogContent, { style: { paddingBlock: 8 }, children: (0, jsx_runtime_1.jsxs)("div", { style: {
39
42
  display: 'flex',
40
43
  flexDirection: 'column',
41
- gap: tokens.spacingVerticalS,
42
- }, children: [_jsx(OperatorSelect, { attribute: attribute, onChange: (value) => handleChangeOperator(value), value: operator }), selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.controls.map((x, i) => {
43
- var _a;
44
- return (_jsx(ConditionValueControl, { type: x, attribute: attribute, value: (_a = values[i]) !== null && _a !== void 0 ? _a : null, onChange: (value) => {
45
- handleChangeValue(value, i);
46
- } }, x + String(i)));
47
- })] }) }), _jsxs(DialogActions, { children: [_jsx(DialogTrigger, { disableButtonEnhancement: true, children: _jsx(Button, { appearance: "secondary", onClick: onCancel, children: strings.cancel }) }), _jsx(Button, { type: "submit", appearance: "primary", disabled: !isValid, onClick: () => {
48
- onApply === null || onApply === void 0 ? void 0 : onApply({
44
+ gap: react_components_1.tokens.spacingVerticalS,
45
+ }, children: [(0, jsx_runtime_1.jsx)(OperatorSelect_1.OperatorSelect, { attribute: attribute, onChange: (value) => handleChangeOperator(value), value: operator }), selectedOption?.controls.map((x, i) => ((0, jsx_runtime_1.jsx)(ConditionValueControl_1.ConditionValueControl, { type: x, attribute: attribute, value: values[i] ?? null, onChange: (value) => {
46
+ handleChangeValue(value, i);
47
+ } }, x + String(i))))] }) }), (0, jsx_runtime_1.jsxs)(react_components_1.DialogActions, { children: [(0, jsx_runtime_1.jsx)(react_components_1.DialogTrigger, { disableButtonEnhancement: true, children: (0, jsx_runtime_1.jsx)(react_components_1.Button, { appearance: "secondary", onClick: onCancel, children: strings.cancel }) }), (0, jsx_runtime_1.jsx)(react_components_1.Button, { type: "submit", appearance: "primary", disabled: !isValid, onClick: () => {
48
+ onApply?.({
49
49
  operator,
50
50
  value: values,
51
51
  });
52
52
  }, children: strings.apply })] })] }));
53
53
  };
54
+ exports.FilterForm = FilterForm;
@@ -1,16 +1,22 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { getLocalizedOperatorOptions } from '@headless-adminapp/app/datagrid/column-filter';
3
- import { useDataService } from '@headless-adminapp/app/transport';
4
- import { useMemo } from 'react';
5
- import { useAppStrings } from '../../App/AppStringContext';
6
- import SelectControl from '../../form/controls/SelectControl';
7
- export function OperatorSelect({ attribute, value, onChange, }) {
8
- const { operatorStrings } = useAppStrings();
9
- const dataService = useDataService();
10
- const operatorOptions = useMemo(() => {
11
- return getLocalizedOperatorOptions(operatorStrings);
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.OperatorSelect = OperatorSelect;
7
+ const jsx_runtime_1 = require("react/jsx-runtime");
8
+ const column_filter_1 = require("@headless-adminapp/app/datagrid/column-filter");
9
+ const transport_1 = require("@headless-adminapp/app/transport");
10
+ const react_1 = require("react");
11
+ const AppStringContext_1 = require("../../App/AppStringContext");
12
+ const SelectControl_1 = __importDefault(require("../../form/controls/SelectControl"));
13
+ function OperatorSelect({ attribute, value, onChange, }) {
14
+ const { operatorStrings } = (0, AppStringContext_1.useAppStrings)();
15
+ const dataService = (0, transport_1.useDataService)();
16
+ const operatorOptions = (0, react_1.useMemo)(() => {
17
+ return (0, column_filter_1.getLocalizedOperatorOptions)(operatorStrings);
12
18
  }, [operatorStrings]);
13
- const options = useMemo(() => {
19
+ const options = (0, react_1.useMemo)(() => {
14
20
  const supportedOperators = dataService.supportedOperators;
15
21
  let operators = operatorOptions[attribute.type];
16
22
  if (supportedOperators) {
@@ -18,5 +24,5 @@ export function OperatorSelect({ attribute, value, onChange, }) {
18
24
  }
19
25
  return operators;
20
26
  }, [attribute.type, operatorOptions, dataService]);
21
- return (_jsx(SelectControl, { options: options, onChange: (value) => onChange === null || onChange === void 0 ? void 0 : onChange(value), value: value }));
27
+ return ((0, jsx_runtime_1.jsx)(SelectControl_1.default, { options: options, onChange: (value) => onChange?.(value), value: value }));
22
28
  }