@headless-adminapp/fluent 1.1.3 → 1.1.6
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/DataGrid/TableCell/TableCellChoice.js +2 -30
- package/DataGrid/useTableColumns.js +41 -2
- package/PageEntityForm/PageEntityForm.js +8 -0
- package/PageEntityForm/SectionContainer.d.ts +2 -2
- package/PageEntityForm/SectionContainer.js +16 -2
- package/PageEntityForm/StandardControl.js +10 -0
- package/components/ChoiceBadge.d.ts +9 -0
- package/components/ChoiceBadge.js +29 -0
- package/components/LoginForm.d.ts +8 -0
- package/components/LoginForm.js +4 -4
- package/components/PageLogin.d.ts +5 -0
- package/components/PageLogin.js +2 -1
- package/form/controls/RegardingControl.d.ts +25 -0
- package/form/controls/RegardingControl.js +202 -0
- package/form/controls/SelectControl.d.ts +1 -1
- package/form/controls/SelectControl.js +1 -3
- package/form/controls/TimeControl.d.ts +4 -0
- package/form/controls/TimeControl.js +89 -0
- package/form/controls/useLookupData.d.ts +12 -2
- package/form/controls/useLookupData.js +71 -20
- package/package.json +2 -2
- package/App/NavigationContainer.d.ts +0 -10
- package/App/NavigationContainer.js +0 -68
- package/App/utils.d.ts +0 -14
- package/App/utils.js +0 -26
- package/Insights/CommandBarContainer.d.ts +0 -1
- package/Insights/CommandBarContainer.js +0 -18
- package/Insights/FilterBarContainer.d.ts +0 -1
- package/Insights/FilterBarContainer.js +0 -99
- package/Insights/hooks/useQueriesData.d.ts +0 -7
- package/Insights/hooks/useQueriesData.js +0 -89
- package/Insights/hooks/useWidgetDetail.d.ts +0 -10
- package/Insights/hooks/useWidgetDetail.js +0 -39
- package/PageCalendar/baseEventAttributes.d.ts +0 -35
- package/PageCalendar/baseEventAttributes.js +0 -38
- package/PageCalendar/context.d.ts +0 -20
- package/PageCalendar/context.js +0 -5
- package/PageCalendar/hooks/index.d.ts +0 -1
- package/PageCalendar/hooks/index.js +0 -17
- package/PageCalendar/hooks/useConfig.d.ts +0 -3
- package/PageCalendar/hooks/useConfig.js +0 -8
- package/PageInsights/PageInsights.d.ts +0 -7
- package/PageInsights/PageInsights.js +0 -31
- package/PageInsights/index.d.ts +0 -1
- package/PageInsights/index.js +0 -5
|
@@ -0,0 +1,89 @@
|
|
|
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.TimeControl = TimeControl;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const react_components_1 = require("@fluentui/react-components");
|
|
9
|
+
const react_timepicker_compat_1 = require("@fluentui/react-timepicker-compat");
|
|
10
|
+
const locale_1 = require("@headless-adminapp/app/locale");
|
|
11
|
+
const icons_1 = require("@headless-adminapp/icons");
|
|
12
|
+
const dayjs_1 = __importDefault(require("dayjs"));
|
|
13
|
+
const customParseFormat_1 = __importDefault(require("dayjs/plugin/customParseFormat"));
|
|
14
|
+
const react_1 = require("react");
|
|
15
|
+
dayjs_1.default.extend(customParseFormat_1.default);
|
|
16
|
+
function TimeControl({ value, onChange, id, name, onBlur, placeholder, disabled, readOnly, }) {
|
|
17
|
+
const { timeFormats: { short: timeFormat }, timezone, } = (0, locale_1.useLocale)();
|
|
18
|
+
const [internalTimeValue, setInternalTimeValue] = (0, react_1.useState)(value ? (0, dayjs_1.default)().startOf('day').add(value, 'minutes').format(timeFormat) : '');
|
|
19
|
+
const internalTimeValueRef = (0, react_1.useRef)(internalTimeValue);
|
|
20
|
+
internalTimeValueRef.current = internalTimeValue;
|
|
21
|
+
(0, react_1.useEffect)(() => {
|
|
22
|
+
const updatedValue = typeof value === 'number'
|
|
23
|
+
? (0, dayjs_1.default)().startOf('day').add(value, 'minutes').format(timeFormat)
|
|
24
|
+
: '';
|
|
25
|
+
if (internalTimeValueRef.current !== updatedValue) {
|
|
26
|
+
setInternalTimeValue(updatedValue);
|
|
27
|
+
}
|
|
28
|
+
}, [value, timezone, timeFormat]);
|
|
29
|
+
const isReadonly = readOnly || disabled;
|
|
30
|
+
const selectedTime = (0, react_1.useMemo)(() => {
|
|
31
|
+
if (typeof value !== 'number') {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
return (0, dayjs_1.default)().startOf('day').add(value, 'minutes').toDate();
|
|
35
|
+
}, [value]);
|
|
36
|
+
console.log('TimeControl', value, selectedTime);
|
|
37
|
+
return ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
38
|
+
display: 'flex',
|
|
39
|
+
alignItems: 'center',
|
|
40
|
+
gap: react_components_1.tokens.spacingHorizontalS,
|
|
41
|
+
}, children: (0, jsx_runtime_1.jsx)(react_timepicker_compat_1.TimePicker, { appearance: "filled-darker", style: {
|
|
42
|
+
flex: 1,
|
|
43
|
+
minWidth: 0,
|
|
44
|
+
pointerEvents: isReadonly ? 'none' : 'auto',
|
|
45
|
+
}, placeholder: placeholder, id: id, name: name, input: {
|
|
46
|
+
style: { minWidth: 0 },
|
|
47
|
+
}, readOnly: isReadonly, selectedTime: selectedTime, freeform: true, value: internalTimeValue, onTimeChange: (_, data) => {
|
|
48
|
+
console.log('onTimeChange', data);
|
|
49
|
+
if (data.selectedTime) {
|
|
50
|
+
onChange?.((0, dayjs_1.default)(data.selectedTime).diff((0, dayjs_1.default)().startOf('day'), 'minutes'));
|
|
51
|
+
}
|
|
52
|
+
else if (data.selectedTimeText) {
|
|
53
|
+
let resolvedTime = resolveTimeValue(data.selectedTimeText, timeFormat);
|
|
54
|
+
if (!resolvedTime) {
|
|
55
|
+
setInternalTimeValue(value ? (0, dayjs_1.default)(value).format(timeFormat) : '');
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const newValue = (0, dayjs_1.default)(resolvedTime).diff((0, dayjs_1.default)().startOf('day'), 'minutes');
|
|
59
|
+
if (newValue !== value) {
|
|
60
|
+
onChange?.(newValue);
|
|
61
|
+
}
|
|
62
|
+
setInternalTimeValue((0, dayjs_1.default)(resolvedTime).format(timeFormat));
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
setInternalTimeValue('');
|
|
66
|
+
onChange?.(null);
|
|
67
|
+
}
|
|
68
|
+
}, onInput: (e) => {
|
|
69
|
+
setInternalTimeValue(e.currentTarget.value);
|
|
70
|
+
}, onBlur: () => {
|
|
71
|
+
onBlur?.();
|
|
72
|
+
}, expandIcon: (0, jsx_runtime_1.jsx)("div", { style: {
|
|
73
|
+
display: 'flex',
|
|
74
|
+
alignItems: 'center',
|
|
75
|
+
justifyContent: 'center',
|
|
76
|
+
marginRight: -4,
|
|
77
|
+
color: react_components_1.tokens.colorNeutralForeground2,
|
|
78
|
+
}, children: (0, jsx_runtime_1.jsx)(icons_1.Icons.Clock, { size: 20 }) }) }) }));
|
|
79
|
+
}
|
|
80
|
+
function resolveTimeValue(value, timeFormat) {
|
|
81
|
+
if (!value) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
const time = (0, dayjs_1.default)(value, timeFormat);
|
|
85
|
+
if (!time.isValid()) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
return time.toDate();
|
|
89
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ViewExperience } from '@headless-adminapp/core/experience/view';
|
|
2
2
|
import { InferredSchemaType, Schema, SchemaAttributes } from '@headless-adminapp/core/schema';
|
|
3
|
-
import { IDataService } from '@headless-adminapp/core/transport';
|
|
3
|
+
import { IDataService, RetriveRecordsResult } from '@headless-adminapp/core/transport';
|
|
4
4
|
interface UseLookupDataOptions {
|
|
5
5
|
dataService: IDataService;
|
|
6
6
|
searchText?: string;
|
|
@@ -9,9 +9,19 @@ interface UseLookupDataOptions {
|
|
|
9
9
|
enabled?: boolean;
|
|
10
10
|
}
|
|
11
11
|
export declare function useLookupData<S extends SchemaAttributes = SchemaAttributes>({ schema, view, searchText, dataService, enabled, }: UseLookupDataOptions): {
|
|
12
|
-
data:
|
|
12
|
+
data: RetriveRecordsResult<InferredSchemaType<S>> | undefined;
|
|
13
13
|
isLoading: boolean;
|
|
14
14
|
};
|
|
15
|
+
interface UseLookupsDataOptions {
|
|
16
|
+
dataService: IDataService;
|
|
17
|
+
searchText?: string;
|
|
18
|
+
enabled?: boolean;
|
|
19
|
+
items: Array<{
|
|
20
|
+
schema: Schema;
|
|
21
|
+
view: ViewExperience | null | undefined;
|
|
22
|
+
}>;
|
|
23
|
+
}
|
|
24
|
+
export declare function useLookupDatas<T = unknown>({ dataService, searchText, enabled, items, }: UseLookupsDataOptions): import("@tanstack/react-query").UseQueryResult[];
|
|
15
25
|
export declare function useGetLookupView(logicalName: string, viewId?: string): {
|
|
16
26
|
isLoading: boolean;
|
|
17
27
|
view: import("@headless-adminapp/core/experience/view").View<SchemaAttributes> | undefined;
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useLookupData = useLookupData;
|
|
4
|
+
exports.useLookupDatas = useLookupDatas;
|
|
4
5
|
exports.useGetLookupView = useGetLookupView;
|
|
5
6
|
const hooks_1 = require("@headless-adminapp/app/hooks");
|
|
6
7
|
const hooks_2 = require("@headless-adminapp/app/metadata/hooks");
|
|
7
8
|
const react_query_1 = require("@tanstack/react-query");
|
|
8
9
|
const react_1 = require("react");
|
|
9
|
-
function
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const expand = (0, react_1.useMemo)(() => (view?.card?.secondaryColumns || [])
|
|
10
|
+
function extractColumns(schema, view) {
|
|
11
|
+
if (!view?.card) {
|
|
12
|
+
return [schema.primaryAttribute];
|
|
13
|
+
}
|
|
14
|
+
return Array.from(new Set([
|
|
15
|
+
view.card.primaryColumn,
|
|
16
|
+
view.card.avatarColumn,
|
|
17
|
+
...(view.card.secondaryColumns ?? [])
|
|
18
|
+
.filter((x) => !x.expandedKey)
|
|
19
|
+
.map((x) => x.name),
|
|
20
|
+
])).filter(Boolean);
|
|
21
|
+
}
|
|
22
|
+
function extractExpand(view) {
|
|
23
|
+
return (view?.card?.secondaryColumns || [])
|
|
24
24
|
.filter((x) => x.expandedKey)
|
|
25
25
|
.reduce((acc, x) => {
|
|
26
26
|
if (!acc[x.name]) {
|
|
@@ -30,17 +30,31 @@ function useLookupData({ schema, view, searchText, dataService, enabled, }) {
|
|
|
30
30
|
acc[x.name].push(x.expandedKey);
|
|
31
31
|
}
|
|
32
32
|
return acc;
|
|
33
|
-
}, {})
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
}, {});
|
|
34
|
+
}
|
|
35
|
+
function getKey({ schema, view, columns, expand, search, }) {
|
|
36
|
+
return [
|
|
37
|
+
columns,
|
|
38
|
+
expand,
|
|
37
39
|
schema.logicalName,
|
|
38
40
|
search,
|
|
39
41
|
view?.filter,
|
|
40
42
|
view?.defaultSorting,
|
|
43
|
+
];
|
|
44
|
+
}
|
|
45
|
+
function useLookupData({ schema, view, searchText, dataService, enabled, }) {
|
|
46
|
+
const [search] = (0, hooks_1.useDebouncedValue)(searchText, 500);
|
|
47
|
+
const columns = (0, react_1.useMemo)(() => {
|
|
48
|
+
return extractColumns(schema, view);
|
|
49
|
+
}, [schema, view]);
|
|
50
|
+
const expand = (0, react_1.useMemo)(() => extractExpand(view), [view?.card?.secondaryColumns]);
|
|
51
|
+
const queryKey = (0, react_1.useMemo)(() => getKey({
|
|
41
52
|
columns,
|
|
42
53
|
expand,
|
|
43
|
-
|
|
54
|
+
schema,
|
|
55
|
+
search,
|
|
56
|
+
view,
|
|
57
|
+
}), [
|
|
44
58
|
columns,
|
|
45
59
|
expand,
|
|
46
60
|
schema.logicalName,
|
|
@@ -71,6 +85,43 @@ function useLookupData({ schema, view, searchText, dataService, enabled, }) {
|
|
|
71
85
|
isLoading: isFetching,
|
|
72
86
|
};
|
|
73
87
|
}
|
|
88
|
+
function useLookupDatas({ dataService, searchText, enabled, items, }) {
|
|
89
|
+
const [search] = (0, hooks_1.useDebouncedValue)(searchText, 500);
|
|
90
|
+
const queries = (0, react_1.useMemo)(() => {
|
|
91
|
+
return items.map((item) => {
|
|
92
|
+
const columns = extractColumns(item.schema, item.view);
|
|
93
|
+
const expand = extractExpand(item.view);
|
|
94
|
+
const queryKey = getKey({
|
|
95
|
+
schema: item.schema,
|
|
96
|
+
view: item.view,
|
|
97
|
+
columns,
|
|
98
|
+
expand,
|
|
99
|
+
search,
|
|
100
|
+
});
|
|
101
|
+
return {
|
|
102
|
+
queryKey: queryKey,
|
|
103
|
+
queryFn: async () => {
|
|
104
|
+
const result = await dataService.retriveRecords({
|
|
105
|
+
logicalName: item.schema.logicalName,
|
|
106
|
+
search,
|
|
107
|
+
columns,
|
|
108
|
+
expand,
|
|
109
|
+
filter: item.view?.filter ?? null,
|
|
110
|
+
skip: 0,
|
|
111
|
+
limit: 5,
|
|
112
|
+
sort: item.view?.defaultSorting,
|
|
113
|
+
});
|
|
114
|
+
return result;
|
|
115
|
+
},
|
|
116
|
+
placeholderData: react_query_1.keepPreviousData,
|
|
117
|
+
enabled: !!item.view && (enabled ?? false),
|
|
118
|
+
};
|
|
119
|
+
});
|
|
120
|
+
}, [items, search, dataService, enabled]);
|
|
121
|
+
return (0, react_query_1.useQueries)({
|
|
122
|
+
queries,
|
|
123
|
+
});
|
|
124
|
+
}
|
|
74
125
|
function useGetLookupView(logicalName, viewId) {
|
|
75
126
|
const { experienceStore } = (0, hooks_2.useMetadata)();
|
|
76
127
|
const { isPending, data, error } = (0, react_query_1.useQuery)({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@headless-adminapp/fluent",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.6",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -50,5 +50,5 @@
|
|
|
50
50
|
"uuid": "11.0.3",
|
|
51
51
|
"yup": "^1.4.0"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "23ea276caca4d792a5229dc2e1323f6888eb1424"
|
|
54
54
|
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { DrawerProps } from '@fluentui/react-components';
|
|
2
|
-
import { FC } from 'react';
|
|
3
|
-
type DrawerType = Required<DrawerProps>['type'];
|
|
4
|
-
interface NavigationContainerProps {
|
|
5
|
-
open: boolean;
|
|
6
|
-
type: DrawerType;
|
|
7
|
-
onOpenChange: (open: boolean) => void;
|
|
8
|
-
}
|
|
9
|
-
export declare const NavigationContainer: FC<NavigationContainerProps>;
|
|
10
|
-
export {};
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NavigationContainer = void 0;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const react_components_1 = require("@fluentui/react-components");
|
|
6
|
-
const react_nav_preview_1 = require("@fluentui/react-nav-preview");
|
|
7
|
-
const app_1 = require("@headless-adminapp/app/app");
|
|
8
|
-
const locale_1 = require("@headless-adminapp/app/locale");
|
|
9
|
-
const hooks_1 = require("@headless-adminapp/app/route/hooks");
|
|
10
|
-
const icons_1 = require("@headless-adminapp/icons");
|
|
11
|
-
const react_1 = require("react");
|
|
12
|
-
const utils_1 = require("./utils");
|
|
13
|
-
const useStyles = (0, react_components_1.makeStyles)({
|
|
14
|
-
root: {
|
|
15
|
-
overflow: 'hidden',
|
|
16
|
-
display: 'flex',
|
|
17
|
-
flexShrink: 0,
|
|
18
|
-
boxShadow: react_components_1.tokens.shadow4,
|
|
19
|
-
zIndex: 1,
|
|
20
|
-
},
|
|
21
|
-
content: {
|
|
22
|
-
flex: '1',
|
|
23
|
-
padding: '16px',
|
|
24
|
-
display: 'grid',
|
|
25
|
-
justifyContent: 'flex-start',
|
|
26
|
-
alignItems: 'flex-start',
|
|
27
|
-
},
|
|
28
|
-
field: {
|
|
29
|
-
display: 'flex',
|
|
30
|
-
marginTop: '4px',
|
|
31
|
-
marginLeft: '8px',
|
|
32
|
-
flexDirection: 'column',
|
|
33
|
-
gridRowGap: react_components_1.tokens.spacingVerticalS,
|
|
34
|
-
},
|
|
35
|
-
});
|
|
36
|
-
const NavigationContainer = ({ open, type, onOpenChange, }) => {
|
|
37
|
-
const styles = useStyles();
|
|
38
|
-
const { appExperience: app } = (0, app_1.useAppContext)();
|
|
39
|
-
return ((0, jsx_runtime_1.jsx)("div", { className: styles.root, children: (0, jsx_runtime_1.jsx)(react_nav_preview_1.NavDrawer, { selectedValue: "active", open: open, type: type, onOpenChange: (value, data) => onOpenChange(data.open), children: (0, jsx_runtime_1.jsx)(react_nav_preview_1.NavDrawerBody, { style: {
|
|
40
|
-
paddingTop: 8,
|
|
41
|
-
// borderRight: `1px solid ${tokens.colorNeutralStroke1}`,
|
|
42
|
-
}, children: app.navItems.map((area) => ((0, jsx_runtime_1.jsx)(react_1.Fragment, { children: area.groups.map((group) => ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [!group.hideLabel && ((0, jsx_runtime_1.jsx)(react_nav_preview_1.NavSectionHeader, { children: group.label })), group.items.map((item, index) => ((0, jsx_runtime_1.jsx)(Test, { item: item, drawerType: type, onOpenChange: onOpenChange }, (item.label ?? '') + String(index))))] }, group.label))) }, area.label))) }) }) }));
|
|
43
|
-
};
|
|
44
|
-
exports.NavigationContainer = NavigationContainer;
|
|
45
|
-
const Test = ({ item, onOpenChange, drawerType }) => {
|
|
46
|
-
const { schemaMetadataDic } = (0, app_1.useAppContext)();
|
|
47
|
-
const router = (0, hooks_1.useRouter)();
|
|
48
|
-
const pathname = (0, hooks_1.usePathname)();
|
|
49
|
-
const selectedPath = pathname;
|
|
50
|
-
const { language } = (0, locale_1.useLocale)();
|
|
51
|
-
const isRouteActive = (0, hooks_1.useIsRouteActive)();
|
|
52
|
-
const routeResolver = (0, hooks_1.useRouteResolver)();
|
|
53
|
-
const navItem = (0, utils_1.transformNavPageItem)({
|
|
54
|
-
item,
|
|
55
|
-
schemaMetadataDic: schemaMetadataDic,
|
|
56
|
-
language,
|
|
57
|
-
routeResolver,
|
|
58
|
-
});
|
|
59
|
-
const Icon = navItem.icon ?? icons_1.Icons.Entity ?? icons_1.IconPlaceholder;
|
|
60
|
-
const isActive = isRouteActive(selectedPath, item);
|
|
61
|
-
return ((0, jsx_runtime_1.jsx)(react_nav_preview_1.NavItem, { href: navItem.link, onClick: (event) => {
|
|
62
|
-
if (drawerType === 'overlay') {
|
|
63
|
-
onOpenChange(false);
|
|
64
|
-
}
|
|
65
|
-
event.preventDefault();
|
|
66
|
-
router.push(navItem.link);
|
|
67
|
-
}, icon: (0, jsx_runtime_1.jsx)(Icon, { size: 20, filled: isActive, color: isActive ? 'var(--colorNeutralForeground2BrandSelected)' : undefined }), value: isActive ? 'active' : '', children: navItem.label }));
|
|
68
|
-
};
|
package/App/utils.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { InternalRouteResolver } from '@headless-adminapp/app/route/context';
|
|
2
|
-
import { NavPageItem } from '@headless-adminapp/core/experience/app';
|
|
3
|
-
import { SchemaExperienceMetadata } from '@headless-adminapp/core/experience/schema';
|
|
4
|
-
export declare function transformNavPageItem({ item, schemaMetadataDic: schemaMetadataObject, language, routeResolver, }: {
|
|
5
|
-
item: NavPageItem;
|
|
6
|
-
schemaMetadataDic: Record<string, SchemaExperienceMetadata>;
|
|
7
|
-
language: string;
|
|
8
|
-
routeResolver: InternalRouteResolver;
|
|
9
|
-
}): {
|
|
10
|
-
label: string | undefined;
|
|
11
|
-
icon: import("@headless-adminapp/icons").Icon | undefined;
|
|
12
|
-
link: string;
|
|
13
|
-
isExternal: boolean;
|
|
14
|
-
};
|
package/App/utils.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.transformNavPageItem = transformNavPageItem;
|
|
4
|
-
function transformNavPageItem({ item, schemaMetadataDic: schemaMetadataObject, language, routeResolver, }) {
|
|
5
|
-
let icon = item.icon;
|
|
6
|
-
let label = item.localizedLabel?.[language] ?? item.label;
|
|
7
|
-
let link = routeResolver(item);
|
|
8
|
-
if (item.type === 'entityview') {
|
|
9
|
-
const metadata = schemaMetadataObject?.[item.logicalName];
|
|
10
|
-
if (metadata) {
|
|
11
|
-
if (!label) {
|
|
12
|
-
label =
|
|
13
|
-
metadata.localizedPluralLabels?.[language] ?? metadata.pluralLabel;
|
|
14
|
-
}
|
|
15
|
-
if (!icon) {
|
|
16
|
-
icon = metadata.icon;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return {
|
|
21
|
-
label,
|
|
22
|
-
icon,
|
|
23
|
-
link,
|
|
24
|
-
isExternal: item.type === 'external',
|
|
25
|
-
};
|
|
26
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function CommandBarContainer(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CommandBarContainer = CommandBarContainer;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const command_1 = require("@headless-adminapp/app/command");
|
|
6
|
-
const hooks_1 = require("@headless-adminapp/app/command/hooks");
|
|
7
|
-
const insights_1 = require("@headless-adminapp/app/insights");
|
|
8
|
-
const mutable_1 = require("@headless-adminapp/app/mutable");
|
|
9
|
-
const OverflowCommandBar_1 = require("../OverflowCommandBar");
|
|
10
|
-
function CommandBarContainer() {
|
|
11
|
-
const baseCommandHandleContext = (0, hooks_1.useBaseCommandHandlerContext)();
|
|
12
|
-
const insightExpereince = (0, mutable_1.useContextSelector)(insights_1.InsightsContext, (x) => x.config);
|
|
13
|
-
const transformedCommands = (0, command_1.useCommands)([insightExpereince.commands], {
|
|
14
|
-
...baseCommandHandleContext,
|
|
15
|
-
primaryControl: {},
|
|
16
|
-
});
|
|
17
|
-
return ((0, jsx_runtime_1.jsx)("div", { style: { flex: 1, flexShrink: 0, overflow: 'hidden' }, children: (0, jsx_runtime_1.jsx)(OverflowCommandBar_1.OverflowCommandBar, { commands: transformedCommands }) }));
|
|
18
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function FilterBarContainer(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FilterBarContainer = FilterBarContainer;
|
|
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/dialog/hooks");
|
|
7
|
-
const insights_1 = require("@headless-adminapp/app/insights");
|
|
8
|
-
const mutable_1 = require("@headless-adminapp/app/mutable");
|
|
9
|
-
const utils_1 = require("@headless-adminapp/app/utils");
|
|
10
|
-
const icons_1 = require("@headless-adminapp/icons");
|
|
11
|
-
const OverflowCommandBar_1 = require("../OverflowCommandBar");
|
|
12
|
-
function FilterBarContainer() {
|
|
13
|
-
const openPromptDialog = (0, hooks_1.useOpenPromptDialog)();
|
|
14
|
-
const insightsState = (0, mutable_1.useContextSelector)(insights_1.InsightsContext, (state) => state);
|
|
15
|
-
const insightExpereince = insightsState.config;
|
|
16
|
-
const setValue = (0, mutable_1.useContextSetValue)(insights_1.InsightsContext);
|
|
17
|
-
const handleOpenPromptDialog = async () => {
|
|
18
|
-
const attributes = insightExpereince.filters.reduce((acc, item) => {
|
|
19
|
-
acc[item.logicalName] =
|
|
20
|
-
insightsState.config.filterAttributes[item.logicalName];
|
|
21
|
-
return acc;
|
|
22
|
-
}, {});
|
|
23
|
-
const defaultValues = insightExpereince.filters.reduce((acc, item) => {
|
|
24
|
-
acc[item.logicalName] = insightsState.filterValues[item.logicalName];
|
|
25
|
-
return acc;
|
|
26
|
-
}, {});
|
|
27
|
-
const result = await openPromptDialog({
|
|
28
|
-
attributes,
|
|
29
|
-
defaultValues,
|
|
30
|
-
title: 'Modify filter',
|
|
31
|
-
allowDismiss: true,
|
|
32
|
-
});
|
|
33
|
-
if (!result) {
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
setValue({
|
|
37
|
-
filterValues: result,
|
|
38
|
-
});
|
|
39
|
-
};
|
|
40
|
-
const filterCommandItems = insightExpereince.filters
|
|
41
|
-
.map((item) => {
|
|
42
|
-
const logicalName = item.logicalName;
|
|
43
|
-
const value = insightsState.filterValues[logicalName];
|
|
44
|
-
const attribute = insightsState.config.filterAttributes[logicalName];
|
|
45
|
-
if (!item.showInFilterBar) {
|
|
46
|
-
return null;
|
|
47
|
-
}
|
|
48
|
-
if (!attribute || !value) {
|
|
49
|
-
return null;
|
|
50
|
-
}
|
|
51
|
-
if (item.allowQuickFilter) {
|
|
52
|
-
return {
|
|
53
|
-
type: 'button',
|
|
54
|
-
Icon: item.Icon,
|
|
55
|
-
text: (0, utils_1.getAttributeFormattedValue)(attribute, value, { maxCount: 2 }),
|
|
56
|
-
onClick: async () => {
|
|
57
|
-
const result = await openPromptDialog({
|
|
58
|
-
allowDismiss: true,
|
|
59
|
-
attributes: {
|
|
60
|
-
[logicalName]: attribute,
|
|
61
|
-
},
|
|
62
|
-
defaultValues: {
|
|
63
|
-
[logicalName]: value,
|
|
64
|
-
},
|
|
65
|
-
title: item.quickFilterTitle ?? attribute.label,
|
|
66
|
-
});
|
|
67
|
-
if (!result) {
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
setValue({
|
|
71
|
-
filterValues: {
|
|
72
|
-
...insightsState.filterValues,
|
|
73
|
-
[logicalName]: result[logicalName],
|
|
74
|
-
},
|
|
75
|
-
});
|
|
76
|
-
},
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
return {
|
|
80
|
-
type: 'label',
|
|
81
|
-
Icon: item.Icon,
|
|
82
|
-
text: (item.beforeContent ?? '') +
|
|
83
|
-
(0, utils_1.getAttributeFormattedValue)(attribute, value, { maxCount: 2 }),
|
|
84
|
-
};
|
|
85
|
-
})
|
|
86
|
-
.filter(Boolean);
|
|
87
|
-
return ((0, jsx_runtime_1.jsxs)("div", { style: {
|
|
88
|
-
display: 'flex',
|
|
89
|
-
flex: 1,
|
|
90
|
-
flexShrink: 0,
|
|
91
|
-
alignItems: 'center',
|
|
92
|
-
overflow: 'hidden',
|
|
93
|
-
}, children: [(0, jsx_runtime_1.jsx)("div", { style: {
|
|
94
|
-
display: 'flex',
|
|
95
|
-
flex: 1,
|
|
96
|
-
overflow: 'hidden',
|
|
97
|
-
flexShrink: 0,
|
|
98
|
-
}, children: (0, jsx_runtime_1.jsx)(OverflowCommandBar_1.OverflowCommandBar, { commands: [filterCommandItems], align: "end", beforeDivider: true }) }), insightExpereince.filters.length > 0 && ((0, jsx_runtime_1.jsx)(react_components_1.Button, { appearance: "primary", icon: (0, jsx_runtime_1.jsx)(icons_1.Icons.Filter, { size: 16 }), onClick: handleOpenPromptDialog, style: { flexShrink: 0, marginInline: 8 }, children: "Filter" }))] }));
|
|
99
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { DataSetItemAllowFunction } from '@headless-adminapp/core/experience/insights';
|
|
2
|
-
export declare function useQueriesData(queries: DataSetItemAllowFunction[]): {
|
|
3
|
-
isPending: boolean;
|
|
4
|
-
isFetching: boolean;
|
|
5
|
-
dataset: any[];
|
|
6
|
-
refetch: () => Promise<import("@tanstack/react-query").QueryObserverResult<any, Error>>[];
|
|
7
|
-
};
|
|
@@ -1,89 +0,0 @@
|
|
|
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.useQueriesData = useQueriesData;
|
|
7
|
-
const insights_1 = require("@headless-adminapp/app/insights");
|
|
8
|
-
const mutable_1 = require("@headless-adminapp/app/mutable");
|
|
9
|
-
const transport_1 = require("@headless-adminapp/app/transport");
|
|
10
|
-
const widget_1 = require("@headless-adminapp/app/widget");
|
|
11
|
-
const transport_2 = require("@headless-adminapp/core/transport");
|
|
12
|
-
const react_query_1 = require("@tanstack/react-query");
|
|
13
|
-
const dayjs_1 = __importDefault(require("dayjs"));
|
|
14
|
-
const react_1 = require("react");
|
|
15
|
-
function useQueriesData(queries) {
|
|
16
|
-
const dataService = (0, transport_1.useDataService)();
|
|
17
|
-
const insightsState = (0, mutable_1.useContextSelector)(insights_1.InsightsContext, (state) => state);
|
|
18
|
-
const widgetState = (0, mutable_1.useContextSelector)(widget_1.WidgetContext, (state) => state);
|
|
19
|
-
const resolvedQueries = (0, react_1.useMemo)(() => {
|
|
20
|
-
return queries.map((item) => {
|
|
21
|
-
if (typeof item === 'function') {
|
|
22
|
-
return item(insightsState, widgetState);
|
|
23
|
-
}
|
|
24
|
-
return item;
|
|
25
|
-
});
|
|
26
|
-
}, [queries, insightsState, widgetState]);
|
|
27
|
-
const result = (0, react_query_1.useQueries)({
|
|
28
|
-
queries: resolvedQueries.map((item) => ({
|
|
29
|
-
queryKey: ['insights', 'aggregate', item],
|
|
30
|
-
queryFn: async () => {
|
|
31
|
-
if (item.type === 'constant') {
|
|
32
|
-
return item.value;
|
|
33
|
-
}
|
|
34
|
-
if (item.type === 'function') {
|
|
35
|
-
return item.value(insightsState, widgetState);
|
|
36
|
-
}
|
|
37
|
-
if (item.type === 'customAction') {
|
|
38
|
-
return dataService.customAction(item.value.actionName, item.value.payload);
|
|
39
|
-
}
|
|
40
|
-
const query = item.value;
|
|
41
|
-
const data = await dataService.retriveAggregate(query);
|
|
42
|
-
const transformedData = transformAggregateData(data, query);
|
|
43
|
-
return transformedData;
|
|
44
|
-
},
|
|
45
|
-
})),
|
|
46
|
-
});
|
|
47
|
-
const isPending = result.some((r) => r.isPending);
|
|
48
|
-
const isFetching = result.some((r) => r.isFetching);
|
|
49
|
-
const refetch = () => result.map((r) => r.refetch());
|
|
50
|
-
const data = (0, react_1.useMemo)(() => {
|
|
51
|
-
return result.map((r) => r.data);
|
|
52
|
-
}, [result]);
|
|
53
|
-
return { isPending, isFetching, dataset: data, refetch };
|
|
54
|
-
}
|
|
55
|
-
function transformAggregateData(data, query) {
|
|
56
|
-
const transformedData = data;
|
|
57
|
-
Object.entries(query.attributes).forEach(([key, attribute]) => {
|
|
58
|
-
const transformer = getAttributeValueTransformer(attribute);
|
|
59
|
-
if (transformer) {
|
|
60
|
-
transformedData.forEach((item) => {
|
|
61
|
-
item[key] = transformer(item[key]);
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
return transformedData;
|
|
66
|
-
}
|
|
67
|
-
function getAttributeValueTransformer(attribute) {
|
|
68
|
-
let transformer = undefined;
|
|
69
|
-
if (attribute.type === 'date') {
|
|
70
|
-
if (attribute.format) {
|
|
71
|
-
transformer = (value) => (0, dayjs_1.default)(value, attribute.format)
|
|
72
|
-
.toDate()
|
|
73
|
-
.getTime();
|
|
74
|
-
}
|
|
75
|
-
else if (attribute.value.type === 'function') {
|
|
76
|
-
if (attribute.value.value === transport_2.AggregateAttributeFunction.YearMonth) {
|
|
77
|
-
transformer = (value) => (0, dayjs_1.default)(value, 'YYYY-MM')
|
|
78
|
-
.toDate()
|
|
79
|
-
.getTime();
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
transformer = (value) => (0, dayjs_1.default)(value)
|
|
84
|
-
.toDate()
|
|
85
|
-
.getTime();
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
return transformer;
|
|
89
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { WidgetContentExperience, WidgetExperience } from '@headless-adminapp/core/experience/insights';
|
|
2
|
-
import { SchemaAttributes } from '@headless-adminapp/core/schema';
|
|
3
|
-
export declare function useWidgetDetail<T extends WidgetContentExperience>(widgetContent: T): {
|
|
4
|
-
isPending: boolean;
|
|
5
|
-
isFetching: boolean;
|
|
6
|
-
dataset: unknown[];
|
|
7
|
-
refetch: () => Promise<import("@tanstack/react-query").QueryObserverResult<unknown, Error>>[];
|
|
8
|
-
widget: WidgetExperience<SchemaAttributes, T>;
|
|
9
|
-
transformedCommands: import("@headless-adminapp/app/command").CommandItemState[][];
|
|
10
|
-
};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useWidgetDetail = useWidgetDetail;
|
|
4
|
-
const command_1 = require("@headless-adminapp/app/command");
|
|
5
|
-
const hooks_1 = require("@headless-adminapp/app/command/hooks");
|
|
6
|
-
const mutable_1 = require("@headless-adminapp/app/mutable");
|
|
7
|
-
const widget_1 = require("@headless-adminapp/app/widget");
|
|
8
|
-
const react_1 = require("react");
|
|
9
|
-
const useQueriesData_1 = require("./useQueriesData");
|
|
10
|
-
function useWidgetDetail(widgetContent) {
|
|
11
|
-
const widgetState = (0, mutable_1.useContextSelector)(widget_1.WidgetContext, (state) => state);
|
|
12
|
-
const widget = widgetState.widget;
|
|
13
|
-
const widgetSetValue = (0, mutable_1.useContextSetValue)(widget_1.WidgetContext);
|
|
14
|
-
const { dataset, isPending, isFetching, refetch } = (0, useQueriesData_1.useQueriesData)(widget.dataset);
|
|
15
|
-
const baseCommandHandleContext = (0, hooks_1.useBaseCommandHandlerContext)();
|
|
16
|
-
const updateStateValue = (0, react_1.useCallback)(
|
|
17
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
|
-
(value) => {
|
|
19
|
-
widgetSetValue((state) => ({
|
|
20
|
-
...state,
|
|
21
|
-
data: { ...state.data, ...value },
|
|
22
|
-
}));
|
|
23
|
-
}, [widgetSetValue]);
|
|
24
|
-
const transformedCommands = (0, command_1.useCommands)([widgetContent.commands], {
|
|
25
|
-
...baseCommandHandleContext,
|
|
26
|
-
primaryControl: {
|
|
27
|
-
refresh: refetch,
|
|
28
|
-
updateStateValue,
|
|
29
|
-
},
|
|
30
|
-
});
|
|
31
|
-
return {
|
|
32
|
-
isPending,
|
|
33
|
-
isFetching,
|
|
34
|
-
dataset,
|
|
35
|
-
refetch,
|
|
36
|
-
widget,
|
|
37
|
-
transformedCommands,
|
|
38
|
-
};
|
|
39
|
-
}
|