@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.
Files changed (55) hide show
  1. package/bpk-component-autosuggest/index.d.ts +6 -0
  2. package/bpk-component-autosuggest/index.js +3 -1
  3. package/bpk-component-autosuggest/src/BpkAutosuggest.d.ts +2 -0
  4. package/bpk-component-autosuggest/src/BpkAutosuggest.js +14 -15
  5. package/bpk-component-autosuggest/src/BpkAutosuggestSuggestion.d.ts +11 -0
  6. package/bpk-component-autosuggest/src/BpkAutosuggestSuggestion.js +35 -55
  7. package/bpk-component-checkbox/index.d.ts +1 -0
  8. package/bpk-component-checkbox/src/BpkCheckboxV2/BpkCheckboxV2.d.ts +2 -2
  9. package/bpk-component-checkbox/src/BpkCheckboxV2/BpkCheckboxV2.module.css +1 -1
  10. package/bpk-component-checkbox/src/BpkCheckboxV2/BpkCheckboxV2HiddenInput.d.ts +6 -1
  11. package/bpk-component-checkbox/src/BpkCheckboxV2/BpkCheckboxV2HiddenInput.js +13 -3
  12. package/bpk-component-checkbox/src/BpkCheckboxV2/BpkCheckboxV2Root.d.ts +2 -1
  13. package/bpk-component-checkbox/src/BpkCheckboxV2/BpkCheckboxV2Root.js +2 -0
  14. package/bpk-component-collapsible/index.d.ts +11 -0
  15. package/bpk-component-collapsible/index.js +22 -0
  16. package/bpk-component-collapsible/src/BpkCollapsible.d.ts +8 -0
  17. package/bpk-component-collapsible/src/BpkCollapsible.js +31 -0
  18. package/bpk-component-collapsible/src/BpkCollapsible.module.css +18 -0
  19. package/bpk-component-collapsible/src/BpkCollapsibleContent.d.ts +6 -0
  20. package/bpk-component-collapsible/src/BpkCollapsibleContent.js +36 -0
  21. package/bpk-component-collapsible/src/BpkCollapsibleIndicator.d.ts +6 -0
  22. package/bpk-component-collapsible/src/BpkCollapsibleIndicator.js +34 -0
  23. package/bpk-component-collapsible/src/BpkCollapsibleRoot.d.ts +22 -0
  24. package/bpk-component-collapsible/src/BpkCollapsibleRoot.js +49 -0
  25. package/bpk-component-collapsible/src/BpkCollapsibleRootProvider.d.ts +10 -0
  26. package/bpk-component-collapsible/src/BpkCollapsibleRootProvider.js +33 -0
  27. package/bpk-component-collapsible/src/BpkCollapsibleTrigger.d.ts +6 -0
  28. package/bpk-component-collapsible/src/BpkCollapsibleTrigger.js +43 -0
  29. package/bpk-component-collapsible/src/common-types.d.ts +9 -0
  30. package/bpk-component-collapsible/src/common-types.js +29 -0
  31. package/bpk-component-collapsible/src/useBpkCollapsible.d.ts +5 -0
  32. package/bpk-component-collapsible/src/useBpkCollapsible.js +21 -0
  33. package/bpk-component-fieldset/src/BpkFieldset.js +0 -1
  34. package/bpk-component-form-validation/index.d.ts +5 -0
  35. package/bpk-component-form-validation/src/BpkFormValidation.d.ts +12 -0
  36. package/bpk-component-form-validation/src/BpkFormValidation.js +0 -9
  37. package/bpk-component-form-validation/src/themeAttributes.d.ts +2 -0
  38. package/bpk-component-horizontal-nav/index.d.ts +6 -0
  39. package/bpk-component-horizontal-nav/index.js +3 -1
  40. package/bpk-component-horizontal-nav/src/BpkHorizontalNav.d.ts +27 -0
  41. package/bpk-component-horizontal-nav/src/BpkHorizontalNav.js +79 -114
  42. package/bpk-component-horizontal-nav/src/BpkHorizontalNavItem.d.ts +25 -0
  43. package/bpk-component-horizontal-nav/src/BpkHorizontalNavItem.js +38 -73
  44. package/bpk-component-radio/index.d.ts +5 -0
  45. package/bpk-component-radio/index.js +3 -1
  46. package/bpk-component-radio/src/BpkRadio.d.ts +13 -0
  47. package/bpk-component-radio/src/BpkRadio.js +3 -11
  48. package/bpk-component-radio/src/themeAttributes.d.ts +2 -0
  49. package/bpk-component-radio/src/themeAttributes.js +3 -1
  50. package/bpk-component-switch/index.d.ts +3 -3
  51. package/bpk-component-switch/index.js +2 -2
  52. package/bpk-component-switch/src/BpkSwitch.d.ts +7 -1
  53. package/bpk-component-switch/src/BpkSwitch.js +10 -1
  54. package/bpk-component-switch/src/BpkSwitch.module.css +1 -1
  55. 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,5 @@
1
+ import BpkFormValidation from './src/BpkFormValidation';
2
+ import themeAttributes from './src/themeAttributes';
3
+ export type { Props } from './src/BpkFormValidation';
4
+ export default BpkFormValidation;
5
+ export { themeAttributes };
@@ -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,2 @@
1
+ declare const _default: string[];
2
+ export default _default;
@@ -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
- */import BpkHorizontalNav, { HORIZONTAL_NAV_TYPES } from "./src/BpkHorizontalNav";
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
- */import PropTypes from 'prop-types';
18
- import { Component, Children, cloneElement } from 'react';
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
- const pos = ref.getBoundingClientRect();
33
- return pos;
33
+ return ref.getBoundingClientRect();
34
34
  };
