@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.
Files changed (221) hide show
  1. package/app/AppProvider.js +24 -32
  2. package/app/AuthWrapper.js +13 -9
  3. package/app/LayoutProvider.js +34 -39
  4. package/app/context.js +5 -2
  5. package/app/hooks/index.js +17 -1
  6. package/app/hooks/useAppContext.js +7 -4
  7. package/app/index.js +11 -4
  8. package/auth/AuthProvider.js +27 -36
  9. package/auth/context.d.ts +1 -1
  10. package/auth/context.js +5 -2
  11. package/auth/hooks/index.js +18 -2
  12. package/auth/hooks/useAuthSession.js +7 -4
  13. package/auth/hooks/useIsSkipAuthCheck.js +7 -4
  14. package/auth/hooks/useLogout.js +11 -8
  15. package/auth/index.js +23 -4
  16. package/auth/types.js +2 -1
  17. package/board/BoardColumnDataResolver.js +23 -20
  18. package/board/BoardColumnProvider.js +14 -10
  19. package/board/context.d.ts +2 -2
  20. package/board/context.js +6 -3
  21. package/board/hooks/index.js +15 -6
  22. package/board/hooks/useBoardColumnConfig.js +7 -4
  23. package/board/hooks/useBoardColumnData.d.ts +3 -1
  24. package/board/hooks/useBoardColumnData.js +7 -4
  25. package/board/hooks/useBoardColumnDataState.js +7 -4
  26. package/board/hooks/useBoardConfig.js +7 -4
  27. package/board/hooks/useBoardSchema.js +6 -3
  28. package/board/hooks/useSearchText.js +10 -7
  29. package/board/types.js +2 -1
  30. package/board/utils.js +4 -1
  31. package/builders/CommandBuilder/CommandBuilder.js +13 -10
  32. package/builders/CommandBuilder/DefaultCommandBuilder.js +30 -23
  33. package/builders/CommandBuilder/FormCommandBuilder.js +29 -38
  34. package/builders/CommandBuilder/SubgridCommandBuilder.js +27 -36
  35. package/builders/CommandBuilder/ViewCommandBuilder.js +29 -38
  36. package/builders/CommandBuilder/index.js +5 -1
  37. package/builders/CommandBuilder/utils.js +7 -3
  38. package/builders/SchemaExperienceBuilder.js +55 -31
  39. package/builders/index.js +7 -2
  40. package/builders/utils.js +59 -44
  41. package/command/hooks/index.js +18 -2
  42. package/command/hooks/useBaseCommandHandlerContext.js +29 -25
  43. package/command/hooks/useCommands.js +9 -6
  44. package/command/index.js +18 -2
  45. package/command/types.js +2 -1
  46. package/command/utils/index.js +41 -13
  47. package/components/ScrollView/index.d.ts +1 -1
  48. package/components/ScrollView/index.js +11 -4
  49. package/components/ScrollbarWithMoreDataRequest/index.js +14 -11
  50. package/dataform/DataFormProvider/DataResolver.js +81 -89
  51. package/dataform/DataFormProvider/InitialValueResolver.js +22 -20
  52. package/dataform/DataFormProvider/ReadonlyInfoResolver.js +14 -12
  53. package/dataform/DataFormProvider/index.js +26 -32
  54. package/dataform/context.js +5 -2
  55. package/dataform/hooks/index.js +29 -13
  56. package/dataform/hooks/useFormInstance.js +6 -3
  57. package/dataform/hooks/useFormIsDirty.js +6 -3
  58. package/dataform/hooks/useFormIsReadonly.js +7 -4
  59. package/dataform/hooks/useFormNotifications.js +12 -9
  60. package/dataform/hooks/useFormRecord.js +7 -4
  61. package/dataform/hooks/useFormSave.js +40 -46
  62. package/dataform/hooks/useFormSchema.js +7 -4
  63. package/dataform/hooks/useLoadFormGridPage.js +19 -25
  64. package/dataform/hooks/useMainFormCommands.js +37 -30
  65. package/dataform/hooks/useProcessFlowSteps.js +27 -23
  66. package/dataform/hooks/useRecordId.js +7 -4
  67. package/dataform/hooks/useRecordTitle.js +12 -9
  68. package/dataform/hooks/useSelectedForm.js +7 -4
  69. package/dataform/index.js +23 -4
  70. package/dataform/utils/defaultParameters.js +16 -6
  71. package/dataform/utils/index.js +90 -56
  72. package/dataform/utils/saveRecord.js +99 -104
  73. package/datagrid/DataGridProvider/DataResolver.js +36 -34
  74. package/datagrid/DataGridProvider/index.js +31 -32
  75. package/datagrid/DataGridProvider/transformViewColumns.js +17 -6
  76. package/datagrid/DataGridProvider/utils.js +13 -5
  77. package/datagrid/column-filter/constants.js +5 -2
  78. package/datagrid/column-filter/index.js +7 -2
  79. package/datagrid/column-filter/types.js +2 -1
  80. package/datagrid/column-filter/utils.js +13 -3
  81. package/datagrid/context.d.ts +1 -1
  82. package/datagrid/context.js +5 -2
  83. package/datagrid/hooks/index.js +36 -20
  84. package/datagrid/hooks/useChangeView.js +10 -7
  85. package/datagrid/hooks/useGridColumnFilter.js +14 -8
  86. package/datagrid/hooks/useGridColumns.js +7 -4
  87. package/datagrid/hooks/useGridCommands.js +7 -4
  88. package/datagrid/hooks/useGridData.js +7 -4
  89. package/datagrid/hooks/useGridDataState.js +7 -4
  90. package/datagrid/hooks/useGridExtraFilter.js +7 -4
  91. package/datagrid/hooks/useGridOptions.js +4 -1
  92. package/datagrid/hooks/useGridPagination.js +4 -1
  93. package/datagrid/hooks/useGridRefresh.js +10 -7
  94. package/datagrid/hooks/useGridSchema.js +7 -4
  95. package/datagrid/hooks/useGridSelection.js +10 -7
  96. package/datagrid/hooks/useGridSorting.js +10 -7
  97. package/datagrid/hooks/useGridViewLookupData.js +7 -4
  98. package/datagrid/hooks/useLoadMainGridPage.js +12 -9
  99. package/datagrid/hooks/useMainGridCommands.js +62 -54
  100. package/datagrid/hooks/useMaxRecords.js +7 -4
  101. package/datagrid/hooks/useOpenRecord.js +20 -17
  102. package/datagrid/hooks/useSearchText.js +10 -7
  103. package/datagrid/hooks/useSelectedView.js +7 -4
  104. package/datagrid/hooks/useSubGridCommands.js +34 -23
  105. package/datagrid/index.js +27 -5
  106. package/defaults.js +5 -2
  107. package/dialog/DialogProvider.js +10 -6
  108. package/dialog/context.d.ts +1 -1
  109. package/dialog/context.js +5 -2
  110. package/dialog/hooks/index.js +24 -8
  111. package/dialog/hooks/useCloseDialog.js +10 -7
  112. package/dialog/hooks/useDialogItem.d.ts +1 -1
  113. package/dialog/hooks/useDialogItem.js +7 -4
  114. package/dialog/hooks/useDialogItems.d.ts +1 -1
  115. package/dialog/hooks/useDialogItems.js +7 -4
  116. package/dialog/hooks/useOpenAlertDialog.js +16 -8
  117. package/dialog/hooks/useOpenConfirmDialog.js +18 -9
  118. package/dialog/hooks/useOpenDialog.js +18 -11
  119. package/dialog/hooks/useOpenErrorDialog.js +16 -8
  120. package/dialog/hooks/useOpenPromptDialog.js +18 -9
  121. package/dialog/index.js +22 -3
  122. package/form/FormValidationStringContext.js +9 -5
  123. package/form/index.js +7 -1
  124. package/hooks/index.js +24 -6
  125. package/hooks/useDebouncedValue.js +11 -8
  126. package/hooks/useElementLayout.js +7 -4
  127. package/hooks/useIsMobile.js +12 -6
  128. package/hooks/useItemsWithKey.js +8 -5
  129. package/hooks/useStorageState.js +7 -5
  130. package/hooks/useSystemColorScheme.js +7 -4
  131. package/insights/InsightsProvider.js +13 -10
  132. package/insights/context.d.ts +1 -1
  133. package/insights/context.js +5 -2
  134. package/insights/hooks/index.js +7 -4
  135. package/insights/index.js +20 -2
  136. package/locale/LocaleProvider.js +12 -8
  137. package/locale/context.js +5 -2
  138. package/locale/index.js +23 -4
  139. package/locale/useCurrencySymbol.js +10 -8
  140. package/locale/useLocale.js +7 -4
  141. package/locale/utils.js +8 -3
  142. package/metadata/MetadataProvider.js +21 -17
  143. package/metadata/context.d.ts +1 -1
  144. package/metadata/context.js +5 -2
  145. package/metadata/hooks/index.js +24 -8
  146. package/metadata/hooks/useAppStore.js +7 -4
  147. package/metadata/hooks/useExperienceStore.js +7 -4
  148. package/metadata/hooks/useExperienceView.js +11 -17
  149. package/metadata/hooks/useExperienceViewCommands.js +14 -20
  150. package/metadata/hooks/useExperienceViewLookup.js +10 -16
  151. package/metadata/hooks/useExperienceViewSubgridCommands.js +14 -20
  152. package/metadata/hooks/useMetadata.js +11 -8
  153. package/metadata/hooks/useSchema.js +6 -3
  154. package/metadata/index.js +22 -3
  155. package/mutable/context.js +25 -17
  156. package/mutable/index.js +27 -3
  157. package/mutable/state.js +10 -6
  158. package/mutable/type.js +2 -1
  159. package/mutable/utils.js +12 -8
  160. package/navigation/hooks/index.js +17 -1
  161. package/navigation/hooks/useOpenForm.js +14 -11
  162. package/navigation/index.js +17 -1
  163. package/package.json +4 -12
  164. package/progress-indicator/ProgressIndicatorProvider.js +16 -12
  165. package/progress-indicator/context.js +5 -2
  166. package/progress-indicator/hooks/index.js +17 -1
  167. package/progress-indicator/hooks/useProgressIndicator.d.ts +1 -1
  168. package/progress-indicator/hooks/useProgressIndicator.js +7 -4
  169. package/progress-indicator/index.js +22 -3
  170. package/providers/PageEntityFormProvider/index.js +7 -4
  171. package/providers/PageEntityViewProvider/index.js +7 -4
  172. package/recordset/RecordSetProvider.js +16 -12
  173. package/recordset/context.d.ts +1 -1
  174. package/recordset/context.js +5 -2
  175. package/recordset/hooks/index.js +19 -3
  176. package/recordset/hooks/useRecordSetResult.js +22 -29
  177. package/recordset/hooks/useRecordSetSetter.js +9 -6
  178. package/recordset/hooks/useRecordSetVisibility.js +10 -7
  179. package/recordset/index.js +22 -3
  180. package/route/RouteProvider.js +18 -14
  181. package/route/context.js +9 -6
  182. package/route/hooks/index.js +22 -6
  183. package/route/hooks/useBasePath.js +7 -4
  184. package/route/hooks/useIsRouteActive.js +7 -4
  185. package/route/hooks/usePathname.js +7 -4
  186. package/route/hooks/useRouteResolver.js +7 -4
  187. package/route/hooks/useRouter.js +7 -4
  188. package/route/hooks/useSearchParams.js +7 -4
  189. package/route/index.js +20 -2
  190. package/route/types.js +2 -1
  191. package/store/ClientAppStore.js +12 -21
  192. package/store/ComponentStore.js +6 -4
  193. package/store/EventManager.js +20 -32
  194. package/store/SchemaExperienceStore.js +186 -217
  195. package/store/index.js +20 -4
  196. package/toast-notification/ToastNotificationProvider.js +10 -6
  197. package/toast-notification/context.d.ts +1 -1
  198. package/toast-notification/context.js +5 -2
  199. package/toast-notification/hooks/index.js +19 -3
  200. package/toast-notification/hooks/useCloseToastNotification.js +10 -7
  201. package/toast-notification/hooks/useOpenToastNotification.js +18 -11
  202. package/toast-notification/hooks/useToastNotificationItems.d.ts +1 -1
  203. package/toast-notification/hooks/useToastNotificationItems.js +7 -4
  204. package/toast-notification/index.js +22 -3
  205. package/transport/InMemoryDataService/index.js +59 -78
  206. package/transport/RestDataService/index.d.ts +2 -2
  207. package/transport/RestDataService/index.js +72 -91
  208. package/transport/context.js +9 -15
  209. package/transport/hooks/index.js +18 -2
  210. package/transport/hooks/useDataService.js +7 -4
  211. package/transport/hooks/useFileService.js +7 -4
  212. package/transport/hooks/useRetriveRecords.d.ts +1 -1
  213. package/transport/hooks/useRetriveRecords.js +25 -31
  214. package/transport/index.js +20 -2
  215. package/utils/calculateColumnWidths.js +5 -2
  216. package/utils/color.js +4 -1
  217. package/utils/getAttributeFormattedValue.js +38 -40
  218. package/utils/index.js +18 -2
  219. package/widget/context.js +5 -2
  220. package/widget/hooks/index.js +7 -4
  221. package/widget/index.js +5 -1
