swoop-common 2.0.6 → 2.0.8

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 (62) hide show
  1. package/dist/api/generated/core/exports.d.ts +5 -6
  2. package/dist/api/generated/core/index.d.ts +5 -7
  3. package/dist/api/generated/core/models/Component.d.ts +24 -0
  4. package/dist/api/generated/core/models/ComponentInstance.d.ts +6 -0
  5. package/dist/api/generated/core/models/DTORegionUpdate.d.ts +6 -0
  6. package/dist/api/generated/core/models/Fee.d.ts +9 -0
  7. package/dist/api/generated/core/models/Itinerary.d.ts +14 -0
  8. package/dist/api/generated/core/models/Template.d.ts +13 -0
  9. package/dist/api/generated/itinerary/index.d.ts +5 -7
  10. package/dist/api/generated/itinerary/models/Component.d.ts +24 -0
  11. package/dist/api/generated/itinerary/models/ComponentInstance.d.ts +6 -0
  12. package/dist/api/generated/itinerary/models/DTORegionUpdate.d.ts +6 -0
  13. package/dist/api/generated/itinerary/models/Fee.d.ts +9 -0
  14. package/dist/api/generated/itinerary/models/Itinerary.d.ts +14 -0
  15. package/dist/api/generated/itinerary/models/Template.d.ts +13 -0
  16. package/dist/api/generated/swoop/core/request.js +2 -2
  17. package/dist/api/init.d.ts +5 -0
  18. package/dist/api/init.js +6 -0
  19. package/dist/rendering/components/StyledFormView.d.ts +33 -6
  20. package/dist/rendering/components/StyledFormView.js +6 -4
  21. package/dist/rendering/contexts/ComponentContext.d.ts +16 -0
  22. package/dist/rendering/contexts/ComponentContext.js +30 -0
  23. package/dist/rendering/hooks/errors.js +0 -1
  24. package/dist/rendering/registry/fields.d.ts +1 -2
  25. package/dist/rendering/renderers/Address.js +1 -6
  26. package/dist/rendering/renderers/Subset.d.ts +1 -20
  27. package/dist/rendering/renderers/Subset.js +40 -62
  28. package/dist/rendering/schema/formBuilders/formBuilderJsonSchema.js +15 -1
  29. package/dist/rendering/schema/formBuilders/formBuilderUiSchema.js +3 -12
  30. package/dist/rendering/schema/generate/formSchemaGenerate.js +0 -1
  31. package/dist/rendering/schema/generate/jsonSchemaGenerate.js +34 -15
  32. package/dist/rendering/schema/generate/uiSchemaGenerate.js +2 -2
  33. package/dist/rendering/type_registration/register.js +2 -19
  34. package/package.json +1 -1
  35. package/dist/api/generated/core/models/BookingResponse.d.ts +0 -19
  36. package/dist/api/generated/core/models/CurrencyResponse.d.ts +0 -20
  37. package/dist/api/generated/core/models/Partner.d.ts +0 -10
  38. package/dist/api/generated/core/models/PartnerResponse.d.ts +0 -28
  39. package/dist/api/generated/core/models/SwooperResponse.d.ts +0 -7
  40. package/dist/api/generated/core/models/Traveller.d.ts +0 -37
  41. package/dist/api/generated/core/models/TravellerResponse.d.ts +0 -87
  42. package/dist/api/generated/itinerary/models/BookingResponse.d.ts +0 -19
  43. package/dist/api/generated/itinerary/models/CurrencyResponse.d.ts +0 -20
  44. package/dist/api/generated/itinerary/models/Partner.d.ts +0 -10
  45. package/dist/api/generated/itinerary/models/PartnerResponse.d.ts +0 -28
  46. package/dist/api/generated/itinerary/models/PartnerResponse.js +0 -1
  47. package/dist/api/generated/itinerary/models/SwooperResponse.d.ts +0 -7
  48. package/dist/api/generated/itinerary/models/SwooperResponse.js +0 -1
  49. package/dist/api/generated/itinerary/models/Traveller.d.ts +0 -37
  50. package/dist/api/generated/itinerary/models/Traveller.js +0 -1
  51. package/dist/api/generated/itinerary/models/TravellerResponse.d.ts +0 -87
  52. package/dist/api/generated/itinerary/models/TravellerResponse.js +0 -1
  53. /package/dist/api/generated/core/models/{BookingResponse.js → Component.js} +0 -0
  54. /package/dist/api/generated/core/models/{CurrencyResponse.js → DTORegionUpdate.js} +0 -0
  55. /package/dist/api/generated/core/models/{Partner.js → Fee.js} +0 -0
  56. /package/dist/api/generated/core/models/{PartnerResponse.js → Itinerary.js} +0 -0
  57. /package/dist/api/generated/core/models/{SwooperResponse.js → Template.js} +0 -0
  58. /package/dist/api/generated/{core/models/Traveller.js → itinerary/models/Component.js} +0 -0
  59. /package/dist/api/generated/{core/models/TravellerResponse.js → itinerary/models/DTORegionUpdate.js} +0 -0
  60. /package/dist/api/generated/itinerary/models/{BookingResponse.js → Fee.js} +0 -0
  61. /package/dist/api/generated/itinerary/models/{CurrencyResponse.js → Itinerary.js} +0 -0
  62. /package/dist/api/generated/itinerary/models/{Partner.js → Template.js} +0 -0
