@headless-adminapp/app 0.0.17-alpha.8 → 1.0.0

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 (243) hide show
  1. package/app/AppProvider.d.ts +0 -3
  2. package/app/AppProvider.js +10 -33
  3. package/app/AuthWrapper.d.ts +1 -1
  4. package/app/AuthWrapper.js +4 -1
  5. package/app/LayoutProvider.d.ts +8 -7
  6. package/app/LayoutProvider.js +28 -2
  7. package/app/context.d.ts +1 -1
  8. package/auth/AuthProvider.d.ts +1 -1
  9. package/auth/AuthProvider.js +30 -23
  10. package/auth/context.d.ts +2 -0
  11. package/auth/hooks/useIsSkipAuthCheck.d.ts +1 -0
  12. package/auth/hooks/useIsSkipAuthCheck.js +8 -0
  13. package/auth/hooks/useLogout.js +1 -1
  14. package/board/BoardColumnDataResolver.d.ts +1 -0
  15. package/board/BoardColumnDataResolver.js +64 -0
  16. package/board/BoardColumnProvider.d.ts +7 -0
  17. package/board/BoardColumnProvider.js +36 -0
  18. package/board/context.d.ts +19 -0
  19. package/board/context.js +6 -0
  20. package/board/hooks/index.d.ts +6 -0
  21. package/board/hooks/index.js +15 -0
  22. package/board/hooks/useBoardColumnConfig.d.ts +2 -0
  23. package/board/hooks/useBoardColumnConfig.js +8 -0
  24. package/board/hooks/useBoardColumnData.d.ts +3 -0
  25. package/board/hooks/useBoardColumnData.js +9 -0
  26. package/board/hooks/useBoardColumnDataState.d.ts +5 -0
  27. package/board/hooks/useBoardColumnDataState.js +9 -0
  28. package/board/hooks/useBoardConfig.d.ts +3 -0
  29. package/board/hooks/useBoardConfig.js +8 -0
  30. package/board/hooks/useBoardSchema.d.ts +2 -0
  31. package/board/hooks/useBoardSchema.js +7 -0
  32. package/board/hooks/useSearchText.d.ts +1 -0
  33. package/board/hooks/useSearchText.js +14 -0
  34. package/board/types.d.ts +47 -0
  35. package/board/utils.d.ts +3 -0
  36. package/board/utils.js +6 -0
  37. package/builders/CommandBuilder/DefaultCommandBuilder.d.ts +15 -6
  38. package/builders/CommandBuilder/DefaultCommandBuilder.js +42 -20
  39. package/builders/CommandBuilder/FormCommandBuilder.d.ts +14 -13
  40. package/builders/CommandBuilder/FormCommandBuilder.js +66 -52
  41. package/builders/CommandBuilder/SubgridCommandBuilder.d.ts +8 -27
  42. package/builders/CommandBuilder/SubgridCommandBuilder.js +115 -57
  43. package/builders/CommandBuilder/ViewCommandBuilder.js +32 -52
  44. package/builders/CommandBuilder/utils.js +1 -1
  45. package/builders/DefineFormExperience.d.ts +27 -0
  46. package/builders/DefineFormExperience.js +99 -0
  47. package/builders/DefineViewExperience.d.ts +13 -0
  48. package/builders/DefineViewExperience.js +33 -0
  49. package/builders/SchemaExperienceBuilder.d.ts +9 -7
  50. package/builders/SchemaExperienceBuilder.js +62 -40
  51. package/builders/utils.js +30 -44
  52. package/calendar/baseEventAttributes.d.ts +35 -0
  53. package/calendar/baseEventAttributes.js +38 -0
  54. package/calendar/context.d.ts +6 -0
  55. package/calendar/context.js +5 -0
  56. package/calendar/hooks/index.d.ts +1 -0
  57. package/{appearance → calendar}/hooks/index.js +1 -1
  58. package/calendar/hooks/useConfig.d.ts +3 -0
  59. package/calendar/hooks/useConfig.js +8 -0
  60. package/calendar/types.d.ts +41 -0
  61. package/calendar/types.js +2 -0
  62. package/calendar/utils.d.ts +3 -0
  63. package/calendar/utils.js +6 -0
  64. package/command/hooks/useBaseCommandHandlerContext.js +15 -6
  65. package/command/hooks/useCommands.js +1 -1
  66. package/command/utils/index.js +34 -9
  67. package/components/ScrollView/index.d.ts +1 -1
  68. package/components/ScrollView/index.js +2 -2
  69. package/components/ScrollbarWithMoreDataRequest/index.d.ts +9 -0
  70. package/components/ScrollbarWithMoreDataRequest/index.js +32 -0
  71. package/dataform/DataFormProvider/CustomHookExecuter.d.ts +5 -0
  72. package/dataform/DataFormProvider/CustomHookExecuter.js +14 -0
  73. package/dataform/DataFormProvider/DataResolver.d.ts +6 -4
  74. package/dataform/DataFormProvider/DataResolver.js +11 -94
  75. package/dataform/DataFormProvider/InitialValueResolver.js +3 -2
  76. package/dataform/DataFormProvider/ReadonlyInfoResolver.js +2 -3
  77. package/dataform/DataFormProvider/getRecord.d.ts +3 -0
  78. package/dataform/DataFormProvider/getRecord.js +56 -0
  79. package/dataform/DataFormProvider/index.d.ts +4 -0
  80. package/dataform/DataFormProvider/index.js +34 -12
  81. package/dataform/DataFormProvider/types.d.ts +13 -0
  82. package/dataform/DataFormProvider/types.js +2 -0
  83. package/dataform/DataFormProvider/utils.d.ts +23 -0
  84. package/dataform/DataFormProvider/utils.js +105 -0
  85. package/dataform/FormManager.d.ts +57 -0
  86. package/dataform/FormManager.js +247 -0
  87. package/dataform/constants.d.ts +1 -0
  88. package/dataform/constants.js +4 -0
  89. package/dataform/context.d.ts +26 -1
  90. package/dataform/hooks/index.d.ts +11 -0
  91. package/dataform/hooks/index.js +11 -0
  92. package/dataform/hooks/useContextKey.d.ts +1 -0
  93. package/dataform/hooks/useContextKey.js +8 -0
  94. package/dataform/hooks/useDisabledControlsManager.d.ts +6 -0
  95. package/dataform/hooks/useDisabledControlsManager.js +46 -0
  96. package/dataform/hooks/useEventManager.d.ts +1 -0
  97. package/dataform/hooks/useEventManager.js +8 -0
  98. package/dataform/hooks/useFormManager.d.ts +2 -0
  99. package/dataform/hooks/useFormManager.js +13 -0
  100. package/dataform/hooks/useFormNotifications.js +2 -2
  101. package/dataform/hooks/useFormSave.js +28 -31
  102. package/dataform/hooks/useHiddenControlsManager.d.ts +7 -0
  103. package/dataform/hooks/useHiddenControlsManager.js +50 -0
  104. package/dataform/hooks/useIsControlDisabled.d.ts +1 -0
  105. package/dataform/hooks/useIsControlDisabled.js +27 -0
  106. package/dataform/hooks/useIsControlHiddenByAttributeName.d.ts +1 -0
  107. package/dataform/hooks/useIsControlHiddenByAttributeName.js +17 -0
  108. package/dataform/hooks/useIsControlHiddenByKey.d.ts +1 -0
  109. package/dataform/hooks/useIsControlHiddenByKey.js +17 -0
  110. package/dataform/hooks/useIsFieldRequired.d.ts +1 -0
  111. package/dataform/hooks/useIsFieldRequired.js +25 -0
  112. package/dataform/hooks/useLoadFormGridPage.js +8 -17
  113. package/dataform/hooks/useMainFormCommands.d.ts +1 -12
  114. package/dataform/hooks/useMainFormCommands.js +13 -3
  115. package/dataform/hooks/useOnFieldValueChangeListener.d.ts +1 -0
  116. package/dataform/hooks/useOnFieldValueChangeListener.js +30 -0
  117. package/dataform/hooks/useProcessFlowSteps.d.ts +1 -0
  118. package/dataform/hooks/useProcessFlowSteps.js +45 -0
  119. package/dataform/hooks/useRecordTitle.d.ts +3 -1
  120. package/dataform/hooks/useRecordTitle.js +12 -5
  121. package/dataform/hooks/useRequiredFieldManager.d.ts +6 -0
  122. package/dataform/hooks/useRequiredFieldManager.js +49 -0
  123. package/dataform/test.d.ts +57 -0
  124. package/dataform/test.js +247 -0
  125. package/dataform/utils/defaultParameters.d.ts +6 -0
  126. package/dataform/utils/defaultParameters.js +54 -0
  127. package/dataform/utils/index.d.ts +6 -24
  128. package/dataform/utils/index.js +164 -190
  129. package/dataform/utils/saveRecord.d.ts +27 -0
  130. package/dataform/utils/saveRecord.js +163 -0
  131. package/datagrid/DataGridProvider/DataResolver.js +38 -109
  132. package/datagrid/DataGridProvider/index.d.ts +6 -0
  133. package/datagrid/DataGridProvider/index.js +18 -8
  134. package/datagrid/DataGridProvider/transformViewColumns.js +10 -2
  135. package/datagrid/DataGridProvider/utils.js +8 -8
  136. package/datagrid/column-filter/constants.js +38 -3
  137. package/datagrid/column-filter/utils.js +7 -1
  138. package/datagrid/context.d.ts +6 -0
  139. package/datagrid/hooks/useChangeView.js +1 -1
  140. package/datagrid/hooks/useGridColumnFilter.js +4 -1
  141. package/datagrid/hooks/useGridDisabled.d.ts +1 -0
  142. package/datagrid/hooks/useGridDisabled.js +8 -0
  143. package/datagrid/hooks/useLoadMainGridPage.js +1 -1
  144. package/datagrid/hooks/useMainGridCommands.js +23 -9
  145. package/datagrid/hooks/useOpenRecord.js +2 -2
  146. package/datagrid/hooks/useSubGridCommands.js +23 -45
  147. package/defaults.d.ts +2 -0
  148. package/defaults.js +5 -0
  149. package/dialog/hooks/useCloseDialog.js +17 -15
  150. package/dialog/hooks/useOpenAlertDialog.js +8 -3
  151. package/dialog/hooks/useOpenConfirmDialog.js +10 -4
  152. package/dialog/hooks/useOpenDialog.js +7 -5
  153. package/dialog/hooks/useOpenErrorDialog.js +8 -3
  154. package/dialog/hooks/useOpenPromptDialog.js +10 -4
  155. package/form/FormValidationStringContext.d.ts +1 -0
  156. package/form/FormValidationStringContext.js +1 -0
  157. package/hooks/index.d.ts +1 -0
  158. package/hooks/index.js +3 -0
  159. package/hooks/useDebouncedValue.js +0 -1
  160. package/hooks/useElementLayout.js +1 -1
  161. package/hooks/useIsMobile.js +0 -1
  162. package/hooks/useItemsWithKey.d.ts +7 -0
  163. package/hooks/useItemsWithKey.js +13 -0
  164. package/hooks/useStorageState.js +1 -2
  165. package/hooks/useSystemColorScheme.d.ts +1 -1
  166. package/hooks/useSystemColorScheme.js +0 -1
  167. package/insights/InsightsProvider.d.ts +8 -0
  168. package/insights/InsightsProvider.js +27 -0
  169. package/locale/LocaleProvider.d.ts +2 -1
  170. package/locale/LocaleProvider.js +3 -3
  171. package/locale/index.d.ts +1 -0
  172. package/locale/index.js +1 -0
  173. package/locale/useCurrencySymbol.d.ts +1 -0
  174. package/locale/useCurrencySymbol.js +12 -0
  175. package/locale/utils.js +4 -2
  176. package/metadata/MetadataProvider.d.ts +8 -4
  177. package/metadata/MetadataProvider.js +23 -17
  178. package/metadata/context.d.ts +3 -2
  179. package/metadata/hooks/index.d.ts +1 -1
  180. package/metadata/hooks/index.js +1 -1
  181. package/metadata/hooks/useAppExperience.d.ts +1 -0
  182. package/metadata/hooks/useAppExperience.js +8 -0
  183. package/metadata/hooks/useAppStore.d.ts +1 -1
  184. package/metadata/hooks/useAppStore.js +3 -3
  185. package/metadata/hooks/useExperienceView.js +2 -11
  186. package/metadata/hooks/useExperienceViewCommands.d.ts +1 -1
  187. package/metadata/hooks/useExperienceViewCommands.js +5 -14
  188. package/metadata/hooks/useExperienceViewLookup.js +2 -11
  189. package/metadata/hooks/useExperienceViewSubgridCommands.d.ts +1 -1
  190. package/metadata/hooks/useExperienceViewSubgridCommands.js +5 -14
  191. package/metadata/hooks/useMetadata.d.ts +11 -10
  192. package/metadata/hooks/useMetadata.js +4 -16
  193. package/metadata/hooks/useSchema.d.ts +1 -1
  194. package/metadata/hooks/useSchema.js +3 -0
  195. package/mutable/context.d.ts +3 -0
  196. package/mutable/context.js +8 -0
  197. package/mutable/utils.js +5 -12
  198. package/navigation/hooks/useOpenForm.js +4 -0
  199. package/package.json +6 -10
  200. package/providers/PageEntityFormProvider/index.d.ts +5 -1
  201. package/providers/PageEntityFormProvider/index.js +2 -2
  202. package/recordset/hooks/useRecordSetResult.js +4 -14
  203. package/route/RouteProvider.d.ts +2 -2
  204. package/route/RouteProvider.js +4 -1
  205. package/store/ClientAppStore.js +7 -20
  206. package/store/ComponentStore.d.ts +1 -1
  207. package/store/ComponentStore.js +6 -12
  208. package/store/EventManager.d.ts +2 -2
  209. package/store/EventManager.js +13 -29
  210. package/store/SchemaExperienceStore.js +179 -215
  211. package/store/index.d.ts +0 -1
  212. package/store/index.js +0 -1
  213. package/toast-notification/hooks/useCloseToastNotification.js +17 -15
  214. package/toast-notification/hooks/useOpenToastNotification.js +7 -5
  215. package/transport/InMemoryDataService/index.js +54 -77
  216. package/transport/RestDataService/index.d.ts +3 -3
  217. package/transport/RestDataService/index.js +68 -91
  218. package/transport/context.d.ts +2 -1
  219. package/transport/context.js +7 -1
  220. package/transport/hooks/index.d.ts +1 -0
  221. package/transport/hooks/index.js +1 -0
  222. package/transport/hooks/useFileService.d.ts +1 -0
  223. package/transport/hooks/useFileService.js +9 -0
  224. package/transport/hooks/useRetriveRecords.d.ts +33 -0
  225. package/transport/hooks/useRetriveRecords.js +110 -0
  226. package/utils/calculateColumnWidths.js +1 -1
  227. package/utils/color.d.ts +1 -0
  228. package/utils/color.js +14 -0
  229. package/utils/getAttributeFormattedValue.d.ts +4 -1
  230. package/utils/getAttributeFormattedValue.js +109 -54
  231. package/utils/phone.d.ts +13 -0
  232. package/utils/phone.js +33 -0
  233. package/appearance/context.d.ts +0 -7
  234. package/appearance/context.js +0 -5
  235. package/appearance/hooks/index.d.ts +0 -1
  236. package/appearance/hooks/useAppearanceContext.d.ts +0 -1
  237. package/appearance/hooks/useAppearanceContext.js +0 -12
  238. package/appearance/index.d.ts +0 -2
  239. package/appearance/index.js +0 -20
  240. package/builders/CommandBuilder.d.ts +0 -176
  241. package/builders/CommandBuilder.js +0 -567
  242. package/locale/types.d.ts +0 -2
  243. /package/{locale → board}/types.js +0 -0
