@headless-adminapp/fluent 0.0.17-alpha.7 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/App/App.d.ts +0 -1
- package/App/App.js +2 -4
- package/App/AppHeaderContianer.d.ts +5 -1
- package/App/AppHeaderContianer.js +43 -26
- package/App/AppLogo.js +15 -4
- package/App/AppUI.js +9 -1
- package/App/LayoutProvider.d.ts +7 -0
- package/App/LayoutProvider.js +17 -0
- package/App/NavigationContainer.d.ts +10 -1
- package/App/NavigationContainer.js +22 -22
- package/App/QuickActionItem.js +2 -2
- package/App/utils.js +3 -4
- package/CommandBar/Button.d.ts +2 -1
- package/CommandBar/Button.js +2 -2
- package/CommandBar/Divider.d.ts +2 -1
- package/CommandBar/Divider.js +2 -2
- package/CommandBar/IconButton.d.ts +2 -1
- package/CommandBar/IconButton.js +2 -2
- package/CommandBar/Label.d.ts +2 -1
- package/CommandBar/Label.js +2 -2
- package/CommandBar/MenuButton.d.ts +2 -1
- package/CommandBar/MenuButton.js +3 -3
- package/CommandBar/MenuItem.js +5 -4
- package/CommandBar/MenuItems.js +4 -4
- package/CommandBar/MenuList.js +5 -4
- package/CommandBar/Wrapper.d.ts +2 -2
- package/CommandBar/Wrapper.js +2 -2
- package/CommandBar/index.d.ts +6 -6
- package/DataGrid/ActionCell.d.ts +1 -1
- package/DataGrid/ActionCell.js +8 -4
- package/DataGrid/CustomizeColumns/AddColumns.js +35 -37
- package/DataGrid/CustomizeColumns/ColumnItem.js +8 -6
- package/DataGrid/CustomizeColumns/CustomizeColumns.d.ts +2 -2
- package/DataGrid/CustomizeColumns/CustomizeColumns.js +3 -6
- package/DataGrid/FormSubgridViewSelector.js +1 -5
- package/DataGrid/GridColumnHeader/ConditionValueControl.js +19 -25
- package/DataGrid/GridColumnHeader/FilterForm.js +9 -10
- package/DataGrid/GridColumnHeader/OperatorSelect.js +10 -3
- package/DataGrid/GridColumnHeader/TableHeaderFilterCell.js +22 -13
- package/DataGrid/GridColumnHeader/utils.js +10 -7
- package/DataGrid/GridHeaderDesktop.js +4 -5
- package/DataGrid/GridHeaderMobile.d.ts +5 -0
- package/DataGrid/GridHeaderMobile.js +29 -0
- package/DataGrid/GridListContainer.d.ts +12 -0
- package/DataGrid/GridListContainer.js +93 -0
- package/DataGrid/GridPaginationContainer.js +1 -2
- package/DataGrid/GridTableContainer.js +113 -77
- package/DataGrid/TableCell/TableCellBase.d.ts +2 -2
- package/DataGrid/TableCell/TableCellBase.js +6 -1
- package/DataGrid/TableCell/TableCellCheckbox.js +6 -5
- package/DataGrid/TableCell/TableCellChoice.d.ts +15 -0
- package/DataGrid/TableCell/TableCellChoice.js +30 -0
- package/DataGrid/TableCell/TableCellLink.d.ts +2 -1
- package/DataGrid/TableCell/TableCellLink.js +13 -5
- package/DataGrid/TableCell/TableCellText.js +9 -4
- package/DataGrid/types.d.ts +5 -0
- package/DataGrid/types.js +2 -0
- package/DataGrid/useTableColumns.d.ts +2 -3
- package/DataGrid/useTableColumns.js +297 -155
- package/DialogContainer/AlertDialog.js +3 -6
- package/DialogContainer/ConfirmDialog.js +5 -9
- package/DialogContainer/DialogContainer.js +2 -13
- package/DialogContainer/ErrorDialog.js +3 -6
- package/DialogContainer/PromptDialog.d.ts +13 -2
- package/DialogContainer/PromptDialog.js +44 -39
- package/Insights/CommandBarContainer.d.ts +1 -0
- package/Insights/CommandBarContainer.js +18 -0
- package/Insights/FilterBarContainer.d.ts +1 -0
- package/Insights/FilterBarContainer.js +99 -0
- package/Insights/Grid.d.ts +6 -0
- package/Insights/Grid.js +26 -0
- package/Insights/InsightsContainer.d.ts +1 -0
- package/Insights/InsightsContainer.js +35 -0
- package/Insights/WidgetChartContainer.d.ts +7 -0
- package/Insights/WidgetChartContainer.js +56 -0
- package/Insights/WidgetDataGridContainer.d.ts +4 -0
- package/Insights/WidgetDataGridContainer.js +80 -0
- package/Insights/WidgetTableContainer.d.ts +7 -0
- package/Insights/WidgetTableContainer.js +57 -0
- package/Insights/WidgetTileContainer.d.ts +7 -0
- package/Insights/WidgetTileContainer.js +24 -0
- package/Insights/WidgetTitleBar.d.ts +7 -0
- package/Insights/WidgetTitleBar.js +21 -0
- package/Insights/Widgets.d.ts +4 -0
- package/Insights/Widgets.js +57 -0
- package/Insights/charts/AreaChart.d.ts +5 -0
- package/Insights/charts/AreaChart.js +20 -0
- package/Insights/charts/BarChart.d.ts +5 -0
- package/Insights/charts/BarChart.js +20 -0
- package/Insights/charts/ComposedChart.d.ts +5 -0
- package/Insights/charts/ComposedChart.js +19 -0
- package/Insights/charts/CustomTooltipContent.d.ts +7 -0
- package/Insights/charts/CustomTooltipContent.js +25 -0
- package/Insights/charts/GaugeChart.d.ts +5 -0
- package/Insights/charts/GaugeChart.js +8 -0
- package/Insights/charts/LineChart.d.ts +5 -0
- package/Insights/charts/LineChart.js +21 -0
- package/Insights/charts/OhlcChart.d.ts +6 -0
- package/Insights/charts/OhlcChart.js +119 -0
- package/Insights/charts/PieChart.d.ts +5 -0
- package/Insights/charts/PieChart.js +54 -0
- package/Insights/charts/RadarChart.d.ts +5 -0
- package/Insights/charts/RadarChart.js +38 -0
- package/Insights/charts/ScatterChart.d.ts +5 -0
- package/Insights/charts/ScatterChart.js +81 -0
- package/Insights/charts/constants.d.ts +1 -0
- package/Insights/charts/constants.js +25 -0
- package/Insights/charts/formatters.d.ts +14 -0
- package/Insights/charts/formatters.js +186 -0
- package/Insights/charts/index.d.ts +4 -0
- package/Insights/charts/index.js +13 -0
- package/Insights/charts/renderers.d.ts +10 -0
- package/Insights/charts/renderers.js +64 -0
- package/Insights/hooks/useQueriesData.d.ts +7 -0
- package/Insights/hooks/useQueriesData.js +90 -0
- package/Insights/hooks/useWidgetDetail.d.ts +10 -0
- package/Insights/hooks/useWidgetDetail.js +39 -0
- package/OverflowCommandBar/OverflowCommandBar.js +1 -4
- package/OverflowCommandBar/OverflowMenu.js +5 -17
- package/OverflowCommandBar/render.js +3 -4
- package/OverflowCommandBar/utils.js +2 -3
- package/PageBoard/BoardColumn.d.ts +5 -0
- package/PageBoard/BoardColumn.js +9 -0
- package/PageBoard/BoardColumnCard.d.ts +12 -0
- package/PageBoard/BoardColumnCard.js +29 -0
- package/PageBoard/BoardColumnUI.d.ts +2 -0
- package/PageBoard/BoardColumnUI.js +76 -0
- package/PageBoard/BoardingColumnCardLoading.d.ts +1 -0
- package/PageBoard/BoardingColumnCardLoading.js +21 -0
- package/PageBoard/Header.d.ts +7 -0
- package/PageBoard/Header.js +31 -0
- package/PageBoard/PageBoard.d.ts +7 -0
- package/PageBoard/PageBoard.js +46 -0
- package/PageBoard/index.d.ts +1 -0
- package/PageBoard/index.js +5 -0
- package/PageCalendar/CalendarSection.d.ts +20 -0
- package/PageCalendar/CalendarSection.js +108 -0
- package/PageCalendar/EventDialog/AttributeController.d.ts +10 -0
- package/PageCalendar/EventDialog/AttributeController.js +17 -0
- package/PageCalendar/EventDialog/EventDialog.d.ts +25 -0
- package/PageCalendar/EventDialog/EventDialog.js +21 -0
- package/PageCalendar/EventDialog/EventFormBody.d.ts +18 -0
- package/PageCalendar/EventDialog/EventFormBody.js +69 -0
- package/PageCalendar/EventDialog/EventFormContent.d.ts +10 -0
- package/PageCalendar/EventDialog/EventFormContent.js +27 -0
- package/PageCalendar/EventDialog/types.d.ts +3 -0
- package/PageCalendar/EventDialog/types.js +2 -0
- package/PageCalendar/EventDialog/utils.d.ts +23 -0
- package/PageCalendar/EventDialog/utils.js +57 -0
- package/PageCalendar/Header.d.ts +8 -0
- package/PageCalendar/Header.js +35 -0
- package/PageCalendar/PageCalendar.d.ts +7 -0
- package/PageCalendar/PageCalendar.js +231 -0
- package/PageCalendar/TitleSelector.d.ts +10 -0
- package/PageCalendar/TitleSelector.js +73 -0
- package/PageCalendar/ViewSelector.d.ts +8 -0
- package/PageCalendar/ViewSelector.js +52 -0
- package/PageCalendar/baseEventAttributes.d.ts +35 -0
- package/PageCalendar/baseEventAttributes.js +38 -0
- package/PageCalendar/context.d.ts +20 -0
- package/PageCalendar/context.js +5 -0
- package/PageCalendar/hooks/index.d.ts +1 -0
- package/PageCalendar/hooks/index.js +17 -0
- package/PageCalendar/hooks/useConfig.d.ts +3 -0
- package/PageCalendar/hooks/useConfig.js +8 -0
- package/PageCalendar/index.d.ts +1 -0
- package/PageCalendar/index.js +5 -0
- package/PageCalendar/renderEventContent.d.ts +2 -0
- package/PageCalendar/renderEventContent.js +22 -0
- package/PageCalendar/types.d.ts +5 -0
- package/PageCalendar/types.js +9 -0
- package/PageCalendar/utils.d.ts +3 -0
- package/PageCalendar/utils.js +17 -0
- package/PageEntityForm/CommandContainer.js +9 -5
- package/PageEntityForm/PageCustomEntityForm.d.ts +15 -0
- package/PageEntityForm/PageCustomEntityForm.js +17 -0
- package/PageEntityForm/PageEntityFormDesktopContainer.js +42 -22
- package/PageEntityForm/ProcessFlow.d.ts +10 -0
- package/PageEntityForm/ProcessFlow.js +84 -0
- package/PageEntityForm/RecordAvatar.d.ts +2 -0
- package/PageEntityForm/RecordAvatar.js +83 -0
- package/PageEntityForm/RecordCard.d.ts +1 -1
- package/PageEntityForm/RecordCard.js +60 -53
- package/PageEntityForm/RecordCardLoading.d.ts +8 -0
- package/PageEntityForm/RecordCardLoading.js +24 -0
- package/PageEntityForm/RecordSetNavigatorContainer.js +1 -2
- package/PageEntityForm/RelatedViewSelector.d.ts +0 -2
- package/PageEntityForm/RelatedViewSelector.js +37 -11
- package/PageEntityForm/SectionContainer.d.ts +2 -2
- package/PageEntityForm/SectionContainer.js +77 -13
- package/PageEntityForm/StandardControl.d.ts +1 -22
- package/PageEntityForm/StandardControl.js +103 -117
- package/PageEntityForm/SubgridControl.d.ts +1 -0
- package/PageEntityForm/SubgridControl.js +4 -2
- package/PageEntityForm/UploadImageDialog.d.ts +12 -0
- package/PageEntityForm/UploadImageDialog.js +114 -0
- package/PageEntityView/FormSubgridContainer.js +5 -2
- package/PageEntityView/FormSubgridNotAvailableContainer.d.ts +2 -0
- package/PageEntityView/FormSubgridNotAvailableContainer.js +48 -0
- package/PageEntityView/PageEntityView.js +4 -1
- package/PageEntityView/PageEntityViewDesktopFrame.js +1 -0
- package/PageEntityView/PageEntityViewMobileContainer.d.ts +2 -0
- package/PageEntityView/PageEntityViewMobileContainer.js +14 -0
- package/PageEntityView/PageEntityViewStringContext.d.ts +2 -0
- package/PageEntityView/PageEntityViewStringContext.js +2 -0
- package/PageInsights/PageInsights.d.ts +9 -0
- package/PageInsights/PageInsights.js +25 -0
- package/PageInsights/index.d.ts +1 -0
- package/PageInsights/index.js +6 -0
- package/ToastNotificationContainer/index.js +1 -2
- package/componentStore.d.ts +2 -0
- package/componentStore.js +5 -0
- package/components/BodyLoading.d.ts +1 -1
- package/components/BodyLoading.js +13 -8
- package/components/DndProvider.d.ts +12 -0
- package/components/DndProvider.js +68 -0
- package/components/LoginForm.js +5 -21
- package/form/FormControl.js +19 -41
- package/form/controls/AttachmentControl.d.ts +27 -0
- package/form/controls/AttachmentControl.js +220 -0
- package/form/controls/AttachmentsControl.d.ts +6 -0
- package/form/controls/AttachmentsControl.js +35 -0
- package/form/controls/CurrencyControl.js +38 -6
- package/form/controls/DateControl.d.ts +1 -1
- package/form/controls/DateControl.js +15 -3
- package/form/controls/DateRangeControl.js +4 -6
- package/form/controls/DateTimeControl.d.ts +1 -1
- package/form/controls/DateTimeControl.js +107 -12
- package/form/controls/DecimalControl.d.ts +5 -0
- package/form/controls/DecimalControl.js +52 -0
- package/form/controls/DurationControl.d.ts +4 -0
- package/form/controls/DurationControl.js +209 -0
- package/form/controls/EmailControl.d.ts +1 -1
- package/form/controls/EmailControl.js +5 -5
- package/form/controls/IntegerControl.d.ts +4 -0
- package/form/controls/IntegerControl.js +25 -0
- package/form/controls/LookupControl.d.ts +1 -0
- package/form/controls/LookupControl.js +57 -13
- package/form/controls/MultiSelectControl.js +3 -3
- package/form/controls/MultiSelectLookupControl.js +16 -17
- package/form/controls/PasswordControl.js +1 -1
- package/form/controls/RichTextControl.d.ts +5 -0
- package/form/controls/RichTextControl.js +33 -0
- package/form/controls/SelectControl.js +4 -5
- package/form/controls/SwitchControl.d.ts +1 -1
- package/form/controls/SwitchControl.js +4 -2
- package/form/controls/TelephoneControl.d.ts +1 -1
- package/form/controls/TelephoneControl.js +26 -4
- package/form/controls/TextAreaControl.d.ts +1 -1
- package/form/controls/TextAreaControl.js +6 -6
- package/form/controls/TextControl.js +4 -4
- package/form/controls/UrlControl.d.ts +4 -0
- package/form/controls/UrlControl.js +16 -0
- package/form/controls/useLookupData.js +26 -41
- package/form/layout/FormSection/FormSection.js +10 -3
- package/form/layout/FormTab/FormTab.js +4 -4
- package/form/types.d.ts +2 -2
- package/package.json +17 -12
- package/styles.css +149 -0
- package/types/index.d.ts +18 -0
- package/utils/avatar.d.ts +2 -0
- package/utils/avatar.js +45 -0
- package/App/AppProvider.d.ts +0 -9
- package/App/AppProvider.js +0 -50
- package/DataGrid/ScrollbarWithMoreDataRequest.d.ts +0 -9
- package/DataGrid/ScrollbarWithMoreDataRequest.js +0 -33
- package/DataGrid/getAttributeFormattedValue.d.ts +0 -16
- package/DataGrid/getAttributeFormattedValue.js +0 -92
- package/form/controls/NumberControl.d.ts +0 -4
- package/form/controls/NumberControl.js +0 -16
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UploadImageDialog = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_components_1 = require("@fluentui/react-components");
|
|
6
|
+
const hooks_1 = require("@headless-adminapp/app/dataform/hooks");
|
|
7
|
+
const dialog_1 = require("@headless-adminapp/app/dialog");
|
|
8
|
+
const transport_1 = require("@headless-adminapp/app/transport");
|
|
9
|
+
const utils_1 = require("@headless-adminapp/core/utils");
|
|
10
|
+
const icons_1 = require("@headless-adminapp/icons");
|
|
11
|
+
const react_query_1 = require("@tanstack/react-query");
|
|
12
|
+
const react_1 = require("react");
|
|
13
|
+
const avatar_1 = require("../utils/avatar");
|
|
14
|
+
const UploadImageDialog = ({ currentImage, recordTitle, recordId, onChange, open, onOpenChange, }) => {
|
|
15
|
+
const schema = (0, hooks_1.useDataFormSchema)();
|
|
16
|
+
const fileService = (0, transport_1.useFileService)();
|
|
17
|
+
const [file, setFile] = (0, react_1.useState)(null); // new file (indicate if file is changed)
|
|
18
|
+
const [fileUrl, setFileUrl] = (0, react_1.useState)(null); // file url, indicate that file is either selected or changed
|
|
19
|
+
const openErrorDialog = (0, dialog_1.useOpenErrorDialog)();
|
|
20
|
+
(0, react_1.useEffect)(() => {
|
|
21
|
+
setFileUrl(currentImage?.url ?? null);
|
|
22
|
+
}, [currentImage?.url]);
|
|
23
|
+
const handleSelectFile = () => {
|
|
24
|
+
const input = document.createElement('input');
|
|
25
|
+
input.type = 'file';
|
|
26
|
+
input.accept = 'image/*';
|
|
27
|
+
input.onchange = async (e) => {
|
|
28
|
+
const files = e.target.files;
|
|
29
|
+
if (!files?.length) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const _file = files[0];
|
|
33
|
+
setFile(_file);
|
|
34
|
+
const dataUrl = await (0, utils_1.readFileAsDataURL)(_file);
|
|
35
|
+
setFileUrl(dataUrl);
|
|
36
|
+
};
|
|
37
|
+
input.click();
|
|
38
|
+
};
|
|
39
|
+
const { isPending, mutate: handleApply } = (0, react_query_1.useMutation)({
|
|
40
|
+
mutationFn: async () => {
|
|
41
|
+
if (!fileService) {
|
|
42
|
+
throw new Error('File service is not available');
|
|
43
|
+
}
|
|
44
|
+
if (file) {
|
|
45
|
+
const url = await fileService.uploadFile(file, {
|
|
46
|
+
context: {
|
|
47
|
+
type: 'entity-form',
|
|
48
|
+
recordId,
|
|
49
|
+
attributeName: schema.avatarAttribute,
|
|
50
|
+
logicalName: schema.logicalName,
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
onChange?.({
|
|
54
|
+
name: file.name,
|
|
55
|
+
size: file.size,
|
|
56
|
+
type: file.type,
|
|
57
|
+
url,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
onChange?.(null);
|
|
62
|
+
}
|
|
63
|
+
onOpenChange(false);
|
|
64
|
+
},
|
|
65
|
+
onError: (error) => {
|
|
66
|
+
console.error(error);
|
|
67
|
+
openErrorDialog({
|
|
68
|
+
title: 'Error',
|
|
69
|
+
text: 'Unable to upload image',
|
|
70
|
+
});
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
// No image - No image selected - Upload Image
|
|
74
|
+
// No image - Image selected - Change, Cancel
|
|
75
|
+
// Image - Not changed - Upload Image, Use Default
|
|
76
|
+
// Image - Removed - Change, Cancel
|
|
77
|
+
// Image - Changed - Change, Cancel
|
|
78
|
+
const isFileChanged = (fileUrl ?? null) !== (currentImage?.url ?? null);
|
|
79
|
+
const showUploadImage = !isFileChanged;
|
|
80
|
+
const showChangeImage = !!isFileChanged;
|
|
81
|
+
const showResetImage = !isFileChanged && !!fileUrl;
|
|
82
|
+
const showCancel = isFileChanged;
|
|
83
|
+
return ((0, jsx_runtime_1.jsx)(react_components_1.Dialog, { open: open, onOpenChange: (e, data) => onOpenChange(data.open), 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.jsx)(react_components_1.DialogTitle, { action: (0, jsx_runtime_1.jsx)(react_components_1.DialogTrigger, { action: "close", children: (0, jsx_runtime_1.jsx)(react_components_1.Button, { appearance: "subtle", "aria-label": "close", icon: (0, jsx_runtime_1.jsx)(icons_1.Icons.Close, {}) }) }), children: "Choose Image" }), (0, jsx_runtime_1.jsx)(react_components_1.DialogContent, { children: (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("div", { children: "Upload an image from your device, or use the default image" }), (0, jsx_runtime_1.jsx)("div", { style: {
|
|
84
|
+
marginTop: react_components_1.tokens.spacingVerticalM,
|
|
85
|
+
marginBottom: react_components_1.tokens.spacingVerticalM,
|
|
86
|
+
display: 'flex',
|
|
87
|
+
alignItems: 'center',
|
|
88
|
+
justifyContent: 'center',
|
|
89
|
+
}, children: (0, jsx_runtime_1.jsx)(react_components_1.Avatar, { shape: "square", style: { width: 120, height: 120 }, name: recordTitle, color: (0, avatar_1.getAvatarColor)(recordTitle), image: {
|
|
90
|
+
src: fileUrl ?? undefined,
|
|
91
|
+
} }) })] }) }), (0, jsx_runtime_1.jsxs)(react_components_1.DialogActions, { children: [showChangeImage && ((0, jsx_runtime_1.jsx)(react_components_1.Button, { appearance: "primary", onClick: () => handleApply(), style: {
|
|
92
|
+
whiteSpace: 'nowrap',
|
|
93
|
+
fontWeight: 'normal',
|
|
94
|
+
}, disabled: isPending, children: isPending ? 'Changing...' : 'Change' })), showUploadImage && ((0, jsx_runtime_1.jsx)(react_components_1.Button, { appearance: "primary", onClick: handleSelectFile, style: {
|
|
95
|
+
whiteSpace: 'nowrap',
|
|
96
|
+
// minWidth: 0,
|
|
97
|
+
fontWeight: 'normal',
|
|
98
|
+
}, children: "Upload Image" })), showResetImage && ((0, jsx_runtime_1.jsx)(react_components_1.Button, { style: {
|
|
99
|
+
whiteSpace: 'nowrap',
|
|
100
|
+
// minWidth: 0,
|
|
101
|
+
fontWeight: 'normal',
|
|
102
|
+
}, onClick: () => {
|
|
103
|
+
setFileUrl(null);
|
|
104
|
+
setFile(null);
|
|
105
|
+
}, children: "Reset to Default" })), showCancel && ((0, jsx_runtime_1.jsx)(react_components_1.Button, { appearance: "secondary", style: {
|
|
106
|
+
whiteSpace: 'nowrap',
|
|
107
|
+
// minWidth: 0,
|
|
108
|
+
fontWeight: 'normal',
|
|
109
|
+
}, onClick: () => {
|
|
110
|
+
setFileUrl(currentImage?.url ?? null);
|
|
111
|
+
setFile(null);
|
|
112
|
+
}, children: "Cancel" }))] })] }) }) }));
|
|
113
|
+
};
|
|
114
|
+
exports.UploadImageDialog = UploadImageDialog;
|
|
@@ -35,11 +35,14 @@ const FormSubgridContainer = ({ hideCommandBar, hideSearch, }) => {
|
|
|
35
35
|
}, children: (0, jsx_runtime_1.jsx)(FormSubgridViewSelector_1.FormSubgridViewSelector, {}) }), (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(react_components_1.Divider, { style: { opacity: 0.2 } }) }), (!hideCommandBar || !hideSearch) && ((0, jsx_runtime_1.jsxs)("div", { style: {
|
|
36
36
|
display: 'flex',
|
|
37
37
|
flexDirection: 'row',
|
|
38
|
-
gap:
|
|
38
|
+
gap: 10,
|
|
39
39
|
overflow: 'hidden',
|
|
40
40
|
width: '100%',
|
|
41
41
|
paddingBlock: 4,
|
|
42
|
-
}, children: [(0, jsx_runtime_1.jsx)("div", { style: {
|
|
42
|
+
}, children: [(0, jsx_runtime_1.jsx)("div", { style: {
|
|
43
|
+
flex: 1,
|
|
44
|
+
minWidth: 0,
|
|
45
|
+
}, children: !hideCommandBar && (0, jsx_runtime_1.jsx)(FormSubgridCommandContainer_1.FormSubgridCommandContainer, {}) }), !hideSearch && ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
43
46
|
display: 'flex',
|
|
44
47
|
alignItems: 'center',
|
|
45
48
|
justifyContent: 'end',
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FormSubgridNotAvailableContainer = void 0;
|
|
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
|
+
const FormSubgridViewSelector_1 = require("../DataGrid/FormSubgridViewSelector");
|
|
8
|
+
const PageEntityViewStringContext_1 = require("./PageEntityViewStringContext");
|
|
9
|
+
const FormSubgridNotAvailableContainer = () => {
|
|
10
|
+
const strings = (0, PageEntityViewStringContext_1.usePageEntityViewStrings)();
|
|
11
|
+
return ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
12
|
+
display: 'flex',
|
|
13
|
+
flex: 1,
|
|
14
|
+
flexDirection: 'column',
|
|
15
|
+
gap: 8,
|
|
16
|
+
overflow: 'hidden',
|
|
17
|
+
}, children: (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
18
|
+
// gap: 12,
|
|
19
|
+
flex: 1,
|
|
20
|
+
display: 'flex',
|
|
21
|
+
flexDirection: 'column',
|
|
22
|
+
// overflow: 'hidden',
|
|
23
|
+
}, children: [(0, jsx_runtime_1.jsx)("div", { style: {
|
|
24
|
+
display: 'flex',
|
|
25
|
+
flexDirection: 'row',
|
|
26
|
+
alignItems: 'center',
|
|
27
|
+
height: 40,
|
|
28
|
+
}, children: (0, jsx_runtime_1.jsx)(FormSubgridViewSelector_1.FormSubgridViewSelector, {}) }), (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(react_components_1.Divider, { style: { opacity: 0.2 } }) }), (0, jsx_runtime_1.jsx)("div", { style: {
|
|
29
|
+
flex: 1,
|
|
30
|
+
display: 'flex',
|
|
31
|
+
flexDirection: 'column',
|
|
32
|
+
}, children: (0, jsx_runtime_1.jsx)("div", { style: {
|
|
33
|
+
gap: 16,
|
|
34
|
+
display: 'flex',
|
|
35
|
+
flexDirection: 'column',
|
|
36
|
+
flex: 1,
|
|
37
|
+
}, children: (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
38
|
+
flex: 1,
|
|
39
|
+
display: 'flex',
|
|
40
|
+
alignItems: 'center',
|
|
41
|
+
justifyContent: 'center',
|
|
42
|
+
flexDirection: 'column',
|
|
43
|
+
gap: react_components_1.tokens.spacingVerticalM,
|
|
44
|
+
minHeight: 300,
|
|
45
|
+
color: react_components_1.tokens.colorNeutralForeground3,
|
|
46
|
+
}, children: [(0, jsx_runtime_1.jsx)(icons_1.Icons.Grid, { size: 48 }), (0, jsx_runtime_1.jsx)(react_components_1.Body1, { children: strings.subgridNotAvailable })] }) }) })] }) }));
|
|
47
|
+
};
|
|
48
|
+
exports.FormSubgridNotAvailableContainer = FormSubgridNotAvailableContainer;
|
|
@@ -3,13 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.PageEntityView = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const datagrid_1 = require("@headless-adminapp/app/datagrid");
|
|
6
|
+
const hooks_1 = require("@headless-adminapp/app/hooks");
|
|
6
7
|
const PageEntityViewProvider_1 = require("@headless-adminapp/app/providers/PageEntityViewProvider");
|
|
7
8
|
const icons_1 = require("@headless-adminapp/icons");
|
|
8
9
|
const PageBroken_1 = require("../components/PageBroken");
|
|
9
10
|
const PageLoading_1 = require("../components/PageLoading");
|
|
10
11
|
const PageEntityViewDesktopContainer_1 = require("./PageEntityViewDesktopContainer");
|
|
12
|
+
const PageEntityViewMobileContainer_1 = require("./PageEntityViewMobileContainer");
|
|
11
13
|
const PageEntityView = ({ logicalName, viewId, onChangeView, }) => {
|
|
12
14
|
const result = (0, datagrid_1.useLoadMainGridPage)(logicalName, viewId);
|
|
15
|
+
const isMobile = (0, hooks_1.useIsMobile)();
|
|
13
16
|
if (result.loading) {
|
|
14
17
|
return (0, jsx_runtime_1.jsx)(PageLoading_1.PageLoading, {});
|
|
15
18
|
}
|
|
@@ -17,6 +20,6 @@ const PageEntityView = ({ logicalName, viewId, onChangeView, }) => {
|
|
|
17
20
|
return ((0, jsx_runtime_1.jsx)(PageBroken_1.PageBroken, { Icon: icons_1.Icons.Error, title: result.title, message: result.message }));
|
|
18
21
|
}
|
|
19
22
|
const { schema, commands, viewLookup, view } = result;
|
|
20
|
-
return ((0, jsx_runtime_1.jsx)(PageEntityViewProvider_1.PageEntityViewProvider, { schema: schema, view: view, availableViews: viewLookup, commands: commands, onChangeView: onChangeView, children: (0, jsx_runtime_1.jsx)(PageEntityViewDesktopContainer_1.PageEntityViewDesktopContainer, {}) }));
|
|
23
|
+
return ((0, jsx_runtime_1.jsx)(PageEntityViewProvider_1.PageEntityViewProvider, { schema: schema, view: view, availableViews: viewLookup, commands: commands, onChangeView: onChangeView, children: isMobile ? ((0, jsx_runtime_1.jsx)(PageEntityViewMobileContainer_1.PageEntityViewMobileContainer, {})) : ((0, jsx_runtime_1.jsx)(PageEntityViewDesktopContainer_1.PageEntityViewDesktopContainer, {})) }));
|
|
21
24
|
};
|
|
22
25
|
exports.PageEntityView = PageEntityView;
|
|
@@ -25,6 +25,7 @@ const PageEntityViewDesktopFrame = ({ commandBar, header, content, footer }) =>
|
|
|
25
25
|
background: react_components_1.tokens.colorNeutralBackground1,
|
|
26
26
|
display: 'flex',
|
|
27
27
|
// overflow: 'hidden',
|
|
28
|
+
minHeight: 40,
|
|
28
29
|
}, children: commandBar }), (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
29
30
|
flex: 1,
|
|
30
31
|
display: 'flex',
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PageEntityViewMobileContainer = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const CommandContainer_1 = require("../DataGrid/CommandContainer");
|
|
7
|
+
const GridHeaderMobile_1 = require("../DataGrid/GridHeaderMobile");
|
|
8
|
+
const GridListContainer_1 = require("../DataGrid/GridListContainer");
|
|
9
|
+
const GridPaginationContainer_1 = require("../DataGrid/GridPaginationContainer");
|
|
10
|
+
const PageEntityViewDesktopFrame_1 = require("./PageEntityViewDesktopFrame");
|
|
11
|
+
const PageEntityViewMobileContainer = () => {
|
|
12
|
+
return ((0, jsx_runtime_1.jsx)(react_1.Fragment, { children: (0, jsx_runtime_1.jsx)(PageEntityViewDesktopFrame_1.PageEntityViewDesktopFrame, { commandBar: (0, jsx_runtime_1.jsx)(CommandContainer_1.CommandContainer, {}), header: (0, jsx_runtime_1.jsx)(GridHeaderMobile_1.GridHeaderMobile, {}), content: (0, jsx_runtime_1.jsx)(GridListContainer_1.GridListContainer, {}), footer: (0, jsx_runtime_1.jsx)(GridPaginationContainer_1.GridPaginationContainer, {}) }) }));
|
|
13
|
+
};
|
|
14
|
+
exports.PageEntityViewMobileContainer = PageEntityViewMobileContainer;
|
|
@@ -17,6 +17,8 @@ export interface PageEntityViewStringSet {
|
|
|
17
17
|
filter: string;
|
|
18
18
|
clearFilter: string;
|
|
19
19
|
filterBy: string;
|
|
20
|
+
noRecordsFound: string;
|
|
21
|
+
subgridNotAvailable: string;
|
|
20
22
|
}
|
|
21
23
|
export declare const defaultPageEntityViewStrings: PageEntityViewStringSet;
|
|
22
24
|
export declare const PageEntityViewStringContext: import("react").Context<PageEntityViewStringSet>;
|
|
@@ -22,6 +22,8 @@ exports.defaultPageEntityViewStrings = {
|
|
|
22
22
|
filter: 'Filter',
|
|
23
23
|
sortByDescending: 'Sort by descending',
|
|
24
24
|
filterBy: 'Filter by',
|
|
25
|
+
noRecordsFound: "We didn't find anything to show here",
|
|
26
|
+
subgridNotAvailable: 'Save the record to view associated records.',
|
|
25
27
|
};
|
|
26
28
|
exports.PageEntityViewStringContext = (0, react_1.createContext)(exports.defaultPageEntityViewStrings);
|
|
27
29
|
function usePageEntityViewStrings() {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { InsightExpereince, InsightLookup } from '@headless-adminapp/core/experience/insights';
|
|
2
|
+
export declare function createInsightLookup(insights: InsightExpereince[]): InsightLookup[];
|
|
3
|
+
interface PageInsightsProps {
|
|
4
|
+
insights: InsightExpereince[];
|
|
5
|
+
insightId: string;
|
|
6
|
+
onChangeInsight: (id: string) => void;
|
|
7
|
+
}
|
|
8
|
+
export declare function PageInsights({ insightId, insights, onChangeInsight, }: PageInsightsProps): import("react/jsx-runtime").JSX.Element | null;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createInsightLookup = createInsightLookup;
|
|
4
|
+
exports.PageInsights = PageInsights;
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const InsightsProvider_1 = require("@headless-adminapp/app/insights/InsightsProvider");
|
|
7
|
+
const react_1 = require("react");
|
|
8
|
+
const InsightsContainer_1 = require("../Insights/InsightsContainer");
|
|
9
|
+
function createInsightLookup(insights) {
|
|
10
|
+
return insights.map((insight) => ({
|
|
11
|
+
id: insight.id,
|
|
12
|
+
title: insight.title,
|
|
13
|
+
subtitle: insight.subtitle,
|
|
14
|
+
}));
|
|
15
|
+
}
|
|
16
|
+
function PageInsights({ insightId, insights, onChangeInsight, }) {
|
|
17
|
+
const insightExpereince = (0, react_1.useMemo)(() => {
|
|
18
|
+
return insights.find((insight) => insight.id === insightId);
|
|
19
|
+
}, [insightId, insights]);
|
|
20
|
+
const insightLookups = (0, react_1.useMemo)(() => createInsightLookup(insights), [insights]);
|
|
21
|
+
if (!insightExpereince) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
return ((0, jsx_runtime_1.jsx)(InsightsProvider_1.InsightsProvider, { experience: insightExpereince, insightLookup: insightLookups, onInsightSelect: onChangeInsight, children: (0, jsx_runtime_1.jsx)(InsightsContainer_1.InsightsContainer, {}) }));
|
|
25
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { PageInsights, createInsightLookup } from './PageInsights';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createInsightLookup = exports.PageInsights = void 0;
|
|
4
|
+
var PageInsights_1 = require("./PageInsights");
|
|
5
|
+
Object.defineProperty(exports, "PageInsights", { enumerable: true, get: function () { return PageInsights_1.PageInsights; } });
|
|
6
|
+
Object.defineProperty(exports, "createInsightLookup", { enumerable: true, get: function () { return PageInsights_1.createInsightLookup; } });
|
|
@@ -18,7 +18,6 @@ const Item = ({ item, toasterId, }) => {
|
|
|
18
18
|
const closeToastNotification = (0, hooks_1.useCloseToastNotification)();
|
|
19
19
|
const opened = (0, react_1.useRef)(false);
|
|
20
20
|
(0, react_1.useEffect)(() => {
|
|
21
|
-
var _a;
|
|
22
21
|
if (!item.isOpen) {
|
|
23
22
|
dismissToast(item.id);
|
|
24
23
|
return;
|
|
@@ -27,7 +26,7 @@ const Item = ({ item, toasterId, }) => {
|
|
|
27
26
|
return;
|
|
28
27
|
}
|
|
29
28
|
opened.current = true;
|
|
30
|
-
dispatchToast((0, jsx_runtime_1.jsxs)(react_components_1.Toast, { children: [(0, jsx_runtime_1.jsx)(react_components_1.ToastTitle, { children: item.title }), (0, jsx_runtime_1.jsx)(react_components_1.ToastBody, { children: item.text }), !!
|
|
29
|
+
dispatchToast((0, jsx_runtime_1.jsxs)(react_components_1.Toast, { children: [(0, jsx_runtime_1.jsx)(react_components_1.ToastTitle, { children: item.title }), (0, jsx_runtime_1.jsx)(react_components_1.ToastBody, { children: item.text }), !!item.actions?.length && ((0, jsx_runtime_1.jsx)(react_components_1.ToastFooter, { children: item.actions.map((action, index) => ((0, jsx_runtime_1.jsx)(react_components_1.Link, { onClick: action.onClick, children: action.text }, index))) }))] }), {
|
|
31
30
|
timeout: 2000,
|
|
32
31
|
intent: item.type,
|
|
33
32
|
pauseOnHover: true,
|
|
@@ -7,13 +7,18 @@ const BodyLoading = ({ loading }) => {
|
|
|
7
7
|
if (!loading) {
|
|
8
8
|
return null;
|
|
9
9
|
}
|
|
10
|
-
return ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { style: {
|
|
11
|
+
position: 'absolute',
|
|
12
|
+
inset: 0,
|
|
13
|
+
backgroundColor: react_components_1.tokens.colorNeutralBackground1,
|
|
14
|
+
opacity: 0.7,
|
|
15
|
+
zIndex: 1,
|
|
16
|
+
} }), (0, jsx_runtime_1.jsx)("div", { style: {
|
|
17
|
+
position: 'absolute',
|
|
18
|
+
inset: 0,
|
|
19
|
+
display: 'flex',
|
|
20
|
+
alignItems: 'center',
|
|
21
|
+
justifyContent: 'center',
|
|
22
|
+
}, children: (0, jsx_runtime_1.jsx)(react_components_1.Spinner, { size: "small" }) })] }));
|
|
18
23
|
};
|
|
19
24
|
exports.BodyLoading = BodyLoading;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { BackendFactory } from 'dnd-core';
|
|
2
|
+
import { FC, PropsWithChildren } from 'react';
|
|
3
|
+
import type * as ReactDndTypes from 'react-dnd';
|
|
4
|
+
interface DndContextState {
|
|
5
|
+
DndProvider: typeof ReactDndTypes.DndProvider;
|
|
6
|
+
backend: BackendFactory;
|
|
7
|
+
useDrag: typeof ReactDndTypes.useDrag;
|
|
8
|
+
useDrop: typeof ReactDndTypes.useDrop;
|
|
9
|
+
}
|
|
10
|
+
export declare const DndProvider: FC<PropsWithChildren>;
|
|
11
|
+
export declare function useDndContext(): DndContextState;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.DndProvider = void 0;
|
|
27
|
+
exports.useDndContext = useDndContext;
|
|
28
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
29
|
+
const react_1 = require("react");
|
|
30
|
+
const DndProviderIntenral = (0, react_1.lazy)(() => Promise.resolve().then(() => __importStar(require('react-dnd'))).then((mod) => ({ default: mod.DndProvider })));
|
|
31
|
+
let ReactDndPromise = null;
|
|
32
|
+
let HTML5BackendPromise = null;
|
|
33
|
+
const DndContext = (0, react_1.createContext)(null);
|
|
34
|
+
const DndProvider = ({ children }) => {
|
|
35
|
+
const [context, setContext] = (0, react_1.useState)(null);
|
|
36
|
+
(0, react_1.useEffect)(() => {
|
|
37
|
+
if (!HTML5BackendPromise) {
|
|
38
|
+
HTML5BackendPromise = Promise.resolve().then(() => __importStar(require('react-dnd-html5-backend'))).then((mod) => mod.HTML5Backend);
|
|
39
|
+
}
|
|
40
|
+
if (!ReactDndPromise) {
|
|
41
|
+
ReactDndPromise = Promise.resolve().then(() => __importStar(require('react-dnd')));
|
|
42
|
+
}
|
|
43
|
+
Promise.all([HTML5BackendPromise, ReactDndPromise])
|
|
44
|
+
.then(([backend, mod]) => {
|
|
45
|
+
setContext({
|
|
46
|
+
DndProvider: mod.DndProvider,
|
|
47
|
+
backend: backend,
|
|
48
|
+
useDrag: mod.useDrag,
|
|
49
|
+
useDrop: mod.useDrop,
|
|
50
|
+
});
|
|
51
|
+
})
|
|
52
|
+
.catch((err) => {
|
|
53
|
+
console.error(err);
|
|
54
|
+
});
|
|
55
|
+
}, []);
|
|
56
|
+
if (!context) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
return ((0, jsx_runtime_1.jsx)(DndContext.Provider, { value: context, children: (0, jsx_runtime_1.jsx)(DndProviderIntenral, { backend: context.backend, children: children }) }));
|
|
60
|
+
};
|
|
61
|
+
exports.DndProvider = DndProvider;
|
|
62
|
+
function useDndContext() {
|
|
63
|
+
const context = (0, react_1.useContext)(DndContext);
|
|
64
|
+
if (!context) {
|
|
65
|
+
throw new Error('useDndContext must be used within DndProvider');
|
|
66
|
+
}
|
|
67
|
+
return context;
|
|
68
|
+
}
|
package/components/LoginForm.js
CHANGED
|
@@ -22,15 +22,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
26
|
exports.LoginForm = LoginForm;
|
|
36
27
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
@@ -56,19 +47,18 @@ function LoginForm(props) {
|
|
|
56
47
|
defaultValues: initialValues,
|
|
57
48
|
resolver: (0, yup_1.yupResolver)(validationSchema),
|
|
58
49
|
});
|
|
59
|
-
const handleOnSubmit = (values) =>
|
|
60
|
-
var _a, _b;
|
|
50
|
+
const handleOnSubmit = async (values) => {
|
|
61
51
|
form.clearErrors();
|
|
62
52
|
try {
|
|
63
|
-
|
|
53
|
+
await props.onLogin(values.username?.toLowerCase().trim(), values.password);
|
|
64
54
|
}
|
|
65
55
|
catch (error) {
|
|
66
56
|
form.setError('root', {
|
|
67
57
|
type: 'manual',
|
|
68
|
-
message:
|
|
58
|
+
message: error?.message ?? 'An error occurred',
|
|
69
59
|
});
|
|
70
60
|
}
|
|
71
|
-
}
|
|
61
|
+
};
|
|
72
62
|
return ((0, jsx_runtime_1.jsx)("form", { onSubmit: form.handleSubmit(handleOnSubmit), children: (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
73
63
|
display: 'flex',
|
|
74
64
|
flexDirection: 'column',
|
|
@@ -88,13 +78,7 @@ function LoginForm(props) {
|
|
|
88
78
|
alignItems: 'stretch',
|
|
89
79
|
justifyContent: 'flex-start',
|
|
90
80
|
gap: 16,
|
|
91
|
-
}, children: [(0, jsx_runtime_1.jsx)(react_hook_form_1.Controller, { control: form.control, name: "username", render: ({ field, fieldState, formState }) => {
|
|
92
|
-
var _a, _b, _c;
|
|
93
|
-
return ((0, jsx_runtime_1.jsx)(SectionControl_1.SectionControlWrapper, { label: "Username", labelPosition: "top", required: true, isError: !!((_a = fieldState.error) === null || _a === void 0 ? void 0 : _a.message) && formState.isSubmitted, errorMessage: (_b = fieldState.error) === null || _b === void 0 ? void 0 : _b.message, children: (0, jsx_runtime_1.jsx)(TextControl_1.TextControl, { placeholder: "Username", appearance: "outline", name: field.name, value: field.value, onChange: field.onChange, onBlur: field.onBlur, autoCapitalize: "none", autoCorrect: "off", error: !!((_c = fieldState.error) === null || _c === void 0 ? void 0 : _c.message) && formState.isSubmitted }) }));
|
|
94
|
-
} }), (0, jsx_runtime_1.jsx)(react_hook_form_1.Controller, { control: form.control, name: "password", render: ({ field, fieldState, formState }) => {
|
|
95
|
-
var _a, _b, _c;
|
|
96
|
-
return ((0, jsx_runtime_1.jsx)(SectionControl_1.SectionControlWrapper, { label: "Password", labelPosition: "top", required: true, isError: !!((_a = fieldState.error) === null || _a === void 0 ? void 0 : _a.message) && formState.isSubmitted, errorMessage: (_b = fieldState.error) === null || _b === void 0 ? void 0 : _b.message, children: (0, jsx_runtime_1.jsx)(PasswordControl_1.PasswordControl, { placeholder: "Password", name: field.name, appearance: "outline", error: !!((_c = fieldState.error) === null || _c === void 0 ? void 0 : _c.message) && formState.isSubmitted, value: field.value, onChange: field.onChange, onBlur: field.onBlur }) }));
|
|
97
|
-
} }), !!form.formState.errors.root && ((0, jsx_runtime_1.jsx)(react_components_1.MessageBar, { intent: "error", children: (0, jsx_runtime_1.jsx)(react_components_1.MessageBarBody, { children: form.formState.errors.root.message }) })), (0, jsx_runtime_1.jsxs)(react_components_1.Button, { appearance: "primary", type: "submit", style: {
|
|
81
|
+
}, children: [(0, jsx_runtime_1.jsx)(react_hook_form_1.Controller, { control: form.control, name: "username", render: ({ field, fieldState, formState }) => ((0, jsx_runtime_1.jsx)(SectionControl_1.SectionControlWrapper, { label: "Username", labelPosition: "top", required: true, isError: !!fieldState.error?.message && formState.isSubmitted, errorMessage: fieldState.error?.message, children: (0, jsx_runtime_1.jsx)(TextControl_1.TextControl, { placeholder: "Username", appearance: "outline", name: field.name, value: field.value, onChange: field.onChange, onBlur: field.onBlur, autoCapitalize: "none", autoCorrect: "off", error: !!fieldState.error?.message && formState.isSubmitted }) })) }), (0, jsx_runtime_1.jsx)(react_hook_form_1.Controller, { control: form.control, name: "password", render: ({ field, fieldState, formState }) => ((0, jsx_runtime_1.jsx)(SectionControl_1.SectionControlWrapper, { label: "Password", labelPosition: "top", required: true, isError: !!fieldState.error?.message && formState.isSubmitted, errorMessage: fieldState.error?.message, children: (0, jsx_runtime_1.jsx)(PasswordControl_1.PasswordControl, { placeholder: "Password", name: field.name, appearance: "outline", error: !!fieldState.error?.message && formState.isSubmitted, value: field.value, onChange: field.onChange, onBlur: field.onBlur }) })) }), !!form.formState.errors.root && ((0, jsx_runtime_1.jsx)(react_components_1.MessageBar, { intent: "error", children: (0, jsx_runtime_1.jsx)(react_components_1.MessageBarBody, { children: form.formState.errors.root.message }) })), (0, jsx_runtime_1.jsxs)(react_components_1.Button, { appearance: "primary", type: "submit", style: {
|
|
98
82
|
marginTop: 8,
|
|
99
83
|
pointerEvents: form.formState.isSubmitting ? 'none' : 'auto',
|
|
100
84
|
}, children: [form.formState.isSubmitting && ((0, jsx_runtime_1.jsx)(react_components_1.Spinner, { size: "extra-tiny", appearance: "inverted", style: { marginRight: 4 } })), "Login"] })] }), (0, jsx_runtime_1.jsx)("div", { style: { height: 80 } })] }) }));
|