@@ -5,16 +5,15 @@ export type { AssignedTravellerGroup } from './index';
5
5
  export type { Assignments } from './index';
6
6
  export type { BookingItem } from './index';
7
7
  export type { BookingItemResponse } from './index';
8
- export type { BookingResponse } from './index';
9
8
  export type { Bundle } from './index';
10
9
  export type { BundleDay } from './index';
11
10
  export type { BundleItem } from './index';
11
+ export type { Component } from './index';
12
12
  export type { ComponentDetails } from './index';
13
13
  export type { componentId } from './index';
14
14
  export type { ComponentInstance } from './index';
15
15
  export type { CurrencyItem } from './index';
16
16
  export type { CurrencyItemResponse } from './index';
17
- export type { CurrencyResponse } from './index';
18
17
  export type { DTOComponentCreate } from './index';
19
18
  export type { DTOComponentRead } from './index';
20
19
  export type { DTOComponentUpdate } from './index';
@@ -23,29 +22,29 @@ export type { DTOItineraryRead } from './index';
23
22
  export type { DTOItineraryUpdate } from './index';
24
23
  export type { DTORegionCreate } from './index';
25
24
  export type { DTORegionRead } from './index';
25
+ export type { DTORegionUpdate } from './index';
26
26
  export type { DTOTemplateCreate } from './index';
27
27
  export type { DTOTemplateRead } from './index';
28
28
  export type { DTOTemplateUpdate } from './index';
29
29
  export type { enquiryId } from './index';
30
+ export type { Fee } from './index';
30
31
  export type { Field } from './index';
31
32
  export type { IBEvent } from './index';
32
33
  export type { id } from './index';
33
34
  export type { itemsPerPage } from './index';
35
+ export type { Itinerary } from './index';
34
36
  export type { itineraryId } from './index';
35
37
  export type { Limit } from './index';
36
38
  export type { Member } from './index';
37
39
  export type { Metadata } from './index';
38
40
  export type { Page } from './index';
39
41
  export type { Pagination } from './index';
40
- export type { Partner } from './index';
41
- export type { PartnerResponse } from './index';
42
42
  export type { Region } from './index';
43
43
  export { regionParam } from './index';
44
44
  export { regionRequired } from './index';
45
45
  export type { search } from './index';
46
46
  export type { sortParam } from './index';
47
- export type { SwooperResponse } from './index';
47
+ export type { Template } from './index';
48
48
  export type { templateId } from './index';
49
- export type { TravellerResponse } from './index';
50
49
  export type { UserComponentInstanceField } from './index';
51
50
  export type { ValidationSchemas } from './index';