35
- class BpkHorizontalNav extends Component {
36
- constructor(props) {
37
- super(props);
38
- this.scrollRef = null;
39
- this.selectedItemRef = null;
40
- }
41
- componentDidMount() {
42
- requestAnimationFrame(() => {
43
- this.scrollSelectedIntoView(false);
44
- });
45
- }
46
- componentDidUpdate() {
47
- this.scrollSelectedIntoView(true);
48
- }
49
- scrollSelectedIntoView = useSmoothScroll => {
50
- if (!this.props.autoScrollToSelected || !this.scrollRef || !this.selectedItemRef) {
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(this.selectedItemRef);
53
+ const selectedItemPos = getPos(selectedItemRef.current);
57
54
  if (!selectedItemPos) {
58
55
  return;
59
56
  }
60
- const scrollPos = getPos(this.scrollRef);
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
- // Some browsers don't support smooth scrolling, so in those cases we must fall back to simply setting `scrollLeft`
72
- if (this.scrollRef && this.scrollRef.scroll && typeof this.scrollRef.scroll === 'function' && useSmoothScroll) {
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 if (this.scrollRef) {
78
- this.scrollRef.scrollLeft = scrollAdjustment;
71
+ } else {
72
+ scrollRef.current.scrollLeft = scrollAdjustment;
79
73
  }
80
- };
81
- render() {
82
- const {
83
- ariaLabel,
84
- autoScrollToSelected,
85
- children: rawChildren,
86
- className,
87
- leadingScrollIndicatorClassName,
88
- showUnderline,
89
- trailingScrollIndicatorClassName,
90
- type,
91
- ...rest
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
- return (
116
- /*#__PURE__*/
117
- // $FlowFixMe[cannot-spread-inexact] - inexact rest. See 'decisions/flowfixme.md'.
118
- _jsx("div", {
119
- className: classNames,
120
- children: /*#__PURE__*/_jsx(BpkMobileScrollContainer, {
121
- ariaLabel: ariaLabel,
122
- innerContainerTagName: "nav",
123
- leadingIndicatorClassName: leadingScrollIndicatorClassName,
124
- trailingIndicatorClassName: trailingScrollIndicatorClassName,
125
- scrollerRef: ref => {
126
- this.scrollRef = ref;
127
- },
128
- ...rest,
129
- children: /*#__PURE__*/_jsx("div", {
130
- className: getClassName('bpk-horizontal-nav__list'),
131
- role: "tablist",
132
- children: children
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
- BpkHorizontalNav.propTypes = {
140
- ariaLabel: PropTypes.string,
141
- children: PropTypes.node.isRequired,
142
- /**
143
- * Ensures that the selected item is within view when loaded on narrow-screened devices.
144
- */
145
- autoScrollToSelected: PropTypes.bool,
146
- className: PropTypes.string,
147
- leadingScrollIndicatorClassName: PropTypes.string,
148
- /**
149
- * When set to "false", the bottom border on the component isn't included. This refers
150
- * to the underline on the whole "BpkHorizontalNav", not the line that appears under the selected item.
151
- */
152
- showUnderline: PropTypes.bool,
153
- trailingScrollIndicatorClassName: PropTypes.string,
154
- type: PropTypes.oneOf(Object.keys(HORIZONTAL_NAV_TYPES))
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
- */import PropTypes from 'prop-types';
18
- import { Component } from 'react';
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
- // In order to be able to access refs on the HorizontalNavItems, they need to be a fully defined
25
- // React Component class.
26
- // eslint-disable-next-line react/prefer-stateless-function
27
- class BpkHorizontalNavItem extends Component {
28
- render() {
29
- const {
30
- children,
31
- className,
32
- disabled,
33
- href,
34
- selected,
35
- spaceAround,
36
- type,
37
- ...rest
38
- } = this.props;
39
- const classNames = getClassName('bpk-horizontal-nav__item', spaceAround && 'bpk-horizontal-nav__item--space-around');
40
- 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);
41
- const clickableElement = href ?
42
- /*#__PURE__*/
43
- // $FlowFixMe[cannot-spread-inexact] - inexact rest. See 'decisions/flowfixme.md'.
44
- _jsx("a", {
45
- href: href,
46
- className: innerClassNames,
47
- "aria-disabled": disabled,
48
- role: "tab",
49
- "aria-selected": selected ? 'true' : 'false',
50
- ...rest,
51
- children: children
52
- }) :
53
- /*#__PURE__*/
54
- // $FlowFixMe[cannot-spread-inexact] - inexact rest. See 'decisions/flowfixme.md'.
55
- _jsx("button", {
56
- type: "button",
57
- className: innerClassNames,
58
- disabled: disabled,
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;
@@ -0,0 +1,5 @@
1
+ import BpkRadio, { type Props as BpkRadioProps } from './src/BpkRadio';
2
+ import themeAttributes from './src/themeAttributes';
3
+ export default BpkRadio;
4
+ export type { BpkRadioProps };
5
+ export { themeAttributes };
@@ -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
- */import BpkRadio from "./src/BpkRadio";
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;