@skyscanner/backpack-web 42.0.0 → 42.2.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.
- package/bpk-component-banner-alert/src/BpkBannerAlert.js +0 -7
- package/bpk-component-breakpoint/src/BpkBreakpoint.js +3 -1
- package/bpk-component-button/src/BpkButton.d.ts +1 -1
- package/bpk-component-button/src/BpkButton.js +17 -3
- package/bpk-component-button/src/BpkButton.module.css +1 -1
- package/bpk-component-button/src/common-types.d.ts +2 -0
- package/bpk-component-calendar/src/utils.js +1 -1
- package/bpk-component-card/index.d.ts +4 -1
- package/bpk-component-card/index.js +3 -1
- package/bpk-component-card/src/BpkCardV2/BpkCardV2.d.ts +27 -0
- package/bpk-component-card/src/BpkCardV2/BpkCardV2.js +57 -0
- package/bpk-component-card/src/BpkCardV2/BpkCardV2.module.css +18 -0
- package/bpk-component-card/src/BpkCardV2/common-types.d.ts +124 -0
- package/bpk-component-card/src/BpkCardV2/common-types.js +102 -0
- package/bpk-component-card/src/BpkCardV2/subcomponents/Body.d.ts +36 -0
- package/bpk-component-card/src/BpkCardV2/subcomponents/Body.js +65 -0
- package/bpk-component-card/src/BpkCardV2/subcomponents/Divider.d.ts +13 -0
- package/bpk-component-card/src/BpkCardV2/subcomponents/Divider.js +37 -0
- package/bpk-component-card/src/BpkCardV2/subcomponents/Footer.d.ts +24 -0
- package/bpk-component-card/src/BpkCardV2/subcomponents/Footer.js +60 -0
- package/bpk-component-card/src/BpkCardV2/subcomponents/Header.d.ts +24 -0
- package/bpk-component-card/src/BpkCardV2/subcomponents/Header.js +60 -0
- package/bpk-component-card/src/BpkCardV2/subcomponents/Root.d.ts +28 -0
- package/bpk-component-card/src/BpkCardV2/subcomponents/Root.js +68 -0
- package/bpk-component-card/src/BpkCardV2/subcomponents/Section.d.ts +22 -0
- package/bpk-component-card/src/BpkCardV2/subcomponents/Section.js +53 -0
- package/bpk-component-card/src/BpkCardV2/subcomponents/resolveDirectionalPadding.d.ts +16 -0
- package/bpk-component-card/src/BpkCardV2/subcomponents/resolveDirectionalPadding.js +32 -0
- package/bpk-component-card-list/src/BpkCardList.module.css +1 -1
- package/bpk-component-card-list/src/BpkCardListRowRail/BpkCardListCarousel.js +3 -3
- package/bpk-component-chatbot-input/index.d.ts +7 -0
- package/bpk-component-chatbot-input/index.js +23 -0
- package/bpk-component-chatbot-input/src/BpkChatbotInput.d.ts +4 -0
- package/bpk-component-chatbot-input/src/BpkChatbotInput.js +118 -0
- package/bpk-component-chatbot-input/src/BpkChatbotInput.module.css +18 -0
- package/bpk-component-chatbot-input/src/InputField/InputField.d.ts +3 -0
- package/bpk-component-chatbot-input/src/InputField/InputField.js +82 -0
- package/bpk-component-chatbot-input/src/InputField.module.css +18 -0
- package/bpk-component-chatbot-input/src/SendButton/SendButton.d.ts +9 -0
- package/bpk-component-chatbot-input/src/SendButton/SendButton.js +47 -0
- package/bpk-component-chatbot-input/src/TextAreaField/TextAreaField.d.ts +10 -0
- package/bpk-component-chatbot-input/src/TextAreaField/TextAreaField.js +93 -0
- package/bpk-component-chatbot-input/src/TextAreaField.module.css +18 -0
- package/bpk-component-chatbot-input/src/common-types.d.ts +37 -0
- package/bpk-component-chatbot-input/src/common-types.js +23 -0
- package/bpk-component-chatbot-input/src/constants.d.ts +5 -0
- package/bpk-component-chatbot-input/src/constants.js +22 -0
- package/bpk-component-chatbot-input/src/hooks/index.d.ts +4 -0
- package/bpk-component-chatbot-input/src/hooks/index.js +22 -0
- package/bpk-component-chatbot-input/src/hooks/useChatbotInput.d.ts +32 -0
- package/bpk-component-chatbot-input/src/hooks/useChatbotInput.js +111 -0
- package/bpk-component-chatbot-input/src/hooks/useChatbotInputManager.d.ts +20 -0
- package/bpk-component-chatbot-input/src/hooks/useChatbotInputManager.js +83 -0
- package/bpk-component-chatbot-input/src/hooks/useInputHandlers.d.ts +8 -0
- package/bpk-component-chatbot-input/src/hooks/useInputHandlers.js +54 -0
- package/bpk-component-chatbot-input/src/hooks/useTextAreaAutoResize.d.ts +22 -0
- package/bpk-component-chatbot-input/src/hooks/useTextAreaAutoResize.js +137 -0
- package/bpk-component-chatbot-input/src/themeAttributes.d.ts +14 -0
- package/bpk-component-chatbot-input/src/themeAttributes.js +34 -0
- package/bpk-component-checkbox/index.d.ts +7 -1
- package/bpk-component-checkbox/index.js +3 -1
- package/bpk-component-checkbox/src/BpkCheckboxV2/BpkCheckboxV2.d.ts +9 -0
- package/bpk-component-checkbox/src/BpkCheckboxV2/BpkCheckboxV2.js +33 -0
- package/bpk-component-checkbox/src/BpkCheckboxV2/BpkCheckboxV2.module.css +18 -0
- package/bpk-component-checkbox/src/BpkCheckboxV2/BpkCheckboxV2Control.d.ts +6 -0
- package/bpk-component-checkbox/src/BpkCheckboxV2/BpkCheckboxV2Control.js +30 -0
- package/bpk-component-checkbox/src/BpkCheckboxV2/BpkCheckboxV2Description.d.ts +6 -0
- package/bpk-component-checkbox/src/BpkCheckboxV2/BpkCheckboxV2Description.js +32 -0
- package/bpk-component-checkbox/src/BpkCheckboxV2/BpkCheckboxV2HiddenInput.d.ts +2 -0
- package/bpk-component-checkbox/src/BpkCheckboxV2/BpkCheckboxV2HiddenInput.js +25 -0
- package/bpk-component-checkbox/src/BpkCheckboxV2/BpkCheckboxV2Indicator.d.ts +2 -0
- package/bpk-component-checkbox/src/BpkCheckboxV2/BpkCheckboxV2Indicator.js +23 -0
- package/bpk-component-checkbox/src/BpkCheckboxV2/BpkCheckboxV2Label.d.ts +6 -0
- package/bpk-component-checkbox/src/BpkCheckboxV2/BpkCheckboxV2Label.js +30 -0
- package/bpk-component-checkbox/src/BpkCheckboxV2/BpkCheckboxV2Root.d.ts +16 -0
- package/bpk-component-checkbox/src/BpkCheckboxV2/BpkCheckboxV2Root.js +49 -0
- package/bpk-component-checkbox/src/BpkCheckboxV2/themeAttributes.d.ts +2 -0
- package/bpk-component-checkbox/src/BpkCheckboxV2/themeAttributes.js +20 -0
- package/bpk-component-checkbox-card/index.d.ts +3 -0
- package/bpk-component-checkbox-card/index.js +20 -0
- package/bpk-component-checkbox-card/src/BpkCheckboxCard.d.ts +128 -0
- package/bpk-component-checkbox-card/src/BpkCheckboxCard.js +216 -0
- package/bpk-component-checkbox-card/src/BpkCheckboxCard.module.css +18 -0
- package/bpk-component-checkbox-card/src/BpkCheckboxCardRoot.d.ts +95 -0
- package/bpk-component-checkbox-card/src/BpkCheckboxCardRoot.js +101 -0
- package/bpk-component-checkbox-card/src/CheckboxCardContext.d.ts +27 -0
- package/bpk-component-checkbox-card/src/CheckboxCardContext.js +47 -0
- package/bpk-component-checkbox-card/src/common-types.d.ts +27 -0
- package/bpk-component-checkbox-card/src/common-types.js +43 -0
- package/bpk-component-checkbox-card/src/themeAttributes.d.ts +46 -0
- package/bpk-component-checkbox-card/src/themeAttributes.js +87 -0
- package/bpk-component-icon/scripts/generate-figma-connect.js +267 -0
- package/bpk-component-inset-banner/index.d.ts +4 -1
- package/bpk-component-inset-banner/index.js +2 -1
- package/bpk-component-inset-banner/src/BpkInsetBannerV3/BpkInsetBannerV3.d.ts +56 -0
- package/bpk-component-inset-banner/src/BpkInsetBannerV3/BpkInsetBannerV3.js +118 -0
- package/bpk-component-inset-banner/src/BpkInsetBannerV3/BpkInsetBannerV3.module.css +18 -0
- package/bpk-component-layout/src/BpkProvider.d.ts +9 -4
- package/bpk-component-layout/src/BpkProvider.js +87 -8
- package/bpk-component-layout/src/types.d.ts +2 -2
- package/bpk-component-link/src/common-types.d.ts +1 -1
- package/bpk-component-modal/index.d.ts +2 -1
- package/bpk-component-modal/index.js +2 -1
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3.d.ts +14 -0
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3.js +43 -0
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3Body/BpkModalV3Body.d.ts +7 -0
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3Body/BpkModalV3Body.js +30 -0
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3Body.module.css +18 -0
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3CloseTrigger/BpkModalV3CloseTrigger.d.ts +7 -0
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3CloseTrigger/BpkModalV3CloseTrigger.js +49 -0
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3CloseTrigger.module.css +18 -0
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3Content/BpkModalV3Content.d.ts +7 -0
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3Content/BpkModalV3Content.js +38 -0
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3Content.module.css +18 -0
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3Context.d.ts +3 -0
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3Context.js +22 -0
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3Description/BpkModalV3Description.d.ts +7 -0
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3Description/BpkModalV3Description.js +28 -0
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3Header/BpkModalV3Header.d.ts +7 -0
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3Header/BpkModalV3Header.js +34 -0
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3Header.module.css +18 -0
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3HeroImage/BpkModalV3HeroImage.d.ts +10 -0
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3HeroImage/BpkModalV3HeroImage.js +44 -0
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3HeroImage.module.css +18 -0
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3Portal/BpkModalV3Portal.d.ts +7 -0
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3Portal/BpkModalV3Portal.js +26 -0
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3Root/BpkModalV3Root.d.ts +13 -0
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3Root/BpkModalV3Root.js +44 -0
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3Scrim/BpkModalV3Scrim.d.ts +2 -0
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3Scrim/BpkModalV3Scrim.js +32 -0
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3Scrim.module.css +18 -0
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3Title/BpkModalV3Title.d.ts +7 -0
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3Title/BpkModalV3Title.js +31 -0
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3Title.module.css +18 -0
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3Trigger/BpkModalV3Trigger.d.ts +8 -0
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3Trigger/BpkModalV3Trigger.js +30 -0
- package/bpk-component-modal/src/BpkModalV3/common-types.d.ts +1 -0
- package/bpk-component-modal/src/BpkModalV3/common-types.js +1 -0
- package/bpk-component-page-indicator/src/NavButton.d.ts +2 -1
- package/bpk-component-scrollable-calendar/src/BpkScrollableCalendarGridList.js +40 -22
- package/bpk-component-scrollable-calendar/src/BpkScrollableCalendarGridList.module.css +1 -1
- package/bpk-component-segmented-control/src/BpkSegmentedControlV2/BpkSegmentedControlV2.js +37 -16
- package/bpk-component-skeleton/src/BpkBaseSkeleton.d.d.ts +1 -0
- package/bpk-component-skeleton/src/BpkSkeleton.d.d.ts +1 -0
- package/bpk-component-table/index.d.ts +2 -1
- package/bpk-component-table/index.js +2 -1
- package/bpk-component-table/src/BpkTable.module.css +1 -1
- package/bpk-component-table/src/BpkTableBody.d.ts +4 -1
- package/bpk-component-table/src/BpkTableBody.js +19 -4
- package/bpk-component-table/src/common-types.d.ts +5 -0
- package/bpk-component-table/src/common-types.js +22 -0
- package/bpk-react-utils/src/Portal.d.ts +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Backpack - Skyscanner's Design System
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2016 Skyscanner Ltd
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { Dialog } from '@ark-ui/react';
|
|
20
|
+
import { cssModules, getDataComponentAttribute } from "../../../../bpk-react-utils";
|
|
21
|
+
import STYLES from "./BpkModalV3Title.module.css";
|
|
22
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
23
|
+
const getClassName = cssModules(STYLES);
|
|
24
|
+
const BpkModalV3Title = ({
|
|
25
|
+
children
|
|
26
|
+
}) => /*#__PURE__*/_jsx(Dialog.Title, {
|
|
27
|
+
className: getClassName('bpk-modal-v3__title'),
|
|
28
|
+
...getDataComponentAttribute('ModalV3Title'),
|
|
29
|
+
children: children
|
|
30
|
+
});
|
|
31
|
+
export default BpkModalV3Title;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Backpack - Skyscanner's Design System
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2016 Skyscanner Ltd
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
.bpk-modal-v3__title{min-width:0;margin:0;flex:1;font-size:inherit;font-weight:inherit}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
type BpkModalV3TriggerProps = {
|
|
3
|
+
children: ReactNode;
|
|
4
|
+
asChild?: boolean;
|
|
5
|
+
};
|
|
6
|
+
declare const BpkModalV3Trigger: ({ asChild, children, }: BpkModalV3TriggerProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export default BpkModalV3Trigger;
|
|
8
|
+
export type { BpkModalV3TriggerProps };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Backpack - Skyscanner's Design System
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2016 Skyscanner Ltd
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { Dialog } from '@ark-ui/react';
|
|
20
|
+
import { getDataComponentAttribute } from "../../../../bpk-react-utils";
|
|
21
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
22
|
+
const BpkModalV3Trigger = ({
|
|
23
|
+
asChild,
|
|
24
|
+
children
|
|
25
|
+
}) => /*#__PURE__*/_jsx(Dialog.Trigger, {
|
|
26
|
+
asChild: asChild,
|
|
27
|
+
...getDataComponentAttribute('ModalV3Trigger'),
|
|
28
|
+
children: children
|
|
29
|
+
});
|
|
30
|
+
export default BpkModalV3Trigger;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type BpkModalV3Type = 'default' | 'full' | 'sheet';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { MouseEvent } from 'react';
|
|
1
2
|
import { BUTTON_TYPES } from '../../bpk-component-button';
|
|
2
3
|
export declare const DIRECTIONS: {
|
|
3
4
|
readonly PREV: "PREV";
|
|
@@ -11,7 +12,7 @@ type Props = {
|
|
|
11
12
|
currentIndex: number;
|
|
12
13
|
direction: Direction;
|
|
13
14
|
disabled?: boolean;
|
|
14
|
-
onClick?: (event:
|
|
15
|
+
onClick?: (event: MouseEvent<HTMLButtonElement>, newIndex: number, direction: Direction) => void;
|
|
15
16
|
type?: ButtonType;
|
|
16
17
|
};
|
|
17
18
|
declare const NavButton: ({ ariaLabel, currentIndex, direction, disabled, onClick, type, }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -25,7 +25,7 @@ import { cssModules, getDataComponentAttribute } from "../../bpk-react-utils";
|
|
|
25
25
|
import BpkScrollableCalendarGrid from "./BpkScrollableCalendarGrid";
|
|
26
26
|
import { getMonthsArray, getMonthItemHeights } from "./utils";
|
|
27
27
|
import STYLES from "./BpkScrollableCalendarGridList.module.css";
|
|
28
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
28
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
29
29
|
const getClassName = cssModules(STYLES);
|
|
30
30
|
|
|
31
31
|
// These constants are here to facilitate calculating the height
|
|
@@ -46,6 +46,7 @@ const BpkScrollableCalendarGridList = props => {
|
|
|
46
46
|
...rest
|
|
47
47
|
} = props;
|
|
48
48
|
const listRef = useRef(null);
|
|
49
|
+
const sentinelRef = useRef(null);
|
|
49
50
|
const startDate = startOfDay(startOfMonth(minDate));
|
|
50
51
|
const endDate = startOfDay(startOfMonth(rest.maxDate));
|
|
51
52
|
const monthsCount = DateUtils.differenceInCalendarMonths(endDate, startDate);
|
|
@@ -54,11 +55,13 @@ const BpkScrollableCalendarGridList = props => {
|
|
|
54
55
|
const rowHeight = customRowHeight;
|
|
55
56
|
// Most calendar grids have 5 rows. Calculate height in px as this is what react-window expects.
|
|
56
57
|
const estimatedMonthItemHeight = (BASE_MONTH_ITEM_HEIGHT + 5 * rowHeight) * DEFAULT_ROOT_FONT_SIZE;
|
|
57
|
-
const getInitialRootFontSize = () => parseFloat(getComputedStyle(document.documentElement).fontSize) || DEFAULT_ROOT_FONT_SIZE;
|
|
58
58
|
|
|
59
59
|
// The `react-window` API requires the height in pixels to be specified
|
|
60
60
|
// To be able to scale text size, we use rem and then we get the root font size so that we can calculate the final value in px
|
|
61
|
-
|
|
61
|
+
// Initialise to the default; the sentinel ResizeObserver corrects this to the true rendered
|
|
62
|
+
// value immediately on mount, so we never rely on getComputedStyle which can be stale under
|
|
63
|
+
// browser font scaling.
|
|
64
|
+
const [rootFontSize, setRootFontSize] = useState(DEFAULT_ROOT_FONT_SIZE);
|
|
62
65
|
const months = useMemo(() => getMonthsArray(startDate, monthsCount), [minDate, monthsCount]);
|
|
63
66
|
const monthItemHeights = useMemo(() => getMonthItemHeights(months, rest.weekStartsOn, COLUMN_COUNT, rowHeight * rootFontSize, BASE_MONTH_ITEM_HEIGHT * rootFontSize), [rootFontSize, months, rest.weekStartsOn]);
|
|
64
67
|
useEffect(() => {
|
|
@@ -67,8 +70,35 @@ const BpkScrollableCalendarGridList = props => {
|
|
|
67
70
|
listRef.current.resetAfterIndex(0);
|
|
68
71
|
}
|
|
69
72
|
}, [monthItemHeights]);
|
|
73
|
+
useEffect(() => {
|
|
74
|
+
// Some browsers apply font scaling at the rendering level without updating getComputedStyle.
|
|
75
|
+
// A sentinel element sized to 1rem lets us measure the true rendered px-per-rem directly,
|
|
76
|
+
// so that react-window item heights stay accurate regardless of browser font scaling.
|
|
77
|
+
const sentinel = sentinelRef.current;
|
|
78
|
+
if (!sentinel || typeof ResizeObserver === 'undefined') return undefined;
|
|
79
|
+
const observer = new ResizeObserver(entries => {
|
|
80
|
+
const entry = entries[0];
|
|
81
|
+
if (entry) {
|
|
82
|
+
const newRootFontSize = entry.contentRect.width || DEFAULT_ROOT_FONT_SIZE;
|
|
83
|
+
setRootFontSize(newRootFontSize);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
observer.observe(sentinel);
|
|
87
|
+
return () => observer.disconnect();
|
|
88
|
+
}, []);
|
|
70
89
|
const getHtmlElement = () => typeof document !== 'undefined' ? document.querySelector('html') : {};
|
|
71
90
|
const getItemSize = index => monthItemHeights[index] || estimatedMonthItemHeight;
|
|
91
|
+
const calculateOffsetInPixels = numberOfMonths => {
|
|
92
|
+
// The `react-window` API requires the scroll offset to be provided in pixels.
|
|
93
|
+
// Here we use the pre-calculated item heights to find the correct pixel offset
|
|
94
|
+
let result = 0;
|
|
95
|
+
for (let i = 0; i < numberOfMonths; i += 1) {
|
|
96
|
+
result += getItemSize(i);
|
|
97
|
+
}
|
|
98
|
+
return result;
|
|
99
|
+
};
|
|
100
|
+
const date = selectionConfiguration?.type === CALENDAR_SELECTION_TYPE.single ? selectionConfiguration?.date : selectionConfiguration?.startDate;
|
|
101
|
+
const selectedDate = focusedDate || date;
|
|
72
102
|
const rowRenderer = ({
|
|
73
103
|
index,
|
|
74
104
|
style
|
|
@@ -85,26 +115,14 @@ const BpkScrollableCalendarGridList = props => {
|
|
|
85
115
|
"aria-hidden": index !== 1
|
|
86
116
|
})
|
|
87
117
|
});
|
|
88
|
-
|
|
89
|
-
// The `react-window` API requires the scroll offset to be provided in pixels.
|
|
90
|
-
// Here we use the pre-calculated item heights to find the correct pixel offset
|
|
91
|
-
let result = 0;
|
|
92
|
-
for (let i = 0; i < numberOfMonths; i += 1) {
|
|
93
|
-
result += getItemSize(i);
|
|
94
|
-
}
|
|
95
|
-
return result;
|
|
96
|
-
};
|
|
97
|
-
const onResize = () => {
|
|
98
|
-
const newRootFontSize = parseFloat(getComputedStyle(document.documentElement).fontSize) || DEFAULT_ROOT_FONT_SIZE;
|
|
99
|
-
setRootFontSize(newRootFontSize);
|
|
100
|
-
};
|
|
101
|
-
const date = selectionConfiguration?.type === CALENDAR_SELECTION_TYPE.single ? selectionConfiguration?.date : selectionConfiguration?.startDate;
|
|
102
|
-
const selectedDate = focusedDate || date;
|
|
103
|
-
return /*#__PURE__*/_jsx("div", {
|
|
118
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
104
119
|
className: getClassName('bpk-scrollable-calendar-grid-list', className),
|
|
105
120
|
...getDataComponentAttribute('ScrollableCalendarGridList'),
|
|
106
|
-
children: /*#__PURE__*/_jsx(
|
|
107
|
-
|
|
121
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
122
|
+
ref: sentinelRef,
|
|
123
|
+
className: getClassName('bpk-scrollable-calendar-grid-list__font-sentinel'),
|
|
124
|
+
"aria-hidden": "true"
|
|
125
|
+
}), /*#__PURE__*/_jsx(AutoSizer, {
|
|
108
126
|
defaultHeight: estimatedMonthItemHeight,
|
|
109
127
|
defaultWidth: ESTIMATED_MONTH_ITEM_WIDTH,
|
|
110
128
|
children: ({
|
|
@@ -124,7 +142,7 @@ const BpkScrollableCalendarGridList = props => {
|
|
|
124
142
|
ref: listRef,
|
|
125
143
|
children: rowRenderer
|
|
126
144
|
})
|
|
127
|
-
})
|
|
145
|
+
})]
|
|
128
146
|
});
|
|
129
147
|
};
|
|
130
148
|
export default BpkScrollableCalendarGridList;
|
|
@@ -15,4 +15,4 @@
|
|
|
15
15
|
* See the License for the specific language governing permissions and
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
|
-
.bpk-scrollable-calendar-grid-list{position:relative;width:100%;height:100%;min-height:26.25rem;overflow-x:hidden;box-sizing:border-box;-ms-overflow-style:-ms-autohiding-scrollbar}
|
|
18
|
+
.bpk-scrollable-calendar-grid-list{position:relative;width:100%;height:100%;min-height:26.25rem;overflow-x:hidden;box-sizing:border-box;-ms-overflow-style:-ms-autohiding-scrollbar}.bpk-scrollable-calendar-grid-list__font-sentinel{position:absolute;visibility:hidden;width:1rem;height:1rem;overflow:hidden;pointer-events:none}
|
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
import {
|
|
19
|
+
import { useRef } from 'react';
|
|
20
|
+
import { SegmentGroup, useLocaleContext } from '@ark-ui/react';
|
|
20
21
|
import { cssModules, getDataComponentAttribute } from "../../../bpk-react-utils";
|
|
21
22
|
import { SEGMENT_TYPES_V2 } from "./common-types";
|
|
22
23
|
import STYLES from "./BpkSegmentedControlV2.module.css";
|
|
@@ -31,22 +32,42 @@ const BpkSegmentedControlV2Root = ({
|
|
|
31
32
|
type = SEGMENT_TYPES_V2.CanvasDefault,
|
|
32
33
|
value
|
|
33
34
|
}) => {
|
|
35
|
+
const {
|
|
36
|
+
dir
|
|
37
|
+
} = useLocaleContext();
|
|
38
|
+
// Tracks the last user-selected value so it can be restored after a key={dir}
|
|
39
|
+
// remount. Without this, uncontrolled usage would reset to defaultValue on every
|
|
40
|
+
// direction change.
|
|
41
|
+
const lastValueRef = useRef(defaultValue);
|
|
34
42
|
const containerClass = getClassName('bpk-segmented-control-v2', `bpk-segmented-control-v2--${type}`, shadow && 'bpk-segmented-control-v2--shadow');
|
|
35
|
-
return
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
43
|
+
return (
|
|
44
|
+
/*#__PURE__*/
|
|
45
|
+
// key={dir} is required because Zag.js measures the indicator position via
|
|
46
|
+
// el.offsetLeft (a physical pixel value) and only re-syncs when `value` changes —
|
|
47
|
+
// it has no listener on locale/direction. When direction changes, LocaleProvider
|
|
48
|
+
// updates the locale context but Zag's internal indicatorRect stays stale, leaving
|
|
49
|
+
// the sliding indicator visually offset. Forcing a remount via key={dir} restarts
|
|
50
|
+
// the Zag machine, which re-measures offsetLeft in the new layout direction.
|
|
51
|
+
// See: decisions/rtl-ark-localeprovider.md — "Zag machine indicator pattern"
|
|
52
|
+
_jsxs(SegmentGroup.Root, {
|
|
53
|
+
className: containerClass,
|
|
54
|
+
value: value,
|
|
55
|
+
defaultValue: lastValueRef.current,
|
|
56
|
+
onValueChange: ({
|
|
57
|
+
value: selectedValue
|
|
58
|
+
}) => {
|
|
59
|
+
if (selectedValue !== null) {
|
|
60
|
+
lastValueRef.current = selectedValue;
|
|
61
|
+
if (onChange) onChange(selectedValue);
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
orientation: "horizontal",
|
|
65
|
+
...getDataComponentAttribute('SegmentedControlV2'),
|
|
66
|
+
children: [/*#__PURE__*/_jsx(SegmentGroup.Label, {
|
|
67
|
+
children: label
|
|
68
|
+
}), children]
|
|
69
|
+
}, dir)
|
|
70
|
+
);
|
|
50
71
|
};
|
|
51
72
|
const BpkSegmentedControlV2Item = ({
|
|
52
73
|
children,
|
|
@@ -4,10 +4,11 @@ import BpkTableCell from './src/BpkTableCell';
|
|
|
4
4
|
import BpkTableHead from './src/BpkTableHead';
|
|
5
5
|
import BpkTableHeadCell from './src/BpkTableHeadCell';
|
|
6
6
|
import BpkTableRow from './src/BpkTableRow';
|
|
7
|
+
import { TABLE_BODY_TYPES } from './src/common-types';
|
|
7
8
|
export type { BpkTableProps } from './src/BpkTable';
|
|
8
9
|
export type { BpkTableHeadProps } from './src/BpkTableHead';
|
|
9
10
|
export type { BpkTableBodyProps } from './src/BpkTableBody';
|
|
10
11
|
export type { BpkTableRowProps } from './src/BpkTableRow';
|
|
11
12
|
export type { BpkTableCellProps } from './src/BpkTableCell';
|
|
12
13
|
export type { BpkTableHeadCellProps } from './src/BpkTableHeadCell';
|
|
13
|
-
export { BpkTable, BpkTableHead, BpkTableBody, BpkTableRow, BpkTableCell, BpkTableHeadCell, };
|
|
14
|
+
export { BpkTable, BpkTableHead, BpkTableBody, BpkTableRow, BpkTableCell, BpkTableHeadCell, TABLE_BODY_TYPES, };
|
|
@@ -22,4 +22,5 @@ import BpkTableCell from "./src/BpkTableCell";
|
|
|
22
22
|
import BpkTableHead from "./src/BpkTableHead";
|
|
23
23
|
import BpkTableHeadCell from "./src/BpkTableHeadCell";
|
|
24
24
|
import BpkTableRow from "./src/BpkTableRow";
|
|
25
|
-
|
|
25
|
+
import { TABLE_BODY_TYPES } from "./src/common-types";
|
|
26
|
+
export { BpkTable, BpkTableHead, BpkTableBody, BpkTableRow, BpkTableCell, BpkTableHeadCell, TABLE_BODY_TYPES };
|
|
@@ -15,4 +15,4 @@
|
|
|
15
15
|
* See the License for the specific language governing permissions and
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
|
-
.bpk-table{width:100%;margin-bottom:.5rem;border-collapse:collapse;table-layout:fixed;box-shadow:0 0 0 1px #c1c7cf}.bpk-table__cell{padding:1rem}.bpk-table__cell--head{background-color:#eff3f8;text-align:left;font-size:1rem;line-height:1.5rem;font-weight:700}html[dir=rtl] .bpk-table__cell--head{text-align:right}.bpk-table__cell--wordBreak{white-space:normal;overflow-wrap:break-word}
|
|
18
|
+
.bpk-table{width:100%;margin-bottom:.5rem;border-collapse:collapse;table-layout:fixed;box-shadow:0 0 0 1px #c1c7cf}.bpk-table__body--striped tr:nth-child(even){background-color:#eff3f8}.bpk-table__cell{padding:1rem}.bpk-table__cell--head{background-color:#eff3f8;text-align:left;font-size:1rem;line-height:1.5rem;font-weight:700}html[dir=rtl] .bpk-table__cell--head{text-align:right}.bpk-table__cell--wordBreak{white-space:normal;overflow-wrap:break-word}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import type { ReactNode, HTMLAttributes } from 'react';
|
|
2
|
+
import type { TableBodyType } from './common-types';
|
|
2
3
|
export interface BpkTableBodyProps extends HTMLAttributes<HTMLTableSectionElement> {
|
|
3
4
|
/** The content of the table */
|
|
4
5
|
children: ReactNode;
|
|
6
|
+
/** The type of table body styling */
|
|
7
|
+
type?: TableBodyType;
|
|
5
8
|
}
|
|
6
|
-
declare const BpkTableBody: (
|
|
9
|
+
declare const BpkTableBody: ({ children, className, type, ...rest }: BpkTableBodyProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
10
|
export default BpkTableBody;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
1
|
/*
|
|
3
2
|
* Backpack - Skyscanner's Design System
|
|
4
3
|
*
|
|
@@ -17,7 +16,23 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
17
16
|
* limitations under the License.
|
|
18
17
|
*/
|
|
19
18
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
import { cssModules, getDataComponentAttribute } from "../../bpk-react-utils";
|
|
20
|
+
import { TABLE_BODY_TYPES } from "./common-types";
|
|
21
|
+
import STYLES from "./BpkTable.module.css";
|
|
22
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
23
|
+
const getClassName = cssModules(STYLES);
|
|
24
|
+
const BpkTableBody = ({
|
|
25
|
+
children,
|
|
26
|
+
className,
|
|
27
|
+
type = TABLE_BODY_TYPES.default,
|
|
28
|
+
...rest
|
|
29
|
+
}) => {
|
|
30
|
+
const classNames = getClassName(type === TABLE_BODY_TYPES.striped && 'bpk-table__body--striped', className);
|
|
31
|
+
return /*#__PURE__*/_jsx("tbody", {
|
|
32
|
+
...rest,
|
|
33
|
+
className: classNames || undefined,
|
|
34
|
+
...getDataComponentAttribute('TableBody'),
|
|
35
|
+
children: children
|
|
36
|
+
});
|
|
37
|
+
};
|
|
23
38
|
export default BpkTableBody;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Backpack - Skyscanner's Design System
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2016 Skyscanner Ltd
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
export const TABLE_BODY_TYPES = {
|
|
20
|
+
default: 'default',
|
|
21
|
+
striped: 'striped'
|
|
22
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skyscanner/backpack-web",
|
|
3
|
-
"version": "42.
|
|
3
|
+
"version": "42.2.0",
|
|
4
4
|
"description": "Backpack Design System web library",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"d3-scale": "^4.0.2",
|
|
38
38
|
"downshift": "^9.0.10",
|
|
39
39
|
"intersection-observer": "^0.12.2",
|
|
40
|
-
"lodash": "^4.17.
|
|
40
|
+
"lodash": "^4.17.23",
|
|
41
41
|
"lodash.clamp": "^4.0.3",
|
|
42
42
|
"lodash.debounce": "^4.0.8",
|
|
43
43
|
"normalize.css": "4.2.0",
|