@@ -7,16 +7,15 @@ export type { AssignedTravellerGroup } from './models/AssignedTravellerGroup';
7
7
  export type { Assignments } from './models/Assignments';
8
8
  export type { BookingItem } from './models/BookingItem';
9
9
  export type { BookingItemResponse } from './models/BookingItemResponse';
10
- export type { BookingResponse } from './models/BookingResponse';
11
10
  export type { Bundle } from './models/Bundle';
12
11
  export type { BundleDay } from './models/BundleDay';
13
12
  export type { BundleItem } from './models/BundleItem';
13
+ export type { Component } from './models/Component';
14
14
  export type { ComponentDetails } from './models/ComponentDetails';
15
15
  export type { componentId } from './models/componentId';
16
16
  export type { ComponentInstance } from './models/ComponentInstance';
17
17
  export type { CurrencyItem } from './models/CurrencyItem';
18
18
  export type { CurrencyItemResponse } from './models/CurrencyItemResponse';
19
- export type { CurrencyResponse } from './models/CurrencyResponse';
20
19
  export type { DTOComponentCreate } from './models/DTOComponentCreate';
21
20
  export type { DTOComponentRead } from './models/DTOComponentRead';
22
21
  export type { DTOComponentUpdate } from './models/DTOComponentUpdate';
@@ -25,31 +24,30 @@ export type { DTOItineraryRead } from './models/DTOItineraryRead';
25
24
  export type { DTOItineraryUpdate } from './models/DTOItineraryUpdate';
26
25
  export type { DTORegionCreate } from './models/DTORegionCreate';
27
26
  export type { DTORegionRead } from './models/DTORegionRead';
27
+ export type { DTORegionUpdate } from './models/DTORegionUpdate';
28
28
  export type { DTOTemplateCreate } from './models/DTOTemplateCreate';
29
29
  export type { DTOTemplateRead } from './models/DTOTemplateRead';
30
30
  export type { DTOTemplateUpdate } from './models/DTOTemplateUpdate';
31
31
  export type { enquiryId } from './models/enquiryId';
32
+ export type { Fee } from './models/Fee';
32
33
  export type { Field } from './models/Field';
33
34
  export type { IBEvent } from './models/IBEvent';
34
35
  export type { id } from './models/id';
35
36
  export type { itemsPerPage } from './models/itemsPerPage';
37
+ export type { Itinerary } from './models/Itinerary';
36
38
  export type { itineraryId } from './models/itineraryId';
37
39
  export type { Limit } from './models/Limit';
38
40
  export type { Member } from './models/Member';
39
41
  export type { Metadata } from './models/Metadata';
40
42
  export type { Page } from './models/Page';
41
43
  export type { Pagination } from './models/Pagination';
42
- export type { Partner } from './models/Partner';
43
- export type { PartnerResponse } from './models/PartnerResponse';
44
44
  export type { Region } from './models/Region';
45
45
  export { regionParam } from './models/regionParam';
46
46
  export { regionRequired } from './models/regionRequired';
47
47
  export type { search } from './models/search';
48
48
  export type { sortParam } from './models/sortParam';
49
- export type { SwooperResponse } from './models/SwooperResponse';
49
+ export type { Template } from './models/Template';
50
50
  export type { templateId } from './models/templateId';
51
- export type { Traveller } from './models/Traveller';
52
- export type { TravellerResponse } from './models/TravellerResponse';
53
51
  export type { UserComponentInstanceField } from './models/UserComponentInstanceField';
54
52
  export type { ValidationSchemas } from './models/ValidationSchemas';
55
53
  export { CoreService } from './services/CoreService';