@@ -1,18 +1,14 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
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
- export function useRetrieveRecordsKey({ schema, search, filter, sorting, columns, expand, maxRecords, }) {
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
- export function useClearDataExceptFirstPage(queryKey) {
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
- export function useRetriveRecords(queryKey, { columns, expand, filter, maxRecords, schema, search, sorting, }) {
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) => __awaiter(this, void 0, void 0, function* () {
53
- var _a;
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 = yield dataService.retriveRecords({
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
- var _a, _b, _c, _d;
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: (_a = data === null || data === void 0 ? void 0 : data.pages) === null || _a === void 0 ? void 0 : _a[0].data.logicalName,
104
- count: (_c = (_b = data === null || data === void 0 ? void 0 : data.pages) === null || _b === void 0 ? void 0 : _b[0].data.count) !== null && _c !== void 0 ? _c : 0,
105
- records: (_d = data === null || data === void 0 ? void 0 : data.pages.map((x) => x.data.records).flat()) !== null && _d !== void 0 ? _d : [],
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 {
@@ -1,2 +1,20 @@
1
- export { DataServiceContext } from './context';
2
- export * from './hooks';
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
- export function calculateColumnWidths(params) {
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 !== null && maxValue !== void 0 ? maxValue : newValue);
42
+ values[i] = Math.min(newValue, maxValue ?? newValue);
40
43
  }
41
44
  } while (true);
42
45
  return values;
package/utils/color.js CHANGED
@@ -1,4 +1,7 @@
1
- export function isColorDark(color) {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isColorDark = isColorDark;
4
+ function isColorDark(color) {
2
5
  if (color.startsWith('#')) {
3
6
  color = color.substring(1);
4
7
  }
@@ -1,8 +1,14 @@
1
- import dayjs from 'dayjs';
2
- import timezone from 'dayjs/plugin/timezone';
3
- import utc from 'dayjs/plugin/utc';
4
- dayjs.extend(utc);
5
- dayjs.extend(timezone);
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 === null || value === void 0 ? void 0 : value.map((v) => v.name);
18
- if ((options === null || options === void 0 ? void 0 : options.maxCount) && (items === null || items === void 0 ? void 0 : items.length) > options.maxCount) {
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 === null || items === void 0 ? void 0 : items.join(', ');
29
+ return items?.join(', ');
24
30
  }
25
31
  }
26
32
  function getAttributeAttachmentFormattedValue(value) {
27
- var _a;
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
- var _a, _b;
32
- const dateFormat = (_a = options === null || options === void 0 ? void 0 : options.dateFormat) !== null && _a !== void 0 ? _a : defaultDateFormat;
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 dayjs(value)
36
- .tz(options === null || options === void 0 ? void 0 : options.timezone)
39
+ return (0, dayjs_1.default)(value)
40
+ .tz(options?.timezone)
37
41
  .format(dateFormat + ' ' + timeFormat);
38
42
  }
39
43
  else {
40
- return dayjs(value)
41
- .tz(options === null || options === void 0 ? void 0 : options.timezone)
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 = (_a = options === null || options === void 0 ? void 0 : options.dateFormat) !== null && _a !== void 0 ? _a : defaultDateFormat;
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 (dayjs(from).tz(options === null || options === void 0 ? void 0 : options.timezone).format(dateFormat) +
59
+ return ((0, dayjs_1.default)(from).tz(options?.timezone).format(dateFormat) +
57
60
  ' - ' +
58
- dayjs(to).tz(options === null || options === void 0 ? void 0 : options.timezone).format(dateFormat));
61
+ (0, dayjs_1.default)(to).tz(options?.timezone).format(dateFormat));
59
62
  }
60
63
  if (from) {
61
- return 'After ' + dayjs(from).tz(options === null || options === void 0 ? void 0 : options.timezone).format(dateFormat);
64
+ return 'After ' + (0, dayjs_1.default)(from).tz(options?.timezone).format(dateFormat);
62
65
  }
63
66
  if (to) {
64
- return 'Before ' + dayjs(to).tz(options === null || options === void 0 ? void 0 : options.timezone).format(dateFormat);
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
- var _a, _b, _c;
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
- ? (_b = attribute.trueLabel) !== null && _b !== void 0 ? _b : strings.yes
73
- : (_c = attribute.falseLabel) !== null && _c !== void 0 ? _c : strings.no;
74
+ ? attribute.trueLabel ?? strings.yes
75
+ : attribute.falseLabel ?? strings.no;
74
76
  }
75
77
  function getAttributeChoiceFormattedValue(attribute, value) {
76
- var _a;
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
- var _a;
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 === null || value === void 0 ? void 0 : value.name;
92
+ return value?.name;
93
93
  }
94
94
  function getAttributeMoneyFormattedValue(value, options) {
95
- var _a, _b, _c, _d;
96
- const locale = (_a = options === null || options === void 0 ? void 0 : options.locale) !== null && _a !== void 0 ? _a : defaultLocale;
97
- const currency = (_b = options === null || options === void 0 ? void 0 : options.currency) !== null && _b !== void 0 ? _b : defaultCurrency;
98
- const currencySign = (_c = options === null || options === void 0 ? void 0 : options.currencySign) !== null && _c !== void 0 ? _c : defaultCurrencySign;
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
- export function getAttributeFormattedValue(attribute, value, options) {
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 = (_a = options === null || options === void 0 ? void 0 : options.locale) !== null && _a !== void 0 ? _a : defaultLocale;
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
- export * from './calculateColumnWidths';
2
- export * from './getAttributeFormattedValue';
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
- import { createContext } from '../mutable';
2
- export const WidgetContext = createContext();
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)();
@@ -1,5 +1,8 @@
1
- import { useContextSelector } from '../../mutable';
2
- import { WidgetContext } from '../context';
3
- export function useWidgetState() {
4
- return useContextSelector(WidgetContext, (state) => state);
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
- export { WidgetContext } from './context';
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; } });