@duffel/components 3.1.2--prototype.2 → 3.1.3--prototype.2

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 (168) hide show
  1. package/.circleci/config.yml +2 -2
  2. package/.prettierignore +5 -1
  3. package/.storybook/main.ts +1 -1
  4. package/.vscode/extensions.json +7 -0
  5. package/.vscode/settings.json +10 -0
  6. package/.yarn/releases/yarn-4.0.1.cjs +893 -0
  7. package/.yarn/sdks/eslint/bin/eslint.js +20 -0
  8. package/.yarn/sdks/eslint/lib/api.js +20 -0
  9. package/.yarn/sdks/eslint/lib/unsupported-api.js +20 -0
  10. package/.yarn/sdks/eslint/package.json +14 -0
  11. package/.yarn/sdks/integrations.yml +5 -0
  12. package/.yarn/sdks/prettier/bin-prettier.js +20 -0
  13. package/.yarn/sdks/prettier/index.js +20 -0
  14. package/.yarn/sdks/prettier/package.json +7 -0
  15. package/.yarn/sdks/typescript/bin/tsc +20 -0
  16. package/.yarn/sdks/typescript/bin/tsserver +20 -0
  17. package/.yarn/sdks/typescript/lib/tsc.js +20 -0
  18. package/.yarn/sdks/typescript/lib/tsserver.js +225 -0
  19. package/.yarn/sdks/typescript/lib/tsserverlibrary.js +225 -0
  20. package/.yarn/sdks/typescript/lib/typescript.js +20 -0
  21. package/.yarn/sdks/typescript/package.json +10 -0
  22. package/.yarnrc.yml +3 -0
  23. package/README.md +4 -0
  24. package/jest.config.ts +1 -1
  25. package/package.json +83 -134
  26. package/react-dist/custom-elements.js +40 -0
  27. package/react-dist/custom-elements.js.map +7 -0
  28. package/react-dist/index.js +21 -47
  29. package/react-dist/index.js.map +7 -0
  30. package/react-dist/scripts/generate-fixture.d.ts +3 -0
  31. package/react-dist/scripts/setup-suggestion-data.d.ts +28 -0
  32. package/react-dist/src/components/DuffelAncillaries/Card.d.ts +14 -0
  33. package/react-dist/src/components/DuffelAncillaries/Counter.d.ts +10 -0
  34. package/react-dist/src/components/DuffelAncillaries/DuffelAncillaries.d.ts +3 -0
  35. package/react-dist/src/components/DuffelAncillaries/DuffelAncillariesCustomElement.d.ts +12 -0
  36. package/react-dist/src/components/DuffelAncillaries/bags/BaggageSelectionCard.d.ts +11 -0
  37. package/react-dist/src/components/DuffelAncillaries/bags/BaggageSelectionController.d.ts +13 -0
  38. package/react-dist/src/components/DuffelAncillaries/bags/BaggageSelectionModal.d.ts +11 -0
  39. package/react-dist/src/components/DuffelAncillaries/bags/BaggageSelectionModalBody.d.ts +11 -0
  40. package/react-dist/src/components/DuffelAncillaries/bags/BaggageSelectionModalBodyPassenger.d.ts +13 -0
  41. package/react-dist/src/components/DuffelAncillaries/bags/BaggageSelectionModalFooter.d.ts +14 -0
  42. package/react-dist/src/components/DuffelAncillaries/bags/BaggageSelectionModalHeader.d.ts +9 -0
  43. package/react-dist/src/components/DuffelAncillaries/bags/IncludedBaggageBanner.d.ts +7 -0
  44. package/react-dist/src/components/DuffelAncillaries/cancel_for_any_reason/CfarSelectionCard.d.ts +10 -0
  45. package/react-dist/src/components/DuffelAncillaries/cancel_for_any_reason/CfarSelectionModal.d.ts +11 -0
  46. package/react-dist/src/components/DuffelAncillaries/cancel_for_any_reason/CfarSelectionModalBody.d.ts +7 -0
  47. package/react-dist/src/components/DuffelAncillaries/cancel_for_any_reason/CfarSelectionModalBodyListItem.d.ts +4 -0
  48. package/react-dist/src/components/DuffelAncillaries/cancel_for_any_reason/CfarSelectionModalFooter.d.ts +11 -0
  49. package/react-dist/src/components/DuffelAncillaries/cancel_for_any_reason/CfarSelectionModalHeader.d.ts +2 -0
  50. package/react-dist/src/components/DuffelAncillaries/seats/Amenity.d.ts +6 -0
  51. package/react-dist/src/components/DuffelAncillaries/seats/DeckSelect.d.ts +15 -0
  52. package/react-dist/src/components/DuffelAncillaries/seats/Element.d.ts +15 -0
  53. package/react-dist/src/components/DuffelAncillaries/seats/EmptyElement.d.ts +2 -0
  54. package/react-dist/src/components/DuffelAncillaries/seats/ExitElement.d.ts +6 -0
  55. package/react-dist/src/components/DuffelAncillaries/seats/Legend.d.ts +12 -0
  56. package/react-dist/src/components/DuffelAncillaries/seats/Row.d.ts +13 -0
  57. package/react-dist/src/components/DuffelAncillaries/seats/RowSection.d.ts +17 -0
  58. package/react-dist/src/components/DuffelAncillaries/seats/SeatElement.d.ts +13 -0
  59. package/react-dist/src/components/DuffelAncillaries/seats/SeatInfo.d.ts +7 -0
  60. package/react-dist/src/components/DuffelAncillaries/seats/SeatMap.d.ts +12 -0
  61. package/react-dist/src/components/DuffelAncillaries/seats/SeatMapUnavailable.d.ts +2 -0
  62. package/react-dist/src/components/DuffelAncillaries/seats/SeatSelectionCard.d.ts +13 -0
  63. package/react-dist/src/components/DuffelAncillaries/seats/SeatSelectionModal.d.ts +13 -0
  64. package/react-dist/src/components/DuffelAncillaries/seats/SeatSelectionModalBody.d.ts +4 -0
  65. package/react-dist/src/components/DuffelAncillaries/seats/SeatSelectionModalFooter.d.ts +16 -0
  66. package/react-dist/src/components/DuffelAncillaries/seats/SeatSelectionModalHeader.d.ts +10 -0
  67. package/react-dist/src/components/DuffelAncillaries/seats/SeatUnavailable.d.ts +5 -0
  68. package/react-dist/src/components/DuffelPayments/DuffelPayments.d.ts +11 -0
  69. package/react-dist/src/components/DuffelPayments/DuffelPaymentsCustomElement.d.ts +13 -0
  70. package/react-dist/src/components/PlacesLookup/PlacesLookup.d.ts +20 -0
  71. package/react-dist/src/components/shared/AnimatedLoaderEllipsis.d.ts +2 -0
  72. package/react-dist/src/components/shared/Button.d.ts +23 -0
  73. package/react-dist/src/components/shared/ErrorBoundary.d.ts +13 -0
  74. package/react-dist/src/components/shared/FetchOfferErrorState.d.ts +5 -0
  75. package/react-dist/src/components/shared/Icon.d.ts +46 -0
  76. package/react-dist/src/components/shared/IconButton.d.ts +16 -0
  77. package/react-dist/src/components/shared/Modal.d.ts +11 -0
  78. package/react-dist/src/components/shared/NonIdealState.d.ts +4 -0
  79. package/react-dist/src/components/shared/Stamp.d.ts +7 -0
  80. package/react-dist/src/components/shared/Tabs.d.ts +16 -0
  81. package/react-dist/src/custom-elements.d.ts +6 -0
  82. package/react-dist/src/index.d.ts +7 -0
  83. package/react-dist/src/lib/captureErrorInSentry.d.ts +1 -0
  84. package/react-dist/src/lib/compileCreateOrderPayload.d.ts +14 -0
  85. package/react-dist/src/lib/createPriceFormatters.d.ts +12 -0
  86. package/react-dist/src/lib/fetchFromDuffelAPI.d.ts +8 -0
  87. package/react-dist/src/lib/fetchFromFixtures.d.ts +4 -0
  88. package/react-dist/src/lib/formatAvailableServices.d.ts +12 -0
  89. package/react-dist/src/lib/formatDate.d.ts +2 -0
  90. package/react-dist/src/lib/formatSeatMaps.d.ts +4 -0
  91. package/react-dist/src/lib/getBaggageServiceDescription.d.ts +2 -0
  92. package/react-dist/src/lib/getCabinsForSegmentAndDeck.d.ts +2 -0
  93. package/react-dist/src/lib/getCurrencyForSeatMaps.d.ts +10 -0
  94. package/react-dist/src/lib/getCurrencyForServices.d.ts +11 -0
  95. package/react-dist/src/lib/getFirstSeatElementMatchingCriteria.d.ts +3 -0
  96. package/react-dist/src/lib/getPassengerBySegmentList.d.ts +6 -0
  97. package/react-dist/src/lib/getPassengerInitials.d.ts +1 -0
  98. package/react-dist/src/lib/getPassengerMapById.d.ts +3 -0
  99. package/react-dist/src/lib/getPassengerName.d.ts +3 -0
  100. package/react-dist/src/lib/getRowNumber.d.ts +2 -0
  101. package/react-dist/src/lib/getSegmentList.d.ts +2 -0
  102. package/react-dist/src/lib/getServicePriceMapById.d.ts +3 -0
  103. package/react-dist/src/lib/getSymbols.d.ts +2 -0
  104. package/react-dist/src/lib/getTotalAmountForServices.d.ts +6 -0
  105. package/react-dist/src/lib/getTotalQuantity.d.ts +2 -0
  106. package/react-dist/src/lib/hasHighLuminance.d.ts +1 -0
  107. package/react-dist/src/lib/hasService.d.ts +2 -0
  108. package/react-dist/src/lib/hasServiceOfSameMetadataTypeAlreadyBeenSelected.d.ts +3 -0
  109. package/react-dist/src/lib/hasWings.d.ts +2 -0
  110. package/react-dist/src/lib/isBaggageService.d.ts +2 -0
  111. package/react-dist/src/lib/isCancelForAnyReasonService.d.ts +2 -0
  112. package/react-dist/src/lib/isFixtureOfferId.d.ts +2 -0
  113. package/react-dist/src/lib/isPayloadComplete.d.ts +2 -0
  114. package/react-dist/src/lib/isSeatElement.d.ts +2 -0
  115. package/react-dist/src/lib/logging.d.ts +46 -0
  116. package/react-dist/src/lib/moneyStringFormatter.d.ts +8 -0
  117. package/react-dist/src/lib/offerIsExpired.d.ts +2 -0
  118. package/react-dist/src/lib/retrieveOffer.d.ts +2 -0
  119. package/react-dist/src/lib/retrieveOfferFromDuffelAPI.d.ts +1 -0
  120. package/react-dist/src/lib/retrieveSeatMaps.d.ts +2 -0
  121. package/react-dist/src/lib/retrieveSeatMapsFromDuffelAPI.d.ts +1 -0
  122. package/react-dist/src/lib/setBodyScrollability.d.ts +1 -0
  123. package/react-dist/src/lib/validateProps.d.ts +7 -0
  124. package/react-dist/src/lib/withPlural.d.ts +1 -0
  125. package/react-dist/src/types/Aircraft.d.ts +14 -0
  126. package/react-dist/src/types/Airline.d.ts +14 -0
  127. package/react-dist/src/types/Airport.d.ts +44 -0
  128. package/react-dist/src/types/City.d.ts +18 -0
  129. package/react-dist/src/types/CreateOrderPayload.d.ts +72 -0
  130. package/react-dist/src/types/CurrencyConversion.d.ts +10 -0
  131. package/react-dist/src/types/DuffelAncillariesProps.d.ts +70 -0
  132. package/react-dist/src/types/Offer.d.ts +711 -0
  133. package/react-dist/src/types/Order.d.ts +8 -0
  134. package/react-dist/src/types/Place.d.ts +8 -0
  135. package/react-dist/src/types/SeatMap.d.ts +190 -0
  136. package/react-dist/src/types/index.d.ts +11 -0
  137. package/scripts/build-and-publish.sh +42 -0
  138. package/scripts/generate-fixture.ts +2 -2
  139. package/scripts.tsconfig.json +1 -1
  140. package/src/components/PlacesLookup/PlacesLookup.tsx +2 -3
  141. package/src/custom-elements.ts +0 -4
  142. package/src/examples/just-typescript/.yarn/install-state.gz +0 -0
  143. package/src/examples/just-typescript/package.json +2 -2
  144. package/src/examples/just-typescript/yarn.lock +467 -0
  145. package/src/examples/next/README.md +28 -0
  146. package/src/examples/next/next-env.d.ts +5 -0
  147. package/src/examples/next/next.config.js +4 -0
  148. package/src/examples/next/package.json +24 -0
  149. package/src/examples/next/src/app/DuffelComponents.tsx +40 -0
  150. package/src/examples/next/src/app/layout.tsx +18 -0
  151. package/src/examples/next/src/app/page.tsx +9 -0
  152. package/src/examples/next/tsconfig.json +27 -0
  153. package/src/examples/next/yarn.lock +257 -0
  154. package/src/examples/payments-just-typescript/yarn.lock +154 -0
  155. package/src/examples/react-app/src/index.tsx +1 -1
  156. package/src/examples/react-app/yarn.lock +219 -0
  157. package/src/index.ts +0 -2
  158. package/src/lib/logging.ts +1 -1
  159. package/tsconfig.json +9 -3
  160. package/.github/workflows/autoapprove.yml +0 -18
  161. package/.github/workflows/release.yml +0 -89
  162. package/.husky/post-commit +0 -4
  163. package/.husky/pre-commit +0 -4
  164. package/.storybook/Storyshots.test.js +0 -3
  165. package/.storybook/__snapshots__/Storyshots.test.js.snap +0 -67984
  166. package/src/components/ShowData/ShowData.tsx +0 -38
  167. package/src/components/ShowData/ShowDataCustomElement.tsx +0 -85
  168. package/src/stories/ShowData.stories.tsx +0 -16
