@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,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.OverflowMenu = void 0;
|
|
15
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
16
|
+
const react_components_1 = require("@fluentui/react-components");
|
|
17
|
+
const locale_1 = require("@headless-adminapp/app/locale");
|
|
18
|
+
const icons_1 = require("@headless-adminapp/icons");
|
|
19
|
+
const react_1 = require("react");
|
|
20
|
+
const MenuItem_1 = require("../CommandBar/MenuItem");
|
|
21
|
+
const OverflowMenuDivider_1 = require("./OverflowMenuDivider");
|
|
22
|
+
const utils_1 = require("./utils");
|
|
23
|
+
const OverflowMenu = ({ items, }) => {
|
|
24
|
+
const { ref, isOverflowing } = (0, react_components_1.useOverflowMenu)();
|
|
25
|
+
const { language } = (0, locale_1.useLocale)();
|
|
26
|
+
if (!isOverflowing) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
return ((0, jsx_runtime_1.jsxs)(react_components_1.Menu, { positioning: "below-end", hasIcons: true, children: [(0, jsx_runtime_1.jsx)(react_components_1.MenuTrigger, { disableButtonEnhancement: true, children: (0, jsx_runtime_1.jsx)(react_components_1.ToolbarButton, { ref: ref, type: "button", icon: (0, jsx_runtime_1.jsx)(icons_1.Icons.MoreHorizontal, {}) }) }), (0, jsx_runtime_1.jsx)(react_components_1.MenuPopover, { children: (0, jsx_runtime_1.jsx)(react_components_1.MenuList, { children: items.map((group, groupIndex) => ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [groupIndex > 0 && ((0, jsx_runtime_1.jsx)(OverflowMenuDivider_1.OverflowMenuDivider, { id: String(groupIndex), previousGroupId: String(groupIndex - 1) })), group.map((item, index) => {
|
|
30
|
+
var _a, _b;
|
|
31
|
+
const text = 'text' in item ? (_a = item.text) !== null && _a !== void 0 ? _a : '' : '';
|
|
32
|
+
return ((0, jsx_runtime_1.jsx)(OverflowMenuItem, { id: `${groupIndex}-${index}`, Icon: item.Icon, onClick: item.type !== 'label' ? item.onClick : undefined, text: text, danger: item.danger, disabled: item.type !== 'label' ? item.disabled : undefined, items: item.type === 'menu'
|
|
33
|
+
? (_b = item.items) === null || _b === void 0 ? void 0 : _b.map((x) => (0, utils_1.transformMenuItems)(x, language))
|
|
34
|
+
: undefined }, index));
|
|
35
|
+
})] }, groupIndex))) }) })] }));
|
|
36
|
+
};
|
|
37
|
+
exports.OverflowMenu = OverflowMenu;
|
|
38
|
+
const OverflowMenuItem = (props) => {
|
|
39
|
+
const { id } = props, rest = __rest(props, ["id"]);
|
|
40
|
+
const isVisible = (0, react_components_1.useIsOverflowItemVisible)(id);
|
|
41
|
+
if (isVisible) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
return (0, jsx_runtime_1.jsx)(MenuItem_1.MenuItem, Object.assign({}, rest));
|
|
45
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OverflowMenuDivider = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_components_1 = require("@fluentui/react-components");
|
|
6
|
+
const OverflowMenuDivider = (props) => {
|
|
7
|
+
const isGroupVisible = (0, react_components_1.useIsOverflowGroupVisible)(props.id);
|
|
8
|
+
const isPreviousGroupVisible = (0, react_components_1.useIsOverflowGroupVisible)(props.previousGroupId);
|
|
9
|
+
if (isGroupVisible !== 'hidden' || isPreviousGroupVisible === 'visible') {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
return (0, jsx_runtime_1.jsx)(react_components_1.MenuDivider, {});
|
|
13
|
+
};
|
|
14
|
+
exports.OverflowMenuDivider = OverflowMenuDivider;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.renderCommandItem = exports.transformMenuItems = exports.OverflowCommandBar = void 0;
|
|
4
|
+
var OverflowCommandBar_1 = require("./OverflowCommandBar");
|
|
5
|
+
Object.defineProperty(exports, "OverflowCommandBar", { enumerable: true, get: function () { return OverflowCommandBar_1.OverflowCommandBar; } });
|
|
6
|
+
var utils_1 = require("./utils");
|
|
7
|
+
Object.defineProperty(exports, "transformMenuItems", { enumerable: true, get: function () { return utils_1.transformMenuItems; } });
|
|
8
|
+
var render_1 = require("./render");
|
|
9
|
+
Object.defineProperty(exports, "renderCommandItem", { enumerable: true, get: function () { return render_1.renderCommandItem; } });
|
|
@@ -0,0 +1,26 @@
|
|
|
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.renderCommandItem = renderCommandItem;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const CommandBar_1 = __importDefault(require("../CommandBar"));
|
|
9
|
+
const MenuButton_1 = require("../CommandBar/MenuButton");
|
|
10
|
+
const utils_1 = require("./utils");
|
|
11
|
+
function renderCommandItem(key, item, language) {
|
|
12
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
13
|
+
const commandType = item.type;
|
|
14
|
+
switch (item.type) {
|
|
15
|
+
case 'menu':
|
|
16
|
+
return ((0, jsx_runtime_1.jsx)(MenuButton_1.CommandMenuButton, { Icon: item.Icon, text: (_c = (_b = (_a = item.localizedTexts) === null || _a === void 0 ? void 0 : _a[language]) !== null && _b !== void 0 ? _b : item.text) !== null && _c !== void 0 ? _c : '', danger: item.danger, disabled: item.disabled, onClick: item.onClick, items: (_d = item.items) === null || _d === void 0 ? void 0 : _d.map((x) => (0, utils_1.transformMenuItems)(x, language)) }, key));
|
|
17
|
+
case 'button':
|
|
18
|
+
return ((0, jsx_runtime_1.jsx)(CommandBar_1.default.Button, { text: (_g = (_f = (_e = item.localizedTexts) === null || _e === void 0 ? void 0 : _e[language]) !== null && _f !== void 0 ? _f : item.text) !== null && _g !== void 0 ? _g : '', Icon: item.Icon, iconPosition: (_h = item.iconPosition) !== null && _h !== void 0 ? _h : 'before', danger: item.danger, disabled: item.disabled, onClick: item.onClick }, key));
|
|
19
|
+
case 'label':
|
|
20
|
+
return ((0, jsx_runtime_1.jsx)(CommandBar_1.default.Label, { text: (_l = (_k = (_j = item.localizedTexts) === null || _j === void 0 ? void 0 : _j[language]) !== null && _k !== void 0 ? _k : item.text) !== null && _l !== void 0 ? _l : '', Icon: item.Icon }, key));
|
|
21
|
+
case 'icon':
|
|
22
|
+
return ((0, jsx_runtime_1.jsx)(CommandBar_1.default.IconButton, { Icon: item.Icon, danger: item.danger, disabled: item.disabled, onClick: item.onClick }, key));
|
|
23
|
+
default:
|
|
24
|
+
throw new Error(`Unknown command type: ${commandType}`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { MenuItemCommandState } from '@headless-adminapp/app/command';
|
|
2
|
+
import { ArrayWithAtLeastOne } from '@headless-adminapp/core/types';
|
|
3
|
+
import { MenuItemProps } from '../CommandBar/MenuItem';
|
|
4
|
+
export declare function transformMenuItems(items: ArrayWithAtLeastOne<MenuItemCommandState>, language: string): ArrayWithAtLeastOne<MenuItemProps>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.transformMenuItems = transformMenuItems;
|
|
4
|
+
function transformMenuItem(item, language) {
|
|
5
|
+
var _a, _b, _c, _d;
|
|
6
|
+
return {
|
|
7
|
+
Icon: item.Icon,
|
|
8
|
+
text: (_c = (_b = (_a = item.localizedTexts) === null || _a === void 0 ? void 0 : _a[language]) !== null && _b !== void 0 ? _b : item.text) !== null && _c !== void 0 ? _c : '',
|
|
9
|
+
danger: item.danger,
|
|
10
|
+
onClick: item.onClick,
|
|
11
|
+
disabled: item.disabled,
|
|
12
|
+
items: (_d = item.items) === null || _d === void 0 ? void 0 : _d.map((x) => transformMenuItems(x, language)),
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
function transformMenuItems(items, language) {
|
|
16
|
+
return items.map((x) => transformMenuItem(x, language));
|
|
17
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CommandContainer = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const hooks_1 = require("@headless-adminapp/app/dataform/hooks");
|
|
6
|
+
const mutable_1 = require("@headless-adminapp/app/mutable");
|
|
7
|
+
const recordset_1 = require("@headless-adminapp/app/recordset");
|
|
8
|
+
const hooks_2 = require("@headless-adminapp/app/recordset/hooks");
|
|
9
|
+
const hooks_3 = require("@headless-adminapp/app/route/hooks");
|
|
10
|
+
const icons_1 = require("@headless-adminapp/icons");
|
|
11
|
+
const react_1 = require("react");
|
|
12
|
+
const OverflowCommandBar_1 = require("../OverflowCommandBar");
|
|
13
|
+
const CommandContainer = () => {
|
|
14
|
+
const gridCommands = (0, hooks_1.useMainFormCommands)();
|
|
15
|
+
const router = (0, hooks_3.useRouter)();
|
|
16
|
+
const schema = (0, hooks_1.useDataFormSchema)();
|
|
17
|
+
const [recordSetVisible, setRecordSetVisible] = (0, hooks_2.useRecordSetVisibility)();
|
|
18
|
+
const recordSetContext = (0, mutable_1.useContextSelector)(recordset_1.RecordSetContext, (state) => state);
|
|
19
|
+
const extendedCommands = (0, react_1.useMemo)(() => {
|
|
20
|
+
return [
|
|
21
|
+
[
|
|
22
|
+
{
|
|
23
|
+
type: 'icon',
|
|
24
|
+
Icon: icons_1.Icons.ArrowLeft,
|
|
25
|
+
onClick: () => {
|
|
26
|
+
router.back();
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
...(recordSetContext.logicalName === schema.logicalName &&
|
|
31
|
+
recordSetContext.ids.length > 0
|
|
32
|
+
? [
|
|
33
|
+
[
|
|
34
|
+
{
|
|
35
|
+
type: 'icon',
|
|
36
|
+
Icon: icons_1.Icons.ListLtr,
|
|
37
|
+
onClick: () => {
|
|
38
|
+
setRecordSetVisible(!recordSetVisible);
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
]
|
|
43
|
+
: []),
|
|
44
|
+
...gridCommands,
|
|
45
|
+
];
|
|
46
|
+
}, [gridCommands, recordSetContext, recordSetVisible, schema.logicalName]);
|
|
47
|
+
return (0, jsx_runtime_1.jsx)(OverflowCommandBar_1.OverflowCommandBar, { commands: extendedCommands });
|
|
48
|
+
};
|
|
49
|
+
exports.CommandContainer = CommandContainer;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { RelatedItemInfo } from './RelatedViewSelector';
|
|
2
|
+
interface FormTabRelatedProps {
|
|
3
|
+
selectedRelatedItem: RelatedItemInfo | null;
|
|
4
|
+
}
|
|
5
|
+
export declare function FormTabRelated({ selectedRelatedItem }: FormTabRelatedProps): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FormTabRelated = FormTabRelated;
|
|
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 hooks_2 = require("@headless-adminapp/app/dataform/hooks");
|
|
8
|
+
const FormTab_1 = require("../form/layout/FormTab");
|
|
9
|
+
const SubgridControl_1 = require("./SubgridControl");
|
|
10
|
+
function FormTabRelated({ selectedRelatedItem }) {
|
|
11
|
+
const recordId = (0, hooks_2.useRecordId)();
|
|
12
|
+
const schema = (0, hooks_1.useDataFormSchema)();
|
|
13
|
+
return ((0, jsx_runtime_1.jsx)(FormTab_1.FormTab, { value: "related", noWrapper: true, children: (0, jsx_runtime_1.jsx)("div", { style: {
|
|
14
|
+
display: 'flex',
|
|
15
|
+
flexDirection: 'column',
|
|
16
|
+
flex: 1,
|
|
17
|
+
}, children: (0, jsx_runtime_1.jsx)("div", { style: {
|
|
18
|
+
display: 'flex',
|
|
19
|
+
flexDirection: 'column',
|
|
20
|
+
flex: 1,
|
|
21
|
+
}, children: (0, jsx_runtime_1.jsx)("div", { style: {
|
|
22
|
+
display: 'flex',
|
|
23
|
+
flexDirection: 'column',
|
|
24
|
+
boxShadow: react_components_1.tokens.shadow2,
|
|
25
|
+
borderRadius: react_components_1.tokens.borderRadiusMedium,
|
|
26
|
+
background: react_components_1.tokens.colorNeutralBackground1,
|
|
27
|
+
flex: 1,
|
|
28
|
+
}, children: (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
|
+
flex: 1,
|
|
34
|
+
display: 'flex',
|
|
35
|
+
flexDirection: 'column',
|
|
36
|
+
}, children: !!selectedRelatedItem && ((0, jsx_runtime_1.jsx)(SubgridControl_1.SubgridControl, { logicalName: selectedRelatedItem.logicalName, allowViewSelection: true, associated: {
|
|
37
|
+
logicalName: schema.logicalName,
|
|
38
|
+
id: recordId,
|
|
39
|
+
refAttributeName: selectedRelatedItem.attributeName,
|
|
40
|
+
} })) }) }) }) }) }) }));
|
|
41
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PageEntityForm = 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 PageEntityFormProvider_1 = require("@headless-adminapp/app/providers/PageEntityFormProvider");
|
|
8
|
+
const icons_1 = require("@headless-adminapp/icons");
|
|
9
|
+
const PageBroken_1 = require("../components/PageBroken");
|
|
10
|
+
const PageLoading_1 = require("../components/PageLoading");
|
|
11
|
+
const PageEntityFormDesktopContainer_1 = require("./PageEntityFormDesktopContainer");
|
|
12
|
+
const RecordSetNavigatorContainer_1 = require("./RecordSetNavigatorContainer");
|
|
13
|
+
const PageEntityForm = ({ logicalName, formId, recordId, }) => {
|
|
14
|
+
const result = (0, hooks_1.useLoadFormGridPage)(logicalName, formId);
|
|
15
|
+
if (result.loading) {
|
|
16
|
+
return (0, jsx_runtime_1.jsx)(PageLoading_1.PageLoading, {});
|
|
17
|
+
}
|
|
18
|
+
if (result.error) {
|
|
19
|
+
return ((0, jsx_runtime_1.jsx)(PageBroken_1.PageBroken, { Icon: icons_1.Icons.Error, title: result.title, message: result.message }));
|
|
20
|
+
}
|
|
21
|
+
const { schema, form, commands } = result;
|
|
22
|
+
return ((0, jsx_runtime_1.jsx)(PageEntityFormProvider_1.PageEntityFormProvider, { schema: schema, form: form, recordId: recordId, commands: commands, children: (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
23
|
+
display: 'flex',
|
|
24
|
+
flex: 1,
|
|
25
|
+
flexDirection: 'row',
|
|
26
|
+
backgroundColor: react_components_1.tokens.colorNeutralBackground2,
|
|
27
|
+
overflow: 'hidden',
|
|
28
|
+
}, children: [(0, jsx_runtime_1.jsx)(RecordSetNavigatorContainer_1.RecordSetNavigatorContainer, {}), (0, jsx_runtime_1.jsx)(PageEntityFormDesktopContainer_1.PageEntityFormDesktopContainer, {})] }) }));
|
|
29
|
+
};
|
|
30
|
+
exports.PageEntityForm = PageEntityForm;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PageEntityFormDesktopContainer = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_components_1 = require("@fluentui/react-components");
|
|
6
|
+
const builders_1 = require("@headless-adminapp/app/builders");
|
|
7
|
+
const dataform_1 = require("@headless-adminapp/app/dataform");
|
|
8
|
+
const hooks_1 = require("@headless-adminapp/app/dataform/hooks");
|
|
9
|
+
const locale_1 = require("@headless-adminapp/app/locale");
|
|
10
|
+
const mutable_1 = require("@headless-adminapp/app/mutable");
|
|
11
|
+
const utils_1 = require("@headless-adminapp/app/utils");
|
|
12
|
+
const react_1 = require("react");
|
|
13
|
+
const react_hook_form_1 = require("react-hook-form");
|
|
14
|
+
const PageBroken_1 = require("../components/PageBroken");
|
|
15
|
+
const PageLoading_1 = require("../components/PageLoading");
|
|
16
|
+
const FormBody_1 = require("../form/layout/FormBody");
|
|
17
|
+
const FormTab_1 = require("../form/layout/FormTab");
|
|
18
|
+
const CommandContainer_1 = require("./CommandContainer");
|
|
19
|
+
const FormTabRelated_1 = require("./FormTabRelated");
|
|
20
|
+
const PageEntityFormStringContext_1 = require("./PageEntityFormStringContext");
|
|
21
|
+
const RelatedViewSelector_1 = require("./RelatedViewSelector");
|
|
22
|
+
const SectionContainer_1 = require("./SectionContainer");
|
|
23
|
+
const PageEntityFormDesktopContainer = () => {
|
|
24
|
+
var _a, _b;
|
|
25
|
+
const dataState = (0, mutable_1.useContextSelector)(dataform_1.DataFormContext, (state) => state.dataState);
|
|
26
|
+
const strings = (0, PageEntityFormStringContext_1.usePageEntityFormStrings)();
|
|
27
|
+
const recordId = (0, hooks_1.useRecordId)();
|
|
28
|
+
const record = (0, mutable_1.useContextSelector)(dataform_1.DataFormContext, (state) => state.record);
|
|
29
|
+
const activeTab = (0, mutable_1.useContextSelector)(dataform_1.DataFormContext, (state) => state.activeTab);
|
|
30
|
+
const { language } = (0, locale_1.useLocale)();
|
|
31
|
+
const schema = (0, hooks_1.useDataFormSchema)();
|
|
32
|
+
const formConfig = (0, hooks_1.useSelectedForm)();
|
|
33
|
+
const setActiveTab = (0, mutable_1.useContextValueSetter)(dataform_1.DataFormContext, (setValue) => (value) => {
|
|
34
|
+
setValue((state) => (Object.assign(Object.assign({}, state), { activeTab: value })));
|
|
35
|
+
});
|
|
36
|
+
(0, react_1.useEffect)(() => {
|
|
37
|
+
setActiveTab('general');
|
|
38
|
+
}, [setActiveTab]);
|
|
39
|
+
const recordTitle = (0, hooks_1.useRecordTitle)();
|
|
40
|
+
// const readonly = useIsFormReadonly();
|
|
41
|
+
const formInstance = (0, hooks_1.useFormInstance)();
|
|
42
|
+
const isDirty = (0, hooks_1.useFormIsDirty)();
|
|
43
|
+
const notifications = (0, hooks_1.useFormNotifications)();
|
|
44
|
+
const [selectedRelatedItem, setSelectedRelatedItem] = (0, react_1.useState)(null);
|
|
45
|
+
if (dataState.isFetching) {
|
|
46
|
+
return (0, jsx_runtime_1.jsx)(PageLoading_1.PageLoading, {});
|
|
47
|
+
}
|
|
48
|
+
if (dataState.isError) {
|
|
49
|
+
return (0, jsx_runtime_1.jsx)(PageBroken_1.PageBroken, { title: "Error", message: "Unable to load page" });
|
|
50
|
+
}
|
|
51
|
+
if (recordId && !record) {
|
|
52
|
+
return ((0, jsx_runtime_1.jsx)(PageBroken_1.PageBroken, { title: "Record not found", message: "Requested record not found in system or you may not have enought permission." }));
|
|
53
|
+
}
|
|
54
|
+
// console.log('render');
|
|
55
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: {
|
|
56
|
+
display: 'flex',
|
|
57
|
+
flex: 1,
|
|
58
|
+
flexDirection: 'column',
|
|
59
|
+
// backgroundColor: tokens.colorNeutralBackground2,
|
|
60
|
+
overflow: 'hidden',
|
|
61
|
+
}, children: [(0, jsx_runtime_1.jsxs)("div", { style: {
|
|
62
|
+
display: 'flex',
|
|
63
|
+
flexDirection: 'column',
|
|
64
|
+
gap: react_components_1.tokens.spacingVerticalM,
|
|
65
|
+
paddingTop: react_components_1.tokens.spacingVerticalM,
|
|
66
|
+
paddingInline: react_components_1.tokens.spacingHorizontalM,
|
|
67
|
+
}, children: [(0, jsx_runtime_1.jsx)("div", { style: {
|
|
68
|
+
// padding: 4,
|
|
69
|
+
boxShadow: react_components_1.tokens.shadow2,
|
|
70
|
+
borderRadius: react_components_1.tokens.borderRadiusMedium,
|
|
71
|
+
background: react_components_1.tokens.colorNeutralBackground1,
|
|
72
|
+
display: 'flex',
|
|
73
|
+
// overflow: 'hidden',
|
|
74
|
+
}, children: (0, jsx_runtime_1.jsx)(CommandContainer_1.CommandContainer, {}) }), notifications.length > 0 && ((0, jsx_runtime_1.jsx)("div", { children: notifications.map((notification, index) => ((0, jsx_runtime_1.jsx)(react_components_1.MessageBar, { intent: notification.level, icon: null, children: (0, jsx_runtime_1.jsx)(react_components_1.MessageBarBody, { children: notification.message }) }, index))) })), (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
75
|
+
display: 'flex',
|
|
76
|
+
flexDirection: 'column',
|
|
77
|
+
boxShadow: react_components_1.tokens.shadow4,
|
|
78
|
+
borderRadius: react_components_1.tokens.borderRadiusMedium,
|
|
79
|
+
background: react_components_1.tokens.colorNeutralBackground1,
|
|
80
|
+
overflow: 'hidden',
|
|
81
|
+
zIndex: 2,
|
|
82
|
+
}, children: [(0, jsx_runtime_1.jsxs)("div", { style: {
|
|
83
|
+
display: 'flex',
|
|
84
|
+
flexDirection: 'row',
|
|
85
|
+
paddingInline: react_components_1.tokens.spacingHorizontalM,
|
|
86
|
+
paddingTop: react_components_1.tokens.spacingVerticalS,
|
|
87
|
+
marginBottom: react_components_1.tokens.spacingVerticalS,
|
|
88
|
+
}, children: [(0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'column', flex: 1 }, children: [(0, jsx_runtime_1.jsxs)("div", { style: {
|
|
89
|
+
display: 'flex',
|
|
90
|
+
gap: react_components_1.tokens.spacingHorizontalXS,
|
|
91
|
+
alignItems: 'center',
|
|
92
|
+
}, children: [(0, jsx_runtime_1.jsx)(react_components_1.Subtitle2, { children: recordTitle }), (0, jsx_runtime_1.jsx)(react_components_1.Caption1, { style: { color: react_components_1.tokens.colorNeutralForeground4 }, children: isDirty
|
|
93
|
+
? `- ${strings.unsaved}`
|
|
94
|
+
: !!record
|
|
95
|
+
? `- ${strings.saved}`
|
|
96
|
+
: '' })] }), (0, jsx_runtime_1.jsx)(react_components_1.Body1, { style: { color: react_components_1.tokens.colorNeutralForeground3 }, children: (0, builders_1.localizedLabel)(language, schema) })] }), (0, jsx_runtime_1.jsx)("div", { style: { display: 'flex', flexDirection: 'row' }, children: formConfig.experience.headerControls.map((controlName, index) => {
|
|
97
|
+
const attribute = schema.attributes[controlName];
|
|
98
|
+
return ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [index > 0 && ((0, jsx_runtime_1.jsx)(react_components_1.Divider, { vertical: true, style: {
|
|
99
|
+
width: react_components_1.tokens.spacingHorizontalXXL,
|
|
100
|
+
opacity: 0.5,
|
|
101
|
+
} })), (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 }) => {
|
|
102
|
+
return ((0, jsx_runtime_1.jsx)(react_components_1.Body1, { children: (0, utils_1.getAttributeFormattedValue)(attribute, field.value) }));
|
|
103
|
+
} })] })] }, controlName));
|
|
104
|
+
}) })] }), (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) => setActiveTab(value.value), children: [formConfig.experience.tabs.map((tab) => ((0, jsx_runtime_1.jsx)(react_components_1.Tab, { value: tab.name, children: (0, builders_1.localizedLabel)(language, tab) }, tab.name))), !!selectedRelatedItem && ((0, jsx_runtime_1.jsx)(react_components_1.Tab, { value: "related", children: (_b = (_a = selectedRelatedItem.localizedPluralLabels) === null || _a === void 0 ? void 0 : _a[language]) !== null && _b !== void 0 ? _b : selectedRelatedItem.pluralLabel }))] }), (0, jsx_runtime_1.jsx)(RelatedViewSelector_1.RelatedViewSelector, { onSelect: (item) => {
|
|
105
|
+
setSelectedRelatedItem(item);
|
|
106
|
+
setActiveTab('related');
|
|
107
|
+
} })] })] })] }), (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 })] })] }));
|
|
108
|
+
// return (
|
|
109
|
+
// <Fragment>
|
|
110
|
+
// <PageEntityViewDesktopFrame
|
|
111
|
+
// commandBar={<CommandContainer />}
|
|
112
|
+
// header={<GridHeaderContainer />}
|
|
113
|
+
// content={<GridTableContainer />}
|
|
114
|
+
// footer={<GridPaginationContainer />}
|
|
115
|
+
// />
|
|
116
|
+
// {/* <CustomizeColumnsContainer /> */}
|
|
117
|
+
// </Fragment>
|
|
118
|
+
// );
|
|
119
|
+
};
|
|
120
|
+
exports.PageEntityFormDesktopContainer = PageEntityFormDesktopContainer;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface PageEntityFormStringSet {
|
|
2
|
+
saved: string;
|
|
3
|
+
unsaved: string;
|
|
4
|
+
related: string;
|
|
5
|
+
}
|
|
6
|
+
export declare const defaultPageEntityFormStrings: PageEntityFormStringSet;
|
|
7
|
+
export declare const PageEntityFormStringContext: import("react").Context<PageEntityFormStringSet>;
|
|
8
|
+
export declare function usePageEntityFormStrings(): PageEntityFormStringSet;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PageEntityFormStringContext = exports.defaultPageEntityFormStrings = void 0;
|
|
4
|
+
exports.usePageEntityFormStrings = usePageEntityFormStrings;
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
exports.defaultPageEntityFormStrings = {
|
|
7
|
+
saved: 'Saved',
|
|
8
|
+
unsaved: 'Unsaved',
|
|
9
|
+
related: 'Related',
|
|
10
|
+
};
|
|
11
|
+
exports.PageEntityFormStringContext = (0, react_1.createContext)(exports.defaultPageEntityFormStrings);
|
|
12
|
+
function usePageEntityFormStrings() {
|
|
13
|
+
const context = (0, react_1.useContext)(exports.PageEntityFormStringContext);
|
|
14
|
+
return context;
|
|
15
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CardView } from '@headless-adminapp/core/experience/view';
|
|
2
|
+
import { InferredSchemaType, Schema, SchemaAttributes } from '@headless-adminapp/core/schema';
|
|
3
|
+
interface RecordCardProps<S extends SchemaAttributes = SchemaAttributes> {
|
|
4
|
+
schema: Schema<S>;
|
|
5
|
+
cardView: CardView<S>;
|
|
6
|
+
record: InferredSchemaType<S>;
|
|
7
|
+
selected?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare function RecordCard<S extends SchemaAttributes = SchemaAttributes>({ schema, cardView, record, selected, }: RecordCardProps<S>): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RecordCard = RecordCard;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_components_1 = require("@fluentui/react-components");
|
|
6
|
+
const utils_1 = require("@headless-adminapp/app/utils");
|
|
7
|
+
const useStyles = (0, react_components_1.makeStyles)({
|
|
8
|
+
root: {
|
|
9
|
+
width: '100%',
|
|
10
|
+
display: 'flex',
|
|
11
|
+
flexDirection: 'row',
|
|
12
|
+
paddingInline: react_components_1.tokens.spacingHorizontalL,
|
|
13
|
+
paddingBlock: react_components_1.tokens.spacingVerticalS,
|
|
14
|
+
gap: react_components_1.tokens.spacingHorizontalS,
|
|
15
|
+
// cursor: 'pointer',
|
|
16
|
+
// '&:hover': {
|
|
17
|
+
// background: tokens.colorNeutralBackground1Hover,
|
|
18
|
+
// },
|
|
19
|
+
// '&:active': {
|
|
20
|
+
// background: tokens.colorNeutralBackground1Pressed,
|
|
21
|
+
// },
|
|
22
|
+
},
|
|
23
|
+
// selected: {
|
|
24
|
+
// background: tokens.colorNeutralBackground1Selected,
|
|
25
|
+
// },
|
|
26
|
+
selected: {},
|
|
27
|
+
});
|
|
28
|
+
function createIntial(name) {
|
|
29
|
+
return name === null || name === void 0 ? void 0 : name.split(' ').map((x) => x[0]).slice(0, 2).join('').toUpperCase();
|
|
30
|
+
}
|
|
31
|
+
function RecordCard({ schema, cardView, record, selected, }) {
|
|
32
|
+
var _a, _b;
|
|
33
|
+
const styles = useStyles();
|
|
34
|
+
const _record = record;
|
|
35
|
+
const recordTitle = _record[schema.primaryAttribute];
|
|
36
|
+
const initials = createIntial(recordTitle);
|
|
37
|
+
let avatarSrc = '';
|
|
38
|
+
if (cardView.avatarColumn) {
|
|
39
|
+
const avatarAttribute = schema.attributes[cardView.avatarColumn];
|
|
40
|
+
if (avatarAttribute.type === 'attachment' &&
|
|
41
|
+
avatarAttribute.format === 'image') {
|
|
42
|
+
avatarSrc = _record[cardView.avatarColumn];
|
|
43
|
+
}
|
|
44
|
+
else if (avatarAttribute.type === 'string' &&
|
|
45
|
+
avatarAttribute.format === 'url') {
|
|
46
|
+
avatarSrc = _record[cardView.avatarColumn];
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: (0, react_components_1.mergeClasses)(styles.root, selected && styles.selected), children: [cardView.showAvatar && ((0, jsx_runtime_1.jsx)(react_components_1.Avatar, { initials: initials, color: "neutral", style: { cursor: 'pointer' }, image: {
|
|
50
|
+
src: avatarSrc,
|
|
51
|
+
} })), (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
52
|
+
display: 'flex',
|
|
53
|
+
flexDirection: 'column',
|
|
54
|
+
flex: 1,
|
|
55
|
+
}, children: [(0, jsx_runtime_1.jsx)(react_components_1.Body1, { children: _record[cardView.primaryColumn] }), (_a = cardView.secondaryColumns) === null || _a === void 0 ? void 0 : _a.map((column) => {
|
|
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: {
|
|
104
|
+
display: 'flex',
|
|
105
|
+
flexDirection: 'column',
|
|
106
|
+
alignItems: 'flex-end',
|
|
107
|
+
}, children: cardView.rightColumn.map((column) => {
|
|
108
|
+
const value = _record[column.name];
|
|
109
|
+
if (!value) {
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
const attribute = schema.attributes[column.name];
|
|
113
|
+
if (column.variant === 'choice') {
|
|
114
|
+
if (attribute.type === 'choice') {
|
|
115
|
+
const choice = attribute.options.find((option) => option.value === value);
|
|
116
|
+
if (!choice) {
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
return ((0, jsx_runtime_1.jsx)(react_components_1.Tag, { size: "extra-small", appearance: "filled", style: {
|
|
120
|
+
background: choice.color,
|
|
121
|
+
color: 'white',
|
|
122
|
+
height: 16,
|
|
123
|
+
display: 'flex',
|
|
124
|
+
alignItems: 'center',
|
|
125
|
+
justifyContent: 'center',
|
|
126
|
+
}, children: choice.label }, column.name));
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
if (column.variant === 'strong') {
|
|
130
|
+
return ((0, jsx_runtime_1.jsx)(react_components_1.Body1Strong, { children: (0, utils_1.getAttributeFormattedValue)(value, attribute) }, column.name));
|
|
131
|
+
}
|
|
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);
|
|
133
|
+
}) }))] }));
|
|
134
|
+
}
|