@headless-adminapp/app 0.0.17-alpha.24 → 0.0.17-alpha.26

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.
@@ -8,7 +8,7 @@ import { RouteProviderProps } from '../route/RouteProvider';
8
8
  export interface LayoutProviderProps {
9
9
  routeProps: RouteProviderProps;
10
10
  queryClient: QueryClient;
11
- localeProps?: LocaleProviderProps;
11
+ localeProps: LocaleProviderProps;
12
12
  dataService: IDataService;
13
13
  authProps?: AuthProviderProps;
14
14
  authPlaceholder?: FC<AuthProviderPlaceholderProps>;
@@ -4,6 +4,7 @@ exports.useUtility = useUtility;
4
4
  exports.useBaseCommandHandlerContext = useBaseCommandHandlerContext;
5
5
  const navigation_1 = require("@headless-adminapp/app/navigation");
6
6
  const react_query_1 = require("@tanstack/react-query");
7
+ const react_1 = require("react");
7
8
  const hooks_1 = require("../../dialog/hooks");
8
9
  const locale_1 = require("../../locale");
9
10
  const hooks_2 = require("../../metadata/hooks");
@@ -17,7 +18,7 @@ function useUtility() {
17
18
  const openErrorDialog = (0, hooks_1.useOpenErrorDialog)();
18
19
  const openPromptDialog = (0, hooks_1.useOpenPromptDialog)();
19
20
  const openToastNotification = (0, useOpenToastNotification_1.useOpenToastNotification)();
20
- return {
21
+ return (0, react_1.useMemo)(() => ({
21
22
  hideProgressIndicator,
22
23
  showProgressIndicator,
23
24
  openAlertDialog,
@@ -25,13 +26,21 @@ function useUtility() {
25
26
  openErrorDialog,
26
27
  openPromptDialog,
27
28
  showNotification: openToastNotification,
28
- };
29
+ }), [
30
+ hideProgressIndicator,
31
+ openAlertDialog,
32
+ openConfirmDialog,
33
+ openErrorDialog,
34
+ openPromptDialog,
35
+ openToastNotification,
36
+ showProgressIndicator,
37
+ ]);
29
38
  }
30
39
  function useNavigation() {
31
40
  const openForm = (0, navigation_1.useOpenForm)();
32
- return {
41
+ return (0, react_1.useMemo)(() => ({
33
42
  openForm,
34
- };
43
+ }), [openForm]);
35
44
  }
36
45
  function useBaseCommandHandlerContext() {
37
46
  const dataService = (0, transport_1.useDataService)();
@@ -40,12 +49,12 @@ function useBaseCommandHandlerContext() {
40
49
  const utility = useUtility();
41
50
  const locale = (0, locale_1.useLocale)();
42
51
  const navigation = useNavigation();
43
- return {
52
+ return (0, react_1.useMemo)(() => ({
44
53
  dataService,
45
54
  queryClient,
46
55
  utility,
47
56
  stores,
48
57
  locale,
49
58
  navigation,
50
- };
59
+ }), [dataService, queryClient, stores, utility, locale, navigation]);
51
60
  }
@@ -75,17 +75,17 @@ function transformColumnFilter(filter, schema, schemaStore) {
75
75
  return transformedResult;
76
76
  }
77
77
  function mergeConditions(schema, filter, extraFilter, columnFilters, schemaStore) {
78
- const conditions = [];
78
+ const filters = [];
79
79
  if (filter) {
80
- conditions.push(filter);
80
+ filters.push(filter);
81
81
  }
82
82
  if (extraFilter) {
83
- conditions.push(extraFilter);
83
+ filters.push(extraFilter);
84
84
  }
85
85
  if (columnFilters) {
86
86
  const transformedColumnFilters = transformColumnFilter(columnFilters, schema, schemaStore);
87
87
  if (transformedColumnFilters) {
88
- conditions.push({
88
+ filters.push({
89
89
  type: 'and',
90
90
  conditions: Object.entries(transformedColumnFilters).map(([field, condition]) => {
91
91
  return {
@@ -98,15 +98,15 @@ function mergeConditions(schema, filter, extraFilter, columnFilters, schemaStore
98
98
  });
99
99
  }
100
100
  }
101
- if (conditions.length === 0) {
101
+ if (filters.length === 0) {
102
102
  return null;
103
103
  }
104
- if (conditions.length === 1) {
105
- return conditions[0];
104
+ if (filters.length === 1) {
105
+ return filters[0];
106
106
  }
107
107
  return {
108
108
  type: 'and',
109
- conditions,
109
+ filters: filters,
110
110
  };
111
111
  }
112
112
  function collectExpandedKeys(columns) {
@@ -64,7 +64,7 @@ function useGridControlContext() {
64
64
  var _a;
65
65
  return ((_a = data === null || data === void 0 ? void 0 : data.records) !== null && _a !== void 0 ? _a : []).filter((record) => selectedIdsObj[record[schema.idAttribute]]);
66
66
  }, [data, schema, selectedIdsObj]);
67
- return {
67
+ return (0, react_1.useMemo)(() => ({
68
68
  data,
69
69
  logicalName: schema.logicalName,
70
70
  schema,
@@ -79,12 +79,25 @@ function useGridControlContext() {
79
79
  openRecord,
80
80
  gridColumns,
81
81
  sorting,
82
- };
82
+ }), [
83
+ columnFilter,
84
+ data,
85
+ extraFilter,
86
+ gridColumns,
87
+ openRecord,
88
+ refresh,
89
+ schema,
90
+ searchText,
91
+ selectedIds,
92
+ selectedRecords,
93
+ sorting,
94
+ view,
95
+ ]);
83
96
  }
84
97
  function useMainGridCommandHandlerContext() {
85
98
  const baseHandlerContext = (0, command_1.useBaseCommandHandlerContext)();
86
99
  const primaryControl = useGridControlContext();
87
- return Object.assign(Object.assign({}, baseHandlerContext), { primaryControl });
100
+ return (0, react_1.useMemo)(() => (Object.assign(Object.assign({}, baseHandlerContext), { primaryControl })), [baseHandlerContext, primaryControl]);
88
101
  }
89
102
  const emptyCommands = [];
90
103
  function useGridCommands() {
@@ -1,7 +1,8 @@
1
1
  import { Locale } from '@headless-adminapp/core/experience/locale';
2
2
  import { FC, PropsWithChildren } from 'react';
3
3
  export interface LocaleProviderProps {
4
- locale?: string;
4
+ locale: string;
5
+ timezone: string;
5
6
  options?: {
6
7
  direction?: Locale['direction'];
7
8
  dateFormats?: Locale['dateFormats'];
@@ -5,10 +5,10 @@ const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const locale_1 = require("@headless-adminapp/core/experience/locale");
6
6
  const react_1 = require("react");
7
7
  const context_1 = require("./context");
8
- const LocaleProvider = ({ children, locale = 'en-US', options, }) => {
8
+ const LocaleProvider = ({ children, locale, timezone, options, }) => {
9
9
  const localeState = (0, react_1.useMemo)(() => {
10
- return (0, locale_1.getLocale)(locale, options);
11
- }, [locale, options]);
10
+ return (0, locale_1.getLocale)(locale, timezone, options);
11
+ }, [locale, timezone, options]);
12
12
  return ((0, jsx_runtime_1.jsx)(context_1.LocaleContext.Provider, { value: localeState, children: children }));
13
13
  };
14
14
  exports.LocaleProvider = LocaleProvider;
@@ -18,7 +18,7 @@ function useMetadata() {
18
18
  const getSchema = (0, react_1.useCallback)((logicalName) => {
19
19
  return schemaStore.getSchema(logicalName);
20
20
  }, [schemaStore]);
21
- return {
21
+ return (0, react_1.useMemo)(() => ({
22
22
  schemas,
23
23
  schemaLoading,
24
24
  /*** @deprecated */
@@ -26,5 +26,5 @@ function useMetadata() {
26
26
  schemaStore,
27
27
  appStore,
28
28
  experienceStore,
29
- };
29
+ }), [schemas, schemaLoading, schemaStore, appStore, experienceStore, getSchema]);
30
30
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@headless-adminapp/app",
3
- "version": "0.0.17-alpha.24",
3
+ "version": "0.0.17-alpha.26",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -39,5 +39,5 @@
39
39
  "react-hook-form": "7.52.2",
40
40
  "yup": "^1.4.0"
41
41
  },
42
- "gitHead": "3280eb0e29b7a026f0251771f564b33c123c9bec"
42
+ "gitHead": "038654b9eb117468f483652a99089cd92764d9d0"
43
43
  }
@@ -11,5 +11,6 @@ export declare function getAttributeFormattedValue<A extends Attribute = Attribu
11
11
  currency?: string;
12
12
  currencySign?: 'accounting' | 'standard';
13
13
  currencyDisplay?: 'symbol' | 'narrowSymbol' | 'code';
14
+ timezone?: string;
14
15
  }): string | null | undefined;
15
16
  export {};
@@ -5,6 +5,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getAttributeFormattedValue = getAttributeFormattedValue;
7
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);
8
12
  const defaultAttributeFormattedValueStrings = {
9
13
  yes: 'Yes',
10
14
  no: 'No',
@@ -44,7 +48,9 @@ function getAttributeFormattedValue(attribute, value, options) {
44
48
  })
45
49
  .join(', ');
46
50
  case 'date':
47
- return (0, dayjs_1.default)(value).format(dateFormat);
51
+ return (0, dayjs_1.default)(value)
52
+ .tz(options === null || options === void 0 ? void 0 : options.timezone)
53
+ .format(dateFormat);
48
54
  case 'daterange':
49
55
  if (!value)
50
56
  return null;
@@ -54,13 +60,15 @@ function getAttributeFormattedValue(attribute, value, options) {
54
60
  return null;
55
61
  }
56
62
  if (from && to) {
57
- return ((0, dayjs_1.default)(from).format(dateFormat) + ' - ' + (0, dayjs_1.default)(to).format(dateFormat));
63
+ return ((0, dayjs_1.default)(from).tz(options === null || options === void 0 ? void 0 : options.timezone).format(dateFormat) +
64
+ ' - ' +
65
+ (0, dayjs_1.default)(to).tz(options === null || options === void 0 ? void 0 : options.timezone).format(dateFormat));
58
66
  }
59
67
  if (from) {
60
- return 'After ' + (0, dayjs_1.default)(from).format(dateFormat);
68
+ return 'After ' + (0, dayjs_1.default)(from).tz(options === null || options === void 0 ? void 0 : options.timezone).format(dateFormat);
61
69
  }
62
70
  if (to) {
63
- return 'Before ' + (0, dayjs_1.default)(to).format(dateFormat);
71
+ return 'Before ' + (0, dayjs_1.default)(to).tz(options === null || options === void 0 ? void 0 : options.timezone).format(dateFormat);
64
72
  }
65
73
  return null;
66
74
  case 'lookup':