@@ -1,38 +0,0 @@
1
- import { Button } from "@components/shared/Button";
2
- import React from "react";
3
-
4
- function isJsonString(dataString: string) {
5
- try {
6
- JSON.parse(dataString);
7
- } catch (e) {
8
- return false;
9
- }
10
- return true;
11
- }
12
-
13
- export interface ShowDataProps {
14
- data: any;
15
- onFinished: (newData: any) => void;
16
- }
17
-
18
- export const ShowData: React.FC<ShowDataProps> = ({ data, onFinished }) => {
19
- const [textareaData, setTextareaData] = React.useState("{}");
20
- const isValid = isJsonString(textareaData);
21
-
22
- return (
23
- <div>
24
- <pre>{JSON.stringify(data, null, 2)}</pre>
25
- <textarea
26
- value={textareaData}
27
- onChange={(e) => setTextareaData(e.target.value)}
28
- />
29
- <Button
30
- disabled={!isValid}
31
- onClick={() => onFinished(JSON.parse(textareaData))}
32
- >
33
- Click me to trigger `onFinished` event
34
- </Button>
35
- {!isValid && <p style={{ color: "tomato" }}>Invalid JSON</p>}
36
- </div>
37
- );
38
- };
@@ -1,85 +0,0 @@
1
- import { createRoot, Root } from "react-dom/client";
2
- import { ShowData, ShowDataProps } from "./ShowData";
3
- declare global {
4
- // eslint-disable-next-line @typescript-eslint/no-namespace
5
- namespace JSX {
6
- interface IntrinsicElements {
7
- "show-data": React.DetailedHTMLProps<
8
- React.HTMLAttributes<HTMLElement>,
9
- HTMLElement
10
- >;
11
- }
12
- }
13
- }
14
-
15
- const CUSTOM_ELEMENT_TAG = "show-data";
16
-
17
- type ShowDataRenderArguments = Pick<ShowDataProps, "data">;
18
-
19
- class ShowDataCustomElement extends HTMLElement {
20
- /**
21
- * The React root for displaying content inside a browser DOM element.
22
- */
23
- private root!: Root;
24
-
25
- /**
26
- * `connectedCallback` is called to initialise the custom element
27
- */
28
- connectedCallback() {
29
- const container = document.createElement("div");
30
- this.appendChild(container);
31
-
32
- this.root = createRoot(container);
33
- }
34
-
35
- /**
36
- * When this function is called, it will render/re-render
37
- * the `DuffelPayments` component with the given props.
38
- */
39
- public render(withProps: ShowDataRenderArguments) {
40
- if (!this.root) {
41
- throw "It was not possible to render `duffel-payments` because `this.root` is missing.";
42
- }
43
-
44
- this.root.render(
45
- <ShowData
46
- {...withProps}
47
- onFinished={() => {
48
- this.dispatchEvent(
49
- new CustomEvent("onFinished", {
50
- composed: true,
51
- })
52
- );
53
- }}
54
- />
55
- );
56
- }
57
- }
58
-
59
- window.customElements.get(CUSTOM_ELEMENT_TAG) ||
60
- window.customElements.define(CUSTOM_ELEMENT_TAG, ShowDataCustomElement);
61
-
62
- function tryToGetShowData(caller: string): ShowDataCustomElement {
63
- const element =
64
- document.querySelector<ShowDataCustomElement>(CUSTOM_ELEMENT_TAG);
65
- if (!element) {
66
- throw new Error(
67
- `Could not find duffel-payments element in the DOM. Maybe you need to call ${caller} after 'window.onload'?`
68
- );
69
- }
70
- return element;
71
- }
72
-
73
- export function renderShowDataCustomElement(props: ShowDataRenderArguments) {
74
- const element = tryToGetShowData("renderShowData");
75
- element.render(props);
76
- }
77
-
78
- export function onShowDataFinished(onFinished: ShowDataProps["onFinished"]) {
79
- const element = tryToGetShowData("onShowDataFinished");
80
-
81
- // using `as EventListener` here because typescript doesn't know the event type for `onPayloadReady`
82
- // There's a few different suggestions to resolve this seemed good enough
83
- // You can learn more here: https://github.com/microsoft/TypeScript/issues/28357
84
- element.addEventListener("onFinished", onFinished as EventListener);
85
- }
@@ -1,16 +0,0 @@
1
- import { Meta, StoryObj } from "@storybook/react";
2
- import { ShowData, ShowDataProps } from "../components/ShowData/ShowData";
3
-
4
- export default {
5
- title: "ShowData",
6
- component: ShowData,
7
- } as Meta;
8
-
9
- const defaultProps: ShowDataProps = {
10
- data: { heres: "some test data" },
11
- onFinished: console.log,
12
- };
13
-
14
- export const AllServices: StoryObj<typeof ShowData> = {
15
- args: defaultProps,
16
- };