@@ -5,84 +5,139 @@ 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
+ const phone_1 = require("./phone");
11
+ dayjs_1.default.extend(utc_1.default);
12
+ dayjs_1.default.extend(timezone_1.default);
8
13
  const defaultAttributeFormattedValueStrings = {
9
14
  yes: 'Yes',
10
15
  no: 'No',
11
16
  };
12
17
  const defaultDateFormat = 'YYYY-MM-DD';
18
+ const defaultTimeFormat = 'HH:mm';
13
19
  const defaultLocale = 'en-US';
14
20
  const defaultCurrency = 'USD';
15
21
  const defaultCurrencySign = 'accounting';
16
22
  const defaultCurrencyDisplay = 'symbol';
23
+ function getAttributeLookupsFormattedValue(value, options) {
24
+ const items = value?.map((v) => v.name);
25
+ if (options?.maxCount && items?.length > options.maxCount) {
26
+ return (items.slice(0, options.maxCount).join(', ') +
27
+ ` (+${items.length - options.maxCount})`);
28
+ }
29
+ else {
30
+ return items?.join(', ');
31
+ }
32
+ }
33
+ function getAttributeAttachmentFormattedValue(value) {
34
+ return value?.url ?? null;
35
+ }
36
+ function getAttributeDateFormattedValue(attribute, value, options) {
37
+ const dateFormat = options?.dateFormat ?? defaultDateFormat;
38
+ const timeFormat = options?.timeFormat ?? defaultTimeFormat;
39
+ if (attribute.format === 'datetime') {
40
+ return (0, dayjs_1.default)(value)
41
+ .tz(options?.timezone)
42
+ .format(dateFormat + ' ' + timeFormat);
43
+ }
44
+ else {
45
+ return (0, dayjs_1.default)(value)
46
+ .tz(options?.timezone)
47
+ .format(dateFormat);
48
+ }
49
+ }
50
+ function getAttributeDateRangeFormattedValue(value, options) {
51
+ if (!value)
52
+ return null;
53
+ const dateFormat = options?.dateFormat ?? defaultDateFormat;
54
+ const from = value[0];
55
+ const to = value[1];
56
+ if (!from && !to) {
57
+ return null;
58
+ }
59
+ if (from && to) {
60
+ return ((0, dayjs_1.default)(from).tz(options?.timezone).format(dateFormat) +
61
+ ' - ' +
62
+ (0, dayjs_1.default)(to).tz(options?.timezone).format(dateFormat));
63
+ }
64
+ if (from) {
65
+ return 'After ' + (0, dayjs_1.default)(from).tz(options?.timezone).format(dateFormat);
66
+ }
67
+ if (to) {
68
+ return 'Before ' + (0, dayjs_1.default)(to).tz(options?.timezone).format(dateFormat);
69
+ }
70
+ return null;
71
+ }
72
+ function getAttributeBooleanFormattedValue(attribute, value, options) {
73
+ const strings = options?.strings ?? defaultAttributeFormattedValueStrings;
74
+ return value
75
+ ? attribute.trueLabel ?? strings.yes
76
+ : attribute.falseLabel ?? strings.no;
77
+ }
78
+ function getAttributeChoiceFormattedValue(attribute, value) {
79
+ return (attribute.options.find((option) => option.value === value) ?? {
80
+ label: '',
81
+ }).label;
82
+ }
83
+ function getAttributeChoicesFormattedValue(attribute, value) {
84
+ return value
85
+ .map((v) => {
86
+ return (attribute.options.find((option) => option.value === v) ?? {
87
+ label: '',
88
+ }).label;
89
+ })
90
+ .join(', ');
91
+ }
92
+ function getAttributeLookupFormattedValue(value) {
93
+ return value?.name;
94
+ }
95
+ function getAttributeMoneyFormattedValue(value, options) {
96
+ const locale = options?.locale ?? defaultLocale;
97
+ const currency = options?.currency ?? defaultCurrency;
98
+ const currencySign = options?.currencySign ?? defaultCurrencySign;
99
+ const currencyDisplay = options?.currencyDisplay ?? defaultCurrencyDisplay;
100
+ return new Intl.NumberFormat(locale, {
101
+ style: 'currency',
102
+ currency,
103
+ currencySign,
104
+ currencyDisplay,
105
+ }).format(value);
106
+ }
17
107
  function getAttributeFormattedValue(attribute, value, options) {
18
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
19
108
  if (value === null || value === undefined) {
20
109
  return null;
21
110
  }
22
- const strings = (_a = options === null || options === void 0 ? void 0 : options.strings) !== null && _a !== void 0 ? _a : defaultAttributeFormattedValueStrings;
23
- const dateFormat = (_b = options === null || options === void 0 ? void 0 : options.dateFormat) !== null && _b !== void 0 ? _b : defaultDateFormat;
24
- const locale = (_c = options === null || options === void 0 ? void 0 : options.locale) !== null && _c !== void 0 ? _c : defaultLocale;
25
- const currency = (_d = options === null || options === void 0 ? void 0 : options.currency) !== null && _d !== void 0 ? _d : defaultCurrency;
26
- const currencySign = (_e = options === null || options === void 0 ? void 0 : options.currencySign) !== null && _e !== void 0 ? _e : defaultCurrencySign;
27
- const currencyDisplay = (_f = options === null || options === void 0 ? void 0 : options.currencyDisplay) !== null && _f !== void 0 ? _f : defaultCurrencyDisplay;
111
+ const locale = options?.locale ?? defaultLocale;
112
+ const region = options?.region ?? 'US';
28
113
  switch (attribute.type) {
29
114
  case 'boolean':
30
- return value
31
- ? (_g = attribute.trueLabel) !== null && _g !== void 0 ? _g : strings.yes
32
- : (_h = attribute.falseLabel) !== null && _h !== void 0 ? _h : strings.no;
115
+ return getAttributeBooleanFormattedValue(attribute, value, options);
33
116
  case 'choice':
34
- return ((_j = attribute.options.find((option) => option.value === value)) !== null && _j !== void 0 ? _j : {
35
- label: '',
36
- }).label;
117
+ return getAttributeChoiceFormattedValue(attribute, value);
37
118
  case 'choices':
38
- return value
39
- .map((v) => {
40
- var _a;
41
- return ((_a = attribute.options.find((option) => option.value === v)) !== null && _a !== void 0 ? _a : {
42
- label: '',
43
- }).label;
44
- })
45
- .join(', ');
119
+ return getAttributeChoicesFormattedValue(attribute, value);
46
120
  case 'date':
47
- return (0, dayjs_1.default)(value).format(dateFormat);
121
+ return getAttributeDateFormattedValue(attribute, value, options);
48
122
  case 'daterange':
49
- if (!value)
50
- return null;
51
- const from = value[0];
52
- const to = value[1];
53
- if (!from && !to) {
54
- return null;
55
- }
56
- if (from && to) {
57
- return ((0, dayjs_1.default)(from).format(dateFormat) + ' - ' + (0, dayjs_1.default)(to).format(dateFormat));
58
- }
59
- if (from) {
60
- return 'After ' + (0, dayjs_1.default)(from).format(dateFormat);
61
- }
62
- if (to) {
63
- return 'Before ' + (0, dayjs_1.default)(to).format(dateFormat);
64
- }
65
- return null;
123
+ return getAttributeDateRangeFormattedValue(value, options);
66
124
  case 'lookup':
67
- return value === null || value === void 0 ? void 0 : value.name;
125
+ return getAttributeLookupFormattedValue(value);
68
126
  case 'lookups':
69
- const items = value === null || value === void 0 ? void 0 : value.map((v) => v.name);
70
- if ((options === null || options === void 0 ? void 0 : options.maxCount) && (items === null || items === void 0 ? void 0 : items.length) > options.maxCount) {
71
- return (items.slice(0, options.maxCount).join(', ') +
72
- ` (+${items.length - options.maxCount})`);
73
- }
74
- else {
75
- return items === null || items === void 0 ? void 0 : items.join(', ');
76
- }
127
+ return getAttributeLookupsFormattedValue(value, options);
77
128
  case 'money':
78
- return new Intl.NumberFormat(locale, {
79
- style: 'currency',
80
- currency,
81
- currencySign,
82
- currencyDisplay,
83
- }).format(value);
129
+ return getAttributeMoneyFormattedValue(value, options);
84
130
  case 'number':
85
131
  return new Intl.NumberFormat(locale).format(value);
132
+ case 'attachment':
133
+ return getAttributeAttachmentFormattedValue(value);
134
+ case 'string':
135
+ if (attribute.format === 'phone' && typeof value === 'string') {
136
+ return (0, phone_1.parsePhoneNumber)(value, region).formattedNationalValue;
137
+ }
138
+ return typeof value === 'object'
139
+ ? JSON.stringify(value)
140
+ : value;
86
141
  default:
87
142
  return typeof value === 'object'
88
143
  ? JSON.stringify(value)
@@ -0,0 +1,13 @@
1
+ export declare function parsePhoneNumber(input: string, defaultCountry?: string): {
2
+ formattedInternationalValue: string;
3
+ formattedNationalValue: string;
4
+ rawValue: string;
5
+ isValid: boolean;
6
+ uri: string;
7
+ } | {
8
+ formattedInternationalValue: string;
9
+ formattedNationalValue: string;
10
+ rawValue: string;
11
+ isValid: boolean;
12
+ uri: null;
13
+ };
package/utils/phone.js ADDED
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parsePhoneNumber = parsePhoneNumber;
4
+ const libphonenumber_js_1 = require("libphonenumber-js");
5
+ function parsePhoneNumber(input, defaultCountry) {
6
+ try {
7
+ const phoneNumber = (0, libphonenumber_js_1.parsePhoneNumberWithError)(input, defaultCountry);
8
+ let rawValue = String(phoneNumber.number);
9
+ if (phoneNumber.ext) {
10
+ rawValue += ';ext=' + phoneNumber.ext;
11
+ }
12
+ let formattedNational = phoneNumber.formatInternational();
13
+ if (defaultCountry && defaultCountry === phoneNumber.country) {
14
+ formattedNational = phoneNumber.formatNational();
15
+ }
16
+ return {
17
+ formattedInternationalValue: phoneNumber.formatInternational(),
18
+ formattedNationalValue: formattedNational,
19
+ rawValue: rawValue,
20
+ isValid: phoneNumber.isPossible(),
21
+ uri: phoneNumber.getURI(),
22
+ };
23
+ }
24
+ catch (error) {
25
+ return {
26
+ formattedInternationalValue: input,
27
+ formattedNationalValue: input,
28
+ rawValue: input,
29
+ isValid: false,
30
+ uri: null,
31
+ };
32
+ }
33
+ }
@@ -1,7 +0,0 @@
1
- import { Dispatch, SetStateAction } from 'react';
2
- export type ColorScheme = 'system' | 'light' | 'dark';
3
- export interface AppearanceContextState {
4
- colorScheme: ColorScheme;
5
- brandColor: string;
6
- }
7
- export declare const AppearanceContext: import("react").Context<[AppearanceContextState, Dispatch<SetStateAction<AppearanceContextState>>] | null>;
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AppearanceContext = void 0;
4
- const react_1 = require("react");
5
- exports.AppearanceContext = (0, react_1.createContext)(null);
@@ -1 +0,0 @@
1
- export * from './useAppearanceContext';
@@ -1 +0,0 @@
1
- export declare function useAppearanceContext(): [import("../context").AppearanceContextState, import("react").Dispatch<import("react").SetStateAction<import("../context").AppearanceContextState>>];
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useAppearanceContext = useAppearanceContext;
4
- const react_1 = require("react");
5
- const context_1 = require("../context");
6
- function useAppearanceContext() {
7
- const context = (0, react_1.useContext)(context_1.AppearanceContext);
8
- if (!context) {
9
- throw new Error('useAppContext must be used within a AppContextProvider');
10
- }
11
- return context;
12
- }
@@ -1,2 +0,0 @@
1
- export { AppearanceContext, type ColorScheme, type AppearanceContextState, } from './context';
2
- export * from './hooks';
@@ -1,20 +0,0 @@
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.AppearanceContext = void 0;
18
- var context_1 = require("./context");
19
- Object.defineProperty(exports, "AppearanceContext", { enumerable: true, get: function () { return context_1.AppearanceContext; } });
20
- __exportStar(require("./hooks"), exports);
@@ -1,176 +0,0 @@
1
- import { EntityFormCommandContext, EntityMainFormCommandItemExperience } from '@headless-adminapp/core/experience/form';
2
- import { EntityMainGridCommandItemExperience, SubGridCommandItemExperience } from '@headless-adminapp/core/experience/view';
3
- import { Localized } from '@headless-adminapp/core/types';
4
- import { Icon } from '@headless-adminapp/icons';
5
- export declare function localizedLabel<T extends {
6
- label: string;
7
- localizedLabels?: Localized<string>;
8
- }>(language: string, value: T, fallback?: T): string;
9
- export declare function createLocalizedSelector<T>(stringSet: T, localizedStringSet: Localized<T> | undefined, language: string): <U>(selector: (stringSet: T) => U) => U;
10
- export declare namespace CommandBuilder {
11
- namespace View {
12
- export function createNewRecordCommand({ Icon, text, localizedTexts, }: {
13
- Icon: Icon;
14
- text: string;
15
- localizedTexts?: Record<string, string>;
16
- }): EntityMainGridCommandItemExperience;
17
- export function createEditRecordCommand({ Icon, text, localizedTexts, }: {
18
- Icon: Icon;
19
- text: string;
20
- localizedTexts?: Record<string, string>;
21
- }): EntityMainGridCommandItemExperience;
22
- interface DeleteRecordCommandStringSet {
23
- confirmation: {
24
- title: string | string[];
25
- text: string | string[];
26
- buttonCancel: string;
27
- buttonConfirm: string;
28
- };
29
- status: {
30
- deleting: string | string[];
31
- };
32
- successNotification: {
33
- title: string | string[];
34
- text: string | string[];
35
- };
36
- errorNotification: {
37
- title: string;
38
- };
39
- }
40
- export const defaultDeleteRecordStringSet: DeleteRecordCommandStringSet;
41
- export function createDeleteRecordCommand({ Icon, localizedText, text, stringSet, localizedStringSet, }: {
42
- Icon: Icon;
43
- text: string;
44
- localizedText?: Record<string, string>;
45
- stringSet?: DeleteRecordCommandStringSet;
46
- localizedStringSet?: Localized<DeleteRecordCommandStringSet>;
47
- }): EntityMainGridCommandItemExperience;
48
- export function createRefreshCommand({ Icon, localizedTexts, text, }: {
49
- Icon: Icon;
50
- text: string;
51
- localizedTexts?: Record<string, string>;
52
- }): EntityMainGridCommandItemExperience;
53
- export function createExportCommand({ button, csv, excel, }: {
54
- button: {
55
- Icon: Icon;
56
- text: string;
57
- localizedTexts?: Record<string, string>;
58
- };
59
- excel: {
60
- Icon: Icon;
61
- text: string;
62
- localizedTexts?: Record<string, string>;
63
- };
64
- csv: {
65
- Icon: Icon;
66
- text: string;
67
- localizedTexts?: Record<string, string>;
68
- };
69
- }): EntityMainGridCommandItemExperience;
70
- export {};
71
- }
72
- namespace Form {
73
- export function createSaveCommand({ Icon, text, localizedTexts, }: {
74
- Icon: Icon;
75
- text: string;
76
- localizedTexts?: Record<string, string>;
77
- }): EntityMainFormCommandItemExperience;
78
- export function createSaveAndCloseCommand({ Icon, text, localizedTexts, }: {
79
- Icon: Icon;
80
- text: string;
81
- localizedTexts?: Record<string, string>;
82
- }): EntityMainFormCommandItemExperience;
83
- interface DeleteRecordCommandStringSet {
84
- confirmation: {
85
- title: string;
86
- text: string;
87
- buttonCancel: string;
88
- buttonConfirm: string;
89
- };
90
- status: {
91
- deleting: string;
92
- };
93
- successNotification: {
94
- title: string;
95
- text: string;
96
- };
97
- errorNotification: {
98
- title: string;
99
- };
100
- }
101
- export const defaultDeleteRecordStringSet: DeleteRecordCommandStringSet;
102
- export function createDeleteCommand({ Icon, text, localizedTexts, stringSet, }: {
103
- Icon: Icon;
104
- text: string;
105
- localizedTexts?: Record<string, string>;
106
- stringSet: DeleteRecordCommandStringSet | ((context: EntityFormCommandContext) => DeleteRecordCommandStringSet);
107
- }): EntityMainFormCommandItemExperience;
108
- export function createRefreshCommand({ Icon, text, localizedTexts, }: {
109
- Icon: Icon;
110
- text: string;
111
- localizedTexts?: Record<string, string>;
112
- }): EntityMainFormCommandItemExperience;
113
- export {};
114
- }
115
- namespace Subgrid {
116
- export function createNewRecordCommand({ Icon, text, localizedTexts, }: {
117
- Icon: Icon;
118
- text: string;
119
- localizedTexts?: Record<string, string>;
120
- }): SubGridCommandItemExperience;
121
- export function createEditRecordCommand({ Icon, text, localizedTexts, }: {
122
- Icon: Icon;
123
- text: string;
124
- localizedTexts?: Record<string, string>;
125
- }): SubGridCommandItemExperience;
126
- interface DeleteRecordCommandStringSet {
127
- confirmation: {
128
- title: string | string[];
129
- text: string | string[];
130
- buttonCancel: string;
131
- buttonConfirm: string;
132
- };
133
- status: {
134
- deleting: string | string[];
135
- };
136
- successNotification: {
137
- title: string | string[];
138
- text: string | string[];
139
- };
140
- errorNotification: {
141
- title: string;
142
- };
143
- }
144
- export const defaultDeleteRecordStringSet: DeleteRecordCommandStringSet;
145
- export function createDeleteRecordCommand({ Icon, localizedText, text, stringSet, localizedStringSet, }: {
146
- Icon: Icon;
147
- text: string;
148
- localizedText?: Record<string, string>;
149
- stringSet?: DeleteRecordCommandStringSet;
150
- localizedStringSet?: Localized<DeleteRecordCommandStringSet>;
151
- }): SubGridCommandItemExperience;
152
- export function createRefreshCommand({ Icon, localizedTexts, text, }: {
153
- Icon: Icon;
154
- text: string;
155
- localizedTexts?: Record<string, string>;
156
- }): SubGridCommandItemExperience;
157
- export function createExportCommand({ button, csv, excel, }: {
158
- button: {
159
- Icon: Icon;
160
- text: string;
161
- localizedTexts?: Record<string, string>;
162
- };
163
- excel: {
164
- Icon: Icon;
165
- text: string;
166
- localizedTexts?: Record<string, string>;
167
- };
168
- csv: {
169
- Icon: Icon;
170
- text: string;
171
- localizedTexts?: Record<string, string>;
172
- };
173
- }): SubGridCommandItemExperience;
174
- export {};
175
- }
176
- }