@@ -0,0 +1,24 @@
1
+ import type { Bundle } from './Bundle';
2
+ import type { ComponentDetails } from './ComponentDetails';
3
+ import type { Field } from './Field';
4
+ import type { Metadata } from './Metadata';
5
+ export type Component = {
6
+ /**
7
+ * Unique identifier
8
+ */
9
+ id: string;
10
+ orgId: string;
11
+ templateId: string;
12
+ revisionGroupId: string;
13
+ revision: number;
14
+ metadata: Metadata;
15
+ name: string;
16
+ componentFields: Array<Field>;
17
+ partners: Array<string>;
18
+ startDate?: string | null;
19
+ endDate?: string | null;
20
+ duration?: number | null;
21
+ details: ComponentDetails;
22
+ bundle: Bundle;
23
+ state?: string | null;
24
+ };
@@ -11,4 +11,10 @@ export type ComponentInstance = {
11
11
  userComponentInstanceFields: Array<UserComponentInstanceField>;
12
12
  assignedPassengers: Array<AssignedPassenger>;
13
13
  assignedTravellerGroups: Array<AssignedTravellerGroup>;
14
+ startDate?: string;
15
+ endDate?: string;
16
+ price?: number;
17
+ currency?: string;
18
+ commissionPercent?: number;
19
+ partner?: string;
14
20
  };
@@ -0,0 +1,6 @@
1
+ export type DTORegionUpdate = {
2
+ name: string;
3
+ description: string;
4
+ destination: string;
5
+ images: Array<string>;
6
+ };
@@ -0,0 +1,9 @@
1
+ import type { AssignedPassenger } from './AssignedPassenger';
2
+ export type Fee = {
3
+ name: string;
4
+ reason: string;
5
+ type: string;
6
+ price: number;
7
+ currency: string;
8
+ assignedPassenger: AssignedPassenger;
9
+ };
@@ -0,0 +1,14 @@
1
+ import type { ComponentInstance } from './ComponentInstance';
2
+ import type { Fee } from './Fee';
3
+ import type { Metadata } from './Metadata';
4
+ export type Itinerary = {
5
+ /**
6
+ * Unique identifier
7
+ */
8
+ id: string;
9
+ title: string;
10
+ enquirerId: string;
11
+ metadata: Metadata;
12
+ componentInstances: Array<ComponentInstance>;
13
+ fees: Array<Fee>;
14
+ };
@@ -0,0 +1,13 @@
1
+ import type { Metadata } from './Metadata';
2
+ import type { ValidationSchemas } from './ValidationSchemas';
3
+ export type Template = {
4
+ id: string;
5
+ orgId: string;
6
+ parentRevisionGroupId: string;
7
+ revisionGroupId: string;
8
+ revision: number;
9
+ metadata: Metadata;
10
+ name: string;
11
+ masterSchema: string;
12
+ validationSchemas: ValidationSchemas;
13
+ };
@@ -7,16 +7,15 @@ export type { AssignedTravellerGroup } from './models/AssignedTravellerGroup';
7
7
  export type { Assignments } from './models/Assignments';
8
8
  export type { BookingItem } from './models/BookingItem';
9
9
  export type { BookingItemResponse } from './models/BookingItemResponse';
10
- export type { BookingResponse } from './models/BookingResponse';
11
10
  export type { Bundle } from './models/Bundle';
12
11
  export type { BundleDay } from './models/BundleDay';
13
12
  export type { BundleItem } from './models/BundleItem';
13
+ export type { Component } from './models/Component';
14
14
  export type { ComponentDetails } from './models/ComponentDetails';
15
15
  export type { componentId } from './models/componentId';
16
16
  export type { ComponentInstance } from './models/ComponentInstance';
17
17
  export type { CurrencyItem } from './models/CurrencyItem';
18
18
  export type { CurrencyItemResponse } from './models/CurrencyItemResponse';
19
- export type { CurrencyResponse } from './models/CurrencyResponse';
20
19
  export type { DTOComponentCreate } from './models/DTOComponentCreate';
21
20
  export type { DTOComponentRead } from './models/DTOComponentRead';
22
21
  export type { DTOComponentUpdate } from './models/DTOComponentUpdate';
@@ -25,31 +24,30 @@ export type { DTOItineraryRead } from './models/DTOItineraryRead';
25
24
  export type { DTOItineraryUpdate } from './models/DTOItineraryUpdate';
