@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
@@ -1,4 +1,4 @@
1
1
  /** @todo move in different dir */
2
2
  export declare function useExperienceViewSubgridCommands(logicalName: string): {
3
- commands: never[];
3
+ commands: import("@headless-adminapp/core/experience/view").SubGridCommandItemExperience[][];
4
4
  };
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.useExperienceViewSubgridCommands = useExperienceViewSubgridCommands;
13
4
  const app_1 = require("@headless-adminapp/app/app");
@@ -16,16 +7,16 @@ const useExperienceStore_1 = require("./useExperienceStore");
16
7
  /** @todo move in different dir */
17
8
  function useExperienceViewSubgridCommands(logicalName) {
18
9
  const experienceStore = (0, useExperienceStore_1.useExperienceStore)();
19
- const { app: { subgridCommands }, } = (0, app_1.useAppContext)();
10
+ const { appExperience: { subgridCommands }, } = (0, app_1.useAppContext)();
20
11
  const { data: commands } = (0, react_query_1.useQuery)({
21
12
  queryKey: ['experience-schema-view-subgrid-commands', logicalName],
22
- queryFn: () => __awaiter(this, void 0, void 0, function* () {
23
- let commands = yield experienceStore.getSubgridCommands(logicalName);
13
+ queryFn: async () => {
14
+ let commands = await experienceStore.getSubgridCommands(logicalName);
24
15
  if (!commands) {
25
16
  commands = subgridCommands;
26
17
  }
27
- return [];
28
- }),
18
+ return commands ?? [];
19
+ },
29
20
  initialData: [],
30
21
  });
31
22
  return {
@@ -1,10 +1,11 @@
1
- import { SchemaAttributes } from '@headless-adminapp/core/schema';
2
- export declare function useMetadata(): {
3
- schemas: Record<string, import("@headless-adminapp/core/schema").Schema<SchemaAttributes>>;
4
- schemaLoading: boolean;
5
- /*** @deprecated */
6
- getSchema: <S extends SchemaAttributes = SchemaAttributes>(logicalName: string) => import("@headless-adminapp/core/schema").Schema<S>;
7
- schemaStore: import("@headless-adminapp/core/store").ISchemaStore<SchemaAttributes>;
8
- appStore: import("@headless-adminapp/core/store").IClientAppStore;
9
- experienceStore: import("@headless-adminapp/core/store").ISchemaExperienceStore;
10
- };
1
+ import type { AppExperience } from '@headless-adminapp/core/experience/app';
2
+ import type { Schema, SchemaAttributes } from '@headless-adminapp/core/schema';
3
+ import type { ISchemaExperienceStore, ISchemaStore } from '@headless-adminapp/core/store';
4
+ interface UseMetadataResult {
5
+ schemas: Record<string, Schema<SchemaAttributes>>;
6
+ schemaStore: ISchemaStore<SchemaAttributes>;
7
+ appExperience: AppExperience;
8
+ experienceStore: ISchemaExperienceStore;
9
+ }
10
+ export declare function useMetadata(): UseMetadataResult;
11
+ export {};
@@ -6,25 +6,13 @@ const context_1 = require("../../mutable/context");
6
6
  const context_2 = require("../context");
7
7
  function useMetadata() {
8
8
  const schemaStore = (0, context_1.useContextSelector)(context_2.MetadataContext, (state) => state.schemaStore);
9
- const appStore = (0, context_1.useContextSelector)(context_2.MetadataContext, (state) => state.appStore);
9
+ const appExperience = (0, context_1.useContextSelector)(context_2.MetadataContext, (state) => state.appExperience);
10
10
  const experienceStore = (0, context_1.useContextSelector)(context_2.MetadataContext, (state) => state.experienceStore);
11
- // const schemaLoading = useContextSelector(
12
- // MetadataContext,
13
- // (state) => state.schemaLoading
14
- // );
15
- const schemaLoading = false;
16
11
  const schemas = schemaStore.getAllSchema();
17
- /*** @deprecated */
18
- const getSchema = (0, react_1.useCallback)((logicalName) => {
19
- return schemaStore.getSchema(logicalName);
20
- }, [schemaStore]);
21
- return {
12
+ return (0, react_1.useMemo)(() => ({
22
13
  schemas,
23
- schemaLoading,
24
- /*** @deprecated */
25
- getSchema,
26
14
  schemaStore,
27
- appStore,
15
+ appExperience,
28
16
  experienceStore,
29
- };
17
+ }), [schemas, schemaStore, appExperience, experienceStore]);
30
18
  }
@@ -1,2 +1,2 @@
1
1
  import { SchemaAttributes } from '@headless-adminapp/core/schema';
2
- export declare function useSchema<S extends SchemaAttributes = SchemaAttributes>(logicalName: string): import("@headless-adminapp/core/schema").Schema<S>;
2
+ export declare function useSchema<S extends SchemaAttributes = SchemaAttributes>(logicalName: string): import("@headless-adminapp/core/schema").Schema<S> | null;
@@ -4,5 +4,8 @@ exports.useSchema = useSchema;
4
4
  const useMetadata_1 = require("./useMetadata");
5
5
  function useSchema(logicalName) {
6
6
  const { schemaStore } = (0, useMetadata_1.useMetadata)();
7
+ if (!schemaStore.hasSchema(logicalName)) {
8
+ return null;
9
+ }
7
10
  return schemaStore.getSchema(logicalName);
8
11
  }
@@ -4,6 +4,9 @@ export type ContextValue<T> = MutableValue<T>;
4
4
  export declare const useContextSelectorInternal: typeof useMutableValueSelector;
5
5
  export declare function createContext<T>(): import("react").Context<ContextValue<T>>;
6
6
  export declare function useCreateContextStore<T>(initialValue: T): MutableValue<T>;
7
+ export declare function useContextValue<T>(context: React.Context<ContextValue<T>>): {
8
+ current: T;
9
+ };
7
10
  export declare function useContextSelector<T, R>(context: React.Context<ContextValue<T>>, selector: (state: T) => R): R;
8
11
  export declare function useContextSetValue<T>(context: React.Context<ContextValue<T>>): (value: Partial<T> | ((state: T) => Partial<T>)) => void;
9
12
  type Setter<T, U extends unknown[]> = (setValue: ContextValue<T>['setValue']) => (...args: U) => void;
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useContextSelectorInternal = void 0;
4
4
  exports.createContext = createContext;
5
5
  exports.useCreateContextStore = useCreateContextStore;
6
+ exports.useContextValue = useContextValue;
6
7
  exports.useContextSelector = useContextSelector;
7
8
  exports.useContextSetValue = useContextSetValue;
8
9
  exports.useContextValueSetter = useContextValueSetter;
@@ -18,6 +19,13 @@ function useCreateContextStore(initialValue) {
18
19
  const [state] = (0, react_1.useState)(() => createContextValue(initialValue));
19
20
  return state;
20
21
  }
22
+ function useContextValue(context) {
23
+ const contextValue = (0, react_1.useContext)(context);
24
+ if (!contextValue) {
25
+ throw new Error('useContextValue must be used within a Provider');
26
+ }
27
+ return contextValue.value;
28
+ }
21
29
  function useContextSelector(context, selector) {
22
30
  const contextValue = (0, react_1.useContext)(context);
23
31
  if (!contextValue) {
package/mutable/utils.js CHANGED
@@ -12,20 +12,13 @@ function createMutableValue(initialValue, isArray) {
12
12
  value: storeValue,
13
13
  setValue: (value) => {
14
14
  if (typeof value === 'function') {
15
- if (isArray) {
16
- storeValue.current = value(storeValue.current);
17
- }
18
- else {
19
- storeValue.current = Object.assign(Object.assign({}, storeValue.current), value(storeValue.current));
20
- }
15
+ value = value(storeValue.current);
16
+ }
17
+ if (isArray) {
18
+ storeValue.current = value;
21
19
  }
22
20
  else {
23
- if (isArray) {
24
- storeValue.current = value;
25
- }
26
- else {
27
- storeValue.current = Object.assign(Object.assign({}, storeValue.current), value);
28
- }
21
+ storeValue.current = { ...storeValue.current, ...value };
29
22
  }
30
23
  listeners.forEach((listener) => listener(storeValue.current));
31
24
  },
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useOpenForm = useOpenForm;
4
+ const defaultParameters_1 = require("@headless-adminapp/app/dataform/utils/defaultParameters");
4
5
  const app_1 = require("@headless-adminapp/core/experience/app");
5
6
  const react_1 = require("react");
6
7
  const hooks_1 = require("../../route/hooks/");
@@ -14,6 +15,9 @@ function useOpenForm() {
14
15
  type: app_1.PageType.EntityForm,
15
16
  id: options.id,
16
17
  });
18
+ if (options.parameters) {
19
+ (0, defaultParameters_1.setFormDefaultParameters)(options.logicalName, options.parameters);
20
+ }
17
21
  if (options.replace) {
18
22
  router.replace(path);
19
23
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@headless-adminapp/app",
3
- "version": "0.0.17-alpha.8",
3
+ "version": "1.0.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -16,13 +16,7 @@
16
16
  "bugs": {
17
17
  "url": "https://github.com/headless-adminapp/adminapp/issues"
18
18
  },
19
- "scripts": {
20
- "build": "tsc",
21
- "ts-check": "tsc --noEmit",
22
- "copy-files": "cp package.json dist && cp src/index.css dist",
23
- "prepublishOnly": "pnpm run build && pnpm run copy-files",
24
- "test": "echo \"Error: no test specified\" && exit 1"
25
- },
19
+ "scripts": {},
26
20
  "keywords": [],
27
21
  "author": "",
28
22
  "license": "ISC",
@@ -33,10 +27,12 @@
33
27
  "dayjs": "^1.11.13",
34
28
  "exceljs": "^4.4.0",
35
29
  "json-to-csv-export": "^2.1.1",
30
+ "libphonenumber-js": "1.11.20",
36
31
  "lodash": "^4.17.21",
37
32
  "react-custom-scrollbars-2": "^4.5.0",
38
33
  "react-hook-form": "7.52.2",
34
+ "uuid": "11.0.3",
39
35
  "yup": "^1.4.0"
40
36
  },
41
- "gitHead": "0c369830a0ba4aa5744cc307f8947ae9660980c4"
42
- }
37
+ "gitHead": "2b03aadc605acf3bc18270afce4cbd9072b0b6ae"
38
+ }
@@ -1,11 +1,15 @@
1
1
  import { EntityMainFormCommandItemExperience, Form } from '@headless-adminapp/core/experience/form';
2
2
  import { Schema, SchemaAttributes } from '@headless-adminapp/core/schema';
3
3
  import { PropsWithChildren } from 'react';
4
+ import { RetriveRecordFn } from '../../dataform/DataFormProvider/types';
5
+ import { SaveRecordFn } from '../../dataform/utils/saveRecord';
4
6
  interface PageEntityFormProviderProps<S extends SchemaAttributes> {
5
7
  schema: Schema<S>;
6
8
  form: Form<S>;
7
9
  recordId?: string;
8
10
  commands: EntityMainFormCommandItemExperience[][];
11
+ retriveRecordFn?: RetriveRecordFn<S>;
12
+ saveRecordFn?: SaveRecordFn;
9
13
  }
10
- export declare function PageEntityFormProvider<S extends SchemaAttributes>({ schema, form, recordId, children, commands, }: PropsWithChildren<PageEntityFormProviderProps<S>>): import("react/jsx-runtime").JSX.Element;
14
+ export declare function PageEntityFormProvider<S extends SchemaAttributes>({ schema, form, recordId, children, commands, retriveRecordFn, saveRecordFn, }: PropsWithChildren<PageEntityFormProviderProps<S>>): import("react/jsx-runtime").JSX.Element;
11
15
  export {};
@@ -3,6 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PageEntityFormProvider = PageEntityFormProvider;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const DataFormProvider_1 = require("../../dataform/DataFormProvider");
6
- function PageEntityFormProvider({ schema, form, recordId, children, commands, }) {
7
- return ((0, jsx_runtime_1.jsx)(DataFormProvider_1.DataFormProvider, { schema: schema, form: form, recordId: recordId, commands: commands, children: children }));
6
+ function PageEntityFormProvider({ schema, form, recordId, children, commands, retriveRecordFn, saveRecordFn, }) {
7
+ return ((0, jsx_runtime_1.jsx)(DataFormProvider_1.DataFormProvider, { schema: schema, form: form, recordId: recordId, commands: commands, retriveRecordFn: retriveRecordFn, saveRecordFn: saveRecordFn, children: children }));
8
8
  }
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.useRecordSetResult = useRecordSetResult;
13
4
  const react_query_1 = require("@tanstack/react-query");
@@ -29,26 +20,25 @@ function useRecordSetResult() {
29
20
  }, [context.logicalName, schemaStore]);
30
21
  const cardView = context.cardView;
31
22
  const columns = (0, react_1.useMemo)(() => {
32
- var _a;
33
23
  if (!cardView) {
34
24
  return [];
35
25
  }
36
26
  return Array.from(new Set([
37
27
  cardView.primaryColumn,
38
28
  cardView.avatarColumn,
39
- ...((_a = cardView.secondaryColumns) !== null && _a !== void 0 ? _a : [])
29
+ ...(cardView.secondaryColumns ?? [])
40
30
  .filter((x) => !x.expandedKey)
41
31
  .map((x) => x.name),
42
32
  ])).filter(Boolean);
43
33
  }, [cardView]);
44
34
  const { isPending, data, error } = (0, react_query_1.useQuery)({
45
35
  queryKey: ['data', 'recordset', context.logicalName, context.ids, columns],
46
- queryFn: () => __awaiter(this, void 0, void 0, function* () {
36
+ queryFn: async () => {
47
37
  if (!context.logicalName || !context.ids.length || !cardView) {
48
38
  return [];
49
39
  }
50
40
  const schema = schemaStore.getSchema(context.logicalName);
51
- const result = yield dataService.retriveRecords({
41
+ const result = await dataService.retriveRecords({
52
42
  logicalName: context.logicalName,
53
43
  filter: {
54
44
  type: 'and',
@@ -66,7 +56,7 @@ function useRecordSetResult() {
66
56
  });
67
57
  const sortedData = (0, lodash_1.sortBy)(result.records, (x) => context.ids.indexOf(x[schema.idAttribute]));
68
58
  return sortedData;
69
- }),
59
+ },
70
60
  });
71
61
  if (error) {
72
62
  console.error(error);
@@ -7,7 +7,7 @@ export interface RouteProviderProps {
7
7
  pathname: string;
8
8
  searchParams: ReadonlyURLSearchParams;
9
9
  basePath?: string;
10
- routeResolver: RouteResolver;
11
- isRouteActive: IsRouteActive;
10
+ routeResolver?: RouteResolver;
11
+ isRouteActive?: IsRouteActive;
12
12
  }
13
13
  export declare const RouteProvider: FC<PropsWithChildren<RouteProviderProps>>;
@@ -2,9 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RouteProvider = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const route_1 = require("@headless-adminapp/core/experience/route");
5
6
  const react_1 = require("react");
6
7
  const context_1 = require("./context");
7
- const RouteProvider = ({ children, pathname, router, searchParams, basePath, routeResolver, isRouteActive, }) => {
8
+ const defaultRouteResolver = (0, route_1.createRouteResolver)(route_1.defaultRouteInfo);
9
+ const defaultIsRouteActive = (0, route_1.createIsRouteActive)(route_1.defaultRouteInfo);
10
+ const RouteProvider = ({ children, pathname, router, searchParams, basePath, routeResolver = defaultRouteResolver, isRouteActive = defaultIsRouteActive, }) => {
8
11
  const basePathRef = (0, react_1.useRef)(basePath);
9
12
  basePathRef.current = basePath;
10
13
  const routeResolverRef = (0, react_1.useRef)(routeResolver);
@@ -1,30 +1,17 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.ClientAppStore = void 0;
13
4
  class ClientAppStore {
14
- constructor() {
15
- this.apps = {};
16
- }
5
+ apps = {};
17
6
  register(app) {
18
7
  this.apps[app.id] = app;
19
8
  }
20
- getApp(id) {
21
- return __awaiter(this, void 0, void 0, function* () {
22
- const app = this.apps[id];
23
- if (!app) {
24
- throw new Error(`App Experience for ${id} not found`);
25
- }
26
- return app;
27
- });
9
+ async getApp(id) {
10
+ const app = this.apps[id];
11
+ if (!app) {
12
+ throw new Error(`App Experience for ${id} not found`);
13
+ }
14
+ return app;
28
15
  }
29
16
  }
30
17
  exports.ClientAppStore = ClientAppStore;
@@ -2,5 +2,5 @@ import { IComponentStore } from '@headless-adminapp/core/store';
2
2
  export declare class ComponentStore implements IComponentStore {
3
3
  private components;
4
4
  registerComponent<T>(name: string, component: T): void;
5
- resolveComponent<T>(name: string): T;
5
+ getComponent<T>(name: string): T | null;
6
6
  }
@@ -1,23 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ComponentStore = void 0;
4
- const jsx_runtime_1 = require("react/jsx-runtime");
5
4
  class ComponentStore {
6
- constructor() {
7
- this.components = {};
8
- }
5
+ components = {};
9
6
  registerComponent(name, component) {
10
7
  this.components[name] = component;
11
8
  }
12
- resolveComponent(name) {
9
+ getComponent(name) {
13
10
  const self = this;
14
- return function (props) {
15
- if (!self.components[name]) {
16
- throw new Error(`Component ${name} is not registered`);
17
- }
18
- const Component = self.components[name];
19
- return (0, jsx_runtime_1.jsx)(Component, Object.assign({}, props));
20
- };
11
+ if (!self.components[name]) {
12
+ return null;
13
+ }
14
+ return self.components[name];
21
15
  }
22
16
  }
23
17
  exports.ComponentStore = ComponentStore;
@@ -1,7 +1,7 @@
1
1
  import { IEventManager } from '@headless-adminapp/core/store';
2
2
  export declare class EventManager implements IEventManager {
3
3
  private handlers;
4
- on<T>(key: string, handler: T): Promise<void>;
5
- off<T>(key: string, handler: T): Promise<void>;
4
+ on<T>(key: string, handler: T): void;
5
+ off<T>(key: string, handler: T): void;
6
6
  emit(key: string, ...args: any[]): any[];
7
7
  }
@@ -1,41 +1,25 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.EventManager = void 0;
13
4
  class EventManager {
14
- constructor() {
15
- this.handlers = {};
16
- }
5
+ handlers = {};
17
6
  on(key, handler) {
18
- return __awaiter(this, void 0, void 0, function* () {
19
- if (!this.handlers[key]) {
20
- this.handlers[key] = [];
21
- }
22
- this.handlers[key].push(handler);
23
- });
7
+ if (!this.handlers[key]) {
8
+ this.handlers[key] = [];
9
+ }
10
+ this.handlers[key].push(handler);
24
11
  }
25
12
  off(key, handler) {
26
- return __awaiter(this, void 0, void 0, function* () {
27
- if (!this.handlers[key]) {
28
- return;
29
- }
30
- this.handlers[key] = this.handlers[key].filter((h) => h !== handler);
31
- if (this.handlers[key].length === 0) {
32
- delete this.handlers[key];
33
- }
34
- });
13
+ if (!this.handlers[key]) {
14
+ return;
15
+ }
16
+ this.handlers[key] = this.handlers[key].filter((h) => h !== handler);
17
+ if (this.handlers[key].length === 0) {
18
+ delete this.handlers[key];
19
+ }
35
20
  }
36
21
  emit(key, ...args) {
37
- var _a;
38
- const handlers = ((_a = this.handlers[key]) !== null && _a !== void 0 ? _a : []);
22
+ const handlers = (this.handlers[key] ?? []);
39
23
  return handlers.map((handler) => handler(...args));
40
24
  }
41
25
  }