@skyscanner/backpack-web 35.1.0 → 35.3.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.
@@ -17,5 +17,5 @@ type Props = {
17
17
  size?: SizeType;
18
18
  style?: StyleType;
19
19
  };
20
- declare const BpkSaveButton: ({ accessibilityLabel, checked, onCheckedChange, size, style, }: Props) => import("react/jsx-runtime").JSX.Element;
20
+ declare const BpkSaveButton: ({ accessibilityLabel, checked, onCheckedChange, size, style, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
21
21
  export default BpkSaveButton;
@@ -44,7 +44,8 @@ const BpkSaveButton = ({
44
44
  checked,
45
45
  onCheckedChange,
46
46
  size = SIZE_TYPES.default,
47
- style = STYLE_TYPES.default
47
+ style = STYLE_TYPES.default,
48
+ ...rest
48
49
  }) => {
49
50
  const [shouldPlayAnim, setPlayAnim] = useState(false);
50
51
  const smallSize = size === SIZE_TYPES.small;
@@ -61,6 +62,7 @@ const BpkSaveButton = ({
61
62
  setPlayAnim(true);
62
63
  }
63
64
  },
65
+ ...rest,
64
66
  children: [/*#__PURE__*/_jsx("div", {
65
67
  className: getClassName(`bpk-save-button__heartIcon`, checked && shouldPlayAnim && `bpk-save-button__heartIcon--clicked`, `bpk-save-button__heartIcon--${style}`),
66
68
  "data-show": checked,
@@ -1,5 +1,5 @@
1
1
  import { Component } from 'react';
2
- import type { ReactElement } from 'react';
2
+ import type { ReactElement, RefObject } from 'react';
3
3
  import type { DaysOfWeek, ReactComponent, SelectionConfiguration } from '../../bpk-component-calendar';
4
4
  type Props = {
5
5
  changeMonthLabel: string;
@@ -49,7 +49,9 @@ type State = {
49
49
  isOpen: boolean;
50
50
  };
51
51
  declare class BpkDatepicker extends Component<Props, State> {
52
- inputRef: React.RefObject<HTMLInputElement>;
52
+ inputRef: (ref: HTMLInputElement) => void;
53
+ elementRef?: HTMLInputElement;
54
+ focusRef?: RefObject<HTMLInputElement>;
53
55
  static defaultProps: {
54
56
  calendarComponent: {
55
57
  new (props: Omit<import("../../bpk-component-calendar/src/composeCalendar").Props & import("../../bpk-component-calendar/src/BpkCalendarContainer").Props, keyof {
@@ -22,6 +22,7 @@ import { composeCalendar, BpkCalendarGridHeader, BpkCalendarGrid, BpkCalendarDat
22
22
  import BpkInput, { withOpenEvents } from "../../bpk-component-input";
23
23
  import BpkModal from "../../bpk-component-modal";
24
24
  import BpkPopover from "../../bpk-component-popover";
25
+ import { setNativeValue } from "../../bpk-react-utils";
25
26
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
26
27
  const Input = withOpenEvents(BpkInput);
27
28
  const DefaultCalendar = withCalendarState(composeCalendar(BpkCalendarNav, BpkCalendarGridHeader, BpkCalendarGrid, BpkCalendarDate));
@@ -55,7 +56,10 @@ class BpkDatepicker extends Component {
55
56
  this.state = {
56
57
  isOpen: props.isOpen
57
58
  };
58
- this.inputRef = /*#__PURE__*/createRef();
59
+ this.focusRef = /*#__PURE__*/createRef();
60
+ this.inputRef = ref => {
61
+ this.elementRef = ref;
62
+ };
59
63
  }
60
64
  componentDidUpdate(prevProps, prevState) {
61
65
  const {
@@ -147,7 +151,9 @@ class BpkDatepicker extends Component {
147
151
  const newEndDate = DateUtils.dateToBoundaries(endDate, DateUtils.startOfDay(minDate), DateUtils.startOfDay(maxDate));
148
152
  if (selectionConfiguration && selectionConfiguration.type === CALENDAR_SELECTION_TYPE.range && selectionConfiguration.startDate && !selectionConfiguration.endDate && (DateUtils.isAfter(newEndDate, selectionConfiguration.startDate) || DateUtils.isSameDay(newEndDate, selectionConfiguration.startDate))) {
149
153
  onDateSelect(selectionConfiguration.startDate, newEndDate);
154
+ this.elementRef && setNativeValue(this.elementRef, this.props.formatDate(newEndDate));
150
155
  } else {
156
+ this.elementRef && setNativeValue(this.elementRef, this.props.formatDate(newStartDate));
151
157
  onDateSelect(newStartDate);
152
158
  }
153
159
  }
@@ -188,8 +194,9 @@ class BpkDatepicker extends Component {
188
194
  delete rest.onOpenChange;
189
195
  delete rest.isOpen;
190
196
  const input = inputComponent || /*#__PURE__*/_jsx("div", {
191
- ref: this.inputRef,
197
+ ref: this.focusRef,
192
198
  children: /*#__PURE__*/_jsx(Input, {
199
+ inputRef: this.inputRef,
193
200
  id: id,
194
201
  name: `${id}_input`,
195
202
  value: this.getValue(selectionConfiguration, formatDate),
@@ -1,20 +1,23 @@
1
- import type { FunctionComponent } from 'react';
1
+ import type { MouseEvent, FunctionComponent } from 'react';
2
2
  export declare const NAVIGATION_TAB_GROUP_TYPES: {
3
3
  CanvasDefault: string;
4
4
  SurfaceContrast: string;
5
5
  };
6
6
  export type NavigationTabGroupTypes = (typeof NAVIGATION_TAB_GROUP_TYPES)[keyof typeof NAVIGATION_TAB_GROUP_TYPES];
7
7
  type TabItem = {
8
+ id: string;
8
9
  text: string;
9
10
  icon?: FunctionComponent<any> | null;
10
11
  href?: string;
12
+ [rest: string]: any;
11
13
  };
12
14
  export type Props = {
15
+ id: string;
13
16
  tabs: TabItem[];
14
17
  type?: NavigationTabGroupTypes;
15
- onItemClick: (tab: TabItem, index: number) => void;
18
+ onItemClick: (e: MouseEvent<HTMLButtonElement | HTMLAnchorElement>, tab: TabItem, index: number) => void;
16
19
  selectedIndex: number;
17
20
  ariaLabel: string;
18
21
  };
19
- declare const BpkNavigationTabGroup: ({ ariaLabel, onItemClick, selectedIndex, tabs, type, }: Props) => import("react/jsx-runtime").JSX.Element;
22
+ declare const BpkNavigationTabGroup: ({ ariaLabel, id, onItemClick, selectedIndex, tabs, type, }: Props) => import("react/jsx-runtime").JSX.Element;
20
23
  export default BpkNavigationTabGroup;
@@ -35,36 +35,42 @@ const TabWrap = ({
35
35
  }) => {
36
36
  const tabStyling = getClassName('bpk-navigation-tab-wrap', `bpk-navigation-tab-wrap--${type}`, selected && `bpk-navigation-tab-wrap--${type}-selected`);
37
37
  return tab.href ? /*#__PURE__*/_jsx("a", {
38
+ ...tab,
39
+ id: tab.id,
38
40
  className: tabStyling,
39
41
  href: tab.href,
40
- onClick: onClick,
42
+ onClick: e => onClick(e),
41
43
  "aria-current": selected ? 'page' : false,
42
44
  children: children
43
45
  }) : /*#__PURE__*/_jsx("button", {
46
+ ...tab,
47
+ id: tab.id,
44
48
  className: tabStyling,
45
49
  type: "button",
46
- onClick: onClick,
47
- "aria-current": selected ? 'page' : false,
50
+ onClick: e => onClick(e),
48
51
  role: "link",
52
+ "aria-current": selected ? 'page' : false,
49
53
  children: children
50
54
  });
51
55
  };
52
56
  const BpkNavigationTabGroup = ({
53
57
  ariaLabel,
58
+ id,
54
59
  onItemClick,
55
60
  selectedIndex,
56
61
  tabs,
57
62
  type = NAVIGATION_TAB_GROUP_TYPES.SurfaceContrast
58
63
  }) => {
59
64
  const [selectedTab, setSelectedTab] = useState(selectedIndex);
60
- const handleButtonClick = (tab, index) => {
65
+ const handleButtonClick = (e, tab, index) => {
61
66
  if (index !== selectedTab) {
62
67
  setSelectedTab(index);
63
68
  }
64
- onItemClick(tab, index);
69
+ onItemClick(e, tab, index);
65
70
  };
66
71
  const containerStyling = getClassName('bpk-navigation-tab-group');
67
72
  return /*#__PURE__*/_jsx("nav", {
73
+ id: id,
68
74
  className: containerStyling,
69
75
  role: "navigation",
70
76
  "aria-label": ariaLabel,
@@ -74,7 +80,7 @@ const BpkNavigationTabGroup = ({
74
80
  return /*#__PURE__*/_jsx(TabWrap, {
75
81
  tab: tab,
76
82
  selected: selected,
77
- onClick: () => handleButtonClick(tab, index),
83
+ onClick: e => handleButtonClick(e, tab, index),
78
84
  type: type,
79
85
  children: /*#__PURE__*/_jsxs(_Fragment, {
80
86
  children: [Icon && /*#__PURE__*/_jsx("span", {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skyscanner/backpack-web",
3
- "version": "35.1.0",
3
+ "version": "35.3.0",
4
4
  "description": "Backpack Design System web library",
5
5
  "repository": {
6
6
  "type": "git",