26
25
  export type { DTORegionCreate } from './models/DTORegionCreate';
27
26
  export type { DTORegionRead } from './models/DTORegionRead';
27
+ export type { DTORegionUpdate } from './models/DTORegionUpdate';
28
28
  export type { DTOTemplateCreate } from './models/DTOTemplateCreate';
29
29
  export type { DTOTemplateRead } from './models/DTOTemplateRead';
30
30
  export type { DTOTemplateUpdate } from './models/DTOTemplateUpdate';
31
31
  export type { enquiryId } from './models/enquiryId';
32
+ export type { Fee } from './models/Fee';
32
33
  export type { Field } from './models/Field';
33
34
  export type { IBEvent } from './models/IBEvent';
34
35
  export type { id } from './models/id';
35
36
  export type { itemsPerPage } from './models/itemsPerPage';
37
+ export type { Itinerary } from './models/Itinerary';
36
38
  export type { itineraryId } from './models/itineraryId';
37
39
  export type { Limit } from './models/Limit';
38
40
  export type { Member } from './models/Member';
39
41
  export type { Metadata } from './models/Metadata';
40
42
  export type { Page } from './models/Page';
41
43
  export type { Pagination } from './models/Pagination';
42
- export type { Partner } from './models/Partner';
43
- export type { PartnerResponse } from './models/PartnerResponse';
44
44
  export type { Region } from './models/Region';
45
45
  export { regionParam } from './models/regionParam';
46
46
  export { regionRequired } from './models/regionRequired';
47
47
  export type { search } from './models/search';
48
48
  export type { sortParam } from './models/sortParam';
49
- export type { SwooperResponse } from './models/SwooperResponse';
49
+ export type { Template } from './models/Template';
50
50
  export type { templateId } from './models/templateId';
51
- export type { Traveller } from './models/Traveller';
52
- export type { TravellerResponse } from './models/TravellerResponse';
53
51
  export type { UserComponentInstanceField } from './models/UserComponentInstanceField';
54
52
  export type { ValidationSchemas } from './models/ValidationSchemas';
55
53
  export { ItineraryService } from './services/ItineraryService';
@@ -0,0 +1,24 @@
1
+ import type { Bundle } from './Bundle';
2
+ import type { ComponentDetails } from './ComponentDetails';
3
+ import type { Field } from './Field';
4
+ import type { Metadata } from './Metadata';
5
+ export type Component = {
6
+ /**
7
+ * Unique identifier
8
+ */
9
+ id: string;
10
+ orgId: string;
11
+ templateId: string;
12
+ revisionGroupId: string;
13
+ revision: number;
14
+ metadata: Metadata;
15
+ name: string;
16
+ componentFields: Array<Field>;
17
+ partners: Array<string>;
18
+ startDate?: string | null;
19
+ endDate?: string | null;
20
+ duration?: number | null;
21
+ details: ComponentDetails;
22
+ bundle: Bundle;
23
+ state?: string | null;
24
+ };
@@ -11,4 +11,10 @@ export type ComponentInstance = {
11
11
  userComponentInstanceFields: Array<UserComponentInstanceField>;
12
12
  assignedPassengers: Array<AssignedPassenger>;
13
13
  assignedTravellerGroups: Array<AssignedTravellerGroup>;
14
+ startDate?: string;
15
+ endDate?: string;
16
+ price?: number;
17
+ currency?: string;
18
+ commissionPercent?: number;
19
+ partner?: string;
14
20
  };
