@skyscanner/backpack-web 42.16.0 → 42.18.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-autosuggest/index.d.ts +6 -0
- package/bpk-component-autosuggest/index.js +3 -1
- package/bpk-component-autosuggest/src/BpkAutosuggest.d.ts +2 -0
- package/bpk-component-autosuggest/src/BpkAutosuggest.js +14 -15
- package/bpk-component-autosuggest/src/BpkAutosuggestSuggestion.d.ts +11 -0
- package/bpk-component-autosuggest/src/BpkAutosuggestSuggestion.js +35 -55
- package/bpk-component-checkbox/index.d.ts +1 -0
- package/bpk-component-checkbox/src/BpkCheckboxV2/BpkCheckboxV2.d.ts +2 -2
- package/bpk-component-checkbox/src/BpkCheckboxV2/BpkCheckboxV2.module.css +1 -1
- package/bpk-component-checkbox/src/BpkCheckboxV2/BpkCheckboxV2HiddenInput.d.ts +6 -1
- package/bpk-component-checkbox/src/BpkCheckboxV2/BpkCheckboxV2HiddenInput.js +13 -3
- package/bpk-component-checkbox/src/BpkCheckboxV2/BpkCheckboxV2Root.d.ts +2 -1
- package/bpk-component-checkbox/src/BpkCheckboxV2/BpkCheckboxV2Root.js +2 -0
- package/bpk-component-collapsible/index.d.ts +11 -0
- package/bpk-component-collapsible/index.js +22 -0
- package/bpk-component-collapsible/src/BpkCollapsible.d.ts +8 -0
- package/bpk-component-collapsible/src/BpkCollapsible.js +31 -0
- package/bpk-component-collapsible/src/BpkCollapsible.module.css +18 -0
- package/bpk-component-collapsible/src/BpkCollapsibleContent.d.ts +6 -0
- package/bpk-component-collapsible/src/BpkCollapsibleContent.js +36 -0
- package/bpk-component-collapsible/src/BpkCollapsibleIndicator.d.ts +6 -0
- package/bpk-component-collapsible/src/BpkCollapsibleIndicator.js +34 -0
- package/bpk-component-collapsible/src/BpkCollapsibleRoot.d.ts +22 -0
- package/bpk-component-collapsible/src/BpkCollapsibleRoot.js +49 -0
- package/bpk-component-collapsible/src/BpkCollapsibleRootProvider.d.ts +10 -0
- package/bpk-component-collapsible/src/BpkCollapsibleRootProvider.js +33 -0
- package/bpk-component-collapsible/src/BpkCollapsibleTrigger.d.ts +6 -0
- package/bpk-component-collapsible/src/BpkCollapsibleTrigger.js +43 -0
- package/bpk-component-collapsible/src/common-types.d.ts +9 -0
- package/bpk-component-collapsible/src/common-types.js +29 -0
- package/bpk-component-collapsible/src/useBpkCollapsible.d.ts +5 -0
- package/bpk-component-collapsible/src/useBpkCollapsible.js +21 -0
- package/bpk-component-fieldset/src/BpkFieldset.js +0 -1
- package/bpk-component-form-validation/index.d.ts +5 -0
- package/bpk-component-form-validation/src/BpkFormValidation.d.ts +12 -0
- package/bpk-component-form-validation/src/BpkFormValidation.js +0 -9
- package/bpk-component-form-validation/src/themeAttributes.d.ts +2 -0
- package/bpk-component-horizontal-nav/index.d.ts +6 -0
- package/bpk-component-horizontal-nav/index.js +3 -1
- package/bpk-component-horizontal-nav/src/BpkHorizontalNav.d.ts +27 -0
- package/bpk-component-horizontal-nav/src/BpkHorizontalNav.js +79 -114
- package/bpk-component-horizontal-nav/src/BpkHorizontalNavItem.d.ts +25 -0
- package/bpk-component-horizontal-nav/src/BpkHorizontalNavItem.js +38 -73
- package/bpk-component-radio/index.d.ts +5 -0
- package/bpk-component-radio/index.js +3 -1
- package/bpk-component-radio/src/BpkRadio.d.ts +13 -0
- package/bpk-component-radio/src/BpkRadio.js +3 -11
- package/bpk-component-radio/src/themeAttributes.d.ts +2 -0
- package/bpk-component-radio/src/themeAttributes.js +3 -1
- package/bpk-component-switch/index.d.ts +3 -3
- package/bpk-component-switch/index.js +2 -2
- package/bpk-component-switch/src/BpkSwitch.d.ts +7 -1
- package/bpk-component-switch/src/BpkSwitch.js +10 -1
- package/bpk-component-switch/src/BpkSwitch.module.css +1 -1
- package/package.json +2 -2
|
@@ -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
|
+
import { forwardRef } from 'react';
|
|
20
|
+
import { Collapsible, useCollapsibleContext } from '@ark-ui/react';
|
|
21
|
+
import { cssModules } from "../../bpk-react-utils";
|
|
22
|
+
import STYLES from "./BpkCollapsible.module.css";
|
|
23
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
24
|
+
const getClassName = cssModules(STYLES);
|
|
25
|
+
// Applies the native HTML `disabled` attribute to the underlying <button> so
|
|
26
|
+
// the trigger is removed from the tab order and announced as disabled by
|
|
27
|
+
// assistive tech. Ark/Zag only emit `data-disabled`, which would otherwise
|
|
28
|
+
// leave the button tabbable and announced as enabled.
|
|
29
|
+
const BpkCollapsibleTrigger = /*#__PURE__*/forwardRef(({
|
|
30
|
+
children
|
|
31
|
+
}, ref) => {
|
|
32
|
+
const {
|
|
33
|
+
disabled
|
|
34
|
+
} = useCollapsibleContext();
|
|
35
|
+
return /*#__PURE__*/_jsx(Collapsible.Trigger, {
|
|
36
|
+
ref: ref,
|
|
37
|
+
className: getClassName('bpk-collapsible__trigger'),
|
|
38
|
+
disabled: disabled,
|
|
39
|
+
children: children
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
BpkCollapsibleTrigger.displayName = 'BpkCollapsibleTrigger';
|
|
43
|
+
export default BpkCollapsibleTrigger;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const COLLAPSIBLE_VARIANTS: {
|
|
2
|
+
readonly default: "default";
|
|
3
|
+
readonly onContrast: "onContrast";
|
|
4
|
+
};
|
|
5
|
+
export type BpkCollapsibleVariant = (typeof COLLAPSIBLE_VARIANTS)[keyof typeof COLLAPSIBLE_VARIANTS];
|
|
6
|
+
export type BpkCollapsibleOpenChangeDetails = {
|
|
7
|
+
open: boolean;
|
|
8
|
+
};
|
|
9
|
+
export declare const getRootClassName: (variant: BpkCollapsibleVariant) => string;
|
|
@@ -0,0 +1,29 @@
|
|
|
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 { cssModules } from "../../bpk-react-utils";
|
|
20
|
+
import STYLES from "./BpkCollapsible.module.css";
|
|
21
|
+
export const COLLAPSIBLE_VARIANTS = {
|
|
22
|
+
default: 'default',
|
|
23
|
+
onContrast: 'onContrast'
|
|
24
|
+
};
|
|
25
|
+
const getClassName = cssModules(STYLES);
|
|
26
|
+
export const getRootClassName = variant => {
|
|
27
|
+
const variantModifier = variant === COLLAPSIBLE_VARIANTS.onContrast ? 'on-contrast' : 'default';
|
|
28
|
+
return getClassName('bpk-collapsible', `bpk-collapsible--${variantModifier}`);
|
|
29
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { UseCollapsibleProps, UseCollapsibleReturn } from '@ark-ui/react';
|
|
2
|
+
export type BpkUseCollapsibleProps = UseCollapsibleProps;
|
|
3
|
+
export type BpkUseCollapsibleReturn = UseCollapsibleReturn;
|
|
4
|
+
declare const useBpkCollapsible: (props?: BpkUseCollapsibleProps) => BpkUseCollapsibleReturn;
|
|
5
|
+
export default useBpkCollapsible;
|
|
@@ -0,0 +1,21 @@
|
|
|
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 { useCollapsible } from '@ark-ui/react';
|
|
20
|
+
const useBpkCollapsible = props => useCollapsible(props);
|
|
21
|
+
export default useBpkCollapsible;
|
|
@@ -17,7 +17,6 @@
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
import { cloneElement } from 'react';
|
|
20
|
-
// @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
|
|
21
20
|
import BpkFormValidation from "../../bpk-component-form-validation";
|
|
22
21
|
import BpkLabel from "../../bpk-component-label";
|
|
23
22
|
import { cssModules, getDataComponentAttribute } from "../../bpk-react-utils";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
import { type Props as AnimateHeightProps } from '../../bpk-animate-height';
|
|
3
|
+
export type Props = Omit<HTMLAttributes<HTMLDivElement>, 'className'> & {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
id: string;
|
|
6
|
+
expanded: boolean;
|
|
7
|
+
isCheckbox?: boolean;
|
|
8
|
+
className?: string | null;
|
|
9
|
+
containerProps?: Partial<AnimateHeightProps>;
|
|
10
|
+
};
|
|
11
|
+
declare const BpkFormValidation: ({ children, className, containerProps, expanded, isCheckbox, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export default BpkFormValidation;
|
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
import PropTypes from 'prop-types';
|
|
20
19
|
import { lineHeightSm, iconSizeSm } from '@skyscanner/bpk-foundations-web/tokens/base.es6';
|
|
21
20
|
import AnimateHeight from "../../bpk-animate-height";
|
|
22
21
|
import { withAlignment } from "../../bpk-component-icon";
|
|
@@ -53,12 +52,4 @@ const BpkFormValidation = ({
|
|
|
53
52
|
})
|
|
54
53
|
});
|
|
55
54
|
};
|
|
56
|
-
BpkFormValidation.propTypes = {
|
|
57
|
-
children: PropTypes.node.isRequired,
|
|
58
|
-
id: PropTypes.string.isRequired,
|
|
59
|
-
expanded: PropTypes.bool.isRequired,
|
|
60
|
-
isCheckbox: PropTypes.bool,
|
|
61
|
-
className: PropTypes.string,
|
|
62
|
-
containerProps: PropTypes.object // eslint-disable-line react/forbid-prop-types
|
|
63
|
-
};
|
|
64
55
|
export default BpkFormValidation;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import BpkHorizontalNav, { HORIZONTAL_NAV_TYPES, type Props as NavProps } from './src/BpkHorizontalNav';
|
|
2
|
+
import BpkHorizontalNavItem, { type Props as ItemProps, themeAttributes } from './src/BpkHorizontalNavItem';
|
|
3
|
+
export type BpkHorizontalNavProps = NavProps;
|
|
4
|
+
export type BpkHorizontalNavItemProps = ItemProps;
|
|
5
|
+
export { HORIZONTAL_NAV_TYPES, BpkHorizontalNavItem, themeAttributes };
|
|
6
|
+
export default BpkHorizontalNav;
|
|
@@ -14,7 +14,9 @@
|
|
|
14
14
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
15
|
* See the License for the specific language governing permissions and
|
|
16
16
|
* limitations under the License.
|
|
17
|
-
*/
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import BpkHorizontalNav, { HORIZONTAL_NAV_TYPES } from "./src/BpkHorizontalNav";
|
|
18
20
|
import BpkHorizontalNavItem, { themeAttributes } from "./src/BpkHorizontalNavItem";
|
|
19
21
|
export { HORIZONTAL_NAV_TYPES, BpkHorizontalNavItem, themeAttributes };
|
|
20
22
|
export default BpkHorizontalNav;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
declare const HORIZONTAL_NAV_TYPES: {
|
|
3
|
+
readonly default: "default";
|
|
4
|
+
readonly light: "light";
|
|
5
|
+
};
|
|
6
|
+
type Props = {
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
ariaLabel?: string | null;
|
|
9
|
+
/**
|
|
10
|
+
* Ensures that the selected item is within view when loaded on narrow-screened devices.
|
|
11
|
+
*/
|
|
12
|
+
autoScrollToSelected?: boolean;
|
|
13
|
+
className?: string | null;
|
|
14
|
+
leadingScrollIndicatorClassName?: string | null;
|
|
15
|
+
/**
|
|
16
|
+
* When set to "false", the bottom border on the component isn't included. This refers
|
|
17
|
+
* to the underline on the whole "BpkHorizontalNav", not the line that appears under the selected item.
|
|
18
|
+
*/
|
|
19
|
+
showUnderline?: boolean;
|
|
20
|
+
trailingScrollIndicatorClassName?: string | null;
|
|
21
|
+
type?: keyof typeof HORIZONTAL_NAV_TYPES;
|
|
22
|
+
[rest: string]: any;
|
|
23
|
+
};
|
|
24
|
+
declare const BpkHorizontalNav: ({ ariaLabel, autoScrollToSelected, children: rawChildren, className, leadingScrollIndicatorClassName, showUnderline, trailingScrollIndicatorClassName, type, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
25
|
+
export type { Props };
|
|
26
|
+
export default BpkHorizontalNav;
|
|
27
|
+
export { HORIZONTAL_NAV_TYPES };
|
|
@@ -14,8 +14,9 @@
|
|
|
14
14
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
15
|
* See the License for the specific language governing permissions and
|
|
16
16
|
* limitations under the License.
|
|
17
|
-
*/
|
|
18
|
-
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { Children, cloneElement, useCallback, useEffect, useRef } from 'react';
|
|
19
20
|
import BpkMobileScrollContainer from "../../bpk-component-mobile-scroll-container";
|
|
20
21
|
import { cssModules } from "../../bpk-react-utils";
|
|
21
22
|
import STYLES from "./BpkHorizontalNav.module.css";
|
|
@@ -29,138 +30,102 @@ const getPos = ref => {
|
|
|
29
30
|
if (!ref) {
|
|
30
31
|
return null;
|
|
31
32
|
}
|
|
32
|
-
|
|
33
|
-
return pos;
|
|
33
|
+
return ref.getBoundingClientRect();
|
|
34
34
|
};
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
scrollSelectedIntoView = useSmoothScroll => {
|
|
50
|
-
if (!
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
if (!this.scrollRef) {
|
|
35
|
+
const BpkHorizontalNav = ({
|
|
36
|
+
ariaLabel = null,
|
|
37
|
+
autoScrollToSelected = false,
|
|
38
|
+
children: rawChildren,
|
|
39
|
+
className = null,
|
|
40
|
+
leadingScrollIndicatorClassName = null,
|
|
41
|
+
showUnderline = true,
|
|
42
|
+
trailingScrollIndicatorClassName = null,
|
|
43
|
+
type = HORIZONTAL_NAV_TYPES.default,
|
|
44
|
+
...rest
|
|
45
|
+
}) => {
|
|
46
|
+
const scrollRef = useRef(null);
|
|
47
|
+
const selectedItemRef = useRef(null);
|
|
48
|
+
const isMounted = useRef(false);
|
|
49
|
+
const scrollSelectedIntoView = useCallback(useSmoothScroll => {
|
|
50
|
+
if (!autoScrollToSelected || !scrollRef.current || !selectedItemRef.current) {
|
|
54
51
|
return;
|
|
55
52
|
}
|
|
56
|
-
const selectedItemPos = getPos(
|
|
53
|
+
const selectedItemPos = getPos(selectedItemRef.current);
|
|
57
54
|
if (!selectedItemPos) {
|
|
58
55
|
return;
|
|
59
56
|
}
|
|
60
|
-
const scrollPos = getPos(
|
|
57
|
+
const scrollPos = getPos(scrollRef.current);
|
|
61
58
|
if (!scrollPos) {
|
|
62
59
|
return;
|
|
63
60
|
}
|
|
64
|
-
|
|
65
|
-
// We only need to carry out a scroll if the element is not already fully within the scroll view
|
|
66
61
|
const needsScroll = selectedItemPos.left < scrollPos.left || selectedItemPos.right > scrollPos.right;
|
|
67
62
|
if (!needsScroll) {
|
|
68
63
|
return;
|
|
69
64
|
}
|
|
70
65
|
const scrollAdjustment = selectedItemPos.left - scrollPos.left;
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
this.scrollRef.scroll({
|
|
66
|
+
if (scrollRef.current.scroll && typeof scrollRef.current.scroll === 'function' && useSmoothScroll) {
|
|
67
|
+
scrollRef.current.scroll({
|
|
74
68
|
left: scrollAdjustment,
|
|
75
69
|
behavior: 'smooth'
|
|
76
70
|
});
|
|
77
|
-
} else
|
|
78
|
-
|
|
71
|
+
} else {
|
|
72
|
+
scrollRef.current.scrollLeft = scrollAdjustment;
|
|
79
73
|
}
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
} = this.props;
|
|
93
|
-
const classNames = getClassName('bpk-horizontal-nav', showUnderline && `bpk-horizontal-nav--show-${type}-underline`, className);
|
|
94
|
-
let children = rawChildren;
|
|
95
|
-
if (autoScrollToSelected || type === HORIZONTAL_NAV_TYPES.light) {
|
|
96
|
-
children = Children.map(rawChildren, child => {
|
|
97
|
-
const childProps = {};
|
|
98
|
-
let childRef;
|
|
99
|
-
if (autoScrollToSelected) {
|
|
100
|
-
if (child && child.props && child.props.selected) {
|
|
101
|
-
childRef = ref => {
|
|
102
|
-
this.selectedItemRef = ref;
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
if (type === HORIZONTAL_NAV_TYPES.light) {
|
|
107
|
-
childProps.type = HORIZONTAL_NAV_TYPES.light;
|
|
108
|
-
}
|
|
109
|
-
return child ? /*#__PURE__*/_jsx("div", {
|
|
110
|
-
ref: childRef,
|
|
111
|
-
children: /*#__PURE__*/cloneElement(child, childProps)
|
|
112
|
-
}) : null;
|
|
113
|
-
});
|
|
74
|
+
}, [autoScrollToSelected]);
|
|
75
|
+
useEffect(() => {
|
|
76
|
+
requestAnimationFrame(() => {
|
|
77
|
+
scrollSelectedIntoView(false);
|
|
78
|
+
});
|
|
79
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
80
|
+
}, []);
|
|
81
|
+
useEffect(() => {
|
|
82
|
+
if (isMounted.current) {
|
|
83
|
+
scrollSelectedIntoView(true);
|
|
84
|
+
} else {
|
|
85
|
+
isMounted.current = true;
|
|
114
86
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
87
|
+
});
|
|
88
|
+
const classNames = getClassName('bpk-horizontal-nav', showUnderline && `bpk-horizontal-nav--show-${type}-underline`, className);
|
|
89
|
+
let children = rawChildren;
|
|
90
|
+
if (autoScrollToSelected || type === HORIZONTAL_NAV_TYPES.light) {
|
|
91
|
+
children = Children.map(rawChildren, child => {
|
|
92
|
+
const isElement = typeof child === 'object' && child !== null && 'props' in child;
|
|
93
|
+
const childProps = {};
|
|
94
|
+
let childRef;
|
|
95
|
+
if (autoScrollToSelected) {
|
|
96
|
+
if (isElement && child.props.selected) {
|
|
97
|
+
childRef = ref => {
|
|
98
|
+
selectedItemRef.current = ref;
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (type === HORIZONTAL_NAV_TYPES.light) {
|
|
103
|
+
childProps.type = HORIZONTAL_NAV_TYPES.light;
|
|
104
|
+
}
|
|
105
|
+
return isElement ? /*#__PURE__*/_jsx("div", {
|
|
106
|
+
ref: childRef,
|
|
107
|
+
children: /*#__PURE__*/cloneElement(child, childProps)
|
|
108
|
+
}) : null;
|
|
109
|
+
});
|
|
137
110
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
};
|
|
156
|
-
BpkHorizontalNav.defaultProps = {
|
|
157
|
-
ariaLabel: null,
|
|
158
|
-
autoScrollToSelected: false,
|
|
159
|
-
className: null,
|
|
160
|
-
leadingScrollIndicatorClassName: null,
|
|
161
|
-
showUnderline: true,
|
|
162
|
-
trailingScrollIndicatorClassName: null,
|
|
163
|
-
type: HORIZONTAL_NAV_TYPES.default
|
|
111
|
+
return /*#__PURE__*/_jsx("div", {
|
|
112
|
+
className: classNames,
|
|
113
|
+
children: /*#__PURE__*/_jsx(BpkMobileScrollContainer, {
|
|
114
|
+
ariaLabel: ariaLabel ?? undefined,
|
|
115
|
+
innerContainerTagName: "nav",
|
|
116
|
+
leadingIndicatorClassName: leadingScrollIndicatorClassName ?? undefined,
|
|
117
|
+
trailingIndicatorClassName: trailingScrollIndicatorClassName ?? undefined,
|
|
118
|
+
scrollerRef: ref => {
|
|
119
|
+
scrollRef.current = ref;
|
|
120
|
+
},
|
|
121
|
+
...rest,
|
|
122
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
123
|
+
className: getClassName('bpk-horizontal-nav__list'),
|
|
124
|
+
role: "tablist",
|
|
125
|
+
children: children
|
|
126
|
+
})
|
|
127
|
+
})
|
|
128
|
+
});
|
|
164
129
|
};
|
|
165
130
|
export default BpkHorizontalNav;
|
|
166
131
|
export { HORIZONTAL_NAV_TYPES };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { HORIZONTAL_NAV_TYPES } from './BpkHorizontalNav';
|
|
3
|
+
type Props = {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
className?: string | null;
|
|
6
|
+
/**
|
|
7
|
+
* **Note:**
|
|
8
|
+
* "disabled" and "selected" are mutually exclusive for true values, i.e. only one of them can be true for a given nav item.
|
|
9
|
+
*/
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
href?: string | null;
|
|
12
|
+
/**
|
|
13
|
+
* **Note:**
|
|
14
|
+
* "disabled" and "selected" are mutually exclusive for true values, i.e. only one of them can be true for a given nav item.
|
|
15
|
+
*/
|
|
16
|
+
selected?: boolean;
|
|
17
|
+
spaceAround?: boolean;
|
|
18
|
+
type?: keyof typeof HORIZONTAL_NAV_TYPES;
|
|
19
|
+
[rest: string]: any;
|
|
20
|
+
};
|
|
21
|
+
declare const BpkHorizontalNavItem: import("react").ForwardRefExoticComponent<Omit<Props, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
22
|
+
declare const themeAttributes: string[];
|
|
23
|
+
export type { Props };
|
|
24
|
+
export { themeAttributes };
|
|
25
|
+
export default BpkHorizontalNavItem;
|
|
@@ -14,84 +14,49 @@
|
|
|
14
14
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
15
|
* See the License for the specific language governing permissions and
|
|
16
16
|
* limitations under the License.
|
|
17
|
-
*/
|
|
18
|
-
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { forwardRef } from 'react';
|
|
19
20
|
import { cssModules } from "../../bpk-react-utils";
|
|
20
21
|
import { HORIZONTAL_NAV_TYPES } from "./BpkHorizontalNav";
|
|
21
22
|
import STYLES from "./BpkHorizontalNavItem.module.css";
|
|
22
23
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
23
24
|
const getClassName = cssModules(STYLES);
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
role: "tab",
|
|
60
|
-
"aria-selected": selected ? 'true' : 'false',
|
|
61
|
-
...rest,
|
|
62
|
-
children: children
|
|
63
|
-
});
|
|
64
|
-
return /*#__PURE__*/_jsx("div", {
|
|
65
|
-
className: classNames,
|
|
66
|
-
children: clickableElement
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
BpkHorizontalNavItem.propTypes = {
|
|
71
|
-
children: PropTypes.node.isRequired,
|
|
72
|
-
className: PropTypes.string,
|
|
73
|
-
/**
|
|
74
|
-
* **Note:**
|
|
75
|
-
* "disabled" and "selected" are mutually exclusive for true values, i.e. only one of them can be true for a given nav item.
|
|
76
|
-
*/
|
|
77
|
-
disabled: PropTypes.bool,
|
|
78
|
-
href: PropTypes.string,
|
|
79
|
-
/**
|
|
80
|
-
* **Note:**
|
|
81
|
-
* "disabled" and "selected" are mutually exclusive for true values, i.e. only one of them can be true for a given nav item.
|
|
82
|
-
*/
|
|
83
|
-
selected: PropTypes.bool,
|
|
84
|
-
spaceAround: PropTypes.bool,
|
|
85
|
-
type: PropTypes.oneOf(Object.keys(HORIZONTAL_NAV_TYPES))
|
|
86
|
-
};
|
|
87
|
-
BpkHorizontalNavItem.defaultProps = {
|
|
88
|
-
className: null,
|
|
89
|
-
disabled: false,
|
|
90
|
-
href: null,
|
|
91
|
-
selected: false,
|
|
92
|
-
spaceAround: false,
|
|
93
|
-
type: HORIZONTAL_NAV_TYPES.default
|
|
94
|
-
};
|
|
25
|
+
const BpkHorizontalNavItem = /*#__PURE__*/forwardRef(({
|
|
26
|
+
children,
|
|
27
|
+
className = null,
|
|
28
|
+
disabled = false,
|
|
29
|
+
href = null,
|
|
30
|
+
selected = false,
|
|
31
|
+
spaceAround = false,
|
|
32
|
+
type = HORIZONTAL_NAV_TYPES.default,
|
|
33
|
+
...rest
|
|
34
|
+
}, ref) => {
|
|
35
|
+
const classNames = getClassName('bpk-horizontal-nav__item', spaceAround && 'bpk-horizontal-nav__item--space-around');
|
|
36
|
+
const innerClassNames = getClassName('bpk-horizontal-nav__link', `bpk-horizontal-nav__link--${type}`, selected && `bpk-horizontal-nav__link--${type}-selected`, disabled && `bpk-horizontal-nav__link--${type}-disabled`, className);
|
|
37
|
+
const clickableElement = href ? /*#__PURE__*/_jsx("a", {
|
|
38
|
+
href: href,
|
|
39
|
+
className: innerClassNames,
|
|
40
|
+
"aria-disabled": disabled,
|
|
41
|
+
role: "tab",
|
|
42
|
+
"aria-selected": selected ? 'true' : 'false',
|
|
43
|
+
...rest,
|
|
44
|
+
children: children
|
|
45
|
+
}) : /*#__PURE__*/_jsx("button", {
|
|
46
|
+
type: "button",
|
|
47
|
+
className: innerClassNames,
|
|
48
|
+
disabled: disabled,
|
|
49
|
+
role: "tab",
|
|
50
|
+
"aria-selected": selected ? 'true' : 'false',
|
|
51
|
+
...rest,
|
|
52
|
+
children: children
|
|
53
|
+
});
|
|
54
|
+
return /*#__PURE__*/_jsx("div", {
|
|
55
|
+
ref: ref,
|
|
56
|
+
className: classNames,
|
|
57
|
+
children: clickableElement
|
|
58
|
+
});
|
|
59
|
+
});
|
|
95
60
|
const themeAttributes = ['horizontalNavLinkColor', 'horizontalNavLinkHoverColor', 'horizontalNavLinkActiveColor', 'horizontalNavLinkSelectedColor', 'horizontalNavBarSelectedColor'];
|
|
96
61
|
export { themeAttributes };
|
|
97
62
|
export default BpkHorizontalNavItem;
|
|
@@ -14,7 +14,9 @@
|
|
|
14
14
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
15
|
* See the License for the specific language governing permissions and
|
|
16
16
|
* limitations under the License.
|
|
17
|
-
*/
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import BpkRadio from "./src/BpkRadio";
|
|
18
20
|
import themeAttributes from "./src/themeAttributes";
|
|
19
21
|
export default BpkRadio;
|
|
20
22
|
export { themeAttributes };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { InputHTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
type NativeInputProps = InputHTMLAttributes<HTMLInputElement>;
|
|
3
|
+
export type Props = Omit<NativeInputProps, 'type' | 'className'> & {
|
|
4
|
+
name: string;
|
|
5
|
+
label: ReactNode;
|
|
6
|
+
ariaLabel?: string | null;
|
|
7
|
+
className?: string | null;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
white?: boolean;
|
|
10
|
+
valid?: boolean | null;
|
|
11
|
+
};
|
|
12
|
+
declare const BpkRadio: ({ ariaLabel, className, disabled, label, name, valid, white, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export default BpkRadio;
|