@headless-adminapp/app 0.0.17-alpha.53 → 0.0.17-alpha.55
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/AppProvider.js +24 -32
- package/app/AuthWrapper.js +13 -9
- package/app/LayoutProvider.js +34 -39
- package/app/context.js +5 -2
- package/app/hooks/index.js +17 -1
- package/app/hooks/useAppContext.js +7 -4
- package/app/index.js +11 -4
- package/auth/AuthProvider.js +27 -36
- package/auth/context.d.ts +1 -1
- package/auth/context.js +5 -2
- package/auth/hooks/index.js +18 -2
- package/auth/hooks/useAuthSession.js +7 -4
- package/auth/hooks/useIsSkipAuthCheck.js +7 -4
- package/auth/hooks/useLogout.js +11 -8
- package/auth/index.js +23 -4
- package/auth/types.js +2 -1
- package/board/BoardColumnDataResolver.js +23 -20
- package/board/BoardColumnProvider.js +14 -10
- package/board/context.d.ts +2 -2
- package/board/context.js +6 -3
- package/board/hooks/index.js +15 -6
- package/board/hooks/useBoardColumnConfig.js +7 -4
- package/board/hooks/useBoardColumnData.d.ts +3 -1
- package/board/hooks/useBoardColumnData.js +7 -4
- package/board/hooks/useBoardColumnDataState.js +7 -4
- package/board/hooks/useBoardConfig.js +7 -4
- package/board/hooks/useBoardSchema.js +6 -3
- package/board/hooks/useSearchText.js +10 -7
- package/board/types.js +2 -1
- package/board/utils.js +4 -1
- package/builders/CommandBuilder/CommandBuilder.js +13 -10
- package/builders/CommandBuilder/DefaultCommandBuilder.js +30 -23
- package/builders/CommandBuilder/FormCommandBuilder.js +29 -38
- package/builders/CommandBuilder/SubgridCommandBuilder.js +27 -36
- package/builders/CommandBuilder/ViewCommandBuilder.js +29 -38
- package/builders/CommandBuilder/index.js +5 -1
- package/builders/CommandBuilder/utils.js +7 -3
- package/builders/SchemaExperienceBuilder.js +55 -31
- package/builders/index.js +7 -2
- package/builders/utils.js +59 -44
- package/command/hooks/index.js +18 -2
- package/command/hooks/useBaseCommandHandlerContext.js +29 -25
- package/command/hooks/useCommands.js +9 -6
- package/command/index.js +18 -2
- package/command/types.js +2 -1
- package/command/utils/index.js +41 -13
- package/components/ScrollView/index.d.ts +1 -1
- package/components/ScrollView/index.js +11 -4
- package/components/ScrollbarWithMoreDataRequest/index.js +14 -11
- package/dataform/DataFormProvider/DataResolver.js +81 -89
- package/dataform/DataFormProvider/InitialValueResolver.js +22 -20
- package/dataform/DataFormProvider/ReadonlyInfoResolver.js +14 -12
- package/dataform/DataFormProvider/index.js +26 -32
- package/dataform/context.js +5 -2
- package/dataform/hooks/index.js +29 -13
- package/dataform/hooks/useFormInstance.js +6 -3
- package/dataform/hooks/useFormIsDirty.js +6 -3
- package/dataform/hooks/useFormIsReadonly.js +7 -4
- package/dataform/hooks/useFormNotifications.js +12 -9
- package/dataform/hooks/useFormRecord.js +7 -4
- package/dataform/hooks/useFormSave.js +40 -46
- package/dataform/hooks/useFormSchema.js +7 -4
- package/dataform/hooks/useLoadFormGridPage.js +19 -25
- package/dataform/hooks/useMainFormCommands.js +37 -30
- package/dataform/hooks/useProcessFlowSteps.js +27 -23
- package/dataform/hooks/useRecordId.js +7 -4
- package/dataform/hooks/useRecordTitle.js +12 -9
- package/dataform/hooks/useSelectedForm.js +7 -4
- package/dataform/index.js +23 -4
- package/dataform/utils/defaultParameters.js +16 -6
- package/dataform/utils/index.js +90 -56
- package/dataform/utils/saveRecord.js +99 -104
- package/datagrid/DataGridProvider/DataResolver.js +36 -34
- package/datagrid/DataGridProvider/index.js +31 -32
- package/datagrid/DataGridProvider/transformViewColumns.js +17 -6
- package/datagrid/DataGridProvider/utils.js +13 -5
- package/datagrid/column-filter/constants.js +5 -2
- package/datagrid/column-filter/index.js +7 -2
- package/datagrid/column-filter/types.js +2 -1
- package/datagrid/column-filter/utils.js +13 -3
- package/datagrid/context.d.ts +1 -1
- package/datagrid/context.js +5 -2
- package/datagrid/hooks/index.js +36 -20
- package/datagrid/hooks/useChangeView.js +10 -7
- package/datagrid/hooks/useGridColumnFilter.js +14 -8
- package/datagrid/hooks/useGridColumns.js +7 -4
- package/datagrid/hooks/useGridCommands.js +7 -4
- package/datagrid/hooks/useGridData.js +7 -4
- package/datagrid/hooks/useGridDataState.js +7 -4
- package/datagrid/hooks/useGridExtraFilter.js +7 -4
- package/datagrid/hooks/useGridOptions.js +4 -1
- package/datagrid/hooks/useGridPagination.js +4 -1
- package/datagrid/hooks/useGridRefresh.js +10 -7
- package/datagrid/hooks/useGridSchema.js +7 -4
- package/datagrid/hooks/useGridSelection.js +10 -7
- package/datagrid/hooks/useGridSorting.js +10 -7
- package/datagrid/hooks/useGridViewLookupData.js +7 -4
- package/datagrid/hooks/useLoadMainGridPage.js +12 -9
- package/datagrid/hooks/useMainGridCommands.js +62 -54
- package/datagrid/hooks/useMaxRecords.js +7 -4
- package/datagrid/hooks/useOpenRecord.js +20 -17
- package/datagrid/hooks/useSearchText.js +10 -7
- package/datagrid/hooks/useSelectedView.js +7 -4
- package/datagrid/hooks/useSubGridCommands.js +34 -23
- package/datagrid/index.js +27 -5
- package/defaults.js +5 -2
- package/dialog/DialogProvider.js +10 -6
- package/dialog/context.d.ts +1 -1
- package/dialog/context.js +5 -2
- package/dialog/hooks/index.js +24 -8
- package/dialog/hooks/useCloseDialog.js +10 -7
- package/dialog/hooks/useDialogItem.d.ts +1 -1
- package/dialog/hooks/useDialogItem.js +7 -4
- package/dialog/hooks/useDialogItems.d.ts +1 -1
- package/dialog/hooks/useDialogItems.js +7 -4
- package/dialog/hooks/useOpenAlertDialog.js +16 -8
- package/dialog/hooks/useOpenConfirmDialog.js +18 -9
- package/dialog/hooks/useOpenDialog.js +18 -11
- package/dialog/hooks/useOpenErrorDialog.js +16 -8
- package/dialog/hooks/useOpenPromptDialog.js +18 -9
- package/dialog/index.js +22 -3
- package/form/FormValidationStringContext.js +9 -5
- package/form/index.js +7 -1
- package/hooks/index.js +24 -6
- package/hooks/useDebouncedValue.js +11 -8
- package/hooks/useElementLayout.js +7 -4
- package/hooks/useIsMobile.js +12 -6
- package/hooks/useItemsWithKey.js +8 -5
- package/hooks/useStorageState.js +7 -5
- package/hooks/useSystemColorScheme.js +7 -4
- package/insights/InsightsProvider.js +13 -10
- package/insights/context.d.ts +1 -1
- package/insights/context.js +5 -2
- package/insights/hooks/index.js +7 -4
- package/insights/index.js +20 -2
- package/locale/LocaleProvider.js +12 -8
- package/locale/context.js +5 -2
- package/locale/index.js +23 -4
- package/locale/useCurrencySymbol.js +10 -8
- package/locale/useLocale.js +7 -4
- package/locale/utils.js +8 -3
- package/metadata/MetadataProvider.js +21 -17
- package/metadata/context.d.ts +1 -1
- package/metadata/context.js +5 -2
- package/metadata/hooks/index.js +24 -8
- package/metadata/hooks/useAppStore.js +7 -4
- package/metadata/hooks/useExperienceStore.js +7 -4
- package/metadata/hooks/useExperienceView.js +11 -17
- package/metadata/hooks/useExperienceViewCommands.js +14 -20
- package/metadata/hooks/useExperienceViewLookup.js +10 -16
- package/metadata/hooks/useExperienceViewSubgridCommands.js +14 -20
- package/metadata/hooks/useMetadata.js +11 -8
- package/metadata/hooks/useSchema.js +6 -3
- package/metadata/index.js +22 -3
- package/mutable/context.js +25 -17
- package/mutable/index.js +27 -3
- package/mutable/state.js +10 -6
- package/mutable/type.js +2 -1
- package/mutable/utils.js +12 -8
- package/navigation/hooks/index.js +17 -1
- package/navigation/hooks/useOpenForm.js +14 -11
- package/navigation/index.js +17 -1
- package/package.json +4 -12
- package/progress-indicator/ProgressIndicatorProvider.js +16 -12
- package/progress-indicator/context.js +5 -2
- package/progress-indicator/hooks/index.js +17 -1
- package/progress-indicator/hooks/useProgressIndicator.d.ts +1 -1
- package/progress-indicator/hooks/useProgressIndicator.js +7 -4
- package/progress-indicator/index.js +22 -3
- package/providers/PageEntityFormProvider/index.js +7 -4
- package/providers/PageEntityViewProvider/index.js +7 -4
- package/recordset/RecordSetProvider.js +16 -12
- package/recordset/context.d.ts +1 -1
- package/recordset/context.js +5 -2
- package/recordset/hooks/index.js +19 -3
- package/recordset/hooks/useRecordSetResult.js +22 -29
- package/recordset/hooks/useRecordSetSetter.js +9 -6
- package/recordset/hooks/useRecordSetVisibility.js +10 -7
- package/recordset/index.js +22 -3
- package/route/RouteProvider.js +18 -14
- package/route/context.js +9 -6
- package/route/hooks/index.js +22 -6
- package/route/hooks/useBasePath.js +7 -4
- package/route/hooks/useIsRouteActive.js +7 -4
- package/route/hooks/usePathname.js +7 -4
- package/route/hooks/useRouteResolver.js +7 -4
- package/route/hooks/useRouter.js +7 -4
- package/route/hooks/useSearchParams.js +7 -4
- package/route/index.js +20 -2
- package/route/types.js +2 -1
- package/store/ClientAppStore.js +12 -21
- package/store/ComponentStore.js +6 -4
- package/store/EventManager.js +20 -32
- package/store/SchemaExperienceStore.js +186 -217
- package/store/index.js +20 -4
- package/toast-notification/ToastNotificationProvider.js +10 -6
- package/toast-notification/context.d.ts +1 -1
- package/toast-notification/context.js +5 -2
- package/toast-notification/hooks/index.js +19 -3
- package/toast-notification/hooks/useCloseToastNotification.js +10 -7
- package/toast-notification/hooks/useOpenToastNotification.js +18 -11
- package/toast-notification/hooks/useToastNotificationItems.d.ts +1 -1
- package/toast-notification/hooks/useToastNotificationItems.js +7 -4
- package/toast-notification/index.js +22 -3
- package/transport/InMemoryDataService/index.js +59 -78
- package/transport/RestDataService/index.d.ts +2 -2
- package/transport/RestDataService/index.js +72 -91
- package/transport/context.js +9 -15
- package/transport/hooks/index.js +18 -2
- package/transport/hooks/useDataService.js +7 -4
- package/transport/hooks/useFileService.js +7 -4
- package/transport/hooks/useRetriveRecords.d.ts +1 -1
- package/transport/hooks/useRetriveRecords.js +25 -31
- package/transport/index.js +20 -2
- package/utils/calculateColumnWidths.js +5 -2
- package/utils/color.js +4 -1
- package/utils/getAttributeFormattedValue.js +38 -40
- package/utils/index.js +18 -2
- package/widget/context.js +5 -2
- package/widget/hooks/index.js +7 -4
- package/widget/index.js +5 -1
|
@@ -1,18 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
10
|
-
import { useDataService } from '@headless-adminapp/app/transport';
|
|
11
|
-
import { useInfiniteQuery, useQueryClient, } from '@tanstack/react-query';
|
|
12
|
-
import { useEffect, useMemo } from 'react';
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useRetrieveRecordsKey = useRetrieveRecordsKey;
|
|
4
|
+
exports.useClearDataExceptFirstPage = useClearDataExceptFirstPage;
|
|
5
|
+
exports.useRetriveRecords = useRetriveRecords;
|
|
6
|
+
const transport_1 = require("@headless-adminapp/app/transport");
|
|
7
|
+
const react_query_1 = require("@tanstack/react-query");
|
|
8
|
+
const react_1 = require("react");
|
|
13
9
|
const ROWS_PER_PAGE = 100;
|
|
14
|
-
|
|
15
|
-
const queryKey = useMemo(() => [
|
|
10
|
+
function useRetrieveRecordsKey({ schema, search, filter, sorting, columns, expand, maxRecords, }) {
|
|
11
|
+
const queryKey = (0, react_1.useMemo)(() => [
|
|
16
12
|
'data',
|
|
17
13
|
'retriveRecords',
|
|
18
14
|
schema.logicalName,
|
|
@@ -25,9 +21,9 @@ export function useRetrieveRecordsKey({ schema, search, filter, sorting, columns
|
|
|
25
21
|
], [schema.logicalName, search, filter, sorting, columns, expand, maxRecords]);
|
|
26
22
|
return queryKey;
|
|
27
23
|
}
|
|
28
|
-
|
|
29
|
-
const queryClient = useQueryClient();
|
|
30
|
-
useEffect(() => {
|
|
24
|
+
function useClearDataExceptFirstPage(queryKey) {
|
|
25
|
+
const queryClient = (0, react_query_1.useQueryClient)();
|
|
26
|
+
(0, react_1.useEffect)(() => {
|
|
31
27
|
return () => {
|
|
32
28
|
// Clear all pages except the first one when the component is unmounted
|
|
33
29
|
queryClient.setQueryData(queryKey, (oldData) => {
|
|
@@ -45,13 +41,12 @@ export function useClearDataExceptFirstPage(queryKey) {
|
|
|
45
41
|
};
|
|
46
42
|
}, [queryClient, queryKey]);
|
|
47
43
|
}
|
|
48
|
-
|
|
49
|
-
const dataService = useDataService();
|
|
50
|
-
const { data, isFetching, hasNextPage, fetchNextPage, isFetchingNextPage } = useInfiniteQuery({
|
|
44
|
+
function useRetriveRecords(queryKey, { columns, expand, filter, maxRecords, schema, search, sorting, }) {
|
|
45
|
+
const dataService = (0, transport_1.useDataService)();
|
|
46
|
+
const { data, isFetching, hasNextPage, fetchNextPage, isFetchingNextPage } = (0, react_query_1.useInfiniteQuery)({
|
|
51
47
|
queryKey: queryKey,
|
|
52
|
-
queryFn: (queryContext) =>
|
|
53
|
-
|
|
54
|
-
const params = (_a = queryContext.pageParam) !== null && _a !== void 0 ? _a : {
|
|
48
|
+
queryFn: async (queryContext) => {
|
|
49
|
+
const params = queryContext.pageParam ?? {
|
|
55
50
|
pageIndex: 0,
|
|
56
51
|
};
|
|
57
52
|
const skip = params.pageIndex * ROWS_PER_PAGE;
|
|
@@ -66,7 +61,7 @@ export function useRetriveRecords(queryKey, { columns, expand, filter, maxRecord
|
|
|
66
61
|
},
|
|
67
62
|
};
|
|
68
63
|
}
|
|
69
|
-
const result =
|
|
64
|
+
const result = await dataService.retriveRecords({
|
|
70
65
|
logicalName: schema.logicalName,
|
|
71
66
|
search,
|
|
72
67
|
columns: columns,
|
|
@@ -80,7 +75,7 @@ export function useRetriveRecords(queryKey, { columns, expand, filter, maxRecord
|
|
|
80
75
|
params: params,
|
|
81
76
|
data: result,
|
|
82
77
|
};
|
|
83
|
-
}
|
|
78
|
+
},
|
|
84
79
|
getNextPageParam: (lastPage) => {
|
|
85
80
|
if (lastPage.data.count <
|
|
86
81
|
ROWS_PER_PAGE * (lastPage.params.pageIndex + 1)) {
|
|
@@ -94,15 +89,14 @@ export function useRetriveRecords(queryKey, { columns, expand, filter, maxRecord
|
|
|
94
89
|
pageIndex: 0,
|
|
95
90
|
},
|
|
96
91
|
});
|
|
97
|
-
const finalData = useMemo(() => {
|
|
98
|
-
|
|
99
|
-
if (!(data === null || data === void 0 ? void 0 : data.pages.length)) {
|
|
92
|
+
const finalData = (0, react_1.useMemo)(() => {
|
|
93
|
+
if (!data?.pages.length) {
|
|
100
94
|
return null;
|
|
101
95
|
}
|
|
102
96
|
return {
|
|
103
|
-
logicalName:
|
|
104
|
-
count:
|
|
105
|
-
records:
|
|
97
|
+
logicalName: data?.pages?.[0].data.logicalName,
|
|
98
|
+
count: data?.pages?.[0].data.count ?? 0,
|
|
99
|
+
records: data?.pages.map((x) => x.data.records).flat() ?? [],
|
|
106
100
|
};
|
|
107
101
|
}, [data]);
|
|
108
102
|
return {
|
package/transport/index.js
CHANGED
|
@@ -1,2 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.DataServiceContext = void 0;
|
|
18
|
+
var context_1 = require("./context");
|
|
19
|
+
Object.defineProperty(exports, "DataServiceContext", { enumerable: true, get: function () { return context_1.DataServiceContext; } });
|
|
20
|
+
__exportStar(require("./hooks"), exports);
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.calculateColumnWidths = calculateColumnWidths;
|
|
4
|
+
function calculateColumnWidths(params) {
|
|
2
5
|
const { columns, availableWidth, gapWidth } = params;
|
|
3
6
|
const totalGapWidth = gapWidth * (columns.length - 1);
|
|
4
7
|
const remainingWidth = availableWidth - totalGapWidth;
|
|
@@ -36,7 +39,7 @@ function extendValues(values, maxValues, available) {
|
|
|
36
39
|
if (maxValue && value >= maxValue)
|
|
37
40
|
continue;
|
|
38
41
|
const newValue = value + value * ratio;
|
|
39
|
-
values[i] = Math.min(newValue, maxValue
|
|
42
|
+
values[i] = Math.min(newValue, maxValue ?? newValue);
|
|
40
43
|
}
|
|
41
44
|
} while (true);
|
|
42
45
|
return values;
|
package/utils/color.js
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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.getAttributeFormattedValue = getAttributeFormattedValue;
|
|
7
|
+
const dayjs_1 = __importDefault(require("dayjs"));
|
|
8
|
+
const timezone_1 = __importDefault(require("dayjs/plugin/timezone"));
|
|
9
|
+
const utc_1 = __importDefault(require("dayjs/plugin/utc"));
|
|
10
|
+
dayjs_1.default.extend(utc_1.default);
|
|
11
|
+
dayjs_1.default.extend(timezone_1.default);
|
|
6
12
|
const defaultAttributeFormattedValueStrings = {
|
|
7
13
|
yes: 'Yes',
|
|
8
14
|
no: 'No',
|
|
@@ -14,89 +20,82 @@ const defaultCurrency = 'USD';
|
|
|
14
20
|
const defaultCurrencySign = 'accounting';
|
|
15
21
|
const defaultCurrencyDisplay = 'symbol';
|
|
16
22
|
function getAttributeLookupsFormattedValue(value, options) {
|
|
17
|
-
const items = value
|
|
18
|
-
if (
|
|
23
|
+
const items = value?.map((v) => v.name);
|
|
24
|
+
if (options?.maxCount && items?.length > options.maxCount) {
|
|
19
25
|
return (items.slice(0, options.maxCount).join(', ') +
|
|
20
26
|
` (+${items.length - options.maxCount})`);
|
|
21
27
|
}
|
|
22
28
|
else {
|
|
23
|
-
return items
|
|
29
|
+
return items?.join(', ');
|
|
24
30
|
}
|
|
25
31
|
}
|
|
26
32
|
function getAttributeAttachmentFormattedValue(value) {
|
|
27
|
-
|
|
28
|
-
return (_a = value === null || value === void 0 ? void 0 : value.url) !== null && _a !== void 0 ? _a : null;
|
|
33
|
+
return value?.url ?? null;
|
|
29
34
|
}
|
|
30
35
|
function getAttributeDateFormattedValue(attribute, value, options) {
|
|
31
|
-
|
|
32
|
-
const
|
|
33
|
-
const timeFormat = (_b = options === null || options === void 0 ? void 0 : options.timeFormat) !== null && _b !== void 0 ? _b : defaultTimeFormat;
|
|
36
|
+
const dateFormat = options?.dateFormat ?? defaultDateFormat;
|
|
37
|
+
const timeFormat = options?.timeFormat ?? defaultTimeFormat;
|
|
34
38
|
if (attribute.format === 'datetime') {
|
|
35
|
-
return
|
|
36
|
-
.tz(options
|
|
39
|
+
return (0, dayjs_1.default)(value)
|
|
40
|
+
.tz(options?.timezone)
|
|
37
41
|
.format(dateFormat + ' ' + timeFormat);
|
|
38
42
|
}
|
|
39
43
|
else {
|
|
40
|
-
return
|
|
41
|
-
.tz(options
|
|
44
|
+
return (0, dayjs_1.default)(value)
|
|
45
|
+
.tz(options?.timezone)
|
|
42
46
|
.format(dateFormat);
|
|
43
47
|
}
|
|
44
48
|
}
|
|
45
49
|
function getAttributeDateRangeFormattedValue(value, options) {
|
|
46
|
-
var _a;
|
|
47
50
|
if (!value)
|
|
48
51
|
return null;
|
|
49
|
-
const dateFormat =
|
|
52
|
+
const dateFormat = options?.dateFormat ?? defaultDateFormat;
|
|
50
53
|
const from = value[0];
|
|
51
54
|
const to = value[1];
|
|
52
55
|
if (!from && !to) {
|
|
53
56
|
return null;
|
|
54
57
|
}
|
|
55
58
|
if (from && to) {
|
|
56
|
-
return (
|
|
59
|
+
return ((0, dayjs_1.default)(from).tz(options?.timezone).format(dateFormat) +
|
|
57
60
|
' - ' +
|
|
58
|
-
|
|
61
|
+
(0, dayjs_1.default)(to).tz(options?.timezone).format(dateFormat));
|
|
59
62
|
}
|
|
60
63
|
if (from) {
|
|
61
|
-
return 'After ' +
|
|
64
|
+
return 'After ' + (0, dayjs_1.default)(from).tz(options?.timezone).format(dateFormat);
|
|
62
65
|
}
|
|
63
66
|
if (to) {
|
|
64
|
-
return 'Before ' +
|
|
67
|
+
return 'Before ' + (0, dayjs_1.default)(to).tz(options?.timezone).format(dateFormat);
|
|
65
68
|
}
|
|
66
69
|
return null;
|
|
67
70
|
}
|
|
68
71
|
function getAttributeBooleanFormattedValue(attribute, value, options) {
|
|
69
|
-
|
|
70
|
-
const strings = (_a = options === null || options === void 0 ? void 0 : options.strings) !== null && _a !== void 0 ? _a : defaultAttributeFormattedValueStrings;
|
|
72
|
+
const strings = options?.strings ?? defaultAttributeFormattedValueStrings;
|
|
71
73
|
return value
|
|
72
|
-
?
|
|
73
|
-
:
|
|
74
|
+
? attribute.trueLabel ?? strings.yes
|
|
75
|
+
: attribute.falseLabel ?? strings.no;
|
|
74
76
|
}
|
|
75
77
|
function getAttributeChoiceFormattedValue(attribute, value) {
|
|
76
|
-
|
|
77
|
-
return ((_a = attribute.options.find((option) => option.value === value)) !== null && _a !== void 0 ? _a : {
|
|
78
|
+
return (attribute.options.find((option) => option.value === value) ?? {
|
|
78
79
|
label: '',
|
|
79
80
|
}).label;
|
|
80
81
|
}
|
|
81
82
|
function getAttributeChoicesFormattedValue(attribute, value) {
|
|
82
83
|
return value
|
|
83
84
|
.map((v) => {
|
|
84
|
-
|
|
85
|
-
return ((_a = attribute.options.find((option) => option.value === v)) !== null && _a !== void 0 ? _a : {
|
|
85
|
+
return (attribute.options.find((option) => option.value === v) ?? {
|
|
86
86
|
label: '',
|
|
87
87
|
}).label;
|
|
88
88
|
})
|
|
89
89
|
.join(', ');
|
|
90
90
|
}
|
|
91
91
|
function getAttributeLookupFormattedValue(value) {
|
|
92
|
-
return value
|
|
92
|
+
return value?.name;
|
|
93
93
|
}
|
|
94
94
|
function getAttributeMoneyFormattedValue(value, options) {
|
|
95
|
-
|
|
96
|
-
const
|
|
97
|
-
const
|
|
98
|
-
const
|
|
99
|
-
const currencyDisplay = (_d = options === null || options === void 0 ? void 0 : options.currencyDisplay) !== null && _d !== void 0 ? _d : defaultCurrencyDisplay;
|
|
95
|
+
const locale = options?.locale ?? defaultLocale;
|
|
96
|
+
const currency = options?.currency ?? defaultCurrency;
|
|
97
|
+
const currencySign = options?.currencySign ?? defaultCurrencySign;
|
|
98
|
+
const currencyDisplay = options?.currencyDisplay ?? defaultCurrencyDisplay;
|
|
100
99
|
return new Intl.NumberFormat(locale, {
|
|
101
100
|
style: 'currency',
|
|
102
101
|
currency,
|
|
@@ -104,12 +103,11 @@ function getAttributeMoneyFormattedValue(value, options) {
|
|
|
104
103
|
currencyDisplay,
|
|
105
104
|
}).format(value);
|
|
106
105
|
}
|
|
107
|
-
|
|
108
|
-
var _a;
|
|
106
|
+
function getAttributeFormattedValue(attribute, value, options) {
|
|
109
107
|
if (value === null || value === undefined) {
|
|
110
108
|
return null;
|
|
111
109
|
}
|
|
112
|
-
const locale =
|
|
110
|
+
const locale = options?.locale ?? defaultLocale;
|
|
113
111
|
switch (attribute.type) {
|
|
114
112
|
case 'boolean':
|
|
115
113
|
return getAttributeBooleanFormattedValue(attribute, value, options);
|
package/utils/index.js
CHANGED
|
@@ -1,2 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./calculateColumnWidths"), exports);
|
|
18
|
+
__exportStar(require("./getAttributeFormattedValue"), exports);
|
package/widget/context.js
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WidgetContext = void 0;
|
|
4
|
+
const mutable_1 = require("../mutable");
|
|
5
|
+
exports.WidgetContext = (0, mutable_1.createContext)();
|
package/widget/hooks/index.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useWidgetState = useWidgetState;
|
|
4
|
+
const mutable_1 = require("../../mutable");
|
|
5
|
+
const context_1 = require("../context");
|
|
6
|
+
function useWidgetState() {
|
|
7
|
+
return (0, mutable_1.useContextSelector)(context_1.WidgetContext, (state) => state);
|
|
5
8
|
}
|
package/widget/index.js
CHANGED
|
@@ -1 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WidgetContext = void 0;
|
|
4
|
+
var context_1 = require("./context");
|
|
5
|
+
Object.defineProperty(exports, "WidgetContext", { enumerable: true, get: function () { return context_1.WidgetContext; } });
|