@@ -0,0 +1,6 @@
1
+ export type DTORegionUpdate = {
2
+ name: string;
3
+ description: string;
4
+ destination: string;
5
+ images: Array<string>;
6
+ };
@@ -0,0 +1,9 @@
1
+ import type { AssignedPassenger } from './AssignedPassenger';
2
+ export type Fee = {
3
+ name: string;
4
+ reason: string;
5
+ type: string;
6
+ price: number;
7
+ currency: string;
8
+ assignedPassenger: AssignedPassenger;
9
+ };
@@ -0,0 +1,14 @@
1
+ import type { ComponentInstance } from './ComponentInstance';
2
+ import type { Fee } from './Fee';
3
+ import type { Metadata } from './Metadata';
4
+ export type Itinerary = {
5
+ /**
6
+ * Unique identifier
7
+ */
8
+ id: string;
9
+ title: string;
10
+ enquirerId: string;
11
+ metadata: Metadata;
12
+ componentInstances: Array<ComponentInstance>;
13
+ fees: Array<Fee>;
14
+ };
@@ -0,0 +1,13 @@
1
+ import type { Metadata } from './Metadata';
2
+ import type { ValidationSchemas } from './ValidationSchemas';
3
+ export type Template = {
4
+ id: string;
5
+ orgId: string;
6
+ parentRevisionGroupId: string;
7
+ revisionGroupId: string;
8
+ revision: number;
9
+ metadata: Metadata;
10
+ name: string;
11
+ masterSchema: string;
12
+ validationSchemas: ValidationSchemas;
13
+ };
@@ -243,7 +243,7 @@ const unwrapHydra = (json) => {
243
243
  // Get keys
244
244
  const keys = Object.keys(context);
245
245
  if (keys.length != 3) {
246
- console.log("Unexpected number of keys within hydra context:", keys);
246
+ console.error("Unexpected number of keys within hydra context:", keys);
247
247
  return json;
248
248
  }
249
249
  // Get the key that is not hydra
@@ -251,7 +251,7 @@ const unwrapHydra = (json) => {
251
251
  // Main WILL exist, as there are 3 keys and filter max 2
252
252
  const data = json[main];
253
253
  if (!data) {
254
- console.log("Hydra defined key did not exist within object:", Object.keys(json));
254
+ console.error("Hydra defined key did not exist within object:", Object.keys(json));
255
255
  return json;
256
256
  }
257
257
  return data;
@@ -1,6 +1,11 @@
1
1
  import * as Core from "./generated/core/index";
2
2
  import * as Itinerary from "./generated/itinerary/index";
3
3
  import * as Swoop from "./generated/swoop/index";
4
+ export declare const InternalServices: {
5
+ SwoopService: Swoop.SwoopService;
6
+ CoreService: Core.CoreService;
7
+ ItineraryService: Itinerary.ItineraryService;
8
+ };
4
9
  export declare const init: (opts: {
5
10
  itineraryServiceUrl: string;
6
11
  coreServiceUrl: string;
package/dist/api/init.js CHANGED
@@ -2,6 +2,12 @@ import * as Core from "./generated/core/index";
2
2
  import * as Itinerary from "./generated/itinerary/index";
3
3
  import * as Swoop from "./generated/swoop/index";
4
4
  let initalised = false;
5
+ // For internal use
6
+ export const InternalServices = {
7
+ SwoopService: new Swoop.SwoopService(),
8
+ CoreService: new Core.CoreService(),
9
+ ItineraryService: new Itinerary.ItineraryService(),
10
+ };
5
11
  export const init = (opts) => {
6
12
  // Keeps it consitent
7
13
  if (opts.coreServiceUrl.endsWith("/"))
@@ -1,16 +1,13 @@
1
1
  import React from 'react';
2
2
  import { ComponentPool } from '../registry/types';
3
3
  import { MasterSchema, Stage } from '../schema/formSchemaTypes';
4
- interface Props {
4
+ import { JsonSchema, Layout } from '@jsonforms/core';
5
+ interface BaseProps {
5
6
  /**
6
7
  * This should only be used for the initial values, as this is not truly a controlled component.
7
- * Frequent updates of this can cause significant perfomance dips.
8
+ * Frequent updates of this can cause significant performance dips.
8
9
  */
9
10
  initialData: any;
10
- /**
11
- * The master schema for this template
12
- */
13
- schema: MasterSchema;
14
11
  /**
15
12
  * This should not be fed back into the form.
16
13
  * Instead store it as a ref.
@@ -34,6 +31,36 @@ interface Props {
34
31
  * Should readonly fields be hidden
35
32
  */
36
33
  hideReadonlyFields?: boolean;
34
+ /**
35
+ * Hint at which component is being rendered, some forms may depend on component data
36
+ */
37
+ hintComponentId?: string;
38
+ }
39
+ interface SchemaProps extends BaseProps {
40
+ /**
41
+ * The master schema for this template
42
+ */
43
+ schema: MasterSchema;
44
+ /**
45
+ * These overrides are mutually exclusive with `schema`
46
+ */
47
+ overrideJsonSchema?: never;
48
+ overrideUiSchema?: never;
49
+ }
50
+ interface OverrideProps extends BaseProps {
51
+ /**
52
+ * The master schema for this template is mutually exclusive with overrides
53
+ */
54
+ schema?: never;
55
+ /**
56
+ * Override JSON schema
57
+ */
58
+ overrideJsonSchema: JsonSchema;
59
+ /**
60
+ * Override UI layout schema
61
+ */
62
+ overrideUiSchema: Layout;
37
63
  }
64
+ type Props = SchemaProps | OverrideProps;
38
65
  export declare const StyledFormView: React.FC<Props>;
39
66
  export {};
@@ -5,9 +5,11 @@ import { getComponents } from '../registry/components';
5
5
  import { generateJsonSchema } from '../schema/generate/jsonSchemaGenerate';
6
6
  import { generateUiSchema } from '../schema/generate/uiSchemaGenerate';
7
7
  import { initialisedCheck } from '../../api/init';
8
- export const StyledFormView = ({ initialData, schema, onChange, stage, pool, readonly, hideReadonlyFields }) => {
8
+ import ComponentContext from '../contexts/ComponentContext';
9
+ export const StyledFormView = ({ initialData, schema, onChange, stage, pool, readonly, hideReadonlyFields, hintComponentId, overrideJsonSchema, overrideUiSchema }) => {
9
10
  useEffect(initialisedCheck, []);
10
- const json = generateJsonSchema(schema, stage, hideReadonlyFields);
11
- const ui = generateUiSchema(schema, stage, hideReadonlyFields);
12
- return (React.createElement(JsonForms, { onChange: onChange, data: initialData, schema: json, uischema: ui, renderers: [...materialRenderers, ...getComponents(pool)], readonly: readonly, cells: materialCells }));
11
+ const json = overrideJsonSchema || generateJsonSchema(schema, stage, hideReadonlyFields);
12
+ const ui = overrideUiSchema || generateUiSchema(schema, stage, hideReadonlyFields);
13
+ return (React.createElement(ComponentContext, { componentId: hintComponentId, stage: stage },
14
+ React.createElement(JsonForms, { onChange: onChange, data: initialData, schema: json, uischema: ui, renderers: [...materialRenderers, ...getComponents(pool)], readonly: readonly, cells: materialCells })));
13
15
  };
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ import { DTOComponentRead } from '../../api';
3
+ import { Stage } from '../schema/formSchemaTypes';
4
+ interface Exported {
5
+ component?: DTOComponentRead;
6
+ stage: Stage;
7
+ }
8
+ export declare const CompContext: React.Context<Exported | null>;
9
+ export declare const useCompContext: () => Exported;
10
+ interface Props {
11
+ children: React.ReactNode;
12
+ componentId?: string;
13
+ stage: Stage;
14
+ }
15
+ declare const ComponentContext: React.FC<Props>;
16
+ export default ComponentContext;
@@ -0,0 +1,30 @@
1
+ import React, { createContext, useContext, useEffect, useState } from 'react';
2
+ import { InternalServices } from '../../api/init';
3
+ import { CircularProgress } from "@mui/material";
4
+ export const CompContext = createContext(null);
5
+ export const useCompContext = () => {
6
+ const cont = useContext(CompContext);
7
+ if (!cont)
8
+ throw new Error("useCompContext must be used from within a styled form");
9
+ return cont;
10
+ };
11
+ const ComponentContext = ({ children, componentId, stage }) => {
12
+ const [loading, setLoading] = useState(true);
13
+ const [component, setComponent] = useState();
14
+ useEffect(() => {
15
+ setLoading(true);
16
+ if (!componentId)
17
+ setLoading(false);
18
+ else {
19
+ setLoading(true);
20
+ InternalServices.CoreService.componentGet(componentId)
21
+ .then(setComponent)
22
+ .catch((e) => console.error(e.message))
23
+ .finally(() => setLoading(false));
24
+ }
25
+ }, [componentId]);
26
+ if (loading)
27
+ return React.createElement(CircularProgress, null);
28
+ return (React.createElement(CompContext.Provider, { value: { component, stage } }, children));
29
+ };
30
+ export default ComponentContext;
@@ -7,7 +7,6 @@ import React from "react";
7
7
  */
8
8
  export const useLocalErrors = (path) => {
9
9
  const { core } = useJsonForms();
10
- console.log(core);
11
10
  // Filters out errors for the current scope
12
11
  const local = React.useMemo(() => {
13
12
  var _a;
@@ -1,10 +1,9 @@
1
- import { JsonSchema } from "@jsonforms/core";
2
1
  import { TemplateField } from "../schema/formBuilders/formBuilderJsonSchema";
3
2
  import { JsonSchemaWithXType } from "../types/jsonSchema";
4
3
  /**
5
4
  * If type is not a default json schema type, it is treated as x-type.
6
5
  * E.g. "number" will define the default number field, whereas "address" will define a custom field
7
6
  */
8
- export declare const registerType: (name: string, title: string, schema: JsonSchema, options: JsonSchemaWithXType, optionsRequired: boolean) => void;
7
+ export declare const registerType: (name: string, title: string, schema: JsonSchemaWithXType, options: JsonSchemaWithXType, optionsRequired: boolean) => void;
9
8
  export declare const getAllTypes: () => Array<TemplateField>;
10
9
  export declare const getType: (xType: string) => TemplateField | undefined;
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- import React, { useEffect, useMemo, useState } from 'react';
2
+ import React, { useMemo, useState } from 'react';
3
3
  import { Paper, Typography, TextField, Grid, Divider } from '@mui/material';
4
4
  import { registerComponent } from '../registry/components';
5
5
  import { ComponentPool } from '../registry/types';
@@ -20,11 +20,6 @@ const FormAddress = ({ data, onChange, enabled, label, postcodePattern }) => {
20
20
  onChange('postcode', value);
21
21
  };
22
22
  const hasAddress = useMemo(() => !!(data.line1 || data.line2 || data.city || data.county || data.postcode), [data]);
23
- useEffect(() => {
24
- if (hasAddress) {
25
- console.log('Address updated:', data);
26
- }
27
- }, [hasAddress, data]);
28
23
  return (React.createElement(Paper, { sx: { display: 'flex', flexDirection: 'column', gap: 2, p: 2, mb: 1 }, component: "form", noValidate: true, autoComplete: "off" },
29
24
  React.createElement(Typography, { variant: "h6" }, label),
30
25
  React.createElement(Grid, { container: true, spacing: 2 },
@@ -1,20 +1 @@
1
- import { DTOComponentRead } from '../../api/generated/core/exports';
2
- export declare const fetchComponents: () => Promise<{
3
- data: {
4
- revisions: DTOComponentRead[];
5
- id: string;
6
- templateId: string;
7
- revisionGroupId: string;
8
- revision: number;
9
- metadata: import("../../api/generated/core").Metadata;
10
- name: string;
11
- componentFields: Array<import("../../api/generated/core").Field>;
12
- partners: Array<string>;
13
- bundle: Array<import("../../api/generated/core").Bundle>;
14
- startDate?: string | null;
15
- endDate?: string | null;
16
- duration?: number | null;
17
- details: import("../../api/generated/core").ComponentDetails;
18
- state?: string | null;
19
- }[];
20
- }>;
1
+ export {};