@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,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.renderEventContent = renderEventContent;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_components_1 = require("@fluentui/react-components");
|
|
6
|
+
function renderEventContent(eventInfo) {
|
|
7
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: {
|
|
8
|
+
display: 'flex',
|
|
9
|
+
backgroundColor: react_components_1.tokens.colorBrandBackground2,
|
|
10
|
+
color: react_components_1.tokens.colorNeutralForeground1,
|
|
11
|
+
borderRadius: react_components_1.tokens.borderRadiusMedium,
|
|
12
|
+
paddingBlock: react_components_1.tokens.spacingVerticalXXS,
|
|
13
|
+
paddingInline: react_components_1.tokens.spacingHorizontalS,
|
|
14
|
+
border: `1px solid ${react_components_1.tokens.colorBrandStroke2}`,
|
|
15
|
+
gap: react_components_1.tokens.spacingHorizontalS,
|
|
16
|
+
width: '100%',
|
|
17
|
+
overflow: 'hidden',
|
|
18
|
+
textOverflow: 'ellipsis',
|
|
19
|
+
height: '100%',
|
|
20
|
+
cursor: 'pointer',
|
|
21
|
+
}, children: [eventInfo.timeText && (0, jsx_runtime_1.jsx)("span", { children: eventInfo.timeText }), (0, jsx_runtime_1.jsx)("span", { style: { fontWeight: react_components_1.tokens.fontWeightSemibold }, children: eventInfo.event.title })] }));
|
|
22
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ViewType = void 0;
|
|
4
|
+
var ViewType;
|
|
5
|
+
(function (ViewType) {
|
|
6
|
+
ViewType["Month"] = "dayGridMonth";
|
|
7
|
+
ViewType["Week"] = "timeGridWeek";
|
|
8
|
+
ViewType["Day"] = "timeGridDay";
|
|
9
|
+
})(ViewType || (exports.ViewType = ViewType = {}));
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.transformEvent = transformEvent;
|
|
4
|
+
function transformEvent(event) {
|
|
5
|
+
const { id, title, description, end, start, ...rest } = event;
|
|
6
|
+
return {
|
|
7
|
+
id,
|
|
8
|
+
title,
|
|
9
|
+
description,
|
|
10
|
+
start: start ?? undefined,
|
|
11
|
+
end: end ?? undefined,
|
|
12
|
+
allDay: event.allDay ?? false,
|
|
13
|
+
backgroundColor: 'transparent',
|
|
14
|
+
borderColor: 'transparent',
|
|
15
|
+
extendedProps: rest,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
@@ -3,18 +3,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.CommandContainer = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const hooks_1 = require("@headless-adminapp/app/dataform/hooks");
|
|
6
|
+
const hooks_2 = require("@headless-adminapp/app/hooks");
|
|
6
7
|
const mutable_1 = require("@headless-adminapp/app/mutable");
|
|
7
8
|
const recordset_1 = require("@headless-adminapp/app/recordset");
|
|
8
|
-
const
|
|
9
|
-
const
|
|
9
|
+
const hooks_3 = require("@headless-adminapp/app/recordset/hooks");
|
|
10
|
+
const hooks_4 = require("@headless-adminapp/app/route/hooks");
|
|
10
11
|
const icons_1 = require("@headless-adminapp/icons");
|
|
11
12
|
const react_1 = require("react");
|
|
12
13
|
const OverflowCommandBar_1 = require("../OverflowCommandBar");
|
|
13
14
|
const CommandContainer = () => {
|
|
14
15
|
const gridCommands = (0, hooks_1.useMainFormCommands)();
|
|
15
|
-
const router = (0,
|
|
16
|
+
const router = (0, hooks_4.useRouter)();
|
|
17
|
+
const isMobile = (0, hooks_2.useIsMobile)();
|
|
16
18
|
const schema = (0, hooks_1.useDataFormSchema)();
|
|
17
|
-
const [recordSetVisible, setRecordSetVisible] = (0,
|
|
19
|
+
const [recordSetVisible, setRecordSetVisible] = (0, hooks_3.useRecordSetVisibility)();
|
|
18
20
|
const recordSetContext = (0, mutable_1.useContextSelector)(recordset_1.RecordSetContext, (state) => state);
|
|
19
21
|
const extendedCommands = (0, react_1.useMemo)(() => {
|
|
20
22
|
return [
|
|
@@ -28,7 +30,8 @@ const CommandContainer = () => {
|
|
|
28
30
|
},
|
|
29
31
|
],
|
|
30
32
|
...(recordSetContext.logicalName === schema.logicalName &&
|
|
31
|
-
recordSetContext.ids.length > 0
|
|
33
|
+
recordSetContext.ids.length > 0 &&
|
|
34
|
+
!isMobile
|
|
32
35
|
? [
|
|
33
36
|
[
|
|
34
37
|
{
|
|
@@ -45,6 +48,7 @@ const CommandContainer = () => {
|
|
|
45
48
|
];
|
|
46
49
|
}, [
|
|
47
50
|
gridCommands,
|
|
51
|
+
isMobile,
|
|
48
52
|
recordSetContext.ids.length,
|
|
49
53
|
recordSetContext.logicalName,
|
|
50
54
|
recordSetVisible,
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { RetriveRecordFn } from '@headless-adminapp/app/dataform/DataFormProvider/types';
|
|
2
|
+
import { SaveRecordFn } from '@headless-adminapp/app/dataform/utils/saveRecord';
|
|
3
|
+
import { EntityMainFormCommandItemExperience, Form } from '@headless-adminapp/core/experience/form';
|
|
4
|
+
import { Schema, SchemaAttributes } from '@headless-adminapp/core/schema';
|
|
5
|
+
import { FC } from 'react';
|
|
6
|
+
interface PageCustomEntityFormProps<SA extends SchemaAttributes = SchemaAttributes> {
|
|
7
|
+
recordId?: string;
|
|
8
|
+
schema: Schema<SA>;
|
|
9
|
+
form: Form<SA>;
|
|
10
|
+
commands: EntityMainFormCommandItemExperience[][];
|
|
11
|
+
retriveRecordFn?: RetriveRecordFn<SA>;
|
|
12
|
+
saveRecordFn?: SaveRecordFn;
|
|
13
|
+
}
|
|
14
|
+
export declare const PageCustomEntityForm: FC<PageCustomEntityFormProps>;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PageCustomEntityForm = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_components_1 = require("@fluentui/react-components");
|
|
6
|
+
const PageEntityFormProvider_1 = require("@headless-adminapp/app/providers/PageEntityFormProvider");
|
|
7
|
+
const PageEntityFormDesktopContainer_1 = require("./PageEntityFormDesktopContainer");
|
|
8
|
+
const PageCustomEntityForm = ({ recordId, commands, form, schema, retriveRecordFn, saveRecordFn, }) => {
|
|
9
|
+
return ((0, jsx_runtime_1.jsx)(PageEntityFormProvider_1.PageEntityFormProvider, { schema: schema, form: form, recordId: recordId, commands: commands, retriveRecordFn: retriveRecordFn, saveRecordFn: saveRecordFn, children: (0, jsx_runtime_1.jsx)("div", { style: {
|
|
10
|
+
display: 'flex',
|
|
11
|
+
flex: 1,
|
|
12
|
+
flexDirection: 'row',
|
|
13
|
+
backgroundColor: react_components_1.tokens.colorNeutralBackground2,
|
|
14
|
+
overflow: 'hidden',
|
|
15
|
+
}, children: (0, jsx_runtime_1.jsx)(PageEntityFormDesktopContainer_1.PageEntityFormDesktopContainer, {}) }) }));
|
|
16
|
+
};
|
|
17
|
+
exports.PageCustomEntityForm = PageCustomEntityForm;
|
|
@@ -3,12 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.PageEntityFormDesktopContainer = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_components_1 = require("@fluentui/react-components");
|
|
6
|
-
const builders_1 = require("@headless-adminapp/app/builders");
|
|
7
6
|
const dataform_1 = require("@headless-adminapp/app/dataform");
|
|
8
7
|
const hooks_1 = require("@headless-adminapp/app/dataform/hooks");
|
|
9
8
|
const locale_1 = require("@headless-adminapp/app/locale");
|
|
9
|
+
const utils_1 = require("@headless-adminapp/app/locale/utils");
|
|
10
10
|
const mutable_1 = require("@headless-adminapp/app/mutable");
|
|
11
|
-
const
|
|
11
|
+
const utils_2 = require("@headless-adminapp/app/utils");
|
|
12
12
|
const react_1 = require("react");
|
|
13
13
|
const react_hook_form_1 = require("react-hook-form");
|
|
14
14
|
const PageBroken_1 = require("../components/PageBroken");
|
|
@@ -18,10 +18,12 @@ const FormTab_1 = require("../form/layout/FormTab");
|
|
|
18
18
|
const CommandContainer_1 = require("./CommandContainer");
|
|
19
19
|
const FormTabRelated_1 = require("./FormTabRelated");
|
|
20
20
|
const PageEntityFormStringContext_1 = require("./PageEntityFormStringContext");
|
|
21
|
+
const ProcessFlow_1 = require("./ProcessFlow");
|
|
22
|
+
const RecordAvatar_1 = require("./RecordAvatar");
|
|
21
23
|
const RelatedViewSelector_1 = require("./RelatedViewSelector");
|
|
22
24
|
const SectionContainer_1 = require("./SectionContainer");
|
|
25
|
+
let previousCachedActiveTabInfo = null;
|
|
23
26
|
const PageEntityFormDesktopContainer = () => {
|
|
24
|
-
var _a, _b;
|
|
25
27
|
const dataState = (0, mutable_1.useContextSelector)(dataform_1.DataFormContext, (state) => state.dataState);
|
|
26
28
|
const strings = (0, PageEntityFormStringContext_1.usePageEntityFormStrings)();
|
|
27
29
|
const recordId = (0, hooks_1.useRecordId)();
|
|
@@ -30,13 +32,29 @@ const PageEntityFormDesktopContainer = () => {
|
|
|
30
32
|
const { language } = (0, locale_1.useLocale)();
|
|
31
33
|
const schema = (0, hooks_1.useDataFormSchema)();
|
|
32
34
|
const formConfig = (0, hooks_1.useSelectedForm)();
|
|
35
|
+
const processFlowSteps = (0, hooks_1.useProcessFlowSteps)();
|
|
33
36
|
const setActiveTab = (0, mutable_1.useContextValueSetter)(dataform_1.DataFormContext, (setValue) => (value) => {
|
|
34
|
-
setValue((state) => (
|
|
37
|
+
setValue((state) => ({
|
|
38
|
+
...state,
|
|
39
|
+
activeTab: value,
|
|
40
|
+
}));
|
|
35
41
|
});
|
|
36
42
|
(0, react_1.useEffect)(() => {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
43
|
+
if (previousCachedActiveTabInfo &&
|
|
44
|
+
previousCachedActiveTabInfo.logicalName === schema.logicalName) {
|
|
45
|
+
setActiveTab(previousCachedActiveTabInfo.name);
|
|
46
|
+
setSelectedRelatedItem(previousCachedActiveTabInfo.relatedItem);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
setActiveTab(formConfig.experience.tabs[0].name);
|
|
50
|
+
previousCachedActiveTabInfo = {
|
|
51
|
+
logicalName: schema.logicalName,
|
|
52
|
+
name: formConfig.experience.tabs[0].name,
|
|
53
|
+
relatedItem: null,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
}, [setActiveTab, formConfig, schema]);
|
|
57
|
+
const [recordTitle] = (0, hooks_1.useRecordTitle)();
|
|
40
58
|
// const readonly = useIsFormReadonly();
|
|
41
59
|
const formInstance = (0, hooks_1.useFormInstance)();
|
|
42
60
|
const isDirty = (0, hooks_1.useFormIsDirty)();
|
|
@@ -84,7 +102,7 @@ const PageEntityFormDesktopContainer = () => {
|
|
|
84
102
|
paddingInline: react_components_1.tokens.spacingHorizontalM,
|
|
85
103
|
paddingTop: react_components_1.tokens.spacingVerticalS,
|
|
86
104
|
marginBottom: react_components_1.tokens.spacingVerticalS,
|
|
87
|
-
}, children: [(0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'column', flex: 1 }, children: [(0, jsx_runtime_1.jsxs)("div", { style: {
|
|
105
|
+
}, children: [(0, jsx_runtime_1.jsx)(RecordAvatar_1.RecordAvatar, {}), (0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'column', flex: 1 }, children: [(0, jsx_runtime_1.jsxs)("div", { style: {
|
|
88
106
|
display: 'flex',
|
|
89
107
|
gap: react_components_1.tokens.spacingHorizontalXS,
|
|
90
108
|
alignItems: 'center',
|
|
@@ -92,28 +110,30 @@ const PageEntityFormDesktopContainer = () => {
|
|
|
92
110
|
? `- ${strings.unsaved}`
|
|
93
111
|
: !!record
|
|
94
112
|
? `- ${strings.saved}`
|
|
95
|
-
: '' })] }), (0, jsx_runtime_1.jsx)(react_components_1.Body1, { style: { color: react_components_1.tokens.colorNeutralForeground3 }, children: (0,
|
|
113
|
+
: '' })] }), (0, jsx_runtime_1.jsx)(react_components_1.Body1, { style: { color: react_components_1.tokens.colorNeutralForeground3 }, children: (0, utils_1.localizedLabel)(language, schema) })] }), (0, jsx_runtime_1.jsx)("div", { style: { display: 'flex', flexDirection: 'row' }, children: formConfig.experience.headerControls?.map((controlName, index) => {
|
|
96
114
|
const attribute = schema.attributes[controlName];
|
|
97
115
|
return ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [index > 0 && ((0, jsx_runtime_1.jsx)(react_components_1.Divider, { vertical: true, style: {
|
|
98
116
|
width: react_components_1.tokens.spacingHorizontalXXL,
|
|
99
117
|
opacity: 0.5,
|
|
100
118
|
} })), (0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'column' }, children: [(0, jsx_runtime_1.jsx)(react_components_1.Body1, { style: { color: react_components_1.tokens.colorNeutralForeground4 }, children: attribute.label }), (0, jsx_runtime_1.jsx)(react_hook_form_1.Controller, { control: formInstance.control, name: controlName, render: ({ field }) => {
|
|
101
|
-
return ((0, jsx_runtime_1.jsx)(react_components_1.Body1, { children: (0,
|
|
119
|
+
return ((0, jsx_runtime_1.jsx)(react_components_1.Body1, { children: (0, utils_2.getAttributeFormattedValue)(attribute, field.value) }));
|
|
102
120
|
} })] })] }, controlName));
|
|
103
|
-
}) })] }), (0, jsx_runtime_1.
|
|
121
|
+
}) })] }), !!processFlowSteps?.length && ((0, jsx_runtime_1.jsx)(ProcessFlow_1.ProcessFlow, { height: 28, rounded: false, items: processFlowSteps })), (0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', paddingBottom: react_components_1.tokens.spacingVerticalS }, children: [(0, jsx_runtime_1.jsxs)(react_components_1.TabList, { selectedValue: activeTab, onTabSelect: (e, value) => {
|
|
122
|
+
setActiveTab(value.value);
|
|
123
|
+
previousCachedActiveTabInfo = {
|
|
124
|
+
logicalName: schema.logicalName,
|
|
125
|
+
name: value.value,
|
|
126
|
+
relatedItem: null,
|
|
127
|
+
};
|
|
128
|
+
}, children: [formConfig.experience.tabs.map((tab) => ((0, jsx_runtime_1.jsx)(react_components_1.Tab, { value: tab.name, children: (0, utils_1.localizedLabel)(language, tab) }, tab.name))), !!selectedRelatedItem && ((0, jsx_runtime_1.jsx)(react_components_1.Tab, { value: "related", children: selectedRelatedItem.localizedPluralLabels?.[language] ??
|
|
129
|
+
selectedRelatedItem.pluralLabel }))] }), (0, jsx_runtime_1.jsx)(RelatedViewSelector_1.RelatedViewSelector, { onSelect: (item) => {
|
|
104
130
|
setSelectedRelatedItem(item);
|
|
105
131
|
setActiveTab('related');
|
|
132
|
+
previousCachedActiveTabInfo = {
|
|
133
|
+
logicalName: schema.logicalName,
|
|
134
|
+
name: 'related',
|
|
135
|
+
relatedItem: item,
|
|
136
|
+
};
|
|
106
137
|
} })] })] })] }), (0, jsx_runtime_1.jsxs)(FormBody_1.FormBody, { children: [formConfig.experience.tabs.map((tab) => ((0, jsx_runtime_1.jsx)(FormTab_1.FormTab, { value: tab.name, columnCount: tab.columnCount, columnWidths: tab.columnWidths, children: tab.tabColumns.map((tabColumn, index) => ((0, jsx_runtime_1.jsx)(FormTab_1.FormTab.Column, { children: tabColumn.sections.map((section) => ((0, jsx_runtime_1.jsx)(SectionContainer_1.SectionContainer, { section: section, readOnly: false }, section.name))) }, index))) }, tab.name))), (0, jsx_runtime_1.jsx)(FormTabRelated_1.FormTabRelated, { selectedRelatedItem: selectedRelatedItem })] })] }));
|
|
107
|
-
// return (
|
|
108
|
-
// <Fragment>
|
|
109
|
-
// <PageEntityViewDesktopFrame
|
|
110
|
-
// commandBar={<CommandContainer />}
|
|
111
|
-
// header={<GridHeaderContainer />}
|
|
112
|
-
// content={<GridTableContainer />}
|
|
113
|
-
// footer={<GridPaginationContainer />}
|
|
114
|
-
// />
|
|
115
|
-
// {/* <CustomizeColumnsContainer /> */}
|
|
116
|
-
// </Fragment>
|
|
117
|
-
// );
|
|
118
138
|
};
|
|
119
139
|
exports.PageEntityFormDesktopContainer = PageEntityFormDesktopContainer;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
interface ProcessFlowProps {
|
|
2
|
+
height?: number;
|
|
3
|
+
rounded?: boolean;
|
|
4
|
+
items: Array<{
|
|
5
|
+
label: string;
|
|
6
|
+
isActivated?: boolean;
|
|
7
|
+
}>;
|
|
8
|
+
}
|
|
9
|
+
export declare function ProcessFlow({ height, rounded, items, }: ProcessFlowProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ProcessFlow = ProcessFlow;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_components_1 = require("@fluentui/react-components");
|
|
6
|
+
function ProcessFlow({ height = 32, rounded = true, items, }) {
|
|
7
|
+
return ((0, jsx_runtime_1.jsx)("div", { style: { position: 'relative', height }, children: (0, jsx_runtime_1.jsx)("div", { style: {
|
|
8
|
+
display: 'flex',
|
|
9
|
+
overflow: 'hidden',
|
|
10
|
+
borderRadius: rounded ? react_components_1.tokens.borderRadiusMedium : 0,
|
|
11
|
+
}, children: items.map((item, index) => ((0, jsx_runtime_1.jsx)(ProcessFlowItem, { height: height, label: item.label, isActivated: item.isActivated, isFirst: index === 0, isLast: index === items.length - 1 }, index))) }) }));
|
|
12
|
+
}
|
|
13
|
+
const ProcessFlowItem = ({ label, height, isActivated, isFirst, isLast, }) => {
|
|
14
|
+
const backgroundColor = isActivated
|
|
15
|
+
? react_components_1.tokens.colorBrandBackground
|
|
16
|
+
: react_components_1.tokens.colorNeutralStrokeDisabled;
|
|
17
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: {
|
|
18
|
+
flex: 1,
|
|
19
|
+
position: 'relative',
|
|
20
|
+
display: 'flex',
|
|
21
|
+
alignItems: 'center',
|
|
22
|
+
justifyContent: 'center',
|
|
23
|
+
height,
|
|
24
|
+
}, children: [(0, jsx_runtime_1.jsxs)("div", { style: { zIndex: 1 }, children: [(0, jsx_runtime_1.jsx)("div", { style: {
|
|
25
|
+
position: 'absolute',
|
|
26
|
+
left: 20,
|
|
27
|
+
right: 20,
|
|
28
|
+
top: 0,
|
|
29
|
+
height: '100%',
|
|
30
|
+
backgroundColor: backgroundColor,
|
|
31
|
+
} }), (0, jsx_runtime_1.jsx)("div", { style: {
|
|
32
|
+
position: 'absolute',
|
|
33
|
+
left: 0,
|
|
34
|
+
top: 0,
|
|
35
|
+
width: 40,
|
|
36
|
+
height: '50%',
|
|
37
|
+
backgroundColor: backgroundColor,
|
|
38
|
+
transform: isFirst ? 'skewX(0deg)' : 'skewX(30deg)',
|
|
39
|
+
borderLeft: isFirst
|
|
40
|
+
? 'none'
|
|
41
|
+
: `1px solid ${react_components_1.tokens.colorNeutralBackground1}`,
|
|
42
|
+
} }), (0, jsx_runtime_1.jsx)("div", { style: {
|
|
43
|
+
position: 'absolute',
|
|
44
|
+
right: 0,
|
|
45
|
+
top: 0,
|
|
46
|
+
width: 40,
|
|
47
|
+
height: '50%',
|
|
48
|
+
backgroundColor: backgroundColor,
|
|
49
|
+
transform: isLast ? 'skewX(0deg)' : 'skewX(30deg)',
|
|
50
|
+
borderRight: isLast
|
|
51
|
+
? 'none'
|
|
52
|
+
: `1px solid ${react_components_1.tokens.colorNeutralBackground1}`,
|
|
53
|
+
} }), (0, jsx_runtime_1.jsx)("div", { style: {
|
|
54
|
+
position: 'absolute',
|
|
55
|
+
left: 0,
|
|
56
|
+
top: '50%',
|
|
57
|
+
width: 40,
|
|
58
|
+
height: '50%',
|
|
59
|
+
backgroundColor: backgroundColor,
|
|
60
|
+
transform: isFirst ? 'skewX(0deg)' : 'skewX(-30deg)',
|
|
61
|
+
borderLeft: isFirst
|
|
62
|
+
? 'none'
|
|
63
|
+
: `1px solid ${react_components_1.tokens.colorNeutralBackground1}`,
|
|
64
|
+
} }), (0, jsx_runtime_1.jsx)("div", { style: {
|
|
65
|
+
position: 'absolute',
|
|
66
|
+
right: 0,
|
|
67
|
+
top: '50%',
|
|
68
|
+
width: 40,
|
|
69
|
+
height: '50%',
|
|
70
|
+
backgroundColor: backgroundColor,
|
|
71
|
+
transform: isLast ? 'skewX(0deg)' : 'skewX(-30deg)',
|
|
72
|
+
borderRight: isLast
|
|
73
|
+
? 'none'
|
|
74
|
+
: `1px solid ${react_components_1.tokens.colorNeutralBackground1}`,
|
|
75
|
+
} })] }), (0, jsx_runtime_1.jsx)("div", { style: {
|
|
76
|
+
display: 'flex',
|
|
77
|
+
flexDirection: 'column',
|
|
78
|
+
flex: 1,
|
|
79
|
+
alignItems: 'center',
|
|
80
|
+
gap: react_components_1.tokens.spacingVerticalS,
|
|
81
|
+
color: isActivated ? 'white' : undefined,
|
|
82
|
+
zIndex: 2,
|
|
83
|
+
}, children: (0, jsx_runtime_1.jsx)(react_components_1.Caption1, { children: label }) })] }));
|
|
84
|
+
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RecordAvatar = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_components_1 = require("@fluentui/react-components");
|
|
6
|
+
const app_1 = require("@headless-adminapp/app/app");
|
|
7
|
+
const dataform_1 = require("@headless-adminapp/app/dataform");
|
|
8
|
+
const hooks_1 = require("@headless-adminapp/app/dataform/hooks");
|
|
9
|
+
const dialog_1 = require("@headless-adminapp/app/dialog");
|
|
10
|
+
const mutable_1 = require("@headless-adminapp/app/mutable");
|
|
11
|
+
const progress_indicator_1 = require("@headless-adminapp/app/progress-indicator");
|
|
12
|
+
const transport_1 = require("@headless-adminapp/app/transport");
|
|
13
|
+
const icons_1 = require("@headless-adminapp/icons");
|
|
14
|
+
const react_1 = require("react");
|
|
15
|
+
const avatar_1 = require("../utils/avatar");
|
|
16
|
+
const UploadImageDialog_1 = require("./UploadImageDialog");
|
|
17
|
+
const RecordAvatar = () => {
|
|
18
|
+
const [recordTitle, isPlaceholder] = (0, hooks_1.useRecordTitle)();
|
|
19
|
+
const schema = (0, hooks_1.useDataFormSchema)();
|
|
20
|
+
const record = (0, mutable_1.useContextSelector)(dataform_1.DataFormContext, (state) => state.record);
|
|
21
|
+
const recordId = (0, hooks_1.useRecordId)();
|
|
22
|
+
const { schemaMetadataDic } = (0, app_1.useAppContext)();
|
|
23
|
+
const dataService = (0, transport_1.useDataService)();
|
|
24
|
+
const refresh = (0, mutable_1.useContextSelector)(dataform_1.DataFormContext, (state) => state.refresh);
|
|
25
|
+
const [showAvatarChangeDialog, setShowAvatarChangeDialog] = (0, react_1.useState)(false);
|
|
26
|
+
const fileService = (0, transport_1.useFileService)();
|
|
27
|
+
const { showProgressIndicator, hideProgressIndicator } = (0, progress_indicator_1.useProgressIndicator)();
|
|
28
|
+
const openErrorDialog = (0, dialog_1.useOpenErrorDialog)();
|
|
29
|
+
if (!schema.avatarAttribute) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
const avatarAttribute = schema.attributes[schema.avatarAttribute];
|
|
33
|
+
if (avatarAttribute?.type !== 'attachment') {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
const value = record?.[schema.avatarAttribute];
|
|
37
|
+
const handleChange = async (value) => {
|
|
38
|
+
if (!recordId) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
console.log('onChange', value);
|
|
42
|
+
try {
|
|
43
|
+
showProgressIndicator();
|
|
44
|
+
await dataService.updateRecord(schema.logicalName, recordId, {
|
|
45
|
+
[schema.avatarAttribute]: value,
|
|
46
|
+
});
|
|
47
|
+
await refresh();
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
openErrorDialog({
|
|
51
|
+
title: 'Error',
|
|
52
|
+
text: 'Unable to update record',
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
finally {
|
|
56
|
+
hideProgressIndicator();
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
if (isPlaceholder && !value) {
|
|
60
|
+
const experienceSchema = schemaMetadataDic[schema.logicalName];
|
|
61
|
+
const Icon = experienceSchema.icon ?? icons_1.Icons.Entity ?? icons_1.IconPlaceholder;
|
|
62
|
+
return ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
63
|
+
display: 'flex',
|
|
64
|
+
alignItems: 'flex-start',
|
|
65
|
+
marginRight: react_components_1.tokens.spacingHorizontalM,
|
|
66
|
+
marginTop: 2,
|
|
67
|
+
}, children: (0, jsx_runtime_1.jsx)(react_components_1.Avatar, { style: { width: 36, height: 36 }, icon: (0, jsx_runtime_1.jsx)(Icon, { size: 20 }) }) }));
|
|
68
|
+
}
|
|
69
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: {
|
|
70
|
+
display: 'flex',
|
|
71
|
+
alignItems: 'flex-start',
|
|
72
|
+
marginRight: react_components_1.tokens.spacingHorizontalM,
|
|
73
|
+
marginTop: 2,
|
|
74
|
+
}, children: [(0, jsx_runtime_1.jsx)(react_components_1.Avatar, { style: { width: 36, height: 36 }, name: recordTitle, color: (0, avatar_1.getAvatarColor)(recordTitle), image: {
|
|
75
|
+
src: value?.url,
|
|
76
|
+
}, onClick: () => {
|
|
77
|
+
if (!fileService) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
setShowAvatarChangeDialog(true);
|
|
81
|
+
} }), !!recordId && !!fileService && ((0, jsx_runtime_1.jsx)(UploadImageDialog_1.UploadImageDialog, { recordTitle: recordTitle, currentImage: value, onChange: handleChange, recordId: recordId, open: showAvatarChangeDialog, onOpenChange: (open) => setShowAvatarChangeDialog(open) }))] }));
|
|
82
|
+
};
|
|
83
|
+
exports.RecordAvatar = RecordAvatar;
|
|
@@ -6,5 +6,5 @@ interface RecordCardProps<S extends SchemaAttributes = SchemaAttributes> {
|
|
|
6
6
|
record: InferredSchemaType<S>;
|
|
7
7
|
selected?: boolean;
|
|
8
8
|
}
|
|
9
|
-
export declare function RecordCard<S extends SchemaAttributes = SchemaAttributes>({ schema, cardView, record, selected, }: RecordCardProps<S
|
|
9
|
+
export declare function RecordCard<S extends SchemaAttributes = SchemaAttributes>({ schema, cardView, record, selected, }: Readonly<RecordCardProps<S>>): import("react/jsx-runtime").JSX.Element;
|
|
10
10
|
export {};
|
|
@@ -4,6 +4,7 @@ exports.RecordCard = RecordCard;
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_components_1 = require("@fluentui/react-components");
|
|
6
6
|
const utils_1 = require("@headless-adminapp/app/utils");
|
|
7
|
+
const color_1 = require("@headless-adminapp/app/utils/color");
|
|
7
8
|
const useStyles = (0, react_components_1.makeStyles)({
|
|
8
9
|
root: {
|
|
9
10
|
width: '100%',
|
|
@@ -26,10 +27,14 @@ const useStyles = (0, react_components_1.makeStyles)({
|
|
|
26
27
|
selected: {},
|
|
27
28
|
});
|
|
28
29
|
function createIntial(name) {
|
|
29
|
-
return name
|
|
30
|
+
return name
|
|
31
|
+
?.split(' ')
|
|
32
|
+
.map((x) => x[0])
|
|
33
|
+
.slice(0, 2)
|
|
34
|
+
.join('')
|
|
35
|
+
.toUpperCase();
|
|
30
36
|
}
|
|
31
37
|
function RecordCard({ schema, cardView, record, selected, }) {
|
|
32
|
-
var _a, _b;
|
|
33
38
|
const styles = useStyles();
|
|
34
39
|
const _record = record;
|
|
35
40
|
const recordTitle = _record[schema.primaryAttribute];
|
|
@@ -39,7 +44,7 @@ function RecordCard({ schema, cardView, record, selected, }) {
|
|
|
39
44
|
const avatarAttribute = schema.attributes[cardView.avatarColumn];
|
|
40
45
|
if (avatarAttribute.type === 'attachment' &&
|
|
41
46
|
avatarAttribute.format === 'image') {
|
|
42
|
-
avatarSrc = _record[cardView.avatarColumn];
|
|
47
|
+
avatarSrc = _record[cardView.avatarColumn]?.url;
|
|
43
48
|
}
|
|
44
49
|
else if (avatarAttribute.type === 'string' &&
|
|
45
50
|
avatarAttribute.format === 'url') {
|
|
@@ -52,55 +57,7 @@ function RecordCard({ schema, cardView, record, selected, }) {
|
|
|
52
57
|
display: 'flex',
|
|
53
58
|
flexDirection: 'column',
|
|
54
59
|
flex: 1,
|
|
55
|
-
}, children: [(0, jsx_runtime_1.jsx)(react_components_1.Body1, { children: _record[cardView.primaryColumn] }), (
|
|
56
|
-
const value = _record[column.name];
|
|
57
|
-
if (!value) {
|
|
58
|
-
return null;
|
|
59
|
-
}
|
|
60
|
-
const attribute = schema.attributes[column.name];
|
|
61
|
-
let label = '';
|
|
62
|
-
if (column.label === true) {
|
|
63
|
-
label = attribute.label;
|
|
64
|
-
}
|
|
65
|
-
else if (typeof column.label === 'string') {
|
|
66
|
-
label = column.label;
|
|
67
|
-
}
|
|
68
|
-
if (column.variant === 'choice') {
|
|
69
|
-
if (attribute.type === 'choice') {
|
|
70
|
-
const choice = attribute.options.find((option) => option.value === value);
|
|
71
|
-
if (!choice) {
|
|
72
|
-
return null;
|
|
73
|
-
}
|
|
74
|
-
return ((0, jsx_runtime_1.jsx)(react_components_1.Tag, { size: "extra-small", appearance: "filled", style: {
|
|
75
|
-
background: choice.color,
|
|
76
|
-
color: 'white',
|
|
77
|
-
height: 16,
|
|
78
|
-
display: 'flex',
|
|
79
|
-
alignItems: 'center',
|
|
80
|
-
justifyContent: 'center',
|
|
81
|
-
}, children: choice.label }, column.name));
|
|
82
|
-
}
|
|
83
|
-
if (attribute.type === 'choices') {
|
|
84
|
-
const choices = attribute.options.filter((option) => value.includes(option.value));
|
|
85
|
-
if (!choices.length) {
|
|
86
|
-
return null;
|
|
87
|
-
}
|
|
88
|
-
return ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
89
|
-
display: 'flex',
|
|
90
|
-
flexDirection: 'row',
|
|
91
|
-
gap: 4,
|
|
92
|
-
}, children: choices.map((choice) => ((0, jsx_runtime_1.jsx)(react_components_1.Tag, { size: "extra-small", appearance: "filled", style: {
|
|
93
|
-
background: choice.color,
|
|
94
|
-
color: 'white',
|
|
95
|
-
height: 16,
|
|
96
|
-
display: 'flex',
|
|
97
|
-
alignItems: 'center',
|
|
98
|
-
justifyContent: 'center',
|
|
99
|
-
}, children: choice.label }, choice.value))) }, column.name));
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
return ((0, jsx_runtime_1.jsxs)(react_components_1.Caption1, { style: { color: react_components_1.tokens.colorNeutralForeground4 }, children: [!!label && `${label}: `, (0, utils_1.getAttributeFormattedValue)(attribute, value)] }, column.name));
|
|
103
|
-
})] }), !!((_b = cardView.rightColumn) === null || _b === void 0 ? void 0 : _b.length) && ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
60
|
+
}, children: [(0, jsx_runtime_1.jsx)(react_components_1.Body1, { style: { wordBreak: 'break-all' }, children: _record[cardView.primaryColumn] }), cardView.secondaryColumns?.map((column) => ((0, jsx_runtime_1.jsx)(SecondaryColumnContent, { record: _record, column: column, schema: schema }, column.name)))] }), !!cardView.rightColumn?.length && ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
104
61
|
display: 'flex',
|
|
105
62
|
flexDirection: 'column',
|
|
106
63
|
alignItems: 'flex-end',
|
|
@@ -129,6 +86,56 @@ function RecordCard({ schema, cardView, record, selected, }) {
|
|
|
129
86
|
if (column.variant === 'strong') {
|
|
130
87
|
return ((0, jsx_runtime_1.jsx)(react_components_1.Body1Strong, { children: (0, utils_1.getAttributeFormattedValue)(value, attribute) }, column.name));
|
|
131
88
|
}
|
|
132
|
-
(0, jsx_runtime_1.jsx)(react_components_1.Caption1, { style: { color: react_components_1.tokens.colorNeutralForeground4 }, children: (0, utils_1.getAttributeFormattedValue)(value, attribute) }, column.name);
|
|
89
|
+
return ((0, jsx_runtime_1.jsx)(react_components_1.Caption1, { style: { color: react_components_1.tokens.colorNeutralForeground4 }, children: (0, utils_1.getAttributeFormattedValue)(value, attribute) }, column.name));
|
|
133
90
|
}) }))] }));
|
|
134
91
|
}
|
|
92
|
+
function SecondaryColumnContent({ record: _record, column, schema, }) {
|
|
93
|
+
const value = _record[column.name];
|
|
94
|
+
if (!value) {
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
const attribute = schema.attributes[column.name];
|
|
98
|
+
let label = '';
|
|
99
|
+
if (column.label === true) {
|
|
100
|
+
label = attribute.label;
|
|
101
|
+
}
|
|
102
|
+
else if (typeof column.label === 'string') {
|
|
103
|
+
label = column.label;
|
|
104
|
+
}
|
|
105
|
+
if (column.variant === 'choice') {
|
|
106
|
+
if (attribute.type === 'choice') {
|
|
107
|
+
return (0, jsx_runtime_1.jsx)(ChoiceTag, { attribute: attribute, value: value });
|
|
108
|
+
}
|
|
109
|
+
if (attribute.type === 'choices') {
|
|
110
|
+
const choices = attribute.options.filter((option) => value.includes(option.value));
|
|
111
|
+
if (!choices.length) {
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
return ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
115
|
+
display: 'flex',
|
|
116
|
+
flexDirection: 'row',
|
|
117
|
+
gap: 4,
|
|
118
|
+
}, children: choices.map((choice) => ((0, jsx_runtime_1.jsx)(ChoiceTag, { attribute: attribute, value: choice.value }, choice.value))) }, column.name));
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return ((0, jsx_runtime_1.jsxs)(react_components_1.Caption1, { style: { color: react_components_1.tokens.colorNeutralForeground4 }, children: [!!label && `${label}: `, (0, utils_1.getAttributeFormattedValue)(attribute, value)] }, column.name));
|
|
122
|
+
}
|
|
123
|
+
const ChoiceTag = ({ attribute, value, }) => {
|
|
124
|
+
const choice = attribute.options.find((option) => option.value === value);
|
|
125
|
+
if (!choice) {
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
const bgColor = choice.color;
|
|
129
|
+
let color;
|
|
130
|
+
if (bgColor) {
|
|
131
|
+
color = (0, color_1.isColorDark)(bgColor) ? '#FFFFFF' : '#000000';
|
|
132
|
+
}
|
|
133
|
+
return ((0, jsx_runtime_1.jsx)(react_components_1.Tag, { size: "extra-small", appearance: "filled", style: {
|
|
134
|
+
background: bgColor,
|
|
135
|
+
color: color,
|
|
136
|
+
height: 16,
|
|
137
|
+
display: 'flex',
|
|
138
|
+
alignItems: 'center',
|
|
139
|
+
justifyContent: 'center',
|
|
140
|
+
}, children: choice.label }));
|
|
141
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CardView } from '@headless-adminapp/core/experience/view';
|
|
2
|
+
import { Schema, SchemaAttributes } from '@headless-adminapp/core/schema';
|
|
3
|
+
interface RecordCardLoadingProps<S extends SchemaAttributes = SchemaAttributes> {
|
|
4
|
+
schema: Schema<S>;
|
|
5
|
+
cardView: CardView<S>;
|
|
6
|
+
}
|
|
7
|
+
export declare function RecordCardLoading<S extends SchemaAttributes = SchemaAttributes>({ cardView }: RecordCardLoadingProps<S>): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RecordCardLoading = RecordCardLoading;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_components_1 = require("@fluentui/react-components");
|
|
6
|
+
const useStyles = (0, react_components_1.makeStyles)({
|
|
7
|
+
root: {
|
|
8
|
+
width: '100%',
|
|
9
|
+
display: 'flex',
|
|
10
|
+
flexDirection: 'row',
|
|
11
|
+
paddingInline: react_components_1.tokens.spacingHorizontalL,
|
|
12
|
+
paddingBlock: react_components_1.tokens.spacingVerticalS,
|
|
13
|
+
gap: react_components_1.tokens.spacingHorizontalS,
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
function RecordCardLoading({ cardView }) {
|
|
17
|
+
const styles = useStyles();
|
|
18
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: (0, react_components_1.mergeClasses)(styles.root), children: [cardView.showAvatar && ((0, jsx_runtime_1.jsx)(react_components_1.Avatar, { color: "neutral", style: { cursor: 'pointer' } })), (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
19
|
+
display: 'flex',
|
|
20
|
+
flexDirection: 'column',
|
|
21
|
+
flex: 1,
|
|
22
|
+
gap: react_components_1.tokens.spacingVerticalXXS,
|
|
23
|
+
}, children: [(0, jsx_runtime_1.jsx)("div", { style: { paddingBlock: 2 }, children: (0, jsx_runtime_1.jsx)(react_components_1.SkeletonItem, { size: 16, style: { height: 16 } }) }), cardView.secondaryColumns?.map((_, index) => ((0, jsx_runtime_1.jsx)("div", { style: { paddingBlock: 2 }, children: (0, jsx_runtime_1.jsx)(react_components_1.SkeletonItem, { size: 16, style: { width: 160, height: 12 } }) }, index)))] })] }));
|
|
24
|
+
}
|