@headless-adminapp/fluent 1.4.21 → 1.4.22
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.js +1 -2
- package/App/LayoutProvider.js +3 -2
- package/Insights/charts/BarChart.js +1 -1
- package/Insights/charts/LineChart.js +1 -1
- package/Insights/charts/OhlcChart.js +1 -1
- package/PageEntityForm/SectionContainer.js +1 -1
- package/PageEntityForm/StandardControl.js +2 -2
- package/QuickCreateContainer/FormContainer.d.ts +8 -0
- package/QuickCreateContainer/FormContainer.js +50 -0
- package/QuickCreateContainer/QuickCreateContainer.d.ts +1 -0
- package/QuickCreateContainer/QuickCreateContainer.js +18 -0
- package/QuickCreateContainer/QuickCreateItemContent.d.ts +9 -0
- package/QuickCreateContainer/QuickCreateItemContent.js +28 -0
- package/QuickCreateContainer/QuickCreateTabContainer.d.ts +2 -0
- package/QuickCreateContainer/QuickCreateTabContainer.js +14 -0
- package/QuickCreateContainer/index.d.ts +1 -0
- package/QuickCreateContainer/index.js +5 -0
- package/QuickCreateContainer/useLoadQuickCreateFormInfo.d.ts +18 -0
- package/QuickCreateContainer/useLoadQuickCreateFormInfo.js +64 -0
- package/components/BodyLoading.js +2 -1
- package/components/DrawerFooter.js +2 -1
- package/form/controls/LookupControl.js +34 -13
- package/form/controls/SelectControl.d.ts +2 -1
- package/form/controls/SelectControl.js +2 -2
- package/package.json +2 -2
package/App/App.js
CHANGED
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.App = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const app_1 = require("@headless-adminapp/app/app");
|
|
6
5
|
const AppUI_1 = require("./AppUI");
|
|
7
6
|
const App = ({ children }) => {
|
|
8
|
-
return (
|
|
7
|
+
return (0, jsx_runtime_1.jsx)(AppUI_1.AppUI, { children: children });
|
|
9
8
|
};
|
|
10
9
|
exports.App = App;
|
package/App/LayoutProvider.js
CHANGED
|
@@ -6,12 +6,13 @@ const react_components_1 = require("@fluentui/react-components");
|
|
|
6
6
|
const LayoutProvider_1 = require("@headless-adminapp/app/app/LayoutProvider");
|
|
7
7
|
const DialogContainer_1 = require("../DialogContainer");
|
|
8
8
|
const ProgressIndicatorContainer_1 = require("../ProgressIndicatorContainer");
|
|
9
|
+
const QuickCreateContainer_1 = require("../QuickCreateContainer");
|
|
9
10
|
const ToastNotificationContainer_1 = require("../ToastNotificationContainer");
|
|
10
11
|
const LayoutProvider = ({ children, theme, ...rest }) => {
|
|
11
|
-
return ((0, jsx_runtime_1.jsx)(react_components_1.FluentProvider, { theme: theme ?? react_components_1.webLightTheme, children: (0, jsx_runtime_1.
|
|
12
|
+
return ((0, jsx_runtime_1.jsx)(react_components_1.FluentProvider, { theme: theme ?? react_components_1.webLightTheme, children: (0, jsx_runtime_1.jsxs)(LayoutProvider_1.LayoutProvider, { ...rest, containers: {
|
|
12
13
|
DialogContainer: DialogContainer_1.DialogContainer,
|
|
13
14
|
ProgressIndicatorContainer: ProgressIndicatorContainer_1.ProgressIndicatorContainer,
|
|
14
15
|
ToastNotificationContainer: ToastNotificationContainer_1.ToastNotificationContainer,
|
|
15
|
-
}, children: children }) }));
|
|
16
|
+
}, children: [children, (0, jsx_runtime_1.jsx)(QuickCreateContainer_1.QuickCreateContainer, {})] }) }));
|
|
16
17
|
};
|
|
17
18
|
exports.LayoutProvider = LayoutProvider;
|
|
@@ -15,7 +15,7 @@ function BarChart({ dataset, chartInfo, }) {
|
|
|
15
15
|
const bars = chartInfo.bars;
|
|
16
16
|
const xAxisFullFormatter = (0, formatters_1.createLongAxisFormatter)(locale, xAxis.tick);
|
|
17
17
|
const yAxisFullFormatter = (0, formatters_1.createLongAxisFormatter)(locale, yAxis.tick);
|
|
18
|
-
return ((0, jsx_runtime_1.jsx)(recharts_1.ResponsiveContainer, { width: "100%", height: "100%", children: (0, jsx_runtime_1.jsxs)(recharts_1.BarChart, { data: dataset[0], stackOffset: chartInfo.stackOffset, children: [(0, renderers_1.renderGrid)(), (0, renderers_1.renderYAxis)(locale, yAxis), (0, renderers_1.renderXAxis)(locale, xAxis), (0, renderers_1.renderBars)(bars, dataset), (0, jsx_runtime_1.jsx)(recharts_1.Tooltip, { cursor: {
|
|
18
|
+
return ((0, jsx_runtime_1.jsx)(recharts_1.ResponsiveContainer, { width: "100%", height: "100%", children: (0, jsx_runtime_1.jsxs)(recharts_1.BarChart, { data: dataset[0], stackOffset: chartInfo.stackOffset, children: [(0, renderers_1.renderGrid)(), (0, renderers_1.renderYAxis)(locale, yAxis), (0, renderers_1.renderXAxis)(locale, xAxis, dataset[0].length < 3), (0, renderers_1.renderBars)(bars, dataset), (0, jsx_runtime_1.jsx)(recharts_1.Tooltip, { cursor: {
|
|
19
19
|
fill: react_components_1.tokens.colorNeutralBackground6,
|
|
20
20
|
opacity: 0.2,
|
|
21
21
|
}, content: ({ active, payload, label }) => ((0, jsx_runtime_1.jsx)(CustomTooltipContent_1.CustomTooltipContent, { xAxisFormatter: xAxisFullFormatter, yAxisFormatter: yAxisFullFormatter, active: active, payload: payload, label: label })) })] }) }));
|
|
@@ -15,7 +15,7 @@ function LineChart({ dataset, chartInfo, }) {
|
|
|
15
15
|
const lines = chartInfo.lines;
|
|
16
16
|
const xAxisFullFormatter = (0, formatters_1.createLongAxisFormatter)(locale, xAxis.tick);
|
|
17
17
|
const yAxisFullFormatter = (0, formatters_1.createLongAxisFormatter)(locale, yAxis.tick);
|
|
18
|
-
return ((0, jsx_runtime_1.jsx)(recharts_1.ResponsiveContainer, { width: "100%", height: "100%", children: (0, jsx_runtime_1.jsxs)(recharts_1.LineChart, { data: dataset[0], children: [(0, renderers_1.renderGrid)(), (0, renderers_1.renderYAxis)(locale, yAxis), (0, renderers_1.renderXAxis)(locale, xAxis), (0, renderers_1.renderLines)(lines), (0, jsx_runtime_1.jsx)(recharts_1.Tooltip, { cursor: {
|
|
18
|
+
return ((0, jsx_runtime_1.jsx)(recharts_1.ResponsiveContainer, { width: "100%", height: "100%", children: (0, jsx_runtime_1.jsxs)(recharts_1.LineChart, { data: dataset[0], children: [(0, renderers_1.renderGrid)(), (0, renderers_1.renderYAxis)(locale, yAxis), (0, renderers_1.renderXAxis)(locale, xAxis, dataset[0].length < 3), (0, renderers_1.renderLines)(lines), (0, jsx_runtime_1.jsx)(recharts_1.Tooltip, { cursor: {
|
|
19
19
|
stroke: react_components_1.tokens.colorNeutralBackground6,
|
|
20
20
|
opacity: 0.5,
|
|
21
21
|
}, content: ({ active, payload, label }) => ((0, jsx_runtime_1.jsx)(CustomTooltipContent_1.CustomTooltipContent, { xAxisFormatter: xAxisFullFormatter, yAxisFormatter: yAxisFullFormatter, active: active, payload: payload, label: label })) })] }) }));
|
|
@@ -51,7 +51,7 @@ function OhlcChart({ dataset, chartInfo, }) {
|
|
|
51
51
|
return ((0, jsx_runtime_1.jsx)(recharts_1.ResponsiveContainer, { width: "100%", height: "100%", children: (0, jsx_runtime_1.jsxs)(recharts_1.ScatterChart, { data: data, children: [(0, renderers_1.renderGrid)(), (0, renderers_1.renderYAxis)(locale, {
|
|
52
52
|
...chartInfo.yAxis,
|
|
53
53
|
domain,
|
|
54
|
-
}), (0, jsx_runtime_1.jsx)(recharts_1.XAxis, { dataKey: xAxis.dataKey, name: xAxis.name, tickFormatter: xAxisFormatter, tickLine: false, minTickGap: 10, padding: "gap", axisLine: {
|
|
54
|
+
}), (0, jsx_runtime_1.jsx)(recharts_1.XAxis, { dataKey: xAxis.dataKey, name: xAxis.name, tickFormatter: xAxisFormatter, tickLine: false, minTickGap: 10, padding: "no-gap", axisLine: {
|
|
55
55
|
stroke: react_components_1.tokens.colorNeutralBackground6,
|
|
56
56
|
}, fontSize: react_components_1.tokens.fontSizeBase100, tick: {
|
|
57
57
|
fill: react_components_1.tokens.colorNeutralForeground1,
|
|
@@ -99,7 +99,7 @@ function SectionContainer({ section, skeleton, }) {
|
|
|
99
99
|
recordId,
|
|
100
100
|
attributeName: control.attributeName,
|
|
101
101
|
logicalName: schema.logicalName,
|
|
102
|
-
}, autoHeight: control.autoHeight, maxHeight: control.maxHeight, skeleton: skeleton }) }));
|
|
102
|
+
}, autoHeight: control.autoHeight, maxHeight: control.maxHeight, skeleton: skeleton, required: required }) }));
|
|
103
103
|
} }, control.attributeName) }, control.attributeName));
|
|
104
104
|
}
|
|
105
105
|
case 'editablegrid': {
|
|
@@ -44,7 +44,7 @@ const StandardControl = (props) => {
|
|
|
44
44
|
// hideLabel,
|
|
45
45
|
hidePlaceholder, readOnly,
|
|
46
46
|
// quickViewControl,
|
|
47
|
-
allowNavigation, allowNewRecord, autoHeight, maxHeight, skeleton, } = props;
|
|
47
|
+
allowNavigation, allowNewRecord, autoHeight, maxHeight, skeleton, required, } = props;
|
|
48
48
|
const isDisabled = readOnly;
|
|
49
49
|
const placeholder = hidePlaceholder
|
|
50
50
|
? undefined
|
|
@@ -192,7 +192,7 @@ const StandardControl = (props) => {
|
|
|
192
192
|
}
|
|
193
193
|
case 'choice': {
|
|
194
194
|
const Control = componentStore_1.componentStore.getComponent('Form.SelectControl') ?? SelectControl_1.default;
|
|
195
|
-
return ((0, jsx_runtime_1.jsx)(Control, { name: name, value: value, onChange: onChange, onBlur: onBlur, error: isError, disabled: isDisabled, options: attribute.options, placeholder: placeholder, borderOnFocusOnly: borderOnFocusOnly, readOnly: readOnly, skeleton: skeleton }));
|
|
195
|
+
return ((0, jsx_runtime_1.jsx)(Control, { name: name, value: value, onChange: onChange, onBlur: onBlur, error: isError, disabled: isDisabled, options: attribute.options, placeholder: placeholder, borderOnFocusOnly: borderOnFocusOnly, readOnly: readOnly, skeleton: skeleton, clearable: !required }));
|
|
196
196
|
}
|
|
197
197
|
case 'choices': {
|
|
198
198
|
const Control = componentStore_1.componentStore.getComponent('Form.MultiSelectControl') ?? MultiSelectControl_1.default;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { DataLookup, Id } from '@headless-adminapp/core/attributes';
|
|
2
|
+
import { FC } from 'react';
|
|
3
|
+
interface FormContainerProps {
|
|
4
|
+
onClose: () => void;
|
|
5
|
+
onCreate: (value: DataLookup<Id>) => void;
|
|
6
|
+
}
|
|
7
|
+
export declare const FormContainer: FC<FormContainerProps>;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FormContainer = 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 useFormDataState_1 = require("@headless-adminapp/app/dataform/hooks/useFormDataState");
|
|
8
|
+
const useMobileHeaderSetValue_1 = require("@headless-adminapp/app/header/hooks/useMobileHeaderSetValue");
|
|
9
|
+
const useFormSave_1 = require("@headless-adminapp/app/quickcreate/hooks/useFormSave");
|
|
10
|
+
const react_query_1 = require("@tanstack/react-query");
|
|
11
|
+
const react_1 = require("react");
|
|
12
|
+
const BodyLoading_1 = require("../components/BodyLoading");
|
|
13
|
+
const DrawerFooter_1 = require("../components/DrawerFooter");
|
|
14
|
+
const DrawerHeader_1 = require("../components/DrawerHeader");
|
|
15
|
+
const PageBroken_1 = require("../components/PageBroken");
|
|
16
|
+
const FormTab_1 = require("../form/layout/FormTab");
|
|
17
|
+
const SectionContainer_1 = require("../PageEntityForm/SectionContainer");
|
|
18
|
+
const QuickCreateTabContainer_1 = require("./QuickCreateTabContainer");
|
|
19
|
+
const FormContainer = ({ onClose, onCreate, }) => {
|
|
20
|
+
const dataState = (0, useFormDataState_1.useFormDataState)();
|
|
21
|
+
const schema = (0, hooks_1.useDataFormSchema)();
|
|
22
|
+
(0, useMobileHeaderSetValue_1.useMobileHeaderSetValue)(schema.label, 2, 'title');
|
|
23
|
+
const formConfig = (0, hooks_1.useSelectedForm)();
|
|
24
|
+
const notifications = (0, hooks_1.useFormNotifications)();
|
|
25
|
+
const saveForm = (0, useFormSave_1.useFormSave)();
|
|
26
|
+
const { mutate: save, isPending: isCreating } = (0, react_query_1.useMutation)({
|
|
27
|
+
mutationFn: saveForm,
|
|
28
|
+
onSuccess: (data) => {
|
|
29
|
+
if (data) {
|
|
30
|
+
onCreate(data);
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
if (!dataState.isFetching && dataState.isError) {
|
|
35
|
+
return (0, jsx_runtime_1.jsx)(PageBroken_1.PageBroken, { title: "Error", message: "Unable to load page" });
|
|
36
|
+
}
|
|
37
|
+
return ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(BodyLoading_1.BodyLoading, { loading: isCreating }), (0, jsx_runtime_1.jsx)(DrawerHeader_1.DrawerHeader, { title: `Quick Create - ${schema.label}`, showCloseButton: true, onClose: onClose, bottomContent: (0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(QuickCreateTabContainer_1.QuickCreateTabContainer, {}), notifications.length > 0 && ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
38
|
+
display: 'flex',
|
|
39
|
+
flexDirection: 'column',
|
|
40
|
+
gap: react_components_1.tokens.spacingVerticalS,
|
|
41
|
+
paddingInline: react_components_1.tokens.spacingHorizontalS,
|
|
42
|
+
paddingTop: react_components_1.tokens.spacingVerticalS,
|
|
43
|
+
}, 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.jsx)(react_components_1.DrawerBody, { style: {
|
|
44
|
+
display: 'flex',
|
|
45
|
+
flexDirection: 'column',
|
|
46
|
+
padding: react_components_1.tokens.spacingVerticalM,
|
|
47
|
+
// backgroundColor: tokens.colorNeutralBackground2,
|
|
48
|
+
}, 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, skeleton: dataState.isFetching }, section.name))) }, index))) }, tab.name))) }), (0, jsx_runtime_1.jsxs)(DrawerFooter_1.DrawerFooter, { children: [(0, jsx_runtime_1.jsx)(react_components_1.Button, { appearance: "primary", onClick: () => save(), children: isCreating ? ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_components_1.Spinner, { size: "extra-tiny", appearance: "inverted", style: { marginRight: 8 } }), "Creating..."] })) : ('Create') }), (0, jsx_runtime_1.jsx)(react_components_1.Button, { onClick: onClose, children: "Cancel" })] })] }));
|
|
49
|
+
};
|
|
50
|
+
exports.FormContainer = FormContainer;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const QuickCreateContainer: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.QuickCreateContainer = 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/quickcreate/hooks");
|
|
7
|
+
const QuickCreateItemContent_1 = require("./QuickCreateItemContent");
|
|
8
|
+
const QuickCreateContainer = () => {
|
|
9
|
+
const items = (0, hooks_1.useQuickCreateItems)();
|
|
10
|
+
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: items.map((item) => {
|
|
11
|
+
const { id, isOpen, ...options } = item;
|
|
12
|
+
return ((0, jsx_runtime_1.jsx)(QuickCreateItem, { logicalName: options.logicalName, onClose: () => options.onCancel?.(), onCreate: (value) => options.onCreate?.(value), isOpen: isOpen }, id));
|
|
13
|
+
}) }));
|
|
14
|
+
};
|
|
15
|
+
exports.QuickCreateContainer = QuickCreateContainer;
|
|
16
|
+
const QuickCreateItem = ({ isOpen, logicalName, onClose, onCreate, }) => {
|
|
17
|
+
return ((0, jsx_runtime_1.jsx)(react_components_1.Drawer, { separator: true, open: isOpen, position: "end", size: "medium", children: (0, jsx_runtime_1.jsx)(QuickCreateItemContent_1.QuickCreateItemContent, { logicalName: logicalName, onClose: onClose, onCreate: onCreate }) }));
|
|
18
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DataLookup, Id } from '@headless-adminapp/core/attributes';
|
|
2
|
+
import { FC } from 'react';
|
|
3
|
+
interface QuickCreateItemContentProps {
|
|
4
|
+
logicalName: string;
|
|
5
|
+
onClose: () => void;
|
|
6
|
+
onCreate: (value: DataLookup<Id>) => void;
|
|
7
|
+
}
|
|
8
|
+
export declare const QuickCreateItemContent: FC<QuickCreateItemContentProps>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.QuickCreateItemContent = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_components_1 = require("@fluentui/react-components");
|
|
6
|
+
const dataform_1 = require("@headless-adminapp/app/dataform");
|
|
7
|
+
const icons_1 = require("@headless-adminapp/icons");
|
|
8
|
+
const react_1 = require("react");
|
|
9
|
+
const BodyLoading_1 = require("../components/BodyLoading");
|
|
10
|
+
const DrawerHeader_1 = require("../components/DrawerHeader");
|
|
11
|
+
const PageBroken_1 = require("../components/PageBroken");
|
|
12
|
+
const FormContainer_1 = require("./FormContainer");
|
|
13
|
+
const useLoadQuickCreateFormInfo_1 = require("./useLoadQuickCreateFormInfo");
|
|
14
|
+
const QuickCreateItemContent = ({ logicalName, onClose, onCreate, }) => {
|
|
15
|
+
const result = (0, useLoadQuickCreateFormInfo_1.useLoadQuickCreateFormInfo)(logicalName, undefined);
|
|
16
|
+
if (result.loading) {
|
|
17
|
+
return ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(DrawerHeader_1.DrawerHeader, { title: "Quick Create", showCloseButton: true, onClose: onClose }), (0, jsx_runtime_1.jsx)(react_components_1.DrawerBody, { children: (0, jsx_runtime_1.jsx)(BodyLoading_1.BodyLoading, { loading: true }) })] }));
|
|
18
|
+
}
|
|
19
|
+
if (result.error) {
|
|
20
|
+
return ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(DrawerHeader_1.DrawerHeader, { title: "Quick Create", showCloseButton: true, onClose: onClose }), (0, jsx_runtime_1.jsx)(react_components_1.DrawerBody, { children: (0, jsx_runtime_1.jsx)(PageBroken_1.PageBroken, { Icon: icons_1.Icons.Error, title: result.title, message: result.message }) })] }));
|
|
21
|
+
}
|
|
22
|
+
const { schema, form, commands } = result;
|
|
23
|
+
if (schema.restrictions?.disableCreate) {
|
|
24
|
+
return ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(DrawerHeader_1.DrawerHeader, { title: `Quick Create - ${schema.label}`, showCloseButton: true, onClose: onClose }), (0, jsx_runtime_1.jsx)(react_components_1.DrawerBody, { children: (0, jsx_runtime_1.jsx)(PageBroken_1.PageBroken, { Icon: icons_1.Icons.Error, title: "Creating is disabled", message: "Creating records is disabled for this entity." }) })] }));
|
|
25
|
+
}
|
|
26
|
+
return ((0, jsx_runtime_1.jsx)(dataform_1.DataFormProvider, { schema: schema, form: form, commands: commands, children: (0, jsx_runtime_1.jsx)(FormContainer_1.FormContainer, { onClose: onClose, onCreate: onCreate }) }));
|
|
27
|
+
};
|
|
28
|
+
exports.QuickCreateItemContent = QuickCreateItemContent;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.QuickCreateTabContainer = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const dataform_1 = require("@headless-adminapp/app/dataform");
|
|
6
|
+
const TabContainer_1 = require("../PageEntityForm/TabContainer");
|
|
7
|
+
const QuickCreateTabContainer = () => {
|
|
8
|
+
const formConfig = (0, dataform_1.useSelectedForm)();
|
|
9
|
+
if (formConfig.experience.tabs.length < 2) {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
return (0, jsx_runtime_1.jsx)(TabContainer_1.TabContainer, {});
|
|
13
|
+
};
|
|
14
|
+
exports.QuickCreateTabContainer = QuickCreateTabContainer;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { QuickCreateContainer } from './QuickCreateContainer';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.QuickCreateContainer = void 0;
|
|
4
|
+
var QuickCreateContainer_1 = require("./QuickCreateContainer");
|
|
5
|
+
Object.defineProperty(exports, "QuickCreateContainer", { enumerable: true, get: function () { return QuickCreateContainer_1.QuickCreateContainer; } });
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { EntityMainFormCommandItemExperience, Form } from '@headless-adminapp/core/experience/form';
|
|
2
|
+
import { Schema } from '@headless-adminapp/core/schema';
|
|
3
|
+
type UseLoadMainFormPageResult = {
|
|
4
|
+
loading: true;
|
|
5
|
+
} | {
|
|
6
|
+
loading: false;
|
|
7
|
+
error: true;
|
|
8
|
+
title: string;
|
|
9
|
+
message: string;
|
|
10
|
+
} | {
|
|
11
|
+
loading: false;
|
|
12
|
+
error: false;
|
|
13
|
+
schema: Schema;
|
|
14
|
+
form: Form;
|
|
15
|
+
commands: EntityMainFormCommandItemExperience[][];
|
|
16
|
+
};
|
|
17
|
+
export declare function useLoadQuickCreateFormInfo(logicalName: string, formId: string | undefined): UseLoadMainFormPageResult;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useLoadQuickCreateFormInfo = useLoadQuickCreateFormInfo;
|
|
4
|
+
const metadata_1 = require("@headless-adminapp/app/metadata");
|
|
5
|
+
const react_query_1 = require("@tanstack/react-query");
|
|
6
|
+
function useLoadQuickCreateFormInfo(logicalName, formId) {
|
|
7
|
+
const schema = (0, metadata_1.useSchema)(logicalName);
|
|
8
|
+
const experienceStore = (0, metadata_1.useExperienceStore)();
|
|
9
|
+
const { data: form, isFetching: isFetchingForm } = (0, react_query_1.useQuery)({
|
|
10
|
+
queryKey: ['experience-schema-quick-create-form', logicalName, formId],
|
|
11
|
+
queryFn: async () => {
|
|
12
|
+
return experienceStore.getQuickCreateForm(logicalName, formId);
|
|
13
|
+
},
|
|
14
|
+
placeholderData: react_query_1.keepPreviousData,
|
|
15
|
+
});
|
|
16
|
+
const { data: commands } = (0, react_query_1.useQuery)({
|
|
17
|
+
queryKey: ['experience-schema-form-commands', logicalName],
|
|
18
|
+
queryFn: async () => {
|
|
19
|
+
return [];
|
|
20
|
+
},
|
|
21
|
+
initialData: [],
|
|
22
|
+
});
|
|
23
|
+
if (!schema) {
|
|
24
|
+
return {
|
|
25
|
+
loading: false,
|
|
26
|
+
error: true,
|
|
27
|
+
title: 'Schema not found',
|
|
28
|
+
message: `The schema "${logicalName}" was not found`,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
if (!form) {
|
|
32
|
+
if (isFetchingForm) {
|
|
33
|
+
return {
|
|
34
|
+
loading: true,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
loading: false,
|
|
39
|
+
error: true,
|
|
40
|
+
title: 'Form not found',
|
|
41
|
+
message: `The form was not found for "${logicalName}"`,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
if (form.logicalName !== schema.logicalName) {
|
|
45
|
+
if (isFetchingForm) {
|
|
46
|
+
return {
|
|
47
|
+
loading: true,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
loading: false,
|
|
52
|
+
error: true,
|
|
53
|
+
title: 'Form not found',
|
|
54
|
+
message: 'The form was not found (missmatch)',
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
loading: false,
|
|
59
|
+
error: false,
|
|
60
|
+
schema,
|
|
61
|
+
form,
|
|
62
|
+
commands,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
@@ -12,13 +12,14 @@ const BodyLoading = ({ loading }) => {
|
|
|
12
12
|
inset: 0,
|
|
13
13
|
backgroundColor: react_components_1.tokens.colorNeutralBackground1,
|
|
14
14
|
opacity: 0.7,
|
|
15
|
-
zIndex:
|
|
15
|
+
zIndex: 10,
|
|
16
16
|
} }), (0, jsx_runtime_1.jsx)("div", { style: {
|
|
17
17
|
position: 'absolute',
|
|
18
18
|
inset: 0,
|
|
19
19
|
display: 'flex',
|
|
20
20
|
alignItems: 'center',
|
|
21
21
|
justifyContent: 'center',
|
|
22
|
+
zIndex: 11,
|
|
22
23
|
}, children: (0, jsx_runtime_1.jsx)(react_components_1.Spinner, { size: "small" }) })] }));
|
|
23
24
|
};
|
|
24
25
|
exports.BodyLoading = BodyLoading;
|
|
@@ -6,9 +6,10 @@ const react_components_1 = require("@fluentui/react-components");
|
|
|
6
6
|
const DrawerFooter = ({ children, justify, }) => {
|
|
7
7
|
return ((0, jsx_runtime_1.jsx)(react_components_1.DrawerFooter, { style: {
|
|
8
8
|
padding: react_components_1.tokens.spacingHorizontalM,
|
|
9
|
-
gap: react_components_1.tokens.spacingHorizontalM,
|
|
10
9
|
background: react_components_1.tokens.colorNeutralBackground2,
|
|
10
|
+
gap: react_components_1.tokens.spacingHorizontalM,
|
|
11
11
|
justifyContent: justify,
|
|
12
|
+
paddingBottom: `max(env(safe-area-inset-bottom), ${react_components_1.tokens.spacingHorizontalM})`,
|
|
12
13
|
}, children: children }));
|
|
13
14
|
};
|
|
14
15
|
exports.DrawerFooter = DrawerFooter;
|
|
@@ -6,7 +6,8 @@ const react_components_1 = require("@fluentui/react-components");
|
|
|
6
6
|
const app_1 = require("@headless-adminapp/app/app");
|
|
7
7
|
const hooks_1 = require("@headless-adminapp/app/hooks");
|
|
8
8
|
const useRecentItemStore_1 = require("@headless-adminapp/app/metadata/hooks/useRecentItemStore");
|
|
9
|
-
const hooks_2 = require("@headless-adminapp/app/
|
|
9
|
+
const hooks_2 = require("@headless-adminapp/app/quickcreate/hooks");
|
|
10
|
+
const hooks_3 = require("@headless-adminapp/app/route/hooks");
|
|
10
11
|
const app_2 = require("@headless-adminapp/core/experience/app");
|
|
11
12
|
const icons_1 = require("@headless-adminapp/icons");
|
|
12
13
|
const react_1 = require("react");
|
|
@@ -34,13 +35,23 @@ const useStyles = (0, react_components_1.makeStyles)({
|
|
|
34
35
|
},
|
|
35
36
|
},
|
|
36
37
|
});
|
|
38
|
+
const recordToDataLookup = (value, schema) => {
|
|
39
|
+
return {
|
|
40
|
+
id: value[schema.idAttribute],
|
|
41
|
+
name: value[schema.primaryAttribute],
|
|
42
|
+
logicalName: schema.logicalName,
|
|
43
|
+
avatar: schema.avatarAttribute
|
|
44
|
+
? value[schema.avatarAttribute]
|
|
45
|
+
: undefined,
|
|
46
|
+
};
|
|
47
|
+
};
|
|
37
48
|
const LookupControlMd = ({ value, onChange, id, name, onBlur, onFocus, placeholder, disabled, autoFocus, readOnly, dataService, schema, viewId, allowNavigation, allowNewRecord, skeleton, }) => {
|
|
38
49
|
const [lookupEnabled, setLookupEnabled] = (0, react_1.useState)(false);
|
|
39
50
|
const [open, setOpen] = (0, react_1.useState)(false);
|
|
40
51
|
const [searchText, setSearchText] = (0, react_1.useState)('');
|
|
41
52
|
const { lookupStrings } = (0, AppStringContext_1.useAppStrings)();
|
|
42
|
-
const routeResolver = (0,
|
|
43
|
-
const router = (0,
|
|
53
|
+
const routeResolver = (0, hooks_3.useRouteResolver)();
|
|
54
|
+
const router = (0, hooks_3.useRouter)();
|
|
44
55
|
const recentItemStore = (0, useRecentItemStore_1.useRecentItemStore)();
|
|
45
56
|
const path = (0, react_1.useMemo)(() => {
|
|
46
57
|
if (!value) {
|
|
@@ -77,6 +88,8 @@ const LookupControlMd = ({ value, onChange, id, name, onBlur, onFocus, placehold
|
|
|
77
88
|
dataService,
|
|
78
89
|
enabled: lookupEnabled && !isViewLoading && !value && !readOnly && !disabled,
|
|
79
90
|
});
|
|
91
|
+
const isQuickCreateSupported = (0, hooks_2.useIsQuickCreateSupported)(schema.logicalName);
|
|
92
|
+
const openQuickCreate = (0, hooks_2.useOpenQuickCreate)();
|
|
80
93
|
(0, react_1.useEffect)(() => {
|
|
81
94
|
if (value) {
|
|
82
95
|
setSearchText(value.name);
|
|
@@ -91,11 +104,7 @@ const LookupControlMd = ({ value, onChange, id, name, onBlur, onFocus, placehold
|
|
|
91
104
|
return onChange?.(null);
|
|
92
105
|
}
|
|
93
106
|
else {
|
|
94
|
-
return onChange?.(
|
|
95
|
-
id: value[schema.idAttribute],
|
|
96
|
-
name: value[schema.primaryAttribute],
|
|
97
|
-
logicalName: schema.logicalName,
|
|
98
|
-
});
|
|
107
|
+
return onChange?.(recordToDataLookup(value, schema));
|
|
99
108
|
}
|
|
100
109
|
};
|
|
101
110
|
if (skeleton) {
|
|
@@ -115,14 +124,26 @@ const LookupControlMd = ({ value, onChange, id, name, onBlur, onFocus, placehold
|
|
|
115
124
|
recentItemStore.addItem((0, useLookupData_1.createLookupRecentKey)(schema.logicalName), _item[schema.idAttribute], _item[schema.idAttribute]);
|
|
116
125
|
}
|
|
117
126
|
handleChange(_item ?? null);
|
|
118
|
-
}, disableAutoFocus: true, onBlur: onBlur, onFocus: onFocus, id: id, autoFocus: autoFocus, children: [data?.records.map((item) => ((0, jsx_runtime_1.jsx)(react_components_1.Option, { value: item[schema.idAttribute], className: (0, react_components_1.mergeClasses)(styles.option), text: item[schema.primaryAttribute], children: view?.experience.card ? ((0, jsx_runtime_1.jsx)(RecordCard_1.RecordCard, { cardView: view.experience.card, record: item, schema: schema })) : item[schema.primaryAttribute] }, item[schema.idAttribute]))), !isLoading && !data?.records.length && ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
127
|
+
}, disableAutoFocus: true, onBlur: onBlur, onFocus: onFocus, id: id, autoFocus: autoFocus, autoCapitalize: "none", autoCorrect: "off", spellCheck: false, children: [data?.records.map((item) => ((0, jsx_runtime_1.jsx)(react_components_1.Option, { value: item[schema.idAttribute], className: (0, react_components_1.mergeClasses)(styles.option), text: item[schema.primaryAttribute], children: view?.experience.card ? ((0, jsx_runtime_1.jsx)(RecordCard_1.RecordCard, { cardView: view.experience.card, record: item, schema: schema })) : item[schema.primaryAttribute] }, item[schema.idAttribute]))), !isLoading && !data?.records.length && ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
119
128
|
paddingInline: react_components_1.tokens.spacingHorizontalL,
|
|
120
129
|
paddingBlock: react_components_1.tokens.spacingVerticalS,
|
|
121
130
|
}, children: (0, jsx_runtime_1.jsx)(react_components_1.Body1, { children: lookupStrings.noRecordsFound }) })), allowNewRecord && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_components_1.Divider, {}), (0, jsx_runtime_1.jsx)("div", { style: { marginTop: react_components_1.tokens.spacingVerticalXXS }, children: (0, jsx_runtime_1.jsx)(react_components_1.ToolbarButton, { style: { fontWeight: 'normal' }, icon: (0, jsx_runtime_1.jsx)(icons_1.Icons.Add, {}), onClick: async () => {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
131
|
+
if (isQuickCreateSupported) {
|
|
132
|
+
const result = await openQuickCreate({
|
|
133
|
+
logicalName: schema.logicalName,
|
|
134
|
+
});
|
|
135
|
+
if (result) {
|
|
136
|
+
setSearchText('');
|
|
137
|
+
onChange?.(result);
|
|
138
|
+
recentItemStore.addItem((0, useLookupData_1.createLookupRecentKey)(schema.logicalName), result.id, result.id);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
await router.push(routeResolver({
|
|
143
|
+
logicalName: schema.logicalName,
|
|
144
|
+
type: app_2.PageType.EntityForm,
|
|
145
|
+
}));
|
|
146
|
+
}
|
|
126
147
|
}, children: lookupStrings.newRecord }) })] }))] }), !!value && ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
127
148
|
position: 'absolute',
|
|
128
149
|
inset: 0,
|
|
@@ -5,5 +5,6 @@ export interface Lookup<T = string> {
|
|
|
5
5
|
}
|
|
6
6
|
export interface SelectControlProps<T> extends ControlProps<T> {
|
|
7
7
|
options: Lookup<T>[];
|
|
8
|
+
clearable?: boolean;
|
|
8
9
|
}
|
|
9
|
-
export default function SelectControl<T extends string | number>({ value, onChange, options, id, name, disabled, onBlur, onFocus, placeholder, skeleton, }: Readonly<SelectControlProps<T>>): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export default function SelectControl<T extends string | number>({ value, onChange, options, id, name, disabled, onBlur, onFocus, placeholder, skeleton, clearable, }: Readonly<SelectControlProps<T>>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -5,7 +5,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
5
5
|
const react_components_1 = require("@fluentui/react-components");
|
|
6
6
|
const react_1 = require("react");
|
|
7
7
|
const SkeletonControl_1 = require("./SkeletonControl");
|
|
8
|
-
function SelectControl({ value, onChange, options, id, name, disabled, onBlur, onFocus, placeholder, skeleton, }) {
|
|
8
|
+
function SelectControl({ value, onChange, options, id, name, disabled, onBlur, onFocus, placeholder, skeleton, clearable, }) {
|
|
9
9
|
const transformedOptions = (0, react_1.useMemo)(() => options.map((x) => ({ label: x.label, value: String(x.value) })), [options]);
|
|
10
10
|
const handleChange = (value) => {
|
|
11
11
|
const option = options.find((x) => String(x.value) === value);
|
|
@@ -30,5 +30,5 @@ function SelectControl({ value, onChange, options, id, name, disabled, onBlur, o
|
|
|
30
30
|
pointerEvents: disabled ? 'none' : undefined,
|
|
31
31
|
width: '100%',
|
|
32
32
|
minWidth: 'unset',
|
|
33
|
-
}, children: transformedOptions.map((x) => ((0, jsx_runtime_1.jsx)(react_components_1.Option, { value: x.value, children: x.label }, x.value))) }));
|
|
33
|
+
}, clearable: clearable, children: transformedOptions.map((x) => ((0, jsx_runtime_1.jsx)(react_components_1.Option, { value: x.value, children: x.label }, x.value))) }));
|
|
34
34
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@headless-adminapp/fluent",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.22",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"uuid": "11.0.3",
|
|
52
52
|
"yup": "^1.4.0"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "8f687a2b8c3151c30c57f43105ac47c5d8c3ee79"
|
|
55
55
|
}
|