@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.
- package/.circleci/config.yml +2 -2
- package/.prettierignore +5 -1
- package/.storybook/main.ts +1 -1
- package/.vscode/extensions.json +7 -0
- package/.vscode/settings.json +10 -0
- package/.yarn/releases/yarn-4.0.1.cjs +893 -0
- package/.yarn/sdks/eslint/bin/eslint.js +20 -0
- package/.yarn/sdks/eslint/lib/api.js +20 -0
- package/.yarn/sdks/eslint/lib/unsupported-api.js +20 -0
- package/.yarn/sdks/eslint/package.json +14 -0
- package/.yarn/sdks/integrations.yml +5 -0
- package/.yarn/sdks/prettier/bin-prettier.js +20 -0
- package/.yarn/sdks/prettier/index.js +20 -0
- package/.yarn/sdks/prettier/package.json +7 -0
- package/.yarn/sdks/typescript/bin/tsc +20 -0
- package/.yarn/sdks/typescript/bin/tsserver +20 -0
- package/.yarn/sdks/typescript/lib/tsc.js +20 -0
- package/.yarn/sdks/typescript/lib/tsserver.js +225 -0
- package/.yarn/sdks/typescript/lib/tsserverlibrary.js +225 -0
- package/.yarn/sdks/typescript/lib/typescript.js +20 -0
- package/.yarn/sdks/typescript/package.json +10 -0
- package/.yarnrc.yml +3 -0
- package/README.md +4 -0
- package/jest.config.ts +1 -1
- package/package.json +83 -134
- package/react-dist/custom-elements.js +40 -0
- package/react-dist/custom-elements.js.map +7 -0
- package/react-dist/index.js +21 -47
- package/react-dist/index.js.map +7 -0
- package/react-dist/scripts/generate-fixture.d.ts +3 -0
- package/react-dist/scripts/setup-suggestion-data.d.ts +28 -0
- package/react-dist/src/components/DuffelAncillaries/Card.d.ts +14 -0
- package/react-dist/src/components/DuffelAncillaries/Counter.d.ts +10 -0
- package/react-dist/src/components/DuffelAncillaries/DuffelAncillaries.d.ts +3 -0
- package/react-dist/src/components/DuffelAncillaries/DuffelAncillariesCustomElement.d.ts +12 -0
- package/react-dist/src/components/DuffelAncillaries/bags/BaggageSelectionCard.d.ts +11 -0
- package/react-dist/src/components/DuffelAncillaries/bags/BaggageSelectionController.d.ts +13 -0
- package/react-dist/src/components/DuffelAncillaries/bags/BaggageSelectionModal.d.ts +11 -0
- package/react-dist/src/components/DuffelAncillaries/bags/BaggageSelectionModalBody.d.ts +11 -0
- package/react-dist/src/components/DuffelAncillaries/bags/BaggageSelectionModalBodyPassenger.d.ts +13 -0
- package/react-dist/src/components/DuffelAncillaries/bags/BaggageSelectionModalFooter.d.ts +14 -0
- package/react-dist/src/components/DuffelAncillaries/bags/BaggageSelectionModalHeader.d.ts +9 -0
- package/react-dist/src/components/DuffelAncillaries/bags/IncludedBaggageBanner.d.ts +7 -0
- package/react-dist/src/components/DuffelAncillaries/cancel_for_any_reason/CfarSelectionCard.d.ts +10 -0
- package/react-dist/src/components/DuffelAncillaries/cancel_for_any_reason/CfarSelectionModal.d.ts +11 -0
- package/react-dist/src/components/DuffelAncillaries/cancel_for_any_reason/CfarSelectionModalBody.d.ts +7 -0
- package/react-dist/src/components/DuffelAncillaries/cancel_for_any_reason/CfarSelectionModalBodyListItem.d.ts +4 -0
- package/react-dist/src/components/DuffelAncillaries/cancel_for_any_reason/CfarSelectionModalFooter.d.ts +11 -0
- package/react-dist/src/components/DuffelAncillaries/cancel_for_any_reason/CfarSelectionModalHeader.d.ts +2 -0
- package/react-dist/src/components/DuffelAncillaries/seats/Amenity.d.ts +6 -0
- package/react-dist/src/components/DuffelAncillaries/seats/DeckSelect.d.ts +15 -0
- package/react-dist/src/components/DuffelAncillaries/seats/Element.d.ts +15 -0
- package/react-dist/src/components/DuffelAncillaries/seats/EmptyElement.d.ts +2 -0
- package/react-dist/src/components/DuffelAncillaries/seats/ExitElement.d.ts +6 -0
- package/react-dist/src/components/DuffelAncillaries/seats/Legend.d.ts +12 -0
- package/react-dist/src/components/DuffelAncillaries/seats/Row.d.ts +13 -0
- package/react-dist/src/components/DuffelAncillaries/seats/RowSection.d.ts +17 -0
- package/react-dist/src/components/DuffelAncillaries/seats/SeatElement.d.ts +13 -0
- package/react-dist/src/components/DuffelAncillaries/seats/SeatInfo.d.ts +7 -0
- package/react-dist/src/components/DuffelAncillaries/seats/SeatMap.d.ts +12 -0
- package/react-dist/src/components/DuffelAncillaries/seats/SeatMapUnavailable.d.ts +2 -0
- package/react-dist/src/components/DuffelAncillaries/seats/SeatSelectionCard.d.ts +13 -0
- package/react-dist/src/components/DuffelAncillaries/seats/SeatSelectionModal.d.ts +13 -0
- package/react-dist/src/components/DuffelAncillaries/seats/SeatSelectionModalBody.d.ts +4 -0
- package/react-dist/src/components/DuffelAncillaries/seats/SeatSelectionModalFooter.d.ts +16 -0
- package/react-dist/src/components/DuffelAncillaries/seats/SeatSelectionModalHeader.d.ts +10 -0
- package/react-dist/src/components/DuffelAncillaries/seats/SeatUnavailable.d.ts +5 -0
- package/react-dist/src/components/DuffelPayments/DuffelPayments.d.ts +11 -0
- package/react-dist/src/components/DuffelPayments/DuffelPaymentsCustomElement.d.ts +13 -0
- package/react-dist/src/components/PlacesLookup/PlacesLookup.d.ts +20 -0
- package/react-dist/src/components/shared/AnimatedLoaderEllipsis.d.ts +2 -0
- package/react-dist/src/components/shared/Button.d.ts +23 -0
- package/react-dist/src/components/shared/ErrorBoundary.d.ts +13 -0
- package/react-dist/src/components/shared/FetchOfferErrorState.d.ts +5 -0
- package/react-dist/src/components/shared/Icon.d.ts +46 -0
- package/react-dist/src/components/shared/IconButton.d.ts +16 -0
- package/react-dist/src/components/shared/Modal.d.ts +11 -0
- package/react-dist/src/components/shared/NonIdealState.d.ts +4 -0
- package/react-dist/src/components/shared/Stamp.d.ts +7 -0
- package/react-dist/src/components/shared/Tabs.d.ts +16 -0
- package/react-dist/src/custom-elements.d.ts +6 -0
- package/react-dist/src/index.d.ts +7 -0
- package/react-dist/src/lib/captureErrorInSentry.d.ts +1 -0
- package/react-dist/src/lib/compileCreateOrderPayload.d.ts +14 -0
- package/react-dist/src/lib/createPriceFormatters.d.ts +12 -0
- package/react-dist/src/lib/fetchFromDuffelAPI.d.ts +8 -0
- package/react-dist/src/lib/fetchFromFixtures.d.ts +4 -0
- package/react-dist/src/lib/formatAvailableServices.d.ts +12 -0
- package/react-dist/src/lib/formatDate.d.ts +2 -0
- package/react-dist/src/lib/formatSeatMaps.d.ts +4 -0
- package/react-dist/src/lib/getBaggageServiceDescription.d.ts +2 -0
- package/react-dist/src/lib/getCabinsForSegmentAndDeck.d.ts +2 -0
- package/react-dist/src/lib/getCurrencyForSeatMaps.d.ts +10 -0
- package/react-dist/src/lib/getCurrencyForServices.d.ts +11 -0
- package/react-dist/src/lib/getFirstSeatElementMatchingCriteria.d.ts +3 -0
- package/react-dist/src/lib/getPassengerBySegmentList.d.ts +6 -0
- package/react-dist/src/lib/getPassengerInitials.d.ts +1 -0
- package/react-dist/src/lib/getPassengerMapById.d.ts +3 -0
- package/react-dist/src/lib/getPassengerName.d.ts +3 -0
- package/react-dist/src/lib/getRowNumber.d.ts +2 -0
- package/react-dist/src/lib/getSegmentList.d.ts +2 -0
- package/react-dist/src/lib/getServicePriceMapById.d.ts +3 -0
- package/react-dist/src/lib/getSymbols.d.ts +2 -0
- package/react-dist/src/lib/getTotalAmountForServices.d.ts +6 -0
- package/react-dist/src/lib/getTotalQuantity.d.ts +2 -0
- package/react-dist/src/lib/hasHighLuminance.d.ts +1 -0
- package/react-dist/src/lib/hasService.d.ts +2 -0
- package/react-dist/src/lib/hasServiceOfSameMetadataTypeAlreadyBeenSelected.d.ts +3 -0
- package/react-dist/src/lib/hasWings.d.ts +2 -0
- package/react-dist/src/lib/isBaggageService.d.ts +2 -0
- package/react-dist/src/lib/isCancelForAnyReasonService.d.ts +2 -0
- package/react-dist/src/lib/isFixtureOfferId.d.ts +2 -0
- package/react-dist/src/lib/isPayloadComplete.d.ts +2 -0
- package/react-dist/src/lib/isSeatElement.d.ts +2 -0
- package/react-dist/src/lib/logging.d.ts +46 -0
- package/react-dist/src/lib/moneyStringFormatter.d.ts +8 -0
- package/react-dist/src/lib/offerIsExpired.d.ts +2 -0
- package/react-dist/src/lib/retrieveOffer.d.ts +2 -0
- package/react-dist/src/lib/retrieveOfferFromDuffelAPI.d.ts +1 -0
- package/react-dist/src/lib/retrieveSeatMaps.d.ts +2 -0
- package/react-dist/src/lib/retrieveSeatMapsFromDuffelAPI.d.ts +1 -0
- package/react-dist/src/lib/setBodyScrollability.d.ts +1 -0
- package/react-dist/src/lib/validateProps.d.ts +7 -0
- package/react-dist/src/lib/withPlural.d.ts +1 -0
- package/react-dist/src/types/Aircraft.d.ts +14 -0
- package/react-dist/src/types/Airline.d.ts +14 -0
- package/react-dist/src/types/Airport.d.ts +44 -0
- package/react-dist/src/types/City.d.ts +18 -0
- package/react-dist/src/types/CreateOrderPayload.d.ts +72 -0
- package/react-dist/src/types/CurrencyConversion.d.ts +10 -0
- package/react-dist/src/types/DuffelAncillariesProps.d.ts +70 -0
- package/react-dist/src/types/Offer.d.ts +711 -0
- package/react-dist/src/types/Order.d.ts +8 -0
- package/react-dist/src/types/Place.d.ts +8 -0
- package/react-dist/src/types/SeatMap.d.ts +190 -0
- package/react-dist/src/types/index.d.ts +11 -0
- package/scripts/build-and-publish.sh +42 -0
- package/scripts/generate-fixture.ts +2 -2
- package/scripts.tsconfig.json +1 -1
- package/src/components/PlacesLookup/PlacesLookup.tsx +2 -3
- package/src/custom-elements.ts +0 -4
- package/src/examples/just-typescript/.yarn/install-state.gz +0 -0
- package/src/examples/just-typescript/package.json +2 -2
- package/src/examples/just-typescript/yarn.lock +467 -0
- package/src/examples/next/README.md +28 -0
- package/src/examples/next/next-env.d.ts +5 -0
- package/src/examples/next/next.config.js +4 -0
- package/src/examples/next/package.json +24 -0
- package/src/examples/next/src/app/DuffelComponents.tsx +40 -0
- package/src/examples/next/src/app/layout.tsx +18 -0
- package/src/examples/next/src/app/page.tsx +9 -0
- package/src/examples/next/tsconfig.json +27 -0
- package/src/examples/next/yarn.lock +257 -0
- package/src/examples/payments-just-typescript/yarn.lock +154 -0
- package/src/examples/react-app/src/index.tsx +1 -1
- package/src/examples/react-app/yarn.lock +219 -0
- package/src/index.ts +0 -2
- package/src/lib/logging.ts +1 -1
- package/tsconfig.json +9 -3
- package/.github/workflows/autoapprove.yml +0 -18
- package/.github/workflows/release.yml +0 -89
- package/.husky/post-commit +0 -4
- package/.husky/pre-commit +0 -4
- package/.storybook/Storyshots.test.js +0 -3
- package/.storybook/__snapshots__/Storyshots.test.js.snap +0 -67984
- package/src/components/ShowData/ShowData.tsx +0 -38
- package/src/components/ShowData/ShowDataCustomElement.tsx +0 -85
- 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
|
-
};
|