@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,95 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { CheckboxCardVariant, CheckboxCardRadius } from './common-types';
|
|
3
|
+
export type RootProps = {
|
|
4
|
+
/**
|
|
5
|
+
* Children components (HiddenInput, Content, slots, etc.)
|
|
6
|
+
*/
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
/**
|
|
9
|
+
* Controlled checked state.
|
|
10
|
+
* When provided, component operates in controlled mode.
|
|
11
|
+
*/
|
|
12
|
+
checked?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Default checked state for uncontrolled mode.
|
|
15
|
+
* @default false
|
|
16
|
+
*/
|
|
17
|
+
defaultChecked?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Callback invoked when checked state changes.
|
|
20
|
+
* @param checked - New checked state
|
|
21
|
+
*/
|
|
22
|
+
onCheckedChange?: (checked: boolean) => void;
|
|
23
|
+
/**
|
|
24
|
+
* Whether the checkbox card is disabled.
|
|
25
|
+
* @default false
|
|
26
|
+
*/
|
|
27
|
+
disabled?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Whether the card is in a loading state.
|
|
30
|
+
* Non-interactive (cursor not-allowed, clicks blocked) but not visually disabled.
|
|
31
|
+
* @default false
|
|
32
|
+
*/
|
|
33
|
+
loading?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Whether the checkbox is required.
|
|
36
|
+
* @default false
|
|
37
|
+
*/
|
|
38
|
+
required?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Form name attribute.
|
|
41
|
+
*/
|
|
42
|
+
name?: string;
|
|
43
|
+
/**
|
|
44
|
+
* Form value attribute.
|
|
45
|
+
*/
|
|
46
|
+
value?: string;
|
|
47
|
+
/**
|
|
48
|
+
* Visual variant based on background context.
|
|
49
|
+
* @default "onCanvasDefault"
|
|
50
|
+
*/
|
|
51
|
+
variant?: CheckboxCardVariant;
|
|
52
|
+
/**
|
|
53
|
+
* Border radius style.
|
|
54
|
+
* @default "rounded"
|
|
55
|
+
*/
|
|
56
|
+
radius?: CheckboxCardRadius;
|
|
57
|
+
/**
|
|
58
|
+
* ARIA label for accessibility.
|
|
59
|
+
* Provide if no visible label is present.
|
|
60
|
+
*/
|
|
61
|
+
'aria-label'?: string;
|
|
62
|
+
/**
|
|
63
|
+
* ID of element that labels this component.
|
|
64
|
+
*/
|
|
65
|
+
'aria-labelledby'?: string;
|
|
66
|
+
/**
|
|
67
|
+
* ID of element that describes this component.
|
|
68
|
+
*/
|
|
69
|
+
'aria-describedby'?: string;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* BpkCheckboxCard.Root - Root container for checkbox card compound component.
|
|
73
|
+
*
|
|
74
|
+
* Built on Ark UI's CheckboxRoot which renders as a <label> element, providing
|
|
75
|
+
* built-in accessibility, keyboard navigation, and form integration.
|
|
76
|
+
*
|
|
77
|
+
* @example Controlled mode
|
|
78
|
+
* <BpkCheckboxCard.Root checked={selected} onCheckedChange={setSelected}>
|
|
79
|
+
* <BpkCheckboxCard.HiddenInput />
|
|
80
|
+
* <BpkCheckboxCard.Content>
|
|
81
|
+
* <BpkCheckboxCard.Label>City Centre</BpkCheckboxCard.Label>
|
|
82
|
+
* </BpkCheckboxCard.Content>
|
|
83
|
+
* </BpkCheckboxCard.Root>
|
|
84
|
+
*
|
|
85
|
+
* @example Uncontrolled mode
|
|
86
|
+
* <BpkCheckboxCard.Root defaultChecked={false}>
|
|
87
|
+
* <BpkCheckboxCard.HiddenInput />
|
|
88
|
+
* <BpkCheckboxCard.Content>
|
|
89
|
+
* <BpkCheckboxCard.Label>City Centre</BpkCheckboxCard.Label>
|
|
90
|
+
* </BpkCheckboxCard.Content>
|
|
91
|
+
* </BpkCheckboxCard.Root>
|
|
92
|
+
*
|
|
93
|
+
* @returns {JSX.Element} The rendered checkbox card root element.
|
|
94
|
+
*/
|
|
95
|
+
export declare function Root({ 'aria-describedby': ariaDescribedby, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledby, checked, children, defaultChecked, disabled, loading, name, onCheckedChange, radius, required, value, variant, }: RootProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,101 @@
|
|
|
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 { useMemo } from 'react';
|
|
20
|
+
import { CheckboxRoot } from '@ark-ui/react';
|
|
21
|
+
import { withButtonAlignment } from "../../bpk-component-icon";
|
|
22
|
+
import TickCircleIcon from "../../bpk-component-icon/sm/tick-circle";
|
|
23
|
+
import { cssModules } from "../../bpk-react-utils";
|
|
24
|
+
import { CheckboxCardContext } from "./CheckboxCardContext";
|
|
25
|
+
import { CHECKBOX_CARD_VARIANTS, CHECKBOX_CARD_RADIUS } from "./common-types";
|
|
26
|
+
import STYLES from "./BpkCheckboxCard.module.css";
|
|
27
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
28
|
+
const getClassName = cssModules(STYLES);
|
|
29
|
+
const AlignedTickCircleIcon = withButtonAlignment(TickCircleIcon);
|
|
30
|
+
/**
|
|
31
|
+
* BpkCheckboxCard.Root - Root container for checkbox card compound component.
|
|
32
|
+
*
|
|
33
|
+
* Built on Ark UI's CheckboxRoot which renders as a <label> element, providing
|
|
34
|
+
* built-in accessibility, keyboard navigation, and form integration.
|
|
35
|
+
*
|
|
36
|
+
* @example Controlled mode
|
|
37
|
+
* <BpkCheckboxCard.Root checked={selected} onCheckedChange={setSelected}>
|
|
38
|
+
* <BpkCheckboxCard.HiddenInput />
|
|
39
|
+
* <BpkCheckboxCard.Content>
|
|
40
|
+
* <BpkCheckboxCard.Label>City Centre</BpkCheckboxCard.Label>
|
|
41
|
+
* </BpkCheckboxCard.Content>
|
|
42
|
+
* </BpkCheckboxCard.Root>
|
|
43
|
+
*
|
|
44
|
+
* @example Uncontrolled mode
|
|
45
|
+
* <BpkCheckboxCard.Root defaultChecked={false}>
|
|
46
|
+
* <BpkCheckboxCard.HiddenInput />
|
|
47
|
+
* <BpkCheckboxCard.Content>
|
|
48
|
+
* <BpkCheckboxCard.Label>City Centre</BpkCheckboxCard.Label>
|
|
49
|
+
* </BpkCheckboxCard.Content>
|
|
50
|
+
* </BpkCheckboxCard.Root>
|
|
51
|
+
*
|
|
52
|
+
* @returns {JSX.Element} The rendered checkbox card root element.
|
|
53
|
+
*/
|
|
54
|
+
|
|
55
|
+
export function Root({
|
|
56
|
+
'aria-describedby': ariaDescribedby,
|
|
57
|
+
'aria-label': ariaLabel,
|
|
58
|
+
'aria-labelledby': ariaLabelledby,
|
|
59
|
+
checked,
|
|
60
|
+
children,
|
|
61
|
+
defaultChecked,
|
|
62
|
+
disabled = false,
|
|
63
|
+
loading = false,
|
|
64
|
+
name,
|
|
65
|
+
onCheckedChange,
|
|
66
|
+
radius = CHECKBOX_CARD_RADIUS.rounded,
|
|
67
|
+
required = false,
|
|
68
|
+
value,
|
|
69
|
+
variant = CHECKBOX_CARD_VARIANTS.onCanvasDefault
|
|
70
|
+
}) {
|
|
71
|
+
const contextValue = useMemo(() => ({
|
|
72
|
+
variant,
|
|
73
|
+
radius,
|
|
74
|
+
loading
|
|
75
|
+
}), [variant, radius, loading]);
|
|
76
|
+
return /*#__PURE__*/_jsx(CheckboxCardContext.Provider, {
|
|
77
|
+
value: contextValue,
|
|
78
|
+
children: /*#__PURE__*/_jsx(CheckboxRoot, {
|
|
79
|
+
checked: checked,
|
|
80
|
+
defaultChecked: defaultChecked,
|
|
81
|
+
onCheckedChange: details => onCheckedChange?.(details.checked),
|
|
82
|
+
disabled: disabled || loading,
|
|
83
|
+
name: name,
|
|
84
|
+
value: value,
|
|
85
|
+
required: required,
|
|
86
|
+
asChild: true,
|
|
87
|
+
children: /*#__PURE__*/_jsxs("label", {
|
|
88
|
+
"aria-label": ariaLabel,
|
|
89
|
+
"aria-labelledby": ariaLabelledby,
|
|
90
|
+
"aria-describedby": ariaDescribedby,
|
|
91
|
+
"data-loading": loading || undefined,
|
|
92
|
+
className: getClassName('bpk-checkbox-card-root', `bpk-checkbox-card-root--${variant}`, `bpk-checkbox-card-root--radius-${radius}`),
|
|
93
|
+
children: [variant === CHECKBOX_CARD_VARIANTS.cars && /*#__PURE__*/_jsx("div", {
|
|
94
|
+
className: getClassName('bpk-checkbox-card-indicator'),
|
|
95
|
+
"aria-hidden": true,
|
|
96
|
+
children: /*#__PURE__*/_jsx(AlignedTickCircleIcon, {})
|
|
97
|
+
}), children]
|
|
98
|
+
})
|
|
99
|
+
})
|
|
100
|
+
});
|
|
101
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { CheckboxCardVariant, CheckboxCardRadius } from './common-types';
|
|
2
|
+
/**
|
|
3
|
+
* Context value for checkbox card components.
|
|
4
|
+
* Holds only Backpack-specific props (variant, radius, size).
|
|
5
|
+
* Checkbox state (checked, disabled, etc.) is accessed via Ark UI's useCheckboxContext().
|
|
6
|
+
*/
|
|
7
|
+
export type CheckboxCardContextValue = {
|
|
8
|
+
/** Visual variant based on background context */
|
|
9
|
+
variant: CheckboxCardVariant;
|
|
10
|
+
/** Border radius style */
|
|
11
|
+
radius: CheckboxCardRadius;
|
|
12
|
+
/** Whether the card is in a loading state (non-interactive, cursor not-allowed) */
|
|
13
|
+
loading: boolean;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* React Context for BPK-specific checkbox card configuration.
|
|
17
|
+
* Checkbox state is managed by Ark UI's CheckboxRoot and accessed via useCheckboxContext().
|
|
18
|
+
*/
|
|
19
|
+
export declare const CheckboxCardContext: import("react").Context<CheckboxCardContextValue | null>;
|
|
20
|
+
/**
|
|
21
|
+
* Hook to access BPK checkbox card context.
|
|
22
|
+
* Must be used within a BpkCheckboxCard.Root component.
|
|
23
|
+
*
|
|
24
|
+
* @throws Error if used outside of BpkCheckboxCard.Root
|
|
25
|
+
* @returns {CheckboxCardContextValue} The checkbox card context value.
|
|
26
|
+
*/
|
|
27
|
+
export declare function useCheckboxCardContext(): CheckboxCardContextValue;
|
|
@@ -0,0 +1,47 @@
|
|
|
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 { createContext, useContext } from 'react';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Context value for checkbox card components.
|
|
23
|
+
* Holds only Backpack-specific props (variant, radius, size).
|
|
24
|
+
* Checkbox state (checked, disabled, etc.) is accessed via Ark UI's useCheckboxContext().
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* React Context for BPK-specific checkbox card configuration.
|
|
29
|
+
* Checkbox state is managed by Ark UI's CheckboxRoot and accessed via useCheckboxContext().
|
|
30
|
+
*/
|
|
31
|
+
export const CheckboxCardContext = /*#__PURE__*/createContext(null);
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Hook to access BPK checkbox card context.
|
|
35
|
+
* Must be used within a BpkCheckboxCard.Root component.
|
|
36
|
+
*
|
|
37
|
+
* @throws Error if used outside of BpkCheckboxCard.Root
|
|
38
|
+
* @returns {CheckboxCardContextValue} The checkbox card context value.
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
export function useCheckboxCardContext() {
|
|
42
|
+
const context = useContext(CheckboxCardContext);
|
|
43
|
+
if (!context) {
|
|
44
|
+
throw new Error('CheckboxCard compound components must be used within BpkCheckboxCard.Root. ' + 'Make sure you have wrapped your components in <BpkCheckboxCard.Root>.');
|
|
45
|
+
}
|
|
46
|
+
return context;
|
|
47
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Variant types for visual presentation based on canvas/surface background
|
|
3
|
+
* - onCanvasDefault: For use on default/white backgrounds (selected: dark blue #05203C)
|
|
4
|
+
* - onCanvasContrast: For use on contrast/colored backgrounds (selected: dark blue #05203C)
|
|
5
|
+
* - onSurfaceContrast: For use on contrast surfaces (selected: accent blue #0062E3)
|
|
6
|
+
* - cars: For use in cars product context — same styling as onCanvasDefault but with
|
|
7
|
+
* the corner Indicator automatically rendered (no need to add <BpkCheckboxCard.Indicator />)
|
|
8
|
+
*/
|
|
9
|
+
export declare const CHECKBOX_CARD_VARIANTS: {
|
|
10
|
+
readonly onCanvasDefault: "on-canvas-default";
|
|
11
|
+
readonly onCanvasContrast: "on-canvas-contrast";
|
|
12
|
+
readonly onSurfaceContrast: "on-surface-contrast";
|
|
13
|
+
readonly cars: "cars";
|
|
14
|
+
};
|
|
15
|
+
export type CheckboxCardVariant = (typeof CHECKBOX_CARD_VARIANTS)[keyof typeof CHECKBOX_CARD_VARIANTS];
|
|
16
|
+
/**
|
|
17
|
+
* Radius types for border-radius
|
|
18
|
+
*/
|
|
19
|
+
export declare const CHECKBOX_CARD_RADIUS: {
|
|
20
|
+
readonly square: "square";
|
|
21
|
+
readonly rounded: "rounded";
|
|
22
|
+
};
|
|
23
|
+
export type CheckboxCardRadius = (typeof CHECKBOX_CARD_RADIUS)[keyof typeof CHECKBOX_CARD_RADIUS];
|
|
24
|
+
/**
|
|
25
|
+
* Change handler signature for checkbox card
|
|
26
|
+
*/
|
|
27
|
+
export type CheckboxCardChangeHandler = (checked: boolean) => void;
|
|
@@ -0,0 +1,43 @@
|
|
|
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
|
+
/**
|
|
20
|
+
* Variant types for visual presentation based on canvas/surface background
|
|
21
|
+
* - onCanvasDefault: For use on default/white backgrounds (selected: dark blue #05203C)
|
|
22
|
+
* - onCanvasContrast: For use on contrast/colored backgrounds (selected: dark blue #05203C)
|
|
23
|
+
* - onSurfaceContrast: For use on contrast surfaces (selected: accent blue #0062E3)
|
|
24
|
+
* - cars: For use in cars product context — same styling as onCanvasDefault but with
|
|
25
|
+
* the corner Indicator automatically rendered (no need to add <BpkCheckboxCard.Indicator />)
|
|
26
|
+
*/
|
|
27
|
+
export const CHECKBOX_CARD_VARIANTS = {
|
|
28
|
+
onCanvasDefault: 'on-canvas-default',
|
|
29
|
+
onCanvasContrast: 'on-canvas-contrast',
|
|
30
|
+
onSurfaceContrast: 'on-surface-contrast',
|
|
31
|
+
cars: 'cars'
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Radius types for border-radius
|
|
35
|
+
*/
|
|
36
|
+
export const CHECKBOX_CARD_RADIUS = {
|
|
37
|
+
square: 'square',
|
|
38
|
+
rounded: 'rounded'
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Change handler signature for checkbox card
|
|
43
|
+
*/
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Theme attributes for BpkCheckboxCard component.
|
|
3
|
+
*
|
|
4
|
+
* These attributes can be customized using BpkThemeProvider to override
|
|
5
|
+
* the default colors and styles of the checkbox card.
|
|
6
|
+
*
|
|
7
|
+
* Use `createCheckboxCardTheme` to build a partial theme — only specify
|
|
8
|
+
* the attributes you want to change; the rest fall back to design tokens.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* import BpkThemeProvider from '@skyscanner/backpack-web/bpk-theming';
|
|
12
|
+
* import {
|
|
13
|
+
* BpkCheckboxCard,
|
|
14
|
+
* CHECKBOX_CARD_THEME_ATTRIBUTES,
|
|
15
|
+
* createCheckboxCardTheme,
|
|
16
|
+
* } from '@skyscanner/backpack-web/bpk-component-checkbox-card';
|
|
17
|
+
*
|
|
18
|
+
* const theme = createCheckboxCardTheme({
|
|
19
|
+
* checkboxCardCheckedBackgroundColor: '#FFFFFF',
|
|
20
|
+
* checkboxCardCheckedTextColor: '#111236',
|
|
21
|
+
* checkboxCardCheckedBorderColor: '#111236',
|
|
22
|
+
* checkboxCardIndicatorBackgroundColor: '#111236',
|
|
23
|
+
* });
|
|
24
|
+
*
|
|
25
|
+
* <BpkThemeProvider theme={theme} themeAttributes={CHECKBOX_CARD_THEME_ATTRIBUTES}>
|
|
26
|
+
* <BpkCheckboxCard.Root>
|
|
27
|
+
* ...
|
|
28
|
+
* </BpkCheckboxCard.Root>
|
|
29
|
+
* </BpkThemeProvider>
|
|
30
|
+
*/
|
|
31
|
+
declare const CHECKBOX_CARD_THEME_ATTRIBUTES: readonly ["checkboxCardDefaultBackgroundColor", "checkboxCardDefaultTextColor", "checkboxCardSecondaryTextColor", "checkboxCardHoverBackgroundColor", "checkboxCardDefaultBorderColor", "checkboxCardHoverBorderColor", "checkboxCardCheckedBackgroundColor", "checkboxCardCheckedTextColor", "checkboxCardCheckedBorderColor", "checkboxCardDisabledBackgroundColor", "checkboxCardDisabledTextColor", "checkboxCardIndicatorBackgroundColor", "checkboxCardIndicatorTextColor"];
|
|
32
|
+
type CheckboxCardThemeKey = (typeof CHECKBOX_CARD_THEME_ATTRIBUTES)[number];
|
|
33
|
+
type CheckboxCardTheme = Record<CheckboxCardThemeKey, string>;
|
|
34
|
+
/**
|
|
35
|
+
* Creates a complete BpkCheckboxCard theme by merging your overrides with the
|
|
36
|
+
* default design-token values. Pass only the attributes you want to change.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* const theme = createCheckboxCardTheme({
|
|
40
|
+
* checkboxCardCheckedBackgroundColor: '#FFFFFF',
|
|
41
|
+
* checkboxCardCheckedBorderColor: '#111236',
|
|
42
|
+
* checkboxCardIndicatorBackgroundColor: '#111236',
|
|
43
|
+
* });
|
|
44
|
+
*/
|
|
45
|
+
export declare function createCheckboxCardTheme(overrides?: Partial<CheckboxCardTheme>): CheckboxCardTheme;
|
|
46
|
+
export default CHECKBOX_CARD_THEME_ATTRIBUTES;
|
|
@@ -0,0 +1,87 @@
|
|
|
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 { canvasDay, coreAccentDay, colorWhite, lineDay, surfaceContrastDay, surfaceLowContrastDay, textDisabledDay, textOnDarkDay, textPrimaryDay, textSecondaryDay } from '@skyscanner/bpk-foundations-web/tokens/base.es6';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Theme attributes for BpkCheckboxCard component.
|
|
23
|
+
*
|
|
24
|
+
* These attributes can be customized using BpkThemeProvider to override
|
|
25
|
+
* the default colors and styles of the checkbox card.
|
|
26
|
+
*
|
|
27
|
+
* Use `createCheckboxCardTheme` to build a partial theme — only specify
|
|
28
|
+
* the attributes you want to change; the rest fall back to design tokens.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* import BpkThemeProvider from '@skyscanner/backpack-web/bpk-theming';
|
|
32
|
+
* import {
|
|
33
|
+
* BpkCheckboxCard,
|
|
34
|
+
* CHECKBOX_CARD_THEME_ATTRIBUTES,
|
|
35
|
+
* createCheckboxCardTheme,
|
|
36
|
+
* } from '@skyscanner/backpack-web/bpk-component-checkbox-card';
|
|
37
|
+
*
|
|
38
|
+
* const theme = createCheckboxCardTheme({
|
|
39
|
+
* checkboxCardCheckedBackgroundColor: '#FFFFFF',
|
|
40
|
+
* checkboxCardCheckedTextColor: '#111236',
|
|
41
|
+
* checkboxCardCheckedBorderColor: '#111236',
|
|
42
|
+
* checkboxCardIndicatorBackgroundColor: '#111236',
|
|
43
|
+
* });
|
|
44
|
+
*
|
|
45
|
+
* <BpkThemeProvider theme={theme} themeAttributes={CHECKBOX_CARD_THEME_ATTRIBUTES}>
|
|
46
|
+
* <BpkCheckboxCard.Root>
|
|
47
|
+
* ...
|
|
48
|
+
* </BpkCheckboxCard.Root>
|
|
49
|
+
* </BpkThemeProvider>
|
|
50
|
+
*/
|
|
51
|
+
const CHECKBOX_CARD_THEME_ATTRIBUTES = ['checkboxCardDefaultBackgroundColor', 'checkboxCardDefaultTextColor', 'checkboxCardSecondaryTextColor', 'checkboxCardHoverBackgroundColor', 'checkboxCardDefaultBorderColor', 'checkboxCardHoverBorderColor', 'checkboxCardCheckedBackgroundColor', 'checkboxCardCheckedTextColor', 'checkboxCardCheckedBorderColor', 'checkboxCardDisabledBackgroundColor', 'checkboxCardDisabledTextColor', 'checkboxCardIndicatorBackgroundColor', 'checkboxCardIndicatorTextColor'];
|
|
52
|
+
/** Default theme values matching the SCSS token fallbacks */
|
|
53
|
+
const CHECKBOX_CARD_DEFAULT_THEME = {
|
|
54
|
+
checkboxCardDefaultBackgroundColor: canvasDay,
|
|
55
|
+
checkboxCardDefaultTextColor: textPrimaryDay,
|
|
56
|
+
checkboxCardSecondaryTextColor: textSecondaryDay,
|
|
57
|
+
checkboxCardHoverBackgroundColor: surfaceLowContrastDay,
|
|
58
|
+
checkboxCardDefaultBorderColor: lineDay,
|
|
59
|
+
checkboxCardHoverBorderColor: lineDay,
|
|
60
|
+
checkboxCardCheckedBackgroundColor: surfaceContrastDay,
|
|
61
|
+
checkboxCardCheckedTextColor: textOnDarkDay,
|
|
62
|
+
checkboxCardCheckedBorderColor: 'transparent',
|
|
63
|
+
checkboxCardDisabledBackgroundColor: canvasDay,
|
|
64
|
+
checkboxCardDisabledTextColor: textDisabledDay,
|
|
65
|
+
checkboxCardIndicatorBackgroundColor: coreAccentDay,
|
|
66
|
+
checkboxCardIndicatorTextColor: colorWhite
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Creates a complete BpkCheckboxCard theme by merging your overrides with the
|
|
71
|
+
* default design-token values. Pass only the attributes you want to change.
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* const theme = createCheckboxCardTheme({
|
|
75
|
+
* checkboxCardCheckedBackgroundColor: '#FFFFFF',
|
|
76
|
+
* checkboxCardCheckedBorderColor: '#111236',
|
|
77
|
+
* checkboxCardIndicatorBackgroundColor: '#111236',
|
|
78
|
+
* });
|
|
79
|
+
*/
|
|
80
|
+
|
|
81
|
+
export function createCheckboxCardTheme(overrides = {}) {
|
|
82
|
+
return {
|
|
83
|
+
...CHECKBOX_CARD_DEFAULT_THEME,
|
|
84
|
+
...overrides
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
export default CHECKBOX_CARD_THEME_ATTRIBUTES;
|