@headless-adminapp/fluent 0.0.17-alpha.1
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 +6 -0
- package/App/App.js +12 -0
- package/App/AppHeaderContianer.d.ts +2 -0
- package/App/AppHeaderContianer.js +67 -0
- package/App/AppLogo.d.ts +8 -0
- package/App/AppLogo.js +17 -0
- package/App/AppProvider.d.ts +9 -0
- package/App/AppProvider.js +50 -0
- package/App/AppStringContext.d.ts +16 -0
- package/App/AppStringContext.js +23 -0
- package/App/AppUI.d.ts +2 -0
- package/App/AppUI.js +16 -0
- package/App/NavigationContainer.d.ts +1 -0
- package/App/NavigationContainer.js +63 -0
- package/App/QuickActionItem.d.ts +10 -0
- package/App/QuickActionItem.js +32 -0
- package/App/index.d.ts +1 -0
- package/App/index.js +5 -0
- package/App/utils.d.ts +14 -0
- package/App/utils.js +27 -0
- package/CommandBar/Button.d.ts +11 -0
- package/CommandBar/Button.js +36 -0
- package/CommandBar/Divider.d.ts +2 -0
- package/CommandBar/Divider.js +10 -0
- package/CommandBar/IconButton.d.ts +9 -0
- package/CommandBar/IconButton.js +32 -0
- package/CommandBar/Label.d.ts +7 -0
- package/CommandBar/Label.js +23 -0
- package/CommandBar/MenuButton.d.ts +13 -0
- package/CommandBar/MenuButton.js +43 -0
- package/CommandBar/MenuItem.d.ts +11 -0
- package/CommandBar/MenuItem.js +37 -0
- package/CommandBar/MenuItems.d.ts +6 -0
- package/CommandBar/MenuItems.js +11 -0
- package/CommandBar/MenuList.d.ts +6 -0
- package/CommandBar/MenuList.js +13 -0
- package/CommandBar/Wrapper.d.ts +8 -0
- package/CommandBar/Wrapper.js +24 -0
- package/CommandBar/index.d.ts +9 -0
- package/CommandBar/index.js +17 -0
- package/CommandBar/types.d.ts +0 -0
- package/CommandBar/types.js +1 -0
- package/DataForm/SectionControl.d.ts +10 -0
- package/DataForm/SectionControl.js +8 -0
- package/DataGrid/ActionCell.d.ts +8 -0
- package/DataGrid/ActionCell.js +11 -0
- package/DataGrid/CommandContainer.d.ts +2 -0
- package/DataGrid/CommandContainer.js +11 -0
- package/DataGrid/CustomizeColumns/AddColumns.d.ts +10 -0
- package/DataGrid/CustomizeColumns/AddColumns.js +94 -0
- package/DataGrid/CustomizeColumns/ColumnItem.d.ts +16 -0
- package/DataGrid/CustomizeColumns/ColumnItem.js +86 -0
- package/DataGrid/CustomizeColumns/CustomizeColumns.d.ts +6 -0
- package/DataGrid/CustomizeColumns/CustomizeColumns.js +80 -0
- package/DataGrid/CustomizeColumns/index.d.ts +1 -0
- package/DataGrid/CustomizeColumns/index.js +5 -0
- package/DataGrid/FormSubgridCommandContainer.d.ts +2 -0
- package/DataGrid/FormSubgridCommandContainer.js +24 -0
- package/DataGrid/FormSubgridViewSelector.d.ts +2 -0
- package/DataGrid/FormSubgridViewSelector.js +41 -0
- package/DataGrid/GridColumnHeader/ConditionValueControl.d.ts +9 -0
- package/DataGrid/GridColumnHeader/ConditionValueControl.js +89 -0
- package/DataGrid/GridColumnHeader/FilterForm.d.ts +11 -0
- package/DataGrid/GridColumnHeader/FilterForm.js +55 -0
- package/DataGrid/GridColumnHeader/OperatorSelect.d.ts +9 -0
- package/DataGrid/GridColumnHeader/OperatorSelect.js +21 -0
- package/DataGrid/GridColumnHeader/TableHeaderFilterCell.d.ts +22 -0
- package/DataGrid/GridColumnHeader/TableHeaderFilterCell.js +152 -0
- package/DataGrid/GridColumnHeader/index.d.ts +1 -0
- package/DataGrid/GridColumnHeader/index.js +5 -0
- package/DataGrid/GridColumnHeader/utils.d.ts +5 -0
- package/DataGrid/GridColumnHeader/utils.js +18 -0
- package/DataGrid/GridHeaderContainer.d.ts +2 -0
- package/DataGrid/GridHeaderContainer.js +9 -0
- package/DataGrid/GridHeaderDesktop.d.ts +6 -0
- package/DataGrid/GridHeaderDesktop.js +40 -0
- package/DataGrid/GridPaginationContainer.d.ts +2 -0
- package/DataGrid/GridPaginationContainer.js +20 -0
- package/DataGrid/GridTableContainer.d.ts +12 -0
- package/DataGrid/GridTableContainer.js +248 -0
- package/DataGrid/ScrollbarWithMoreDataRequest.d.ts +9 -0
- package/DataGrid/ScrollbarWithMoreDataRequest.js +33 -0
- package/DataGrid/TableCell/TableCellAction.d.ts +8 -0
- package/DataGrid/TableCell/TableCellAction.js +41 -0
- package/DataGrid/TableCell/TableCellBase.d.ts +7 -0
- package/DataGrid/TableCell/TableCellBase.js +9 -0
- package/DataGrid/TableCell/TableCellCheckbox.d.ts +6 -0
- package/DataGrid/TableCell/TableCellCheckbox.js +14 -0
- package/DataGrid/TableCell/TableCellLink.d.ts +8 -0
- package/DataGrid/TableCell/TableCellLink.js +33 -0
- package/DataGrid/TableCell/TableCellText.d.ts +7 -0
- package/DataGrid/TableCell/TableCellText.js +24 -0
- package/DataGrid/TableCell/index.d.ts +4 -0
- package/DataGrid/TableCell/index.js +20 -0
- package/DataGrid/getAttributeFormattedValue.d.ts +16 -0
- package/DataGrid/getAttributeFormattedValue.js +92 -0
- package/DataGrid/index.d.ts +4 -0
- package/DataGrid/index.js +11 -0
- package/DataGrid/useTableColumns.d.ts +10 -0
- package/DataGrid/useTableColumns.js +251 -0
- package/DataGrid/utils.d.ts +2 -0
- package/DataGrid/utils.js +15 -0
- package/DialogContainer/AlertDialog.d.ts +10 -0
- package/DialogContainer/AlertDialog.js +15 -0
- package/DialogContainer/ConfirmDialog.d.ts +12 -0
- package/DialogContainer/ConfirmDialog.js +18 -0
- package/DialogContainer/DialogContainer.d.ts +1 -0
- package/DialogContainer/DialogContainer.js +43 -0
- package/DialogContainer/ErrorDialog.d.ts +10 -0
- package/DialogContainer/ErrorDialog.js +22 -0
- package/DialogContainer/PromptDialog.d.ts +27 -0
- package/DialogContainer/PromptDialog.js +99 -0
- package/DialogContainer/index.d.ts +1 -0
- package/DialogContainer/index.js +5 -0
- package/LICENSE +21 -0
- package/OverflowCommandBar/OverflowCommandBar.d.ts +10 -0
- package/OverflowCommandBar/OverflowCommandBar.js +32 -0
- package/OverflowCommandBar/OverflowMenu.d.ts +4 -0
- package/OverflowCommandBar/OverflowMenu.js +45 -0
- package/OverflowCommandBar/OverflowMenuDivider.d.ts +4 -0
- package/OverflowCommandBar/OverflowMenuDivider.js +14 -0
- package/OverflowCommandBar/index.d.ts +3 -0
- package/OverflowCommandBar/index.js +9 -0
- package/OverflowCommandBar/render.d.ts +2 -0
- package/OverflowCommandBar/render.js +26 -0
- package/OverflowCommandBar/utils.d.ts +4 -0
- package/OverflowCommandBar/utils.js +17 -0
- package/PageEntityForm/CommandContainer.d.ts +2 -0
- package/PageEntityForm/CommandContainer.js +49 -0
- package/PageEntityForm/FormTabRelated.d.ts +6 -0
- package/PageEntityForm/FormTabRelated.js +41 -0
- package/PageEntityForm/PageEntityForm.d.ts +8 -0
- package/PageEntityForm/PageEntityForm.js +30 -0
- package/PageEntityForm/PageEntityFormDesktopContainer.d.ts +2 -0
- package/PageEntityForm/PageEntityFormDesktopContainer.js +120 -0
- package/PageEntityForm/PageEntityFormStringContext.d.ts +8 -0
- package/PageEntityForm/PageEntityFormStringContext.js +15 -0
- package/PageEntityForm/RecordCard.d.ts +10 -0
- package/PageEntityForm/RecordCard.js +134 -0
- package/PageEntityForm/RecordSetNavigatorContainer.d.ts +2 -0
- package/PageEntityForm/RecordSetNavigatorContainer.js +72 -0
- package/PageEntityForm/RelatedViewSelector.d.ts +15 -0
- package/PageEntityForm/RelatedViewSelector.js +78 -0
- package/PageEntityForm/SectionContainer.d.ts +6 -0
- package/PageEntityForm/SectionContainer.js +62 -0
- package/PageEntityForm/StandardControl.d.ts +24 -0
- package/PageEntityForm/StandardControl.js +227 -0
- package/PageEntityForm/SubgridControl.d.ts +13 -0
- package/PageEntityForm/SubgridControl.js +66 -0
- package/PageEntityForm/index.d.ts +1 -0
- package/PageEntityForm/index.js +5 -0
- package/PageEntityView/FormSubgridContainer.d.ts +7 -0
- package/PageEntityView/FormSubgridContainer.js +65 -0
- package/PageEntityView/PageEntityView.d.ts +8 -0
- package/PageEntityView/PageEntityView.js +22 -0
- package/PageEntityView/PageEntityViewDesktopContainer.d.ts +2 -0
- package/PageEntityView/PageEntityViewDesktopContainer.js +14 -0
- package/PageEntityView/PageEntityViewDesktopFrame.d.ts +9 -0
- package/PageEntityView/PageEntityViewDesktopFrame.js +48 -0
- package/PageEntityView/PageEntityViewStringContext.d.ts +23 -0
- package/PageEntityView/PageEntityViewStringContext.js +30 -0
- package/PageEntityView/index.d.ts +1 -0
- package/PageEntityView/index.js +5 -0
- package/ProgressIndicatorContainer/index.d.ts +1 -0
- package/ProgressIndicatorContainer/index.js +30 -0
- package/ToastNotificationContainer/index.d.ts +1 -0
- package/ToastNotificationContainer/index.js +44 -0
- package/components/BodyLoading.d.ts +6 -0
- package/components/BodyLoading.js +19 -0
- package/components/DialogLogin.d.ts +6 -0
- package/components/DialogLogin.js +9 -0
- package/components/LoginForm.d.ts +6 -0
- package/components/LoginForm.js +101 -0
- package/components/PageBroken.d.ts +8 -0
- package/components/PageBroken.js +15 -0
- package/components/PageLoading.d.ts +5 -0
- package/components/PageLoading.js +15 -0
- package/components/PageLogin.d.ts +7 -0
- package/components/PageLogin.js +46 -0
- package/form/FormControl.d.ts +6 -0
- package/form/FormControl.js +95 -0
- package/form/FormControlLoading.d.ts +2 -0
- package/form/FormControlLoading.js +9 -0
- package/form/controls/CurrencyControl.d.ts +4 -0
- package/form/controls/CurrencyControl.js +16 -0
- package/form/controls/DateControl.d.ts +6 -0
- package/form/controls/DateControl.js +21 -0
- package/form/controls/DateRangeControl.d.ts +6 -0
- package/form/controls/DateRangeControl.js +49 -0
- package/form/controls/DateTimeControl.d.ts +6 -0
- package/form/controls/DateTimeControl.js +23 -0
- package/form/controls/EmailControl.d.ts +6 -0
- package/form/controls/EmailControl.js +22 -0
- package/form/controls/LookupControl.d.ts +26 -0
- package/form/controls/LookupControl.js +134 -0
- package/form/controls/MultiSelectControl.d.ts +6 -0
- package/form/controls/MultiSelectControl.js +17 -0
- package/form/controls/MultiSelectLookupControl.d.ts +26 -0
- package/form/controls/MultiSelectLookupControl.js +187 -0
- package/form/controls/NumberControl.d.ts +4 -0
- package/form/controls/NumberControl.js +15 -0
- package/form/controls/PasswordControl.d.ts +6 -0
- package/form/controls/PasswordControl.js +13 -0
- package/form/controls/SelectControl.d.ts +9 -0
- package/form/controls/SelectControl.js +29 -0
- package/form/controls/SwitchControl.d.ts +4 -0
- package/form/controls/SwitchControl.js +6 -0
- package/form/controls/TelephoneControl.d.ts +5 -0
- package/form/controls/TelephoneControl.js +16 -0
- package/form/controls/TextAreaControl.d.ts +6 -0
- package/form/controls/TextAreaControl.js +16 -0
- package/form/controls/TextControl.d.ts +10 -0
- package/form/controls/TextControl.js +24 -0
- package/form/controls/types.d.ts +14 -0
- package/form/controls/types.js +2 -0
- package/form/controls/useLookupData.d.ts +19 -0
- package/form/controls/useLookupData.js +104 -0
- package/form/layout/FormBody/FormBody.d.ts +2 -0
- package/form/layout/FormBody/FormBody.js +11 -0
- package/form/layout/FormBody/index.d.ts +1 -0
- package/form/layout/FormBody/index.js +17 -0
- package/form/layout/FormSection/FormSection.d.ts +16 -0
- package/form/layout/FormSection/FormSection.js +83 -0
- package/form/layout/FormSection/FormSectionColumn.d.ts +6 -0
- package/form/layout/FormSection/FormSectionColumn.js +15 -0
- package/form/layout/FormSection/FormSectionLoading.d.ts +6 -0
- package/form/layout/FormSection/FormSectionLoading.js +7 -0
- package/form/layout/FormSection/index.d.ts +1 -0
- package/form/layout/FormSection/index.js +5 -0
- package/form/layout/FormTab/FormTab.d.ts +13 -0
- package/form/layout/FormTab/FormTab.js +82 -0
- package/form/layout/FormTab/FormTabColumn.d.ts +6 -0
- package/form/layout/FormTab/FormTabColumn.js +15 -0
- package/form/layout/FormTab/index.d.ts +1 -0
- package/form/layout/FormTab/index.js +5 -0
- package/form/layout/TabContext.d.ts +6 -0
- package/form/layout/TabContext.js +5 -0
- package/form/layout/index.d.ts +3 -0
- package/form/layout/index.js +11 -0
- package/form/types.d.ts +74 -0
- package/form/types.js +5 -0
- package/package.json +30 -0
- package/types/index.d.ts +32 -0
- package/types/index.js +2 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RecordSetNavigatorContainer = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_components_1 = require("@fluentui/react-components");
|
|
6
|
+
const ScrollView_1 = require("@headless-adminapp/app/components/ScrollView");
|
|
7
|
+
const hooks_1 = require("@headless-adminapp/app/dataform/hooks");
|
|
8
|
+
const locale_1 = require("@headless-adminapp/app/locale");
|
|
9
|
+
const hooks_2 = require("@headless-adminapp/app/recordset/hooks");
|
|
10
|
+
const hooks_3 = require("@headless-adminapp/app/route/hooks");
|
|
11
|
+
const app_1 = require("@headless-adminapp/core/experience/app");
|
|
12
|
+
const react_1 = require("react");
|
|
13
|
+
const RecordCard_1 = require("./RecordCard");
|
|
14
|
+
const useStyles = (0, react_components_1.makeStyles)({
|
|
15
|
+
item: {
|
|
16
|
+
cursor: 'pointer',
|
|
17
|
+
'&:hover': {
|
|
18
|
+
background: react_components_1.tokens.colorNeutralBackground1Hover,
|
|
19
|
+
},
|
|
20
|
+
'&:active': {
|
|
21
|
+
background: react_components_1.tokens.colorNeutralBackground1Pressed,
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
selected: {
|
|
25
|
+
background: react_components_1.tokens.colorNeutralBackground1Selected,
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
const RecordSetNavigatorContainer = () => {
|
|
29
|
+
var _a, _b;
|
|
30
|
+
const { data, cardView, schema } = (0, hooks_2.useRecordSetResult)();
|
|
31
|
+
const [visible] = (0, hooks_2.useRecordSetVisibility)();
|
|
32
|
+
const recordId = (0, hooks_1.useRecordId)();
|
|
33
|
+
const styles = useStyles();
|
|
34
|
+
const routeResolver = (0, hooks_3.useRouteResolver)();
|
|
35
|
+
const router = (0, hooks_3.useRouter)();
|
|
36
|
+
const { language, direction } = (0, locale_1.useLocale)();
|
|
37
|
+
if (!schema) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
if (!visible) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
return ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
44
|
+
[direction === 'rtl' ? 'paddingRight' : 'paddingLeft']: react_components_1.tokens.spacingVerticalM,
|
|
45
|
+
paddingBlock: react_components_1.tokens.spacingVerticalM,
|
|
46
|
+
display: 'flex',
|
|
47
|
+
// display: 'none',
|
|
48
|
+
}, children: (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
49
|
+
boxShadow: react_components_1.tokens.shadow2,
|
|
50
|
+
borderRadius: react_components_1.tokens.borderRadiusMedium,
|
|
51
|
+
background: react_components_1.tokens.colorNeutralBackground1,
|
|
52
|
+
display: 'flex',
|
|
53
|
+
minWidth: 320,
|
|
54
|
+
flexDirection: 'column',
|
|
55
|
+
}, children: [(0, jsx_runtime_1.jsx)("div", { style: {
|
|
56
|
+
display: 'flex',
|
|
57
|
+
flexDirection: 'column',
|
|
58
|
+
paddingInline: 16,
|
|
59
|
+
paddingBlock: 8,
|
|
60
|
+
}, children: (0, jsx_runtime_1.jsx)(react_components_1.Body1Strong, { children: (_b = (_a = schema.localizedPluralLabels) === null || _a === void 0 ? void 0 : _a[language]) !== null && _b !== void 0 ? _b : schema === null || schema === void 0 ? void 0 : schema.pluralLabel }) }), (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(react_components_1.Divider, { vertical: false, style: { opacity: 0.2 } }) }), (0, jsx_runtime_1.jsx)("div", { style: { display: 'flex', flex: 1, flexDirection: 'column' }, children: (0, jsx_runtime_1.jsx)(ScrollView_1.ScrollView, { autoHide: true, rtl: direction === 'rtl', children: data === null || data === void 0 ? void 0 : data.map((record) => ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { role: "button", className: (0, react_components_1.mergeClasses)(styles.item, recordId ===
|
|
61
|
+
record[schema.idAttribute] &&
|
|
62
|
+
styles.selected), onClick: () => {
|
|
63
|
+
const path = routeResolver({
|
|
64
|
+
type: app_1.PageType.EntityForm,
|
|
65
|
+
logicalName: schema.logicalName,
|
|
66
|
+
id: record[schema.idAttribute],
|
|
67
|
+
});
|
|
68
|
+
router.replace(path);
|
|
69
|
+
}, children: (0, jsx_runtime_1.jsx)(RecordCard_1.RecordCard, { cardView: cardView, record: record, schema: schema, selected: recordId ===
|
|
70
|
+
record[schema.idAttribute] }) }), (0, jsx_runtime_1.jsx)("div", { style: { paddingInline: react_components_1.tokens.spacingHorizontalL }, children: (0, jsx_runtime_1.jsx)(react_components_1.Divider, { vertical: false, style: { opacity: 0.2 } }) })] }, record[schema.idAttribute]))) }) })] }) }));
|
|
71
|
+
};
|
|
72
|
+
exports.RecordSetNavigatorContainer = RecordSetNavigatorContainer;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Localized } from '@headless-adminapp/core/types';
|
|
2
|
+
export interface RelatedItemInfo {
|
|
3
|
+
key: string;
|
|
4
|
+
logicalName: string;
|
|
5
|
+
label: string;
|
|
6
|
+
localizedLabels?: Localized<string>;
|
|
7
|
+
pluralLabel: string;
|
|
8
|
+
localizedPluralLabels?: Localized<string>;
|
|
9
|
+
attributeName: string;
|
|
10
|
+
}
|
|
11
|
+
interface RelatedViewSelectorProps {
|
|
12
|
+
onSelect: (item: RelatedItemInfo) => void;
|
|
13
|
+
}
|
|
14
|
+
export declare function RelatedViewSelector(props: RelatedViewSelectorProps): import("react/jsx-runtime").JSX.Element | null;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RelatedViewSelector = RelatedViewSelector;
|
|
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 locale_1 = require("@headless-adminapp/app/locale");
|
|
8
|
+
const hooks_2 = require("@headless-adminapp/app/metadata/hooks");
|
|
9
|
+
const utils_1 = require("@headless-adminapp/core/attributes/utils");
|
|
10
|
+
const icons_1 = require("@headless-adminapp/icons");
|
|
11
|
+
const react_1 = require("react");
|
|
12
|
+
const PageEntityFormStringContext_1 = require("./PageEntityFormStringContext");
|
|
13
|
+
function getRelatedItems(currentSchema, schemas) {
|
|
14
|
+
return Object.values(schemas)
|
|
15
|
+
.map((s) => {
|
|
16
|
+
return Object.entries(s.attributes)
|
|
17
|
+
.map(([key, attribute]) => {
|
|
18
|
+
if (!(0, utils_1.isLookupAttribute)(attribute)) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
// console.log('temp.a ', attribute);
|
|
22
|
+
if (attribute.entity !== currentSchema.logicalName) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
key,
|
|
27
|
+
attribute,
|
|
28
|
+
};
|
|
29
|
+
})
|
|
30
|
+
.filter(Boolean)
|
|
31
|
+
.map((item) => {
|
|
32
|
+
if (!item) {
|
|
33
|
+
throw new Error('item is null');
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
key: `${s.logicalName}.${item.key}`,
|
|
37
|
+
logicalName: s.logicalName,
|
|
38
|
+
label: s.label,
|
|
39
|
+
localizedLabels: s.localizedLabels,
|
|
40
|
+
pluralLabel: s.pluralLabel,
|
|
41
|
+
localizedPluralLabels: s.localizedPluralLabels,
|
|
42
|
+
attributeName: item.key,
|
|
43
|
+
};
|
|
44
|
+
});
|
|
45
|
+
})
|
|
46
|
+
.flat();
|
|
47
|
+
}
|
|
48
|
+
function RelatedViewSelector(props) {
|
|
49
|
+
const schema = (0, hooks_1.useDataFormSchema)();
|
|
50
|
+
const { schemas } = (0, hooks_2.useMetadata)();
|
|
51
|
+
const strings = (0, PageEntityFormStringContext_1.usePageEntityFormStrings)();
|
|
52
|
+
const { language } = (0, locale_1.useLocale)();
|
|
53
|
+
const data = (0, react_1.useMemo)(() => getRelatedItems(schema, schemas), [schema, schemas]);
|
|
54
|
+
if (!data.length) {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
return ((0, jsx_runtime_1.jsxs)(react_components_1.Menu, { children: [(0, jsx_runtime_1.jsx)(react_components_1.MenuTrigger, { children: (0, jsx_runtime_1.jsxs)("button", { style: {
|
|
58
|
+
border: 'none',
|
|
59
|
+
overflow: 'hidden',
|
|
60
|
+
borderRadius: react_components_1.tokens.borderRadiusMedium,
|
|
61
|
+
padding: `${react_components_1.tokens.spacingVerticalM} ${react_components_1.tokens.spacingHorizontalMNudge}`,
|
|
62
|
+
fontFamily: react_components_1.tokens.fontFamilyBase,
|
|
63
|
+
lineHeight: react_components_1.tokens.lineHeightBase300,
|
|
64
|
+
backgroundColor: react_components_1.tokens.colorTransparentBackground,
|
|
65
|
+
alignItems: 'center',
|
|
66
|
+
position: 'relative',
|
|
67
|
+
display: 'flex',
|
|
68
|
+
justifyContent: 'center',
|
|
69
|
+
flexShrink: 0,
|
|
70
|
+
cursor: 'pointer',
|
|
71
|
+
outlineStyle: 'none',
|
|
72
|
+
textTransform: 'none',
|
|
73
|
+
columnGap: react_components_1.tokens.spacingHorizontalSNudge,
|
|
74
|
+
}, children: [strings.related, (0, jsx_runtime_1.jsx)(icons_1.Icons.ChevronDown, { size: 16 })] }) }), (0, jsx_runtime_1.jsx)(react_components_1.MenuPopover, { children: (0, jsx_runtime_1.jsx)(react_components_1.MenuList, { children: data.map((item) => {
|
|
75
|
+
var _a, _b;
|
|
76
|
+
return ((0, jsx_runtime_1.jsx)(react_components_1.MenuItem, { onClick: () => props.onSelect(item), children: (_b = (_a = item.localizedPluralLabels) === null || _a === void 0 ? void 0 : _a[language]) !== null && _b !== void 0 ? _b : item.pluralLabel }, item.key));
|
|
77
|
+
}) }) })] }));
|
|
78
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Section } from '@headless-adminapp/core/experience/form';
|
|
2
|
+
import { SchemaAttributes } from '@headless-adminapp/core/schema';
|
|
3
|
+
export declare function SectionContainer<S extends SchemaAttributes = SchemaAttributes>({ section }: {
|
|
4
|
+
section: Section<S>;
|
|
5
|
+
readOnly: boolean;
|
|
6
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SectionContainer = SectionContainer;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const builders_1 = require("@headless-adminapp/app/builders");
|
|
6
|
+
const hooks_1 = require("@headless-adminapp/app/dataform/hooks");
|
|
7
|
+
const locale_1 = require("@headless-adminapp/app/locale");
|
|
8
|
+
const react_hook_form_1 = require("react-hook-form");
|
|
9
|
+
const SectionControl_1 = require("../DataForm/SectionControl");
|
|
10
|
+
const layout_1 = require("../form/layout");
|
|
11
|
+
const StandardControl_1 = require("./StandardControl");
|
|
12
|
+
const SubgridControl_1 = require("./SubgridControl");
|
|
13
|
+
function SectionContainer({ section }) {
|
|
14
|
+
const schema = (0, hooks_1.useDataFormSchema)();
|
|
15
|
+
const formInstance = (0, hooks_1.useFormInstance)();
|
|
16
|
+
const recordId = (0, hooks_1.useRecordId)();
|
|
17
|
+
const readonly = (0, hooks_1.useFormIsReadonly)();
|
|
18
|
+
const { language } = (0, locale_1.useLocale)();
|
|
19
|
+
return ((0, jsx_runtime_1.jsx)(layout_1.FormSection, { title: (0, builders_1.localizedLabel)(language, section), columnCount: section.columnCount, labelPosition: section.labelPosition, noPadding: section.noPadding, hideLabel: section.hideLabel, children: section.controls.map((control, index) => {
|
|
20
|
+
var _a;
|
|
21
|
+
switch (control.type) {
|
|
22
|
+
case 'standard':
|
|
23
|
+
const attribute = schema.attributes[control.attributeName];
|
|
24
|
+
return ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
25
|
+
gridColumn: control.span
|
|
26
|
+
? `var(--section-item-span-${control.span})`
|
|
27
|
+
: undefined,
|
|
28
|
+
}, children: (0, jsx_runtime_1.jsx)(react_hook_form_1.Controller, { control: formInstance.control, name: control.attributeName, render: ({ field, fieldState, formState }) => {
|
|
29
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
30
|
+
const isError = (fieldState.isTouched || formState.isSubmitted) &&
|
|
31
|
+
!!((_a = fieldState.error) === null || _a === void 0 ? void 0 : _a.message);
|
|
32
|
+
const errorMessage = fieldState.isTouched || formState.isSubmitted
|
|
33
|
+
? (_b = fieldState.error) === null || _b === void 0 ? void 0 : _b.message
|
|
34
|
+
: '';
|
|
35
|
+
const label = (_g = (_f = (_d = (_c = control.localizedLabels) === null || _c === void 0 ? void 0 : _c[language]) !== null && _d !== void 0 ? _d : (_e = attribute.localizedLabels) === null || _e === void 0 ? void 0 : _e[language]) !== null && _f !== void 0 ? _f : control.label) !== null && _g !== void 0 ? _g : attribute.label;
|
|
36
|
+
return ((0, jsx_runtime_1.jsx)(SectionControl_1.SectionControlWrapper, { label: label, labelPosition: section.labelPosition, required: attribute.required, isError: isError, errorMessage: errorMessage, children: (0, jsx_runtime_1.jsx)(StandardControl_1.StandardControl, { attribute: attribute, name: control.attributeName, value: field.value, onChange: field.onChange, onBlur: field.onBlur, errorMessage: errorMessage, isError: isError, disabled: readonly, label: label, placeholder: label, allowNavigation: true, allowNewRecord: true }) }));
|
|
37
|
+
} }, control.attributeName) }, control.attributeName));
|
|
38
|
+
case 'editablegrid': {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
case 'quickview':
|
|
42
|
+
return null;
|
|
43
|
+
case 'subgrid':
|
|
44
|
+
return ((0, jsx_runtime_1.jsx)(SubgridControl_1.SubgridControl, { logicalName: control.logicalName, allowViewSelection: control.allowViewSelection, viewId: control.viewId, availableViewIds: control.availableViewIds, associated: !control.associatedAttribute
|
|
45
|
+
? false
|
|
46
|
+
: {
|
|
47
|
+
logicalName: schema.logicalName,
|
|
48
|
+
id: recordId,
|
|
49
|
+
refAttributeName: control.associatedAttribute,
|
|
50
|
+
} }, index));
|
|
51
|
+
case 'spacer':
|
|
52
|
+
return ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
53
|
+
gridColumn: control.span
|
|
54
|
+
? `var(--section-item-span-${control.span})`
|
|
55
|
+
: undefined,
|
|
56
|
+
display: `var(--section-item-spacer-${(_a = control.span) !== null && _a !== void 0 ? _a : 1})`,
|
|
57
|
+
} }, index));
|
|
58
|
+
default:
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
}) }));
|
|
62
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Attribute } from '@headless-adminapp/core/attributes';
|
|
2
|
+
import { FC } from 'react';
|
|
3
|
+
interface StandardControlProps {
|
|
4
|
+
attribute: Attribute;
|
|
5
|
+
label?: string;
|
|
6
|
+
isError: boolean;
|
|
7
|
+
errorMessage: string | undefined;
|
|
8
|
+
name: string;
|
|
9
|
+
value: any;
|
|
10
|
+
placeholder?: string;
|
|
11
|
+
onChange: (value: any) => void;
|
|
12
|
+
onBlur: () => void;
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
borderOnFocusOnly?: boolean;
|
|
15
|
+
hideLabel?: boolean;
|
|
16
|
+
hidePlaceholder?: boolean;
|
|
17
|
+
allowQuickCreate?: boolean;
|
|
18
|
+
readOnly?: boolean;
|
|
19
|
+
quickViewControl?: boolean;
|
|
20
|
+
allowNavigation?: boolean;
|
|
21
|
+
allowNewRecord?: boolean;
|
|
22
|
+
}
|
|
23
|
+
export declare const StandardControl: FC<StandardControlProps>;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,227 @@
|
|
|
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.StandardControl = void 0;
|
|
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 react_1 = require("react");
|
|
11
|
+
const CurrencyControl_1 = require("../form/controls/CurrencyControl");
|
|
12
|
+
const DateControl_1 = require("../form/controls/DateControl");
|
|
13
|
+
const DateRangeControl_1 = require("../form/controls/DateRangeControl");
|
|
14
|
+
const DateTimeControl_1 = require("../form/controls/DateTimeControl");
|
|
15
|
+
const EmailControl_1 = require("../form/controls/EmailControl");
|
|
16
|
+
const LookupControl_1 = require("../form/controls/LookupControl");
|
|
17
|
+
const MultiSelectControl_1 = __importDefault(require("../form/controls/MultiSelectControl"));
|
|
18
|
+
const MultiSelectLookupControl_1 = require("../form/controls/MultiSelectLookupControl");
|
|
19
|
+
const NumberControl_1 = require("../form/controls/NumberControl");
|
|
20
|
+
const SelectControl_1 = __importDefault(require("../form/controls/SelectControl"));
|
|
21
|
+
const SwitchControl_1 = require("../form/controls/SwitchControl");
|
|
22
|
+
const TelephoneControl_1 = require("../form/controls/TelephoneControl");
|
|
23
|
+
const TextAreaControl_1 = require("../form/controls/TextAreaControl");
|
|
24
|
+
const TextControl_1 = require("../form/controls/TextControl");
|
|
25
|
+
const StandardControl = ({ attribute, label: _label, isError,
|
|
26
|
+
// errorMessage,
|
|
27
|
+
name, value, onBlur, onChange,
|
|
28
|
+
// dataService,
|
|
29
|
+
// fileService,
|
|
30
|
+
disabled, borderOnFocusOnly, placeholder: _placeholder,
|
|
31
|
+
// hideLabel,
|
|
32
|
+
hidePlaceholder, readOnly,
|
|
33
|
+
// quickViewControl,
|
|
34
|
+
allowNavigation, allowNewRecord, }) => {
|
|
35
|
+
var _a;
|
|
36
|
+
const isDisabled = attribute.readonly || disabled;
|
|
37
|
+
// const label = hideLabel ? undefined : _label ?? attribute.label;
|
|
38
|
+
const placeholder = hidePlaceholder
|
|
39
|
+
? undefined
|
|
40
|
+
: (_a = _placeholder !== null && _placeholder !== void 0 ? _placeholder : _label) !== null && _a !== void 0 ? _a : attribute.label;
|
|
41
|
+
// const required = quickViewControl ? false : attribute.required;
|
|
42
|
+
const dataService = (0, transport_1.useDataService)();
|
|
43
|
+
const { schemaStore, experienceStore } = (0, hooks_1.useMetadata)();
|
|
44
|
+
// const { openQuickCreate } = useQuickCreateForm();
|
|
45
|
+
switch (attribute.type) {
|
|
46
|
+
case 'string':
|
|
47
|
+
const controlProps = {
|
|
48
|
+
name,
|
|
49
|
+
placeholder,
|
|
50
|
+
value,
|
|
51
|
+
onChange,
|
|
52
|
+
onBlur,
|
|
53
|
+
error: isError,
|
|
54
|
+
disabled: isDisabled,
|
|
55
|
+
readOnly,
|
|
56
|
+
};
|
|
57
|
+
switch (attribute.format) {
|
|
58
|
+
case 'text':
|
|
59
|
+
return ((0, jsx_runtime_1.jsx)(TextControl_1.TextControl, Object.assign({}, controlProps, { textTransform: attribute.textTransform })));
|
|
60
|
+
case 'email':
|
|
61
|
+
return (0, jsx_runtime_1.jsx)(EmailControl_1.EmailControl, Object.assign({}, controlProps));
|
|
62
|
+
case 'phone':
|
|
63
|
+
return (0, jsx_runtime_1.jsx)(TelephoneControl_1.TelephoneControl, Object.assign({}, controlProps));
|
|
64
|
+
case 'url':
|
|
65
|
+
return (0, jsx_runtime_1.jsx)(TextControl_1.TextControl, Object.assign({}, controlProps));
|
|
66
|
+
case 'textarea':
|
|
67
|
+
return (0, jsx_runtime_1.jsx)(TextAreaControl_1.TextAreaControl, Object.assign({}, controlProps));
|
|
68
|
+
default:
|
|
69
|
+
return (0, jsx_runtime_1.jsx)(react_1.Fragment, {});
|
|
70
|
+
}
|
|
71
|
+
case 'number':
|
|
72
|
+
return ((0, jsx_runtime_1.jsx)(NumberControl_1.NumberControl, { name: name, placeholder: placeholder, value: value, onChange: onChange, onBlur: onBlur, error: isError, disabled: isDisabled, readOnly: readOnly }));
|
|
73
|
+
case 'date': {
|
|
74
|
+
const controlProps = {
|
|
75
|
+
name,
|
|
76
|
+
placeholder,
|
|
77
|
+
value,
|
|
78
|
+
onChange,
|
|
79
|
+
onBlur,
|
|
80
|
+
error: isError,
|
|
81
|
+
disabled: isDisabled,
|
|
82
|
+
readOnly,
|
|
83
|
+
};
|
|
84
|
+
if (attribute.format === 'datetime') {
|
|
85
|
+
return (0, jsx_runtime_1.jsx)(DateTimeControl_1.DateTimeControl, Object.assign({}, controlProps));
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
return (0, jsx_runtime_1.jsx)(DateControl_1.DateControl, Object.assign({}, controlProps));
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
case 'daterange': {
|
|
92
|
+
const controlProps = {
|
|
93
|
+
name,
|
|
94
|
+
placeholder,
|
|
95
|
+
value,
|
|
96
|
+
onChange,
|
|
97
|
+
onBlur,
|
|
98
|
+
error: isError,
|
|
99
|
+
disabled: isDisabled,
|
|
100
|
+
readOnly,
|
|
101
|
+
};
|
|
102
|
+
return (0, jsx_runtime_1.jsx)(DateRangeControl_1.DateRangeControl, Object.assign({}, controlProps));
|
|
103
|
+
}
|
|
104
|
+
case 'money': {
|
|
105
|
+
return ((0, jsx_runtime_1.jsx)(CurrencyControl_1.CurrencyControl, { name: name, placeholder: placeholder, value: value, onChange: onChange, onBlur: onBlur, error: isError, disabled: isDisabled, borderOnFocusOnly: borderOnFocusOnly, readOnly: readOnly }));
|
|
106
|
+
}
|
|
107
|
+
case 'lookup': {
|
|
108
|
+
// const experienceSchema = getExperienceSchema(attribute.entity);
|
|
109
|
+
// const routes = getExperienceRoutes(attribute.entity);
|
|
110
|
+
// const path = routes?.create?.();
|
|
111
|
+
// let createButtonProps:
|
|
112
|
+
// | {
|
|
113
|
+
// label: string;
|
|
114
|
+
// onClick: () => void;
|
|
115
|
+
// }
|
|
116
|
+
// | undefined;
|
|
117
|
+
// if (allowQuickCreate && experienceSchema.defaultQuickCreateForm) {
|
|
118
|
+
// createButtonProps = {
|
|
119
|
+
// label: 'New record',
|
|
120
|
+
// onClick: async () => {
|
|
121
|
+
// try {
|
|
122
|
+
// const result = await openQuickCreate({
|
|
123
|
+
// logicalName: attribute.entity,
|
|
124
|
+
// });
|
|
125
|
+
// if (result) {
|
|
126
|
+
// onChange(result);
|
|
127
|
+
// }
|
|
128
|
+
// } catch (error) {
|
|
129
|
+
// console.error(error);
|
|
130
|
+
// }
|
|
131
|
+
// },
|
|
132
|
+
// };
|
|
133
|
+
// } else if (path) {
|
|
134
|
+
// createButtonProps = {
|
|
135
|
+
// label: 'New record',
|
|
136
|
+
// onClick: () => {
|
|
137
|
+
// router.push(path);
|
|
138
|
+
// },
|
|
139
|
+
// };
|
|
140
|
+
// }
|
|
141
|
+
// return (
|
|
142
|
+
// <FormControl
|
|
143
|
+
// type="lookup"
|
|
144
|
+
// name={name}
|
|
145
|
+
// label={label}
|
|
146
|
+
// placeholder={placeholder}
|
|
147
|
+
// required={required}
|
|
148
|
+
// value={value}
|
|
149
|
+
// onChange={onChange}
|
|
150
|
+
// onBlur={onBlur}
|
|
151
|
+
// error={isError}
|
|
152
|
+
// helperText={errorMessage}
|
|
153
|
+
// disabled={isDisabled}
|
|
154
|
+
// borderOnFocusOnly={borderOnFocusOnly}
|
|
155
|
+
// readOnly={readOnly}
|
|
156
|
+
// createButton={createButtonProps}
|
|
157
|
+
// openRecord={
|
|
158
|
+
// routes?.edit
|
|
159
|
+
// ? (id) => {
|
|
160
|
+
// router.push(routes.edit!(id));
|
|
161
|
+
// }
|
|
162
|
+
// : undefined
|
|
163
|
+
// }
|
|
164
|
+
// async
|
|
165
|
+
// dataResolver={async (options) => {
|
|
166
|
+
// const lookupSchema = getSchema(attribute.entity);
|
|
167
|
+
// const data = await dataService.retriveRecords({
|
|
168
|
+
// logicalName: attribute.entity,
|
|
169
|
+
// search: options?.search ?? '',
|
|
170
|
+
// columnFilters: {},
|
|
171
|
+
// pagination: {
|
|
172
|
+
// pageIndex: 0,
|
|
173
|
+
// rowsPerPage: 10,
|
|
174
|
+
// sortBy: 'createdAt',
|
|
175
|
+
// sortOrder: 'desc',
|
|
176
|
+
// },
|
|
177
|
+
// viewFilter: null,
|
|
178
|
+
// columns: ['_id', lookupSchema.primaryAttribute ?? 'name'],
|
|
179
|
+
// limit: options?.limit ?? 10,
|
|
180
|
+
// });
|
|
181
|
+
// return data.records.map((x: any) => ({
|
|
182
|
+
// _id: x._id,
|
|
183
|
+
// name: x[lookupSchema.primaryAttribute ?? 'name'],
|
|
184
|
+
// }));
|
|
185
|
+
// }}
|
|
186
|
+
// />
|
|
187
|
+
// );
|
|
188
|
+
return ((0, jsx_runtime_1.jsx)(LookupControl_1.LookupControl, { name: name, value: value, onChange: onChange, onBlur: onBlur, placeholder: placeholder, disabled: isDisabled, dataService: dataService, schema: schemaStore.getSchema(attribute.entity), experienceStore: experienceStore, allowNavigation: allowNavigation, allowNewRecord: allowNewRecord }));
|
|
189
|
+
}
|
|
190
|
+
case 'lookups': {
|
|
191
|
+
return ((0, jsx_runtime_1.jsx)(MultiSelectLookupControl_1.MultiSelectLookupControl, { name: name, value: value, onChange: onChange, onBlur: onBlur, placeholder: placeholder, disabled: isDisabled, dataService: dataService, schema: schemaStore.getSchema(attribute.entity), experienceStore: experienceStore, allowNavigation: allowNavigation, allowNewRecord: allowNewRecord }));
|
|
192
|
+
}
|
|
193
|
+
case 'boolean': {
|
|
194
|
+
return ((0, jsx_runtime_1.jsx)(SwitchControl_1.SwitchControl, { name: name, value: value, onChange: onChange, onBlur: onBlur, error: isError, disabled: isDisabled, readOnly: readOnly }));
|
|
195
|
+
}
|
|
196
|
+
case 'choice': {
|
|
197
|
+
return ((0, jsx_runtime_1.jsx)(SelectControl_1.default, { name: name, value: value, onChange: onChange, onBlur: onBlur, error: isError, disabled: isDisabled, options: attribute.options, placeholder: placeholder, borderOnFocusOnly: borderOnFocusOnly, readOnly: readOnly }));
|
|
198
|
+
}
|
|
199
|
+
case 'choices': {
|
|
200
|
+
return ((0, jsx_runtime_1.jsx)(MultiSelectControl_1.default, { name: name, value: value, onChange: onChange, onBlur: onBlur, error: isError, disabled: isDisabled, options: attribute.options, placeholder: placeholder, borderOnFocusOnly: borderOnFocusOnly, readOnly: readOnly }));
|
|
201
|
+
}
|
|
202
|
+
// case 'attachment': {
|
|
203
|
+
// return (
|
|
204
|
+
// <FormControl
|
|
205
|
+
// type="attachment"
|
|
206
|
+
// name={name}
|
|
207
|
+
// label={label}
|
|
208
|
+
// required={required}
|
|
209
|
+
// value={value}
|
|
210
|
+
// onChange={onChange}
|
|
211
|
+
// onBlur={onBlur}
|
|
212
|
+
// error={isError}
|
|
213
|
+
// helperText={errorMessage}
|
|
214
|
+
// disabled={isDisabled}
|
|
215
|
+
// placeholder={placeholder}
|
|
216
|
+
// borderOnFocusOnly={borderOnFocusOnly}
|
|
217
|
+
// readOnly={readOnly}
|
|
218
|
+
// format={attribute.format}
|
|
219
|
+
// maxSize={attribute.maxSize}
|
|
220
|
+
// fileService={fileService}
|
|
221
|
+
// />
|
|
222
|
+
// );
|
|
223
|
+
// }
|
|
224
|
+
}
|
|
225
|
+
return (0, jsx_runtime_1.jsx)(react_1.Fragment, {});
|
|
226
|
+
};
|
|
227
|
+
exports.StandardControl = StandardControl;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
interface SubgridControlProps {
|
|
2
|
+
logicalName: string;
|
|
3
|
+
allowViewSelection?: boolean;
|
|
4
|
+
viewId?: string;
|
|
5
|
+
availableViewIds?: string[];
|
|
6
|
+
associated: false | {
|
|
7
|
+
logicalName: string;
|
|
8
|
+
id: string;
|
|
9
|
+
refAttributeName: string;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export declare function SubgridControl(props: SubgridControlProps): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SubgridControl = SubgridControl;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_components_1 = require("@fluentui/react-components");
|
|
6
|
+
const DataGridProvider_1 = require("@headless-adminapp/app/datagrid/DataGridProvider");
|
|
7
|
+
const hooks_1 = require("@headless-adminapp/app/metadata/hooks");
|
|
8
|
+
const react_1 = require("react");
|
|
9
|
+
const FormSubgridContainer_1 = require("../PageEntityView/FormSubgridContainer");
|
|
10
|
+
function SubgridControl(props) {
|
|
11
|
+
var _a;
|
|
12
|
+
const schema = (0, hooks_1.useSchema)(props.logicalName);
|
|
13
|
+
const [viewId, setViewId] = (0, react_1.useState)(props.viewId);
|
|
14
|
+
const { view, isLoadingView } = (0, hooks_1.useExperienceView)(props.logicalName, viewId, !!props.associated, props.availableViewIds);
|
|
15
|
+
const { viewLookup } = (0, hooks_1.useExperienceViewLookup)(props.logicalName, !!props.associated, props.availableViewIds);
|
|
16
|
+
const { commands } = (0, hooks_1.useExperienceViewCommands)(props.logicalName);
|
|
17
|
+
const { commands: subgridCommands } = (0, hooks_1.useExperienceViewSubgridCommands)(props.logicalName);
|
|
18
|
+
const extraFilter = (0, react_1.useMemo)(() => {
|
|
19
|
+
if (!props.associated) {
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
return {
|
|
23
|
+
type: 'and',
|
|
24
|
+
conditions: [
|
|
25
|
+
{
|
|
26
|
+
field: props.associated.refAttributeName,
|
|
27
|
+
operator: 'eq',
|
|
28
|
+
value: props.associated.id,
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
};
|
|
32
|
+
}, [props.associated]);
|
|
33
|
+
const loadingContent = ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
34
|
+
display: 'flex',
|
|
35
|
+
flex: 1,
|
|
36
|
+
flexDirection: 'column',
|
|
37
|
+
gap: 16,
|
|
38
|
+
alignItems: 'center',
|
|
39
|
+
justifyContent: 'center',
|
|
40
|
+
}, children: (0, jsx_runtime_1.jsx)(react_components_1.Spinner, {}) }));
|
|
41
|
+
const brokenContent = ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
42
|
+
display: 'flex',
|
|
43
|
+
flex: 1,
|
|
44
|
+
flexDirection: 'column',
|
|
45
|
+
alignItems: 'center',
|
|
46
|
+
justifyContent: 'center',
|
|
47
|
+
gap: 16,
|
|
48
|
+
}, children: (0, jsx_runtime_1.jsx)(react_components_1.Body1, { children: "Unable to load control" }) }));
|
|
49
|
+
if (!schema) {
|
|
50
|
+
return brokenContent;
|
|
51
|
+
}
|
|
52
|
+
if (!view) {
|
|
53
|
+
if (isLoadingView) {
|
|
54
|
+
return loadingContent;
|
|
55
|
+
}
|
|
56
|
+
return brokenContent;
|
|
57
|
+
}
|
|
58
|
+
if (view.logicalName !== schema.logicalName) {
|
|
59
|
+
if (isLoadingView) {
|
|
60
|
+
console.log('missmatched view', view, schema);
|
|
61
|
+
return loadingContent;
|
|
62
|
+
}
|
|
63
|
+
return brokenContent;
|
|
64
|
+
}
|
|
65
|
+
return ((0, jsx_runtime_1.jsx)(DataGridProvider_1.DataGridProvider, { schema: schema, view: view, views: viewLookup, onChangeView: setViewId, commands: (props.associated ? subgridCommands : commands), isSubGrid: props.associated ? true : false, extraFilter: extraFilter, allowViewSelection: (_a = props.allowViewSelection) !== null && _a !== void 0 ? _a : false, children: (0, jsx_runtime_1.jsx)(FormSubgridContainer_1.FormSubgridContainer, {}) }));
|
|
66
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { PageEntityForm } from './PageEntityForm';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PageEntityForm = void 0;
|
|
4
|
+
var PageEntityForm_1 = require("./PageEntityForm");
|
|
5
|
+
Object.defineProperty(exports, "PageEntityForm", { enumerable: true, get: function () { return PageEntityForm_1.PageEntityForm; } });
|